public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Add constructor to bound_minimal_symbol
@ 2022-02-16 20:47 Tom Tromey
  2022-02-18 19:46 ` Simon Marchi
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2022-02-16 20:47 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds a constructor to bound_minimal_symbol, to avoid a build
failure with clang that Simon pointed out.

I also took the opportunity to remove some redundant initializations,
and to change one use of push_back to emplace_back, as suggested by
Simon.
---
 gdb/breakpoint.c |  8 ++++----
 gdb/hppa-tdep.c  |  2 +-
 gdb/linespec.c   |  3 +--
 gdb/minsyms.c    | 10 +++++-----
 gdb/minsyms.h    |  8 ++++++++
 gdb/psymtab.c    |  2 +-
 6 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 9ff2bf82374..a3cfeea6989 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -3171,10 +3171,10 @@ static const char *const longjmp_names[] =
 struct breakpoint_objfile_data
 {
   /* Minimal symbol for "_ovly_debug_event" (if any).  */
-  struct bound_minimal_symbol overlay_msym {};
+  struct bound_minimal_symbol overlay_msym;
 
   /* Minimal symbol(s) for "longjmp", "siglongjmp", etc. (if any).  */
-  struct bound_minimal_symbol longjmp_msym[NUM_LONGJMP_NAMES] {};
+  struct bound_minimal_symbol longjmp_msym[NUM_LONGJMP_NAMES];
 
   /* True if we have looked for longjmp probes.  */
   int longjmp_searched = 0;
@@ -3184,10 +3184,10 @@ struct breakpoint_objfile_data
   std::vector<probe *> longjmp_probes;
 
   /* Minimal symbol for "std::terminate()" (if any).  */
-  struct bound_minimal_symbol terminate_msym {};
+  struct bound_minimal_symbol terminate_msym;
 
   /* Minimal symbol for "_Unwind_DebugHook" (if any).  */
-  struct bound_minimal_symbol exception_msym {};
+  struct bound_minimal_symbol exception_msym;
 
   /* True if we have looked for exception probes.  */
   int exception_searched = 0;
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index 7734115b744..760cb1bea13 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -2531,7 +2531,7 @@ struct bound_minimal_symbol
 hppa_lookup_stub_minimal_symbol (const char *name,
 				 enum unwind_stub_types stub_type)
 {
-  struct bound_minimal_symbol result = { NULL, NULL };
+  struct bound_minimal_symbol result;
 
   for (objfile *objfile : current_program_space->objfiles ())
     {
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 9e21df76efa..707a3a2586a 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -4273,8 +4273,7 @@ add_minsym (struct minimal_symbol *minsym, struct objfile *objfile,
   if (!list_mode && !msymbol_is_function (objfile, minsym))
     return;
 
-  struct bound_minimal_symbol mo = {minsym, objfile};
-  msyms->push_back (mo);
+  msyms->emplace_back (minsym, objfile);
   return;
 }
 
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 9a44e4bcf6d..4eab8daabec 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -230,13 +230,13 @@ add_minsym_to_demangled_hash_table (struct minimal_symbol *sym,
 struct found_minimal_symbols
 {
   /* External symbols are best.  */
-  bound_minimal_symbol external_symbol {};
+  bound_minimal_symbol external_symbol;
 
   /* File-local symbols are next best.  */
-  bound_minimal_symbol file_symbol {};
+  bound_minimal_symbol file_symbol;
 
   /* Symbols for shared library trampolines are next best.  */
-  bound_minimal_symbol trampoline_symbol {};
+  bound_minimal_symbol trampoline_symbol;
 
   /* Called when a symbol name matches.  Check if the minsym is a
      better type than what we had already found, and record it in one
@@ -601,8 +601,8 @@ struct bound_minimal_symbol
 lookup_minimal_symbol_text (const char *name, struct objfile *objf)
 {
   struct minimal_symbol *msymbol;
-  struct bound_minimal_symbol found_symbol = { NULL, NULL };
-  struct bound_minimal_symbol found_file_symbol = { NULL, NULL };
+  struct bound_minimal_symbol found_symbol;
+  struct bound_minimal_symbol found_file_symbol;
 
   unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
 
diff --git a/gdb/minsyms.h b/gdb/minsyms.h
index ed31d32483a..519702494ed 100644
--- a/gdb/minsyms.h
+++ b/gdb/minsyms.h
@@ -28,6 +28,14 @@ struct type;
 
 struct bound_minimal_symbol
 {
+  bound_minimal_symbol (struct minimal_symbol *msym, struct objfile *objf)
+    : minsym (msym),
+      objfile (objf)
+  {
+  }
+
+  bound_minimal_symbol () = default;
+
   /* The minimal symbol that was found, or NULL if no minimal symbol
      was found.  */
 
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index ac5009aec37..2aa1d18fed3 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1577,7 +1577,7 @@ maintenance_print_psymbols (const char *args, int from_tty)
 
 	  if (address_arg != NULL)
 	    {
-	      struct bound_minimal_symbol msymbol = { NULL, NULL };
+	      struct bound_minimal_symbol msymbol;
 
 	      /* We don't assume each pc has a unique objfile (this is for
 		 debugging).  */
-- 
2.31.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Add constructor to bound_minimal_symbol
  2022-02-16 20:47 [PATCH] Add constructor to bound_minimal_symbol Tom Tromey
@ 2022-02-18 19:46 ` Simon Marchi
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Marchi @ 2022-02-18 19:46 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches



On 2022-02-16 15:47, Tom Tromey via Gdb-patches wrote:
> This adds a constructor to bound_minimal_symbol, to avoid a build
> failure with clang that Simon pointed out.

Mine wasn't with clang.  I think the important point is when building
with -std=c++11 or -std=gnu++11.

Otherwise, LGTM, thanks.

Simon

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-18 19:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16 20:47 [PATCH] Add constructor to bound_minimal_symbol Tom Tromey
2022-02-18 19:46 ` Simon Marchi

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).