From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 57582 invoked by alias); 31 May 2016 07:36:25 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 57569 invoked by uid 89); 31 May 2016 07:36:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=mixture X-HELO: mga01.intel.com Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 31 May 2016 07:36:09 +0000 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP; 31 May 2016 00:36:09 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga003.jf.intel.com with ESMTP; 31 May 2016 00:36:07 -0700 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u4V7a6mr030502; Tue, 31 May 2016 08:36:06 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id u4V7a6w8029967; Tue, 31 May 2016 09:36:06 +0200 Received: (from mmetzger@localhost) by ulvlx001.iul.intel.com with œ id u4V7a5QS029963; Tue, 31 May 2016 09:36:06 +0200 From: Markus Metzger 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 Message-Id: <1464680165-29696-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes X-SW-Source: 2016-05/txt/msg00551.txt.bz2 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 * 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