1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 06:47:34 +00:00

LibDebug: Move Dwarf::LineProgram into Dwarf::CompilationUnit

Previously, the LineProgram objects were short-lived, and only created
inside DebugInfo::prepare_lines() to create a vector of sorted LineInfo
data.

However, Dwarf::LineProgram also contains other useful data, such as
index-to-string mapping of source directories and filenames.

This commit makes each Dwarf::CompilationUnit own its
Dwarf::LineProgram.
DebugInfo::prepare_lines() then iterates over the compilation units to
prepare its sorted vector of lines.
This commit is contained in:
Itamar 2021-06-18 15:25:27 +03:00 committed by Andreas Kling
parent e9e4358a93
commit 0d89f70b66
6 changed files with 30 additions and 17 deletions

View file

@ -78,17 +78,11 @@ void DebugInfo::parse_scopes_impl(const Dwarf::DIE& die)
void DebugInfo::prepare_lines()
{
auto section = elf().lookup_section(".debug_line"sv);
if (!section.has_value())
return;
InputMemoryStream stream { section->bytes() };
Vector<Dwarf::LineProgram::LineInfo> all_lines;
while (!stream.eof()) {
Dwarf::LineProgram program(m_dwarf_info, stream);
all_lines.extend(program.lines());
}
m_dwarf_info.for_each_compilation_unit([&all_lines](const Dwarf::CompilationUnit& unit) {
all_lines.extend(unit.line_program().lines());
});
HashMap<FlyString, Optional<String>> memoized_full_paths;
auto compute_full_path = [&](FlyString const& file_path) -> Optional<String> {