Questions tagged [ltrace]

ltrace is a library call tracer. It is a debugging utility in Linux, used to display the calls a userland application makes to shared libraries.

 

Description:

      ltrace is a program that simply runs the specified command until it exits. It intercepts and records the dynamic library calls which are called by the executed process and the signals which are received by that process. It can also intercept and print the system calls executed by the program.

 

Package:

       ltrace

 

Usage:

      Check out the manpage for complete list of options and their usage.

 

Prototype Library Discovery:

      When a library is mapped into the address space of a traced process, ltrace needs to know what the prototypes are of functions that this library implements. For purposes of ltrace, prototype really is a bit more than just type signature: it's also formatting of individual parameters and of return value. These prototypes are stored in files called prototype libraries.

      After a library is mapped, ltrace finds out what its SONAME is. It then looks for a file named SONAME.conf e.g. Prototype library for libc.so.6 would be in a file called libc.so.6.conf. When such file is found, ltrace reads all prototypes stored therein.

  • When a symbol table entry point (such as those traced by -x) is hit, the prototype is looked up in a prototype library corresponding to the library where the hit occurred.
  • When a library call (such as those traced by -e and -l) is hit, the prototype is looked up in all prototype libraries loaded for given process. That is necessary, because a library call is traced in a PLT table of a caller library, but the prototype is described at callee library.

      If a library has no SONAME, basename of library file is considered instead. For the main program binary, basename is considered as well (e.g. prototype library for /bin/echo would be called echo.conf).

      If a name corresponding to soname (e.g. libc.so.6.conf) is not found, and the module under consideration is a shared library, ltrace also tries partial matches. ltrace snips one period after another, retrying the search, until either a protolib is found, or X.so is all that's left. Thus libc.so.conf would be considered, but libc.conf not.

      When looking for a prototype library, ltrace potentially looks into several directories. On Linux, those are $XDG_CONFIG_HOME/ltrace, $HOME/.ltrace, X/ltrace for each X in $XDG_CONFIG_DIRS and /usr/share/ltrace. If the environment variable XDG_CONFIG_HOME is not defined, ltrace looks into $HOME/.config/ltrace instead.

      There's also a mechanism for loading legacy config files. If $HOME/.ltrace.conf exists, it is imported to every loaded prototype library. Similarly for /etc/ltrace.conf. If both exist, both are imported, and $HOME/.ltrace.conf is consulted before /etc/ltrace.conf.

      If -F contains any directories, those are searched in precedence to the above system directories, in the same order in which they are mentioned in -F. Any files passed in -F are imported similarly to above legacy config files, before them.

 

References:

  1. http://man7.org/linux/man-pages/man1/ltrace.1.html
  2. http://en.wikipedia.org/wiki/Ltrace
  3. http://linux.die.net/man/1/ltrace
  4. man ltrace on a Linux machine.
50 questions
0
votes
1 answer

How to identify the shared library, whose functions are currently being executed by an executable

An executable file, a.out, loads the shared libraries 1.so, 2.so and 3.so. There is a function func() implemented in each of the three libraries. When func() is invoked, I want to identify, which implementation of func() is executed. I tried ltrace…
Guru24
  • 41
  • 3
0
votes
1 answer

Build ltrace for Android

I'm trying to build ltrace for Android. I've followed these commands: export SYS_ROOT="/home/pedro/Android/Sdk/ndk-bundle/platforms/android-19/arch-x86" export…
Pedro Maltez
  • 87
  • 1
  • 11
0
votes
1 answer

Unable to attach a running process with 'ltrace' command on Linux server

I want to attach a process with ltrace command to trace one specific library calls. But when i used the below basic options, ltrace command throws error as below bash-3.2$ **ltrace -l /path/libxml2.so.2.6.32 -p 26120** failed to init breakpoints…
sakthivp
  • 21
  • 4
-1
votes
1 answer

Empty enviroment variable name

I'm debugging an application in Ubuntu 20.04 with: ltrace -e getenv ./cmd I want to know which enviroment variables and their respective values are involved. I got surprised when I realized that there is an "empty name variable" without a value.…
-1
votes
1 answer

How do i find the license key for this program?

I'm trying to solve this exercise for university. We have to "crack" a program, which is missing a license file that is required to start the program. We are only working with a Linux shell. So what I've already done is creating this missing license…
Kroonox
  • 21
  • 3
1 2 3
4