Knowledge Library
Knowledge Library Home
Knowledge Library Home Knowledge Library Products Operating Systems Wind River Linux Wind River Linux 9 Debug & Analysis Tools Wind River Linux Tutorial: Dynamic User Space Instrumentation, 9 Dynamically Obtain Shared Object Library Data with uprobes

Dynamically Obtain Shared Object Library Data with uprobes

Use uprobe to dynamically obtain data on a specific object, created as a new probe, in the perf application.


This procedure requires the following for successful completion:

  • Previously configured and built platform project with debugging symbols. See the Wind River Linux Debug and Analysis Tools User’s Guide: User Space Debugging.

  • The perf package included in your platform project build. For additional information on adding packages, see Configuring uprobes with perf.

  • The CONFIG_UPROBE_EVENT=y kernel configuration parameter enabled in the kernel.

    By default, uprobes are included in your kernel configuration, but may not be supported by all BSPs. To see whether your BSP supports this functionality, refer to the Kernel Configuration > Kernel Hacking > Tracers section of the utility.

  • The platform project is launched on a hardware target and you are logged in as a root user.

To debug an object file effectively, you can use the following procedure to examine the symbols visible to perf probe.


  1. Confirm which symbols are available to perf in a specific object file.

    This step uses the -F option, for example:

    # perf probe -F -x /lib/ | grep mal
  2. Create a probe for an interesting function.
    # perf probe -x /lib/  malloc
    Added new event:
      probe_libc:malloc    (on 0x88914)

    You can now use the probe in all perf command-line tools, such as:

    # perf record -e probe_libc:malloc -aR sleep 1
  3. Obtain some data.

    Run perf in the background for an extended period of time:

    # perf record -e probe_libc:malloc -agR sleep 60 &
  4. In the previous example, we have added the g option (-agR) to the command to enable a call graph for stack chain/backtrace in the recorded results. Enter some random commands to generate data. For example:
    # tar -czf this.tar /etc/*
  5. Observe the results.

    Once the console reports the run as complete, enter perf report to examine the results. They will look similar to the following:

    Events: 3K probe_libc:malloc
     86.37%        tar  [.] malloc
      5.33%       perf  [.] malloc
      4.73%  tcf-agent  [.] malloc
      2.30%        top  [.] malloc
      1.28%       gzip  [.] malloc
  6. Select a line number and press ENTER to observe the call tree if perf report is interactive.

    Not all functions are displayed. On a typical embedded system, the libraries will be stripped of debug information and only public APIs will be shown.

    perf report Call Tree

    perf report Call Tree
  7. Press q to exit the interactive mode of perf.
  8. List the probes you have created.
    # perf probe -l |more
      probe_libc:malloc    (on 0x00088914)
      probe_libc:strstr    (on 0x0008dcd4)
  9. Remove the probes using the d option.
    # perf probe -d probe_libc:malloc
    Removed event: probe_libc:malloc 


Having collected and analyzed shared object library data, you may also need to do the same with user application data as described in Dynamically Obtain User Application Data with uprobes.

Last modified