23 #include <sys/utsname.h> 24 #include <sys/types.h> 45 #include <api/fs/fs.h> 55 #define PERFPROBE_GROUP "probe" 60 #define semantic_error(msg ...) pr_err("Semantic error :" msg) 67 ret = vsnprintf(str, size, format, ap);
85 pr_debug(
"Failed to init symbol map.\n");
89 if (host_machine || user_only)
97 pr_debug(
"machine__new_host() failed.\n");
130 bool reloc,
bool reladdr)
138 if (reloc_sym && strcmp(name, reloc_sym->
name) == 0)
146 ((reladdr) ? map->
start : 0);
157 if (module && strchr(module,
'/'))
191 char *ptr1, *ptr2, *exec_copy;
195 exec_copy = strdup(exec);
199 ptr1 = basename(exec_copy);
205 for (ptr2 = ptr1; *ptr2 !=
'\0'; ptr2++) {
206 if (!
isalnum(*ptr2) && *ptr2 !=
'_') {
216 *result = strdup(buf);
217 ret = *result ? 0 : -ENOMEM;
235 for (i = 0; i < ntevs; i++)
249 if (ret == 0 && etext_addr < address)
250 pr_warning(
"%s is out of .text, skip it.\n", symbol);
252 pr_warning(
"%s is blacklisted function, skip it.\n", symbol);
272 char *mod_name = NULL;
275 fd = open(module, O_RDONLY);
283 if (gelf_getehdr(elf, &ehdr) == NULL)
287 ".gnu.linkonce.this_module", NULL);
291 data = elf_getdata(sec, NULL);
292 if (!data || !data->d_buf)
304 if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
309 mod_name = strdup((
char *)data->d_buf + name_offset);
318 #ifdef HAVE_DWARF_SUPPORT 320 static int kernel_get_module_dso(
const char *module,
struct dso **pdso)
324 const char *vmlinux_name;
328 char module_name[128];
330 snprintf(module_name,
sizeof(module_name),
"[%s]", module);
336 pr_debug(
"Failed to find module %s.\n", module);
359 static int find_alternative_probe_point(
struct debuginfo *dinfo,
381 address = sym->
start;
390 pr_debug(
"Symbol %s address found : %" PRIx64
"\n",
396 ret = (!ret) ? -ENOENT : ret;
410 static int get_alternative_probe_event(
struct debuginfo *dinfo,
418 ret = find_alternative_probe_point(dinfo, tmp, &pev->
point, pev->
target,
426 static int get_alternative_line_range(
struct debuginfo *dinfo,
428 const char *
target,
bool user)
436 memset(&result, 0,
sizeof(result));
438 if (lr->
end != INT_MAX)
440 ret = find_alternative_probe_point(dinfo, &pp, &result,
446 if (lr->
end != INT_MAX)
454 static struct debuginfo *open_debuginfo(
const char *module,
struct nsinfo *nsi,
457 const char *path = module;
459 struct debuginfo *ret = NULL;
464 if (!module || !strchr(module,
'/')) {
465 err = kernel_get_module_dso(module, &dso);
469 strcpy(reason,
"(unknown)");
473 pr_err(
"Failed to find the path for %s: %s\n",
474 module ?:
"kernel", reason);
481 if (!ret && !silent) {
482 pr_warning(
"The %s file has no debug information.\n", path);
484 pr_warning(
"Rebuild with CONFIG_DEBUG_INFO=y, ");
487 pr_warning(
"or install an appropriate debuginfo package.\n");
494 static struct debuginfo *debuginfo_cache;
495 static char *debuginfo_cache_path;
497 static struct debuginfo *debuginfo_cache__open(
const char *module,
bool silent)
499 const char *path = module;
505 if (debuginfo_cache_path && !strcmp(debuginfo_cache_path, path))
509 free(debuginfo_cache_path);
510 debuginfo_cache_path = strdup(path);
511 if (!debuginfo_cache_path) {
513 debuginfo_cache = NULL;
517 debuginfo_cache = open_debuginfo(module, NULL, silent);
518 if (!debuginfo_cache)
519 zfree(&debuginfo_cache_path);
521 return debuginfo_cache;
527 debuginfo_cache = NULL;
528 zfree(&debuginfo_cache_path);
532 static int get_text_start_address(
const char *exec,
unsigned long *address,
538 int fd, ret = -ENOENT;
542 fd = open(exec, O_RDONLY);
553 if (gelf_getehdr(elf, &ehdr) == NULL)
559 *address = shdr.sh_addr - shdr.sh_offset;
576 struct debuginfo *dinfo = NULL;
577 unsigned long stext = 0;
587 ret = get_text_start_address(tp->
module, &stext, NULL);
600 pr_debug(
"try to find information at %" PRIx64
" in %s\n", addr,
606 (
unsigned long)addr, pp);
615 pr_debug(
"Failed to find corresponding probes from debuginfo.\n");
616 return ret ? : -ENOENT;
621 struct map *
map,
unsigned long offs)
656 int ntevs,
const char *pathname)
659 unsigned long stext = 0;
664 if (!map || get_text_start_address(pathname, &stext, NULL) < 0) {
665 pr_warning(
"Failed to get ELF symbols for %s\n", pathname);
669 for (i = 0; i < ntevs; i++) {
670 ret = post_process_probe_trace_point(&tevs[i].point,
681 int ntevs,
const char *exec,
685 unsigned long stext = 0;
690 ret = get_text_start_address(exec, &stext, nsi);
694 for (i = 0; i < ntevs && ret >= 0; i++) {
698 if (!tevs[i].point.module) {
710 int ntevs,
const char *module,
711 struct debuginfo *dinfo)
713 Dwarf_Addr text_offs = 0;
715 char *mod_name = NULL;
723 pr_warning(
"Failed to get ELF symbols for %s\n", module);
728 for (i = 0; i < ntevs; i++) {
729 ret = post_process_probe_trace_point(&tevs[i].point,
730 map, (
unsigned long)text_offs);
734 strdup(mod_name ? mod_name : module);
735 if (!tevs[i].point.module) {
757 return post_process_offline_probe_trace_events(tevs, ntevs,
762 pr_warning(
"Relocated base symbol is not found!\n");
766 for (i = 0; i < ntevs; i++) {
767 if (!tevs[i].point.address)
777 tmp = strdup(reloc_sym->
name);
782 if (!tevs[i].point.realname)
785 free(tevs[i].point.symbol);
795 int ntevs __maybe_unused)
802 int ntevs,
const char *module,
803 bool uprobe,
struct debuginfo *dinfo)
808 ret = add_exec_to_probe_trace_events(tevs, ntevs, module,
812 ret = post_process_module_probe_trace_events(tevs, ntevs,
815 ret = post_process_kernel_probe_trace_events(tevs, ntevs);
829 struct debuginfo *dinfo;
832 dinfo = open_debuginfo(pev->
target, pev->
nsi, !need_dwarf);
836 pr_debug(
"Could not open debuginfo. Try to use symbols.\n");
840 pr_debug(
"Try to find probe point from debuginfo.\n");
845 ret = get_alternative_probe_event(dinfo, pev, &tmp);
858 pr_debug(
"Found %d probe_trace_events.\n", ntevs);
859 ret = post_process_probe_trace_events(pev, *tevs, ntevs,
861 if (ret < 0 || ret == ntevs) {
862 pr_debug(
"Post processing failed or all events are skipped. (%d)\n", ret);
875 }
else if (ntevs < 0) {
877 pr_debug(
"An error occurred in debuginfo analysis (%d).\n", ntevs);
879 pr_warning(
"Warning: No dwarf info found in the vmlinux - " 880 "please rebuild kernel with CONFIG_DEBUG_INFO=y.\n");
882 pr_debug(
"Trying to use symbols.\n");
889 #define LINEBUF_SIZE 256 890 #define NR_ADDITIONAL_LINES 2 892 static int __show_one_line(FILE *fp,
int l,
bool skip,
bool show_num)
896 const char *prefix = NULL;
899 if (fgets(buf, LINEBUF_SIZE, fp) == NULL)
904 prefix = show_num ?
"%7d " :
" ";
909 }
while (strchr(buf,
'\n') == NULL);
915 str_error_r(errno, sbuf,
sizeof(sbuf)));
921 static int _show_one_line(FILE *fp,
int l,
bool skip,
bool show_num)
923 int rv = __show_one_line(fp, l,
skip, show_num);
925 pr_warning(
"Source file is shorter than expected.\n");
931 #define show_one_line_with_num(f,l) _show_one_line(f,l,false,true) 932 #define show_one_line(f,l) _show_one_line(f,l,false,false) 933 #define skip_one_line(f,l) _show_one_line(f,l,true,false) 934 #define show_one_line_or_eof(f,l) __show_one_line(f,l,false,false) 940 static int __show_line_range(
struct line_range *lr,
const char *module,
945 struct debuginfo *dinfo;
952 dinfo = open_debuginfo(module, NULL,
false);
958 ret = get_alternative_line_range(dinfo, lr, module, user);
963 if (ret == 0 || ret == -ENOENT) {
964 pr_warning(
"Specified source line is not found.\n");
966 }
else if (ret < 0) {
980 pr_warning(
"Failed to find source file path.\n");
990 fprintf(stdout,
"<%s:%d>\n", lr->
path, lr->
start);
992 fp = fopen(lr->
path,
"r");
995 str_error_r(errno, sbuf,
sizeof(sbuf)));
999 while (l < lr->
start) {
1000 ret = skip_one_line(fp, l++);
1006 for (; ln->
i > l; l++) {
1007 ret = show_one_line(fp, l - lr->
offset);
1011 ret = show_one_line_with_num(fp, l++ - lr->
offset);
1016 if (lr->
end == INT_MAX)
1017 lr->
end = l + NR_ADDITIONAL_LINES;
1018 while (l <= lr->end) {
1019 ret = show_one_line_or_eof(fp, l++ - lr->
offset);
1029 struct nsinfo *nsi,
bool user)
1038 ret = __show_line_range(lr, module, user);
1045 static int show_available_vars_at(
struct debuginfo *dinfo,
1059 pr_debug(
"Searching variables at %s\n", buf);
1063 ret = get_alternative_probe_event(dinfo, pev, &tmp);
1072 if (ret == 0 || ret == -ENOENT) {
1073 pr_err(
"Failed to find the address of %s\n", buf);
1081 fprintf(stdout,
"Available variables at %s\n", buf);
1082 for (i = 0; i < ret; i++) {
1088 fprintf(stdout,
"\t@<%s+%lu>\n", vl->point.symbol,
1090 zfree(&vl->point.symbol);
1094 var = strchr(node->
s,
'\t') + 1;
1096 fprintf(stdout,
"\t\t%s\n", node->
s);
1103 fprintf(stdout,
"\t\t(No matched variables)\n");
1116 struct debuginfo *dinfo;
1122 dinfo = open_debuginfo(pevs->
target, pevs->
nsi,
false);
1130 for (i = 0; i < npevs && ret >= 0; i++)
1131 ret = show_available_vars_at(dinfo, &pevs[i], _filter);
1148 bool is_kprobe __maybe_unused)
1157 pr_warning(
"Debuginfo-analysis is not supported.\n");
1165 const char *module __maybe_unused,
1166 struct nsinfo *nsi __maybe_unused,
1167 bool user __maybe_unused)
1169 pr_warning(
"Debuginfo-analysis is not supported.\n");
1174 int npevs __maybe_unused,
1177 pr_warning(
"Debuginfo-analysis is not supported.\n");
1189 memset(lr, 0,
sizeof(*lr));
1194 memset(lr, 0,
sizeof(*lr));
1204 const char *
start = *ptr;
1207 *val = strtol(*ptr, ptr, 0);
1208 if (errno || *ptr == start) {
1218 if (!
isalpha(*name) && *name !=
'_')
1220 while (*++name !=
'\0') {
1236 char *range, *file, *
name = strdup(arg);
1245 range = strchr(name,
':');
1253 if (*range ==
'+' || *range ==
'-') {
1254 const char c = *range++;
1277 " than end line.\n");
1280 if (*range !=
'\0') {
1286 file = strchr(name,
'@');
1289 lr->
file = strdup(++file);
1290 if (lr->
file == NULL) {
1295 }
else if (strchr(name,
'/') || strchr(name,
'.'))
1328 if (pev->
event == NULL)
1336 "follow C symbol-naming rule.\n", *arg);
1348 bool file_spec =
false;
1393 if (ptr && *ptr ==
'=') {
1417 if (ptr && memchr(arg,
'.', ptr - arg))
1449 if (tmp && !strncmp(tmp,
"0x", 2)) {
1475 pp->
line = strtoul(arg, &tmp, 0);
1478 " in line number.\n");
1483 pp->
offset = strtoul(arg, &tmp, 0);
1496 if (pp->
file == NULL)
1500 if (strcmp(arg,
"return") == 0) {
1508 pr_err(
"This program has a bug at %s:%d.\n",
1509 __FILE__, __LINE__);
1549 pr_debug(
"symbol:%s file:%s line:%d offset:%lu return:%d lazy:%s\n",
1558 char *tmp, *goodname;
1561 pr_debug(
"parsing arg: %s into ", str);
1563 tmp = strchr(str,
'=');
1565 arg->
name = strndup(str, tmp - str);
1566 if (arg->
name == NULL)
1572 tmp = strchr(str,
':');
1575 arg->
type = strdup(tmp + 1);
1576 if (arg->
type == NULL)
1581 tmp = strpbrk(str,
"-.[");
1584 arg->
var = strdup(str);
1585 if (arg->
var == NULL)
1592 arg->
var = strndup(str, tmp - str);
1593 if (arg->
var == NULL)
1595 goodname = arg->
var;
1597 fieldp = &arg->
field;
1601 if (*fieldp == NULL)
1605 (*fieldp)->index = strtol(str + 1, &tmp, 0);
1606 (*fieldp)->ref =
true;
1607 if (*tmp !=
']' || tmp == str + 1) {
1618 (*fieldp)->ref =
false;
1619 }
else if (tmp[1] ==
'>') {
1621 (*fieldp)->ref =
true;
1627 tmp = strpbrk(str,
"-.[");
1630 (*fieldp)->name = strndup(str, tmp - str);
1631 if ((*fieldp)->name == NULL)
1634 goodname = (*fieldp)->name;
1635 pr_debug(
"%s(%d), ", (*fieldp)->name, (*fieldp)->ref);
1636 fieldp = &(*fieldp)->
next;
1639 (*fieldp)->
name = strdup(str);
1640 if ((*fieldp)->name == NULL)
1643 goodname = (*fieldp)->name;
1644 pr_debug(
"%s(%d)\n", (*fieldp)->name, (*fieldp)->ref);
1648 arg->
name = strdup(goodname);
1649 if (arg->
name == NULL)
1659 int argc, i, ret = 0;
1663 pr_debug(
"Failed to split arguments.\n");
1677 pev->
nargs = argc - 1;
1679 if (pev->
args == NULL) {
1683 for (i = 0; i < pev->
nargs && ret >= 0; i++) {
1703 for (i = 0; i < pev->
nargs; i++)
1729 char *argv0_str = NULL, *
fmt, *fmt1_str, *fmt2_str, *fmt3_str;
1733 pr_debug(
"Parsing probe_events: %s\n", cmd);
1736 pr_debug(
"Failed to split arguments.\n");
1746 argv0_str = strdup(argv[0]);
1747 if (argv0_str == NULL) {
1751 fmt1_str = strtok_r(argv0_str,
":", &fmt);
1752 fmt2_str = strtok_r(NULL,
"/", &fmt);
1753 fmt3_str = strtok_r(NULL,
" \t", &fmt);
1754 if (fmt1_str == NULL || strlen(fmt1_str) != 1 || fmt2_str == NULL
1755 || fmt3_str == NULL) {
1761 tev->
group = strdup(fmt2_str);
1762 tev->
event = strdup(fmt3_str);
1763 if (tev->
group == NULL || tev->
event == NULL) {
1772 p = strchr(argv[1],
':');
1774 tp->
module = strndup(argv[1], p - argv[1]);
1783 fmt1_str = strtok_r(p,
"+", &fmt);
1785 if (fmt1_str[0] ==
'0') {
1793 if (strcmp(fmt1_str,
"0x") == 0) {
1794 if (!argv[2] || strcmp(argv[2],
"(null)")) {
1801 for (i = 2; argv[i + 1] != NULL; i++)
1802 argv[i] = argv[i + 1];
1807 tp->
address = strtoul(fmt1_str, NULL, 0);
1810 tp->
symbol = strdup(fmt1_str);
1811 if (tp->
symbol == NULL) {
1815 fmt2_str = strtok_r(NULL,
"", &fmt);
1816 if (fmt2_str == NULL)
1819 tp->
offset = strtoul(fmt2_str, NULL, 10);
1822 tev->
nargs = argc - 2;
1824 if (tev->
args == NULL) {
1828 for (i = 0; i < tev->
nargs; i++) {
1829 p = strchr(argv[i + 2],
'=');
1834 tev->
args[i].
name = strdup(argv[i + 2]);
1868 if (field->
name[0] ==
'[')
1873 field = field->
next;
1892 char *tmp, *ret = NULL;
1914 tmp = strchr(pp->
file + len - 30,
'/');
1915 tmp = tmp ? tmp + 1 : pp->
file + len - 30;
1931 char *tmp, *ret = NULL;
1946 for (i = 0; i < pev->
nargs; i++) {
1970 return (err < 0) ?
err : depth;
1988 if (arg->
value[0] ==
'@' && arg->
ref)
1999 if (arg->
value[0] ==
'@' && arg->
ref)
2005 while (!
err && depth--)
2046 else if (!strncmp(tp->
symbol,
"0x", 2))
2056 for (i = 0; i < tev->
nargs; i++)
2071 struct map *map = NULL;
2081 if (tp->
symbol && !addr) {
2083 &addr,
true,
false) < 0)
2101 if (map && !is_kprobe) {
2122 pr_debug(
"Failed to find probe point from both of dwarf and map.\n");
2151 if (pev->
event == NULL || pev->
group == NULL)
2162 if (pev->
args == NULL)
2164 for (i = 0; i < tev->
nargs && ret >= 0; i++) {
2173 if (pev->
args[i].
name == NULL && ret >= 0)
2193 for (i = 0; i < pev->
nargs; i++) {
2206 memset(pev, 0,
sizeof(*pev));
2209 #define strdup_or_goto(str, label) \ 2210 ({ char *__p = NULL; if (str && !(__p = strdup(str))) goto label; __p; }) 2238 ppfield = &(dst->
field);
2240 *ppfield =
zalloc(
sizeof(*field));
2244 (*ppfield)->index = field->
index;
2245 (*ppfield)->ref = field->
ref;
2246 field = field->
next;
2247 ppfield = &((*ppfield)->next);
2272 for (i = 0; i < src->
nargs; i++)
2292 for (i = 0; i < tev->
nargs; i++) {
2304 memset(tev, 0,
sizeof(*tev));
2318 while (!list_empty(blacklist)) {
2319 node = list_first_entry(blacklist,
2321 list_del(&node->
list);
2330 const char *__debugfs = debugfs__mountpoint();
2335 if (__debugfs == NULL)
2342 fp = fopen(buf,
"r");
2348 node =
zalloc(
sizeof(*node));
2353 INIT_LIST_HEAD(&node->
list);
2354 list_add_tail(&node->
list, blacklist);
2355 if (sscanf(buf,
"0x%lx-0x%lx", &node->
start, &node->
end) != 2) {
2359 p = strchr(buf,
'\t');
2362 if (p[strlen(p) - 1] ==
'\n')
2363 p[strlen(p) - 1] =
'\0';
2365 p = (
char *)
"unknown";
2366 node->
symbol = strdup(p);
2371 pr_debug2(
"Blacklist: 0x%lx-0x%lx, %s\n",
2384 unsigned long address)
2388 list_for_each_entry(node, blacklist,
list) {
2389 if (node->
start <= address && address < node->
end)
2400 if (!list_empty(&kprobe_blacklist))
2404 pr_debug(
"No kprobe blacklist support, ignored\n");
2425 if (asprintf(&buf,
"%s:%s", group, event) < 0)
2442 if (!ret && pev->
nargs > 0) {
2444 for (i = 0; !ret && i < pev->
nargs; i++) {
2461 const char *module,
bool use_stdout)
2469 printf(
"%s\n", buf.
buf);
2502 memset(&tev, 0,
sizeof(tev));
2503 memset(&pev, 0,
sizeof(pev));
2538 int kp_fd, up_fd, ret;
2555 if (up_fd >= 0 && ret >= 0)
2567 struct strlist *namelist,
bool ret_event,
2575 nbase = strdup(base);
2580 p = strpbrk(nbase,
".@");
2581 if (p && p != nbase)
2585 ret =
e_snprintf(buf, len,
"%s%s", nbase, ret_event ?
"__return" :
"");
2587 pr_debug(
"snprintf() failed: %d\n", ret);
2593 if (!allow_suffix) {
2594 pr_warning(
"Error: event \"%s\" already exists.\n" 2595 " Hint: Remove existing event by 'perf probe -d'\n" 2596 " or force duplicates by 'perf probe -f'\n" 2597 " or set 'force=yes' in BPF source.\n",
2605 ret =
e_snprintf(buf, len,
"%s_%d", nbase, i);
2607 pr_debug(
"snprintf() failed: %d\n", ret);
2613 if (i == MAX_EVENT_INDEX) {
2614 pr_warning(
"Too many events are on the same function.\n");
2623 pr_warning(
"Internal error: \"%s\" is an invalid event name.\n",
2641 for (i = 0; i < tev->
nargs; i++)
2643 pr_warning(
"Please upgrade your kernel to at least " 2644 "3.14 to have access to feature %s\n",
2665 else if (tev->
event)
2678 else if (tev->
group)
2691 tev->
event = strdup(event);
2692 tev->
group = strdup(group);
2693 if (tev->
event == NULL || tev->
group == NULL)
2713 pr_debug(
"Failed to get current event list.\n");
2722 int ntevs,
bool allow_suffix)
2724 int i, fd[2] = {-1, -1}, up, ret;
2727 struct strlist *namelist[2] = {NULL, NULL};
2736 for (i = 0; i < ntevs; i++) {
2767 allow_suffix =
true;
2769 if (ret == -EINVAL && pev->
uprobes)
2776 pr_warning(
"Failed to add event to probe cache\n");
2781 for (up = 0; up < 2; up++) {
2794 struct rb_node *tmp;
2795 const char *norm, *ver;
2797 bool cut_version =
true;
2803 if (strchr(name,
'@'))
2804 cut_version =
false;
2813 ver = strchr(norm,
'@');
2815 buf = strndup(norm, ver - norm);
2825 syms[found - 1] =
sym;
2836 struct map *map __maybe_unused,
2846 struct map *map = NULL;
2853 int num_matched_functions;
2854 int ret, i, j, skipped = 0;
2874 if (num_matched_functions <= 0) {
2876 pev->
target ? :
"kernel");
2880 pr_err(
"Too many functions matched in %s\n",
2881 pev->
target ? :
"kernel");
2891 pr_warning(
"Relocated base symbol is not found!\n");
2898 *tevs =
zalloc(
sizeof(*tev) * num_matched_functions);
2906 for (j = 0; j < num_matched_functions; j++) {
2909 tev = (*tevs) + ret;
2911 if (ret == num_matched_functions) {
2912 pr_warning(
"Too many symbols are listed. Skip it.\n");
2918 pr_warning(
"Offset %ld is bigger than the size of %s\n",
2931 }
else if (reloc_sym) {
2948 strdup(mod_name ? mod_name : pev->
target);
2959 if (tev->
args == NULL)
2962 for (i = 0; i < tev->
nargs; i++) {
2977 if (ret == skipped) {
3014 *tevs =
zalloc(
sizeof(*tev));
3073 for (i = 0; i < tev->
nargs; i++)
3085 static void *
memcat(
void *a,
size_t sz_a,
void *b,
size_t sz_b)
3089 ret =
malloc(sz_a + sz_b);
3092 memcpy(ret + sz_a, b, sz_b);
3115 new_tevs =
memcat(*tevs, (*ntevs) *
sizeof(**tevs),
3116 *tevs2, ntevs2 *
sizeof(**tevs2));
3171 if (ntevs > 0 && target && target[0] ==
'/')
3193 pr_debug(
"Failed to get buildids: %d\n", ret);
3243 ret = pev->
sdt ? -ENOENT : 0;
3249 pr_debug(
"Too many entries matched in the cache of %s\n",
3250 pev->
target ? :
"kernel");
3255 *tevs =
zalloc(ret *
sizeof(*tev));
3263 tev = &(*tevs)[i++];
3286 ret = pev->
group ? 0 : -ENOMEM;
3290 pr_warning(
"Failed to make a group name.\n");
3301 if (ret > 0 || pev->
sdt)
3302 return ret == 0 ? -ENOENT : ret;
3317 for (i = 0; i < npevs; i++) {
3325 pevs[i].
ntevs = ret;
3338 pr_debug(
"Failed to synthesize probe trace event.\n");
3343 printf(
"%s\n", buf);
3359 for (j = 0; j < npevs && !ret; j++) {
3361 for (i = 0; i < pev->
ntevs && !ret; i++) {
3362 tev = &pev->
tevs[i];
3384 for (i = 0; i < npevs; i++) {
3400 for (i = 0; i < npevs; i++) {
3402 for (j = 0; j < pevs[i].
ntevs; j++)
3404 zfree(&pevs[i].tevs);
3431 int ret, ret2, ufd = -1, kfd = -1;
3443 if (ret < 0 && ret != -ENOENT)
3447 if (ret2 < 0 && ret2 != -ENOENT) {
3478 pr_err(
"Failed to get a map for %s\n", (target) ? :
"kernel");
3486 pr_err(
"Failed to find symbols matched to \"%s\"\n",
3490 pr_err(
"Failed to load symbols in %s\n",
3491 (target) ? :
"kernel");
3504 printf(
"%s\n", pos->
sym.
name);
3517 if (tvar->
value == NULL)
3521 if (tvar->
type == NULL)
3526 if (tvar->
name == NULL)
char * build_id_cache__origname(const char *sbuild_id)
int strbuf_init(struct strbuf *sb, ssize_t hint)
bool perf_probe_with_var(struct perf_probe_event *pev)
int debuginfo__find_line_range(struct debuginfo *dbg, struct line_range *lr)
int show_perf_probe_events(struct strfilter *filter)
int probe_cache__add_entry(struct probe_cache *pcache, struct perf_probe_event *pev, struct probe_trace_event *tevs, int ntevs)
#define intlist__for_each_entry(pos, ilist)
struct probe_cache_entry * probe_cache__find(struct probe_cache *pcache, struct perf_probe_event *pev)
static LIST_HEAD(kprobe_blacklist)
int color_fprintf(FILE *fp, const char *color, const char *fmt,...)
static bool is_c_func_name(const char *name)
int del_perf_probe_events(struct strfilter *filter)
struct map * map_groups__find_by_name(struct map_groups *mg, const char *name)
void clear_probe_trace_event(struct probe_trace_event *tev)
void nsinfo__mountns_enter(struct nsinfo *nsi, struct nscookie *nc)
int show_perf_probe_event(const char *group, const char *event, struct perf_probe_event *pev, const char *module, bool use_stdout)
#define strdup_or_goto(str, label)
const char * vmlinux_name
struct kmap * map__kmap(struct map *map)
int probe_file__open_both(int *kfd, int *ufd, int flag)
static void skip(int size)
static int probe_trace_event__set_name(struct probe_trace_event *tev, struct perf_probe_event *pev, struct strlist *namelist, bool allow_suffix)
struct probe_trace_point point
struct perf_probe_arg_field * next
static void clear_perf_probe_point(struct perf_probe_point *pp)
void argv_free(char **argv)
static int convert_to_probe_trace_events(struct perf_probe_event *pev, struct probe_trace_event **tevs)
int init_probe_symbol_maps(bool user_only)
void intlist__delete(struct intlist *ilist)
static bool strisglob(const char *str)
#define nsinfo__zput(nsi)
static int perf_probe_arg__copy(struct perf_probe_arg *dst, struct perf_probe_arg *src)
int strlist__add(struct strlist *slist, const char *new_entry)
struct rb_root symbol_names
#define map__for_each_symbol(map, pos, n)
static int perf_probe_point__copy(struct perf_probe_point *dst, struct perf_probe_point *src)
void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs)
int dso__strerror_load(struct dso *dso, char *buf, size_t buflen)
int probe_file__add_event(int fd, struct probe_trace_event *tev)
#define pr_debug2(fmt,...)
bool dso__sorted_by_name(const struct dso *dso)
struct map * dso__new_map(const char *name)
#define for_each_probe_cache_entry(entry, pcache)
struct strlist * probe_file__get_namelist(int fd)
struct perf_probe_point point
bool strglobmatch(const char *str, const char *pat)
static int try_to_find_probe_trace_events(struct perf_probe_event *pev, struct probe_trace_event **tevs __maybe_unused)
char * synthesize_perf_probe_arg(struct perf_probe_arg *pa)
static void kprobe_blacklist__release(void)
static unsigned int strlist__nr_entries(const struct strlist *slist)
static char * find_module_name(const char *module)
int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr, struct perf_probe_point *ppt)
x86 movsq based memset() in arch/x86/lib/memset_64.S") MEMSET_FN(memset_erms
int debuginfo__find_trace_events(struct debuginfo *dbg, struct perf_probe_event *pev, struct probe_trace_event **tevs)
bool kretprobe_offset_is_supported(void)
int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs)
static int find_cached_events(struct perf_probe_event *pev, struct probe_trace_event **tevs, const char *target)
void line_range__clear(struct line_range *lr)
#define PERF_ELF_C_READ_MMAP
static int try_to_find_absolute_address(struct perf_probe_event *pev, struct probe_trace_event **tevs)
char * synthesize_perf_probe_command(struct perf_probe_event *pev)
void map__put(struct map *map)
static struct symbol * machine__find_kernel_symbol_by_name(struct machine *machine, const char *name, struct map **mapp)
struct probe_trace_event * tevs
enum dso_load_errno load_errno
static int find_probe_trace_events_from_cache(struct perf_probe_event *pev, struct probe_trace_event **tevs)
char * synthesize_probe_trace_command(struct probe_trace_event *tev)
static void debuginfo_cache__exit(void)
int show_available_vars(struct perf_probe_event *pevs __maybe_unused, int npevs __maybe_unused, struct strfilter *filter __maybe_unused)
struct perf_probe_arg_field * field
int show_available_funcs(const char *target, struct nsinfo *nsi, struct strfilter *_filter, bool user)
static struct map * machine__kernel_map(struct machine *machine)
static void clear_probe_trace_events(struct probe_trace_event *tevs, int ntevs)
int parse_line_range_desc(const char *arg, struct line_range *lr)
#define map__for_each_symbol_by_name(map, sym_name, pos)
struct probe_trace_arg_ref * next
struct map * maps__first(struct maps *maps)
static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)
bool perf_probe_event_need_dwarf(struct perf_probe_event *pev)
void nsinfo__mountns_exit(struct nscookie *nc)
#define semantic_error(msg ...)
#define pr_debug(fmt,...)
static int find_cached_events_all(struct perf_probe_event *pev, struct probe_trace_event **tevs)
int probe_file__del_events(int fd, struct strfilter *filter)
int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs)
void dso__sort_by_name(struct dso *dso)
void clear_perf_probe_event(struct perf_probe_event *pev)
void exit_probe_symbol_maps(void)
struct map * map__next(struct map *map)
static int kprobe_blacklist__load(struct list_head *blacklist)
static int entry(u64 ip, struct unwind_info *ui)
static int __show_perf_probe_events(int fd, bool is_kprobe, struct strfilter *filter)
static void * memcat(void *a, size_t sz_a, void *b, size_t sz_b)
static int parse_perf_probe_arg(char *str, struct perf_probe_arg *arg)
static void kprobe_blacklist__delete(struct list_head *blacklist)
static struct machine * host_machine
Elf_Scn * elf_section_by_name(Elf *elf, GElf_Ehdr *ep, GElf_Shdr *shp, const char *name, size_t *idx)
static bool kprobe_blacklist__listed(unsigned long address)
static int __synthesize_probe_trace_arg_ref(struct probe_trace_arg_ref *ref, struct strbuf *buf, int depth)
struct intlist * line_list
static int str(yyscan_t scanner, int token)
static int __add_probe_trace_events(struct perf_probe_event *pev, struct probe_trace_event *tevs, int ntevs, bool allow_suffix)
int strbuf_add(struct strbuf *sb, const void *data, size_t len)
#define strlist__for_each_entry(pos, slist)
static struct ref_reloc_sym * kernel_get_ref_reloc_sym(void)
int get_real_path(const char *raw_path, const char *comp_dir, char **new_path)
struct probe_cache * probe_cache__new(const char *target, struct nsinfo *nsi)
static int __open_probe_file_and_namelist(bool uprobe, struct strlist **namelist)
static int strbuf_addstr(struct strbuf *sb, const char *s)
struct probe_trace_arg * args
char * strfilter__string(struct strfilter *filter)
struct ref_reloc_sym * ref_reloc_sym
char * strpbrk_esc(char *str, const char *stopset)
x86 movsq based memcpy() in arch/x86/lib/memcpy_64.S") MEMCPY_FN(memcpy_erms
bool strfilter__compare(struct strfilter *filter, const char *str)
struct symbol * map__find_symbol(struct map *map, u64 addr)
static struct map * kernel_get_module_map(const char *module)
bool ignore_vmlinux_buildid
void __weak arch__fix_tev_from_maps(struct perf_probe_event *pev __maybe_unused, struct probe_trace_event *tev __maybe_unused, struct map *map __maybe_unused, struct symbol *sym __maybe_unused)
static int get_new_event_name(char *buf, size_t len, const char *base, struct strlist *namelist, bool ret_event, bool allow_suffix)
void probe_cache__delete(struct probe_cache *pcache)
static int synthesize_probe_trace_arg(struct probe_trace_arg *arg, struct strbuf *buf)
static int find_perf_probe_point_from_map(struct probe_trace_point *tp, struct perf_probe_point *pp, bool is_kprobe)
int show_probe_trace_events(struct perf_probe_event *pevs, int npevs)
void arch__post_process_probe_trace_events(struct perf_probe_event *pev, int ntevs)
static struct map * map__get(struct map *map)
int add_perf_probe_events(struct perf_probe_event *pevs, int npevs)
static int convert_to_perf_probe_event(struct probe_trace_event *tev, struct perf_probe_event *pev, bool is_kprobe)
static int is_c_varname(const char *name)
int e_snprintf(char *str, size_t size, const char *format,...)
struct intlist * intlist__new(const char *slist)
struct nsinfo * nsinfo__get(struct nsinfo *nsi)
struct strfilter * filter
static int convert_to_perf_probe_point(struct probe_trace_point *tp, struct perf_probe_point *pp, bool is_kprobe)
int parse_perf_probe_command(const char *cmd, struct perf_probe_event *pev)
static void warn_uprobe_event_compat(struct probe_trace_event *tev)
int probe_cache__commit(struct probe_cache *pcache)
static int find_perf_probe_point_from_dwarf(struct probe_trace_point *tp __maybe_unused, struct perf_probe_point *pp __maybe_unused, bool is_kprobe __maybe_unused)
static int find_probe_trace_events_from_map(struct perf_probe_event *pev, struct probe_trace_event **tevs)
int copy_to_probe_trace_arg(struct probe_trace_arg *tvar, struct perf_probe_arg *pvar)
struct map * get_target_map(const char *target, struct nsinfo *nsi, bool user)
int strbuf_addch(struct strbuf *sb, int c)
unsigned long abs_address
char * strbuf_detach(struct strbuf *sb, size_t *sz)
static int parse_line_num(char **ptr, int *val, const char *what)
int show_line_range(struct line_range *lr __maybe_unused, const char *module __maybe_unused, struct nsinfo *nsi __maybe_unused, bool user __maybe_unused)
struct perf_probe_event pev
static int sym(yyscan_t scanner, int type, int config)
int probe_cache_entry__get_event(struct probe_cache_entry *entry, struct probe_trace_event **tevs)
void machine__delete(struct machine *machine)
static bool kprobe_warn_out_range(const char *symbol, unsigned long address)
int strtailcmp(const char *s1, const char *s2)
void strlist__delete(struct strlist *slist)
int probe_cache__show_all_caches(struct strfilter *filter)
static int perf_probe_event__sprintf(const char *group, const char *event, struct perf_probe_event *pev, const char *module, struct strbuf *result)
struct machine * machine__new_host(void)
static int convert_exec_to_group(const char *exec, char **result)
const char * arch__normalize_symbol_name(const char *name)
static void kprobe_blacklist__init(void)
static int show_probe_trace_event(struct probe_trace_event *tev)
int symbol__init(struct perf_env *env)
static struct symbol * machine__find_kernel_symbol(struct machine *machine, u64 addr, struct map **mapp)
struct strlist * build_id_cache__list_all(bool validonly)
int strbuf_addf(struct strbuf *sb, const char *fmt,...)
static int parse_perf_probe_event_name(char **arg, struct perf_probe_event *pev)
static int concat_probe_trace_events(struct probe_trace_event **tevs, int *ntevs, struct probe_trace_event **tevs2, int ntevs2)
static struct maps * machine__kernel_maps(struct machine *machine)
int parse_probe_trace_command(const char *cmd, struct probe_trace_event *tev)
int debuginfo__find_available_vars_at(struct debuginfo *dbg, struct perf_probe_event *pev, struct variable_list **vls)
int dso__load_vmlinux_path(struct dso *dso, struct map *map)
int perf_probe_event__copy(struct perf_probe_event *dst, struct perf_probe_event *src)
char * build_id_cache__complement(const char *incomplete_sbuild_id)
u64(* unmap_ip)(struct map *, u64)
static int find_probe_functions(struct map *map, char *name, struct symbol **syms)
int debuginfo__get_text_offset(struct debuginfo *dbg, Dwarf_Addr *offs, bool adjust_offset)
int probe_file__open(int flag)
struct perf_probe_arg * args
#define pr_warning(fmt,...)
static int kernel_get_symbol_address_by_name(const char *name, u64 *addr, bool reloc, bool reladdr)
void debuginfo__delete(struct debuginfo *dbg)
int line_range__init(struct line_range *lr)
int map__load(struct map *map)
char * strdup_esc(const char *str)
static struct kprobe_blacklist_node * kprobe_blacklist__find_by_address(struct list_head *blacklist, unsigned long address)
static bool strlist__has_entry(struct strlist *slist, const char *entry)
struct strlist * strlist__new(const char *list, const struct strlist_config *config)
static bool is_sdt_event(char *str __maybe_unused)
static bool filter_probe_trace_event(struct probe_trace_event *tev, struct strfilter *filter)
void strbuf_release(struct strbuf *sb)
char * synthesize_perf_probe_point(struct perf_probe_point *pp)
int dso__load_vmlinux(struct dso *dso, struct map *map, const char *vmlinux, bool vmlinux_allocated)
char ** argv_split(const char *str, int *argcp)
struct debuginfo * debuginfo__new(const char *path)
void static void * zalloc(size_t size)
struct strlist * probe_file__get_rawlist(int fd)
struct probe_trace_arg_ref * ref