From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 854 invoked by alias); 13 Jan 2014 19:13:12 -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 741 invoked by uid 89); 13 Jan 2014 19:13:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS,UNWANTED_LANGUAGE_BODY autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 13 Jan 2014 19:13:07 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0DJD6HH007116 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 13 Jan 2014 14:13:06 -0500 Received: from barimba.redhat.com (ovpn-113-85.phx2.redhat.com [10.3.113.85]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0DJCptP016701; Mon, 13 Jan 2014 14:13:05 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFC 19/32] convert to_detach Date: Mon, 13 Jan 2014 19:13:00 -0000 Message-Id: <1389640367-5571-20-git-send-email-tromey@redhat.com> In-Reply-To: <1389640367-5571-1-git-send-email-tromey@redhat.com> References: <1389640367-5571-1-git-send-email-tromey@redhat.com> X-SW-Source: 2014-01/txt/msg00337.txt.bz2 2014-01-08 Tom Tromey * target-delegates.c : Rebuild. * target.c (target_detach): Unconditionally delegate. (init_dummy_target): Don't initialize to_detach. * target.h (struct target_ops) : Use TARGET_DEFAULT_IGNORE. convert to_attach 2014-01-08 Tom Tromey * target-delegates.c : Rebuild. * target.c (init_dummy_target): Don't initialize to_attach. (target_attach): Unconditionally delegate. * target.h (struct target_ops) : Use TARGET_DEFAULT_FUNC. convert to_rcmd 2014-01-08 Tom Tromey * target-delegates.c : Rebuild. * target.c (update_current_target): Don't inherit or default to_rcmd. (default_rcmd): New function. (do_monitor_command): Unconditionally delegate. * target.h (struct target_ops) : Use TARGET_DEFAULT_FUNC. convert to_post_attach 2014-01-08 Tom Tromey * target-delegates.c : Rebuild. * target.c (update_current_target): Don't inherit or default to_post_attach. * target.h (struct target_ops) : Use TARGET_DEFAULT_IGNORE. convert to_prepare_to_store 2014-01-08 Tom Tromey * target-delegates.c : Rebuild. * target.c (update_current_target): Don't inherit or default to_store. * target.h (struct target_ops) : Use TARGET_DEFAULT_NORETURN. convert to_files_info 2014-01-08 Tom Tromey * target-delegates.c : Rebuild. * target.c (update_current_target): Don't inherit or default to_files_info. * target.h (struct target_ops) : Use TARGET_DEFAULT_IGNORE. convert to_can_use_hw_breakpoint 2014-01-08 Tom Tromey * target-delegates.c : Rebuild. * target.c (update_current_target): Don't inherit or default to_can_use_hw_breakpoint. * target.h (struct target_ops) : Use TARGET_DEFAULT_RETURN. convert to_insert_hw_breakpoint 2014-01-08 Tom Tromey * target-delegates.c : Rebuild. * target.c (update_current_target): Don't inherit or default to_insert_hw_breakpoint. * target.h (struct target_ops) : Use TARGET_DEFAULT_RETURN. convert to_remove_hw_breakpoint 2014-01-08 Tom Tromey * target-delegates.c : Rebuild. * target.c (update_current_target): Don't inherit or default to_remove_hw_breakpoint. * target.h (struct target_ops) : Use TARGET_DEFAULT_RETURN. convert to_insert_watchpoint 2014-01-08 Tom Tromey * target-delegates.c : Rebuild. * target.c (update_current_target): Don't inherit or default to_insert_watchpoint. * target.h (struct target_ops) : Use TARGET_DEFAULT_RETURN. --- gdb/ChangeLog | 82 ++++++++++++++++++++++++++++ gdb/target-delegates.c | 145 +++++++++++++++++++++++++++++++++++++++++++++++++ gdb/target.c | 98 ++++++++------------------------- gdb/target.h | 30 ++++++---- 4 files changed, 271 insertions(+), 84 deletions(-) diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c index 77f3113..5a5954d 100644 --- a/gdb/target-delegates.c +++ b/gdb/target-delegates.c @@ -4,6 +4,37 @@ /* To regenerate this file, run:*/ /* make-target-delegates target.h > target-delegates.c */ static void +delegate_attach (struct target_ops *self, char *arg1, int arg2) +{ + self = self->beneath; + self->to_attach (self, arg1, arg2); +} + +static void +delegate_post_attach (struct target_ops *self, int arg1) +{ + self = self->beneath; + self->to_post_attach (self, arg1); +} + +static void +tdefault_post_attach (struct target_ops *self, int arg1) +{ +} + +static void +delegate_detach (struct target_ops *self, const char *arg1, int arg2) +{ + self = self->beneath; + self->to_detach (self, arg1, arg2); +} + +static void +tdefault_detach (struct target_ops *self, const char *arg1, int arg2) +{ +} + +static void delegate_resume (struct target_ops *self, ptid_t arg1, int arg2, enum gdb_signal arg3) { self = self->beneath; @@ -42,6 +73,31 @@ tdefault_store_registers (struct target_ops *self, struct regcache *arg1, int ar noprocess (); } +static void +delegate_prepare_to_store (struct target_ops *self, struct regcache *arg1) +{ + self = self->beneath; + self->to_prepare_to_store (self, arg1); +} + +static void +tdefault_prepare_to_store (struct target_ops *self, struct regcache *arg1) +{ + noprocess (); +} + +static void +delegate_files_info (struct target_ops *self) +{ + self = self->beneath; + self->to_files_info (self); +} + +static void +tdefault_files_info (struct target_ops *self) +{ +} + static int delegate_insert_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2) { @@ -57,6 +113,58 @@ delegate_remove_breakpoint (struct target_ops *self, struct gdbarch *arg1, struc } static int +delegate_can_use_hw_breakpoint (struct target_ops *self, int arg1, int arg2, int arg3) +{ + self = self->beneath; + return self->to_can_use_hw_breakpoint (self, arg1, arg2, arg3); +} + +static int +tdefault_can_use_hw_breakpoint (struct target_ops *self, int arg1, int arg2, int arg3) +{ + return 0; +} + +static int +delegate_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2) +{ + self = self->beneath; + return self->to_insert_hw_breakpoint (self, arg1, arg2); +} + +static int +tdefault_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2) +{ + return -1; +} + +static int +delegate_remove_hw_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2) +{ + self = self->beneath; + return self->to_remove_hw_breakpoint (self, arg1, arg2); +} + +static int +tdefault_remove_hw_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2) +{ + return -1; +} + +static int +delegate_insert_watchpoint (struct target_ops *self, CORE_ADDR arg1, int arg2, int arg3, struct expression *arg4) +{ + self = self->beneath; + return self->to_insert_watchpoint (self, arg1, arg2, arg3, arg4); +} + +static int +tdefault_insert_watchpoint (struct target_ops *self, CORE_ADDR arg1, int arg2, int arg3, struct expression *arg4) +{ + return -1; +} + +static int delegate_stopped_by_watchpoint (struct target_ops *self) { self = self->beneath; @@ -82,6 +190,13 @@ tdefault_stopped_data_address (struct target_ops *self, CORE_ADDR *arg1) return 0; } +static void +delegate_rcmd (struct target_ops *self, char *arg1, struct ui_file *arg2) +{ + self = self->beneath; + self->to_rcmd (self, arg1, arg2); +} + static int delegate_can_async_p (struct target_ops *self) { @@ -138,20 +253,40 @@ tdefault_supports_btrace (struct target_ops *self) static void install_delegators (struct target_ops *ops) { + if (ops->to_attach == NULL) + ops->to_attach = delegate_attach; + if (ops->to_post_attach == NULL) + ops->to_post_attach = delegate_post_attach; + if (ops->to_detach == NULL) + ops->to_detach = delegate_detach; if (ops->to_resume == NULL) ops->to_resume = delegate_resume; if (ops->to_wait == NULL) ops->to_wait = delegate_wait; if (ops->to_store_registers == NULL) ops->to_store_registers = delegate_store_registers; + if (ops->to_prepare_to_store == NULL) + ops->to_prepare_to_store = delegate_prepare_to_store; + if (ops->to_files_info == NULL) + ops->to_files_info = delegate_files_info; if (ops->to_insert_breakpoint == NULL) ops->to_insert_breakpoint = delegate_insert_breakpoint; if (ops->to_remove_breakpoint == NULL) ops->to_remove_breakpoint = delegate_remove_breakpoint; + if (ops->to_can_use_hw_breakpoint == NULL) + ops->to_can_use_hw_breakpoint = delegate_can_use_hw_breakpoint; + if (ops->to_insert_hw_breakpoint == NULL) + ops->to_insert_hw_breakpoint = delegate_insert_hw_breakpoint; + if (ops->to_remove_hw_breakpoint == NULL) + ops->to_remove_hw_breakpoint = delegate_remove_hw_breakpoint; + if (ops->to_insert_watchpoint == NULL) + ops->to_insert_watchpoint = delegate_insert_watchpoint; if (ops->to_stopped_by_watchpoint == NULL) ops->to_stopped_by_watchpoint = delegate_stopped_by_watchpoint; if (ops->to_stopped_data_address == NULL) ops->to_stopped_data_address = delegate_stopped_data_address; + if (ops->to_rcmd == NULL) + ops->to_rcmd = delegate_rcmd; if (ops->to_can_async_p == NULL) ops->to_can_async_p = delegate_can_async_p; if (ops->to_is_async_p == NULL) @@ -167,13 +302,23 @@ install_delegators (struct target_ops *ops) static void install_dummy_methods (struct target_ops *ops) { + ops->to_attach = find_default_attach; + ops->to_post_attach = tdefault_post_attach; + ops->to_detach = tdefault_detach; ops->to_resume = tdefault_resume; ops->to_wait = tdefault_wait; ops->to_store_registers = tdefault_store_registers; + ops->to_prepare_to_store = tdefault_prepare_to_store; + ops->to_files_info = tdefault_files_info; ops->to_insert_breakpoint = memory_insert_breakpoint; ops->to_remove_breakpoint = memory_remove_breakpoint; + ops->to_can_use_hw_breakpoint = tdefault_can_use_hw_breakpoint; + ops->to_insert_hw_breakpoint = tdefault_insert_hw_breakpoint; + ops->to_remove_hw_breakpoint = tdefault_remove_hw_breakpoint; + ops->to_insert_watchpoint = tdefault_insert_watchpoint; ops->to_stopped_by_watchpoint = tdefault_stopped_by_watchpoint; ops->to_stopped_data_address = tdefault_stopped_data_address; + ops->to_rcmd = default_rcmd; ops->to_can_async_p = find_default_can_async_p; ops->to_is_async_p = find_default_is_async_p; ops->to_async = tdefault_async; diff --git a/gdb/target.c b/gdb/target.c index 1f3562f..794d099 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -55,6 +55,8 @@ static int default_watchpoint_addr_within_range (struct target_ops *, static int default_region_ok_for_hw_watchpoint (struct target_ops *, CORE_ADDR, int); +static void default_rcmd (struct target_ops *, char *, struct ui_file *); + static void tcomplain (void) ATTRIBUTE_NORETURN; static int nomemory (CORE_ADDR, char *, int, int, struct target_ops *); @@ -585,7 +587,7 @@ update_current_target (void) /* Do not inherit to_open. */ /* Do not inherit to_close. */ /* Do not inherit to_attach. */ - INHERIT (to_post_attach, t); + /* Do not inherit to_post_attach. */ INHERIT (to_attach_no_wait, t); /* Do not inherit to_detach. */ /* Do not inherit to_disconnect. */ @@ -593,16 +595,16 @@ update_current_target (void) /* Do not inherit to_wait. */ /* Do not inherit to_fetch_registers. */ /* Do not inherit to_store_registers. */ - INHERIT (to_prepare_to_store, t); + /* Do not inherit to_prepare_to_store. */ INHERIT (deprecated_xfer_memory, t); - INHERIT (to_files_info, t); + /* Do not inherit to_files_info. */ /* 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); + /* Do not inherit to_can_use_hw_breakpoint. */ + /* Do not inherit to_insert_hw_breakpoint. */ + /* Do not inherit to_remove_hw_breakpoint. */ /* Do not inherit to_ranged_break_num_registers. */ - INHERIT (to_insert_watchpoint, t); + /* Do not inherit to_insert_watchpoint. */ INHERIT (to_remove_watchpoint, t); /* Do not inherit to_insert_mask_watchpoint. */ /* Do not inherit to_remove_mask_watchpoint. */ @@ -644,7 +646,7 @@ update_current_target (void) INHERIT (to_thread_name, t); INHERIT (to_stop, t); /* Do not inherit to_xfer_partial. */ - INHERIT (to_rcmd, t); + /* Do not inherit to_rcmd. */ INHERIT (to_pid_to_exec_file, t); INHERIT (to_log_command, t); INHERIT (to_stratum, t); @@ -724,34 +726,10 @@ update_current_target (void) de_fault (to_close, (void (*) (struct target_ops *)) target_ignore); - de_fault (to_post_attach, - (void (*) (struct target_ops *, int)) - target_ignore); - de_fault (to_prepare_to_store, - (void (*) (struct target_ops *, struct regcache *)) - noprocess); de_fault (deprecated_xfer_memory, (int (*) (CORE_ADDR, gdb_byte *, int, int, struct mem_attrib *, struct target_ops *)) nomemory); - de_fault (to_files_info, - (void (*) (struct target_ops *)) - target_ignore); - de_fault (to_can_use_hw_breakpoint, - (int (*) (struct target_ops *, int, int, int)) - return_zero); - de_fault (to_insert_hw_breakpoint, - (int (*) (struct target_ops *, struct gdbarch *, - struct bp_target_info *)) - return_minus_one); - de_fault (to_remove_hw_breakpoint, - (int (*) (struct target_ops *, struct gdbarch *, - struct bp_target_info *)) - return_minus_one); - de_fault (to_insert_watchpoint, - (int (*) (struct target_ops *, CORE_ADDR, int, int, - struct expression *)) - return_minus_one); de_fault (to_remove_watchpoint, (int (*) (struct target_ops *, CORE_ADDR, int, int, struct expression *)) @@ -823,9 +801,6 @@ update_current_target (void) de_fault (to_stop, (void (*) (struct target_ops *, ptid_t)) target_ignore); - de_fault (to_rcmd, - (void (*) (struct target_ops *, char *, struct ui_file *)) - tcomplain); de_fault (to_pid_to_exec_file, (char *(*) (struct target_ops *, int)) return_zero); @@ -2617,19 +2592,10 @@ target_detach (const char *args, int from_tty) prepare_for_detach (); - for (t = current_target.beneath; t != NULL; t = t->beneath) - { - if (t->to_detach != NULL) - { - t->to_detach (t, args, from_tty); - if (targetdebug) - fprintf_unfiltered (gdb_stdlog, "target_detach (%s, %d)\n", - args, from_tty); - return; - } - } - - internal_error (__FILE__, __LINE__, _("could not find a target to detach")); + current_target.to_detach (¤t_target, args, from_tty); + if (targetdebug) + fprintf_unfiltered (gdb_stdlog, "target_detach (%s, %d)\n", + args, from_tty); } void @@ -3736,9 +3702,6 @@ init_dummy_target (void) dummy_target.to_shortname = "None"; dummy_target.to_longname = "None"; dummy_target.to_doc = ""; - dummy_target.to_attach = find_default_attach; - dummy_target.to_detach = - (void (*)(struct target_ops *, const char *, int))target_ignore; dummy_target.to_create_inferior = find_default_create_inferior; dummy_target.to_supports_non_stop = find_default_supports_non_stop; dummy_target.to_supports_disable_randomization @@ -3785,22 +3748,10 @@ target_close (struct target_ops *targ) void target_attach (char *args, int from_tty) { - struct target_ops *t; - - for (t = current_target.beneath; t != NULL; t = t->beneath) - { - if (t->to_attach != NULL) - { - t->to_attach (t, args, from_tty); - if (targetdebug) - fprintf_unfiltered (gdb_stdlog, "target_attach (%s, %d)\n", - args, from_tty); - return; - } - } - - internal_error (__FILE__, __LINE__, - _("could not find a target to attach")); + current_target.to_attach (¤t_target, args, from_tty); + if (targetdebug) + fprintf_unfiltered (gdb_stdlog, "target_attach (%s, %d)\n", + args, from_tty); } int @@ -4951,16 +4902,15 @@ stack of targets currently in use (including the exec-file,\n\ core-file, and process, if any), as well as the symbol file name."; static void +default_rcmd (struct target_ops *self, char *command, struct ui_file *output) +{ + error (_("\"monitor\" command not supported by this target.")); +} + +static void do_monitor_command (char *cmd, int from_tty) { - if ((current_target.to_rcmd - == (void (*) (struct target_ops *, char *, struct ui_file *)) tcomplain) - || (current_target.to_rcmd == debug_to_rcmd - && (debug_target.to_rcmd - == (void (*) (struct target_ops *, - char *, struct ui_file *)) tcomplain))) - error (_("\"monitor\" command not supported by this target.")); target_rcmd (cmd, gdb_stdtarg); } diff --git a/gdb/target.h b/gdb/target.h index 4668c23..5f521c5 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -389,9 +389,12 @@ struct target_ops to xfree everything (including the "struct target_ops"). */ void (*to_xclose) (struct target_ops *targ); void (*to_close) (struct target_ops *); - void (*to_attach) (struct target_ops *ops, char *, int); - void (*to_post_attach) (struct target_ops *, int); - void (*to_detach) (struct target_ops *ops, const char *, int); + void (*to_attach) (struct target_ops *ops, char *, int) + TARGET_DEFAULT_FUNC (find_default_attach); + void (*to_post_attach) (struct target_ops *, int) + TARGET_DEFAULT_IGNORE (); + void (*to_detach) (struct target_ops *ops, const char *, int) + TARGET_DEFAULT_IGNORE (); void (*to_disconnect) (struct target_ops *, char *, int); void (*to_resume) (struct target_ops *, ptid_t, int, enum gdb_signal) TARGET_DEFAULT_NORETURN (noprocess ()); @@ -401,7 +404,8 @@ struct target_ops void (*to_fetch_registers) (struct target_ops *, struct regcache *, int); void (*to_store_registers) (struct target_ops *, struct regcache *, int) TARGET_DEFAULT_NORETURN (noprocess ()); - void (*to_prepare_to_store) (struct target_ops *, struct regcache *); + void (*to_prepare_to_store) (struct target_ops *, struct regcache *) + TARGET_DEFAULT_NORETURN (noprocess ()); /* Transfer LEN bytes of memory between GDB address MYADDR and target address MEMADDR. If WRITE, transfer them to the target, else @@ -429,26 +433,31 @@ struct target_ops struct mem_attrib *attrib, struct target_ops *target); - void (*to_files_info) (struct target_ops *); + void (*to_files_info) (struct target_ops *) + TARGET_DEFAULT_IGNORE (); int (*to_insert_breakpoint) (struct target_ops *, struct gdbarch *, struct bp_target_info *) TARGET_DEFAULT_FUNC (memory_insert_breakpoint); int (*to_remove_breakpoint) (struct target_ops *, struct gdbarch *, struct bp_target_info *) TARGET_DEFAULT_FUNC (memory_remove_breakpoint); - int (*to_can_use_hw_breakpoint) (struct target_ops *, int, int, int); + int (*to_can_use_hw_breakpoint) (struct target_ops *, int, int, int) + TARGET_DEFAULT_RETURN (0); int (*to_ranged_break_num_registers) (struct target_ops *); int (*to_insert_hw_breakpoint) (struct target_ops *, - struct gdbarch *, struct bp_target_info *); + struct gdbarch *, struct bp_target_info *) + TARGET_DEFAULT_RETURN (-1); int (*to_remove_hw_breakpoint) (struct target_ops *, - struct gdbarch *, struct bp_target_info *); + struct gdbarch *, struct bp_target_info *) + TARGET_DEFAULT_RETURN (-1); /* Documentation of what the two routines below are expected to do is provided with the corresponding target_* macros. */ int (*to_remove_watchpoint) (struct target_ops *, CORE_ADDR, int, int, struct expression *); int (*to_insert_watchpoint) (struct target_ops *, - CORE_ADDR, int, int, struct expression *); + CORE_ADDR, int, int, struct expression *) + TARGET_DEFAULT_RETURN (-1); int (*to_insert_mask_watchpoint) (struct target_ops *, CORE_ADDR, CORE_ADDR, int); @@ -512,7 +521,8 @@ struct target_ops char *(*to_thread_name) (struct target_ops *, struct thread_info *); void (*to_stop) (struct target_ops *, ptid_t); void (*to_rcmd) (struct target_ops *, - char *command, struct ui_file *output); + char *command, struct ui_file *output) + TARGET_DEFAULT_FUNC (default_rcmd); char *(*to_pid_to_exec_file) (struct target_ops *, int pid); void (*to_log_command) (struct target_ops *, const char *); struct target_section_table *(*to_get_section_table) (struct target_ops *); -- 1.8.1.4