(2015/02/26 16:12), Naohiro Aota wrote:
> 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)
> 
> 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 <na...@elisp.net>
> ---
>  tools/perf/util/probe-finder.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
> index b5247d7..8e0714c 100644
> --- a/tools/perf/util/probe-finder.c
> +++ b/tools/perf/util/probe-finder.c
> @@ -39,6 +39,7 @@
>  #include "util.h"
>  #include "symbol.h"
>  #include "probe-finder.h"
> +#include "probe-event.h"
>  
>  /* Kprobe tracer basic type is up to u64 */
>  #define MAX_BASIC_TYPE_BITS  64
> @@ -849,11 +850,23 @@ 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) {
> +                     free(fpath);

Here, if the get_real_path is failed, fpath should be freed before returning.
If not, there is a bug, and yeah, there is a bug...

Thank you!

> +                     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;
>       }
> 


-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu...@hitachi.com


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

Reply via email to