scripts/gendwarfksyms/die.c
Source file repositories/reference/linux-study-clean/scripts/gendwarfksyms/die.c
File Facts
- System
- Linux kernel
- Corpus path
scripts/gendwarfksyms/die.c- Extension
.c- Size
- 3106 bytes
- Lines
- 167
- 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.
- 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
string.hgendwarfksyms.h
Detected Declarations
function die_hashfunction init_diefunction __die_map_getfunction hash_for_each_possiblefunction reset_diefunction list_for_each_entry_safefunction die_map_for_eachfunction hash_for_each_safefunction die_map_freefunction hash_for_each_safefunction die_map_add_stringfunction die_map_add_linebreakfunction die_map_add_die
Annotated Snippet
if (cd->addr == addr && cd->state == state) {
*res = cd;
return 0;
}
}
return -1;
}
struct die *die_map_get(Dwarf_Die *die, enum die_state state)
{
struct die *cd;
if (__die_map_get((uintptr_t)die->addr, state, &cd) == 0) {
map_hits++;
return cd;
}
map_misses++;
return create_die(die, state);
}
static void reset_die(struct die *cd)
{
struct die_fragment *tmp;
struct die_fragment *df;
list_for_each_entry_safe(df, tmp, &cd->fragments, list) {
if (df->type == FRAGMENT_STRING)
free(df->data.str);
free(df);
}
if (cd->fqn && *cd->fqn)
free(cd->fqn);
init_die(cd);
}
void die_map_for_each(die_map_callback_t func, void *arg)
{
struct hlist_node *tmp;
struct die *cd;
hash_for_each_safe(die_map, cd, tmp, hash) {
func(cd, arg);
}
}
void die_map_free(void)
{
struct hlist_node *tmp;
unsigned int stats[DIE_LAST + 1];
struct die *cd;
int i;
memset(stats, 0, sizeof(stats));
hash_for_each_safe(die_map, cd, tmp, hash) {
stats[cd->state]++;
reset_die(cd);
free(cd);
}
hash_init(die_map);
if (map_hits + map_misses > 0)
debug("hits %u, misses %u (hit rate %.02f%%)", map_hits,
map_misses,
(100.0f * map_hits) / (map_hits + map_misses));
for (i = 0; i <= DIE_LAST; i++)
debug("%s: %u entries", die_state_name(i), stats[i]);
}
static struct die_fragment *append_item(struct die *cd)
{
struct die_fragment *df;
df = xmalloc(sizeof(*df));
df->type = FRAGMENT_EMPTY;
list_add_tail(&df->list, &cd->fragments);
return df;
}
void die_map_add_string(struct die *cd, const char *str)
{
struct die_fragment *df;
if (!cd)
return;
Annotation
- Immediate include surface: `string.h`, `gendwarfksyms.h`.
- Detected declarations: `function die_hash`, `function init_die`, `function __die_map_get`, `function hash_for_each_possible`, `function reset_die`, `function list_for_each_entry_safe`, `function die_map_for_each`, `function hash_for_each_safe`, `function die_map_free`, `function hash_for_each_safe`.
- Atlas domain: Support Tooling And Documentation / scripts.
- 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.