NameMatch process_name_match_type)
: m_match_info(), m_name_match_type(process_name_match_type),
m_match_all_users(false) {
- m_match_info.GetExecutableFile().SetFile(process_name, false,
+ m_match_info.GetExecutableFile().SetFile(process_name,
FileSpec::Style::native);
}
///
/// Takes a path to a file which can be just a filename, or a full path. If
/// \a path is not nullptr or empty, this function will call
- /// FileSpec::SetFile (const char *path, bool resolve).
+ /// FileSpec::SetFile (const char *path).
///
/// @param[in] path
/// The full or partial path to a file.
///
- /// @param[in] resolve_path
- /// If \b true, then we resolve the path, removing stray ../.. and so
- /// forth,
- /// if \b false we trust the path is in canonical form already.
+ /// @param[in] style
+ /// The style of the path
///
- /// @see FileSpec::SetFile (const char *path, bool resolve)
+ /// @see FileSpec::SetFile (const char *path)
//------------------------------------------------------------------
- explicit FileSpec(llvm::StringRef path, bool resolve_path,
- Style style = Style::native);
+ explicit FileSpec(llvm::StringRef path, Style style = Style::native);
- explicit FileSpec(llvm::StringRef path, bool resolve_path,
- const llvm::Triple &Triple);
+ explicit FileSpec(llvm::StringRef path, const llvm::Triple &Triple);
//------------------------------------------------------------------
/// Copy constructor
//------------------------------------------------------------------
void Dump(Stream *s) const;
- //------------------------------------------------------------------
- /// Canonicalize this file path (basically running the static
- /// FileSpec::Resolve method on it). Useful if you asked us not to resolve
- /// the file path when you set the file.
- //------------------------------------------------------------------
- bool ResolvePath();
-
Style GetPathStyle() const;
//------------------------------------------------------------------
bool IsAbsolute() const;
/// Temporary helper for FileSystem change.
- void SetPath(llvm::StringRef p) { SetFile(p, false); }
+ void SetPath(llvm::StringRef p) { SetFile(p); }
//------------------------------------------------------------------
/// Extract the full path to the file.
/// If \b true, then we will try to resolve links the path using
/// the static FileSpec::Resolve.
//------------------------------------------------------------------
- void SetFile(llvm::StringRef path, bool resolve_path, Style style);
+ void SetFile(llvm::StringRef path, Style style);
- void SetFile(llvm::StringRef path, bool resolve_path,
- const llvm::Triple &Triple);
+ void SetFile(llvm::StringRef path, const llvm::Triple &Triple);
bool IsResolved() const { return m_is_resolved; }
//------------------------------------------------------------------
void SetIsResolved(bool is_resolved) { m_is_resolved = is_resolved; }
- //------------------------------------------------------------------
- /// Resolves user name and links in \a path, and overwrites the input
- /// argument with the resolved path.
- ///
- /// @param[in] path
- /// Input path to be resolved, in the form of a llvm::SmallString or
- /// similar.
- //------------------------------------------------------------------
- static void Resolve(llvm::SmallVectorImpl<char> &path);
-
FileSpec CopyByAppendingPathComponent(llvm::StringRef component) const;
FileSpec CopyByRemovingLastPathComponent() const;
//------------------------------------------------------------------
// Convenience method for setting the file without changing the style.
//------------------------------------------------------------------
- void SetFile(llvm::StringRef path, bool resolve_path);
+ void SetFile(llvm::StringRef path);
//------------------------------------------------------------------
// Member variables
SBAttachInfo::SBAttachInfo(const char *path, bool wait_for)
: m_opaque_sp(new ProcessAttachInfo()) {
if (path && path[0])
- m_opaque_sp->GetExecutableFile().SetFile(path, false,
- FileSpec::Style::native);
+ m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native);
m_opaque_sp->SetWaitForLaunch(wait_for);
}
SBAttachInfo::SBAttachInfo(const char *path, bool wait_for, bool async)
: m_opaque_sp(new ProcessAttachInfo()) {
if (path && path[0])
- m_opaque_sp->GetExecutableFile().SetFile(path, false,
- FileSpec::Style::native);
+ m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native);
m_opaque_sp->SetWaitForLaunch(wait_for);
m_opaque_sp->SetAsync(async);
}
void SBAttachInfo::SetExecutable(const char *path) {
if (path && path[0])
- m_opaque_sp->GetExecutableFile().SetFile(path, false,
- FileSpec::Style::native);
+ m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native);
else
m_opaque_sp->GetExecutableFile().Clear();
}
m_opaque_sp->GetPlatformList().GetSelectedPlatform().get(), arch_name);
TargetSP target_sp(
m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture(
- FileSpec(filename, false), arch_name ? &arch : nullptr));
+ FileSpec(filename), arch_name ? &arch : nullptr));
sb_target.SetSP(target_sp);
}
return sb_target;
: m_opaque_ap(new lldb_private::FileSpec(fspec)) {}
// Deprecated!!!
-SBFileSpec::SBFileSpec(const char *path)
- : m_opaque_ap(new FileSpec(path, true)) {}
+SBFileSpec::SBFileSpec(const char *path) : m_opaque_ap(new FileSpec(path)) {
+ FileSystem::Instance().Resolve(*m_opaque_ap);
+}
SBFileSpec::SBFileSpec(const char *path, bool resolve)
- : m_opaque_ap(new FileSpec(path, resolve)) {}
+ : m_opaque_ap(new FileSpec(path)) {
+ if (resolve)
+ FileSystem::Instance().Resolve(*m_opaque_ap);
+}
SBFileSpec::~SBFileSpec() {}
int SBFileSpec::ResolvePath(const char *src_path, char *dst_path,
size_t dst_len) {
llvm::SmallString<64> result(src_path);
- lldb_private::FileSpec::Resolve(result);
+ FileSystem::Instance().Resolve(result);
::snprintf(dst_path, dst_len, "%s", result.c_str());
return std::min(dst_len - 1, result.size());
}
#include "Plugins/ScriptInterpreter/Python/lldb-python.h"
#endif
-#include "lldb/API/SBHostOS.h"
#include "lldb/API/SBError.h"
+#include "lldb/API/SBHostOS.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/HostNativeThread.h"
llvm::SmallString<64> home_dir_path;
llvm::sys::path::home_directory(home_dir_path);
- FileSpec homedir(home_dir_path.c_str(), true);
+ FileSpec homedir(home_dir_path.c_str());
+ FileSystem::Instance().Resolve(homedir);
sb_fspec.SetFileSpec(homedir);
return sb_fspec;
}
void SBLaunchInfo::SetWorkingDirectory(const char *working_dir) {
- m_opaque_sp->SetWorkingDirectory(FileSpec{working_dir, false});
+ m_opaque_sp->SetWorkingDirectory(FileSpec(working_dir));
}
uint32_t SBLaunchInfo::GetLaunchFlags() {
}
void SBLaunchInfo::SetShell(const char *path) {
- m_opaque_sp->SetShell(FileSpec(path, false));
+ m_opaque_sp->SetShell(FileSpec(path));
}
bool SBLaunchInfo::GetShellExpandArguments() {
bool SBLaunchInfo::AddOpenFileAction(int fd, const char *path, bool read,
bool write) {
- return m_opaque_sp->AppendOpenFileAction(fd, FileSpec{path, false}, read,
- write);
+ return m_opaque_sp->AppendOpenFileAction(fd, FileSpec(path), read, write);
}
bool SBLaunchInfo::AddSuppressFileAction(int fd, bool read, bool write) {
SBModuleSpecList SBModuleSpecList::GetModuleSpecifications(const char *path) {
SBModuleSpecList specs;
- FileSpec file_spec(path, true);
+ FileSpec file_spec(path);
+ FileSystem::Instance().Resolve(file_spec);
Host::ResolveExecutableInBundle(file_spec);
ObjectFile::GetModuleSpecifications(file_spec, 0, 0, *specs.m_opaque_ap);
return specs;
PlatformSP platform_sp(GetSP());
if (platform_sp) {
if (path)
- platform_sp->SetWorkingDirectory(FileSpec{path, false});
+ platform_sp->SetWorkingDirectory(FileSpec(path));
else
- platform_sp->SetWorkingDirectory(FileSpec{});
+ platform_sp->SetWorkingDirectory(FileSpec());
return true;
}
return false;
if (working_dir)
shell_command.SetWorkingDirectory(working_dir);
}
- return platform_sp->RunShellCommand(command, FileSpec{working_dir, false},
+ return platform_sp->RunShellCommand(command, FileSpec(working_dir),
&shell_command.m_opaque_ptr->m_status,
&shell_command.m_opaque_ptr->m_signo,
&shell_command.m_opaque_ptr->m_output,
PlatformSP platform_sp(GetSP());
if (platform_sp) {
sb_error.ref() =
- platform_sp->MakeDirectory(FileSpec{path, false}, file_permissions);
+ platform_sp->MakeDirectory(FileSpec(path), file_permissions);
} else {
sb_error.SetErrorString("invalid platform");
}
PlatformSP platform_sp(GetSP());
if (platform_sp) {
uint32_t file_permissions = 0;
- platform_sp->GetFilePermissions(FileSpec{path, false}, file_permissions);
+ platform_sp->GetFilePermissions(FileSpec(path), file_permissions);
return file_permissions;
}
return 0;
SBError sb_error;
PlatformSP platform_sp(GetSP());
if (platform_sp) {
- sb_error.ref() = platform_sp->SetFilePermissions(FileSpec{path, false},
- file_permissions);
+ sb_error.ref() =
+ platform_sp->SetFilePermissions(FileSpec(path), file_permissions);
} else {
sb_error.SetErrorString("invalid platform");
}
if (process_sp->GetState() == eStateConnected) {
if (stop_at_entry)
launch_flags |= eLaunchFlagStopAtEntry;
- ProcessLaunchInfo launch_info(
- FileSpec{stdin_path, false}, FileSpec{stdout_path, false},
- FileSpec{stderr_path, false}, FileSpec{working_directory, false},
- launch_flags);
+ ProcessLaunchInfo launch_info(FileSpec(stdin_path), FileSpec(stdout_path),
+ FileSpec(stderr_path),
+ FileSpec(working_directory), launch_flags);
Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer();
if (exe_module)
launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
return error;
}
- FileSpec core_file(file_name, false);
+ FileSpec core_file(file_name);
error.ref() = PluginManager::SaveCore(process_sp, core_file);
return error;
}
SBProcess sb_process;
TargetSP target_sp(GetSP());
if (target_sp) {
- FileSpec filespec(core_file, true);
+ FileSpec filespec(core_file);
+ FileSystem::Instance().Resolve(filespec);
ProcessSP process_sp(target_sp->CreateProcess(
target_sp->GetDebugger().GetListener(), "", &filespec));
if (process_sp) {
if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO"))
launch_flags |= eLaunchFlagDisableSTDIO;
- ProcessLaunchInfo launch_info(
- FileSpec{stdin_path, false}, FileSpec{stdout_path, false},
- FileSpec{stderr_path, false}, FileSpec{working_directory, false},
- launch_flags);
+ ProcessLaunchInfo launch_info(FileSpec(stdin_path), FileSpec(stdout_path),
+ FileSpec(stderr_path),
+ FileSpec(working_directory), launch_flags);
Module *exe_module = target_sp->GetExecutableModulePointer();
if (exe_module)
if (name && target_sp) {
ProcessAttachInfo attach_info;
- attach_info.GetExecutableFile().SetFile(name, false,
- FileSpec::Style::native);
+ attach_info.GetExecutableFile().SetFile(name, FileSpec::Style::native);
attach_info.SetWaitForLaunch(wait_for);
if (listener.IsValid())
attach_info.SetListener(listener.GetSP());
const lldb::addr_t offset = 0;
if (module_name && module_name[0]) {
FileSpecList module_spec_list;
- module_spec_list.Append(FileSpec(module_name, false));
+ module_spec_list.Append(FileSpec(module_name));
sb_bp = target_sp->CreateBreakpoint(
&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto,
eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
SBFileSpecList module_spec_list;
SBFileSpecList comp_unit_list;
if (module_name && module_name[0]) {
- module_spec_list.Append(FileSpec(module_name, false));
+ module_spec_list.Append(FileSpec(module_name));
}
return BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown,
module_spec_list, comp_unit_list);
SBFileSpecList module_spec_list;
if (module_name && module_name[0]) {
- module_spec_list.Append(FileSpec(module_name, false));
+ module_spec_list.Append(FileSpec(module_name));
}
SBFileSpecList source_file_list;
if (target_sp) {
ModuleSpec module_spec;
if (path)
- module_spec.GetFileSpec().SetFile(path, false, FileSpec::Style::native);
+ module_spec.GetFileSpec().SetFile(path, FileSpec::Style::native);
if (uuid_cstr)
module_spec.GetUUID().SetFromStringRef(uuid_cstr);
module_spec.GetArchitecture() = target_sp->GetArchitecture();
if (symfile)
- module_spec.GetSymbolFileSpec().SetFile(symfile, false,
- FileSpec::Style::native);
+ module_spec.GetSymbolFileSpec().SetFile(symfile, FileSpec::Style::native);
sb_module.SetSP(target_sp->GetSharedModule(module_spec));
}
error.SetErrorString("BRA::CFSD: Couldn't read module name entry.");
return nullptr;
}
- module_filespec.SetFile(module_name, false, FileSpec::Style::native);
+ module_filespec.SetFile(module_name, FileSpec::Style::native);
}
return new BreakpointResolverAddress(bkpt, address, module_filespec);
}
return nullptr;
}
- FileSpec file_spec(filename, false);
+ FileSpec file_spec(filename);
return new BreakpointResolverFileLine(bkpt, file_spec, line_no, column,
offset, check_inlines, skip_prologue,
CompletionRequest &request)
: CommandCompletions::Completer(interpreter, request),
m_include_support_files(include_support_files), m_matching_files() {
- FileSpec partial_spec(m_request.GetCursorArgumentPrefix(), false);
+ FileSpec partial_spec(m_request.GetCursorArgumentPrefix());
m_file_name = partial_spec.GetFilename().GetCString();
m_dir_name = partial_spec.GetDirectory().GetCString();
}
CommandCompletions::ModuleCompleter::ModuleCompleter(
CommandInterpreter &interpreter, CompletionRequest &request)
: CommandCompletions::Completer(interpreter, request) {
- FileSpec partial_spec(m_request.GetCursorArgumentPrefix(), false);
+ FileSpec partial_spec(m_request.GetCursorArgumentPrefix());
m_file_name = partial_spec.GetFilename().GetCString();
m_dir_name = partial_spec.GetDirectory().GetCString();
}
} break;
case 'f':
- m_filenames.AppendIfUnique(FileSpec(option_arg, false));
+ m_filenames.AppendIfUnique(FileSpec(option_arg));
break;
case 'F':
break;
case 's':
- m_modules.AppendIfUnique(FileSpec(option_arg, false));
+ m_modules.AppendIfUnique(FileSpec(option_arg));
break;
case 'S':
std::unique_lock<std::recursive_mutex> lock;
target->GetBreakpointList().GetListMutex(lock);
- FileSpec input_spec(m_options.m_filename, true);
+ FileSpec input_spec(m_options.m_filename);
+ FileSystem::Instance().Resolve(input_spec);
BreakpointIDList new_bps;
Status error = target->CreateBreakpointsFromFile(
input_spec, m_options.m_names, new_bps);
return false;
}
}
- Status error = target->SerializeBreakpointsToFile(
- FileSpec(m_options.m_filename, true), valid_bp_ids, m_options.m_append);
+ FileSpec file_spec(m_options.m_filename);
+ FileSystem::Instance().Resolve(file_spec);
+ Status error = target->SerializeBreakpointsToFile(file_spec, valid_bp_ids,
+ m_options.m_append);
if (!error.Success()) {
result.AppendErrorWithFormat("error serializing breakpoints: %s.",
error.AsCString());
return false;
}
- FileSpec cmd_file(command[0].ref, true);
+ FileSpec cmd_file(command[0].ref);
+ FileSystem::Instance().Resolve(cmd_file);
ExecutionContext *exe_ctx = nullptr; // Just use the default context.
// If any options were set, then use them
switch (short_option) {
case 'f':
- log_file.SetFile(option_arg, true, FileSpec::Style::native);
+ log_file.SetFile(option_arg, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(log_file);
break;
case 't':
log_options |= LLDB_LOG_OPTION_THREADSAFE;
switch (short_option) {
case 'i':
- m_infile.SetFile(option_value, true, FileSpec::Style::native);
+ m_infile.SetFile(option_value, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(m_infile);
if (!FileSystem::Instance().Exists(m_infile)) {
m_infile.Clear();
error.SetErrorStringWithFormat("input file does not exist: '%s'",
else
mode = lldb::eFilePermissionsUserRWX | lldb::eFilePermissionsGroupRWX |
lldb::eFilePermissionsWorldRX;
- Status error =
- platform_sp->MakeDirectory(FileSpec{cmd_line, false}, mode);
+ Status error = platform_sp->MakeDirectory(FileSpec(cmd_line), mode);
if (error.Success()) {
result.SetStatus(eReturnStatusSuccessFinishResult);
} else {
perms = lldb::eFilePermissionsUserRW | lldb::eFilePermissionsGroupRW |
lldb::eFilePermissionsWorldRead;
lldb::user_id_t fd = platform_sp->OpenFile(
- FileSpec(cmd_line, false),
+ FileSpec(cmd_line),
File::eOpenOptionRead | File::eOpenOptionWrite |
File::eOpenOptionAppend | File::eOpenOptionCanCreate,
perms, error);
if (platform_sp) {
const char *remote_file_path = args.GetArgumentAtIndex(0);
const char *local_file_path = args.GetArgumentAtIndex(1);
- Status error = platform_sp->GetFile(FileSpec(remote_file_path, false),
- FileSpec(local_file_path, false));
+ Status error = platform_sp->GetFile(FileSpec(remote_file_path),
+ FileSpec(local_file_path));
if (error.Success()) {
result.AppendMessageWithFormat(
"successfully get-file from %s (remote) to %s (host)\n",
m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp) {
std::string remote_file_path(args.GetArgumentAtIndex(0));
- user_id_t size =
- platform_sp->GetFileSize(FileSpec(remote_file_path, false));
+ user_id_t size = platform_sp->GetFileSize(FileSpec(remote_file_path));
if (size != UINT64_MAX) {
result.AppendMessageWithFormat("File size of %s (remote): %" PRIu64
"\n",
const char *src = args.GetArgumentAtIndex(0);
const char *dst = args.GetArgumentAtIndex(1);
- FileSpec src_fs(src, true);
- FileSpec dst_fs(dst ? dst : src_fs.GetFilename().GetCString(), false);
+ FileSpec src_fs(src);
+ FileSystem::Instance().Resolve(src_fs);
+ FileSpec dst_fs(dst ? dst : src_fs.GetFilename().GetCString());
PlatformSP platform_sp(
m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
case 'n':
match_info.GetProcessInfo().GetExecutableFile().SetFile(
- option_arg, false, FileSpec::Style::native);
+ option_arg, FileSpec::Style::native);
match_info.SetNameMatchType(NameMatch::Equals);
break;
case 'e':
match_info.GetProcessInfo().GetExecutableFile().SetFile(
- option_arg, false, FileSpec::Style::native);
+ option_arg, FileSpec::Style::native);
match_info.SetNameMatchType(NameMatch::EndsWith);
break;
case 's':
match_info.GetProcessInfo().GetExecutableFile().SetFile(
- option_arg, false, FileSpec::Style::native);
+ option_arg, FileSpec::Style::native);
match_info.SetNameMatchType(NameMatch::StartsWith);
break;
case 'c':
match_info.GetProcessInfo().GetExecutableFile().SetFile(
- option_arg, false, FileSpec::Style::native);
+ option_arg, FileSpec::Style::native);
match_info.SetNameMatchType(NameMatch::Contains);
break;
case 'r':
match_info.GetProcessInfo().GetExecutableFile().SetFile(
- option_arg, false, FileSpec::Style::native);
+ option_arg, FileSpec::Style::native);
match_info.SetNameMatchType(NameMatch::RegularExpression);
break;
break;
case 'n':
- attach_info.GetExecutableFile().SetFile(option_arg, false,
+ attach_info.GetExecutableFile().SetFile(option_arg,
FileSpec::Style::native);
break;
ProcessInstanceInfoMatch match_info;
if (partial_name) {
match_info.GetProcessInfo().GetExecutableFile().SetFile(
- partial_name, false, FileSpec::Style::native);
+ partial_name, FileSpec::Style::native);
match_info.SetNameMatchType(NameMatch::StartsWith);
}
platform_sp->FindProcesses(match_info, process_infos);
return false;
}
// TODO: move the bulk of this code over to the platform itself
- FileSpec src(args.GetArgumentAtIndex(0), true);
- FileSpec dst(args.GetArgumentAtIndex(1), false);
+ FileSpec src(args.GetArgumentAtIndex(0));
+ FileSystem::Instance().Resolve(src);
+ FileSpec dst(args.GetArgumentAtIndex(1));
if (!FileSystem::Instance().Exists(src)) {
result.AppendError("source location does not exist or is not accessible");
result.SetStatus(eReturnStatusFailed);
Status error;
- FileSpec dylib_fspec(command[0].ref, true);
+ FileSpec dylib_fspec(command[0].ref);
+ FileSystem::Instance().Resolve(dylib_fspec);
if (m_interpreter.GetDebugger().LoadPlugin(dylib_fspec, error))
result.SetStatus(eReturnStatusSuccessFinishResult);
break;
case 'n':
- attach_info.GetExecutableFile().SetFile(option_arg, false,
+ attach_info.GetExecutableFile().SetFile(option_arg,
FileSpec::Style::native);
break;
ProcessInstanceInfoMatch match_info;
if (partial_name) {
match_info.GetProcessInfo().GetExecutableFile().SetFile(
- partial_name, false, FileSpec::Style::native);
+ partial_name, FileSpec::Style::native);
match_info.SetNameMatchType(NameMatch::StartsWith);
}
platform_sp->FindProcesses(match_info, process_infos);
case 'i':
do_install = true;
if (!option_arg.empty())
- install_path.SetFile(option_arg, false, FileSpec::Style::native);
+ install_path.SetFile(option_arg, FileSpec::Style::native);
break;
default:
error.SetErrorStringWithFormat("invalid short option character '%c'",
uint32_t image_token = LLDB_INVALID_IMAGE_TOKEN;
if (!m_options.do_install) {
- FileSpec image_spec(image_path, false);
+ FileSpec image_spec(image_path);
platform->ResolveRemotePath(image_spec, image_spec);
image_token =
platform->LoadImage(process, FileSpec(), image_spec, error);
} else if (m_options.install_path) {
- FileSpec image_spec(image_path, true);
+ FileSpec image_spec(image_path);
+ FileSystem::Instance().Resolve(image_spec);
platform->ResolveRemotePath(m_options.install_path,
m_options.install_path);
image_token = platform->LoadImage(process, image_spec,
m_options.install_path, error);
} else {
- FileSpec image_spec(image_path, true);
+ FileSpec image_spec(image_path);
+ FileSystem::Instance().Resolve(image_spec);
image_token =
platform->LoadImage(process, image_spec, FileSpec(), error);
}
ProcessSP process_sp = m_exe_ctx.GetProcessSP();
if (process_sp) {
if (command.GetArgumentCount() == 1) {
- FileSpec output_file(command.GetArgumentAtIndex(0), false);
+ FileSpec output_file(command.GetArgumentAtIndex(0));
Status error = PluginManager::SaveCore(process_sp, output_file);
if (error.Success()) {
result.SetStatus(eReturnStatusSuccessFinishResult);
protected:
bool DoExecute(Args &args, CommandReturnObject &result) override {
- std::string path(FileSpec(m_options.m_filename, true).GetPath());
+ FileSpec file_spec(m_options.m_filename);
+ FileSystem::Instance().Resolve(file_spec);
+ std::string path(file_spec.GetPath());
uint32_t options = File::OpenOptions::eOpenOptionWrite |
File::OpenOptions::eOpenOptionCanCreate;
if (m_options.m_append)
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- FileSpec file(m_options.m_filename, true);
+ FileSpec file(m_options.m_filename);
+ FileSystem::Instance().Resolve(file);
ExecutionContext clean_ctx;
CommandInterpreterRunOptions options;
options.SetAddToHistory(false);
// Dump the line entries found in the file specified in the option.
bool DumpLinesForFile(CommandReturnObject &result) {
- FileSpec file_spec(m_options.file_name, false);
+ FileSpec file_spec(m_options.file_name);
const char *filename = m_options.file_name.c_str();
Target *target = m_exe_ctx.GetTargetPtr();
const ModuleList &module_list =
m_module_list.Clear();
if (!m_options.modules.empty()) {
for (size_t i = 0, e = m_options.modules.size(); i < e; ++i) {
- FileSpec module_file_spec(m_options.modules[i], false);
+ FileSpec module_file_spec(m_options.modules[i]);
if (module_file_spec) {
ModuleSpec module_spec(module_file_spec);
if (target->GetImages().FindModules(module_spec, m_module_list) == 0)
if (num_modules > 0) {
ModuleList matching_modules;
for (size_t i = 0; i < num_modules; ++i) {
- FileSpec module_file_spec(m_options.modules[i], false);
+ FileSpec module_file_spec(m_options.modules[i]);
if (module_file_spec) {
ModuleSpec module_spec(module_file_spec);
matching_modules.Clear();
if (num_modules > 0) {
ModuleList matching_modules;
for (size_t i = 0; i < num_modules; ++i) {
- FileSpec module_file_spec(m_options.modules[i], false);
+ FileSpec module_file_spec(m_options.modules[i]);
if (module_file_spec) {
ModuleSpec module_spec(module_file_spec);
matching_modules.Clear();
if (!m_options.modules.empty()) {
ModuleList matching_modules;
for (size_t i = 0, e = m_options.modules.size(); i < e; ++i) {
- FileSpec module_file_spec(m_options.modules[i], false);
+ FileSpec module_file_spec(m_options.modules[i]);
if (module_file_spec) {
ModuleSpec module_spec(module_file_spec);
matching_modules.Clear();
Timer scoped_timer(func_cat, "(lldb) target create '%s'", file_path);
FileSpec file_spec;
- if (file_path)
- file_spec.SetFile(file_path, true, FileSpec::Style::native);
+ if (file_path) {
+ file_spec.SetFile(file_path, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(file_spec);
+ }
bool must_set_platform_path = false;
static size_t FindModulesByName(Target *target, const char *module_name,
ModuleList &module_list,
bool check_global_list) {
- FileSpec module_file_spec(module_name, false);
+ FileSpec module_file_spec(module_name);
ModuleSpec module_spec(module_file_spec);
const size_t initial_size = module_list.GetSize();
for (int arg_idx = 0;
(arg_cstr = command.GetArgumentAtIndex(arg_idx)) != nullptr;
++arg_idx) {
- FileSpec file_spec(arg_cstr, false);
+ FileSpec file_spec(arg_cstr);
const ModuleList &target_modules = target->GetImages();
std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
if (entry.ref.empty())
continue;
- FileSpec file_spec(entry.ref, true);
+ FileSpec file_spec(entry.ref);
if (FileSystem::Instance().Exists(file_spec)) {
ModuleSpec module_spec(file_spec);
if (m_uuid_option_group.GetOptionValue().OptionWasSet())
break;
case 'f':
- m_file.SetFile(option_arg, false, FileSpec::Style::native);
+ m_file.SetFile(option_arg, FileSpec::Style::native);
m_type = eLookupTypeFileLine;
break;
for (auto &entry : args.entries()) {
if (!entry.ref.empty()) {
- module_spec.GetSymbolFileSpec().SetFile(entry.ref, true,
- FileSpec::Style::native);
+ auto &symbol_file_spec = module_spec.GetSymbolFileSpec();
+ symbol_file_spec.SetFile(entry.ref, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(symbol_file_spec);
if (file_option_set) {
module_spec.GetFileSpec() =
m_file_option.GetOptionValue().GetCurrentValue();
switch (short_option) {
case 'f':
- m_filenames.AppendIfUnique(FileSpec(option_arg, false));
+ m_filenames.AppendIfUnique(FileSpec(option_arg));
if (m_filenames.GetSize() > 1)
return Status("only one source file expected.");
break;
// file type information.
if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file ||
ft == fs::file_type::type_unknown) {
- FileSpec plugin_file_spec(path, false);
- plugin_file_spec.ResolvePath();
+ FileSpec plugin_file_spec(path);
+ FileSystem::Instance().Resolve(plugin_file_spec);
if (plugin_file_spec.GetFileNameExtension() != g_dylibext &&
plugin_file_spec.GetFileNameExtension() != g_solibext) {
if (error.Success() && memory_info.GetMapped() &&
memory_info.GetRange().GetRangeBase() == base_addr &&
!(memory_info.GetName().IsEmpty())) {
- ModuleSpec new_module_spec(
- FileSpec(memory_info.GetName().AsCString(), false),
- target.GetArchitecture());
+ ModuleSpec new_module_spec(FileSpec(memory_info.GetName().AsCString()),
+ target.GetArchitecture());
if ((module_sp = modules.FindFirstModule(new_module_spec))) {
UpdateLoadedSections(module_sp, link_map_addr, base_addr, false);
uint32_t Module::ResolveSymbolContextForFilePath(
const char *file_path, uint32_t line, bool check_inlines,
lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) {
- FileSpec file_spec(file_path, false);
+ FileSpec file_spec(file_path);
return ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines,
resolve_scope, sc_list);
}
uint32_t ModuleList::ResolveSymbolContextForFilePath(
const char *file_path, uint32_t line, bool check_inlines,
SymbolContextItem resolve_scope, SymbolContextList &sc_list) const {
- FileSpec file_spec(file_path, false);
+ FileSpec file_spec(file_path);
return ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines,
resolve_scope, sc_list);
}
const auto num_directories = module_search_paths_ptr->GetSize();
for (size_t idx = 0; idx < num_directories; ++idx) {
auto search_path_spec = module_search_paths_ptr->GetFileSpecAtIndex(idx);
- if (!search_path_spec.ResolvePath())
- continue;
+ FileSystem::Instance().Resolve(search_path_spec);
namespace fs = llvm::sys::fs;
if (!fs::is_directory(search_path_spec.GetPath()))
continue;
// file type information.
if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file ||
ft == fs::file_type::type_unknown) {
- FileSpec plugin_file_spec(path, false);
- plugin_file_spec.ResolvePath();
+ FileSpec plugin_file_spec(path);
+ FileSystem::Instance().Resolve(plugin_file_spec);
if (PluginIsLoaded(plugin_file_spec))
return FileSystem::eEnumerateDirectoryResultNext;
error.SetErrorString("SFBM::CFSD: filter module item not a string.");
return nullptr;
}
- FileSpec module_spec(module, false);
+ FileSpec module_spec(module);
return std::make_shared<SearchFilterByModule>(target.shared_from_this(),
module_spec);
"SFBM::CFSD: filter module item %zu not a string.", i);
return nullptr;
}
- modules.Append(FileSpec(module, false));
+ modules.Append(FileSpec(module));
}
}
"SFBM::CFSD: filter module item %zu not a string.", i);
return result_sp;
}
- modules.Append(FileSpec(module, false));
+ modules.Append(FileSpec(module));
}
}
"SFBM::CFSD: filter cu item %zu not a string.", i);
return nullptr;
}
- cus.Append(FileSpec(cu, false));
+ cus.Append(FileSpec(cu));
}
return std::make_shared<SearchFilterByModuleListAndCU>(
tmpdir_file_spec.GetFilename().SetCString(file_basename.AsCString());
m_repl_source_path = tmpdir_file_spec.GetPath();
} else {
- tmpdir_file_spec = FileSpec("/tmp", false);
+ tmpdir_file_spec = FileSpec("/tmp");
tmpdir_file_spec.AppendPathComponent(file_basename.AsCString());
}
// Now set the default file and line to the REPL source file
m_target.GetSourceManager().SetDefaultFileAndLine(
- FileSpec(m_repl_source_path, false), new_default_line);
+ FileSpec(m_repl_source_path), new_default_line);
}
static_cast<IOHandlerEditline &>(io_handler)
.SetBaseLineNumber(m_code.GetSize() + 1);
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/Editline.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/LLDBAssert.h"
const char *GetHistoryFilePath() {
if (m_path.empty() && m_history && !m_prefix.empty()) {
- FileSpec parent_path{"~/.lldb", true};
+ FileSpec parent_path("~/.lldb");
+ FileSystem::Instance().Resolve(parent_path);
char history_path[PATH_MAX];
if (!llvm::sys::fs::create_directory(parent_path.GetPath())) {
snprintf(history_path, sizeof(history_path), "~/.lldb/%s-history",
snprintf(history_path, sizeof(history_path), "~/%s-widehistory",
m_prefix.c_str());
}
- m_path = FileSpec(history_path, true).GetPath();
+ auto file_spec = FileSpec(history_path);
+ FileSystem::Instance().Resolve(file_spec);
+ m_path = file_spec.GetPath();
}
if (m_path.empty())
return NULL;
if (::fcntl(GetDescriptor(), F_GETPATH, path) == -1)
error.SetErrorToErrno();
else
- file_spec.SetFile(path, false, FileSpec::Style::native);
+ file_spec.SetFile(path, FileSpec::Style::native);
} else {
error.SetErrorString("invalid file handle");
}
error.SetErrorToErrno();
else {
path[len] = '\0';
- file_spec.SetFile(path, false, FileSpec::Style::native);
+ file_spec.SetFile(path, FileSpec::Style::native);
}
}
#else
if (EC)
return EC;
- FileSpec new_file_spec(path, false, file_spec.GetPathStyle());
+ FileSpec new_file_spec(path, file_spec.GetPathStyle());
file_spec = new_file_spec;
return {};
}
// Update the FileSpec with the resolved path.
file_spec.SetPath(path);
+ file_spec.SetIsResolved(true);
}
bool FileSystem::ResolveExecutableLocation(FileSpec &file_spec) {
return false;
// Make sure that the result exists.
- FileSpec result(*error_or_path, false);
+ FileSpec result(*error_or_path);
if (!Exists(result))
return false;
#if !defined(__ANDROID__)
Dl_info info;
if (::dladdr(host_addr, &info)) {
- if (info.dli_fname)
- module_filespec.SetFile(info.dli_fname, true, FileSpec::Style::native);
+ if (info.dli_fname) {
+ module_filespec.SetFile(info.dli_fname, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(module_filespec);
+ }
}
#endif
return module_filespec;
}
}
- FileSpec output_file_spec{output_file_path.c_str(), false};
+ FileSpec output_file_spec(output_file_path.c_str());
launch_info.AppendSuppressFileAction(STDIN_FILENO, true, false);
if (output_file_spec) {
bool HostInfoBase::ComputeTempFileBaseDirectory(FileSpec &file_spec) {
llvm::SmallVector<char, 16> tmpdir;
llvm::sys::path::system_temp_directory(/*ErasedOnReboot*/ true, tmpdir);
- file_spec = FileSpec(std::string(tmpdir.data(), tmpdir.size()), true);
+ file_spec = FileSpec(std::string(tmpdir.data(), tmpdir.size()));
+ FileSystem::Instance().Resolve(file_spec);
return true;
}
llvm::sys::fs::file_status stats;
status(exe_spec.GetPath(), stats);
if (!exists(stats)) {
- exe_spec.ResolvePath();
+ FileSystem::Instance().Resolve(exe_spec);
status(exe_spec.GetPath(), stats);
}
if (!exists(stats)) {
FileSystem::Instance().ResolveSymbolicLink(module_file_spec, module_file_spec);
const ConstString &file_dir = module_file_spec.GetDirectory();
- debug_file_search_paths.AppendIfUnique(
- FileSpec(file_dir.AsCString("."), true));
+ {
+ FileSpec file_spec(file_dir.AsCString("."));
+ FileSystem::Instance().Resolve(file_spec);
+ debug_file_search_paths.AppendIfUnique(file_spec);
+ }
// Add current working directory.
- debug_file_search_paths.AppendIfUnique(FileSpec(".", true));
+ {
+ FileSpec file_spec(".");
+ FileSystem::Instance().Resolve(file_spec);
+ debug_file_search_paths.AppendIfUnique(file_spec);
+ }
#ifndef _WIN32
#if defined(__NetBSD__)
// Add /usr/libdata/debug directory.
- debug_file_search_paths.AppendIfUnique(
- FileSpec("/usr/libdata/debug", true));
+ {
+ FileSpec file_spec("/usr/libdata/debug");
+ FileSystem::Instance().Resolve(file_spec);
+ debug_file_search_paths.AppendIfUnique(file_spec);
+ }
#else
// Add /usr/lib/debug directory.
- debug_file_search_paths.AppendIfUnique(FileSpec("/usr/lib/debug", true));
+ {
+ FileSpec file_spec("/usr/lib/debug");
+ FileSystem::Instance().Resolve(file_spec);
+ debug_file_search_paths.AppendIfUnique(file_spec);
+ }
#endif
#endif // _WIN32
size_t num_directories = debug_file_search_paths.GetSize();
for (size_t idx = 0; idx < num_directories; ++idx) {
FileSpec dirspec = debug_file_search_paths.GetFileSpecAtIndex(idx);
- dirspec.ResolvePath();
+ FileSystem::Instance().Resolve(dirspec);
if (!llvm::sys::fs::is_directory(dirspec.GetPath()))
continue;
const uint32_t num_files = files.size();
for (size_t idx_file = 0; idx_file < num_files; ++idx_file) {
const std::string &filename = files[idx_file];
- FileSpec file_spec(filename, true);
+ FileSpec file_spec(filename);
+ FileSystem::Instance().Resolve(file_spec);
if (llvm::sys::fs::equivalent(file_spec.GetPath(),
module_file_spec.GetPath()))
return false;
process_info.SetProcessID(pid);
- process_info.GetExecutableFile().SetFile(PathRef, false,
- FileSpec::Style::native);
+ process_info.GetExecutableFile().SetFile(PathRef, FileSpec::Style::native);
llvm::StringRef Rest = Environ->getBuffer();
while (!Rest.empty()) {
ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path) - 1);
if (len > 0) {
exe_path[len] = 0;
- g_program_filespec.SetFile(exe_path, false, FileSpec::Style::native);
+ g_program_filespec.SetFile(exe_path, FileSpec::Style::native);
}
}
}
bool HostInfoLinux::ComputeSystemPluginsDirectory(FileSpec &file_spec) {
- FileSpec temp_file("/usr/lib" LLDB_LIBDIR_SUFFIX "/lldb/plugins", true);
+ FileSpec temp_file("/usr/lib" LLDB_LIBDIR_SUFFIX "/lldb/plugins");
+ FileSystem::Instance().Resolve(temp_file);
file_spec.GetDirectory().SetCString(temp_file.GetPath().c_str());
return true;
}
"UUID %s -- looking for the dSYM",
path, uuid->GetAsString().c_str());
}
- FileSpec dsym_filespec(path, path[0] == '~');
+ FileSpec dsym_filespec(path);
+ if (path[0] == '~')
+ FileSystem::Instance().Resolve(dsym_filespec);
if (llvm::sys::fs::is_directory(dsym_filespec.GetPath())) {
dsym_filespec =
path, uuid->GetAsString().c_str());
}
++items_found;
- FileSpec exec_filespec(path, path[0] == '~');
+ FileSpec exec_filespec(path);
+ if (path[0] == '~')
+ FileSystem::Instance().Resolve(exec_filespec);
if (FileSystem::Instance().Exists(exec_filespec)) {
success = true;
return_module_spec.GetFileSpec() = exec_filespec;
"bundle with name with name %s",
path);
}
- FileSpec file_spec(path, true);
+ FileSpec file_spec(path);
+ FileSystem::Instance().Resolve(file_spec);
ModuleSpecList module_specs;
ModuleSpec matched_module_spec;
using namespace llvm::sys::fs;
if (::CFURLGetFileSystemRepresentation(bundle_exe_url.get(),
true, (UInt8 *)path,
sizeof(path) - 1)) {
- FileSpec bundle_exe_file_spec(path, true);
+ FileSpec bundle_exe_file_spec(path);
+ FileSystem::Instance().Resolve(bundle_exe_file_spec);
if (ObjectFile::GetModuleSpecifications(
bundle_exe_file_spec, 0, 0, module_specs) &&
module_specs.FindMatchingModuleSpec(
(CFDictionaryRef)uuid_dict, CFSTR("DBGSymbolRichExecutable"));
if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
if (CFCString::FileSystemRepresentation(cf_str, str)) {
- module_spec.GetFileSpec().SetFile(str.c_str(), true,
- FileSpec::Style::native);
+ module_spec.GetFileSpec().SetFile(str.c_str(), FileSpec::Style::native);
+ FileSystem::Instance().Resolve(module_spec.GetFileSpec());
if (log) {
log->Printf(
"From dsymForUUID plist: Symbol rich executable is at '%s'",
CFSTR("DBGDSYMPath"));
if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
if (CFCString::FileSystemRepresentation(cf_str, str)) {
- module_spec.GetSymbolFileSpec().SetFile(str.c_str(), true,
+ module_spec.GetSymbolFileSpec().SetFile(str.c_str(),
FileSpec::Style::native);
+ FileSystem::Instance().Resolve(module_spec.GetFileSpec());
success = true;
if (log) {
log->Printf("From dsymForUUID plist: dSYM is at '%s'", str.c_str());
DBGSourcePath = original_DBGSourcePath_value;
}
if (DBGSourcePath[0] == '~') {
- FileSpec resolved_source_path(DBGSourcePath.c_str(), true);
+ FileSpec resolved_source_path(DBGSourcePath.c_str());
+ FileSystem::Instance().Resolve(resolved_source_path);
DBGSourcePath = resolved_source_path.GetPath();
}
// With version 2 of DBGSourcePathRemapping, we can chop off the
ConstString(DBGBuildSourcePath.c_str()),
ConstString(DBGSourcePath.c_str()), true);
if (do_truncate_remapping_names) {
- FileSpec build_path(DBGBuildSourcePath.c_str(), false);
- FileSpec source_path(DBGSourcePath.c_str(), false);
+ FileSpec build_path(DBGBuildSourcePath.c_str());
+ FileSpec source_path(DBGSourcePath.c_str());
build_path.RemoveLastPathComponent();
build_path.RemoveLastPathComponent();
source_path.RemoveLastPathComponent();
if (!DBGBuildSourcePath.empty() && !DBGSourcePath.empty()) {
if (DBGSourcePath[0] == '~') {
- FileSpec resolved_source_path(DBGSourcePath.c_str(), true);
+ FileSpec resolved_source_path(DBGSourcePath.c_str());
+ FileSystem::Instance().Resolve(resolved_source_path);
DBGSourcePath = resolved_source_path.GetPath();
}
module_spec.GetSourceMappingList().Append(
getenv("LLDB_APPLE_DSYMFORUUID_EXECUTABLE");
FileSpec dsym_for_uuid_exe_spec;
if (dsym_for_uuid_exe_path_cstr) {
- dsym_for_uuid_exe_spec.SetFile(dsym_for_uuid_exe_path_cstr, true,
+ dsym_for_uuid_exe_spec.SetFile(dsym_for_uuid_exe_path_cstr,
FileSpec::Style::native);
+ FileSystem::Instance().Resolve(dsym_for_uuid_exe_spec);
g_dsym_for_uuid_exe_exists =
FileSystem::Instance().Exists(dsym_for_uuid_exe_spec);
}
if (!g_dsym_for_uuid_exe_exists) {
- dsym_for_uuid_exe_spec.SetFile("/usr/local/bin/dsymForUUID", false,
+ dsym_for_uuid_exe_spec.SetFile("/usr/local/bin/dsymForUUID",
FileSpec::Style::native);
g_dsym_for_uuid_exe_exists =
FileSystem::Instance().Exists(dsym_for_uuid_exe_spec);
tilde_rc && tilde_rc->pw_dir) {
std::string dsymforuuid_path(tilde_rc->pw_dir);
dsymforuuid_path += "/bin/dsymForUUID";
- dsym_for_uuid_exe_spec.SetFile(dsymforuuid_path.c_str(), false,
+ dsym_for_uuid_exe_spec.SetFile(dsymforuuid_path.c_str(),
FileSpec::Style::native);
g_dsym_for_uuid_exe_exists =
FileSystem::Instance().Exists(dsym_for_uuid_exe_spec);
}
}
if (!g_dsym_for_uuid_exe_exists && g_dbgshell_command != NULL) {
- dsym_for_uuid_exe_spec.SetFile(g_dbgshell_command, true,
+ dsym_for_uuid_exe_spec.SetFile(g_dbgshell_command,
FileSpec::Style::native);
+ FileSystem::Instance().Resolve(dsym_for_uuid_exe_spec);
g_dsym_for_uuid_exe_exists =
FileSystem::Instance().Exists(dsym_for_uuid_exe_spec);
}
if (file.GetPath(path, sizeof(path))) {
CFCBundle bundle(path);
if (bundle.GetPath(path, sizeof(path))) {
- bundle_directory.SetFile(path, false, FileSpec::Style::native);
+ bundle_directory.SetFile(path, FileSpec::Style::native);
return true;
}
}
if (url.get()) {
if (::CFURLGetFileSystemRepresentation(url.get(), YES, (UInt8 *)path,
sizeof(path))) {
- file.SetFile(path, false, FileSpec::Style::native);
+ file.SetFile(path, FileSpec::Style::native);
return true;
}
}
triple_arch == llvm::Triple::x86_64);
const char *cstr = data.GetCStr(&offset);
if (cstr) {
- process_info.GetExecutableFile().SetFile(cstr, false,
- FileSpec::Style::native);
+ process_info.GetExecutableFile().SetFile(cstr, FileSpec::Style::native);
if (match_info_ptr == NULL ||
NameMatches(
llvm::sys::fs::file_status stats;
status(exe_spec.GetPath(), stats);
if (!exists(stats)) {
- exe_spec.ResolvePath();
+ FileSystem::Instance().Resolve(exe_spec);
status(exe_spec.GetPath(), stats);
}
if (!exists(stats)) {
"cwd does not exist; cannot launch with shell argument expansion");
return error;
} else {
- FileSpec working_dir(wd, false);
+ FileSpec working_dir(wd);
free(wd);
launch_info.SetWorkingDirectory(working_dir);
}
//
//===----------------------------------------------------------------------===//
-#include "lldb/Host/HostInfo.h"
#include "lldb/Host/macosx/HostInfoMacOSX.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
#include "lldb/Utility/Args.h"
#include "lldb/Utility/Log.h"
uint32_t len = sizeof(program_fullpath);
int err = _NSGetExecutablePath(program_fullpath, &len);
if (err == 0)
- g_program_filespec.SetFile(program_fullpath, false,
- FileSpec::Style::native);
+ g_program_filespec.SetFile(program_fullpath, FileSpec::Style::native);
else if (err == -1) {
char *large_program_fullpath = (char *)::malloc(len + 1);
err = _NSGetExecutablePath(large_program_fullpath, &len);
if (err == 0)
- g_program_filespec.SetFile(large_program_fullpath, false,
+ g_program_filespec.SetFile(large_program_fullpath,
FileSpec::Style::native);
::free(large_program_fullpath);
// as in the case of a python script, the executable is python, not
// the lldb driver.
raw_path.append("/../bin");
- FileSpec support_dir_spec(raw_path, true);
+ FileSpec support_dir_spec(raw_path);
+ FileSystem::Instance().Resolve(support_dir_spec);
if (!llvm::sys::fs::is_directory(support_dir_spec.GetPath())) {
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (log)
}
bool HostInfoMacOSX::ComputeUserPluginsDirectory(FileSpec &file_spec) {
- FileSpec temp_file("~/Library/Application Support/LLDB/PlugIns", true);
+ FileSpec temp_file("~/Library/Application Support/LLDB/PlugIns");
+ FileSystem::Instance().Resolve(temp_file);
file_spec.GetDirectory().SetCString(temp_file.GetPath().c_str());
return true;
}
error.SetErrorToErrno();
else {
buf[count] = '\0'; // Success
- dst.SetFile(buf, false, FileSpec::Style::native);
+ dst.SetFile(buf, FileSpec::Style::native);
}
return error;
}
return err;
}
- dst = FileSpec(real_path, false);
+ dst = FileSpec(real_path);
return Status();
}
uint32_t HostInfoPosix::GetEffectiveGroupID() { return getegid(); }
-FileSpec HostInfoPosix::GetDefaultShell() { return FileSpec("/bin/sh", false); }
+FileSpec HostInfoPosix::GetDefaultShell() { return FileSpec("/bin/sh"); }
bool HostInfoPosix::ComputePathRelativeToLibrary(FileSpec &file_spec,
llvm::StringRef dir) {
}
bool HostInfoPosix::ComputeHeaderDirectory(FileSpec &file_spec) {
- FileSpec temp_file("/opt/local/include/lldb", false);
+ FileSpec temp_file("/opt/local/include/lldb");
file_spec.GetDirectory().SetCString(temp_file.GetPath().c_str());
return true;
}
return error;
}
- error = FileSystem::Instance().Readlink(FileSpec{link_path, false}, file_spec);
+ error = FileSystem::Instance().Readlink(FileSpec(link_path), file_spec);
if (!error.Success())
return error;
LoadCWDlldbinitFile should_load =
target->TargetProperties::GetLoadCWDlldbinitFile();
if (should_load == eLoadCWDlldbinitWarn) {
- FileSpec dot_lldb(".lldbinit", true);
+ FileSpec dot_lldb(".lldbinit");
+ FileSystem::Instance().Resolve(dot_lldb);
llvm::SmallString<64> home_dir_path;
llvm::sys::path::home_directory(home_dir_path);
- FileSpec homedir_dot_lldb(home_dir_path.c_str(), false);
+ FileSpec homedir_dot_lldb(home_dir_path.c_str());
homedir_dot_lldb.AppendPathComponent(".lldbinit");
- homedir_dot_lldb.ResolvePath();
+ FileSystem::Instance().Resolve(homedir_dot_lldb);
if (FileSystem::Instance().Exists(dot_lldb) &&
dot_lldb.GetDirectory() != homedir_dot_lldb.GetDirectory()) {
result.AppendErrorWithFormat(
return;
}
} else if (should_load == eLoadCWDlldbinitTrue) {
- init_file.SetFile("./.lldbinit", true, FileSpec::Style::native);
+ init_file.SetFile("./.lldbinit", FileSpec::Style::native);
+ FileSystem::Instance().Resolve(init_file);
}
}
} else {
// init files.
llvm::SmallString<64> home_dir_path;
llvm::sys::path::home_directory(home_dir_path);
- FileSpec profilePath(home_dir_path.c_str(), false);
+ FileSpec profilePath(home_dir_path.c_str());
profilePath.AppendPathComponent(".lldbinit");
std::string init_file_path = profilePath.GetPath();
char program_init_file_name[PATH_MAX];
::snprintf(program_init_file_name, sizeof(program_init_file_name),
"%s-%s", init_file_path.c_str(), program_name);
- init_file.SetFile(program_init_file_name, true,
- FileSpec::Style::native);
+ init_file.SetFile(program_init_file_name, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(init_file);
if (!FileSystem::Instance().Exists(init_file))
init_file.Clear();
}
}
if (!init_file && !m_skip_lldbinit_files)
- init_file.SetFile(init_file_path, false, FileSpec::Style::native);
+ init_file.SetFile(init_file_path, FileSpec::Style::native);
}
// If the file exists, tell HandleCommand to 'source' it; this will do the
// or whitespace.
value = value.trim("\"' \t");
m_value_was_set = true;
- m_current_value.SetFile(value.str(), m_resolve, FileSpec::Style::native);
+ m_current_value.SetFile(value.str(), FileSpec::Style::native);
+ if (m_resolve)
+ FileSystem::Instance().Resolve(m_current_value);
m_data_sp.reset();
m_data_mod_time = llvm::sys::TimePoint<>();
NotifyValueChanged();
count);
} else {
for (size_t i = 1; i < argc; ++i, ++idx) {
- FileSpec file(args.GetArgumentAtIndex(i), false);
+ FileSpec file(args.GetArgumentAtIndex(i));
if (idx < count)
m_current_value.Replace(idx, file);
else
if (argc > 0) {
m_value_was_set = true;
for (size_t i = 0; i < argc; ++i) {
- FileSpec file(args.GetArgumentAtIndex(i), false);
+ FileSpec file(args.GetArgumentAtIndex(i));
m_current_value.Append(file);
}
NotifyValueChanged();
if (op == eVarSetOperationInsertAfter)
++idx;
for (size_t i = 1; i < argc; ++i, ++idx) {
- FileSpec file(args.GetArgumentAtIndex(i), false);
+ FileSpec file(args.GetArgumentAtIndex(i));
m_current_value.Insert(idx, file);
}
NotifyValueChanged();
const char *module_name =
request.GetParsedLine().GetArgumentAtIndex(cur_arg_pos);
if (module_name) {
- FileSpec module_spec(module_name, false);
+ FileSpec module_spec(module_name);
lldb::TargetSP target_sp =
interpreter.GetDebugger().GetSelectedTarget();
// Search filters require a target...
// "definition.default_uint_value" represents if the
// "definition.default_cstr_value" should be resolved or not
const bool resolve = definition.default_uint_value != 0;
- m_value_sp.reset(new OptionValueFileSpec(
- FileSpec(definition.default_cstr_value, resolve), resolve));
+ FileSpec file_spec = FileSpec(definition.default_cstr_value);
+ if (resolve)
+ FileSystem::Instance().Resolve(file_spec);
+ m_value_sp.reset(new OptionValueFileSpec(file_spec, resolve));
break;
}
if (header.filetype == llvm::MachO::MH_EXECUTE &&
(header.flags & llvm::MachO::MH_DYLDLINK) == 0) {
// Create a full module to get the UUID
- ModuleSP memory_module_sp = process->ReadModuleFromMemory(
- FileSpec("temp_mach_kernel", false), addr);
+ ModuleSP memory_module_sp =
+ process->ReadModuleFromMemory(FileSpec("temp_mach_kernel"), addr);
if (!memory_module_sp.get())
return UUID();
if (m_load_address == LLDB_INVALID_ADDRESS)
return false;
- FileSpec file_spec;
- file_spec.SetFile(m_name.c_str(), false, FileSpec::Style::native);
+ FileSpec file_spec(m_name.c_str());
llvm::MachO::mach_header mh;
size_t size_to_read = 512;
PlatformDarwinKernel::GetPluginNameStatic());
if (platform_name == g_platform_name) {
ModuleSpec kext_bundle_module_spec(module_spec);
- FileSpec kext_filespec(m_name.c_str(), false);
+ FileSpec kext_filespec(m_name.c_str());
kext_bundle_module_spec.GetFileSpec() = kext_filespec;
platform_sp->GetSharedModule(
kext_bundle_module_spec, process, m_module_sp,
E = m_rendezvous.loaded_end();
for (I = m_rendezvous.loaded_begin(); I != E; ++I) {
- FileSpec file(I->path, true);
+ FileSpec file(I->path);
+ FileSystem::Instance().Resolve(file);
ModuleSP module_sp =
LoadModuleAtAddress(file, I->link_addr, I->base_addr, true);
if (module_sp.get()) {
E = m_rendezvous.unloaded_end();
for (I = m_rendezvous.unloaded_begin(); I != E; ++I) {
- FileSpec file(I->path, true);
+ FileSpec file(I->path);
+ FileSystem::Instance().Resolve(file);
ModuleSpec module_spec(file);
ModuleSP module_sp = loaded_modules.FindFirstModule(module_spec);
for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I) {
const char *module_path = I->path.c_str();
- FileSpec file(module_path, false);
+ FileSpec file(module_path);
ModuleSP module_sp =
LoadModuleAtAddress(file, I->link_addr, I->base_addr, true);
if (module_sp.get()) {
image_infos[i].mod_date =
image->GetValueForKey("mod_date")->GetAsInteger()->GetValue();
image_infos[i].file_spec.SetFile(
- image->GetValueForKey("pathname")->GetAsString()->GetValue(), false,
+ image->GetValueForKey("pathname")->GetAsString()->GetValue(),
FileSpec::Style::native);
StructuredData::Dictionary *mh =
error);
// don't resolve the path
if (error.Success()) {
- const bool resolve_path = false;
- image_infos[i].file_spec.SetFile(raw_path, resolve_path,
- FileSpec::Style::native);
+ image_infos[i].file_spec.SetFile(raw_path, FileSpec::Style::native);
}
}
return true;
const lldb::offset_t name_offset =
load_cmd_offset + data.GetU32(&offset);
const char *path = data.PeekCStr(name_offset);
- lc_id_dylinker->SetFile(path, true, FileSpec::Style::native);
+ lc_id_dylinker->SetFile(path, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(*lc_id_dylinker);
}
break;
entry.base_addr = base_addr;
entry.dyn_addr = dyn_addr;
- entry.file_spec.SetFile(name, false, FileSpec::Style::native);
+ entry.file_spec.SetFile(name, FileSpec::Style::native);
UpdateBaseAddrIfNecessary(entry, name);
return false;
std::string file_path = ReadStringFromMemory(entry.path_addr);
- entry.file_spec.SetFile(file_path, false, FileSpec::Style::native);
+ entry.file_spec.SetFile(file_path, FileSpec::Style::native);
UpdateBaseAddrIfNecessary(entry, file_path);
if (m_vdso_base == LLDB_INVALID_ADDRESS)
return;
- FileSpec file("[vdso]", false);
+ FileSpec file("[vdso]");
MemoryRegionInfo info;
Status status = m_process->GetMemoryRegionInfo(m_vdso_base, info);
return nullptr;
}
- FileSpec file(info.GetName().GetCString(), false);
+ FileSpec file(info.GetName().GetCString());
ModuleSpec module_spec(file, target.GetArchitecture());
if (ModuleSP module_sp = target.GetSharedModule(module_spec)) {
#include "llvm/Support/Threading.h"
// Project includes
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#if !defined(_WIN32)
#include "lldb/Host/posix/HostInfoPosix.h"
"Developer/Toolchains/XcodeDefault.xctoolchain",
swift_clang_resource_dir);
if (!verify || VerifyClangPath(clang_path)) {
- file_spec.SetFile(clang_path.c_str(), true, FileSpec::Style::native);
+ file_spec.SetFile(clang_path.c_str(), FileSpec::Style::native);
+ FileSystem::Instance().Resolve(file_spec);
return true;
}
} else if (parent != r_end && *parent == "PrivateFrameworks" &&
raw_path.resize(parent - r_end);
llvm::sys::path::append(clang_path, raw_path, swift_clang_resource_dir);
if (!verify || VerifyClangPath(clang_path)) {
- file_spec.SetFile(clang_path.c_str(), true, FileSpec::Style::native);
+ file_spec.SetFile(clang_path.c_str(), FileSpec::Style::native);
+ FileSystem::Instance().Resolve(file_spec);
return true;
}
raw_path = lldb_shlib_spec.GetPath();
// Fall back to the Clang resource directory inside the framework.
raw_path.append("LLDB.framework/Resources/Clang");
- file_spec.SetFile(raw_path.c_str(), true, FileSpec::Style::native);
+ file_spec.SetFile(raw_path.c_str(), FileSpec::Style::native);
+ FileSystem::Instance().Resolve(file_spec);
return true;
}
char jit_name[64];
snprintf(jit_name, 64, "JIT(0x%" PRIx64 ")", symbolfile_addr);
module_sp = m_process->ReadModuleFromMemory(
- FileSpec(jit_name, false), symbolfile_addr, symbolfile_size);
+ FileSpec(jit_name), symbolfile_addr, symbolfile_size);
if (module_sp && module_sp->GetObjectFile()) {
// load the symbol table right away
// Limit the number of modules that are searched for these breakpoints for
// Apple binaries.
FileSpecList filter_modules;
- filter_modules.Append(FileSpec("libc++abi.dylib", false));
- filter_modules.Append(FileSpec("libSystem.B.dylib", false));
+ filter_modules.Append(FileSpec("libc++abi.dylib"));
+ filter_modules.Append(FileSpec("libSystem.B.dylib"));
return target.GetSearchFilterForModuleList(&filter_modules);
} else {
return LanguageRuntime::CreateExceptionSearchFilter();
if (target.GetArchitecture().GetTriple().getVendor() == llvm::Triple::Apple) {
FileSpecList filter_modules;
- filter_modules.Append(FileSpec("libobjc.A.dylib", false));
+ filter_modules.Append(FileSpec("libobjc.A.dylib"));
return target.GetSearchFilterForModuleList(&filter_modules);
} else {
return LanguageRuntime::CreateExceptionSearchFilter();
"Allocation information not available");
// Check we can read from file
- FileSpec file(path, true);
+ FileSpec file(path);
+ FileSystem::Instance().Resolve(file);
if (!FileSystem::Instance().Exists(file)) {
strm.Printf("Error: File %s does not exist", path);
strm.EOL();
"Allocation information not available");
// Check we can create writable file
- FileSpec file_spec(path, true);
+ FileSpec file_spec(path);
+ FileSystem::Instance().Resolve(file_spec);
File file(file_spec, File::eOpenOptionWrite | File::eOpenOptionCanCreate |
File::eOpenOptionTruncate);
if (!file) {
switch (short_option) {
case 'f':
- m_outfile.SetFile(option_arg, true, FileSpec::Style::native);
+ m_outfile.SetFile(option_arg, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(m_outfile);
if (FileSystem::Instance().Exists(m_outfile)) {
m_outfile.Clear();
err.SetErrorStringWithFormat("file already exists: '%s'",
FileSpecList file_spec_list;
if (!m_gnu_debuglink_file.empty()) {
- FileSpec file_spec(m_gnu_debuglink_file, false);
+ FileSpec file_spec(m_gnu_debuglink_file);
file_spec_list.Append(file_spec);
}
return file_spec_list;
uint32_t str_index = static_cast<uint32_t>(symbol.d_val);
const char *lib_name = dynstr_data.PeekCStr(str_index);
- m_filespec_ap->Append(FileSpec(lib_name, true));
+ FileSpec file_spec(lib_name);
+ FileSystem::Instance().Resolve(file_spec);
+ m_filespec_ap->Append(file_spec);
}
}
uint32_t name_offset = cmd_offset + m_data.GetU32(&offset);
const char *path = m_data.PeekCStr(name_offset);
if (path) {
- FileSpec file_spec(path, false);
+ FileSpec file_spec(path);
// Strip the path if there is @rpath, @executable, etc so we just use
// the basename
if (path[0] == '@')
// string in the DW_AT_comp_dir, and the second is the
// directory for the source file so you end up with a path
// that looks like "/tmp/src//tmp/src/"
- FileSpec so_dir(so_path, false);
+ FileSpec so_dir(so_path);
if (!FileSystem::Instance().Exists(so_dir)) {
- so_dir.SetFile(&full_so_path[double_slash_pos + 1], false,
+ so_dir.SetFile(&full_so_path[double_slash_pos + 1],
FileSpec::Style::native);
if (FileSystem::Instance().Exists(so_dir)) {
// Trim off the incorrect path
std::vector<std::string> rpath_paths;
std::vector<std::string> rpath_relative_paths;
std::vector<std::string> at_exec_relative_paths;
- const bool resolve_path = false; // Don't resolve the dependent file paths
- // since they may not reside on this
- // system
uint32_t i;
for (i = 0; i < m_header.ncmds; ++i) {
const uint32_t cmd_offset = offset;
at_exec_relative_paths.push_back(path
+ strlen("@executable_path"));
} else {
- FileSpec file_spec(path, resolve_path);
+ FileSpec file_spec(path);
if (files.AppendIfUnique(file_spec))
count++;
}
}
FileSpec this_file_spec(m_file);
- this_file_spec.ResolvePath();
-
+ FileSystem::Instance().Resolve(this_file_spec);
+
if (!rpath_paths.empty()) {
// Fixup all LC_RPATH values to be absolute paths
std::string loader_path("@loader_path");
path += rpath_relative_path;
// It is OK to resolve this path because we must find a file on disk
// for us to accept it anyway if it is rpath relative.
- FileSpec file_spec(path, true);
+ FileSpec file_spec(path);
+ FileSystem::Instance().Resolve(file_spec);
if (FileSystem::Instance().Exists(file_spec) &&
files.AppendIfUnique(file_spec)) {
count++;
if (IsHost() || !m_remote_platform_sp)
return PlatformLinux::GetFile(source, destination);
- FileSpec source_spec(source.GetPath(false), false, FileSpec::Style::posix);
+ FileSpec source_spec(source.GetPath(false), FileSpec::Style::posix);
if (source_spec.IsRelative())
source_spec = GetRemoteWorkingDirectory().CopyByAppendingPathComponent(
source_spec.GetCString(false));
if (IsHost() || !m_remote_platform_sp)
return PlatformLinux::PutFile(source, destination, uid, gid);
- FileSpec destination_spec(destination.GetPath(false), false,
- FileSpec::Style::posix);
+ FileSpec destination_spec(destination.GetPath(false), FileSpec::Style::posix);
if (destination_spec.IsRelative())
destination_spec = GetRemoteWorkingDirectory().CopyByAppendingPathComponent(
destination_spec.GetCString(false));
log->Printf("Failed to remove temp directory: %s", error.AsCString());
});
- FileSpec symfile_platform_filespec(tmpdir, false);
+ FileSpec symfile_platform_filespec(tmpdir);
symfile_platform_filespec.AppendPathComponent("symbolized.oat");
// Execute oatdump on the remote device to generate a file with symtab
cs_path.Printf(
"%s/Library/PrivateFrameworks/CoreSimulator.framework/CoreSimulator",
developer_dir);
- const bool resolve_path = true;
- m_core_simulator_framework_path =
- FileSpec(cs_path.GetData(), resolve_path);
+ m_core_simulator_framework_path = FileSpec(cs_path.GetData());
+ FileSystem::Instance().Resolve(*m_core_simulator_framework_path);
}
}
EnumerateDirectoryCallback(void *baton, llvm::sys::fs::file_type ft,
llvm::StringRef path) {
if (ft == llvm::sys::fs::file_type::directory_file) {
- FileSpec file_spec(path, false);
+ FileSpec file_spec(path);
const char *filename = file_spec.GetFilename().GetCString();
if (filename &&
strncmp(filename, "AppleTVSimulator", strlen("AppleTVSimulator")) ==
platform_file_path);
// First try in the SDK and see if the file is in there
- local_file.SetFile(resolved_path, true, FileSpec::Style::native);
+ local_file.SetFile(resolved_path, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(local_file);
if (FileSystem::Instance().Exists(local_file))
return error;
// Else fall back to the actual path itself
- local_file.SetFile(platform_file_path, true, FileSpec::Style::native);
+ local_file.SetFile(platform_file_path, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(local_file);
if (FileSystem::Instance().Exists(local_file))
return error;
}
EnumerateDirectoryCallback(void *baton, llvm::sys::fs::file_type ft,
llvm::StringRef path) {
if (ft == llvm::sys::fs::file_type::directory_file) {
- FileSpec file_spec(path, false);
+ FileSpec file_spec(path);
const char *filename = file_spec.GetFilename().GetCString();
if (filename &&
strncmp(filename, "AppleWatchSimulator",
platform_file_path);
// First try in the SDK and see if the file is in there
- local_file.SetFile(resolved_path, true, FileSpec::Style::native);
+ local_file.SetFile(resolved_path, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(local_file);
if (FileSystem::Instance().Exists(local_file))
return error;
// Else fall back to the actual path itself
- local_file.SetFile(platform_file_path, true, FileSpec::Style::native);
+ local_file.SetFile(platform_file_path, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(local_file);
if (FileSystem::Instance().Exists(local_file))
return error;
}
"%s/../Python/%s.py",
symfile_spec.GetDirectory().GetCString(),
original_module_basename.c_str());
- FileSpec script_fspec(path_string.GetString(), true);
- FileSpec orig_script_fspec(original_path_string.GetString(),
- true);
+ FileSpec script_fspec(path_string.GetString());
+ FileSystem::Instance().Resolve(script_fspec);
+ FileSpec orig_script_fspec(original_path_string.GetString());
+ FileSystem::Instance().Resolve(orig_script_fspec);
// if we did some replacements of reserved characters, and a
// file with the untampered name exists, then warn the user
if (!cache_path.empty()) {
std::string module_path(module_spec.GetFileSpec().GetPath());
cache_path.append(module_path);
- FileSpec module_cache_spec(cache_path, false);
+ FileSpec module_cache_spec(cache_path);
// if rsync is supported, always bring in the file - rsync will be very
// efficient when files are the same on the local and remote end of the
snprintf(new_path + search_path_len,
sizeof(new_path) - search_path_len, "/%s",
platform_path + bundle_directory_len);
- FileSpec new_file_spec(new_path, false);
+ FileSpec new_file_spec(new_path);
if (FileSystem::Instance().Exists(new_file_spec)) {
ModuleSpec new_module_spec(module_spec);
new_module_spec.GetFileSpec() = new_file_spec;
if (xcode_select_prefix_dir)
xcode_dir_path.append(xcode_select_prefix_dir);
xcode_dir_path.append("/usr/share/xcode-select/xcode_dir_path");
- temp_file_spec.SetFile(xcode_dir_path, false, FileSpec::Style::native);
+ temp_file_spec.SetFile(xcode_dir_path, FileSpec::Style::native);
auto dir_buffer =
DataBufferLLVM::CreateFromPath(temp_file_spec.GetPath());
if (dir_buffer && dir_buffer->GetByteSize() > 0) {
}
if (!developer_dir_path_valid) {
- FileSpec xcode_select_cmd("/usr/bin/xcode-select", false);
+ FileSpec xcode_select_cmd("/usr/bin/xcode-select");
if (FileSystem::Instance().Exists(xcode_select_cmd)) {
int exit_status = -1;
int signo = -1;
}
developer_dir_path[i] = '\0';
- FileSpec devel_dir(developer_dir_path, false);
+ FileSpec devel_dir(developer_dir_path);
if (llvm::sys::fs::is_directory(devel_dir.GetPath())) {
developer_dir_path_valid = true;
}
}
if (developer_dir_path_valid) {
- temp_file_spec.SetFile(developer_dir_path, false,
- FileSpec::Style::native);
+ temp_file_spec.SetFile(developer_dir_path, FileSpec::Style::native);
if (FileSystem::Instance().Exists(temp_file_spec)) {
m_developer_directory.assign(developer_dir_path);
return m_developer_directory.c_str();
FileSpecList bp_modules;
for (size_t i = 0; i < llvm::array_lengthof(g_bp_modules); i++) {
const char *bp_module = g_bp_modules[i];
- bp_modules.Append(FileSpec(bp_module, false));
+ bp_modules.Append(FileSpec(bp_module));
}
bool internal = true;
size_t pos = path_to_shlib.rfind(substr);
if (pos != std::string::npos) {
path_to_shlib.erase(pos + strlen(substr));
- FileSpec ret(path_to_shlib, false);
+ FileSpec ret(path_to_shlib);
FileSpec xcode_binary_path = ret;
xcode_binary_path.AppendPathComponent("MacOS");
if (!g_xcode_filespec) {
const char *developer_dir_env_var = getenv("DEVELOPER_DIR");
if (developer_dir_env_var && developer_dir_env_var[0]) {
- g_xcode_filespec =
- CheckPathForXcode(FileSpec(developer_dir_env_var, true));
+ FileSpec developer_dir_spec = FileSpec(developer_dir_env_var);
+ FileSystem::Instance().Resolve(developer_dir_spec);
+ g_xcode_filespec = CheckPathForXcode(developer_dir_spec);
}
// Fall back to using "xcrun" to find the selected Xcode
}
output.append("/..");
- g_xcode_filespec = CheckPathForXcode(FileSpec(output, false));
+ g_xcode_filespec = CheckPathForXcode(FileSpec(output));
}
}
}
void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef path) {
SDKEnumeratorInfo *enumerator_info = static_cast<SDKEnumeratorInfo *>(baton);
- FileSpec spec(path, false);
+ FileSpec spec(path);
if (SDKSupportsModules(enumerator_info->sdk_type, spec)) {
enumerator_info->found_path = spec;
return FileSystem::EnumerateDirectoryResult::eEnumerateDirectoryResultNext;
GetUserSpecifiedDirectoriesToSearch();
// Add simple directory /Applications/Xcode.app/Contents/Developer/../Symbols
- FileSpec possible_dir(developer_dir + "/../Symbols", true);
+ FileSpec possible_dir(developer_dir + "/../Symbols");
+ FileSystem::Instance().Resolve(possible_dir);
if (llvm::sys::fs::is_directory(possible_dir.GetPath()))
m_search_directories.push_back(possible_dir);
// Add simple directory of the current working directory
- m_search_directories_no_recursing.push_back(FileSpec(".", true));
+ FileSpec cwd(".");
+ FileSystem::Instance().Resolve(cwd);
+ m_search_directories_no_recursing.push_back(cwd);
}
void PlatformDarwinKernel::GetUserSpecifiedDirectoriesToSearch() {
const uint32_t user_dirs_count = user_dirs.GetSize();
for (uint32_t i = 0; i < user_dirs_count; i++) {
FileSpec dir = user_dirs.GetFileSpecAtIndex(i);
- dir.ResolvePath();
+ FileSystem::Instance().Resolve(dir);
if (llvm::sys::fs::is_directory(dir.GetPath())) {
m_search_directories.push_back(dir);
}
// /AppleInternal/Developer/KDKs/*.kdk/...
nullptr};
for (int i = 0; subdirs[i] != nullptr; i++) {
- FileSpec testdir(dir + subdirs[i], true);
+ FileSpec testdir(dir + subdirs[i]);
+ FileSystem::Instance().Resolve(testdir);
if (llvm::sys::fs::is_directory(testdir.GetPath()))
thisp->m_search_directories.push_back(testdir);
}
// Look for kernel binaries in the top level directory, without any recursion
- thisp->m_search_directories_no_recursing.push_back(
- FileSpec(dir + "/", false));
+ thisp->m_search_directories_no_recursing.push_back(FileSpec(dir + "/"));
}
// Given a directory path dir, look for any subdirs named *.kdk and *.sdk
static ConstString g_kdk_suffix = ConstString(".kdk");
PlatformDarwinKernel *thisp = (PlatformDarwinKernel *)baton;
- FileSpec file_spec(path, false);
+ FileSpec file_spec(path);
if (ft == llvm::sys::fs::file_type::directory_file &&
(file_spec.GetFileNameExtension() == g_sdk_suffix ||
file_spec.GetFileNameExtension() == g_kdk_suffix)) {
static ConstString g_dsym_suffix = ConstString(".dSYM");
static ConstString g_bundle_suffix = ConstString("Bundle");
- FileSpec file_spec(path, false);
+ FileSpec file_spec(path);
ConstString file_spec_extension = file_spec.GetFileNameExtension();
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
file_spec_extension == g_kext_suffix) {
AddKextToMap(thisp, file_spec);
// Look to see if there is a PlugIns subdir with more kexts
- FileSpec contents_plugins(file_spec.GetPath() + "/Contents/PlugIns", false);
+ FileSpec contents_plugins(file_spec.GetPath() + "/Contents/PlugIns");
std::string search_here_too;
if (llvm::sys::fs::is_directory(contents_plugins.GetPath())) {
search_here_too = contents_plugins.GetPath();
} else {
- FileSpec plugins(file_spec.GetPath() + "/PlugIns", false);
+ FileSpec plugins(file_spec.GetPath() + "/PlugIns");
if (llvm::sys::fs::is_directory(plugins.GetPath())) {
search_here_too = plugins.GetPath();
}
kext_bundle_filepath.GetPath() + "/Contents/MacOS/";
deep_bundle_str += executable_name.AsCString();
deep_bundle_str += ".dSYM";
- dsym_fspec.SetFile(deep_bundle_str, true, FileSpec::Style::native);
+ dsym_fspec.SetFile(deep_bundle_str, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(dsym_fspec);
if (llvm::sys::fs::is_directory(dsym_fspec.GetPath())) {
return true;
}
std::string shallow_bundle_str = kext_bundle_filepath.GetPath() + "/";
shallow_bundle_str += executable_name.AsCString();
shallow_bundle_str += ".dSYM";
- dsym_fspec.SetFile(shallow_bundle_str, true, FileSpec::Style::native);
+ dsym_fspec.SetFile(shallow_bundle_str, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(dsym_fspec);
if (llvm::sys::fs::is_directory(dsym_fspec.GetPath())) {
return true;
}
break;
if (llvm::sys::fs::is_regular_file(*status) &&
llvm::sys::fs::can_execute(it->path()))
- executables.emplace_back(it->path(), false);
+ executables.emplace_back(it->path());
}
return executables;
}
"SDKs/MacOSX%u.%u.sdk",
xcode_contents_path.c_str(), versions[0],
versions[1]);
- fspec.SetFile(sdk_path.GetString(), false, FileSpec::Style::native);
+ fspec.SetFile(sdk_path.GetString(), FileSpec::Style::native);
if (FileSystem::Instance().Exists(fspec))
return ConstString(sdk_path.GetString());
}
if (!default_xcode_sdk.empty()) {
- fspec.SetFile(default_xcode_sdk, false, FileSpec::Style::native);
+ fspec.SetFile(default_xcode_sdk, FileSpec::Style::native);
if (FileSystem::Instance().Exists(fspec))
return ConstString(default_xcode_sdk);
}
std::string cache_path(GetLocalCacheDirectory());
std::string module_path(platform_file.GetPath());
cache_path.append(module_path);
- FileSpec module_cache_spec(cache_path, false);
+ FileSpec module_cache_spec(cache_path);
if (FileSystem::Instance().Exists(module_cache_spec)) {
local_file = module_cache_spec;
return Status();
PlatformRemoteDarwinDevice::GetContainedFilesIntoVectorOfStringsCallback(
void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path) {
((PlatformRemoteDarwinDevice::SDKDirectoryInfoCollection *)baton)
- ->push_back(
- PlatformRemoteDarwinDevice::SDKDirectoryInfo(FileSpec(path, false)));
+ ->push_back(PlatformRemoteDarwinDevice::SDKDirectoryInfo(FileSpec(path)));
return FileSystem::eEnumerateDirectoryResultNext;
}
if (m_sdk_directory_infos.empty()) {
// A --sysroot option was supplied - add it to our list of SDKs to check
if (m_sdk_sysroot) {
- FileSpec sdk_sysroot_fspec(m_sdk_sysroot.GetCString(), true);
+ FileSpec sdk_sysroot_fspec(m_sdk_sysroot.GetCString());
+ FileSystem::Instance().Resolve(sdk_sysroot_fspec);
const SDKDirectoryInfo sdk_sysroot_directory_info(sdk_sysroot_fspec);
m_sdk_directory_infos.push_back(sdk_sysroot_directory_info);
if (log) {
const uint32_t num_installed = m_sdk_directory_infos.size();
std::string local_sdk_cache_str = "~/Library/Developer/Xcode/";
local_sdk_cache_str += dirname;
- FileSpec local_sdk_cache(local_sdk_cache_str.c_str(), true);
+ FileSpec local_sdk_cache(local_sdk_cache_str.c_str());
+ FileSystem::Instance().Resolve(local_sdk_cache);
if (FileSystem::Instance().Exists(local_sdk_cache)) {
if (log) {
log->Printf("PlatformRemoteDarwinDevice::UpdateSDKDirectoryInfosIfNeeded "
const char *paths_to_try[] = {"Symbols", "", "Symbols.Internal", nullptr};
for (size_t i = 0; paths_to_try[i] != nullptr; i++) {
- local_file.SetFile(sdkroot_path, false, FileSpec::Style::native);
+ local_file.SetFile(sdkroot_path, FileSpec::Style::native);
if (paths_to_try[i][0] != '\0')
local_file.AppendPathComponent(paths_to_try[i]);
local_file.AppendPathComponent(platform_file_path);
- local_file.ResolvePath();
+ FileSystem::Instance().Resolve(local_file);
if (FileSystem::Instance().Exists(local_file)) {
if (log)
log->Printf("Found a copy of %s in the SDK dir %s/%s",
::snprintf(resolved_path, sizeof(resolved_path), "%s/%s", os_version_dir,
platform_file_path);
- local_file.SetFile(resolved_path, true, FileSpec::Style::native);
+ local_file.SetFile(resolved_path, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(local_file);
if (FileSystem::Instance().Exists(local_file)) {
if (log) {
log->Printf("Found a copy of %s in the DeviceSupport dir %s",
::snprintf(resolved_path, sizeof(resolved_path), "%s/Symbols.Internal/%s",
os_version_dir, platform_file_path);
- local_file.SetFile(resolved_path, true, FileSpec::Style::native);
+ local_file.SetFile(resolved_path, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(local_file);
if (FileSystem::Instance().Exists(local_file)) {
if (log) {
log->Printf(
::snprintf(resolved_path, sizeof(resolved_path), "%s/Symbols/%s",
os_version_dir, platform_file_path);
- local_file.SetFile(resolved_path, true, FileSpec::Style::native);
+ local_file.SetFile(resolved_path, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(local_file);
if (FileSystem::Instance().Exists(local_file)) {
if (log) {
log->Printf("Found a copy of %s in the DeviceSupport dir %s/Symbols",
EnumerateDirectoryCallback(void *baton, llvm::sys::fs::file_type ft,
llvm::StringRef path) {
if (ft == llvm::sys::fs::file_type::directory_file) {
- FileSpec file_spec(path, false);
+ FileSpec file_spec(path);
const char *filename = file_spec.GetFilename().GetCString();
if (filename &&
strncmp(filename, "iPhoneSimulator", strlen("iPhoneSimulator")) == 0) {
platform_file_path);
// First try in the SDK and see if the file is in there
- local_file.SetFile(resolved_path, true, FileSpec::Style::native);
+ local_file.SetFile(resolved_path, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(local_file);
if (FileSystem::Instance().Exists(local_file))
return error;
// Else fall back to the actual path itself
- local_file.SetFile(platform_file_path, true, FileSpec::Style::native);
+ local_file.SetFile(platform_file_path, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(local_file);
if (FileSystem::Instance().Exists(local_file))
return error;
}
// Check in case our file action open wants to open the slave
const char *slave_path = launch_info.GetPTY().GetSlaveName(NULL, 0);
if (slave_path) {
- FileSpec slave_spec(slave_path, false);
+ FileSpec slave_spec(slave_path);
if (file_spec == slave_spec) {
int slave_fd = launch_info.GetPTY().GetSlaveFileDescriptor();
if (slave_fd == PseudoTerminal::invalid_fd)
// on the current path variables
if (!FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) {
resolved_module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
- resolved_module_spec.GetFileSpec().SetFile(exe_path, true,
+ resolved_module_spec.GetFileSpec().SetFile(exe_path,
FileSpec::Style::native);
+ FileSystem::Instance().Resolve(resolved_module_spec.GetFileSpec());
}
if (!FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec()))
std::string name_string;
process->ReadCStringFromMemory(buffer_addr, name_string, utility_error);
if (utility_error.Success())
- loaded_image->SetFile(name_string, false,
- llvm::sys::path::Style::posix);
+ loaded_image->SetFile(name_string, llvm::sys::path::Style::posix);
}
return process->AddImageToken(token);
}
// variables
if (!FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) {
resolved_module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
- resolved_module_spec.GetFileSpec().SetFile(exe_path, true,
+ resolved_module_spec.GetFileSpec().SetFile(exe_path,
FileSpec::Style::native);
+ FileSystem::Instance().Resolve(resolved_module_spec.GetFileSpec());
}
if (!FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec()))
FileSpec stdout_file_spec{};
FileSpec stderr_file_spec{};
- const FileSpec dbg_pts_file_spec{launch_info.GetPTY().GetSlaveName(NULL, 0),
- false};
+ const FileSpec dbg_pts_file_spec{launch_info.GetPTY().GetSlaveName(NULL, 0)};
file_action = launch_info.GetFileActionForFD(STDIN_FILENO);
stdin_file_spec =
m_supports_mem_region = LazyBool::eLazyBoolNo;
return parse_error;
}
- m_mem_region_cache.emplace_back(
- info, FileSpec(info.GetName().GetCString(), true));
+ FileSpec file_spec(info.GetName().GetCString());
+ FileSystem::Instance().Resolve(file_spec);
+ m_mem_region_cache.emplace_back(info, file_spec);
}
if (m_mem_region_cache.empty()) {
if (error.Fail())
return error;
- FileSpec module_file_spec(module_path, true);
+ FileSpec module_file_spec(module_path);
+ FileSystem::Instance().Resolve(module_file_spec);
file_spec.Clear();
for (const auto &it : m_mem_region_cache) {
if (error.Fail())
return error;
- FileSpec file(file_name, false);
+ FileSpec file(file_name);
for (const auto &it : m_mem_region_cache) {
if (it.second == file) {
load_addr = it.first.GetRange().GetRangeBase();
ModuleSpec exe_module_spec;
exe_module_spec.GetArchitecture() = arch;
exe_module_spec.GetFileSpec().SetFile(
- m_nt_file_entries[0].path.GetCString(), false,
- FileSpec::Style::native);
+ m_nt_file_entries[0].path.GetCString(), FileSpec::Style::native);
if (exe_module_spec.GetFileSpec()) {
exe_module_sp = GetTarget().GetSharedModule(exe_module_spec);
if (exe_module_sp)
// debugserver to use and use it if we do.
const char *env_debugserver_path = getenv("LLDB_DEBUGSERVER_PATH");
if (env_debugserver_path) {
- debugserver_file_spec.SetFile(env_debugserver_path, false,
+ debugserver_file_spec.SetFile(env_debugserver_path,
FileSpec::Style::native);
if (log)
log->Printf("GDBRemoteCommunication::%s() gdb-remote stub exe path set "
return false;
std::string cwd;
response.GetHexByteString(cwd);
- working_dir.SetFile(cwd, false, GetHostArchitecture().GetTriple());
+ working_dir.SetFile(cwd, GetHostArchitecture().GetTriple());
return !cwd.empty();
}
return false;
// characters in a process name
std::string name;
extractor.GetHexByteString(name);
- process_info.GetExecutableFile().SetFile(name, false,
- FileSpec::Style::native);
+ process_info.GetExecutableFile().SetFile(name, FileSpec::Style::native);
} else if (name.equals("cputype")) {
value.getAsInteger(0, cpu);
} else if (name.equals("cpusubtype")) {
StringExtractor extractor(value);
std::string path;
extractor.GetHexByteString(path);
- module_spec.GetFileSpec() = FileSpec(path, false, arch_spec.GetTriple());
+ module_spec.GetFileSpec() = FileSpec(path, arch_spec.GetTriple());
}
}
if (!dict->GetValueForKeyAsString("file_path", string))
return llvm::None;
- result.GetFileSpec() =
- FileSpec(string, false, result.GetArchitecture().GetTriple());
+ result.GetFileSpec() = FileSpec(string, result.GetArchitecture().GetTriple());
return result;
}
std::string file;
extractor.GetHexByteString(file);
match_info.GetProcessInfo().GetExecutableFile().SetFile(
- file, false, FileSpec::Style::native);
+ file, FileSpec::Style::native);
} else if (key.equals("name_match")) {
NameMatch name_match = llvm::StringSwitch<NameMatch>(value)
.Case("equals", NameMatch::Equals)
if (packet.GetChar() == ',') {
mode_t mode = packet.GetHexMaxU32(false, 0600);
Status error;
- const FileSpec path_spec{path, true};
+ FileSpec path_spec(path);
+ FileSystem::Instance().Resolve(path_spec);
int fd = ::open(path_spec.GetCString(), flags, mode);
const int save_errno = fd == -1 ? errno : 0;
StreamString response;
packet.GetHexByteString(path);
if (!path.empty()) {
Status error;
- const uint32_t mode = File::GetPermissions(FileSpec{path, true}, error);
+ FileSpec file_spec(path);
+ FileSystem::Instance().Resolve(file_spec);
+ const uint32_t mode = File::GetPermissions(file_spec, error);
StreamString response;
response.Printf("F%u", mode);
if (mode == 0 || error.Fail())
packet.GetHexByteStringTerminatedBy(dst, ',');
packet.GetChar(); // Skip ',' char
packet.GetHexByteString(src);
- Status error = FileSystem::Instance().Symlink(FileSpec{src, true}, FileSpec{dst, false});
+
+ FileSpec src_spec(src);
+ FileSystem::Instance().Resolve(src_spec);
+ Status error = FileSystem::Instance().Symlink(src_spec, FileSpec(dst));
+
StreamString response;
response.Printf("F%u,%u", error.GetError(), error.GetError());
return SendPacketNoLock(response.GetString());
packet.GetHexByteString(working_dir);
int status, signo;
std::string output;
- Status err = Host::RunShellCommand(
- path.c_str(), FileSpec{working_dir, true}, &status, &signo, &output,
- std::chrono::seconds(10));
+ FileSpec working_spec(working_dir);
+ FileSystem::Instance().Resolve(working_spec);
+ Status err =
+ Host::RunShellCommand(path.c_str(), working_spec, &status, &signo,
+ &output, std::chrono::seconds(10));
StreamGDBRemote response;
if (err.Fail()) {
response.PutCString("F,");
packet.GetHexByteString(path);
const bool read = true;
const bool write = false;
- if (file_action.Open(STDIN_FILENO, FileSpec{path, false}, read, write)) {
+ if (file_action.Open(STDIN_FILENO, FileSpec(path), read, write)) {
m_process_launch_info.AppendFileAction(file_action);
return SendOKResponse();
}
packet.GetHexByteString(path);
const bool read = false;
const bool write = true;
- if (file_action.Open(STDOUT_FILENO, FileSpec{path, false}, read, write)) {
+ if (file_action.Open(STDOUT_FILENO, FileSpec(path), read, write)) {
m_process_launch_info.AppendFileAction(file_action);
return SendOKResponse();
}
packet.GetHexByteString(path);
const bool read = false;
const bool write = true;
- if (file_action.Open(STDERR_FILENO, FileSpec{path, false}, read, write)) {
+ if (file_action.Open(STDERR_FILENO, FileSpec(path), read, write)) {
m_process_launch_info.AppendFileAction(file_action);
return SendOKResponse();
}
if (success) {
if (arg_idx == 0)
m_process_launch_info.GetExecutableFile().SetFile(
- arg, false, FileSpec::Style::native);
+ arg, FileSpec::Style::native);
m_process_launch_info.GetArguments().AppendArgument(arg);
if (log)
log->Printf("LLGSPacketHandler::%s added arg %d: \"%s\"",
#ifdef __ANDROID__
return HostInfoAndroid::ResolveLibraryPath(module_path, arch);
#else
- return FileSpec(module_path, true);
+ FileSpec file_spec(module_path);
+ FileSystem::Instance().Resolve(file_spec);
+ return file_spec;
#endif
}
llvm::StringRef triple) {
ArchSpec arch(triple);
- const FileSpec req_module_path_spec(module_path, true);
+ FileSpec req_module_path_spec(module_path);
+ FileSystem::Instance().Resolve(req_module_path_spec);
+
const FileSpec module_path_spec =
FindModuleFile(req_module_path_spec.GetPath(), arch);
const ModuleSpec module_spec(module_path_spec, arch);
packet.SetFilePos(::strlen("QSetWorkingDir:"));
std::string path;
packet.GetHexByteString(path);
- m_process_launch_info.SetWorkingDirectory(FileSpec{path, true});
+ m_process_launch_info.SetWorkingDirectory(FileSpec(path));
return SendOKResponse();
}
const char *domainsocket_dir_env =
::getenv("LLDB_DEBUGSERVER_DOMAINSOCKET_DIR");
if (domainsocket_dir_env != nullptr)
- g_domainsocket_dir = FileSpec(domainsocket_dir_env, false);
+ g_domainsocket_dir = FileSpec(domainsocket_dir_env);
else
g_domainsocket_dir = HostInfo::GetProcessTempDir();
});
socket_path_spec.AppendPathComponent(socket_name.c_str());
llvm::sys::fs::createUniqueFile(socket_path_spec.GetCString(), socket_path);
- return FileSpec(socket_path.c_str(), false);
+ return FileSpec(socket_path.c_str());
}
void GDBRemoteCommunicationServerPlatform::SetPortOffset(uint16_t port_offset) {
if (!FileSystem::Instance().Exists(target_definition_fspec)) {
// If the filename doesn't exist, it may be a ~ not having been expanded -
// try to resolve it.
- target_definition_fspec.ResolvePath();
+ FileSystem::Instance().Resolve(target_definition_fspec);
}
if (target_definition_fspec) {
// See if we can get register definitions from a python file
if (disable_stdio) {
// set to /dev/null unless redirected to a file above
if (!stdin_file_spec)
- stdin_file_spec.SetFile(FileSystem::DEV_NULL, false,
+ stdin_file_spec.SetFile(FileSystem::DEV_NULL,
FileSpec::Style::native);
if (!stdout_file_spec)
- stdout_file_spec.SetFile(FileSystem::DEV_NULL, false,
+ stdout_file_spec.SetFile(FileSystem::DEV_NULL,
FileSpec::Style::native);
if (!stderr_file_spec)
- stderr_file_spec.SetFile(FileSystem::DEV_NULL, false,
+ stderr_file_spec.SetFile(FileSystem::DEV_NULL,
FileSpec::Style::native);
} else if (platform_sp && platform_sp->IsHost()) {
// If the debugserver is local and we aren't disabling STDIO, lets use
// does a lot of output.
if ((!stdin_file_spec || !stdout_file_spec || !stderr_file_spec) &&
pty.OpenFirstAvailableMaster(O_RDWR | O_NOCTTY, NULL, 0)) {
- FileSpec slave_name{pty.GetSlaveName(NULL, 0), false};
+ FileSpec slave_name{pty.GetSlaveName(NULL, 0)};
if (!stdin_file_spec)
stdin_file_spec = slave_name;
if (!modInfo.get_link_map(link_map))
link_map = LLDB_INVALID_ADDRESS;
- FileSpec file(mod_name, true);
+ FileSpec file(mod_name);
+ FileSystem::Instance().Resolve(file);
lldb::ModuleSP module_sp =
LoadModuleAtAddress(file, link_map, mod_base, mod_base_is_offset);
}
const auto uuid = m_minidump_parser.GetModuleUUID(module);
- const auto file_spec =
- FileSpec(name.getValue(), true, GetArchitecture().GetTriple());
+ auto file_spec = FileSpec(name.getValue(), GetArchitecture().GetTriple());
+ FileSystem::Instance().Resolve(file_spec);
ModuleSpec module_spec(file_spec, uuid);
Status error;
lldb::ModuleSP module_sp = GetTarget().GetSharedModule(module_spec, &error);
lldb::DebuggerSP debugger_sp = m_interpreter.GetDebugger().shared_from_this();
{
- FileSpec target_file(pathname, true);
+ FileSpec target_file(pathname);
+ FileSystem::Instance().Resolve(target_file);
std::string basename(target_file.GetFilename().GetCString());
StreamString command_stream;
// Build up the module list.
FileSpecList module_spec_list;
auto module_file_spec =
- FileSpec(GetGlobalProperties()->GetLoggingModuleName(), false);
+ FileSpec(GetGlobalProperties()->GetLoggingModuleName());
module_spec_list.Append(module_file_spec);
// We aren't specifying a source file set.
for (uint32_t file_idx = 1;
prologue.GetFile(file_idx, cu_comp_dir, file_spec); ++file_idx) {
if (module_sp->RemapSourceFile(file_spec.GetPath(), remapped_file))
- file_spec.SetFile(remapped_file, false, FileSpec::Style::native);
+ file_spec.SetFile(remapped_file, FileSpec::Style::native);
support_files.Append(file_spec);
}
return true;
const lldb_private::FileSpec &comp_dir, FileSpec &file) const {
uint32_t idx = file_idx - 1; // File indexes are 1 based...
if (idx < file_names.size()) {
- file.SetFile(file_names[idx].name, false, FileSpec::Style::native);
+ file.SetFile(file_names[idx].name, FileSpec::Style::native);
if (file.IsRelative()) {
if (file_names[idx].dir_idx > 0) {
const uint32_t dir_idx = file_names[idx].dir_idx - 1;
bool is_symlink = false;
// Always normalize our compile unit directory to get rid of redundant
// slashes and other path anomalies before we use it for path prepending
- FileSpec local_spec(local_path, false);
+ FileSpec local_spec(local_path);
const auto &file_specs = GetGlobalPluginProperties()->GetSymLinkPaths();
for (size_t i = 0; i < file_specs.GetSize() && !is_symlink; ++i)
is_symlink = FileSpec::Equal(file_specs.GetFileSpecAtIndex(i),
if (module_sp) {
const DWARFDIE cu_die = dwarf_cu->DIE();
if (cu_die) {
- FileSpec cu_file_spec{cu_die.GetName(), false};
+ FileSpec cu_file_spec(cu_die.GetName());
if (cu_file_spec) {
// 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
std::string remapped_file;
if (module_sp->RemapSourceFile(cu_file_spec.GetPath(),
remapped_file))
- cu_file_spec.SetFile(remapped_file, false,
- FileSpec::Style::native);
+ cu_file_spec.SetFile(remapped_file, FileSpec::Style::native);
}
LanguageType cu_language = DWARFUnit::LanguageTypeFromDWARF(
return dwo_symfile;
}
- FileSpec dwo_file(dwo_name, true);
+ FileSpec dwo_file(dwo_name);
+ FileSystem::Instance().Resolve(dwo_file);
if (dwo_file.IsRelative()) {
const char *comp_dir = cu_die.GetAttributeValueAsString(
this, &dwarf_cu, DW_AT_comp_dir, nullptr);
if (!comp_dir)
return nullptr;
- dwo_file.SetFile(comp_dir, true, FileSpec::Style::native);
+ dwo_file.SetFile(comp_dir, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(dwo_file);
dwo_file.AppendPathComponent(dwo_name);
}
die.GetAttributeValueAsString(DW_AT_GNU_dwo_name, nullptr);
if (dwo_path) {
ModuleSpec dwo_module_spec;
- dwo_module_spec.GetFileSpec().SetFile(dwo_path, false,
+ dwo_module_spec.GetFileSpec().SetFile(dwo_path,
FileSpec::Style::native);
if (dwo_module_spec.GetFileSpec().IsRelative()) {
const char *comp_dir =
die.GetAttributeValueAsString(DW_AT_comp_dir, nullptr);
if (comp_dir) {
- dwo_module_spec.GetFileSpec().SetFile(comp_dir, true,
+ dwo_module_spec.GetFileSpec().SetFile(comp_dir,
FileSpec::Style::native);
+ FileSystem::Instance().Resolve(dwo_module_spec.GetFileSpec());
dwo_module_spec.GetFileSpec().AppendPathComponent(dwo_path);
}
}
ModuleSpec module_spec;
module_spec.GetFileSpec() = m_obj_file->GetFileSpec();
module_spec.GetSymbolFileSpec() =
- FileSpec(m_obj_file->GetFileSpec().GetPath() + ".dwp", false);
+ FileSpec(m_obj_file->GetFileSpec().GetPath() + ".dwp");
FileSpec dwp_filespec = Symbols::LocateExecutableSymbolFile(module_spec);
if (FileSystem::Instance().Exists(dwp_filespec)) {
m_dwp_symfile = SymbolFileDWARFDwp::Create(GetObjectFile()->GetModule(),
so_symbol->GetType() == eSymbolTypeSourceFile &&
oso_symbol->GetType() == eSymbolTypeObjectFile) {
m_compile_unit_infos[i].so_file.SetFile(
- so_symbol->GetName().AsCString(), false, FileSpec::Style::native);
+ so_symbol->GetName().AsCString(), FileSpec::Style::native);
m_compile_unit_infos[i].oso_path = oso_symbol->GetName();
m_compile_unit_infos[i].oso_mod_time =
llvm::sys::toTimePoint(oso_symbol->GetIntegerValue(0));
m_oso_map[{comp_unit_info->oso_path, comp_unit_info->oso_mod_time}] =
comp_unit_info->oso_sp;
const char *oso_path = comp_unit_info->oso_path.GetCString();
- FileSpec oso_file(oso_path, false);
+ FileSpec oso_file(oso_path);
ConstString oso_object;
if (FileSystem::Instance().Exists(oso_file)) {
auto oso_mod_time = FileSystem::Instance().GetModificationTime(oso_file);
llvm::StringRef source_file_name =
m_index->compilands().GetMainSourceFile(cci);
- FileSpec fs(source_file_name, false);
+ FileSpec fs(source_file_name);
CompUnitSP cu_sp =
std::make_shared<CompileUnit>(m_obj_file->GetModule(), nullptr, fs,
for (llvm::StringRef f : cci->m_file_list) {
FileSpec::Style style =
f.startswith("/") ? FileSpec::Style::posix : FileSpec::Style::windows;
- FileSpec spec(f, false, style);
+ FileSpec spec(f, style);
support_files.Append(spec);
}
if (!src_file_up)
return false;
- FileSpec spec(src_file_up->getFileName(), /*resolve_path*/ false);
+ FileSpec spec(src_file_up->getFileName());
decl.SetFile(spec);
decl.SetColumn(first_line_up->getColumnNumber());
decl.SetLine(first_line_up->getLineNumber());
return false;
while (auto file = files->getNext()) {
- FileSpec spec(file->getFileName(), false, FileSpec::Style::windows);
+ FileSpec spec(file->getFileName(), FileSpec::Style::windows);
support_files.AppendIfUnique(spec);
}
std::string source_file = compiland->getSourceFileFullPath();
if (source_file.empty())
continue;
- FileSpec this_spec(source_file, false, FileSpec::Style::windows);
+ FileSpec this_spec(source_file, FileSpec::Style::windows);
bool need_full_match = !file_spec.GetDirectory().IsEmpty();
if (FileSpec::Compare(file_spec, this_spec, need_full_match) != 0)
continue;
uint32_t src_file_id = first_line->getSourceFileId();
auto src_file = m_session_up->getSourceFileById(src_file_id);
if (src_file) {
- FileSpec spec(src_file->getFileName(), /*resolve_path*/ false);
+ FileSpec spec(src_file->getFileName());
decl.SetFile(spec);
decl.SetColumn(first_line->getColumnNumber());
decl.SetLine(first_line->getLineNumber());
const FileSpec fspec = file_spec_list.GetFileSpecAtIndex(idx);
module_spec.GetFileSpec() = obj_file->GetFileSpec();
- module_spec.GetFileSpec().ResolvePath();
+ FileSystem::Instance().Resolve(module_spec.GetFileSpec());
module_spec.GetSymbolFileSpec() = fspec;
module_spec.GetUUID() = uuid;
FileSpec dsym_fspec = Symbols::LocateExecutableSymbolFile(module_spec);
resources[strlen("/Contents/Resources/")] = '\0';
snprintf(dsym_uuid_plist_path, sizeof(dsym_uuid_plist_path),
"%s%s.plist", dsym_path, uuid_str.c_str());
- FileSpec dsym_uuid_plist_spec(dsym_uuid_plist_path, false);
+ FileSpec dsym_uuid_plist_spec(dsym_uuid_plist_path);
if (FileSystem::Instance().Exists(dsym_uuid_plist_spec)) {
ApplePropertyList plist(dsym_uuid_plist_path);
if (plist) {
}
if (DBGSourcePath[0] == '~') {
FileSpec resolved_source_path(
- DBGSourcePath.c_str(), true);
+ DBGSourcePath.c_str());
+ FileSystem::Instance().Resolve(
+ resolved_source_path);
DBGSourcePath =
resolved_source_path.GetPath();
}
// Add this as another option in addition to
// the full source path remap.
if (do_truncate_remapping_names) {
- FileSpec build_path(key.AsCString(), false);
- FileSpec source_path(DBGSourcePath.c_str(), false);
+ FileSpec build_path(key.AsCString());
+ FileSpec source_path(DBGSourcePath.c_str());
build_path.RemoveLastPathComponent();
build_path.RemoveLastPathComponent();
source_path.RemoveLastPathComponent();
if (!DBGBuildSourcePath.empty() &&
!DBGSourcePath.empty()) {
if (DBGSourcePath[0] == '~') {
- FileSpec resolved_source_path(DBGSourcePath.c_str(),
- true);
+ FileSpec resolved_source_path(DBGSourcePath.c_str());
+ FileSystem::Instance().Resolve(resolved_source_path);
DBGSourcePath = resolved_source_path.GetPath();
}
module_sp->GetSourceMappingList().Append(
// libdispatch symbols were in libSystem.B.dylib up through Mac OS X 10.6
// ("Snow Leopard")
- ModuleSpec libSystem_module_spec(FileSpec("libSystem.B.dylib", false));
+ ModuleSpec libSystem_module_spec(FileSpec("libSystem.B.dylib"));
ModuleSP module_sp(m_process->GetTarget().GetImages().FindFirstModule(
libSystem_module_spec));
if (module_sp)
// libdispatch symbols are in their own dylib as of Mac OS X 10.7 ("Lion")
// and later
if (dispatch_queue_offsets_symbol == NULL) {
- ModuleSpec libdispatch_module_spec(FileSpec("libdispatch.dylib", false));
+ ModuleSpec libdispatch_module_spec(FileSpec("libdispatch.dylib"));
module_sp = m_process->GetTarget().GetImages().FindFirstModule(
libdispatch_module_spec);
if (module_sp)
"pthread_layout_offsets");
const Symbol *libpthread_layout_offsets_symbol = NULL;
- ModuleSpec libpthread_module_spec(FileSpec("libsystem_pthread.dylib", false));
+ ModuleSpec libpthread_module_spec(FileSpec("libsystem_pthread.dylib"));
ModuleSP module_sp(m_process->GetTarget().GetImages().FindFirstModule(
libpthread_module_spec));
if (module_sp) {
"dispatch_tsd_indexes");
const Symbol *libdispatch_tsd_indexes_symbol = NULL;
- ModuleSpec libpthread_module_spec(FileSpec("libdispatch.dylib", false));
+ ModuleSpec libpthread_module_spec(FileSpec("libdispatch.dylib"));
ModuleSP module_sp(m_process->GetTarget().GetImages().FindFirstModule(
libpthread_module_spec));
if (module_sp) {
const char *pathname, const lldb::user_id_t cu_sym_id,
lldb::LanguageType language,
lldb_private::LazyBool is_optimized)
- : ModuleChild(module_sp), FileSpec(pathname, false), UserID(cu_sym_id),
+ : ModuleChild(module_sp), FileSpec(pathname), UserID(cu_sym_id),
m_user_data(user_data), m_language(language), m_flags(0),
m_support_files(), m_line_table_ap(), m_variables(),
m_is_optimized(is_optimized) {
std::string obj;
if (regex_match.GetMatchAtIndex(path_with_object, 1, path) &&
regex_match.GetMatchAtIndex(path_with_object, 2, obj)) {
- archive_file.SetFile(path, false, FileSpec::Style::native);
+ archive_file.SetFile(path, FileSpec::Style::native);
archive_object.SetCString(obj.c_str());
if (must_exist && !FileSystem::Instance().Exists(archive_file))
return false;
// back into a string that is the re-exported name.
intptr_t str_ptr = m_addr_range.GetByteSize();
if (str_ptr != 0)
- return FileSpec((const char *)str_ptr, false);
+ return FileSpec((const char *)str_ptr);
}
return FileSpec();
}
break;
case eModuleSpecified: {
// See if we can find the Module, if so stick it in the SymbolContext.
- FileSpec module_file_spec(spec_string, false);
+ FileSpec module_file_spec(spec_string);
ModuleSpec module_spec(module_file_spec);
lldb::ModuleSP module_sp(
m_target_sp->GetImages().FindFirstModule(module_spec));
// CompUnits can't necessarily be resolved here, since an inlined function
// might show up in a number of CompUnits. Instead we just convert to a
// FileSpec and store it away.
- m_file_spec_ap.reset(new FileSpec(spec_string, false));
+ m_file_spec_ap.reset(new FileSpec(spec_string));
m_type |= eFileSpecified;
break;
case eLineStartSpecified:
if (m_module_sp.get() != sc.module_sp.get())
return false;
} else {
- FileSpec module_file_spec(m_module_spec, false);
+ FileSpec module_file_spec(m_module_spec);
if (!FileSpec::Equal(module_file_spec, sc.module_sp->GetFileSpec(),
false))
return false;
}
FileSpec GetSymbolFileSpec(const FileSpec &module_file_spec) {
- return FileSpec(module_file_spec.GetPath() + kSymFileExtension, false);
+ return FileSpec(module_file_spec.GetPath() + kSymFileExtension);
}
void DeleteExistingModule(const FileSpec &root_dir_spec,
}
const auto error = MakeDirectory(
- FileSpec(sysroot_module_path_spec.GetDirectory().AsCString(), false));
+ FileSpec(sysroot_module_path_spec.GetDirectory().AsCString()));
if (error.Fail())
return error;
ConstString NormalizePath(const ConstString &path) {
// If we use "path" to construct a FileSpec, it will normalize the path for
// us. We then grab the string and turn it back into a ConstString.
- return ConstString(FileSpec(path.GetStringRef(), false).GetPath());
+ return ConstString(FileSpec(path.GetStringRef()).GetPath());
}
}
//----------------------------------------------------------------------
// We need to figure out if the "path" argument is relative. If it is,
// then we should remap, else skip this entry.
if (path_is_relative == eLazyBoolCalculate) {
- path_is_relative = FileSpec(path, false).IsRelative() ? eLazyBoolYes :
- eLazyBoolNo;
+ path_is_relative =
+ FileSpec(path).IsRelative() ? eLazyBoolYes : eLazyBoolNo;
}
if (!path_is_relative)
continue;
}
- FileSpec remapped(it.second.GetStringRef(), false);
+ FileSpec remapped(it.second.GetStringRef());
remapped.AppendPathComponent(path);
new_path = remapped.GetPath();
return true;
for (const auto &it : m_pairs) {
if (!path_ref.consume_front(it.second.GetStringRef()))
continue;
- fixed.SetFile(it.first.GetStringRef(), false, FileSpec::Style::native);
+ fixed.SetFile(it.first.GetStringRef(), FileSpec::Style::native);
fixed.AppendPathComponent(path_ref);
return true;
}
if (orig_path_len >= prefix_len) {
if (::strncmp(pos->first.GetCString(), orig_path, prefix_len) == 0) {
- new_spec.SetFile(pos->second.GetCString(), false,
- FileSpec::Style::native);
+ new_spec.SetFile(pos->second.GetCString(), FileSpec::Style::native);
new_spec.AppendPathComponent(orig_path + prefix_len);
if (FileSystem::Instance().Exists(new_spec))
return true;
if (!llvm::sys::path::home_directory(user_home_dir))
return;
- module_cache_dir = FileSpec(user_home_dir.c_str(), false);
+ module_cache_dir = FileSpec(user_home_dir.c_str());
module_cache_dir.AppendPathComponent(".lldb");
module_cache_dir.AppendPathComponent("module_cache");
SetModuleCacheDirectory(module_cache_dir);
if (IsHost()) {
llvm::SmallString<64> cwd;
if (llvm::sys::fs::current_path(cwd))
- return FileSpec{};
- else
- return FileSpec(cwd, true);
+ return {};
+ else {
+ FileSpec file_spec(cwd);
+ FileSystem::Instance().Resolve(file_spec);
+ return file_spec;
+ }
} else {
if (!m_working_dir)
m_working_dir = GetRemoteWorkingDirectory();
RecurseCopy_Callback(void *baton, llvm::sys::fs::file_type ft,
llvm::StringRef path) {
RecurseCopyBaton *rc_baton = (RecurseCopyBaton *)baton;
- FileSpec src(path, false);
+ FileSpec src(path);
namespace fs = llvm::sys::fs;
switch (ft) {
case fs::file_type::fifo_file:
bool Platform::ResolveRemotePath(const FileSpec &platform_path,
FileSpec &resolved_platform_path) {
resolved_platform_path = platform_path;
- return resolved_platform_path.ResolvePath();
+ FileSystem::Instance().Resolve(resolved_platform_path);
+ return true;
}
const ArchSpec &Platform::GetSystemArchitecture() {
{
FileSpec file_to_use;
if (remote_filename.IsAbsolute())
- file_to_use = FileSpec(remote_filename.GetFilename().GetStringRef(),
- false,
- remote_filename.GetPathStyle());
+ file_to_use = FileSpec(remote_filename.GetFilename().GetStringRef(),
+
+ remote_filename.GetPathStyle());
else
file_to_use = remote_filename;
case 'i': // STDIN for read only
{
FileAction action;
- if (action.Open(STDIN_FILENO, FileSpec{option_arg, false}, true, false))
+ if (action.Open(STDIN_FILENO, FileSpec(option_arg), true, false))
launch_info.AppendFileAction(action);
break;
}
case 'o': // Open STDOUT for write only
{
FileAction action;
- if (action.Open(STDOUT_FILENO, FileSpec{option_arg, false}, false, true))
+ if (action.Open(STDOUT_FILENO, FileSpec(option_arg), false, true))
launch_info.AppendFileAction(action);
break;
}
case 'e': // STDERR for write only
{
FileAction action;
- if (action.Open(STDERR_FILENO, FileSpec{option_arg, false}, false, true))
+ if (action.Open(STDERR_FILENO, FileSpec(option_arg), false, true))
launch_info.AppendFileAction(action);
break;
}
case 'n': // Disable STDIO
{
FileAction action;
- const FileSpec dev_null{FileSystem::DEV_NULL, false};
+ const FileSpec dev_null(FileSystem::DEV_NULL);
if (action.Open(STDIN_FILENO, dev_null, true, false))
launch_info.AppendFileAction(action);
if (action.Open(STDOUT_FILENO, dev_null, false, true))
}
case 'w':
- launch_info.SetWorkingDirectory(FileSpec{option_arg, false});
+ launch_info.SetWorkingDirectory(FileSpec(option_arg));
break;
case 't': // Open process in new terminal window
case 'c':
if (!option_arg.empty())
- launch_info.SetShell(FileSpec(option_arg, false));
+ launch_info.SetShell(FileSpec(option_arg));
else
launch_info.SetShell(HostInfo::GetDefaultShell());
break;
ProcessInfo::ProcessInfo(const char *name, const ArchSpec &arch,
lldb::pid_t pid)
- : m_executable(name, false), m_arguments(), m_environment(),
- m_uid(UINT32_MAX), m_gid(UINT32_MAX), m_arch(arch), m_pid(pid) {}
+ : m_executable(name), m_arguments(), m_environment(), m_uid(UINT32_MAX),
+ m_gid(UINT32_MAX), m_arch(arch), m_pid(pid) {}
void ProcessInfo::Clear() {
m_executable.Clear();
// Yes the first argument is an executable, set it as the executable in
// the launch options. Don't resolve the file path as the path could be a
// remote platform path
- const bool resolve = false;
- m_executable.SetFile(first_arg, resolve, FileSpec::Style::native);
+ m_executable.SetFile(first_arg, FileSpec::Style::native);
}
}
}
// Yes the first argument is an executable, set it as the executable in
// the launch options. Don't resolve the file path as the path could be a
// remote platform path
- const bool resolve = false;
- m_executable.SetFile(first_arg, resolve, FileSpec::Style::native);
+ m_executable.SetFile(first_arg, FileSpec::Style::native);
}
}
}
bool ProcessLaunchInfo::AppendSuppressFileAction(int fd, bool read,
bool write) {
FileAction file_action;
- if (file_action.Open(fd, FileSpec{FileSystem::DEV_NULL, false}, read,
- write)) {
+ if (file_action.Open(fd, FileSpec(FileSystem::DEV_NULL), read, write)) {
AppendFileAction(file_action);
return true;
}
open_flags |= O_CLOEXEC;
#endif
if (m_pty->OpenFirstAvailableMaster(open_flags, nullptr, 0)) {
- const FileSpec slave_file_spec{m_pty->GetSlaveName(nullptr, 0),
- false};
+ const FileSpec slave_file_spec(m_pty->GetSlaveName(nullptr, 0));
// Only use the slave tty if we don't have anything specified for
// input and don't have an action for stdin
// Add a modified PATH environment variable in case argv[0] is a
// relative path.
const char *argv0 = argv[0];
- FileSpec arg_spec(argv0, false);
+ FileSpec arg_spec(argv0);
if (arg_spec.IsRelative()) {
// We have a relative path to our executable which may not work if we
// just try to run "a.out" (without it being converted to "./a.out")
if (!user_exe_path.empty()) {
ModuleSpecList module_specs;
ModuleSpec module_spec;
- module_spec.GetFileSpec().SetFile(user_exe_path, true,
- FileSpec::Style::native);
+ module_spec.GetFileSpec().SetFile(user_exe_path, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(module_spec.GetFileSpec());
// Resolve the executable in case we are given a path to a application
// bundle like a .app bundle on MacOSX
if (!arch.IsValid())
arch = specified_arch;
- FileSpec file(user_exe_path, false);
+ FileSpec file(user_exe_path);
if (!FileSystem::Instance().Exists(file) && user_exe_path.startswith("~")) {
// we want to expand the tilde but we don't want to resolve any symbolic
// links so we can't use the FileSpec constructor's resolve flag
Resolver.ResolveFullPath(user_exe_path, unglobbed_path);
if (unglobbed_path.empty())
- file = FileSpec(user_exe_path, false);
+ file = FileSpec(user_exe_path);
else
- file = FileSpec(unglobbed_path.c_str(), false);
+ file = FileSpec(unglobbed_path.c_str());
}
bool user_exe_path_is_bundle = false;
if (file.IsRelative() && !user_exe_path.empty()) {
llvm::SmallString<64> cwd;
if (! llvm::sys::fs::current_path(cwd)) {
- FileSpec cwd_file(cwd.c_str(), false);
+ FileSpec cwd_file(cwd.c_str());
cwd_file.AppendPathComponent(file);
if (FileSystem::Instance().Exists(cwd_file))
file = cwd_file;
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Stream.h"
-#include "lldb/Utility/TildeExpressionResolver.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
} // end anonymous namespace
-void FileSpec::Resolve(llvm::SmallVectorImpl<char> &path) {
- if (path.empty())
- return;
-
- llvm::SmallString<32> Source(path.begin(), path.end());
- StandardTildeExpressionResolver Resolver;
- Resolver.ResolveFullPath(Source, path);
-
- // Save a copy of the original path that's passed in
- llvm::SmallString<128> original_path(path.begin(), path.end());
-
- llvm::sys::fs::make_absolute(path);
- if (!llvm::sys::fs::exists(path)) {
- path.clear();
- path.append(original_path.begin(), original_path.end());
- }
-}
-
FileSpec::FileSpec() : m_style(GetNativeStyle()) {}
//------------------------------------------------------------------
// Default constructor that can take an optional full path to a file on disk.
//------------------------------------------------------------------
-FileSpec::FileSpec(llvm::StringRef path, bool resolve_path, Style style)
- : m_style(style) {
- SetFile(path, resolve_path, style);
+FileSpec::FileSpec(llvm::StringRef path, Style style) : m_style(style) {
+ SetFile(path, style);
}
-FileSpec::FileSpec(llvm::StringRef path, bool resolve_path,
- const llvm::Triple &Triple)
- : FileSpec{path, resolve_path,
- Triple.isOSWindows() ? Style::windows : Style::posix} {}
+FileSpec::FileSpec(llvm::StringRef path, const llvm::Triple &Triple)
+ : FileSpec{path, Triple.isOSWindows() ? Style::windows : Style::posix} {}
//------------------------------------------------------------------
// Copy constructor
return *this;
}
-void FileSpec::SetFile(llvm::StringRef pathname, bool resolve) {
- SetFile(pathname, resolve, m_style);
-}
+void FileSpec::SetFile(llvm::StringRef pathname) { SetFile(pathname, m_style); }
//------------------------------------------------------------------
// 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(llvm::StringRef pathname, bool resolve, Style style) {
+void FileSpec::SetFile(llvm::StringRef pathname, Style style) {
m_filename.Clear();
m_directory.Clear();
m_is_resolved = false;
if (pathname.empty())
return;
- llvm::SmallString<64> resolved(pathname);
-
- if (resolve) {
- FileSpec::Resolve(resolved);
- m_is_resolved = true;
- }
+ llvm::SmallString<128> resolved(pathname);
// Normalize the path by removing ".", ".." and other redundant components.
if (needsNormalization(resolved))
llvm::StringRef filename = llvm::sys::path::filename(resolved, m_style);
if(!filename.empty())
m_filename.SetString(filename);
+
llvm::StringRef directory = llvm::sys::path::parent_path(resolved, m_style);
if(!directory.empty())
m_directory.SetString(directory);
}
-void FileSpec::SetFile(llvm::StringRef path, bool resolve,
- const llvm::Triple &Triple) {
- return SetFile(path, resolve,
- Triple.isOSWindows() ? Style::windows : Style::posix);
+void FileSpec::SetFile(llvm::StringRef path, const llvm::Triple &Triple) {
+ return SetFile(path, Triple.isOSWindows() ? Style::windows : Style::posix);
}
//----------------------------------------------------------------------
// Equal to operator
//------------------------------------------------------------------
bool FileSpec::operator==(const FileSpec &rhs) const {
- if (!FileEquals(rhs))
- return false;
- if (DirectoryEquals(rhs))
- return true;
-
- // TODO: determine if we want to keep this code in here.
- // The code below was added to handle a case where we were trying to set a
- // file and line breakpoint and one path was resolved, and the other not and
- // the directory was in a mount point that resolved to a more complete path:
- // "/tmp/a.c" == "/private/tmp/a.c". I might end up pulling this out...
- if (IsResolved() && rhs.IsResolved()) {
- // Both paths are resolved, no need to look further...
- return false;
- }
-
- FileSpec resolved_lhs(*this);
-
- // If "this" isn't resolved, resolve it
- if (!IsResolved()) {
- if (resolved_lhs.ResolvePath()) {
- // This path wasn't resolved but now it is. Check if the resolved
- // directory is the same as our unresolved directory, and if so, we can
- // mark this object as resolved to avoid more future resolves
- m_is_resolved = (m_directory == resolved_lhs.m_directory);
- } else
- return false;
- }
-
- FileSpec resolved_rhs(rhs);
- if (!rhs.IsResolved()) {
- if (resolved_rhs.ResolvePath()) {
- // rhs's path wasn't resolved but now it is. Check if the resolved
- // directory is the same as rhs's unresolved directory, and if so, we can
- // mark this object as resolved to avoid more future resolves
- rhs.m_is_resolved = (rhs.m_directory == resolved_rhs.m_directory);
- } else
- return false;
- }
-
- // If we reach this point in the code we were able to resolve both paths and
- // since we only resolve the paths if the basenames are equal, then we can
- // just check if both directories are equal...
- return DirectoryEquals(rhs);
+ return FileEquals(rhs) && DirectoryEquals(rhs);
}
//------------------------------------------------------------------
}
}
-bool FileSpec::ResolvePath() {
- if (m_is_resolved)
- return true; // We have already resolved this path
-
- // SetFile(...) will set m_is_resolved correctly if it can resolve the path
- SetFile(GetPath(false), true);
- return m_is_resolved;
-}
-
FileSpec::Style FileSpec::GetPathStyle() const { return m_style; }
//------------------------------------------------------------------
llvm::SmallString<64> current_path;
GetPath(current_path, false);
if (llvm::sys::path::has_parent_path(current_path, m_style))
- return FileSpec(llvm::sys::path::parent_path(current_path, m_style), false,
+ return FileSpec(llvm::sys::path::parent_path(current_path, m_style),
m_style);
return *this;
}
llvm::sys::path::append(new_path,
llvm::sys::path::begin(current_path, m_style),
llvm::sys::path::end(current_path), m_style);
- SetFile(new_path, false, m_style);
+ SetFile(new_path, m_style);
}
void FileSpec::PrependPathComponent(const FileSpec &new_path) {
llvm::SmallString<64> current_path;
GetPath(current_path, false);
llvm::sys::path::append(current_path, m_style, component);
- SetFile(current_path, false, m_style);
+ SetFile(current_path, m_style);
}
void FileSpec::AppendPathComponent(const FileSpec &new_path) {
llvm::SmallString<64> current_path;
GetPath(current_path, false);
if (llvm::sys::path::has_parent_path(current_path, m_style)) {
- SetFile(llvm::sys::path::parent_path(current_path, m_style), false);
+ SetFile(llvm::sys::path::parent_path(current_path, m_style));
return true;
}
return false;
// C++ Includes
-
#include "Acceptor.h"
#include "LLDBServerUtilities.h"
#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h"
#include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostGetOpt.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Host/Pipe.h"
llvm::errs() << "Error getting current directory: " << ec.message() << "\n";
exit(1);
}
- info.SetWorkingDirectory(FileSpec(cwd, true));
+ FileSpec cwd_spec(cwd);
+ FileSystem::Instance().Resolve(cwd_spec);
+ info.SetWorkingDirectory(cwd_spec);
info.GetEnvironment() = Host::GetEnvironment();
gdb_server.SetLaunchInfo(info);
static Status save_socket_id_to_file(const std::string &socket_id,
const FileSpec &file_spec) {
- FileSpec temp_file_spec(file_spec.GetDirectory().AsCString(), false);
+ FileSpec temp_file_spec(file_spec.GetDirectory().AsCString());
Status error(llvm::sys::fs::create_directory(temp_file_spec.GetPath()));
if (error.Fail())
return Status("Failed to create directory %s: %s",
case 'f': // Socket file
if (optarg && optarg[0])
- socket_file.SetFile(optarg, false, FileSpec::Style::native);
+ socket_file.SetFile(optarg, FileSpec::Style::native);
break;
case 'p': {
if (!File.empty()) {
assert(Line != 0);
- FileSpec src_file(File, false);
+ FileSpec src_file(File);
size_t cu_count = Module.GetNumCompileUnits();
for (size_t i = 0; i < cu_count; i++) {
lldb::CompUnitSP cu_sp = Module.GetCompileUnitAtIndex(i);
SymbolContextList List;
- FileSpec src_file(File, false);
+ FileSpec src_file(File);
size_t cu_count = Module.GetNumCompileUnits();
for (size_t i = 0; i < cu_count; i++) {
lldb::CompUnitSP cu_sp = Module.GetCompileUnitAtIndex(i);
int HadErrors = 0;
for (const auto &File : InputFilenames) {
outs() << "Module: " << File << "\n";
- ModuleSpec Spec{FileSpec(File, false)};
- Spec.GetSymbolFileSpec().SetFile(File, false, FileSpec::Style::native);
+ ModuleSpec Spec{FileSpec(File)};
+ Spec.GetSymbolFileSpec().SetFile(File, FileSpec::Style::native);
auto ModulePtr = std::make_shared<lldb_private::Module>(Spec);
SymbolVendor *Vendor = ModulePtr->GetSymbolVendor();
int HadErrors = 0;
for (const auto &File : opts::object::InputFilenames) {
- ModuleSpec Spec{FileSpec(File, false)};
+ ModuleSpec Spec{FileSpec(File)};
auto ModulePtr = std::make_shared<lldb_private::Module>(Spec);
// Fetch symbol vendor before we get the section list to give the symbol
ASSERT_NO_ERROR(llvm::sys::fs::file_size(Obj, Size));
ASSERT_GT(Size, 0u);
- ModuleSpec Spec{FileSpec(Obj, false)};
- Spec.GetSymbolFileSpec().SetFile(Obj, false, FileSpec::Style::native);
+ ModuleSpec Spec{FileSpec(Obj)};
+ Spec.GetSymbolFileSpec().SetFile(Obj, FileSpec::Style::native);
auto M = std::make_shared<Module>(Spec);
auto Count = [M](const char *Name, FunctionNameType Type) -> int {
#include "gtest/gtest.h"
#include "lldb/Host/Editline.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Pipe.h"
#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Utility/Status.h"
public:
void SetUp() {
+ FileSystem::Initialize();
+
// We need a TERM set properly for editline to work as expected.
setenv("TERM", "vt100", 1);
_el_adapter.CloseInput();
if (_sp_output_thread)
_sp_output_thread->join();
+
+ FileSystem::Terminate();
}
EditlineAdapter &GetEditlineAdapter() { return _el_adapter; }
static std::string ComputeClangDir(std::string lldb_shlib_path,
bool verify = false) {
FileSpec clang_dir;
- FileSpec lldb_shlib_spec(lldb_shlib_path, false);
+ FileSpec lldb_shlib_spec(lldb_shlib_path);
ComputeClangDirectory(lldb_shlib_spec, clang_dir, verify);
return clang_dir.GetPath();
}
TEST(FileSystemTest, FileAndDirectoryComponents) {
using namespace std::chrono;
+ FileSystem fs;
- const bool resolve = true;
#ifdef _WIN32
- FileSpec fs1("C:\\FILE\\THAT\\DOES\\NOT\\EXIST.TXT", !resolve);
+ FileSpec fs1("C:\\FILE\\THAT\\DOES\\NOT\\EXIST.TXT");
#else
- FileSpec fs1("/file/that/does/not/exist.txt", !resolve);
+ FileSpec fs1("/file/that/does/not/exist.txt");
#endif
- FileSpec fs2(TestMainArgv0, resolve);
+ FileSpec fs2(TestMainArgv0);
- FileSystem fs;
+ fs.Resolve(fs2);
EXPECT_EQ(system_clock::time_point(), fs.GetModificationTime(fs1));
EXPECT_LT(system_clock::time_point() + hours(24 * 365 * 20),
FileSystem fs(GetSimpleDummyFS());
EXPECT_TRUE(fs.Exists("/foo"));
- EXPECT_TRUE(fs.Exists(FileSpec("/foo", false, FileSpec::Style::posix)));
+ EXPECT_TRUE(fs.Exists(FileSpec("/foo", FileSpec::Style::posix)));
}
TEST(FileSystemTest, Readable) {
FileSystem fs(GetSimpleDummyFS());
EXPECT_TRUE(fs.Readable("/foo"));
- EXPECT_TRUE(fs.Readable(FileSpec("/foo", false, FileSpec::Style::posix)));
+ EXPECT_TRUE(fs.Readable(FileSpec("/foo", FileSpec::Style::posix)));
EXPECT_FALSE(fs.Readable("/qux"));
- EXPECT_FALSE(fs.Readable(FileSpec("/qux", false, FileSpec::Style::posix)));
+ EXPECT_FALSE(fs.Readable(FileSpec("/qux", FileSpec::Style::posix)));
}
TEST(FileSystemTest, GetByteSize) {
EXPECT_EQ((uint64_t)1024, fs.GetByteSize("/foo"));
EXPECT_EQ((uint64_t)1024,
- fs.GetByteSize(FileSpec("/foo", false, FileSpec::Style::posix)));
+ fs.GetByteSize(FileSpec("/foo", FileSpec::Style::posix)));
}
TEST(FileSystemTest, GetPermissions) {
EXPECT_EQ(sys::fs::all_all, fs.GetPermissions("/foo"));
EXPECT_EQ(sys::fs::all_all,
- fs.GetPermissions(FileSpec("/foo", false, FileSpec::Style::posix)));
+ fs.GetPermissions(FileSpec("/foo", FileSpec::Style::posix)));
}
TEST(FileSystemTest, MakeAbsolute) {
}
{
- FileSpec file_spec("foo", false);
+ FileSpec file_spec("foo");
auto EC = fs.MakeAbsolute(file_spec);
EXPECT_FALSE(EC);
EXPECT_EQ("/foo", file_spec.GetPath());
}
{
- FileSpec file_spec("foo", false);
+ FileSpec file_spec("foo");
fs.Resolve(file_spec);
EXPECT_EQ("/foo", file_spec.GetPath());
}
}
{
- FileSpec file_spec("bogus", false);
+ FileSpec file_spec("bogus");
fs.Resolve(file_spec);
EXPECT_EQ("bogus", file_spec.GetPath());
}
ModuleSpec module_spec;
// using a GUID here because the symbol file shouldn't actually exist on disk
module_spec.GetSymbolFileSpec().SetFile(
- "4A524676-B24B-4F4E-968A-551D465EBAF1.so", false,
- FileSpec::Style::native);
+ "4A524676-B24B-4F4E-968A-551D465EBAF1.so", FileSpec::Style::native);
FileSpec symbol_file_spec = Symbols::LocateExecutableSymbolFile(module_spec);
EXPECT_TRUE(symbol_file_spec.GetFilename().IsEmpty());
}
//===----------------------------------------------------------------------===//
#include "lldb/Host/Host.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Target/Process.h"
#include "gtest/gtest.h"
namespace {
class HostTest : public testing::Test {
public:
- static void SetUpTestCase() { HostInfo::Initialize(); }
- static void TearDownTestCase() { HostInfo::Terminate(); }
+ static void SetUpTestCase() {
+ FileSystem::Initialize();
+ HostInfo::Initialize();
+ }
+ static void TearDownTestCase() {
+ HostInfo::Terminate();
+ FileSystem::Terminate();
+ }
};
} // namespace
ASSERT_NO_ERROR(llvm::sys::fs::file_size(obj, size));
ASSERT_GT(size, 0u);
- ModuleSpec spec{FileSpec(obj, false)};
- spec.GetSymbolFileSpec().SetFile(obj, false, FileSpec::Style::native);
+ ModuleSpec spec{FileSpec(obj)};
+ spec.GetSymbolFileSpec().SetFile(obj, FileSpec::Style::native);
auto module_sp = std::make_shared<Module>(spec);
SectionList *list = module_sp->GetSectionList();
ASSERT_NE(nullptr, list);
TEST_F(ObjectFileELFTest, GetModuleSpecifications_EarlySectionHeaders) {
std::string SO = GetInputFilePath("early-section-headers.so");
ModuleSpecList Specs;
- ASSERT_EQ(1u, ObjectFile::GetModuleSpecifications(FileSpec(SO, false), 0, 0, Specs));
+ ASSERT_EQ(1u, ObjectFile::GetModuleSpecifications(FileSpec(SO), 0, 0, Specs));
ModuleSpec Spec;
ASSERT_TRUE(Specs.GetModuleSpecAtIndex(0, Spec)) ;
UUID Uuid;
std::string base = "/Applications/Xcode.app/Contents/Developer/Platforms/";
EXPECT_TRUE(PlatformDarwinTester::SDKSupportsModules(
PlatformDarwin::SDKType::iPhoneSimulator,
- FileSpec(base +
- "iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk",
- false)));
+ FileSpec(
+ base +
+ "iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk")));
EXPECT_FALSE(PlatformDarwinTester::SDKSupportsModules(
PlatformDarwin::SDKType::iPhoneSimulator,
- FileSpec(base +
- "iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.2.sdk",
- false)));
+ FileSpec(
+ base +
+ "iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.2.sdk")));
EXPECT_TRUE(PlatformDarwinTester::SDKSupportsModules(
PlatformDarwin::SDKType::MacOSX,
- FileSpec(base + "MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk",
- false)));
+ FileSpec(base + "MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk")));
EXPECT_FALSE(PlatformDarwinTester::SDKSupportsModules(
PlatformDarwin::SDKType::MacOSX,
- FileSpec(base + "MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk", false)));
+ FileSpec(base + "MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk")));
}
llvm::Triple triple("i386-pc-linux");
FileSpec file_specs[] = {
- FileSpec("/foo/bar.so", false, FileSpec::Style::posix),
- FileSpec("/foo/baz.so", false, FileSpec::Style::posix),
+ FileSpec("/foo/bar.so", FileSpec::Style::posix),
+ FileSpec("/foo/baz.so", FileSpec::Style::posix),
// This is a bit dodgy but we currently depend on GetModulesInfo not
// performing denormalization. It can go away once the users
// (DynamicLoaderPOSIXDYLD, at least) correctly set the path syntax for
// the FileSpecs they create.
- FileSpec("/foo/baw.so", false, FileSpec::Style::windows),
+ FileSpec("/foo/baw.so", FileSpec::Style::windows),
};
std::future<llvm::Optional<std::vector<ModuleSpec>>> async_result =
std::async(std::launch::async,
TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfo_UUID20) {
llvm::Triple triple("i386-pc-linux");
- FileSpec file_spec("/foo/bar.so", false, FileSpec::Style::posix);
+ FileSpec file_spec("/foo/bar.so", FileSpec::Style::posix);
std::future<llvm::Optional<std::vector<ModuleSpec>>> async_result =
std::async(std::launch::async,
[&] { return client.GetModulesInfo(file_spec, triple); });
TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfoInvalidResponse) {
llvm::Triple triple("i386-pc-linux");
- FileSpec file_spec("/foo/bar.so", false, FileSpec::Style::posix);
+ FileSpec file_spec("/foo/bar.so", FileSpec::Style::posix);
const char *invalid_responses[] = {
// no UUID
ASSERT_NO_ERROR(llvm::sys::fs::file_size(obj, size));
ASSERT_GT(size, 0u);
- auto module_sp = std::make_shared<Module>(ModuleSpec(FileSpec(obj, false)));
+ auto module_sp = std::make_shared<Module>(ModuleSpec(FileSpec(obj)));
SectionList *list = module_sp->GetSectionList();
ASSERT_NE(nullptr, list);
TEST_F(SymbolFileDWARFTests, TestAbilitiesForDWARF) {
// Test that when we have Dwarf debug info, SymbolFileDWARF is used.
- FileSpec fspec(m_dwarf_test_exe, false);
+ FileSpec fspec(m_dwarf_test_exe);
ArchSpec aspec("i686-pc-windows");
lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
static const size_t module_size = 5602;
static FileSpec GetDummyRemotePath() {
- FileSpec fs("/", false, FileSpec::Style::posix);
+ FileSpec fs("/", FileSpec::Style::posix);
fs.AppendPathComponent(dummy_remote_dir);
fs.AppendPathComponent(module_name);
return fs;
struct Matches {
FileSpec original;
FileSpec remapped;
- Matches(const char *o, const char *r)
- : original(o, false), remapped(r, false) {}
+ Matches(const char *o, const char *r) : original(o), remapped(r) {}
};
} // namespace
std::string orig_normalized = match.original.GetPath();
EXPECT_TRUE(
map.RemapPath(ConstString(match.original.GetPath()), actual_remapped));
- EXPECT_EQ(FileSpec(actual_remapped.GetStringRef(), false), match.remapped);
+ EXPECT_EQ(FileSpec(actual_remapped.GetStringRef()), match.remapped);
FileSpec unmapped_spec;
EXPECT_TRUE(map.ReverseRemapPath(match.remapped, unmapped_spec));
std::string unmapped_path = unmapped_spec.GetPath();
using namespace lldb_private;
TEST(FileSpecTest, FileAndDirectoryComponents) {
- FileSpec fs_posix("/foo/bar", false, FileSpec::Style::posix);
+ FileSpec fs_posix("/foo/bar", FileSpec::Style::posix);
EXPECT_STREQ("/foo/bar", fs_posix.GetCString());
EXPECT_STREQ("/foo", fs_posix.GetDirectory().GetCString());
EXPECT_STREQ("bar", fs_posix.GetFilename().GetCString());
- FileSpec fs_windows("F:\\bar", false, FileSpec::Style::windows);
+ FileSpec fs_windows("F:\\bar", FileSpec::Style::windows);
EXPECT_STREQ("F:\\bar", fs_windows.GetCString());
// EXPECT_STREQ("F:\\", fs_windows.GetDirectory().GetCString()); // It returns
// "F:/"
EXPECT_STREQ("bar", fs_windows.GetFilename().GetCString());
- FileSpec fs_posix_root("/", false, FileSpec::Style::posix);
+ FileSpec fs_posix_root("/", FileSpec::Style::posix);
EXPECT_STREQ("/", fs_posix_root.GetCString());
EXPECT_EQ(nullptr, fs_posix_root.GetDirectory().GetCString());
EXPECT_STREQ("/", fs_posix_root.GetFilename().GetCString());
- FileSpec fs_net_drive("//net", false, FileSpec::Style::posix);
+ FileSpec fs_net_drive("//net", FileSpec::Style::posix);
EXPECT_STREQ("//net", fs_net_drive.GetCString());
EXPECT_EQ(nullptr, fs_net_drive.GetDirectory().GetCString());
EXPECT_STREQ("//net", fs_net_drive.GetFilename().GetCString());
- FileSpec fs_net_root("//net/", false, FileSpec::Style::posix);
+ FileSpec fs_net_root("//net/", FileSpec::Style::posix);
EXPECT_STREQ("//net/", fs_net_root.GetCString());
EXPECT_STREQ("//net", fs_net_root.GetDirectory().GetCString());
EXPECT_STREQ("/", fs_net_root.GetFilename().GetCString());
- FileSpec fs_windows_drive("F:", false, FileSpec::Style::windows);
+ FileSpec fs_windows_drive("F:", FileSpec::Style::windows);
EXPECT_STREQ("F:", fs_windows_drive.GetCString());
EXPECT_EQ(nullptr, fs_windows_drive.GetDirectory().GetCString());
EXPECT_STREQ("F:", fs_windows_drive.GetFilename().GetCString());
- FileSpec fs_windows_root("F:\\", false, FileSpec::Style::windows);
+ FileSpec fs_windows_root("F:\\", FileSpec::Style::windows);
EXPECT_STREQ("F:\\", fs_windows_root.GetCString());
EXPECT_STREQ("F:", fs_windows_root.GetDirectory().GetCString());
// EXPECT_STREQ("\\", fs_windows_root.GetFilename().GetCString()); // It
// returns "/"
- FileSpec fs_posix_long("/foo/bar/baz", false, FileSpec::Style::posix);
+ FileSpec fs_posix_long("/foo/bar/baz", FileSpec::Style::posix);
EXPECT_STREQ("/foo/bar/baz", fs_posix_long.GetCString());
EXPECT_STREQ("/foo/bar", fs_posix_long.GetDirectory().GetCString());
EXPECT_STREQ("baz", fs_posix_long.GetFilename().GetCString());
- FileSpec fs_windows_long("F:\\bar\\baz", false, FileSpec::Style::windows);
+ FileSpec fs_windows_long("F:\\bar\\baz", FileSpec::Style::windows);
EXPECT_STREQ("F:\\bar\\baz", fs_windows_long.GetCString());
// EXPECT_STREQ("F:\\bar", fs_windows_long.GetDirectory().GetCString()); // It
// returns "F:/bar"
EXPECT_STREQ("baz", fs_windows_long.GetFilename().GetCString());
- FileSpec fs_posix_trailing_slash("/foo/bar/", false, FileSpec::Style::posix);
+ FileSpec fs_posix_trailing_slash("/foo/bar/", FileSpec::Style::posix);
EXPECT_STREQ("/foo/bar", fs_posix_trailing_slash.GetCString());
EXPECT_STREQ("/foo", fs_posix_trailing_slash.GetDirectory().GetCString());
EXPECT_STREQ("bar", fs_posix_trailing_slash.GetFilename().GetCString());
- FileSpec fs_windows_trailing_slash("F:\\bar\\", false,
- FileSpec::Style::windows);
+ FileSpec fs_windows_trailing_slash("F:\\bar\\", FileSpec::Style::windows);
EXPECT_STREQ("F:\\bar", fs_windows_trailing_slash.GetCString());
EXPECT_STREQ("bar", fs_windows_trailing_slash.GetFilename().GetCString());
}
TEST(FileSpecTest, AppendPathComponent) {
- FileSpec fs_posix("/foo", false, FileSpec::Style::posix);
+ FileSpec fs_posix("/foo", FileSpec::Style::posix);
fs_posix.AppendPathComponent("bar");
EXPECT_STREQ("/foo/bar", fs_posix.GetCString());
EXPECT_STREQ("/foo", fs_posix.GetDirectory().GetCString());
EXPECT_STREQ("bar", fs_posix.GetFilename().GetCString());
- FileSpec fs_posix_2("/foo", false, FileSpec::Style::posix);
+ FileSpec fs_posix_2("/foo", FileSpec::Style::posix);
fs_posix_2.AppendPathComponent("//bar/baz");
EXPECT_STREQ("/foo/bar/baz", fs_posix_2.GetCString());
EXPECT_STREQ("/foo/bar", fs_posix_2.GetDirectory().GetCString());
EXPECT_STREQ("baz", fs_posix_2.GetFilename().GetCString());
- FileSpec fs_windows("F:\\bar", false, FileSpec::Style::windows);
+ FileSpec fs_windows("F:\\bar", FileSpec::Style::windows);
fs_windows.AppendPathComponent("baz");
EXPECT_STREQ("F:\\bar\\baz", fs_windows.GetCString());
// EXPECT_STREQ("F:\\bar", fs_windows.GetDirectory().GetCString()); // It
// returns "F:/bar"
EXPECT_STREQ("baz", fs_windows.GetFilename().GetCString());
- FileSpec fs_posix_root("/", false, FileSpec::Style::posix);
+ FileSpec fs_posix_root("/", FileSpec::Style::posix);
fs_posix_root.AppendPathComponent("bar");
EXPECT_STREQ("/bar", fs_posix_root.GetCString());
EXPECT_STREQ("/", fs_posix_root.GetDirectory().GetCString());
EXPECT_STREQ("bar", fs_posix_root.GetFilename().GetCString());
- FileSpec fs_windows_root("F:\\", false, FileSpec::Style::windows);
+ FileSpec fs_windows_root("F:\\", FileSpec::Style::windows);
fs_windows_root.AppendPathComponent("bar");
EXPECT_STREQ("F:\\bar", fs_windows_root.GetCString());
// EXPECT_STREQ("F:\\", fs_windows_root.GetDirectory().GetCString()); // It
}
TEST(FileSpecTest, CopyByAppendingPathComponent) {
- FileSpec fs = FileSpec("/foo", false, FileSpec::Style::posix)
+ FileSpec fs = FileSpec("/foo", FileSpec::Style::posix)
.CopyByAppendingPathComponent("bar");
EXPECT_STREQ("/foo/bar", fs.GetCString());
EXPECT_STREQ("/foo", fs.GetDirectory().GetCString());
}
TEST(FileSpecTest, PrependPathComponent) {
- FileSpec fs_posix("foo", false, FileSpec::Style::posix);
+ FileSpec fs_posix("foo", FileSpec::Style::posix);
fs_posix.PrependPathComponent("/bar");
EXPECT_STREQ("/bar/foo", fs_posix.GetCString());
- FileSpec fs_posix_2("foo/bar", false, FileSpec::Style::posix);
+ FileSpec fs_posix_2("foo/bar", FileSpec::Style::posix);
fs_posix_2.PrependPathComponent("/baz");
EXPECT_STREQ("/baz/foo/bar", fs_posix_2.GetCString());
- FileSpec fs_windows("baz", false, FileSpec::Style::windows);
+ FileSpec fs_windows("baz", FileSpec::Style::windows);
fs_windows.PrependPathComponent("F:\\bar");
EXPECT_STREQ("F:\\bar\\baz", fs_windows.GetCString());
- FileSpec fs_posix_root("bar", false, FileSpec::Style::posix);
+ FileSpec fs_posix_root("bar", FileSpec::Style::posix);
fs_posix_root.PrependPathComponent("/");
EXPECT_STREQ("/bar", fs_posix_root.GetCString());
- FileSpec fs_windows_root("bar", false, FileSpec::Style::windows);
+ FileSpec fs_windows_root("bar", FileSpec::Style::windows);
fs_windows_root.PrependPathComponent("F:\\");
EXPECT_STREQ("F:\\bar", fs_windows_root.GetCString());
}
TEST(FileSpecTest, EqualSeparator) {
- FileSpec backward("C:\\foo\\bar", false, FileSpec::Style::windows);
- FileSpec forward("C:/foo/bar", false, FileSpec::Style::windows);
+ FileSpec backward("C:\\foo\\bar", FileSpec::Style::windows);
+ FileSpec forward("C:/foo/bar", FileSpec::Style::windows);
EXPECT_EQ(forward, backward);
}
};
for (const auto &test : tests) {
- FileSpec one(test.first, false, FileSpec::Style::windows);
- FileSpec two(test.second, false, FileSpec::Style::windows);
+ FileSpec one(test.first, FileSpec::Style::windows);
+ FileSpec two(test.second, FileSpec::Style::windows);
EXPECT_EQ(one, two);
}
}
};
for (const auto &test : tests) {
- FileSpec one(test.first, false, FileSpec::Style::posix);
- FileSpec two(test.second, false, FileSpec::Style::posix);
+ FileSpec one(test.first, FileSpec::Style::posix);
+ FileSpec two(test.second, FileSpec::Style::posix);
EXPECT_EQ(one, two);
}
}
};
for (const auto &test : tests) {
- FileSpec one(test.first, false, FileSpec::Style::posix);
- FileSpec two(test.second, false, FileSpec::Style::posix);
+ FileSpec one(test.first, FileSpec::Style::posix);
+ FileSpec two(test.second, FileSpec::Style::posix);
EXPECT_EQ(one, two);
}
}
for (auto test : posix_tests) {
SCOPED_TRACE(llvm::Twine("test.first = ") + test.first);
EXPECT_EQ(test.second,
- FileSpec(test.first, false, FileSpec::Style::posix).GetPath());
+ FileSpec(test.first, FileSpec::Style::posix).GetPath());
}
std::pair<const char *, const char *> windows_tests[] = {
};
for (auto test : windows_tests) {
EXPECT_EQ(test.second,
- FileSpec(test.first, false, FileSpec::Style::windows).GetPath())
+ FileSpec(test.first, FileSpec::Style::windows).GetPath())
<< "Original path: " << test.first;
}
}
EXPECT_EQ("(empty)", llvm::formatv("{0:D}", F).str());
EXPECT_EQ("(empty)", llvm::formatv("{0:F}", F).str());
- F = FileSpec("C:\\foo\\bar.txt", false, win);
+ F = FileSpec("C:\\foo\\bar.txt", win);
EXPECT_EQ("C:\\foo\\bar.txt", llvm::formatv("{0}", F).str());
EXPECT_EQ("C:\\foo\\", llvm::formatv("{0:D}", F).str());
EXPECT_EQ("bar.txt", llvm::formatv("{0:F}", F).str());
- F = FileSpec("foo\\bar.txt", false, win);
+ F = FileSpec("foo\\bar.txt", win);
EXPECT_EQ("foo\\bar.txt", llvm::formatv("{0}", F).str());
EXPECT_EQ("foo\\", llvm::formatv("{0:D}", F).str());
EXPECT_EQ("bar.txt", llvm::formatv("{0:F}", F).str());
- F = FileSpec("foo", false, win);
+ F = FileSpec("foo", win);
EXPECT_EQ("foo", llvm::formatv("{0}", F).str());
EXPECT_EQ("foo", llvm::formatv("{0:F}", F).str());
EXPECT_EQ("(empty)", llvm::formatv("{0:D}", F).str());
"/foo/../.",
};
for (const auto &path: not_relative) {
- FileSpec spec(path, false, FileSpec::Style::posix);
+ FileSpec spec(path, FileSpec::Style::posix);
EXPECT_FALSE(spec.IsRelative());
}
llvm::StringRef is_relative[] = {
"./foo/bar.c"
};
for (const auto &path: is_relative) {
- FileSpec spec(path, false, FileSpec::Style::posix);
+ FileSpec spec(path, FileSpec::Style::posix);
EXPECT_TRUE(spec.IsRelative());
}
}
TEST(FileSpecTest, RemoveLastPathComponent) {
- FileSpec fs_posix("/foo/bar/baz", false, FileSpec::Style::posix);
+ FileSpec fs_posix("/foo/bar/baz", FileSpec::Style::posix);
EXPECT_STREQ("/foo/bar/baz", fs_posix.GetCString());
EXPECT_TRUE(fs_posix.RemoveLastPathComponent());
EXPECT_STREQ("/foo/bar", fs_posix.GetCString());
EXPECT_FALSE(fs_posix.RemoveLastPathComponent());
EXPECT_STREQ("/", fs_posix.GetCString());
- FileSpec fs_posix_relative("./foo/bar/baz", false, FileSpec::Style::posix);
+ FileSpec fs_posix_relative("./foo/bar/baz", FileSpec::Style::posix);
EXPECT_STREQ("foo/bar/baz", fs_posix_relative.GetCString());
EXPECT_TRUE(fs_posix_relative.RemoveLastPathComponent());
EXPECT_STREQ("foo/bar", fs_posix_relative.GetCString());
EXPECT_FALSE(fs_posix_relative.RemoveLastPathComponent());
EXPECT_STREQ("foo", fs_posix_relative.GetCString());
- FileSpec fs_posix_relative2("./", false, FileSpec::Style::posix);
+ FileSpec fs_posix_relative2("./", FileSpec::Style::posix);
EXPECT_STREQ(".", fs_posix_relative2.GetCString());
EXPECT_FALSE(fs_posix_relative2.RemoveLastPathComponent());
EXPECT_STREQ(".", fs_posix_relative2.GetCString());
EXPECT_FALSE(fs_posix_relative.RemoveLastPathComponent());
EXPECT_STREQ(".", fs_posix_relative2.GetCString());
- FileSpec fs_windows("C:\\foo\\bar\\baz", false, FileSpec::Style::windows);
+ FileSpec fs_windows("C:\\foo\\bar\\baz", FileSpec::Style::windows);
EXPECT_STREQ("C:\\foo\\bar\\baz", fs_windows.GetCString());
EXPECT_TRUE(fs_windows.RemoveLastPathComponent());
EXPECT_STREQ("C:\\foo\\bar", fs_windows.GetCString());
TEST(StructuredDataTest, ParseJSONFromFile) {
Status status;
auto object_sp = StructuredData::ParseJSONFromFile(
- FileSpec("non-existing-file.json", false), status);
+ FileSpec("non-existing-file.json"), status);
EXPECT_EQ(nullptr, object_sp);
std::string input = GetInputFilePath("StructuredData-basic.json");
- object_sp = StructuredData::ParseJSONFromFile(FileSpec(input, false), status);
+ object_sp = StructuredData::ParseJSONFromFile(FileSpec(input), status);
ASSERT_NE(nullptr, object_sp);
StreamString S;