From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5079 invoked by alias); 14 Jan 2014 18:43: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 5067 invoked by uid 89); 14 Jan 2014 18:43:51 -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 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; Tue, 14 Jan 2014 18:43:50 +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 s0EIhmeD016818 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 14 Jan 2014 13:43:49 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0EIhkaP016878; Tue, 14 Jan 2014 13:43:47 -0500 Message-ID: <52D58562.6040409@redhat.com> Date: Tue, 14 Jan 2014 18:43:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Tom Tromey CC: gdb-patches@sourceware.org Subject: Re: [RFC 22/32] convert to_extra_thread_info References: <1389640367-5571-1-git-send-email-tromey@redhat.com> <1389640367-5571-23-git-send-email-tromey@redhat.com> In-Reply-To: <1389640367-5571-23-git-send-email-tromey@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-01/txt/msg00458.txt.bz2 Looks fine. On 01/13/2014 07:12 PM, Tom Tromey wrote: > 2014-01-08 Tom Tromey > > * target-delegates.c : Rebuild. > * target.c (update_current_target): Don't inherit or default > to_extra_thread_info. > * target.h (struct target_ops) : Use > TARGET_DEFAULT_RETURN. > > convert to_thread_name > > 2014-01-08 Tom Tromey > > * target-delegates.c : Rebuild. > * target.c (update_current_target): Don't inherit or default > to_thread_name. > (target_thread_name): Unconditionally delegate. > * target.h (struct target_ops) : Use > TARGET_DEFAULT_RETURN. > > convert to_pid_to_exec_file > > 2014-01-08 Tom Tromey > > * target-delegates.c : Rebuild. > * target.c (update_current_target): Don't inherit or default > to_pid_to_exec_file. > * target.h (struct target_ops) : Use > TARGET_DEFAULT_RETURN. > > convert to_log_command > > 2014-01-08 Tom Tromey > > * target-delegates.c : Rebuild. > * target.c (update_current_target): Don't inherit or default > to_log_command. > * target.h (struct target_ops) : Use > TARGET_DEFAULT_IGNORE. > (target_log_command): Unconditionally delegate. > > convert to_find_memory_regions > > 2014-01-08 Tom Tromey > > * target-delegates.c : Rebuild. > * target.c (update_current_target): Don't inherit or default > to_find_memory_regions. > (init_dummy_target): Don't initialize to_find_memory_regions. > * target.h (struct target_ops) : Use > TARGET_DEFAULT_FUNC. > > convert to_make_corefile_notes > > 2014-01-08 Tom Tromey > > * target-delegates.c : Rebuild. > * target.c (update_current_target): Don't inherit or default > to_make_corefile_notes. > (init_dummy_target): Don't initialize to_make_corefile_notes. > * target.h (struct target_ops) : Use > TARGET_DEFAULT_FUNC. > > convert to_get_bookmark > > 2014-01-08 Tom Tromey > > * target-delegates.c : Rebuild. > * target.c (update_current_target): Don't inherit or default > to_get_bookmark. > (dummy_get_bookmark): Remove. > (init_dummy_target): Don't inherit or default to_get_bookmark. > * target.h (struct target_ops) : Use > TARGET_DEFAULT_NORETURN > > convert to_goto_bookmark > > 2014-01-08 Tom Tromey > > * target-delegates.c : Rebuild. > * target.c (update_current_target): Don't inherit or default > to_goto_bookmark. > (dummy_goto_bookmark): Remove. > (init_dummy_target): Don't inherit or default to_goto_bookmark. > * target.h (struct target_ops) : Use > TARGET_DEFAULT_NORETURN. > > convert to_can_execute_reverse > > 2014-01-08 Tom Tromey > > * target-delegates.c : Rebuild. > * target.c (update_current_target): Don't inherit or default > to_can_execute_reverse. > * target.h (struct target_ops) : Use > TARGET_DEFAULT_RETURN. > (target_can_execute_reverse): Unconditionally delegate. > > convert to_execution_direction > > 2014-01-08 Tom Tromey > > * target-delegates.c : Rebuild. > * target.c (update_current_target): Don't inherit or default > to_execution_direction. > * target.h (struct target_ops) : Use > TARGET_DEFAULT_FUNC. > --- > gdb/ChangeLog | 89 +++++++++++++++++++++++++++++++ > gdb/target-delegates.c | 141 +++++++++++++++++++++++++++++++++++++++++++++++++ > gdb/target.c | 69 ++++++++---------------- > gdb/target.h | 41 +++++++------- > 4 files changed, 274 insertions(+), 66 deletions(-) > > diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c > index 7abb393..a2293c4 100644 > --- a/gdb/target-delegates.c > +++ b/gdb/target-delegates.c > @@ -426,6 +426,32 @@ tdefault_has_exited (struct target_ops *self, int arg1, int arg2, int *arg3) > return 0; > } > > +static char * > +delegate_extra_thread_info (struct target_ops *self, struct thread_info *arg1) > +{ > + self = self->beneath; > + return self->to_extra_thread_info (self, arg1); > +} > + > +static char * > +tdefault_extra_thread_info (struct target_ops *self, struct thread_info *arg1) > +{ > + return 0; > +} > + > +static char * > +delegate_thread_name (struct target_ops *self, struct thread_info *arg1) > +{ > + self = self->beneath; > + return self->to_thread_name (self, arg1); > +} > + > +static char * > +tdefault_thread_name (struct target_ops *self, struct thread_info *arg1) > +{ > + return 0; > +} > + > static void > delegate_rcmd (struct target_ops *self, char *arg1, struct ui_file *arg2) > { > @@ -433,6 +459,31 @@ delegate_rcmd (struct target_ops *self, char *arg1, struct ui_file *arg2) > self->to_rcmd (self, arg1, arg2); > } > > +static char * > +delegate_pid_to_exec_file (struct target_ops *self, int arg1) > +{ > + self = self->beneath; > + return self->to_pid_to_exec_file (self, arg1); > +} > + > +static char * > +tdefault_pid_to_exec_file (struct target_ops *self, int arg1) > +{ > + return 0; > +} > + > +static void > +delegate_log_command (struct target_ops *self, const char *arg1) > +{ > + self = self->beneath; > + self->to_log_command (self, arg1); > +} > + > +static void > +tdefault_log_command (struct target_ops *self, const char *arg1) > +{ > +} > + > static int > delegate_can_async_p (struct target_ops *self) > { > @@ -460,6 +511,46 @@ tdefault_async (struct target_ops *self, async_callback_ftype *arg1, void *arg2) > tcomplain (); > } > > +static int > +delegate_find_memory_regions (struct target_ops *self, find_memory_region_ftype arg1, void *arg2) > +{ > + self = self->beneath; > + return self->to_find_memory_regions (self, arg1, arg2); > +} > + > +static char * > +delegate_make_corefile_notes (struct target_ops *self, bfd *arg1, int *arg2) > +{ > + self = self->beneath; > + return self->to_make_corefile_notes (self, arg1, arg2); > +} > + > +static gdb_byte * > +delegate_get_bookmark (struct target_ops *self, char *arg1, int arg2) > +{ > + self = self->beneath; > + return self->to_get_bookmark (self, arg1, arg2); > +} > + > +static gdb_byte * > +tdefault_get_bookmark (struct target_ops *self, char *arg1, int arg2) > +{ > + tcomplain (); > +} > + > +static void > +delegate_goto_bookmark (struct target_ops *self, gdb_byte *arg1, int arg2) > +{ > + self = self->beneath; > + self->to_goto_bookmark (self, arg1, arg2); > +} > + > +static void > +tdefault_goto_bookmark (struct target_ops *self, gdb_byte *arg1, int arg2) > +{ > + tcomplain (); > +} > + > static LONGEST > delegate_xfer_partial (struct target_ops *self, enum target_object arg1, const char *arg2, gdb_byte *arg3, const gdb_byte *arg4, ULONGEST arg5, LONGEST arg6) > { > @@ -474,6 +565,26 @@ tdefault_xfer_partial (struct target_ops *self, enum target_object arg1, const > } > > static int > +delegate_can_execute_reverse (struct target_ops *self) > +{ > + self = self->beneath; > + return self->to_can_execute_reverse (self); > +} > + > +static int > +tdefault_can_execute_reverse (struct target_ops *self) > +{ > + return 0; > +} > + > +static enum exec_direction_kind > +delegate_execution_direction (struct target_ops *self) > +{ > + self = self->beneath; > + return self->to_execution_direction (self); > +} > + > +static int > delegate_supports_btrace (struct target_ops *self) > { > self = self->beneath; > @@ -561,16 +672,36 @@ install_delegators (struct target_ops *ops) > ops->to_set_syscall_catchpoint = delegate_set_syscall_catchpoint; > if (ops->to_has_exited == NULL) > ops->to_has_exited = delegate_has_exited; > + if (ops->to_extra_thread_info == NULL) > + ops->to_extra_thread_info = delegate_extra_thread_info; > + if (ops->to_thread_name == NULL) > + ops->to_thread_name = delegate_thread_name; > if (ops->to_rcmd == NULL) > ops->to_rcmd = delegate_rcmd; > + if (ops->to_pid_to_exec_file == NULL) > + ops->to_pid_to_exec_file = delegate_pid_to_exec_file; > + if (ops->to_log_command == NULL) > + ops->to_log_command = delegate_log_command; > if (ops->to_can_async_p == NULL) > ops->to_can_async_p = delegate_can_async_p; > if (ops->to_is_async_p == NULL) > ops->to_is_async_p = delegate_is_async_p; > if (ops->to_async == NULL) > ops->to_async = delegate_async; > + if (ops->to_find_memory_regions == NULL) > + ops->to_find_memory_regions = delegate_find_memory_regions; > + if (ops->to_make_corefile_notes == NULL) > + ops->to_make_corefile_notes = delegate_make_corefile_notes; > + if (ops->to_get_bookmark == NULL) > + ops->to_get_bookmark = delegate_get_bookmark; > + if (ops->to_goto_bookmark == NULL) > + ops->to_goto_bookmark = delegate_goto_bookmark; > if (ops->to_xfer_partial == NULL) > ops->to_xfer_partial = delegate_xfer_partial; > + if (ops->to_can_execute_reverse == NULL) > + ops->to_can_execute_reverse = delegate_can_execute_reverse; > + if (ops->to_execution_direction == NULL) > + ops->to_execution_direction = delegate_execution_direction; > if (ops->to_supports_btrace == NULL) > ops->to_supports_btrace = delegate_supports_btrace; > } > @@ -614,10 +745,20 @@ install_dummy_methods (struct target_ops *ops) > ops->to_remove_exec_catchpoint = tdefault_remove_exec_catchpoint; > ops->to_set_syscall_catchpoint = tdefault_set_syscall_catchpoint; > ops->to_has_exited = tdefault_has_exited; > + ops->to_extra_thread_info = tdefault_extra_thread_info; > + ops->to_thread_name = tdefault_thread_name; > ops->to_rcmd = default_rcmd; > + ops->to_pid_to_exec_file = tdefault_pid_to_exec_file; > + ops->to_log_command = tdefault_log_command; > 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; > + ops->to_find_memory_regions = dummy_find_memory_regions; > + ops->to_make_corefile_notes = dummy_make_corefile_notes; > + ops->to_get_bookmark = tdefault_get_bookmark; > + ops->to_goto_bookmark = tdefault_goto_bookmark; > ops->to_xfer_partial = tdefault_xfer_partial; > + ops->to_can_execute_reverse = tdefault_can_execute_reverse; > + ops->to_execution_direction = default_execution_direction; > ops->to_supports_btrace = tdefault_supports_btrace; > } > diff --git a/gdb/target.c b/gdb/target.c > index 076e4be..604469c 100644 > --- a/gdb/target.c > +++ b/gdb/target.c > @@ -80,10 +80,20 @@ static LONGEST default_xfer_partial (struct target_ops *ops, > static struct gdbarch *default_thread_architecture (struct target_ops *ops, > ptid_t ptid); > > +static int dummy_find_memory_regions (struct target_ops *self, > + find_memory_region_ftype ignore1, > + void *ignore2); > + > +static char *dummy_make_corefile_notes (struct target_ops *self, > + bfd *ignore1, int *ignore2); > + > static int find_default_can_async_p (struct target_ops *ignore); > > static int find_default_is_async_p (struct target_ops *ignore); > > +static enum exec_direction_kind default_execution_direction > + (struct target_ops *self); > + > #include "target-delegates.c" > > static void init_dummy_target (void); > @@ -640,13 +650,13 @@ update_current_target (void) > /* Do not inherit to_thread_alive. */ > /* Do not inherit to_find_new_threads. */ > /* Do not inherit to_pid_to_str. */ > - INHERIT (to_extra_thread_info, t); > - INHERIT (to_thread_name, t); > + /* Do not inherit to_extra_thread_info. */ > + /* Do not inherit to_thread_name. */ > INHERIT (to_stop, t); > /* Do not inherit to_xfer_partial. */ > /* Do not inherit to_rcmd. */ > - INHERIT (to_pid_to_exec_file, t); > - INHERIT (to_log_command, t); > + /* Do not inherit to_pid_to_exec_file. */ > + /* Do not inherit to_log_command. */ > INHERIT (to_stratum, t); > /* Do not inherit to_has_all_memory. */ > /* Do not inherit to_has_memory. */ > @@ -657,13 +667,13 @@ update_current_target (void) > /* Do not inherit to_can_async_p. */ > /* Do not inherit to_is_async_p. */ > /* Do not inherit to_async. */ > - INHERIT (to_find_memory_regions, t); > - INHERIT (to_make_corefile_notes, t); > - INHERIT (to_get_bookmark, t); > - INHERIT (to_goto_bookmark, t); > + /* Do not inherit to_find_memory_regions. */ > + /* Do not inherit to_make_corefile_notes. */ > + /* Do not inherit to_get_bookmark. */ > + /* Do not inherit to_goto_bookmark. */ > /* Do not inherit to_get_thread_local_address. */ > - INHERIT (to_can_execute_reverse, t); > - INHERIT (to_execution_direction, t); > + /* Do not inherit to_can_execute_reverse. */ > + /* Do not inherit to_execution_direction. */ > INHERIT (to_thread_architecture, t); > /* Do not inherit to_read_description. */ > INHERIT (to_get_ada_task_ptid, t); > @@ -731,18 +741,9 @@ update_current_target (void) > de_fault (to_can_run, > (int (*) (struct target_ops *)) > return_zero); > - de_fault (to_extra_thread_info, > - (char *(*) (struct target_ops *, struct thread_info *)) > - return_zero); > - de_fault (to_thread_name, > - (char *(*) (struct target_ops *, struct thread_info *)) > - return_zero); > de_fault (to_stop, > (void (*) (struct target_ops *, ptid_t)) > target_ignore); > - de_fault (to_pid_to_exec_file, > - (char *(*) (struct target_ops *, int)) > - return_zero); > de_fault (to_thread_architecture, > default_thread_architecture); > current_target.to_read_description = NULL; > @@ -859,7 +860,6 @@ update_current_target (void) > de_fault (to_augmented_libraries_svr4_read, > (int (*) (struct target_ops *)) > return_zero); > - de_fault (to_execution_direction, default_execution_direction); > > #undef de_fault > > @@ -2603,15 +2603,7 @@ target_pid_to_str (ptid_t ptid) > char * > target_thread_name (struct thread_info *info) > { > - struct target_ops *t; > - > - for (t = current_target.beneath; t != NULL; t = t->beneath) > - { > - if (t->to_thread_name != NULL) > - return (*t->to_thread_name) (t, info); > - } > - > - return NULL; > + return current_target.to_thread_name (¤t_target, info); > } > > void > @@ -3611,21 +3603,6 @@ dummy_make_corefile_notes (struct target_ops *self, > return NULL; > } > > -/* Error-catcher for target_get_bookmark. */ > -static gdb_byte * > -dummy_get_bookmark (struct target_ops *self, char *ignore1, int ignore2) > -{ > - tcomplain (); > - return NULL; > -} > - > -/* Error-catcher for target_goto_bookmark. */ > -static void > -dummy_goto_bookmark (struct target_ops *self, gdb_byte *ignore, int from_tty) > -{ > - tcomplain (); > -} > - > /* Set up the handful of non-empty slots needed by the dummy target > vector. */ > > @@ -3641,10 +3618,6 @@ init_dummy_target (void) > = find_default_supports_disable_randomization; > dummy_target.to_pid_to_str = dummy_pid_to_str; > dummy_target.to_stratum = dummy_stratum; > - dummy_target.to_find_memory_regions = dummy_find_memory_regions; > - dummy_target.to_make_corefile_notes = dummy_make_corefile_notes; > - dummy_target.to_get_bookmark = dummy_get_bookmark; > - dummy_target.to_goto_bookmark = dummy_goto_bookmark; > dummy_target.to_has_all_memory = (int (*) (struct target_ops *)) return_zero; > dummy_target.to_has_memory = (int (*) (struct target_ops *)) return_zero; > dummy_target.to_has_stack = (int (*) (struct target_ops *)) return_zero; > diff --git a/gdb/target.h b/gdb/target.h > index 6a563f7..bc2dc6a 100644 > --- a/gdb/target.h > +++ b/gdb/target.h > @@ -537,14 +537,18 @@ struct target_ops > int (*to_thread_alive) (struct target_ops *, ptid_t ptid); > void (*to_find_new_threads) (struct target_ops *); > char *(*to_pid_to_str) (struct target_ops *, ptid_t); > - char *(*to_extra_thread_info) (struct target_ops *, struct thread_info *); > - char *(*to_thread_name) (struct target_ops *, struct thread_info *); > + char *(*to_extra_thread_info) (struct target_ops *, struct thread_info *) > + TARGET_DEFAULT_RETURN (0); > + char *(*to_thread_name) (struct target_ops *, struct thread_info *) > + TARGET_DEFAULT_RETURN (0); > void (*to_stop) (struct target_ops *, ptid_t); > void (*to_rcmd) (struct target_ops *, > 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 *); > + char *(*to_pid_to_exec_file) (struct target_ops *, int pid) > + TARGET_DEFAULT_RETURN (0); > + void (*to_log_command) (struct target_ops *, const char *) > + TARGET_DEFAULT_IGNORE (); > struct target_section_table *(*to_get_section_table) (struct target_ops *); > enum strata to_stratum; > int (*to_has_all_memory) (struct target_ops *); > @@ -564,13 +568,17 @@ struct target_ops > int (*to_supports_non_stop) (struct target_ops *); > /* find_memory_regions support method for gcore */ > int (*to_find_memory_regions) (struct target_ops *, > - find_memory_region_ftype func, void *data); > + find_memory_region_ftype func, void *data) > + TARGET_DEFAULT_FUNC (dummy_find_memory_regions); > /* make_corefile_notes support method for gcore */ > - char * (*to_make_corefile_notes) (struct target_ops *, bfd *, int *); > + char * (*to_make_corefile_notes) (struct target_ops *, bfd *, int *) > + TARGET_DEFAULT_FUNC (dummy_make_corefile_notes); > /* get_bookmark support method for bookmarks */ > - gdb_byte * (*to_get_bookmark) (struct target_ops *, char *, int); > + gdb_byte * (*to_get_bookmark) (struct target_ops *, char *, int) > + TARGET_DEFAULT_NORETURN (tcomplain ()); > /* goto_bookmark support method for bookmarks */ > - void (*to_goto_bookmark) (struct target_ops *, gdb_byte *, int); > + void (*to_goto_bookmark) (struct target_ops *, gdb_byte *, int) > + TARGET_DEFAULT_NORETURN (tcomplain ()); > /* Return the thread-local address at OFFSET in the > thread-local storage for the thread PTID and the shared library > or executable file given by OBJFILE. If that block of > @@ -675,12 +683,14 @@ struct target_ops > CORE_ADDR *found_addrp); > > /* Can target execute in reverse? */ > - int (*to_can_execute_reverse) (struct target_ops *); > + int (*to_can_execute_reverse) (struct target_ops *) > + TARGET_DEFAULT_RETURN (0); > > /* The direction the target is currently executing. Must be > implemented on targets that support reverse execution and async > mode. The default simply returns forward execution. */ > - enum exec_direction_kind (*to_execution_direction) (struct target_ops *); > + enum exec_direction_kind (*to_execution_direction) (struct target_ops *) > + TARGET_DEFAULT_FUNC (default_execution_direction); > > /* Does this target support debugging multiple processes > simultaneously? */ > @@ -1711,8 +1721,7 @@ extern int target_masked_watch_num_registers (CORE_ADDR addr, CORE_ADDR mask); > > /* Target can execute in reverse? */ > #define target_can_execute_reverse \ > - (current_target.to_can_execute_reverse ? \ > - current_target.to_can_execute_reverse (¤t_target) : 0) > + current_target.to_can_execute_reverse (¤t_target) > > extern const struct target_desc *target_read_description (struct target_ops *); > > @@ -1887,12 +1896,8 @@ extern char *target_fileio_read_stralloc (const char *filename); > > /* Command logging facility. */ > > -#define target_log_command(p) \ > - do \ > - if (current_target.to_log_command) \ > - (*current_target.to_log_command) (¤t_target, \ > - p); \ > - while (0) > +#define target_log_command(p) \ > + (*current_target.to_log_command) (¤t_target, p) > > > extern int target_core_of_thread (ptid_t ptid); > -- Pedro Alves