|
@@ -16,6 +16,7 @@
|
|
#include "util/debug.h"
|
|
#include "util/debug.h"
|
|
#include "util/build-id.h"
|
|
#include "util/build-id.h"
|
|
#include "util/data.h"
|
|
#include "util/data.h"
|
|
|
|
+#include "util/auxtrace.h"
|
|
|
|
|
|
#include "util/parse-options.h"
|
|
#include "util/parse-options.h"
|
|
|
|
|
|
@@ -30,6 +31,7 @@ struct perf_inject {
|
|
struct perf_data_file output;
|
|
struct perf_data_file output;
|
|
u64 bytes_written;
|
|
u64 bytes_written;
|
|
struct list_head samples;
|
|
struct list_head samples;
|
|
|
|
+ struct itrace_synth_opts itrace_synth_opts;
|
|
};
|
|
};
|
|
|
|
|
|
struct event_entry {
|
|
struct event_entry {
|
|
@@ -205,6 +207,32 @@ static int perf_event__repipe_fork(struct perf_tool *tool,
|
|
return err;
|
|
return err;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static int perf_event__repipe_comm(struct perf_tool *tool,
|
|
|
|
+ union perf_event *event,
|
|
|
|
+ struct perf_sample *sample,
|
|
|
|
+ struct machine *machine)
|
|
|
|
+{
|
|
|
|
+ int err;
|
|
|
|
+
|
|
|
|
+ err = perf_event__process_comm(tool, event, sample, machine);
|
|
|
|
+ perf_event__repipe(tool, event, sample, machine);
|
|
|
|
+
|
|
|
|
+ return err;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int perf_event__repipe_exit(struct perf_tool *tool,
|
|
|
|
+ union perf_event *event,
|
|
|
|
+ struct perf_sample *sample,
|
|
|
|
+ struct machine *machine)
|
|
|
|
+{
|
|
|
|
+ int err;
|
|
|
|
+
|
|
|
|
+ err = perf_event__process_exit(tool, event, sample, machine);
|
|
|
|
+ perf_event__repipe(tool, event, sample, machine);
|
|
|
|
+
|
|
|
|
+ return err;
|
|
|
|
+}
|
|
|
|
+
|
|
static int perf_event__repipe_tracing_data(struct perf_tool *tool,
|
|
static int perf_event__repipe_tracing_data(struct perf_tool *tool,
|
|
union perf_event *event,
|
|
union perf_event *event,
|
|
struct perf_session *session)
|
|
struct perf_session *session)
|
|
@@ -217,6 +245,18 @@ static int perf_event__repipe_tracing_data(struct perf_tool *tool,
|
|
return err;
|
|
return err;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static int perf_event__repipe_id_index(struct perf_tool *tool,
|
|
|
|
+ union perf_event *event,
|
|
|
|
+ struct perf_session *session)
|
|
|
|
+{
|
|
|
|
+ int err;
|
|
|
|
+
|
|
|
|
+ perf_event__repipe_synth(tool, event);
|
|
|
|
+ err = perf_event__process_id_index(tool, event, session);
|
|
|
|
+
|
|
|
|
+ return err;
|
|
|
|
+}
|
|
|
|
+
|
|
static int dso__read_build_id(struct dso *dso)
|
|
static int dso__read_build_id(struct dso *dso)
|
|
{
|
|
{
|
|
if (dso->has_build_id)
|
|
if (dso->has_build_id)
|
|
@@ -401,16 +441,20 @@ static int __cmd_inject(struct perf_inject *inject)
|
|
struct perf_session *session = inject->session;
|
|
struct perf_session *session = inject->session;
|
|
struct perf_data_file *file_out = &inject->output;
|
|
struct perf_data_file *file_out = &inject->output;
|
|
int fd = perf_data_file__fd(file_out);
|
|
int fd = perf_data_file__fd(file_out);
|
|
|
|
+ u64 output_data_offset;
|
|
|
|
|
|
signal(SIGINT, sig_handler);
|
|
signal(SIGINT, sig_handler);
|
|
|
|
|
|
- if (inject->build_ids || inject->sched_stat) {
|
|
|
|
|
|
+ if (inject->build_ids || inject->sched_stat ||
|
|
|
|
+ inject->itrace_synth_opts.set) {
|
|
inject->tool.mmap = perf_event__repipe_mmap;
|
|
inject->tool.mmap = perf_event__repipe_mmap;
|
|
inject->tool.mmap2 = perf_event__repipe_mmap2;
|
|
inject->tool.mmap2 = perf_event__repipe_mmap2;
|
|
inject->tool.fork = perf_event__repipe_fork;
|
|
inject->tool.fork = perf_event__repipe_fork;
|
|
inject->tool.tracing_data = perf_event__repipe_tracing_data;
|
|
inject->tool.tracing_data = perf_event__repipe_tracing_data;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ output_data_offset = session->header.data_offset;
|
|
|
|
+
|
|
if (inject->build_ids) {
|
|
if (inject->build_ids) {
|
|
inject->tool.sample = perf_event__inject_buildid;
|
|
inject->tool.sample = perf_event__inject_buildid;
|
|
} else if (inject->sched_stat) {
|
|
} else if (inject->sched_stat) {
|
|
@@ -429,10 +473,22 @@ static int __cmd_inject(struct perf_inject *inject)
|
|
else if (!strncmp(name, "sched:sched_stat_", 17))
|
|
else if (!strncmp(name, "sched:sched_stat_", 17))
|
|
evsel->handler = perf_inject__sched_stat;
|
|
evsel->handler = perf_inject__sched_stat;
|
|
}
|
|
}
|
|
|
|
+ } else if (inject->itrace_synth_opts.set) {
|
|
|
|
+ session->itrace_synth_opts = &inject->itrace_synth_opts;
|
|
|
|
+ inject->itrace_synth_opts.inject = true;
|
|
|
|
+ inject->tool.comm = perf_event__repipe_comm;
|
|
|
|
+ inject->tool.exit = perf_event__repipe_exit;
|
|
|
|
+ inject->tool.id_index = perf_event__repipe_id_index;
|
|
|
|
+ inject->tool.auxtrace_info = perf_event__process_auxtrace_info;
|
|
|
|
+ inject->tool.auxtrace = perf_event__process_auxtrace;
|
|
|
|
+ inject->tool.ordered_events = true;
|
|
|
|
+ inject->tool.ordering_requires_timestamps = true;
|
|
|
|
+ /* Allow space in the header for new attributes */
|
|
|
|
+ output_data_offset = 4096;
|
|
}
|
|
}
|
|
|
|
|
|
if (!file_out->is_pipe)
|
|
if (!file_out->is_pipe)
|
|
- lseek(fd, session->header.data_offset, SEEK_SET);
|
|
|
|
|
|
+ lseek(fd, output_data_offset, SEEK_SET);
|
|
|
|
|
|
ret = perf_session__process_events(session);
|
|
ret = perf_session__process_events(session);
|
|
|
|
|
|
@@ -440,6 +496,14 @@ static int __cmd_inject(struct perf_inject *inject)
|
|
if (inject->build_ids)
|
|
if (inject->build_ids)
|
|
perf_header__set_feat(&session->header,
|
|
perf_header__set_feat(&session->header,
|
|
HEADER_BUILD_ID);
|
|
HEADER_BUILD_ID);
|
|
|
|
+ /*
|
|
|
|
+ * The AUX areas have been removed and replaced with
|
|
|
|
+ * synthesized hardware events, so clear the feature flag.
|
|
|
|
+ */
|
|
|
|
+ if (inject->itrace_synth_opts.set)
|
|
|
|
+ perf_header__clear_feat(&session->header,
|
|
|
|
+ HEADER_AUXTRACE);
|
|
|
|
+ session->header.data_offset = output_data_offset;
|
|
session->header.data_size = inject->bytes_written;
|
|
session->header.data_size = inject->bytes_written;
|
|
perf_session__write_header(session, session->evlist, fd, true);
|
|
perf_session__write_header(session, session->evlist, fd, true);
|
|
}
|
|
}
|
|
@@ -497,6 +561,9 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused)
|
|
OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name, "file",
|
|
OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name, "file",
|
|
"kallsyms pathname"),
|
|
"kallsyms pathname"),
|
|
OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"),
|
|
OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"),
|
|
|
|
+ OPT_CALLBACK_OPTARG(0, "itrace", &inject.itrace_synth_opts,
|
|
|
|
+ NULL, "opts", "Instruction Tracing options",
|
|
|
|
+ itrace_parse_synth_opts),
|
|
OPT_END()
|
|
OPT_END()
|
|
};
|
|
};
|
|
const char * const inject_usage[] = {
|
|
const char * const inject_usage[] = {
|