From: "Metzger, Markus T" <markus.t.metzger@intel.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: "palves@redhat.com" <palves@redhat.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PATCH v2 2/3] frame: use get_prev_frame_always in skip_tailcall_frames
Date: Mon, 08 Feb 2016 08:14:00 -0000 [thread overview]
Message-ID: <A78C989F6D9628469189715575E55B233325F370@IRSMSX104.ger.corp.intel.com> (raw)
In-Reply-To: <20160207130057.GE20874@adacore.com>
> -----Original Message-----
> From: Joel Brobecker [mailto:brobecker@adacore.com]
> Sent: Sunday, February 7, 2016 2:01 PM
> To: Metzger, Markus T <markus.t.metzger@intel.com>
> Cc: palves@redhat.com; gdb-patches@sourceware.org
> Subject: Re: [PATCH v2 2/3] frame: use get_prev_frame_always in
> skip_tailcall_frames
Hi Joel,
Thanks for your review.
> > Following the practice in skip_artificial_frames, also use
> > get_prev_frame_always instead of get_prev_frame in
> > skip_tailcall_frames.
> >
> > 2016-02-05 Markus Metzger <markus.t.metzger@intel.com>
> >
> > gdb/
> > * frame.c (skip_tailcall_frames): Call get_prev_frame_always.
>
> This seems OK; but would you be able to create a testcase for this?
I modified an existing test case to cover the changes. GDB dies with the modified
test and without the changes to skip_tailcall_frames. This also showed another place
where we want to use get_prev_frame_always.
Here's the modified version of this patch:
commit d426b734a965ef21d03bf7ed30f20be7d7ed31fa
Author: Markus Metzger <markus.t.metzger@intel.com>
Date: Fri Feb 5 09:39:05 2016 +0100
frame: use get_prev_frame_always in skip_tailcall_frames and finish_command
Following the practice in skip_artificial_frames, also use get_prev_frame_always
instead of get_prev_frame in skip_tailcall_frames and in finish_command.
2016-02-08 Markus Metzger <markus.t.metzger@intel.com>
gdb/
* frame.c (skip_tailcall_frames): Call get_prev_frame_always.
* infcmd.c (finish_command): Call get_prev_frame_always.
testsuite/
* gdb.arch/amd64-tailcall-ret.exp: Set backtrace limit.
diff --git a/gdb/frame.c b/gdb/frame.c
index b7832c7..6ab8834 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -443,8 +443,12 @@ skip_artificial_frames (struct frame_info *frame)
struct frame_info *
skip_tailcall_frames (struct frame_info *frame)
{
+ /* Note we use get_prev_frame_always, and not get_prev_frame. The
+ latter will truncate the frame chain, leading to this function
+ unintentionally returning a null_frame_id (e.g., when the user
+ sets a backtrace limit). */
while (get_frame_type (frame) == TAILCALL_FRAME)
- frame = get_prev_frame (frame);
+ frame = get_prev_frame_always (frame);
return frame;
}
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 930dc61..e98f6f5 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1958,7 +1958,10 @@ finish_command (char *arg, int from_tty)
/* Done with ARGS. */
do_cleanups (args_chain);
- frame = get_prev_frame (get_selected_frame (_("No selected frame.")));
+ /* Note we use get_prev_frame_always, and not get_prev_frame. The latter
+ will truncate the frame chain, leading to this function unintentionally
+ throwing an error (e.g., when the user sets a backtrace limit). */
+ frame = get_prev_frame_always (get_selected_frame (_("No selected frame.")));
if (frame == 0)
error (_("\"finish\" not meaningful in the outermost frame."));
diff --git a/gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp b/gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp
index 2642cdd..0334b54 100644
--- a/gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp
+++ b/gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp
@@ -36,6 +36,11 @@ if ![runto_main] {
gdb_breakpoint "g"
gdb_continue_to_breakpoint "g" ".* v = 2;"
+# Severely limit the back trace. The limit should be ignored for "return"
+# and "finish" commands.
+#
+gdb_test "set backtrace limit 1"
+
gdb_test "return" { f \(\); /\* second \*/} "return" \
{Make g return now\? \(y or n\) } "y"
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
next prev parent reply other threads:[~2016-02-08 8:14 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-05 14:18 [PATCH v2 1/3] frame: add skip_tailcall_frames Markus Metzger
2016-02-05 14:18 ` [PATCH v2 2/3] frame: use get_prev_frame_always in skip_tailcall_frames Markus Metzger
2016-02-07 13:01 ` Joel Brobecker
2016-02-08 8:14 ` Metzger, Markus T [this message]
2016-02-09 11:42 ` Pedro Alves
2016-02-09 11:58 ` Joel Brobecker
2016-02-09 14:25 ` Metzger, Markus T
2016-02-09 14:41 ` Pedro Alves
[not found] ` <A78C989F6D9628469189715575E55B233325FCA0@IRSMSX104.ger.corp.intel.com>
2016-02-15 9:51 ` Metzger, Markus T
2016-02-17 15:32 ` Pedro Alves
2016-02-19 11:36 ` Metzger, Markus T
2016-02-09 14:44 ` Joel Brobecker
2016-02-05 14:19 ` [PATCH v2 3/3] btrace, frame: fix crash in get_frame_type Markus Metzger
2016-02-09 12:05 ` Pedro Alves
2016-02-09 14:43 ` Metzger, Markus T
2016-02-09 22:01 ` Pedro Alves
2016-02-10 7:40 ` Metzger, Markus T
2016-02-10 9:59 ` Pedro Alves
2016-02-10 10:29 ` Metzger, Markus T
2016-02-10 15:02 ` Metzger, Markus T
2016-02-10 15:34 ` Pedro Alves
2016-02-11 9:51 ` Metzger, Markus T
2016-02-11 13:39 ` Pedro Alves
2016-02-11 15:42 ` Metzger, Markus T
2016-02-11 15:58 ` Pedro Alves
2016-02-11 16:07 ` Metzger, Markus T
2016-02-07 13:00 ` [PATCH v2 1/3] frame: add skip_tailcall_frames Joel Brobecker
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=A78C989F6D9628469189715575E55B233325F370@IRSMSX104.ger.corp.intel.com \
--to=markus.t.metzger@intel.com \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.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