Token导航 LogoToken导航TokenDH.com
研究检索只读github未标认证来源可访问许可证需确认审计通过

valgrindvalgrind 搜索

Agent Skill

valgrind 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

2,399

周安装

98

GitHub Stars

80

下载量

776
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:valgrind(valgrind 搜索)
来源仓库:https://github.com/mohitmishra786/low-level-dev-skills
仓库路径:skills/valgrind
安装命令:
npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill valgrind
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill valgrind

简介

valgrind 用于内存调试和泄漏检测,适合在 Codex、Claude、Cursor、Gemini CLI 中需要分析程序运行时内存问题时使用。

  • 可检测无效读写、未初始化值使用、内存泄漏及释放后使用等常见错误,支持多种参数配置以适应不同场景。
  • 通过命令行运行目标程序并配合 valgrind 选项生成详细报告,便于定位代码中的内存缺陷。
  • 安装需通过 GitHub 仓库,建议确认环境兼容性、权限范围及是否允许执行外部命令或访问系统资源。
  • valgrind 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Valgrind

Purpose

Guide agents through Valgrind tools: Memcheck for memory errors, Cachegrind for cache simulation, Callgrind for call graphs, and Massif for heap profiling.

Triggers

  • "My program has a memory leak / use-after-free"
  • "I can't use ASan — can I use Valgrind instead?"
  • "How do I profile cache behaviour without perf?"
  • "How do I visualize call graphs with Callgrind?"
  • "How do I profile heap allocation patterns?"
  • "Valgrind reports errors in third-party code I can't fix"

Workflow

1. Memcheck — memory error detection

Compile with -g -O1 for best results. -O0 is also fine; avoid -O2+ which can produce false positives.

valgrind --tool=memcheck \
         --leak-check=full \
         --show-leak-kinds=all \
         --track-origins=yes \
         --error-exitcode=1 \
         ./prog [args]

Key flags:

FlagDefaultEffect
--leak-check=fullsummaryFull leak details
--show-leak-kinds=alldefiniteShow all leak kinds
--track-origins=yesnoShow where uninit values came from (slow)
--error-exitcode=N0Exit N if errors found (CI integration)
--log-file=filestderrSave report to file
--suppressions=filenoneSuppress known FPs
--gen-suppressions=yesnoPrint suppression directives for errors
--max-stackframe=N2000000Increase for deep stacks
--malloc-fill=0xABoffFill allocated memory (detect uninit use)
--free-fill=0xCDoffFill freed memory (detect use-after-free)

2. Understanding Memcheck output

==12345== Invalid read of size 4
==12345==    at 0x4007A2: foo (main.c:15)
==12345==    by 0x400846: main (main.c:30)
==12345==  Address 0x5204040 is 0 bytes after a block of size 40 alloc'd
==12345==    at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck.so)
==12345==    by 0x40074B: main (main.c:25)
  • Invalid read/write: out-of-bounds access; check array bounds
  • Use of uninitialised value: read before write; use --track-origins=yes
  • Invalid free / double free: mismatched malloc/free; check ownership
  • Definitely lost: reachable via no pointers; clear leak
  • Indirectly lost: lost through a chain; usually means one root leak
  • Possibly lost: might be pointing into the middle of a block; often FP with custom allocators

3. Leak kinds

KindMeaning
Definitely lostNo pointer to block
Indirectly lostLost via another lost block
Possibly lostPointer into middle of block
Still reachablePointer exists at exit; not a leak but never freed

For library code: --show-leak-kinds=definite,indirect reduces noise from still-reachable.

4. Suppressions

# Generate suppression for current error
valgrind --gen-suppressions=yes ./prog 2>&1 | grep -A20 '{'

# Example suppression file (valgrind.supp)
{
   openssl_uninit
   Memcheck:Cond
   fun:SHA256_Init
   ...
}

# Use suppression file
valgrind --suppressions=valgrind.supp ./prog

5. Cachegrind — cache simulation

valgrind --tool=cachegrind ./prog

# Output: cachegrind.out.PID
# Annotate source
cg_annotate cachegrind.out.12345 --auto=yes

# Diff two runs
cg_diff cachegrind.out.before cachegrind.out.after

Key metrics:

  • I1mr / ILmr: L1/LL instruction cache miss rate
  • D1mr / DLmr: L1/LL data read miss rate
  • D1mw / DLmw: L1/LL data write miss rate

6. Callgrind — call graph profiling

valgrind --tool=callgrind --callgrind-out-file=callgrind.out ./prog

# Analyse
callgrind_annotate callgrind.out

# Visualise in KCachegrind (GUI)
kcachegrind callgrind.out

Callgrind is slower than perf but works without root and provides exact call counts.

7. Massif — heap profiling

valgrind --tool=massif ./prog

# Visualise
ms_print massif.out.PID | less

# GUI
massif-visualizer massif.out.PID

Massif shows heap usage over time; useful for finding peak allocation sites and tracking gradual leaks.

8. Performance considerations

Valgrind Memcheck runs ~10-50x slower than native. Mitigations:

  • Use a shorter representative workload
  • Use --error-exitcode=1 to fail fast in CI
  • Use ASan (-fsanitize=address) for faster memory checking during development
  • Reserve Valgrind for cases where ASan can't be used (old toolchains, production-like environments)

For a comparison of Valgrind vs ASan, see references/valgrind-vs-asan.md.

Related skills

  • Use skills/runtimes/sanitizers for faster ASan/UBSan alternatives
  • Use skills/profilers/linux-perf for CPU-level profiling (faster than Cachegrind)
  • Use skills/profilers/flamegraphs to visualise Callgrind output

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.49%
按下载量换算283

Claude

28.41%
按下载量换算220

Cursor

18.58%
按下载量换算144

Gemini CLI

9.33%
按下载量换算72

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills