[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-67ecdfed-4d79-4770-9bfc-452481429ec0":3,"$fHCj8Lg6V_ljtV-c9PXOfvt9nAW9oaxew-KeD1QnmTZU":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"67ecdfed-4d79-4770-9bfc-452481429ec0","gdb-cli","AI代理的GDB调试助手 - 分析核心转储，调试实时进程，通过源代码关联调查崩溃和死锁","cat_life_career","mod_other","sickn33,other","---\nname: gdb-cli\ndescription: \"GDB debugging assistant for AI agents - analyze core dumps, debug live processes, investigate crashes and deadlocks with source code correlation\"\ncategory: development\nrisk: critical\nsource: community\ndate_added: \"2026-03-22\"\nauthor: Cerdore\ntags:\n- debugging\n- gdb\n- core-dump\n- crash-analysis\n- c++\n- c\ntools:\n- claude-code\n- cursor\n- gemini-cli\n- codex-cli\n- antigravity\n---\n\n# GDB Debugging Assistant\n\n## Overview\n\nA GDB debugging skill designed for AI agents. Combines **source code analysis** with **runtime state inspection** using gdb-cli to provide intelligent debugging assistance for C\u002FC++ programs.\n\n## When to Use This Skill\n\n- Analyze core dumps or crash dumps\n- Debug running processes with GDB attach\n- Investigate crashes, deadlocks, or memory issues\n- Get intelligent debugging assistance with source code context\n- Debug multi-threaded applications\n\n## Do Not Use This Skill When\n\n- The task is unrelated to C\u002FC++ debugging\n- The user needs general-purpose assistance without debugging\n- No GDB is available (GDB 9.0+ with Python support required)\n\n## Prerequisites\n\n```bash\n# Install gdb-cli\npip install gdb-cli\n\n# Or from GitHub\npip install git+https:\u002F\u002Fgithub.com\u002FCerdore\u002Fgdb-cli.git\n\n# Verify GDB has Python support\ngdb -nx -q -batch -ex \"python print('OK')\"\n```\n\n**Requirements:**\n- Python 3.6.8+\n- GDB 9.0+ with Python support enabled\n- Linux OS\n\n## How It Works\n\n### Step 1: Initialize Debug Session\n\n**For core dump analysis:**\n```bash\ngdb-cli load --binary \u003Cbinary_path> --core \u003Ccore_path> [--gdb-path \u003Cgdb_path>]\n```\n\n**For live process debugging:**\n```bash\ngdb-cli attach --pid \u003Cpid> [--binary \u003Cbinary_path>]\n```\n\n**Output:** A session_id like `\"session_id\": \"a1b2c3\"`. Store this for subsequent commands.\n\n### Step 2: Gather Initial Information\n\n```bash\nSESSION=\"\u003Csession_id>\"\n\n# List all threads\ngdb-cli threads -s $SESSION\n\n# Get backtrace (with local variables)\ngdb-cli bt -s $SESSION --full\n\n# Get registers\ngdb-cli registers -s $SESSION\n```\n\n### Step 3: Correlate Source Code (CRITICAL)\n\nFor each frame in the backtrace:\n1. **Extract frame info**: `{file}:{line} in {function}`\n2. **Read source context**: Get ±20 lines around the crash point\n3. **Get local variables**: `gdb-cli locals-cmd -s $SESSION --frame \u003CN>`\n4. **Analyze**: Correlate code logic with variable values\n\n**Example correlation:**\n```\nFrame #0: process_data() at src\u002Fworker.c:87\nSource code shows:\n  85: Node* node = get_node(id);\n  86: if (node == NULL) return;\n  87: node->data = value;  \u003C- Crash here\n\nVariables show:\n  node = 0x0 (NULL)\n\nAnalysis: The NULL check on line 86 didn't catch the issue.\n```\n\n### Step 4: Deep Investigation\n\n```bash\n# Examine variables\ngdb-cli eval-cmd -s $SESSION \"variable_name\"\ngdb-cli eval-cmd -s $SESSION \"ptr->field\"\ngdb-cli ptype -s $SESSION \"struct_name\"\n\n# Memory inspection\ngdb-cli memory -s $SESSION \"0x7fffffffe000\" --size 64\n\n# Disassembly\ngdb-cli disasm -s $SESSION --count 20\n\n# Check all threads (for deadlock analysis)\ngdb-cli thread-apply -s $SESSION bt --all\n\n# View shared libraries\ngdb-cli sharedlibs -s $SESSION\n```\n\n### Step 5: Session Management\n\n```bash\n# List active sessions\ngdb-cli sessions\n\n# Check session status\ngdb-cli status -s $SESSION\n\n# Stop session (cleanup)\ngdb-cli stop -s $SESSION\n```\n\n## Common Debugging Patterns\n\n### Pattern: Null Pointer Dereference\n\n**Indicators:**\n- Crash on memory access instruction\n- Pointer variable is 0x0\n\n**Investigation:**\n```bash\ngdb-cli registers -s $SESSION  # Check RIP\ngdb-cli eval-cmd -s $SESSION \"ptr\"  # Check pointer value\n```\n\n### Pattern: Deadlock\n\n**Indicators:**\n- Multiple threads stuck in lock functions\n- `pthread_mutex_lock` in backtrace\n\n**Investigation:**\n```bash\ngdb-cli thread-apply -s $SESSION bt --all\n# Look for circular wait patterns\n```\n\n### Pattern: Memory Corruption\n\n**Indicators:**\n- Crash in malloc\u002Ffree\n- Garbage values in variables\n\n**Investigation:**\n```bash\ngdb-cli memory -s $SESSION \"&variable\" --size 128\ngdb-cli registers -s $SESSION\n```\n\n## Examples\n\n### Example 1: Core Dump Analysis\n\n```bash\n# Load core dump\ngdb-cli load --binary .\u002Fmyapp --core \u002Ftmp\u002Fcore.1234\n\n# Get crash location\ngdb-cli bt -s a1b2c3 --full\n\n# Examine crash frame\ngdb-cli locals-cmd -s a1b2c3 --frame 0\n```\n\n### Example 2: Live Process Debugging\n\n```bash\n# Attach to stuck server\ngdb-cli attach --pid 12345\n\n# Check all threads\ngdb-cli threads -s b2c3d4\n\n# Get all backtraces\ngdb-cli thread-apply -s b2c3d4 bt --all\n```\n\n## Best Practices\n\n- Always read source code before drawing conclusions from variable values\n- Use `--range` for pagination on large thread counts or deep backtraces\n- Use `ptype` to understand complex data structures before examining values\n- Check all threads for multi-threaded issues\n- Cross-reference types with source code definitions\n\n## Security & Safety Notes\n\n- This skill requires GDB access to processes and core dumps\n- Attaching to processes may require appropriate permissions (sudo, ptrace_scope)\n- Core dumps may contain sensitive data - handle with care\n- Only debug processes you have authorization to analyze\n\n## Related Skills\n\n- `@systematic-debugging` - General debugging methodology\n- `@test-driven-development` - Write tests before implementation\n\n## Links\n\n- **Repository**: https:\u002F\u002Fgithub.com\u002FCerdore\u002Fgdb-cli\n- **PyPI**: https:\u002F\u002Fpypi.org\u002Fproject\u002Fgdb-cli\u002F\n- **Documentation**: https:\u002F\u002Fgithub.com\u002FCerdore\u002Fgdb-cli#readme\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,214,1174,"2026-05-16 13:19:46",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"其他","other","mdi-page-next-outline","其他类型Skill",5,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"职场发展","career","mdi-briefcase-outline","面试准备、简历优化、职业规划",4,575,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"71aa9f60-426d-4dcd-a032-7118c37202c3","1.0.0","gdb-cli.zip",2572,"uploads\u002Fskills\u002F67ecdfed-4d79-4770-9bfc-452481429ec0\u002Fgdb-cli.zip","a7c89502878c3f2639ed85cd86a39cf71dcc95e4d80892bbaf01a0ebde6058b0","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":5736}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]