home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / findhit / findhit.doc < prev    next >
Text File  |  1998-11-15  |  7KB  |  203 lines

  1.                             FindHit 37.1
  2.  
  3.                                   by
  4.                             Douglas Keller
  5.  
  6.                 Copyright 1993 Synthetic Technologies
  7.  
  8.                            March 30, 1993
  9.  
  10.  
  11. 0. Introduction
  12. ---------------
  13.  
  14. FindHit is used to find the line numbers where Enforcer and Mungwall
  15. hits occur in C source code.  The idea for FindHit came from Doug
  16. Walker's Hitme program.
  17.  
  18. FindHit requires AmigaDOS 2.0, v37 or greater.
  19.  
  20.  
  21. 1. Contents
  22. -----------
  23.  
  24. FindHit     - FindHit v37.1.
  25. FindHit.doc - This doc file.
  26.  
  27. FindHit.c   - Sas/C 6.2 source for FindHit.
  28. headers.h   - System headers included by FindHit.c.
  29. lmkfile     - Sas/C 6.2 smake makefile.
  30.  
  31. offender     - Example program that cause Enforcer and Mungwall hits.
  32. offender.c   - Sas/C 6.2 source for offender.
  33. offender.map - Mapfile for offender produced by slink.
  34.  
  35.  
  36. 2. How to use FindHit
  37. ---------------------
  38.  
  39. FindHit takes the following command line arguments:
  40.  
  41.   MAPFILE/A,OFFSET/A/M,HUNK/N,DEL=DELETEOMDFILE/S
  42.  
  43.     MAPFILE/A  - Name of the mapfile from Slink, for the program
  44.                  that produced the hit.  The mapfile is the file Slink
  45.                  generates when the MAP <map_file_name>,h option is used.
  46.                  This argument is required.
  47.  
  48.     OFFSET/A/M - Offset that Enforcer or Mungwall reports that
  49.                  caused the hit.  This value is in hexadecimal
  50.                  with no leading $ or 0x.  Multiple offsets can
  51.                  be specified, but at least on offset is required.
  52.  
  53.     HUNK/N     - The hunk that Enforcer or Mungwall reports that
  54.                  caused the hit.  The hunk is not required and if
  55.                  it is no specified the default hunk will be zero.
  56.  
  57.     DEL=DELETEOMDFILE/S - This tells FindHit to delete the Omd file
  58.                  after it is done.  By default the Omd file is NOT
  59.                  deleted.  If FindHit is run and it finds an Omd file
  60.                  that is not out of date it will use the Omd file
  61.                  without running Omd again.  The Omd file is generated
  62.                  in t:.
  63.  
  64. Here are some examples of running FindHit:
  65.  
  66.   1> findhit offender.map 270
  67.  
  68.      Found offset 0x00000270 in "offender.c", on line 11
  69.  
  70.      Searchs offender.map for offset 270 hex in hunk 0.  The output
  71.      shows the hit was found on line 11 of offender.c.
  72.  
  73.   1> findhit rush.map 1ac44 hunk 2 delomdfile
  74.  
  75.      Found offset 0x0001AC44 in "req_palette.c", on line 278
  76.  
  77.      Searchs rush.map for offset 1ac44 hex in hunk 2, and deletes
  78.      the omd file after it is done.
  79.  
  80.   1> findhit magic.map 988 4ac8 857c
  81.  
  82.      Found offset 0x00000988 in "magic.c", on line 173
  83.      Found offset 0x00004AC8 in "addgads.c", on line 470
  84.      Found offset 0x0000857C in "cmds2.c", on line 310
  85.  
  86.      Searchs magic.map for the three offsets 988, 4ac8, and 857c.
  87.  
  88.  
  89. 3. Using FindHit with Enforcer, Mungwall, and SegTracker
  90. --------------------------------------------------------
  91.  
  92. For best results you should be using the latest versions of Enforcer
  93. and Mungwall which take advantage of SegTracker.
  94.  
  95. When the included offender program is run it produces the following
  96. hits.
  97.  
  98.   BYTE-WRITE to  00000000        data=61         PC: 07D20D9A
  99.   USP:  07CB80AC SR: 0000 SW: 0711  (U0)(-)(-)  TCB: 079DAA80
  100.   Data: 07CB80AC 00000002 000003ED 00001008 00000001 0000002B 0000003B 079DAADC
  101.   Addr: 07C379AA 079BAA00 07AE44C9 07AE44CC 07C37768 00000000 0780DF24 --------
  102.   Stck: 07C379AE 0780DF24 07D216BA 00000001 07C379AA 07D21392 0000FFFF 079DBB1C
  103.   Stck: 079DAA80 00F952CA 07800810 00000000 07CB80EC 00008011 01E799F9 00000000
  104.   SegT: 07D20D9A - "offender"  Hunk 0000 Offset 0000028A
  105.   SegT: 07C379AE - "offender"  Hunk 0001 Offset 00000246
  106.   SegT: 07D216BA - "offender"  Hunk 0000 Offset 00000BAA
  107.   SegT: 07C379AA - "offender"  Hunk 0001 Offset 00000242
  108.   SegT: 07D21392 - "offender"  Hunk 0000 Offset 00000882
  109.   Name: "New_WShell"  CLI: "offender"  Hunk 0000 Offset 0000028A
  110.    
  111.   BYTE-WRITE to  00000000        data=62         PC: 07D20D80
  112.   USP:  07CB80A4 SR: 0000 SW: 0711  (U0)(-)(-)  TCB: 079DAA80
  113.   Data: 07CB80AC 00000002 000003ED 00001008 00000001 0000002B 0000003B 079DAADC
  114.   Addr: 07C379AA 079BAA00 07AE44C9 07AE44CC 07C37768 00000000 0780DF24 --------
  115.   Stck: 00000000 07D20D9C 07C379AE 0780DF24 07D216BA 00000001 07C379AA 07D21392
  116.   Stck: 0000FFFF 079DBB1C 079DAA80 00F952CA 07800810 00000000 07CB80EC 00008011
  117.   SegT: 07D20D80 - "offender"  Hunk 0000 Offset 00000270
  118.   SegT: 07D20D9C - "offender"  Hunk 0000 Offset 0000028C
  119.   SegT: 07C379AE - "offender"  Hunk 0001 Offset 00000246
  120.   SegT: 07D216BA - "offender"  Hunk 0000 Offset 00000BAA
  121.   SegT: 07C379AA - "offender"  Hunk 0001 Offset 00000242
  122.   SegT: 07D21392 - "offender"  Hunk 0000 Offset 00000882
  123.   Name: "New_WShell"  CLI: "offender"  Hunk 0000 Offset 00000270
  124.  
  125.   Mismatched FreeMem size 99!
  126.   Original allocation: 100 bytes from A:0x7D20DA8 C:0x780DF24 Task 0x79DAA80
  127.   Testing with original size.
  128.    
  129.     FreeMem(0x7C37650,99) attempted by "offender" (task 0x79DAA80)
  130.     from A:0x7D20DB2 C:0x780DF24 SP:0x7CB80A8
  131.   A:0x07D20DB2 in seglist of "offender"   Hunk 0000 Offset 000002A2
  132.  
  133.  
  134. The first hit is in hunk 0 at offset 28A, if the follow is typed:
  135.  
  136.     1> findhit offender.map 28a
  137.  
  138.        Found offset 0x0000028A in "offender.c", on line 20
  139.  
  140. This shows the hit is in offender.c on line 20.
  141.  
  142. The second hit is a little more interesting, it is in a
  143. subroutine.  The second SegT line that Enforcer reports is:
  144.  
  145.     SegT: 07D20D9C - "offender"  Hunk 0000 Offset 0000028C
  146.  
  147. This is the offset in offender where the function that caused the hit
  148. is called from.  This SegT information can be helpful if Enforcer does
  149. not find the Name of the program that caused the hit.
  150.  
  151. The last hit is from Mungwall, it shows the FreeMem() that has the
  152. problem is in hunk 0 offset 2a2.
  153.  
  154.  
  155. 4. How FindHit Works
  156. --------------------
  157.  
  158. FindHit search through the mapfile that Slink generates to find the
  159. object file that has the problem.  FindHit then executes Omd on the C
  160. source and the object file to disassemble it.  The base of the object
  161. file, from the mapfile, plus the offset into the Omd file should equal
  162. the offset that Enforcer or Mungwall reports.
  163.  
  164. Since Omd is used to disassemble the code, code must be compiled with
  165. a debug level of at least DEBUG=LINE.
  166.  
  167. If the DELETEOMDFILE option is not given the Omd file is generated in
  168. T: and is not deleted ater FindHit is done with it.  The next time
  169. FindHit is run it checks the date of the Omd file and the object file
  170. to see of the Omd file needs to be regenerated.  If the Omd file is
  171. newer then the object file, FindHit uses the Omd file that it finds in
  172. T:, else it generates the Omd file again.
  173.  
  174. If you prefer the default to delete the Omd file, the following alias
  175. can be made:  alias FindHit "FindHit deleteomdfile".
  176.  
  177.  
  178. 5. About the Source
  179. -------------------
  180.  
  181. Sas/C 6.2 source is included.  The source does not use any startup
  182. code and there is not writable global data, so it is reentrant.
  183.  
  184.  
  185. 6. Legal junk
  186. -------------
  187.  
  188. Permission is granted to distribute this program and its documentation
  189. for non-commercial purposes as long as the copyright notices are not
  190. removed.  This program may not be distributed for a profit without
  191. permission from Doug Keller.  Fred Fish has permission to distribute
  192. this program as part of the Fred Fish library.
  193.  
  194.  
  195. 7. Bugs and Info
  196. ----------------
  197.  
  198. If you would like to get in touch with me I can be reached on the
  199. following:
  200.  
  201.             Bix : dkeller
  202.         Internet: dkeller@vnet.ibm.com
  203.