aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-02-12 15:45:08 -0700
committerTom Tromey <tom@tromey.com>2020-02-12 15:51:58 -0700
commit3d4560f707b077adfb54759df5efbd96301ca2d8 (patch)
treec9ef758cce6c2d290761a69477f7a41ca133720e /gdb
parent219823045622bd111d68b984e31aa7b1712d5e10 (diff)
downloadgdb-3d4560f707b077adfb54759df5efbd96301ca2d8.zip
gdb-3d4560f707b077adfb54759df5efbd96301ca2d8.tar.gz
gdb-3d4560f707b077adfb54759df5efbd96301ca2d8.tar.bz2
Move the frame data to the BFD when possible
Now that comp_unit and the remaining frame data are all independent of the objfile, it can all be stored on the BFD and shared across inferiors. As with other code doing this same thing, care must be taken to not share the data when the objfile requires relocations. So, two keys are used: one for the BFD and one for the objfile, and gdb_bfd_requires_relocations is used to differentiate between the two cases. gdb/ChangeLog 2020-02-12 Tom Tromey <tom@tromey.com> * dwarf2/frame.c (dwarf2_frame_bfd_data): New global. (dwarf2_frame_objfile_data): Add comment. (find_comp_unit, set_comp_unit): New functions. (dwarf2_frame_find_fde): Use find_comp_unit. (dwarf2_build_frame_info): Use set_comp_unit.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/dwarf2/frame.c39
2 files changed, 42 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 27166b4..f9dd0b6 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
2020-02-12 Tom Tromey <tom@tromey.com>
+ * dwarf2/frame.c (dwarf2_frame_bfd_data): New global.
+ (dwarf2_frame_objfile_data): Add comment.
+ (find_comp_unit, set_comp_unit): New functions.
+ (dwarf2_frame_find_fde): Use find_comp_unit.
+ (dwarf2_build_frame_info): Use set_comp_unit.
+
+2020-02-12 Tom Tromey <tom@tromey.com>
+
* dwarf2/frame.c (struct comp_unit) <objfile>: Remove.
(comp_unit): Don't initialize objfile.
(execute_cfa_program): Add text_offset parameter.
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index ff33f4d..b240a25 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -1480,8 +1480,14 @@ dwarf2_frame_cfa (struct frame_info *this_frame)
return get_frame_base (this_frame);
}
-static const struct objfile_key<comp_unit> dwarf2_frame_objfile_data;
-
+/* We store the frame data on the BFD. This is only done if it is
+ independent of the address space and so can be shared. */
+static const struct bfd_key<comp_unit> dwarf2_frame_bfd_data;
+
+/* If any BFD sections require relocations (note; really should be if
+ any debug info requires relocations), then we store the frame data
+ on the objfile instead, and do not share it. */
+const struct objfile_key<comp_unit> dwarf2_frame_objfile_data;
/* Pointer encoding helper functions. */
@@ -1635,6 +1641,29 @@ bsearch_fde_cmp (const dwarf2_fde *fde, CORE_ADDR seek_pc)
return 1;
}
+/* Find an existing comp_unit for an objfile, if any. */
+
+static comp_unit *
+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);
+}
+
+/* Store the comp_unit on OBJFILE, or the corresponding BFD, as
+ appropriate. */
+
+static void
+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);
+}
+
/* Find the FDE for *PC. Return a pointer to the FDE, and store the
initial location associated with it into *PC. */
@@ -1646,11 +1675,11 @@ dwarf2_frame_find_fde (CORE_ADDR *pc, CORE_ADDR *out_offset)
CORE_ADDR offset;
CORE_ADDR seek_pc;
- comp_unit *unit = dwarf2_frame_objfile_data.get (objfile);
+ comp_unit *unit = find_comp_unit (objfile);
if (unit == NULL)
{
dwarf2_build_frame_info (objfile);
- unit = dwarf2_frame_objfile_data.get (objfile);
+ unit = find_comp_unit (objfile);
}
gdb_assert (unit != NULL);
@@ -2262,7 +2291,7 @@ dwarf2_build_frame_info (struct objfile *objfile)
}
unit->fde_table.shrink_to_fit ();
- dwarf2_frame_objfile_data.set (objfile, unit.release ());
+ set_comp_unit (objfile, unit.release ());
}
/* Handle 'maintenance show dwarf unwinders'. */