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.

Dependency Surface

Detected Declarations

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, &current_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(&current_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

Implementation Notes