delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/04/12/05:15:36

Date: Thu, 12 Apr 2001 12:15:50 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Dennis Yelle <dennis51 AT jps DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: gdb still doesn't work for me
In-Reply-To: <3AD5216F.128D108C@jps.net>
Message-ID: <Pine.SUN.3.91.1010412121455.15826C-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Wed, 11 Apr 2001, Dennis Yelle wrote:
> > Instead, it stops here:
> > 
> >    count += 2;
> > 
> > which is _after_ Paths::car7() was called.
> 
> Yes, that is another thing I have noticed several times with
> different versions of gdb.  I set a breakpoint and run, and
> the program either runs to completion, or stops someplace other
> than the place where I put the breakpoint.  This is one of
> the reasons I just concluded that gdb was unusable, and so
> I didn't ever try very hard to use it.

You need to be aware that debugging C++ code, and optimized C++ code
on top of that, is a tricky business.  GDB is certainly _not_
unusable, but it has some problems with C++ programs.  The default
DJGPP COFF debugging info is totally inappropriate for debugging C++,
as Hans-Bernhard told you (this is in the DJGPP FAQ list, btw).  Stabs
are better, but some bleeding-edge C++ features are not supported well
enough even by stabs.

I believe the next GDB version will support C++ a whole lot better,
but in the meanwhile, you shouldn't draw too general conclusions from
a single program that seems to reveal some of the difficulties.  You
should instead try a slightly different approach, a different set of
compiler switches, and of course you are welcome to ask questions
here.

Don't give up on GDB: its power is more than enough to debug even the
most tricky problems!

> > Another way is to not use the `n'
> > command, and instead use "tb +1" and "c" commands.  The first sets a
> > temporary breakpoint on the next source line, the second runs the
> > program until that breakpoint.
> 
> Well, OK, so, is there a way to define a single character command that
> will do the equivalent of the "tb +1" and "c" commands?

The GDB scripting language lets you define your own commands:

  (gdb) define z
  >tb +1
  >c
  >end

Now you have a command `z' which will do this.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019