aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/probe-event.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/probe-event.c')
-rw-r--r--tools/perf/util/probe-event.c60
1 files changed, 1 insertions, 59 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 30545ce2c712..d8bb616ff57c 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -332,6 +332,7 @@ static int find_alternative_probe_point(struct debuginfo *dinfo,
332 else { 332 else {
333 result->offset += pp->offset; 333 result->offset += pp->offset;
334 result->line += pp->line; 334 result->line += pp->line;
335 result->retprobe = pp->retprobe;
335 ret = 0; 336 ret = 0;
336 } 337 }
337 338
@@ -654,65 +655,6 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
654 return ntevs; 655 return ntevs;
655} 656}
656 657
657/*
658 * Find a src file from a DWARF tag path. Prepend optional source path prefix
659 * and chop off leading directories that do not exist. Result is passed back as
660 * a newly allocated path on success.
661 * Return 0 if file was found and readable, -errno otherwise.
662 */
663static int get_real_path(const char *raw_path, const char *comp_dir,
664 char **new_path)
665{
666 const char *prefix = symbol_conf.source_prefix;
667
668 if (!prefix) {
669 if (raw_path[0] != '/' && comp_dir)
670 /* If not an absolute path, try to use comp_dir */
671 prefix = comp_dir;
672 else {
673 if (access(raw_path, R_OK) == 0) {
674 *new_path = strdup(raw_path);
675 return *new_path ? 0 : -ENOMEM;
676 } else
677 return -errno;
678 }
679 }
680
681 *new_path = malloc((strlen(prefix) + strlen(raw_path) + 2));
682 if (!*new_path)
683 return -ENOMEM;
684
685 for (;;) {
686 sprintf(*new_path, "%s/%s", prefix, raw_path);
687
688 if (access(*new_path, R_OK) == 0)
689 return 0;
690
691 if (!symbol_conf.source_prefix) {
692 /* In case of searching comp_dir, don't retry */
693 zfree(new_path);
694 return -errno;
695 }
696
697 switch (errno) {
698 case ENAMETOOLONG:
699 case ENOENT:
700 case EROFS:
701 case EFAULT:
702 raw_path = strchr(++raw_path, '/');
703 if (!raw_path) {
704 zfree(new_path);
705 return -ENOENT;
706 }
707 continue;
708
709 default:
710 zfree(new_path);
711 return -errno;
712 }
713 }
714}
715
716#define LINEBUF_SIZE 256 658#define LINEBUF_SIZE 256
717#define NR_ADDITIONAL_LINES 2 659#define NR_ADDITIONAL_LINES 2
718 660