From: Arnaldo Carvalho de Melo <acme@redhat.com>
To: Stephane Eranian <eranian@google.com>
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
mingo@elte.hu, ak@linux.intel.com, jolsa@redhat.com,
namhyung@kernel.org, kan.liang@intel.com, dsahern@gmail.com,
adrian.hunter@intel.com
Subject: Re: [PATCH v2 1/4] perf script: enable printing of interrupted machine state
Date: Mon, 31 Aug 2015 17:51:27 -0300 [thread overview]
Message-ID: <20150831205127.GF2443@redhat.com> (raw)
In-Reply-To: <1441039273-16260-2-git-send-email-eranian@google.com>
Em Mon, Aug 31, 2015 at 06:41:10PM +0200, Stephane Eranian escreveu:
> 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:
Tested and applied,
- Arnaldo
> $ perf script -F ip,iregs
> 40afc2 AX:0x6c5770 BX:0x1e CX:0x5f4d80a DX:0x101010101010101 SI:0x1
>
> Signed-off-by: Stephane Eranian <eranian@google.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 @@ static int perf_session__check_output_opt(struct perf_session *session)
> 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...]",
> --
> 1.9.1
next prev parent reply other threads:[~2015-08-31 20:51 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-31 16:41 [PATCH v2 0/4] perf: improve script and record for iregs and brstack Stephane Eranian
2015-08-31 16:41 ` [PATCH v2 1/4] perf script: enable printing of interrupted machine state Stephane Eranian
2015-08-31 20:51 ` Arnaldo Carvalho de Melo [this message]
2015-09-01 8:31 ` [tip:perf/urgent] perf script: Enable " tip-bot for Stephane Eranian
2015-08-31 16:41 ` [PATCH v2 2/4] perf/x86: add list of register names Stephane Eranian
2015-09-01 8:31 ` [tip:perf/urgent] perf/x86: Add " tip-bot for Stephane Eranian
2015-08-31 16:41 ` [PATCH v2 3/4] perf record: add ability to name registers to record Stephane Eranian
2015-08-31 21:02 ` Arnaldo Carvalho de Melo
2015-09-01 8:32 ` [tip:perf/urgent] perf record: Add " tip-bot for Stephane Eranian
2015-08-31 16:41 ` [PATCH v2 4/4] perf script: enable printing of branch stack Stephane Eranian
2015-08-31 17:05 ` Andi Kleen
2015-08-31 17:08 ` Andi Kleen
2015-10-30 9:13 ` [tip:perf/core] perf script: Enable " tip-bot for Stephane Eranian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150831205127.GF2443@redhat.com \
--to=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=jolsa@redhat.com \
--cc=kan.liang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome