gdb: Check for nullptr when computing srcpath
Commit Message
Comments
On 2020-02-27 1:00 p.m., Aaron Merey wrote:
>
Hi Aaron,
Please provide in the commit message an explanation of what this fixes, including
how to reproduce the crash. Since this fixes the execution of an existing test
case, you can include the "make check" command line used to run it, like:
make check TESTS="gdb.dwarf2/dw2-ranges-base"
Simon
On 2020-02-27 2:18 p.m., Simon Marchi wrote:
> On 2020-02-27 1:00 p.m., Aaron Merey wrote:
>>
>
> Hi Aaron,
>
> Please provide in the commit message an explanation of what this fixes, including
> how to reproduce the crash. Since this fixes the execution of an existing test
> case, you can include the "make check" command line used to run it, like:
>
> make check TESTS="gdb.dwarf2/dw2-ranges-base"
>
> Simon
>
Also, do you think you'd be able to send your patches using git-send-email? That makes
it much easier to read and comment on.
Thanks,
Simon
+ if (build_id != nullptr && srcpath.size () > 0)
I usually prefer !srcpath.empty ()
Also, I would like to second simark's suggestion for git-send-email!
Christian
On Thu, Feb 27, 2020 at 12:00 PM Aaron Merey <amerey@redhat.com> wrote:
>
>
From e3eb4852487b941a9efb4bbcc8b6fb5f522b8298 Mon Sep 17 00:00:00 2001
From: Aaron Merey <amerey@redhat.com>
Date: Thu, 27 Feb 2020 12:52:05 -0500
Subject: [PATCH] gdb: Check for nullptr when computing srcpath
gdb/ChangeLog:
2020-02-27 Aaron Merey <amerey@redhat.com>
* source.c (open_source_file): Check for nullptr when computing
srcpath.
---
gdb/ChangeLog | 4 ++++
gdb/source.c | 4 ++--
2 files changed, 6 insertions(+), 2 deletions(-)
@@ -1,3 +1,7 @@
+2020-02-27 Aaron Merey <amerey@redhat.com>
+ * source.c (open_source_file): Check for nullptr when computing
+ srcpath.
+
2020-02-27 Andrew Burgess <andrew.burgess@embecosm.com>
* gdbtypes.c (create_array_type_with_stride): Use std::abs not
@@ -1160,7 +1160,7 @@ open_source_file (struct symtab *s)
std::string srcpath;
if (IS_ABSOLUTE_PATH (s->filename))
srcpath = s->filename;
- else
+ else if (SYMTAB_DIRNAME (s) != nullptr)
{
srcpath = SYMTAB_DIRNAME (s);
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);
/* Query debuginfod for the source file. */
- if (build_id != nullptr)
+ if (build_id != nullptr && srcpath.size () > 0)
fd = debuginfod_source_query (build_id->data,
build_id->size,
srcpath.c_str (),
--
2.24.1