public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mjw@redhat.com>
To: Milian Wolff <mail@milianw.de>
Cc: elfutils-devel@sourceware.org
Subject: Re: resolving kernel addresses to symbol names via /proc/kallsyms
Date: Wed, 01 Feb 2017 11:16:00 -0000	[thread overview]
Message-ID: <1485947785.3776.52.camel@redhat.com> (raw)
In-Reply-To: <3094525.5gWoQJ3HEP@milian-kdab2>

On Tue, 2017-01-31 at 14:39 +0100, Milian Wolff wrote:
> should I be able to resolve kernel addresses to symbol names with elfutils 
> libdwfl?

Yes. See also eu-addr2line -k -S which I believe does what you are
trying to do below.

> I did something like this:
> 
>     m_dwfl = dwfl_begin(m_callbacks);
>     auto i_k = dwfl_linux_kernel_report_kernel(m_dwfl);
>     auto i_m = dwfl_linux_kernel_report_modules(m_dwfl);
> 
> Both i_k and i_m returned 0. Then, I picked a random address from my /proc/
> kallsyms, e.g.:
> 
>     ffffffff81001000 T hypercall_page
> 
> and try to find that symbol:
> 
>     auto module = dwfl_addrmodule(m_dwfl, 0xffffffff81001000ll);
> 
> The module is non-null and points me at this module (comparing to output I get 
> from dwfl_getmodules):
> 
>     0x61400000fa40 kernel ffffffff81000000

You could also use dwfl_module_info () to get the name and other
information about the module found for that address.

> But when I try to get a symbol, I get a nullptr:
> 
>     auto sym = dwfl_module_addrname(module, 0xffffffff81001000ll);
> 
> So, what am I missing?

I don't immediately know without seeing the full program.
You could try using dwfl_module_addrinfo () to see if you can get more
information about the address in that module.

You could also try calling dwfl_module_getsymtab () on the module and
look at some of the symbols found with dwfl_module_getsym_info () to see
if libdwfl found the symbol table for that module.

> Also, it doesn't seem to be possible to specify the path to the kallsyms file 
> with the current dwfl_linux_kernel_report_kernel API - how is this intended to 
> be handled? Should one instead use dwfl_linux_kernel_report_offline when one 
> wants to support cross-machine analysis?

Yes, one should use dwfl_linux_kernel_report_offline when cross-machine
(or even just cross kernel version) analysis. The /proc/kallsyms file is
only used to estimate some running kernel address boundaries (but isn't
strictly necessary).

      reply	other threads:[~2017-02-01 11:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-31 13:39 Milian Wolff
2017-02-01 11:16 ` Mark Wielaard [this message]

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=1485947785.3776.52.camel@redhat.com \
    --to=mjw@redhat.com \
    --cc=elfutils-devel@sourceware.org \
    --cc=mail@milianw.de \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).