beside
asked on
GDB, how to know where your program failed
I have such a situation:
I run a program to debug, and get
Program received signal SIGABRT, Aborted.
0x4012cee9 in raise () from /lib/tls/libc.so.6
I know there is bug in my prog. But how to find out where? after wich command in my prog it gets SIGABRT?
I run a program to debug, and get
Program received signal SIGABRT, Aborted.
0x4012cee9 in raise () from /lib/tls/libc.so.6
I know there is bug in my prog. But how to find out where? after wich command in my prog it gets SIGABRT?
You must post your code.
If you have a coredump, just start gdb with that file and it'll take you straight to the line where it failed:
gdb <corefile>
gdb <corefile>
ASKER
can't I just use a debugger to find out more?
ASKER
how to make that coredump?
ASKER
Oh I forgot it to compile using debug flag..
try putting a breakpoint on _throw. When a throw is made in any catch statement, you'll hit the breakpoint, and the stack will still be available.
Remember its "_throw" with an underscore.
Remember its "_throw" with an underscore.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>That would make sense if the SIGABRT came from lbstdc++.o, but not from libc.o. 'raise()'
>>might be the better place :o)
That might work, but I've had problems with gdb/gnu in that if you put the break point at the crash position, you loose the stack information.
Where-as if you put the break point at _throw, you still have the stack available.
>>might be the better place :o)
That might work, but I've had problems with gdb/gnu in that if you put the break point at the crash position, you loose the stack information.
Where-as if you put the break point at _throw, you still have the stack available.
ASKER
jkr you just noticed that I can give core dump to gdb, but how to make that my program reproduce core dump on SIGABRT, because now, it gives me no core dump.. It would be very helpfull if there would be core dump, because It's relly difficult to reproduce this error in my programe.
beside,
Have you try using the breakpoint method?
What OS are you working on?
Have you try using the breakpoint method?
What OS are you working on?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yes, I got a point how to find out bug, no I just waiting when i accours, because it's very difficult to catch...
coredump are not produced if you set
coredumpsize to 0 ..so maybe you can check your login files of your shell if it is being set to zero
more information here
http://www.unixguide.net/hp/faq/8.5.shtml
coredumpsize to 0 ..so maybe you can check your login files of your shell if it is being set to zero
more information here
http://www.unixguide.net/hp/faq/8.5.shtml
ASKER
here I have everything what I could get from debuger and core file, but this is something mistical for me... could you explain.. here is information:
root@isdn:~/server_new# gdb isdn_server core
GNU gdb 6.1-debian
Copyright 2004 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-linux"...Using host libthread_db library "/lib/tls/libthread_db.so. 1".
Core was generated by `./isdn_server'.
Program terminated with signal 6, Aborted.
warning: current_sos: Can't read pathname for load map: Input/output error
Reading symbols from /usr/lib/libstdc++.so.5... done.
Loaded symbols for /usr/lib/libstdc++.so.5
Reading symbols from /lib/tls/libm.so.6...done.
Loaded symbols for /lib/tls/libm.so.6
Reading symbols from /lib/libgcc_s.so.1...done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /lib/tls/libc.so.6...done.
Loaded symbols for /lib/tls/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/tls/libnss_files.so.2 ...done.
Loaded symbols for /lib/tls/libnss_files.so.2
#0 0x4012cee9 in raise () from /lib/tls/libc.so.6
(gdb) where
#0 0x4012cee9 in raise () from /lib/tls/libc.so.6
#1 0x4023aedc in ?? () from /lib/tls/libc.so.6
#2 0x0804c518 in ?? ()
#3 0x4012e781 in abort () from /lib/tls/libc.so.6
#4 0x00000000 in ?? ()
#5 0x00000020 in ?? ()
#6 0x00000000 in ?? ()
#7 0x00000000 in ?? ()
#8 0x00000000 in ?? ()
#9 0x00000000 in ?? ()
#10 0x00000000 in ?? ()
#11 0x00000000 in ?? ()
#12 0x00000000 in ?? ()
#13 0x00000000 in ?? ()
#14 0x00000000 in ?? ()
#15 0x00000000 in ?? ()
#16 0x00000000 in ?? ()
#17 0x00000000 in ?? ()
#18 0x00000000 in ?? ()
#19 0x00000000 in ?? ()
#20 0x00000000 in ?? ()
#21 0x00000000 in ?? ()
#22 0x00000000 in ?? ()
#23 0x00000000 in ?? ()
#24 0x00000000 in ?? ()
#25 0x00000000 in ?? ()
#26 0x00000000 in ?? ()
#27 0x00000000 in ?? ()
#28 0x00000000 in ?? ()
#29 0x00000000 in ?? ()
#30 0x00000000 in ?? ()
#31 0x00000000 in ?? ()
#32 0x00000000 in ?? ()
#33 0x00000000 in ?? ()
#34 0x00000000 in ?? ()
---Type <return> to continue, or q <return> to quit---
#35 0x00000000 in ?? ()
#36 0x00000000 in ?? ()
#37 0x00000000 in ?? ()
#38 0x00000000 in ?? ()
#39 0x00000000 in ?? ()
#40 0x09844246 in ?? ()
#41 0xbfffdb30 in ?? ()
#42 0x40017a08 in ?? ()
#43 0x401187f8 in __libc_start_main () from /lib/tls/libc.so.6
#44 0x00000000 in ?? ()
#45 0xbfffdb50 in ?? ()
#46 0x40017a08 in ?? ()
#47 0x4000ba16 in _dl_map_object_deps () from /lib/ld-linux.so.2
Previous frame inner to this frame (corrupt stack?)
(gdb)
I compile program as follow:
/usr/bin/g++ -ansi -pedantic -Wall -g -DDEBUG -o isdn_server -L. main.cpp analyzeisdn.cpp callcard.cpp isdnmessage.cpp socketcon.cpp
And by the way, what this meens when I load core file.
warning: current_sos: Can't read pathname for load map: Input/output error
root@isdn:~/server_new# gdb isdn_server core
GNU gdb 6.1-debian
Copyright 2004 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-linux"...Using host libthread_db library "/lib/tls/libthread_db.so.
Core was generated by `./isdn_server'.
Program terminated with signal 6, Aborted.
warning: current_sos: Can't read pathname for load map: Input/output error
Reading symbols from /usr/lib/libstdc++.so.5...
Loaded symbols for /usr/lib/libstdc++.so.5
Reading symbols from /lib/tls/libm.so.6...done.
Loaded symbols for /lib/tls/libm.so.6
Reading symbols from /lib/libgcc_s.so.1...done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /lib/tls/libc.so.6...done.
Loaded symbols for /lib/tls/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/tls/libnss_files.so.2
Loaded symbols for /lib/tls/libnss_files.so.2
#0 0x4012cee9 in raise () from /lib/tls/libc.so.6
(gdb) where
#0 0x4012cee9 in raise () from /lib/tls/libc.so.6
#1 0x4023aedc in ?? () from /lib/tls/libc.so.6
#2 0x0804c518 in ?? ()
#3 0x4012e781 in abort () from /lib/tls/libc.so.6
#4 0x00000000 in ?? ()
#5 0x00000020 in ?? ()
#6 0x00000000 in ?? ()
#7 0x00000000 in ?? ()
#8 0x00000000 in ?? ()
#9 0x00000000 in ?? ()
#10 0x00000000 in ?? ()
#11 0x00000000 in ?? ()
#12 0x00000000 in ?? ()
#13 0x00000000 in ?? ()
#14 0x00000000 in ?? ()
#15 0x00000000 in ?? ()
#16 0x00000000 in ?? ()
#17 0x00000000 in ?? ()
#18 0x00000000 in ?? ()
#19 0x00000000 in ?? ()
#20 0x00000000 in ?? ()
#21 0x00000000 in ?? ()
#22 0x00000000 in ?? ()
#23 0x00000000 in ?? ()
#24 0x00000000 in ?? ()
#25 0x00000000 in ?? ()
#26 0x00000000 in ?? ()
#27 0x00000000 in ?? ()
#28 0x00000000 in ?? ()
#29 0x00000000 in ?? ()
#30 0x00000000 in ?? ()
#31 0x00000000 in ?? ()
#32 0x00000000 in ?? ()
#33 0x00000000 in ?? ()
#34 0x00000000 in ?? ()
---Type <return> to continue, or q <return> to quit---
#35 0x00000000 in ?? ()
#36 0x00000000 in ?? ()
#37 0x00000000 in ?? ()
#38 0x00000000 in ?? ()
#39 0x00000000 in ?? ()
#40 0x09844246 in ?? ()
#41 0xbfffdb30 in ?? ()
#42 0x40017a08 in ?? ()
#43 0x401187f8 in __libc_start_main () from /lib/tls/libc.so.6
#44 0x00000000 in ?? ()
#45 0xbfffdb50 in ?? ()
#46 0x40017a08 in ?? ()
#47 0x4000ba16 in _dl_map_object_deps () from /lib/ld-linux.so.2
Previous frame inner to this frame (corrupt stack?)
(gdb)
I compile program as follow:
/usr/bin/g++ -ansi -pedantic -Wall -g -DDEBUG -o isdn_server -L. main.cpp analyzeisdn.cpp callcard.cpp isdnmessage.cpp socketcon.cpp
And by the way, what this meens when I load core file.
warning: current_sos: Can't read pathname for load map: Input/output error
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>As I stated in my previous comments, it has been my experience that if you try to get stack data after a crash,
>>you loose stack data.
FYI: Above comment is just referring to gdb, and not other debuggers.
>>you loose stack data.
FYI: Above comment is just referring to gdb, and not other debuggers.
ASKER
thanx axter, will try, and report...
ASKER
(gdb) b _throw
Function "_throw" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (_throw) pending.
if I did correctly? or something here is wrong that it could not file _throw?
Function "_throw" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (_throw) pending.
if I did correctly? or something here is wrong that it could not file _throw?
What was the command line you use to start gdb?
Also, is your code compiled as C++ or C?
Do you have *.cpp files,or *.c files?
Do you have *.cpp files,or *.c files?
If _throw doesn't work, try jkr's suggestion, and put a breakpoint on raise
ASKER
command line to start gdb is:
gdb isdn_server
(gdb) set follow-fork-mode child
(gdb) b _throw
(gdb) run
my code is compiled as C++, I have .cpp files
gdb isdn_server
(gdb) set follow-fork-mode child
(gdb) b _throw
(gdb) run
my code is compiled as C++, I have .cpp files
ASKER
I think I found problem in my program (without using debuger), but thanx for suggestions, know I'm more reliable on debuging program with gdb.
Thank you all.
Thank you all.