#include "gdbcore.h"
#include "gdbsupport/pathstuff.h"
#include "gdbsupport/scoped_fd.h"
+#include "run-on-main-thread.h"
const char *
dwz_file::read_string (struct objfile *objfile, LONGEST str_offset)
size_t buildid_len;
bfd_byte *buildid;
- if (per_bfd->dwz_file != NULL)
- return per_bfd->dwz_file.get ();
+ if (per_bfd->dwz_file.has_value ())
+ {
+ dwz_file *result = per_bfd->dwz_file->get ();
+ if (require && result == nullptr)
+ error (_("could not read '.gnu_debugaltlink' section"));
+ return result;
+ }
+
+ /* This may query the user via the debuginfod support, so it may
+ only be run in the main thread. */
+ gdb_assert (is_main_thread ());
+
+ /* Set this early, so that on error it remains NULL. */
+ per_bfd->dwz_file.emplace (nullptr);
bfd_set_error (bfd_error_no_error);
gdb::unique_xmalloc_ptr<char> data
gdb_bfd_record_inclusion (per_bfd->obfd, result->dwz_bfd.get ());
per_bfd->dwz_file = std::move (result);
- return per_bfd->dwz_file.get ();
+ return per_bfd->dwz_file->get ();
}
dwarf_read_debug_printf ("called");
+ /* Try to fetch any potential dwz file early, while still on the
+ main thread. */
+ try
+ {
+ dwarf2_get_dwz_file (per_bfd);
+ }
+ catch (const gdb_exception_error &err)
+ {
+ warning (_("%s"), err.what ());
+ }
+
/* If we're about to read full symbols, don't bother with the
indices. In this case we also don't care if some other debug
format is making psymtabs, because they are all about to be
&per_objfile->per_bfd->abbrev, 0,
types_htab, rcuh_kind::TYPE);
- dwz_file *dwz;
- try
- {
- dwz = dwarf2_get_dwz_file (per_objfile->per_bfd);
- }
- catch (const gdb_exception_error &)
- {
- per_objfile->per_bfd->all_units.clear ();
- throw;
- }
+ dwz_file *dwz = dwarf2_get_dwz_file (per_objfile->per_bfd);
if (dwz != NULL)
{
/* Pre-read the sections we'll need to construct an index. */
/* The shared '.dwz' file, if one exists. This is used when the
original data was compressed using 'dwz -m'. */
- std::unique_ptr<struct dwz_file> dwz_file;
+ gdb::optional<std::unique_ptr<struct dwz_file>> dwz_file;
/* Whether copy relocations are supported by this object format. */
bool can_copy;
gdb_load ${::binfile}-${::testname}
- if { $::testname == "mismatch" && [readnow] } {
- # Main is found in the minimal symbols. When using readnow, a
- # failure to read the dwarf also causes the minimal symbols to be
- # unavailable.
- # Setup a kfail for "FAIL: gdb_breakpoint: set breakpoint at main".
- setup_kfail "symtab/26797" *-*-*
- }
if {![runto_main]} {
return
}
clean_restart
-set msg "\r\ncould not find '\.gnu_debugaltlink' file for \[^\r\n\]*"
+set msg "\r\nwarning: could not find '\.gnu_debugaltlink' file for \[^\r\n\]*"
gdb_test "file $binfile" "$msg" "file command"
set question "Load new symbol table from .*\? .y or n. "
-gdb_test "file $binfile" "$msg" "file command, again" $question "y"
+gdb_test "file $binfile" "" "file command, again" $question "y"