]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: remove SYMTAB_DIRNAME macro
authorSimon Marchi <simon.marchi@efficios.com>
Sun, 21 Nov 2021 03:24:54 +0000 (22:24 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Sun, 6 Feb 2022 21:03:46 +0000 (16:03 -0500)
Remove the macro, replace with an equivalent method.

Change-Id: I46ec36b91bb734331138eb9cd086b2db01635aed

gdb/cli/cli-cmds.c
gdb/source.c
gdb/symmisc.c
gdb/symtab.h

index 9120bbf1d84dc5fea04a12ce6f0ef77946fb0b25..15156792c504ab4ef081f41082c8a578465f584f 100644 (file)
@@ -2046,8 +2046,8 @@ ambiguous_line_spec (gdb::array_view<const symtab_and_line> sals,
 static int
 cmp_symtabs (const symtab_and_line &sala, const symtab_and_line &salb)
 {
-  const char *dira = SYMTAB_DIRNAME (sala.symtab);
-  const char *dirb = SYMTAB_DIRNAME (salb.symtab);
+  const char *dira = sala.symtab->dirname ();
+  const char *dirb = salb.symtab->dirname ();
   int r;
 
   if (dira == NULL)
index 1339c4a727f31a43b9a5e96d6b1a52d7b10e6156..53854c02eac186227d4721e727c601a1c3449c66 100644 (file)
@@ -713,8 +713,8 @@ info_source_command (const char *ignore, int from_tty)
 
   cust = s->compunit ();
   printf_filtered (_("Current source file is %s\n"), s->filename);
-  if (SYMTAB_DIRNAME (s) != NULL)
-    printf_filtered (_("Compilation directory is %s\n"), SYMTAB_DIRNAME (s));
+  if (s->dirname () != NULL)
+    printf_filtered (_("Compilation directory is %s\n"), s->dirname ());
   if (s->fullname)
     printf_filtered (_("Located in %s\n"), s->fullname);
   const std::vector<off_t> *offsets;
@@ -1180,7 +1180,7 @@ open_source_file (struct symtab *s)
 
   gdb::unique_xmalloc_ptr<char> fullname (s->fullname);
   s->fullname = NULL;
-  scoped_fd fd = find_and_open_source (s->filename, SYMTAB_DIRNAME (s),
+  scoped_fd fd = find_and_open_source (s->filename, s->dirname (),
                                       &fullname);
 
   if (fd.get () < 0)
@@ -1192,9 +1192,9 @@ open_source_file (struct symtab *s)
          std::string srcpath;
          if (IS_ABSOLUTE_PATH (s->filename))
            srcpath = s->filename;
-         else if (SYMTAB_DIRNAME (s) != nullptr)
+         else if (s->dirname () != nullptr)
            {
-             srcpath = SYMTAB_DIRNAME (s);
+             srcpath = s->dirname ();
              srcpath += SLASH_STRING;
              srcpath += s->filename;
            }
@@ -1268,10 +1268,10 @@ symtab_to_fullname (struct symtab *s)
          /* rewrite_source_path would be applied by find_and_open_source, we
             should report the pathname where GDB tried to find the file.  */
 
-         if (SYMTAB_DIRNAME (s) == NULL || IS_ABSOLUTE_PATH (s->filename))
+         if (s->dirname () == NULL || IS_ABSOLUTE_PATH (s->filename))
            fullname.reset (xstrdup (s->filename));
          else
-           fullname.reset (concat (SYMTAB_DIRNAME (s), SLASH_STRING,
+           fullname.reset (concat (s->dirname (), SLASH_STRING,
                                    s->filename, (char *) NULL));
 
          s->fullname = rewrite_source_path (fullname.get ()).release ();
index 62b584041defb979a3aff51be09e5ab62420eded..179b83e416fec9a83f5ffc63b5451a3072c8197d 100644 (file)
@@ -249,9 +249,9 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
                    symtab_to_filename_for_display (symtab),
                    host_address_to_string (symtab));
 
-  if (SYMTAB_DIRNAME (symtab) != NULL)
+  if (symtab->dirname () != NULL)
     fprintf_filtered (outfile, "Compilation directory is %s\n",
-                     SYMTAB_DIRNAME (symtab));
+                     symtab->dirname ());
   fprintf_filtered (outfile, "Read from object file %s (%s)\n",
                    objfile_name (objfile),
                    host_address_to_string (objfile));
index 5ef4bdaa110924d753436fda78ca8063bc6c1531..88dab003c5c3bf5ce106b7300888d364493e6a1e 100644 (file)
@@ -1409,6 +1409,8 @@ struct symtab
 
   program_space *pspace () const;
 
+  const char *dirname () const;
+
   /* Unordered chain of all filetabs in the compunit,  with the exception
      that the "main" source file is the first entry in the list.  */
 
@@ -1441,8 +1443,6 @@ struct symtab
 
 using symtab_range = next_range<symtab>;
 
-#define SYMTAB_DIRNAME(symtab) ((symtab)->compunit ()->dirname ())
-
 /* Compunit symtabs contain the actual "symbol table", aka blockvector, as well
    as the list of all source files (what gdb has historically associated with
    the term "symtab").
@@ -1696,6 +1696,12 @@ symtab::objfile () const
   return this->compunit ()->objfile ();
 }
 
+inline const char *
+symtab::dirname () const
+{
+  return this->compunit ()->dirname ();
+}
+
 /* Return the language of CUST.  */
 
 extern enum language compunit_language (const struct compunit_symtab *cust);