[PATCH 08/33] gdb: remove COMPUNIT_DEBUGFORMAT macro, add getter/setter

Simon Marchi simon.marchi@polymtl.ca
Fri Jan 28 12:45:06 GMT 2022


From: Simon Marchi <simon.marchi@efficios.com>

Add a getter and a setter for a compunit_symtab's debugformat.  Remove
the corresponding macro and adjust all callers.

Change-Id: I1667b02d5322346f8e23abd9f8a584afbcd75975
---
 gdb/buildsym.c   |  2 +-
 gdb/mdebugread.c |  2 +-
 gdb/or1k-tdep.c  |  2 +-
 gdb/source.c     |  2 +-
 gdb/symfile.c    |  2 +-
 gdb/symmisc.c    |  2 +-
 gdb/symtab.h     | 13 +++++++++++--
 gdb/z80-tdep.c   |  2 +-
 8 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 855d84bd27a6..267b9462abd4 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -1010,7 +1010,7 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
     }
 
   /* Save the debug format string (if any) in the symtab.  */
-  COMPUNIT_DEBUGFORMAT (cu) = m_debugformat;
+  cu->set_debugformat (m_debugformat);
 
   /* Similarly for the producer.  */
   COMPUNIT_PRODUCER (cu) = m_producer;
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 836da8a3b8ca..44c7bc306d07 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -4634,7 +4634,7 @@ new_symtab (const char *name, int maxlines, struct objfile *objfile)
     BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
   COMPUNIT_BLOCKVECTOR (cust) = bv;
 
-  COMPUNIT_DEBUGFORMAT (cust) = "ECOFF";
+  cust->set_debugformat ("ECOFF");
   return cust;
 }
 
diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c
index 1e01df223add..5670a623024f 100644
--- a/gdb/or1k-tdep.c
+++ b/gdb/or1k-tdep.c
@@ -472,7 +472,7 @@ or1k_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 	  struct symtab_and_line prologue_sal = find_pc_line (start_pc, 0);
 	  struct compunit_symtab *compunit
 	    = SYMTAB_COMPUNIT (prologue_sal.symtab);
-	  const char *debug_format = COMPUNIT_DEBUGFORMAT (compunit);
+	  const char *debug_format = compunit->debugformat ();
 
 	  if ((NULL != debug_format)
 	      && (strlen ("dwarf") <= strlen (debug_format))
diff --git a/gdb/source.c b/gdb/source.c
index 2160619b34ff..3f047467b2eb 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -727,7 +727,7 @@ info_source_command (const char *ignore, int from_tty)
 		   COMPUNIT_PRODUCER (cust) != NULL
 		   ? COMPUNIT_PRODUCER (cust) : _("unknown"));
   printf_filtered (_("Compiled with %s debugging format.\n"),
-		   COMPUNIT_DEBUGFORMAT (cust));
+		   cust->debugformat ());
   printf_filtered (_("%s preprocessor macro info.\n"),
 		   COMPUNIT_MACRO_TABLE (cust) != NULL
 		   ? "Includes" : "Does not include");
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 8ec214fb8e65..b20284cad988 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2831,7 +2831,7 @@ allocate_compunit_symtab (struct objfile *objfile, const char *name)
   saved_name = lbasename (name);
   cu->name = obstack_strdup (&objfile->objfile_obstack, saved_name);
 
-  COMPUNIT_DEBUGFORMAT (cu) = "unknown";
+  cu->set_debugformat ("unknown");
 
   if (symtab_create_debug)
     {
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 61e3eff562e5..4220fd7f9395 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -777,7 +777,7 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
 			printf_filtered ("  { ((struct compunit_symtab *) %s)\n",
 					 host_address_to_string (cust));
 			printf_filtered ("    debugformat %s\n",
-					 COMPUNIT_DEBUGFORMAT (cust));
+					 cust->debugformat ());
 			printf_filtered ("    producer %s\n",
 					 COMPUNIT_PRODUCER (cust) != NULL
 					 ? COMPUNIT_PRODUCER (cust)
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 45d4bc4dc299..2500c8e4166d 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1482,6 +1482,16 @@ struct compunit_symtab
       }
   }
 
+  const char *debugformat () const
+  {
+    return m_debugformat;
+  }
+
+  void set_debugformat (const char *debugformat)
+  {
+    m_debugformat = debugformat;
+  }
+
   /* Make PRIMARY_FILETAB the primary filetab of this compunit symtab.
 
      PRIMARY_FILETAB must already be a filetab of this compunit symtab.  */
@@ -1525,7 +1535,7 @@ struct compunit_symtab
      such as "stabs", "dwarf 1", "dwarf 2", "coff", etc.  This is mostly useful
      for automated testing of gdb but may also be information that is
      useful to the user.  */
-  const char *debugformat;
+  const char *m_debugformat;
 
   /* String of producer version information, or NULL if we don't know.  */
   const char *producer;
@@ -1577,7 +1587,6 @@ struct compunit_symtab
 
 using compunit_symtab_range = next_range<compunit_symtab>;
 
-#define COMPUNIT_DEBUGFORMAT(cust) ((cust)->debugformat)
 #define COMPUNIT_PRODUCER(cust) ((cust)->producer)
 #define COMPUNIT_DIRNAME(cust) ((cust)->dirname)
 #define COMPUNIT_BLOCKVECTOR(cust) ((cust)->blockvector)
diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c
index 46fc64bd69b3..4a58fe5138ea 100644
--- a/gdb/z80-tdep.c
+++ b/gdb/z80-tdep.c
@@ -496,7 +496,7 @@ z80_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
     {
       struct symtab_and_line prologue_sal = find_pc_line (func_addr, 0);
       struct compunit_symtab *compunit = SYMTAB_COMPUNIT (prologue_sal.symtab);
-      const char *debug_format = COMPUNIT_DEBUGFORMAT (compunit);
+      const char *debug_format = compunit->debugformat ();
 
       if (debug_format != NULL &&
 	  !strncasecmp ("dwarf", debug_format, strlen("dwarf")))
-- 
2.34.1



More information about the Gdb-patches mailing list