Loading...
Searching...
No Matches
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.

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

## _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.

{
if (check <= 0) return omError_NoError;
omCheckReturn(check > 1 && _omCheckMemory(check - 1, (report ? report : omError_MemoryCorrupted), OM_FLR_VAL));
return omDoCheckBin(bin, what_bin, check, report, OM_FLR_VAL);
}

## _omCheckMemory()

omError_t _omCheckMemory | ( | char | check,
|  | omError_t | report,
|  | OM_FLR_DECL | )

Definition at line 58 of file omDebugCheck.c.

{
int i = 0;
omSpecBin s_bin;
omBin sticky;
if (check <= 0) return omError_NoError;
omCheckReturn(omCheckBinPageRegions(check, report, OM_FLR_VAL));
for (i=0; i<= OM_MAX_BIN_INDEX; i++)
{
omCheckReturn(omDoCheckBin(&om_StaticBin[i], 1, check, report, OM_FLR_VAL));
}
s_bin = om_SpecBin;
omCheckReturn(omCheckGList(s_bin, next, check, omError_MemoryCorrupted, OM_FLR_VAL));
while (s_bin != NULL)
{
omCheckReturn(omDoCheckBin(s_bin->bin, 1, check, report, OM_FLR_VAL));
s_bin = s_bin->next;
}
sticky = om_StickyBins;
omCheckReturn(omCheckGList(sticky, next, check, omError_MemoryCorrupted, OM_FLR_VAL));
while (sticky != NULL)
{
omCheckReturn(omDoCheckBin(sticky, 1, check, report, OM_FLR_VAL));
sticky = sticky->next;
}
#ifdef OM_HAVE_TRACK
for (i=0; i<= OM_MAX_BIN_INDEX; i++)
{
omCheckReturn(omDoCheckBin(&om_StaticTrackBin[i], 0, check, report, OM_FLR_VAL));
}
s_bin = om_SpecTrackBin;
omCheckReturn(omCheckGList(s_bin, next, check, omError_MemoryCorrupted, OM_FLR_VAL));
while (s_bin != NULL)
{
omCheckReturn(omDoCheckBin(s_bin->bin, 0, check, report, OM_FLR_VAL));
s_bin = s_bin->next;
}
#endif
if (check > 1)
{
if (om_KeptAddr != NULL)
{
void* addr = om_KeptAddr;
omCheckReturn(omCheckList(om_KeptAddr, check - 1, (report ? report : omError_KeptAddrListCorrupted), OM_FLR_VAL));
while (addr != NULL)
{
omCheckReturn(omDoCheckAddr(addr, NULL, OM_FKEPT, check, report, OM_FLR_VAL));
addr = *((void**) addr);
}
}
if (om_AlwaysKeptAddrs != NULL)
{
void* addr = om_AlwaysKeptAddrs;
omCheckReturn(omCheckList(om_AlwaysKeptAddrs, check - 1, (report ? report : omError_KeptAddrListCorrupted), OM_FLR_VAL));
while (addr != NULL)
{
omCheckReturn(omDoCheckAddr(addr, NULL, OM_FKEPT, check, report, OM_FLR_VAL));
addr = *((void**) addr);
}
}
}
return omError_NoError;
}
i
int i
Definition cfEzgcd.cc:132
next
ListNode * next
Definition janet.h:31
om_StickyBins
omBin om_StickyBins
Definition omBin.c:374
om_StaticBin
omBin_t om_StaticBin[]
omCheckBinPageRegions
omError_t omCheckBinPageRegions(int level, omError_t report, OM_FLR_DECL)
Definition omBinPage.c:531
om_AlwaysKeptAddrs
void * om_AlwaysKeptAddrs
Definition omDebug.c:31
om_KeptAddr
void * om_KeptAddr
Definition omDebug.c:28
OM_FKEPT
#define OM_FKEPT
Definition omDebug.h:35
omError_KeptAddrListCorrupted
@ omError_KeptAddrListCorrupted
Definition omError.h:36
NULL
#define NULL
Definition omList.c:12
omCheckGList
#define omCheckGList(ptr, next, level, report, OM_FLR_VAL)
Definition omList.h:115
omCheckList
#define omCheckList(ptr, level, report, OM_FLR_VAL)
Definition omList.h:83
omBin
omBin_t * omBin
Definition omStructs.h:12
omSpecBin
omSpecBin_t * omSpecBin
Definition omStructs.h:30
OM_MAX_BIN_INDEX
#define OM_MAX_BIN_INDEX
Definition omTables.h:4
om_SpecBin
omSpecBin om_SpecBin
Definition om_Alloc.c:20

## _omPrintAddrInfo()

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.

{
int x;
if ((! (x=omCheckPtr(addr, omError_MaxError, OM_FLR)))
||(x==omError_UnalignedAddr))
{
fprintf(fd, "%s addr:%p size:%ld", s, addr, (long)omSizeOfAddr(addr));
if (error == omError_UnalignedAddr)
fputs(" unaligned",fd);
if (error == omError_WrongSize && (flags & OM_FSIZE))
fprintf(fd, " specified size:%ld", (long) bin_size);
if (error == omError_WrongBin && (flags & OM_FBIN))
fprintf(fd, " specified bin is of size:%ld",
(long)((omBin) bin_size)->sizeW << LOG_SIZEOF_LONG);
if (omIsTrackAddr(addr))
omPrintTrackAddrInfo(fd, addr, frames);
else
{
fputs(" !omIsTrackAddr\n",fd);
omPrintTrackAddrInfo(fd, addr, frames);
}
}
else
{
fprintf(fd, "%s (invalid) addr: %p (error=%d)\n", s, addr,x);
}
}
x
Variable x
Definition cfModGcd.cc:4090
s
const CanonicalForm int s
Definition facAbsFact.cc:51
error
#define error(a)
Definition mpr_numeric.cc:966
omSizeOfAddr
size_t omSizeOfAddr(const void *addr)
Definition omAllocSystem.c:110
omCheckPtr
omError_t omCheckPtr(const void *ptr, omError_t report, OM_FLR_DECL)
Definition omDebugCheck.c:136
OM_FSIZE
#define OM_FSIZE
Definition omDebug.h:33
OM_FBIN
#define OM_FBIN
Definition omDebug.h:32
omIsTrackAddr
#define omIsTrackAddr(addr)
Definition omDebug.h:12
omError_WrongSize
@ omError_WrongSize
Definition omError.h:26
omError_MaxError
@ omError_MaxError
Definition omError.h:42
omError_UnalignedAddr
@ omError_UnalignedAddr
Definition omError.h:32
omError_WrongBin
@ omError_WrongBin
Definition omError.h:29
fd
int status int fd
Definition si_signals.h:69

## _omPrintUsedAddr()

void _omPrintUsedAddr | ( | void * | addr | ) |

static

Definition at line 551 of file omDebugCheck.c.

{
if (!omIsTrackAddr(addr) || !omIsStaticTrackAddr(addr))
{
om_total_used_blocks++;
om_total_used_size += omSizeOfAddr(addr);
if (om_print_frames > 0)
{
_omPrintAddrInfo(om_print_used_addr_fd, omError_NoError, addr, NULL, 0, om_print_frames, "");
fputc('\n',om_print_used_addr_fd);
}
}
}
om_print_used_addr_fd
static FILE * om_print_used_addr_fd
Definition omDebugCheck.c:546
om_total_used_size
static size_t om_total_used_size
Definition omDebugCheck.c:547
om_total_used_blocks
static unsigned long om_total_used_blocks
Definition omDebugCheck.c:548
om_print_frames
static int om_print_frames
Definition omDebugCheck.c:549
_omPrintAddrInfo
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
omIsStaticTrackAddr
#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.

{
omCheckReturnError(ptr == NULL, omError_NullAddr);
omCheckReturnError(!OM_IS_ALIGNED(ptr), omError_UnalignedAddr);
omCheckReturnError(((unsigned long) ptr) < om_MinAddr ||
((unsigned long) ptr) >= om_MaxAddr, omError_InvalidRangeAddr);
return omError_NoError;
}
om_MaxAddr
unsigned long om_MaxAddr
Definition omDebugCheck.c:19
om_MinAddr
unsigned long om_MinAddr
Definition omDebugCheck.c:20
omCheckReturnError
#define omCheckReturnError(cond, error)
Definition omDebug.h:172
omError_NullAddr
@ omError_NullAddr
Definition omError.h:22
omError_InvalidRangeAddr
@ 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.

{
if (level <= 0) return omError_NoError;
omAssume(! ((flags & OM_FSIZE) && (flags & OM_FBIN)));
if (addr == NULL)
{
omCheckReturnError(!(flags & OM_FSLOPPY), omError_NullAddr);
return omError_NoError;
}
if ((flags & OM_FSIZE) && bin_size == NULL) return omError_NoError;
omAddrCheckReturn(omCheckPtr(addr, report, OM_FLR_VAL));
omAddrCheckReturnError((flags & OM_FALIGN) && !OM_IS_STRICT_ALIGNED(addr), omError_UnalignedAddr);
omAddrCheckReturnError((flags & OM_FBIN) && !omIsKnownTopBin((omBin) bin_size, 1), omError_UnknownBin);
if (omIsBinPageAddr(addr))
{
#ifdef OM_HAVE_TRACK
if (omIsBinAddrTrackAddr(addr))
return omCheckTrackAddr(addr, bin_size, flags, level, report, OM_FLR_VAL);
else
#endif
return omDoCheckBinAddr(addr, bin_size, flags, level, report, OM_FLR_VAL);
}
else
{
return omDoCheckLargeAddr(addr, bin_size, flags, level, report, OM_FLR_VAL);
}
}
level
int level(const CanonicalForm &f)
Definition canonicalform.h:331
omIsKnownTopBin
#define omIsKnownTopBin(bin, normal_bin)
Definition omBin.h:55
omDoCheckLargeAddr
static omError_t omDoCheckLargeAddr(void *addr, void *bin_size, omTrackFlags_t flags, char level, omError_t report, OM_FLR_DECL)
Definition omDebugCheck.c:179
omDoCheckBinAddr
omError_t omDoCheckBinAddr(void *addr, void *bin_size, omTrackFlags_t flags, char level, omError_t report, OM_FLR_DECL)
Definition omDebugCheck.c:198
OM_FSLOPPY
#define OM_FSLOPPY
Definition omDebug.h:39
OM_FALIGN
#define OM_FALIGN
Definition omDebug.h:38
omAddrCheckReturnError
#define omAddrCheckReturnError(cond, error)
Definition omDebug.h:186
omAddrCheckReturn
#define omAddrCheckReturn(cond)
Definition omDebug.h:176
omAssume
#define omAssume(x)
Definition omError.h:85
omError_UnknownBin
@ 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.

{
omBin top_bin = bin;
omCheckReturnError(!omIsKnownTopBin(bin, normal_bin), omError_UnknownBin);
if (! omIsStickyBin(bin))
omCheckReturn(omCheckGList(bin->next, next, level, report, OM_FLR_VAL));
do
{
int where;
omBinPage page;
if (bin->last_page == NULL || bin->current_page == om_ZeroPage)
{
omCheckReturnCorrupted(! (bin->current_page == om_ZeroPage && bin->last_page == NULL));
continue;
}
omCheckReturn(omDoCheckBinPage(bin->current_page, normal_bin, level, report, OM_FLR_VAL));
omCheckReturn(bin->current_page != bin->last_page &&
omDoCheckBinPage(bin->last_page, normal_bin, level, report, OM_FLR_VAL));
omCheckReturnCorrupted(bin->last_page->next != NULL);
if (bin != top_bin)
{
omCheckReturnCorrupted(bin->sizeW != top_bin->sizeW ||
bin->max_blocks != top_bin->max_blocks);
}
if (level <= 1) continue;
if (! omIsStickyBin(bin))
omCheckReturnCorrupted(omFindInGList(bin->next, next, sticky, bin->sticky));
omCheckReturn(omCheckGList(bin->last_page, prev, level-1, report, OM_FLR_VAL));
page = omGListLast(bin->last_page, prev);
omCheckReturn(omCheckGList(page, next, level-1, report, OM_FLR_VAL));
omCheckReturnCorrupted(omGListLength(bin->last_page, prev) != omGListLength(page, next));
omCheckReturnCorrupted(! omIsOnGList(bin->last_page, prev, bin->current_page));
page = bin->last_page;
where = 1;
while (page != NULL)
{
omCheckReturnCorrupted(omGetTopBinOfPage(page) != top_bin);
omCheckReturn(page != bin->last_page && page != bin->current_page &&
omDoCheckBinPage(page, normal_bin, level - 1, report, OM_FLR_VAL));
omCheckReturnCorrupted(page != bin->last_page &&
(page->next == NULL || page->next->prev != page));
omCheckReturnCorrupted(page->prev != NULL && page->prev->next != page);
omCheckReturnCorrupted(omGetStickyOfPage(page) != bin->sticky && bin->sticky < SIZEOF_VOIDP);
omCheckReturnCorrupted(omGetBinOfPage(page) != bin);
if (where == -1)
{
/* we are at the left of current_page,
i.e., page is empty */
omCheckReturnCorrupted(omGetUsedBlocksOfPage(page) != 0 || page->current != NULL);
}
else
{
if (page == bin->current_page)
{
where = -1;
}
else
{
/* we are at the right of current_page,
i.e., page is neither full nor empty */
omCheckReturnCorrupted(page->current == NULL ||
omGetUsedBlocksOfPage(page) == bin->max_blocks - 1);
}
}
page = page->prev;
} /* while (page != NULL) */
} while (!omIsStickyBin(bin) && ((bin = bin->next) != NULL));
return omError_NoError;
}
omGetTopBinOfPage
#define omGetTopBinOfPage(page)
Definition omAllocPrivate.h:65
omGetStickyOfPage
#define omGetStickyOfPage(page)
Definition omAllocPrivate.h:67
omIsStickyBin
#define omIsStickyBin(bin)
Definition omBin.h:33
omDoCheckBinPage
static omError_t omDoCheckBinPage(omBinPage page, int normal_page, int level, omError_t report, OM_FLR_DECL)
Definition omDebugCheck.c:336
omGetUsedBlocksOfPage
#define omGetUsedBlocksOfPage(page)
Definition omDebug.h:88
omCheckReturnCorrupted
#define omCheckReturnCorrupted(cond)
Definition omDebug.h:174
omGetBinOfPage
OM_INLINE_DECL omBin omGetBinOfPage(omBinPage page)
omFindInGList
#define omFindInGList(ptr, next, what, value)
Definition omList.h:104
omGListLength
#define omGListLength(ptr, next)
Definition omList.h:94
omGListLast
#define omGListLast(ptr, next)
Definition omList.h:96
omIsOnGList
#define omIsOnGList(ptr, next, addr)
Definition omList.h:100
omBinPage
omBinPage_t * omBinPage
Definition omStructs.h:16
om_ZeroPage
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.

{
omBinPage page = omGetBinPageOfAddr(addr);
omBinPageRegion region = page->region;
omBin bin = omGetBinOfPage(page);
omAssume(omIsBinPageAddr(addr));
omAssume(! omCheckPtr(addr, 0, OM_FLR));
omAddrCheckReturnCorrupted(! omIsKnownTopBin(bin, ! omIsBinAddrTrackAddr(addr)));
if (flags & OM_FBINADDR && flags & OM_FSIZE)
omAddrCheckReturnError(bin->sizeW*SIZEOF_LONG != (size_t) bin_size, omError_WrongSize);
if (level > 1)
{
omAddrCheckReturnError(omIsAddrOnFreeBinPage(addr), omError_FreedAddr);
omAddrCheckReturnError(omFindRegionOfAddr(addr) != region, omError_FreedAddrOrMemoryCorrupted);
omAddrCheckReturnError(!omIsOnGList(bin->last_page, prev, page), omError_FreedAddrOrMemoryCorrupted);
if (flags & OM_FUSED)
{
omAddrCheckReturnError(omIsOnList(page->current, addr), omError_FreedAddr);
omAddrCheckReturnError((level > 1) && omIsInKeptAddrList(addr), omError_FreedAddr);
}
}
else
{
omAddrCheckReturnError(omCheckPtr(region, omError_MaxError, OM_FLR_VAL), omError_FreedAddrOrMemoryCorrupted);
}
/* Check that addr is aligned within page of bin */
omAddrCheckReturnError((bin->max_blocks >= 1) &&
( ( ( (unsigned long) addr)
- ((unsigned long) page)
- SIZEOF_OM_BIN_PAGE_HEADER)
% (bin->sizeW * SIZEOF_VOIDP)
!= 0), omError_FalseAddr);
/* Check that specified bin or size is correct */
omAddrCheckReturnError((flags & OM_FBIN) && bin_size != NULL
&& ((omBin) bin_size) != omGetTopBinOfAddr(addr), omError_WrongBin);
if ((flags & OM_FSIZE) && (!(flags & OM_FSLOPPY) || (size_t) bin_size > 0))
{
size_t size = (size_t) bin_size;
omAssume(!omIsBinAddrTrackAddr(addr));
omAddrCheckReturnError((bin->sizeW << LOG_SIZEOF_LONG) < OM_ALIGN_SIZE(size), omError_WrongSize);
}
return omError_NoError;
}
size
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition cf_ops.cc:600
omGetTopBinOfAddr
#define omGetTopBinOfAddr(addr)
Definition omAllocPrivate.h:78
SIZEOF_OM_BIN_PAGE_HEADER
#define SIZEOF_OM_BIN_PAGE_HEADER
Definition omAllocPrivate.h:31
omFindRegionOfAddr
omBinPageRegion omFindRegionOfAddr(void *addr)
Definition omBinPage.c:578
omIsAddrOnFreeBinPage
int omIsAddrOnFreeBinPage(void *addr)
Definition omBinPage.c:595
omGetBinPageOfAddr
#define omGetBinPageOfAddr(addr)
Definition omBinPage.h:22
OM_FBINADDR
#define OM_FBINADDR
Definition omDebug.h:40
omAddrCheckReturnCorrupted
#define omAddrCheckReturnCorrupted(cond)
Definition omDebug.h:188
OM_FUSED
#define OM_FUSED
Definition omDebug.h:34
omIsInKeptAddrList
int omIsInKeptAddrList(void *addr)
Definition omDebugTrack.c:743
omError_FreedAddr
@ omError_FreedAddr
Definition omError.h:27
omError_FreedAddrOrMemoryCorrupted
@ omError_FreedAddrOrMemoryCorrupted
Definition omError.h:28
omError_FalseAddr
@ omError_FalseAddr
Definition omError.h:24
omIsOnList
#define omIsOnList(ptr, addr)
Definition omList.h:68
omBinPageRegion
omBinPageRegion_t * omBinPageRegion
Definition omStructs.h:20

## omDoCheckBinPage()

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.

{
omBin bin;
omCheckReturn(omCheckPtr(page, report, OM_FLR_VAL));
omCheckReturnCorrupted(! omIsAddrPageAligned(page));
omCheckReturn(omCheckPtr(page->region, report, OM_FLR_VAL));
omCheckReturnCorrupted(level > 1 && omFindRegionOfAddr(page) != page->region);
#ifdef OM_HAVE_TRACK
if (! normal_page)
{
omCheckReturnCorrupted(! omIsSetTrackOfUsedBlocks(page->used_blocks));
}
else
#endif
omAssume(normal_page);
bin = omGetTopBinOfPage(page);
if (bin->max_blocks > 1)
{
omCheckReturnCorrupted(omGetUsedBlocksOfPage(page) > bin->max_blocks - 1);
omCheckReturnCorrupted(omGetUsedBlocksOfPage(page) == bin->max_blocks - 1 &&
page->current != NULL);
omCheckReturnCorrupted(omGetUsedBlocksOfPage(page) < 0);
}
else
{
omCheckReturnCorrupted(omGetUsedBlocksOfPage(page) != 0);
}
omCheckReturn(omCheckList(page->current, level, report, OM_FLR_VAL));
if (level > 1)
{
void* current = page->current;
omCheckReturnCorrupted(current != NULL &&
omListLength(current) != bin->max_blocks - omGetUsedBlocksOfPage(page) - 1);
while (current != NULL)
{
omCheckReturnCorrupted(omGetPageOfAddr(current) != page);
omCheckReturnCorrupted( ( ( (unsigned long) current)
- ((unsigned long) page)
- SIZEOF_OM_BIN_PAGE_HEADER)
% (bin->sizeW * SIZEOF_LONG)
!= 0);
current = *((void**) current);
}
}
return omError_NoError;
}
omIsAddrPageAligned
#define omIsAddrPageAligned(addr)
Definition omBinPage.h:16
omGetPageOfAddr
#define omGetPageOfAddr(addr)
Definition omBinPage.h:19
omListLength
#define omListLength(ptr)
Definition omList.h:62

## omDoCheckLargeAddr()

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.

{
size_t r_size;
omAssume(! omIsBinPageAddr(addr));
omAssume(! omCheckPtr(addr, omError_NoError, OM_FLR));
omAddrCheckReturnError((flags & OM_FBIN) || (flags & OM_FBINADDR), omError_NotBinAddr);
omAddrCheckReturnError(level > 1 && omFindRegionOfAddr(addr) != NULL, omError_FreedAddrOrMemoryCorrupted);
r_size = omSizeOfLargeAddr(addr);
omAddrCheckReturnError(! OM_IS_ALIGNED(r_size), omError_FalseAddrOrMemoryCorrupted);
omAddrCheckReturnError(r_size <= OM_MAX_BLOCK_SIZE, omError_FalseAddrOrMemoryCorrupted);
omAddrCheckReturnError((flags & OM_FSIZE) && r_size < OM_ALIGN_SIZE((size_t) bin_size),
omError_WrongSize);
omAddrCheckReturnError((level > 1) && (flags & OM_FUSED) && omIsInKeptAddrList(addr), omError_FreedAddr);
return omError_NoError;
}
omSizeOfLargeAddr
size_t omSizeOfLargeAddr(void *addr)
Definition omAllocSystem.c:105
omError_NotBinAddr
@ omError_NotBinAddr
Definition omError.h:31
omError_FalseAddrOrMemoryCorrupted
@ omError_FalseAddrOrMemoryCorrupted
Definition omError.h:25
OM_MAX_BLOCK_SIZE
#define OM_MAX_BLOCK_SIZE
Definition omTables.c:31

## omIterateTroughAddrs()

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

Definition at line 503 of file omDebugCheck.c.

{
int i;
omSpecBin s_bin;
omBin sticky;
if (normal)
{
for (i=0; i<=OM_MAX_BIN_INDEX; i++)
{
omIterateTroughBinAddrs(&om_StaticBin[i], CallBackUsed, CallBackFree);
}
s_bin = om_SpecBin;
while (s_bin != NULL)
{
omIterateTroughBinAddrs(s_bin->bin, CallBackUsed, CallBackFree);
s_bin = s_bin->next;
}
}
#ifdef OM_HAVE_TRACK
if (track)
{
for (i=0; i<=OM_MAX_BIN_INDEX; i++)
{
omIterateTroughBinAddrs(&om_StaticTrackBin[i], CallBackUsed, CallBackFree);
}
s_bin = om_SpecTrackBin;
while (s_bin != NULL)
{
omIterateTroughBinAddrs(s_bin->bin, CallBackUsed, CallBackFree);
s_bin = s_bin->next;
}
}
#endif
sticky = om_StickyBins;
while (sticky != NULL)
{
omIterateTroughBinAddrs(sticky, CallBackUsed, CallBackFree);
sticky = sticky->next;
}
}
omIterateTroughBinAddrs
void omIterateTroughBinAddrs(omBin bin, void(*CallBackUsed)(void *), void(*CallBackFree)(void *))
Definition omDebugCheck.c:464

## omIterateTroughBinAddrs()

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

Definition at line 464 of file omDebugCheck.c.

{
omBinPage page;
char* addr;
int is_free;
int i;
do
{
page = bin->last_page;
while (page != NULL)
{
addr = (char*) page + SIZEOF_OM_BIN_PAGE_HEADER;
i = 0;
do
{
is_free = omIsOnList(page->current, addr) != NULL
|| omIsInKeptAddrList(addr);
if (is_free)
{
if (CallBackFree != NULL) CallBackFree(addr);
}
else
{
if (CallBackUsed != NULL) CallBackUsed(addr);
}
addr = (char *)((char**) addr) + bin->sizeW;
i++;
} while (i < bin->max_blocks);
page = page->prev;
}
if (omIsStickyBin(bin))
bin = NULL;
else
bin = bin->next;
} while (bin != NULL);
}

## omPrintAddrInfo()

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

Definition at line 453 of file omDebugCheck.c.

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

## omPrintUsedAddrs()

void omPrintUsedAddrs | ( | FILE * | fd,
|  | int | max )

Definition at line 565 of file omDebugCheck.c.

{
om_total_used_size = 0;
om_total_used_blocks = 0;
om_print_used_addr_fd = (fd == NULL ? stdout : fd);
om_print_frames = max;
omIterateTroughAddrs(1, 1, _omPrintUsedAddr, NULL);
fprintf(fd, "UsedAddrs Summary: UsedBlocks:%ld TotalSize:%ld\n",
om_total_used_blocks, (long)om_total_used_size);
}
max
static int max(int a, int b)
Definition fast_mult.cc:264
_omPrintUsedAddr
static void _omPrintUsedAddr(void *addr)
Definition omDebugCheck.c:551
omIterateTroughAddrs
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.

{
om_total_used_size = 0;
om_total_used_blocks = 0;
om_print_used_addr_fd = (fd == NULL ? stdout : fd);
om_print_frames = max;
omIterateTroughAddrs(0, 1 , _omPrintUsedAddr, NULL);
fprintf(fd, "UsedTrackAddrs Summary: UsedBlocks:%ld TotalSize:%ld\n",
om_total_used_blocks, (long)om_total_used_size);
}

## 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.

{
int max_check, max_track;
va_list ap;
va_start(ap, fmt);
/* reset MaxTrack and MaxCheck to prevent infinite loop, in case
printf allocates memory */
max_check = om_Opts.MaxCheck;
max_track = om_Opts.MaxTrack;
om_Opts.MaxCheck = 0;
om_Opts.MaxTrack = 0;
om_CallErrorHook = 0;
omReportError(error, report_error, OM_FLR_VAL, fmt, ap);
om_CallErrorHook = 1;
if ((error!=omError_NotBinAddr)&&(error!=omError_FreedAddr))
_omPrintAddrInfo(stderr, error, addr, bin_size, flags, 10, " occurred for");
om_Opts.ErrorHook();
om_Opts.MaxCheck = max_check;
om_Opts.MaxTrack = max_track;
return om_ErrorStatus;
}
ap
Definition ap.h:40
om_ErrorStatus
omError_t om_ErrorStatus
Definition omError.c:13
om_CallErrorHook
int om_CallErrorHook
Definition omError.c:77
omReportError
omError_t omReportError(omError_t error, omError_t report_error, OM_FLR_DECL, const char *fmt,...)
Definition omError.c:80
om_Opts
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.