tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: Richard Jackson <rjackson () portal ! gmu ! edu>
To: tru64-unix-managers
Subject: SUMMARY: GCC 2.95.1 and 2.95.2 step into iostream via gdb
Date: Sun, 11 Jun 2000 20:08:47 +0000	[thread overview]
Message-ID: <96086825814635.tru64-unix-managers.marc@archive.invalid> (raw)

Hello,

SUMMARY:
------------------------------------------------------------------------
The problem with gdb stepping into a function instead of over with the
gdb next command when used with gcc 2.95.1 and 2.95.2 is a gcc bug
specific to the Alpha.  A fix was added to the development version of
gcc recently.  I have not verified this but I will once the next
release of gcc is available.  A gdb work-around is noted below in Debra
Alpert's response.
------------------------------------------------------------------------

---
Regards,
Richard Jackson
Computer Center Lead Engineer,
Central Systems & Dept. UNIX Consulting
University Computing & Information Systems (UCIS)
George Mason University, Fairfax, Virginia

RESPONDERS:
------------------------------------------------------------------------
Andrew Hobson <ahobson@eng.mindspring.net>
Debra Alpert <alpert@fas.harvard.edu>
Larry Griffith <larry@cs.wsc.ma.edu>
------------------------------------------------------------------------

QUESTION:
------------------------------------------------------------------------
I noted that gdb 4.16, 4.18, and 20000314 all step into gcc 2.95.2
(g++) and gcc 2.95.1 iostream via a next.  However, compiling with gcc
2.8.1 and using gdb does not step into iostream.  Is this a bug or
configuration problem with gcc or gdb?  It seems it maybe a gcc
problem.  We are using AlphaServers running Digital UNIX 4.0D.
However, under Solaris 2.7 with gdb 19990712 and gcc 2.95.2 it works
fine.  I posted this question to gnu.gcc.bug (USENET) and the response
back is 'The debug info being produced by the compiler on your
AlphaServers must be wrong.'  I reported the possible bug to 
gcc-bugs@gcc.gnu.org without a response.

Reduced program to test, test.cpp:
--------------------------------------
#include <iostream>

int main ()
{
   cout << "\nStarting main";
   cout << "\nLeaving main";
   return 0;
}
--------------------------------------

Test to reproduce problem:
g++ -g test.cpp
gdb a.out
break main
run
n
n
q

Does anyone have any suggestions?

This is the gdb session using the students real program:
--------------------------------------
GNU gdb 20000314
Copyright 1998 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 "alphaev56-dec-osf4.0d"...
(gdb) break main
Breakpoint 1 at 0x12000b5d8: file created.cpp, line 23.
(gdb) run
Starting program: /home/u3/rjackson/cpp/a.out

Constructor for obj
Breakpoint 1, main () at created.cpp:23
23         cout << "\nStarting main";
(gdb) n
ostream::operator<< (this=0x14000eac0, s=0x140006c20 "")
    at /usr/local/src/gcc_2.95.2/gcc-2.95.2/libio/iostream.cc:816
816     {
(gdb) n
ostream::operator<< (this=0x1400003f8, s=0x140005568 "\nStarting main")
    at /usr/local/src/gcc_2.95.2/gcc-2.95.2/libio/iostream.cc:817
817       if (opfx())
(gdb) quit
The program is running.  Exit anyway? (y or n) y
--------------------------------------

On a Solaris system gdb next works as expected.

--------------------------------------
GNU gdb 19990712
Copyright 1998 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 "sparc-sun-solaris2.7"...
(gdb) break main
Breakpoint 1 at 0x12054: file created.cpp, line 20.
(gdb) run
Starting program: /home/rjackson/a.out


Breakpoint 1, main () at created.cpp:20
20         cout << "\nStarting main";
(gdb) n
Constructor for obj 1 called
21         simpleObj obj2 (2);            // main local automatic object
(gdb) n
Starting main
Constructor for obj 2 called
23         somefunc();                   //  function call
(gdb) q
The program is running.  Exit anyway? (y or n) y
--------------------------------------
------------------------------------------------------------------------

RESPONSES:
------------------------------------------------------------------------
From Andrew Hobson <ahobson@eng.mindspring.net>:
It's a bug in gcc that it just so happens was fixed in the development
version of gcc yesterday.  I'd guess that the gcc 3.0 release will
have this fix in it.

http://gcc.gnu.org/ml/gcc-patches/2000-05/msg01282.html

and

http://gcc.gnu.org/ml/gcc-patches/2000-05/msg01285.html
------------------------------------------------------------------------
From Debra Alpert <alpert@fas.harvard.edu>:
We noticed a similar problem on our systems. The detailed description is
available at the URL:

http://sourceware.cygnus.com/ml/bug-gdb/1999-10/msg00048.html.

One of the responses,

http://sourceware.cygnus.com/ml/bug-gdb/1999-04/msg00109.html,

suggested patches to two files, gdb/alpha-tdep.c and gdb/symtab.c, that
are part of the gdb-4.17 distribution, as a workaround to the problem.
I've installed these patches and recompiled gdb-4.17. With these fixes,
the problem I described is eliminated. I compiled your little code
snippet, and with the patched gdb, the behavior of next is as expected.
The original version of gdb-4.17, on the other hand, exhibits the aberrant
behavior you noted when applied to a.out.

Various responses to my original post indicate that the underlying problem
is a bug in gcc-2.95.1 which produces bad function prologues that confuse
gdb. The fix is not trivial since it would affect machine independent
parts of gcc as well as the alpha specific parts. It does not seem that
such a fix is forthcoming any time soon. The patch to which I refer does
not rectify the underlying gcc problem, but works around it.
------------------------------------------------------------------------
From Larry Griffith <larry@cs.wsc.ma.edu>:
I also complained to the bug reporting address for GCC without success. gdb 
also steps into user code even with a next command.  We are using some old DEC 
3000's, so it isn't peculiar to AlphaServers.  My complaint is almost a year 
old, incidentally.
------------------------------------------------------------------------

                 reply	other threads:[~2000-06-11 20:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox