home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / mungwall / mungwall.doc < prev    next >
Text File  |  1996-05-23  |  16KB  |  379 lines

  1. Mungwall 37.71 (c) 1988-93 Commodore-Amiga, Inc. All Rights Reserved
  2. Munglist 37.12 (c) 1992-93 Commodore-Amiga, Inc. All Rights Reserved
  3.  
  4. Mungwall munges memory and watches for illegal FreeMem's.
  5. Mungwall is especially useful in combination with Enforcer.
  6. Output is either serial or parallel (mungwall.par), or local by
  7. using both mungwall and a local serial debug capture tool such
  8. as Sushi.
  9.  
  10. Munglist may be used in conjunction with Mungwall, and allows you to
  11. list the owners and allocation information for memory blocks which are
  12. in-use, and perform other memory functions.  See Munglist.doc after
  13. Mungwall.doc.
  14.  
  15.  
  16. Mungwall.doc
  17. ============
  18.  
  19. Revisions
  20. =========
  21.  
  22. (Thanks to Vic Wagner for SAS-6ifying and fixing some bugs!)
  23.  
  24. $Log: mungwall.doc,v $
  25. Revision 37.71  1993/10/02  03:48:13  Vic
  26. Changed - the way the length of the task/process name is calculated.
  27.           There was a slight bug if the name had no 'path' in it and
  28.           was not terminated with a null which could cause problems
  29.           if some arguments had originally been given to the program
  30.  
  31. Revision 37.70  1993/10/01  22:59:35  Vic
  32. Deleted - from this document all the Munglist stuff (it has it's own document
  33.           now.
  34. Added   - RCS Id and Log information for future tracking
  35. Changed - the munging of C0DEF00D to C0DEFEED which was installed in 37.49
  36.           should now work.
  37.         - all other changes had to do with 'moving' to SAS C 6.x
  38.  
  39.  
  40. Since 37.49 MungWall, NAMETAG option tags each allocation with the name
  41. of the allocator.  The new "MUNGLIST" program examines used memory areas
  42. for mungwall tag info, and outputs a list of who owns the various
  43. pieces of allocated memory, their sizes, etc.  If you have used the
  44. NAMETAG option of MungWall, this list will include the name of the
  45. task or command that allocated the memory.  Note that certain
  46. allocations belonging to your program may be displayed as belonging
  47. to another task (such as the task of a disk device that you
  48. locked a file on or accessed).
  49.  
  50. Mungwall 37.51 adds an AvailMem wedge which reduces reported available
  51. memory by the size which Mungwall will add to any allocation.  It also
  52. correct a problem which had caused the NAMETAG option to crash on a
  53. 68000.
  54.  
  55. Mungwall 37.52 fixes Enforcer hits in task name comparisons and adds
  56. better A6 handling when calling the real memory functions.
  57.  
  58. Mungwall 37.53 should finally fix mungwall crashes on 68000 when
  59. using taskname-related options.
  60.  
  61. Mungwall 37.54 - some fixes to output during initialization
  62.  
  63. Mungwall 37.55 - fixes a bug in Mungwall where last chunk of memory
  64.    could be lost, and fixes a similar bug in munglist which could occur
  65.    if munglist's buffer filled.  Also added munglist bufsize argument.
  66.  
  67. Mungwall 37.57 - stops null terminating cli_CommandName in place which
  68.    makes mungwall name options again compatible with DMAKE and ARexx
  69.    scripts with 1-character names.  Adds new SHOWFAIL option which
  70.    tells Mungwall to report all failed allocations.  Changes the output
  71.    text "(at 0xhhhhhhh)" to "(task 0xhhhhhhh)" to be easier to understand.
  72.  
  73. Mungwall 37.58 - adds matching NO and UPDATE options for SHOWSTACK,
  74.    NAMETAG, and SHOWFAIL.
  75.  
  76. Mungwall 37.60 - adds SHOWPC dump of memory at A: and C: caller addresses
  77.    and a matching NOSHOWPC option.  Does not show a supposed PC address
  78.    if it is not RAM according to TypeOfMem().  This is to help prevent
  79.    enforcer hits or worse, possible reads (or read-triggered writes)
  80.    to hardware registers.
  81.  
  82. Mungwall 37.61 and Munglist 37.4 - Add the important capability for
  83.    Mungwall to distinguish between old mungwall cookies left over in
  84.    memory after rebooting, and new ones.  The mungwall info area on
  85.    each allocation has been enlarged by 8 bytes and now contains a
  86.    second per-session cookie which is based on the datestamp
  87.    when mungwall is first started.   Munglist has been enhanced
  88.    to show the addresses applications received when they allocated
  89.    memory, not the address of the larger piece mungwall allocated.
  90.    Some changes to output format.
  91.  
  92. Mungwall 37.62 implements a new default rolling fill character for
  93.    the walls surrounding memory allocations.  Each allocation gets
  94.    a new fill character between $81 and $FF.  This allows Mungwall to
  95.    generally catch errors where too much memory has been copied
  96.    from one allocation to another.  Note that the explicit FILLCHAR
  97.    option of Mungwall now disables the rolling fillchar feature.
  98.    Do not use the FILLCHAR option if you want the protection of the
  99.    rolling fill char.  Some changes to output format.
  100.  
  101. Mungwall 37.63 adds SHOWHUNK and NOSHOWHUNK options.  With SHOWHUNK,
  102.    mungwall will attempt to show the hunk and offset for the probable
  103.    C or Asm PC addresses of the caller generating the hit if the PC
  104.    address is in RAM and also within the seglist of the caller's process.
  105.  
  106. Mungwall 37.64 adds SegTracker support.  If SHOWHUNK is option is on,
  107.    if SegTracker is installed, mungwall will get hunk/offset info
  108.    from SegTracker, else mungwall can only check if the probable
  109.    PC addresses are in the calling process's own SegList.
  110.  
  111. Mungwall 37.65 - Fixes output where decimal size was being printed
  112.    as if it were a hex number 0xnnnn  (should be just nnnn)
  113.  
  114. Mungwall 37.67 - Adds TIMESTAMP option
  115.  
  116. Mungwall 37.68 - Adds timestamp output to hits and snoops if TIMESTAMP on
  117.  
  118. Mungwall 37.69 - Modified for new Munglist MARK option
  119.  
  120.  
  121. What Mungwall Does
  122. ==================
  123.  
  124. Memory munging:
  125.  
  126.  - Except when Enforcer is running, location 0 is set to $C0DEDBAD, i.e.
  127.    programs referencing location zero will not f.e. find a null string.
  128.  
  129.  - On startup all free memory is munged with $ABADCAFE. If this number
  130.    shows up, someone is referencing memory in the free list.
  131.  
  132.  - Except when MEMF_CLEAR is set, memory is pre-munged on allocation with
  133.    $DEADFOOD. When this is used in an Enforcer report, the caller is
  134.    allocating memory and doesn't initialize it before using it. Note that
  135.    only memory which has a cookie attached will be pre-munged.
  136.  
  137.  - Memory is filled with $DEADBEEF before it is freed, encouraging
  138.    programs reusing free'ed memory to crash.
  139.  
  140. Memory watching:
  141.  
  142. Mungwall places a magic cookie before the memory allocation.
  143. Along with a wall of bytes on either side of the allocation to keep an
  144. eye on the memory just before or after the allocation. If the
  145. memory wall is trashed, mungwall complains and shows the damaged area.
  146. If memory is trashed so bad that the cookie is completely gone, Mungwall
  147. will not consider it a walled memory allocation and lets it go. Changes
  148. are you'll be corrupting the memory list and/or overwriting other memory
  149. allocation and crash soon after that. If a mungwall hit occurs, memory
  150. will not be munged or free'ed, to give you a change to look at what was
  151. written there.
  152.  
  153. Both null pointer FreeMem()'s and null sized Alloc/FreeMem()'s trigger
  154. mungwall. Mungwall also gets upset when a memoryblock is free'ed with a
  155. size different from the one used for allocating the memoryblock, and will
  156. say so. The integrity of the walls will be tested according to the size
  157. specified on allocation time, but will not be free'ed.
  158.  
  159. Pointers passed to FreeMem() will be rejected if they are non-longword
  160. alligned. Thus possible catching bogus pointers otherwise left untouched
  161. by mungwall.
  162.  
  163. Unless a specific task(s) is watched and that task leaves before mungwall
  164. does, mungwall will always lose some memory.
  165.  
  166. NOTES:
  167.  
  168. Other debugging tools which SetFunction() AllocMem() and/or
  169. FreeMem() and JSR to what they think is the old memory routine,
  170. should be run BEFORE mungwall. Mungwall needs to know the returnaddress
  171. of the initial caller. Running other debugging tools after mungwall
  172. will result in false reports about layers.library and invalid
  173. mungwall reports about the caller. The 'scratcher' for example must
  174. be run before mungwall, 'memoration' can be run afterwards, since it
  175. JMP's.
  176.  
  177. When mungwall is being stopped, the walls around the original allocations
  178. which are not free'ed at that point, will never get free'ed, only the block
  179. within. Thus causing memory fragmentation and memory loss.
  180. In addition, stopping and restarting mungwall can cause numerous
  181. bogus mungwall hits if applications allocate uncleared memory
  182. (containing unlceared mungwall cookies) while mungwall is off and then
  183. free it when mungwall is back on.
  184.  
  185.  
  186. Memory allocations larger than 3 gigabytes will not be marked by mungwall.
  187.  
  188. Usage: Mungwall [UPDATE] [TASK name] [(NO)WAIT] [(NO)SHOWFAIL]
  189.   [(NO)SNOOP] [INFO] [(NO)SHOWSTACK] [(NO)SHOWPC] [(NO)SHOWHUNK]
  190.   [(NO)NAMETAG] [(NO)TIMESTAMP] [PRESIZE n] [POSTSIZE n] [FILLCHAR 0xHH]
  191.  
  192. TASK name   - Watch only the task(s), or all but the task(s) specified
  193.               with 'name'. Multiple tasknames are indicated by placing
  194.               a '|' between the names. If the names are preceeded by an
  195.               exclamation mark, all tasks except the ones indicated are
  196.               tracked. ALL is a reserved name, indicating all tasks
  197.               should be tracked. Default ALL.
  198.  
  199. PRESIZE     - Size of wall before memory allocation in bytes. Minimum 4,
  200.               maximum 64. Default 32.
  201.  
  202. POSTSIZE    - Size of wall after memory allocation in bytes. Minimum 4,
  203.               maximum 64. The actual number of bytes after the allocation
  204.               may vary slightly, since it's upped to the nearest longword.
  205.               Default 32.
  206.  
  207. FILLCHAR n  - Character to build the memory wall with. Can be indicated
  208.               both hexadecimal and decimal. Default is a rolling fillchar
  209.           which uses a new odd number between $81 and $FF for each
  210.           new allocation.  This makes it possible for Mungwall to
  211.           usually catch errors where too much memory is copied
  212.           from one allocation to another.  Specifying a FILLCHAR
  213.           disables the default rolling fillchar feature.
  214.           
  215. SNOOP       - Produce snoop compatible output. No snoop output is given
  216.               for illegal FreeMem's. Default OFF. Layers AllocMem's and
  217.               FreeMem's are never snooped. SNOOP is particulary useful
  218.               in combination with TASK. Snoop output can be filtered
  219.               with 'snoopstrip' to find the origin of memory loss.
  220.  
  221. WAIT        - Halt task causing a hit and wait for Ctrl-C. Make sure you
  222.             - can issue a break to the task. WAIT can be used without
  223.               specifying a specific taskname to watch. Default OFF.
  224.  
  225. INFO        - Show configuration information.
  226.  
  227. SHOWSTACK   - Show 32 longwords of the stack whenever a hit/snoop occurs
  228.  
  229. NAMETAG     - Tag each allocation with allocating task or command's name
  230.  
  231. SHOWFAIL    - Tells mungwall to report all memory allocation failures
  232.  
  233. SHOWPC        - Show a dump of memory at the A: and C: possible PC
  234.           (program counter) addresses (one should be correct)
  235.               Does not show a supposed PC address if it is not RAM
  236.               according to TypeOfMem().  This is to help prevent enforcer
  237.               hits or worse, possible reads (or read-triggered writes)
  238.               to hardware registers.
  239.  
  240. SHOWHUNK    - On a hit or snoop, if the probable PC address of a reported
  241.           call to AllocMem or FreeMem is within the calling process's
  242.           seglist, attempt to show hunk and offset information.
  243.  
  244. TIMESTAMP   - Timestamp each allocation with system time
  245.  
  246. UPDATE      - Indicates an already running mungwall task should be up-
  247.               dated with new parameters. Presize, postsize and fillchar
  248.               can never be updated.  NOTE - when doing an UPDATE, the
  249.           UPDATE option must be the first command line arg
  250.  
  251. The following are extra updating parameters.
  252.  
  253. NOSNOOP     - Turn snooping off.
  254.  
  255. NOWAIT      - No longer halt a task in case of an error.
  256.  
  257. NONAMETAG   - Turn off taskname storage
  258.  
  259. NOSHOWSTACK - Turn off showstack option
  260.  
  261. NOSHOWFAIL  - Turn off option that displays memory allocation failures
  262.  
  263. NOSHOWPC    - Turn off option that displays dump of memory at caller PC
  264.  
  265. NOSHOWHUNK  - Turn off options that displays hunk and offset information
  266.  
  267. NOTIMESTAMP - Turn off the timestamping feature
  268.  
  269.  
  270.  
  271.  
  272. Munglist.doc
  273. ============
  274.  
  275. Munglist examines memory for in-use pieces of memory which were allocated
  276. while mungwall was active.  Mungwall saves special information at the start
  277. of each allocation.  Munglist finds this information and outputs it,
  278. providing a fairly accurate list of currently-in-use pieces of memory
  279. and who allocated them.
  280.  
  281. Revisions
  282. =========
  283.  
  284. $Log: munglist.doc,v $
  285. ; Revision 37.12  1993/10/01  23:09:52  Vic
  286. ; Added   - ONLY option
  287. ;         - MARK/SINCE MARK description to the 'usage'
  288. ;         - RCS Id and Log information for future tracking
  289. ; Changed - only slightly the ordering of this document (put what Munglist
  290. ;           is as the 1st paragraph)
  291. ;         - separated this document from the combined document with Mungwall
  292. ;
  293.  
  294. MungList 37.6 adds serial-output memory checking and remunging options
  295.  
  296. Munglist 37.8 adds SHOWTIME option (displays TIMESTAMP above)
  297.  
  298. Munglist 37.10 adds MARK and SINCE MARK options
  299.  
  300. Munglist 37.11 removes debugging line, adds TOTAL taskname option
  301.  
  302.  
  303.  
  304. Usage: munglist [buffsize] [SHOWHUNK] [CHECK] [REMUNGE] [SHOWTIME] [-tickdelay]
  305.                 [MARK] [SINCE MARK] [ONLY|TOTAL taskname]
  306. Requires mungwall 37.69+.  SHOWTIME requires V37+ and mungwall 37.69+.
  307. Output errors possible for memory freed and/or reallocated while listing
  308. Good SHOWHUNK output requires SegTracker and still-loaded allocating program
  309. CHECK/REMUNGE are serial output and turn off listing. tickdelay is for CHECK
  310. MARK saves the current time for use with:
  311. SINCE MARK lists only allocations which have occured SINCE the MARKed time
  312. ONLY Taskname list ONLY allocations by that task (implies TOTAL also)
  313. TOTAL Taskname just totals up the amount currently allocated by that task
  314. Default buffsize is 8000
  315.  
  316.  
  317. buffsize option
  318.  
  319. The default 8000 byte buffer used by munglist may not be large enough to
  320. capture a large or fragmented memory list.  To provide a different
  321. buffsize, just pass the size in bytes as the first argument.
  322.  
  323. SHOWHUNK option
  324.  
  325. With the SHOWHUNK option (and SegTracker from The Enforcer archive running),
  326. Munglist will try to show possible Hunk and Offset from which memory was
  327. allocated.  This can be inexact since one program may have forgotten to
  328. free memory, and another program may now be loaded in the same location
  329. the old program was unloaded from.
  330.  
  331. SHOWTIME option
  332.  
  333. If TIMESTAMP was specifed for Mungwall, the SHOWTIME option of Munglist
  334. can show you the time each allocation was made.
  335.  
  336. MARK option
  337.  
  338. Tells MungList to mark the current time, for use by SINCE MARK.
  339. If this is the only argument passed, munglist will mark and exit.
  340. Mark (m) is now also offered as an option when munglist presents
  341. its interactive prompt after listing.
  342.  
  343. SINCE MARK option
  344.  
  345. Tells MungList to only list allocations made since the MARK time.
  346. When done, the new prompt will offer choices to quit, mark again,
  347. run again.  This allows you to just list recent allocations.
  348. SINCE MARK may be used in combination with the MARK option to avoid
  349. an overly long first list.
  350.  
  351. TOTAL taskname
  352.  
  353. This tells munglist to just total up the amount of memory allocated
  354. by the named task.  This can be used with the SINCE MARK option.
  355.  
  356.  
  357. NOTE: The REMUNGE and CHECK options TURN OFF the stdout munglist output
  358.  
  359.  
  360. REMUNGE option
  361.  
  362. Instead of outputting a list of memory chunks in use, MungList will
  363. remunge free memory, outputting a short serial message.
  364.  
  365.  
  366. CHECK option
  367.  
  368. Instead of outputting a list of memory pieces in use, MungList will
  369. check the in-use memory pieces for trashed bytes before or after
  370. each allocation.  A short serial message is output, followed by
  371. mungwall-like serial error output for any trashed memory pieces.
  372.  
  373. -tickdelay
  374.  
  375. Tells MungList CHECK or REMUNGE to stay loaded and loop every tickdelay
  376. 50th's of a second.
  377.  
  378.  
  379.