scripts/gendwarfksyms/dwarf.c

Source file repositories/reference/linux-study-clean/scripts/gendwarfksyms/dwarf.c

File Facts

System
Linux kernel
Corpus path
scripts/gendwarfksyms/dwarf.c
Extension
.c
Size
30197 bytes
Lines
1186
Domain
Support Tooling And Documentation
Bucket
scripts
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.

Dependency Surface

Detected Declarations

Annotated Snippet

if (match(&current)) {
			/* <0 = error, 0 = continue, >0 = stop */
			res = checkp(func(state, cache, &current));
			if (res)
				goto out;
		}

		res = checkp(dwarf_siblingof(&current, &current));
	}

	res = 0;
out:
	if (state)
		state->first_list_item = false;

	return res;
}

static int process_type(struct state *state, struct die *parent,
			Dwarf_Die *die);

static void process_type_attr(struct state *state, struct die *cache,
			      Dwarf_Die *die)
{
	Dwarf_Die type;

	if (get_ref_die_attr(die, DW_AT_type, &type)) {
		check(process_type(state, cache, &type));
		return;
	}

	/* Compilers can omit DW_AT_type -- print out 'void' to clarify */
	process(cache, "base_type void");
}

static void process_list_comma(struct state *state, struct die *cache)
{
	if (state->first_list_item) {
		state->first_list_item = false;
	} else {
		process(cache, " ,");
		process_linebreak(cache, 0);
	}
}

/* Comma-separated with DW_AT_type */
static void __process_list_type(struct state *state, struct die *cache,
				Dwarf_Die *die, const char *type)
{
	const char *name = get_name_attr(die);

	if (stable) {
		if (is_kabi_prefix(name))
			name = NULL;
		state->kabi.orig_name = NULL;
	}

	process_list_comma(state, cache);
	process(cache, type);
	process_type_attr(state, cache, die);

	if (stable && state->kabi.orig_name)
		name = state->kabi.orig_name;
	if (name) {
		process(cache, " ");
		process(cache, name);
	}

	process_accessibility_attr(cache, die);
	process_bit_size_attr(cache, die);
	process_data_bit_offset_attr(cache, die);
	process_data_member_location_attr(cache, die);
}

#define DEFINE_PROCESS_LIST_TYPE(type)                                       \
	static void process_##type##_type(struct state *state,               \
					  struct die *cache, Dwarf_Die *die) \
	{                                                                    \
		__process_list_type(state, cache, die, #type " ");           \
	}

DEFINE_PROCESS_LIST_TYPE(formal_parameter)
DEFINE_PROCESS_LIST_TYPE(member)

/* Container types with DW_AT_type */
static void __process_type(struct state *state, struct die *cache,
			   Dwarf_Die *die, const char *type)
{
	process(cache, type);
	process_fqn(cache, die);

Annotation

Implementation Notes