From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9798 invoked by alias); 12 Jan 2009 12:57:04 -0000 Received: (qmail 9788 invoked by uid 22791); 12 Jan 2009 12:57:03 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,SARE_SPEC_REPL_OBFU1,SPF_PASS,WEIRD_PORT X-Spam-Check-By: sourceware.org Received: from smtpout.sgsi.ucl.ac.be (HELO smtp3.sgsi.ucl.ac.be) (130.104.5.77) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 12 Jan 2009 12:56:26 +0000 Received: from [130.104.228.14] (unknown [130.104.228.14]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jaradin@smtp3.sgsi.ucl.ac.be) by smtp3.sgsi.ucl.ac.be (Postfix) with ESMTPSA for ; Mon, 12 Jan 2009 13:56:17 +0100 (CET) Message-ID: <496B3DF1.2060303@uclouvain.be> Date: Mon, 12 Jan 2009 12:57:00 -0000 From: Yves Jaradin User-Agent: Thunderbird 2.0.0.18 (X11/20081125) MIME-Version: 1.0 To: gdb@sourceware.org Subject: Watching memory adress given by an expression Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AV-Checked: ClamAV using ClamSMTP X-Sgsi-Spamcheck: SASL authenticated, X-SGSI-MailScanner-ID: DE4ED1C7B5A.2C402 X-SGSI-MailScanner: Found to be clean X-SGSI-From: yves.jaradin@uclouvain.be X-SGSI-Spam-Status: No 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: 2009-01/txt/msg00055.txt.bz2 Hi, Recently, I stumbled upon a dangling pointer in some code I'm maintaining. The best reproducible crash was still very time sensitive (order of a few seconds at most), so I couldn't really debug interactively. Some structure on the heap was corrupted, so I set up a breakpoint when the structure was correctly initialized with commands to set up a watchpoint on the memory that would be corrupted. Unfortunately, the expression I had for the to-be-corrupted memory was going out of scope before the corruption. I resorted to this: break emulate.cc:316 ignore $bpnum 9 commands print entry x &(entry.pc) set $targetpc=$_ watch *($targetpc) continue end continue Which is ugly because: I works only for a single triggering of the breakpoint. It prints an extra value. The $_ business I'm doing is really a hack. I could remove the first problem using shell, source, etc. but this isn't cleaner. Is there a cleaner way to do this kind of debugging? I would have liked to have a command like: watchmem &(entry.pc) which would immediately evaluate it's expression to a pointer and set a watcher to the pointed space. Regards, Yves