mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-01 08:54:44 +08:00
gdb: Check for nullptr when computing srcpath
This fixes a regression caused by commit 0d79cdc494d5: $ make check TESTS="gdb.dwarf2/dw2-ranges-base.exp" [...] ERROR: GDB process no longer exists This error is caused by an abort during the computation of srcpath when SYMTAB_DIRNAME (s) == NULL. Computing srcpath only when SYMTAB_DIRNAME (s) is not NULL fixes this error. Also change the condition for calling debuginfod_source_query to include whether srcpath could be computed. gdb/ChangeLog: 2020-02-27 Aaron Merey <amerey@redhat.com> * source.c (open_source_file): Check for nullptr when computing srcpath.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
2020-02-27 Aaron Merey <amerey@redhat.com>
|
||||||
|
|
||||||
|
* source.c (open_source_file): Check for nullptr when computing
|
||||||
|
srcpath.
|
||||||
|
|
||||||
2020-02-27 Tom Tromey <tromey@adacore.com>
|
2020-02-27 Tom Tromey <tromey@adacore.com>
|
||||||
|
|
||||||
* dwarf2/read.c (struct field_info) <nfields>: Now a method, not a
|
* dwarf2/read.c (struct field_info) <nfields>: Now a method, not a
|
||||||
|
@ -1160,7 +1160,7 @@ open_source_file (struct symtab *s)
|
|||||||
std::string srcpath;
|
std::string srcpath;
|
||||||
if (IS_ABSOLUTE_PATH (s->filename))
|
if (IS_ABSOLUTE_PATH (s->filename))
|
||||||
srcpath = s->filename;
|
srcpath = s->filename;
|
||||||
else
|
else if (SYMTAB_DIRNAME (s) != nullptr)
|
||||||
{
|
{
|
||||||
srcpath = SYMTAB_DIRNAME (s);
|
srcpath = SYMTAB_DIRNAME (s);
|
||||||
srcpath += SLASH_STRING;
|
srcpath += SLASH_STRING;
|
||||||
@ -1170,7 +1170,7 @@ open_source_file (struct symtab *s)
|
|||||||
const struct bfd_build_id *build_id = build_id_bfd_get (ofp->obfd);
|
const struct bfd_build_id *build_id = build_id_bfd_get (ofp->obfd);
|
||||||
|
|
||||||
/* Query debuginfod for the source file. */
|
/* Query debuginfod for the source file. */
|
||||||
if (build_id != nullptr)
|
if (build_id != nullptr && !srcpath.empty ())
|
||||||
fd = debuginfod_source_query (build_id->data,
|
fd = debuginfod_source_query (build_id->data,
|
||||||
build_id->size,
|
build_id->size,
|
||||||
srcpath.c_str (),
|
srcpath.c_str (),
|
||||||
|
Reference in New Issue
Block a user