TSF Using 16-bit Segmented Addressing

;  Trace source file for the xxx dynalink.  Compiled with 16-bit offsets.

     MODNAME=\c\src\xxx.dll
     MAJOR=0xC5
     MAXDATALEN=200
;  We will want to trace up to 200 bytes in any one trace call.

     TYPELIST NAME=API,ID=08,
              NAME=SYS,ID=04,
              NAME=PRE,ID=02,
              NAME=POST,ID=64

     GROUPLIST NAME=MEM,ID=1,
               NAME=FS,ID=3

              /* The following tracepoint does not need debug info,
                 only a MAP file is necessary with label xxalloc
                 public in it.  The program must be compiled in 16-bit
                 mode because segmented addressing is used (ASCIIZ
                 instead of ASCIIZ32).
                 This logs the word registers AX and BX and the string
                 pointed at by DS:DI for a max of 20 bytes. */

     TRACE    MINOR=25, TP=.xxalloc,
              OPCODE=0x8B,    /* the opcode is optional */
              TYPE=(API,PRE),
              GROUP=MEM,
              DESC="(OS) xxalloc Pre-Invocation",
              FMT ="                             AX = %W ",
              FMT ="                             upper BX = %B",
              FMT ="                             lower BX = %B",
              FMT ="                             param = %P%S",
              REGS=(AX,BX),
              ASCIIZ=(RDS+DI,DIRECT,20)


              /* This defines a tracepoint at Foo label.  The ten words
                 to log are found indirectly through SS:SP.  Note that
                 each word needs a format control but since only one
                 memory access was done,  one prefix control is needed. */

      TRACE   MINOR=0xB0, TP=.Foo,
              TYPE=(SYS),
              GROUP=FS,
              DESC="(OS) Foo Pre-Invocation",
              FMT="                     First Five words = %P%W%W%W%W%W",
              FMT="                     Three words ignored %I6",
              FMT="                     Last Two Words = %W%W",
              MEM=(RSS+SP,INDIRECT,20)


              /* This defines a tracepoint at Goo label.  DS:DI points
                 to a structure whose second field is a pointer to an
                 ASCIIZ string.  The offset from the first field in the
                 structure is 4 bytes. Max string size to log is 40 bytes. */

      TRACE   MINOR=0xB1, TP=.Goo,
              TYPE=(SYS),
              GROUP=FS,
              DESC="(OS) Goo Pre-Invocation",
              FMT="          Second field in struct points to %P%S",
              ASCIIZ=(RDS+DI+4,INDIRECT,40)


              /* This defines a tracepoint at Hoo label.  DS:DI points to
                 memory that contains a pointer to a structure. We want to
                 log the third field in the structure (offset 6 from begin
                 of structure). */

      TRACE   MINOR=0xB2, TP=.Hoo,
              TYPE=(SYS),
              GROUP=FS,
              DESC="(OS) Hoo Pre-Invocation",
              FMT="          Third field in struct is doubleword = %P%D",
              MEM=(RDS+DI,INDIRECT*+6,4)


              /* This defines a tracepoint at Zoo label.  DS:DI points to
                 memory that contains a pointer to end of a structure. We
                 want to log the last field in the structure(offset -2 from
                 end of structure). */

      TRACE   MINOR=0xB3, TP=.Zoo,
              TYPE=(SYS),
              GROUP=FS,
              DESC="(OS) Zoo Pre-Invocation",
              FMT="          Last field in struct is word = %P%W",
              MEM=(RDS+DI,INDIRECT*-2,2)


              /* This defines a tracepoint at procedure CheckIT.  This
                 is a C routine compiled with debug information.  The
                 data to log is an ASCIIZ string called NameIt.  */

      TRACE   MINOR=0xB3, TP=.CheckIt,
              TYPE=(PRE),
              GROUP=FS,
              DESC="(OS) CheckIt Pre-Invocation",
              FMT="              NameIt = %P%S",
              ASCIIZ=(.NameIt,DIRECT,64)


              /* This defines a tracepoint at the return point of the
                 procedure CheckIt, a C routine compiled with debug.
                 Status_Rec is a record variable. We want to log the
                 age field (four bytes from the begin of Status_Rec),
                 the name (six bytes from Status_Rec that points to
                 an ASCIIZ string), the age of the next Status_Rec
                 (a pointer to the next Status_Rec is ten bytes from
                 the begin of Status_Rec, the age is four bytes from
                 the begin of the next Status_Rec). */

      TRACE   MINOR=0x80B3, TP=.CheckIt,RETEP,
              TYPE=(POST),
              GROUP=FS,
              DESC="(OS) CheckIt Post-Invocation",
              FMT="              Status_Rec.age = %P%W",
              FMT="              Status_Rec.name = %P%S",
              FMT="              Status_Rec.next->age = %P%W",
              MEM=(.Status_Rec+4,DIRECT,2),
              ASCIIZ=(.Status_Rec+6,INDIRECT,64),
              MEM=(.Status_Rec+10,INDIRECT*+4,2)


              /* This defines a tracepoint at line 58 in the source
                 file check.c   Debug info is needed to use this
                 type of tracepoint. v_ptr is a pointer to a variable
                 sized record.  The length is 4 bytes past the
                 beginning of the record.  Log that record. */

      TRACE   MINOR=0x71B4, TP=@check.c,58,
              TYPE=(SYS),
              GROUP=FS,
              DESC="(OS) CheckIt   before allocation",
              FMT="              Variant Record = %P%W%D%U",
              LEN=(v_ptr,INDIRECT*+4),
              MEM=(.v_ptr,INDIRECT,LEN)


              /* This does not define a tracepoint, it only defines a
                 trace formatting string for minor code 181 (B5 hex). */

      TRACE   MINOR=0xB5, TP=@STATIC,
              DESC="(OS) StaticProcedure Pre-Invocation",
              FMT="                 DI = %W FLAGS = %W"


              /* This defines a tracepoint at routine LookUp, but no
                 data is to be logged, only the DESC will show up
                 in the Trace log when the tracepoint is formatted. */

      TRACE   MINOR=0xB6, TP=.LookUp,
              TYPE=(SYS),
              GROUP=FS,
              DESC="(APP) LookUp  Pre-Invocation",




[Back: Sample Trace Source Files]
[Next: TSF Using 32-bit Addressing]