This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: conditional breakpoint with (char* ) string condition


On Fri, 2006-05-12 at 21:24 +0300, Eli Zaretskii wrote:
> > From: PAUL GILLIAM <pgilliam@us.ibm.com>
> > Cc: Eli Zaretskii <eliz@gnu.org>, Fabio De Bona <Auslieferator@gmx.net>,
> >         gdb@sources.redhat.com
> > Date: Fri, 12 May 2006 08:05:32 -0700
> > 
> > How about strlen as well?
> 
> Where would it be useful?

Here is an admittedly contrived example. Say we had a target program
that was writing a 'progress meter' to stderr with the following code:

        void progress_tick (buf)
        {
          void strcat (buf, ".");
          fprintf (stderr, "\r%s", buf);
        }
        
        main ()
        {
          char progress[1024] = { 0 };
          . . .
          while ( ! done)
          {
            progress_tick (progress);
            real_work ();
          }
        
          return 0;
        }
        
Then in GDB you could do this:

        start
        b real_work if $_strlen(progress) >= 5
        

Yes, this example might not be 'real world', but strlen just seems to go
with strcmp.
 
-=# Paul #=-


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]