agentleFS
ROCmROCm/rocprofiler-systems-skills/skills/debugging-rocprof-sys/SKILL.md

debugging-rocprof-sys

Skill5 starsChanged 16 days agoMITView on GitHub

Use when rocprofiler-systems crashes, hangs, produces wrong output, fails to instrument, or has GPU/MPI/threading issues during profiling

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 6 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Ask before escalating to heavier tools (gdb, strace)

    line 13
  2. Distinctive:

    Never assume root cause without evidence

    line 14
  3. Distinctive:

    Never attach debuggers to processes without user confirmation </IMPORTANT>

    line 15
  4. Very specific:

    Use AskUserQuestion to collect:

    line 65
  5. Distinctive:

    Ask user before using any of these tools.

    line 126
  6. Very specific:

    Look for rocprof frames in backtrace to distinguish profiler vs app crash

    line 145
  7. Very specific:

    Always: use -f for threaded apps, -ff -o prefix for multiprocess

    line 152
  8. Distinctive:

    If Phase 2 narrows but doesn't resolve, inspect source or create minimal repro.

    line 159
  9. Very specific:

    Source inspection: Use exploration-explore-code to navigate the rocprof-sys source when needed.

    line 161
  10. Distinctive:

    Remove optional features one at a time (GPU, MPI, sampling)

    line 167
  11. Very specific:

    Test with simplest preset (--balanced)

    line 168
  12. Very specific:

    If code fix needed, suggest planning-bugfix.

    line 174

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Debugging rocprofiler-systems

Collaborative debugging for rocprofiler-systems issues. Work WITH the user through systematic triage, not autonomously.

<IMPORTANT> This is a COLLABORATIVE skill. At each step: 1. Present findings and reasoning to the user 2. Ask before escalating to heavier tools (gdb, strace) 3. Never assume root cause without evidence 4. Never attach debuggers to processes without user confirmation </IMPORTANT>

When to Use

  • Crashes or segfaults when profiling with rocprof-sys
  • Missing, incorrect, or corrupted profiling output
  • Instrumentation failures (Dyninst, symbol issues)
  • Multiprocess (fork/MPI) or multithreaded app problems
  • GPU/ROCm tracing or sampling failures
  • Signal handling conflicts between app and profiler
  • Profiling overhead issues

When NOT to Use

  • Quick usage questions -> ask
  • Root cause known, planning a fix -> planning-bugfix
  • Exploring code without a bug -> exploration-explore-code

Workflow

digraph debugging {
    "User reports issue" [shape=doublecircle];
    "Gather context" [shape=box];
    "Classify problem" [shape=diamond];
    "Enable debug logging" [shape=box];
    "Logs reveal root cause?" [shape=diamond];
    "Conclude" [shape=doublecircle];
    "Choose escalation tool" [shape=diamond];
    "Run tool with user" [shape=box];
    "Root cause found?" [shape=diamond];
    "Deep dive: source + minimal repro" [shape=box];

    "User reports issue" -> "Gather context";
    "Gather context" -> "Classify problem";
    "Classify problem" -> "Enable debug logging";
    "Enable debug logging" -> "Logs reveal root cause?";
    "Logs reveal root cause?" -> "Conclude" [label="yes"];
    "Logs reveal root cause?" -> "Choose escalation tool" [label="no"];
    "Choose escalation tool" -> "Run tool with user";
    "Run tool with user" -> "Root cause found?";
    "Root cause found?" -> "Conclude" [label="yes"];
    "Root cause found?" -> "Deep dive: source + minimal repro" [label="no"];
    "Deep dive: source + minimal repro" -> "Conclude";
}

Phase 0: Gather Context

Use AskUserQuestion to collect:

QuestionWhy
What command are you running?Which tool: run, instrument, sample, causal
What happens vs what you expect?Classifies the problem
Multiprocess? (fork, MPI)Process-level complexity
Multithreaded? (pthreads, OpenMP, HIP)Thread-level complexity
Works without rocprof-sys?Isolates profiler vs app
ROCm version and GPU?Hardware/driver context

Problem Classification

CategoryIndicatorsStart With
Config/SetupWrong output, missing dataLogs, rocprof-sys-avail
Crash/SegfaultSIGSEGV, SIGABRTLogs, then gdb
Hang/DeadlockNever finishesgdb attach, strace
Incorrect OutputWrong valuesLogs, trace query
Instrumentation FailureDyninst errorsLogs with -vvv
GPU/ROCm IssueMissing GPU dataLogs, amd-smi, env vars
Multiprocess IssueFork/MPI failuresLogs with PID, strace -f
Performance OverheadProfiled app too slowSampling config, strace -c

Phase 1: Log Analysis (Always Start Here)

Enable Debug Logging

export ROCPROFSYS_LOG_LEVEL=debug   # trace|debug|info|warn|error|critical|off
export ROCPROFSYS_VERBOSE=3
export ROCPROFSYS_LOG_FILE=/tmp/rocprof-sys-debug.log

# For instrumentation issues
rocprof-sys-instrument -vvv -- ./app

Check Configuration

rocprof-sys-avail -G /tmp/current-config.cfg --all
env | grep ROCPROFSYS

Log Patterns

PatternMeaning
[critical] or [error]Direct failure
throw / exceptionC++ exception
signal / SIGSignal received - check if app or profiler
fork / pidProcess lifecycle
pthread / threadThread lifecycle
perfettoTrace backend issues
dyninst / instrumentationBinary rewriting
rocm / hip / hsaGPU subsystem

Decision point: Present log findings to user. If root cause is clear, go to Phase 4. Otherwise, escalate.

Phase 2: Tool Escalation

Ask user before using any of these tools. Explain WHY the chosen tool fits.

Tool Selection

ProblemToolReason
Crash/signalgdbInspect crash state, backtrace
Hang/deadlockgdb attach + straceSee what's blocked
Syscall failures, missing filesstraceTrace OS interactions
Library call issuesltraceTrace shared library calls
GPU device issuesamd-smiCheck GPU visibility and state
Library depslddCheck shared library resolution
Symbol issuesnm / objdumpCheck symbol availability
Memory issuesvalgrindDetect memory errors

rocprof-sys-specific gdb Tips

Standard gdb usage applies. These are rocprof-sys-specific considerations:

  • Look for rocprof frames in backtrace to distinguish profiler vs app crash
  • For fork/MPI: set follow-fork-mode child or attach to specific rank PID
  • For threads: thread apply all bt to see all thread states
  • Useful breakpoints: rocprofiler_systems_v1::configure, fork_gotcha::audit

rocprof-sys-specific strace Tips

  • Always use -f for threaded apps, -ff -o prefix for multiprocess
  • Watch for open("/dev/kfd") failures (GPU access)
  • Repeated futex(FUTEX_WAIT) suggests deadlock in profiler
  • For MPI: mpirun -n 4 strace -ff -o /tmp/strace-mpi rocprof-sys-run -- ./app

Phase 3: Deep Dive

If Phase 2 narrows but doesn't resolve, inspect source or create minimal repro.

Source inspection: Use exploration-explore-code to navigate the rocprof-sys source when needed.

Minimal Reproduction

  1. Strip app to smallest failing case
  2. Isolate rocprof-sys mode (run vs instrument vs sample)
  3. Remove optional features one at a time (GPU, MPI, sampling)
  4. Test with simplest preset (--balanced)

Phase 4: Conclude

Summarize: problem, root cause, evidence, tools used, resolution.

If code fix needed, suggest planning-bugfix.

Known Gotchas

GotchaDetails
Fork + OpenMPI + libfabricMay segfault; use binary rewrite instead of runtime
GPU handles after forkAMD SMI reinitializes in parent, disabled in child
Perfetto buffer overflowIncrease ROCPROFSYS_PERFETTO_BUFFER_SIZE_KB
Thread vs process samplingDifferent env vars control each
Signal conflictsApp and profiler may both want SIGPROF/SIGALRM

Common Mistakes

MistakeFix
Jumping straight to gdbCheck logs first - most issues are config errors
strace without -f on threaded appsAlways -f for threads, -ff for multiprocess
Not testing without profiler firstIsolate profiler vs app issue
Ignoring env varsAlways env | grep ROCPROFSYS
Skipping rocprof-sys-availValidates config before deeper debugging

Integration

After This SkillUse
Root cause found, fix neededplanning-bugfix
Need to understand code areaexploration-explore-code
Fix needs teststesting-gtest-gmock or testing-pytest

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.