8 static char * _Purify_MemTypeNames
[] =
18 static const char * purify_ErrorMsgs
[] =
21 #define _ERROR_DEF(n,s) s,
25 void Purify_PrePrintError (void)
29 Purify_RememberCallers (&rd
);
31 fprintf (stderr
, "*** Purify %s ***\n", purify_ErrorMsgs
[Purify_Error
]);
32 Purify_PrintCallers (&rd
);
35 void Purify_PostPrintError (void)
37 fprintf (stderr
, "***\n");
40 void Purify_PrintError (const char * fmt
, ...)
44 Purify_PrePrintError ();
46 vfprintf (stderr
, fmt
, args
);
49 Purify_PostPrintError ();
52 void Purify_PrintAccessError (const char * access
, const void * addr
, int size
)
56 long offset
= (long)addr
- (long)(Purify_LastNode
->mem
);
58 if (Purify_LastNode
->type
!= PURIFY_MemType_Heap
)
61 "%s of %d bytes at %p. This is %d bytes into the block\n"
62 "%s%s%sat %p with the size of %d bytes (type=%s)",
63 access
, size
, addr
, offset
,
64 Purify_LastNode
->data
? "\"" : "",
65 Purify_LastNode
->data
? (char *)Purify_LastNode
->data
: "",
66 Purify_LastNode
->data
? "\" " : "",
67 Purify_LastNode
->mem
, Purify_LastNode
->size
,
68 _Purify_MemTypeNames
[Purify_LastNode
->type
]
73 PMemoryNode
* node
= (PMemoryNode
*)Purify_LastNode
->data
;
75 Purify_PrePrintError ();
77 "%s of %d bytes at %p. This is %ld bytes into the block\n"
78 "allocated at %p with the size of %d bytes (type=%s)\n"
79 "The block was allocated ",
80 access
, size
, addr
, offset
,
81 Purify_LastNode
->mem
, Purify_LastNode
->size
,
82 _Purify_MemTypeNames
[Purify_LastNode
->type
]
84 Purify_PrintCallers (&node
->alloc
);
85 if (node
->free
.nstack
!= -1)
87 fprintf (stderr
, "It was freed ");
88 Purify_PrintCallers (&node
->free
);
90 Purify_PostPrintError ();
96 MemHash
* next
= Purify_FindNextMemory (addr
, &offset
);
98 if (next
->type
!= PURIFY_MemType_Heap
)
101 "%s of %d bytes at %p. This is %d bytes %s the block\n"
102 "%s%s%sat %p with the size of %d bytes (type=%s)",
103 access
, size
, addr
, offset
, (offset
< 0 ? "before" : "after"),
104 next
->data
? "\"" : "",
105 next
->data
? (char *)next
->data
: "",
106 next
->data
? "\" " : "",
107 next
->mem
, next
->size
,
108 _Purify_MemTypeNames
[next
->type
]
113 PMemoryNode
* node
= (PMemoryNode
*)next
->data
;
115 Purify_PrePrintError ();
117 "%s of %d bytes at %p. This is %d bytes %s the block\n"
118 "allocated at %p with the size of %d bytes (type=%s)\n"
119 "The block was allocated ",
120 access
, size
, addr
, offset
, (offset
< 0 ? "before" : "after"),
121 next
->mem
, next
->size
,
122 _Purify_MemTypeNames
[next
->type
]
124 Purify_PrintCallers (&node
->alloc
);
125 if (node
->free
.nstack
!= -1)
127 fprintf (stderr
, "It was freed ");
128 Purify_PrintCallers (&node
->free
);
130 Purify_PostPrintError ();