{"owner":"iovisor","repo":"bcc","hasSkills":true,"totalSkillsCount":2,"totalTokensCount":2235,"categories":["copilot-instructions","plugin-manifest"],"hasMcp":false,"mcpConfig":null,"found":[".github/copilot-instructions.md","libbpf-tools/README.md"],"skills":{".github/copilot-instructions.md":"# BCC Project — GitHub Copilot Instructions\n\nBCC is a toolkit for creating efficient kernel tracing and manipulation programs using eBPF. Tools run in **mission-critical environments as root**.\n\n## Global Review Principles (Applied to all PRs)\n\n### PR Value Assessment (Evaluate First)\n\nBefore detailed code review, assess:\n\n1. **Scope fit**: Does this belong in BCC, or should it be a separate tool/project?\n2. **Existing coverage**: Does an existing tool already do this? Can it be extended instead?\n3. **Production value**: Is there a real use case? (Not just \"might be useful someday\")\n4. **Maintenance cost**: Is the added complexity justified by the value?\n\nFlag as 🔴 if PR adds a tool that duplicates existing functionality without clear differentiation.\n\n### Kernel & eBPF Alignment\n\n**Modern eBPF Direction (Prefer)**\n- CO-RE over kernel-version `#ifdef`\n- BTF-enabled patterns over legacy\n- fentry/fexit with kprobe fallback when targeting broad kernel support\n\n**Backward Compatibility**\n- New features MUST NOT break existing default behavior\n- Kernel-version-dependent features: provide fallback or graceful degradation\n- Document minimum kernel version in man page if tool requires specific features\n\n### Performance Considerations\n\n- **Prefer filtering in BPF**: Reduce kernel-to-user data transfer where feasible\n- **Prefer map aggregation**: Over per-event output for high-frequency events\n- **Be mindful of helper costs**: `bpf_get_stackid`, `bpf_probe_read_user_str` have overhead — acceptable when core to tool's purpose, but avoid in unrelated hot paths\n- **Disclose overhead**: Man page OVERHEAD section MUST describe expected impact\n\n### Commit Message Format\n\n```\n<prefix>: <short summary>\n\n<WHY this change is needed — not just what changed>\n- Problem being solved\n- Why this approach was chosen\n```\n\n**Prefixes:** `tools/toolname:`, `libbpf-tools/toolname:`, `src/cc:`, `build:`, `ci:`, `docs:`, `tests/python:`\n\n### Style Checks\n\n- **Python:** `scripts/py-style-check.sh` (pycodestyle, ignore E123/E125/E126/E127/E128/E302)\n- **C/C++:** `scripts/c-style-check.sh` (git clang-format against master)\n\n<CriticalRules>\n- MUST perform a NULL check after any BPF C Map lookup.\n- MUST perform a NULL check after every `malloc()`, `calloc()`, `realloc()`, and `strdup()` call in userspace C code.\n- MUST perform a bounds check for all array accesses.\n- BPF C functions: flag if stack usage appears to approach or exceed 512 bytes (eBPF verifier hard limit).\n- Default output format MUST be under 80 characters wide.\n</CriticalRules>\n\n### Documentation Requirements (New Tools)\n\nAll **new tools** require these **minimum** files (enforce as blocker):\n1. Tool script\n2. Man page (`man/man8/`) with an **OVERHEAD** section\n3. `README.md` entry\n\nAdditional per-subsystem requirements apply — defer to the relevant\n`instructions/*.instructions.md` file (e.g., `tools.instructions.md` also\nrequires `tests/python/test_tools_smoke.py`; `*_example.txt` is required for\n`tools/` but recommended for `libbpf-tools/`).\n\nFor **bug-fix or enhancement PRs on existing tools**: flag missing docs as 🟡 Warning, not a blocker.\n> Note: ~14% of libbpf-tools currently ship without a man page — this is a known gap, not a reason to skip the requirement for new tools.\n\n### Unix Philosophy\n\n- Do one thing and do it well\n- Default output **< 80 characters wide**\n- Prefer short tool names; avoid underscores for new tools unless needed for\n  clarity or to match an existing naming pattern (e.g., `mysqld_qslower`)\n- Prefer a positional argument for the most common parameter (e.g., interval) over a flag,\n  where it makes sense for the tool's use case\n","libbpf-tools/README.md":"Useful links\n------------\n\n- [BPF Portability and CO-RE](https://facebookmicrosites.github.io/bpf/blog/2020/02/19/bpf-portability-and-co-re.html)\n- [HOWTO: BCC to libbpf conversion](https://facebookmicrosites.github.io/bpf/blog/2020/02/20/bcc-to-libbpf-howto-guide.html)\n- [Tips & tricks for writing libbpf-tools](https://en.pingcap.com/blog/tips-and-tricks-for-writing-linux-bpf-applications-with-libbpf)\n\nBuilding\n-------\n\nTo build libbpf-based tools, simply run `make`. This will build all the listed\ntools/applications. All the build artifacts, by default, go into .output\nsubdirectory to keep source code and build artifacts completely separate. The\nonly exception is resulting tool binaries, which are put in a current\ndirectory. `make clean` will clean up all the build artifacts, including\ngenerated binaries.\n\nGiven that the libbpf package might not be available across wide variety of\ndistributions, all libbpf-based tools are linked statically against a version\nof libbpf that BCC links against (from submodule under src/cc/libbpf). This\nresults in binaries with minimal amount of dependencies (libc, libelf, and\nlibz are linked dynamically, though, given their widespread availability).\nIf your build fails because the libbpf submodule is outdated, try running `git\nsubmodule update --init --recursive`.\n\nTools are expected to follow a simple naming convention:\n  - <tool>.c contains userspace C code of a tool.\n  - <tool>.bpf.c contains BPF C code, which gets compiled into BPF ELF file.\n    This ELF file is used to generate BPF skeleton <tool>.skel.h, which is\n    subsequently is included from <tool>.c.\n  - <tool>.h can optionally contain any types and constants, shared by both\n    BPF and userspace sides of a tool.\n\nFor such cases, simply adding <tool> name to Makefile's APPS variable will\nensure this tool is built alongside others.\n\nFor more complicated applications, some extra Makefile rules might need to be\ncreated. For such cases, it is advised to put application into a dedicated\nsubdirectory and link it from main Makefile.\n\nvmlinux.h generation\n-------------------\n\nvmlinux.h contains all kernel types, both exported and internal-only. BPF\nCO-RE-based applications are expected to include this file in their BPF\nprogram C source code to avoid dependency on kernel headers package.\n\nFor more reproducible builds, vmlinux.h header file is pre-generated and\nchecked in along the other sources. This is done to avoid dependency on\nspecific user/build server's kernel configuration, because vmlinux.h\ngeneration depends on having a kernel with BTF type information built-in\n(which is enabled by `CONFIG_DEBUG_INFO_BTF=y` Kconfig option See below).\n\nvmlinux.h is generated from upstream Linux version at particular minor\nversion tag. E.g., `vmlinux_505.h` is generated from v5.5 tag. Exact set of\ntypes available in compiled kernel depends on configuration used to compile\nit. To generate present vmlinux.h header, default configuration was used, with\nonly extra `CONFIG_DEBUG_INFO_BTF=y` option enabled.\n\nGiven different kernel version can have incompatible type definitions, it\nmight be important to use vmlinux.h of a specific kernel version as a \"base\"\nversion of header. To that extent, all vmlinux.h headers are versioned by\nappending <MAJOR><MINOR> suffix to a file name. There is always a symbolic\nlink vmlinux.h, that points to whichever version is deemed to be default\n(usually, latest).\n\nbpftool\n-------\n\nbpftool is a universal tool used for inspection of BPF resources, as well as\nproviding various extra BPF-related facilities, like code-generation of BPF\nprogram skeletons. The latter functionality is heavily used by these tools to\nload and interact with BPF programs.\n\nGiven bpftool package can't yet be expected to be available widely across many\ndistributions, bpftool binary is checked in into BCC repository in bin/\nsubdirectory. Once bpftool package is more widely available, this can be\nchanged in favor of using pre-packaged version of bpftool.\n\n\nRe-compiling your Kernel with CONFIG_DEBUG_INFO_BTF=y\n-----------------------------------------------------\nlibbpf probes to see if your sys fs exports the file `/sys/kernel/btf/vmlinux` (from Kernel 5.5+) or if you have the ELF version in your system [`code`](https://github.com/libbpf/libbpf/blob/master/src/btf.c)\nPlease note the ELF file could exist without the BTF info in it. Your Kconfig should contain the options below\n\n1. Compile options\n```code\nCONFIG_DEBUG_INFO_BTF=y\nCONFIG_DEBUG_INFO=y\n```\n2. Also, make sure that you have pahole 1.13 (or preferably 1.16+) during the\nkernel build (it comes from dwarves package). Without it, BTF won't be\ngenerated, and on older kernels you'd get only warning, but still would\nbuild kernel successfully\n\nRunning in kernels without CONFIG_DEBUG_INFO_BTF=y\n--------------------------------------------------\n\nIt's possible to run some tools in kernels that don't expose\n`/sys/kernel/btf/vmlinux`. For those cases,\n[BTFGen](https://lore.kernel.org/bpf/20220215225856.671072-1-mauricio@kinvolk.io)\nand [BTFHub](https://github.com/aquasecurity/btfhub) can be used to\ngenerate small BTF files for the most popular Linux distributions that\nare shipped with the tools in order to provide the needed information to\nperform the CO-RE relocations when loading the eBPF programs.\n\nIf you haven't cloned the\n[btfhub-archive](https://github.com/aquasecurity/btfhub) repository, you\ncan run make and it'll clone it for you into the `$HOME/.local/share`\ndirectory:\n\n```bash\nmake ENABLE_MIN_CORE_BTFS=1 -j$(nproc)\n```\n\nIf you have a local copy of such repository, you can pass it's location\nto avoid cloning it again:\n\n```bash\nmake ENABLE_MIN_CORE_BTFS=1 BTF_HUB_ARCHIVE=<path_to_btfhub-archive> -j$(nproc)\n```\n"},"files":{".github/copilot-instructions.md":"# BCC Project — GitHub Copilot Instructions\n\nBCC is a toolkit for creating efficient kernel tracing and manipulation programs using eBPF. Tools run in **mission-critical environments as root**.\n\n## Global Review Principles (Applied to all PRs)\n\n### PR Value Assessment (Evaluate First)\n\nBefore detailed code review, assess:\n\n1. **Scope fit**: Does this belong in BCC, or should it be a separate tool/project?\n2. **Existing coverage**: Does an existing tool already do this? Can it be extended instead?\n3. **Production value**: Is there a real use case? (Not just \"might be useful someday\")\n4. **Maintenance cost**: Is the added complexity justified by the value?\n\nFlag as 🔴 if PR adds a tool that duplicates existing functionality without clear differentiation.\n\n### Kernel & eBPF Alignment\n\n**Modern eBPF Direction (Prefer)**\n- CO-RE over kernel-version `#ifdef`\n- BTF-enabled patterns over legacy\n- fentry/fexit with kprobe fallback when targeting broad kernel support\n\n**Backward Compatibility**\n- New features MUST NOT break existing default behavior\n- Kernel-version-dependent features: provide fallback or graceful degradation\n- Document minimum kernel version in man page if tool requires specific features\n\n### Performance Considerations\n\n- **Prefer filtering in BPF**: Reduce kernel-to-user data transfer where feasible\n- **Prefer map aggregation**: Over per-event output for high-frequency events\n- **Be mindful of helper costs**: `bpf_get_stackid`, `bpf_probe_read_user_str` have overhead — acceptable when core to tool's purpose, but avoid in unrelated hot paths\n- **Disclose overhead**: Man page OVERHEAD section MUST describe expected impact\n\n### Commit Message Format\n\n```\n<prefix>: <short summary>\n\n<WHY this change is needed — not just what changed>\n- Problem being solved\n- Why this approach was chosen\n```\n\n**Prefixes:** `tools/toolname:`, `libbpf-tools/toolname:`, `src/cc:`, `build:`, `ci:`, `docs:`, `tests/python:`\n\n### Style Checks\n\n- **Python:** `scripts/py-style-check.sh` (pycodestyle, ignore E123/E125/E126/E127/E128/E302)\n- **C/C++:** `scripts/c-style-check.sh` (git clang-format against master)\n\n<CriticalRules>\n- MUST perform a NULL check after any BPF C Map lookup.\n- MUST perform a NULL check after every `malloc()`, `calloc()`, `realloc()`, and `strdup()` call in userspace C code.\n- MUST perform a bounds check for all array accesses.\n- BPF C functions: flag if stack usage appears to approach or exceed 512 bytes (eBPF verifier hard limit).\n- Default output format MUST be under 80 characters wide.\n</CriticalRules>\n\n### Documentation Requirements (New Tools)\n\nAll **new tools** require these **minimum** files (enforce as blocker):\n1. Tool script\n2. Man page (`man/man8/`) with an **OVERHEAD** section\n3. `README.md` entry\n\nAdditional per-subsystem requirements apply — defer to the relevant\n`instructions/*.instructions.md` file (e.g., `tools.instructions.md` also\nrequires `tests/python/test_tools_smoke.py`; `*_example.txt` is required for\n`tools/` but recommended for `libbpf-tools/`).\n\nFor **bug-fix or enhancement PRs on existing tools**: flag missing docs as 🟡 Warning, not a blocker.\n> Note: ~14% of libbpf-tools currently ship without a man page — this is a known gap, not a reason to skip the requirement for new tools.\n\n### Unix Philosophy\n\n- Do one thing and do it well\n- Default output **< 80 characters wide**\n- Prefer short tool names; avoid underscores for new tools unless needed for\n  clarity or to match an existing naming pattern (e.g., `mysqld_qslower`)\n- Prefer a positional argument for the most common parameter (e.g., interval) over a flag,\n  where it makes sense for the tool's use case\n","libbpf-tools/README.md":"Useful links\n------------\n\n- [BPF Portability and CO-RE](https://facebookmicrosites.github.io/bpf/blog/2020/02/19/bpf-portability-and-co-re.html)\n- [HOWTO: BCC to libbpf conversion](https://facebookmicrosites.github.io/bpf/blog/2020/02/20/bcc-to-libbpf-howto-guide.html)\n- [Tips & tricks for writing libbpf-tools](https://en.pingcap.com/blog/tips-and-tricks-for-writing-linux-bpf-applications-with-libbpf)\n\nBuilding\n-------\n\nTo build libbpf-based tools, simply run `make`. This will build all the listed\ntools/applications. All the build artifacts, by default, go into .output\nsubdirectory to keep source code and build artifacts completely separate. The\nonly exception is resulting tool binaries, which are put in a current\ndirectory. `make clean` will clean up all the build artifacts, including\ngenerated binaries.\n\nGiven that the libbpf package might not be available across wide variety of\ndistributions, all libbpf-based tools are linked statically against a version\nof libbpf that BCC links against (from submodule under src/cc/libbpf). This\nresults in binaries with minimal amount of dependencies (libc, libelf, and\nlibz are linked dynamically, though, given their widespread availability).\nIf your build fails because the libbpf submodule is outdated, try running `git\nsubmodule update --init --recursive`.\n\nTools are expected to follow a simple naming convention:\n  - <tool>.c contains userspace C code of a tool.\n  - <tool>.bpf.c contains BPF C code, which gets compiled into BPF ELF file.\n    This ELF file is used to generate BPF skeleton <tool>.skel.h, which is\n    subsequently is included from <tool>.c.\n  - <tool>.h can optionally contain any types and constants, shared by both\n    BPF and userspace sides of a tool.\n\nFor such cases, simply adding <tool> name to Makefile's APPS variable will\nensure this tool is built alongside others.\n\nFor more complicated applications, some extra Makefile rules might need to be\ncreated. For such cases, it is advised to put application into a dedicated\nsubdirectory and link it from main Makefile.\n\nvmlinux.h generation\n-------------------\n\nvmlinux.h contains all kernel types, both exported and internal-only. BPF\nCO-RE-based applications are expected to include this file in their BPF\nprogram C source code to avoid dependency on kernel headers package.\n\nFor more reproducible builds, vmlinux.h header file is pre-generated and\nchecked in along the other sources. This is done to avoid dependency on\nspecific user/build server's kernel configuration, because vmlinux.h\ngeneration depends on having a kernel with BTF type information built-in\n(which is enabled by `CONFIG_DEBUG_INFO_BTF=y` Kconfig option See below).\n\nvmlinux.h is generated from upstream Linux version at particular minor\nversion tag. E.g., `vmlinux_505.h` is generated from v5.5 tag. Exact set of\ntypes available in compiled kernel depends on configuration used to compile\nit. To generate present vmlinux.h header, default configuration was used, with\nonly extra `CONFIG_DEBUG_INFO_BTF=y` option enabled.\n\nGiven different kernel version can have incompatible type definitions, it\nmight be important to use vmlinux.h of a specific kernel version as a \"base\"\nversion of header. To that extent, all vmlinux.h headers are versioned by\nappending <MAJOR><MINOR> suffix to a file name. There is always a symbolic\nlink vmlinux.h, that points to whichever version is deemed to be default\n(usually, latest).\n\nbpftool\n-------\n\nbpftool is a universal tool used for inspection of BPF resources, as well as\nproviding various extra BPF-related facilities, like code-generation of BPF\nprogram skeletons. The latter functionality is heavily used by these tools to\nload and interact with BPF programs.\n\nGiven bpftool package can't yet be expected to be available widely across many\ndistributions, bpftool binary is checked in into BCC repository in bin/\nsubdirectory. Once bpftool package is more widely available, this can be\nchanged in favor of using pre-packaged version of bpftool.\n\n\nRe-compiling your Kernel with CONFIG_DEBUG_INFO_BTF=y\n-----------------------------------------------------\nlibbpf probes to see if your sys fs exports the file `/sys/kernel/btf/vmlinux` (from Kernel 5.5+) or if you have the ELF version in your system [`code`](https://github.com/libbpf/libbpf/blob/master/src/btf.c)\nPlease note the ELF file could exist without the BTF info in it. Your Kconfig should contain the options below\n\n1. Compile options\n```code\nCONFIG_DEBUG_INFO_BTF=y\nCONFIG_DEBUG_INFO=y\n```\n2. Also, make sure that you have pahole 1.13 (or preferably 1.16+) during the\nkernel build (it comes from dwarves package). Without it, BTF won't be\ngenerated, and on older kernels you'd get only warning, but still would\nbuild kernel successfully\n\nRunning in kernels without CONFIG_DEBUG_INFO_BTF=y\n--------------------------------------------------\n\nIt's possible to run some tools in kernels that don't expose\n`/sys/kernel/btf/vmlinux`. For those cases,\n[BTFGen](https://lore.kernel.org/bpf/20220215225856.671072-1-mauricio@kinvolk.io)\nand [BTFHub](https://github.com/aquasecurity/btfhub) can be used to\ngenerate small BTF files for the most popular Linux distributions that\nare shipped with the tools in order to provide the needed information to\nperform the CO-RE relocations when loading the eBPF programs.\n\nIf you haven't cloned the\n[btfhub-archive](https://github.com/aquasecurity/btfhub) repository, you\ncan run make and it'll clone it for you into the `$HOME/.local/share`\ndirectory:\n\n```bash\nmake ENABLE_MIN_CORE_BTFS=1 -j$(nproc)\n```\n\nIf you have a local copy of such repository, you can pass it's location\nto avoid cloning it again:\n\n```bash\nmake ENABLE_MIN_CORE_BTFS=1 BTF_HUB_ARCHIVE=<path_to_btfhub-archive> -j$(nproc)\n```\n"},"items":[{"name":"copilot-instructions.md","path":".github/copilot-instructions.md","rawUrl":"https://raw.githubusercontent.com/iovisor/bcc/HEAD/.github/copilot-instructions.md","title":"GitHub Copilot Instructions","category":"copilot-instructions","format":"markdown","content":"# BCC Project — GitHub Copilot Instructions\n\nBCC is a toolkit for creating efficient kernel tracing and manipulation programs using eBPF. Tools run in **mission-critical environments as root**.\n\n## Global Review Principles (Applied to all PRs)\n\n### PR Value Assessment (Evaluate First)\n\nBefore detailed code review, assess:\n\n1. **Scope fit**: Does this belong in BCC, or should it be a separate tool/project?\n2. **Existing coverage**: Does an existing tool already do this? Can it be extended instead?\n3. **Production value**: Is there a real use case? (Not just \"might be useful someday\")\n4. **Maintenance cost**: Is the added complexity justified by the value?\n\nFlag as 🔴 if PR adds a tool that duplicates existing functionality without clear differentiation.\n\n### Kernel & eBPF Alignment\n\n**Modern eBPF Direction (Prefer)**\n- CO-RE over kernel-version `#ifdef`\n- BTF-enabled patterns over legacy\n- fentry/fexit with kprobe fallback when targeting broad kernel support\n\n**Backward Compatibility**\n- New features MUST NOT break existing default behavior\n- Kernel-version-dependent features: provide fallback or graceful degradation\n- Document minimum kernel version in man page if tool requires specific features\n\n### Performance Considerations\n\n- **Prefer filtering in BPF**: Reduce kernel-to-user data transfer where feasible\n- **Prefer map aggregation**: Over per-event output for high-frequency events\n- **Be mindful of helper costs**: `bpf_get_stackid`, `bpf_probe_read_user_str` have overhead — acceptable when core to tool's purpose, but avoid in unrelated hot paths\n- **Disclose overhead**: Man page OVERHEAD section MUST describe expected impact\n\n### Commit Message Format\n\n```\n<prefix>: <short summary>\n\n<WHY this change is needed — not just what changed>\n- Problem being solved\n- Why this approach was chosen\n```\n\n**Prefixes:** `tools/toolname:`, `libbpf-tools/toolname:`, `src/cc:`, `build:`, `ci:`, `docs:`, `tests/python:`\n\n### Style Checks\n\n- **Python:** `scripts/py-style-check.sh` (pycodestyle, ignore E123/E125/E126/E127/E128/E302)\n- **C/C++:** `scripts/c-style-check.sh` (git clang-format against master)\n\n<CriticalRules>\n- MUST perform a NULL check after any BPF C Map lookup.\n- MUST perform a NULL check after every `malloc()`, `calloc()`, `realloc()`, and `strdup()` call in userspace C code.\n- MUST perform a bounds check for all array accesses.\n- BPF C functions: flag if stack usage appears to approach or exceed 512 bytes (eBPF verifier hard limit).\n- Default output format MUST be under 80 characters wide.\n</CriticalRules>\n\n### Documentation Requirements (New Tools)\n\nAll **new tools** require these **minimum** files (enforce as blocker):\n1. Tool script\n2. Man page (`man/man8/`) with an **OVERHEAD** section\n3. `README.md` entry\n\nAdditional per-subsystem requirements apply — defer to the relevant\n`instructions/*.instructions.md` file (e.g., `tools.instructions.md` also\nrequires `tests/python/test_tools_smoke.py`; `*_example.txt` is required for\n`tools/` but recommended for `libbpf-tools/`).\n\nFor **bug-fix or enhancement PRs on existing tools**: flag missing docs as 🟡 Warning, not a blocker.\n> Note: ~14% of libbpf-tools currently ship without a man page — this is a known gap, not a reason to skip the requirement for new tools.\n\n### Unix Philosophy\n\n- Do one thing and do it well\n- Default output **< 80 characters wide**\n- Prefer short tool names; avoid underscores for new tools unless needed for\n  clarity or to match an existing naming pattern (e.g., `mysqld_qslower`)\n- Prefer a positional argument for the most common parameter (e.g., interval) over a flag,\n  where it makes sense for the tool's use case\n","isInternal":false,"tokens":861,"sizeBytes":3666},{"name":"README.md","path":"libbpf-tools/README.md","rawUrl":"https://raw.githubusercontent.com/iovisor/bcc/HEAD/libbpf-tools/README.md","title":"libbpf-tools Documentation","category":"plugin-manifest","format":"markdown","content":"Useful links\n------------\n\n- [BPF Portability and CO-RE](https://facebookmicrosites.github.io/bpf/blog/2020/02/19/bpf-portability-and-co-re.html)\n- [HOWTO: BCC to libbpf conversion](https://facebookmicrosites.github.io/bpf/blog/2020/02/20/bcc-to-libbpf-howto-guide.html)\n- [Tips & tricks for writing libbpf-tools](https://en.pingcap.com/blog/tips-and-tricks-for-writing-linux-bpf-applications-with-libbpf)\n\nBuilding\n-------\n\nTo build libbpf-based tools, simply run `make`. This will build all the listed\ntools/applications. All the build artifacts, by default, go into .output\nsubdirectory to keep source code and build artifacts completely separate. The\nonly exception is resulting tool binaries, which are put in a current\ndirectory. `make clean` will clean up all the build artifacts, including\ngenerated binaries.\n\nGiven that the libbpf package might not be available across wide variety of\ndistributions, all libbpf-based tools are linked statically against a version\nof libbpf that BCC links against (from submodule under src/cc/libbpf). This\nresults in binaries with minimal amount of dependencies (libc, libelf, and\nlibz are linked dynamically, though, given their widespread availability).\nIf your build fails because the libbpf submodule is outdated, try running `git\nsubmodule update --init --recursive`.\n\nTools are expected to follow a simple naming convention:\n  - <tool>.c contains userspace C code of a tool.\n  - <tool>.bpf.c contains BPF C code, which gets compiled into BPF ELF file.\n    This ELF file is used to generate BPF skeleton <tool>.skel.h, which is\n    subsequently is included from <tool>.c.\n  - <tool>.h can optionally contain any types and constants, shared by both\n    BPF and userspace sides of a tool.\n\nFor such cases, simply adding <tool> name to Makefile's APPS variable will\nensure this tool is built alongside others.\n\nFor more complicated applications, some extra Makefile rules might need to be\ncreated. For such cases, it is advised to put application into a dedicated\nsubdirectory and link it from main Makefile.\n\nvmlinux.h generation\n-------------------\n\nvmlinux.h contains all kernel types, both exported and internal-only. BPF\nCO-RE-based applications are expected to include this file in their BPF\nprogram C source code to avoid dependency on kernel headers package.\n\nFor more reproducible builds, vmlinux.h header file is pre-generated and\nchecked in along the other sources. This is done to avoid dependency on\nspecific user/build server's kernel configuration, because vmlinux.h\ngeneration depends on having a kernel with BTF type information built-in\n(which is enabled by `CONFIG_DEBUG_INFO_BTF=y` Kconfig option See below).\n\nvmlinux.h is generated from upstream Linux version at particular minor\nversion tag. E.g., `vmlinux_505.h` is generated from v5.5 tag. Exact set of\ntypes available in compiled kernel depends on configuration used to compile\nit. To generate present vmlinux.h header, default configuration was used, with\nonly extra `CONFIG_DEBUG_INFO_BTF=y` option enabled.\n\nGiven different kernel version can have incompatible type definitions, it\nmight be important to use vmlinux.h of a specific kernel version as a \"base\"\nversion of header. To that extent, all vmlinux.h headers are versioned by\nappending <MAJOR><MINOR> suffix to a file name. There is always a symbolic\nlink vmlinux.h, that points to whichever version is deemed to be default\n(usually, latest).\n\nbpftool\n-------\n\nbpftool is a universal tool used for inspection of BPF resources, as well as\nproviding various extra BPF-related facilities, like code-generation of BPF\nprogram skeletons. The latter functionality is heavily used by these tools to\nload and interact with BPF programs.\n\nGiven bpftool package can't yet be expected to be available widely across many\ndistributions, bpftool binary is checked in into BCC repository in bin/\nsubdirectory. Once bpftool package is more widely available, this can be\nchanged in favor of using pre-packaged version of bpftool.\n\n\nRe-compiling your Kernel with CONFIG_DEBUG_INFO_BTF=y\n-----------------------------------------------------\nlibbpf probes to see if your sys fs exports the file `/sys/kernel/btf/vmlinux` (from Kernel 5.5+) or if you have the ELF version in your system [`code`](https://github.com/libbpf/libbpf/blob/master/src/btf.c)\nPlease note the ELF file could exist without the BTF info in it. Your Kconfig should contain the options below\n\n1. Compile options\n```code\nCONFIG_DEBUG_INFO_BTF=y\nCONFIG_DEBUG_INFO=y\n```\n2. Also, make sure that you have pahole 1.13 (or preferably 1.16+) during the\nkernel build (it comes from dwarves package). Without it, BTF won't be\ngenerated, and on older kernels you'd get only warning, but still would\nbuild kernel successfully\n\nRunning in kernels without CONFIG_DEBUG_INFO_BTF=y\n--------------------------------------------------\n\nIt's possible to run some tools in kernels that don't expose\n`/sys/kernel/btf/vmlinux`. For those cases,\n[BTFGen](https://lore.kernel.org/bpf/20220215225856.671072-1-mauricio@kinvolk.io)\nand [BTFHub](https://github.com/aquasecurity/btfhub) can be used to\ngenerate small BTF files for the most popular Linux distributions that\nare shipped with the tools in order to provide the needed information to\nperform the CO-RE relocations when loading the eBPF programs.\n\nIf you haven't cloned the\n[btfhub-archive](https://github.com/aquasecurity/btfhub) repository, you\ncan run make and it'll clone it for you into the `$HOME/.local/share`\ndirectory:\n\n```bash\nmake ENABLE_MIN_CORE_BTFS=1 -j$(nproc)\n```\n\nIf you have a local copy of such repository, you can pass it's location\nto avoid cloning it again:\n\n```bash\nmake ENABLE_MIN_CORE_BTFS=1 BTF_HUB_ARCHIVE=<path_to_btfhub-archive> -j$(nproc)\n```\n","isInternal":false,"tokens":1374,"sizeBytes":5737}],"systemPromptSnippet":"<yakaai_skills repo=\"iovisor/bcc\">\n<!-- File: .github/copilot-instructions.md (Tokens: ~861 | Category: copilot-instructions) -->\n# BCC Project — GitHub Copilot Instructions\n\nBCC is a toolkit for creating efficient kernel tracing and manipulation programs using eBPF. Tools run in **mission-critical environments as root**.\n\n## Global Review Principles (Applied to all PRs)\n\n### PR Value Assessment (Evaluate First)\n\nBefore detailed code review, assess:\n\n1. **Scope fit**: Does this belong in BCC, or should it be a separate tool/project?\n2. **Existing coverage**: Does an existing tool already do this? Can it be extended instead?\n3. **Production value**: Is there a real use case? (Not just \"might be useful someday\")\n4. **Maintenance cost**: Is the added complexity justified by the value?\n\nFlag as 🔴 if PR adds a tool that duplicates existing functionality without clear differentiation.\n\n### Kernel & eBPF Alignment\n\n**Modern eBPF Direction (Prefer)**\n- CO-RE over kernel-version `#ifdef`\n- BTF-enabled patterns over legacy\n- fentry/fexit with kprobe fallback when targeting broad kernel support\n\n**Backward Compatibility**\n- New features MUST NOT break existing default behavior\n- Kernel-version-dependent features: provide fallback or graceful degradation\n- Document minimum kernel version in man page if tool requires specific features\n\n### Performance Considerations\n\n- **Prefer filtering in BPF**: Reduce kernel-to-user data transfer where feasible\n- **Prefer map aggregation**: Over per-event output for high-frequency events\n- **Be mindful of helper costs**: `bpf_get_stackid`, `bpf_probe_read_user_str` have overhead — acceptable when core to tool's purpose, but avoid in unrelated hot paths\n- **Disclose overhead**: Man page OVERHEAD section MUST describe expected impact\n\n### Commit Message Format\n\n```\n<prefix>: <short summary>\n\n<WHY this change is needed — not just what changed>\n- Problem being solved\n- Why this approach was chosen\n```\n\n**Prefixes:** `tools/toolname:`, `libbpf-tools/toolname:`, `src/cc:`, `build:`, `ci:`, `docs:`, `tests/python:`\n\n### Style Checks\n\n- **Python:** `scripts/py-style-check.sh` (pycodestyle, ignore E123/E125/E126/E127/E128/E302)\n- **C/C++:** `scripts/c-style-check.sh` (git clang-format against master)\n\n<CriticalRules>\n- MUST perform a NULL check after any BPF C Map lookup.\n- MUST perform a NULL check after every `malloc()`, `calloc()`, `realloc()`, and `strdup()` call in userspace C code.\n- MUST perform a bounds check for all array accesses.\n- BPF C functions: flag if stack usage appears to approach or exceed 512 bytes (eBPF verifier hard limit).\n- Default output format MUST be under 80 characters wide.\n</CriticalRules>\n\n### Documentation Requirements (New Tools)\n\nAll **new tools** require these **minimum** files (enforce as blocker):\n1. Tool script\n2. Man page (`man/man8/`) with an **OVERHEAD** section\n3. `README.md` entry\n\nAdditional per-subsystem requirements apply — defer to the relevant\n`instructions/*.instructions.md` file (e.g., `tools.instructions.md` also\nrequires `tests/python/test_tools_smoke.py`; `*_example.txt` is required for\n`tools/` but recommended for `libbpf-tools/`).\n\nFor **bug-fix or enhancement PRs on existing tools**: flag missing docs as 🟡 Warning, not a blocker.\n> Note: ~14% of libbpf-tools currently ship without a man page — this is a known gap, not a reason to skip the requirement for new tools.\n\n### Unix Philosophy\n\n- Do one thing and do it well\n- Default output **< 80 characters wide**\n- Prefer short tool names; avoid underscores for new tools unless needed for\n  clarity or to match an existing naming pattern (e.g., `mysqld_qslower`)\n- Prefer a positional argument for the most common parameter (e.g., interval) over a flag,\n  where it makes sense for the tool's use case\n\n<!-- File: libbpf-tools/README.md (Tokens: ~1374 | Category: plugin-manifest) -->\nUseful links\n------------\n\n- [BPF Portability and CO-RE](https://facebookmicrosites.github.io/bpf/blog/2020/02/19/bpf-portability-and-co-re.html)\n- [HOWTO: BCC to libbpf conversion](https://facebookmicrosites.github.io/bpf/blog/2020/02/20/bcc-to-libbpf-howto-guide.html)\n- [Tips & tricks for writing libbpf-tools](https://en.pingcap.com/blog/tips-and-tricks-for-writing-linux-bpf-applications-with-libbpf)\n\nBuilding\n-------\n\nTo build libbpf-based tools, simply run `make`. This will build all the listed\ntools/applications. All the build artifacts, by default, go into .output\nsubdirectory to keep source code and build artifacts completely separate. The\nonly exception is resulting tool binaries, which are put in a current\ndirectory. `make clean` will clean up all the build artifacts, including\ngenerated binaries.\n\nGiven that the libbpf package might not be available across wide variety of\ndistributions, all libbpf-based tools are linked statically against a version\nof libbpf that BCC links against (from submodule under src/cc/libbpf). This\nresults in binaries with minimal amount of dependencies (libc, libelf, and\nlibz are linked dynamically, though, given their widespread availability).\nIf your build fails because the libbpf submodule is outdated, try running `git\nsubmodule update --init --recursive`.\n\nTools are expected to follow a simple naming convention:\n  - <tool>.c contains userspace C code of a tool.\n  - <tool>.bpf.c contains BPF C code, which gets compiled into BPF ELF file.\n    This ELF file is used to generate BPF skeleton <tool>.skel.h, which is\n    subsequently is included from <tool>.c.\n  - <tool>.h can optionally contain any types and constants, shared by both\n    BPF and userspace sides of a tool.\n\nFor such cases, simply adding <tool> name to Makefile's APPS variable will\nensure this tool is built alongside others.\n\nFor more complicated applications, some extra Makefile rules might need to be\ncreated. For such cases, it is advised to put application into a dedicated\nsubdirectory and link it from main Makefile.\n\nvmlinux.h generation\n-------------------\n\nvmlinux.h contains all kernel types, both exported and internal-only. BPF\nCO-RE-based applications are expected to include this file in their BPF\nprogram C source code to avoid dependency on kernel headers package.\n\nFor more reproducible builds, vmlinux.h header file is pre-generated and\nchecked in along the other sources. This is done to avoid dependency on\nspecific user/build server's kernel configuration, because vmlinux.h\ngeneration depends on having a kernel with BTF type information built-in\n(which is enabled by `CONFIG_DEBUG_INFO_BTF=y` Kconfig option See below).\n\nvmlinux.h is generated from upstream Linux version at particular minor\nversion tag. E.g., `vmlinux_505.h` is generated from v5.5 tag. Exact set of\ntypes available in compiled kernel depends on configuration used to compile\nit. To generate present vmlinux.h header, default configuration was used, with\nonly extra `CONFIG_DEBUG_INFO_BTF=y` option enabled.\n\nGiven different kernel version can have incompatible type definitions, it\nmight be important to use vmlinux.h of a specific kernel version as a \"base\"\nversion of header. To that extent, all vmlinux.h headers are versioned by\nappending <MAJOR><MINOR> suffix to a file name. There is always a symbolic\nlink vmlinux.h, that points to whichever version is deemed to be default\n(usually, latest).\n\nbpftool\n-------\n\nbpftool is a universal tool used for inspection of BPF resources, as well as\nproviding various extra BPF-related facilities, like code-generation of BPF\nprogram skeletons. The latter functionality is heavily used by these tools to\nload and interact with BPF programs.\n\nGiven bpftool package can't yet be expected to be available widely across many\ndistributions, bpftool binary is checked in into BCC repository in bin/\nsubdirectory. Once bpftool package is more widely available, this can be\nchanged in favor of using pre-packaged version of bpftool.\n\n\nRe-compiling your Kernel with CONFIG_DEBUG_INFO_BTF=y\n-----------------------------------------------------\nlibbpf probes to see if your sys fs exports the file `/sys/kernel/btf/vmlinux` (from Kernel 5.5+) or if you have the ELF version in your system [`code`](https://github.com/libbpf/libbpf/blob/master/src/btf.c)\nPlease note the ELF file could exist without the BTF info in it. Your Kconfig should contain the options below\n\n1. Compile options\n```code\nCONFIG_DEBUG_INFO_BTF=y\nCONFIG_DEBUG_INFO=y\n```\n2. Also, make sure that you have pahole 1.13 (or preferably 1.16+) during the\nkernel build (it comes from dwarves package). Without it, BTF won't be\ngenerated, and on older kernels you'd get only warning, but still would\nbuild kernel successfully\n\nRunning in kernels without CONFIG_DEBUG_INFO_BTF=y\n--------------------------------------------------\n\nIt's possible to run some tools in kernels that don't expose\n`/sys/kernel/btf/vmlinux`. For those cases,\n[BTFGen](https://lore.kernel.org/bpf/20220215225856.671072-1-mauricio@kinvolk.io)\nand [BTFHub](https://github.com/aquasecurity/btfhub) can be used to\ngenerate small BTF files for the most popular Linux distributions that\nare shipped with the tools in order to provide the needed information to\nperform the CO-RE relocations when loading the eBPF programs.\n\nIf you haven't cloned the\n[btfhub-archive](https://github.com/aquasecurity/btfhub) repository, you\ncan run make and it'll clone it for you into the `$HOME/.local/share`\ndirectory:\n\n```bash\nmake ENABLE_MIN_CORE_BTFS=1 -j$(nproc)\n```\n\nIf you have a local copy of such repository, you can pass it's location\nto avoid cloning it again:\n\n```bash\nmake ENABLE_MIN_CORE_BTFS=1 BTF_HUB_ARCHIVE=<path_to_btfhub-archive> -j$(nproc)\n```\n</yakaai_skills>"}