Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Aaron Merey <amerey@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] gdb: Check for nullptr when computing srcpath
Date: Thu, 27 Feb 2020 18:00:00 -0000	[thread overview]
Message-ID: <CAJDtP-Q8E=Kyf4n8-o3OJ=gKjR4e+sHKTA0FbL0h8uTqF-NmnQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2 bytes --]



[-- Attachment #2: 0001-gdb-Check-for-nullptr-when-computing-srcpath.patch --]
[-- Type: text/x-patch, Size: 1612 bytes --]

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(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4376161673..371ef91421 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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
diff --git a/gdb/source.c b/gdb/source.c
index 051caf5c57..29eeb5341b 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -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


             reply	other threads:[~2020-02-27 18:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-27 18:00 Aaron Merey [this message]
2020-02-27 19:18 ` Simon Marchi
2020-02-27 19:20   ` Simon Marchi
2020-02-27 19:33 ` Christian Biesinger via gdb-patches
2020-02-27 22:12   ` Aaron Merey
2020-02-27 23:37     ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJDtP-Q8E=Kyf4n8-o3OJ=gKjR4e+sHKTA0FbL0h8uTqF-NmnQ@mail.gmail.com' \
    --to=amerey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox