delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/05/13/03:53:27

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f
Message-ID: <001001c1fa53$37d5c2b0$0102a8c0@acceleron>
From: "Andrew Cottrell" <acottrel AT ihug DOT com DOT au>
To: <djgpp-workers AT delorie DOT com>
Cc: "Andris Pavenis" <pavenis AT latnet DOT lv>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1020513073555 DOT 8317A-100000 AT is>
Subject: C++ Debugging Quirk/Problem (was Re: Debugging Problem with win2k (fwd) )
Date: Mon, 13 May 2002 17:52:34 +1000
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Reply-To: djgpp-workers AT delorie DOT com

Eli & Andris,

There still appears to be problems with GCC 3.04 & GDB 5.2 (Rhide) debugging
C++ apps. I have tried the source (test.cpp) code below in Rhide 1.5.0
snaphot dated 30-Apr-2002 with GCC 3.04 and it appears that the C++
debugging output is not quite working correctly in Rhide. I can step over
the lines, but cannot set a breakpoint on a line and go to the line. Eli,
Rhide 1.5.0 uses GDB 5.2.

I used the compiler debugging options in Rhide as Eli suggested "-gstabs+".
When I used this I could step through the code, but I could not set a
breakpoint on a line and go to the line. If I use "-gstabs2" then it appears
to be the same as "-gstabs+". If I use "-g2" option I cannot debug, but this
option works okay on C programs.

I tried some other debugging options and found that "-gdwarf-2" allowed
setting breakponts on a line and go to the line. Looks like this one work
the best. I didn't try it with classes or in templates.

Now for the hard questions:-
    With GCC 3.04 and GDB 5.2 what is the prefered (optimal/workable
etc....) switches for C++ debugging?

Any comments


======================== SAMPLE APP START =========================
#include <iostream.h>

int main()
{
    int a = 1;
    cout << a << endl;

    cout << "This is a test" << endl;
    cout << "This is a test" << (a * a) << endl;

    return 0;
}

======================== SAMPLE APP END =========================
Below is the cut down original problem as reported by the end user.
----- Original Message -----
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
To: <jwvm AT umich DOT edu>
> > > From: "JWV Miller" <jwvm AT umich DOT edu>
> > > Date: Sun, 12 May 2002 11:16:56 -0400
> > >
> > > Take your pick. It fails with all programs. Here is a trivial example:
> > >
> > > #include <iostream.h>
> > >
> > > int main()
> > > {
> > >     int a = 1;
> > >     cout << a << endl;
> > >     return 0;
> > > }
> >
> > I cannot reproduce the problem, at least not with command-line
> > compilation and GDB as the debugger (I don't have RHIDE installed, so
> > I couldn't try that).
> >
> > What compilation switches did you try to build the program?  Did you
> > actually link it to produce a .exe file, or just compiled the source
> > into an object file?  What debugging switches did you use (like I use
> > "-gstabs+" in the example below)?
> >
> > Below is what I tried with this short program.  As you see, I can
> > successfully step through the program line by line.
> >
> >   c:\> gpp -gstabs+ testcpp.cc -o testcpp.exe
> >   c:\> gdb ./testcpp.exe
> >   GNU gdb 5.1.1
> >   Copyright 2002 Free Software Foundation, Inc.
> >   GDB is free software, covered by the GNU General Public License, and
you
> are
> >   welcome to change it and/or distribute copies of it under certain
> conditions.
> >   Type "show copying" to see the conditions.
> >   There is absolutely no warranty for GDB.  Type "show warranty" for
> details.
> >   This GDB was configured as "i386-pc-msdosdjgpp"...
> >   (gdb) break main
> >   Breakpoint 1 at 0x15e9: file testcpp.cc, line 5.
> >   (gdb) run
> >   Starting program: d:/usr/djgpp/gnu/eli/rmail/./testcpp.exe
> >
> >   Breakpoint 1, main () at cppt2.cc:5
> >   5           int a = 1;
> >   (gdb) next
> >   6           cout << a << endl;
> >   (gdb) next
> >   1
> >   7           return 0;
> >   (gdb) next
> >   8       }
> >   (gdb) next
> >   0x000051f2 in __crt1_startup ()
> >       at d:/usr/djgpp/lang/cxx-v3/bits/locale_facets.tcc:75
> >   75            const locale::facet* __fp = (*__facet)[__i];
> >   (gdb) next
> >
> >   Program exited normally.
> >   (gdb) q


- Raw text -


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