This is the mail archive of the gdb@sourceware.cygnus.com 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]

Re: gdb seg violation during print command


cogen@ll.mit.edu (David Cogen) writes:


First off, your code is broken. You claim to return an int, but don't.
This is what is causing the segfault in gdb.
It's impossible for us to not believe the compiler when it says "this
function returns an int". We expect it to return an int.

In the newer gdb, what'll happen is you'll get no segfault, but a weird number
returned, which will actually the address of the function, which is
the last value we have around, i guess.



> I have a simple test case which demonstrates this problem. The following is a
> transcript. I trust I have included all necessary details?
> 
> redsavina% uname -a
> SunOS redsavina 5.7 Generic_106541-09 sun4u sparc SUNW,Ultra-Enterprise
> redsavina% g++ --version
> 2.95.2
> redsavina% gdb --version
> GNU gdb 4.18
> 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.4".
> redsavina% cat test.cc
> #include <iostream>
> 
> int tteesstt11 (int)
> {
>   cerr << "\n";
> }
> 
> int main ()
> {
> }
> 
> redsavina% g++ -g -o test test.cc
> redsavina% gdb -n ./test
> GNU gdb 4.18
> 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.4"...
> (gdb) break main
> Breakpoint 1 at 0x1a8a0: file test.cc, line 9.
> (gdb) r
> Starting program: /data/redsavina0/cogen/l/astb/src/util/derive_message_stream_files/./test -input test.strm
> 
> Breakpoint 1, main () at test.cc:9
> 9	{
> (gdb) p tteesstt11(1)
> Segmentation Fault (core dumped)
> redsavina% 

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