Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1216685
| From | tip-bot for Stephane Eranian <tipbot@zytor.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [tip:perf/urgent] perf script: Enable printing of interrupted machine state |
| Date | 2015-09-01 10:40 +0200 |
| Message-ID | <q3PgM-1hp-45@gated-at.bofh.it> (permalink) |
| References | <q3Arq-50w-35@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Commit-ID: fc36f9485aee3a62b22be1f561543a31bce6d48e
Gitweb: http://git.kernel.org/tip/fc36f9485aee3a62b22be1f561543a31bce6d48e
Author: Stephane Eranian <eranian@google.com>
AuthorDate: Mon, 31 Aug 2015 18:41:10 +0200
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 31 Aug 2015 17:51:07 -0300
perf script: Enable printing of interrupted machine state
This patch adds the output of the interrupted machine state (iregs) to
perf script. It presents them as NAME:VALUE so this is easy to parse
during post processing.
To capture the interrupted machine state:
$ perf record -I ....
to display iregs, use the -F option:
$ perf script -F ip,iregs
40afc2 AX:0x6c5770 BX:0x1e CX:0x5f4d80a DX:0x101010101010101 SI:0x1
Signed-off-by: Stephane Eranian <eranian@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1441039273-16260-2-git-send-email-eranian@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/Documentation/perf-script.txt | 2 +-
tools/perf/builtin-script.c | 31 ++++++++++++++++++++++++++++++-
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index 614b2c7..dc3ec78 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -116,7 +116,7 @@ OPTIONS
--fields::
Comma separated list of fields to print. Options are:
comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff,
- srcline, period, flags.
+ srcline, period, iregs, flags.
Field list can be prepended with the type, trace, sw or hw,
to indicate to which event type the field list applies.
e.g., -f sw:comm,tid,time,ip,sym and -f trace:time,cpu,trace
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 4430340..eb51325 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -6,6 +6,7 @@
#include "util/exec_cmd.h"
#include "util/header.h"
#include "util/parse-options.h"
+#include "util/perf_regs.h"
#include "util/session.h"
#include "util/tool.h"
#include "util/symbol.h"
@@ -46,6 +47,7 @@ enum perf_output_field {
PERF_OUTPUT_SYMOFFSET = 1U << 11,
PERF_OUTPUT_SRCLINE = 1U << 12,
PERF_OUTPUT_PERIOD = 1U << 13,
+ PERF_OUTPUT_IREGS = 1U << 14,
};
struct output_option {
@@ -66,6 +68,7 @@ struct output_option {
{.str = "symoff", .field = PERF_OUTPUT_SYMOFFSET},
{.str = "srcline", .field = PERF_OUTPUT_SRCLINE},
{.str = "period", .field = PERF_OUTPUT_PERIOD},
+ {.str = "iregs", .field = PERF_OUTPUT_IREGS},
};
/* default set to maintain compatibility with current format */
@@ -255,6 +258,11 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
PERF_OUTPUT_PERIOD))
return -EINVAL;
+ if (PRINT_FIELD(IREGS) &&
+ perf_evsel__check_stype(evsel, PERF_SAMPLE_REGS_INTR, "IREGS",
+ PERF_OUTPUT_IREGS))
+ return -EINVAL;
+
return 0;
}
@@ -352,6 +360,24 @@ out:
return 0;
}
+static void print_sample_iregs(union perf_event *event __maybe_unused,
+ struct perf_sample *sample,
+ struct thread *thread __maybe_unused,
+ struct perf_event_attr *attr)
+{
+ struct regs_dump *regs = &sample->intr_regs;
+ uint64_t mask = attr->sample_regs_intr;
+ unsigned i = 0, r;
+
+ if (!regs)
+ return;
+
+ for_each_set_bit(r, (unsigned long *) &mask, sizeof(mask) * 8) {
+ u64 val = regs->regs[i++];
+ printf("%5s:0x%"PRIx64" ", perf_reg_name(r), val);
+ }
+}
+
static void print_sample_start(struct perf_sample *sample,
struct thread *thread,
struct perf_evsel *evsel)
@@ -525,6 +551,9 @@ static void process_event(union perf_event *event, struct perf_sample *sample,
PERF_MAX_STACK_DEPTH);
}
+ if (PRINT_FIELD(IREGS))
+ print_sample_iregs(event, sample, thread, attr);
+
printf("\n");
}
@@ -1643,7 +1672,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
"comma separated output fields prepend with 'type:'. "
"Valid types: hw,sw,trace,raw. "
"Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,"
- "addr,symoff,period,flags", parse_output_fields),
+ "addr,symoff,period,iregs,flags", parse_output_fields),
OPT_BOOLEAN('a', "all-cpus", &system_wide,
"system-wide collection from all CPUs"),
OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 0/4] perf: improve script and record for iregs and brstack Stephane Eranian <eranian@google.com> - 2015-08-31 18:50 +0200
[PATCH v2 4/4] perf script: enable printing of branch stack Stephane Eranian <eranian@google.com> - 2015-08-31 18:50 +0200
Re: [PATCH v2 4/4] perf script: enable printing of branch stack Andi Kleen <andi@firstfloor.org> - 2015-08-31 19:10 +0200
Re: [PATCH v2 4/4] perf script: enable printing of branch stack Andi Kleen <ak@linux.intel.com> - 2015-08-31 19:10 +0200
[PATCH v2 1/4] perf script: enable printing of interrupted machine state Stephane Eranian <eranian@google.com> - 2015-08-31 18:50 +0200
Re: [PATCH v2 1/4] perf script: enable printing of interrupted machine state Arnaldo Carvalho de Melo <acme@redhat.com> - 2015-08-31 23:00 +0200
[tip:perf/urgent] perf script: Enable printing of interrupted machine state tip-bot for Stephane Eranian <tipbot@zytor.com> - 2015-09-01 10:40 +0200
[PATCH v2 3/4] perf record: add ability to name registers to record Stephane Eranian <eranian@google.com> - 2015-08-31 18:50 +0200
Re: [PATCH v2 3/4] perf record: add ability to name registers to record Arnaldo Carvalho de Melo <acme@redhat.com> - 2015-08-31 23:10 +0200
[tip:perf/urgent] perf record: Add ability to name registers to record tip-bot for Stephane Eranian <tipbot@zytor.com> - 2015-09-01 10:40 +0200
csiph-web