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);
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;
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 (),
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);
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;
}
/* 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);
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. */
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)
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.
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",
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. */
/* 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. */