kernel/gcov/clang.c
Source file repositories/reference/linux-study-clean/kernel/gcov/clang.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/gcov/clang.c- Extension
.c- Size
- 10364 bytes
- Lines
- 394
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/list.hlinux/printk.hlinux/ratelimit.hlinux/slab.hlinux/mm.hgcov.h
Detected Declarations
struct gcov_infostruct gcov_fn_infofunction llvm_gcov_initfunction llvm_gcda_start_filefunction llvm_gcda_emit_functionfunction llvm_gcda_emit_arcsfunction llvm_gcda_summary_infofunction llvm_gcda_end_filefunction gcov_info_versionfunction gcov_info_linkfunction gcov_info_unlinkfunction gcov_info_within_modulefunction gcov_info_resetfunction gcov_info_is_compatiblefunction gcov_info_addfunction list_for_each_entryfunction list_for_each_entryfunction gcov_info_freefunction list_for_each_entry_safefunction convert_to_gcdafunction list_for_each_entryexport llvm_gcov_initexport llvm_gcda_start_fileexport llvm_gcda_emit_functionexport llvm_gcda_emit_arcsexport llvm_gcda_summary_infoexport llvm_gcda_end_file
Annotated Snippet
struct gcov_info {
struct list_head head;
const char *filename;
unsigned int version;
u32 checksum;
struct list_head functions;
};
struct gcov_fn_info {
struct list_head head;
u32 ident;
u32 checksum;
u32 cfg_checksum;
u32 num_counters;
u64 *counters;
};
static struct gcov_info *current_info;
static LIST_HEAD(clang_gcov_list);
void llvm_gcov_init(llvm_gcov_callback writeout, llvm_gcov_callback flush)
{
struct gcov_info *info = kzalloc_obj(*info);
if (!info)
return;
INIT_LIST_HEAD(&info->head);
INIT_LIST_HEAD(&info->functions);
mutex_lock(&gcov_lock);
list_add_tail(&info->head, &clang_gcov_list);
current_info = info;
writeout();
current_info = NULL;
if (gcov_events_enabled)
gcov_event(GCOV_ADD, info);
mutex_unlock(&gcov_lock);
}
EXPORT_SYMBOL(llvm_gcov_init);
void llvm_gcda_start_file(const char *orig_filename, u32 version, u32 checksum)
{
current_info->filename = orig_filename;
current_info->version = version;
current_info->checksum = checksum;
}
EXPORT_SYMBOL(llvm_gcda_start_file);
void llvm_gcda_emit_function(u32 ident, u32 func_checksum, u32 cfg_checksum)
{
struct gcov_fn_info *info = kzalloc_obj(*info);
if (!info)
return;
INIT_LIST_HEAD(&info->head);
info->ident = ident;
info->checksum = func_checksum;
info->cfg_checksum = cfg_checksum;
list_add_tail(&info->head, ¤t_info->functions);
}
EXPORT_SYMBOL(llvm_gcda_emit_function);
void llvm_gcda_emit_arcs(u32 num_counters, u64 *counters)
{
struct gcov_fn_info *info = list_last_entry(¤t_info->functions,
struct gcov_fn_info, head);
info->num_counters = num_counters;
info->counters = counters;
}
EXPORT_SYMBOL(llvm_gcda_emit_arcs);
void llvm_gcda_summary_info(void)
{
}
EXPORT_SYMBOL(llvm_gcda_summary_info);
void llvm_gcda_end_file(void)
{
}
EXPORT_SYMBOL(llvm_gcda_end_file);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/list.h`, `linux/printk.h`, `linux/ratelimit.h`, `linux/slab.h`, `linux/mm.h`, `gcov.h`.
- Detected declarations: `struct gcov_info`, `struct gcov_fn_info`, `function llvm_gcov_init`, `function llvm_gcda_start_file`, `function llvm_gcda_emit_function`, `function llvm_gcda_emit_arcs`, `function llvm_gcda_summary_info`, `function llvm_gcda_end_file`, `function gcov_info_version`, `function gcov_info_link`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: integration 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.