Debugging rocprofiler-systems
Collaborative debugging for rocprofiler-systems issues. Work WITH the user through systematic triage, not autonomously.
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:
| Question |
Why |
| 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
| Category |
Indicators |
Start With |
| Config/Setup |
Wrong output, missing data |
Logs, rocprof-sys-avail |
| Crash/Segfault |
SIGSEGV, SIGABRT |
Logs, then gdb |
| Hang/Deadlock |
Never finishes |
gdb attach, strace |
| Incorrect Output |
Wrong values |
Logs, trace query |
| Instrumentation Failure |
Dyninst errors |
Logs with -vvv |
| GPU/ROCm Issue |
Missing GPU data |
Logs, amd-smi, env vars |
| Multiprocess Issue |
Fork/MPI failures |
Logs with PID, strace -f |
| Performance Overhead |
Profiled app too slow |
Sampling 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
| Pattern |
Meaning |
[critical] or [error] |
Direct failure |
throw / exception |
C++ exception |
signal / SIG |
Signal received - check if app or profiler |
fork / pid |
Process lifecycle |
pthread / thread |
Thread lifecycle |
perfetto |
Trace backend issues |
dyninst / instrumentation |
Binary rewriting |
rocm / hip / hsa |
GPU 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
| Problem |
Tool |
Reason |
| Crash/signal |
gdb |
Inspect crash state, backtrace |
| Hang/deadlock |
gdb attach + strace |
See what's blocked |
| Syscall failures, missing files |
strace |
Trace OS interactions |
| Library call issues |
ltrace |
Trace shared library calls |
| GPU device issues |
amd-smi |
Check GPU visibility and state |
| Library deps |
ldd |
Check shared library resolution |
| Symbol issues |
nm / objdump |
Check symbol availability |
| Memory issues |
valgrind |
Detect 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
- Strip app to smallest failing case
- Isolate rocprof-sys mode (run vs instrument vs sample)
- Remove optional features one at a time (GPU, MPI, sampling)
- 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
| Gotcha |
Details |
| Fork + OpenMPI + libfabric |
May segfault; use binary rewrite instead of runtime |
| GPU handles after fork |
AMD SMI reinitializes in parent, disabled in child |
| Perfetto buffer overflow |
Increase ROCPROFSYS_PERFETTO_BUFFER_SIZE_KB |
| Thread vs process sampling |
Different env vars control each |
| Signal conflicts |
App and profiler may both want SIGPROF/SIGALRM |
Common Mistakes
| Mistake |
Fix |
| Jumping straight to gdb |
Check logs first - most issues are config errors |
strace without -f on threaded apps |
Always -f for threads, -ff for multiprocess |
| Not testing without profiler first |
Isolate profiler vs app issue |
| Ignoring env vars |
Always env | grep ROCPROFSYS |
Skipping rocprof-sys-avail |
Validates config before deeper debugging |
Integration
| After This Skill |
Use |
| Root cause found, fix needed |
planning-bugfix |
| Need to understand code area |
exploration-explore-code |
| Fix needs tests |
testing-gtest-gmock or testing-pytest |
1---2name: debugging-rocprof-sys3description: Use when rocprofiler-systems crashes, hangs, produces wrong output, fails to instrument, or has GPU/MPI/threading issues during profiling4---56# Debugging rocprofiler-systems78Collaborative debugging for rocprofiler-systems issues. Work WITH the user through systematic triage, not autonomously.910<IMPORTANT>11This is a COLLABORATIVE skill. At each step:121. Present findings and reasoning to the user132. Ask before escalating to heavier tools (gdb, strace)143. Never assume root cause without evidence154. Never attach debuggers to processes without user confirmation16</IMPORTANT>1718## When to Use1920- Crashes or segfaults when profiling with rocprof-sys21- Missing, incorrect, or corrupted profiling output22- Instrumentation failures (Dyninst, symbol issues)23- Multiprocess (fork/MPI) or multithreaded app problems24- GPU/ROCm tracing or sampling failures25- Signal handling conflicts between app and profiler26- Profiling overhead issues2728## When NOT to Use2930- Quick usage questions -> `ask`31- Root cause known, planning a fix -> `planning-bugfix`32- Exploring code without a bug -> `exploration-explore-code`3334## Workflow3536```dot37digraph debugging {38 "User reports issue" [shape=doublecircle];39 "Gather context" [shape=box];40 "Classify problem" [shape=diamond];41 "Enable debug logging" [shape=box];42 "Logs reveal root cause?" [shape=diamond];43 "Conclude" [shape=doublecircle];44 "Choose escalation tool" [shape=diamond];45 "Run tool with user" [shape=box];46 "Root cause found?" [shape=diamond];47 "Deep dive: source + minimal repro" [shape=box];4849 "User reports issue" -> "Gather context";50 "Gather context" -> "Classify problem";51 "Classify problem" -> "Enable debug logging";52 "Enable debug logging" -> "Logs reveal root cause?";53 "Logs reveal root cause?" -> "Conclude" [label="yes"];54 "Logs reveal root cause?" -> "Choose escalation tool" [label="no"];55 "Choose escalation tool" -> "Run tool with user";56 "Run tool with user" -> "Root cause found?";57 "Root cause found?" -> "Conclude" [label="yes"];58 "Root cause found?" -> "Deep dive: source + minimal repro" [label="no"];59 "Deep dive: source + minimal repro" -> "Conclude";60}61```6263## Phase 0: Gather Context6465Use `AskUserQuestion` to collect:6667| Question | Why |68|----------|-----|69| What command are you running? | Which tool: run, instrument, sample, causal |70| What happens vs what you expect? | Classifies the problem |71| Multiprocess? (fork, MPI) | Process-level complexity |72| Multithreaded? (pthreads, OpenMP, HIP) | Thread-level complexity |73| Works without rocprof-sys? | Isolates profiler vs app |74| ROCm version and GPU? | Hardware/driver context |7576### Problem Classification7778| Category | Indicators | Start With |79|----------|-----------|------------|80| Config/Setup | Wrong output, missing data | Logs, `rocprof-sys-avail` |81| Crash/Segfault | SIGSEGV, SIGABRT | Logs, then gdb |82| Hang/Deadlock | Never finishes | gdb attach, strace |83| Incorrect Output | Wrong values | Logs, trace query |84| Instrumentation Failure | Dyninst errors | Logs with `-vvv` |85| GPU/ROCm Issue | Missing GPU data | Logs, `amd-smi`, env vars |86| Multiprocess Issue | Fork/MPI failures | Logs with PID, `strace -f` |87| Performance Overhead | Profiled app too slow | Sampling config, `strace -c` |8889## Phase 1: Log Analysis (Always Start Here)9091### Enable Debug Logging9293```bash94export ROCPROFSYS_LOG_LEVEL=debug # trace|debug|info|warn|error|critical|off95export ROCPROFSYS_VERBOSE=396export ROCPROFSYS_LOG_FILE=/tmp/rocprof-sys-debug.log9798# For instrumentation issues99rocprof-sys-instrument -vvv -- ./app100```101102### Check Configuration103104```bash105rocprof-sys-avail -G /tmp/current-config.cfg --all106env | grep ROCPROFSYS107```108109### Log Patterns110111| Pattern | Meaning |112|---------|---------|113| `[critical]` or `[error]` | Direct failure |114| `throw` / `exception` | C++ exception |115| `signal` / `SIG` | Signal received - check if app or profiler |116| `fork` / `pid` | Process lifecycle |117| `pthread` / `thread` | Thread lifecycle |118| `perfetto` | Trace backend issues |119| `dyninst` / `instrumentation` | Binary rewriting |120| `rocm` / `hip` / `hsa` | GPU subsystem |121122**Decision point:** Present log findings to user. If root cause is clear, go to Phase 4. Otherwise, escalate.123124## Phase 2: Tool Escalation125126Ask user before using any of these tools. Explain WHY the chosen tool fits.127128### Tool Selection129130| Problem | Tool | Reason |131|---------|------|--------|132| Crash/signal | gdb | Inspect crash state, backtrace |133| Hang/deadlock | gdb attach + strace | See what's blocked |134| Syscall failures, missing files | strace | Trace OS interactions |135| Library call issues | ltrace | Trace shared library calls |136| GPU device issues | `amd-smi` | Check GPU visibility and state |137| Library deps | ldd | Check shared library resolution |138| Symbol issues | nm / objdump | Check symbol availability |139| Memory issues | valgrind | Detect memory errors |140141### rocprof-sys-specific gdb Tips142143Standard gdb usage applies. These are rocprof-sys-specific considerations:144145- Look for `rocprof` frames in backtrace to distinguish profiler vs app crash146- For **fork/MPI**: `set follow-fork-mode child` or attach to specific rank PID147- For **threads**: `thread apply all bt` to see all thread states148- Useful breakpoints: `rocprofiler_systems_v1::configure`, `fork_gotcha::audit`149150### rocprof-sys-specific strace Tips151152- **Always** use `-f` for threaded apps, `-ff -o prefix` for multiprocess153- Watch for `open("/dev/kfd")` failures (GPU access)154- Repeated `futex(FUTEX_WAIT)` suggests deadlock in profiler155- For MPI: `mpirun -n 4 strace -ff -o /tmp/strace-mpi rocprof-sys-run -- ./app`156157## Phase 3: Deep Dive158159If Phase 2 narrows but doesn't resolve, inspect source or create minimal repro.160161**Source inspection:** Use `exploration-explore-code` to navigate the rocprof-sys source when needed.162163### Minimal Reproduction1641651. Strip app to smallest failing case1662. Isolate rocprof-sys mode (run vs instrument vs sample)1673. Remove optional features one at a time (GPU, MPI, sampling)1684. Test with simplest preset (`--balanced`)169170## Phase 4: Conclude171172Summarize: problem, root cause, evidence, tools used, resolution.173174If code fix needed, suggest `planning-bugfix`.175176## Known Gotchas177178| Gotcha | Details |179|--------|---------|180| Fork + OpenMPI + libfabric | May segfault; use binary rewrite instead of runtime |181| GPU handles after fork | AMD SMI reinitializes in parent, disabled in child |182| Perfetto buffer overflow | Increase `ROCPROFSYS_PERFETTO_BUFFER_SIZE_KB` |183| Thread vs process sampling | Different env vars control each |184| Signal conflicts | App and profiler may both want SIGPROF/SIGALRM |185186## Common Mistakes187188| Mistake | Fix |189|---------|-----|190| Jumping straight to gdb | Check logs first - most issues are config errors |191| strace without `-f` on threaded apps | Always `-f` for threads, `-ff` for multiprocess |192| Not testing without profiler first | Isolate profiler vs app issue |193| Ignoring env vars | Always `env \| grep ROCPROFSYS` |194| Skipping `rocprof-sys-avail` | Validates config before deeper debugging |195196## Integration197198| After This Skill | Use |199|------------------|-----|200| Root cause found, fix needed | `planning-bugfix` |201| Need to understand code area | `exploration-explore-code` |202| Fix needs tests | `testing-gtest-gmock` or `testing-pytest` |