[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: core file writing

From: Roland McGrath
Subject: Re: core file writing
Date: Wed, 6 Mar 2002 23:01:00 -0500 (EST)

> Yes.  I saw this afternoon how to walk through memory with vm_region and
> I think I have this part of it in hand. Basic idea as I understand it
> is:

Well, inexactly, yes.  There is also some old unfinshied code in hurd/exec/
that did some of this.  I pointed you at vminfo because that is a working
program that actually gets all the nits right in calling vm_region.  Note
that vm_region will give you lots of little regions that are actually only
a few large logical mappings.  You don't want to litter the core file with
tons of little segments, so your code should coalesce adjacent regions with
identical properties.  

> The register set seems to be available from thread_get_state().  

Of course.  I was talking about the specific details of the file format.

> That took a little looking to figure out, but I think I'm ok here now
> too.  The idea is to stash the threads' register info in segments called
> '.regs[n]' where [n] is the thread ID if I'm not mistaken.  

You are not being very specific, so I presume you are talking about the
name fields in the PT_NOTE segments.

> GDB doesn't seem to need a WHOLE LOT of work if I stick to a fairly
> standard core file format like elf.

Again, I am talking about the specific details of what the data inside the
note segments looks like.

> I have pulled some of the structure together here, but it is currently
> using the 'elf.h' structures directly and calculating offsets.  When I
> figured out that libbfd would do most of this for me, I thought I'd
> rewrite it using that, so I'll spend a little time understanding bfd's
> API.

I'm not sure that BFD is the way to go.  It is a very heavyweight solution
to what is a pretty simple problem for writing ELF.  But if you do want to
use bfd, there seems to be some code in gdb that uses it to write core
files and you can see how that uses bfd.  If you want something to help a
little but not quite that hairy, you could try libelf.

If you are going to use BFD, then you might as well just start by working
on gdb (5.2 or current CVS sources) and getting its `gcore' command to work.
I have just whipped up the `find_memory_regions' function for gnu-nat.c,
and maybe you can test that out.  I will post it separately in a little bit.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]