DwarfLines
Description
Parsed .debug_line content. Entries are flat and sorted-by- address per the line-number program’s natural emission order inside each compilation unit. Lookups do a linear scan across all CUs.
Fields
| Name | Description |
|---|---|
allocator |
Allocator backing entries + string_pool. |
entries |
All (address, file, line, …) rows, in CU / program order. |
string_pool |
Owned buffer holding the file / directory strings that entries borrows from. Required because .debug_line file/dir entries are interleaved byte-strings inside the section — we copy them into a contiguous pool so the Elf’s lifetime doesn’t have to match ours. |
Usage example (Cross-references)
Usage examples (Cross-references)
bool has_sidecar;
#if FEATURE_PARSER_DWARF
DwarfLines dwarf;
bool dwarf_built;
bool dwarf_ok; bool dwarf_built;
bool dwarf_ok;
DwarfLines sidecar_dwarf;
bool sidecar_dwarf_built;
bool sidecar_dwarf_ok;- In
Dwarf.h:81:
DwarfLineEntries entries;
Str string_pool;
} DwarfLines;
///
- In
Dwarf.h:113:
/// TAGS: Parser, DWARF, Lookup
///
const DwarfLineEntry *DwarfLinesResolve(const DwarfLines *self, u64 vaddr);
///
- In
Dwarf.h:123:
/// TAGS: Parser, DWARF, Lines, Deinit, Lifecycle
///
void DwarfLinesDeinit(DwarfLines *self);
// ===========================================================================
- In
Dwarf.c:295:
static bool lnp_emit(
DwarfLines *out,
Str *pool,
const CuStrings *cs,- In
Dwarf.c:337:
const LineProgHeader *hdr,
const CuStrings *cs,
DwarfLines *out,
U64Vec *pending_file_offsets,
U64Vec *pending_dir_offsets- In
Dwarf.c:540:
// ---------------------------------------------------------------------------
bool dwarf_lines_build_from_elf(DwarfLines *out, const Elf *elf, Allocator *alloc) {
if (!out || !elf || !alloc) {
LOG_FATAL("DwarfLinesBuildFromElf: NULL argument");- In
Dwarf.c:658:
}
void DwarfLinesDeinit(DwarfLines *self) {
if (!self)
return;- In
Dwarf.c:670:
// ---------------------------------------------------------------------------
const DwarfLineEntry *DwarfLinesResolve(const DwarfLines *self, u64 vaddr) {
if (!self || VecLen(&self->entries) == 0)
return NULL;- In
Dwarf.c:29:
}
DwarfLines lines;
bool built = DwarfLinesBuildFromElf(&lines, &elf, ALLOCATOR_OF(&alloc));
bool ok = built && VecLen(&lines.entries) > 0;- In
Dwarf.c:69:
}
DwarfLines lines;
bool built = DwarfLinesBuildFromElf(&lines, &elf, base);
bool ok = false;- In
Dwarf.c:582:
}
DwarfLines lines;
bool built = DwarfLinesBuildFromElf(&lines, &elf, base);
bool ok = built;- In
Dwarf.c:637:
}
DwarfLines lines;
bool built = DwarfLinesBuildFromElf(&lines, &elf, base);
// The malformed unit is rejected: either the build fails outright, or
- In
Dwarf.c:738:
DefaultAllocator alloc;
Elf elf;
DwarfLines lines;
bool built;
} LinesFixture;- In
Dwarf.c:872:
// Run a crafted program and return a built DwarfLines via `*lines`.
// Returns true if the build succeeded (caller must Deinit on true).
static bool build_lines_from_program(DwarfLines *lines, Allocator *base, const u8 *prog, u64 prog_len) {
u8 dl[512];
u64 dl_len = build_line_with_program(dl, prog, prog_len);- In
Dwarf.c:1008:
}
static bool lines_from_debug_line(DwarfLines *out, Elf *elf, const u8 *dl, u64 dl_len, Allocator *base) {
static u8 elfbuf[8192];
u64 elf_len = 0;- In
Dwarf.c:1523:
}
DwarfLines lines;
bool built = DwarfLinesBuildFromElf(&lines, &elf, base);
// The over-long extended record must be rejected: either the build fails
- In
Dwarf.c:1621:
p = emit_end_sequence(p);
DwarfLines lines;
bool built = build_lines_from_program(&lines, base, prog, (u64)(p - prog));
bool ok = built;- In
Dwarf.c:1659:
p = emit_end_sequence(p);
DwarfLines lines;
bool built = build_lines_from_program(&lines, base, prog, (u64)(p - prog));
bool ok = built;- In
Dwarf.c:1704:
p = emit_end_sequence(p);
DwarfLines lines;
bool built = build_lines_from_program(&lines, base, prog, (u64)(p - prog));
bool ok = built;- In
Dwarf.c:1741:
p = emit_end_sequence(p);
DwarfLines lines;
bool built = build_lines_from_program(&lines, base, prog, (u64)(p - prog));
bool ok = built;- In
Dwarf.c:1772:
p = emit_end_sequence(p);
DwarfLines lines;
bool built = build_lines_from_program(&lines, base, prog, (u64)(p - prog));
bool ok = built;- In
Dwarf.c:1825:
p = emit_end_sequence(p);
DwarfLines lines;
bool built = build_lines_from_program(&lines, base, prog, (u64)(p - prog));
bool ok = built;- In
Dwarf.c:1899:
static bool build_lines_custom(
DwarfLines *lines,
Allocator *base,
u8 opcode_base,- In
Dwarf.c:1974:
p = emit_end_sequence(p);
DwarfLines lines;
bool built = build_lines_custom(&lines, base, 20, std_lengths, prog, (u64)(p - prog));
bool ok = built;- In
Dwarf.c:2023:
p = emit_end_sequence(p);
DwarfLines lines;
bool built = build_lines_custom(&lines, base, 15, std_lengths, prog, (u64)(p - prog));
bool ok = built;- In
Dwarf.c:2060:
p = emit_end_sequence(p);
DwarfLines lines;
bool built = build_lines_from_program(&lines, base, prog, (u64)(p - prog));
bool ok = built;- In
Dwarf.c:2132:
Elf elf;
DwarfLines lines;
if (!lines_from_debug_line(&lines, &elf, dl, dl_len, base)) {
DefaultAllocatorDeinit(&alloc);- In
Dwarf.c:2201:
Elf elf;
DwarfLines lines;
if (!lines_from_debug_line(&lines, &elf, dl, dl_len, base)) {
DefaultAllocatorDeinit(&alloc);- In
Dwarf.c:2256:
Elf elf;
DwarfLines lines;
if (!lines_from_debug_line(&lines, &elf, dl, dl_len, base)) {
DefaultAllocatorDeinit(&alloc);- In
Dwarf.c:2328:
Elf elf;
DwarfLines lines;
if (!lines_from_debug_line(&lines, &elf, dl, dl_len, base)) {
DefaultAllocatorDeinit(&alloc);- In
Dwarf.c:2381:
Elf elf;
DwarfLines lines;
bool built = lines_from_debug_line(&lines, &elf, dl, dl_len, base);
bool ok = !built || VecLen(&lines.entries) == 0;- In
Dwarf.c:2427:
Elf elf;
DwarfLines lines;
if (!lines_from_debug_line(&lines, &elf, dl, dl_len, base)) {
DefaultAllocatorDeinit(&alloc);- In
Dwarf.c:2473:
}
DwarfLines lines;
bool built = DwarfLinesBuildFromElf(&lines, &elf, base);
bool ok = built; // 562: `ok=true`->false => built would be false.
- In
Dwarf.c:2517:
}
DwarfLines lines;
bool built = DwarfLinesBuildFromElf(&lines, &elf, base);
// Real code: rejected -> built == false. Mutant (ok=true): built == true.
- In
Dwarf.c:2553:
}
DwarfLines lines;
bool built = DwarfLinesBuildFromElf(&lines, &elf, base);
// Real code rejects the overrun -> built == false. Mutant returns true.
- In
Dwarf.c:2588:
}
DwarfLines lines;
bool built = DwarfLinesBuildFromElf(&lines, &elf, base);
bool ok = built;- In
Dwarf.c:2643:
size before = DebugAllocatorLiveCount(&dbg);
DwarfLines lines;
bool built = DwarfLinesBuildFromElf(&lines, &elf, base);
bool ok = built;- In
Dwarf.c:2689:
size before = DebugAllocatorLiveCount(&dbg);
DwarfLines lines;
bool built = DwarfLinesBuildFromElf(&lines, &elf, base);
bool ok = built;- In
Dwarf.c:2753:
Elf elf;
DwarfLines lines;
if (!lines_from_debug_line(&lines, &elf, dl, dl_len, base)) {
// Real code must build this valid CU; a build failure here is a kill.
- In
Dwarf.c:2807:
Elf elf;
DwarfLines lines;
if (!lines_from_debug_line(&lines, &elf, dl, dl_len, base)) {
DefaultAllocatorDeinit(&alloc);- In
Dwarf.c:2866:
Elf elf;
DwarfLines lines;
if (!lines_from_debug_line(&lines, &elf, dl, dl_len, base)) {
DefaultAllocatorDeinit(&alloc);- In
Dwarf.c:2927:
Elf elf;
DwarfLines lines;
bool built = lines_from_debug_line(&lines, &elf, dl, dl_len, base);- In
Dwarf.c:2972:
Elf elf;
DwarfLines lines;
if (!lines_from_debug_line(&lines, &elf, dl, dl_len, base)) {
DefaultAllocatorDeinit(&alloc);- In
Dwarf.c:3078:
// Build a DwarfLines from a raw `.debug_line` payload through `base`.
// Returns the build result; on true the caller owns `*lines` + `*elf`.
static bool build_from_dl(DwarfLines *lines, Elf *elf, Allocator *base, const u8 *dl, u64 dl_len) {
static u8 elfbuf[8192];
u64 elf_len = 0;- In
Dwarf.c:3100:
// tests. Returns u64max-or-mismatch-safe: scans for the first non-end_sequence
// row and reports its address via *out, returns whether one was found.
static bool first_real_row_address(const DwarfLines *lines, u64 *out) {
for (u64 i = 0; i < VecLen(&lines->entries); ++i) {
const DwarfLineEntry *e = &VecAt(&lines->entries, i);- In
Dwarf.c:3137:
Elf elf;
DwarfLines lines;
bool built = build_from_dl(&lines, &elf, base, dl, dl_len);
bool ok = built;- In
Dwarf.c:3208:
Elf elf;
DwarfLines lines;
bool built = build_from_dl(&lines, &elf, base, dl, dl_len);
bool ok = built;- In
Dwarf.c:3241:
Elf elf;
DwarfLines lines;
bool built = build_from_dl(&lines, &elf, base, dl, dl_len);
bool ok = built;- In
Dwarf.c:3271:
Elf elf;
DwarfLines lines;
bool built = build_from_dl(&lines, &elf, base, dl, dl_len);
bool ok = built;- In
Dwarf.c:3301:
Elf elf;
DwarfLines lines;
bool built = build_from_dl(&lines, &elf, base, dl, dl_len);
bool ok = built;- In
Dwarf.c:3330:
Elf elf;
DwarfLines lines;
bool built = build_from_dl(&lines, &elf, base, dl, dl_len);
bool ok = built;- In
Dwarf.c:3366:
Elf elf;
DwarfLines lines;
bool built = build_from_dl(&lines, &elf, base, dl, dl_len);
// Real code rejects the truncated trailing unit (returns false).
- In
Dwarf.c:3406:
Elf elf;
DwarfLines lines;
bool built = build_from_dl(&lines, &elf, base, dl, dl_len);
if (built)- In
Dwarf.c:3456:
Elf elf;
DwarfLines lines;
bool built = build_from_dl(&lines, &elf, base, dl, dl_len);
if (built)
Last updated on