From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9959 invoked by alias); 13 Apr 2012 01:39:54 -0000 Received: (qmail 9944 invoked by uid 22791); 13 Apr 2012 01:39:52 -0000 X-SWARE-Spam-Status: No, hits=-4.0 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 13 Apr 2012 01:39:37 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1SIVU8-0002b0-4G from Yao_Qi@mentor.com ; Thu, 12 Apr 2012 18:39:36 -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); Thu, 12 Apr 2012 18:39:35 -0700 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.1.289.1; Thu, 12 Apr 2012 18:39:34 -0700 Message-ID: <4F8783C4.60807@codesourcery.com> Date: Fri, 13 Apr 2012 02:03:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 MIME-Version: 1.0 To: CC: Eli Zaretskii Subject: Re: [PATCH] breakpoint always inserted in record target References: <1334149619-2738-1-git-send-email-yao@codesourcery.com> <4F85C027.3010105@redhat.com> In-Reply-To: <4F85C027.3010105@redhat.com> Content-Type: multipart/mixed; boundary="------------020700010502040607000306" 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: 2012-04/txt/msg00332.txt.bz2 --------------020700010502040607000306 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Content-length: 791 On 04/12/2012 01:32 AM, Keith Seitz wrote: > I don't normally chime in on patches, but I felt compelled to ask for > one change in your patch (which otherwise looks okay to me): > > On 04/11/2012 06:06 AM, Yao Qi wrote: >> >> +/* Invoke CALLBACK for each of bp_location. */ >> + >> +void >> +iterate_over_bp_locations (void (*callback) (struct bp_location *)) >> +{ >> + struct bp_location *loc, **loc_tmp; >> + >> + ALL_BP_LOCATIONS (loc, loc_tmp) >> + { >> + callback (loc); >> + } >> +} >> + > > Can you please define a typedef for this CALLBACK parameter? > This updated patch addresses both Keith's and Doug's comments. I realize that this change is user visible, so add one entry in NEWS. If no objections, I'll check it in in three or four days. -- Yao (齐尧) --------------020700010502040607000306 Content-Type: text/x-patch; name="0001-breakpoint-always-inserted-in-record-target.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-breakpoint-always-inserted-in-record-target.patch" Content-length: 3768 gdb: 2012-04-12 Yao Qi * breakpoint.c (iterate_over_bp_locations): New. * breakpoint.h: Declare. New typedef walk_bp_location_callback. * record.c (record_open): Call record_init_record_breakpoints. (record_sync_record_breakpoints): New. (record_init_record_breakpoints): New. * NEWS: Mention supporting breakpoint always-inserted mode in record target. --- gdb/NEWS | 2 ++ gdb/breakpoint.c | 13 +++++++++++++ gdb/breakpoint.h | 4 ++++ gdb/record.c | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 0 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index c287ffa..9b190e4 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -82,6 +82,8 @@ * Ada support for GDB/MI Variable Objects has been added. +* GDB can now support breakpoint always-inserted mode in record target. + * New commands ** "catch load" and "catch unload" can be used to stop when a shared diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index be536bc..0df0a81 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -2425,6 +2425,19 @@ insert_breakpoints (void) insert_breakpoint_locations (); } +/* Invoke CALLBACK for each of bp_location. */ + +void +iterate_over_bp_locations (walk_bp_location_callback callback) +{ + struct bp_location *loc, **loc_tmp; + + ALL_BP_LOCATIONS (loc, loc_tmp) + { + callback (loc); + } +} + /* This is used when we need to synch breakpoint conditions between GDB and the target. It is the case with deleting and disabling of breakpoints when using always-inserted mode. */ diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index e0eeeaa..c0b1bad 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -1131,6 +1131,10 @@ extern void delete_breakpoint (struct breakpoint *); extern void breakpoint_auto_delete (bpstat); +typedef void (*walk_bp_location_callback) (void *data); + +extern void iterate_over_bp_locations (walk_bp_location_callback); + /* Return the chain of command lines to execute when this breakpoint is hit. */ extern struct command_line *breakpoint_commands (struct breakpoint *b); diff --git a/gdb/record.c b/gdb/record.c index 9b7ee2f..946ca95 100644 --- a/gdb/record.c +++ b/gdb/record.c @@ -896,6 +896,8 @@ record_open_1 (char *name, int from_tty) push_target (&record_ops); } +static void record_init_record_breakpoints (void); + /* "to_open" target method. Open the process record target. */ static void @@ -993,6 +995,8 @@ record_open (char *name, int from_tty) record_async_inferior_event_token = create_async_event_handler (record_async_inferior_event_handler, NULL); + + record_init_record_breakpoints (); } /* "to_close" target method. Close the process record target. */ @@ -1744,6 +1748,34 @@ DEF_VEC_P(record_breakpoint_p); active. */ VEC(record_breakpoint_p) *record_breakpoints = NULL; +static void +record_sync_record_breakpoints (void *data) +{ + struct bp_location *loc = (struct bp_location *) data; + + if (loc->inserted) + { + struct record_breakpoint *bp = XNEW (struct record_breakpoint); + + bp->addr = loc->target_info.placed_address; + bp->address_space = loc->target_info.placed_address_space; + + bp->in_target_beneath = 1; + + VEC_safe_push (record_breakpoint_p, record_breakpoints, bp); + } +} + +/* Sync existing breakpoints to record_breakpoints. */ + +static void +record_init_record_breakpoints (void) +{ + VEC_free (record_breakpoint_p, record_breakpoints); + + iterate_over_bp_locations (record_sync_record_breakpoints); +} + /* Behavior is conditional on RECORD_IS_REPLAY. We will not actually insert or remove breakpoints in the real target when replaying, nor when recording. */ -- 1.7.0.4 --------------020700010502040607000306--