Index: source/Host/common/FileSpec.cpp =================================================================== --- source/Host/common/FileSpec.cpp +++ source/Host/common/FileSpec.cpp @@ -164,7 +164,32 @@ ResolveUsername(path); #endif // #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER + // Save a copy of the original path that's passed in + char original_path[PATH_MAX]; + ::strncpy (original_path, path.data(), sizeof (original_path)); + if (path.size() < sizeof (original_path)) + original_path[path.size()] = '\0'; + else + original_path[sizeof (original_path) - 1] = '\0'; + llvm::sys::fs::make_absolute(path); + + // Get the resolved path as a char*, call stat() to see if it exists + char resolved_path[PATH_MAX]; + ::strncpy (resolved_path, path.data(), sizeof (resolved_path)); + if (path.size() < sizeof (original_path)) + resolved_path[path.size()] = '\0'; + else + resolved_path[sizeof (resolved_path) - 1] = '\0'; + + struct stat file_stats; + if (::stat (resolved_path, &file_stats) != 0) + { + // resolved path was a bust - we got a path to a file that doesn't exist + // Return the original path instead + path.resize (strlen (original_path) + 1); + memcpy (path.data(), original_path, strlen (original_path) + 1); + } } FileSpec::FileSpec() :