diff options
Diffstat (limited to 'tools/perf/util/probe-event.c')
-rw-r--r-- | tools/perf/util/probe-event.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 28eb1417cb2a..919937eb0be2 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -446,7 +446,7 @@ static int post_process_probe_trace_events(struct probe_trace_event *tevs, | |||
446 | } | 446 | } |
447 | 447 | ||
448 | for (i = 0; i < ntevs; i++) { | 448 | for (i = 0; i < ntevs; i++) { |
449 | if (tevs[i].point.address) { | 449 | if (tevs[i].point.address && !tevs[i].point.retprobe) { |
450 | tmp = strdup(reloc_sym->name); | 450 | tmp = strdup(reloc_sym->name); |
451 | if (!tmp) | 451 | if (!tmp) |
452 | return -ENOMEM; | 452 | return -ENOMEM; |
@@ -495,9 +495,11 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev, | |||
495 | } | 495 | } |
496 | 496 | ||
497 | if (ntevs == 0) { /* No error but failed to find probe point. */ | 497 | if (ntevs == 0) { /* No error but failed to find probe point. */ |
498 | pr_warning("Probe point '%s' not found.\n", | 498 | pr_warning("Probe point '%s' not found in debuginfo.\n", |
499 | synthesize_perf_probe_point(&pev->point)); | 499 | synthesize_perf_probe_point(&pev->point)); |
500 | return -ENOENT; | 500 | if (need_dwarf) |
501 | return -ENOENT; | ||
502 | return 0; | ||
501 | } | 503 | } |
502 | /* Error path : ntevs < 0 */ | 504 | /* Error path : ntevs < 0 */ |
503 | pr_debug("An error occurred in debuginfo analysis (%d).\n", ntevs); | 505 | pr_debug("An error occurred in debuginfo analysis (%d).\n", ntevs); |
@@ -2050,9 +2052,11 @@ static int write_probe_trace_event(int fd, struct probe_trace_event *tev) | |||
2050 | pr_debug("Writing event: %s\n", buf); | 2052 | pr_debug("Writing event: %s\n", buf); |
2051 | if (!probe_event_dry_run) { | 2053 | if (!probe_event_dry_run) { |
2052 | ret = write(fd, buf, strlen(buf)); | 2054 | ret = write(fd, buf, strlen(buf)); |
2053 | if (ret <= 0) | 2055 | if (ret <= 0) { |
2056 | ret = -errno; | ||
2054 | pr_warning("Failed to write event: %s\n", | 2057 | pr_warning("Failed to write event: %s\n", |
2055 | strerror_r(errno, sbuf, sizeof(sbuf))); | 2058 | strerror_r(errno, sbuf, sizeof(sbuf))); |
2059 | } | ||
2056 | } | 2060 | } |
2057 | free(buf); | 2061 | free(buf); |
2058 | return ret; | 2062 | return ret; |
@@ -2189,18 +2193,17 @@ static int __add_probe_trace_events(struct perf_probe_event *pev, | |||
2189 | return ret; | 2193 | return ret; |
2190 | } | 2194 | } |
2191 | 2195 | ||
2192 | static char *looking_function_name; | 2196 | static int find_probe_functions(struct map *map, char *name) |
2193 | static int num_matched_functions; | ||
2194 | |||
2195 | static int probe_function_filter(struct map *map __maybe_unused, | ||
2196 | struct symbol *sym) | ||
2197 | { | 2197 | { |
2198 | if ((sym->binding == STB_GLOBAL || sym->binding == STB_LOCAL) && | 2198 | int found = 0; |
2199 | strcmp(looking_function_name, sym->name) == 0) { | 2199 | struct symbol *sym; |
2200 | num_matched_functions++; | 2200 | |
2201 | return 0; | 2201 | map__for_each_symbol_by_name(map, name, sym) { |
2202 | if (sym->binding == STB_GLOBAL || sym->binding == STB_LOCAL) | ||
2203 | found++; | ||
2202 | } | 2204 | } |
2203 | return 1; | 2205 | |
2206 | return found; | ||
2204 | } | 2207 | } |
2205 | 2208 | ||
2206 | #define strdup_or_goto(str, label) \ | 2209 | #define strdup_or_goto(str, label) \ |
@@ -2218,10 +2221,10 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev, | |||
2218 | struct kmap *kmap = NULL; | 2221 | struct kmap *kmap = NULL; |
2219 | struct ref_reloc_sym *reloc_sym = NULL; | 2222 | struct ref_reloc_sym *reloc_sym = NULL; |
2220 | struct symbol *sym; | 2223 | struct symbol *sym; |
2221 | struct rb_node *nd; | ||
2222 | struct probe_trace_event *tev; | 2224 | struct probe_trace_event *tev; |
2223 | struct perf_probe_point *pp = &pev->point; | 2225 | struct perf_probe_point *pp = &pev->point; |
2224 | struct probe_trace_point *tp; | 2226 | struct probe_trace_point *tp; |
2227 | int num_matched_functions; | ||
2225 | int ret, i; | 2228 | int ret, i; |
2226 | 2229 | ||
2227 | /* Init maps of given executable or kernel */ | 2230 | /* Init maps of given executable or kernel */ |
@@ -2238,10 +2241,8 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev, | |||
2238 | * Load matched symbols: Since the different local symbols may have | 2241 | * Load matched symbols: Since the different local symbols may have |
2239 | * same name but different addresses, this lists all the symbols. | 2242 | * same name but different addresses, this lists all the symbols. |
2240 | */ | 2243 | */ |
2241 | num_matched_functions = 0; | 2244 | num_matched_functions = find_probe_functions(map, pp->function); |
2242 | looking_function_name = pp->function; | 2245 | if (num_matched_functions == 0) { |
2243 | ret = map__load(map, probe_function_filter); | ||
2244 | if (ret || num_matched_functions == 0) { | ||
2245 | pr_err("Failed to find symbol %s in %s\n", pp->function, | 2246 | pr_err("Failed to find symbol %s in %s\n", pp->function, |
2246 | target ? : "kernel"); | 2247 | target ? : "kernel"); |
2247 | ret = -ENOENT; | 2248 | ret = -ENOENT; |
@@ -2253,7 +2254,7 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev, | |||
2253 | goto out; | 2254 | goto out; |
2254 | } | 2255 | } |
2255 | 2256 | ||
2256 | if (!pev->uprobes) { | 2257 | if (!pev->uprobes && !pp->retprobe) { |
2257 | kmap = map__kmap(map); | 2258 | kmap = map__kmap(map); |
2258 | reloc_sym = kmap->ref_reloc_sym; | 2259 | reloc_sym = kmap->ref_reloc_sym; |
2259 | if (!reloc_sym) { | 2260 | if (!reloc_sym) { |
@@ -2271,7 +2272,8 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev, | |||
2271 | } | 2272 | } |
2272 | 2273 | ||
2273 | ret = 0; | 2274 | ret = 0; |
2274 | map__for_each_symbol(map, sym, nd) { | 2275 | |
2276 | map__for_each_symbol_by_name(map, pp->function, sym) { | ||
2275 | tev = (*tevs) + ret; | 2277 | tev = (*tevs) + ret; |
2276 | tp = &tev->point; | 2278 | tp = &tev->point; |
2277 | if (ret == num_matched_functions) { | 2279 | if (ret == num_matched_functions) { |