public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Process memory map
@ 2021-11-03  0:32 Howard Chu
  2021-11-03  7:20 ` Chris Packham
  0 siblings, 1 reply; 4+ messages in thread
From: Howard Chu @ 2021-11-03  0:32 UTC (permalink / raw)
  To: gdb

Is the complete map of process address space saved in a core file? When debugging
with a core file, is there a gdb command to mmap the files that were mapped at the
time the core was taken, so that references to addresses in those regions will be
valid?
-- 
  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/

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

* Re: Process memory map
  2021-11-03  0:32 Process memory map Howard Chu
@ 2021-11-03  7:20 ` Chris Packham
  2021-11-03 15:59   ` John Baldwin
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Packham @ 2021-11-03  7:20 UTC (permalink / raw)
  To: Howard Chu; +Cc: gdb

On Wed, Nov 3, 2021 at 1:33 PM Howard Chu <hyc@symas.com> wrote:
>
> Is the complete map of process address space saved in a core file? When debugging
> with a core file, is there a gdb command to mmap the files that were mapped at the
> time the core was taken, so that references to addresses in those regions will be
> valid?

I recently had a similar need. I found `info proc all` (technically
`info proc mappings`) contained the mapping info I needed. For a
regular core file the shared libraries were automatically loaded (in
my case I needed to `set auto-load safe-path` and `set sysroot` for my
cross-build environment). The one slight problem I had was with a very
specific core file where the crash was in ld.so in that specific case
it wasn't automatically loaded and I had to muck around with `add
symbol-file` and manually working out some offsets to get it loaded
into the right place.

I'd be interested in hearing tips from anyone else.

> --
>   -- Howard Chu
>   CTO, Symas Corp.           http://www.symas.com
>   Director, Highland Sun     http://highlandsun.com/hyc/
>   Chief Architect, OpenLDAP  http://www.openldap.org/project/

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

* Re: Process memory map
  2021-11-03  7:20 ` Chris Packham
@ 2021-11-03 15:59   ` John Baldwin
  2021-11-03 16:07     ` Howard Chu
  0 siblings, 1 reply; 4+ messages in thread
From: John Baldwin @ 2021-11-03 15:59 UTC (permalink / raw)
  To: Chris Packham, Howard Chu; +Cc: gdb

On 11/3/21 12:20 AM, Chris Packham via Gdb wrote:
> On Wed, Nov 3, 2021 at 1:33 PM Howard Chu <hyc@symas.com> wrote:
>>
>> Is the complete map of process address space saved in a core file? When debugging
>> with a core file, is there a gdb command to mmap the files that were mapped at the
>> time the core was taken, so that references to addresses in those regions will be
>> valid?
> 
> I recently had a similar need. I found `info proc all` (technically
> `info proc mappings`) contained the mapping info I needed. For a
> regular core file the shared libraries were automatically loaded (in
> my case I needed to `set auto-load safe-path` and `set sysroot` for my
> cross-build environment). The one slight problem I had was with a very
> specific core file where the crash was in ld.so in that specific case
> it wasn't automatically loaded and I had to muck around with `add
> symbol-file` and manually working out some offsets to get it loaded
> into the right place.
> 
> I'd be interested in hearing tips from anyone else.

Note that manually loading symbols is much easier in recent versions of
GDB.  You can find the base address that a given file is loaded at
via 'info proc mappings' and then just use
'add-symbol-file -o <base address> /path/to/library' to load all of the
symbols without having to calculate the address of individual sections.

-- 
John Baldwin

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

* Re: Process memory map
  2021-11-03 15:59   ` John Baldwin
@ 2021-11-03 16:07     ` Howard Chu
  0 siblings, 0 replies; 4+ messages in thread
From: Howard Chu @ 2021-11-03 16:07 UTC (permalink / raw)
  To: John Baldwin, Chris Packham; +Cc: gdb

John Baldwin wrote:
> On 11/3/21 12:20 AM, Chris Packham via Gdb wrote:
>> On Wed, Nov 3, 2021 at 1:33 PM Howard Chu <hyc@symas.com> wrote:
>>>
>>> Is the complete map of process address space saved in a core file? When debugging
>>> with a core file, is there a gdb command to mmap the files that were mapped at the
>>> time the core was taken, so that references to addresses in those regions will be
>>> valid?
>>
>> I recently had a similar need. I found `info proc all` (technically
>> `info proc mappings`) contained the mapping info I needed. For a
>> regular core file the shared libraries were automatically loaded (in
>> my case I needed to `set auto-load safe-path` and `set sysroot` for my
>> cross-build environment). The one slight problem I had was with a very
>> specific core file where the crash was in ld.so in that specific case
>> it wasn't automatically loaded and I had to muck around with `add
>> symbol-file` and manually working out some offsets to get it loaded
>> into the right place.
>>
>> I'd be interested in hearing tips from anyone else.
> 
> Note that manually loading symbols is much easier in recent versions of
> GDB.  You can find the base address that a given file is loaded at
> via 'info proc mappings' and then just use
> 'add-symbol-file -o <base address> /path/to/library' to load all of the
> symbols without having to calculate the address of individual sections.
> 
Thanks, `info proc mappings` is helpful but I'm talking about referencing
the contents of arbitrary mmap'd files, not shared libraries. gdb doesn't
currently map them, and by default their contents are not included in core
files.

-- 
  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/

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

end of thread, other threads:[~2021-11-03 16:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-03  0:32 Process memory map Howard Chu
2021-11-03  7:20 ` Chris Packham
2021-11-03 15:59   ` John Baldwin
2021-11-03 16:07     ` Howard Chu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).