From patchwork Thu Apr 3 06:09:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 395 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 8C580360068 for ; Wed, 2 Apr 2014 23:12:42 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14314964) id 407CF40CB289E; Wed, 2 Apr 2014 23:12:42 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx20.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx20.g.dreamhost.com (Postfix) with ESMTPS id 1E75940C56641 for ; Wed, 2 Apr 2014 23:12:42 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; q=dns; s=default; b=ILcHbxRN4ZujjDnXS0I2yYwDJBx23 P6PLcM5OCym7++2tyMYrnCbZb2X9grzjmFu8f4omyxEw5RqtPyOKpUewpkAyD5xV 30UBlsTA2kygOOM2lNgRAOHKTWAUqomGBsDuBpk9EJ9jToUOp6inYeJA4V3vANDn mHPBiDDPIT8xl8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; s=default; bh=gF1m6lHO5y+Y8TAVo6bLfC71w+U=; b=MLV y1HR02GZd7aiv0owPLwlSCrAS7T1CkoCeTTqjCP0GWk8UNv83SrvBlksaMw2OS4z D14txKB8vcbkLGyvgtmIHI7TQDrwDxotqlsZ1aSqrtvyrUCo7VYyTEJbvwl6sij2 pUDsCQfm8G6piQLaPeH3/ZpIFjL4oGrTjXAeO8d4= Received: (qmail 13125 invoked by alias); 3 Apr 2014 06:12:39 -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 13112 invoked by uid 89); 3 Apr 2014 06:12:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 03 Apr 2014 06:12:36 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1WVat7-000600-Fj from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Wed, 02 Apr 2014 23:12:33 -0700 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 2 Apr 2014 23:12:33 -0700 Received: from qiyao.dyndns.org.com (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.2.247.3; Wed, 2 Apr 2014 23:11:25 -0700 From: Yao Qi To: Subject: [PATCH] Get frame after pull single-step breakpoints out Date: Thu, 3 Apr 2014 14:09:58 +0800 Message-ID: <1396505398-23634-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in Hi, I find that instruction that red by signal trampoline unwinder sniffer is always the breakpoint instruction. I suspect that GDB tries to get frame before pulls breakpoint out of the target. The backtrace is like: #0 tramp_frame_sniffer () at gdb/tramp-frame.c:135 #1 frame_unwind_try_unwinder () at gdb/frame-unwind.c:108 ..... ..... #13 get_current_frame () at gdb/frame.c:1480 #14 handle_signal_stop () at gdb/infrun.c:3971 In infrun.c:handle_signal_stop, /* At this point, get hold of the now-current thread's frame. */ frame = get_current_frame (); gdbarch = get_frame_arch (frame); /* Pull the single step breakpoints out of the target. */ if (singlestep_breakpoints_inserted_p) we can see GDB gets frame before pulling single-step breakpoint out, that is the reason why trampoline unwinder reads breakpoint instruction. I find this problem on nios2-linux, but it should affect software single step targets (I don't see these fails in arm-linux-gnu-eabi, because signal trampoline frame is created when PC is still in function keeper, so although breakpoint instruction isn't pulled out of the inferior, instructions in signal trampoline are not changed). This patch is to exchange the order of getting frame and pulling out breakpoints, so trampoline frame unwinder can read the real instruction rather than breakpoint instruction. This patch fixes these fails on nios2-linux target: FAIL: gdb.base/sigbpt.exp: stepi; stepi out of handler FAIL: gdb.base/sigbpt.exp: stepi bp before segv; stepi out of handler FAIL: gdb.base/sigbpt.exp: stepi bp at segv; stepi out of handler FAIL: gdb.base/sigbpt.exp: stepi bp before and at segv; stepi out of handler FAIL: gdb.base/siginfo.exp: step out of handler FAIL: gdb.base/sigstep.exp: step from handler; leave handler FAIL: gdb.base/sigstep.exp: stepi from handleri; leave handler FAIL: gdb.base/sigstep.exp: stepi from handleri; leave signal trampoline FAIL: gdb.base/sigstep.exp: next from handler; leave handler FAIL: gdb.base/sigstep.exp: nexti from handleri; leave handler FAIL: gdb.base/sigstep.exp: nexti from handleri; leave signal trampoline gdb: 2014-04-03 Yao Qi * infrun.c (handle_signal_stop): Exchange code on getting frame and pulling single-step breakpoints out. --- gdb/infrun.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 31bb132..a641a6e 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -3941,10 +3941,6 @@ handle_signal_stop (struct execution_control_state *ecs) deprecated_context_hook (pid_to_thread_id (ecs->ptid)); } - /* At this point, get hold of the now-current thread's frame. */ - frame = get_current_frame (); - gdbarch = get_frame_arch (frame); - /* Pull the single step breakpoints out of the target. */ if (singlestep_breakpoints_inserted_p) { @@ -3979,6 +3975,10 @@ handle_signal_stop (struct execution_control_state *ecs) singlestep_breakpoints_inserted_p = 0; } + /* At this point, get hold of the now-current thread's frame. */ + frame = get_current_frame (); + gdbarch = get_frame_arch (frame); + if (ecs->stepped_after_stopped_by_watchpoint) stopped_by_watchpoint = 0; else