public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: gdb-patches@sourceware.org
Subject: [ob/pushed] Fix crash with stepi, no debug info, and "set debug infrun 1"
Date: Fri, 18 Mar 2022 19:25:39 +0000	[thread overview]
Message-ID: <20220318192539.3459991-1-pedro@palves.net> (raw)

A stepi in a function without debug info with "set debug infrun 1"
crashes GDB since commit c8353d682f69 (gdb/infrun: some extra infrun
debug print statements), due to a reference to
"tp->current_symtab->filename" when tp->current_symtab is null.

This commit adds the missing null check.  The output in this case
becomes:

  [infrun] set_step_info: symtab = <null>, line = 0, step_frame_id = {stack=0x7fffffffd980,code=0x0000000000456c30,!special}, step_stack_frame_id = {stack=0x7fffffffd980,code=0x0000000000456c30,!special}

Change-Id: I5171a9d222bc7e15b9dba2feaba7d55c7acd99f8
---
 gdb/infrun.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index bc6521c8ec6..104c29abf0a 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -4180,7 +4180,8 @@ set_step_info (thread_info *tp, struct frame_info *frame,
 
   infrun_debug_printf
     ("symtab = %s, line = %d, step_frame_id = %s, step_stack_frame_id = %s",
-     tp->current_symtab->filename, tp->current_line,
+     tp->current_symtab != nullptr ? tp->current_symtab->filename : "<null>",
+     tp->current_line,
      tp->control.step_frame_id.to_string ().c_str (),
      tp->control.step_stack_frame_id.to_string ().c_str ());
 }

base-commit: da729c5ccde6eeccae539cbe51a285bc84769b3d
-- 
2.26.2


                 reply	other threads:[~2022-03-18 19:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220318192539.3459991-1-pedro@palves.net \
    --to=pedro@palves.net \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).