home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / programs / misc / enote / source.lha / source / debugma.h < prev    next >
C/C++ Source or Header  |  1995-01-10  |  1KB  |  43 lines

  1. #ifndef DWR_DEBUGMA_H
  2. #define DWR_DEBUGMA_H
  3.  
  4. #ifndef DWR_MEMORY_H
  5. #include "memory.h"
  6. #endif
  7.  
  8. typedef struct DebugMemABlock{
  9.   VOID                  (*AllocRA)();
  10.   ULONG                  Size;
  11.   struct DebugMemABlock *Succ;
  12.   struct DebugMemABlock *Pred;
  13.   UBYTE                  Block[1];
  14. } DMABLK;
  15.   
  16. extern VOID MemError(DMABLK *Allocation);
  17.  
  18. /*
  19. If memory.a is assembled with 'DEBUG' defined, every allocated block
  20. will contain some debug info.  There are 4 bytes more allocated behind
  21. the block from which the first is filled with 0xaa.  Somewhere before
  22. the block, the return address of the allocating routine is stored.  If
  23. the 0xaa-byte is trashed, MemError() is called with the offending
  24. block.
  25.  
  26. You could define MemError as follows:
  27.  
  28. VOID MemError(DMABLK *Allocation)
  29. {
  30.   char *BlockEnd;
  31.   
  32.   BlockEnd=&Allocation->Block[Allocation->Size-31];
  33.   (*Allocation->AllocRA)(0L);
  34. }
  35.  
  36. Put a breakpoint in this function, examine BlockEnd to look at the
  37. nature of the trash.  Follow the call into the allocating function,
  38. but stop there because the environt is wrong (quit or reboot).
  39. */
  40.  
  41.  
  42. #endif
  43.