summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2021-10-09 17:47:43 +0200
committerLinus Groh <mail@linusgroh.de>2021-10-17 17:09:58 +0100
commita60d9604208ed6f01580062d2d8b2d5127b7f8cd (patch)
tree4ea4e69b31e73b9a7269458f42767000bd17b969
parent622d408d82c7474c6fb48b1eb939e5255dca8d6a (diff)
downloadserenity-a60d9604208ed6f01580062d2d8b2d5127b7f8cd.zip
LibDebug: Don't create compilation units for embedded resources
Our implementation (naively) assumes that there is a one-to-one correspondence between compilation units and line programs, and that their orders are identical. This is not the case for embedded resources, as Clang only creates line programs for it, but not compilation units. This mismatch caused an assertion failure, which made generating backtraces for GUI applications impossible. This commit introduces a hack that skips creating CompilationUnit objects for LinePrograms that come from embedded resources.
-rw-r--r--Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp14
-rw-r--r--Userland/Libraries/LibDebug/Dwarf/LineProgram.h11
2 files changed, 18 insertions, 7 deletions
diff --git a/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp b/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp
index 2a2c3bbd83..cdfb2b5c17 100644
--- a/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp
+++ b/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp
@@ -57,8 +57,18 @@ void DwarfInfo::populate_compilation_units()
auto line_program = make<LineProgram>(*this, line_info_stream);
- m_compilation_units.append(make<CompilationUnit>(*this, unit_offset, compilation_unit_header, move(line_program)));
- debug_info_stream.discard_or_error(length_after_header);
+ // HACK: Clang generates line programs for embedded resource assembly files, but not compile units.
+ // Meaning that for graphical applications, some line info data would be unread, triggering the assertion below.
+ // As a fix, we don't create compilation units for line programs that come from resource files.
+#ifdef __clang__
+ if (line_program->source_files().size() == 1 && line_program->source_files()[0].name.view().contains("serenity_icon_"sv)) {
+ debug_info_stream.seek(unit_offset);
+ } else
+#endif
+ {
+ m_compilation_units.append(make<CompilationUnit>(*this, unit_offset, compilation_unit_header, move(line_program)));
+ debug_info_stream.discard_or_error(length_after_header);
+ }
}
VERIFY(line_info_stream.eof());
diff --git a/Userland/Libraries/LibDebug/Dwarf/LineProgram.h b/Userland/Libraries/LibDebug/Dwarf/LineProgram.h
index ed6f01bd08..b90b10d948 100644
--- a/Userland/Libraries/LibDebug/Dwarf/LineProgram.h
+++ b/Userland/Libraries/LibDebug/Dwarf/LineProgram.h
@@ -122,6 +122,12 @@ public:
};
DirectoryAndFile get_directory_and_file(size_t file_index) const;
+ struct FileEntry {
+ FlyString name;
+ size_t directory_index { 0 };
+ };
+ Vector<FileEntry> const& source_files() const { return m_source_files; }
+
private:
void parse_unit_header();
void parse_source_directories();
@@ -159,11 +165,6 @@ private:
SetDiscriminator,
};
- struct FileEntry {
- FlyString name;
- size_t directory_index { 0 };
- };
-
static constexpr u16 MIN_DWARF_VERSION = 3;
static constexpr u16 MAX_DWARF_VERSION = 5;