2015-02-09 Markus Metzger <markus.t.metzger@intel.com>
+ * btrace.c (btrace_enable): Pass BTRACE_FORMAT_BTS.
+ * record-btrace.c (record_btrace_open): Remove call to
+ target_supports_btrace.
+ * remote.c (remote_supports_btrace): Update parameters.
+ * target.c (target_supports_btrace): Update parameters.
+ * target.h (to_supports_btrace, target_supports_btrace): Update
+ parameters.
+ * target-delegates.c: Regenerate.
+ * target-debug.h (target_debug_print_enum_btrace_format): New.
+ * nat/linux-btrace.c
+ (kernel_supports_btrace): Rename into ...
+ (kernel_supports_bts): ... this. Update users. Update warning text.
+ (intel_supports_btrace): Rename into ...
+ (intel_supports_bts): ... this. Update users.
+ (cpu_supports_btrace): Rename into ...
+ (cpu_supports_bts): ... this. Update users.
+ (linux_supports_btrace): Update parameters. Split into this and ...
+ (linux_supports_bts): ... this.
+ * nat/linux-btrace.h (linux_supports_btrace): Update parameters.
+
+2015-02-09 Markus Metzger <markus.t.metzger@intel.com>
+
* Makefile.in (SFILES): Add common/btrace-common.c.
(COMMON_OBS): Add common/btrace-common.o.
(btrace-common.o): Add build rules.
if (tp->btrace.target != NULL)
return;
- if (!target_supports_btrace ())
+ if (!target_supports_btrace (BTRACE_FORMAT_BTS))
error (_("Target does not support branch tracing."));
DEBUG ("enable thread %d (%s)", tp->num, target_pid_to_str (tp->ptid));
2015-02-09 Markus Metzger <markus.t.metzger@intel.com>
+ * server.c (handle_btrace_general_set): Remove call to
+ target_supports_btrace.
+ (supported_btrace_packets): New.
+ (handle_query): Call supported_btrace_packets.
+ * target.h: include btrace-common.h.
+ (btrace_target_info): Removed.
+ (supports_btrace, target_supports_btrace): Update parameters.
+
+2015-02-09 Markus Metzger <markus.t.metzger@intel.com>
+
* Makefile.in (SFILES): Add common/btrace-common.c.
(OBS): Add common/btrace-common.o.
(btrace-common.o): Add build rules.
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))
{
return (unsigned long long) crc;
}
+/* Add supported btrace packets to BUF. */
+
+static void
+supported_btrace_packets (char *buf)
+{
+ if (target_supports_btrace (BTRACE_FORMAT_BTS))
+ strcat (buf, ";Qbtrace:bts+");
+ else
+ return;
+
+ strcat (buf, ";Qbtrace:off+");
+ strcat (buf, ";qXfer:btrace:read+");
+}
+
/* Handle all of the extended 'q' packets. */
void
if (target_supports_agent ())
strcat (own_buf, ";QAgent+");
- if (target_supports_btrace ())
- {
- strcat (own_buf, ";Qbtrace:bts+");
- strcat (own_buf, ";Qbtrace:off+");
- strcat (own_buf, ";qXfer:btrace:read+");
- }
+ supported_btrace_packets (own_buf);
return;
}
#include "target/wait.h"
#include "target/waitstatus.h"
#include "mem-break.h"
+#include "btrace-common.h"
struct emit_ops;
-struct btrace_target_info;
struct buffer;
struct process_info;
int (*supports_agent) (void);
/* Check whether the target supports branch tracing. */
- int (*supports_btrace) (struct target_ops *);
+ int (*supports_btrace) (struct target_ops *, enum btrace_format);
/* Enable branch tracing for @ptid and allocate a branch trace target
information struct for reading and for disabling branch trace. */
(the_target->supports_agent ? \
(*the_target->supports_agent) () : 0)
-#define target_supports_btrace() \
+#define target_supports_btrace(format) \
(the_target->supports_btrace \
- ? (*the_target->supports_btrace) (the_target) : 0)
+ ? (*the_target->supports_btrace) (the_target, format) : 0)
#define target_enable_btrace(ptid) \
(*the_target->enable_btrace) (ptid)
return btrace;
}
-/* Check whether the kernel supports branch tracing. */
+/* Check whether the kernel supports BTS. */
static int
-kernel_supports_btrace (void)
+kernel_supports_bts (void)
{
struct perf_event_attr attr;
pid_t child, pid;
switch (child)
{
case -1:
- warning (_("test branch tracing: cannot fork: %s."), strerror (errno));
+ warning (_("test bts: cannot fork: %s."), strerror (errno));
return 0;
case 0:
status = ptrace (PTRACE_TRACEME, 0, NULL, NULL);
if (status != 0)
{
- warning (_("test branch tracing: cannot PTRACE_TRACEME: %s."),
+ warning (_("test bts: cannot PTRACE_TRACEME: %s."),
strerror (errno));
_exit (1);
}
status = raise (SIGTRAP);
if (status != 0)
{
- warning (_("test branch tracing: cannot raise SIGTRAP: %s."),
+ warning (_("test bts: cannot raise SIGTRAP: %s."),
strerror (errno));
_exit (1);
}
pid = waitpid (child, &status, 0);
if (pid != child)
{
- warning (_("test branch tracing: bad pid %ld, error: %s."),
+ warning (_("test bts: bad pid %ld, error: %s."),
(long) pid, strerror (errno));
return 0;
}
if (!WIFSTOPPED (status))
{
- warning (_("test branch tracing: expected stop. status: %d."),
+ warning (_("test bts: expected stop. status: %d."),
status);
return 0;
}
pid = waitpid (child, &status, 0);
if (pid != child)
{
- warning (_("test branch tracing: bad pid %ld, error: %s."),
+ warning (_("test bts: bad pid %ld, error: %s."),
(long) pid, strerror (errno));
if (!WIFSIGNALED (status))
- warning (_("test branch tracing: expected killed. status: %d."),
+ warning (_("test bts: expected killed. status: %d."),
status);
}
}
}
-/* Check whether an Intel cpu supports branch tracing. */
+/* Check whether an Intel cpu supports BTS. */
static int
-intel_supports_btrace (void)
+intel_supports_bts (void)
{
unsigned int cpuid, model, family;
return 1;
}
-/* Check whether the cpu supports branch tracing. */
+/* Check whether the cpu supports BTS. */
static int
-cpu_supports_btrace (void)
+cpu_supports_bts (void)
{
unsigned int ebx, ecx, edx;
if (ebx == signature_INTEL_ebx && ecx == signature_INTEL_ecx
&& edx == signature_INTEL_edx)
- return intel_supports_btrace ();
+ return intel_supports_bts ();
/* Don't know about others. Let's assume they do. */
return 1;
}
-/* See linux-btrace.h. */
+/* Check whether the linux target supports BTS. */
-int
-linux_supports_btrace (struct target_ops *ops)
+static int
+linux_supports_bts (void)
{
static int cached;
if (cached == 0)
{
- if (!kernel_supports_btrace ())
+ if (!kernel_supports_bts ())
cached = -1;
- else if (!cpu_supports_btrace ())
+ else if (!cpu_supports_bts ())
cached = -1;
else
cached = 1;
/* See linux-btrace.h. */
+int
+linux_supports_btrace (struct target_ops *ops, enum btrace_format format)
+{
+ switch (format)
+ {
+ case BTRACE_FORMAT_NONE:
+ return 0;
+
+ case BTRACE_FORMAT_BTS:
+ return linux_supports_bts ();
+ }
+
+ internal_error (__FILE__, __LINE__, _("Unknown branch trace format"));
+}
+
+/* See linux-btrace.h. */
+
struct btrace_target_info *
linux_enable_btrace (ptid_t ptid)
{
/* See linux-btrace.h. */
int
-linux_supports_btrace (struct target_ops *ops)
+linux_supports_btrace (struct target_ops *ops, enum btrace_format format)
{
return 0;
}
};
/* See to_supports_btrace in target.h. */
-extern int linux_supports_btrace (struct target_ops *);
+extern int linux_supports_btrace (struct target_ops *, enum btrace_format);
/* See to_enable_btrace in target.h. */
extern struct btrace_target_info *linux_enable_btrace (ptid_t ptid);
if (!target_has_execution)
error (_("The program is not being run."));
- if (!target_supports_btrace ())
- error (_("Target does not support branch tracing."));
-
if (non_stop)
error (_("Record btrace can't debug inferior in non-stop mode."));
/* Check whether the target supports branch tracing. */
static int
-remote_supports_btrace (struct target_ops *self)
+remote_supports_btrace (struct target_ops *self, enum btrace_format format)
{
if (packet_support (PACKET_Qbtrace_off) != PACKET_ENABLE)
return 0;
- if (packet_support (PACKET_Qbtrace_bts) != PACKET_ENABLE)
- return 0;
if (packet_support (PACKET_qXfer_btrace) != PACKET_ENABLE)
return 0;
- return 1;
+ switch (format)
+ {
+ case BTRACE_FORMAT_NONE:
+ return 0;
+
+ case BTRACE_FORMAT_BTS:
+ return (packet_support (PACKET_Qbtrace_bts) == PACKET_ENABLE);
+ }
+
+ internal_error (__FILE__, __LINE__, _("Unknown branch trace format"));
}
/* Enable branch tracing. */
target_debug_do_print (host_address_to_string (X))
#define target_debug_print_struct_btrace_data_p(X) \
target_debug_do_print (host_address_to_string (X))
+#define target_debug_print_enum_btrace_format(X) \
+ target_debug_do_print (plongest (X))
static void
target_debug_print_struct_target_waitstatus_p (struct target_waitstatus *status)
}
static int
-delegate_supports_btrace (struct target_ops *self)
+delegate_supports_btrace (struct target_ops *self, enum btrace_format arg1)
{
self = self->beneath;
- return self->to_supports_btrace (self);
+ return self->to_supports_btrace (self, arg1);
}
static int
-tdefault_supports_btrace (struct target_ops *self)
+tdefault_supports_btrace (struct target_ops *self, enum btrace_format arg1)
{
return 0;
}
static int
-debug_supports_btrace (struct target_ops *self)
+debug_supports_btrace (struct target_ops *self, enum btrace_format arg1)
{
int result;
fprintf_unfiltered (gdb_stdlog, "-> %s->to_supports_btrace (...)\n", debug_target.to_shortname);
- result = debug_target.to_supports_btrace (&debug_target);
+ result = debug_target.to_supports_btrace (&debug_target, arg1);
fprintf_unfiltered (gdb_stdlog, "<- %s->to_supports_btrace (", debug_target.to_shortname);
target_debug_print_struct_target_ops_p (&debug_target);
+ fputs_unfiltered (", ", gdb_stdlog);
+ target_debug_print_enum_btrace_format (arg1);
fputs_unfiltered (") = ", gdb_stdlog);
target_debug_print_int (result);
fputs_unfiltered ("\n", gdb_stdlog);
/* See target.h. */
+int
+target_supports_btrace (enum btrace_format format)
+{
+ return current_target.to_supports_btrace (¤t_target, format);
+}
+
+/* See target.h. */
+
struct btrace_target_info *
target_enable_btrace (ptid_t ptid)
{
TARGET_DEFAULT_RETURN (0);
/* Check whether the target supports branch tracing. */
- int (*to_supports_btrace) (struct target_ops *)
+ int (*to_supports_btrace) (struct target_ops *, enum btrace_format)
TARGET_DEFAULT_RETURN (0);
/* Enable branch tracing for PTID and allocate a branch trace target
/* Imported from machine dependent code. */
/* See to_supports_btrace in struct target_ops. */
-#define target_supports_btrace() \
- (current_target.to_supports_btrace (¤t_target))
+extern int target_supports_btrace (enum btrace_format);
/* See to_enable_btrace in struct target_ops. */
extern struct btrace_target_info *target_enable_btrace (ptid_t ptid);