tools/bpf/bpf_dbg.c
Source file repositories/reference/linux-study-clean/tools/bpf/bpf_dbg.c
File Facts
- System
- Linux kernel
- Corpus path
tools/bpf/bpf_dbg.c- Extension
.c- Size
- 28836 bytes
- Lines
- 1399
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdio.hunistd.hstdlib.hctype.hstdbool.hstdarg.hsetjmp.hlinux/filter.hlinux/if_packet.hreadline/readline.hreadline/history.hsys/types.hsys/socket.hsys/stat.hsys/mman.hfcntl.herrno.hsignal.harpa/inet.hnet/ethernet.h
Detected Declarations
struct shell_cmdstruct pcap_filehdrstruct pcap_timevalstruct pcap_pkthdrstruct bpf_regsfunction __check_format_printffunction matchesfunction hex_dumpfunction bpf_prog_loadedfunction bpf_disasmfunction bpf_dump_currfunction bpf_dump_pktfunction bpf_disasm_allfunction bpf_dump_allfunction bpf_runnablefunction bpf_reset_breakpointsfunction bpf_set_breakpointsfunction bpf_dump_breakpointsfunction bpf_resetfunction bpf_safe_regsfunction bpf_restore_regsfunction extract_u32function extract_u16function extract_u8function set_returnfunction bpf_single_stepfunction bpf_pc_has_breakpointfunction bpf_handle_breakpointfunction bpf_run_allfunction bpf_run_steppingfunction pcap_loadedfunction pcap_next_pktfunction pcap_reset_pktfunction try_load_pcapfunction try_close_pcapfunction cmd_load_bpffunction cmd_load_pcapfunction cmd_loadfunction cmd_stepfunction cmd_selectfunction cmd_breakpointfunction cmd_runfunction cmd_disassemblefunction cmd_dumpfunction cmd_quitfunction execffunction intr_shellfunction init_shell
Annotated Snippet
struct shell_cmd {
const char *name;
int (*func)(char *args);
};
struct pcap_filehdr {
uint32_t magic;
uint16_t version_major;
uint16_t version_minor;
int32_t thiszone;
uint32_t sigfigs;
uint32_t snaplen;
uint32_t linktype;
};
struct pcap_timeval {
int32_t tv_sec;
int32_t tv_usec;
};
struct pcap_pkthdr {
struct pcap_timeval ts;
uint32_t caplen;
uint32_t len;
};
struct bpf_regs {
uint32_t A;
uint32_t X;
uint32_t M[BPF_MEMWORDS];
uint32_t R;
bool Rs;
uint16_t Pc;
};
static struct sock_filter bpf_image[BPF_MAXINSNS + 1];
static unsigned int bpf_prog_len;
static int bpf_breakpoints[64];
static struct bpf_regs bpf_regs[BPF_MAXINSNS + 1];
static struct bpf_regs bpf_curr;
static unsigned int bpf_regs_len;
static int pcap_fd = -1;
static unsigned int pcap_packet;
static size_t pcap_map_size;
static char *pcap_ptr_va_start, *pcap_ptr_va_curr;
static const char * const op_table[] = {
[BPF_ST] = "st",
[BPF_STX] = "stx",
[BPF_LD_B] = "ldb",
[BPF_LD_H] = "ldh",
[BPF_LD_W] = "ld",
[BPF_LDX] = "ldx",
[BPF_LDX_B] = "ldxb",
[BPF_JMP_JA] = "ja",
[BPF_JMP_JEQ] = "jeq",
[BPF_JMP_JGT] = "jgt",
[BPF_JMP_JGE] = "jge",
[BPF_JMP_JSET] = "jset",
[BPF_ALU_ADD] = "add",
[BPF_ALU_SUB] = "sub",
[BPF_ALU_MUL] = "mul",
[BPF_ALU_DIV] = "div",
[BPF_ALU_MOD] = "mod",
[BPF_ALU_NEG] = "neg",
[BPF_ALU_AND] = "and",
[BPF_ALU_OR] = "or",
[BPF_ALU_XOR] = "xor",
[BPF_ALU_LSH] = "lsh",
[BPF_ALU_RSH] = "rsh",
[BPF_MISC_TAX] = "tax",
[BPF_MISC_TXA] = "txa",
[BPF_RET] = "ret",
};
static __check_format_printf(1, 2) int rl_printf(const char *fmt, ...)
{
int ret;
va_list vl;
va_start(vl, fmt);
ret = vfprintf(rl_outstream, fmt, vl);
va_end(vl);
return ret;
}
static int matches(const char *cmd, const char *pattern)
Annotation
- Immediate include surface: `stdio.h`, `unistd.h`, `stdlib.h`, `ctype.h`, `stdbool.h`, `stdarg.h`, `setjmp.h`, `linux/filter.h`.
- Detected declarations: `struct shell_cmd`, `struct pcap_filehdr`, `struct pcap_timeval`, `struct pcap_pkthdr`, `struct bpf_regs`, `function __check_format_printf`, `function matches`, `function hex_dump`, `function bpf_prog_loaded`, `function bpf_disasm`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.