All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Davis <markdavisinboston@gmail.com>
To: linux-perf-users@vger.kernel.org
Subject: No source code for static library (compiled with -g -ggdb)
Date: Thu, 28 Apr 2016 13:44:16 -0400	[thread overview]
Message-ID: <CAPe7T+8oQptK0Wak2y_b1RNBy7ddmftc+++HNMPF5R8BDxWVYQ@mail.gmail.com> (raw)

Hello, I'm using perf record and perf report to profile an application
which is made from a static (.a) library file that I made as well as a
handful of C++ files that are not in the static library. They are all
compiled with "-g -ggdb -fno-inline -O2 -fno-omit-frame-pointer" and
all linked together to create the application.

When I use perf report (in interactive/tui mode), when I annotate the
symbols that are in the C++ files (not the static library), I see the
source code intermingled with the assembly (this is what I want). I
can do this at any layer of the call stack. However, when I drill into
the symbols that are from the static library, I just see the assembly
of the leaf symbol. I don't expect to see the source in this case, as
the leaf symbol is a low-level library from libc; but, perf report
won't let me drill into (i.e., annotate) any non-leaf symbols.

Example:
execute_native_thread_routine
std::_Bind_simple<int (*(int, char**, Thread*))(int, char**,
Thread*)>::operator()()
main(int, char**)
my_func_A
my_func_B
malloc

When I annotate my_func_A and my_func_B, it just jumps to the
annotation of malloc (I see this listed at the top of the annotation
view). Note that my_func_A and my_func_B are both defined in the
static library that I'm linking in. However, when I do a similar thing
with a different stack where I'm annotating a function that's not from
the static library (but in the regular C++ files), it works fine.

Here's what I'm doing to create my static lib:
ar -cvrs $@ $(OBJS)


I did confirm with nm --debug-syms that my static lib has debugging
symbols in it:

U __assert_fail
0000000000000000 b .bss
0000000000000000 n .comment
U __cxa_atexit
0000000000000000 d .data
0000000000000000 N .debug_abbrev
0000000000000000 N .debug_aranges
0000000000000000 N .debug_info
0000000000000000 N .debug_line
0000000000000000 N .debug_loc
0000000000000000 N .debug_ranges
0000000000000000 N .debug_str
U __dso_handle
0000000000000000 r .eh_frame
U exit


How can I compile and link my application and configure perf report so
I can drill in like this on functions defined in a static library with
debug symbols?

Thank you,
Mark

             reply	other threads:[~2016-04-28 17:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-28 17:44 Mark Davis [this message]
2016-04-28 22:16 ` No source code for static library (compiled with -g -ggdb) Arnaldo Carvalho de Melo
2016-04-29 12:28   ` Mark Davis
2016-04-29 13:26     ` Mark Davis
2016-05-02  7:58       ` Milian Wolff
2016-08-16 20:14         ` Mark Davis
2016-04-29 14:45     ` Arnaldo Carvalho de Melo
2016-04-30 23:49       ` Mark Davis

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=CAPe7T+8oQptK0Wak2y_b1RNBy7ddmftc+++HNMPF5R8BDxWVYQ@mail.gmail.com \
    --to=markdavisinboston@gmail.com \
    --cc=linux-perf-users@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.