Mail Archives: djgpp-workers/2002/05/13/03:53:27
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 -