📄 diag.c
字号:
__mp_diag(" (" MP_POINTER ") ", i->variant.logfree.block); logcall(h, i, 0); break; case LT_SET: __mp_diag(" (" MP_POINTER ", ", i->variant.logmemset.block); __mp_printsize(i->variant.logmemset.size); __mp_diag(", 0x%02X) ", i->variant.logmemset.byte); logcall(h, i, 0); break; case LT_COPY: __mp_diag(" (" MP_POINTER ", " MP_POINTER ", ", i->variant.logmemcopy.srcblock, i->variant.logmemcopy.dstblock); __mp_printsize(i->variant.logmemcopy.size); __mp_diag(", 0x%02X) ", i->variant.logmemcopy.byte); logcall(h, i, 0); break; case LT_LOCATE: __mp_diag(" (" MP_POINTER ", ", i->variant.logmemlocate.block); __mp_printsize(i->variant.logmemlocate.size); __mp_diag(", " MP_POINTER ", ", i->variant.logmemlocate.patblock); __mp_printsize(i->variant.logmemlocate.patsize); __mp_diag(") "); logcall(h, i, 0); break; case LT_COMPARE: __mp_diag(" (" MP_POINTER ", " MP_POINTER ", ", i->variant.logmemcompare.block1, i->variant.logmemcompare.block2); __mp_printsize(i->variant.logmemcompare.size); __mp_diag(") "); logcall(h, i, 0); break; case LT_MAX: __mp_diag(" () "); logcall(h, i, 0); break; } }}/* Display the details of all allocation nodes on the allocation tree. */MP_GLOBALvoid__mp_printallocs(infohead *h, int e){ allocnode *n; treenode *t; char f; f = 0; if (e != 0) { /* We are now displaying the allocation nodes for a second * time, except this time to the standard error stream. If * the log file is already on standard error then don't bother * displaying them again. */ if (logfile == stderr) { h->fini = 1; __mp_abort(); } __mp_closelogfile(); __mp_diagflags &= ~FLG_HTML; __mp_diag("\nALLOC:"); if (h->alloc.heap.memory.prog != NULL) __mp_diag(" %s:", h->alloc.heap.memory.prog); __mp_diag("\n"); } __mp_diag("\nunfreed allocations: %lu (", h->alloc.atree.size - h->mcount); __mp_printsize(h->alloc.asize - h->mtotal); __mp_diag(")\n"); for (t = __mp_minimum(h->alloc.atree.root); t != NULL; t = __mp_successor(t)) { n = (allocnode *) ((char *) t - offsetof(allocnode, tnode)); if (!(((infonode *) n->info)->data.flags & FLG_MARKED)) { if (f == 0) f = 1; else __mp_diag("\n"); __mp_printalloc(&h->syms, n); } } if (e != 0) { h->fini = 1; __mp_abort(); }}/* Display the details of all allocation nodes on the freed tree. */MP_GLOBALvoid__mp_printfreed(infohead *h){ allocnode *n; treenode *t; char f; f = 0; __mp_diag("\nfreed allocations: %lu (", h->alloc.gtree.size); __mp_printsize(h->alloc.gsize); __mp_diag(")\n"); for (t = __mp_minimum(h->alloc.gtree.root); t != NULL; t = __mp_successor(t)) { n = (allocnode *) ((char *) t - offsetof(allocnode, tnode)); if (f == 0) f = 1; else __mp_diag("\n"); __mp_printalloc(&h->syms, n); }}/* Display the details of all free blocks. */MP_GLOBALvoid__mp_printfree(infohead *h){ allocnode *n, *p; treenode *s, *t; size_t c; __mp_diag("\nfree blocks: %lu (", h->alloc.ftree.size); __mp_printsize(h->alloc.fsize); __mp_diag(")\n"); for (t = __mp_maximum(h->alloc.ftree.root); t != NULL; t = s) { n = (allocnode *) ((char *) t - offsetof(allocnode, tnode)); s = t; c = 0; do { if (s = __mp_predecessor(s)) p = (allocnode *) ((char *) s - offsetof(allocnode, tnode)); else p = NULL; c++; } while ((p != NULL) && (p->size == n->size)); __mp_diag(" %8lu: %lu\n", n->size, c); }}/* Display the details of a leak table node. */staticvoidprintleakinfo(tablenode *n, size_t *a, size_t *b, int o, int c){ size_t i, j; if (o == SOPT_ALLOCATED) { i = n->data.acount; j = n->data.atotal; } else if (o == SOPT_FREED) { i = n->data.dcount; j = n->data.dtotal; } else { i = n->data.acount - n->data.dcount; j = n->data.atotal - n->data.dtotal; } if (c != 0) __mp_diag(" %6lu %8lu ", i, j); else __mp_diag(" %8lu %6lu ", j, i); if ((n->data.file != NULL) && (n->data.line != 0)) __mp_diag("%s line %lu\n", n->data.file, n->data.line); else if (n->data.file != NULL) __mp_diag("%s\n", n->data.file); else if (n->data.line != 0) __mp_diag(MP_POINTER "\n", n->data.line); else __mp_diag("unknown location\n"); *a += i; *b += j;}/* Display the leak table. */MP_GLOBALvoid__mp_printleaktab(infohead *h, size_t l, int o, unsigned char f){ tablenode *n; treenode *t; char *s; size_t b, c; __mp_sortleaktab(&h->ltable, o, (f & FLG_COUNTS)); if ((l == 0) || (l > h->ltable.tree.size)) l = h->ltable.tree.size; if (o == SOPT_ALLOCATED) s = "allocated"; else if (o == SOPT_FREED) s = "freed"; else s = "unfreed"; if (l == 0) { __mp_diag("no %s memory entries in leak table\n", s); return; } __mp_diag("%s %lu %s memory %s in leak table:\n\n", (f & FLG_BOTTOM) ? "bottom" : "top", l, s, (l == 1) ? "entry" : "entries"); if (f & FLG_COUNTS) { __mp_diag(" count bytes location\n"); __mp_diag(" ------ -------- --------\n"); } else { __mp_diag(" bytes count location\n"); __mp_diag(" -------- ------ --------\n"); } b = c = 0; if (f & FLG_BOTTOM) for (t = __mp_minimum(h->ltable.tree.root); (t != NULL) && (l != 0); t = __mp_successor(t), l--) { n = (tablenode *) ((char *) t - offsetof(tablenode, data.tnode)); printleakinfo(n, &c, &b, o, (f & FLG_COUNTS)); } else for (t = __mp_maximum(h->ltable.tree.root); (t != NULL) && (l != 0); t = __mp_predecessor(t), l--) { n = (tablenode *) ((char *) t - offsetof(tablenode, data.tnode)); printleakinfo(n, &c, &b, o, (f & FLG_COUNTS)); } if (f & FLG_COUNTS) __mp_diag(" %6lu %8lu total\n", c, b); else __mp_diag(" %8lu %6lu total\n", b, c);}/* Display a complete memory map of the heap. */MP_GLOBALvoid__mp_printmap(infohead *h){ allocnode *n; infonode *m; void *a, *b; size_t l, s; a = NULL; __mp_diag("memory map:\n"); for (n = (allocnode *) h->alloc.list.head; n->lnode.next != NULL; n = (allocnode *) n->lnode.next) { m = (infonode *) n->info; if ((h->alloc.flags & FLG_PAGEALLOC) && (m != NULL)) { b = (void *) __mp_rounddown((unsigned long) n->block, h->alloc.heap.memory.page); l = __mp_roundup(n->size + ((char *) n->block - (char *) b), h->alloc.heap.memory.page); } else { b = n->block; l = n->size; } if (m != NULL) { b = (char *) b - h->alloc.oflow; l += h->alloc.oflow << 1; } if ((a != NULL) && (a < b)) {#if ENVIRON == ENVIRON_64 __mp_diag(" ------------------------------------- gap (");#else /* ENVIRON */ __mp_diag(" --------------------- gap (");#endif /* ENVIRON */ __mp_printsize((char *) b - (char *) a); __mp_diag(")\n"); } if (m != NULL) if (h->alloc.oflow > 0) { s = (char *) n->block - (char *) b; __mp_diag(" / " MP_POINTER "-" MP_POINTER " overflow (", b, (char *) b + s - 1); __mp_printsize(s); __mp_diag(")\n |+ "); } else __mp_diag(" + "); else __mp_diag("--- "); __mp_diag(MP_POINTER "-" MP_POINTER, n->block, (char *) n->block + n->size - 1); if (m == NULL) __mp_diag(" free ("); else if (m->data.flags & FLG_FREED) __mp_diag(" freed ("); else __mp_diag(" allocated ("); __mp_printsize(n->size); __mp_diag(")"); if (m != NULL) { __mp_diag(" "); __mp_printtype(m); __mp_diag(" "); __mp_printloc(m); if ((m->data.typestr != NULL) && (m->data.typesize != 0)) { __mp_diag(" "); __mp_printtypeinfo(m, n->size); } if (h->alloc.oflow > 0) { s = l - n->size - s; __mp_diag("\n \\ " MP_POINTER "-" MP_POINTER " overflow (", (char *) n->block + n->size, (char *) b + l - 1); __mp_printsize(s); __mp_diag(")"); } } __mp_diag("\n"); a = (char *) b + l; }}/* Display the version and copyright details. */MP_GLOBALvoid__mp_printversion(void){ __mp_diag("%s\n", __mp_version); if (__mp_diagflags & FLG_HTML) { __mp_diagtag("<BR>\n"); __mp_diag("%s ", __mp_copyright); __mp_diagtag("<A HREF=\"mailto:"); __mp_diagtag(__mp_email); __mp_diagtag("\">"); __mp_diag("%s", __mp_author); __mp_diagtag("</A>\n"); __mp_diagtag("<P>\n"); } else __mp_diag("%s %s\n\n", __mp_copyright, __mp_author); __mp_diag("This is free software, and you are welcome to redistribute it " "under certain\n"); __mp_diag("conditions; see the GNU Library General Public License for " "details.\n"); if (__mp_diagflags & FLG_HTML) __mp_diagtag("<P>"); __mp_diag("\nFor the latest mpatrol release and documentation,\n"); if (__mp_diagflags & FLG_HTML) { __mp_diag("visit "); __mp_diagtag("<A HREF=\""); __mp_diagtag(__mp_homepage); __mp_diagtag("\">"); __mp_diag("%s", __mp_homepage); __mp_diagtag("</A>.\n"); __mp_diagtag("<P>\n"); __mp_diagtag("<TABLE CELLSPACING=0 CELLPADDING=1 BORDER=1>\n"); __mp_diagtag("<TR>\n"); __mp_diagtag("<TD>"); __mp_diag("operating system"); __mp_diagtag("</TD>\n"); __mp_diagtag("<TD>"); __mp_diag("%s", TARGET_STR); __mp_diagtag("</TD>\n"); __mp_diagtag("</TR>\n"); __mp_diagtag("<TR>\n"); __mp_diagtag("<TD>"); __mp_diag("system variant"); __mp_diagtag("</TD>\n"); __mp_diagtag("<TD>"); __mp_diag("%s", SYSTEM_STR); __mp_diagtag("</TD>\n"); __mp_diagtag("</TR>\n"); __mp_diagtag("<TR>\n"); __mp_diagtag("<TD>"); __mp_diag("processor architecture"); __mp_diagtag("</TD>\n"); __mp_diagtag("<TD>"); __mp_diag("%s", ARCH_STR); __mp_diagtag("</TD>\n"); __mp_diagtag("</TR>\n"); __mp_diagtag("<TR>\n"); __mp_diagtag("<TD>"); __mp_diag("processor word size"); __mp_diagtag("</TD>\n"); __mp_diagtag("<TD>"); __mp_diag("%s", ENVIRON_STR); __mp_diagtag("</TD>\n"); __mp_diagtag("</TR>\n"); __mp_diagtag("<TR>\n"); __mp_diagtag("<TD>"); __mp_diag("object file format"); __mp_diagtag("</TD>\n"); __mp_diagtag("<TD>"); __mp_diag("%s", FORMAT_STR); __mp_diagtag("</TD>\n"); __mp_diagtag("</TR>\n"); __mp_diagtag("<TR>\n"); __mp_diagtag("<TD>"); __mp_diag("dynamic linker type"); __mp_diagtag("</TD>\n"); __mp_diagtag("<TD>"); __mp_diag("%s", DYNLINK_STR); __mp_diagtag("</TD>\n"); __mp_diagtag("</TR>\n"); __mp_diagtag("</TABLE>\n"); __mp_diagtag("<P>\n"); } else { __mp_diag("visit %s.\n\n", __mp_homepage); __mp_diag("operating system: %s\n", TARGET_STR); __mp_diag("system variant: %s\n", SYSTEM_STR); __mp_diag("processor architecture: %s\n", ARCH_STR); __mp_diag("processor word size: %s\n", ENVIRON_STR); __mp_diag("object file format: %s\n", FORMAT_STR); __mp_diag("dynamic linker type: %s\n\n", DYNLINK_STR); } if (!currenttime) currenttime = time(NULL); if (currenttime != (time_t) -1) { __mp_diag("Log file generated on %s", ctime(¤ttime)); if (__mp_diagflags & FLG_HTML) __mp_diagtag("<P>"); __mp_diag("\n"); }}/* Display a summary of all mpatrol library settings and statistics. */MP_GLOBAL
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -