public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Introduce new add_psymbol_to_list overload
@ 2020-04-24 21:35 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2020-04-24 21:35 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2467f4f6a533a28047e0b45ce716b9b1f9f72a09

commit 2467f4f6a533a28047e0b45ce716b9b1f9f72a09
Author: Tom Tromey <tom@tromey.com>
Date:   Fri Apr 24 15:35:01 2020 -0600

    Introduce new add_psymbol_to_list overload
    
    This adds a new overload of add_psymbol_to_list.  This one takes an
    already constructed psymbol and adds it to the bcache and the
    appropriate list.
    
    This seemed cleaner than continuing to add parameters to the existing
    add_psymbol_to_list, and is more in line with how full symbols are
    constructed.
    
    gdb/ChangeLog
    2020-04-24  Tom Tromey  <tom@tromey.com>
    
            * psymtab.c (add_psymbol_to_bcache): Simplify calling convention.
            (add_psymbol_to_list): New overload.  Make old overload call new
            one.
            * psympriv.h (add_psymbol_to_list): New overload.

Diff:
---
 gdb/ChangeLog  |  7 +++++++
 gdb/psympriv.h |  8 ++++++++
 gdb/psymtab.c  | 53 +++++++++++++++++++++++++++++------------------------
 3 files changed, 44 insertions(+), 24 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index df43ffd296e..083d4d29eca 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2020-04-24  Tom Tromey  <tom@tromey.com>
+
+	* psymtab.c (add_psymbol_to_bcache): Simplify calling convention.
+	(add_psymbol_to_list): New overload.  Make old overload call new
+	one.
+	* psympriv.h (add_psymbol_to_list): New overload.
+
 2020-04-24  Tom Tromey  <tom@tromey.com>
 
 	* dwarf2/read.c (partial_die_info::read) <case
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index fdcee99e330..6f0307e05b7 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -424,6 +424,14 @@ extern void add_psymbol_to_list (gdb::string_view name,
 				 enum language language,
 				 struct objfile *objfile);
 
+/* Add a symbol to the partial symbol table of OBJFILE.  The psymbol
+   must be fully constructed, and the names must be set and intern'd
+   as appropriate.  */
+
+extern void add_psymbol_to_list (const partial_symbol &psym,
+				 psymbol_placement where,
+				 struct objfile *objfile);
+
 /* Initialize storage for partial symbols.  If partial symbol storage
    has already been initialized, this does nothing.  TOTAL_SYMBOLS is
    an estimate of how many symbols there will be.  */
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 376cbeedcdf..118dc570e7c 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1590,24 +1590,10 @@ psymbol_compare (const void *addr1, const void *addr2, int length)
    different domain (or address) is possible and correct.  */
 
 static struct partial_symbol *
-add_psymbol_to_bcache (gdb::string_view name, bool copy_name,
-		       domain_enum domain,
-		       enum address_class theclass,
-		       short section,
-		       CORE_ADDR coreaddr,
-		       enum language language, struct objfile *objfile,
+add_psymbol_to_bcache (const partial_symbol &psymbol,
+		       struct objfile *objfile,
 		       int *added)
 {
-  struct partial_symbol psymbol;
-  memset (&psymbol, 0, sizeof (psymbol));
-
-  psymbol.set_unrelocated_address (coreaddr);
-  psymbol.ginfo.section = section;
-  psymbol.domain = domain;
-  psymbol.aclass = theclass;
-  psymbol.ginfo.set_language (language, objfile->partial_symtabs->obstack ());
-  psymbol.ginfo.compute_and_set_names (name, copy_name, objfile->per_bfd);
-
   /* Stash the partial symbol away in the cache.  */
   return ((struct partial_symbol *)
 	  objfile->partial_symtabs->psymbol_cache.insert
@@ -1628,21 +1614,16 @@ append_psymbol_to_list (std::vector<partial_symbol *> *list,
 /* See psympriv.h.  */
 
 void
-add_psymbol_to_list (gdb::string_view name, bool copy_name,
-		     domain_enum domain,
-		     enum address_class theclass,
-		     short section,
+add_psymbol_to_list (const partial_symbol &psymbol,
 		     psymbol_placement where,
-		     CORE_ADDR coreaddr,
-		     enum language language, struct objfile *objfile)
+		     struct objfile *objfile)
 {
   struct partial_symbol *psym;
 
   int added;
 
   /* Stash the partial symbol away in the cache.  */
-  psym = add_psymbol_to_bcache (name, copy_name, domain, theclass,
-				section, coreaddr, language, objfile, &added);
+  psym = add_psymbol_to_bcache (psymbol, objfile, &added);
 
   /* Do not duplicate global partial symbols.  */
   if (where == psymbol_placement::GLOBAL && !added)
@@ -1658,6 +1639,30 @@ add_psymbol_to_list (gdb::string_view name, bool copy_name,
 
 /* See psympriv.h.  */
 
+void
+add_psymbol_to_list (gdb::string_view name, bool copy_name,
+		     domain_enum domain,
+		     enum address_class theclass,
+		     short section,
+		     psymbol_placement where,
+		     CORE_ADDR coreaddr,
+		     enum language language, struct objfile *objfile)
+{
+  struct partial_symbol psymbol;
+  memset (&psymbol, 0, sizeof (psymbol));
+
+  psymbol.set_unrelocated_address (coreaddr);
+  psymbol.ginfo.section = section;
+  psymbol.domain = domain;
+  psymbol.aclass = theclass;
+  psymbol.ginfo.set_language (language, objfile->partial_symtabs->obstack ());
+  psymbol.ginfo.compute_and_set_names (name, copy_name, objfile->per_bfd);
+
+  add_psymbol_to_list (psymbol, where, objfile);
+}
+
+/* See psympriv.h.  */
+
 void
 init_psymbol_list (struct objfile *objfile, int total_symbols)
 {


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-04-24 21:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-24 21:35 [binutils-gdb] Introduce new add_psymbol_to_list overload Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).