[binutils-gdb] gdb: fix logic of find_comp_unit and set_comp_unit
Simon Marchi
simark@sourceware.org
Thu Dec 3 20:48:28 GMT 2020
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0bc2e38dd71e24676e180b6b37e0a2cd1186994d
commit 0bc2e38dd71e24676e180b6b37e0a2cd1186994d
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date: Thu Dec 3 15:47:56 2020 -0500
gdb: fix logic of find_comp_unit and set_comp_unit
The logic in find_comp_unit and set_comp_unit is reversed. When the BFD
requires relocation, we want to put the comp_unit structure in the
map where the comp_unit objects are not shared, that is the one indexed
by objfile. If the BFD does not require relocation, then, we can share
a single comp_unit structure for all users of that BFD, so we want to
put it in the BFD-indexed map. The comments on top of
dwarf2_frame_bfd_data and dwarf2_frame_objfile_data make that clear.
Fix it by swapping the two in find_comp_unit and set_comp_unit.
I don't have a test for this, because I don't see how to write one in a
reasonable amount of time.
gdb/ChangeLog:
PR gdb/26876
* dwarf2/frame.c (find_comp_unit, set_comp_unit): Reverse use of
dwarf2_frame_bfd_data and dwarf2_frame_objfile_data.
Change-Id: I80c1ee7ad8425fa4947de65b170973d05f5a52ec
Diff:
---
gdb/ChangeLog | 6 ++++++
gdb/dwarf2/frame.c | 10 ++++++----
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7c0739368ec..75d7422559d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2020-12-03 Simon Marchi <simon.marchi@polymtl.ca>
+
+ PR gdb/26876
+ * dwarf2/frame.c (find_comp_unit, set_comp_unit): Reverse use of
+ dwarf2_frame_bfd_data and dwarf2_frame_objfile_data.
+
2020-12-02 Andrew Burgess <andrew.burgess@embecosm.com>
* arch/riscv.c: Include 'rv32e-xregs.c'.
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index a577a671f24..7df3ccfe46a 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -1640,8 +1640,9 @@ find_comp_unit (struct objfile *objfile)
{
bfd *abfd = objfile->obfd;
if (gdb_bfd_requires_relocations (abfd))
- return dwarf2_frame_bfd_data.get (abfd);
- return dwarf2_frame_objfile_data.get (objfile);
+ return dwarf2_frame_objfile_data.get (objfile);
+
+ return dwarf2_frame_bfd_data.get (abfd);
}
/* Store the comp_unit on OBJFILE, or the corresponding BFD, as
@@ -1652,8 +1653,9 @@ set_comp_unit (struct objfile *objfile, struct comp_unit *unit)
{
bfd *abfd = objfile->obfd;
if (gdb_bfd_requires_relocations (abfd))
- return dwarf2_frame_bfd_data.set (abfd, unit);
- return dwarf2_frame_objfile_data.set (objfile, unit);
+ return dwarf2_frame_objfile_data.set (objfile, unit);
+
+ return dwarf2_frame_bfd_data.set (abfd, unit);
}
/* Find the FDE for *PC. Return a pointer to the FDE, and store the
More information about the Gdb-cvs
mailing list