From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 125320 invoked by alias); 11 Mar 2016 11:49:29 -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 125283 invoked by uid 89); 11 Mar 2016 11:49:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Continuing X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 11 Mar 2016 11:49:25 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 2B650445AF; Fri, 11 Mar 2016 11:49:24 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2BBnNuT022215; Fri, 11 Mar 2016 06:49:23 -0500 Subject: Re: [PATCH 4/8] Force to insert software single step breakpoint To: Yao Qi , gdb-patches@sourceware.org References: <1457088276-1170-1-git-send-email-yao.qi@linaro.org> <1457088276-1170-5-git-send-email-yao.qi@linaro.org> From: Pedro Alves Message-ID: <56E2B0C2.705@redhat.com> Date: Fri, 11 Mar 2016 11:49:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <1457088276-1170-5-git-send-email-yao.qi@linaro.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2016-03/txt/msg00183.txt.bz2 On 03/04/2016 10:44 AM, Yao Qi wrote: > GDB doesn't insert software single step breakpoint if the instruction > branches to itself, so that the program can't stop after command "si". > > (gdb) b 32 > Breakpoint 2 at 0x8680: file git/gdb/testsuite/gdb.base/branch-to-self.c, line 32. > (gdb) c > Continuing. > > Breakpoint 2, main () at gdb/git/gdb/testsuite/gdb.base/branch-to-self.c:32 > 32 asm (".Lhere: " BRANCH_INSN " .Lhere"); /* loop-line */ > (gdb) si > infrun: clear_proceed_status_thread (Thread 3991.3991) > infrun: proceed (addr=0xffffffff, signal=GDB_SIGNAL_DEFAULT) > infrun: step-over queue now empty > infrun: resuming [Thread 3991.3991] for step-over > infrun: skipping breakpoint: stepping past insn at: 0x8680 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Sending packet: $Z0,8678,4#f3...Packet received: OK > infrun: skipping breakpoint: stepping past insn at: 0x8680 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Sending packet: $Z0,b6fe86c8,4#82...Packet received: OK > infrun: resume (step=1, signal=GDB_SIGNAL_0), trap_expected=1, current thread [Thread 3991.3991] at 0x868 > > breakpoint.c:should_be_inserted thinks the breakpoint shouldn't be > inserted, which is wrong. This patch restrict the condition that only > return false if breakpoint is NOT single step breakpoint. Hmm, I think we might need to do something else. If you put a breakpoint there, then the instruction under the breakpoint won't execute at all. If it's a conditional branch, and the condition is false, we will fail to ever advance past the instruction. Similarly if the branch instruction happens to have important side effects (flags? counters?). Thanks, Pedro Alves