From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16712 invoked by alias); 27 Sep 2012 11:43:02 -0000 Received: (qmail 16703 invoked by uid 22791); 27 Sep 2012 11:43:01 -0000 X-SWARE-Spam-Status: No, hits=-3.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,SARE_SPEC_REPL_OBFU1 X-Spam-Check-By: sourceware.org Received: from mail-pb0-f41.google.com (HELO mail-pb0-f41.google.com) (209.85.160.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 27 Sep 2012 11:42:58 +0000 Received: by pbbrq2 with SMTP id rq2so3755754pbb.0 for ; Thu, 27 Sep 2012 04:42:57 -0700 (PDT) Received: by 10.68.242.42 with SMTP id wn10mr10529788pbc.105.1348746177855; Thu, 27 Sep 2012 04:42:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.66.80.134 with HTTP; Thu, 27 Sep 2012 04:42:37 -0700 (PDT) From: "Laurent G." Date: Thu, 27 Sep 2012 11:43:00 -0000 Message-ID: Subject: Delete a watchpoint by address to automate segfault tracking To: gdb@sourceware.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2012-09/txt/msg00075.txt.bz2 Hi, I'm debugging a segfault in a pretty large real-time program (the kind of which we can't figure out what's wrong just by looking at the code). In short, I know where the program crash (non-valid pointer) but I don't known who and when my pointer gets corrupted, as the program alloc & destroy 2/3 similar buffers by second. I find out a nice technique is this article (http://www.outflux.net/blog/archives/2007/09/15/catching-stack-overflows-i= n-gdb-as-they-happen/) which automate the creation of watchpoint on malloced buffer: (gdb) commands 1 >silent >set variable $m =3D p_mypointer >watch *$m >cont >end In the article, the author says "I couldn=92t find an easy way to track the memory watch number that was created during the first breakpoint, I just built a gdb counter, and deleted the memory watch when leaving, since I could predict gdb=92s numbering" and implements watchpoints destruction this way: (gdb) set variable $count =3D 3 (gdb) commands 2 >silent >delete $count >set variable $count =3D $count + 1 >cont >end This technique works well when the buffers get destroyed in the same order than there are created. But in my program this is not the case. =46rom the value passed to free() I can get the memory address of the to-be-destroyed buffer, but I couldn't find a way to tell GDB to delete that specific watchpoint: (gdb) delete *0x080483c6 -> OK but can't be automated (gdb) set variable $d =3D p_mypointer (gdb) p $d 0x080483c6 (gdb) d $d -> Can't do. "Convenience variables used in line specs must have integer values." How can I do a "delete *`print $d`" in GDB? Thanks! Regards, Laurent