zturner created this revision.
zturner added reviewers: labath, JDevlieghere, jingham.
Herald added subscribers: jdoerfert, MaskRay, arichardson, mgorny, emaste.
Herald added a reviewer: espindola.

After this change, there is only 1 remaining dependency in Host to Target.

While this change might seem like kind of a heavy hammer to solving the 
dependency problem, it makes more sense even conceptually to be in Symbols.  
While some of the specific places to search for symbol files might change 
depending on the Host, this is not inherently true in the same way that 
"accessing the file system" or "starting threads" is fundamentally dependent on 
the Host.

PDBs, for example, recently became a reality on non-Windows platforms, and it's 
theoretically possible that DSYMs could become a thing on non MacOSX platforms 
(maybe in a remote debugging scenario).  Other types of symbol files, such as 
DWO, DWP, etc have never been tied to any Host platform anyway.

So I think this change both makes sense logically, and also improves the 
layering.


https://reviews.llvm.org/D58730

Files:
  lldb/include/lldb/Host/Symbols.h
  lldb/include/lldb/Symbol/LocateSymbolFile.h
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Core/ModuleList.cpp
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/Symbols.cpp
  lldb/source/Host/macosx/Symbols.cpp
  lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
  lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
  lldb/source/Symbol/CMakeLists.txt
  lldb/source/Symbol/LocateSymbolFile.cpp
  lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
  lldb/unittests/Host/CMakeLists.txt
  lldb/unittests/Host/SymbolsTest.cpp
  lldb/unittests/Symbol/CMakeLists.txt
  lldb/unittests/Symbol/LocateSymbolFileTest.cpp

Index: lldb/unittests/Symbol/LocateSymbolFileTest.cpp
===================================================================
--- lldb/unittests/Symbol/LocateSymbolFileTest.cpp
+++ lldb/unittests/Symbol/LocateSymbolFileTest.cpp
@@ -11,7 +11,7 @@
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/HostInfo.h"
-#include "lldb/Host/Symbols.h"
+#include "lldb/Symbol/LocateSymbolFile.h"
 
 using namespace lldb_private;
 
Index: lldb/unittests/Symbol/CMakeLists.txt
===================================================================
--- lldb/unittests/Symbol/CMakeLists.txt
+++ lldb/unittests/Symbol/CMakeLists.txt
@@ -1,4 +1,5 @@
 add_lldb_unittest(SymbolTests
+  LocateSymbolFileTest.cpp
   TestClangASTContext.cpp
   TestDWARFCallFrameInfo.cpp
   TestType.cpp
Index: lldb/unittests/Host/CMakeLists.txt
===================================================================
--- lldb/unittests/Host/CMakeLists.txt
+++ lldb/unittests/Host/CMakeLists.txt
@@ -9,7 +9,6 @@
   ProcessLaunchInfoTest.cpp
   SocketAddressTest.cpp
   SocketTest.cpp
-  SymbolsTest.cpp
   TaskPoolTest.cpp
 )
 
Index: lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
===================================================================
--- lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
+++ lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "lldb/Host/Symbols.h"
+#include "lldb/Symbol/LocateSymbolFile.h"
 
 #include <dirent.h>
 #include <pwd.h>
@@ -54,7 +54,7 @@
       log->Printf("Spotlight lookup for .dSYM bundles is disabled.");
     return 0;
   }
-  
+
   return_module_spec = module_spec;
   return_module_spec.GetFileSpec().Clear();
   return_module_spec.GetSymbolFileSpec().Clear();
@@ -422,8 +422,8 @@
               source_path.RemoveLastPathComponent();
               source_path.RemoveLastPathComponent();
               module_spec.GetSourceMappingList().Append(
-                ConstString(build_path.GetPath().c_str()),
-                ConstString(source_path.GetPath().c_str()), true);
+                  ConstString(build_path.GetPath().c_str()),
+                  ConstString(source_path.GetPath().c_str()), true);
             }
           }
         }
@@ -434,7 +434,6 @@
       }
     }
 
-
     // If we have a DBGBuildSourcePath + DBGSourcePath pair, append them to the
     // source remappings list.
 
Index: lldb/source/Symbol/LocateSymbolFile.cpp
===================================================================
--- lldb/source/Symbol/LocateSymbolFile.cpp
+++ lldb/source/Symbol/LocateSymbolFile.cpp
@@ -6,7 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "lldb/Host/Symbols.h"
+#include "lldb/Symbol/LocateSymbolFile.h"
+
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Symbol/ObjectFile.h"
@@ -66,8 +67,8 @@
 
 // Given a binary exec_fspec, and a ModuleSpec with an architecture/uuid,
 // return true if there is a matching dSYM bundle next to the exec_fspec,
-// and return that value in dsym_fspec.  
-// If there is a .dSYM.yaa compressed archive next to the exec_fspec, 
+// and return that value in dsym_fspec.
+// If there is a .dSYM.yaa compressed archive next to the exec_fspec,
 // call through Symbols::DownloadObjectAndSymbolFile to download the
 // expanded/uncompressed dSYM and return that filepath in dsym_fspec.
 
@@ -99,9 +100,9 @@
 
     // See if we have "../CF.framework" - so we'll look for
     // CF.framework.dSYM/Contents/Resources/DWARF/CF
-    // We need to drop the last suffix after '.' to match 
+    // We need to drop the last suffix after '.' to match
     // 'CF' in the DWARF subdir.
-    std::string binary_name (filename.AsCString());
+    std::string binary_name(filename.AsCString());
     auto last_dot = binary_name.find_last_of('.');
     if (last_dot != std::string::npos) {
       binary_name.erase(last_dot);
@@ -152,11 +153,13 @@
   Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
   const FileSpec &exec_fspec = module_spec.GetFileSpec();
   if (exec_fspec) {
-    if (::LookForDsymNextToExecutablePath (module_spec, exec_fspec, dsym_fspec)) {
-        if (log) {
-          log->Printf("dSYM with matching UUID & arch found at %s", dsym_fspec.GetPath().c_str());
-        }
-        return true;
+    if (::LookForDsymNextToExecutablePath(module_spec, exec_fspec,
+                                          dsym_fspec)) {
+      if (log) {
+        log->Printf("dSYM with matching UUID & arch found at %s",
+                    dsym_fspec.GetPath().c_str());
+      }
+      return true;
     } else {
       FileSpec parent_dirs = exec_fspec;
 
@@ -182,7 +185,8 @@
         if (fn == nullptr)
           break;
         if (::strchr(fn, '.') != nullptr) {
-          if (::LookForDsymNextToExecutablePath (module_spec, parent_dirs, dsym_fspec)) {
+          if (::LookForDsymNextToExecutablePath(module_spec, parent_dirs,
+                                                dsym_fspec)) {
             if (log) {
               log->Printf("dSYM with matching UUID & arch found at %s",
                           dsym_fspec.GetPath().c_str());
@@ -262,7 +266,8 @@
     // Add module directory.
     FileSpec module_file_spec = module_spec.GetFileSpec();
     // We keep the unresolved pathname if it fails.
-    FileSystem::Instance().ResolveSymbolicLink(module_file_spec, module_file_spec);
+    FileSystem::Instance().ResolveSymbolicLink(module_file_spec,
+                                               module_file_spec);
 
     const ConstString &file_dir = module_file_spec.GetDirectory();
     {
@@ -306,7 +311,7 @@
       //   /usr/lib/debug/.build-id/ff/e7fe727889ad82bb153de2ad065b2189693315.debug
       uuid_str = module_uuid.GetAsString("");
       std::transform(uuid_str.begin(), uuid_str.end(), uuid_str.begin(),
-          ::tolower);
+                     ::tolower);
       uuid_str.insert(2, 1, '/');
       uuid_str = uuid_str + ".debug";
     }
Index: lldb/source/Symbol/CMakeLists.txt
===================================================================
--- lldb/source/Symbol/CMakeLists.txt
+++ lldb/source/Symbol/CMakeLists.txt
@@ -1,3 +1,9 @@
+set(LLVM_OPTIONAL_SOURCES LocateSymbolFileMacOSX.cpp)
+
+if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
+  set(PLATFORM_SOURCES LocateSymbolFileMacOSX.cpp)
+endif()
+
 add_lldb_library(lldbSymbol
   ArmUnwindInfo.cpp
   Block.cpp
@@ -18,6 +24,7 @@
   FuncUnwinders.cpp
   LineEntry.cpp
   LineTable.cpp
+  LocateSymbolFile.cpp
   ObjectFile.cpp
   Symbol.cpp
   SymbolContext.cpp
@@ -34,6 +41,8 @@
   VariableList.cpp
   VerifyDecl.cpp
 
+  ${PLATFORM_SOURCES}
+
   LINK_LIBS
     clangAST
     clangBasic
Index: lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
===================================================================
--- lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
+++ lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
@@ -15,8 +15,8 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Host/Host.h"
-#include "lldb/Host/Symbols.h"
 #include "lldb/Host/XML.h"
+#include "lldb/Symbol/LocateSymbolFile.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/StreamString.h"
 #include "lldb/Utility/Timer.h"
Index: lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
===================================================================
--- lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
+++ lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
@@ -15,7 +15,7 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Host/Host.h"
-#include "lldb/Host/Symbols.h"
+#include "lldb/Symbol/LocateSymbolFile.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/StreamString.h"
 #include "lldb/Utility/Timer.h"
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -29,7 +29,6 @@
 
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/Host.h"
-#include "lldb/Host/Symbols.h"
 
 #include "lldb/Interpreter/OptionValueFileSpecList.h"
 #include "lldb/Interpreter/OptionValueProperties.h"
@@ -42,6 +41,7 @@
 #include "lldb/Symbol/CompilerDeclContext.h"
 #include "lldb/Symbol/DebugMacros.h"
 #include "lldb/Symbol/LineTable.h"
+#include "lldb/Symbol/LocateSymbolFile.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/SymbolVendor.h"
 #include "lldb/Symbol/TypeMap.h"
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -41,7 +41,6 @@
 #include "lldb/Host/PosixApi.h"
 #include "lldb/Host/PseudoTerminal.h"
 #include "lldb/Host/StringConvert.h"
-#include "lldb/Host/Symbols.h"
 #include "lldb/Host/ThreadLauncher.h"
 #include "lldb/Host/XML.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
@@ -54,6 +53,7 @@
 #include "lldb/Interpreter/OptionValueProperties.h"
 #include "lldb/Interpreter/Options.h"
 #include "lldb/Interpreter/Property.h"
+#include "lldb/Symbol/LocateSymbolFile.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Target/ABI.h"
 #include "lldb/Target/DynamicLoader.h"
Index: lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
===================================================================
--- lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -18,7 +18,6 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Host/ConnectionFileDescriptor.h"
 #include "lldb/Host/Host.h"
-#include "lldb/Host/Symbols.h"
 #include "lldb/Host/ThreadLauncher.h"
 #include "lldb/Host/common/TCPSocket.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
@@ -28,6 +27,7 @@
 #include "lldb/Interpreter/OptionGroupString.h"
 #include "lldb/Interpreter/OptionGroupUInt64.h"
 #include "lldb/Interpreter/OptionValueProperties.h"
+#include "lldb/Symbol/LocateSymbolFile.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Target.h"
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -21,9 +21,9 @@
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/HostInfo.h"
-#include "lldb/Host/Symbols.h"
 #include "lldb/Host/XML.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Symbol/LocateSymbolFile.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/SymbolFile.h"
 #include "lldb/Symbol/SymbolVendor.h"
Index: lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
===================================================================
--- lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -15,8 +15,8 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Core/StreamFile.h"
-#include "lldb/Host/Symbols.h"
 #include "lldb/Interpreter/OptionValueProperties.h"
+#include "lldb/Symbol/LocateSymbolFile.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Target/OperatingSystem.h"
 #include "lldb/Target/RegisterContext.h"
Index: lldb/source/Host/CMakeLists.txt
===================================================================
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -44,7 +44,6 @@
   common/SocketAddress.cpp
   common/Socket.cpp
   common/StringConvert.cpp
-  common/Symbols.cpp
   common/TaskPool.cpp
   common/TCPSocket.cpp
   common/Terminal.cpp
@@ -95,7 +94,6 @@
     add_subdirectory(macosx/objcxx)
     set(LLDBObjCLibs lldbHostMacOSXObjCXX)
     add_host_subdirectory(macosx
-      macosx/Symbols.cpp
       macosx/cfcpp/CFCBundle.cpp
       macosx/cfcpp/CFCData.cpp
       macosx/cfcpp/CFCMutableArray.cpp
@@ -166,7 +164,6 @@
 
   LINK_LIBS
     lldbCore
-    lldbSymbol
     lldbTarget
     lldbUtility
     ${EXTRA_LIBS}
Index: lldb/source/Core/ModuleList.cpp
===================================================================
--- lldb/source/Core/ModuleList.cpp
+++ lldb/source/Core/ModuleList.cpp
@@ -11,10 +11,10 @@
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Host/FileSystem.h"
-#include "lldb/Host/Symbols.h"
 #include "lldb/Interpreter/OptionValueFileSpec.h"
 #include "lldb/Interpreter/OptionValueProperties.h"
 #include "lldb/Interpreter/Property.h"
+#include "lldb/Symbol/LocateSymbolFile.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Symbol/VariableList.h"
Index: lldb/source/Commands/CommandObjectTarget.cpp
===================================================================
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -17,7 +17,6 @@
 #include "lldb/DataFormatters/ValueObjectPrinter.h"
 #include "lldb/Host/OptionParser.h"
 #include "lldb/Host/StringConvert.h"
-#include "lldb/Host/Symbols.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Interpreter/OptionArgParser.h"
@@ -35,6 +34,7 @@
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/FuncUnwinders.h"
 #include "lldb/Symbol/LineTable.h"
+#include "lldb/Symbol/LocateSymbolFile.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/SymbolFile.h"
 #include "lldb/Symbol/SymbolVendor.h"
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to