Date: Wed, 8 Apr 1998 18:42:15 +0200 (SAT) From: Graham Wheeler <gram@cdsec.com> To: hackers@FreeBSD.ORG Subject: Re: Debugging new/delete for C++ (fwd) Message-ID: <199804081642.SAA06272@cdsec.com>
next in thread | raw e-mail | index | archive | help
> ------- debug.cc ------------------------------------------------------- ... > > // we make separate ones for construct/destruct to ease debugging > // using leak IDs and breakpoints > > static void TraceC(char *op, long id, char *name, char *where, int lnum) > { > Trace(op, id, name, where, lnum); > } > > static void TraceD(char *op, long id, char *name, char *where, int lnum) > { > Trace(op, id, name, where, lnum); > } I forgot to mention - this can be quite useful. After running findleak, if it reports any errors it will also report the ID associated with the allocation or deallocation that caused the error. This ID should be unique. If you rerun your program with the same inputs, assuming there is no behaviour dependent on other factors (such as timing or random numbers), you should be able to set a breakpoint on either TraceC or TraceD with the condition that the id parameter equals the ID you are interested in, and get the debugger to stop the program at the offending allocation or deallocation. -- Dr Graham Wheeler E-mail: gram@cdsec.com Citadel Data Security Phone: +27(21)23-6065/6/7 Internet/Intranet Network Specialists Mobile: +27(83)-253-9864 Firewalls/Virtual Private Networks Fax: +27(21)24-3656 Data Security Products WWW: http://www.cdsec.com/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199804081642.SAA06272>