Re: [PATCH] Quit after debugging corefiles

Edjunior Barbosa Machado
2010-06-22T20:03:48Z

On 06/22/2010 02:42 PM, Michael Snyder wrote:
> Hmm, I don't think you're supposed to "continue" when debugging a core
> file...

I meant I had already started debugging (with breakpoints and 'run') before, which is permitted in the current version (although I noticed this behavior has been discussed in the thread that Pedro previously mentioned).

You can see the full output below. Sorry if it was unclear in the beginning.

Using the following faulty code:

$ cat -n corefile-quit.c
1 #include <stdio.h>
2
3 static void
4 fault_func (char *arg)
5 {
6 *arg = 0; /* segfault */
7 }
8
9 int main (int argc, char *argv[])
10 {
11 char *ptr = NULL;
12
13 printf("hello world\n");
14
15 fault_func (ptr);
16
17 return 0;
18 }

$ ./gdb -q ./corefile-quit core
Reading symbols from /home/emachado/work/gdb/community/build/gdb/corefile-quit...done.
[New Thread 17524]

warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/i686/cmov/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/i686/cmov/libc.so.6
Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.2
Core was generated by `./corefile-quit'.
Program terminated with signal 11, Segmentation fault.
#0 0x080483ca in fault_func (arg=0x0) at corefile-quit.c:6
6 *arg = 0; /* segfault */
Setting up the environment for debugging gdb.
Function "internal_error" not defined.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
Function "info_command" not defined.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
.gdbinit:8: Error in sourced command file:
Argument required (one or more breakpoint numbers).
(gdb) b 14
Breakpoint 1 at 0x80483ec: file corefile-quit.c, line 14.
(gdb) r
Starting program: /home/emachado/work/gdb/community/build/gdb/corefile-quit
hello world

Breakpoint 1, main (argc=
During symbol reading, incomplete CFI data; unspecified registers (e.g., eax) at 0x80483d2.
1, argv=0xbffff544) at corefile-quit.c:15
15 fault_func (ptr);
(gdb) set ptr="new"
(gdb) cont
Continuing.

Program exited normally.
(gdb) quit
../../git/gdb/inferior.c:362: internal-error: find_inferior_pid: Assertion `pid != 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) n
../../git/gdb/inferior.c:362: internal-error: find_inferior_pid: Assertion `pid != 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) n

--
Edjunior Barbosa Machado
IBM Linux Technology Center