ardabro
ardabro

Reputation: 2061

Program freezes under gdb when exception occurs

I compiled with g++ a simple test program:

int main()
{
  try
  {
    printf("before\n");
    throw 1;
  }
  catch(int i)
  {
    printf("catched int\n");
  }
  catch(...)
  {
    printf("catched(...)\n");
  }
}

Normally works ok with or without debug info included. But when debugged with gdb it always hangs on "throw 1;" line so I'm not able to debug programs, that normally throws exceptions. The last information from debugger is:

Catchpoint 1 (exception thrown), 0x00007ffff7b8f9e0 in __cxa_throw () from /usr/lib/libstdc++.so.6

My compilation and linking options:

g++ -Wshadow -Wunreachable-code -Wswitch-enum -Wswitch-default -Wextra -Wall  -pg -g -m64    -c main.cpp

g++ -o exec/exception_problem obj/main.o -pg

My environment: ubuntu 10.10, 64bit; g++/gcc 4.4.5; gdb 7.2; debugged under codeblocks svn rev 7440

Any ideas what is the problem?

Additional info: Last two lines of gdb log are:

Catchpoint 1 (exception thrown), 0x00007ffff7b8f9e0 in __cxa_throw () from /usr/lib/libstdc++.so.6
>>>>>>cb_gdb:

The last character in log is colon. gdb commandline:

/usr/bin/gdb -nx -fullname -quiet -args exec/exception_problem 

I did not found any *gdbinit* in my home directory; global gdbinit is empty. Is it possible that codeblocks prepares specific gdbinit and puts it to gdb?

Best regards for all.

Upvotes: 3

Views: 1111

Answers (1)

Employed Russian
Employed Russian

Reputation: 213576

Catchpoint 1 (exception thrown) ...

Is there something in your .gdbinit that you haven't told us about? (Perhaps catch throw ?)

Is the Catchpoint 1 really the last line that GDB prints? Here is what I see:

Reading symbols from /tmp/a.out...done.
Catchpoint 1 (throw)
(gdb) run
before
Catchpoint 1 (exception thrown), __cxxabiv1::__cxa_throw (obj=0x602090, tinfo=0x601060, dest=0) at ../../../../src/libstdc++-v3/libsupc++/eh_throw.cc:70
70  ../../../../src/libstdc++-v3/libsupc++/eh_throw.cc: No such file or directory.
    in ../../../../src/libstdc++-v3/libsupc++/eh_throw.cc
(gdb) c
catched int
[Inferior 1 (process 16008) exited normally]
(gdb) q

Upvotes: 1

Related Questions