Re: [patch v9 07/23] gdbserver, btrace: add generic btrace support

Jan Kratochvil
2013-03-05T20:08:53Z

On Mon, 04 Mar 2013 18:05:54 +0100, Markus Metzger wrote:
> Add support to gdbserver to understand branch trace related packages.
>
> 2013-03-04 Markus Metzger <markus.t.metzger@intel.com>
>
> gdbserver/
> * target.h (struct target_ops): Add btrace ops.
> (target_supports_btrace): New macro.
> (target_btrace_has_changed): New macro.
> (target_enable_btrace): New macro.
> (target_disable_btrace): New macro.
> (target_read_btrace): New macro.
> * gdbthread.h (struct thread_info): Add btrace field.
> * server.c (handle_btrace_general_set): New function.
> (handle_btrace_enable): New function.
> (handle_btrace_disable): New function.
> (handle_general_set): Call handle_btrace_general_set.
> (handle_qxfer_btrace): New function.
> (struct qxfer qxfer_packets[]): Add btrace entry.
> (handle_btrace_query): New function.
> (handle_query): Add btrace to supported query, call handle_btrace_query.
> * inferiors.c (remove_thread): Disable btrace.
[...]
> +/* Handle the "Qbtrace" packet. */
> +
> +static int
> +handle_btrace_general_set (char *own_buf)
> +{
> + struct thread_info *thread;
> + const char *err;
> + char *op;
> +
> + if (strncmp ("Qbtrace:", own_buf, strlen ("Qbtrace:")) != 0)
> + return 0;
> +
> + op = own_buf + strlen ("Qbtrace:");
> +
> + if (!target_supports_btrace ())
> + {
> + strcpy (own_buf, "E.Target does not support branch tracing.");
> + return -1;
> + }
> +
> + if (ptid_equal (general_thread, null_ptid)
> + || ptid_equal (general_thread, minus_one_ptid))
> + {
> + strcpy (own_buf, "E.Must select a single thread.");
> + return -1;
> + }
> +
> + thread = find_thread_ptid (general_thread);
> + if (thread == NULL)
> + {
> + strcpy (own_buf, "E.No such thread.");
> + return -1;
> + }
> +
> + err = NULL;
> +
> + if (strcmp (op, "on") == 0)
> + err = handle_btrace_enable (thread);

Again not merged.

> + else if (strcmp (op, "off") == 0)
> + err = handle_btrace_disable (thread);
> + else
> + err = "E.Bad Qbtrace operation. Use on or off.";
> +
> + if (err != 0)
> + strcpy (own_buf, err);
> + else
> + write_ok (own_buf);
> +
> + return 1;
> +}
> +

Reviewed by Pedro.

Thanks,
Jan