Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Markus Metzger <markus.t.metzger@intel.com>
To: gdb-patches@sourceware.org
Cc: yao.qi@arm.com
Subject: [PATCH] infcmd, btrace: fix crash in 'finish' for tailcall-only frames
Date: Tue, 31 May 2016 07:36:00 -0000	[thread overview]
Message-ID: <1464680165-29696-1-git-send-email-markus.t.metzger@intel.com> (raw)

Patch 7eb895307f53 Skip unwritable frames in command "finish"
skips non-writable frames in addition to tailcall frames.

If skip_tailcall_frames already returns NULL, skip_unwritable_frames
will be called with a NULL frame and crash in get_frame_arch.  This is
caught by gdb.btrace/tailcall-only.exp.

Further, if we ever end up with a mixture of tailcall and non-writable
frames, we may not skip all of them, as intended.

Loop over skip_tailcall_frames and skip_unwritable_frames as long as at least
one of them makes progress.

2016-05-31  Markus Metzger  <markus.t.metzger@intel.com>

	* infcmd.c (skip_finish_frames): New.
	(finish_command): Call skip_finish_frames.
---
 gdb/infcmd.c | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 14d51fd..ca8655a 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1927,6 +1927,28 @@ finish_forward (struct finish_command_fsm *sm, struct frame_info *frame)
   proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
 }
 
+/* Skip frames for "finish".  */
+
+static struct frame_info *
+skip_finish_frames (struct frame_info *frame)
+{
+  struct frame_info *start;
+
+  do {
+    start = frame;
+
+    frame = skip_tailcall_frames (frame);
+    if (frame == NULL)
+      break;
+
+    frame = skip_unwritable_frames (frame);
+    if (frame == NULL)
+      break;
+  } while (start != frame);
+
+  return frame;
+}
+
 /* "finish": Set a temporary breakpoint at the place the selected
    frame will return to, then continue.  */
 
@@ -2025,11 +2047,7 @@ finish_command (char *arg, int from_tty)
     finish_backward (sm);
   else
     {
-      /* Ignore TAILCALL_FRAME type frames, they were executed already before
-	 entering THISFRAME.  */
-      frame = skip_tailcall_frames (frame);
-
-      frame = skip_unwritable_frames (frame);
+      frame = skip_finish_frames (frame);
 
       if (frame == NULL)
 	error (_("Cannot find the caller frame."));
-- 
1.8.3.1


             reply	other threads:[~2016-05-31  7:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-31  7:36 Markus Metzger [this message]
2016-06-01  8:51 ` Yao Qi
2016-06-01  9:04   ` Metzger, Markus T

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=1464680165-29696-1-git-send-email-markus.t.metzger@intel.com \
    --to=markus.t.metzger@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=yao.qi@arm.com \
    /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