lib/dynamic_debug.c
Source file repositories/reference/linux-study-clean/lib/dynamic_debug.c
File Facts
- System
- Linux kernel
- Corpus path
lib/dynamic_debug.c- Extension
.c- Size
- 38650 bytes
- Lines
- 1496
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/moduleparam.hlinux/kallsyms.hlinux/types.hlinux/mutex.hlinux/proc_fs.hlinux/seq_file.hlinux/list.hlinux/sysctl.hlinux/ctype.hlinux/string.hlinux/parser.hlinux/string_helpers.hlinux/uaccess.hlinux/dynamic_debug.hlinux/debugfs.hlinux/slab.hlinux/jump_label.hlinux/hardirq.hlinux/sched.hlinux/device.hlinux/netdevice.hrdma/ib_verbs.h
Detected Declarations
struct ddebug_tablestruct ddebug_querystruct ddebug_iterstruct flag_settingsstruct flagsbuffunction vpr_info_dqfunction list_for_each_entryfunction ddebug_changefunction ddebug_tokenizefunction parse_linenofunction parse_linerangefunction check_setfunction offunction ddebug_parse_flagsfunction ddebug_exec_queryfunction paramfunction ddebug_apply_class_bitmapfunction param_set_dyndbg_classnamesfunction param_set_dyndbg_classesfunction param_get_dyndbg_classesfunction remainingfunction __dynamic_pr_debugfunction __dynamic_dev_dbgfunction __dynamic_netdev_dbgfunction __dynamic_ibdev_dbgfunction dyndbg_setupfunction ddebug_proc_writefunction readfunction ddebug_proc_showfunction ddebug_proc_stopfunction ddebug_proc_openfunction ddebug_attach_module_classesfunction ddebug_add_modulefunction ddebug_dyndbg_param_cbfunction ddebug_dyndbg_boot_param_cbfunction load_modulefunction ddebug_table_freefunction ddebug_remove_modulefunction ddebug_module_notifyfunction ddebug_remove_all_tablesfunction dynamic_debug_init_controlfunction dynamic_debug_initmodule init dynamic_debug_init_controlexport param_set_dyndbg_classesexport param_get_dyndbg_classesexport param_ops_dyndbg_classesexport __dynamic_pr_debugexport __dynamic_dev_dbg
Annotated Snippet
static const struct file_operations ddebug_proc_fops = {
.owner = THIS_MODULE,
.open = ddebug_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release_private,
.write = ddebug_proc_write
};
static const struct proc_ops proc_fops = {
.proc_open = ddebug_proc_open,
.proc_read = seq_read,
.proc_lseek = seq_lseek,
.proc_release = seq_release_private,
.proc_write = ddebug_proc_write
};
static void ddebug_attach_module_classes(struct ddebug_table *dt,
struct ddebug_class_map *classes,
int num_classes)
{
struct ddebug_class_map *cm;
int i, j, ct = 0;
for (cm = classes, i = 0; i < num_classes; i++, cm++) {
if (!strcmp(cm->mod_name, dt->mod_name)) {
v2pr_info("class[%d]: module:%s base:%d len:%d ty:%d\n", i,
cm->mod_name, cm->base, cm->length, cm->map_type);
for (j = 0; j < cm->length; j++)
v3pr_info(" %d: %d %s\n", j + cm->base, j,
cm->class_names[j]);
list_add(&cm->link, &dt->maps);
ct++;
}
}
if (ct)
vpr_info("module:%s attached %d classes\n", dt->mod_name, ct);
}
/*
* Allocate a new ddebug_table for the given module
* and add it to the global list.
*/
static int ddebug_add_module(struct _ddebug_info *di, const char *modname)
{
struct ddebug_table *dt;
v3pr_info("add-module: %s.%d sites\n", modname, di->num_descs);
if (!di->num_descs) {
v3pr_info(" skip %s\n", modname);
return 0;
}
dt = kzalloc_obj(*dt);
if (dt == NULL) {
pr_err("error adding module: %s\n", modname);
return -ENOMEM;
}
/*
* For built-in modules, name lives in .rodata and is
* immortal. For loaded modules, name points at the name[]
* member of struct module, which lives at least as long as
* this struct ddebug_table.
*/
dt->mod_name = modname;
dt->ddebugs = di->descs;
dt->num_ddebugs = di->num_descs;
INIT_LIST_HEAD(&dt->link);
INIT_LIST_HEAD(&dt->maps);
if (di->classes && di->num_classes)
ddebug_attach_module_classes(dt, di->classes, di->num_classes);
mutex_lock(&ddebug_lock);
list_add_tail(&dt->link, &ddebug_tables);
mutex_unlock(&ddebug_lock);
vpr_info("%3u debug prints in module %s\n", di->num_descs, modname);
return 0;
}
/* helper for ddebug_dyndbg_(boot|module)_param_cb */
static int ddebug_dyndbg_param_cb(char *param, char *val,
const char *modname, int on_err)
{
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/kallsyms.h`, `linux/types.h`, `linux/mutex.h`, `linux/proc_fs.h`, `linux/seq_file.h`.
- Detected declarations: `struct ddebug_table`, `struct ddebug_query`, `struct ddebug_iter`, `struct flag_settings`, `struct flagsbuf`, `function vpr_info_dq`, `function list_for_each_entry`, `function ddebug_change`, `function ddebug_tokenize`, `function parse_lineno`.
- Atlas domain: Kernel Services / lib.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.