From patchwork Mon Feb 8 08:14:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Metzger, Markus T" X-Patchwork-Id: 10757 Received: (qmail 44994 invoked by alias); 8 Feb 2016 08:14:15 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 44974 invoked by uid 89); 8 Feb 2016 08:14:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=Sunday, unintentionally, brobecker, Joel X-HELO: mga04.intel.com Received: from mga04.intel.com (HELO mga04.intel.com) (192.55.52.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 08 Feb 2016 08:14:12 +0000 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP; 08 Feb 2016 00:14:11 -0800 X-ExtLoop1: 1 Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by orsmga003.jf.intel.com with ESMTP; 08 Feb 2016 00:14:10 -0800 Received: from irsmsx104.ger.corp.intel.com ([169.254.5.210]) by IRSMSX102.ger.corp.intel.com ([169.254.2.97]) with mapi id 14.03.0248.002; Mon, 8 Feb 2016 08:14:09 +0000 From: "Metzger, Markus T" To: Joel Brobecker CC: "palves@redhat.com" , "gdb-patches@sourceware.org" Subject: RE: [PATCH v2 2/3] frame: use get_prev_frame_always in skip_tailcall_frames Date: Mon, 8 Feb 2016 08:14:09 +0000 Message-ID: References: <1454681922-2228-1-git-send-email-markus.t.metzger@intel.com> <1454681922-2228-2-git-send-email-markus.t.metzger@intel.com> <20160207130057.GE20874@adacore.com> In-Reply-To: <20160207130057.GE20874@adacore.com> MIME-Version: 1.0 X-IsSubscribed: yes > -----Original Message----- > From: Joel Brobecker [mailto:brobecker@adacore.com] > Sent: Sunday, February 7, 2016 2:01 PM > To: Metzger, Markus T > 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 > > > > 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 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 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. 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 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"