Agent skill

Dynamic Instrumentation

by aftermathlabs in aftermathlabs/llvm-msvc

Expertise in LLVM-based dynamic binary instrumentation, runtime tracing, and program monitoring.

AGPL-3.0Auto-check passedDevelopment

Install Dynamic Instrumentation

skills CLI
$ npx skills add aftermathlabs/llvm-msvc --skill dynamic-instrumentation -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install aftermathlabs/llvm-msvc dynamic-instrumentation --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/aftermathlabs/llvm-msvc.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/dynamic-instrumentation .claude/skills/dynamic-instrumentation && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
dynamic-instrumentation
GitHub stars
438
Token cost
~2.6k tokens
SKILL.md length
273 words
Files
1
Skills in repo
8
Repo updated
First seen
Licence
AGPL-3.0

At a glance

Expertise in LLVM-based dynamic binary instrumentation, runtime tracing, and program monitoring.

  • Works in 5 steps: Minimize Overhead: Only instrument… → Buffer Events: Batch event logging to… → Use Sampling: Full tracing is expensive,… → …
  • Implementing runtime analysis tools
  • SKILL.md covers Dynamic Binary Instrumentation…, QBDI (QuarkslaB DBI), Instrew - LLVM Lifting DBI and Compile-Time Instrumentation, plus 7 more sections
  • Reaches raw.githubusercontent.com

What it does

Dynamic Instrumentation is an agent skill from aftermathlabs/llvm-msvc. Expertise in LLVM-based dynamic binary instrumentation, runtime tracing, and program monitoring. Use this skill when implementing runtime analysis tools, code coverage systems, profilers, or dynamic security monitors.

Its SKILL.md is about 2.6k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Performance optimization and Test coverage. The repository describes itself as: LLVM fork with explicit compatibility with MSVC 2022 features. The licence is AGPL-3.0.

When your agent uses it

  • Implementing runtime analysis tools
  • Code coverage systems
  • Dynamic security monitors

Example prompts

  • “/dynamic-instrumentation”

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Minimize Overhead: Only instrument necessary code paths
  2. Buffer Events: Batch event logging to reduce I/O
  3. Use Sampling: Full tracing is expensive, sample for production
  4. Thread Safety: Ensure instrumentation is thread-safe
  5. Symbol Resolution: Use debug info for meaningful output

What it can do on your machine

Read from SKILL.md and the folder at commit bfc7254. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are cpp and bash).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • raw.githubusercontent.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Dynamic Instrumentation loads about 2.6k tokens when it runs. Until then it costs about 60 tokens; SKILL.md has 273 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~60
When it runs · the whole SKILL.md, loaded when a task matches
~2.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from aftermathlabs/llvm-msvc at commit bfc7254, republished under its AGPL-3.0 licence (© aftermathlabs). 273 words, ~2,601 tokens.

Download SKILL.mdSave it as .claude/skills/dynamic-instrumentation/SKILL.md (or your agent's skills folder).
name
dynamic-instrumentation
description
Expertise in LLVM-based dynamic binary instrumentation, runtime tracing, and program monitoring. Use this skill when implementing runtime analysis tools, code coverage systems, profilers, or dynamic security monitors.

Dynamic Instrumentation Skill

This skill covers dynamic binary instrumentation (DBI), runtime tracing, and program monitoring using LLVM infrastructure.

Dynamic Binary Instrumentation Overview

What is DBI?

Dynamic Binary Instrumentation allows modifying program behavior at runtime without source code access:

  • Insert analysis code at arbitrary points
  • Monitor program execution
  • Modify control flow and data
LLVM-Based DBI Tools
  • QBDI: QuarkslaB Dynamic Binary Instrumentation
  • Instrew: Fast instrumentation through LLVM lifting
  • binopt: Runtime optimization of binary code

QBDI (QuarkslaB DBI)

Basic Usage
cpp
#include <QBDI.h>

// Callback function for instrumentation
QBDI::VMAction onInstruction(QBDI::VMInstanceRef vm, 
                              QBDI::GPRState *gprState,
                              QBDI::FPRState *fprState, 
                              void *data) {
    // Get current instruction info
    const QBDI::InstAnalysis *inst = vm.getInstAnalysis();
    
    printf("Executing: 0x%lx - %s %s\n", 
           inst->address, 
           inst->mnemonic, 
           inst->operandsStr);
    
    return QBDI::VMAction::CONTINUE;
}

int main() {
    QBDI::VM vm;
    
    // Get current stack
    uint8_t *fakestack;
    QBDI::allocateVirtualStack(vm.getGPRState(), 0x100000, &fakestack);
    
    // Add instrumentation callback
    vm.addCodeCB(QBDI::PREINST, onInstruction, nullptr);
    
    // Run target function
    QBDI::rword retval;
    vm.call(&retval, (QBDI::rword)targetFunction, {arg1, arg2});
    
    return 0;
}
Memory Access Tracking
cpp
QBDI::VMAction onMemoryAccess(QBDI::VMInstanceRef vm,
                               QBDI::GPRState *gprState,
                               QBDI::FPRState *fprState,
                               void *data) {
    // Get memory accesses for current instruction
    std::vector<QBDI::MemoryAccess> memAccesses = vm.getMemoryAccess();
    
    for (const auto &access : memAccesses) {
        const char* type = (access.type == QBDI::MEMORY_READ) ? "READ" : "WRITE";
        printf("%s: addr=0x%lx, size=%d, value=0x%lx\n",
               type, access.accessAddress, access.size, access.value);
    }
    
    return QBDI::VMAction::CONTINUE;
}

// Register callback for memory access events
vm.addMemAccessCB(QBDI::MEMORY_READ_WRITE, onMemoryAccess, nullptr);
Instruction Filtering
cpp
// Only instrument specific instruction ranges
vm.addCodeRangeCB(startAddr, endAddr, QBDI::PREINST, callback, nullptr);

// Instrument specific modules
vm.addCodeAddrCB(targetAddr, QBDI::PREINST, callback, nullptr);

// Remove instrumentation dynamically
vm.deleteInstrumentation(callbackId);

Instrew - LLVM Lifting DBI

Concept

Instrew lifts binary code to LLVM IR at runtime, enabling:

  • High-level optimizations on binary code
  • Efficient instrumentation through LLVM passes
  • JIT recompilation with modifications
Architecture
Binary → Rellume Lifter → LLVM IR → Custom Passes → JIT → Execute
                              ↓
                     [Instrumentation Passes]

Compile-Time Instrumentation

LLVM IR Instrumentation Pass
cpp
struct InstrumentationPass : public llvm::PassInfoMixin<InstrumentationPass> {
    llvm::PreservedAnalyses run(llvm::Module &M,
                                 llvm::ModuleAnalysisManager &MAM) {
        auto &Ctx = M.getContext();
        
        // Declare instrumentation functions
        auto *VoidTy = llvm::Type::getVoidTy(Ctx);
        auto *Int64Ty = llvm::Type::getInt64Ty(Ctx);
        
        auto *LogFuncTy = llvm::FunctionType::get(VoidTy, {Int64Ty}, false);
        auto LogFunc = M.getOrInsertFunction("__log_bb", LogFuncTy);
        
        for (auto &F : M) {
            for (auto &BB : F) {
                // Insert at beginning of each basic block
                llvm::IRBuilder<> Builder(&*BB.getFirstInsertionPt());
                
                auto *BBAddr = llvm::ConstantInt::get(
                    Int64Ty, reinterpret_cast<uint64_t>(&BB));
                Builder.CreateCall(LogFunc, {BBAddr});
            }
        }
        
        return llvm::PreservedAnalyses::none();
    }
};
SanitizerCoverage

Built-in LLVM coverage instrumentation:

bash
# Enable coverage instrumentation
clang -fsanitize-coverage=trace-pc-guard source.c

# Edge coverage
clang -fsanitize-coverage=edge source.c

# Trace comparisons
clang -fsanitize-coverage=trace-cmp source.c
cpp
// Implement coverage callbacks
extern "C" void __sanitizer_cov_trace_pc_guard(uint32_t *guard) {
    if (!*guard) return;
    
    void *PC = __builtin_return_address(0);
    printf("Edge: guard=%u, PC=%p\n", *guard, PC);
}

extern "C" void __sanitizer_cov_trace_pc_guard_init(
    uint32_t *start, uint32_t *stop) {
    
    static uint32_t N = 0;
    for (uint32_t *x = start; x < stop; x++) {
        *x = ++N;
    }
    printf("Total edges: %u\n", N);
}

Runtime Tracing

Function Tracing
cpp
// Compile with: clang -finstrument-functions source.c

extern "C" {
    void __cyg_profile_func_enter(void *func, void *caller) {
        Dl_info info;
        if (dladdr(func, &info)) {
            printf("ENTER: %s\n", info.dli_sname);
        }
    }
    
    void __cyg_profile_func_exit(void *func, void *caller) {
        Dl_info info;
        if (dladdr(func, &info)) {
            printf("EXIT: %s\n", info.dli_sname);
        }
    }
}
XRay Instrumentation

LLVM's built-in instrumentation framework:

bash
# Enable XRay
clang -fxray-instrument -fxray-instruction-threshold=1 source.c
cpp
// Custom XRay handler
[[clang::xray_always_instrument]]
void my_function() {
    // Function will always be instrumented
}

// Runtime control
__xray_patch();    // Enable instrumentation
__xray_unpatch();  // Disable instrumentation

Performance Profiling

Block Frequency
cpp
struct BlockProfiler : public llvm::PassInfoMixin<BlockProfiler> {
    llvm::PreservedAnalyses run(llvm::Function &F,
                                 llvm::FunctionAnalysisManager &FAM) {
        auto &BFI = FAM.getResult<llvm::BlockFrequencyAnalysis>(F);
        
        for (auto &BB : F) {
            auto Freq = BFI.getBlockFreq(&BB);
            llvm::errs() << BB.getName() << ": " << Freq.getFrequency() << "\n";
        }
        
        return llvm::PreservedAnalyses::all();
    }
};
Sampling Profiler Integration
cpp
// Use with perf or similar
// Map addresses back to source using debug info

void interpretProfile(const std::string &profilePath) {
    // Parse profile data
    // Map samples to LLVM IR/source locations
    // Generate optimization hints
}

System Call Monitoring

SysCallStubber

Intercept and monitor system calls:

cpp
// Hook system calls at LLVM IR level
struct SyscallMonitor : public llvm::PassInfoMixin<SyscallMonitor> {
    llvm::PreservedAnalyses run(llvm::Module &M,
                                 llvm::ModuleAnalysisManager &MAM) {
        for (auto &F : M) {
            for (auto &BB : F) {
                for (auto &I : BB) {
                    if (auto *Call = llvm::dyn_cast<llvm::CallInst>(&I)) {
                        if (isSyscallWrapper(Call)) {
                            instrumentSyscall(Call);
                        }
                    }
                }
            }
        }
        return llvm::PreservedAnalyses::none();
    }
};

eBPF Integration

bpfcov - Code Coverage with eBPF
cpp
// eBPF program for coverage collection
SEC("uprobe/target_function")
int trace_function(struct pt_regs *ctx) {
    u64 addr = PT_REGS_IP(ctx);
    
    // Record coverage
    u32 *count = bpf_map_lookup_elem(&coverage_map, &addr);
    if (count) {
        __sync_fetch_and_add(count, 1);
    }
    
    return 0;
}

Taint Tracking

Dynamic Taint Analysis
cpp
// Shadow memory for taint tracking
class TaintTracker {
    std::unordered_map<void*, TaintInfo> shadowMemory;
    
public:
    void markTainted(void *addr, size_t size, TaintSource source) {
        for (size_t i = 0; i < size; i++) {
            shadowMemory[(char*)addr + i] = {source, true};
        }
    }
    
    bool isTainted(void *addr) {
        return shadowMemory.count(addr) && shadowMemory[addr].tainted;
    }
    
    void propagateTaint(void *dst, void *src, size_t size) {
        for (size_t i = 0; i < size; i++) {
            if (isTainted((char*)src + i)) {
                markTainted((char*)dst + i, 1, shadowMemory[(char*)src + i].source);
            }
        }
    }
};

Best Practices

  1. Minimize Overhead: Only instrument necessary code paths
  2. Buffer Events: Batch event logging to reduce I/O
  3. Use Sampling: Full tracing is expensive, sample for production
  4. Thread Safety: Ensure instrumentation is thread-safe
  5. Symbol Resolution: Use debug info for meaningful output

Integration Patterns

Fuzzer Integration
cpp
// Coverage-guided fuzzing with instrumentation
void fuzzerCallback(uint8_t *data, size_t size) {
    // Reset coverage
    __sanitizer_cov_reset_coverage();
    
    // Run target
    targetFunction(data, size);
    
    // Collect coverage
    uint8_t *coverage = __sanitizer_cov_get_coverage();
    feedbackToFuzzer(coverage);
}
Debugging Integration
cpp
// Breakpoint-like instrumentation
void onBreakpoint(void *addr, void *context) {
    // Dump registers
    // Inspect memory
    // Allow continue/step
}

Resources

See Dynamic Binary Instrumentation, Monitor, and eBPF sections in README.md for related tools and projects.

Getting Detailed Information

When you need detailed and up-to-date resource links, tool lists, or project references, fetch the latest data from:

https://raw.githubusercontent.com/gmh5225/awesome-llvm-security/refs/heads/main/README.md

This README contains comprehensive curated lists of:

  • Dynamic Binary Instrumentation tools (DBI section)
  • Runtime monitoring and tracing tools (Monitor section)
  • eBPF-related projects and resources

© aftermathlabs, AGPL-3.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/dynamic-instrumentation of aftermathlabs/llvm-msvc.

Open the folder on GitHubat commit bfc7254

Compare with similar skills

Dynamic Instrumentation next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Dynamic Instrumentation compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Dynamic Instrumentation this skillaftermathlabs/llvm-msvc438—~2.6kAutomated safety check: PassAGPL-3.0
Constraint-Driven Developmentaddyosmani/agent-skills103k2 repos~5.2kAutomated safety check: PassMIT
Issue Fixmono/SkiaSharp5.6k—~5.1kAutomated safety check: PassMIT
MAUI PR Performance Analysisdotnet/maui23k—~2.4kAutomated safety check: PassMIT
Review Envoy Gateway PRenvoyproxy/gateway3.1k—~850Automated safety check: PassApache-2.0
Code Reviewpolyipseity/obsidian-terminal950—~1.6kAutomated safety check: PassAGPL-3.0

Similar skills

  • Constraint-Driven Development

    addyosmani/agent-skills

    Records a project's quality bar in CONSTRAINTS.md and watches diffs for signs an agent quietly weakened it, such as suppressions, skipped tests or lowered thresholds.

    103k GitHub starsUsed in 2 repos~5.2k tokens
    DevelopmentAuto-check passed
  • Issue Fix

    mono/SkiaSharp

    Fix bugs in SkiaSharp C bindings. An agent skill from mono/SkiaSharp.

    5.6k GitHub stars~5.1k tokensUpdated today
    DevelopmentAuto-check passed
  • Official

    Interprets pinned managed benchmark evidence for a dotnet/maui pull request and writes a narrative for the performance review workflow, without running or publishing anything.

    23k GitHub stars~2.4k tokensUpdated today
    DevelopmentAuto-check passed
  • Review Envoy Gateway PR

    envoyproxy/gateway

    Review an Envoy Gateway pull request for essential API, implementation, status, and test coverage requirements.

    3.1k GitHub stars~850 tokensUpdated today
    DevelopmentAuto-check passed
  • Code Review

    polyipseity/obsidian-terminal

    A skill your agent uses when reviewing PRs, code changes, or conducting code audits in obsidian-terminal.

    950 GitHub stars~1.6k tokensUpdated 6 days ago
    DevelopmentAuto-check passed
  • Phoronix Test Suite Benchmarks

    intel/intel-performance-skills

    Official

    Installs, runs, parses and optimizes Phoronix Test Suite benchmarks, saving scores and comparing results before and after code changes.

    334 GitHub stars~2.4k tokensUpdated 11 days ago
    DevelopmentAuto-check passed

More from aftermathlabs/llvm-msvc

All 8 skills in this repo
  • Compiler Development

    aftermathlabs/llvm-msvc

    Expertise in compiler development using LLVM infrastructure including frontend design, IR generation, optimization passes, and code generation.

    438 GitHub stars~1.7k tokensUpdated 6 days ago
    Auto-check passed
  • Llvm Learning

    aftermathlabs/llvm-msvc

    Comprehensive learning resources and tutorials for LLVM, Clang, and compiler development.

    438 GitHub stars~2.1k tokensUpdated 6 days ago
    Auto-check passed
  • Llvm Optimization

    aftermathlabs/llvm-msvc

    Expertise in LLVM optimization passes, performance tuning, and code transformation techniques.

    438 GitHub stars~2.5k tokensUpdated 6 days ago
    Auto-check passed
  • Llvm Security

    aftermathlabs/llvm-msvc

    Expertise in LLVM security features including sanitizers, hardening techniques, exploit mitigations, and secure compilation.

    438 GitHub stars~1.8k tokensUpdated 6 days ago
    Auto-check passed
  • Llvm Tooling

    aftermathlabs/llvm-msvc

    Expertise in LLVM tooling development including Clang plugins, LLDB debugger extensions, Clangd/LSP, and LibTooling.

    438 GitHub stars~2.2k tokensUpdated 6 days ago
    Auto-check passed
  • Mlir Development

    aftermathlabs/llvm-msvc

    Expertise in MLIR (Multi-Level Intermediate Representation) and CIR (Clang IR) development for domain-specific compilation and high-level optimizations.

    438 GitHub stars~2.4k tokensUpdated 6 days ago
    Auto-check passed

Questions about Dynamic Instrumentation

What does Dynamic Instrumentation do?

Expertise in LLVM-based dynamic binary instrumentation, runtime tracing, and program monitoring. Dynamic Instrumentation is an agent skill from aftermathlabs/llvm-msvc. Expertise in LLVM-based dynamic binary instrumentation, runtime tracing, and program monitoring.

When should I use Dynamic Instrumentation?

Dynamic Instrumentation fits situations like: implementing runtime analysis tools; code coverage systems; dynamic security monitors.

How do I install Dynamic Instrumentation in Claude Code?

Run `npx skills add aftermathlabs/llvm-msvc --skill dynamic-instrumentation -a claude-code`. Or copy the skill folder (.agents/skills/dynamic-instrumentation in aftermathlabs/llvm-msvc) into .claude/skills/dynamic-instrumentation in your project. Claude Code loads it when a task matches its description.

How do I install Dynamic Instrumentation in Codex?

Run `npx skills add aftermathlabs/llvm-msvc --skill dynamic-instrumentation -a codex`. Or copy the skill folder (.agents/skills/dynamic-instrumentation in aftermathlabs/llvm-msvc) into .agents/skills/dynamic-instrumentation in your project. Codex loads it when a task matches its description.

Can I use Dynamic Instrumentation in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add aftermathlabs/llvm-msvc --skill dynamic-instrumentation -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/dynamic-instrumentation, .gemini/skills/dynamic-instrumentation, .github/skills/dynamic-instrumentation and .opencode/skills/dynamic-instrumentation in your project.

What does Dynamic Instrumentation need to run?

SKILL.md names no scripts, command-line tools or credentials: Dynamic Instrumentation is instructions for the agent only.

Does Dynamic Instrumentation access the network?

SKILL.md names 1 domain. In commands or code: raw.githubusercontent.com; the agent is likely to contact it when it follows the instructions. This is read from the text; nothing was executed.

Is Dynamic Instrumentation safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Dynamic Instrumentation use?

Dynamic Instrumentation is published under the AGPL-3.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Dynamic Instrumentation use?

About 2.6k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Dynamic Instrumentation?

Skills that share tags, products or a category with Dynamic Instrumentation: Constraint-Driven Development (addyosmani/agent-skills, 103k stars), Issue Fix (mono/SkiaSharp, 5.6k stars), MAUI PR Performance Analysis (dotnet/maui, 23k stars) and Review Envoy Gateway PR (envoyproxy/gateway, 3.1k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Dynamic Instrumentation?

aftermathlabs (a GitHub organization) maintains it in aftermathlabs/llvm-msvc, which has 438 GitHub stars. The repository holds 8 skills in this directory. The repository was last updated on October 3, 2026.

Source: aftermathlabs/llvm-msvc on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.