[Lldb-commits] [lldb] r163676 - in /lldb/trunk: include/lldb/Host/Symbols.h include/lldb/Target/Platform.h source/Commands/CommandObjectTarget.cpp source/Host/common/Symbols.cpp source/Host/macosx/Symbols.cpp source/Plugins/Platform/MacOSX/PlatformDarwin.cpp source/Plugins/Platform/MacOSX/PlatformDarwin.h source/Target/Platform.cpp

Greg Clayton gclayton at apple.com
Tue Sep 11 19:03:59 PDT 2012


Author: gclayton
Date: Tue Sep 11 21:03:59 2012
New Revision: 163676

URL: http://llvm.org/viewvc/llvm-project?rev=163676&view=rev
Log:
<rdar://problem/11374963>

Partial fix for the above radar where we now resolve dsym mach-o files within the dSYM bundle when using "add-dsym" through the platform.


Modified:
    lldb/trunk/include/lldb/Host/Symbols.h
    lldb/trunk/include/lldb/Target/Platform.h
    lldb/trunk/source/Commands/CommandObjectTarget.cpp
    lldb/trunk/source/Host/common/Symbols.cpp
    lldb/trunk/source/Host/macosx/Symbols.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
    lldb/trunk/source/Target/Platform.cpp

Modified: lldb/trunk/include/lldb/Host/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Symbols.h?rev=163676&r1=163675&r2=163676&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Symbols.h (original)
+++ lldb/trunk/include/lldb/Host/Symbols.h Tue Sep 11 21:03:59 2012
@@ -29,6 +29,11 @@
 
     static FileSpec
     LocateExecutableSymbolFile (const ModuleSpec &module_spec);
+    
+    static FileSpec
+    FindSymbolFileInBundle (const FileSpec& dsym_bundle_fspec,
+                            const lldb_private::UUID *uuid,
+                            const ArchSpec *arch);
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/include/lldb/Target/Platform.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=163676&r1=163675&r2=163676&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Platform.h (original)
+++ lldb/trunk/include/lldb/Target/Platform.h Tue Sep 11 21:03:59 2012
@@ -118,6 +118,59 @@
                            lldb::ModuleSP &module_sp,
                            const FileSpecList *module_search_paths_ptr);
 
+        
+        //------------------------------------------------------------------
+        /// Find a symbol file given a symbol file module specification.
+        ///
+        /// Each platform might have tricks to find symbol files for an
+        /// executable given information in a symbol file ModuleSpec. Some
+        /// platforms might also support symbol files that are bundles and
+        /// know how to extract the right symbol file given a bundle.
+        ///
+        /// @param[in] target
+        ///     The target in which we are trying to resolve the symbol file.
+        ///     The target has a list of modules that we might be able to
+        ///     use in order to help find the right symbol file. If the
+        ///     "m_file" or "m_platform_file" entries in the \a sym_spec
+        ///     are filled in, then we might be able to locate a module in
+        ///     the target, extract its UUID and locate a symbol file.
+        ///     If just the "m_uuid" is specified, then we might be able
+        ///     to find the module in the target that matches that UUID
+        ///     and pair the symbol file along with it. If just "m_symbol_file"
+        ///     is specified, we can use a variety of tricks to locate the
+        ///     symbols in an SDK, PDK, or other development kit location.
+        ///
+        /// @param[in] sym_spec
+        ///     A module spec that describes some information about the
+        ///     symbol file we are trying to resolve. The ModuleSpec might
+        ///     contain the following:
+        ///     m_file - A full or partial path to an executable from the
+        ///              target (might be empty).
+        ///     m_platform_file - Another executable hint that contains
+        ///                       the path to the file as known on the
+        ///                       local/remote platform.
+        ///     m_symbol_file - A full or partial path to a symbol file
+        ///                     or symbol bundle that should be used when
+        ///                     trying to resolve the symbol file.
+        ///     m_arch - The architecture we are looking for when resolving
+        ///              the symbol file.
+        ///     m_uuid - The UUID of the executable and symbol file. This
+        ///              can often be used to match up an exectuable with
+        ///              a symbol file, or resolve an symbol file in a
+        ///              symbol file bundle.
+        ///
+        /// @param[out] sym_file
+        ///     The resolved symbol file spec if the returned error
+        ///     indicates succes.
+        ///
+        /// @return
+        ///     Returns an error that describes success or failure.
+        //------------------------------------------------------------------
+        virtual Error
+        ResolveSymbolFile (Target &target,
+                           const ModuleSpec &sym_spec,
+                           FileSpec &sym_file);
+
         //------------------------------------------------------------------
         /// Resolves the FileSpec to a (possibly) remote path. Remote
         /// platforms must override this to resolve to a path on the remote

Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=163676&r1=163675&r2=163676&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Tue Sep 11 21:03:59 2012
@@ -4040,12 +4040,21 @@
             }
             else
             {
+                PlatformSP platform_sp (target->GetPlatform());
+
                 for (size_t i=0; i<argc; ++i)
                 {
                     const char *symfile_path = args.GetArgumentAtIndex(i);
                     if (symfile_path)
                     {
-                        FileSpec symfile_spec(symfile_path, true);
+                        ModuleSpec sym_spec;
+                        FileSpec symfile_spec;
+                        sym_spec.GetSymbolFileSpec().SetFile(symfile_path, true);
+                        if (platform_sp)
+                            platform_sp->ResolveSymbolFile(*target, sym_spec, symfile_spec);
+                        else
+                            symfile_spec.SetFile(symfile_path, true);
+                        
                         ArchSpec arch;
                         if (symfile_spec.Exists())
                         {

Modified: lldb/trunk/source/Host/common/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Symbols.cpp?rev=163676&r1=163675&r2=163676&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Symbols.cpp (original)
+++ lldb/trunk/source/Host/common/Symbols.cpp Tue Sep 11 21:03:59 2012
@@ -28,4 +28,13 @@
     return FileSpec();
 }
 
+FileSpec
+Symbols::FindSymbolFileInBundle (const FileSpec& symfile_bundle,
+                                 const lldb_private::UUID *uuid,
+                                 const ArchSpec *arch)
+{
+    return FileSpec();
+}
+
+
 #endif

Modified: lldb/trunk/source/Host/macosx/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Symbols.cpp?rev=163676&r1=163675&r2=163676&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Symbols.cpp (original)
+++ lldb/trunk/source/Host/macosx/Symbols.cpp Tue Sep 11 21:03:59 2012
@@ -244,12 +244,10 @@
     return false;
 }
 
-static FileSpec
-LocateDSYMMachFileInDSYMBundle
-(
-    const FileSpec& dsym_bundle_fspec,
-    const lldb_private::UUID *uuid,
-    const ArchSpec *arch)
+FileSpec
+Symbols::FindSymbolFileInBundle (const FileSpec& dsym_bundle_fspec,
+                                 const lldb_private::UUID *uuid,
+                                 const ArchSpec *arch)
 {
     char path[PATH_MAX];
 
@@ -361,7 +359,7 @@
 
                             if (out_dsym_fspec->GetFileType () == FileSpec::eFileTypeDirectory)
                             {
-                                *out_dsym_fspec = LocateDSYMMachFileInDSYMBundle (*out_dsym_fspec, uuid, arch);
+                                *out_dsym_fspec = Symbols::FindSymbolFileInBundle (*out_dsym_fspec, uuid, arch);
                                 if (*out_dsym_fspec)
                                     ++items_found;
                             }

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=163676&r1=163675&r2=163676&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Tue Sep 11 21:03:59 2012
@@ -19,6 +19,7 @@
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Host/Host.h"
+#include "lldb/Host/Symbols.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Target/Target.h"
 
@@ -170,6 +171,33 @@
     return error;
 }
 
+Error
+PlatformDarwin::ResolveSymbolFile (Target &target,
+                                   const ModuleSpec &sym_spec,
+                                   FileSpec &sym_file)
+{
+    Error error;
+    sym_file = sym_spec.GetSymbolFileSpec();
+    if (sym_file.Exists())
+    {
+        if (sym_file.GetFileType() == FileSpec::eFileTypeDirectory)
+        {
+            sym_file = Symbols::FindSymbolFileInBundle (sym_file,
+                                                        sym_spec.GetUUIDPtr(),
+                                                        sym_spec.GetArchitecturePtr());
+        }
+    }
+    else
+    {
+        if (sym_spec.GetUUID().IsValid())
+        {
+            
+        }
+    }
+    return error;
+    
+}
+
 
 
 Error

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h?rev=163676&r1=163675&r2=163676&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h Tue Sep 11 21:03:59 2012
@@ -34,6 +34,11 @@
                        const lldb_private::FileSpecList *module_search_paths_ptr);
 
     virtual lldb_private::Error
+    ResolveSymbolFile (lldb_private::Target &target,
+                       const lldb_private::ModuleSpec &sym_spec,
+                       lldb_private::FileSpec &sym_file);
+
+    virtual lldb_private::Error
     GetSharedModule (const lldb_private::ModuleSpec &module_spec,
                      lldb::ModuleSP &module_sp,
                      const lldb_private::FileSpecList *module_search_paths_ptr,

Modified: lldb/trunk/source/Target/Platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=163676&r1=163675&r2=163676&view=diff
==============================================================================
--- lldb/trunk/source/Target/Platform.cpp (original)
+++ lldb/trunk/source/Target/Platform.cpp Tue Sep 11 21:03:59 2012
@@ -466,6 +466,22 @@
     return error;
 }
 
+Error
+Platform::ResolveSymbolFile (Target &target,
+                             const ModuleSpec &sym_spec,
+                             FileSpec &sym_file)
+{
+    Error error;
+    if (sym_spec.GetSymbolFileSpec().Exists())
+        sym_file = sym_spec.GetSymbolFileSpec();
+    else
+        error.SetErrorString("unable to resolve symbol file");
+    return error;
+    
+}
+
+
+
 bool
 Platform::ResolveRemotePath (const FileSpec &platform_path,
                              FileSpec &resolved_platform_path)





More information about the lldb-commits mailing list