diff options
author | Markus Metzger <markus.t.metzger@intel.com> | 2014-01-17 13:29:19 +0100 |
---|---|---|
committer | Markus Metzger <markus.t.metzger@intel.com> | 2015-02-09 09:31:14 +0100 |
commit | 043c35779713a14e0916a1b3e31e006cd1270ee4 (patch) | |
tree | 78cc293d4bfbd43ae860a32373ab7721542fe5ea /gdb/nat/linux-btrace.c | |
parent | 734b0e4bda4c56d0003182cdc3f5137d4bea00d4 (diff) | |
download | binutils-gdb-043c35779713a14e0916a1b3e31e006cd1270ee4.tar.gz |
btrace: add format argument to supports_btrace
Add a format argument to the various supports_btrace functions to check
for support of a specific btrace format. This is to prepare for a new
format.
Removed two redundant calls. The check will be made in the subsequent
btrace_enable call.
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.
gdbserver/
* 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.
Diffstat (limited to 'gdb/nat/linux-btrace.c')
-rw-r--r-- | gdb/nat/linux-btrace.c | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c index 6cec5d04c10..08eb49b31c8 100644 --- a/gdb/nat/linux-btrace.c +++ b/gdb/nat/linux-btrace.c @@ -248,10 +248,10 @@ perf_event_read_bts (struct btrace_target_info* tinfo, const uint8_t *begin, 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; @@ -262,14 +262,14 @@ kernel_supports_btrace (void) 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); } @@ -277,7 +277,7 @@ kernel_supports_btrace (void) 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); } @@ -288,14 +288,14 @@ kernel_supports_btrace (void) 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; } @@ -320,10 +320,10 @@ kernel_supports_btrace (void) 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); } @@ -331,10 +331,10 @@ kernel_supports_btrace (void) } } -/* 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; @@ -372,10 +372,10 @@ intel_supports_btrace (void) 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; @@ -384,24 +384,24 @@ cpu_supports_btrace (void) 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; @@ -412,6 +412,23 @@ linux_supports_btrace (struct target_ops *ops) /* 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) { @@ -602,7 +619,7 @@ linux_read_btrace (struct btrace_data *btrace, /* 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; } |