From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC v2 38/38] convert to_get_unwinder and to_get_tailcall_unwinder to methods
Date: Fri, 07 Feb 2014 16:02:00 -0000 [thread overview]
Message-ID: <52F503A4.9010102@redhat.com> (raw)
In-Reply-To: <1391720136-2121-39-git-send-email-tromey@redhat.com>
Looks fine.
On 02/06/2014 08:55 PM, Tom Tromey wrote:
> This converts to_get_unwinder and to_get_tailcall_unwinder to methods
> and arranges for them to use the new delegation scheme.
>
> This just lets us avoid having a differing style (neither new-style
> nor INHERIT) of delegation in the tree.
>
> 2014-02-06 Tom Tromey <tromey@redhat.com>
>
> * target.c (target_get_unwinder): Rewrite.
> (target_get_tailcall_unwinder): Rewrite.
> * record-btrace.c (record_btrace_to_get_unwinder): New function.
> (record_btrace_to_get_tailcall_unwinder): New function.
> (init_record_btrace_ops): Update.
> * target.h (struct target_ops) <to_get_unwinder,
> to_get_tailcall_unwinder>: Now function pointers. Use
> TARGET_DEFAULT_RETURN.
> ---
> gdb/ChangeLog | 11 +++++++++++
> gdb/record-btrace.c | 20 ++++++++++++++++++--
> gdb/target-delegates.c | 32 ++++++++++++++++++++++++++++++++
> gdb/target.c | 16 ++--------------
> gdb/target.h | 12 ++++++++----
> 5 files changed, 71 insertions(+), 20 deletions(-)
>
> diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
> index c4872eb..ab288ef 100644
> --- a/gdb/record-btrace.c
> +++ b/gdb/record-btrace.c
> @@ -1302,6 +1302,22 @@ const struct frame_unwind record_btrace_tailcall_frame_unwind =
> record_btrace_frame_dealloc_cache
> };
>
> +/* Implement the to_get_unwinder method. */
> +
> +static const struct frame_unwind *
> +record_btrace_to_get_unwinder (struct target_ops *self)
> +{
> + return &record_btrace_frame_unwind;
> +}
> +
> +/* Implement the to_get_tailcall_unwinder method. */
> +
> +static const struct frame_unwind *
> +record_btrace_to_get_tailcall_unwinder (struct target_ops *self)
> +{
> + return &record_btrace_tailcall_frame_unwind;
> +}
> +
> /* Indicate that TP should be resumed according to FLAG. */
>
> static void
> @@ -1888,8 +1904,8 @@ init_record_btrace_ops (void)
> ops->to_fetch_registers = record_btrace_fetch_registers;
> ops->to_store_registers = record_btrace_store_registers;
> ops->to_prepare_to_store = record_btrace_prepare_to_store;
> - ops->to_get_unwinder = &record_btrace_frame_unwind;
> - ops->to_get_tailcall_unwinder = &record_btrace_tailcall_frame_unwind;
> + ops->to_get_unwinder = &record_btrace_to_get_unwinder;
> + ops->to_get_tailcall_unwinder = &record_btrace_to_get_tailcall_unwinder;
> ops->to_resume = record_btrace_resume;
> ops->to_wait = record_btrace_wait;
> ops->to_find_new_threads = record_btrace_find_new_threads;
> diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
> index d9c68cd..03b0d2a 100644
> --- a/gdb/target-delegates.c
> +++ b/gdb/target-delegates.c
> @@ -1572,6 +1572,32 @@ tdefault_augmented_libraries_svr4_read (struct target_ops *self)
> return 0;
> }
>
> +static const struct frame_unwind *
> +delegate_get_unwinder (struct target_ops *self)
> +{
> + self = self->beneath;
> + return self->to_get_unwinder (self);
> +}
> +
> +static const struct frame_unwind *
> +tdefault_get_unwinder (struct target_ops *self)
> +{
> + return NULL;
> +}
> +
> +static const struct frame_unwind *
> +delegate_get_tailcall_unwinder (struct target_ops *self)
> +{
> + self = self->beneath;
> + return self->to_get_tailcall_unwinder (self);
> +}
> +
> +static const struct frame_unwind *
> +tdefault_get_tailcall_unwinder (struct target_ops *self)
> +{
> + return NULL;
> +}
> +
> static CORE_ADDR
> delegate_decr_pc_after_break (struct target_ops *self, struct gdbarch *arg1)
> {
> @@ -1844,6 +1870,10 @@ install_delegators (struct target_ops *ops)
> ops->to_call_history_range = delegate_call_history_range;
> if (ops->to_augmented_libraries_svr4_read == NULL)
> ops->to_augmented_libraries_svr4_read = delegate_augmented_libraries_svr4_read;
> + if (ops->to_get_unwinder == NULL)
> + ops->to_get_unwinder = delegate_get_unwinder;
> + if (ops->to_get_tailcall_unwinder == NULL)
> + ops->to_get_tailcall_unwinder = delegate_get_tailcall_unwinder;
> if (ops->to_decr_pc_after_break == NULL)
> ops->to_decr_pc_after_break = delegate_decr_pc_after_break;
> }
> @@ -1982,5 +2012,7 @@ install_dummy_methods (struct target_ops *ops)
> ops->to_call_history_from = tdefault_call_history_from;
> ops->to_call_history_range = tdefault_call_history_range;
> ops->to_augmented_libraries_svr4_read = tdefault_augmented_libraries_svr4_read;
> + ops->to_get_unwinder = tdefault_get_unwinder;
> + ops->to_get_tailcall_unwinder = tdefault_get_tailcall_unwinder;
> ops->to_decr_pc_after_break = default_target_decr_pc_after_break;
> }
> diff --git a/gdb/target.c b/gdb/target.c
> index 72d5a09..d03c4fb 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -3761,13 +3761,7 @@ debug_to_prepare_to_store (struct target_ops *self, struct regcache *regcache)
> const struct frame_unwind *
> target_get_unwinder (void)
> {
> - struct target_ops *t;
> -
> - for (t = current_target.beneath; t != NULL; t = t->beneath)
> - if (t->to_get_unwinder != NULL)
> - return t->to_get_unwinder;
> -
> - return NULL;
> + return current_target.to_get_unwinder (¤t_target);
> }
>
> /* See target.h. */
> @@ -3775,13 +3769,7 @@ target_get_unwinder (void)
> const struct frame_unwind *
> target_get_tailcall_unwinder (void)
> {
> - struct target_ops *t;
> -
> - for (t = current_target.beneath; t != NULL; t = t->beneath)
> - if (t->to_get_tailcall_unwinder != NULL)
> - return t->to_get_tailcall_unwinder;
> -
> - return NULL;
> + return current_target.to_get_tailcall_unwinder (¤t_target);
> }
>
> /* Default implementation of to_decr_pc_after_break. */
> diff --git a/gdb/target.h b/gdb/target.h
> index c988a01..58519b0 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -1095,10 +1095,14 @@ struct target_ops
> int (*to_augmented_libraries_svr4_read) (struct target_ops *)
> TARGET_DEFAULT_RETURN (0);
>
> - /* Those unwinders are tried before any other arch unwinders. Use NULL if
> - it is not used. */
> - const struct frame_unwind *to_get_unwinder;
> - const struct frame_unwind *to_get_tailcall_unwinder;
> + /* Those unwinders are tried before any other arch unwinders. If
> + SELF doesn't have unwinders, it should delegate to the
> + "beneath" target. */
> + const struct frame_unwind *(*to_get_unwinder) (struct target_ops *self)
> + TARGET_DEFAULT_RETURN (NULL);
> +
> + const struct frame_unwind *(*to_get_tailcall_unwinder) (struct target_ops *self)
> + TARGET_DEFAULT_RETURN (NULL);
>
> /* Return the number of bytes by which the PC needs to be decremented
> after executing a breakpoint instruction.
>
--
Pedro Alves
next prev parent reply other threads:[~2014-02-07 16:02 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
2014-02-06 20:55 ` [RFC v2 02/38] introduce and use find_target_at Tom Tromey
2014-02-07 15:43 ` Pedro Alves
2014-02-07 21:54 ` Tom Tromey
2014-02-10 14:28 ` Pedro Alves
2014-02-06 20:55 ` [RFC v2 08/38] Add target_ops argument to to_terminal_init Tom Tromey
2014-02-06 20:55 ` [RFC v2 09/38] Add target_ops argument to to_insert_vfork_catchpoint Tom Tromey
2014-02-06 20:55 ` [RFC v2 03/38] add make-target-delegates Tom Tromey
2014-02-06 20:55 ` [RFC v2 16/38] Add target_ops argument to to_static_tracepoint_markers_by_strid Tom Tromey
2014-02-06 20:56 ` [RFC v2 24/38] convert to_upload_trace_state_variables Tom Tromey
2014-02-06 20:56 ` [RFC v2 32/38] remove function casts from target.c Tom Tromey
2014-02-06 20:56 ` [RFC v2 36/38] convert to_decr_pc_after_break Tom Tromey
2014-02-06 20:56 ` [RFC v2 26/38] convert to_insert_mask_watchpoint Tom Tromey
2014-02-06 20:56 ` [RFC v2 34/38] remove exec_set_find_memory_regions Tom Tromey
2014-02-06 20:56 ` [RFC v2 21/38] convert to_extra_thread_info Tom Tromey
2014-02-06 20:56 ` [RFC v2 10/38] Add target_ops argument to to_thread_name Tom Tromey
2014-02-06 20:56 ` [RFC v2 28/38] convert to_insn_history Tom Tromey
2014-02-06 20:56 ` [RFC v2 23/38] convert to_disable_tracepoint Tom Tromey
2014-02-06 20:56 ` [RFC v2 27/38] convert to_get_section_table Tom Tromey
2014-02-06 20:56 ` [RFC v2 37/38] fix buglet in nto-procfs.c Tom Tromey
2014-02-07 16:01 ` Pedro Alves
2014-02-06 20:56 ` [RFC v2 07/38] Add target_ops argument to to_close Tom Tromey
2014-02-08 3:00 ` Yao Qi
2014-02-10 17:50 ` Tom Tromey
2014-02-06 20:56 ` [RFC v2 29/38] convert to_search_memory Tom Tromey
2014-02-06 20:56 ` [RFC v2 22/38] convert to_thread_architecture Tom Tromey
2014-02-06 20:56 ` [RFC v2 01/38] add "this" pointers to more target APIs Tom Tromey
2014-02-08 5:19 ` Doug Evans
2014-02-10 22:36 ` Doug Evans
2014-02-10 23:01 ` Doug Evans
2014-02-12 19:56 ` Tom Tromey
2014-02-12 20:22 ` Doug Evans
2014-02-06 20:56 ` [RFC v2 35/38] remove some calls to INHERIT and de_fault Tom Tromey
2014-02-06 20:58 ` [RFC v2 20/38] convert to_load Tom Tromey
2014-02-06 20:58 ` [RFC v2 04/38] add target method delegation Tom Tromey
2014-02-07 15:53 ` Pedro Alves
2014-02-07 21:37 ` Tom Tromey
2014-02-06 20:58 ` [RFC v2 17/38] Add target_ops argument to to_save_record Tom Tromey
2014-02-06 20:58 ` [RFC v2 11/38] Add target_ops argument to to_get_ada_task_ptid Tom Tromey
2014-02-06 20:58 ` [RFC v2 25/38] convert to_static_tracepoint_markers_by_strid Tom Tromey
2014-02-06 21:23 ` [RFC v2 15/38] Add target_ops argument to to_upload_trace_state_variables Tom Tromey
2014-02-06 21:23 ` [RFC v2 19/38] convert to_remove_watchpoint Tom Tromey
2014-02-06 21:23 ` [RFC v2 12/38] Add target_ops argument to to_can_execute_reverse Tom Tromey
2014-02-06 21:23 ` [RFC v2 06/38] introduce remote_load Tom Tromey
2014-02-06 21:24 ` [RFC v2 05/38] convert to_supports_btrace Tom Tromey
2014-02-06 21:24 ` [RFC v2 14/38] Add target_ops argument to to_disable_tracepoint Tom Tromey
2014-02-06 21:24 ` [RFC v2 13/38] Add target_ops argument to to_fileio_pwrite Tom Tromey
2014-02-06 21:24 ` [RFC v2 31/38] minor cleanups to update_current_target Tom Tromey
2014-02-06 21:38 ` [RFC v2 33/38] pass NULL to TARGET_DEFAULT_RETURN when appropriate Tom Tromey
2014-02-06 21:38 ` [RFC v2 30/38] change delegation for to_read_description Tom Tromey
2014-02-06 21:42 ` [RFC v2 18/38] convert to_detach Tom Tromey
2014-02-06 21:47 ` [RFC v2 38/38] convert to_get_unwinder and to_get_tailcall_unwinder to methods Tom Tromey
2014-02-07 16:02 ` Pedro Alves [this message]
2014-02-07 16:47 ` [RFC v2 00/38] clean up target delegation Pedro Alves
2014-02-19 16:35 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52F503A4.9010102@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox