public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@redhat.com>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Chase Douglas <chase.douglas@canonical.com>,
	linux-kernel@vger.kernel.org,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@elte.hu>
Subject: Re: perf: relative path to source for perf probe?
Date: Thu, 13 May 2010 17:23:14 -0400	[thread overview]
Message-ID: <4BEC6DC2.4040207@redhat.com> (raw)
In-Reply-To: <20100513173426.GK19192@ghostprotocols.net>

Arnaldo Carvalho de Melo wrote:
> Em Thu, May 13, 2010 at 06:01:10PM +0200, Chase Douglas escreveu:
>> On Thu, May 13, 2010 at 4:58 PM, Arnaldo Carvalho de Melo
>> <acme@ghostprotocols.net> wrote:
>>> Look in tools/perf/util/symbol.c, these variables are the ones tools use
>>> to govern how the symbol system work wrt finding vmlinux:
>>>
>>> symbol_conf.use_vmlinux_path
>>> symbol_conf.vmlinux_name
>>>
>>> In addition to this it will use what is in ~/.debug/ if it has a
>>> build-id in the perf.data header.
>>>
>>> The changes for support kvm also touched this and allow for some
>>> prefixing to look for guest symbols, generalizing that to make guest
>>> kernel vmlinux + modules relative location be reused to look for
>>> relative location for host kernel vmlinux + modules seems the way to go.
>>
>> After reading this some more, I think we are talking about two
>> different things. I think your notes above are referring to locating
>> the vmlinux image and other debug symbols. This seems to work fine for
>> me using the -k flag.
> 
> What about finding the associated modules?
> 
>> However, I'm encountering an issue where the source code location
>> isn't found. I think this is fairly specific to the probe command of
>> perf, which is fairly new, so maybe it's missing the same level of
>> support that the symbol finding code has?
> 
> Annotation needs it, in top, report, too.
> 
> But probably (haven't looked at the sources) the way to specify it will
> be different, since we rely on objdump to do the disassembly, we need to
> inform it where the sources are, but look at the source of all this, the
> relevant DWARF tags:
> 
>  <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
>     < c>   DW_AT_stmt_list   : 0x0      
>     <10>   DW_AT_ranges      : 0x0      
>     <14>   DW_AT_name        : /home/acme_unencrypted/git/linux-2.6-tip/arch/x86/kernel/head_64.S       
>     <57>   DW_AT_comp_dir    : /home/acme_unencrypted/git/build/v2.6.34-rc6-

Actually, these doesn't help us so much. DW_AT_name shows the absolute path
of source file (and perf probe already have it), and DW_AT_comp_dir just 
shows where the object code has been stored (or where the make command ran).

In this case (after compiling kernel, user moved its source into another
directory), we have to find the top directory of this source code.

Imagine that, if user compiled code under /home/user/git-ksrc/, and 
it was moved under  /usr/src/2.6.x/, perf probe will be given an option
'-s /usr/src/2.6.x/'.

If we know the top directory is /home/user/git-ksrc/, we can replace
it with /usr/src/2.6.x/. However, dwarf doesn't provide this information.
So we need to assume that where is the top directory in absolute path.

I think, we can do it by brute force (I'm not sure how gdb does it).

Replace the root directory with given directory and try to open it.

 fopen("/usr/src/2.6.x/" "home/user/git-ksrc/kernel/kprobes.c"); -> NG

If there is no file exist, remove next directory and add given directory
and try to open it again.

 fopen("/usr/src/2.6.x/" "user/git-ksrc/kernel/kprobes.c"); -> NG

And repeat it until the file exist.

 fopen("/usr/src/2.6.x/" "git-ksrc/kernel/kprobes.c"); -> NG

 fopen("/usr/src/2.6.x/" "kernel/kprobes.c"); -> OK!


Thank you,

-- 
Masami Hiramatsu
e-mail: mhiramat@redhat.com

  reply	other threads:[~2010-05-13 21:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-13 14:13 perf: relative path to source for perf probe? Chase Douglas
2010-05-13 14:58 ` Arnaldo Carvalho de Melo
2010-05-13 15:51   ` Chase Douglas
2010-05-13 17:36     ` Arnaldo Carvalho de Melo
2010-05-13 16:01   ` Chase Douglas
2010-05-13 17:34     ` Arnaldo Carvalho de Melo
2010-05-13 21:23       ` Masami Hiramatsu [this message]
2010-05-13 21:46         ` Arnaldo Carvalho de Melo
2010-05-13 22:10           ` Chase Douglas
2010-05-13 22:11           ` Masami Hiramatsu
2010-05-13 21:00 ` Masami Hiramatsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BEC6DC2.4040207@redhat.com \
    --to=mhiramat@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=chase.douglas@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox