2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
13 static char * _Purify_MemTypeNames
[] =
23 static const char * purify_ErrorMsgs
[] =
26 #define _ERROR_DEF(n,s) s,
30 void Purify_PrePrintError (void)
34 Purify_RememberCallers (&rd
);
36 fprintf (stderr
, "*** Purify %s ***\n", purify_ErrorMsgs
[Purify_Error
]);
37 Purify_PrintCallers (&rd
);
40 void Purify_PostPrintError (void)
42 fprintf (stderr
, "***\n");
45 void Purify_PrintError (const char * fmt
, ...)
49 Purify_PrePrintError ();
51 vfprintf (stderr
, fmt
, args
);
54 Purify_PostPrintError ();
57 void Purify_PrintAccessError (const char * access
, const void * addr
, int size
)
61 long offset
= (long)addr
- (long)(Purify_LastNode
->mem
);
63 if (Purify_LastNode
->type
!= PURIFY_MemType_Heap
)
66 "%s of %d bytes at %p. This is %d bytes into the block\n"
67 "%s%s%sat %p with the size of %d bytes (type=%s)",
68 access
, size
, addr
, offset
,
69 Purify_LastNode
->data
? "\"" : "",
70 Purify_LastNode
->data
? (char *)Purify_LastNode
->data
: "",
71 Purify_LastNode
->data
? "\" " : "",
72 Purify_LastNode
->mem
, Purify_LastNode
->size
,
73 _Purify_MemTypeNames
[Purify_LastNode
->type
]
78 PMemoryNode
* node
= (PMemoryNode
*)Purify_LastNode
->data
;
80 Purify_PrePrintError ();
82 "%s of %d bytes at %p. This is %ld bytes into the block\n"
83 "allocated at %p with the size of %d bytes (type=%s)\n"
84 "The block was allocated ",
85 access
, size
, addr
, offset
,
86 Purify_LastNode
->mem
, Purify_LastNode
->size
,
87 _Purify_MemTypeNames
[Purify_LastNode
->type
]
89 Purify_PrintCallers (&node
->alloc
);
90 if (node
->free
.nstack
!= -1)
92 fprintf (stderr
, "It was freed ");
93 Purify_PrintCallers (&node
->free
);
95 Purify_PostPrintError ();
101 MemHash
* next
= Purify_FindNextMemory (addr
, &offset
);
103 if (next
->type
!= PURIFY_MemType_Heap
)
106 "%s of %d bytes at %p. This is %d bytes %s the block\n"
107 "%s%s%sat %p with the size of %d bytes (type=%s)",
108 access
, size
, addr
, offset
, (offset
< 0 ? "before" : "after"),
109 next
->data
? "\"" : "",
110 next
->data
? (char *)next
->data
: "",
111 next
->data
? "\" " : "",
112 next
->mem
, next
->size
,
113 _Purify_MemTypeNames
[next
->type
]
118 PMemoryNode
* node
= (PMemoryNode
*)next
->data
;
120 Purify_PrePrintError ();
122 "%s of %d bytes at %p. This is %d bytes %s the block\n"
123 "allocated at %p with the size of %d bytes (type=%s)\n"
124 "The block was allocated ",
125 access
, size
, addr
, offset
, (offset
< 0 ? "before" : "after"),
126 next
->mem
, next
->size
,
127 _Purify_MemTypeNames
[next
->type
]
129 Purify_PrintCallers (&node
->alloc
);
130 if (node
->free
.nstack
!= -1)
132 fprintf (stderr
, "It was freed ");
133 Purify_PrintCallers (&node
->free
);
135 Purify_PostPrintError ();