summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFalseHonesty <thefalsehonesty@gmail.com>2021-04-12 12:16:53 -0400
committerAndreas Kling <kling@serenityos.org>2021-04-12 22:43:33 +0200
commitbffa1a0df8b820ca0a33492db9f5767216af2c95 (patch)
tree00343eb51dbf4f172dca5c6ce73e895a36babdf5
parentcffc0a4f4566cb3054a477f58a543684c9f1f116 (diff)
downloadserenity-bffa1a0df8b820ca0a33492db9f5767216af2c95.zip
LibDebug: Stop parsing unhandled variable types
Previously, when trying to debug variables with more complex types (such as String), we would crash the debugger simply because it didn't know how to handle types that were irrelevant anyways. Now we just skip data we don't yet know how to handle.
-rw-r--r--Userland/Libraries/LibDebug/DebugInfo.cpp19
-rw-r--r--Userland/Libraries/LibDebug/DebugInfo.h1
2 files changed, 13 insertions, 7 deletions
diff --git a/Userland/Libraries/LibDebug/DebugInfo.cpp b/Userland/Libraries/LibDebug/DebugInfo.cpp
index 4e6aae944a..853cda962c 100644
--- a/Userland/Libraries/LibDebug/DebugInfo.cpp
+++ b/Userland/Libraries/LibDebug/DebugInfo.cpp
@@ -254,12 +254,7 @@ static void parse_variable_location(const Dwarf::DIE& variable_die, DebugInfo::V
OwnPtr<DebugInfo::VariableInfo> DebugInfo::create_variable_info(const Dwarf::DIE& variable_die, const PtraceRegisters& regs, u32 address_offset) const
{
- VERIFY(variable_die.tag() == Dwarf::EntryTag::Variable
- || variable_die.tag() == Dwarf::EntryTag::Member
- || variable_die.tag() == Dwarf::EntryTag::FormalParameter
- || variable_die.tag() == Dwarf::EntryTag::EnumerationType
- || variable_die.tag() == Dwarf::EntryTag::Enumerator
- || variable_die.tag() == Dwarf::EntryTag::StructureType);
+ VERIFY(is_variable_tag_supported(variable_die.tag()));
if (variable_die.tag() == Dwarf::EntryTag::FormalParameter
&& !variable_die.get_attribute(Dwarf::Attribute::Name).has_value()) {
@@ -302,7 +297,7 @@ OwnPtr<DebugInfo::VariableInfo> DebugInfo::create_variable_info(const Dwarf::DIE
type_die.value().for_each_child([&](const Dwarf::DIE& member) {
if (member.is_null())
return;
- if (member.tag() == Dwarf::EntryTag::SubProgram)
+ if (!is_variable_tag_supported(member.tag()))
return;
auto member_variable = create_variable_info(member, regs, variable_info->location_data.address);
@@ -330,6 +325,16 @@ OwnPtr<DebugInfo::VariableInfo> DebugInfo::create_variable_info(const Dwarf::DIE
return variable_info;
}
+bool DebugInfo::is_variable_tag_supported(const Dwarf::EntryTag& tag)
+{
+ return tag == Dwarf::EntryTag::Variable
+ || tag == Dwarf::EntryTag::Member
+ || tag == Dwarf::EntryTag::FormalParameter
+ || tag == Dwarf::EntryTag::EnumerationType
+ || tag == Dwarf::EntryTag::Enumerator
+ || tag == Dwarf::EntryTag::StructureType;
+}
+
String DebugInfo::name_of_containing_function(u32 address) const
{
auto function = get_containing_function(address);
diff --git a/Userland/Libraries/LibDebug/DebugInfo.h b/Userland/Libraries/LibDebug/DebugInfo.h
index 4c1372d9c2..a70e96c5f4 100644
--- a/Userland/Libraries/LibDebug/DebugInfo.h
+++ b/Userland/Libraries/LibDebug/DebugInfo.h
@@ -141,6 +141,7 @@ private:
void prepare_lines();
void parse_scopes_impl(const Dwarf::DIE& die);
OwnPtr<VariableInfo> create_variable_info(const Dwarf::DIE& variable_die, const PtraceRegisters&, u32 address_offset = 0) const;
+ static bool is_variable_tag_supported(const Dwarf::EntryTag& tag);
NonnullOwnPtr<const ELF::Image> m_elf;
String m_source_root;