lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 14 Apr 2015 15:35:33 +0900
From:	Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
To:	Arnaldo Carvalho de Melo <acme@...nel.org>
CC:	Naohiro Aota <naota@...sp.net>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Paul Mackerras <paulus@...ba.org>,
	Ingo Molnar <mingo@...hat.com>,
	Namhyung Kim <namhyung@...nel.org>,
	He Kuang <hekuang@...wei.com>, Jiri Olsa <jolsa@...nel.org>,
	"open list:PERFORMANCE EVENT..." <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3] perf probe: Find compilation directory path for lazy
 matching

(2015/04/14 8:10), Arnaldo Carvalho de Melo wrote:
> Em Fri, Mar 13, 2015 at 02:18:40PM +0900, Naohiro Aota escreveu:
>> If we use lazy matching, it failed to open a souce file if perf command
>> is invoked outside of compilation directory:
>>
>> $ perf probe -a '__schedule;clear_*'
>> Failed to open kernel/sched/core.c: No such file or directory
>>   Error: Failed to add events. (-2)
> 
> Masami, you mean this one, right?

Yes, this is what I meant :)

Thank you!

> 
> - Arnaldo
>  
>> OTOH, other commands like "probe -L" can solve the souce directory by
>> themselves. Let's make it possible for lazy matching too!
>>
>> Signed-off-by: Naohiro Aota <naota@...sp.net>
>> ---
>>  tools/perf/util/probe-event.c  | 59 -----------------------------------
>>  tools/perf/util/probe-finder.c | 71 +++++++++++++++++++++++++++++++++++++++++-
>>  tools/perf/util/probe-finder.h |  4 +++
>>  3 files changed, 74 insertions(+), 60 deletions(-)
>>
>> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
>> index f272a71..32a429b 100644
>> --- a/tools/perf/util/probe-event.c
>> +++ b/tools/perf/util/probe-event.c
>> @@ -648,65 +648,6 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
>>  	return ntevs;
>>  }
>>  
>> -/*
>> - * Find a src file from a DWARF tag path. Prepend optional source path prefix
>> - * and chop off leading directories that do not exist. Result is passed back as
>> - * a newly allocated path on success.
>> - * Return 0 if file was found and readable, -errno otherwise.
>> - */
>> -static int get_real_path(const char *raw_path, const char *comp_dir,
>> -			 char **new_path)
>> -{
>> -	const char *prefix = symbol_conf.source_prefix;
>> -
>> -	if (!prefix) {
>> -		if (raw_path[0] != '/' && comp_dir)
>> -			/* If not an absolute path, try to use comp_dir */
>> -			prefix = comp_dir;
>> -		else {
>> -			if (access(raw_path, R_OK) == 0) {
>> -				*new_path = strdup(raw_path);
>> -				return *new_path ? 0 : -ENOMEM;
>> -			} else
>> -				return -errno;
>> -		}
>> -	}
>> -
>> -	*new_path = malloc((strlen(prefix) + strlen(raw_path) + 2));
>> -	if (!*new_path)
>> -		return -ENOMEM;
>> -
>> -	for (;;) {
>> -		sprintf(*new_path, "%s/%s", prefix, raw_path);
>> -
>> -		if (access(*new_path, R_OK) == 0)
>> -			return 0;
>> -
>> -		if (!symbol_conf.source_prefix) {
>> -			/* In case of searching comp_dir, don't retry */
>> -			zfree(new_path);
>> -			return -errno;
>> -		}
>> -
>> -		switch (errno) {
>> -		case ENAMETOOLONG:
>> -		case ENOENT:
>> -		case EROFS:
>> -		case EFAULT:
>> -			raw_path = strchr(++raw_path, '/');
>> -			if (!raw_path) {
>> -				zfree(new_path);
>> -				return -ENOENT;
>> -			}
>> -			continue;
>> -
>> -		default:
>> -			zfree(new_path);
>> -			return -errno;
>> -		}
>> -	}
>> -}
>> -
>>  #define LINEBUF_SIZE 256
>>  #define NR_ADDITIONAL_LINES 2
>>  
>> diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
>> index 46f009a..0fd2df4 100644
>> --- a/tools/perf/util/probe-finder.c
>> +++ b/tools/perf/util/probe-finder.c
>> @@ -849,11 +849,22 @@ static int probe_point_lazy_walker(const char *fname, int lineno,
>>  static int find_probe_point_lazy(Dwarf_Die *sp_die, struct probe_finder *pf)
>>  {
>>  	int ret = 0;
>> +	char *fpath;
>>  
>>  	if (intlist__empty(pf->lcache)) {
>> +		const char *comp_dir;
>> +
>> +		comp_dir = cu_get_comp_dir(&pf->cu_die);
>> +		ret = get_real_path(pf->fname, comp_dir, &fpath);
>> +		if (ret < 0) {
>> +			pr_warning("Failed to find source file path.\n");
>> +			return ret;
>> +		}
>> +
>>  		/* Matching lazy line pattern */
>> -		ret = find_lazy_match_lines(pf->lcache, pf->fname,
>> +		ret = find_lazy_match_lines(pf->lcache, fpath,
>>  					    pf->pev->point.lazy_line);
>> +		free(fpath);
>>  		if (ret <= 0)
>>  			return ret;
>>  	}
>> @@ -1616,3 +1627,61 @@ found:
>>  	return (ret < 0) ? ret : lf.found;
>>  }
>>  
>> +/*
>> + * Find a src file from a DWARF tag path. Prepend optional source path prefix
>> + * and chop off leading directories that do not exist. Result is passed back as
>> + * a newly allocated path on success.
>> + * Return 0 if file was found and readable, -errno otherwise.
>> + */
>> +int get_real_path(const char *raw_path, const char *comp_dir,
>> +			 char **new_path)
>> +{
>> +	const char *prefix = symbol_conf.source_prefix;
>> +
>> +	if (!prefix) {
>> +		if (raw_path[0] != '/' && comp_dir)
>> +			/* If not an absolute path, try to use comp_dir */
>> +			prefix = comp_dir;
>> +		else {
>> +			if (access(raw_path, R_OK) == 0) {
>> +				*new_path = strdup(raw_path);
>> +				return *new_path ? 0 : -ENOMEM;
>> +			} else
>> +				return -errno;
>> +		}
>> +	}
>> +
>> +	*new_path = malloc((strlen(prefix) + strlen(raw_path) + 2));
>> +	if (!*new_path)
>> +		return -ENOMEM;
>> +
>> +	for (;;) {
>> +		sprintf(*new_path, "%s/%s", prefix, raw_path);
>> +
>> +		if (access(*new_path, R_OK) == 0)
>> +			return 0;
>> +
>> +		if (!symbol_conf.source_prefix) {
>> +			/* In case of searching comp_dir, don't retry */
>> +			zfree(new_path);
>> +			return -errno;
>> +		}
>> +
>> +		switch (errno) {
>> +		case ENAMETOOLONG:
>> +		case ENOENT:
>> +		case EROFS:
>> +		case EFAULT:
>> +			raw_path = strchr(++raw_path, '/');
>> +			if (!raw_path) {
>> +				zfree(new_path);
>> +				return -ENOENT;
>> +			}
>> +			continue;
>> +
>> +		default:
>> +			zfree(new_path);
>> +			return -errno;
>> +		}
>> +	}
>> +}
>> diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h
>> index 92590b2..ebf8c8c 100644
>> --- a/tools/perf/util/probe-finder.h
>> +++ b/tools/perf/util/probe-finder.h
>> @@ -55,6 +55,10 @@ extern int debuginfo__find_available_vars_at(struct debuginfo *dbg,
>>  					     struct variable_list **vls,
>>  					     int max_points, bool externs);
>>  
>> +/* Find a src file from a DWARF tag path */
>> +int get_real_path(const char *raw_path, const char *comp_dir,
>> +			 char **new_path);
>> +
>>  struct probe_finder {
>>  	struct perf_probe_event	*pev;		/* Target probe event */
>>  
>> -- 
>> 2.3.1
> 


-- 
Masami HIRAMATSU
Linux Technology Research Center, System Productivity Research Dept.
Center for Technology Innovation - Systems Engineering
Hitachi, Ltd., Research & Development Group
E-mail: masami.hiramatsu.pt@...achi.com


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ