* [RFA] Always use addr info to add a separate debug file
@ 2010-01-06 11:18 Tristan Gingold
2010-01-06 19:43 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Tristan Gingold @ 2010-01-06 11:18 UTC (permalink / raw)
To: gdb-patches
Hi,
as explained by Jan, it is necessary to use addr_info while loading a
separate debug file.
No regressions on GNU Linux i386.
Tristan.
2010-01-04 Tristan Gingold <gingold@adacore.com>
* symfile.c (build_section_addr_info_from_objfile): New function.
(symbol_file_add_separate): Don't use offsets from objfile but
built an addr info.
---
gdb/symfile.c | 36 ++++++++++++++++++++++++++++++++++--
1 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 91b7870..511d426 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -384,6 +384,29 @@ build_section_addr_info_from_section_table (const struct target_section *start,
return sap;
}
+/* Create a section_addr_info from section offsets in OBJFILE. */
+
+static struct section_addr_info *
+build_section_addr_info_from_objfile (const struct objfile *objfile)
+{
+ struct section_addr_info *sap;
+ int i;
+ struct bfd_section *sec;
+
+ sap = alloc_section_addr_info (objfile->num_sections);
+ for (i = 0, sec = objfile->obfd->sections;
+ i < objfile->num_sections;
+ i++, sec = sec->next)
+ {
+ gdb_assert (sec != NULL);
+ sap->other[i].addr = bfd_get_section_vma (objfile->obfd, sec)
+ + objfile->section_offsets->offsets[i];
+ sap->other[i].name = xstrdup (bfd_get_section_name (objfile->obfd, sec));
+ sap->other[i].sectindex = sec->index;
+ }
+ return sap;
+}
+
/* Free all memory allocated by build_section_addr_info_from_section_table. */
@@ -1043,14 +1066,23 @@ void
symbol_file_add_separate (bfd *bfd, int symfile_flags, struct objfile *objfile)
{
struct objfile *new_objfile;
+ struct section_addr_info *sap;
+ struct cleanup *my_cleanup;
+
+ /* Create section_addr_info. We can't directly use offsets from OBJFILE
+ because sections of BFD may not match sections of OBJFILE and because
+ vma may have been modified by tools such as prelink. */
+ sap = build_section_addr_info_from_objfile (objfile);
+ my_cleanup = make_cleanup_free_section_addr_info (sap);
new_objfile = symbol_file_add_with_addrs_or_offsets
(bfd, symfile_flags,
- 0, /* No addr table. */
- objfile->section_offsets, objfile->num_sections,
+ sap, NULL, 0,
objfile->flags & (OBJF_REORDERED | OBJF_SHARED | OBJF_READNOW
| OBJF_USERLOADED));
+ do_cleanups (my_cleanup);
+
add_separate_debug_objfile (new_objfile, objfile);
}
--
1.6.5.rc2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA] Always use addr info to add a separate debug file
2010-01-06 11:18 [RFA] Always use addr info to add a separate debug file Tristan Gingold
@ 2010-01-06 19:43 ` Tom Tromey
2010-01-07 9:32 ` Tristan Gingold
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2010-01-06 19:43 UTC (permalink / raw)
To: Tristan Gingold; +Cc: gdb-patches
>>>>> "Tristan" == Tristan Gingold <gingold@ACT-Europe.FR> writes:
Tristan> 2010-01-04 Tristan Gingold <gingold@adacore.com>
Tristan> * symfile.c (build_section_addr_info_from_objfile): New function.
Tristan> (symbol_file_add_separate): Don't use offsets from objfile but
Tristan> built an addr info.
Thanks. Just one nit.
Tristan> + sap->other[i].addr = bfd_get_section_vma (objfile->obfd, sec)
Tristan> + + objfile->section_offsets->offsets[i];
According to GNU rules the RHS of the assignment should be
parenthesized, and the second line thus more deeply indented.
Ok with that change.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA] Always use addr info to add a separate debug file
2010-01-06 19:43 ` Tom Tromey
@ 2010-01-07 9:32 ` Tristan Gingold
0 siblings, 0 replies; 3+ messages in thread
From: Tristan Gingold @ 2010-01-07 9:32 UTC (permalink / raw)
To: tromey; +Cc: Tristan Gingold, gdb-patches
On Jan 6, 2010, at 8:42 PM, Tom Tromey wrote:
>>>>>> "Tristan" == Tristan Gingold <gingold@ACT-Europe.FR> writes:
>
> Tristan> 2010-01-04 Tristan Gingold <gingold@adacore.com>
> Tristan> * symfile.c (build_section_addr_info_from_objfile): New function.
> Tristan> (symbol_file_add_separate): Don't use offsets from objfile but
> Tristan> built an addr info.
>
> Thanks. Just one nit.
>
> Tristan> + sap->other[i].addr = bfd_get_section_vma (objfile->obfd, sec)
> Tristan> + + objfile->section_offsets->offsets[i];
>
> According to GNU rules the RHS of the assignment should be
> parenthesized, and the second line thus more deeply indented.
Ah, I thought this was optional but after re-reading the GNU standard, it isn't.
Thanks for the prompt review, committed with the nit fixed.
Tristan.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-01-07 9:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-06 11:18 [RFA] Always use addr info to add a separate debug file Tristan Gingold
2010-01-06 19:43 ` Tom Tromey
2010-01-07 9:32 ` Tristan Gingold
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox