[Lldb-commits] [lldb] r152836 - in /lldb/trunk: include/lldb/Core/Module.h include/lldb/Core/ModuleList.h include/lldb/Target/PathMappingList.h source/Core/Module.cpp source/Core/ModuleList.cpp source/Core/SourceManager.cpp source/Host/macosx/Symbols.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp source/Target/PathMappingList.cpp

Greg Clayton gclayton at apple.com
Thu Mar 15 14:01:31 PDT 2012


Author: gclayton
Date: Thu Mar 15 16:01:31 2012
New Revision: 152836

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

Use the metadata in the dSYM bundle Info.plist to remap source paths when they keys are available.


Modified:
    lldb/trunk/include/lldb/Core/Module.h
    lldb/trunk/include/lldb/Core/ModuleList.h
    lldb/trunk/include/lldb/Target/PathMappingList.h
    lldb/trunk/source/Core/Module.cpp
    lldb/trunk/source/Core/ModuleList.cpp
    lldb/trunk/source/Core/SourceManager.cpp
    lldb/trunk/source/Host/macosx/Symbols.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
    lldb/trunk/source/Target/PathMappingList.cpp

Modified: lldb/trunk/include/lldb/Core/Module.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=152836&r1=152835&r2=152836&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Module.h (original)
+++ lldb/trunk/include/lldb/Core/Module.h Thu Mar 15 16:01:31 2012
@@ -21,26 +21,9 @@
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Symbol/Symtab.h"
 #include "lldb/Symbol/TypeList.h"
+#include "lldb/Target/PathMappingList.h"
+
 
-//----------------------------------------------------------------------
-/// @class Module Module.h "lldb/Core/Module.h"
-/// @brief A class that describes an executable image and its associated
-///        object and symbol files.
-///
-/// The module is designed to be able to select a single slice of an
-/// executable image as it would appear on disk and during program
-/// execution.
-///
-/// Modules control when and if information is parsed according to which
-/// accessors are called. For example the object file (ObjectFile)
-/// representation will only be parsed if the object file is requested
-/// using the Module::GetObjectFile() is called. The debug symbols
-/// will only be parsed if the symbol vendor (SymbolVendor) is
-/// requested using the Module::GetSymbolVendor() is called.
-///
-/// The module will parse more detailed information as more queries are
-/// made.
-//----------------------------------------------------------------------
 namespace lldb_private {
 
 class ModuleSpec
@@ -53,7 +36,8 @@
         m_arch (),
         m_uuid (),
         m_object_name (),
-        m_object_offset (0)
+        m_object_offset (0),
+        m_source_mappings ()
     {
     }
 
@@ -64,7 +48,8 @@
         m_arch (),
         m_uuid (),
         m_object_name (),
-        m_object_offset (0)
+        m_object_offset (0),
+        m_source_mappings ()
     {
     }
 
@@ -75,7 +60,8 @@
         m_arch (arch),
         m_uuid (),
         m_object_name (),
-        m_object_offset (0)
+        m_object_offset (0),
+        m_source_mappings ()
     {
     }
     
@@ -86,7 +72,8 @@
         m_arch (rhs.m_arch),
         m_uuid (rhs.m_uuid),
         m_object_name (rhs.m_object_name),
-        m_object_offset (rhs.m_object_offset)
+        m_object_offset (rhs.m_object_offset),
+        m_source_mappings (rhs.m_source_mappings)
     {
     }
 
@@ -102,6 +89,7 @@
             m_uuid = rhs.m_uuid;
             m_object_name = rhs.m_object_name;
             m_object_offset = rhs.m_object_offset;
+            m_source_mappings = rhs.m_source_mappings;
         }
         return *this;
     }
@@ -270,6 +258,12 @@
         m_object_offset = object_offset;
     }
 
+    PathMappingList &
+    GetSourceMappingList () const
+    {
+        return m_source_mappings;
+    }
+
 protected:
     FileSpec m_file;
     FileSpec m_platform_file;
@@ -278,8 +272,28 @@
     UUID m_uuid;
     ConstString m_object_name;
     uint64_t m_object_offset;
+    mutable PathMappingList m_source_mappings;
 };
 
+//----------------------------------------------------------------------
+/// @class Module Module.h "lldb/Core/Module.h"
+/// @brief A class that describes an executable image and its associated
+///        object and symbol files.
+///
+/// The module is designed to be able to select a single slice of an
+/// executable image as it would appear on disk and during program
+/// execution.
+///
+/// Modules control when and if information is parsed according to which
+/// accessors are called. For example the object file (ObjectFile)
+/// representation will only be parsed if the object file is requested
+/// using the Module::GetObjectFile() is called. The debug symbols
+/// will only be parsed if the symbol vendor (SymbolVendor) is
+/// requested using the Module::GetSymbolVendor() is called.
+///
+/// The module will parse more detailed information as more queries are
+/// made.
+//----------------------------------------------------------------------
 class Module :
     public STD_ENABLE_SHARED_FROM_THIS(Module),
     public SymbolContextScope
@@ -994,6 +1008,21 @@
         return m_mutex;
     }
 
+    PathMappingList &
+    GetSourceMappingList ()
+    {
+        return m_source_mappings;
+    }
+    
+    const PathMappingList &
+    GetSourceMappingList () const
+    {
+        return m_source_mappings;
+    }
+    
+    bool
+    FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const;
+    
 protected:
     //------------------------------------------------------------------
     // Member Variables
@@ -1010,6 +1039,8 @@
     lldb::ObjectFileSP          m_objfile_sp;   ///< A shared pointer to the object file parser for this module as it may or may not be shared with the SymbolFile
     std::auto_ptr<SymbolVendor> m_symfile_ap;   ///< A pointer to the symbol vendor for this module.
     ClangASTContext             m_ast;          ///< The AST context for this module.
+    PathMappingList             m_source_mappings; ///< Module specific source remappings for when you have debug info for a module that doesn't match where the sources currently are
+
     bool                        m_did_load_objfile:1,
                                 m_did_load_symbol_vendor:1,
                                 m_did_parse_uuid:1,

Modified: lldb/trunk/include/lldb/Core/ModuleList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleList.h?rev=152836&r1=152835&r2=152836&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ModuleList.h (original)
+++ lldb/trunk/include/lldb/Core/ModuleList.h Thu Mar 15 16:01:31 2012
@@ -347,6 +347,9 @@
                TypeList& types);
     
     bool
+    FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const;
+    
+    bool
     Remove (const lldb::ModuleSP &module_sp);
 
     size_t

Modified: lldb/trunk/include/lldb/Target/PathMappingList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/PathMappingList.h?rev=152836&r1=152835&r2=152836&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/PathMappingList.h (original)
+++ lldb/trunk/include/lldb/Target/PathMappingList.h Thu Mar 15 16:01:31 2012
@@ -31,6 +31,8 @@
     //------------------------------------------------------------------
     // Constructors and Destructors
     //------------------------------------------------------------------
+    PathMappingList ();
+
     PathMappingList (ChangedCallback callback,
                      void *callback_baton);
 
@@ -46,6 +48,9 @@
     Append (const ConstString &path, const ConstString &replacement, bool notify);
 
     void
+    Append (const PathMappingList &rhs, bool notify);
+
+    void
     Clear (bool notify);
 
     // By default, dump all pairs.
@@ -53,7 +58,10 @@
     Dump (Stream *s, int pair_index=-1);
 
     size_t
-    GetSize ();
+    GetSize () const
+    {
+        return m_pairs.size();
+    }
 
     bool
     GetPathsAtIndex (uint32_t idx, ConstString &path, ConstString &new_path) const;
@@ -76,7 +84,10 @@
              bool notify);
     
     bool
-    RemapPath (const ConstString &path, ConstString &new_path);
+    RemapPath (const ConstString &path, ConstString &new_path) const;
+
+    bool
+    FindFile (const FileSpec &orig_spec, FileSpec &new_spec) const;
 
     uint32_t
     FindIndexForPath (const ConstString &path) const;

Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=152836&r1=152835&r2=152836&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Thu Mar 15 16:01:31 2012
@@ -127,6 +127,7 @@
     m_objfile_sp (),
     m_symfile_ap (),
     m_ast (),
+    m_source_mappings (),
     m_did_load_objfile (false),
     m_did_load_symbol_vendor (false),
     m_did_parse_uuid (false),
@@ -168,6 +169,7 @@
     m_objfile_sp (),
     m_symfile_ap (),
     m_ast (),
+    m_source_mappings (),
     m_did_load_objfile (false),
     m_did_load_symbol_vendor (false),
     m_did_parse_uuid (false),
@@ -1156,3 +1158,10 @@
     return true;
 }
 
+bool
+Module::FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const
+{
+    Mutex::Locker locker (m_mutex);
+    return m_source_mappings.FindFile (orig_spec, new_spec);
+}
+

Modified: lldb/trunk/source/Core/ModuleList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=152836&r1=152835&r2=152836&view=diff
==============================================================================
--- lldb/trunk/source/Core/ModuleList.cpp (original)
+++ lldb/trunk/source/Core/ModuleList.cpp Thu Mar 15 16:01:31 2012
@@ -372,6 +372,21 @@
     return total_matches;
 }
 
+bool
+ModuleList::FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const
+{
+    Mutex::Locker locker(m_modules_mutex);
+    collection::const_iterator pos, end = m_modules.end();
+    for (pos = m_modules.begin(); pos != end; ++pos)
+    {
+        if ((*pos)->FindSourceFile (orig_spec, new_spec))
+            return true;
+    }
+    return false;
+}
+
+
+
 ModuleSP
 ModuleList::FindFirstModule (const ModuleSpec &module_spec)
 {

Modified: lldb/trunk/source/Core/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/SourceManager.cpp?rev=152836&r1=152835&r2=152836&view=diff
==============================================================================
--- lldb/trunk/source/Core/SourceManager.cpp (original)
+++ lldb/trunk/source/Core/SourceManager.cpp Thu Mar 15 16:01:31 2012
@@ -272,10 +272,10 @@
 
 void
 SourceManager::FindLinesMatchingRegex (FileSpec &file_spec,
-                        RegularExpression& regex, 
-                        uint32_t start_line, 
-                        uint32_t end_line, 
-                        std::vector<uint32_t> &match_lines)
+                                       RegularExpression& regex,
+                                       uint32_t start_line,
+                                       uint32_t end_line,
+                                       std::vector<uint32_t> &match_lines)
 {
     match_lines.clear();
     FileSP file_sp = GetFile (file_spec);
@@ -333,7 +333,7 @@
                     {
                         SymbolContext sc;
                         sc_list.GetContextAtIndex (0, sc);
-                        m_file_spec = static_cast<FileSpec *>(sc.comp_unit);
+                        m_file_spec = sc.comp_unit;
                         m_mod_time = m_file_spec.GetModificationTime();
                     }
                 }
@@ -341,12 +341,15 @@
             // Try remapping if m_file_spec does not correspond to an existing file.
             if (!m_file_spec.Exists())
             {
-                ConstString new_path;
-                if (target->GetSourcePathMap().RemapPath(m_file_spec.GetDirectory(), new_path))
+                FileSpec new_file_spec;
+                // Check target specific source remappings first, then fall back to
+                // modules objects can have individual path remappings that were detected
+                // when the debug info for a module was found.
+                // then
+                if (target->GetSourcePathMap().FindFile (m_file_spec, new_file_spec) ||
+                    target->GetImages().FindSourceFile (m_file_spec, new_file_spec))
                 {
-                    char resolved_path[PATH_MAX];
-                    ::snprintf(resolved_path, PATH_MAX, "%s/%s", new_path.AsCString(), m_file_spec.GetFilename().AsCString());
-                    m_file_spec = new FileSpec(resolved_path, true);
+                    m_file_spec = new_file_spec;
                     m_mod_time = m_file_spec.GetModificationTime();
                 }
             }

Modified: lldb/trunk/source/Host/macosx/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Symbols.cpp?rev=152836&r1=152835&r2=152836&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Symbols.cpp (original)
+++ lldb/trunk/source/Host/macosx/Symbols.cpp Thu Mar 15 16:01:31 2012
@@ -367,28 +367,47 @@
                         }
                     }
 
-                    if (out_exec_fspec)
+                    CFCReleaser<CFDictionaryRef> dict(::DBGCopyDSYMPropertyLists (dsym_url.get()));
+                    CFDictionaryRef uuid_dict = NULL;
+                    if (dict.get())
                     {
-                        CFCReleaser<CFDictionaryRef> dict(::DBGCopyDSYMPropertyLists (dsym_url.get()));
-                        bool success = false;
-                        if (dict.get())
+                        char uuid_cstr_buf[64];
+                        const char *uuid_cstr = uuid->GetAsCString (uuid_cstr_buf, sizeof(uuid_cstr_buf));
+                        CFCString uuid_cfstr (uuid_cstr);
+                        CFDictionaryRef uuid_dict = static_cast<CFDictionaryRef>(::CFDictionaryGetValue (dict.get(), uuid_cfstr.get()));
+                        if (uuid_dict)
                         {
-                            char uuid_cstr_buf[64];
-                            const char *uuid_cstr = uuid->GetAsCString (uuid_cstr_buf, sizeof(uuid_cstr_buf));
-                            CFCString uuid_cfstr (uuid_cstr);
-                            CFDictionaryRef uuid_dict = static_cast<CFDictionaryRef>(::CFDictionaryGetValue (dict.get(), uuid_cfstr.get()));
-                            if (uuid_dict)
+
+                            CFStringRef actual_src_cfpath = static_cast<CFStringRef>(::CFDictionaryGetValue (uuid_dict, CFSTR("DBGSourcePath")));
+                            if (actual_src_cfpath)
                             {
-                                CFStringRef exec_cf_path = static_cast<CFStringRef>(::CFDictionaryGetValue (uuid_dict, CFSTR("DBGSymbolRichExecutable")));
-                                if (exec_cf_path && ::CFStringGetFileSystemRepresentation (exec_cf_path, path, sizeof(path)))
+                                CFStringRef build_src_cfpath = static_cast<CFStringRef>(::CFDictionaryGetValue (uuid_dict, CFSTR("DBGBuildSourcePath")));
+                                if (build_src_cfpath)
                                 {
-                                    ++items_found;
-                                    out_exec_fspec->SetFile(path, path[0] == '~');
-                                    if (out_exec_fspec->Exists())
-                                        success = true;
+                                    char actual_src_path[PATH_MAX];
+                                    char build_src_path[PATH_MAX];
+                                    ::CFStringGetFileSystemRepresentation (actual_src_cfpath, actual_src_path, sizeof(actual_src_path));
+                                    ::CFStringGetFileSystemRepresentation (build_src_cfpath, build_src_path, sizeof(build_src_path));
+                                    module_spec.GetSourceMappingList().Append (ConstString(build_src_path), ConstString(actual_src_path), true);
                                 }
                             }
                         }
+                    }
+
+                    if (out_exec_fspec)
+                    {
+                        bool success = false;
+                        if (uuid_dict)
+                        {
+                            CFStringRef exec_cf_path = static_cast<CFStringRef>(::CFDictionaryGetValue (uuid_dict, CFSTR("DBGSymbolRichExecutable")));
+                            if (exec_cf_path && ::CFStringGetFileSystemRepresentation (exec_cf_path, path, sizeof(path)))
+                            {
+                                ++items_found;
+                                out_exec_fspec->SetFile(path, path[0] == '~');
+                                if (out_exec_fspec->Exists())
+                                    success = true;
+                            }
+                        }
 
                         if (!success)
                         {

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp?rev=152836&r1=152835&r2=152836&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp Thu Mar 15 16:01:31 2012
@@ -14,6 +14,7 @@
 
 #include "lldb/Core/FileSpecList.h"
 #include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/Timer.h"
 #include "lldb/Host/Host.h"
 
@@ -467,7 +468,11 @@
 }
 
 bool
-DWARFDebugLine::ParseSupportFiles(const DataExtractor& debug_line_data, const char *cu_comp_dir, dw_offset_t stmt_list, FileSpecList &support_files)
+DWARFDebugLine::ParseSupportFiles (const lldb::ModuleSP &module_sp,
+                                   const DataExtractor& debug_line_data,
+                                   const char *cu_comp_dir,
+                                   dw_offset_t stmt_list,
+                                   FileSpecList &support_files)
 {
     uint32_t offset = stmt_list + 4;    // Skip the total length
     const char * s;
@@ -537,7 +542,12 @@
             
             // We don't need to realpath files in the debug_line tables.
             FileSpec file_spec(fullpath.c_str(), false);
-            support_files.Append(file_spec);
+            
+            FileSpec remapped_file_spec;
+            if (module_sp->FindSourceFile(file_spec, remapped_file_spec))
+                support_files.Append(remapped_file_spec);
+            else
+                support_files.Append(file_spec);
         }
     }
 

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h?rev=152836&r1=152835&r2=152836&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h Thu Mar 15 16:01:31 2012
@@ -196,7 +196,7 @@
 
     static bool DumpOpcodes(lldb_private::Log *log, SymbolFileDWARF* dwarf2Data, dw_offset_t line_offset = DW_INVALID_OFFSET, uint32_t dump_flags = 0);   // If line_offset is invalid, dump everything
     static bool DumpLineTableRows(lldb_private::Log *log, SymbolFileDWARF* dwarf2Data, dw_offset_t line_offset = DW_INVALID_OFFSET);  // If line_offset is invalid, dump everything
-    static bool ParseSupportFiles(const lldb_private::DataExtractor& debug_line_data, const char *cu_comp_dir, dw_offset_t stmt_list, lldb_private::FileSpecList &support_files);
+    static bool ParseSupportFiles(const lldb::ModuleSP &module_sp, const lldb_private::DataExtractor& debug_line_data, const char *cu_comp_dir, dw_offset_t stmt_list, lldb_private::FileSpecList &support_files);
     static bool ParsePrologue(const lldb_private::DataExtractor& debug_line_data, dw_offset_t* offset_ptr, Prologue* prologue);
     static bool ParseStatementTable(const lldb_private::DataExtractor& debug_line_data, dw_offset_t* offset_ptr, State::Callback callback, void* userData);
     static dw_offset_t DumpStatementTable(lldb_private::Log *log, const lldb_private::DataExtractor& debug_line_data, const dw_offset_t line_offset);

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=152836&r1=152835&r2=152836&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Mar 15 16:01:31 2012
@@ -711,6 +711,10 @@
 {
     if (curr_cu != NULL)
     {
+        ModuleSP module_sp (m_obj_file->GetModule());
+        if (!module_sp)
+            return false;
+
         const DWARFDebugInfoEntry * cu_die = curr_cu->GetCompileUnitDIEOnly ();
         if (cu_die)
         {
@@ -736,8 +740,12 @@
                     cu_file_spec.SetFile (fullpath.c_str(), false);
                 }
 
-                compile_unit_sp.reset(new CompileUnit (m_obj_file->GetModule(), 
-                                                       curr_cu, 
+                FileSpec remapped_file_spec;
+                if (module_sp->FindSourceFile(cu_file_spec, remapped_file_spec))
+                    cu_file_spec = remapped_file_spec;
+
+                compile_unit_sp.reset(new CompileUnit (module_sp,
+                                                       curr_cu,
                                                        cu_file_spec, 
                                                        MakeUserID(curr_cu->GetOffset()),
                                                        cu_language));
@@ -926,7 +934,7 @@
         // supposed to be the compile unit itself.
         support_files.Append (*sc.comp_unit);
 
-        return DWARFDebugLine::ParseSupportFiles(get_debug_line_data(), cu_comp_dir, stmt_list, support_files);
+        return DWARFDebugLine::ParseSupportFiles(sc.comp_unit->GetModule(), get_debug_line_data(), cu_comp_dir, stmt_list, support_files);
     }
     return false;
 }

Modified: lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp?rev=152836&r1=152835&r2=152836&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp Thu Mar 15 16:01:31 2012
@@ -120,6 +120,9 @@
 SymbolVendor*
 SymbolVendorMacOSX::CreateInstance (const lldb::ModuleSP &module_sp)
 {
+    if (!module_sp)
+        return NULL;
+
     Timer scoped_timer (__PRETTY_FUNCTION__,
                         "SymbolVendorMacOSX::CreateInstance (module = %s/%s)",
                         module_sp->GetFileSpec().GetDirectory().AsCString(),
@@ -154,6 +157,10 @@
                     ModuleSpec module_spec(file_spec, module_sp->GetArchitecture());
                     module_spec.GetUUID() = module_sp->GetUUID();
                     dsym_fspec = Symbols::LocateExecutableSymbolFile (module_spec);
+                    if (module_spec.GetSourceMappingList().GetSize())
+                    {
+                        module_sp->GetSourceMappingList().Append (module_spec.GetSourceMappingList (), true);
+                    }
                 }
             }
             

Modified: lldb/trunk/source/Target/PathMappingList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/PathMappingList.cpp?rev=152836&r1=152835&r2=152836&view=diff
==============================================================================
--- lldb/trunk/source/Target/PathMappingList.cpp (original)
+++ lldb/trunk/source/Target/PathMappingList.cpp Thu Mar 15 16:01:31 2012
@@ -8,13 +8,15 @@
 //===----------------------------------------------------------------------===//
 
 // C Includes
+#include <string.h>
+
 // C++ Includes
 // Other libraries and framework includes
+// Project includes
 #include "lldb/Core/Error.h"
 #include "lldb/Core/Stream.h"
-// Project includes
+#include "lldb/Host/FileSpec.h"
 #include "lldb/Target/PathMappingList.h"
-#include <string.h>
 
 using namespace lldb;
 using namespace lldb_private;
@@ -22,6 +24,13 @@
 //----------------------------------------------------------------------
 // PathMappingList constructor
 //----------------------------------------------------------------------
+PathMappingList::PathMappingList () :
+    m_pairs (),
+    m_callback (NULL),
+    m_callback_baton (NULL)
+{
+}
+
 PathMappingList::PathMappingList 
 (
     ChangedCallback callback,
@@ -73,6 +82,19 @@
 }
 
 void
+PathMappingList::Append (const PathMappingList &rhs, bool notify)
+{
+    if (!rhs.m_pairs.empty())
+    {
+        const_iterator pos, end = rhs.m_pairs.end();
+        for (pos = rhs.m_pairs.begin(); pos != end; ++pos)
+            m_pairs.push_back(*pos);
+        if (notify && m_callback)
+            m_callback (*this, m_callback_baton);
+    }
+}
+
+void
 PathMappingList::Insert (const ConstString &path,
                          const ConstString &replacement,
                          uint32_t index,
@@ -131,14 +153,8 @@
         m_callback (*this, m_callback_baton);
 }
 
-size_t
-PathMappingList::GetSize ()
-{
-    return m_pairs.size();
-}
-
 bool
-PathMappingList::RemapPath (const ConstString &path, ConstString &new_path)
+PathMappingList::RemapPath (const ConstString &path, ConstString &new_path) const
 {
     const_iterator pos, end = m_pairs.end();
     for (pos = m_pairs.begin(); pos != end; ++pos)
@@ -157,6 +173,41 @@
 }
 
 bool
+PathMappingList::FindFile (const FileSpec &orig_spec, FileSpec &new_spec) const
+{
+    if (!m_pairs.empty())
+    {
+        char orig_path[PATH_MAX];
+        char new_path[PATH_MAX];
+        const size_t orig_path_len = orig_spec.GetPath (orig_path, sizeof(orig_path));
+        if (orig_path_len > 0)
+        {
+            const_iterator pos, end = m_pairs.end();
+            for (pos = m_pairs.begin(); pos != end; ++pos)
+            {
+                const size_t prefix_len = pos->first.GetLength();
+                
+                if (orig_path_len >= prefix_len)
+                {
+                    if (::strncmp (pos->first.GetCString(), orig_path, prefix_len) == 0)
+                    {
+                        const size_t new_path_len = snprintf(new_path, sizeof(new_path), "%s/%s", pos->second.GetCString(), orig_path + prefix_len);
+                        if (new_path_len < sizeof(new_path))
+                        {
+                            new_spec.SetFile (new_path, true);
+                            if (new_spec.Exists())
+                                return true;
+                        }
+                    }
+                }
+            }
+        }
+    }
+    new_spec.Clear();
+    return false;
+}
+
+bool
 PathMappingList::Replace (const ConstString &path, const ConstString &new_path, bool notify)
 {
     uint32_t idx = FindIndexForPath (path);





More information about the lldb-commits mailing list