home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CDPD Public Domain Collection for CDTV 3
/
CDPDIII.bin
/
pd
/
programming
/
debug-utils
/
findhit
/
findhit.doc
< prev
next >
Wrap
Text File
|
1993-03-30
|
7KB
|
203 lines
FindHit 37.1
by
Douglas Keller
Copyright 1993 Synthetic Technologies
March 30, 1993
0. Introduction
---------------
FindHit is used to find the line numbers where Enforcer and Mungwall
hits occur in C source code. The idea for FindHit came from Doug
Walker's Hitme program.
FindHit requires AmigaDOS 2.0, v37 or greater.
1. Contents
-----------
FindHit - FindHit v37.1.
FindHit.doc - This doc file.
FindHit.c - Sas/C 6.2 source for FindHit.
headers.h - System headers included by FindHit.c.
lmkfile - Sas/C 6.2 smake makefile.
offender - Example program that cause Enforcer and Mungwall hits.
offender.c - Sas/C 6.2 source for offender.
offender.map - Mapfile for offender produced by slink.
2. How to use FindHit
---------------------
FindHit takes the following command line arguments:
MAPFILE/A,OFFSET/A/M,HUNK/N,DEL=DELETEOMDFILE/S
MAPFILE/A - Name of the mapfile from Slink, for the program
that produced the hit. The mapfile is the file Slink
generates when the MAP <map_file_name>,h option is used.
This argument is required.
OFFSET/A/M - Offset that Enforcer or Mungwall reports that
caused the hit. This value is in hexadecimal
with no leading $ or 0x. Multiple offsets can
be specified, but at least on offset is required.
HUNK/N - The hunk that Enforcer or Mungwall reports that
caused the hit. The hunk is not required and if
it is no specified the default hunk will be zero.
DEL=DELETEOMDFILE/S - This tells FindHit to delete the Omd file
after it is done. By default the Omd file is NOT
deleted. If FindHit is run and it finds an Omd file
that is not out of date it will use the Omd file
without running Omd again. The Omd file is generated
in t:.
Here are some examples of running FindHit:
1> findhit offender.map 270
Found offset 0x00000270 in "offender.c", on line 11
Searchs offender.map for offset 270 hex in hunk 0. The output
shows the hit was found on line 11 of offender.c.
1> findhit rush.map 1ac44 hunk 2 delomdfile
Found offset 0x0001AC44 in "req_palette.c", on line 278
Searchs rush.map for offset 1ac44 hex in hunk 2, and deletes
the omd file after it is done.
1> findhit magic.map 988 4ac8 857c
Found offset 0x00000988 in "magic.c", on line 173
Found offset 0x00004AC8 in "addgads.c", on line 470
Found offset 0x0000857C in "cmds2.c", on line 310
Searchs magic.map for the three offsets 988, 4ac8, and 857c.
3. Using FindHit with Enforcer, Mungwall, and SegTracker
--------------------------------------------------------
For best results you should be using the latest versions of Enforcer
and Mungwall which take advantage of SegTracker.
When the included offender program is run it produces the following
hits.
BYTE-WRITE to 00000000 data=61 PC: 07D20D9A
USP: 07CB80AC SR: 0000 SW: 0711 (U0)(-)(-) TCB: 079DAA80
Data: 07CB80AC 00000002 000003ED 00001008 00000001 0000002B 0000003B 079DAADC
Addr: 07C379AA 079BAA00 07AE44C9 07AE44CC 07C37768 00000000 0780DF24 --------
Stck: 07C379AE 0780DF24 07D216BA 00000001 07C379AA 07D21392 0000FFFF 079DBB1C
Stck: 079DAA80 00F952CA 07800810 00000000 07CB80EC 00008011 01E799F9 00000000
SegT: 07D20D9A - "offender" Hunk 0000 Offset 0000028A
SegT: 07C379AE - "offender" Hunk 0001 Offset 00000246
SegT: 07D216BA - "offender" Hunk 0000 Offset 00000BAA
SegT: 07C379AA - "offender" Hunk 0001 Offset 00000242
SegT: 07D21392 - "offender" Hunk 0000 Offset 00000882
Name: "New_WShell" CLI: "offender" Hunk 0000 Offset 0000028A
BYTE-WRITE to 00000000 data=62 PC: 07D20D80
USP: 07CB80A4 SR: 0000 SW: 0711 (U0)(-)(-) TCB: 079DAA80
Data: 07CB80AC 00000002 000003ED 00001008 00000001 0000002B 0000003B 079DAADC
Addr: 07C379AA 079BAA00 07AE44C9 07AE44CC 07C37768 00000000 0780DF24 --------
Stck: 00000000 07D20D9C 07C379AE 0780DF24 07D216BA 00000001 07C379AA 07D21392
Stck: 0000FFFF 079DBB1C 079DAA80 00F952CA 07800810 00000000 07CB80EC 00008011
SegT: 07D20D80 - "offender" Hunk 0000 Offset 00000270
SegT: 07D20D9C - "offender" Hunk 0000 Offset 0000028C
SegT: 07C379AE - "offender" Hunk 0001 Offset 00000246
SegT: 07D216BA - "offender" Hunk 0000 Offset 00000BAA
SegT: 07C379AA - "offender" Hunk 0001 Offset 00000242
SegT: 07D21392 - "offender" Hunk 0000 Offset 00000882
Name: "New_WShell" CLI: "offender" Hunk 0000 Offset 00000270
Mismatched FreeMem size 99!
Original allocation: 100 bytes from A:0x7D20DA8 C:0x780DF24 Task 0x79DAA80
Testing with original size.
FreeMem(0x7C37650,99) attempted by "offender" (task 0x79DAA80)
from A:0x7D20DB2 C:0x780DF24 SP:0x7CB80A8
A:0x07D20DB2 in seglist of "offender" Hunk 0000 Offset 000002A2
The first hit is in hunk 0 at offset 28A, if the follow is typed:
1> findhit offender.map 28a
Found offset 0x0000028A in "offender.c", on line 20
This shows the hit is in offender.c on line 20.
The second hit is a little more interesting, it is in a
subroutine. The second SegT line that Enforcer reports is:
SegT: 07D20D9C - "offender" Hunk 0000 Offset 0000028C
This is the offset in offender where the function that caused the hit
is called from. This SegT information can be helpful if Enforcer does
not find the Name of the program that caused the hit.
The last hit is from Mungwall, it shows the FreeMem() that has the
problem is in hunk 0 offset 2a2.
4. How FindHit Works
--------------------
FindHit search through the mapfile that Slink generates to find the
object file that has the problem. FindHit then executes Omd on the C
source and the object file to disassemble it. The base of the object
file, from the mapfile, plus the offset into the Omd file should equal
the offset that Enforcer or Mungwall reports.
Since Omd is used to disassemble the code, code must be compiled with
a debug level of at least DEBUG=LINE.
If the DELETEOMDFILE option is not given the Omd file is generated in
T: and is not deleted ater FindHit is done with it. The next time
FindHit is run it checks the date of the Omd file and the object file
to see of the Omd file needs to be regenerated. If the Omd file is
newer then the object file, FindHit uses the Omd file that it finds in
T:, else it generates the Omd file again.
If you prefer the default to delete the Omd file, the following alias
can be made: alias FindHit "FindHit deleteomdfile".
5. About the Source
-------------------
Sas/C 6.2 source is included. The source does not use any startup
code and there is not writable global data, so it is reentrant.
6. Legal junk
-------------
Permission is granted to distribute this program and its documentation
for non-commercial purposes as long as the copyright notices are not
removed. This program may not be distributed for a profit without
permission from Doug Keller. Fred Fish has permission to distribute
this program as part of the Fred Fish library.
7. Bugs and Info
----------------
If you would like to get in touch with me I can be reached on the
following:
Bix : dkeller
Internet: dkeller@vnet.ibm.com