# Ltrace

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Ltrace
> Markdown URL: https://mediated.wiki/source/Ltrace.md
> Source: https://en.wikipedia.org/wiki/Ltrace
> Source revision: 1353623321
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these messages) This article includes a list of references, related reading, or external links, but its sources remain unclear because it lacks inline citations. Please help improve this article by introducing more precise citations. (May 2016) (Learn how and when to remove this message) This article relies excessively on references to primary sources. Please improve this article by adding secondary or tertiary sources. Find sources: "Ltrace" – news · newspapers · books · scholar · JSTOR (May 2016) (Learn how and when to remove this message) (Learn how and when to remove this message)

Unix programming tool

**ltrace** is a [debugging](/source/Debugging) utility in [Linux](/source/Linux), used to display the calls a [userspace](/source/User_space) application makes to [shared libraries](/source/Library_(computing)#Unix-like_systems).

## Overview

It does this by hooking into the [dynamic loading](/source/Dynamic_loading) system, allowing it to insert [shims](/source/Shim_(computing)) which display the [parameters](/source/Parameter_(computer_programming)) which the applications uses when making the call, and the [return value](/source/Return_statement) which the library call reports. ltrace can also trace Linux [system calls](/source/System_call). Because it uses the dynamic library hooking mechanism, ltrace cannot trace calls to libraries which are [statically linked](/source/Static_library) directly to the target binary. Since 0.7.3, ltrace can also trace calls to libraries which are loaded using [dlopen](/source/Dlopen).

## Example output

The following is the first few lines of an invocation of [xterm](/source/Xterm). It shows ltrace displaying calls to a variety of libraries, including the [C standard library](/source/C_standard_library) ([malloc](/source/Malloc), [strlen](/source/Strlen)), [POSIX libraries](/source/Unistd.h) (getuid), [X Toolkit Intrinsics](/source/X_Toolkit_Intrinsics) (XtOpenApplication), and the [X11 inter-client communication library](/source/X_Window_System_protocols_and_architecture#Inter-client_communication) (IceAddConnectionWatch). A call's return value is shown after the = symbol.

[pid 11783] __libc_start_main(0x407420, 1, 0x7fff75b6aad8, 0x443cc0, 0x443d50 <unfinished ...>
[pid 11783] geteuid()                            = 1000
[pid 11783] getegid()                            = 1000
[pid 11783] getuid()                             = 1000
[pid 11783] getgid()                             = 1000
[pid 11783] setuid(1000)                         = 0
[pid 11783] malloc(91)                           = 0x00cf8010
[pid 11783] XtSetLanguageProc(0, 0, 0, 0x7f968c9a3740, 1) = 0x7f968bc16220
[pid 11783] ioctl(0, 21505, 0x7fff75b6a960)      = 0
[pid 11783] XtSetErrorHandler(0x42bbb0, 0x44f99c, 0x669f80, 146, 0x7fff75b6a72c) = 0
[pid 11783] XtOpenApplication(0x670260, 0x44f99c, 0x669f80, 146, 0x7fff75b6a72c) = 0xd219a0
[pid 11783] IceAddConnectionWatch(0x42adc0, 0, 0, 0x7f968c9a3748, 0 <unfinished ...>
[pid 11783] IceConnectionNumber(0xd17ec0, 0, 1, 0xcfb138, 0xd17c00) = 4
[pid 11783] <... IceAddConnectionWatch resumed> ) = 1
[pid 11783] XtSetErrorHandler(0, 0, 1, 0xcfb138, 0xd17c00) = 0
[pid 11783] XtGetApplicationResources(0xd219a0, 0x6701c0, 0x66b220, 34, 0) = 0
[pid 11783] strlen("off")                        = 3

## See also

- [strace](/source/Strace) – system call tracer for linux

- [ktrace](/source/Ktrace) – system call tracer for *BSD

- [DTrace](/source/DTrace) – Solaris / OS X / BSD / Windows kernel tracing tool

- [SystemTap](/source/SystemTap) – Linux kernel tracing tool

## References

## External links

- [Official website](http://www.ltrace.org)

- [ltrace(1)](https://www.mankier.com/1/ltrace) – [Linux](/source/Linux) General Commands [Manual](/source/Man_page) from ManKier.com

- Rodrigo Rubira Branco, [*Ltrace Internals*](https://www.kernel.org/doc/ols/2007/ols2007v1-pages-41-52.pdf), [Ottawa Linux Symposium](https://web.archive.org/web/20080913185728/http://www.linuxsymposium.org/) 2007

- [latrace](https://latrace.sourceforge.net/latrace.html), a dynamic library call tracer which operates using the LD_AUDIT libc feature

---
Adapted from the Wikipedia article [Ltrace](https://en.wikipedia.org/wiki/Ltrace) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Ltrace?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
