Re: How to catch GDB crash

Dmitry Smirnov
2008-06-24T17:03:15Z

Finally, I was able to gather some logs from Cygwin GDB. For this, I've switched debug configuration in Eclipse from gdbServer to Cygwin GDB. It differs in how it starts the program. gdbServer connects to remote target by itself, whereas Cygwin GDB allows me to do it manually from its console.
Below is the log. I've set additional breakpoint at mi_execute_command to see what coommands are issued by Eclipse.
As you can see, first time mi_on_resume is called with ptid={pid = -1, lwp = 0, tid = 0}. Something happens between this call and second call where ptid={pid = 42000, lwp = 0, tid = 0}.

I'm going to figure out which command is followed by wrong pid. I'm suspecting memory corruption.

I have to note that I didn't see some of these commands while debugging gdbServer as a Java code (CDT debugger) from Eclipse. I've seen the following commands that are common for both cases:
info threads
-stack-info-depth
-stack-list-frames
-data-list-changed-registers
-stack-list-arguments 0 0 0
info signal SIGHUP
-data-disassemble -f <my_file> -l 333 -n 100 -- 1
-data-disassemble -s 0x8c4a8e -e 0x8c4af2 -- 0
-stack-list-locals 0

I will try to simulate these command with console (do not use Eclipse), so if you know equivalent commands for GDB console, please let me know.

BTW, command 'info threads' gives me
(gdb) info threads
warning: RMT ERROR : failed to get remote thread list.

Dmitry

(gdb) attach 4760
Attaching to program `/cygdrive/d/Install/GDB/gdb-6.8.50.20080620/gdb-6.8.50.200
80620/gdb/gdb.exe', process 4760
[Switching to thread 4760.0xcbc]
(gdb) ni
0x7c9507a8 in ntdll!KiIntSystemCall () from /c/WINDOWS/system32/ntdll.dll
(gdb)
0x7c9507bb in ntdll!KiIntSystemCall () from /c/WINDOWS/system32/ntdll.dll
(gdb)
0x7c9507bf in ntdll!KiIntSystemCall () from /c/WINDOWS/system32/ntdll.dll
(gdb)
0x7c9507c1 in ntdll!KiIntSystemCall () from /c/WINDOWS/system32/ntdll.dll
(gdb)
[Switching to thread 4760.0x1150]

Breakpoint 5, mi_execute_command (
cmd=0x113a4610 "182-interpreter-exec console \"info b\"", from_tty=1)
at .././gdb/mi/mi-main.c:1135
1135 {
(gdb) c
Continuing.

Breakpoint 5, mi_execute_command (cmd=0x1392c8c8 "183-exec-continue",
from_tty=1) at .././gdb/mi/mi-main.c:1135
1135 {
(gdb) c
Continuing.

Breakpoint 4, mi_on_resume (ptid={pid = -1, lwp = 0, tid = 0})
at .././gdb/mi/mi-interp.c:335
335 if (PIDGET (ptid) == -1)
(gdb) c
Continuing.

Breakpoint 5, mi_execute_command (cmd=0x138c2700 "184 info threads",
from_tty=1) at .././gdb/mi/mi-main.c:1135
1135 {
(gdb) c
Continuing.

Breakpoint 5, mi_execute_command (cmd=0x13931a38 "185-stack-info-depth",
from_tty=1) at .././gdb/mi/mi-main.c:1135
1135 {
(gdb) c
Continuing.

Breakpoint 5, mi_execute_command (
cmd=0x10d2abf0 "186-stack-list-frames 0 11", from_tty=1)
at .././gdb/mi/mi-main.c:1135
1135 {
(gdb) c
Continuing.

Breakpoint 5, mi_execute_command (
cmd=0x10c3d120 "187-data-list-changed-registers", from_tty=1)
at .././gdb/mi/mi-main.c:1135
1135 {
(gdb) c
Continuing.

Breakpoint 5, mi_execute_command (cmd=0x10c3d2c0 "188 info sharedlibrary",
from_tty=1) at .././gdb/mi/mi-main.c:1135
1135 {
(gdb) c
Continuing.

Breakpoint 5, mi_execute_command (cmd=0x10cfd660 "189 info signal SIGHUP",
from_tty=1) at .././gdb/mi/mi-main.c:1135
1135 {
(gdb) c
Continuing.

Breakpoint 5, mi_execute_command (
cmd=0x1144e0a8 "190-data-disassemble -f <my_file> -l 333 -n 100 -- 1", from_tty=1)
at .././gdb/mi/mi-main.c:1135
1135 {
(gdb)
Continuing.

Breakpoint 5, mi_execute_command (
cmd=0x10d438b8 "191-stack-list-arguments 0 0 0", from_tty=1)
at .././gdb/mi/mi-main.c:1135
1135 {
(gdb)
Continuing.

Breakpoint 5, mi_execute_command (
cmd=0x10d2a770 "192-data-disassemble -s 0x8c4a8e -e 0x8c4af2 -- 0",
from_tty=1) at .././gdb/mi/mi-main.c:1135
1135 {
(gdb)
Continuing.

Breakpoint 5, mi_execute_command (cmd=0x10d2a820 "193-stack-list-locals 0",
from_tty=1) at .././gdb/mi/mi-main.c:1135
1135 {
(gdb)
Continuing.

Breakpoint 5, mi_execute_command (cmd=0x10d2a8d0 "194 whatis i", from_tty=1)
at .././gdb/mi/mi-main.c:1135
1135 {
(gdb)
Continuing.

Breakpoint 5, mi_execute_command (cmd=0x10f3ea98 "195 whatis rt_status",
from_tty=1) at .././gdb/mi/mi-main.c:1135
1135 {
(gdb)
Continuing.

Breakpoint 5, mi_execute_command (cmd=0x10f34780 "196 whatis __result",
from_tty=1) at .././gdb/mi/mi-main.c:1135
1135 {
(gdb)
Continuing.

Breakpoint 5, mi_execute_command (cmd=0x10f3e748 "197-var-create - * i",
from_tty=1) at .././gdb/mi/mi-main.c:1135
1135 {
(gdb)
Continuing.

Breakpoint 5, mi_execute_command (
cmd=0x10f39150 "198-var-evaluate-expression var1", from_tty=1)
at .././gdb/mi/mi-main.c:1135
1135 {
(gdb)
Continuing.

Breakpoint 5, mi_execute_command (
cmd=0x1131f9e8 "199-var-create - * rt_status", from_tty=1)
at .././gdb/mi/mi-main.c:1135
1135 {
(gdb)
Continuing.

Breakpoint 5, mi_execute_command (
cmd=0x11244350 "200-var-evaluate-expression var2", from_tty=1)
at .././gdb/mi/mi-main.c:1135
1135 {
(gdb)
Continuing.

Breakpoint 5, mi_execute_command (
cmd=0x1127bb70 "201-var-create - * __result", from_tty=1)
at .././gdb/mi/mi-main.c:1135
1135 {
(gdb)
Continuing.

Breakpoint 5, mi_execute_command (
cmd=0x1127bdc8 "202-var-evaluate-expression var3", from_tty=1)
at .././gdb/mi/mi-main.c:1135
1135 {
(gdb)
Continuing.

Breakpoint 5, mi_execute_command (
cmd=0x112d6500 "203-exec-next-instruction 1", from_tty=1)
at .././gdb/mi/mi-main.c:1135
1135 {
(gdb) c
Continuing.

Breakpoint 4, mi_on_resume (ptid={pid = 42000, lwp = 0, tid = 0})
at .././gdb/mi/mi-interp.c:335
335 if (PIDGET (ptid) == -1)
(gdb) c
Continuing.

Breakpoint 2, 0x61084819 in cygwin1!abort () from /usr/bin/cygwin1.dll
(gdb)