This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: Improve support for "debugging" unlinked objects


Daniel Jacobowitz wrote:
If you compile a file containing both code and initialized data, and load
the unlinked object (.o) file using GDB, "print Variable" won't work. You'll get garbage-looking data, which is in fact the start of the first
section in the file - usually .text.


All sections appear to have address 0.  i.e., they overlap, sort of like
overlays but not similar enough to reuse the overlay machinery.  For this
case, if we fill in section_offsets, we can place them at random locations
which are sufficiently unique that we can see the locations of variables as
distinct.  And if we pass this information back to exec.c, we can see the
values of variables correctly, too.

Here's a patch along with a testcase; the test fails before the patch, and
passes afterwards.  Any comments on the way I fixed this?


I think this is a great idea, and...


> Also, with a fix that I'm going to commit to bfd soon, you
> can use "gdb -write" to patch an object file.

this bit's especially great.

One suggestion -- could you use the section's file offset
in place of a "random location"?  I'm guessing it's available
from bfd, and it seems to me that it's guaranteed to be unique.

There might be some advantage in terms of following non-relocated
branches etc.

Michael


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]