Difference between revisions of "Ltrace"

[unchecked revision] [quality revision]
(Distribution Package)
 

1 Article purpose[edit]

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

2 Introduction[edit]

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[edit]

3.1 Using the STM32MPU Embedded Software distribution[edit]

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


3.1.1 Distribution Package[edit]

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[edit]

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[edit]

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

6 References[edit]


  • 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


== Article purpose ==
This article provides the basic information needed to start using the Linux tool: '''ltrace'''<ref name=ltracedotorg/>.

== Introduction ==
{{:Trace_and_debug_tools_assignment_table_template}}<onlyinclude>

 | [[Ltrace|ltrace]]
 | [[:Category:Tracing tools|Tracing tools]]
 | style="text-align:left;" | '''ltrace'''<ref name=ltracedotorg>https://www.ltrace.org/</ref> is used to display the calls to shared libraries made by a userspace application. '''ltrace''' is a userspace application.<br>

''Its use is very similar to [[Strace|strace]]''.
 | {{N}} || {{N}} || {{Y}}
 | {{N}} || {{N}} || {{N}}
 |-</onlyinclude>

|}

== Installing the trace and debug tool on your target board ==
=== Using the STM32MPU Embedded Software distribution ===
{{highlight|'''ltrace''' is not part of the standard STM32MPU Embedded Software distribution image.}}

{{InternalInfo|'''This part with Developer Package need to be reviewed, because latest version available with tarball, is not the same version as proposed in Distribution Package, and this is currently not working on the board.
'''&#61;&#61;&#61;&#61; Developer Package &#61;&#61;&#61;&#61;

With the Developer Package, you have to rebuild '''ltrace''' from the tarball version available on the official website<ref name=ltracedotorg/>.

After getting the source code, you must cross-compile it using OpenSTLinux SDK.

These steps are described below:
* Create an area to store the ltrace libs and binaries that are to be compiled for your target board:
 {{PC$}} cd <''your_local_dir''>

 {{PC$}} mkdir ltrace_target

* Get the application source code:
 {{PC$}} cd ltrace_target
 {{PC$}} wget https://www.ltrace.org/ltrace_<''latest_ltrace_version''>.orig.tar.bz2 && tar xvf ltrace_<''latest_ltrace_version''>.orig.tar.bz2 && cd ltrace-<''latest_ltrace_version''>


 Example with ltrace version 0.7.3:
 {{PC$}} wget https://www.ltrace.org/ltrace_0.7.3.orig.tar.bz2 && tar xvf ltrace_0.7.3.orig.tar.bz2 && cd ltrace-0.7.3

* Install and set up a cross compilation environment using SDK: See [[Cross-compile with OpenSTLinux SDK#Adding Linux user space applications|Cross-compile Linux user space application with OpenSTLinux SDK]]

* Cross-compile '''ltrace''' sources using shell console where your cross compilation environment is set:
 {{PC$}} cd ltrace_target
 {{PC$}} ./configure --host&#61;arm-linux-gnueabi --disable-werror
 {{PC$}} make

* Install the binary file on the target using network link:
 {{PC$}} scp ltrace root@<''ip_of_board''>:/usr/bin/
}}

==== Distribution Package ====

To include '''ltrace''' in your Distribution Package image build, please follow steps below:
* Add ltrace package for the image building
 {{PC$}} cd {{HighlightParam|''<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 {{HighlightParam|''<full_image_name>''}} # Needed to include ltrace into the final image rootfs

* Reload the new image on your board: see [[STM32MP1 Distribution Package#Flashing the built image|Flashing the built image]] <br>


== 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 {{HighlightParam|''<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 {{HighlightParam|''<PID>''}}
{{highlight|Note: {{HighlightParam|''<PID>''}} value can be replace by {{HighlightParam|''`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

== To go further ==
Other options can be set. For details, please refer to the manual page<ref>http://man7.org/linux/man-pages/man1/ltrace.1.html</ref>.

== References ==<references />


*Useful external links
{|
|-
! scope=col | Document link
! scope=col | Document Type
! scope=col | Description
|-
| [https://linux.die.net/man/1/ltrace ltrace linux.die.net]
| Standard
| linux.die.net
|-
| [https://en.wikipedia.org/wiki/Ltrace ltrace wikipedia.org]
| Standard
| wikipedia.org
|-
| [https://www.go4expert.com/articles/ltrace-linux-debugging-utility-tutorial-t29095 ltrace tutorial]
| User Guide
| go4expert.com
|-
| [https://www.ellexus.com/getting-started-with-ltrace-how-does-it-do-that ltrace training]

| Training
| ellexus.com
|}

{{ ArticleBasedOnModel | Trace and debug tools article model }}
{{ PublicationRequestId | 9773 | 07Dec'18 }}

[[Category:Linux tracing tools]]
Line 54: Line 54:
 
* Add ltrace package for the image building
 
* Add ltrace package for the image building
 
  {{PC$}} cd {{HighlightParam|''<your_Distribution_Package_root_dir>''}}
 
  {{PC$}} cd {{HighlightParam|''<your_Distribution_Package_root_dir>''}}
  {{PC$}} echo 'IMAGE_INSTALL_append += "ltrace"' >> meta-st/meta-st-openstlinux/recipes-st/images/st-image-weston.bbappend
+
  {{PC$}} echo 'IMAGE_INSTALL_append += "ltrace"' >> layers/meta-st/meta-st-openstlinux/recipes-st/images/st-image-weston.bbappend
   
 
* Rebuild your full image
 
* Rebuild your full image