Skip to content

Commit d365274

Browse files
committed
Adapted the main DWARF parser, loading the debug str offsets offset
1 parent d8c5038 commit d365274

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/parser/file/dwarf/dwarf_parser.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -385,22 +385,28 @@ static inline bool dwarf_parseCompDir(struct dwarf_parser* self) {
385385
const vector_pair_uint64_t abbrevs = dwarf_getAbbreviationTable(self->debugAbbrev, abbrevCode, abbrevOffset, version);
386386
vector_iterate(pair_uint64_t, &abbrevs, {
387387
if (element->first == DW_AT_comp_dir) {
388-
self->compilationDirectory = dwarf5_readString(self->debugInfo.content,
388+
self->compilationDirectory = dwarf5_readString(self,
389+
self->debugInfo.content,
389390
&counter,
390-
element->second,
391-
bit64,
392-
self->debugLineStr,
393-
self->debugStr,
394-
self->debugStrOffsets);
391+
element->second);
395392
break;
393+
} else if (version >= 5 && element->first == DW_AT_str_offsets_base) {
394+
if (self->bit64) {
395+
self->debugStrOffset.value = *((uint64_t*) (self->debugInfo.content + counter));
396+
counter += 8;
397+
} else {
398+
self->debugStrOffset.value = *((uint32_t*) (self->debugInfo.content + counter));
399+
counter += 4;
400+
}
401+
self->debugStrOffset.has_value = true;
396402
} else if (version >= 5 && element->second == DW_FORM_implicit_const) {
397403
continue;
398404
} else if (element->second == DW_FORM_indirect) {
399405
const uint64_t actualForm = getULEB128(self->debugInfo.content, &counter);
400-
if (!dwarf5_consumeSome(self->debugInfo.content, &counter, actualForm, bit64)) {
406+
if (!dwarf5_consumeSome(self, self->debugInfo.content, &counter, actualForm)) {
401407
break;
402408
}
403-
} else if (!dwarf5_consumeSome(self->debugInfo.content, &counter, element->second, bit64)) {
409+
} else if (!dwarf5_consumeSome(self, self->debugInfo.content, &counter, element->second)) {
404410
break;
405411
}
406412
})
@@ -433,7 +439,8 @@ bool dwarf_parseLineProgram(struct lcs_section debugLine,
433439
.cb = cb,
434440
.args = args,
435441
.stdOpcodeLengths = vector_initializer,
436-
.compilationDirectory = NULL
442+
.compilationDirectory = NULL,
443+
.debugStrOffset = (optional_uint64_t) { .has_value = false },
437444
};
438445
if (!dwarf_parseCompDir(&parser)) {
439446
return false;

0 commit comments

Comments
 (0)