Ltrace

1 Article purpose

This article provides the basic information needed to start using the Linux tool: ltrace[1].

2 Introduction

The following table provides a brief description of the tool, as well as its availability depending on the software packages:

Yes: this tool is either present (ready to use or to be activated), or can be integrated and activated on the software package.

No: this tool is not present and cannot be integrated, or it is present but cannot be activated on the software package.

Tool STM32MPU Embedded Software distribution STM32MPU Embedded Software distribution for Android™
Name Category Purpose Starter Package Developer Package Distribution Package Starter Package Developer Package Distribution Package
ltrace Tracing tools ltrace[1] is used to display the calls to shared libraries made by a userspace application. ltrace is a userspace application.

Its use is very similar to strace.

No No Yes No No No

3 Installing the trace and debug tool on your target board

3.1 Using the STM32MPU Embedded Software distribution

ltrace is not part of the standard STM32MPU Embedded Software distribution image.


3.1.1 Distribution Package

To include ltrace in your Distribution Package image build, please follow steps below:

  • Add ltrace package for the image building
PC $> cd <your_Distribution_Package_root_dir>
PC $> echo 'IMAGE_INSTALL_append += "ltrace"' >> layers/meta-st/meta-st-openstlinux/recipes-st/images/st-image-weston.bbappend
  • Rebuild your full image
PC $> bitbake <full_image_name> # Needed to include ltrace into the final image rootfs

4 Getting started

To use ltrace, there are two main methods:

  • by giving, as parameter, the name of program for which you want to list dynamic library calls, and its arguments if required:
Board $> ltrace <Program> [ARGS]
As example:
Board $> ltrace weston-simple-egl
__libc_start_main(0x11a90, 1, 0xbec45d04, 0x131f0 <unfinished ...>
memset(0xbec456f8, 0, 72, 0x11a90)                                             = 0xbec456f8
memset(0xbec45754, 0, 68, 0xbec45740)                                          = 0xbec45754
wl_display_connect(0, 250, 32, 0xbec45750)                                     = 0x26150
wl_proxy_marshal_constructor(0x26150, 1, 0x24e90, 0)                           = 0x2a268
wl_proxy_add_listener(0x2a268, 0x132e0, 0xbec456f8, 0)                         = 0
wl_display_roundtrip(0x26150, 0x132e0, 0xbec456f8, 0 <unfinished ...>
strcmp(0x2a404, 0x133e8, 1, 0x2a404)                                           = 0
wl_proxy_marshal_constructor_versioned(0x2a268, 0, 0x24ed8, 1)                 = 0x2b070
strcmp(0x2a49c, 0x133e8, 2, 0x2a49c)                                           = 16
strcmp(0x2a49c, 0x133f8, 115, 0x635f6c77)                                      = -3
...
  • by giving, as parameter, the PID of the process to be studied:
Board $> ltrace -p <PID>

Note: <PID> value can be replace by `pidof <process_name>`

As example:
Board $> weston-simple-egl & ltrace -p `pidof weston-simple-egl`
has EGL_EXT_buffer_age and EGL_EXT_swap_buffers_with_damage
glGetShaderiv(1, 0x8b81, 0xbee14260, 0)                                        = 0
glCreateShader(0x8b31, 0x8b31, 256, 1)                                         = 2
glShaderSource(2, 1, 0xbee1425c, 0)                                            = 0x1a96f0
glCompileShader(2, 0, 154, 0xbee14260)                                         = 1
glGetShaderiv(2, 0x8b81, 0xbee14260, 0)                                        = 0
glCreateProgram(2, 2, 256, 1)                                                  = 3
glAttachShader(3, 1, -1, 1)                                                    = 0
glAttachShader(3, 2, 0x8b30, 1)                                                = 0
glLinkProgram(3, 0x8dd9, 0x8b31, 1)                                            = 0x285234
glGetProgramiv(3, 0x8b82, 0xbee14698, 0)                                       = 0
glUseProgram(3, 3, 256, 1)                                                     = 1
glBindAttribLocation(3, 0, 0x13884, 1)                                         = 1
glBindAttribLocation(3, 1, 0x13888, 0)                                         = 1
glLinkProgram(3, 0x1388e, 0, 0x1b9090)                                         = 1
...

Board $> killall weston-simple-egl

5 To go further

Other options can be set. For details, please refer to the manual page[2].

6 References


  • Useful external links
Document link Document Type Description
ltrace linux.die.net Standard linux.die.net
ltrace wikipedia.org Standard wikipedia.org
ltrace tutorial User Guide go4expert.com
ltrace training


Training ellexus.com



Attachments

Discussions