[lttng-dev] get function names with lttng-ust-cyg-profile

Liu, Changcheng changcheng.liu at intel.com
Tue Jun 23 21:10:30 EDT 2020


>    You could use the command 'nm' to get your symbols and look them up. I
>    am sure Babeltrace can do this from a python level. You could also use
>    a GUI based trace viewer to get the information.
      nm only shows the linked address, but the traced address are the
      loaded address in memory. So, they're different.
      For example:
      trace at trace:~/cc$ nm instrument | grep 'add3\|main'
      00000000000011a9 T add3
      00000000000011ee T main

@Christophe:
    Do you mean that babeltrace2 can help get the function name and call site offset?

B.R.
Changcheng

On 12:52 Tue 23 Jun, Christophe Bédard wrote:
>    Hi,
> 
>      Babeltrace is doing exactly what it should as far as I know.
> 
>    yes, but babeltrace can provide the information if:
>    * ip and vpid contexts are enabled (for userspace), e.g.
> 
>    $ lttng add-context --userspace --type=ip --type=vpid
> 
>    * LTTng state dump events are enabled, e.g.
> 
>    $ lttng enable-event --userspace 'lttng_ust_statedump:*'
> 
>    see this (from bt2 but it also applies to
>    bt1): [1]https://babeltrace.org/docs/v2.0/man7/babeltrace2-filter.lttng
>    -utils.debug-info.7/#doc-lttng-prereq
>    Note that the Python bindings for babeltrace don't provide/expose this
>    debug info.
>    Christophe
>    On Tue, 23 Jun 2020 at 11:12, Matthew Khouzam via lttng-dev
>    <[2]lttng-dev at lists.lttng.org> wrote:
> 
>    Hi,
>    You have the pointers that are traced. Babeltrace is doing exactly what
>    it should as far as I know.
>    You could use the command 'nm' to get your symbols and look them up. I
>    am sure Babeltrace can do this from a python level. You could also use
>    a GUI based trace viewer to get the information.
>    Hope that helps.
>    Matthew
>      __________________________________________________________________
> 
>    From: lttng-dev <[3]lttng-dev-bounces at lists.lttng.org> on behalf of
>    Liu, Changcheng via lttng-dev <[4]lttng-dev at lists.lttng.org>
>    Sent: Tuesday, June 23, 2020 10:37 AM
>    To: [5]lttng-dev at lists.lttng.org <[6]lttng-dev at lists.lttng.org>
>    Cc: [7]changcheng.liu at intel.com <[8]changcheng.liu at intel.com>
>    Subject: [lttng-dev] get function names with lttng-ust-cyg-profile
> 
>    Hi all,
>       I'm trying to use lttng-ust-cyg-profile to trace program.
>       Does anyone know how to get function names and offset through
>    lttng-ust-cyg-profile?
>       In below example, the babeltrace could only get the function
>    entry/exit value.
>       1. Source program: instrument.c
>             1 #include <stdio.h>
>             2
>             3 int add3(int val) {
>             4         return val + 3;
>             5 }
>             6
>             7 int main(int argc, char **argv) {
>             8     int x = 4;
>             9
>            10     puts("Press Enter to continue...");
>            11     getchar();
>            12
>            13     x = add3(x);
>            14
>            15     return 0;
>            16 }
>       2. build source code:
>            $ gcc -g -finstrument-functions instrument.c -o instrument
>       3. run program:
>           $
>    LD_PRELOAD=/usr/lib/x86_64-linux-gnu/liblttng-ust-cyg-profile.so
>    ./instrument
>       4. start trace process:
>           trace at trace:~/cc$ sudo lttng create instrument
>           Session instrument created.
>           Traces will be output to
>    /root/lttng-traces/instrument-20200623-222917
>           trace at trace:~/cc$ sudo lttng enable-channel user_func_trace
>    --userspace
>           UST channel user_func_trace enabled for session instrument
>           trace at trace:~/cc$ sudo lttng enable-event --userspace
>    lttng_ust_cyg_profile:func_entry --channel user_func_trace
>           UST event lttng_ust_cyg_profile:func_entry created in channel
>    user_func_trace
>           trace at trace:~/cc$ sudo lttng enable-event --userspace
>    lttng_ust_cyg_profile:func_exit --channel user_func_trace
>           UST event lttng_ust_cyg_profile:func_exit created in channel
>    user_func_trace
>           trace at trace:~/cc$ sudo lttng start
>           Tracing started for session instrument
>           trace at trace:~/cc$ sudo lttng destroy
>           Destroying session instrument..
>           Session instrument destroyed
>           trace at trace:~/cc$ sudo babeltrace
>    /root/lttng-traces/instrument-20200623-222917
>           [22:29:55.388607059] (+?.?????????) trace
>    lttng_ust_cyg_profile:func_entry: { cpu_id = 2 }, { addr =
>    0x5625C88B01A9, call_site = 0x5625C88B0237 }
>           [22:29:55.388612293] (+0.000005234) trace
>    lttng_ust_cyg_profile:func_exit: { cpu_id = 2 }, { addr =
>    0x5625C88B01A9, call_site = 0x5625C88B0237 }
>           [22:29:55.388613215] (+0.000000922) trace
>    lttng_ust_cyg_profile:func_exit: { cpu_id = 2 }, { addr =
>    0x5625C88B01EE, call_site = 0x7FE40BD5C0B3 }
>    B.R.
>    Changcheng


More information about the lttng-dev mailing list