take core dump from gdb of running process?

  • Follow


Folks,

If I use gdb to attach to a running process, do some stuff, exit while 
leaving process running, but I want to take a core dump of the process 
before leaving gdb, how might I do that? When I try "shell gcore [pid]" 
from within gdb, gcore complains that process is being traced (which it 
is I suppose). Any thoughts on how to get this core dump without killing 
the process being debugged?

Chris
0
Reply Chris 7/10/2004 6:43:37 AM

Chris Markle <cmarkle@sendmail.com> writes:

> If I use gdb to attach to a running process, do some stuff, exit while
> leaving process running, but I want to take a core dump of the process
> before leaving gdb, how might I do that? When I try "shell gcore
> [pid]" from within gdb, gcore complains that process is being traced
> (which it is I suppose). Any thoughts on how to get this core dump
> without killing the process being debugged?

Detach gdb from the process and then run gcore, or have you found
that you cannot detach gdb from the process without killing it?

tim
0
Reply Tim 7/11/2004 12:37:47 AM


Tim,

>>If I use gdb to attach to a running process, do some stuff, exit while
>>leaving process running, but I want to take a core dump of the process
>>before leaving gdb, how might I do that? [...]
> Detach gdb from the process and then run gcore, or have you found
> that you cannot detach gdb from the process without killing it?

I can try that. I had hoped to make the whole thing as automated as 
possible to get in and get out as fast as possible to minimize impact 
the running application. I'll think some more about how to automate it. 
Thx for the suggestion.

Chris
0
Reply Chris 7/11/2004 1:02:29 AM

On Fri, 09 Jul 2004 23:43:37 -0700 Chris Markle <cmarkle@sendmail.com> wrote:
> Folks,
>
> If I use gdb to attach to a running process, do some stuff, exit while
> leaving process running, but I want to take a core dump of the process
> before leaving gdb, how might I do that? When I try "shell gcore
> [pid]" from within gdb, gcore complains that process is being traced
> (which it is I suppose). Any thoughts on how to get this core dump
> without killing the process being debugged?

Just run the gdb command 'gcore'.

(gdb) help gcore
Save a core file with the current state of the debugged process.
Argument is optional filename.  Default filename is 'core.<process_id>'.

/fc
0
Reply Frank 7/11/2004 3:23:35 AM

Frank,

> > [...] but I want to take a core dump of the process
> > before leaving gdb, how might I do that? When I try "shell gcore
> > [pid]" from within gdb, gcore complains that process is being traced
> > (which it is I suppose). Any thoughts on how to get this core dump
> > without killing the process being debugged?
>
> Just run the gdb command 'gcore'.

http://www.gnu.org/software/gdb/documentation/ makes no mention of a gdb
gcore command. Is this a doc omission or is gcore support in gdb specific to
some particular gdb implementations (e.g. I got the slight impression from
googling that gcore might be a linux-only gdb capability)?

Chris


0
Reply Chris 7/11/2004 6:28:41 AM

On Sun, 11 Jul 2004 06:28:41 GMT "Chris Markle" <cmarkle@sendmail.com> wrote:
> Frank,
>
>> > [...] but I want to take a core dump of the process
>> > before leaving gdb, how might I do that? When I try "shell gcore
>> > [pid]" from within gdb, gcore complains that process is being traced
>> > (which it is I suppose). Any thoughts on how to get this core dump
>> > without killing the process being debugged?
>>
>> Just run the gdb command 'gcore'.
>
> http://www.gnu.org/software/gdb/documentation/ makes no mention of a gdb
> gcore command. Is this a doc omission or is gcore support in gdb specific to
> some particular gdb implementations (e.g. I got the slight impression from
> googling that gcore might be a linux-only gdb capability)?

Did you try it and find it doesn't work?  I don't have a Solaris machine
with gdb to actually try it.  I'll admit, I only know of it by word-of-
mouth, not from ever having seen any documentation.  I know for sure it
works on Linux, so it must be a doc omission, possibly due to limited
platform support (or maybe just plain oversight).

From the gdb/NEWS file (5.2.1):

  * New command "generate-core-file" (or "gcore").
 
  This new gdb command allows the user to drop a core file of the child
  process state at any time.  So far it's been implemented only for
  GNU/Linux and Solaris, but should be relatively easily ported to other
  hosts.  Argument is core file name (defaults to core.<pid>).

From a grep:

../gdb/procfs.c:/* gcore only implemented on solaris and unixware (so far) */

so who knows ...

/fc
0
Reply Frank 7/11/2004 7:28:01 AM

5 Replies
1023 Views

(page loaded in 0.068 seconds)

Similiar Articles:













7/23/2012 4:37:45 AM


Reply: