Fixed an issue where we were resolving paths when we should have been.
So the issue here was that we have lldb_private::FileSpec that by default was
always resolving a path when using the:
FileSpec::FileSpec (const char *path);
and in the:
void FileSpec::SetFile(const char *pathname, bool resolve = true);
This isn't what we want in many many cases. One example is you have "/tmp" on
your file system which is really "/private/tmp". You compile code in that
directory and end up with debug info that mentions "/tmp/file.c". Then you
type:
(lldb) breakpoint set --file file.c --line 5
If your current working directory is "/tmp", then "file.c" would be turned
into "/private/tmp/file.c" which won't match anything in the debug info.
Also, it should have been just a FileSpec with no directory and a filename
of "file.c" which could (and should) potentially match any instances of "file.c"
in the debug info.
So I removed the constructor that just takes a path:
FileSpec::FileSpec (const char *path); // REMOVED
You must now use the other constructor that has a "bool resolve" parameter that you must always supply:
FileSpec::FileSpec (const char *path, bool resolve);
I also removed the default parameter to SetFile():
void FileSpec::SetFile(const char *pathname, bool resolve);
And fixed all of the code to use the right settings.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@116944 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Host/macosx/Symbols.cpp b/source/Host/macosx/Symbols.cpp
index f59f35e..cc39319 100644
--- a/source/Host/macosx/Symbols.cpp
+++ b/source/Host/macosx/Symbols.cpp
@@ -239,8 +239,7 @@
DIR* dirp = ::opendir(path);
if (dirp != NULL)
{
- const size_t path_len = strlen(path);
- const int bytes_left = sizeof(path) - path_len - 1;
+ dsym_fspec.GetDirectory().SetCString(path);
struct dirent* dp;
while ((dp = readdir(dirp)) != NULL)
{
@@ -256,9 +255,7 @@
if (dp->d_type == DT_REG || dp->d_type == DT_UNKNOWN)
{
- ::strncpy (&path[path_len], dp->d_name, bytes_left);
-
- dsym_fspec.SetFile(path);
+ dsym_fspec.GetFilename().SetCString(dp->d_name);
if (FileAtPathContainsArchAndUUID (dsym_fspec, arch, uuid))
return dsym_fspec;
}
@@ -334,7 +331,7 @@
{
if (::CFURLGetFileSystemRepresentation (dsym_url.get(), true, (UInt8*)path, sizeof(path)-1))
{
- out_dsym_fspec->SetFile(path);
+ out_dsym_fspec->SetFile(path, false);
if (out_dsym_fspec->GetFileType () == FileSpec::eFileTypeDirectory)
{
@@ -358,7 +355,7 @@
if (exec_cf_path && ::CFStringGetFileSystemRepresentation (exec_cf_path, path, sizeof(path)))
{
++items_found;
- out_dsym_fspec->SetFile(path);
+ out_dsym_fspec->SetFile(path, false);
}
}
}
@@ -384,7 +381,7 @@
strncat(path, ".dSYM/Contents/Resources/DWARF/", sizeof(path));
strncat(path, exec_fspec->GetFilename().AsCString(), sizeof(path));
- dsym_fspec.SetFile(path);
+ dsym_fspec.SetFile(path, false);
if (FileAtPathContainsArchAndUUID (dsym_fspec, arch, uuid))
{
@@ -403,7 +400,7 @@
*next_slash = '\0';
strncat(path, ".dSYM/Contents/Resources/DWARF/", sizeof(path));
strncat(path, exec_fspec->GetFilename().AsCString(), sizeof(path));
- dsym_fspec.SetFile(path);
+ dsym_fspec.SetFile(path, false);
if (dsym_fspec.Exists())
return true;
else