From f65fe5704af56aca58fd5547d0841a9512e540af Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 1 Nov 2019 16:10:48 -0600 Subject: [PATCH] Make add_separate_debug_objfile static This changes objfile::make to take a "parent" parameter, and makes add_separate_debug_objfile static. gdb/ChangeLog 2019-12-12 Tom Tromey * symfile.c (symbol_file_add_with_addrs): Pass "parent" to objfile::make. * objfiles.h (struct objjfile) : No longer inline. (add_separate_debug_objfile): Don't declare. * objfiles.c (add_separate_debug_objfile): Now static. (objfile::make): Move from objfiles.h. Call add_separate_debug_objfile. Add "parent" parameter. Change-Id: I631f43bb71738dea6ae0697317bf8ef4a0db4617 --- gdb/ChangeLog | 10 ++++++++++ gdb/objfiles.c | 14 +++++++++++++- gdb/objfiles.h | 8 ++------ gdb/symfile.c | 5 +---- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 393d43ef316..7bcd2c7fbd0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2019-12-12 Tom Tromey + + * symfile.c (symbol_file_add_with_addrs): Pass "parent" to + objfile::make. + * objfiles.h (struct objjfile) : No longer inline. + (add_separate_debug_objfile): Don't declare. + * objfiles.c (add_separate_debug_objfile): Now static. + (objfile::make): Move from objfiles.h. Call + add_separate_debug_objfile. Add "parent" parameter. + 2019-12-12 Tom Tromey * symfile.c (symbol_file_add_with_addrs): Use objfile::make. diff --git a/gdb/objfiles.c b/gdb/objfiles.c index b5bc09f41ea..0ee5720cf67 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -520,7 +520,7 @@ put_objfile_before (struct objfile *objfile, struct objfile *before_this) /* Add OBJFILE as a separate debug objfile of PARENT. */ -void +static void add_separate_debug_objfile (struct objfile *objfile, struct objfile *parent) { gdb_assert (objfile && parent); @@ -541,6 +541,18 @@ add_separate_debug_objfile (struct objfile *objfile, struct objfile *parent) put_objfile_before (objfile, parent); } +/* See objfiles.h. */ + +objfile * +objfile::make (bfd *bfd_, const char *name_, objfile_flags flags_, + objfile *parent) +{ + objfile *result = new objfile (bfd_, name_, flags_); + if (parent != nullptr) + add_separate_debug_objfile (result, parent); + return result; +} + /* Free all separate debug objfile of OBJFILE, but don't free OBJFILE itself. */ diff --git a/gdb/objfiles.h b/gdb/objfiles.h index b5c04eb7cb9..663e6390dcd 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -402,10 +402,8 @@ private: public: /* Create an objfile. */ - static objfile *make (bfd *bfd_, const char *name_, objfile_flags flags_) - { - return new objfile (bfd_, name_, flags_); - } + static objfile *make (bfd *bfd_, const char *name_, objfile_flags flags_, + objfile *parent = nullptr); ~objfile (); @@ -649,8 +647,6 @@ extern CORE_ADDR entry_point_address (void); extern void build_objfile_section_table (struct objfile *); -extern void add_separate_debug_objfile (struct objfile *, struct objfile *); - extern void free_objfile_separate_debug (struct objfile *); extern void free_all_objfiles (void); diff --git a/gdb/symfile.c b/gdb/symfile.c index eef27a8418e..8e3cf7f23e5 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1093,10 +1093,7 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name, if (mainline) flags |= OBJF_MAINLINE; - objfile = objfile::make (abfd, name, flags); - - if (parent) - add_separate_debug_objfile (objfile, parent); + objfile = objfile::make (abfd, name, flags, parent); /* We either created a new mapped symbol table, mapped an existing symbol table file which has not had initial symbol reading -- 2.30.2