From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 130058 invoked by alias); 8 May 2015 12:12:52 -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 130045 invoked by uid 89); 8 May 2015 12:12:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: usevmg20.ericsson.net Received: from usevmg20.ericsson.net (HELO usevmg20.ericsson.net) (198.24.6.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 08 May 2015 12:12:50 +0000 Received: from EUSAAHC007.ericsson.se (Unknown_Domain [147.117.188.93]) by usevmg20.ericsson.net (Symantec Mail Security) with SMTP id 00.3E.32689.5305C455; Fri, 8 May 2015 07:57:09 +0200 (CEST) Received: from [142.133.183.107] (147.117.188.8) by smtp-am.internal.ericsson.com (147.117.188.95) with Microsoft SMTP Server id 14.3.210.2; Fri, 8 May 2015 08:12:47 -0400 Message-ID: <554CA83F.7080909@ericsson.com> Date: Fri, 08 May 2015 12:12:00 -0000 From: Antoine Tremblay User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Pedro Alves , Yao Qi CC: Subject: Re: [PATCH] [gdbserver] Disable conditional breakpoints on no-hardware-single-step targets References: <1430411029-12097-1-git-send-email-qiyaoltc@gmail.com> <554A368F.4060309@redhat.com> <86oalwvf38.fsf@gmail.com> <554B5052.2090904@ericsson.com> <554CA308.1030509@redhat.com> In-Reply-To: <554CA308.1030509@redhat.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-05/txt/msg00187.txt.bz2 On 05/08/2015 07:50 AM, Pedro Alves wrote: > On 05/07/2015 12:45 PM, Antoine Tremblay wrote: > >> Just fyi, I'm working on doing this at the moment, my investigation is >> still incomplete... >> >> So far I mainly plan to port the arm_get_next code to gdbserver, to >> accomplish 1. , the code doesn't have so many deps so it should be ok >> 2. by looking at $cpsr >> 3. should be fine as 1 and 2 are done... >> >> I don't know however yet the best strategy to share the code but I'm >> guessing I could make the parts that don't have any deps to gdbarch etc >> in a shared function with gdb/gdbserver... Any pointers on this are >> welcome... > > Yeah, sharing is good. > > Maybe adding an abstraction layer object, like: > > struct get_next_pc; > > struct get_next_pc_ops > { > void (*read_memory) (struct get_next_pc *self, ...); > void (*read_register) (struct get_next_pc *self, ...); > ... > }; > > struct get_next_pcs > { > struct get_next_pc_ops *vtable; > > VEC(CORE_ADDR) *result; > > enum bfd_endian byte_order; > enum bfd_endian byte_order_for_code; > whatever_type whatever_other_context; > ... > }; > > And then both GDB and GDBserver would instantiate > a struct get_next_pc object, like: > > struct get_next_pc_ops gdb_get_next_pc_ops = { > gdb_get_next_pc_read_memory, > gdb_get_next_pc_read_register, > ... > } > > struct gdb_get_next_pcs > { > struct get_next_pc base; > > // add whatever other context only gdb needs. > }; > > int > arm_software_single_step (struct frame_info *frame) > { > struct gdbarch *gdbarch = get_frame_arch (frame); > struct gdb_get_next_pc next_pc; > CORE_ADDR pc; > > next_pc.vtable = gdb_get_next_pc_ops; > next_pc.byte_order = gdbarch_byte_order (gdbarch); > next_pc.byte_order_for_code = gdbarch_byte_order_for_code (gdbarch); > > // arm_get_next_pcs is the existing gdb code adjusted to the > // new interface. > arm_get_next_pcs (&next_pc); > > // walk result vec (a VEC of CORE_ADDRs) and insert breakpoints. > // alternatively add a insert_breakpoint callback to struct get_next_pc_ops > // and insert breakpoints from within arm_get_next_pcs, as currently. > for (i = 0; > VEC_iterate (CORE_ADDR, next_pcs.result, i, pc); > ++i) > { > arm_insert_single_step_breakpoint (gdbarch, aspace, pc); > } > > return 1; > } > This looks very nice thanks! , but I do have one question , why is the result a VEC ? From the context and current code won't we have only one next instruction ? Also, if you may,file structure wise, where would be a good place for this abstration layer in your view ? Thanks, Antoine