7 #include <subcmd/exec-cmd.h> 9 #include <subcmd/parse-options.h> 31 #include <linux/bitmap.h> 32 #include <linux/kernel.h> 33 #include <linux/stringify.h> 34 #include <linux/time64.h> 42 #include <sys/param.h> 43 #include <sys/types.h> 150 [PERF_TYPE_HARDWARE] = {
162 [PERF_TYPE_SOFTWARE] = {
175 [PERF_TYPE_TRACEPOINT] = {
197 [PERF_TYPE_BREAKPOINT] = {
246 goto out_free_filename;
269 fstat(fileno(es->
fp), &st);
270 return fprintf(fp,
"[ perf script: Wrote %.3f MB %s (%" PRIu64
" samples) ]\n",
307 const char *
str =
"";
309 for (i = 0; i < imax; ++i) {
318 #define PRINT_FIELD(x) (output[output_type(attr->type)].fields & PERF_OUTPUT_##x) 321 u64 sample_type,
const char *sample_msg,
325 struct perf_event_attr *
attr = &evsel->
attr;
329 if (attr->sample_type & sample_type)
336 pr_err(
"Samples for '%s' event do not have %s attribute set. " 337 "Cannot print '%s' field.\n",
343 output[type].fields &= ~field;
345 pr_debug(
"Samples for '%s' event do not have %s attribute set. " 346 "Skipping '%s' field.\n",
353 u64 sample_type,
const char *sample_msg,
363 struct perf_event_attr *
attr = &evsel->
attr;
398 pr_err(
"Display of symbols requested but neither sample IP nor " 399 "sample address\nis selected. Hence, no addresses to convert " 404 pr_err(
"Display of offsets requested but symbol is not" 410 pr_err(
"Display of DSO requested but no address to convert. Select\n" 411 "sample IP, sample address, brstack, brstacksym, or brstackoff.\n");
415 pr_err(
"Display of source line number requested but sample IP is not\n" 416 "selected. Hence, no address to lookup the source line number.\n");
421 PERF_SAMPLE_BRANCH_ANY)) {
422 pr_err(
"Display of branch stack assembler requested, but non all-branch filter set\n" 423 "Hint: run 'perf record -b ...'\n");
463 output[type].print_ip_opts = 0;
498 pr_err(
"%s events do not exist. " 499 "Remove corresponding -F option to proceed.\n",
515 bool use_callchain =
false;
516 bool not_pipe =
false;
521 use_callchain =
true;
525 if (not_pipe && !use_callchain)
534 !
output[PERF_TYPE_TRACEPOINT].user_set) {
535 j = PERF_TYPE_TRACEPOINT;
538 if (evsel->
attr.type != j)
557 struct perf_event_attr *
attr, FILE *fp)
560 uint64_t
mask = attr->sample_regs_intr;
567 for_each_set_bit(r, (
unsigned long *) &mask,
sizeof(mask) * 8) {
568 u64 val = regs->
regs[i++];
569 printed += fprintf(fp,
"%5s:0x%"PRIx64
" ",
perf_reg_name(r), val);
576 struct perf_event_attr *
attr, FILE *fp)
579 uint64_t
mask = attr->sample_regs_user;
583 if (!regs || !regs->
regs)
586 printed += fprintf(fp,
" ABI:%" PRIu64
" ", regs->
abi);
588 for_each_set_bit(r, (
unsigned long *) &mask,
sizeof(mask) * 8) {
589 u64 val = regs->
regs[i++];
590 printed += fprintf(fp,
"%5s:0x%"PRIx64
" ",
perf_reg_name(r), val);
601 struct perf_event_attr *
attr = &evsel->
attr;
603 unsigned long long nsecs;
616 printed += fprintf(fp,
"%5d/%-5d ", sample->
pid, sample->
tid);
618 printed += fprintf(fp,
"%5d ", sample->
pid);
620 printed += fprintf(fp,
"%5d ", sample->
tid);
624 printed += fprintf(fp,
"%3d ", sample->
cpu);
626 printed += fprintf(fp,
"[%03d] ", sample->
cpu);
633 (sample->misc & PERF_RECORD_MISC_##m) == PERF_RECORD_MISC_##m 636 ret += fprintf(fp,
"K");
638 ret += fprintf(fp,
"U");
640 ret += fprintf(fp,
"H");
641 if (
has(GUEST_KERNEL))
642 ret += fprintf(fp,
"G");
644 ret += fprintf(fp,
"g");
647 case PERF_RECORD_MMAP:
648 case PERF_RECORD_MMAP2:
650 ret += fprintf(fp,
"M");
652 case PERF_RECORD_COMM:
654 ret += fprintf(fp,
"E");
656 case PERF_RECORD_SWITCH:
657 case PERF_RECORD_SWITCH_CPU_WIDE:
658 if (
has(SWITCH_OUT)) {
659 ret += fprintf(fp,
"S");
660 if (sample->
misc & PERF_RECORD_MISC_SWITCH_OUT_PREEMPT)
661 ret += fprintf(fp,
"p");
669 ret += fprintf(fp,
"%*s", 6 - ret,
" ");
674 nsecs = sample->
time;
679 printed += fprintf(fp,
"%5lu.%09llu: ", secs, nsecs);
681 char sample_time[32];
683 printed += fprintf(fp,
"%12s: ", sample_time);
701 struct perf_event_attr *
attr, FILE *fp)
711 for (i = 0; i < br->
nr; i++) {
716 memset(&alf, 0,
sizeof(alf));
717 memset(&alt, 0,
sizeof(alt));
722 printed += fprintf(fp,
" 0x%"PRIx64, from);
724 printed += fprintf(fp,
"(");
726 printed += fprintf(fp,
")");
729 printed += fprintf(fp,
"/0x%"PRIx64, to);
731 printed += fprintf(fp,
"(");
733 printed += fprintf(fp,
")");
736 printed += fprintf(fp,
"/%c/%c/%c/%d ",
748 struct perf_event_attr *
attr, FILE *fp)
758 for (i = 0; i < br->
nr; i++) {
760 memset(&alf, 0,
sizeof(alf));
761 memset(&alt, 0,
sizeof(alt));
770 printed += fprintf(fp,
"(");
772 printed += fprintf(fp,
")");
774 printed += fprintf(fp,
"%c",
'/');
777 printed += fprintf(fp,
"(");
779 printed += fprintf(fp,
")");
781 printed += fprintf(fp,
"/%c/%c/%c/%d ",
793 struct perf_event_attr *
attr, FILE *fp)
803 for (i = 0; i < br->
nr; i++) {
805 memset(&alf, 0,
sizeof(alf));
806 memset(&alt, 0,
sizeof(alt));
818 printed += fprintf(fp,
" 0x%"PRIx64, from);
820 printed += fprintf(fp,
"(");
822 printed += fprintf(fp,
")");
824 printed += fprintf(fp,
"/0x%"PRIx64, to);
826 printed += fprintf(fp,
"(");
828 printed += fprintf(fp,
")");
830 printed += fprintf(fp,
"/%c/%c/%c/%d ",
839 #define MAXBB 16384UL 843 bool *is64bit, u8 *
cpumode,
bool last)
854 *cpumode = PERF_RECORD_MISC_KERNEL;
856 *cpumode = PERF_RECORD_MISC_USER;
865 pr_debug(
"\tblock %" PRIx64
"-%" PRIx64
" transfers between kernel and user\n", start, end);
869 memset(&al, 0,
sizeof(al));
872 pr_debug(
"\tbrstack does not reach to final jump (%" PRIx64
"-%" PRIx64
")\n", start, end);
874 pr_debug(
"\tblock %" PRIx64
"-%" PRIx64
" (%" PRIu64
") too long to dump\n", start, end, end - start);
879 pr_debug(
"\tcannot resolve %" PRIx64
"-%" PRIx64
"\n", start, end);
883 pr_debug(
"\tcannot resolve %" PRIx64
"-%" PRIx64
"\n", start, end);
896 pr_debug(
"\tcannot fetch code for block at %" PRIx64
"-%" PRIx64
"\n",
905 int printed = fprintf(fp,
"\t%016" PRIx64
"\t%-30s\t#%s%s%s%s", ip,
912 printed += fprintf(fp,
" %d cycles", en->
flags.
cycles);
914 printed += fprintf(fp,
" %.2f IPC", (
float)insn / en->
flags.
cycles);
916 return printed + fprintf(fp,
"\n");
921 struct perf_event_attr *
attr, FILE *fp)
924 int off, printed = 0;
926 memset(&al, 0,
sizeof(al));
930 if ((*lastsym) && al.
addr >= (*lastsym)->start && al.
addr < (*lastsym)->end)
945 printed += fprintf(fp,
"\t%s", al.
sym->
name);
947 printed += fprintf(fp,
"%+d", off);
948 printed += fprintf(fp,
":");
951 printed += fprintf(fp,
"\n");
959 struct perf_event_attr *
attr,
964 int i,
insn, len,
nr, ilen, printed = 0;
968 struct symbol *lastsym = NULL;
979 printed += fprintf(fp,
"%c",
'\n');
989 &x, buffer, len, 0, fp);
993 for (i = nr - 2; i >= 0; i--) {
995 pr_debug(
"%d: %" PRIx64
"-%" PRIx64
"\n", i,
1003 if (len == -ENXIO && i > 0) {
1005 pr_debug(
"\tpatching up to %" PRIx64
"-%" PRIx64
"\n", start, end);
1012 for (off = 0;; off += ilen) {
1013 uint64_t ip = start + off;
1020 printed += fprintf(fp,
"\t%016" PRIx64
"\t%s\n", ip,
1021 dump_insn(&x, ip, buffer + off, len - off, &ilen));
1052 printed += fprintf(fp,
"\t%016" PRIx64
"\t%s\n", sample->
ip,
1056 for (off = 0; off <= end -
start; off += ilen) {
1057 printed += fprintf(fp,
"\t%016" PRIx64
"\t%s\n", start + off,
1058 dump_insn(&x, start + off, buffer + off, len - off, &ilen));
1068 struct perf_event_attr *
attr, FILE *fp)
1071 int printed = fprintf(fp,
"%16" PRIx64, sample->
addr);
1079 printed += fprintf(fp,
" ");
1087 printed += fprintf(fp,
" (");
1089 printed += fprintf(fp,
")");
1100 struct perf_event_attr *
attr = &evsel->
attr;
1103 const char *
name = NULL;
1133 len = fprintf(fp,
"%*s%s", (
int)depth * 4,
"", name);
1135 len = fprintf(fp,
"%*s%16" PRIx64, (
int)depth * 4,
"", ip);
1144 if (len > spacing || (len && len < spacing - 52))
1145 spacing = round_up(len + 4, 32);
1148 len += fprintf(fp,
"%*s", spacing - len,
"");
1154 struct perf_event_attr *
attr,
1161 printed += fprintf(fp,
" ilen: %d", sample->
insn_len);
1165 printed += fprintf(fp,
" insn:");
1166 for (i = 0; i < sample->
insn_len; i++)
1167 printed += fprintf(fp,
" %02x", (
unsigned char)sample->
insn[i]);
1181 struct perf_event_attr *
attr = &evsel->
attr;
1183 bool print_srcline_last =
false;
1191 unsigned int print_opts =
output[type].print_ip_opts;
1199 if (cursor == NULL) {
1200 printed += fprintf(fp,
" ");
1202 print_srcline_last =
true;
1203 print_opts &= ~EVSEL__PRINT_SRCLINE;
1206 printed += fprintf(fp,
"\n");
1213 ((evsel->
attr.sample_type & PERF_SAMPLE_ADDR) &&
1214 !
output[type].user_set)) {
1215 printed += fprintf(fp,
" => ");
1219 if (print_srcline_last)
1223 return printed + fprintf(fp,
"\n");
1251 const char *
name = NULL;
1256 if (
sample_flags[i].flags == (flags & ~PERF_IP_FLAG_IN_TX)) {
1262 for (i = 0; i < n; i++, flags >>= 1) {
1264 str[pos++] = chars[i];
1266 for (; i < 32; i++, flags >>= 1) {
1273 return fprintf(fp,
" %-7s%4s ", name, in_tx ?
"(x)" :
"");
1275 return fprintf(fp,
" %-11s ", str);
1286 void *extra, FILE *fp)
1288 unsigned char ch = (
unsigned char)val;
1294 printed += fprintf(fp,
"\n");
1297 printed += fprintf(fp,
"%17s", !printer_data->
line_no ?
"BPF output:" :
1301 printed += fprintf(fp,
" %04x:", val);
1304 printed += fprintf(fp,
" %02x", val);
1307 printed += fprintf(fp,
" ");
1310 printed += fprintf(fp,
" ");
1313 if (printer_data->
hit_nul && ch)
1317 printed += fprintf(fp,
"%c",
'.');
1327 printed += fprintf(fp,
"%c", ch);
1331 printed += fprintf(fp,
" ");
1334 printed += fprintf(fp,
"\n");
1347 unsigned int nr_bytes = sample->
raw_size;
1353 printed += fprintf(fp,
"%17s \"%s\"\n",
"BPF string:", (
char *)(sample->
raw_data));
1360 if (len > 0 && len < spacing)
1361 return fprintf(fp,
"%*s", spacing - len,
"");
1379 len = fprintf(fp,
" IP: %u payload: %#" PRIx64
" ",
1392 len = fprintf(fp,
" hints: %#x extensions: %#x ",
1405 len = fprintf(fp,
" hw: %u cstate: %u sub-cstate: %u ",
1418 len = fprintf(fp,
" IP: %u ", data->
ip);
1430 len = fprintf(fp,
" deepest cstate: %u last cstate: %u wake reason: %#x ",
1446 len = fprintf(fp,
" cbr: %2u freq: %4u MHz ", data->
cbr, freq);
1449 len += fprintf(fp,
"(%3u%%) ", percent);
1457 switch (evsel->
attr.config) {
1505 max = MAX(len, max);
1521 len = scnprintf(out, 100,
"%16" PRIx64
" %s", data_src, decode);
1525 return fprintf(fp,
"%-*s", maxlen, out);
1537 const char *
unit,
double val)
1544 PERF_RECORD_SAMPLE, mctx->
fp);
1545 fputs(
"\tmetric: ", mctx->
fp);
1550 fprintf(mctx->
fp,
" %s\n", unit);
1558 PERF_RECORD_SAMPLE, mctx->
fp);
1559 fputs(
"\tmetric: ", mctx->
fp);
1577 .force_header =
false,
1616 struct perf_event_attr *
attr = &evsel->
attr;
1627 PERF_RECORD_SAMPLE, fp);
1630 fprintf(fp,
"%10" PRIu64
" ", sample->
period);
1638 fprintf(fp,
"%*s: ", script->
name_width, evname ?:
"[unknown]");
1664 fprintf(fp,
"%16" PRIu64, sample->
weight);
1674 fputc(cursor ?
'\n' :
' ', fp);
1696 fprintf(fp,
"%16" PRIx64, sample->
phys_addr);
1710 static int header_printed;
1715 if (!header_printed) {
1716 printf(
"%3s %8s %15s %15s %15s %15s %s\n",
1717 "CPU",
"THREAD",
"VAL",
"ENA",
"RUN",
"TIME",
"EVENT");
1721 for (thread = 0; thread <
nthreads; thread++) {
1722 for (cpu = 0; cpu <
ncpus; cpu++) {
1727 printf(
"%3d %8d %15" PRIu64
" %15" PRIu64
" %15" PRIu64
" %15" PRIu64
" %s\n",
1761 return scripting_ops ? scripting_ops->
flush_script() : 0;
1766 pr_debug(
"\nperf script stopped\n");
1768 return scripting_ops ? scripting_ops->
stop_script() : 0;
1787 pr_err(
"Samples misordered, previous: %" PRIu64
1797 pr_err(
"problem processing %d event, skipping it.\n",
1805 if (
cpu_list && !test_bit(sample->
cpu, cpu_bitmap))
1833 if (evsel->
attr.type >= PERF_TYPE_MAX &&
1838 if (pos->
attr.type == evsel->
attr.type && pos != evsel)
1844 if (evsel->
attr.sample_type)
1862 if (thread == NULL) {
1863 pr_debug(
"problem processing COMM event, skipping it.\n");
1870 if (!evsel->
attr.sample_id_all) {
1873 sample->
tid =
event->comm.tid;
1874 sample->
pid =
event->comm.pid;
1877 PERF_RECORD_COMM, stdout);
1898 if (thread == NULL) {
1899 pr_debug(
"problem processing NAMESPACES event, skipping it.\n");
1906 if (!evsel->
attr.sample_id_all) {
1909 sample->
tid =
event->namespaces.tid;
1910 sample->
pid =
event->namespaces.pid;
1913 PERF_RECORD_NAMESPACES, stdout);
1935 if (thread == NULL) {
1936 pr_debug(
"problem processing FORK event, skipping it.\n");
1940 if (!evsel->
attr.sample_id_all) {
1942 sample->
time =
event->fork.time;
1943 sample->
tid =
event->fork.tid;
1944 sample->
pid =
event->fork.pid;
1947 PERF_RECORD_FORK, stdout);
1965 if (thread == NULL) {
1966 pr_debug(
"problem processing EXIT event, skipping it.\n");
1970 if (!evsel->
attr.sample_id_all) {
1973 sample->
tid =
event->fork.tid;
1974 sample->
pid =
event->fork.pid;
1977 PERF_RECORD_EXIT, stdout);
2001 if (thread == NULL) {
2002 pr_debug(
"problem processing MMAP event, skipping it.\n");
2006 if (!evsel->
attr.sample_id_all) {
2009 sample->
tid =
event->mmap.tid;
2010 sample->
pid =
event->mmap.pid;
2013 PERF_RECORD_MMAP, stdout);
2033 if (thread == NULL) {
2034 pr_debug(
"problem processing MMAP2 event, skipping it.\n");
2038 if (!evsel->
attr.sample_id_all) {
2041 sample->
tid =
event->mmap2.tid;
2042 sample->
pid =
event->mmap2.pid;
2045 PERF_RECORD_MMAP2, stdout);
2066 if (thread == NULL) {
2067 pr_debug(
"problem processing SWITCH event, skipping it.\n");
2072 PERF_RECORD_SWITCH, stdout);
2095 PERF_RECORD_LOST, stdout);
2141 if (evsel->
priv != NULL)
2145 if (evsel->
priv == NULL)
2146 goto out_err_fclose;
2164 es_stdout.
fp = stdout;
2167 evsel->
priv = &es_stdout;
2213 pr_err(
"Couldn't create the per event dump files\n");
2237 struct scripting_ops *
ops)
2242 strcpy(s->
spec, spec);
2251 list_add_tail(&s->
node, &script_specs);
2258 list_for_each_entry(s, &script_specs,
node)
2259 if (strcasecmp(s->
spec, spec) == 0)
2294 fprintf(stderr,
"\n");
2295 fprintf(stderr,
"Scripting language extensions (used in " 2296 "perf script -s [spec:]script.[spec]):\n\n");
2298 list_for_each_entry(s, &script_specs,
node)
2299 fprintf(stderr,
" %-42s [%s]\n", s->
spec, s->
ops->
name);
2301 fprintf(stderr,
"\n");
2305 const char *
str,
int unset __maybe_unused)
2308 const char *script, *ext;
2311 if (strcmp(str,
"lang") == 0) {
2316 script = strchr(str,
':');
2320 fprintf(stderr,
"invalid language specifier");
2323 strncpy(spec, str, len);
2326 if (!scripting_ops) {
2327 fprintf(stderr,
"invalid language specifier");
2333 ext = strrchr(script,
'.');
2335 fprintf(stderr,
"invalid script extension");
2339 if (!scripting_ops) {
2340 fprintf(stderr,
"invalid script extension");
2351 const char *arg,
int unset __maybe_unused)
2353 char *tok, *strtok_saveptr = NULL;
2357 char *
str = strdup(arg);
2359 enum { DEFAULT,
SET,
ADD, REMOVE } change = DEFAULT;
2368 tok = strchr(str,
':');
2372 if (!strcmp(str,
"hw"))
2373 type = PERF_TYPE_HARDWARE;
2374 else if (!strcmp(str,
"sw"))
2375 type = PERF_TYPE_SOFTWARE;
2376 else if (!strcmp(str,
"trace"))
2377 type = PERF_TYPE_TRACEPOINT;
2378 else if (!strcmp(str,
"raw"))
2379 type = PERF_TYPE_RAW;
2380 else if (!strcmp(str,
"break"))
2381 type = PERF_TYPE_BREAKPOINT;
2382 else if (!strcmp(str,
"synth"))
2385 fprintf(stderr,
"Invalid event type in field string.\n");
2391 pr_warning(
"Overriding previous field request for %s events.\n",
2395 output[type].user_set =
true;
2396 output[type].wildcard_set =
false;
2400 if (strlen(str) == 0) {
2402 "Cannot set fields to 'none' for all event types.\n");
2408 if (strchr(str,
'+') || strchr(str,
'-'))
2412 pr_warning(
"Overriding previous field request for all events.\n");
2416 output[j].user_set =
true;
2417 output[j].wildcard_set =
true;
2422 for (tok = strtok_r(tok,
",", &strtok_saveptr); tok; tok = strtok_r(NULL,
",", &strtok_saveptr)) {
2428 }
else if (*tok ==
'-') {
2434 if (change !=
SET && change != DEFAULT)
2439 for (i = 0; i < imax; ++i) {
2443 if (i == imax && strcmp(tok,
"flags") == 0) {
2448 fprintf(stderr,
"Invalid field requested.\n");
2459 pr_warning(
"\'%s\' not valid for %s events. Ignoring.\n",
2462 if (change == REMOVE)
2470 fprintf(stderr,
"\'%s\' not valid for %s events.\n",
2482 pr_debug(
"No fields requested for %s type. " 2483 "Events will not be displayed.\n",
event_type(type));
2489 fprintf(stderr,
"Cannot mix +-field with overridden fields\n");
2496 #define for_each_lang(scripts_path, scripts_dir, lang_dirent) \ 2497 while ((lang_dirent = readdir(scripts_dir)) != NULL) \ 2498 if ((lang_dirent->d_type == DT_DIR || \ 2499 (lang_dirent->d_type == DT_UNKNOWN && \ 2500 is_directory(scripts_path, lang_dirent))) && \ 2501 (strcmp(lang_dirent->d_name, ".")) && \ 2502 (strcmp(lang_dirent->d_name, ".."))) 2504 #define for_each_script(lang_path, lang_dir, script_dirent) \ 2505 while ((script_dirent = readdir(lang_dir)) != NULL) \ 2506 if (script_dirent->d_type != DT_DIR && \ 2507 (script_dirent->d_type != DT_UNKNOWN || \ 2508 !is_directory(lang_path, script_dirent))) 2511 #define RECORD_SUFFIX "-record" 2512 #define REPORT_SUFFIX "-report" 2527 if (s != NULL && name)
2528 s->
name = strdup(name);
2543 list_add_tail(&s->
node, &script_descs);
2550 list_for_each_entry(s, &script_descs,
node)
2551 if (strcasecmp(s->
name, name) == 0)
2574 size_t suffix_len = strlen(suffix);
2575 const char *p =
str;
2577 if (strlen(str) > suffix_len) {
2578 p = str + strlen(str) - suffix_len;
2579 if (!strncmp(p, suffix, suffix_len))
2588 char line[BUFSIZ], *p;
2591 fp = fopen(filename,
"r");
2595 while (fgets(line,
sizeof(line), fp)) {
2602 if (strlen(p) && *p ==
'!')
2606 if (strlen(p) && p[strlen(p) - 1] ==
'\n')
2607 p[strlen(p) - 1] =
'\0';
2609 if (!strncmp(p,
"description:", strlen(
"description:"))) {
2610 p += strlen(
"description:");
2615 if (!strncmp(p,
"args:", strlen(
"args:"))) {
2616 p += strlen(
"args:");
2629 char *script_root, *
str;
2631 script_root = strdup(script_dirent->d_name);
2635 str = (
char *)
ends_with(script_root, suffix);
2646 const char *s __maybe_unused,
2647 int unset __maybe_unused)
2649 struct dirent *script_dirent, *lang_dirent;
2650 char scripts_path[MAXPATHLEN];
2651 DIR *scripts_dir, *lang_dir;
2652 char script_path[MAXPATHLEN];
2653 char lang_path[MAXPATHLEN];
2655 char first_half[BUFSIZ];
2658 snprintf(scripts_path, MAXPATHLEN,
"%s/scripts", get_argv_exec_path());
2660 scripts_dir = opendir(scripts_path);
2663 "open(%s) failed.\n" 2664 "Check \"PERF_EXEC_PATH\" env to set scripts dir.\n",
2670 scnprintf(lang_path, MAXPATHLEN,
"%s/%s/bin", scripts_path,
2671 lang_dirent->d_name);
2672 lang_dir = opendir(lang_path);
2680 scnprintf(script_path, MAXPATHLEN,
"%s/%s",
2681 lang_path, script_dirent->d_name);
2688 fprintf(stdout,
"List of available trace scripts:\n");
2689 list_for_each_entry(desc, &script_descs,
node) {
2690 sprintf(first_half,
"%s %s", desc->
name,
2692 fprintf(stdout,
" %-36s %s\n", first_half,
2711 char filename[MAXPATHLEN], evname[128];
2712 char line[BUFSIZ], *p;
2717 scnprintf(filename, MAXPATHLEN,
"%s/bin/%s-record", dir_name, scriptname);
2719 fp = fopen(filename,
"r");
2723 while (fgets(line,
sizeof(line), fp)) {
2729 p = strstr(p,
"-e");
2735 len = strcspn(p,
" \t");
2739 snprintf(evname, len + 1,
"%s", p);
2769 struct dirent *script_dirent, *lang_dirent;
2770 char scripts_path[MAXPATHLEN], lang_path[MAXPATHLEN];
2771 DIR *scripts_dir, *lang_dir;
2786 snprintf(scripts_path, MAXPATHLEN,
"%s/scripts", get_argv_exec_path());
2788 scripts_dir = opendir(scripts_path);
2795 scnprintf(lang_path, MAXPATHLEN,
"%s/%s", scripts_path,
2796 lang_dirent->d_name);
2797 #ifndef HAVE_LIBPERL_SUPPORT 2798 if (strstr(lang_path,
"perl"))
2801 #ifndef HAVE_LIBPYTHON_SUPPORT 2802 if (strstr(lang_path,
"python"))
2806 lang_dir = opendir(lang_path);
2812 if (strstr(script_dirent->d_name,
"top."))
2814 sprintf(scripts_path_array[i],
"%s/%s", lang_path,
2815 script_dirent->d_name);
2816 temp = strchr(script_dirent->d_name,
'.');
2817 snprintf(scripts_array[i],
2818 (temp - script_dirent->d_name) + 1,
2819 "%s", script_dirent->d_name);
2822 scripts_array[i], session))
2830 closedir(scripts_dir);
2837 struct dirent *script_dirent, *lang_dirent;
2838 char scripts_path[MAXPATHLEN];
2839 char script_path[MAXPATHLEN];
2840 DIR *scripts_dir, *lang_dir;
2841 char lang_path[MAXPATHLEN];
2842 char *__script_root;
2844 snprintf(scripts_path, MAXPATHLEN,
"%s/scripts", get_argv_exec_path());
2846 scripts_dir = opendir(scripts_path);
2851 scnprintf(lang_path, MAXPATHLEN,
"%s/%s/bin", scripts_path,
2852 lang_dirent->d_name);
2853 lang_dir = opendir(lang_path);
2859 if (__script_root && !strcmp(script_root, __script_root)) {
2860 free(__script_root);
2862 closedir(scripts_dir);
2863 scnprintf(script_path, MAXPATHLEN,
"%s/%s",
2864 lang_path, script_dirent->d_name);
2865 return strdup(script_path);
2867 free(__script_root);
2871 closedir(scripts_dir);
2878 return ends_with(script_path,
"top") == NULL ? false :
true;
2895 for (p = desc->
args; *p; p++)
2906 char **__argv =
malloc(
sizeof(
const char *) * argc);
2909 pr_err(
"malloc failed\n");
2913 memcpy(__argv, argv,
sizeof(
const char *) * argc);
2914 argc = parse_options(argc, (
const char **)__argv,
record_options,
2915 NULL, PARSE_OPT_STOP_AT_NON_OPTION);
2929 if ((sample_type & PERF_SAMPLE_REGS_USER) &&
2930 (sample_type & PERF_SAMPLE_STACK_USER)) {
2933 }
else if (sample_type & PERF_SAMPLE_BRANCH_STACK)
2971 if (WARN_ONCE(script->
allocated,
"stats double allocation\n"))
2991 pr_warning(
"Extra thread map event, ignoring.\n");
3010 pr_warning(
"Extra cpu map event, ignoring.\n");
3021 #ifdef HAVE_AUXTRACE_SUPPORT 3037 #define perf_script__process_auxtrace_info 0 3042 bool show_full_info =
false;
3043 bool header =
false;
3044 bool header_only =
false;
3045 bool script_started =
false;
3046 char *rec_script_path = NULL;
3047 char *rep_script_path = NULL;
3050 char *script_path = NULL;
3051 const char **__argv;
3076 .ordered_events =
true,
3077 .ordering_requires_timestamps =
true,
3083 const struct option options[] = {
3084 OPT_BOOLEAN(
'D',
"dump-raw-trace", &
dump_trace,
3085 "dump raw trace in ASCII"),
3086 OPT_INCR(
'v',
"verbose", &
verbose,
3087 "be more verbose (show symbol address, etc)"),
3089 "show latency attributes (irqs/preemption disabled, etc)"),
3090 OPT_CALLBACK_NOOPT(
'l',
"list", NULL, NULL,
"list available scripts",
3092 OPT_CALLBACK(
's',
"script", NULL,
"name",
3093 "script file name (lang:script name, script name, or *)",
3096 "generate perf-script.xx script in specified language"),
3097 OPT_STRING(
'i',
"input", &
input_name,
"file",
"input file name"),
3099 "do various checks like samples ordering and lost events"),
3100 OPT_BOOLEAN(0,
"header", &header,
"Show data header."),
3101 OPT_BOOLEAN(0,
"header-only", &header_only,
"Show only data header."),
3103 "file",
"vmlinux pathname"),
3105 "file",
"kallsyms pathname"),
3107 "When printing symbols do not display call chain"),
3108 OPT_CALLBACK(0,
"symfs", NULL,
"directory",
3109 "Look for files with symbols relative to this directory",
3111 OPT_CALLBACK(
'F',
"fields", NULL,
"str",
3112 "comma separated output fields prepend with 'type:'. " 3113 "+field to add and -field to remove." 3114 "Valid types: hw,sw,trace,raw,synth. " 3115 "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso," 3116 "addr,symoff,period,iregs,uregs,brstack,brstacksym,flags," 3117 "bpf-output,callindent,insn,insnlen,brstackinsn,synth,phys_addr",
3120 "system-wide collection from all CPUs"),
3122 "only consider these symbols"),
3124 "Stop display of callgraph at these symbols"),
3125 OPT_STRING(
'C',
"cpu", &
cpu_list,
"cpu",
"list of cpus to profile"),
3127 "only display events for these comms"),
3129 "only consider symbols in these pids"),
3131 "only consider symbols in these tids"),
3133 "Set the maximum stack depth when parsing the callchain, " 3134 "anything beyond the specified depth will be ignored. " 3135 "Default: kernel.perf_event_max_stack or " __stringify(PERF_MAX_STACK_DEPTH)),
3136 OPT_BOOLEAN(
'I',
"show-info", &show_full_info,
3137 "display extended information from perf.data file"),
3139 "Show the path of [kernel.kallsyms]"),
3141 "Show the fork/comm/exit events"),
3143 "Show the mmap events"),
3145 "Show context switch events (if recorded)"),
3147 "Show namespace events (if recorded)"),
3149 "Show lost events (if recorded)"),
3151 "Show round events (if recorded)"),
3153 "Dump trace output to files named by the monitored events"),
3156 "Maximum number of code blocks to dump with brstackinsn"),
3158 "Use 9 decimal places when displaying time"),
3159 OPT_CALLBACK_OPTARG(0,
"itrace", &itrace_synth_opts, NULL,
"opts",
3160 "Instruction Tracing options",
3163 "Show full source file name path for source lines"),
3165 "Enable symbol demangling"),
3167 "Enable kernel symbol demangling"),
3168 OPT_STRING(0,
"time", &script.
time_str,
"str",
3169 "Time span of interest (start,stop)"),
3171 "Show inline function"),
3174 const char *
const script_subcommands[] = {
"record",
"report", NULL };
3175 const char *script_usage[] = {
3176 "perf script [<options>]",
3177 "perf script [<options>] record <script> [<record-options>] <command>",
3178 "perf script [<options>] report <script> [script-args]",
3179 "perf script [<options>] <script> [<record-options>] <command>",
3180 "perf script [<options>] <top-script> [script-args]",
3188 argc = parse_options_subcommand(argc, argv, options, script_subcommands, script_usage,
3189 PARSE_OPT_STOP_AT_NON_OPTION);
3194 if (argc > 1 && !strncmp(argv[0],
"rec", strlen(
"rec"))) {
3196 if (!rec_script_path)
3200 if (argc > 1 && !strncmp(argv[0],
"rep", strlen(
"rep"))) {
3202 if (!rep_script_path) {
3204 "Please specify a valid report script" 3205 "(see 'perf script -l' for listing)\n");
3215 set_argv_exec_path(get_argv_exec_path());
3217 if (argc && !
script_name && !rec_script_path && !rep_script_path) {
3225 if (!rec_script_path && !rep_script_path) {
3226 usage_with_options_msg(script_usage, options,
3227 "Couldn't find script `%s'\n\n See perf" 3228 " script -l for available scripts.\n", argv[0]);
3232 rep_args = argc - 1;
3237 rec_args = (argc - 1) - rep_args;
3239 usage_with_options_msg(script_usage, options,
3240 "`%s' script requires options." 3241 "\n\n See perf script -l for available " 3242 "scripts and options.\n", argv[0]);
3246 if (pipe(live_pipe) < 0) {
3247 perror(
"failed to create pipe");
3253 perror(
"failed to fork");
3260 dup2(live_pipe[1], 1);
3261 close(live_pipe[0]);
3266 if (
have_cmd(argc - rep_args, &argv[rep_args]) != 0) {
3272 __argv =
malloc((argc + 6) *
sizeof(
const char *));
3274 pr_err(
"malloc failed\n");
3279 __argv[j++] =
"/bin/sh";
3280 __argv[j++] = rec_script_path;
3286 for (i = rep_args + 1; i <
argc; i++)
3287 __argv[j++] = argv[i];
3290 execvp(
"/bin/sh", (
char **)__argv);
3295 dup2(live_pipe[0], 0);
3296 close(live_pipe[1]);
3298 __argv =
malloc((argc + 4) *
sizeof(
const char *));
3300 pr_err(
"malloc failed\n");
3306 __argv[j++] =
"/bin/sh";
3307 __argv[j++] = rep_script_path;
3308 for (i = 1; i < rep_args + 1; i++)
3309 __argv[j++] = argv[i];
3314 execvp(
"/bin/sh", (
char **)__argv);
3319 if (rec_script_path)
3320 script_path = rec_script_path;
3321 if (rep_script_path)
3322 script_path = rep_script_path;
3327 if (!rec_script_path)
3330 if (
have_cmd(argc - 1, &argv[1]) != 0) {
3336 __argv =
malloc((argc + 2) *
sizeof(
const char *));
3338 pr_err(
"malloc failed\n");
3343 __argv[j++] =
"/bin/sh";
3344 __argv[j++] = script_path;
3347 for (i = 2; i <
argc; i++)
3348 __argv[j++] = argv[i];
3351 execvp(
"/bin/sh", (
char **)__argv);
3360 if (session == NULL)
3363 if (header || header_only) {
3399 pr_err(
"%s: failed to set libtraceevent function resolver\n", __func__);
3405 struct stat perf_stat;
3410 "custom fields not supported for generated scripts");
3415 input = open(data.
file.
path, O_RDONLY);
3418 perror(
"failed to open file");
3422 err = fstat(input, &perf_stat);
3424 perror(
"failed to stat file");
3428 if (!perf_stat.st_size) {
3429 fprintf(stderr,
"zero-sized file, nothing to do!\n");
3434 if (!scripting_ops) {
3435 fprintf(stderr,
"invalid language specifier");
3450 script_started =
true;
3469 pr_err(
"HINT: no first/last sample time found in perf data.\n" 3470 "Please use latest perf binary to execute 'perf record'\n" 3471 "(if '--buildid-all' is enabled, please set '--timestamp-boundary').\n");
3483 pr_err(
"Invalid time string\n");
static LIST_HEAD(script_specs)
void perf_evlist__set_maps(struct perf_evlist *evlist, struct cpu_map *cpus, struct thread_map *threads)
static int flush_scripting(void)
void thread__resolve(struct thread *thread, struct addr_location *al, struct perf_sample *sample)
static int has_required_arg(char *script_path)
void perf_stat__print_shadow_stats(struct perf_evsel *evsel, double avg, int cpu, struct perf_stat_output_ctx *out, struct rblist *metric_events, struct runtime_stat *st)
static int process_finished_round_event(struct perf_tool *tool __maybe_unused, union perf_event *event, struct ordered_events *oe __maybe_unused)
const char * comm_list_str
static unsigned int attr_type(unsigned int type)
static int perf_sample__fprintf_brstack(struct perf_sample *sample, struct thread *thread, struct perf_event_attr *attr, FILE *fp)
static int cleanup_scripting(void)
int color_fprintf(FILE *fp, const char *color, const char *fmt,...)
u64(* map_ip)(struct map *, u64)
static int read_script_info(struct script_desc *desc, const char *filename)
static void script_desc__add(struct script_desc *s)
struct perf_evlist * evlist
static struct script_spec * script_spec__new(const char *spec, struct scripting_ops *ops)
bool is_bts_event(struct perf_event_attr *attr)
static int perf_evlist__max_name_len(struct perf_evlist *evlist)
static int perf_evsel__check_stype(struct perf_evsel *evsel, u64 sample_type, const char *sample_msg, enum perf_output_field field)
static int perf_sample__fprintf_brstacksym(struct perf_sample *sample, struct thread *thread, struct perf_event_attr *attr, FILE *fp)
void event_format__fprintf(struct event_format *event, int cpu, void *data, int size, FILE *fp)
static int perf_sample__fprintf_synth_cbr(struct perf_sample *sample, FILE *fp)
int machine__resolve(struct machine *machine, struct addr_location *al, struct perf_sample *sample)
static struct perf_evsel_script * evsel_script(struct perf_evsel *evsel)
const char * vmlinux_name
static void set_print_ip_opts(struct perf_event_attr *attr)
#define perf_sample__bad_synth_size(s, d)
static int perf_sample__fprintf_pt_spacing(int len, FILE *fp)
void perf_evlist__free_stats(struct perf_evlist *evlist)
static u64 map__map_ip(struct map *map, u64 ip)
static int process_cpu_map_event(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_session *session __maybe_unused)
static int perf_evsel_script__fprintf(struct perf_evsel_script *es, FILE *fp)
static int perf_sample__fprintf_addr(struct perf_sample *sample, struct thread *thread, struct perf_event_attr *attr, FILE *fp)
static bool output_set_by_user(void)
static int parse_output_fields(const struct option *opt __maybe_unused, const char *arg, int unset __maybe_unused)
int cmd_record(int argc, const char **argv)
struct perf_evsel * evsel
static int process_attr(struct perf_tool *tool, union perf_event *event, struct perf_evlist **pevlist)
int perf_event__process_mmap(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine)
static int output_type(unsigned int type)
static int perf_evsel__do_check_stype(struct perf_evsel *evsel, u64 sample_type, const char *sample_msg, enum perf_output_field field, bool allow_user_set)
__thread struct callchain_cursor callchain_cursor
static void script_new_line(void *ctx)
#define EVSEL__PRINT_SYMOFFSET
static bool perf_evsel__is_bpf_output(struct perf_evsel *evsel)
static void * perf_sample__synth_ptr(struct perf_sample *sample)
static char const * script_name
unsigned int callchain_sz
static int perf_sample__fprintf_flags(u32 flags, FILE *fp)
void perf_set_singlethreaded(void)
struct ip_callchain * callchain
struct map * thread__find_map(struct thread *thread, u8 cpumode, u64 addr, struct addr_location *al)
const char * bt_stop_list_str
struct perf_time_interval * perf_time__range_alloc(const char *ostr, int *size)
static void sig_handler(int sig __maybe_unused)
int sample__fprintf_sym(struct perf_sample *sample, struct addr_location *al, int left_alignment, unsigned int print_opts, struct callchain_cursor *cursor, FILE *fp)
static void perf_script__fclose_per_event_dump(struct perf_script *script)
struct itrace_synth_opts * itrace_synth_opts
static int input(yyscan_t yyscanner)
struct perf_data_file file
const char * tid_list_str
static void process_event(struct perf_script *script, struct perf_sample *sample, struct perf_evsel *evsel, struct addr_location *al, struct machine *machine)
static struct scripting_ops * scripting_ops
enum perf_call_graph_mode record_mode
static int perf_sample__fprintf_brstackinsn(struct perf_sample *sample, struct thread *thread, struct perf_event_attr *attr, struct machine *machine, FILE *fp)
struct cpu_map * cpu_map__new_data(struct cpu_map_data *data)
static void list_available_languages(void)
struct namespaces_event namespaces
static int perf_session__check_output_opt(struct perf_session *session)
int perf_event__process_comm(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine)
print_metric_t print_metric
int perf_event__process_exit(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine)
static const char * perf_reg_name(int id)
struct output_option all_output_options[]
static int process_exit_event(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine)
static int process_mmap_event(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine)
int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz)
int perf_event__process_fork(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine)
struct stat_config_event stat_config
static int perf_sample__fprintf_spacing(int len, int spacing, FILE *fp)
static int process_lost_event(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine)
struct runtime_stat rt_stat
static char * get_script_path(const char *script_root, const char *suffix)
static int sample__fprintf_bpf_output(enum binary_printer_ops op, unsigned int val, void *extra, FILE *fp)
bool srcline_full_filename
static int process_stat_config_event(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_session *session __maybe_unused)
__weak const char * dump_insn(struct perf_insn *x __maybe_unused, u64 ip __maybe_unused, u8 *inbuf __maybe_unused, int inlen __maybe_unused, int *lenp)
bool perf_session__has_traces(struct perf_session *session, const char *msg)
static const char * ends_with(const char *str, const char *suffix)
x86 movsq based memset() in arch/x86/lib/memset_64.S") MEMSET_FN(memset_erms
int cmd_script(int argc, const char **argv)
bool perf_time__ranges_skip_sample(struct perf_time_interval *ptime_buf, int num, u64 timestamp)
static struct script_desc * script_desc__findnew(const char *name)
int perf_event__process_auxtrace_error(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_session *session)
void perf_session__delete(struct perf_session *session)
static void perf_evsel_script__delete(struct perf_evsel_script *es)
int map__fprintf_srcline(struct map *map, u64 addr, const char *prefix, FILE *fp)
static int __cmd_script(struct perf_script *script)
struct perf_sample * sample
struct branch_entry entries[0]
void setup_python_scripting(void)
struct trace_event tevent
#define EVSEL__PRINT_SRCLINE
static int have_cmd(int argc, const char **argv)
static int perf_sample__fprintf_brstackoff(struct perf_sample *sample, struct thread *thread, struct perf_event_attr *attr, FILE *fp)
static int grab_bb(u8 *buffer, u64 start, u64 end, struct machine *machine, struct thread *thread, bool *is64bit, u8 *cpumode, bool last)
u64 perf_evlist__combined_sample_type(struct perf_evlist *evlist)
size_t symbol__fprintf_symname_offs(const struct symbol *sym, const struct addr_location *al, FILE *fp)
static u64 last_timestamp
static void perf_script__exit_per_event_dump_stats(struct perf_script *script)
unsigned int scripting_max_stack
void addr_location__put(struct addr_location *al)
static struct script_desc * script_desc__new(const char *name)
int symbol__config_symfs(const struct option *opt __maybe_unused, const char *dir, int unset __maybe_unused)
const char * event_type(int type)
static int ip__fprintf_jump(uint64_t ip, struct branch_entry *en, struct perf_insn *x, u8 *inbuf, int len, int insn, FILE *fp)
bool dwarf_callchain_users
const char * thread__comm_str(const struct thread *thread)
#define for_each_script(lang_path, lang_dir, script_dirent)
static int perf_sample__fprintf_start(struct perf_sample *sample, struct thread *thread, struct perf_evsel *evsel, u32 type, FILE *fp)
#define pr_debug(fmt,...)
void setup_perl_scripting(void)
static char * get_script_root(struct dirent *script_dirent, const char *suffix)
static struct perf_evsel_script * perf_evsel_script__new(struct perf_evsel *evsel, struct perf_data *data)
static struct perf_session * session
#define evlist__for_each_entry(evlist, evsel)
static unsigned int nthreads
static int perf_sample__fprintf_callindent(struct perf_sample *sample, struct perf_evsel *evsel, struct thread *thread, struct addr_location *al, FILE *fp)
int(* flush_script)(void)
unsigned int print_ip_opts
static void perf_sample__fprint_metric(struct perf_script *script, struct thread *thread, struct perf_evsel *evsel, struct perf_sample *sample, FILE *fp)
struct regs_dump user_regs
static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS)
static struct perf_tool tool
static bool machine__kernel_ip(struct machine *machine, u64 ip)
struct event_format * tp_format
static int perf_sample__fprintf_synth(struct perf_sample *sample, struct perf_evsel *evsel, FILE *fp)
struct cpu_map_event cpu_map
int itrace_parse_synth_opts(const struct option *opt, const char *str, int unset)
size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp)
static char const * generate_script_lang
void(* process_stat)(struct perf_stat_config *config, struct perf_evsel *evsel, u64 tstamp)
bool show_namespace_events
struct thread_map * thread_map__new_event(struct thread_map_event *event)
static int perf_sample__fprintf_iregs(struct perf_sample *sample, struct perf_event_attr *attr, FILE *fp)
static int perf_script__fopen_per_event_dump(struct perf_script *script)
union perf_mem_data_src data_src
static int perf_sample__fprintf_synth_pwre(struct perf_sample *sample, FILE *fp)
static int process_fork_event(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine)
static void script_spec__add(struct script_spec *s)
struct perf_evsel * perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id)
static int perf_sample__fprintf_bts(struct perf_sample *sample, struct perf_evsel *evsel, struct thread *thread, struct addr_location *al, struct machine *machine, FILE *fp)
static const char * cpu_list
struct regs_dump intr_regs
const char * pid_list_str
struct thread_map * threads
s64 perf_event__process_auxtrace(struct perf_tool *tool, union perf_event *event, struct perf_session *session)
struct perf_counts * counts
int perf_event__process_auxtrace_info(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_session *session)
struct branch_stack * branch_stack
static int process_stat_round_event(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_session *session)
static int process_namespaces_event(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine)
static struct script_desc * script_desc__find(const char *name)
static void script__setup_sample_type(struct perf_script *script)
static int process_comm_event(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine)
size_t thread_stack__depth(struct thread *thread)
#define for_each_lang(scripts_path, scripts_dir, lang_dirent)
x86 movsq based memcpy() in arch/x86/lib/memcpy_64.S") MEMCPY_FN(memcpy_erms
struct thread_map * threads
struct symbol * map__find_symbol(struct map *map, u64 addr)
int perf_event__process_switch(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine)
int perf_script__meminfo_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
const char * perf_evsel__name(struct perf_evsel *evsel)
int perf_stat_process_counter(struct perf_stat_config *config, struct perf_evsel *counter)
int binary__fprintf(unsigned char *data, size_t len, size_t bytes_per_line, binary__fprintf_t printer, void *extra, FILE *fp)
static int thread_map__nr(struct thread_map *threads)
void perf_stat__init_shadow_stats(void)
struct perf_event_header header
static int perf_script__setup_per_event_dump(struct perf_script *script)
static int process_thread_map_event(struct perf_tool *tool, union perf_event *event, struct perf_session *session __maybe_unused)
void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 count, int cpu, struct runtime_stat *st)
static int set_maps(struct perf_script *script)
static int perf_sample__fprintf_uregs(struct perf_sample *sample, struct perf_event_attr *attr, FILE *fp)
int(* generate_script)(struct pevent *pevent, const char *outfile)
static struct @9 output[OUTPUT_TYPE_MAX]
struct option * record_options
struct perf_session * perf_session__new(struct perf_data *data, bool repipe, struct perf_tool *tool)
int script_spec_register(const char *spec, struct scripting_ops *ops)
int perf_event__process_mmap2(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine)
const char * kallsyms_name
#define for_each_group_member(_evsel, _leader)
size_t map__fprintf_dsoname(struct map *map, FILE *fp)
void thread__put(struct thread *thread)
int perf_time__percent_parse_str(struct perf_time_interval *ptime_buf, int num, const char *ostr, u64 start, u64 end)
unsigned long * cpu_bitmap
int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw)
int perf_session__process_events(struct perf_session *session)
static struct @10 sample_flags[]
struct perf_evsel * leader
int perf_event__process_stat_event(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_session *session)
static void script_desc__delete(struct script_desc *s)
static int list_available_scripts(const struct option *opt __maybe_unused, const char *s __maybe_unused, int unset __maybe_unused)
static void script_print_metric(void *ctx, const char *color, const char *fmt, const char *unit, double val)
static int process_mmap2_event(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine)
static unsigned int ncpus
static void __process_stat(struct perf_evsel *counter, u64 tstamp)
void perf_stat__reset_shadow_stats(void)
struct symbol * thread__find_symbol(struct thread *thread, u8 cpumode, u64 addr, struct addr_location *al)
u64 perf_evlist__combined_branch_type(struct perf_evlist *evlist)
struct perf_header header
static void setup_scripting(void)
static double percent(int st, int tot)
static int data_src__fprintf(u64 data_src, FILE *fp)
struct perf_evsel * perf_session__find_first_evtype(struct perf_session *session, unsigned int type)
size_t perf_event__fprintf(union perf_event *event, FILE *fp)
int symbol__init(struct perf_env *env)
static unsigned int nsecs
int(* start_script)(const char *script, int argc, const char **argv)
static int perf_sample__fprintf_synth_mwait(struct perf_sample *sample, FILE *fp)
static int parse_scriptname(const struct option *opt __maybe_unused, const char *str, int unset __maybe_unused)
int perf_event__process_id_index(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_session *session)
static int perf_sample__fprintf_synth_pwrx(struct perf_sample *sample, FILE *fp)
const char * sym_list_str
static int ip__fprintf_sym(uint64_t addr, struct thread *thread, u8 cpumode, int cpu, struct symbol **lastsym, struct perf_event_attr *attr, FILE *fp)
static pid_t thread_map__pid(struct thread_map *map, int thread)
enum perf_output_field field
struct scripting_ops * ops
static int process_sample_event(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct perf_evsel *evsel, struct machine *machine)
struct thread_map_event thread_map
static int perf_evsel__nr_cpus(struct perf_evsel *evsel)
static struct perf_counts_values * perf_counts(struct perf_counts *counts, int cpu, int thread)
static struct script_spec * script_spec__find(const char *spec)
int find_scripts(char **scripts_array, char **scripts_path_array)
int thread__resolve_callchain(struct thread *thread, struct callchain_cursor *cursor, struct perf_evsel *evsel, struct perf_sample *sample, struct symbol **parent, struct addr_location *root_al, int max_stack)
ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine, u64 offset, u8 *data, ssize_t size)
static struct perf_evsel * perf_evlist__last(struct perf_evlist *evlist)
#define PERF_IP_FLAG_CHARS
static bool is_top_script(const char *script_path)
static bool latency_format
bool sample_addr_correlates_sym(struct perf_event_attr *attr)
struct perf_stat_evsel * stats
int(* init)(struct perf_evsel *evsel)
static void process_stat_interval(u64 tstamp)
static int perf_sample__fprintf_synth_ptwrite(struct perf_sample *sample, FILE *fp)
char * machine__resolve_kernel_addr(void *vmachine, unsigned long long *addrp, char **modp)
static void process_stat(struct perf_evsel *counter, u64 tstamp)
#define pr_warning(fmt,...)
int perf_session__cpu_bitmap(struct perf_session *session, const char *cpu_list, unsigned long *cpu_bitmap)
static struct perf_stat_config stat_config
void perf_session__fprintf_info(struct perf_session *session, FILE *fp, bool full)
static bool evsel__has_callchain(const struct perf_evsel *evsel)
static int perf_sample__fprintf_insn(struct perf_sample *sample, struct perf_event_attr *attr, struct thread *thread, struct machine *machine, FILE *fp)
struct perf_time_interval * ptime_range
int perf_event__process_namespaces(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine)
int map__load(struct map *map)
static int perf_sample__fprintf_synth_exstop(struct perf_sample *sample, FILE *fp)
void(* process_stat_interval)(u64 tstamp)
static int perf_evsel__check_attr(struct perf_evsel *evsel, struct perf_session *session)
void(* process_event)(union perf_event *event, struct perf_sample *sample, struct perf_evsel *evsel, struct addr_location *al)
static int process_switch_event(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine)
static int check_ev_match(char *dir_name, char *scriptname, struct perf_session *session)
static struct scripting_ops * script_spec__lookup(const char *spec)
struct perf_session * session
struct thread * machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid)
int perf_time__parse_str(struct perf_time_interval *ptime, const char *ostr)
struct perf_event_attr attr
static char mispred_str(struct branch_entry *br)
struct branch_flags flags
void perf_event__read_stat_config(struct perf_stat_config *config, struct stat_config_event *event)
static int perf_sample__fprintf_bpf_output(struct perf_sample *sample, FILE *fp)
#define perf_script__process_auxtrace_info
void static void * zalloc(size_t size)
static const char * output_field2str(enum perf_output_field field)