[Lldb-commits] [lldb] r114054 - in /lldb/trunk: include/lldb/Core/FileSpec.h source/Core/FileSpec.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Jim Ingham
jingham at apple.com
Wed Sep 15 17:57:34 PDT 2010
Author: jingham
Date: Wed Sep 15 19:57:33 2010
New Revision: 114054
URL: http://llvm.org/viewvc/llvm-project?rev=114054&view=rev
Log:
Add the ability to not resolve the name passed to FileSpec. Then don't resolve the names of compilation units found in DWARF.
Modified:
lldb/trunk/include/lldb/Core/FileSpec.h
lldb/trunk/source/Core/FileSpec.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Modified: lldb/trunk/include/lldb/Core/FileSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FileSpec.h?rev=114054&r1=114053&r2=114054&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FileSpec.h (original)
+++ lldb/trunk/include/lldb/Core/FileSpec.h Wed Sep 15 19:57:33 2010
@@ -66,6 +66,23 @@
explicit FileSpec (const char *path);
//------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Takes an optional full path to a file. If \a path is valid,
+ /// this function will call FileSpec::SetFile (\a path).
+ ///
+ /// @param[in] path
+ /// The full or partial path to a file.
+ ///
+ /// @param[in] resolve_path
+ /// If \b true, then we resolve the path with realpath,
+ /// if \b false we trust the path is in canonical form already.
+ ///
+ /// @see FileSpec::SetFile ()
+ //------------------------------------------------------------------
+ explicit FileSpec (const char *path, bool resolve_path);
+
+ //------------------------------------------------------------------
/// Copy constructor
///
/// Makes a copy of the uniqued directory and filename strings from
@@ -275,6 +292,17 @@
//------------------------------------------------------------------
bool
ResolveExecutableLocation ();
+
+
+ //------------------------------------------------------------------
+ /// Canonicalize this file path (basically running the static Resolve method on it).
+ /// Useful if you asked us not to resolve the file path when you set the file.
+ ///
+ /// @return
+ /// None.
+ //------------------------------------------------------------------
+ bool
+ ResolvePath ();
uint64_t
GetByteSize() const;
@@ -429,9 +457,13 @@
///
/// @param[in] path
/// A full, partial, or relative path to a file.
+ ///
+ /// @param[in] resolve
+ /// If \b true, then we will try to resolve links the path using
+ /// the static FileSpec::Resolve.
//------------------------------------------------------------------
void
- SetFile (const char *path);
+ SetFile (const char *path, bool resolve = true);
//------------------------------------------------------------------
/// Read the file into an array of strings, one per line.
Modified: lldb/trunk/source/Core/FileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpec.cpp?rev=114054&r1=114053&r2=114054&view=diff
==============================================================================
--- lldb/trunk/source/Core/FileSpec.cpp (original)
+++ lldb/trunk/source/Core/FileSpec.cpp Wed Sep 15 19:57:33 2010
@@ -183,6 +183,18 @@
}
//------------------------------------------------------------------
+// Default constructor that can take an optional full path to a
+// file on disk.
+//------------------------------------------------------------------
+FileSpec::FileSpec(const char *pathname, bool resolve_path) :
+ m_directory(),
+ m_filename()
+{
+ if (pathname && pathname[0])
+ SetFile(pathname, resolve_path);
+}
+
+//------------------------------------------------------------------
// Copy constructor
//------------------------------------------------------------------
FileSpec::FileSpec(const FileSpec& rhs) :
@@ -223,14 +235,13 @@
return *this;
}
-
//------------------------------------------------------------------
// Update the contents of this object with a new path. The path will
// be split up into a directory and filename and stored as uniqued
// string values for quick comparison and efficient memory usage.
//------------------------------------------------------------------
void
-FileSpec::SetFile(const char *pathname)
+FileSpec::SetFile(const char *pathname, bool resolve)
{
m_filename.Clear();
m_directory.Clear();
@@ -238,8 +249,22 @@
return;
char resolved_path[PATH_MAX];
+ bool path_fit = true;
+
+ if (resolve)
+ {
+ path_fit = (FileSpec::Resolve (pathname, resolved_path, sizeof(resolved_path)) < sizeof(resolved_path) - 1);
+ }
+ else
+ {
+ if (strlen (pathname) > sizeof(resolved_path) - 1)
+ path_fit = false;
+ else
+ strcpy (resolved_path, pathname);
+ }
- if (FileSpec::Resolve (pathname, resolved_path, sizeof(resolved_path)) < sizeof(resolved_path) - 1)
+
+ if (path_fit)
{
char *filename = ::basename (resolved_path);
if (filename)
@@ -453,6 +478,17 @@
return false;
}
+bool
+FileSpec::ResolvePath ()
+{
+ char path_buf[PATH_MAX];
+
+ if (!GetPath (path_buf, PATH_MAX))
+ return false;
+ SetFile (path_buf, true);
+ return true;
+}
+
uint64_t
FileSpec::GetByteSize() const
{
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=114054&r1=114053&r2=114054&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp Wed Sep 15 19:57:33 2010
@@ -525,7 +525,9 @@
}
fullpath += path;
}
- FileSpec file_spec(fullpath.c_str());
+
+ // We don't need to realpath files in the debug_line tables.
+ FileSpec file_spec(fullpath.c_str(), false);
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=114054&r1=114053&r2=114054&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Sep 15 19:57:33 2010
@@ -488,9 +488,13 @@
LanguageType class_language = (LanguageType)cu_die->GetAttributeValueAsUnsigned(this, cu, DW_AT_language, 0);
if (cu_die_name)
{
+ FileSpec cu_file_spec;
+
if (cu_die_name[0] == '/' || cu_comp_dir == NULL && cu_comp_dir[0])
{
- compile_unit_sp.reset(new CompileUnit(m_obj_file->GetModule(), cu, cu_die_name, cu->GetOffset(), class_language));
+ // 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);
}
else
{
@@ -498,10 +502,10 @@
if (*fullpath.rbegin() != '/')
fullpath += '/';
fullpath += cu_die_name;
-
- compile_unit_sp.reset(new CompileUnit(m_obj_file->GetModule(), cu, fullpath.c_str(), cu->GetOffset(), class_language));
+ cu_file_spec.SetFile (fullpath.c_str(), false);
}
+ compile_unit_sp.reset(new CompileUnit(m_obj_file->GetModule(), cu, cu_file_spec, cu->GetOffset(), class_language));
if (compile_unit_sp.get())
{
cu->SetUserData(compile_unit_sp.get());
More information about the lldb-commits
mailing list