]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Rename symtab::fullname
authorTom Tromey <tromey@adacore.com>
Wed, 5 Jun 2024 14:51:01 +0000 (08:51 -0600)
committerTom Tromey <tromey@adacore.com>
Mon, 24 Jun 2024 15:11:29 +0000 (09:11 -0600)
This renames symtab::fullname to m_fullname and adds new accessor
methods.

gdb/annotate.c
gdb/python/py-breakpoint.c
gdb/source.c
gdb/symfile-debug.c
gdb/symfile.c
gdb/symmisc.c
gdb/symtab.h

index 4ff3eb89807bc62bd070d5a88fc654b9e29b124f..88180295d1d6752ae5256582c3f7fa007f494573 100644 (file)
@@ -451,7 +451,7 @@ annotate_source_line (struct symtab *s, int line, int mid_statement,
       if (line > offsets->size ())
        return false;
 
-      annotate_source (s->fullname, line, (int) (*offsets)[line - 1],
+      annotate_source (s->fullname (), line, (int) (*offsets)[line - 1],
                       mid_statement, s->compunit ()->objfile ()->arch (),
                       pc);
 
index fdc24832315071638dbee5e766be1884313ff67e..e7dd47020c58b67aca16c07e212957bbee02629d 100644 (file)
@@ -1716,10 +1716,10 @@ bplocpy_get_fullname (PyObject *py_self, void *closure)
   BPPY_REQUIRE_VALID (self->owner);
   BPLOCPY_REQUIRE_VALID (self->owner, self);
   const auto symtab = self->bp_loc->symtab;
-  if (symtab != nullptr && symtab->fullname != nullptr)
+  if (symtab != nullptr && symtab->fullname () != nullptr)
     {
       gdbpy_ref<> fullname
-       = host_string_to_python_string (symtab->fullname);
+       = host_string_to_python_string (symtab->fullname ());
       return fullname.release ();
     }
   Py_RETURN_NONE;
index 24a8769da91472760d07af6ae9f43aadaa9b7be1..9e528d3f705dc875327a8b4860ee0b2f5a4fb0d3 100644 (file)
@@ -685,8 +685,8 @@ info_source_command (const char *ignore, int from_tty)
   gdb_printf (_("Current source file is %s\n"), s->filename);
   if (s->compunit ()->dirname () != NULL)
     gdb_printf (_("Compilation directory is %s\n"), s->compunit ()->dirname ());
-  if (s->fullname)
-    gdb_printf (_("Located in %s\n"), s->fullname);
+  if (s->fullname () != nullptr)
+    gdb_printf (_("Located in %s\n"), s->fullname ());
   const std::vector<off_t> *offsets;
   if (g_source_cache.get_line_charpos (s, &offsets))
     gdb_printf (_("Contains %d line%s.\n"), (int) offsets->size (),
@@ -1145,8 +1145,7 @@ open_source_file (struct symtab *s)
   if (!s)
     return scoped_fd (-EINVAL);
 
-  gdb::unique_xmalloc_ptr<char> fullname (s->fullname);
-  s->fullname = NULL;
+  gdb::unique_xmalloc_ptr<char> fullname = s->release_fullname ();
   scoped_fd fd = find_and_open_source (s->filename, s->compunit ()->dirname (),
                                       &fullname);
 
@@ -1182,14 +1181,14 @@ open_source_file (struct symtab *s)
                 It handles the reporting of its own errors.  */
              if (query_fd.get () >= 0)
                {
-                 s->fullname = fullname.release ();
+                 s->set_fullname (std::move (fullname));
                  return query_fd;
                }
            }
        }
     }
 
-  s->fullname = fullname.release ();
+  s->set_fullname (std::move (fullname));
   return fd;
 }
 
@@ -1236,7 +1235,7 @@ symtab_to_fullname (struct symtab *s)
   /* Use cached copy if we have it.
      We rely on forget_cached_source_info being called appropriately
      to handle cases like the file being moved.  */
-  if (s->fullname == NULL)
+  if (s->fullname () == nullptr)
     {
       scoped_fd fd = open_source_file (s);
 
@@ -1254,13 +1253,13 @@ symtab_to_fullname (struct symtab *s)
            fullname.reset (concat (s->compunit ()->dirname (), SLASH_STRING,
                                    s->filename, (char *) NULL));
 
-         s->fullname = rewrite_source_path (fullname.get ()).release ();
-         if (s->fullname == NULL)
-           s->fullname = fullname.release ();
+         s->set_fullname (rewrite_source_path (fullname.get ()));
+         if (s->fullname () == nullptr)
+           s->set_fullname (std::move (fullname));
        }
     } 
 
-  return s->fullname;
+  return s->fullname ();
 }
 
 /* See commentary in source.h.  */
index 86c7010b2d29ab800eaafe071a17cb24f87ba9a4..39128894a5c059bd09764f69535e67670a91f5ea 100644 (file)
@@ -156,13 +156,7 @@ objfile::forget_cached_source_info ()
   for (compunit_symtab *cu : compunits ())
     {
       for (symtab *s : cu->filetabs ())
-       {
-         if (s->fullname != NULL)
-           {
-             xfree (s->fullname);
-             s->fullname = NULL;
-           }
-       }
+       s->release_fullname ();
     }
 
   for (const auto &iter : qf)
index 5a03def91c61be01160b3e080bb9a214877eba71..b0510b4b4090e211ebca6615939958a894d7887e 100644 (file)
@@ -2803,7 +2803,6 @@ allocate_symtab (struct compunit_symtab *cust, const char *filename,
 
   symtab->filename = objfile->intern (filename);
   symtab->filename_for_id = objfile->intern (filename_for_id);
-  symtab->fullname = NULL;
   symtab->set_language (deduce_language_from_filename (filename));
 
   /* This can be very verbose with lots of headers.
index 2956ad92fcef22b7bdd3d188ed4a6b86d95a93c3..b4e0360041e7b3ab85fce869479df595eaeebd4c 100644 (file)
@@ -811,8 +811,8 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
                    gdb_printf ("((struct symtab *) %s)\n",
                                host_address_to_string (symtab));
                    gdb_printf ("\t  fullname %s\n",
-                               symtab->fullname != NULL
-                               ? symtab->fullname
+                               symtab->fullname () != nullptr
+                               ? symtab->fullname ()
                                : "(null)");
                    gdb_printf ("\t  "
                                "linetable ((struct linetable *) %s)\n",
index 3d766fd5685597d1dcfef0cbdaf5323d696f1e69..e75c6389953d3336f2cb1d6bc2bbbf95faedf020 100644 (file)
@@ -1739,6 +1739,27 @@ struct symtab
     m_language = language;
   }
 
+  /* Return the current full name of this symtab.  */
+  const char *fullname () const
+  { return m_fullname; }
+
+  /* Transfer ownership of the current full name to the caller.  The
+     full name is reset to nullptr.  */
+  gdb::unique_xmalloc_ptr<char> release_fullname ()
+  {
+    gdb::unique_xmalloc_ptr<char> result (m_fullname);
+    m_fullname = nullptr;
+    return result;
+  }
+
+  /* Set the current full name to NAME, transferring ownership to this
+     symtab.  */
+  void set_fullname (gdb::unique_xmalloc_ptr<char> name)
+  {
+    gdb_assert (m_fullname == nullptr);
+    m_fullname = name.release ();
+  }
+
   /* Unordered chain of all filetabs in the compunit,  with the exception
      that the "main" source file is the first entry in the list.  */
 
@@ -1776,7 +1797,7 @@ struct symtab
   /* Full name of file as found by searching the source path.
      NULL if not yet known.  */
 
-  char *fullname;
+  char *m_fullname;
 };
 
 /* A range adapter to allowing iterating over all the file tables in a list.  */