This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] btrace, gdbserver: check btrace target pointers
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: Markus Metzger <markus dot t dot metzger at intel dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 28 Feb 2018 16:25:50 +0000
- Subject: Re: [PATCH] btrace, gdbserver: check btrace target pointers
- Authentication-results: sourceware.org; auth=none
- References: <1519727985-17914-1-git-send-email-markus.t.metzger@intel.com>
Markus Metzger <markus.t.metzger@intel.com> writes:
> -#define target_enable_btrace(ptid, conf) \
> - (*the_target->enable_btrace) (ptid, conf)
> +static inline struct btrace_target_info *
> +target_enable_btrace (ptid_t ptid, const struct btrace_config *conf)
> +{
> + if (the_target->enable_btrace == nullptr)
> + error ("Target does not support branch tracing.");
> +
> + return (*the_target->enable_btrace) (ptid, conf);
> +}
It is reasonable to me that (*the_target->enable_btrace) may throw
various exceptions due to different reasons, but I am not convinced that
we should error on (the_target->enable_btrace == nullptr). I don't like
replacing control flow logic with exception. This is my personal
flavor. Instead, can we check
(the_target->enable_btrace == nullptr) before using
target_enable_btrace, and error in handle_btrace_general_set if
thread->btrace is NULL. What do you think?
--
Yao (齐尧)