HPlogo System Debug Reference Manual > Chapter 6 System Debug Command Specifications M-X

TR[ACE]

MPE documents

Complete PDF
Table of Contents
Index

E0201 Edition 4 ♥
E0300 Edition 3
E0692 Edition 3

Displays a stack trace.

Syntax



   TR[ACE] [level] [options]

The TR command produces a trace of the procedures active on the current PIN's stack. The command is mode sensitive. If the user is in cmdebug, a trace of the compatibility mode stack is produced, if in nmdebug, a trace of the native mode stack is printed. An interleaved stack trace of both CM and NM stacks is produced by using the DUAL option.

If the current stack is the NM interrupt control stack (ICS), when the base of the ICS is reached, System Debug automatically switches to the stack of the last running process and continues the stack trace. This feature in no way implies that the routines on the ICS were invoked on behalf of the last running process. If the dispatcher is currently running, there is no last running process, so the stack trace stops when the base of the ICS is found.

Parameters


level

The desired maximum depth for the stack trace. If level is omitted, the entire depth of the stack is traced.

options

Any combination of the following options may be specified:

DUAL

Display both NM and CM stack markers, interleaved across switch markers.

SINGLE

Display a single stack marker at the specified level.

UNWIND

Display formatted stack unwind descriptor information.

FULL

Display a fully detailed stack trace.

ISM

Trace across interrupt markers.

NM Examples



   $nmdebug > tr
        PC=115.00005b50 processstudent.highscore
   * 0) SP=40221180 RP=115.00005f0c processstudent+$1e8
     1) SP=40221180 RP=115.00006b1c PROGRAM+$300
     2) SP=40221100 RP=115.00000000
        (end of NM stack)

Display an entire NM stack trace. The first line indicates the address the PC register points to. Each stack level is formatted, starting from the top of stack and working down the depth of the stack. Level numbers are indicated on the left; an asterisk marks the current level. (Refer to the LEV command.)

   $nmdebug > tr
        PC=a.0074da24 FWRITE
   * 0) SP=40221260 RP=a.00748150 ?FWRITE+$8
          export stub: f4.0012d044 P_FLUSHLINE+$54
     1) SP=40221260 RP=f4.00139560 P_WRITELN+$20
     2) SP=40221200 RP=f4.00139630 P_WRITELN+$9c
     3) SP=402211c8 RP=f4.0013950c ?P_WRITELN+$8
          export stub: 115.00005e30 processstudent+$10c
     4) SP=40221180 RP=115.00006b1c PROGRAM+$300
     5) SP=40221100 RP=115.00000000
        (end of NM stack)

The above example shows a stack trace that contains a call from the program file to a user library, and from the user library to the system NL. Transitions between libraries are performed through the use of export stubs. (Refer to the Procedure Calling Conventions Reference Manual (09740-90015) for a description of export stubs.)

 $nmdebug > tr,unw
      PC=115.00005b50 processstudent.highscore
 * 0) SP=40221180 RP=115.00005f0c processstudent+$1e8

    Can't Unwind: 0  Entry-FR: 00  Call_FR: 00       Region: Normal
       Millicode: 0  Entry-GR: 00  Call_GR: 00   Frame-size: 6 (dbl words)
  Large-Frame-R3: 0  Save-SRs: 00  Save-SP:  0     Save-MRP: 0
        Save-SR0: 0   Cleanup:  0  Save-RP:  0  Args-stored: 1
  Interrupt-Mrkr: 0

   1) SP=40221180 RP=115.00006b1c PROGRAM+$300

    Can't Unwind: 0  Entry-FR: 00  Call_FR: 00       Region: Normal
       Millicode: 0  Entry-GR: 03  Call_GR: 00   Frame-size: 10 (dbl words)
  Large-Frame-R3: 0  Save-SRs: 00  Save-SP:  1     Save-MRP: 0
        Save-SR0: 0   Cleanup:  0  Save-RP:  1  Args-stored: 1
  Interrupt-Mrkr: 0

   2) SP=40221100 RP=115.00000000

    Can't Unwind: 0  Entry-FR: 00  Call_FR: 00       Region: Normal
       Millicode: 0  Entry-GR: 00  Call_GR: 00   Frame-size: c (dbl words)
  Large-Frame-R3: 0  Save-SRs: 00  Save-SP:  1     Save-MRP: 0
        Save-SR0: 0   Cleanup:  0  Save-RP:  1  Args-stored: 0
  Interrupt-Mrkr: 0

      (end of NM stack)

Native mode stack trace relies on the presence of unwind descriptors as produced by the language compilers. Without these information blocks, a stack trace would not be possible. The UNWIND option is used to display the unwind descriptor associated with each procedure. (Refer to the Procedure Calling Conventions Reference Manual (09740-90015) for a description of unwind descriptors.)

 $nmdebug > tr,f
      PC=a.0074da24 NL.PUB.SYS/FWRITE
 * 0) SP=40221260 RP=a.00748150 ?FWRITE+$8
      DP=c0200008 PSP=40221260 PCPRIV=0
        export stub:
  f4.0012d044 XL.PUB.SYS/P_FLUSHLINE+$54
   1) SP=40221260 RP=f4.00139560 P_WRITELN+$20
      DP=40200648 PSP=40221200 PCPRIV=3
   2) SP=40221200 RP=f4.00139630 P_WRITELN+$9c
      DP=40200648 PSP=402211c8 PCPRIV=3
   3) SP=402211c8 RP=f4.0013950c ?P_WRITELN+$8
      DP=40200648 PSP=40221180 PCPRIV=3
        export stub: 115.00005e30 GRADES.DEMO.TELESUP/processstudent+$10c
   4) SP=40221180 RP=115.00006b1c PROGRAM+$300
      DP=40200008 PSP=40221100 PCPRIV=3
   5) SP=40221100 RP=115.00000000
      DP=40200008 PS
 P=402210a0 PCPRIV=3
      (end of NM stack)

A FULL stack trace displays the value of DP, PSP and the privilege level (0-3 for each level in the stack).

   $nmdebug > tr 2,single
     2) SP=40221200 RP=f4.00139630 P_WRITELN+$9c

Display only stack level 2.

   $nmdebug > tr
        PC=a.006777fc trap_handler
   * 0) SP=40221338 RP=a.002a1fec conditional+$ac
     1) SP=40221338 RP=a.000a5040 hpe_interrupt_marker_stub
    --- Interrupt Marker


   $nmdebug > tr,ism
        PC=a.006777fc trap_handler
   * 0) SP=40221338 RP=a.002a1fec conditional+$ac
     1) SP=40221338 RP=a.000a5040 hpe_interrupt_marker_stub
    --- Interrupt Marker
     2) SP=402211e8 RP=25d.00015134 small_divisor+$8
    --- End Interrupt Marker Frame ---

        PC=25d.00015134 small_divisor+$8
     0) SP=402211e8 RP=25d.00015d38 average+$b0
     1) SP=402211e8 RP=25d.00015c74 ?average+$8
          export stub: 25c.00005d98 processstudent+$74
     2) SP=40221180 RP=25c.00006b1c PROGRAM+$300
     3) SP=40221100 RP=25c.00000000
        (end of NM stack)
    $nmdebug >

In the above example, the first stack trace encounters an interrupt marker and stops tracing. The second stack trace uses the ISM option to continue tracing past the interrupt marker. The interrupt that caused the interrupt marker to be generated was caused by a divide by zero in the small_divisor routine.

CM Examples



   %cmdebug > tr
         PROG %   0.1421   PROCESSSTUDENT+14     (mITroc CCG)  SEG'
   *  0) PROG %   0.2004   PROCESSSTUDENT+377    (mITroc CCG)  SEG'
      1) PROG %   0.253    OB'+253               (mITroc CCG)  SEG'
      2) SYS  %   25.0     ?TERMINATE            (MItroc CCG)  CMSWITCH

Display a CM stack trace. The first line indicates the address CMPC points to. Each stack marker is formatted, starting from the top of stack and working down the depth of the stack. Level numbers are indicated on the left; an asterisk marks the current level. (Refer to the LEV command.)

   %cmdebug > tr,f
         PROG %   0.1421   PROCESSSTUDENT+14      (CSTX 1)  SEG'
         X=22750   P=1421    Status=(mITroc CCG 301)  DeltaQ=13670
   *  0) PROG %   0.2004   PROCESSSTUDENT+377     (CSTX 1)  SEG'
         X=6       P=2004    Status=(mITroc CCG 301)  DeltaQ=14
      1) PROG %   0.253    OB'+253                (CSTX 1)  SEG'
         X=36      P=253     Status=(mITroc CCG 301)  DeltaQ=10
      2) SYS  %  25.0      ?TERMINATE             (CST 26)  CMSWITCH
         X=0       P=0       Status=(MItroc CCG 026)  DeltaQ=4

The above examples specifies the FULL option to display the value of the X, P, and status registers, and the DELTA-Q value.

Translated Code Examples



   Break at: NM    [1] TRANS 24.00854ea4 PASCAL'LIBRARY2:?P'WRITESTR
   $nmdebug > tr ,dual
          PC=24.00854ea4 PASCAL'LIBRARY2:?P'WRITESTR
   NM* 0) SP=40221290 RP=a.0067320c outer_block+$e8
   NM  1) SP=402210a0 RP=a.00000000 inx_A0000+$14
        (end of NM stack)

The above example shows Debug stopping at a breakpoint. The breakpoint was set in SL.PUB.SYS at the entry point to the P'WRITESTR routine. Since the system SL is translated, Debug set two breakpoints (one in the CM emulated code and one in the translated NM code). The NM translated code breakpoint is encountered, and so Debug stops.

A stack trace reveals that the process is indeed stopped at the entry point to P'WRITESTR, but no other recognizable markers appear. This is because translated code does not actually switch to CM mode, so no switch markers exist to enable the DUAL option to function. However, the CM stack is maintained as if the code were being run by the emulator. Switching to cmdebug and performing a stack trace reveals this.

 $nmdebug > cm
 %cmdebug > tr
       SYS  %  36.15626  ?P'WRITESTR          (mITroc CCG)  PASCAL'LIBRARY2
 *  0) PROG %   0.1737   PROCESSSTUDENT+%332  (mITroc CCG)  SEG'
    1) PROG %   0.253    OB'+%253             (mITroc CCG)  SEG'
    2) SYS  %  25.0      ?TERMINATE           (MItroc CCG)  CMSWITCH

The above trace shows all of the CM procedures that are active on the stack. Remember, the CM stack is maintained even if the code is running translated.

Dual Mode Examples



 $nmdat > tr,d
        PC=a.000a4838 enable_int+$20
 NM* 0) SP=40201ce0 RP=a.0013cdf0 notify_dispatcher.block_current_process+$294
 NM  1) SP=40201ce0 RP=a.0013deec notify_dispatcher+$34c
 NM  2) SP=40201c88 RP=a.001dc964 wait_for_active_port+$ec
 NM  3) SP=40201c10 RP=a.001dd680 receive_from_port+$450
 NM  4) SP=40201bc0 RP=a.00228514 extend_receive+$4d8
 NM  5) SP=40201b28 RP=a.00218bdc rendezvousio.get_specific+$194
 NM  6) SP=40201a78 RP=a.00218ec8 rendezvousio+$13c
 NM  7) SP=40201a08 RP=a.0020f274 attachio.perform_io+$f8
 NM  8) SP=402018c8 RP=a.00210414 attachio.terminal_functions+$fac
 NM  9) SP=40201838 RP=a.00214d40 attachio+$2e4
 NM  a) SP=402017e0 RP=a.0020e3bc ?attachio+$8
          export stub: a.003e30e4 arg_regs+$28
 NM  b) SP=402015c8 RP=a.0044db34 nm_switch_code+$f30
 NM  c) SP=40201498 RP=a.000a09b0 cm_swtnm_call+$8
        (switch marker frame)
    CM       SYS  %  27.253    SWITCH'TO'NM'+%4     (Mitroc CCG)  SUSER1
    CM *  0) SYS  %  27.253    SWITCH'TO'NM'+%4     (Mitroc CCG)  SUSER1
    CM    1) SYS  %  25.7765   ATTACHIO+%325        (Mitroc CCG)  CMSWITCH
    CM    2) SYS  %  22.17700  DEALLOCATE+%30       (Mitroc CCG)  XLSEG11
    CM    3) SYS  %   3.5540   F'CLOSE'+%4321       (MitroC CCG)  FSSEG3
    CM    4) switch marker                          (Mitroc CCG)
 NM  d) SP=40201208 RP=a.000a07bc ?CM_SWITCH+$30
          export stub: a.0044c3e4 switch_to_cm+$c30
 NM  e) SP=40201018 RP=a.006f3c84 fclose_nm+$74c
 NM  f) SP=40200db0 RP=a.006e62a8 FCLOSE+$368
 NM 10) SP=40200aa8 RP=a.0036a0b0 fs_proc_term+$a4
 NM 11) SP=40200a00 RP=a.00197550 terminate_process+$318
 NM 12) SP=40200948 RP=a.00326fb0 TERMINATE+$28
 NM 13) SP=40200668 RP=a.00326a2c ?TERMINATE+$8
          export stub: a.003e30e4 arg_regs+$28
 NM 14) SP=40200638 RP=a.0044db34 nm_switch_code+$f30
 NM 15) SP=40200508 RP=a.000a09b0 cm_swtnm_call+$8
        (switch marker frame)
    CM    5) SYS  %  27.253    SWITCH'TO'NM'+%4     (MITroc CCG)  SUSER1
    CM    6) SYS  %  25.5      TERMINATE+%5         (MITroc CCG)  CMSWITCH
    CM    7) PROG %   0.244                         (mITroc CCE)
    CM   10) SYS  %  25.0      ?TERMINATE           (MItroc CCG)  CMSWITCH
 NM 16) SP=40200278 RP=a.0030d868 outer_block+$144
 NM 17) SP=40200088 RP=a.00000000
      (end of NM stack)
 $nmdat >

The above example shows an interleaved NM and CM stack trace.

Limitations, Restrictions


The DUAL option is ignored if the current mode is not the same as the original entry mode. (Refer to the ENV ENTRY_MODE command.)

When CM code has been translated, it is not possible to obtain dual mode stack traces. The NM and CM stacks may be traced individually, however.

People debugging the operating system need to be aware of the following limitation. If an interrupt handler is running that has interrupted code running in CM mode, dual stack trace is incorrect. In addition, not all of the CM stack may be shown.

Native mode stack trace depends on the presence and accuracy of unwind descriptors in the program file and libraries to trace stacks. If these descriptors are not present, corrupted, or not correctly sorted, System Debug may produce incorrect stack traces.

DAT is only able to trace the part of the NM stack that corresponds to code in NL.PUB.SYS. If by chance the unwind descriptors of the code that called the NL routines are resident, the stacked procedure calls are displayed all the way to the base of the stack. The names of the procedures in other libraries and program files are not known to DAT.




TERM


TRAP