[Lldb-commits] [lldb] r288687 - [lldb] Update the check for Linux or FreeBSD in SymbolFileDWARF::FindFunctions

Alexander Shaposhnikov via lldb-commits lldb-commits at lists.llvm.org
Mon Dec 5 10:42:21 PST 2016


Author: alexshap
Date: Mon Dec  5 12:42:21 2016
New Revision: 288687

URL: http://llvm.org/viewvc/llvm-project?rev=288687&view=rev
Log:
[lldb] Update the check for Linux or FreeBSD in SymbolFileDWARF::FindFunctions

This diff
1. Adds a comment to ObjectFileELF.cpp about the current
approach to determining the OS.
2. Replaces the check in SymbolFileDWARF.cpp with a more robust one.

Test plan:
Built (on Linux) a test binary linked to a c++ shared library
which contains just an implementation of a function TestFunction,
the library (the binary itself) doesn't contain ELF notes 
and EI_OSABI is set to System V.
Checked in lldb that now "p TestFunction()" works fine 
(and doesn't work without this patch).

Differential revision: https://reviews.llvm.org/D27380

Modified:
    lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=288687&r1=288686&r2=288687&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Mon Dec  5 12:42:21 2016
@@ -1513,8 +1513,14 @@ size_t ObjectFileELF::GetSectionHeaderIn
     const uint32_t sub_type = subTypeFromElfHeader(header);
     arch_spec.SetArchitecture(eArchTypeELF, header.e_machine, sub_type,
                               header.e_ident[EI_OSABI]);
-    //
-    // Validate if it is ok to remove GetOsFromOSABI
+    
+    // Validate if it is ok to remove GetOsFromOSABI.
+    // Note, that now the OS is determined based on EI_OSABI flag and
+    // the info extracted from ELF notes (see RefineModuleDetailsFromNote).
+    // However in some cases that still might be not enough: for example
+    // a shared library might not have any notes at all
+    // and have EI_OSABI flag set to System V,
+    // as result the OS will be set to UnknownOS.
     GetOsFromOSABI(header.e_ident[EI_OSABI], ostype);
     spec_ostype = arch_spec.GetTriple().getOS();
     assert(spec_ostype == ostype);

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=288687&r1=288686&r2=288687&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Mon Dec  5 12:42:21 2016
@@ -2586,8 +2586,7 @@ SymbolFileDWARF::FindFunctions(const Con
       if (sc_list.GetSize() == original_size) {
         ArchSpec arch;
         if (!parent_decl_ctx && GetObjectFile()->GetArchitecture(arch) &&
-            (arch.GetTriple().isOSFreeBSD() || arch.GetTriple().isOSLinux() ||
-             arch.GetMachine() == llvm::Triple::hexagon)) {
+            arch.GetTriple().isOSBinFormatELF()) {
           SymbolContextList temp_sc_list;
           FindFunctions(name, m_function_basename_index, include_inlines,
                         temp_sc_list);




More information about the lldb-commits mailing list