* [PATCH] infcmd, btrace: fix crash in 'finish' for tailcall-only frames
@ 2016-05-31 7:36 Markus Metzger
2016-06-01 8:51 ` Yao Qi
0 siblings, 1 reply; 3+ messages in thread
From: Markus Metzger @ 2016-05-31 7:36 UTC (permalink / raw)
To: gdb-patches; +Cc: yao.qi
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
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] infcmd, btrace: fix crash in 'finish' for tailcall-only frames
2016-05-31 7:36 [PATCH] infcmd, btrace: fix crash in 'finish' for tailcall-only frames Markus Metzger
@ 2016-06-01 8:51 ` Yao Qi
2016-06-01 9:04 ` Metzger, Markus T
0 siblings, 1 reply; 3+ messages in thread
From: Yao Qi @ 2016-06-01 8:51 UTC (permalink / raw)
To: Markus Metzger; +Cc: gdb-patches
Markus Metzger <markus.t.metzger@intel.com> writes:
Patch is good to me, nits on code format,
> + do {
"{" should be in the new line.
> + start = frame;
> +
> + frame = skip_tailcall_frames (frame);
> + if (frame == NULL)
> + break;
> +
> + frame = skip_unwritable_frames (frame);
> + if (frame == NULL)
> + break;
> + } while (start != frame);
"while" should be in the new line too. The format is documented in
https://www.gnu.org/prep/standards/standards.html#Writing-C
--
Yao (齐尧)
^ permalink raw reply [flat|nested] 3+ messages in thread* RE: [PATCH] infcmd, btrace: fix crash in 'finish' for tailcall-only frames
2016-06-01 8:51 ` Yao Qi
@ 2016-06-01 9:04 ` Metzger, Markus T
0 siblings, 0 replies; 3+ messages in thread
From: Metzger, Markus T @ 2016-06-01 9:04 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 768 bytes --]
> -----Original Message-----
> From: Yao Qi [mailto:qiyaoltc@gmail.com]
> Sent: Wednesday, June 1, 2016 10:51 AM
> To: Metzger, Markus T <markus.t.metzger@intel.com>
> Cc: gdb-patches@sourceware.org
> Subject: Re: [PATCH] infcmd, btrace: fix crash in 'finish' for tailcall-only frames
>
> Markus Metzger <markus.t.metzger@intel.com> writes:
>
> Patch is good to me, nits on code format,
Thanks,
Markus.
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
\x16º&Öéj×!zÊÞ¶êç×}|ë¹b²Ö«r\x18\x1dnr\x17¬
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-06-01 9:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-31 7:36 [PATCH] infcmd, btrace: fix crash in 'finish' for tailcall-only frames Markus Metzger
2016-06-01 8:51 ` Yao Qi
2016-06-01 9:04 ` Metzger, Markus T
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox