gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gdb] GDB wipes out stack upon exception


From: Vadim Ogranovich
Subject: [Gdb] GDB wipes out stack upon exception
Date: Tue, 30 Apr 2002 14:11:20 -0500

Hi,

I want to the debugger to stop when an exception is thrown in the code
below, however it wipes out the stack of foo(). This behavior has something
to do with the argument of foo() being 'const std::vector<double> &' as GDB
behaves correctly if the argument is a built-in type.


// file foo.cpp
// compile with
// g++ -g -pedantic -Wall foo.cpp -o foo
#include <exception>
#include <vector>


void foo(const std::vector<double> & xA)
//void foo(const double & xA)
{
  throw std::exception();
}


int main() {
  std::vector<double> A;
  // double A;
  foo(A);
}


Here is a transcript of a GDB session, note that foo() is not on the stack
as I'd have expected:

(gdb) R
The program being debugged has been started already.
Start it from the beginning? (y or n) y

`/home/west/vograno/test/foo' has changed; re-reading symbols.
Starting program: /home/west/vograno/test/foo 

Program received signal SIGABRT, Aborted.
0x400c1a01 in __kill () from /lib/i686/libc.so.6

(gdb) backtrace
#0  0x400c1a01 in __kill () from /lib/i686/libc.so.6
#1  0x400c17da in raise (sig=6) at ../sysdeps/posix/raise.c:27
#2  0x400c2f82 in abort () at ../sysdeps/generic/abort.c:88
#3  0x40051efb in __default_terminate () at ../../gcc/libgcc2.c:3034
#4  0x40051f1a in __terminate () at ../../gcc/libgcc2.c:3034
#5  0x40052c55 in throw_helper (eh=0x4006fac0, pc=0x400af506, 
    my_udata=0xbffff210, offset_p=0xbffff20c) at ../../gcc/libgcc2.c:3168
#6  0x40052f4f in __rethrow (index=0x8049aec) at ../../gcc/libgcc2.c:3168
#7  0x0804890f in main () at /usr/include/g++-3/stl_vector.h:266
#8  0x400af507 in __libc_start_main (main=0x8048840 <main>, argc=1, 
    ubp_av=0xbffff364, init=0x8048640 <_init>, fini=0x80489a0 <_fini>, 
    rtld_fini=0x4000dc14 <_dl_fini>, stack_end=0xbffff35c)
    at ../sysdeps/generic/libc-start.c:129


If however I change foo(const std::vector<double> & xA) to foo(const double
& xA) everything will be fine and the stack of foo() will be on the list.
Any suggestion?

Please CC me on your replies as I am not subscribed to the gdb list

Thanks, Vadim




gdb --version
GNU gdb Red Hat Linux 7.x (5.0rh-15) (MI_OUT)
This GDB was configured as "i386-redhat-linux".

gcc --version
2.96

-------------------------------------------------- 
DISCLAIMER 
This e-mail, and any attachments thereto, is intended only for use by the
addressee(s) named herein and may contain legally privileged and/or
confidential information.  If you are not the intended recipient of this
e-mail, you are hereby notified that any dissemination, distribution or
copying of this e-mail, and any attachments thereto, is strictly prohibited.
If you have received this e-mail in error, please immediately notify me and
permanently delete the original and any copy of any e-mail and any printout
thereof. 

E-mail transmission cannot be guaranteed to be secure or error-free.  The
sender therefore does not accept liability for any errors or omissions in
the contents of this message which arise as a result of e-mail transmission.

NOTICE REGARDING PRIVACY AND CONFIDENTIALITY 

Knight Trading Group may, at its discretion, monitor and review the content
of all e-mail communications. 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]