Linux command
xtrace 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Trace an X11 client
xtrace [xeyes]
Forward to a specific
xtrace --display [:0] [firefox]
Set a custom fake
xtrace --fakedisplay [:42] [xclock]
Keep xtrace running
xtrace --keeprunning [xterm]
Wait for a later client
xtrace --waitforclient --fakedisplay [:42]
Write trace output
xtrace --outfile [trace.log] [xeyes]
Show relative timestamps
xtrace --relative-timestamps [xclock]
说明
xtrace is a debugging tool that inspects the X11 wire protocol traffic between an X client (such as a GUI application) and an X server (such as Xorg or Xwayland). It starts a fake X server on a chosen display number, forwards every connection to the real X server pointed to by $DISPLAY (or --display), and prints a human-readable log of each request, reply, event, and error that flows across the wire. The launched program has its $DISPLAY environment variable rewritten to the fake display, so it transparently connects through xtrace. This makes it possible to see, for example, which X requests an application issues on startup, what events the server delivers, and where protocol errors occur — without modifying the application itself. When no command is given (typically combined with --waitforclient), xtrace simply listens on the fake display and logs any client that later connects to it, which is useful for attaching to applications that are started by other means.
参数
- -d, --display _DISPLAY_
- Real X server to forward connections to (defaults to $DISPLAY).
- -D, --fakedisplay _DISPLAY_
- Fake display name xtrace listens on (default :9).
- -k, --keeprunning
- Keep running after the launched client disconnects.
- -s, --stopwhendone
- Terminate when all clients have disconnected (default behavior).
- -W, --waitforclient
- Do not exit even if the launched program terminates without connecting.
- -c, --copyauthentication
- Copy X authentication cookies from the real display (default).
- -n, --nocopyauthentication
- Do not copy authentication data to the fake display.
- -f _file_
- Read authentication data from _file_.
- -F _file_
- Write generated authentication data to _file_.
- -o, --outfile _FILE_
- Write trace output to _FILE_ instead of stdout.
- -b, --buffered
- Buffer trace output for higher performance.
- -w, --readwritedebug
- Include byte counts for every read and write operation.
- --timestamps
- Prefix each entry with an absolute wall-clock timestamp.
- --relative-timestamps
- Prefix each entry with time elapsed since the previous entry.
- --monotonic-timestamps
- Prefix each entry with a monotonic timestamp source.
FAQ
What is the xtrace command used for?
xtrace is a debugging tool that inspects the X11 wire protocol traffic between an X client (such as a GUI application) and an X server (such as Xorg or Xwayland). It starts a fake X server on a chosen display number, forwards every connection to the real X server pointed to by $DISPLAY (or --display), and prints a human-readable log of each request, reply, event, and error that flows across the wire. The launched program has its $DISPLAY environment variable rewritten to the fake display, so it transparently connects through xtrace. This makes it possible to see, for example, which X requests an application issues on startup, what events the server delivers, and where protocol errors occur — without modifying the application itself. When no command is given (typically combined with --waitforclient), xtrace simply listens on the fake display and logs any client that later connects to it, which is useful for attaching to applications that are started by other means.
How do I run a basic xtrace example?
Run `xtrace [xeyes]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -d, --display _DISPLAY_ do in xtrace?
Real X server to forward connections to (defaults to $DISPLAY).