From owner-freebsd-hackers Wed Apr 8 09:38:18 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id JAA06698 for freebsd-hackers-outgoing; Wed, 8 Apr 1998 09:38:18 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from citadel.cdsec.com (citadel.cdsec.com [192.96.22.18]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA06577 for ; Wed, 8 Apr 1998 09:38:00 -0700 (PDT) (envelope-from gram@cdsec.com) Received: (from nobody@localhost) by citadel.cdsec.com (8.8.5/8.6.9) id SAA29554 for ; Wed, 8 Apr 1998 18:43:10 +0200 (SAT) Received: by citadel via recvmail id 29516; Wed Apr 8 18:42:15 1998 From: Graham Wheeler Message-Id: <199804081642.SAA06272@cdsec.com> Subject: Re: Debugging new/delete for C++ (fwd) To: hackers@FreeBSD.ORG Date: Wed, 8 Apr 1998 18:42:15 +0200 (SAT) X-Mailer: ELM [version 2.4 PL25-h4.1] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > ------- 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