From patchwork Wed Jun 4 05:12:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 1281 Received: (qmail 16934 invoked by alias); 4 Jun 2014 05:14:54 -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 16923 invoked by uid 89); 4 Jun 2014 05:14:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_00, UNSUBSCRIBE_BODY autolearn=no 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; Wed, 04 Jun 2014 05:14:52 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1Ws3XD-0003WU-IN from Yao_Qi@mentor.com ; Tue, 03 Jun 2014 22:14:47 -0700 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 3 Jun 2014 22:14:47 -0700 Received: from qiyao.dyndns.org (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; Tue, 3 Jun 2014 22:14:03 -0700 Message-ID: <538EAACD.8000700@codesourcery.com> Date: Wed, 4 Jun 2014 13:12:45 +0800 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Pedro Alves , Andreas Schwab CC: Joel Brobecker , Subject: Re: [RFA/7.8] user breakpoint not inserted if software-single-step at same location References: <1401394280-14999-1-git-send-email-brobecker@adacore.com> <5387BFF0.6010208@redhat.com> <20140530122253.GC4289@adacore.com> <53887ED5.5050603@redhat.com> <20140530132659.GD4289@adacore.com> <5388AA76.4070101@redhat.com> <538DB721.30308@codesourcery.com> <538DB8EC.20109@redhat.com> <538DBD65.5050409@redhat.com> In-Reply-To: <538DBD65.5050409@redhat.com> X-IsSubscribed: yes On 06/03/2014 08:19 PM, Pedro Alves wrote: > On 06/03/2014 01:12 PM, Andreas Schwab wrote: >> Pedro Alves writes: >> >>> Ah, thanks. We need to replace then with asm("nop") then. >> >> nop isn't portable. > > Yes, but it doesn't matter what the instruction is as > long as it's a single instruction that doesn't do much. > For archs that don't have "nop" (like e.g., IA64), we can > just use #ifdef to pick another insn. > Pedro, here is the patch to tweak sss-bp-on-user-bp.exp. I give up on looking for a portable "nop" for various arch. In stead, we can use disassemble to get the next instruction address and set breakpoint there. See details in the commit log below. diff --git a/gdb/testsuite/gdb.base/sss-bp-on-user-bp.c b/gdb/testsuite/gdb.base/sss-bp-on-user-bp.c index ff82051..edc2e8c 100644 --- a/gdb/testsuite/gdb.base/sss-bp-on-user-bp.c +++ b/gdb/testsuite/gdb.base/sss-bp-on-user-bp.c @@ -21,10 +21,10 @@ int main (void) { - /* Assume writes to integers compile to a single instruction. */ volatile int i = 0; i = 1; /* set foo break here */ - i = 2; /* set bar break here */ + i = 2; + return 0; } diff --git a/gdb/testsuite/gdb.base/sss-bp-on-user-bp.exp b/gdb/testsuite/gdb.base/sss-bp-on-user-bp.exp index 2a12ad6..0b39fc1 100644 --- a/gdb/testsuite/gdb.base/sss-bp-on-user-bp.exp +++ b/gdb/testsuite/gdb.base/sss-bp-on-user-bp.exp @@ -32,7 +32,21 @@ if ![runto_main] then { gdb_breakpoint [gdb_get_line_number "set foo break here"] gdb_continue_to_breakpoint "first breakpoint" ".* set foo break here .*" -gdb_breakpoint [gdb_get_line_number "set bar break here"] +# Get the address of the next instruction and set a breakpoint there. +set next_insn_addr "" +set test "disassemble main" +gdb_test_multiple $test $test { + -re ".*=> $hex <\\+$decimal>:\[^\r\n\]+\r\n ($hex) .*$gdb_prompt $" { + set next_insn_addr $expect_out(1,string) + pass $test + } +} + +if { $next_insn_addr == "" } { + return -1 +} + +gdb_test "b *$next_insn_addr" "Breakpoint .*" # So that GDB doesn't try to remove the regular breakpoint when the # step finishes. @@ -43,9 +57,9 @@ gdb_test_no_output "set breakpoint always-inserted on" # remove it. But, a regular breakpoint is planted there already, and # with always-inserted on, should remain planted when the step # finishes. -gdb_test "si" "Breakpoint .* bar break .*" +gdb_test "si" "Breakpoint .*" # If the breakpoint is still correctly inserted, then this jump should # re-trigger it. Otherwise, GDB will lose control and the program # will exit. See PR breakpoints/17000. -gdb_test "jump *\$pc" "Breakpoint .* bar break .*" +gdb_test "jump *\$pc" "Breakpoint .*"