sas created this revision.
sas added reviewers: tberghammer, clayborg.
sas added a subscriber: lldb-commits.
Herald added a subscriber: rengolin.

This was GetAddressClass' behavior before. This is required when
debugging binaries that don't have mapping symbols ($a, $t, etc). These
binaries will only have the lower bit of the address set in the symbol
table.

http://reviews.llvm.org/D14507

Files:
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -972,9 +972,29 @@
     auto ub = m_address_class_map.upper_bound(file_addr);
     if (ub == m_address_class_map.begin())
     {
-        // No entry in the address class map before the address. Return
-        // default address class for an address in a code section.
-        return eAddressClassCode;
+        // No entry in the address class map before the address. Try finding
+        // the address class by using symbol flags, otherwise return default
+        // address class for an address in a code section.
+
+        ArchSpec arch_spec;
+        GetArchitecture(arch_spec);
+        if (arch_spec.GetMachine() != llvm::Triple::arm)
+            return res;
+
+        auto symtab = GetSymtab();
+        if (symtab == nullptr)
+            return res;
+
+        auto symbol = symtab->FindSymbolContainingFileAddress(file_addr);
+        if (symbol == nullptr)
+            return res;
+
+        // Thumb symbols have the lower bit set in the flags field so we just 
check
+        // for that.
+        if (symbol->GetFlags() & ARM_ELF_SYM_IS_THUMB)
+            res = eAddressClassCodeAlternateISA;
+
+        return res;
     }
 
     // Move iterator to the address class entry preceding address


Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -972,9 +972,29 @@
     auto ub = m_address_class_map.upper_bound(file_addr);
     if (ub == m_address_class_map.begin())
     {
-        // No entry in the address class map before the address. Return
-        // default address class for an address in a code section.
-        return eAddressClassCode;
+        // No entry in the address class map before the address. Try finding
+        // the address class by using symbol flags, otherwise return default
+        // address class for an address in a code section.
+
+        ArchSpec arch_spec;
+        GetArchitecture(arch_spec);
+        if (arch_spec.GetMachine() != llvm::Triple::arm)
+            return res;
+
+        auto symtab = GetSymtab();
+        if (symtab == nullptr)
+            return res;
+
+        auto symbol = symtab->FindSymbolContainingFileAddress(file_addr);
+        if (symbol == nullptr)
+            return res;
+
+        // Thumb symbols have the lower bit set in the flags field so we just check
+        // for that.
+        if (symbol->GetFlags() & ARM_ELF_SYM_IS_THUMB)
+            res = eAddressClassCodeAlternateISA;
+
+        return res;
     }
 
     // Move iterator to the address class entry preceding address
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to