home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 16 Announce / 16-Announce.zip / PTRACE.ZIP / PTRACE.DOC
Text File  |  1988-12-14  |  42KB  |  1,013 lines

  1.  
  2.          -------------------------------------------------
  3.          What follows is a fairly complete, but informal
  4.          explanation of the OS/2 DosPtrace function.  This
  5.          is to be used as a guide to DosPtrace, but is not
  6.          to be regarded as 'official' documentation.
  7.          -------------------------------------------------
  8.  
  9.        The code that most applications programmers write for OS/2  consists of
  10.  
  11.        -   Batch Files (foo.BAT and foo.CMD)
  12.        -   Programs (Processes and Threads)
  13.        -   Libraries (DLLs)
  14.        -   Ring 0 Device Drivers
  15.  
  16.        Ptrace is  not intended  for use with Batch Files or any object at ring
  17.        0, nor is it intended for assisting real-mode development.
  18.  
  19.        PTrace provides connections on  a per-process basis.  These connections
  20.        are  independent  of  screen  groups,  so  that  even   a  detached  or
  21.        synchronous process may be debugged.  A debugger may not  debug itself,
  22.        nor any process  that is debugging it, but a debugger  may debug a copy
  23.        of itself.
  24.  
  25.        A  debugger  may debug  more than  one process  simultaneously, but any
  26.        debuggee must have  at most one  debugger.  In  general,  this  set  of
  27.        debugging connections forms a collection of trees.
  28.  
  29.        Threads within processes are the main  objects that PTrace  works with.
  30.        DLLs do not  have  threads  associated  with  them  directly,  but  are
  31.        accessed and manipulated by threads  of processes.  So, PTrace supports
  32.        debugging of  DLLs  by permitting the debugger to observe the memory of
  33.        the DLL, and the registers of a thread while using the DLL.
  34.  
  35.        PTrace also assists  the debugger  in  debugging  DLLs  by  telling the
  36.        debugger when a library is loaded.  It also uses PTrace to get the name
  37.        of  a  library,  or to  convert a  logical  segment number and MTE to a
  38.        selector.  By storing  these items, debuggers can transform an  address
  39.        or value to a symbolic reference.
  40.  
  41.    *   Debugging Intrusion and Limitations
  42.  
  43.        A  debugger  should be accurate,  showing as closely  as  possible  the
  44.        operations that a thread or process executes.
  45.  
  46.        However,  there  are always limitations  that complicate the situation.
  47.        For instance, if a debugger is  in use,  the  timing of scheduling  and
  48.        semaphores is affected.
  49.  
  50.        Note that intrusion may become a very serious matter.  The most serious
  51.        known problem comes when a debuggee requests and sets a semaphore, then
  52.        hits a breakpoint.  If  the  debugger  requests  this  same  semaphore,
  53.        without letting the debuggee clear it, a deadlock will occur.
  54.  
  55.        This  can  happen   with  any  semaphore,  including   semaphores   not
  56.        implemented by the  OS/2  base.  This  becomes  most  serious  when  it
  57.        happens to a semaphore vital to the operation of the system, such as the
  58.        VIO semaphore.
  59.  
  60.    *   Ptrace Errors
  61.  
  62.        If (AX) is nonzero, the Ptrace buffer  is invalid.  This  was caused by
  63.        an error that prevented the Ptrace command from being  executed at all,
  64.        such as a GP fault while reading the buffer.
  65.  
  66.        If Ptrace returns (AX)  =  ERROR_INTERRUPT  after  a command,  the next
  67.        notification may have been lost.  If the debuggee was executing code at
  68.        that time, (via a Go or SStep command) it will be automatically stopped.
  69.        To prevent this, it is recommended that DosPtrace not be used by thread
  70.        1 when signals are being used.
  71.  
  72.    *   Ptrace Buffer Format
  73.  
  74.        The Ptrace buffer (as defined in the manuals) contains :
  75.  
  76.        -   Pid - Debuggee's Process ID
  77.  
  78.        -   Tid - Debuggee Thread ID
  79.  
  80.        -   Cmd - PTrace Command or Notification number.
  81.  
  82.        -   Value - Generic data.
  83.  
  84.        -   Seg,Off - Generic far pointer.
  85.  
  86.        -   Mte  - Debuggee's program module MTE handle.  (Usually)
  87.  
  88.        -   Application Register Set
  89.  
  90.    *   Command Numbers
  91.  
  92.        0       TRC_C_Null              ; Null
  93.        1       TRC_C_ReadMem           ; Read Word
  94.        1       TRC_C_ReadMem_I         ; Read Word (instruction)
  95.        2       TRC_C_ReadMem_D         ; Read Word (data)
  96.        3       TRC_C_ReadReg           ; Read Registers
  97.        4       TRC_C_WriteMem          ; Write Word
  98.        4       TRC_C_WriteMem_I        ; Write Word (instruction)
  99.        5       TRC_C_WriteMem_D        ; Write Word (data)
  100.        6       TRC_C_WriteReg          ; Write Registers
  101.        7       TRC_C_Go                ; Go
  102.        8       TRC_C_Term              ; Terminate
  103.        9       TRC_C_SStep             ; Single Step
  104.        10      TRC_C_Stop              ; Stop
  105.        11      TRC_C_Freeze            ; Freeze Thread
  106.        12      TRC_C_Resume            ; Resume Thread
  107.        13      TRC_C_NumtoSel          ; Segment Number to Selector
  108.        14      TRC_C_GetFPRegs         ; Get 80287 Registers
  109.        15      TRC_C_SetFPRegs         ; Set 80287 Registers
  110.        16      TRC_C_GetLibName        ; Get Library Name
  111.        17      TRC_C_ThrdStat          ; Thread Status
  112.        18      TRC_C_MapROAlias        ; Map Read-Only Memory Alias
  113.        19      TRC_C_MapRWAlias        ; Map Read-Write Memory Alias
  114.        20      TRC_C_UnMapAlias        ; UnMap Memory Alias
  115.  
  116.    *   Notification Numbers
  117.  
  118.         0      TRC_C_SUC_ret           ; Success
  119.        -1      TRC_C_ERR_ret           ; Error
  120.        -2      TRC_C_SIG_ret           ; Signal
  121.        -3      TRC_C_TBT_ret           ; Single-Step
  122.        -4      TRC_C_BPT_ret           ; Breakpoint
  123.        -5      TRC_C_NMI_ret           ; NMI (NOT USED)
  124.        -6      TRC_C_KIL_ret           ; Process Termination
  125.        -7      TRC_C_GPF_ret           ; GP Fault
  126.        -8      TRC_C_LIB_ret           ; DLL Library Attachment
  127.        -9      TRC_C_FPE_ret           ; Floating Point Error
  128.        -10     TRC_C_THD_ret           ; Thread Termination
  129.        -11     TRC_C_STP_ret           ; Asynchronous Stop
  130.        -12     TRC_C_NEW_ret           ; New Process
  131.        -13     TRC_C_AFR_ret           ; Alias Free
  132.  
  133.    *   Error numbers with TRC_C_ERR_ret :
  134.  
  135.        1       trace_bad_command       ; command failed
  136.        2       trace_child_not_found   ; process not found
  137.        5       trace_child_untraceable ; cannot debug this process
  138.  
  139.    *   Command Parameters
  140.  
  141.        Not all fields need  to  be  defined on every  Ptrace command,  and the
  142.        meanings of some fields change on  a per-command basis.  This is a list
  143.        of the parameters for each command and notification.
  144.  
  145.        PTB fields not listed are not useful for that command.  Error cases for
  146.        each command are not listed here.
  147.  
  148.                Null Command
  149.  
  150.                --  Parameters
  151.  
  152.                        Pid = Process ID of debuggee
  153.                        Cmd = TRC_C_Null
  154.  
  155.                --  Returns
  156.  
  157.                    No operation is performed on the debuggee.
  158.  
  159.                    Pid must be valid, or an error will be returned.
  160.  
  161.                --  Unchanged
  162.  
  163.                        All except Seg, Off
  164.  
  165.                Read Registers Command
  166.  
  167.                --  Parameters
  168.  
  169.                        Pid = Process ID of debuggee
  170.                        TID  =  Thread ID of register set to  read.  If 0,  the
  171.                        register set comes  from  the  'current'  thread of the
  172.                        debuggee.
  173.                        Cmd = TRC_C_ReadReg
  174.  
  175.                --  Returns
  176.  
  177.                    The register set is updated.  The register set includes all
  178.                    general, segment, and control registers.
  179.  
  180.                        TID = Thread ID corresponding to register set.
  181.                        MTE = Program module's MTE handle
  182.  
  183.                --  Unchanged
  184.  
  185.                        Pid, Seg, Off
  186.  
  187.                Write Registers Command
  188.  
  189.                --  Parameters
  190.  
  191.                        Pid = Process ID of debuggee
  192.                        TID =  Thread ID of register set  to write.  If  0, the
  193.                        register  set  goes  to  the 'current'  thread  of  the
  194.                        debuggee.
  195.                        Cmd = TRC_C_WriteReg
  196.  
  197.                    All general, segment, and control registers contain desired
  198.                    values.  Reserved  system  or  processor  flags can not  be
  199.                    modified via this method,  but are silently masked to their
  200.                    correct values.
  201.  
  202.                --  Returns
  203.  
  204.                        TID = Thread ID corresponding to register set.
  205.  
  206.                --  Unchanged
  207.  
  208.                        Pid, MTE, Seg, Off, Register set.
  209.  
  210.                Read Word Command
  211.  
  212.                --  Parameters
  213.  
  214.                        Pid = Process ID of debuggee
  215.                        Seg:Off = Address to read from
  216.                        Cmd = TRC_C_ReadMem_I
  217.                        Cmd = TRC_C_ReadMem_D
  218.                        Cmd = TRC_C_ReadMem
  219.                        (These 3 commands are identical)
  220.  
  221.                --  Returns
  222.  
  223.                    The word  at the desired  address is read, and  stored into
  224.                    Value.
  225.  
  226.                        Value = word read from the desired location
  227.  
  228.                --  Restrictions
  229.  
  230.                        Unable to read from one-byte segments
  231.                        Unable to read from execute-only segments
  232.                        Unable to read from ring 0
  233.                        OK  to   read from both  InfoSeg  segments,  and GDT
  234.                        segments
  235.  
  236.                Write Word Command
  237.  
  238.                --  Parameters
  239.  
  240.                        Pid = Process ID of debuggee
  241.                        Seg:Off = Address to write to
  242.                        Value = word to write
  243.                        Cmd = TRC_C_WriteMem_I
  244.                        Cmd = TRC_C_WriteMem_D
  245.                        Cmd = TRC_C_WriteMem
  246.                        (These 3 commands are identical)
  247.  
  248.                --  Returns
  249.  
  250.                    The word in Value  is written  to  the address specified by
  251.                    Seg:Off.
  252.  
  253.                    In the case  of  a  write  to a shared  code  segment,  the
  254.                    segment is converted to  a  private  segment,  and any  set
  255.                    Dynamic  RAS  tracepoints  are removed  from  that  segment
  256.                    before the write is performed.
  257.  
  258.                    DynamicTrace will continue to function in  that segment, in
  259.                    the context of other processes.  The  segment will continue
  260.                    to be shared by those other processes, if any exist.
  261.  
  262.                    Breakpoints may be set in  the  debuggee  without affecting
  263.                    the other modules.
  264.  
  265.                --  Restrictions
  266.  
  267.                        Unable to write to one-byte segments
  268.                        Unable to write to ring 0
  269.                        Unable to write to GDT segments
  270.                        Unable to write to LDT InfoSeg
  271.                        Unable to write to execute-only segments
  272.  
  273.                Stop Command
  274.  
  275.                --  Parameters
  276.  
  277.                        Pid = Process ID of debuggee
  278.                        Cmd = TRC_C_Stop
  279.  
  280.                --  Returns
  281.  
  282.                    *   If debuggee is stopped
  283.  
  284.                        If there is a pending  notification  from  the  current
  285.                        thread,   it  is   returned.   Otherwise,   Success  is
  286.                        returned.
  287.  
  288.                    *   If the debuggee is running user code
  289.  
  290.                        The debuggee is marked to stop before the next time  it
  291.                        is ready to run user-space (ring 2 or 3) code.
  292.  
  293.                        Kernel  operations  will  not  be interrupted for  this
  294.                        Asynchronous stop command.  That is, threads blocked in
  295.                        the kernel (via a semaphore or internal operation) will
  296.                        not be  interrupted, but an infinite loop in user space
  297.                        will.
  298.  
  299.                        The  PTB register  set may be inaccurate when  the Stop
  300.                        command  finishes.  If the debuggee thread was  stopped
  301.                        via  an  AsyncStop command, an  AsyncStop  notification
  302.                        will be  returned  to the  debugger thread which issued
  303.                        the Go command, with an accurate register set.
  304.  
  305.                        Note that the AsyncStop command implies a debugger with
  306.                        a  minimum of 2  threads - one waiting for a Go command
  307.                        to finish, and one doing the Stop command.
  308.  
  309.                Go Command
  310.  
  311.                --  Parameters
  312.  
  313.                        Pid = Process ID of debuggee
  314.                        Cmd = TRC_C_Go
  315.  
  316.                --  Returns
  317.  
  318.                    All non-frozen threads of  the debuggee  are allowed to run
  319.                    user code  at once.  If  all  of the  debuggee threads  are
  320.                    frozen, an error is returned.
  321.  
  322.                    The  Go command  completes  when  a Ptrace event (such as a
  323.                    breakpoint)  occurs.  This  can   be   any   one   of   the
  324.                    notifications listed below.
  325.  
  326.                    When the  next  Ptrace  event  occurs,  all  threads in the
  327.                    debuggee  are  marked  to not run any additional user  code
  328.                    until  the  next  Go  command  is issued.  This  provides a
  329.                    stable environment for debugging.
  330.  
  331.                    When the Go command returns, the TID, MTE, and register set
  332.                    are  automatically  updated  to reflect  the  thread  which
  333.                    detected the event.
  334.  
  335.                    The  thread which detected the event  becomes the 'current'
  336.                    thread, used to determine which thread to access if  TID=0,
  337.                    on some of  the  commands.  This 'current thread' method is
  338.                    not recommended.  By simply not modifying the  TID field of
  339.                    the PTB, the same affect can be generated.
  340.  
  341.                Single Step Command
  342.  
  343.                --  Parameters
  344.  
  345.                        Pid = Process ID of debuggee
  346.                        Tid =  Thread  ID of thread to single-step.  If  0, all
  347.                        threads will be  marked to  single-step, and  the first
  348.                        thread  to  be  scheduled  to  run user-space code will
  349.                        single-step.
  350.                        Cmd = TRC_C_SStep
  351.  
  352.                --  Returns
  353.  
  354.                    Most likely, the SStep notification  will be  returned, but
  355.                    any  notification  may  be returned.  See  the  section  on
  356.                    notifications.
  357.  
  358.                    Callgates that result  in  a privilege  level transition to
  359.                    ring  0 will appear to single-step as a single instruction,
  360.                    with  the  single-step occurring  just  after the  function
  361.                    completes.
  362.  
  363.                    If Tid is  nonzero, the thread will single-step even if  it
  364.                    was  marked  frozen.  However, if  Tid  is zero, the frozen
  365.                    threads will not single-step.
  366.  
  367.                --  Restrictions
  368.  
  369.                    Callgate single-stepping  must  be  simulated  because  the
  370.                    flags (specifically, the TF bit) are not stored in the ring
  371.                    0 callgate  stack frame.  Because  of this,  a  single-step
  372.                    which  results in leaving  a ring 0 callgate will sometimes
  373.                    not  execute  any  user-space code.  The  next  single-step
  374.                    should function normally, however.
  375.  
  376.                Terminate Command
  377.  
  378.                --  Parameters
  379.  
  380.                        Pid = Process ID of debuggee
  381.                        Cmd = TRC_C_Term
  382.  
  383.                --  Returns
  384.  
  385.                    The debuggee process is terminated immediately.
  386.  
  387.                    No additional Ptrace  commands  or  notifications  will  be
  388.                    allowed to this process.  Memory  aliases  to  the debuggee
  389.                    will be invalidated automatically.
  390.  
  391.                    Debuggee ExitList processing  will be  attempted,  but  any
  392.                    Ptrace event (such as a breakpoint) during this period will
  393.                    cause  the  process to  terminate  without  completing  the
  394.                    ExitList processing.
  395.  
  396.                    If  the  Terminate  command   is   issued  during  ExitList
  397.                    processing, ExitList processing will terminate immediately,
  398.                    without continuing the ExitList routine.
  399.  
  400.                Freeze Thread Command
  401.  
  402.                --  Parameters
  403.  
  404.                        Pid = Process ID of debuggee
  405.                        Tid  =  Thread  ID of  thread  to  freeze.  If  0,  all
  406.                        debuggee threads will be frozen.
  407.                        Cmd = TRC_C_Freeze
  408.  
  409.                --  Returns
  410.  
  411.                    The desired  thread(s) are prevented from running user code
  412.                    on  a Go or SStep  command.  Note that this can be defeated
  413.                    when single-stepping a specific thread.
  414.  
  415.                    By using the Freeze and  Resume  commands, a given  set  of
  416.                    threads can be run at once, while keeping the other threads
  417.                    suspended.
  418.  
  419.                    No error is returned if the thread  was previously frozen -
  420.                    it just remains frozen.   Freeze and Resume commands do not
  421.                    nest.  A  single Resume  command will thaw  a thread frozen
  422.                    multiple times.
  423.  
  424.                    If  the  TID  was  zero, it will be set to  the  TID of the
  425.                    'current' thread.
  426.  
  427.                Resume Thread Command
  428.  
  429.                --  Parameters
  430.  
  431.                        Pid = Process ID of debuggee
  432.                        Tid = Thread ID of thread  to thaw.  If 0, all debuggee
  433.                        threads will be thawed.
  434.                        Cmd = TRC_C_Resume
  435.  
  436.                --  Returns
  437.  
  438.                    The  resume  command  complements  the  freeze  command.  A
  439.                    thread which has been resumed  will  function as if it  was
  440.                    never frozen.
  441.  
  442.                    No error will be returned if the thread was not  previously
  443.                    frozen
  444.  
  445.                    If  the  TID was zero,  it will be set  to  the TID  of the
  446.                    'current' thread.
  447.  
  448.                Get 80287 Registers Command
  449.  
  450.                --  Parameters
  451.  
  452.                        Pid = Process ID of debuggee
  453.                        TID = Thread ID of NPX register set to read.  If 0, the
  454.                        register  set  comes from the 'current'  thread of  the
  455.                        debuggee.
  456.                        Cmd = TRC_C_GetFPRegs
  457.                        Seg:Off  ->  287  NPX context buffer.  This NPX context
  458.                        buffer format  is  the  same  as that  defined  by  the
  459.                        fsave/frestore  instructions as executed by  the  80287
  460.                        chip.
  461.  
  462.                --  Returns
  463.  
  464.                    Debugger's 287 NPX  context buffer filled in with registers
  465.                    read from the NPX chip, for the Thread specified in the Tid
  466.                    field.
  467.  
  468.                    If  the  TID was  zero,  it will be set  to the TID of  the
  469.                    'current' thread.
  470.  
  471.                --  Restrictions
  472.  
  473.                    An error  will  be  returned  if  the  debuggee  process is
  474.                    emulating the NPX, or if  the desired  debuggee thread  has
  475.                    not yet attempted to use the NPX.
  476.  
  477.                Set 80287 Registers Command
  478.  
  479.                --  Parameters
  480.  
  481.                        Pid = Process ID of debuggee
  482.                        TID  = Thread  ID of NPX register set to write.  If  0,
  483.                        the register  set goes to the 'current'  thread  of the
  484.                        debuggee.
  485.                        Cmd = TRC_C_SetFPRegs
  486.                        Seg:Off ->  Debugger's 287  NPX  context  buffer.  This
  487.                        NPX context buffer format is  the  same as that defined
  488.                        by the fsave/frestore  instructions  as executed by the
  489.                        80287 chip.
  490.  
  491.                --  Returns
  492.  
  493.                    287 NPX registers  filled in from passed-in  buffer, to the
  494.                    Thread specified in the Tid field.
  495.  
  496.                    If the TID was zero,  it  will  be  set to the  TID  of the
  497.                    'current' thread.
  498.  
  499.                --  Restrictions
  500.  
  501.                    An error  will  be  returned  if the  debuggee  process  is
  502.                    emulating  the NPX,  or if  the desired debuggee thread has
  503.                    not yet attempted to use the NPX.
  504.  
  505.                    The 287  NPX  processor  may  adjust  some control register
  506.                    bits, but Ptrace will not return an error if a modification
  507.                    is  attempted.  Because of  internal NPX  management,  this
  508.                    adjustment may  be delayed  until the thread  actually uses
  509.                    the NPX again.
  510.  
  511.                Convert Segment Number to Selector Command
  512.  
  513.                --  Parameters
  514.  
  515.                        Pid = Process ID of debuggee
  516.                        Cmd = TRC_C_NumtoSel
  517.                        Value = Logical segment number
  518.                        MTE = MTE handle of module of interest
  519.  
  520.                --  Returns
  521.  
  522.                    Value is converted into a selector (valid in the debuggee's
  523.                    memory space)  that  maps  the requested logical segment of
  524.                    the requested module.
  525.  
  526.                    The logical segment numbers are generated at link time.  By
  527.                    using  this  function,  selectors  can  be  mapped back  to
  528.                    logical segment  numbers.  Once the logical segment  number
  529.                    is  known, symbols can  be  generated  via a map or  symbol
  530.                    file, for symbolic debugging.
  531.  
  532.                Get Library Name Command
  533.  
  534.                --  Parameters
  535.  
  536.                        Pid = Process ID of debuggee
  537.                        Cmd = TRC_C_GetLibName
  538.                        Value = MTE handle of module of interest
  539.                        Seg:Off  = Pointer to Debugger's  LibName  buffer.  The
  540.                        debugger  should  reserve  enough memory space  at  the
  541.                        desired location to hold a fully qualified path name.
  542.  
  543.                --  Returns
  544.  
  545.                    The fully  qualified path  name of the module corresponding
  546.                    to the MTE handle in  Value is returned to the  debugger at
  547.                    the location pointed to by Seg:Off.
  548.  
  549.                    The GetLibName command is useful for generating a path to a
  550.                    symbol file to aid in symbolic debugging.
  551.  
  552.                Thread Status Command
  553.  
  554.                --  Parameters
  555.  
  556.                        Pid = Process ID of debuggee
  557.                        TID  = Thread  ID  of thread of  interest.  If  0,  the
  558.                        status of the 'current' thread will be returned.
  559.                        Cmd = TRC_C_ThrdStat
  560.                        Seg:Off = pointer to Thread Status buffer
  561.                        Thread Status buffer format
  562.  
  563.                        TStat   struc
  564.                                DbgState        db      ?
  565.                                TState          db      ?
  566.                                TPriority       dw      ?
  567.                        TStat   ends
  568.  
  569.                --  Returns
  570.  
  571.                        Value = Thread ID of 'next' active thread
  572.                        Tid = Thread ID matching status
  573.  
  574.                    The  thread status  buffer  will  be  filled  in  with  the
  575.                    following  values,  depending  on the  thread's state.  The
  576.                    DbgState   byte  gives  information   about  the  state  of
  577.                    debugging,  while the TState  byte  gives information about
  578.                    scheduling.
  579.  
  580.                    TStat.DbgState values :
  581.  
  582.                    TRC_C_Thawed    equ     0
  583.                    TRC_C_Frozen    equ     1
  584.  
  585.                    TStat.TState values :
  586.  
  587.                    TRC_C_Runnable  equ     0
  588.                    TRC_C_Suspended equ     1
  589.                    TRC_C_Blocked   equ     2
  590.                    TRC_C_CritSec   equ     3
  591.  
  592.                    TStat.TPriority will be the thread's scheduling priority.
  593.  
  594.                    The Value field will be filled in with the Thread ID of the
  595.                    'next' thread to look at.
  596.  
  597.                    By  repeatedly  calling the ThrdStat command, replacing the
  598.                    Tid  with  the  last returned  Value, until  a thread ID is
  599.                    repeated, all threads in the process can be traversed.  The
  600.                    TIDs returned by the ThrdStat command form a loop.
  601.  
  602.                Map Read-Only Memory Alias Command
  603.  
  604.                --  Parameters
  605.  
  606.                        Pid = Process ID of debuggee
  607.                        Cmd = TRC_C_MapROAlias
  608.                        Value = Debugger alias selector to be remapped.  If  0,
  609.                        a new alias will be mapped.
  610.                        Seg = Debuggee selector to alias to.
  611.  
  612.                --  Returns
  613.  
  614.                        Value = Debugger alias selector
  615.                        Off = Segment limit of alias selector
  616.  
  617.                    A read-only alias to the debuggee's selector is mapped into
  618.                    the debugger's memory space.  This selector is reserved for
  619.                    use as an alias until it is unmapped.
  620.  
  621.                    Because the segment cannot  be written  to  via a read-only
  622.                    segment, DynamicTrace  tracepoints are left in shared code,
  623.                    and  the segment is not  made  private.  For  this  reason,
  624.                    Read-only aliases should be used when simply perusing code,
  625.                    to conserve system resources.
  626.  
  627.                    Only selectors returned by a previous Ptrace call to map an
  628.                    alias may  be  remapped.  It is okay to  remap a read-write
  629.                    alias  from  a  read-only  alias,  and  vice  versa, but  a
  630.                    selector returned via other  memory management  calls (such
  631.                    as AllocSeg) may not be used.  Most other memory management
  632.                    calls may not be used on these aliases.
  633.  
  634.                    When   the  debuggee  frees  the   segment,  an  alias-free
  635.                    notification  is   returned  to  the  debugger.   See   the
  636.                    notification section for details.
  637.  
  638.                    If the  debuggee  changes the size of the segment, the size
  639.                    of  the alias will be updated to match, without telling the
  640.                    debugger.   For  this  reason,  it   is   recommended  that
  641.                    debuggers access this alias segment only  when the debuggee
  642.                    is not running, and after checking the size of the segment,
  643.                    to prevent the debugger from faulting.
  644.  
  645.                    This  command  may  be  performed  while  the  debuggee  is
  646.                    executing  code  via  a  Go  command.   The  alias  may  be
  647.                    accessed while the debuggee is running.
  648.  
  649.                Map Read-Write Memory Alias Command
  650.  
  651.                --  Parameters
  652.  
  653.                        Pid = Process ID of debuggee
  654.                        Cmd = TRC_C_MapRWAlias
  655.                        Value = Debugger alias selector to be remapped.  If  0,
  656.                        a new alias will be mapped.
  657.                        Seg = Debuggee selector to alias to.
  658.  
  659.                --  Returns
  660.  
  661.                        Value = Debugger alias selector
  662.                        Off = Segment limit of alias selector
  663.  
  664.                    A read-write alias to  the  debuggee's  selector  is mapped
  665.                    into  the  debugger's   memory  space.  This  selector   is
  666.                    reserved for use as an alias until it is unmapped.
  667.  
  668.                    Because  the segment  can be written to,  if it is a shared
  669.                    code segment, DynamicTrace tracepoints are removed, and the
  670.                    segment is made private.
  671.  
  672.                    Only selectors returned by a previous Ptrace call to map an
  673.                    alias may  be remapped.  It  is  okay to remap a read-write
  674.                    alias  from  a  read-only  alias,  and  vice  versa,  but a
  675.                    selector returned  via other  memory management calls (such
  676.                    as AllocSeg) may not be used.  Most other memory management
  677.                    calls may not be used on these aliases.
  678.  
  679.                    When  the  debuggee  frees   the   segment,  an  alias-free
  680.                    notification  is   returned  to   the   debugger.  See  the
  681.                    notification section for details.
  682.  
  683.                    If the  debuggee changes the size of the segment, the  size
  684.                    of the  alias will be updated to match, without telling the
  685.                    debugger.  For   this   reason,  it   is  recommended  that
  686.                    debuggers  access this alias segment only when the debuggee
  687.                    is not running, and after checking the size of the segment,
  688.                    to prevent the debugger from faulting.
  689.  
  690.                    This  command  may  be  performed  while  the  debuggee  is
  691.                    executing  code  via  a  Go  command.   The  alias  may  be
  692.                    accessed while the debuggee is running.
  693.  
  694.                --  Restrictions
  695.  
  696.                    A number  of  segments, such as the  infoseg, GDT segments,
  697.                    and the like, cannot be mapped to.
  698.  
  699.                UnMap Memory Alias Command
  700.  
  701.                --  Parameters
  702.  
  703.                        Pid = Process ID of debuggee
  704.                        Cmd = TRC_C_UnMapAlias
  705.                        Value = Debugger alias selector to be unmapped.
  706.  
  707.                --  Returns
  708.  
  709.                    The  UnMapAlias  command  is  used  when the  debugger  has
  710.                    finished using an alias selector,  and  wishes to return it
  711.                    to  the  selector   pool.  Both  read-only  and  read-write
  712.                    aliases may be freed in this way.
  713.  
  714.                    A selector  returned  from  other  memory  management calls
  715.                    (such as AllocSeg) may not be used.
  716.  
  717.                    This  command  may  be  performed  while  the  debuggee  is
  718.                    executing code via a Go command.
  719.  
  720.                    When  the debuggee process finally  terminates, all aliases
  721.                    to it's memory space will be invalidated.
  722.  
  723.                --  Restrictions
  724.  
  725.                    A number  of segments, such  as  the infoseg, GDT segments,
  726.                    and the like, cannot be mapped to.
  727.  
  728.    *   Notification Parameters
  729.  
  730.                Success Notification
  731.  
  732.                --  Meaning
  733.  
  734.                        The Ptrace command was successful.
  735.  
  736.                --  Returns
  737.  
  738.                        Cmd = TRC_C_SUC_ret
  739.                        Other  returned  values  depend  on which  command  was
  740.                        executed - see Commands section.
  741.  
  742.                Error Notification
  743.  
  744.                --  Meaning
  745.  
  746.                        An  error  was   detected  while  attempting  a  Ptrace
  747.                        command.
  748.  
  749.                --  Returns
  750.  
  751.                        Cmd = TRC_C_ERR_ret
  752.                        Value =
  753.  
  754.                        *   trace_bad_command  -  The  Ptrace  command  failed,
  755.                            probably because of invalid parameters.
  756.  
  757.                        *   trace_child_not_found  - The process could  not  be
  758.                            located from the given Pid.
  759.  
  760.                        *   trace_child_untraceable - The process  was located,
  761.                            but is either not marked for debugging, or is being
  762.                            debugged by another debugger.
  763.  
  764.                Signal Notification
  765.  
  766.                --  Meaning
  767.  
  768.                    The debuggee process is about to set up to  dispatch  to  a
  769.                    signal  handler.   A  bit  vector  of  pending  signals  is
  770.                    returned in the low byte of Value.  If more than one signal
  771.                    is  pending,  which  signal handler that gets dispatched to
  772.                    first is undetermined.
  773.  
  774.                --  Returns
  775.  
  776.                        Cmd = TRC_C_SIG_ret
  777.                        Value = Bit vector of pending signals
  778.                        Seg:Off = 0:0
  779.  
  780.                    The bit positions  in  the low byte of  Value correspond to
  781.                    signal numbers.
  782.  
  783.                    Bit     Name            Meaning
  784.  
  785.                    0       -------         reserved
  786.                    1       SIGINTR         Ctrl-C
  787.                    2       -------         reserved
  788.                    3       SIGTERM         Program termination
  789.                    4       SIGBREAK        Ctrl-Break
  790.                    5       SIGPFA          Process flag A
  791.                    6       SIGPFB          Process flag B
  792.                    7       SIGPFC          Process flag C
  793.  
  794.                Single-Step Notification
  795.  
  796.                --  Meaning
  797.  
  798.                    A single-step trap has been detected.  This  occurs when an
  799.                    instruction is executed  with the TF bit  set.  This can be
  800.                    done via the SStep command.
  801.  
  802.                --  Returns
  803.  
  804.                        Cmd = TRC_C_TBT_ret
  805.                        Value = 0
  806.                        Seg:Off = CS:IP location of SStep
  807.  
  808.                Breakpoint Notification
  809.  
  810.                --  Meaning
  811.  
  812.                    A breakpoint trap has been detected.  This occurs when  the
  813.                    int 3 software interrupt is executed.
  814.  
  815.                    The debuggee's IP location is automatically decremented  by
  816.                    1  to  adjust  for  the  length  of  the   one-byte  int  3
  817.                    instruction.  The two-byte form is not recommended for this
  818.                    reason.
  819.  
  820.                --  Returns
  821.  
  822.                        Cmd = TRC_C_BPT_ret
  823.                        Value = 0
  824.                        Seg:Off = user's CS:IP (decremented by 1)
  825.  
  826.                NMI Notification (NOT USED)
  827.  
  828.                --  Meaning
  829.  
  830.                    A nonmaskable interrupt has been detected.
  831.  
  832.                    This  is  meaningless  in  protected  mode,  and  is  never
  833.                    returned.
  834.  
  835.                Process Termination Notification
  836.  
  837.                --  Meaning
  838.  
  839.                    The debuggee process is about to terminate.
  840.  
  841.                    All ExitList processing is complete at this point.
  842.  
  843.                    The debugger  is still allowed  to  examine  the debuggee's
  844.                    final register and memory contents at this time.  Note that
  845.                    when   the   debugger  has   completed   this   post-mortem
  846.                    examination,  it should  finish  terminating  the  debuggee
  847.                    process with a final Go, SStep, or Terminate command.
  848.  
  849.                    Value contains  the  return  code  from the  process.  This
  850.                    return  code is  the same as that returned via  a  DosCWait
  851.                    call.
  852.  
  853.                --  Returns
  854.  
  855.                        Cmd = TRC_C_KIL_ret
  856.                        Value = Process return code (CWait Exit_Code)
  857.                        Seg:Off = 0:0
  858.  
  859.                GP Fault Notification
  860.  
  861.                --  Meaning
  862.  
  863.                    A General Protection fault has been detected.
  864.  
  865.                    The  debugger is allowed  to fix the faulting condition and
  866.                    restart the  operation.  The  debuggee is not automatically
  867.                    terminated.
  868.  
  869.                    The  error code from the fault,  as passed by the hardware,
  870.                    is returned via the Value field.  This is either zero, or a
  871.                    selector.  Note  that  the  RPL  bits  of the  selector are
  872.                    always cleared by the processor.
  873.  
  874.                --  Returns
  875.  
  876.                        Cmd = TRC_C_GPF_ret
  877.                        Value = Exception error code from processor
  878.                        Seg:Off = CS:IP location or SStep
  879.  
  880.                --  Restrictions
  881.  
  882.                    The (CX) register may not be valid after a GP fault because
  883.                    of a hardware problem with some 80286 processors.
  884.  
  885.                DLL Library Load Notification
  886.  
  887.                --  Meaning
  888.  
  889.                    A DLL library has just been  attached  to the module.  This
  890.                    occurs either at program startup, or during a DosLoadModule
  891.                    call.
  892.  
  893.                    The module's handle is returned via Value, for use  in  the
  894.                    GetLibName and NumToSel commands, for symbolic debugging.
  895.  
  896.                    There may be many module attachments done at one  time, but
  897.                    Ptrace is only able to communicate a single load during any
  898.                    one  notification.  In  this  case, the  additional library
  899.                    load notifications  become pending.  The debugger should do
  900.                    repeated  Stop commands to be notified of these  additional
  901.                    library  loads,  until  Success is  returned from the  Stop
  902.                    command.  If the Go or SStep commands  are  used instead of
  903.                    the  Stop  command,  the   pending  notifications  will  be
  904.                    returned  immediately,   until   there   are   no   further
  905.                    notifications.
  906.  
  907.                --  Returns
  908.  
  909.                        Cmd = TRC_C_LIB_ret
  910.                        Value = MTE handle of newly attached library
  911.                        Seg:Off = 0:0
  912.  
  913.                Floating Point Error Notification
  914.  
  915.                --  Meaning
  916.  
  917.                    An  error  was detected  while  processing the GetFPRegs or
  918.                    SetFPRegs commands.  This  can happen because  the debuggee
  919.                    is emulating the NPX, or if the debuggee thread has not yet
  920.                    used the NPX processor.
  921.  
  922.                --  Returns
  923.  
  924.                        Cmd = TRC_C_FPE_ret
  925.                        Value = undefined
  926.                        Seg:Off = unchanged
  927.  
  928.                Thread Termination Notification
  929.  
  930.                --  Meaning
  931.  
  932.                    A debuggee thread is about to terminate.
  933.  
  934.                    ExitList processing has not yet been started.
  935.  
  936.                    The  debugger  is  still  allowed  to  examine the debuggee
  937.                    thread's  final register contents  at this time.  Note that
  938.                    when   the  debugger   has   completed   this   post-mortem
  939.                    examination,  it  should finish  terminating  the  debuggee
  940.                    thread with a final Go, or SStep command.
  941.  
  942.                    Value contains the return code from the thread.  Note  that
  943.                    this is  only a  proposed return  code, as  passed  in from
  944.                    DosExit.  Only when the process actually  terminates is the
  945.                    return code that is passed via CWait finally known.
  946.  
  947.                --  Returns
  948.  
  949.                        Cmd = TRC_C_THD_ret
  950.                        Value = Thread's proposed return code (from DosExit)
  951.                        Seg:Off = 0:0
  952.  
  953.                Asynchronous Stop Notification
  954.  
  955.                --  Meaning
  956.  
  957.                    An Asynchronous Stop request has been detected.
  958.  
  959.                    The asynchronous stop command is used to get the  attention
  960.                    of some debuggee  thread,  so that the  debugger  can again
  961.                    control the process.  Because any  notification results  in
  962.                    the  debuggee  coming under  control of the debugger again,
  963.                    the  asynchronous stop  notification  becomes  redundant in
  964.                    that case.
  965.  
  966.                    The asynchronous stop request will be overridden and ignored
  967.                    if another notification may  be performed.  An asynchronous
  968.                    stop  notification  never becomes a 'pending' notification,
  969.                    in the sense that a library attachment notification becomes
  970.                    pending.
  971.  
  972.                --  Returns
  973.  
  974.                        Cmd = TRC_C_STP_ret
  975.                        Value = 0
  976.                        Seg:Off = 0:0
  977.  
  978.                New Process Notification
  979.  
  980.                --  Meaning
  981.  
  982.                    The debuggee process has just started a  child process, and
  983.                    that child process needs to be debugged.
  984.  
  985.                --  Returns
  986.  
  987.                        Cmd = TRC_C_NEW_ret
  988.                        Value = Pid of the new process.
  989.                        Seg:Off = 0:0
  990.  
  991.                Alias Free Notification
  992.  
  993.                --  Meaning
  994.  
  995.                    A segment that has an alias  attached to it is about to  be
  996.                    freed by the debuggee.
  997.  
  998.                    The  alias selector must  be  remapped or unmapped before the
  999.                    debugger may run the debuggee again.
  1000.  
  1001.                    The  UnMapAlias command is the  usual  response to an alias
  1002.                    free  notification.  The other proper  response is to remap
  1003.                    the alias that is being freed to another debuggee segment.
  1004.  
  1005.                    Value contains the debugger alias selector that needs to be
  1006.                    remapped or unmapped.
  1007.  
  1008.                --  Returns
  1009.  
  1010.                        Cmd = TRC_C_AFR_ret
  1011.                        Value = Alias selector that needs to be freed
  1012.                        Seg:Off = 0:0
  1013.