Function Call Tracing

Trace C/C++ function calls into per-thread logs for Perfetto visualization.

3.5k|556|Updated Oct 17, 2025
One-click install
npx skills add https://github.com/gadievron/raptor --skill function-call-tracing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Function Call Tracing
Source: https://github.com/gadievron/raptor/tree/main/.claude/skills/crash-analysis/function-tracing
Command: npx skills add https://github.com/gadievron/raptor --skill function-call-tracing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Trace all function calls in C/C++ programs to generate per-thread logs for Perfetto visualization.

Core Features & Use Cases

  • Instrumentation Library (trace_instrument.c) captures function entry/exit, writes per-thread logs.
  • Perfetto Converter (trace_to_perfetto.cpp) converts logs to Perfetto Chrome JSON format.
  • Use Case: Profiling multi-threaded applications to visualize call graphs and performance hotspots in Perfetto.

Quick Start

  1. Copy trace_instrument.c and trace_to_perfetto.cpp to your project.
  2. Build the instrumentation library and your project.
  3. Enable -finstrument-functions in CFLAGS and link with -ltrace and -lpthread as needed.
  4. Run your program to generate trace_<tid>.log files.
  5. Convert logs to Perfetto: ./trace_to_perfetto trace_*.log -o trace.json and view it at ui.perfetto.dev.

Frequently Asked Questions about Function Call Tracing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I trace function calls in C/C++ programs?

Function call tracing captures entry and exit points in C/C++ code to generate per-thread logs. Enable it by adding -finstrument-functions to your compiler flags, link against the instrumentation library, and run your program to produce trace logs that record every function invocation with timing data.

Can I visualize C/C++ function traces in Perfetto?

Yes. Convert your trace logs to Perfetto's Chrome JSON format using the included converter, then upload the JSON file to ui.perfetto.dev. Perfetto displays call graphs, thread timelines, and performance hotspots from your instrumented C/C++ application.

What's the best way to profile multi-threaded C/C++ applications?

Instrument your build with function call tracing to capture per-thread execution logs, then convert them to Perfetto format. This approach isolates thread behavior, reveals contention points, and visualizes call stacks across your entire multi-threaded workload.

Do I need to modify my C/C++ source code to enable function tracing?

No source code changes are required. Function call tracing works through compiler instrumentation flags (-finstrument-functions) and linking the trace library. The compiler automatically inserts entry/exit hooks into every function during compilation.

What output does function call tracing produce?

Tracing generates per-thread log files (trace_<tid>.log) containing function entry/exit records with timestamps. These logs can be converted to Perfetto's JSON format for visualization or analyzed programmatically for performance metrics.

Can function call tracing work with existing build systems?

Yes. Integrate tracing by adding -finstrument-functions to CFLAGS and linking with -ltrace and -lpthread. The instrumentation library is designed as a drop-in component for standard C/C++ build workflows.