diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2018-11-01 21:05:36 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2018-11-01 21:05:36 +0000 |
commit | 8f3be7a32b631e9ba584872c1f0dde8fd8536c07 (patch) | |
tree | b4cfca7eb1e0996decd88a2b1dd1954ff3d7ff28 /lldb/source/Commands | |
parent | 8487d22d12f5b7b5c745e5a5cdda61f8a07391e1 (diff) | |
download | llvm-8f3be7a32b631e9ba584872c1f0dde8fd8536c07.zip llvm-8f3be7a32b631e9ba584872c1f0dde8fd8536c07.tar.gz llvm-8f3be7a32b631e9ba584872c1f0dde8fd8536c07.tar.bz2 |
[FileSystem] Move path resolution logic out of FileSpec
This patch removes the logic for resolving paths out of FileSpec and
updates call sites to rely on the FileSystem class instead.
Differential revision: https://reviews.llvm.org/D53915
llvm-svn: 345890
Diffstat (limited to 'lldb/source/Commands')
-rw-r--r-- | lldb/source/Commands/CommandCompletions.cpp | 4 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectBreakpoint.cpp | 13 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectCommands.cpp | 3 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectLog.cpp | 3 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectMemory.cpp | 3 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectPlatform.cpp | 36 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectPlugin.cpp | 3 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectProcess.cpp | 16 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectSettings.cpp | 7 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectSource.cpp | 10 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectTarget.cpp | 19 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectThread.cpp | 2 |
12 files changed, 67 insertions, 52 deletions
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index fbc9a33..af699a5 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -361,7 +361,7 @@ CommandCompletions::SourceFileCompleter::SourceFileCompleter( 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(); } @@ -501,7 +501,7 @@ size_t CommandCompletions::SymbolCompleter::DoCompletion(SearchFilter *filter) { 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(); } diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index 1f324c7..0002b7f 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -438,7 +438,7 @@ public: } break; case 'f': - m_filenames.AppendIfUnique(FileSpec(option_arg, false)); + m_filenames.AppendIfUnique(FileSpec(option_arg)); break; case 'F': @@ -557,7 +557,7 @@ public: break; case 's': - m_modules.AppendIfUnique(FileSpec(option_arg, false)); + m_modules.AppendIfUnique(FileSpec(option_arg)); break; case 'S': @@ -2370,7 +2370,8 @@ protected: 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); @@ -2504,8 +2505,10 @@ protected: 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()); diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index 7f50025..1759bef 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -308,7 +308,8 @@ protected: 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 diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp index 8cc21ec..6fca265 100644 --- a/lldb/source/Commands/CommandObjectLog.cpp +++ b/lldb/source/Commands/CommandObjectLog.cpp @@ -101,7 +101,8 @@ public: 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; diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index 5fbc622..95001e0 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -1209,7 +1209,8 @@ public: 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'", diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp index b800174..6cbbf42 100644 --- a/lldb/source/Commands/CommandObjectPlatform.cpp +++ b/lldb/source/Commands/CommandObjectPlatform.cpp @@ -491,8 +491,7 @@ public: 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 { @@ -545,7 +544,7 @@ public: 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); @@ -883,8 +882,8 @@ public: 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", @@ -949,8 +948,7 @@ public: 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", @@ -987,8 +985,9 @@ public: 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()); @@ -1336,31 +1335,31 @@ protected: 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; @@ -1529,7 +1528,7 @@ public: break; case 'n': - attach_info.GetExecutableFile().SetFile(option_arg, false, + attach_info.GetExecutableFile().SetFile(option_arg, FileSpec::Style::native); break; @@ -1576,7 +1575,7 @@ public: 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); @@ -1816,8 +1815,9 @@ public: 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); diff --git a/lldb/source/Commands/CommandObjectPlugin.cpp b/lldb/source/Commands/CommandObjectPlugin.cpp index 13ef6b2..af450ae 100644 --- a/lldb/source/Commands/CommandObjectPlugin.cpp +++ b/lldb/source/Commands/CommandObjectPlugin.cpp @@ -63,7 +63,8 @@ protected: 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); diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 73af71f..2bd98b2 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -352,7 +352,7 @@ public: break; case 'n': - attach_info.GetExecutableFile().SetFile(option_arg, false, + attach_info.GetExecutableFile().SetFile(option_arg, FileSpec::Style::native); break; @@ -403,7 +403,7 @@ public: 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); @@ -975,7 +975,7 @@ public: 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'", @@ -1023,18 +1023,20 @@ protected: 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); } @@ -1281,7 +1283,7 @@ protected: 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); diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp index 48ce3753f..cceb420 100644 --- a/lldb/source/Commands/CommandObjectSettings.cpp +++ b/lldb/source/Commands/CommandObjectSettings.cpp @@ -403,7 +403,9 @@ public: 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) @@ -506,7 +508,8 @@ public: 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); diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index d321afd..c484a2c 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -517,7 +517,7 @@ protected: // 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 = @@ -596,7 +596,7 @@ protected: 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) @@ -921,7 +921,7 @@ protected: 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(); @@ -946,7 +946,7 @@ protected: 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(); @@ -1203,7 +1203,7 @@ protected: 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(); diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index de9526d..d897799 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -313,8 +313,10 @@ protected: 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; @@ -1793,7 +1795,7 @@ static uint32_t LookupFileAndLineInModule(CommandInterpreter &interpreter, 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(); @@ -2352,7 +2354,7 @@ protected: 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()); @@ -2532,7 +2534,7 @@ protected: 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()) @@ -3616,7 +3618,7 @@ public: break; case 'f': - m_file.SetFile(option_arg, false, FileSpec::Style::native); + m_file.SetFile(option_arg, FileSpec::Style::native); m_type = eLookupTypeFileLine; break; @@ -4348,8 +4350,9 @@ protected: 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(); diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index 53b5b7a..44ed39c 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -1729,7 +1729,7 @@ public: 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; |