diff options
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/dwarf2/dwz.c | 13 | ||||
-rw-r--r-- | gdb/dwarf2/read.c | 36 |
2 files changed, 28 insertions, 21 deletions
diff --git a/gdb/dwarf2/dwz.c b/gdb/dwarf2/dwz.c index 1eb4816..c7cdba2 100644 --- a/gdb/dwarf2/dwz.c +++ b/gdb/dwarf2/dwz.c @@ -282,9 +282,14 @@ dwarf2_read_dwz_file (dwarf2_per_objfile *per_objfile) struct dwz_file * dwarf2_get_dwz_file (dwarf2_per_bfd *per_bfd, bool require) { - gdb_assert (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")); + gdb_assert (!require || per_bfd->dwz_file.has_value ()); + + dwz_file *result = nullptr; + if (per_bfd->dwz_file.has_value ()) + { + result = per_bfd->dwz_file->get (); + if (require && result == nullptr) + error (_("could not read '.gnu_debugaltlink' section")); + } return result; } diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 31313bc..9e37011 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1362,11 +1362,11 @@ dwarf2_has_info (struct objfile *objfile, return false; dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); + bool just_created = false; if (per_objfile == NULL) { dwarf2_per_bfd *per_bfd; - bool just_created = false; /* We can share a "dwarf2_per_bfd" with other objfiles if the BFD doesn't require relocations. @@ -1398,27 +1398,29 @@ dwarf2_has_info (struct objfile *objfile, } per_objfile = dwarf2_objfile_data_key.emplace (objfile, objfile, per_bfd); + } + + const bool has_info = (!per_objfile->per_bfd->info.is_virtual + && per_objfile->per_bfd->info.s.section != nullptr + && !per_objfile->per_bfd->abbrev.is_virtual + && per_objfile->per_bfd->abbrev.s.section != nullptr); - if (just_created) + if (just_created && has_info) + { + /* Try to fetch any potential dwz file early, while still on + the main thread. Also, be sure to do it just once per + BFD, to avoid races. */ + try { - /* Try to fetch any potential dwz file early, while still on - the main thread. Also, be sure to do it just once per - BFD, to avoid races. */ - try - { - dwarf2_read_dwz_file (per_objfile); - } - catch (const gdb_exception_error &err) - { - warning (_("%s"), err.what ()); - } + dwarf2_read_dwz_file (per_objfile); + } + catch (const gdb_exception_error &err) + { + warning (_("%s"), err.what ()); } } - return (!per_objfile->per_bfd->info.is_virtual - && per_objfile->per_bfd->info.s.section != NULL - && !per_objfile->per_bfd->abbrev.is_virtual - && per_objfile->per_bfd->abbrev.s.section != NULL); + return has_info; } /* See declaration. */ |