My Project
Loading...
Searching...
No Matches
Functions | Variables
omDebugCheck.c File Reference
#include <limits.h>
#include <stdarg.h>
#include "omalloc.h"
#include "omDebug.h"

Go to the source code of this file.

Functions

static omError_t omDoCheckLargeAddr (void *addr, void *bin_size, omTrackFlags_t flags, char level, omError_t report, OM_FLR_DECL)
 
omError_t omDoCheckBin (omBin bin, int normal_bin, char level, omError_t report, OM_FLR_DECL)
 
static omError_t omDoCheckBinPage (omBinPage page, int normal_page, int level, omError_t report, OM_FLR_DECL)
 
static void _omPrintAddrInfo (FILE *fd, omError_t error, void *addr, void *bin_size, omTrackFlags_t flags, int max_frames, const char *s)
 
omError_t _omCheckAddr (void *addr, void *size_bin, omTrackFlags_t flags, char check, omError_t report, OM_FLR_DECL)
 
omError_t _omCheckBin (omBin bin, int what_bin, char check, omError_t report, OM_FLR_DECL)
 
omError_t _omCheckMemory (char check, omError_t report, OM_FLR_DECL)
 
omError_t omCheckPtr (const void *ptr, omError_t report, OM_FLR_DECL)
 
omError_t omDoCheckAddr (void *addr, void *bin_size, omTrackFlags_t flags, char level, omError_t report, OM_FLR_DECL)
 
omError_t omDoCheckBinAddr (void *addr, void *bin_size, omTrackFlags_t flags, char level, omError_t report, OM_FLR_DECL)
 
omError_t omReportAddrError (omError_t error, omError_t report_error, void *addr, void *bin_size, omTrackFlags_t flags, OM_FLR_DECL, const char *fmt,...)
 
void omPrintAddrInfo (FILE *fd, void *addr, const char *s)
 
void omIterateTroughBinAddrs (omBin bin, void(*CallBackUsed)(void *), void(*CallBackFree)(void *))
 
void omIterateTroughAddrs (int normal, int track, void(*CallBackUsed)(void *), void(*CallBackFree)(void *))
 
static void _omPrintUsedAddr (void *addr)
 
void omPrintUsedAddrs (FILE *fd, int max)
 
void omPrintUsedTrackAddrs (FILE *fd, int max)
 

Variables

unsigned long om_MaxAddr = 0
 
unsigned long om_MinAddr = ULONG_MAX
 
static FILE * om_print_used_addr_fd
 
static size_t om_total_used_size
 
static unsigned long om_total_used_blocks
 
static int om_print_frames
 

Function Documentation

◆ _omCheckAddr()

omError_t _omCheckAddr ( void *  addr,
void *  size_bin,
omTrackFlags_t  flags,
char  check,
omError_t  report,
OM_FLR_DECL   
)

Definition at line 36 of file omDebugCheck.c.

38{
39 if (check <= 0) return omError_NoError;
40 if (check > 1)
41 {
42 omCheckReturn(check > 2 && _omCheckMemory(check - 2, (report ? report : omError_MemoryCorrupted), OM_FLR_VAL));
44 (report ? report : omError_MemoryCorrupted), OM_FLR_VAL));
45 }
46 return omDoCheckAddr(addr, size_bin, flags, check, report, OM_FLR_VAL);
47}
VAR int check
Definition: libparse.cc:1106
#define omGetBinOfAddr(addr)
#define omIsBinPageAddr(addr)
Definition: omBinPage.h:68
omError_t omDoCheckAddr(void *addr, void *bin_size, omTrackFlags_t flags, char level, omError_t report, OM_FLR_DECL)
Definition: omDebugCheck.c:146
omError_t _omCheckMemory(char check, omError_t report, OM_FLR_DECL)
Definition: omDebugCheck.c:58
omError_t omDoCheckBin(omBin bin, int normal_bin, char level, omError_t report, OM_FLR_DECL)
Definition: omDebugCheck.c:253
#define omIsBinAddrTrackAddr(addr)
Definition: omDebug.h:15
#define omCheckReturn(cond)
Definition: omDebug.h:170
@ omError_MemoryCorrupted
Definition: omError.h:21
@ omError_NoError
Definition: omError.h:18
int status int void size_t count int const void size_t count const char int flags
Definition: si_signals.h:73

◆ _omCheckBin()

omError_t _omCheckBin ( omBin  bin,
int  what_bin,
char  check,
omError_t  report,
OM_FLR_DECL   
)

Definition at line 49 of file omDebugCheck.c.

50{
51 if (check <= 0) return omError_NoError;
52
53 omCheckReturn(check > 1 && _omCheckMemory(check - 1, (report ? report : omError_MemoryCorrupted), OM_FLR_VAL));
54
55 return omDoCheckBin(bin, what_bin, check, report, OM_FLR_VAL);
56}

◆ _omCheckMemory()

omError_t _omCheckMemory ( char  check,
omError_t  report,
OM_FLR_DECL   
)

Definition at line 58 of file omDebugCheck.c.

59{
60 int i = 0;
61 omSpecBin s_bin;
62 omBin sticky;
63
64 if (check <= 0) return omError_NoError;
65
66 omCheckReturn(omCheckBinPageRegions(check, report, OM_FLR_VAL));
67
68 for (i=0; i<= OM_MAX_BIN_INDEX; i++)
69 {
70 omCheckReturn(omDoCheckBin(&om_StaticBin[i], 1, check, report, OM_FLR_VAL));
71 }
72
73 s_bin = om_SpecBin;
75 while (s_bin != NULL)
76 {
77 omCheckReturn(omDoCheckBin(s_bin->bin, 1, check, report, OM_FLR_VAL));
78 s_bin = s_bin->next;
79 }
80
81 sticky = om_StickyBins;
83 while (sticky != NULL)
84 {
85 omCheckReturn(omDoCheckBin(sticky, 1, check, report, OM_FLR_VAL));
86 sticky = sticky->next;
87 }
88
89#ifdef OM_HAVE_TRACK
90 for (i=0; i<= OM_MAX_BIN_INDEX; i++)
91 {
92 omCheckReturn(omDoCheckBin(&om_StaticTrackBin[i], 0, check, report, OM_FLR_VAL));
93 }
94 s_bin = om_SpecTrackBin;
96 while (s_bin != NULL)
97 {
98 omCheckReturn(omDoCheckBin(s_bin->bin, 0, check, report, OM_FLR_VAL));
99 s_bin = s_bin->next;
100 }
101#endif
102
103 if (check > 1)
104 {
105 if (om_KeptAddr != NULL)
106 {
107 void* addr = om_KeptAddr;
108 omCheckReturn(omCheckList(om_KeptAddr, check - 1, (report ? report : omError_KeptAddrListCorrupted), OM_FLR_VAL));
109 while (addr != NULL)
110 {
111 omCheckReturn(omDoCheckAddr(addr, NULL, OM_FKEPT, check, report, OM_FLR_VAL));
112 addr = *((void**) addr);
113 }
114 }
116 {
117 void* addr = om_AlwaysKeptAddrs;
119 while (addr != NULL)
120 {
121 omCheckReturn(omDoCheckAddr(addr, NULL, OM_FKEPT, check, report, OM_FLR_VAL));
122 addr = *((void**) addr);
123 }
124 }
125 }
126
127 return omError_NoError;
128}
int i
Definition: cfEzgcd.cc:132
ListNode * next
Definition: janet.h:31
omBin om_StickyBins
Definition: omBin.c:374
omBin_t om_StaticBin[]
omError_t omCheckBinPageRegions(int level, omError_t report, OM_FLR_DECL)
Definition: omBinPage.c:531
void * om_AlwaysKeptAddrs
Definition: omDebug.c:31
void * om_KeptAddr
Definition: omDebug.c:28
#define OM_FKEPT
Definition: omDebug.h:35
@ omError_KeptAddrListCorrupted
Definition: omError.h:36
#define NULL
Definition: omList.c:12
#define omCheckGList(ptr, next, level, report, OM_FLR_VAL)
Definition: omList.h:115
#define omCheckList(ptr, level, report, OM_FLR_VAL)
Definition: omList.h:83
omBin_t * omBin
Definition: omStructs.h:12
omSpecBin_t * omSpecBin
Definition: omStructs.h:30
omSpecBin om_SpecBin
Definition: om_Alloc.c:20

◆ _omPrintAddrInfo()

static void _omPrintAddrInfo ( FILE *  fd,
omError_t  error,
void *  addr,
void *  bin_size,
omTrackFlags_t  flags,
int  max_frames,
const char *  s 
)
static

Definition at line 421 of file omDebugCheck.c.

422{
423 int x;
424 if ((! (x=omCheckPtr(addr, omError_MaxError, OM_FLR)))
426 {
427 fprintf(fd, "%s addr:%p size:%ld", s, addr, (long)omSizeOfAddr(addr));
428
430 fputs(" unaligned",fd);
431
433 fprintf(fd, " specified size:%ld", (long) bin_size);
434
435 if (error == omError_WrongBin && (flags & OM_FBIN))
436 fprintf(fd, " specified bin is of size:%ld",
437 (long)((omBin) bin_size)->sizeW << LOG_SIZEOF_LONG);
438
439 if (omIsTrackAddr(addr))
440 omPrintTrackAddrInfo(fd, addr, frames);
441 else
442 {
443 fputs(" !omIsTrackAddr\n",fd);
444 omPrintTrackAddrInfo(fd, addr, frames);
445 }
446 }
447 else
448 {
449 fprintf(fd, "%s (invalid) addr: %p (error=%d)\n", s, addr,x);
450 }
451}
Variable x
Definition: cfModGcd.cc:4082
const CanonicalForm int s
Definition: facAbsFact.cc:51
#define error(a)
Definition: mpr_numeric.cc:966
size_t omSizeOfAddr(const void *addr)
omError_t omCheckPtr(const void *ptr, omError_t report, OM_FLR_DECL)
Definition: omDebugCheck.c:136
#define OM_FSIZE
Definition: omDebug.h:33
#define OM_FBIN
Definition: omDebug.h:32
#define omIsTrackAddr(addr)
Definition: omDebug.h:12
@ omError_WrongSize
Definition: omError.h:26
@ omError_MaxError
Definition: omError.h:42
@ omError_UnalignedAddr
Definition: omError.h:32
@ omError_WrongBin
Definition: omError.h:29
int status int fd
Definition: si_signals.h:59

◆ _omPrintUsedAddr()

static void _omPrintUsedAddr ( void *  addr)
static

Definition at line 551 of file omDebugCheck.c.

552{
553 if (!omIsTrackAddr(addr) || !omIsStaticTrackAddr(addr))
554 {
557 if (om_print_frames > 0)
558 {
560 fputc('\n',om_print_used_addr_fd);
561 }
562 }
563}
static FILE * om_print_used_addr_fd
Definition: omDebugCheck.c:546
static size_t om_total_used_size
Definition: omDebugCheck.c:547
static unsigned long om_total_used_blocks
Definition: omDebugCheck.c:548
static int om_print_frames
Definition: omDebugCheck.c:549
static void _omPrintAddrInfo(FILE *fd, omError_t error, void *addr, void *bin_size, omTrackFlags_t flags, int max_frames, const char *s)
Definition: omDebugCheck.c:421
#define omIsStaticTrackAddr(addr)
Definition: omDebug.h:150

◆ omCheckPtr()

omError_t omCheckPtr ( const void *  ptr,
omError_t  report,
OM_FLR_DECL   
)

Definition at line 136 of file omDebugCheck.c.

137{
139 omCheckReturnError(!OM_IS_ALIGNED(ptr), omError_UnalignedAddr);
140 omCheckReturnError(((unsigned long) ptr) < om_MinAddr ||
141 ((unsigned long) ptr) >= om_MaxAddr, omError_InvalidRangeAddr);
142 return omError_NoError;
143}
unsigned long om_MaxAddr
Definition: omDebugCheck.c:19
unsigned long om_MinAddr
Definition: omDebugCheck.c:20
#define omCheckReturnError(cond, error)
Definition: omDebug.h:172
@ omError_NullAddr
Definition: omError.h:22
@ omError_InvalidRangeAddr
Definition: omError.h:23

◆ omDoCheckAddr()

omError_t omDoCheckAddr ( void *  addr,
void *  bin_size,
omTrackFlags_t  flags,
char  level,
omError_t  report,
OM_FLR_DECL   
)

Definition at line 146 of file omDebugCheck.c.

148{
149 if (level <= 0) return omError_NoError;
150 omAssume(! ((flags & OM_FSIZE) && (flags & OM_FBIN)));
151
152 if (addr == NULL)
153 {
155 return omError_NoError;
156 }
157 if ((flags & OM_FSIZE) && bin_size == NULL) return omError_NoError;
158 omAddrCheckReturn(omCheckPtr(addr, report, OM_FLR_VAL));
159 omAddrCheckReturnError((flags & OM_FALIGN) && !OM_IS_STRICT_ALIGNED(addr), omError_UnalignedAddr);
161
162 if (omIsBinPageAddr(addr))
163 {
164#ifdef OM_HAVE_TRACK
165 if (omIsBinAddrTrackAddr(addr))
166 return omCheckTrackAddr(addr, bin_size, flags, level, report, OM_FLR_VAL);
167 else
168#endif
169 return omDoCheckBinAddr(addr, bin_size, flags, level, report, OM_FLR_VAL);
170 }
171 else
172 {
173 return omDoCheckLargeAddr(addr, bin_size, flags, level, report, OM_FLR_VAL);
174 }
175}
int level(const CanonicalForm &f)
#define omIsKnownTopBin(bin, normal_bin)
Definition: omBin.h:55
static omError_t omDoCheckLargeAddr(void *addr, void *bin_size, omTrackFlags_t flags, char level, omError_t report, OM_FLR_DECL)
Definition: omDebugCheck.c:179
omError_t omDoCheckBinAddr(void *addr, void *bin_size, omTrackFlags_t flags, char level, omError_t report, OM_FLR_DECL)
Definition: omDebugCheck.c:198
#define OM_FSLOPPY
Definition: omDebug.h:39
#define OM_FALIGN
Definition: omDebug.h:38
#define omAddrCheckReturnError(cond, error)
Definition: omDebug.h:186
#define omAddrCheckReturn(cond)
Definition: omDebug.h:176
#define omAssume(x)
Definition: omError.h:85
@ omError_UnknownBin
Definition: omError.h:30

◆ omDoCheckBin()

omError_t omDoCheckBin ( omBin  bin,
int  normal_bin,
char  level,
omError_t  report,
OM_FLR_DECL   
)

Definition at line 253 of file omDebugCheck.c.

255{
256 omBin top_bin = bin;
257
259 if (! omIsStickyBin(bin))
260 omCheckReturn(omCheckGList(bin->next, next, level, report, OM_FLR_VAL));
261
262 do
263 {
264 int where;
265 omBinPage page;
266
267 if (bin->last_page == NULL || bin->current_page == om_ZeroPage)
268 {
269 omCheckReturnCorrupted(! (bin->current_page == om_ZeroPage && bin->last_page == NULL));
270 continue;
271 }
272 omCheckReturn(omDoCheckBinPage(bin->current_page, normal_bin, level, report, OM_FLR_VAL));
273 omCheckReturn(bin->current_page != bin->last_page &&
274 omDoCheckBinPage(bin->last_page, normal_bin, level, report, OM_FLR_VAL));
275 omCheckReturnCorrupted(bin->last_page->next != NULL);
276
277 if (bin != top_bin)
278 {
279 omCheckReturnCorrupted(bin->sizeW != top_bin->sizeW ||
280 bin->max_blocks != top_bin->max_blocks);
281 }
282 if (level <= 1) continue;
283
284 if (! omIsStickyBin(bin))
285 omCheckReturnCorrupted(omFindInGList(bin->next, next, sticky, bin->sticky));
286 omCheckReturn(omCheckGList(bin->last_page, prev, level-1, report, OM_FLR_VAL));
287 page = omGListLast(bin->last_page, prev);
288 omCheckReturn(omCheckGList(page, next, level-1, report, OM_FLR_VAL));
289 omCheckReturnCorrupted(omGListLength(bin->last_page, prev) != omGListLength(page, next));
290
291 omCheckReturnCorrupted(! omIsOnGList(bin->last_page, prev, bin->current_page));
292
293 page = bin->last_page;
294 where = 1;
295 while (page != NULL)
296 {
298 omCheckReturn(page != bin->last_page && page != bin->current_page &&
299 omDoCheckBinPage(page, normal_bin, level - 1, report, OM_FLR_VAL));
300
301 omCheckReturnCorrupted(page != bin->last_page &&
302 (page->next == NULL || page->next->prev != page));
303 omCheckReturnCorrupted(page->prev != NULL && page->prev->next != page);
304
305 omCheckReturnCorrupted(omGetStickyOfPage(page) != bin->sticky && bin->sticky < SIZEOF_VOIDP);
307
308 if (where == -1)
309 {
310 /* we are at the left of current_page,
311 i.e., page is empty */
312 omCheckReturnCorrupted(omGetUsedBlocksOfPage(page) != 0 || page->current != NULL);
313 }
314 else
315 {
316 if (page == bin->current_page)
317 {
318 where = -1;
319 }
320 else
321 {
322 /* we are at the right of current_page,
323 i.e., page is neither full nor empty */
324 omCheckReturnCorrupted(page->current == NULL ||
325 omGetUsedBlocksOfPage(page) == bin->max_blocks - 1);
326 }
327 }
328 page = page->prev;
329 } /* while (page != NULL) */
330 } while (!omIsStickyBin(bin) && ((bin = bin->next) != NULL));
331
332 return omError_NoError;
333}
#define omGetTopBinOfPage(page)
#define omGetStickyOfPage(page)
#define omIsStickyBin(bin)
Definition: omBin.h:33
static omError_t omDoCheckBinPage(omBinPage page, int normal_page, int level, omError_t report, OM_FLR_DECL)
Definition: omDebugCheck.c:336
#define omGetUsedBlocksOfPage(page)
Definition: omDebug.h:88
#define omCheckReturnCorrupted(cond)
Definition: omDebug.h:174
OM_INLINE_DECL omBin omGetBinOfPage(omBinPage page)
#define omFindInGList(ptr, next, what, value)
Definition: omList.h:104
#define omGListLength(ptr, next)
Definition: omList.h:94
#define omGListLast(ptr, next)
Definition: omList.h:96
#define omIsOnGList(ptr, next, addr)
Definition: omList.h:100
omBinPage_t * omBinPage
Definition: omStructs.h:16
omBinPage_t om_ZeroPage[]
Definition: om_Alloc.c:19

◆ omDoCheckBinAddr()

omError_t omDoCheckBinAddr ( void *  addr,
void *  bin_size,
omTrackFlags_t  flags,
char  level,
omError_t  report,
OM_FLR_DECL   
)

Definition at line 198 of file omDebugCheck.c.

200{
201 omBinPage page = omGetBinPageOfAddr(addr);
202 omBinPageRegion region = page->region;
203 omBin bin = omGetBinOfPage(page);
204
206 omAssume(! omCheckPtr(addr, 0, OM_FLR));
207
209
210 if (flags & OM_FBINADDR && flags & OM_FSIZE)
211 omAddrCheckReturnError(bin->sizeW*SIZEOF_LONG != (size_t) bin_size, omError_WrongSize);
212
213 if (level > 1)
214 {
218
219 if (flags & OM_FUSED)
220 {
223 }
224 }
225 else
226 {
228 }
229
230
231 /* Check that addr is aligned within page of bin */
232 omAddrCheckReturnError((bin->max_blocks >= 1) &&
233 ( ( ( (unsigned long) addr)
234 - ((unsigned long) page)
236 % (bin->sizeW * SIZEOF_VOIDP)
237 != 0), omError_FalseAddr);
238
239 /* Check that specified bin or size is correct */
240 omAddrCheckReturnError((flags & OM_FBIN) && bin_size != NULL
241 && ((omBin) bin_size) != omGetTopBinOfAddr(addr), omError_WrongBin);
242
243 if ((flags & OM_FSIZE) && (!(flags & OM_FSLOPPY) || (size_t) bin_size > 0))
244 {
245 size_t size = (size_t) bin_size;
247 omAddrCheckReturnError((bin->sizeW << LOG_SIZEOF_LONG) < OM_ALIGN_SIZE(size), omError_WrongSize);
248 }
249
250 return omError_NoError;
251}
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
#define omGetTopBinOfAddr(addr)
#define SIZEOF_OM_BIN_PAGE_HEADER
omBinPageRegion omFindRegionOfAddr(void *addr)
Definition: omBinPage.c:578
int omIsAddrOnFreeBinPage(void *addr)
Definition: omBinPage.c:595
#define omGetBinPageOfAddr(addr)
Definition: omBinPage.h:22
#define OM_FBINADDR
Definition: omDebug.h:40
#define omAddrCheckReturnCorrupted(cond)
Definition: omDebug.h:188
#define OM_FUSED
Definition: omDebug.h:34
int omIsInKeptAddrList(void *addr)
Definition: omDebugTrack.c:743
@ omError_FreedAddr
Definition: omError.h:27
@ omError_FreedAddrOrMemoryCorrupted
Definition: omError.h:28
@ omError_FalseAddr
Definition: omError.h:24
#define omIsOnList(ptr, addr)
Definition: omList.h:68
omBinPageRegion_t * omBinPageRegion
Definition: omStructs.h:20

◆ omDoCheckBinPage()

static omError_t omDoCheckBinPage ( omBinPage  page,
int  normal_page,
int  level,
omError_t  report,
OM_FLR_DECL   
)
static

Definition at line 336 of file omDebugCheck.c.

338{
339 omBin bin;
340
341 omCheckReturn(omCheckPtr(page, report, OM_FLR_VAL));
343
344 omCheckReturn(omCheckPtr(page->region, report, OM_FLR_VAL));
345 omCheckReturnCorrupted(level > 1 && omFindRegionOfAddr(page) != page->region);
346
347
348#ifdef OM_HAVE_TRACK
349 if (! normal_page)
350 {
351 omCheckReturnCorrupted(! omIsSetTrackOfUsedBlocks(page->used_blocks));
352 }
353 else
354#endif
355 omAssume(normal_page);
356
357 bin = omGetTopBinOfPage(page);
358 if (bin->max_blocks > 1)
359 {
360 omCheckReturnCorrupted(omGetUsedBlocksOfPage(page) > bin->max_blocks - 1);
361 omCheckReturnCorrupted(omGetUsedBlocksOfPage(page) == bin->max_blocks - 1 &&
362 page->current != NULL);
364 }
365 else
366 {
368 }
369
370 omCheckReturn(omCheckList(page->current, level, report, OM_FLR_VAL));
371
372 if (level > 1)
373 {
374 void* current = page->current;
375
376 omCheckReturnCorrupted(current != NULL &&
377 omListLength(current) != bin->max_blocks - omGetUsedBlocksOfPage(page) - 1);
378
379 while (current != NULL)
380 {
381 omCheckReturnCorrupted(omGetPageOfAddr(current) != page);
382
383 omCheckReturnCorrupted( ( ( (unsigned long) current)
384 - ((unsigned long) page)
386 % (bin->sizeW * SIZEOF_LONG)
387 != 0);
388 current = *((void**) current);
389 }
390 }
391 return omError_NoError;
392}
#define omIsAddrPageAligned(addr)
Definition: omBinPage.h:16
#define omGetPageOfAddr(addr)
Definition: omBinPage.h:19
#define omListLength(ptr)
Definition: omList.h:62

◆ omDoCheckLargeAddr()

static omError_t omDoCheckLargeAddr ( void *  addr,
void *  bin_size,
omTrackFlags_t  flags,
char  level,
omError_t  report,
OM_FLR_DECL   
)
static

Definition at line 179 of file omDebugCheck.c.

181{
182 size_t r_size;
183
184 omAssume(! omIsBinPageAddr(addr));
185 omAssume(! omCheckPtr(addr, omError_NoError, OM_FLR));
186
189 r_size = omSizeOfLargeAddr(addr);
192 omAddrCheckReturnError((flags & OM_FSIZE) && r_size < OM_ALIGN_SIZE((size_t) bin_size),
195 return omError_NoError;
196}
size_t omSizeOfLargeAddr(void *addr)
@ omError_NotBinAddr
Definition: omError.h:31
@ omError_FalseAddrOrMemoryCorrupted
Definition: omError.h:25
#define OM_MAX_BLOCK_SIZE
Definition: omTables.c:31

◆ omIterateTroughAddrs()

void omIterateTroughAddrs ( int  normal,
int  track,
void(*)(void *)  CallBackUsed,
void(*)(void *)  CallBackFree 
)

Definition at line 503 of file omDebugCheck.c.

504{
505 int i;
506 omSpecBin s_bin;
507 omBin sticky;
508
509 if (normal)
510 {
511 for (i=0; i<=OM_MAX_BIN_INDEX; i++)
512 {
513 omIterateTroughBinAddrs(&om_StaticBin[i], CallBackUsed, CallBackFree);
514 }
515 s_bin = om_SpecBin;
516 while (s_bin != NULL)
517 {
518 omIterateTroughBinAddrs(s_bin->bin, CallBackUsed, CallBackFree);
519 s_bin = s_bin->next;
520 }
521 }
522
523#ifdef OM_HAVE_TRACK
524 if (track)
525 {
526 for (i=0; i<=OM_MAX_BIN_INDEX; i++)
527 {
528 omIterateTroughBinAddrs(&om_StaticTrackBin[i], CallBackUsed, CallBackFree);
529 }
530 s_bin = om_SpecTrackBin;
531 while (s_bin != NULL)
532 {
533 omIterateTroughBinAddrs(s_bin->bin, CallBackUsed, CallBackFree);
534 s_bin = s_bin->next;
535 }
536 }
537#endif
538 sticky = om_StickyBins;
539 while (sticky != NULL)
540 {
541 omIterateTroughBinAddrs(sticky, CallBackUsed, CallBackFree);
542 sticky = sticky->next;
543 }
544}
void omIterateTroughBinAddrs(omBin bin, void(*CallBackUsed)(void *), void(*CallBackFree)(void *))
Definition: omDebugCheck.c:464

◆ omIterateTroughBinAddrs()

void omIterateTroughBinAddrs ( omBin  bin,
void(*)(void *)  CallBackUsed,
void(*)(void *)  CallBackFree 
)

Definition at line 464 of file omDebugCheck.c.

465{
466 omBinPage page;
467 char* addr;
468 int is_free;
469 int i;
470
471 do
472 {
473 page = bin->last_page;
474 while (page != NULL)
475 {
476 addr = (char*) page + SIZEOF_OM_BIN_PAGE_HEADER;
477 i = 0;
478 do
479 {
480 is_free = omIsOnList(page->current, addr) != NULL
481 || omIsInKeptAddrList(addr);
482 if (is_free)
483 {
484 if (CallBackFree != NULL) CallBackFree(addr);
485 }
486 else
487 {
488 if (CallBackUsed != NULL) CallBackUsed(addr);
489 }
490 addr = (char *)((char**) addr) + bin->sizeW;
491 i++;
492 } while (i < bin->max_blocks);
493 page = page->prev;
494 }
495 if (omIsStickyBin(bin))
496 bin = NULL;
497 else
498 bin = bin->next;
499 } while (bin != NULL);
500
501}

◆ omPrintAddrInfo()

void omPrintAddrInfo ( FILE *  fd,
void *  addr,
const char *  s 
)

Definition at line 453 of file omDebugCheck.c.

454{
455 _omPrintAddrInfo(fd, omError_NoError, addr, NULL, 0, 10, s);
456}

◆ omPrintUsedAddrs()

void omPrintUsedAddrs ( FILE *  fd,
int  max 
)

Definition at line 565 of file omDebugCheck.c.

566{
569 om_print_used_addr_fd = (fd == NULL ? stdout : fd);
572 fprintf(fd, "UsedAddrs Summary: UsedBlocks:%ld TotalSize:%ld\n",
574}
static int max(int a, int b)
Definition: fast_mult.cc:264
static void _omPrintUsedAddr(void *addr)
Definition: omDebugCheck.c:551
void omIterateTroughAddrs(int normal, int track, void(*CallBackUsed)(void *), void(*CallBackFree)(void *))
Definition: omDebugCheck.c:503

◆ omPrintUsedTrackAddrs()

void omPrintUsedTrackAddrs ( FILE *  fd,
int  max 
)

Definition at line 576 of file omDebugCheck.c.

577{
580 om_print_used_addr_fd = (fd == NULL ? stdout : fd);
583 fprintf(fd, "UsedTrackAddrs Summary: UsedBlocks:%ld TotalSize:%ld\n",
585}

◆ omReportAddrError()

omError_t omReportAddrError ( omError_t  error,
omError_t  report_error,
void *  addr,
void *  bin_size,
omTrackFlags_t  flags,
OM_FLR_DECL  ,
const char *  fmt,
  ... 
)

Definition at line 394 of file omDebugCheck.c.

396{
397 int max_check, max_track;
398 va_list ap;
399 va_start(ap, fmt);
400
401 /* reset MaxTrack and MaxCheck to prevent infinite loop, in case
402 printf allocates memory */
403 max_check = om_Opts.MaxCheck;
404 max_track = om_Opts.MaxTrack;
405 om_Opts.MaxCheck = 0;
406 om_Opts.MaxTrack = 0;
407
409 omReportError(error, report_error, OM_FLR_VAL, fmt, ap);
411
413 _omPrintAddrInfo(stderr, error, addr, bin_size, flags, 10, " occurred for");
414 om_Opts.ErrorHook();
415
416 om_Opts.MaxCheck = max_check;
417 om_Opts.MaxTrack = max_track;
418 return om_ErrorStatus;
419}
Definition: ap.h:40
omError_t om_ErrorStatus
Definition: omError.c:13
int om_CallErrorHook
Definition: omError.c:77
omError_t omReportError(omError_t error, omError_t report_error, OM_FLR_DECL, const char *fmt,...)
Definition: omError.c:80
omOpts_t om_Opts
Definition: omOpts.c:13

Variable Documentation

◆ om_MaxAddr

unsigned long om_MaxAddr = 0

Definition at line 19 of file omDebugCheck.c.

◆ om_MinAddr

unsigned long om_MinAddr = ULONG_MAX

Definition at line 20 of file omDebugCheck.c.

◆ om_print_frames

int om_print_frames
static

Definition at line 549 of file omDebugCheck.c.

◆ om_print_used_addr_fd

FILE* om_print_used_addr_fd
static

Definition at line 546 of file omDebugCheck.c.

◆ om_total_used_blocks

unsigned long om_total_used_blocks
static

Definition at line 548 of file omDebugCheck.c.

◆ om_total_used_size

size_t om_total_used_size
static

Definition at line 547 of file omDebugCheck.c.