From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32394 invoked by alias); 14 Mar 2007 18:03:35 -0000 Received: (qmail 32386 invoked by uid 22791); 14 Mar 2007 18:03:34 -0000 X-Spam-Check-By: sourceware.org Received: from mta01.pge.com (HELO mta01.pge.com) (131.89.129.71) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 14 Mar 2007 18:03:26 +0000 Received: from mta12.comp.pge.com (mta12.comp.pge.com [10.245.211.127]) by mta01.pge.com (Switch-3.2.4/Switch-3.2.4) with ESMTP id l2EI3HQk013774; Wed, 14 Mar 2007 11:03:18 -0700 (PDT) Received: from mdssdr01.utility.pge.com (mdssdr01.utility.pge.com [10.244.52.48]) by mta12.comp.pge.com (Switch-3.2.4/Switch-3.1.7) with ESMTP id l2EI3GsR014068; Wed, 14 Mar 2007 11:03:16 -0700 (PDT) Received: (from esp5@localhost) by mdssdr01.utility.pge.com (8.11.7p3+Sun/8.11.7) id l2EI3Hg04583; Wed, 14 Mar 2007 11:03:17 -0700 (PDT) Date: Wed, 14 Mar 2007 18:03:00 -0000 From: "Ed S. Peschko" To: Michael Veksler Cc: Eli Zaretskii , gdb@sourceware.org Subject: Re: dynamic breakpoints/watchpoints Message-ID: <20070314180317.GA3771@venus> References: <20070314002242.GB17710@venus> <20070314083409.GA21561@venus> <45F7BE52.8020409@tx.technion.ac.il> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <45F7BE52.8020409@tx.technion.ac.il> User-Agent: Mutt/1.4.2.1i 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: 2007-03/txt/msg00201.txt.bz2 On Wed, Mar 14, 2007 at 11:20:18AM +0200, Michael Veksler wrote: > Ed S. Peschko wrote: > >For example, > > > >int main() > >{ > > ==> int stuff; > > aha(); > > aha2(); > >} > > > > > >int aha() > >{ > > fprintf(stderr, "HERE1"); > >} > > > >int aha2() > >{ > > fprintf(stderr, "HERE"); > >} > > > >Suppose that I'm at the '==>'. if I say bc /HERE/", I would break in the > >function 'aha', at the fprintf statement HERE1'. If I said bc /HERE/ at > >THAT > >point, then I'd break at 'HERE2'. The breakpoint changes as you go along. > > > What I usually do is use emacs' tags system to search for the string, > and then manually put breakpoints at the relevant locations. This works > well when there is only couple of matching lines. Well, yeah, of course there are workarounds, but they are IMO messy and hard to deal with. Instead of setting up tags, or grepping through code, doing a code match in the debugger is far easier. That's why I wrote it for perl in the first place, I got sick of doing these workarounds. Plus, I'm not sure if the tags solution is complete. Tags normally only handles function calls, declarations, etc. as I understand it. How do you make breakpoints for statements inside function calls using it without grepping through the code and manufacturing breakpoints using some sort of scripting? > My normal use case is: > > 1. An error text is printed, or some activity is logged into a file. > 2. I want to stop right at the place that caused that behavior. So I > perform the following: > 1. Try to guess how the relevant code looks like > 2. Look for all occurrences of such code using grep/tags > 3. If search result is too wide or too narrow go to step i. > 4. Break at all relevant locations > > This process is quite long and prone to errors. It would be much better > if it were integrated into gdb+libc+libstdc++ in the following way: > > 1. libc+libstdc++ will have hooks that gdb will be able to use to > intercept FILE/stream writes. > 2. A slower alternative to 1 is for for GDB to intercept write system > calls, and check their contents. To improve granularity in C, > buffering should be set to line granularity. In C++, buffering > should be eliminated (unless people use std::endl instead of the > much better "\n"). > 3. GDB will stop at each write, and look for the requested text. If > the text is encountered - break. look, I agree.. having some searching ability is better than none at all, and if it is easy to implement this then maybe that is the way to go. But it's incredibly comforting in perl to have a universal search (in perl this is of course integrated with regular expressions). I know that no matter what I search for, I'll find it as soon as the data is matched. And true, its slow as hell because everything is interpreted, but it would be far slower for me to track it down manually. For gcc and gdb, I'd be willing to build my own special compiler instance to carry this functionality, and avoid the overhead for my regular compiles by having ifdefs in the gcc code . Another point - unless this functionality is to be linux only, I'd be hesitant to put the change into libstdc++ and/or glibc. glibc is NOTORIOUSLY unportable, and is far from universal. > provided by the libstdc++ team. They could add an strcmp looking for the > requested string, every time the string is mutated, and then GDB will be > able to break on a match. Other data-types are more complicated, and > most of them are impractical candidates for dynamic watchpoints (unless > GCC is heavily modified to insert hooks for all updates to, for example, > int variables - this will be slow as hell). yeah, but as I indicated above, I think that patching gcc would be probably the only way to get widespread portability. Ed