[Lldb-commits] [lldb] r153059 - in /lldb/trunk: include/lldb/Core/Module.h include/lldb/Target/PathMappingList.h source/Core/Module.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Target/PathMappingList.cpp
Greg Clayton
gclayton at apple.com
Mon Mar 19 15:22:42 PDT 2012
Author: gclayton
Date: Mon Mar 19 17:22:41 2012
New Revision: 153059
URL: http://llvm.org/viewvc/llvm-project?rev=153059&view=rev
Log:
<rdar://problem/11072382>
Fixed a case where the source path remappings on the module were too expensive to
use when we try to verify (stat the file system) that the remapped path points to
a valid file. Now we will use the lldb_private::Module path remappings (if any) when
parsing the debug info without verifying that the paths exist so we don't slow down
line table parsing speeds.
Modified:
lldb/trunk/include/lldb/Core/Module.h
lldb/trunk/include/lldb/Target/PathMappingList.h
lldb/trunk/source/Core/Module.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.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=153059&r1=153058&r2=153059&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Module.h (original)
+++ lldb/trunk/include/lldb/Core/Module.h Mon Mar 19 17:22:41 2012
@@ -1020,9 +1020,50 @@
return m_source_mappings;
}
+ //------------------------------------------------------------------
+ /// Finds a source file given a file spec using the module source
+ /// path remappings (if any).
+ ///
+ /// Tries to resolve \a orig_spec by checking the module source path
+ /// remappings. It makes sure the file exists, so this call can be
+ /// expensive if the remappings are on a network file system, so
+ /// use this function sparingly (not in a tight debug info parsing
+ /// loop).
+ ///
+ /// @param[in] orig_spec
+ /// The original source file path to try and remap.
+ ///
+ /// @param[out] new_spec
+ /// The newly remapped filespec that is guaranteed to exist.
+ ///
+ /// @return
+ /// /b true if \a orig_spec was successfully located and
+ /// \a new_spec is filled in with an existing file spec,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
bool
FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const;
+ //------------------------------------------------------------------
+ /// Remaps a source file given \a path into \a new_path.
+ ///
+ /// Remaps \a path if any source remappings match. This function
+ /// does NOT stat the file system so it can be used in tight loops
+ /// where debug info is being parsed.
+ ///
+ /// @param[in] path
+ /// The original source file path to try and remap.
+ ///
+ /// @param[out] new_path
+ /// The newly remapped filespec that is may or may not exist.
+ ///
+ /// @return
+ /// /b true if \a path was successfully located and \a new_path
+ /// is filled in with a new source path, \b false otherwise.
+ //------------------------------------------------------------------
+ bool
+ RemapSourceFile (const char *path, std::string &new_path) const;
+
protected:
//------------------------------------------------------------------
// Member Variables
Modified: lldb/trunk/include/lldb/Target/PathMappingList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/PathMappingList.h?rev=153059&r1=153058&r2=153059&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/PathMappingList.h (original)
+++ lldb/trunk/include/lldb/Target/PathMappingList.h Mon Mar 19 17:22:41 2012
@@ -86,6 +86,47 @@
bool
RemapPath (const ConstString &path, ConstString &new_path) const;
+ //------------------------------------------------------------------
+ /// Remaps a source file given \a path into \a new_path.
+ ///
+ /// Remaps \a path if any source remappings match. This function
+ /// does NOT stat the file system so it can be used in tight loops
+ /// where debug info is being parsed.
+ ///
+ /// @param[in] path
+ /// The original source file path to try and remap.
+ ///
+ /// @param[out] new_path
+ /// The newly remapped filespec that is may or may not exist.
+ ///
+ /// @return
+ /// /b true if \a path was successfully located and \a new_path
+ /// is filled in with a new source path, \b false otherwise.
+ //------------------------------------------------------------------
+ bool
+ RemapPath (const char *path, std::string &new_path) const;
+
+
+ //------------------------------------------------------------------
+ /// Finds a source file given a file spec using the path remappings.
+ ///
+ /// Tries to resolve \a orig_spec by checking the path remappings.
+ /// It makes sure the file exists by checking with the file system,
+ /// so this call can be expensive if the remappings are on a network
+ /// or are even on the local file system, so use this function
+ /// sparingly (not in a tight debug info parsing loop).
+ ///
+ /// @param[in] orig_spec
+ /// The original source file path to try and remap.
+ ///
+ /// @param[out] new_spec
+ /// The newly remapped filespec that is guaranteed to exist.
+ ///
+ /// @return
+ /// /b true if \a orig_spec was successfully located and
+ /// \a new_spec is filled in with an existing file spec,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
bool
FindFile (const FileSpec &orig_spec, FileSpec &new_spec) const;
Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=153059&r1=153058&r2=153059&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Mon Mar 19 17:22:41 2012
@@ -1165,3 +1165,10 @@
return m_source_mappings.FindFile (orig_spec, new_spec);
}
+bool
+Module::RemapSourceFile (const char *path, std::string &new_path) const
+{
+ Mutex::Locker locker (m_mutex);
+ return m_source_mappings.RemapPath(path, new_path);
+}
+
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=153059&r1=153058&r2=153059&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp Mon Mar 19 17:22:41 2012
@@ -497,6 +497,7 @@
break;
}
std::string fullpath;
+ std::string remapped_fullpath;
while (offset < end_prologue_offset)
{
const char* path = debug_line_data.GetCStr( &offset );
@@ -509,7 +510,10 @@
if (path[0] == '/')
{
// The path starts with a directory delimiter, so we are done.
- fullpath = path;
+ if (module_sp->RemapSourceFile (path, fullpath))
+ support_files.Append(FileSpec (fullpath.c_str(), false));
+ else
+ support_files.Append(FileSpec (path, false));
}
else
{
@@ -538,16 +542,12 @@
fullpath += '/';
}
fullpath += path;
+ if (module_sp->RemapSourceFile (fullpath.c_str(), remapped_fullpath))
+ support_files.Append(FileSpec (remapped_fullpath.c_str(), false));
+ else
+ support_files.Append(FileSpec (fullpath.c_str(), false));
}
- // We don't need to realpath files in the debug_line tables.
- FileSpec file_spec(fullpath.c_str(), false);
-
- 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/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=153059&r1=153058&r2=153059&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Mon Mar 19 17:22:41 2012
@@ -723,13 +723,17 @@
LanguageType cu_language = (LanguageType)cu_die->GetAttributeValueAsUnsigned(this, curr_cu, DW_AT_language, 0);
if (cu_die_name)
{
+ std::string ramapped_file;
FileSpec cu_file_spec;
if (cu_die_name[0] == '/' || cu_comp_dir == NULL || cu_comp_dir[0] == '\0')
{
// If we have a full path to the compile unit, we don't need to resolve
// the file. This can be expensive e.g. when the source files are NFS mounted.
- cu_file_spec.SetFile (cu_die_name, false);
+ if (module_sp->RemapSourceFile(cu_die_name, ramapped_file))
+ cu_file_spec.SetFile (ramapped_file.c_str(), false);
+ else
+ cu_file_spec.SetFile (cu_die_name, false);
}
else
{
@@ -737,13 +741,12 @@
if (*fullpath.rbegin() != '/')
fullpath += '/';
fullpath += cu_die_name;
- cu_file_spec.SetFile (fullpath.c_str(), false);
+ if (module_sp->RemapSourceFile (fullpath.c_str(), ramapped_file))
+ cu_file_spec.SetFile (ramapped_file.c_str(), false);
+ else
+ cu_file_spec.SetFile (fullpath.c_str(), false);
}
- 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,
Modified: lldb/trunk/source/Target/PathMappingList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/PathMappingList.cpp?rev=153059&r1=153058&r2=153059&view=diff
==============================================================================
--- lldb/trunk/source/Target/PathMappingList.cpp (original)
+++ lldb/trunk/source/Target/PathMappingList.cpp Mon Mar 19 17:22:41 2012
@@ -174,6 +174,27 @@
}
bool
+PathMappingList::RemapPath (const char *path, std::string &new_path) const
+{
+ if (!m_pairs.empty() || path == NULL || path[0] == '\0')
+ return false;
+
+ const_iterator pos, end = m_pairs.end();
+ for (pos = m_pairs.begin(); pos != end; ++pos)
+ {
+ const size_t prefix_len = pos->first.GetLength();
+
+ if (::strncmp (pos->first.GetCString(), path, prefix_len) == 0)
+ {
+ new_path = pos->second.GetCString();
+ new_path.append(path + prefix_len);
+ return true;
+ }
+ }
+ return false;
+}
+
+bool
PathMappingList::FindFile (const FileSpec &orig_spec, FileSpec &new_spec) const
{
if (!m_pairs.empty())
More information about the lldb-commits
mailing list