function-call-tracing
Instruments C/C++ code for deep execution tracing and visualization.
Install
mkdir -p .claude/skills/function-call-tracing && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/4716" && unzip -o skill.zip -d .claude/skills/function-call-tracing && rm skill.zipInstalls to .claude/skills/function-call-tracing
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Instrument C/C++ with -finstrument-functions for execution tracing and Perfetto visualisationKey capabilities
- →Instrument C/C++ function calls
- →Capture per-thread execution logs
- →Convert logs to Perfetto JSON format
- →Visualize call stacks in Perfetto UI
How it works
The tool uses compiler instrumentation to inject entry and exit hooks into functions, logs these events per thread, and converts the logs into a format readable by the Perfetto UI.
Inputs & outputs
When to use function-call-tracing
- →Tracing function execution flow
- →Profiling C/C++ application performance
- →Visualizing call stacks in Perfetto
About this skill
Function Call Tracing
Purpose
Trace all function calls in C/C++ programs with per-thread logs and Perfetto visualization.
Components
1. Instrumentation Library (trace_instrument.c)
Captures function entry/exit, writes per-thread logs.
Build:
gcc -c -fPIC trace_instrument.c -o trace_instrument.o
gcc -shared trace_instrument.o -o libtrace.so -ldl -lpthread
2. Perfetto Converter (trace_to_perfetto.cpp)
Converts logs to Chrome JSON for Perfetto UI.
Build:
g++ -O3 -std=c++17 trace_to_perfetto.cpp -o trace_to_perfetto
Usage
Step 1: Add to Build
CFLAGS += -finstrument-functions -g
LDFLAGS += -L. -ltrace -ldl -lpthread
Step 2: Build Target
make
Step 3: Run
export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
./program
# Creates trace_<tid>.log files
Step 4: Convert to Perfetto
./trace_to_perfetto trace_*.log -o trace.json
# Open trace.json in ui.perfetto.dev
Log Format
[seq] [timestamp] [dots] [ENTRY|EXIT!] function_name
[0] [1.000000000] [ENTRY] main
[1] [1.000050000] . [ENTRY] helper
[2] [1.000100000] . [EXIT!] helper
[3] [1.000150000] [EXIT!] main
- Dots indicate call depth
- Timestamp in seconds.nanoseconds
- One log file per thread
When User Requests Tracing
Steps
- Copy
trace_instrument.candtrace_to_perfetto.cppto project - Build instrumentation library
- Add
-finstrument-functionsto CFLAGS - Add
-L. -ltrace -ldl -lpthreadto LDFLAGS - Build project
- Set
LD_LIBRARY_PATHand run - Convert logs:
./trace_to_perfetto trace_*.log -o trace.json - Provide link to ui.perfetto.dev
Build System Detection
Makefile: Add flags conditionally
ENABLE_TRACE ?= 0
ifeq ($(ENABLE_TRACE),1)
CFLAGS += -finstrument-functions -g
LDFLAGS += -L. -ltrace -ldl -lpthread
endif
CMake: Add option
option(ENABLE_TRACE "Enable tracing" OFF)
if(ENABLE_TRACE)
add_compile_options(-finstrument-functions -g)
link_libraries(trace dl pthread)
endif()
Output
- trace_<tid>.log: Per-thread text logs
- trace.json: Perfetto Chrome JSON format
- View at https://ui.perfetto.dev
Perfetto JSON Format
Function ENTRY → "B" (begin) event Function EXIT! → "E" (end) event All threads aligned by timestamp in single file.
When not to use it
- →Tracing non-C/C++ applications
- →Profiling in production environments with strict performance requirements
Prerequisites
Limitations
- →Instrumentation adds overhead to execution
- →Requires recompilation of the target application
How it compares
This provides a visual call stack trace for C/C++ applications instead of relying on manual log analysis.
Compared to similar skills
function-call-tracing side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| function-call-tracing (this skill) | 1 | 4mo | Review | Advanced |
| debug-lldb | 1 | 7mo | Review | Intermediate |
| benchmark-kernel | 1 | 7mo | Review | Advanced |
| analyze-kernel-bottleneck | 0 | 2mo | Review | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by gadievron
View all by gadievron →You might also like
debug-lldb
regenrek
Capture and analyze thread backtraces with LLDB/GDB to debug hangs, deadlocks, UI freezes, IPC stalls, or high-CPU loops across any language or project. Use when an app becomes unresponsive, switching contexts stalls, or you need thread stacks to locate lock inversion or blocking calls.
benchmark-kernel
flashinfer-ai
Guide for benchmarking FlashInfer kernels with CUPTI timing
analyze-kernel-bottleneck
pjt222
>
validate-render
kzahedi
Validates YARS rendering by exporting first frame as PNG and comparing with reference screenshot
trace
taedlar
Add opt_trace() calls for debugging and profiling. Use -t option to enable specific trace tiers and levels.
cpp-pro
sleepyvani
Writes, optimizes, and debugs C++ applications using modern C++20/23 features, template metaprogramming, and high-performance systems techniques. Use when building or refactoring C++ code requiring concepts, ranges, coroutines, SIMD optimization, or careful memory management — or when addressing per