home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dumptool.zip / TRUTILS.ZIP / trctools.doc < prev    next >
Text File  |  1998-11-11  |  41KB  |  1,136 lines

  1. TRCTOOLS: System Trace Tools
  2. Authors: Richard Moore & Pete Guy
  3. Version: 1.14
  4. Date: 11th Nov 1998
  5.  
  6. This package comprises a consolidated set of the latest (beta test) system trace
  7. customisation utiltities. This package consolidates and replaces the following
  8. OS2TOOLS packages:
  9. DTRACE, TRSPOOL
  10.  
  11.  
  12.  
  13. The utilities supplied in this edition of TRCTOOLS are:
  14.  
  15. SYSSPLIT: Breaks up a SYSTEM.TDF or SYSTEM.TFF file into its
  16. constituent *.TDF and *.TFF files.
  17.  
  18. TDFLST: Formats a TDF file (except SYSTEM.TDF) into a readable listing
  19. that may be used as input to DTRACE, either to re-generate the TDF or
  20. to apply the tracepoints.
  21.  
  22. TFFLST: Formats a TFF file (except SYSTEM.TFF) into a readable listing
  23. that may be processed by TRCUST to re-generate the TFF.
  24.  
  25. TRCUST: Latest version of the Trace Cusomizer.
  26.  
  27. TRACE: Latest version of the Trace Command.
  28.  
  29. TRACEFMT: Latest version of the Trace Formatter.
  30.  
  31. TRSPOOL: Latest version of the Trace Spooler.
  32.  
  33. TRSTOP: Termination utility for TRSPOOL.
  34.  
  35. DTRACE: Latest version of the DTRACE utility.
  36.  
  37. DYNDD: A sample dynamic trace device driver exit.
  38.  
  39. SAMPLRPN: Sample RPN files for DTRACE.
  40.  
  41. MAPTSF: Generates a TSF from a MAP file.
  42.  
  43. MAKETSF: Extracts trace definiitons from source files and generates line
  44.          number information.
  45.  
  46. SELTSF: Extracts a subset if tracepoints from TFFLST output.
  47.  
  48. SELRPN: Extracts a subset if tracepoints from TDFLST output.
  49.  
  50. TRACEF: Extracts (filtres) a subset of formatted trace entries.
  51.  
  52.  
  53.  
  54. The last three commands have been supplied by Pete Guy.
  55.  
  56.  
  57. All utilities are described in detail below. An example of the
  58. use of TFFLST and TDFLST is given at the end of this document.
  59.  
  60.  
  61.  
  62.                    Descriptions of TRCTOOLS Utilities
  63.                    ----------------------------------
  64.  
  65.  
  66. TRACEFMT
  67. --------
  68. TRACEFMT contains a number of string formatting fixes and also fixes
  69. two traps (a floating-point exception and an access exception). This version
  70. of TRACEFMT is compatible with the Warp 3.0 Fix Pack 35 trace enhancments.
  71. TRACEFMT now supports the %C formatting control character.
  72. See TRACE.DOC for details of additional enhancements specific to OS2 Warp V3
  73. Fix Pack 35 in TRACECMD.ZIP.
  74.  
  75. Version 2.3 fixes problems with selection criteria where <, <=, > or >=
  76. comparisons were used. It also handled time comparisions incorreclty. Time
  77. specified in an abbreviated form as follows in now handled correctly:
  78.  
  79.    Abbreviated form           Equivalent form
  80.    h                          h:0:0.0
  81.    h:m                        h:m:0.0
  82.    h:m:s                      h:m:s.0
  83.  
  84.  
  85. TRACE
  86. -----
  87.  
  88. Version 2.4 contains adds syntax help.
  89.  
  90. The TRACE command contains support for non-DLL modules, which was
  91. regressed when WARP 3 was released.
  92.  
  93.       TRACE ON|OFF <module_name> | <tdfname>
  94.  
  95. now supports a fully qualified module name including path.  If a short
  96. name with no extension is supplied the name.DLL is assumed.  The TDF
  97. for the module must contain the same name with the extension TDF.  TDFs
  98. are searched for in the following order:
  99.  
  100.       Current directory + DPATH
  101.       OS2\SYSTEM\TRACE
  102.       OS2\SYSTEM\TRACE\SYSTEM.TDF
  103.       module directory
  104.  
  105. If no load module is found then TRACE searches for a TDF file with name specified,
  106. if found uses the module name embedded within the TDF.
  107.  
  108. Thus for private TDFs, the TDF file may be stored in the same directory
  109. as the traced module.
  110.  
  111. If the module path information is not supplied then TRACE uses LIBPATH
  112. for DLLs and PATH for other module types.
  113.  
  114. See TRACE.DOC for details of additional enhancements specific to OS2 Warp V3
  115. Fix Pack 35 in TRACECMD.ZIP.
  116.  
  117.  
  118. TRCUST
  119. ------
  120.  
  121. The base version of TRCUST shipped with the Warp 3.0 and 4.0 ToolKits is 2.0.
  122.  
  123. TRCUST 3.05 provides the following enhancements and fixes since version 2.0:
  124.  
  125. Regression for NE modules, which may result in a TRAP D but also
  126. results in an invalid TDF being generated.
  127.  
  128. MODNAME is not required for Static Tracepoints.
  129.  
  130. Supports MAXDATALEN may be specified upto 4099. Note, MAXDATALEN above 512
  131. is permissible only on Warp 3.0 Fix Pack 35 and higher.
  132.  
  133. MAXDATALEN defaults to 512
  134.  
  135. Allows formatting controls to be specified in lower case.
  136.  
  137. Supports Major codes up to 0xffff.  Note, MAJOR code above 255 are
  138. permissible only on Warp 3.0 Fix Pack 35 and higher.
  139.  
  140. Fixed problems with keyword order on the TRACE statement.
  141.  
  142. Allows the %C formatting control to specify an ASCII character interpretation of
  143. a byte of trace data.
  144.  
  145. Allows the /NODE switch to bypass module debug information processing.
  146.  
  147. RETEP has been extended to work with MAP files and HLL version 4
  148. style debugging information.
  149.  
  150. Case insensitive references to MAP file symbols is allowed.
  151.  
  152. Line number support for HLL 4 (VisualAge C++)
  153.  
  154. All TSF keywords are case insensitive.
  155.  
  156. All TRCUST parameters are case insensitive.
  157.  
  158. TSF TRACE statement keywords are now order independent.
  159.  
  160. /L= parameter introduce to allow MODNAME to specify a different filespec
  161.     to the load module read by TRCUST.
  162.  
  163. /P  allows the path information specified with MODNAME to be retained in
  164.     the built TDF.
  165.  
  166. Fixes a TRAP caused by large line number tables with HLL3 (CSET++ 2.01)
  167.  
  168. Fixes a TRAP caused by using non-code DLLs.
  169.  
  170. Fixes a problem where TEST, NOT and NEG instructions with opcode byte 0XF6
  171. or 0XF7 were disallowed as tracepoints.
  172.  
  173. Fixes a problem with RETEP compatibility processing with previous versions,
  174. adds the /RP parameter and extends /RM options.
  175.  
  176.  
  177. The syntax for TRCUST 3.05 is as follows:
  178.  
  179. Usage1:  Trcust filename1 filename2 /M=mapfile /W{0|1|2} /D +
  180.                 /L=loadmod /NODE /NOLN /RM{0-6} /RSnnn /I /P
  181.  
  182.         filename1  is Trace Source File
  183.         filename2  is Trace Defintion File      (Optional)
  184.         /M=mapfile is map filename to use       (Optional)
  185.         /W{0|1|2}  is warning level to use      (Optional)
  186.         /D         allows duplicate minors      (Optional)
  187.         /L=loadmod is file name of load module  (Optional)
  188.         /NODE      ignore debug information     (Optional)
  189.         /NOLN      ignore line numbers          (Optional)
  190.         /RM{0-7}   RETEP match criteria         (Optional)
  191.         /RSnnn     RETEP search range           (Optional)
  192.         /RP        RETEP Pascal returns allowed (Optional)
  193.         /I         Case insensitive map symbols (Optional)
  194.         /P         Retain MODNAME Path Info     (Optional)
  195.  
  196. Usage2:  Trcust filename1 /C=dest_tff /W{0|1|2}
  197.  
  198.         filename1  is Trace Combine File containing TFF filenames
  199.         dest_tff   is destination TFF name for combined records
  200.         /W{0|1|2}  is warning level to use      (Optional)
  201.  
  202.  
  203. Usage 1 has introduced sever new parameters and some previouly
  204. undocumented parameters, which are now described:
  205.  
  206. /L=loadmod allows TRCUST to use a different file specification to the
  207.        name specified by the MODNAME TSF statement.
  208.  
  209.        TRCUST needs to exctract information from the load module to
  210.        generate the TDF. The module name is also required by the
  211.        TRACE command and so is recorded in the TDF from the MODNAME
  212.        statemenmt. /L is useful in cases where a module is built
  213.        using one name and subsequenlty renamed when installed,
  214.        or where the load module is built in a target directory
  215.        which differs from that of the TSF.
  216.  
  217.  
  218. /NODE  forces TRCUST to ignore debugging information even if present.
  219.        This is provide for cases where
  220.  
  221.        a)  the user wishes to use MAP symbols in preference to
  222.            debugging info.
  223.        b)  the level of debugging info in not supported by TRCUST and errors
  224.            are produces if it is used.
  225.  
  226.  NB debugging information is not a public standard. Some compilers may
  227.  appear to emulate Code View level 0, HLL 3 or HLL4, which not
  228.  actually doing so.
  229.  
  230. /NOLN forces TRCUST to ignore module line number records but honor
  231.       any other debugging informantion present.
  232.       This option is provided for cases where line number information
  233.       does not conform to supported specifications.
  234.  
  235.       N.B /NODE implies /NOLN
  236.  
  237. /I allows MAP file references to public symbols to be made case
  238. insensitively.
  239.  
  240. /RM{0-7} specfifes the default Return Entry Point (RETEP) match
  241.          criteria. By default, RETEP will use mode 2, however the
  242.          following modes may be specified:
  243.  
  244.          0  - Disallow RETEP.
  245.  
  246.          1 - Take RETEP from Code View symbol records only. NB HLL does
  247.              not provide return information.
  248.  
  249.          2 - Use mode 1 then search for a LEAVE+RET  or POP EBP 
  250.              instruction sequence near the end of the routine.
  251.  
  252.          3 - Use mode 2 then search for an isolated LEAVE instruction
  253.              near the end of the routine.
  254.  
  255.          4 - Use mode 2 then search for an isolated RET instruction
  256.              near the end of the routine.
  257.  
  258.          5 - Use modes 2 and 3 combined. Version 2.0 of TRCUST uses this
  259.              search mode. 
  260.  
  261.          6 - Use mode 4 then search for an isoloted JMP instruction
  262.              near the end of the routine.
  263.  
  264.          7 - Use mode 6 but search for an isolated LEAVE instruction
  265.              near the end of the routine, before searching for JMP.
  266.  
  267.         NB Determination of RETEP is subject to the following
  268.            limitations:
  269.  
  270.          1 - Only the last return from a routine is located.
  271.  
  272.          2 - Only mode 1 can accurately determine the last return, however
  273.              this is only available to code-view version 0 modules.
  274.  
  275.          3 - Searching for instruction sequences may result in a tracepoint
  276.              erroneously being placed within an instruction.
  277.  
  278.          4 - It may not be possible to use RETEP to define the return
  279.              tracepoint for modules that  use private (particularly optimised)
  280.              calling conventions.
  281.  
  282.          5 - The default mode is 2. This reasonably safe. Higher modes are less
  283.              safe.
  284.  
  285.          6 - Use mode 5 for compatible behaviour with earlier versions of TRCUST.
  286.              However, note that earlier versions of TRCUST erroneously permitted 
  287.              certain tracepoints which are not permitted using mode 5.
  288.  
  289.          7 - To avoid possible errors, JMP instructions with opcode 0xff are not 
  290.              selected.
  291.  
  292. /RP modifies RETEP processing to allow Pascal Return instructions (RET n) to be 
  293.     included in the search criteria with normal returns. Use this with 16-bit 
  294.     code where you know pascal returns are generated.
  295.  
  296.  
  297. /RSnnn specifies how far RETEP will search from the end of a routine
  298.        to find the return instruction sequence. This defaults to
  299.        18 bytes however RETEP will not search before the start of the routine.
  300.  
  301.  
  302. The RETEP keyword of the TSF  TRACE statement has been extended to
  303. allow specific RETEP search criteria to be specified per tracepoint.
  304. The syntax for RETEP is:
  305.  
  306.  RETEP[=options]
  307.  
  308. where options may be a combination of the following keywords
  309. separated by + signs:
  310.  
  311. CV    - use CV information
  312.  
  313. LRET  - search for a LEAVE+RET or POP EBP + RET sequence near
  314.         the end of the routine.
  315.  
  316. RET   - search for RET instruction near the end of the routine.
  317.  
  318. JMP   - search for JMP instruction near the end of the routine.
  319.  
  320. LEAVE - search for a LEAVE instruction near the end of the routine.
  321.  
  322. If more than one option is specified the RETEP uses the
  323. following order of precidence:
  324.  
  325. CV, LRET, RET, LEAVE, JMP
  326.  
  327.  
  328. DTRACE
  329. ------
  330.  
  331. See DTRACE.DOC for a full description of DTRACE 4.3
  332.  
  333. TRSPOOL
  334. -------
  335.  
  336. See TRSPOOL.DOC for a full description of TRSPOOL 4.0
  337.  
  338. DYNDD
  339. -----
  340.  
  341. See DYNDD.TXT for a description of this sample device driver.
  342.  
  343. SAMPLRPN
  344. --------
  345.  
  346. See SAMPLRPN.DOC for a full description.
  347.  
  348.  
  349. SYSSPLIT
  350. --------
  351.  
  352. Syntax:
  353.          SYSSPLIT <input_file>
  354.  
  355.  
  356. Trace definition files - SYSTEM.TDF:
  357.  
  358. When applying tracepionts to a DLL, TRACE.EXE will search the current
  359. path, then the DPATH for the dll_name.TDF file. If not found it
  360. searches OS2\SYSTEM\TRACE\SYSTEM.TDF and finally,
  361. OS2\SYSTEM\TRACE\dll_name.TDF.
  362.  
  363. If the system trace definitions for a particular module needs to be
  364. replaced or modified then SYSSPLIT may be used to split SYSTEM.TDF
  365. into its constituent TDF files. The resultant *.TDF files may be saved
  366. in OS2\SYSTEM\TRACE. Because of the search order employed by TRACE.EXE
  367. it is recommended that SYSTEM.TDF be renamed after being split.
  368.  
  369. The file names of the split *.TDFs will be chosen to be the original
  370. names used to create SYSTEM.TDF.
  371.  
  372. N.B. The trace definitions for the OS2KRNL may be in OS2KRNL.TDF or
  373. DOSCALLS.TDF. The TRACE command recognises the keyword KERNEL as an
  374. alias for each of the kernel TDF names. TRACE.EXE searches the DPATH
  375. for DOSCALLS.TDF, but due to a bug only \OS2\SYSTEM\TRACE of the
  376. current drive (as opposed to the boot drive) for OS2KRNL.TDF. The
  377. result of this latter point is that TRACE ON KERNEL will only work
  378. for OS2KRNL.TDF if a directory from the boot drive is curent.
  379.  
  380. The TDFLST utility mat be used with each of the resultant TDFs to
  381. format the trace point definitions.
  382.  
  383.  
  384.  
  385. Trace formatting files - SYSTEM.TFF:
  386.  
  387. When formatting the system trace, TRACEFMT.EXE will search
  388. OS2\SYSTEM\TRACE\SYSTEM.TFF for the formatting templates for each
  389. major code encountered in the trace buffer. If a major code is not
  390. found in SYSTEM.TFF then TRACEFMT will search for a file named
  391. TRC00xx.TFF, where xx is the major code number in hexadecimal.
  392.  
  393. If the formatting templates for a particular module needs to be
  394. replaced or modified then SYSSPLIT may be used to split SYSTEM.TFF
  395. into its constituent TFF files. The resultant *.TFF files may be saved
  396. in OS2\SYSTEM\TRACE. Because of the search order employed by
  397. TRACEFMT.EXE it is recommended that SYSTEM.TFF be renamed after being
  398. split.
  399.  
  400. The file names of the split *.TFFs will be chosen to be the original
  401. names used to create SYSTEM.TDF, that is names formed from their major
  402. codes.
  403.  
  404. The TFFLST utility mat be used with each of the resultant TFFs to
  405. format the trace point definitions.
  406.  
  407.  
  408. N.B. TRCUST has the ability to combine TFFs for the same major code.
  409. This is not to be confused with the special SYSTEM.TFF and SYSTEM.TDF
  410. files that are concatenations of dissimilar major code definitions.
  411.  
  412.  
  413. TDFLST
  414. ------
  415.  
  416. Syntax:
  417.  
  418.          TDFLST <tdf_file>
  419.  
  420. TDF list formats a TDF as DTRACE compatible trace program file. The
  421. output is directed to STDOUT, which may be captured in a file using
  422. the redirection operator (>).
  423.  
  424. Trace definitions may be modified or supplemented using an editor and
  425. the TDF rebuilt using DTRACE BUILDTDF.
  426.  
  427.  
  428. TFFLST
  429. ------
  430.  
  431. Syntax:
  432.  
  433.          TFFLST <tdf_file>
  434.  
  435. TFF list formats a TFF as TRCUST compatible source. The
  436. output is directed to STDOUT, which may be captured in a file using
  437. the redirection operator (>).
  438.  
  439. Trace formatting templates may be modified or supplemented using
  440. an editor and the TFF rebuilt using TRCUST.
  441.  
  442. N.B. TRCUST is used for generating TDFs and TFFs. The keyword,
  443. TP=@STATIC directs TRCUST solely to generate TFFs. Normally this is
  444. used with static trace but equally valid for dynamic trace where the
  445. tracepoints have already been defined.
  446.  
  447. N.B.  Large TDF and TFF files may take a minutes or two to list.  A
  448. degree of searching and cross-referencing has to take place before the
  449. listing is produced.  Consequently the may be a considerable pause
  450. before the listing is produced.
  451.  
  452. MAPTSF 1.7
  453. ----------
  454.  
  455. Syntax:
  456.          MAPTSF map_file [/MAJOR=major_code]
  457.                          [/MODNAME=name]
  458.                          [/MAXDATALENGTH=max_data_length]
  459.                          [/MINORSTART=minor_code]
  460.                          [/TEMPLATE=template_file]
  461.                          [/LOGSTACK=stack_bytes]
  462.                          [/EXCLUDE=string[*][,....]]
  463.                          [/INCLUDE=string[*][,....]]
  464.                          [/REGISTERS=reg[,reg]...]
  465.                          [/LOGRETURN]
  466.                          [/RETEP]
  467.                          [/CASESENSITIVE]
  468.                          [/TYPES]
  469.                          [/GROUPS=string[,.....]]
  470.  
  471. This utility will generate a TSF from a MAP file. One tracepoint is
  472. generated for each public code symbol. Optionally a return tracepoint
  473. may be generated for each public code symbol.  map_file is the only
  474. required parameter.  The remaining optional parameters have the
  475. following meaning:
  476.  
  477.     /MAJOR specifies the major code to be used in the MAJOR= statement
  478.     of the TSF . If omitted, TRCUST will select the default major code
  479.     of 1 when compiling the TSF.
  480.  
  481.     /MODNAME specifies the module name to be used in the MODNAME=
  482.     statement of the TSF. If omitted, MAPTSF will use the module name
  483.     that appears in the second line of the MAP file. Note, the MAP file
  484.     excludes the module extension. TRCUST will assume an extension of
  485.     .DLL if not specified.
  486.  
  487.     /MAXDATALENGTH specifies the MAXDATALENGTH= statement of the TSF.
  488.     If omitted, TRCUST will assume the default of 512 when compiling
  489.     the TSF.
  490.  
  491.     /MINORSTART specifies the first minor code. Subsequent
  492.     tracepoints have incremental minor codes. If omitted, the MINOR=
  493.     statement is not generated. TRCUST will assume an initial minor
  494.     code of 1 and increment for each tracepoint.
  495.  
  496.     /INCLUDE specifies a comma delimited list of case insensitive
  497.     strings used as inclusion criteria for public symbols.  An optional
  498.     trailing * signifies a generic match. If both /INCLUDE and /EXCLUDE
  499.     are specified then the logical OR of their criteria is used for
  500.     selection.
  501.     For example:
  502.  
  503.        /I=dos*,strupr inludes all public symbols beginning 'dos' or
  504.        equal to 'strupr'.
  505.  
  506.        /E=s* /I=strupr excludes all public symbols beginning 's' except
  507.        for 'strupr' and includes everything else.
  508.  
  509.     /EXCLUDE specifies a comma delimited list of case insensitive
  510.     strings used as exclusion criteria for public symbols.  An optional
  511.     trailing * signifies a generic match. If both /INCLUDE and /EXCLUDE
  512.     are specified then the logical OR of their criteria is used for
  513.     selection.
  514.     For example:
  515.  
  516.        /E=_*,dos* excludes all public symbols beginning '_' or 'dos'.
  517.  
  518.        /E=s* /I=strupr excludes all public symbols beginning 's' except
  519.        for 'strupr' and includes everything else.
  520.  
  521.     /CASESENSITIVE switch applies to /INCLUDE and /EXCLUDE. If specified
  522.     then the inculde and exclude strings will be match on a case-sensitve
  523.     basis.
  524.  
  525.     /LOGSTACK=n specifies the number of bytes of stack to log for entry
  526.     tracepoints. This causes the following TSF statements to be
  527.     generated for each entry tracepoint:
  528.  
  529.     for 16-bit code -
  530.         REGS=(SP,SS),
  531.         FMT="Stack pointer SS:SP=%A->",
  532.         MEM=(RSS+SP,D,n),
  533.         FMT="%R%W"
  534.  
  535.     for 32-bit code -
  536.         REGS=(ESP),
  537.         FMT="Stack pointer ESP=%F->",
  538.         MEM32=(FESP,D,n)
  539.         FMT="%R%F"
  540.  
  541.  
  542.     If /LOGSTACK is specified without a value then 16 bytes is assumed.
  543.  
  544.  
  545.     /LOGRETURN specifies that for each return tracepoint, the return
  546.     value in AX/EAX should be logged. This causes the following TSF
  547.     statements to be generated:
  548.  
  549.     for 16-bit code:
  550.         REGS=(AX)
  551.         FMT="Returns (ax) %W"
  552.  
  553.     for 32-bit code:
  554.         REGS=(EAX)
  555.         FMT="Returns (eax) %F"
  556.  
  557.  
  558.     /REGISTERS specifies one or more processor registers to be logged, each
  559.     separated by a comma.  The following register mnemonics are supported:
  560.  
  561.         AX,BX,CX,DX,CS,DS,ES,FS,GS,IP,SI,DI,SP,BP,FLAGS,
  562.         EAX,EBX,ECX,EDX,EIP,ESI,EDI,ESP,EBP,EFLAGS
  563.  
  564.  
  565.     /REGS may be used as a synonym for /REGISTERS.
  566.  
  567.  
  568.     /RETEP specifies that for each public entry-point in the MAP file, a
  569.     return tracepoint should be generated using the RETEP parameter of
  570.     the TRACE statement in the TSF. Note: RETEP is only processed by
  571.     TRCUST if the module has debugging information present. If this is
  572.     not the case then TRCUST (2.20) will ignore the RETEP parameter and
  573.     a warning message will be issued for the associated tracepoint.
  574.  
  575.     /TYPES
  576.         pre-defined types:
  577.  
  578.             PUB  = Public routines - names the begin upper case
  579.             (ignoring leading underscores)
  580.  
  581.             PRIV = Private routines - names the begin lower case
  582.             (ignoring leading underscores)
  583.  
  584.             PRE  = Entry tracepoint.
  585.  
  586.             POST = Exit tracepoint.
  587.  
  588.     /GROUPS
  589.  
  590.         Requests that each of the strings listed be used to define a
  591.         group. Tracepoints are assigned to a group according to
  592.         whether a group name matches the beginning of the tracepoint
  593.         name, ignoring case and leading underscore characters
  594.  
  595.     /TEMPLATE specifies a file where up to four template tracepoint
  596.     definitions may be specified, one for each of the following
  597.     categories:
  598.  
  599.        16-bit entry points
  600.        16-bit return points
  601.        32-bit entry points
  602.        32-bit return points
  603.  
  604.     The definitions are in a shortened form of the TRCUST TRACE
  605.     statement syntax. They are appended to each tracepoint of the
  606.     category to which they apply. All parameters other than MINOR and
  607.     DESC are permissible. TP and RETEP are specified as follows:
  608.  
  609.        TP=@16           signifies a 16-bit entry-point
  610.        TP=@16,RETEP     signifies a 16-bit return-point
  611.        TP=@32           signifies a 32-bit entry-point
  612.        TP=@32,RETEP     signifies a 32-bit return-point
  613.  
  614.     Only TP and RETEP may appear on the same line as the TRACE keyword.
  615.  
  616.  
  617.     For example:
  618.  
  619.         TRACE TP=@16
  620.               MEM=(SS:BP+8,I,0x10)
  621.               FMT="16-bytes of parameter 1: %R%W"
  622.  
  623.  
  624.      will append
  625.  
  626.               MEM=(SS:BP+8,I,0x10)
  627.               FMT="16-bytes of parameter 1: %R%W"
  628.  
  629.      to every 16-bit entry tracepoint definition.
  630.  
  631.  
  632. MAKETSF 1.1
  633. -----------
  634.  
  635. The purpose of MAKETSF is to extract dynamic trace definitions imbedded
  636. in C or ASM source file to which they relate. MAKETSF will also
  637. substitute line number information into those trace definions that are
  638. specified by line number and source file reference.
  639.  
  640. For example:
  641.  
  642.   TRACE TP=@myprog.c,1234
  643.  
  644. This specifies a tracepoint at location corresponding to line 1234
  645. in module whose source is "myprocg.c".
  646.  
  647. The problem with this type of specification is that line number
  648. reference will need to be updated whenever the source is changed.
  649.  
  650. MAKETSF allows the trace definitions to be imbedded in the source as
  651. comments but in extraction will generate the correct line number
  652. information. It does this be detecting the string "TP=@," or "TP=@ "
  653. and then inserting the line number specification. If the TP=
  654. keyword explicitly specifies an address expression then the trace
  655. definiton is extracted without modification.
  656.  
  657. To use line number references modules must be compiled and linked
  658. with debugging information. For CSET2 the compile option is /TI, and
  659. the LINK386 option is /DE.
  660.  
  661. Warning: Optimised code may not place tracepoints in the desired
  662. location.
  663.  
  664.  
  665. For example:
  666. in C:
  667.  
  668.     +-------------------------------------------+
  669.     |/***DT here is the header                  |
  670.     | * MODNAME=my.exe                          |
  671.     | * MAJOR=256                               |
  672.     | */                                        |
  673.     |                                           |
  674.     |                                           |
  675.     |                                           |
  676.     |void myproc(char * parm1) {                |
  677.     |int result;                                |
  678.     |                                           |
  679.     |.                                          |
  680.     |.                                          |
  681.     |.                                          |
  682.     |                                           |
  683.     |/***DT tracepoint definition               |
  684.     | *   TRACE TP=@,                           |
  685.     | *   DESC="a tracepoint",                  |
  686.     | *   MEM32=(.parm1,I,4),                   |
  687.     | *   MEM32=(.resut,D,4),                   |
  688.     | *   FMT="parm1=%p%f result=%f"            |
  689.     | */                                        |
  690.     |                                           |
  691.     |                                           |
  692.     |                                           |
  693.     +-------------------------------------------+
  694.  
  695.  
  696.  
  697.     in ASM:
  698.  
  699.     +-------------------------------------------+
  700.     |;***DT here is the header                  |
  701.     |;  MODNAME=my.exe                          |
  702.     |;  MAJOR=256                               |
  703.     |                                           |
  704.     |                                           |
  705.     |parm1 DD ?                                 |
  706.     |                                           |
  707.     |myproc proc                                |
  708.     |       push ebp                            |
  709.     |       move ebp,esp                        |
  710.     |.                                          |
  711.     |.                                          |
  712.     |.                                          |
  713.     |                                           |
  714.     |;***DT tracepoint definition               |
  715.     |;   TRACE TP=@,                            |
  716.     |;   DESC="a tracepoint",                   |
  717.     |;   MEM32=(.parm1,D,4),                    |
  718.     |;   FMT="parm1=%p%f"                       |
  719.     |                                           |
  720.     |                                           |
  721.     +-------------------------------------------+
  722.  
  723. Notes: The comment block must begin in column 1 with either
  724.        ;***DT or /***DT.
  725.  
  726.        If the C form is used then an * must appear in column 2 of each
  727.        line. A */ in column 2 ends the comment block.
  728.  
  729.        If the ASM form is used then a ; is required in every column.
  730.  
  731.        If TP=@ is coded then MAPTSF will insert the file name and line
  732.        number corresponding to the trace definition.
  733.  
  734. MAKETSF  will respond to the $include <filename> directive if coded
  735. in column 1. This is intended for use where multiple source modules
  736. comprise a single load module. A list of component source files can
  737. be coded in a single file using include statements then given to
  738. MAKETSF for processing. For example:
  739.  
  740.     +-------------------------------------------+
  741.     |;A sample include file for MAKETSF         |
  742.     |                                           |
  743.     |                                           |
  744.     |$include myprog.c                          |
  745.     |$include ..\asm\myproc.asm                 |
  746.     |$include ..\sub\subr.c  This is a comment  |
  747.     |                                           |
  748.     +-------------------------------------------+
  749.  
  750.  
  751. MAKETSF will ignore any line that is not part of a ;***DT or /***DT
  752. comment block or a $include statement.
  753.  
  754. TSF output form MAKETSF is written to the output file if specified,
  755. otherwise to STDOUT.
  756.  
  757. Messages are written to STDERR.
  758.  
  759. There are five switch options that MAKETSF supports:
  760.  
  761. -v verbose mode - this gives information about number of files read
  762.    and blocks processed.
  763.  
  764. -n no includes - this forces MAKETSF to ignore $include directives.
  765.  
  766. -p include source file path info  - this forces MAKETSF to retain
  767.    the full file specification from $include statements or the
  768.    command line input file in the TP= keyword.
  769.    The default is to strip path information.
  770.  
  771. -a append output to output file. Default - replace output file
  772.  
  773. -o<output> specifies the output file. The default is to direct output
  774.    to STDOUT.
  775.  
  776. The syntax for MAKTSF is:
  777.  
  778.     MAKETSF <options> input
  779.  
  780.  
  781. The DEBSTRIP utility may be use to remove debugging information after
  782. TRCUST has generated the TDF, alternatively re-link the load module
  783. without /DE. Removal of debugging information does not affect the
  784. validity of the TDF, however if the source is re-compiled then the
  785. TDF must be re-built.
  786.  
  787. The syntax for DEBSTRIP is:
  788.  
  789.     DEBSTRIP <-o debinfo> module
  790.  
  791. where <module> is the load module file to be stripped of debugging
  792. debugging information and <debinfo> is an optional output file that
  793. in which the stripped debugging information is placed. This file may
  794. be subsequently appended to the load module is TRCUST is to be
  795. re-used.
  796.  
  797.  
  798.  
  799.  
  800.  
  801. SELRPN
  802. ------
  803.  
  804. Syntax:
  805.  
  806.          SELRPN <minor code list>
  807.  
  808. Required parameters are the minor codes of interest.  Each code is
  809. entered in decimal by default.  An 'x' anywhere in a parameter means
  810. that parameter is hex.  You may enter as many codes as you want.  You
  811. may enter a range of codes by using smaller-larger syntax.  The letter
  812. 'q' anywhere in the parameters will cause the first 8 minor codes which
  813. are not used to be written to STDERR Redirect STDIN and STDOUT to use
  814. files.
  815.  
  816.  
  817. SELTSF
  818. ------
  819.  
  820. Syntax:
  821.  
  822.         SELTSF <minor code list>
  823.  
  824. Required parameters are the minor codes of interest.  Each code is
  825. entered in decimal, or optionally in hex.  An x anywhere in a parameter
  826. means that parameter is hex.  You may enter as many codes as you want.
  827. You may enter a range of codes by using smaller-larger syntax.
  828. Redirect STDIN and STDOUT to use files.
  829.  
  830.  
  831. TRACEF
  832. ------
  833.  
  834. Syntax:
  835.  
  836.        TRACEF <selection criteria>
  837.  
  838.  
  839. TraceFilter 0.7 reads formatted trace data saved by TRACEFMT, and
  840. creates an output file which either includes or excludes events based
  841. on process ids, major event codes, and CASE-SENSITIVE strings.
  842.  
  843. Each parameter is processed as follows:
  844. Special processing is done based on the first character.
  845.   if '?', you get this help.
  846.   if '=', the rest is a string which must be in the event.
  847.   if '!', the rest is a string which must NOT be in the event.
  848.   if '-' or '/', the parameter is NOT a filename.
  849.  
  850. The first parameter not already explained is the input file name.
  851. The default input file is "TRACEFMT.SAV"  .
  852. The second parameter not already explained is the output file name.
  853. The default is stdout, and is redirectable. Once the input and
  854. output files have been named, you no longer need '-' or '/'.
  855. You may (Include or EXclude) (processes and/or event codes),
  856. but using both Include and EXclude for either one is invalid.
  857. Parameter position 1 is the include/exclude flag.
  858. To include, use 'i'; to exclude, use either 'e' or 'x'.
  859. Parameter position 2 is the process/major code flag.
  860. For processes, use 'p'; for major event codes, use 'm'.
  861. Parameter position 3 is where the hex number begins.
  862.  
  863. Examples:
  864. TRACEF -IPC /IPD -IPE >MYFILE
  865. Input file is 'TRACEFMT.SAV', output file is MYFILE (created);
  866. output contains only events from processes 12,13,14 (decimal).
  867.  
  868. TRACEF tracefmt.sav myfile ipd ip0000e ipc      same as above.
  869.  
  870.  
  871. TRACEF what.now -IPC /IPD -IPE MYFILE
  872. Input file is 'what.now', output file is MYFILE (created);
  873.  
  874. TRACEF /xp2c -im10
  875. Input is TRACEFMT.SAV, output is stdout, and includes only major
  876. event 16 (decimal) for all processes except 44 (decimal).
  877.  
  878. TRACEF =Protection
  879. Output has only those events which contain
  880. the case-sensitive string "Protection".
  881.  
  882. The program logic is first to find out if the event is excluded
  883. by PID, major code, or negative string. If excluded, no output.
  884. Next, if "include" is specified, and the reason for inclusion
  885. is not in this event, try the next event.
  886. Last, if no decision is yet made, output the event.
  887. Note: lines longer than 255 characters are not processed properly.
  888. Note: you may specify up to 16 PIDs, 16 Major codes,
  889. 16 positive and 16 negative strings.
  890. Experimentation with known data is recommended.
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.                          Examples
  898.                          --------
  899.  
  900. In this example the tracepoint definition WinPostMsg is supplemented
  901. by having the caller's (caller to WinPostMsg) return address and stack
  902. address recorded.
  903.  
  904.  
  905. Notes:
  906.  
  907.    The recording of the caller's return address is often vital in
  908.    trying to determine which module was responsible for calling a
  909.    particular instance of an API. This address may be used with the
  910.    kernel debugger, dump formatter or Theseus2 to determine which DLL
  911.    issued an API. Or if the address is a private arena then PSTAT,
  912.    with the PID recorded in the trace entry will readily reveal which
  913.    process, hence executable, is calling a particular API.
  914.  
  915.    Recording the caller's stack address gives an indication of the
  916.    level of recursion when an API was called.
  917.  
  918. Step:
  919.  
  920. 1) The first step is to make a temporary directory then split
  921.    SYSTEM.TDF and SYSTEM.TFF:
  922.  
  923.    md temp
  924.    cd temp
  925.    syssplit c:\os2\system\trace.system.tdf
  926.    syssplit c:\os2\system\trace.system.tff
  927.  
  928.  
  929. 2) WinPostMsg is a PMWIN API so we list PMWIN.TDF
  930.  
  931.    tdflst pmwin.tdf > pmwin.rpn
  932.  
  933. 3) From the TDF listing we can see that the major code for PMWIN is
  934.    194 or 0xc2. (This information can also be obtained from the System
  935.    Trace Reference in the OS/2 Debugging Handbook.) This tells us that
  936.    the corresponding TFF is TRC00C2.TFF. This is listed to produce
  937.    PMWIN.TSF:
  938.  
  939.    tfflst trc00c2.tff > pmwin.tsf
  940.  
  941. 4) From PMWIN.TSF we can locate WinPostMsg pre-invocation. We see that
  942.    the minor code is 706 or 0x2c2. The formatting definition appears as
  943.    follows:
  944.  
  945.    /* start TP 0x02C2  */
  946.  
  947.    TRACE MINOR=0x02C2,
  948.          TP=@STATIC,
  949.          DESC="WINPOSTMSG  PRE-INVOCATION",
  950.          FMT="hwndDest=%P%F, msg=%F, mp1=%F, mp2=%F "
  951.  
  952.    /* end TP 0x02C2  */
  953.  
  954.    Searching for minor=0x02c3 in PMWIN.RPN we see that the tracepoint
  955.    definition appears as:
  956.  
  957.    minor=0x02C2
  958.    object=0x00000004
  959.    offset=0x00007B60
  960.    opcode=0x55
  961.    push w,0x0010
  962.    push esp
  963.    push d,0x00000004
  964.    add
  965.    log mrf
  966.  
  967. 5) Since WinPostMsg is a 32-bit API, and will therefore have been
  968. called as a Near 32-bit call, we will need to record the EIP from the
  969. first double word of the stack. The stack address can be recorded
  970. directly from the value in ESP. Thus the tracepoint definition in
  971. PMWIN.RPN will be modified to look like the following:
  972.  
  973.    minor=0x02C2
  974.    object=0x00000004
  975.    offset=0x00007B60
  976.    opcode=0x55
  977.    ; inserted instructions
  978.    push d,4          ; 4 bytes to log
  979.    push esp          ; address of data to log
  980.    log  mrf          ; log memory from flat address
  981.    push esp          ; save the stack address
  982.    log  dn,1         ; log 1 double word
  983.    ; end of inserts
  984.    push w,0x0010
  985.    push esp
  986.    push d,0x00000004
  987.    add
  988.    log mrf
  989.  
  990. 6) The formatting template for WinPostMsg is modified for the new
  991.    data:
  992.  
  993.    TRACE MINOR=0x02C2,
  994.          TP=@STATIC,
  995.          DESC="WINPOSTMSG  PRE-INVOCATION",
  996.          FMT="Return Address=%P%F, Stack Pointer=%F"
  997.          FMT="hwndDest=%P%F, msg=%F, mp1=%F, mp2=%F "
  998.  
  999. 7) Rebuild the TDF and copy to OS2\SYSTEM\TRACE
  1000.  
  1001.    dtrace buildtdf pmwin.rpn pmwin.tdf
  1002.    copy pmwin.tdf c:\os2\system\trace
  1003.  
  1004.    Note: PMWIN.TDF needs to be specified otherwise DTRACE will build a
  1005.    file called PMMERGE.TDF. This is because the tracepoints, along
  1006.    with PMGRE and PMSHAPI are actually applied to PMMERGE.DLL.
  1007.  
  1008. 8) Rebuild the TFF and copy to OS2\SYSTEM\TRACE
  1009.  
  1010.    trcust pmwin.tsf
  1011.    copy trc00c2.tff c:\os2\system\trace
  1012.  
  1013. 9) Activate tracing on WinPostMsg and format the trace buffer:
  1014.  
  1015.    trace on pmwin(706)
  1016.    trace /c
  1017.    tracefmt
  1018.  
  1019. 10) The WinPostMsg trace points now appear as
  1020.  
  1021. WINPOSTMSG  PRE-INVOCATION
  1022. EVENT#[0001]  PID[00AA]  MAJOR[C2]  MINOR[02C2]  LENGTH[001E] TIME: 11:55:55.44
  1023. Return Address=1BF96A41 , Stack Pointer=0007EF00
  1024. hwndDest=800001E5 , msg=00000020 , mp1=00001BBE , mp2=00000000
  1025.  
  1026. WINPOSTMSG  PRE-INVOCATION
  1027. EVENT#[0002]  PID[0004]  MAJOR[C2]  MINOR[02C2]  LENGTH[001E] TIME: 11:55:55.35
  1028. Return Address=1BECB470 , Stack Pointer=0003F574
  1029. hwndDest=8000000C , msg=00002F43 , mp1=00000001 , mp2=00000300
  1030.  
  1031.  
  1032.  
  1033. 11) In OS/2 version 2.x WinPostMsg is a 16-bit API, its definition
  1034. would have been modified as follows:
  1035.  
  1036.    TRACE MINOR=0x02C2,
  1037.          TP=@STATIC,
  1038.          DESC="WINPOSTMSG  PRE-INVOCATION",
  1039.          FMT="Entry SP:%W SS:%W, Return IP:%P%W CS:%W"
  1040.          FMT="%PMP2 = %D, MP1 = %D, MSG = %W, HWND = %A "
  1041.  
  1042.  
  1043.    minor=0x02C2
  1044.    major=0x00C2
  1045.    object=0x00000001
  1046.    offset=0x0000DE7E
  1047.    opcode=0x58
  1048.    ;inserted instructions
  1049.    push ss           ; save selector
  1050.    push esp          ; and offset of stack
  1051.    log wn,2          ; log these as two words
  1052.    push w,4          ; prepare to log 4 bytes of data
  1053.    push ss           ; save selector
  1054.    push esp          ; and offset of address of data
  1055.    log mrs           ; log the data (return cs:ip)
  1056.    ;end of inserted instructions
  1057.    push w,0x000E
  1058.    push ss
  1059.    push esp
  1060.    push w,0x0004
  1061.    add
  1062.    log mrs
  1063.  
  1064. ---------------------------------------------------------------------
  1065.  
  1066.  
  1067. Observations and warnings:
  1068. --------------------------
  1069.  
  1070. 1) Always save the original versions of SYSTEM.TFF and SYSTEM.TDF
  1071.  
  1072. 2) Re-work any modifications after applying system maintenance since
  1073.    the location of the tracepoints will probably have changes and new
  1074.    SYSTEM.TFF and SYSTEM.TDF files will have been shipped with the
  1075.    maintenance.
  1076.  
  1077. 3) TRACEFMT objects badly to a mismatched TFF. Be sure to rename
  1078.    SYSTEM.TFF and SYSTEM.TDF so as not to invoke old definitions.
  1079.  
  1080. 4) Be selective with tracing. Tracing unnecessary events will wrap the
  1081.    trace buffer. Also some system tracepoints may not be correctly
  1082.    formatted - this tends to upset TRACEFMT as noted in 3).
  1083.  
  1084. 5) OS/2 Version 4.0 ceases to ship SYSTEM.TDF and SYSTEM.TFF, since
  1085.    these have lead to maintenance problems. Instead their constituent
  1086.    TFF and TDF file will be shipped.
  1087.  
  1088. 6) The TRACEFMT facility shipped with OS/2 version 4 is a totally
  1089.    revised facility with many new functions. Some of the observations
  1090.    and restrictions noted above have been eliminated. In particular,
  1091.    a TFF path may be explicitly specified, furthermore SYSTEM.TFF
  1092.    will be used as a last resort.
  1093.  
  1094.  
  1095. Change History
  1096. -------------
  1097.  
  1098. 1.0 2nd Sept 96  Submitted to OS2TOOLS
  1099. 1.1 3rd Sept 96  Corrected function of SYSSPLIT when multipe TFF of
  1100.                  the same major code have been concatenated into
  1101.                  SYSTEM.TFF. Also added clarification on how
  1102.                  TRACE processes OS2KRNL.TDF.
  1103. 1.2 19th Sep 96  Fix PUSH ECS in TDFLST, and fix TDF generation in
  1104.                  SYSSPLIT caused by new TFF processing introduced in 1.1
  1105. 1.3              TDFLST: suppress null group/type specification
  1106.                  TDFLST: suppress redundant major code overrides
  1107. 1.4              fix push ecs error
  1108. 1.5 13th Jan 97  Non-DLL name support + new Merlin rpn commands
  1109. 1.6 29th Apr 97  SELRPN and SELTSF utilities added.
  1110. 1.7  7th May 97  MAPTSF and TRACEF added. Latest TRCUST
  1111.                  added. Information on latest TRACE and TRACEFMT added.
  1112. 1.8 17th May 97  MAPTSF 1.3 added to package. /REGS, /INCLUDE, /EXCLUDE, /TEMPLATE
  1113.                  switches added. Better parsing of map file added. Error messages
  1114.                  directed to STDERR.
  1115.                  SELRPN and SETST 0.8 - parameter scanning error fixed.
  1116. 1.9 10th Oct 97  Added /CASESENSITIVE to MAPTSF and improved code segment recognition.
  1117. 1.10 16th Jul 98 Shipped the latest tools at the Warp 3 FP 35 level++
  1118. 1.11 11th Aug 98 Update TRCUST, TDFLST and TFFLST. Add MAKETSF. Include updated
  1119.                  TRACE.DOC for FP35.
  1120. 1.12 22th Aug 98 Update MAPTSF, MAKETSF, TRCUST and TRACEFMT.
  1121.                  Fixes: Return entry points not correctly generated by MAPTSF.
  1122.                         MAKETSF supports additional switches.
  1123.                         TRCUST supports /L parameter, /P switch and fixes two traps.
  1124.                         TRCUST not allowing traceponints on TEST, NOT and NEG
  1125.                         instrucitons.
  1126.                         TRACEFMT Selection Filter logic incorrect with > or <
  1127.                         comparisons. Time specification was not handled correctly.
  1128.                         DTRACE: handling of BASEDEVs. Opcode validation added.
  1129.                                 Whitespace character handling added.
  1130.                         TRACE: handling of BASEDEVs.
  1131. 1.13 25th Sep 98 Release 1.12 to OS2TOOLS + 
  1132.                  Add: TRSTOP to enable TRSPOOL to be terminated from another
  1133.                  command window or CMD file.
  1134. 1.14 11th Nov 98 Release 1.14 to OS2TOOLS + 
  1135.                  Update TRCUST and TRACE.
  1136.