uftrace logo

uftrace

Comprehensive function call tracing for native and kernel code

uftrace records entry/exit timestamps, arguments, and return values of C, C++, Rust, Python, and kernel functions, offering filters and visualizations via Chrome trace, flame graphs, and Graphviz.

uftrace banner

Overview

Overview

uftrace is a Linux‑focused tracer that captures function entry and exit events across user‑space binaries, shared libraries, and kernel code. It records timestamps, arguments, and return values for C, C++, Rust, and Python programs, and can also collect perf events and PMU counters. By analyzing function prologues it can dynamically patch code, allowing tracing without recompilation, while still supporting traditional instrumentation flags.

Usage & Deployment

After building with ./configure && make && sudo make install, developers use commands such as record, replay, report, live, and graph to collect and analyze traces. Powerful filters limit data by duration, depth, or name, and the --auto-args option automatically extracts argument values using DWARF information. Visual output is available through Chrome trace viewer, flame graphs, and Graphviz or Mermaid diagrams. Python and LuaJIT scripting APIs let users create custom analyses, making uftrace suitable for performance profiling, debugging complex call flows, and kernel development.

Highlights

Dynamic function tracing without recompilation via instruction patching
Automatic capture of arguments and return values using DWARF and lib prototypes
Multiple visualizations: Chrome trace, flame graphs, Graphviz & Mermaid
Supports user‑space, library, and kernel functions plus perf events

Pros

  • No need to recompile programs when using dynamic patching
  • Detailed timing, argument, and return‑value data
  • Flexible filtering reduces overhead and trace size
  • Rich set of visualization formats for analysis

Considerations

  • Requires unstripped binaries or separate symbol files for full detail
  • Linux‑only; kernel tracing needs specific kernel configuration
  • Root privileges are necessary for kernel and some perf events
  • Advanced filters and scripting have a learning curve

Managed products teams compare with

When teams consider uftrace, these hosted platforms usually appear on the same shortlist.

AWS X-Ray logo

AWS X-Ray

Trace requests through distributed and serverless apps on AWS.

Better Stack Tracing logo

Better Stack Tracing

Tracing correlated with logs and metrics for faster debugging.

Grafana Cloud Traces logo

Grafana Cloud Traces

Managed distributed tracing powered by Grafana Tempo.

Looking for a hosted option? These are the services engineering teams benchmark against before choosing open source.

Fit guide

Great for

  • Performance profiling of native applications
  • Debugging complex call flows in multi‑threaded programs
  • Kernel developers needing function‑graph insight
  • Teams that want scriptable, customizable trace analysis

Not ideal when

  • Windows or macOS environments
  • Projects without any debug symbols available
  • Real‑time systems where tracing overhead is unacceptable
  • Users needing an out‑of‑the‑box GUI without command‑line setup

How teams use it

Identify slow functions in a C++ server

Pinpoint functions consuming the most CPU time and optimize them, reducing request latency by measurable percentages.

Trace library calls in a Python data pipeline

Visualize interactions between Python code and C extensions, revealing hidden bottlenecks.

Kernel function graph for driver development

Capture entry/exit of driver functions and related kernel events, aiding debugging of race conditions.

Automated argument logging for security auditing

Record input parameters of critical system calls, enabling post‑mortem analysis of potential exploits.

Tech snapshot

C74%
Python21%
Makefile2%
Assembly1%
Shell1%
C++1%

Tags

tracertracefunctiontracing

Frequently asked questions

Do I need to recompile my program to use uftrace?

No, uftrace can dynamically patch functions using the -P. option, though recompiling with -pg or -finstrument-functions also works.

Which operating systems are supported?

uftrace runs on Linux; kernel tracing requires a kernel built with CONFIG_FUNCTION_GRAPH_TRACER.

How can I view the trace results?

Use uftrace replay for text output, or export to Chrome trace, flame graph, Graphviz, or Mermaid for graphical views.

Is root access required?

Root is only needed for tracing kernel functions or perf events; user‑space tracing works without elevated privileges.

Can I filter out noisy functions?

Yes, uftrace provides filters by function name, duration, depth, and more to limit recorded data.

Project at a glance

Active
Stars
3,376
Watchers
3,376
Forks
538
LicenseGPL-2.0
Repo age11 years old
Last commit2 months ago
Primary languageC

Last synced 3 hours ago