aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-06-05 09:42:15 -0600
committerTom Tromey <tom@tromey.com>2018-06-28 08:20:59 -0600
commitd95d3aef9e63242e732e293e1f081d40d0d27eda (patch)
tree74018f795eac6296d0367c55cec2bd03db7671a3 /gdb
parent2512d7efdf49a1b8953932626bfdfa1da2367d9d (diff)
downloadgdb-d95d3aef9e63242e732e293e1f081d40d0d27eda.zip
gdb-d95d3aef9e63242e732e293e1f081d40d0d27eda.tar.gz
gdb-d95d3aef9e63242e732e293e1f081d40d0d27eda.tar.bz2
Make dwarf2_free_objfile static
I noticed that dwarf2_free_objfile can be made static, by changing it to be a registry cleanup function. This simplifies the code, as well, because now symbol readers don't have to explicitly call it. Tested by the buildbot. gdb/ChangeLog 2018-06-28 Tom Tromey <tom@tromey.com> * coffread.c (coff_symfile_finish): Update. * xcoffread.c (xcoff_symfile_finish): Update. * elfread.c (elf_symfile_finish): Update. * symfile.h (dwarf2_free_objfile): Don't declare. * dwarf2read.c (_initialize_dwarf2_read): Use register_objfile_data_with_cleanup. (dwarf2_free_objfile): Now static. Change signature.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog10
-rw-r--r--gdb/coffread.c2
-rw-r--r--gdb/dwarf2read.c12
-rw-r--r--gdb/elfread.c1
-rw-r--r--gdb/symfile.h2
-rw-r--r--gdb/xcoffread.c2
6 files changed, 16 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8062619..81fae49 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
+2018-06-28 Tom Tromey <tom@tromey.com>
+
+ * coffread.c (coff_symfile_finish): Update.
+ * xcoffread.c (xcoff_symfile_finish): Update.
+ * elfread.c (elf_symfile_finish): Update.
+ * symfile.h (dwarf2_free_objfile): Don't declare.
+ * dwarf2read.c (_initialize_dwarf2_read): Use
+ register_objfile_data_with_cleanup.
+ (dwarf2_free_objfile): Now static. Change signature.
+
2018-06-28 Petr Tesarik <ptesarik@suse.cz>
* symfile.c (add_symbol_file_command, _initialize_symfile): Add
diff --git a/gdb/coffread.c b/gdb/coffread.c
index bc266fb..30583e1 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -766,8 +766,6 @@ coff_symfile_finish (struct objfile *objfile)
{
/* Let stabs reader clean up. */
stabsread_clear_cache ();
-
- dwarf2_free_objfile (objfile);
}
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 083ec91..9f6d34f 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -24997,13 +24997,13 @@ free_one_cached_comp_unit (struct dwarf2_per_cu_data *target_per_cu)
}
}
-/* Release all extra memory associated with OBJFILE. */
+/* Cleanup function for the dwarf2_per_objfile data. */
-void
-dwarf2_free_objfile (struct objfile *objfile)
+static void
+dwarf2_free_objfile (struct objfile *objfile, void *datum)
{
struct dwarf2_per_objfile *dwarf2_per_objfile
- = get_dwarf2_per_objfile (objfile);
+ = static_cast<struct dwarf2_per_objfile *> (datum);
delete dwarf2_per_objfile;
}
@@ -25325,8 +25325,8 @@ show_check_physname (struct ui_file *file, int from_tty,
void
_initialize_dwarf2_read (void)
{
-
- dwarf2_objfile_data_key = register_objfile_data ();
+ dwarf2_objfile_data_key
+ = register_objfile_data_with_cleanup (nullptr, dwarf2_free_objfile);
add_prefix_cmd ("dwarf", class_maintenance, set_dwarf_cmd, _("\
Set DWARF specific variables.\n\
diff --git a/gdb/elfread.c b/gdb/elfread.c
index e11c051..feca5ea 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1336,7 +1336,6 @@ elf_new_init (struct objfile *ignore)
static void
elf_symfile_finish (struct objfile *objfile)
{
- dwarf2_free_objfile (objfile);
}
/* ELF specific initialization routine for reading symbols. */
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 1b47669..79c7687 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -616,8 +616,6 @@ extern bool dwarf2_initialize_objfile (struct objfile *objfile,
extern void dwarf2_build_psymtabs (struct objfile *);
extern void dwarf2_build_frame_info (struct objfile *);
-void dwarf2_free_objfile (struct objfile *);
-
/* From mdebugread.c */
extern void mdebug_build_psymtabs (minimal_symbol_reader &,
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 7b9694b..79b1df7 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1959,8 +1959,6 @@ xcoff_symfile_finish (struct objfile *objfile)
inclTable = NULL;
}
inclIndx = inclLength = inclDepth = 0;
-
- dwarf2_free_objfile (objfile);
}