From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27970 invoked by alias); 19 May 2009 21:33:02 -0000 Received: (qmail 27958 invoked by uid 22791); 19 May 2009 21:33:01 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_51,SPF_HELO_PASS,SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from mailgw.tensilica.com (HELO mailgw.tensilica.com) (65.205.227.134) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 19 May 2009 21:32:55 +0000 Received: from localhost (unknown [127.0.0.1]) by mailgw.tensilica.com (Postfix) with ESMTP id 70D39116053E; Tue, 19 May 2009 21:32:51 +0000 (UTC) Received: from mailgw.tensilica.com ([127.0.0.1]) by localhost (mailgw.tensilica.com [127.0.0.1]) (amavisd-maia, port 10024) with ESMTP id 00665-06; Tue, 19 May 2009 14:32:51 -0700 (PDT) Received: from mail.tensilica.com (mail.tensilica.com [192.168.15.138]) by mailgw.tensilica.com (Postfix) with ESMTP id 3558411604ED; Tue, 19 May 2009 14:32:51 -0700 (PDT) Received: from [172.16.150.11] (172.16.150.11) by exch.hq.tensilica.com (192.168.15.138) with Microsoft SMTP Server (TLS) id 8.1.358.0; Tue, 19 May 2009 14:32:26 -0700 Message-ID: <4A132565.207@tensilica.com> Date: Tue, 19 May 2009 21:33:00 -0000 From: Ross Morley User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040805 Netscape/7.2 MIME-Version: 1.0 To: Pedro Alves CC: "gdb-patches@sourceware.org" Subject: Re: [Fwd: Re: [PATCH] Program Breakpoints] References: <4A12EC43.3010107@tensilica.com> <200905191958.35348.pedro@codesourcery.com> <4A130DE1.9060202@tensilica.com> <200905192121.10299.pedro@codesourcery.com> In-Reply-To: <200905192121.10299.pedro@codesourcery.com> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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 X-SW-Source: 2009-05/txt/msg00406.txt.bz2 Pedro Alves wrote: >On Tuesday 19 May 2009 20:52:01, Ross Morley wrote: > > >>First, the intention is that a program breakpoint is not >>reported in the case of hitting a GDB breakpoint. >> >> > >You mean, reported to the user, right? > No, I mean reported to the workings of infrun (high level of GDB). The target interface reports a trap which could be a GDB breakpoint. But handle_inferior_event distinguishes a program breakpoint from a GDB one then sets a flag in the thread structure if it's a program breakpoint. This chunk in infrun.c: /* The PTID we'll do a target_wait on.*/ @@ -2937,6 +2944,13 @@ || stop_soon == STOP_QUIETLY || stop_soon == STOP_QUIETLY_NO_SIGSTOP || stop_soon == STOP_QUIETLY_REMOTE) { + /* If we hit a trap not inserted by GDB, it must be in the program. */ + ecs->event_thread->program_breakpoint_hit + = (STOPPED_BY_TRAP_INSTRUCTION (&ecs->event_thread->program_breakpoint_size) + && !software_breakpoint_inserted_here_p (stop_pc)); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + if (debug_infrun && ecs->event_thread->program_breakpoint_hit) + fprintf_unfiltered (gdb_stdlog, "infrun: program breakpoint hit\n"); + So a program breakpoint is deemed hit if a trap was hit and there was not a software breakpoint inserted there. The idea is to avoid interfering with normal breakpoint handling and only handle cases where it's a program breakpoint. > I agree. However, >the target will report to gdb a program breakpoint for >gdb breakpoints as well: > >+ if (the_low_target.trap_size_at != NULL) >+ trap_size = (*the_low_target.trap_size_at) (stop_pc); >+ else if (the_low_target.breakpoint_at != NULL >+ && (*the_low_target.breakpoint_at) (stop_pc)) >+ trap_size = the_low_target.breakpoint_len; > >Only way to tell the difference is if there's a breakpoint >at PC in gdb's tables or not. > > Exactly. >Hmm, isn't there an off-by-one error in the XCHAL_HAVE_BE >case here? : > >+#if XCHAL_HAVE_BE >+ if (insn[1] == 0xd2 && (insn[2] & 0x0f) == 0x0f) >+#else >+ if (insn[0] == 0x2d && (insn[1] & 0xf0) == 0xf0) >+#endif >+ /* break.n s (density) */ > > > You are right. There's also a byte reversal in the big endian case of the 3 byte break. I did gdbserver in a hurry just to test with the FSF source tree since our toolchain doesn't have the top of trunk changes yet so I couldn't use our simulator. I used a little endian configuration and didn't test big endian. I will test this on big endian before submitting a final patch. > > >>Test cases seem impossible to write completely generically >>because the test needs a target-specific break instruction. >>We have one (not in this patch) I could submit for Xtensa. >>It places 2 sizes of program breakpoints for Xtensa as follows: >> __asm__("break 7,15"); >> __asm__("break.n 7"); >>Is there a way to write a generic test with a program break? >> >> > >I think you can do something reasonably generic enough by >passing "additional_flags=-DNOP=mysmallnopinsn -DBREAK_INSN1=foo -DBREAK_INSN2=bar" >to gdb_compile, and write the test in c with embedded asm, as: > >int foo () >{ > NOP > NOP > BREAK_INSN1 >jmphere: > NOP /* breakpoint here*/ > NOP > BREAK_INSN1 > NOP >goto jmphere; >} > >etc, etc. > >Then, the .exp file passes the appropriate defines/flags >based on target triplet. > >if { ([istarget "xtensa*-*-*"] } { > additional_flags={-DNOP=mysmallnopinsn -DBREAK_INSN1="break 7,15" -DBREAK_INSN2="break.n 7"} >} else if { ([istarget "fooarch*-*-*"] } { > ... >} > > > OK, I'll try that. It will be a day or two before I can look at the other issues you raised. Thanks, Ross