Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Re: How to catch GDB crash
@ 2008-06-24 17:03 Dmitry Smirnov
  2008-06-24 17:29 ` Pedro Alves
  0 siblings, 1 reply; 31+ messages in thread
From: Dmitry Smirnov @ 2008-06-24 17:03 UTC (permalink / raw)
  To: gdb

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)


^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: How to catch GDB crash
@ 2008-06-24 12:39 Dmitry Smirnov
  2008-06-24 12:58 ` Pedro Alves
  0 siblings, 1 reply; 31+ messages in thread
From: Dmitry Smirnov @ 2008-06-24 12:39 UTC (permalink / raw)
  To: gdb

Hi!

I have to say that your advices were useful. I was able to catch the crash.
Maybe it will be interesting for you.
First, after I attached to the process, I've set 3 breakpoints: exit, _exit, abort (which is cygwin1!abort in fact).
Next, I've noticed that program is stopped in that weird state Brian wrote about:

(gdb) bt
#0  0x7c901231 in ntdll!DbgUiConnectToDbg ()  from /c/WINDOWS/system32/ntdll.dll
#1  0x7c9507a8 in ntdll!KiIntSystemCall () from /c/WINDOWS/system32/ntdll.dll
#2  0x00000005 in ?? ()

I've tried to step through the code: three or four 'ni' commands and, oops.. it looks the program has been resumed.
After that, I performed actions that lead to the crash (it is just issuing 'ni' for arm-elf-gdb from Eclipse) and I was brought to the following situation:

Breakpoint 2, 0x61084819 in cygwin1!abort () from /usr/bin/cygwin1.dll
(gdb)
0x6108481e in cygwin1!abort () from /usr/bin/cygwin1.dll
(gdb) info th
  3 thread 5424.0x114c  0x7c90eb94 in ntdll!LdrAccessResource ()
   from /c/WINDOWS/system32/ntdll.dll
  2 thread 5424.0x1108  0x7c90eb94 in ntdll!LdrAccessResource ()
   from /c/WINDOWS/system32/ntdll.dll
* 1 thread 5424.0x1bc  0x6108481e in cygwin1!abort ()
   from /usr/bin/cygwin1.dll
(gdb) bt
#0  0x6108481e in cygwin1!abort () from /usr/bin/cygwin1.dll
#1  0x61086e60 in sigfillset () from /usr/bin/cygwin1.dll
#2  0x0040b6b7 in internal_verror (file=0x62380b ".././gdb/mi/mi-interp.c",
    line=340, fmt=0x6237ed "%s: Assertion `%s' failed.", ap=0x22e64c "-7b")
    at utils.c:809
#3  0x0040b6f6 in internal_error (file=0x62380b ".././gdb/mi/mi-interp.c",
    line=340, string=0x6237ed "%s: Assertion `%s' failed.") at utils.c:818
#4  0x0048cfec in mi_on_resume (ptid={pid = 42000, lwp = 0, tid = 0})
    at .././gdb/mi/mi-interp.c:340
#5  0x0046377f in observer_target_resumed_notification_stub (data=0x48cf40,
    args_data=0x22e6b0) at observer.inc:378
#6  0x00463052 in generic_observer_notify (subject=0x1, args=0x5e74ac)
    at observer.c:166
#7  0x004637fe in observer_notify_target_resumed (ptid=
      {pid = 42000, lwp = 0, tid = 0}) at observer.inc:402
#8  0x0047bd22 in set_running (ptid={pid = 42000, lwp = 0, tid = 0},
    running=1) at thread.c:435
#9  0x004265a0 in resume (step=1, sig=TARGET_SIGNAL_HUP) at infrun.c:1063
#10 0x004294c0 in proceed (addr=4294967295, siggnal=TARGET_SIGNAL_DEFAULT,
    step=1) at infrun.c:1265
#11 0x00412564 in step_1 (skip_subroutines=1, single_inst=1, count_string=0x0)
    at infcmd.c:789
#12 0x00402433 in execute_command (p=0x22e872 "", from_tty=1) at top.c:466
#13 0x004116e2 in catch_exception (uiout=0x100f0c80,
    func=0x48e040 <do_captured_execute_command>, func_args=0x22e898, mask=6)
    at exceptions.c:463
#14 0x0048e0e6 in cli_interpreter_exec (data=0x0, command_str=0x103230b0 "ni")
    at .././gdb/cli/cli-interp.c:130
#15 0x0041acfb in interp_exec (interp=0x100f0ce8, command_str=0x103230b0 "ni")
    at interps.c:325
#16 0x0048cc49 in mi_cmd_interpreter_exec (
    command=0x64d54e "-interpreter-exec", argv=0x22e998, argc=2)
    at .././gdb/mi/mi-interp.c:209
#17 0x00505a45 in captured_mi_execute_command (uiout=0x100f1660,
    data=0x22ea40) at .././gdb/mi/mi-main.c:1104
#18 0x004116e2 in catch_exception (uiout=0x100f1660,
    func=0x5057a0 <captured_mi_execute_command>, func_args=0x22ea40, mask=6)
    at exceptions.c:463
#19 0x0050558a in mi_execute_command (cmd=0x10ef9ea0 "229 ni", from_tty=1)
    at .././gdb/mi/mi-main.c:1159
#20 0x0048cd49 in mi_execute_command_wrapper (cmd=0x10ef9ea0 "229 ni")
    at .././gdb/mi/mi-interp.c:265
#21 0x00436e5a in handle_file_event (event_file_desc=0) at event-loop.c:732
#22 0x004368c2 in process_event () at event-loop.c:341
#23 0x004371a5 in gdb_do_one_event (data=0x0) at event-loop.c:378
#24 0x0041192b in catch_errors (func=0x437020 <gdb_do_one_event>,
    func_args=0x0, errstring=0x607b20 "", mask=6) at exceptions.c:509
#25 0x00436914 in start_event_loop () at event-loop.c:404
#26 0x004010ab in captured_command_loop (data=0x0) at .././gdb/main.c:99
#27 0x0041192b in catch_errors (func=0x4010a0 <captured_command_loop>,
    func_args=0x0, errstring=0x5f7139 "", mask=6) at exceptions.c:509
#28 0x00401914 in captured_main (data=0x22ee10) at .././gdb/main.c:882
#29 0x0041192b in catch_errors (func=0x4010f0 <captured_main>,
    func_args=0x22ee10, errstring=0x5f7139 "", mask=6) at exceptions.c:509
#30 0x00402113 in gdb_main (args=0x22ee10) at .././gdb/main.c:891
#31 0x0040109b in main (argc=8, argv=0x100301a0) at gdb.c:33
(gdb)


Now I can start investigations.

Dmitry


^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: How to catch GDB crash
@ 2008-06-24  8:52 Dmitry Smirnov
  0 siblings, 0 replies; 31+ messages in thread
From: Dmitry Smirnov @ 2008-06-24  8:52 UTC (permalink / raw)
  To: gdb

Hi,

I'm sorry guys, but I believe we are going wrong way. 
First, I suppose I do not need JIT: as I said, I can attach to the 
running arm-elf-gdb before the crash. I supposed that GDB is smart 
enough to catch system exceptions. Moreover, I have some indication 
of that: my skyeye is Cygwin-compiled program and when I run it in 
Eclipse (which uses Cygwin GDB as a debugger for this program), I can 
see the follwing stack:
-----------------
Skyeye_1.2.4 Cygwin GCC [C/C++ Local Application]	
	Cygwin gdb Debugger (23.06.08 20:12) (Suspended)	
		Thread [1] (Suspended: Signal 'SIGSEGV' received. Description: Segmentation fault.)	
			3 RpcRaiseException()  0x77ea27ea	
			2 h_errno()  0x662b7258	
			1 <symbol is not available> 0x00000000	
		Thread [2] (Suspended)	
	gdb (23.06.08 20:12)	
	D:\Dvs\Project\Skyeye_1.2.4\binary\skyeye.exe (23.06.08 20:12)	
----------------------
Here is the stack of command-line GDB:
----------------------
Program received signal SIGSEGV, Segmentation fault.
0x77ea27ea in RpcRaiseException () from /c/WINDOWS/system32/rpcrt4.dll
(gdb) info stack
#0  0x77ea27ea in RpcRaiseException () from /c/WINDOWS/system32/rpcrt4.dll
#1  0x662b7258 in h_errno () from /c/WINDOWS/system32/hnetcfg.dll
#2  0x00000000 in ?? () from
------------------------

I'm 99% sure that Cygwin GDB can intersept these sygnals.

Am I wrong? Perhaps this a Cygwin_libs-generated signal?

Second, as I mentioned in first mail, someone is trying to save the 
crashdump file. Who's that guy? Why it fails to save? Can I set a breakpoint 
just before he starts to save (e.g. when it detects the crash)?

Is it possible that arm-elf-gdb itself is handling some signals thus preventing 
Cygwin GDB from handling it? Where is that code?

Dmitry
	



^ permalink raw reply	[flat|nested] 31+ messages in thread
* How to catch GDB crash
@ 2008-06-23 16:32 Dmitry Smirnov
  2008-06-23 16:57 ` Aleksandar Ristovski
                   ` (2 more replies)
  0 siblings, 3 replies; 31+ messages in thread
From: Dmitry Smirnov @ 2008-06-23 16:32 UTC (permalink / raw)
  To: gdb

Hi,

I've encountered the very annoying problem with GDB. While debugging, it crashes for some reason and I cannot catch this moment. I have a possibility to attach to the running process with another GDB, but it does not help. Perhaps, there is some way to catch some system exception or something similar?

I'm using a litle bit complex setup, so there is no much freedom (at least I cannot simplify the situation). First, I'm debugging from Eclipse (and it looks this crash happens only while running from Eclipse, I've tried from commad line - there is no crash). The debugger I'm using is cross-compiled arm-elf-gdb. It is compiled on windows (i686) platform:
GNU gdb (GDB) 6.8.50.20080620
...
This GDB was configured as "--host=i686-pc-cygwin --target=arm-elf".

I doubt this can be linked to GDB version. I recall I've seen this crash earlier with arm-elf-gdb 6.5 from GNUARM. I was just skipped this crash somehow but now I cannot continue my job.

This arm-elf-gdb is running against skyeye simulator as a remote target.

As you can see there are many possibilities for mailfunctioning software (Eclipse, GDB, skyeye). But the only way I can find the root cause is to debug the crash in arm-elf-gdb. While crashing it attempts to create the crashdump file, but it is incomplete and Cygwin gdb cannot recognize it. Typically it contains just three lines:

Stack trace:
Frame     Function  Args
0022E268  7C802532  (00000058

If attached, Cygwin GDB just reporting me:
Program exited with code 037777777777.

Is there any way to stop arm-elf-gdb on some critical error?

Dmitry


^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2008-07-08  8:27 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-24 17:03 How to catch GDB crash Dmitry Smirnov
2008-06-24 17:29 ` Pedro Alves
2008-06-25  8:03   ` Dmitry Smirnov
2008-06-25 23:28     ` Pedro Alves
2008-06-26 13:56       ` Dmitry Smirnov
2008-06-26 14:21         ` Pedro Alves
2008-06-26 14:33           ` Dmitry Smirnov
2008-06-30 15:58             ` Dmitry Smirnov
2008-07-02 11:05               ` Dmitry Smirnov
2008-07-02 11:52                 ` Pedro Alves
2008-07-02 12:51                   ` Re[2]: " Dmitry Smirnov
2008-07-05  3:15                     ` Pedro Alves
2008-07-07  8:36                       ` Dmitry Smirnov
2008-07-07 14:29                         ` Pedro Alves
2008-07-07 15:47                           ` Dmitry Smirnov
2008-07-07 16:01                             ` Pedro Alves
2008-07-08  8:27                               ` Dmitry Smirnov
2008-07-01 11:38       ` Vladimir Prus
2008-07-01 11:41         ` Pedro Alves
  -- strict thread matches above, loose matches on Subject: below --
2008-06-24 12:39 Dmitry Smirnov
2008-06-24 12:58 ` Pedro Alves
2008-06-24  8:52 Dmitry Smirnov
2008-06-23 16:32 Dmitry Smirnov
2008-06-23 16:57 ` Aleksandar Ristovski
2008-06-23 17:12 ` Michael Snyder
2008-06-23 18:23   ` Eli Zaretskii
2008-06-23 18:32     ` Michael Snyder
2008-06-23 18:36     ` Pedro Alves
2008-06-23 19:37       ` Brian Dessent
2008-06-23 20:50 ` Dr. Rolf Jansen
2008-06-23 20:59   ` Dr. Rolf Jansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox