From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20510 invoked by alias); 19 Dec 2013 16:45:23 -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 20402 invoked by uid 89); 19 Dec 2013 16:45:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mga02.intel.com Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 19 Dec 2013 16:45:19 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 19 Dec 2013 08:45:14 -0800 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 19 Dec 2013 08:45:03 -0800 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id rBJGj152026072; Thu, 19 Dec 2013 16:45:01 GMT Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id rBJGj102029879; Thu, 19 Dec 2013 17:45:01 +0100 Received: (from mmetzger@localhost) by ulvlx001.iul.intel.com with œ id rBJGj1ts029875; Thu, 19 Dec 2013 17:45:01 +0100 From: Markus Metzger To: jan.kratochvil@redhat.com, palves@redhat.com Cc: gdb-patches@sourceware.org Subject: [PATCH v9 20/29] target, breakpoint: allow insert/remove breakpoint to be forwarded Date: Thu, 19 Dec 2013 16:45:00 -0000 Message-Id: <1387471499-29444-21-git-send-email-markus.t.metzger@intel.com> In-Reply-To: <1387471499-29444-1-git-send-email-markus.t.metzger@intel.com> References: <1387471499-29444-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00767.txt.bz2 2013-12-19 Markus Metzger * target.h (target_ops) : Add target_ops parameter. (forward_target_insert_breakpoint): New. (forward_target_remove_breakpoint): New. (memory_remove_breakpoint, memory_insert_breakpoint): Add target_ops parameter. * target.c (target_insert_breakpoint): Split into this and ... (forward_target_insert_breakpoint): ... this. (target_remove_breakpoint): Split into this and ... (forward_target_remove_breakpoint): ... this. (debug_to_insert_breakpoint): Add target_ops parameter. Call forward_target_insert_breakpoint. (debug_to_remove_breakpoint): Add target_ops parameter. Call forward_target_remove_breakpoint. (update_current_target): Do not inherit or default to_insert_breakpoint and to_remove_breakpoint. * corelow.c (ignore): Add target_ops parameter. * exec.c (ignore): Add target_ops parameter. * mem-break.c (memory_insert_breakpoint, memory_remove_breakpoint): Add target_ops parameter. * monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint): Add target_ops parameter. * nto-procfs.c (procfs_insert_breakpoint, procfs_remove_breakpoint): Add target_ops parameter. * record-full.c (record_full_beneath_to_insert_breakpoint) (record_full_beneath_to_remove_breakpoint, tmp_to_insert_breakpoint) (tmp_to_remove_breakpoint, record_full_insert_breakpoint) (record_full_remove_breakpoint, record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint): Add target_ops parameter. * m32r-sdi.c (m32r_insert_breakpoint, m32r_remove_breakpoint): Add target_ops parameter. * remote-mips.c (mips_insert_breakpoint, mips_remove_breakpoint): Add target_ops parameter. * remote.c (remote_insert_breakpoint, remote_remove_breakpoint): Add target_ops parameter. --- gdb/corelow.c | 3 ++- gdb/exec.c | 3 ++- gdb/mem-break.c | 4 ++-- gdb/monitor.c | 4 ++-- gdb/nto-procfs.c | 4 ++-- gdb/record-full.c | 28 ++++++++++++++--------- gdb/remote-m32r-sdi.c | 6 +++-- gdb/remote-mips.c | 8 +++---- gdb/remote.c | 10 +++++---- gdb/target.c | 62 +++++++++++++++++++++++++++++++++++++-------------- gdb/target.h | 25 +++++++++++++++++---- 11 files changed, 108 insertions(+), 49 deletions(-) diff --git a/gdb/corelow.c b/gdb/corelow.c index 2869eea..50f89cf 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -842,7 +842,8 @@ core_xfer_partial (struct target_ops *ops, enum target_object object, breakpoint_init_inferior). */ static int -ignore (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) +ignore (struct target_ops *ops, struct gdbarch *gdbarch, + struct bp_target_info *bp_tgt) { return 0; } diff --git a/gdb/exec.c b/gdb/exec.c index 38d2edb..70409d9 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -801,7 +801,8 @@ exec_set_section_address (const char *filename, int index, CORE_ADDR address) breakpoint_init_inferior). */ static int -ignore (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) +ignore (struct target_ops *ops, struct gdbarch *gdbarch, + struct bp_target_info *bp_tgt) { return 0; } diff --git a/gdb/mem-break.c b/gdb/mem-break.c index f06c4ae..9e2a1a4 100644 --- a/gdb/mem-break.c +++ b/gdb/mem-break.c @@ -77,14 +77,14 @@ default_memory_remove_breakpoint (struct gdbarch *gdbarch, int -memory_insert_breakpoint (struct gdbarch *gdbarch, +memory_insert_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { return gdbarch_memory_insert_breakpoint (gdbarch, bp_tgt); } int -memory_remove_breakpoint (struct gdbarch *gdbarch, +memory_remove_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { return gdbarch_memory_remove_breakpoint (gdbarch, bp_tgt); diff --git a/gdb/monitor.c b/gdb/monitor.c index 5d2c3f3..6074435 100644 --- a/gdb/monitor.c +++ b/gdb/monitor.c @@ -2095,7 +2095,7 @@ monitor_mourn_inferior (struct target_ops *ops) /* Tell the monitor to add a breakpoint. */ static int -monitor_insert_breakpoint (struct gdbarch *gdbarch, +monitor_insert_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { CORE_ADDR addr = bp_tgt->placed_address; @@ -2132,7 +2132,7 @@ monitor_insert_breakpoint (struct gdbarch *gdbarch, /* Tell the monitor to remove a breakpoint. */ static int -monitor_remove_breakpoint (struct gdbarch *gdbarch, +monitor_remove_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { CORE_ADDR addr = bp_tgt->placed_address; diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c index 1c2f298..6c9604d 100644 --- a/gdb/nto-procfs.c +++ b/gdb/nto-procfs.c @@ -922,14 +922,14 @@ procfs_breakpoint (CORE_ADDR addr, int type, int size) } static int -procfs_insert_breakpoint (struct gdbarch *gdbarch, +procfs_insert_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { return procfs_breakpoint (bp_tgt->placed_address, _DEBUG_BREAK_EXEC, 0); } static int -procfs_remove_breakpoint (struct gdbarch *gdbarch, +procfs_remove_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { return procfs_breakpoint (bp_tgt->placed_address, _DEBUG_BREAK_EXEC, -1); diff --git a/gdb/record-full.c b/gdb/record-full.c index 1710a51..b54314d 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -230,10 +230,12 @@ static void (*record_full_beneath_to_store_registers) (struct target_ops *, static struct target_ops *record_full_beneath_to_xfer_partial_ops; static target_xfer_partial_ftype *record_full_beneath_to_xfer_partial; static int - (*record_full_beneath_to_insert_breakpoint) (struct gdbarch *, + (*record_full_beneath_to_insert_breakpoint) (struct target_ops *, + struct gdbarch *, struct bp_target_info *); static int - (*record_full_beneath_to_remove_breakpoint) (struct gdbarch *, + (*record_full_beneath_to_remove_breakpoint) (struct target_ops *, + struct gdbarch *, struct bp_target_info *); static int (*record_full_beneath_to_stopped_by_watchpoint) (void); static int (*record_full_beneath_to_stopped_data_address) (struct target_ops *, @@ -801,9 +803,9 @@ static void (*tmp_to_store_registers) (struct target_ops *, int regno); static struct target_ops *tmp_to_xfer_partial_ops; static target_xfer_partial_ftype *tmp_to_xfer_partial; -static int (*tmp_to_insert_breakpoint) (struct gdbarch *, +static int (*tmp_to_insert_breakpoint) (struct target_ops *, struct gdbarch *, struct bp_target_info *); -static int (*tmp_to_remove_breakpoint) (struct gdbarch *, +static int (*tmp_to_remove_breakpoint) (struct target_ops *, struct gdbarch *, struct bp_target_info *); static int (*tmp_to_stopped_by_watchpoint) (void); static int (*tmp_to_stopped_data_address) (struct target_ops *, CORE_ADDR *); @@ -1745,7 +1747,8 @@ record_full_init_record_breakpoints (void) when recording. */ static int -record_full_insert_breakpoint (struct gdbarch *gdbarch, +record_full_insert_breakpoint (struct target_ops *ops, + struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { struct record_full_breakpoint *bp; @@ -1762,7 +1765,8 @@ record_full_insert_breakpoint (struct gdbarch *gdbarch, int ret; old_cleanups = record_full_gdb_operation_disable_set (); - ret = record_full_beneath_to_insert_breakpoint (gdbarch, bp_tgt); + ret = record_full_beneath_to_insert_breakpoint (ops->beneath, gdbarch, + bp_tgt); do_cleanups (old_cleanups); if (ret != 0) @@ -1782,7 +1786,8 @@ record_full_insert_breakpoint (struct gdbarch *gdbarch, /* "to_remove_breakpoint" method for process record target. */ static int -record_full_remove_breakpoint (struct gdbarch *gdbarch, +record_full_remove_breakpoint (struct target_ops *ops, + struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { struct record_full_breakpoint *bp; @@ -1802,7 +1807,8 @@ record_full_remove_breakpoint (struct gdbarch *gdbarch, int ret; old_cleanups = record_full_gdb_operation_disable_set (); - ret = record_full_beneath_to_remove_breakpoint (gdbarch, bp_tgt); + ret = record_full_beneath_to_remove_breakpoint (ops->beneath, + gdbarch, bp_tgt); do_cleanups (old_cleanups); if (ret != 0) @@ -2252,7 +2258,8 @@ record_full_core_xfer_partial (struct target_ops *ops, /* "to_insert_breakpoint" method for prec over corefile. */ static int -record_full_core_insert_breakpoint (struct gdbarch *gdbarch, +record_full_core_insert_breakpoint (struct target_ops *ops, + struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { return 0; @@ -2261,7 +2268,8 @@ record_full_core_insert_breakpoint (struct gdbarch *gdbarch, /* "to_remove_breakpoint" method for prec over corefile. */ static int -record_full_core_remove_breakpoint (struct gdbarch *gdbarch, +record_full_core_remove_breakpoint (struct target_ops *ops, + struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { return 0; diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c index f560388..c606d71 100644 --- a/gdb/remote-m32r-sdi.c +++ b/gdb/remote-m32r-sdi.c @@ -1145,7 +1145,8 @@ m32r_mourn_inferior (struct target_ops *ops) } static int -m32r_insert_breakpoint (struct gdbarch *gdbarch, +m32r_insert_breakpoint (struct target_ops *ops, + struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { CORE_ADDR addr = bp_tgt->placed_address; @@ -1189,7 +1190,8 @@ m32r_insert_breakpoint (struct gdbarch *gdbarch, } static int -m32r_remove_breakpoint (struct gdbarch *gdbarch, +m32r_remove_breakpoint (struct target_ops *ops, + struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { CORE_ADDR addr = bp_tgt->placed_address; diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c index 5b3254d..507e157 100644 --- a/gdb/remote-mips.c +++ b/gdb/remote-mips.c @@ -2363,27 +2363,27 @@ mips_mourn_inferior (struct target_ops *ops) target contents. */ static int -mips_insert_breakpoint (struct gdbarch *gdbarch, +mips_insert_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { if (monitor_supports_breakpoints) return mips_set_breakpoint (bp_tgt->placed_address, MIPS_INSN32_SIZE, BREAK_FETCH); else - return memory_insert_breakpoint (gdbarch, bp_tgt); + return memory_insert_breakpoint (ops, gdbarch, bp_tgt); } /* Remove a breakpoint. */ static int -mips_remove_breakpoint (struct gdbarch *gdbarch, +mips_remove_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { if (monitor_supports_breakpoints) return mips_clear_breakpoint (bp_tgt->placed_address, MIPS_INSN32_SIZE, BREAK_FETCH); else - return memory_remove_breakpoint (gdbarch, bp_tgt); + return memory_remove_breakpoint (ops, gdbarch, bp_tgt); } /* Tell whether this target can support a hardware breakpoint. CNT diff --git a/gdb/remote.c b/gdb/remote.c index 5fe1c53..99ab6e0 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -8205,7 +8205,8 @@ remote_add_target_side_commands (struct gdbarch *gdbarch, which don't, we insert a traditional memory breakpoint. */ static int -remote_insert_breakpoint (struct gdbarch *gdbarch, +remote_insert_breakpoint (struct target_ops *ops, + struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { /* Try the "Z" s/w breakpoint packet if it is not already disabled. @@ -8261,11 +8262,12 @@ remote_insert_breakpoint (struct gdbarch *gdbarch, } } - return memory_insert_breakpoint (gdbarch, bp_tgt); + return memory_insert_breakpoint (ops, gdbarch, bp_tgt); } static int -remote_remove_breakpoint (struct gdbarch *gdbarch, +remote_remove_breakpoint (struct target_ops *ops, + struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { CORE_ADDR addr = bp_tgt->placed_address; @@ -8295,7 +8297,7 @@ remote_remove_breakpoint (struct gdbarch *gdbarch, return (rs->buf[0] == 'E'); } - return memory_remove_breakpoint (gdbarch, bp_tgt); + return memory_remove_breakpoint (ops, gdbarch, bp_tgt); } static int diff --git a/gdb/target.c b/gdb/target.c index 0759ae9..c9fef6b 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -85,10 +85,10 @@ static void debug_to_open (char *, int); static void debug_to_files_info (struct target_ops *); -static int debug_to_insert_breakpoint (struct gdbarch *, +static int debug_to_insert_breakpoint (struct target_ops *, struct gdbarch *, struct bp_target_info *); -static int debug_to_remove_breakpoint (struct gdbarch *, +static int debug_to_remove_breakpoint (struct target_ops *, struct gdbarch *, struct bp_target_info *); static int debug_to_can_use_hw_breakpoint (int, int, int); @@ -580,8 +580,8 @@ update_current_target (void) /* Do not inherit to_prepare_to_store. */ INHERIT (deprecated_xfer_memory, t); INHERIT (to_files_info, t); - INHERIT (to_insert_breakpoint, t); - INHERIT (to_remove_breakpoint, t); + /* Do not inherit to_insert_breakpoint. */ + /* Do not inherit to_remove_breakpoint. */ INHERIT (to_can_use_hw_breakpoint, t); INHERIT (to_insert_hw_breakpoint, t); INHERIT (to_remove_hw_breakpoint, t); @@ -718,10 +718,6 @@ update_current_target (void) de_fault (to_files_info, (void (*) (struct target_ops *)) target_ignore); - de_fault (to_insert_breakpoint, - memory_insert_breakpoint); - de_fault (to_remove_breakpoint, - memory_remove_breakpoint); de_fault (to_can_use_hw_breakpoint, (int (*) (int, int, int)) return_zero); @@ -2449,9 +2445,12 @@ get_target_memory_unsigned (struct target_ops *ops, CORE_ADDR addr, return extract_unsigned_integer (buf, len, byte_order); } +/* See target.h. */ + int -target_insert_breakpoint (struct gdbarch *gdbarch, - struct bp_target_info *bp_tgt) +forward_target_insert_breakpoint (struct target_ops *ops, + struct gdbarch *gdbarch, + struct bp_target_info *bp_tgt) { if (!may_insert_breakpoints) { @@ -2459,13 +2458,29 @@ target_insert_breakpoint (struct gdbarch *gdbarch, return 1; } - return (*current_target.to_insert_breakpoint) (gdbarch, bp_tgt); + for (; ops != NULL; ops = ops->beneath) + if (ops->to_insert_breakpoint != NULL) + return ops->to_insert_breakpoint (ops, gdbarch, bp_tgt); + + return memory_insert_breakpoint (ops, gdbarch, bp_tgt); } +/* See target.h. */ + int -target_remove_breakpoint (struct gdbarch *gdbarch, +target_insert_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { + return forward_target_insert_breakpoint (¤t_target, gdbarch, bp_tgt); +} + +/* See target.h. */ + +int +forward_target_remove_breakpoint (struct target_ops *ops, + struct gdbarch *gdbarch, + struct bp_target_info *bp_tgt) +{ /* This is kind of a weird case to handle, but the permission might have been changed after breakpoints were inserted - in which case we should just take the user literally and assume that any @@ -2476,7 +2491,20 @@ target_remove_breakpoint (struct gdbarch *gdbarch, return 1; } - return (*current_target.to_remove_breakpoint) (gdbarch, bp_tgt); + for (; ops != NULL; ops = ops->beneath) + if (ops->to_remove_breakpoint != NULL) + return ops->to_remove_breakpoint (ops, gdbarch, bp_tgt); + + return memory_remove_breakpoint (ops, gdbarch, bp_tgt); +} + +/* See target.h. */ + +int +target_remove_breakpoint (struct gdbarch *gdbarch, + struct bp_target_info *bp_tgt) +{ + return forward_target_remove_breakpoint (¤t_target, gdbarch, bp_tgt); } static void @@ -4547,12 +4575,12 @@ debug_to_files_info (struct target_ops *target) } static int -debug_to_insert_breakpoint (struct gdbarch *gdbarch, +debug_to_insert_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { int retval; - retval = debug_target.to_insert_breakpoint (gdbarch, bp_tgt); + retval = forward_target_insert_breakpoint (&debug_target, gdbarch, bp_tgt); fprintf_unfiltered (gdb_stdlog, "target_insert_breakpoint (%s, xxx) = %ld\n", @@ -4562,12 +4590,12 @@ debug_to_insert_breakpoint (struct gdbarch *gdbarch, } static int -debug_to_remove_breakpoint (struct gdbarch *gdbarch, +debug_to_remove_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { int retval; - retval = debug_target.to_remove_breakpoint (gdbarch, bp_tgt); + retval = forward_target_remove_breakpoint (&debug_target, gdbarch, bp_tgt); fprintf_unfiltered (gdb_stdlog, "target_remove_breakpoint (%s, xxx) = %ld\n", diff --git a/gdb/target.h b/gdb/target.h index c415266..212f8d0 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -403,8 +403,10 @@ struct target_ops struct target_ops *target); void (*to_files_info) (struct target_ops *); - int (*to_insert_breakpoint) (struct gdbarch *, struct bp_target_info *); - int (*to_remove_breakpoint) (struct gdbarch *, struct bp_target_info *); + int (*to_insert_breakpoint) (struct target_ops *, struct gdbarch *, + struct bp_target_info *); + int (*to_remove_breakpoint) (struct target_ops *, struct gdbarch *, + struct bp_target_info *); int (*to_can_use_hw_breakpoint) (int, int, int); int (*to_ranged_break_num_registers) (struct target_ops *); int (*to_insert_hw_breakpoint) (struct gdbarch *, struct bp_target_info *); @@ -1132,12 +1134,27 @@ int target_write_memory_blocks (VEC(memory_write_request_s) *requests, (*current_target.to_files_info) (¤t_target) /* Insert a breakpoint at address BP_TGT->placed_address in the target + machine. Result is 0 for success, non-zero for error. + Start the target search at OPS. */ + +extern int forward_target_insert_breakpoint (struct target_ops *ops, + struct gdbarch *gdbarch, + struct bp_target_info *bp_tgt); + +/* Insert a breakpoint at address BP_TGT->placed_address in the target machine. Result is 0 for success, non-zero for error. */ extern int target_insert_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt); /* Remove a breakpoint at address BP_TGT->placed_address in the target + machine. Result is 0 for success, non-zero for error. + Start the target search at OPS. */ + +extern int forward_target_remove_breakpoint (struct target_ops *ops, + struct gdbarch *gdbarch, + struct bp_target_info *bp_tgt); +/* Remove a breakpoint at address BP_TGT->placed_address in the target machine. Result is 0 for success, non-zero for error. */ extern int target_remove_breakpoint (struct gdbarch *gdbarch, @@ -1884,10 +1901,10 @@ extern struct target_section_table *target_get_section_table /* From mem-break.c */ -extern int memory_remove_breakpoint (struct gdbarch *, +extern int memory_remove_breakpoint (struct target_ops *, struct gdbarch *, struct bp_target_info *); -extern int memory_insert_breakpoint (struct gdbarch *, +extern int memory_insert_breakpoint (struct target_ops *, struct gdbarch *, struct bp_target_info *); extern int default_memory_remove_breakpoint (struct gdbarch *, -- 1.8.3.1