/dev/kev

xlibtrace

LD_PRELOAD library to trace libX11 calls

Description
xlibtrace displays the interaction between X11 client programs and the X11 client shared library (libX11.so), by showing the Xlib calls that are made. Output is shown in a similar style to strace(1).

xlibtrace works by using the $LD_PRELOAD dynamic linker option to insert itself between the target X11 client program and libX11.so. This allows it to "intercept" all calls to X functions, whereupon it has the opportunity to print the name of the function being called, along with any arguments and return value.

xlibtrace allows the user to investigate which X functions are being called, when they are being called, what parameters are passed and what the return value is. This can be particularly useful when analysing the behaviour of closed-source X11 programs.

Downloads

Installation
Standard autoconf process: ./configure && make && make install

Usage
    xlibtrace [options] <program> [args...]

Valid options are:

  --stderr          Send output to stderr (default)
  --stdout          Send output to stdout
  -o filename       Send output to the specified file
  -a, --append      Append output to file specified by -o

  --single          Trace only the specified program, and not any
                    other subsequently forked processes.  Useful for
                    tracing xterms, etc.

  --prompt          Prompt user prior to each call.  Useful for
                    interactively stepping through the X11 calls.
  --sleep us        Sleep for the given microseconds after each call.
                    Useful for artificially slowing down the client.
  --xflush          Call XFlush() after each call.  Useful in
                    conjunction with --prompt or --sleep to interactively
                    step through drawing commands, etc.
  --xsync, --sync   Call XSync(..., False) after each call.  Useful in
                    conjunction with --prompt or --sleep to interactively
                    step through drawing commands, etc.
  --fflush          Call fflush() after each line of output.
  --flush           Equivalent to --xflush --fflush

  --show-implementation-dependent-structs
                    Show the contents of structs that are xlib
                    implementation dependent, but still publicly
                    declared in XFree86/Xorg (may cause segfaults)

Examples
Click the links below to download sample trace files from running these commands on my system.


Last updated: Monday, 15 February, 2021.
Copyright © 1994-2018, Kevin Pulo, kev at pulo dot com dot au
Public key fingerprint: 94A4 D2B6 85E6 A46A 5330 74F3 199C 4F85 563D C85F