[Lldb-commits] [lldb] r237467 - Only check _ZN function prefix in Linux and FreeBSD targets in SymbolFileDWARF

Robert Flack flackr at gmail.com
Fri May 15 12:00:00 PDT 2015


Author: flackr
Date: Fri May 15 13:59:59 2015
New Revision: 237467

URL: http://llvm.org/viewvc/llvm-project?rev=237467&view=rev
Log:
Only check _ZN function prefix in Linux and FreeBSD targets in SymbolFileDWARF

In http://reviews.llvm.org/D9754 I enabled the mangled symbol name lookup
workaround used to find global and anonymous namespace symbols in linux binaries
for all platforms, however we should still only check for these symbols when
processing Linux or FreeBSD binaries where they are relevant. This patch makes
this change.

Test Plan: The tests from the original revision still pass:
TestCallCPPFunction.py
TestCallStopAndContinue.py
TestExprs.py
TestExprsChar.py
TestNamespace.py
TestOverloadedFunctions.py
TestRvalueReferences.py
TestThreadExit.py

Differential Revision: http://reviews.llvm.org/D9782

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

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=237467&r1=237466&r2=237467&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri May 15 13:59:59 2015
@@ -26,6 +26,7 @@
 
 #include "llvm/Support/Casting.h"
 
+#include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/ModuleSpec.h"
@@ -4036,14 +4037,21 @@ SymbolFileDWARF::FindFunctions (const Co
             // functions debugging FreeBSD and Linux binaries.
             // If we didn't find any functions in the global namespace try
             // looking in the basename index but ignore any returned
-            // functions that have a namespace (ie. mangled names starting with 
-            // '_ZN') but keep functions which have an anonymous namespace
+            // functions that have a namespace but keep functions which
+            // have an anonymous namespace
+            // TODO: The arch in the object file isn't correct for MSVC
+            // binaries on windows, we should find a way to make it
+            // correct and handle those symbols as well.
             if (sc_list.GetSize() == 0)
             {
-                SymbolContextList temp_sc_list;
-                FindFunctions (name, m_function_basename_index, include_inlines, temp_sc_list);
-                if (!namespace_decl)
+                ArchSpec arch;
+                if (!namespace_decl &&
+                    GetObjectFile()->GetArchitecture(arch) &&
+                    (arch.GetTriple().isOSFreeBSD() || arch.GetTriple().isOSLinux() ||
+                     arch.GetMachine() == llvm::Triple::hexagon))
                 {
+                    SymbolContextList temp_sc_list;
+                    FindFunctions (name, m_function_basename_index, include_inlines, temp_sc_list);
                     SymbolContext sc;
                     for (uint32_t i = 0; i < temp_sc_list.GetSize(); i++)
                     {
@@ -4051,6 +4059,8 @@ SymbolFileDWARF::FindFunctions (const Co
                         {
                             ConstString mangled_name = sc.GetFunctionName(Mangled::ePreferMangled);
                             ConstString demangled_name = sc.GetFunctionName(Mangled::ePreferDemangled);
+                            // Mangled names on Linux and FreeBSD are of the form:
+                            // _ZN18function_namespace13function_nameEv.
                             if (strncmp(mangled_name.GetCString(), "_ZN", 3) ||
                                 !strncmp(demangled_name.GetCString(), "(anonymous namespace)", 21))
                             {





More information about the lldb-commits mailing list