본문으로 건너뛰기
cccskills
무료GitHub에 공개

Function Call Tracing

Instrument C/C++ with -finstrument-functions for execution tracing and Perfetto visualisation

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(3)

  • SKILL.md4.3 KB
  • trace_instrument.c3.4 KB
  • trace_to_perfetto.cpp6.2 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Function Call Tracing

Purpose

Trace all function calls in C/C++ programs with per-thread logs and Perfetto visualization.

Containment

The traced project is untrusted — its build scripts and the produced binary execute arbitrary code. Every command that runs the target's build system or the instrumented binary goes through libexec/raptor-run-sandboxed --output-dir <dir> <cmd> [args...] (--output-dir = the directory the command writes into: the project tree for builds, the working directory for runs). The sandbox strips loader variables (LD_LIBRARY_PATH, LD_PRELOAD) by design; the instrumented link bakes an rpath instead, so the sandboxed run resolves libtrace.so with no loader variable. If a sandboxed step fails, fix the sandboxed path — never run the target bare. Building the instrumentation library itself (RAPTOR's own skill sources) needs no sandbox.

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

LIBTRACE_DIR is the absolute directory holding libtrace.so; the -Wl,-rpath makes the binary find it at run time inside the sandbox (which strips LD_LIBRARY_PATH).

CFLAGS += -finstrument-functions -g
LDFLAGS += -L$(LIBTRACE_DIR) -Wl,-rpath,$(LIBTRACE_DIR) -ltrace -ldl -lpthread

Step 2: Build Target (sandboxed — the build scripts are untrusted)

libexec/raptor-run-sandboxed --output-dir <project-dir> make ENABLE_TRACE=1

Step 3: Run (sandboxed; the rpath resolves libtrace.so — no loader variable)

libexec/raptor-run-sandboxed --output-dir <working-dir> <project-dir>/program
# Creates trace_<tid>.log files

Step 4: Convert to Perfetto (sandboxed — the log bytes came from the untrusted target, and the converter is native code)

libexec/raptor-run-sandboxed --output-dir <working-dir> ./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

  1. Copy trace_instrument.c and trace_to_perfetto.cpp to project
  2. Build instrumentation library
  3. Add -finstrument-functions to CFLAGS
  4. Add -L$(LIBTRACE_DIR) -Wl,-rpath,$(LIBTRACE_DIR) -ltrace -ldl -lpthread to LDFLAGS
  5. Build project via libexec/raptor-run-sandboxed --output-dir <project-dir> ...
  6. Run the instrumented binary via libexec/raptor-run-sandboxed --output-dir <working-dir> ... (the rpath resolves libtrace.so)
  7. Convert logs via libexec/raptor-run-sandboxed --output-dir <working-dir> ./trace_to_perfetto trace_*.log -o trace.json (untrusted log bytes into a native parser)
  8. 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$(LIBTRACE_DIR) -Wl,-rpath,$(LIBTRACE_DIR) -ltrace -ldl -lpthread
endif

CMake: Add option

option(ENABLE_TRACE "Enable tracing" OFF)
if(ENABLE_TRACE)
    add_compile_options(-finstrument-functions -g)
    link_directories(${LIBTRACE_DIR})
    add_link_options(-Wl,-rpath,${LIBTRACE_DIR})
    link_libraries(trace dl pthread)
endif()

Output

Perfetto JSON Format

Function ENTRY → "B" (begin) event Function EXIT! → "E" (end) event All threads aligned by timestamp in single file.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

audit

무료

Hypothesis-driven, tool-grounded security review of coverage gaps

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

gadievron/raptor3.9천2026년 10월 19일 업데이트

Add gcov code coverage instrumentation to C/C++ projects

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

gadievron/raptor3.9천2026년 10월 19일 업데이트

Provides adversarial code comprehension for security research, mapping architecture, tracing data flows, and hunting vulnerability variants to build ground-truth understanding before or alongside static analysis.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

gadievron/raptor3.9천2026년 10월 19일 업데이트

Multi-stage pipeline for validating that vulnerability findings are real, reachable, and exploitable, preventing wasted effort on hallucinated findings, dead code paths, or findings with unrealistic preconditions.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

gadievron/raptor3.9천2026년 10월 19일 업데이트

frida

무료

Dynamic instrumentation via Frida - attach to or spawn a process, load a JS hook script, capture send() events into a lifecycle-managed run directory. Supports local, USB-attached, and remote frida-server targets.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

gadievron/raptor3.9천2026년 10월 19일 업데이트

Investigate GitHub security incidents using tamper-proof GitHub Archive data via BigQuery. Use when verifying repository activity claims, recovering deleted PRs/branches/tags/repos, attributing actions to actors, or reconstructing attack timelines. Provides immutable forensic evidence of all public GitHub events since 2011.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

gadievron/raptor3.9천2026년 10월 19일 업데이트

gadievron의 스킬 모두 보기

이 스킬의 문제 신고