diff --git a/lldb/include/lldb/Utility/FileSpec.h b/lldb/include/lldb/Utility/FileSpec.h index 9da6670f1c612c..61b6209bb3c020 100644 --- a/lldb/include/lldb/Utility/FileSpec.h +++ b/lldb/include/lldb/Utility/FileSpec.h @@ -75,18 +75,6 @@ class FileSpec { explicit FileSpec(llvm::StringRef path, const llvm::Triple &triple); - /// Copy constructor - /// - /// Makes a copy of the uniqued directory and filename strings from \a rhs - /// if it is not nullptr. - /// - /// \param[in] rhs - /// A const FileSpec object pointer to copy if non-nullptr. - FileSpec(const FileSpec *rhs); - - /// Destructor. - ~FileSpec(); - bool DirectoryEquals(const FileSpec &other) const; bool FileEquals(const FileSpec &other) const; diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index 2dada9a6118db4..f7f748f5683217 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -1037,7 +1037,7 @@ SBError SBThread::JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line) { Thread *thread = exe_ctx.GetThreadPtr(); - Status err = thread->JumpToLine(file_spec.get(), line, true); + Status err = thread->JumpToLine(file_spec.ref(), line, true); sb_error.SetError(err); return LLDB_RECORD_RESULT(sb_error); } diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp index 6978a31fb2e513..b0ce967a796654 100644 --- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -114,9 +114,10 @@ const char *ObjectFilePECOFF::GetPluginDescriptionStatic() { ObjectFile *ObjectFilePECOFF::CreateInstance(const lldb::ModuleSP &module_sp, DataBufferSP &data_sp, lldb::offset_t data_offset, - const lldb_private::FileSpec *file, + const lldb_private::FileSpec *file_p, lldb::offset_t file_offset, lldb::offset_t length) { + FileSpec file = file_p ? *file_p : FileSpec(); if (!data_sp) { data_sp = MapFileData(file, length, file_offset); if (!data_sp) @@ -135,7 +136,7 @@ ObjectFile *ObjectFilePECOFF::CreateInstance(const lldb::ModuleSP &module_sp, } auto objfile_up = std::make_unique( - module_sp, data_sp, data_offset, file, file_offset, length); + module_sp, data_sp, data_offset, file_p, file_offset, length); if (!objfile_up || !objfile_up->ParseHeader()) return nullptr; diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index 6a3e6b4cadefc6..ae9f20db43cc25 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -1106,7 +1106,7 @@ static FileSpec GetXcodeSelectPath() { std::string command_output; Status status = Host::RunShellCommand("/usr/bin/xcode-select --print-path", - nullptr, // current working directory + FileSpec(), // current working directory &exit_status, &signo, &command_output, std::chrono::seconds(2), // short timeout false); // don't run in a shell diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp index 95ba81a2ab4930..134a4c7c80759c 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp @@ -180,11 +180,11 @@ ConstString PlatformMacOSX::GetSDKDirectory(lldb_private::Target &target) { std::string output; const char *command = "xcrun -sdk macosx --show-sdk-path"; lldb_private::Status error = RunShellCommand( - command, // shell command to run - nullptr, // current working directory - &status, // Put the exit status of the process in here - &signo, // Put the signal that caused the process to exit in - // here + command, // shell command to run + FileSpec(), // current working directory + &status, // Put the exit status of the process in here + &signo, // Put the signal that caused the process to exit in + // here &output, // Get the output from the command and place it in this // string std::chrono::seconds(3)); diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp index 154bd25da48115..f24856bc5b3f65 100644 --- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -223,7 +223,7 @@ static uint32_t chown_file(Platform *platform, const char *path, command.Printf(":%d", gid); command.Printf("%s", path); int status; - platform->RunShellCommand(command.GetData(), nullptr, &status, nullptr, + platform->RunShellCommand(command.GetData(), FileSpec(), &status, nullptr, nullptr, std::chrono::seconds(10)); return status; } @@ -248,7 +248,7 @@ PlatformPOSIX::PutFile(const lldb_private::FileSpec &source, StreamString command; command.Printf("cp %s %s", src_path.c_str(), dst_path.c_str()); int status; - RunShellCommand(command.GetData(), nullptr, &status, nullptr, nullptr, + RunShellCommand(command.GetData(), FileSpec(), &status, nullptr, nullptr, std::chrono::seconds(10)); if (status != 0) return Status("unable to perform copy"); @@ -278,7 +278,7 @@ PlatformPOSIX::PutFile(const lldb_private::FileSpec &source, GetHostname(), dst_path.c_str()); LLDB_LOGF(log, "[PutFile] Running command: %s\n", command.GetData()); int retcode; - Host::RunShellCommand(command.GetData(), nullptr, &retcode, nullptr, + Host::RunShellCommand(command.GetData(), FileSpec(), &retcode, nullptr, nullptr, std::chrono::minutes(1)); if (retcode == 0) { // Don't chown a local file for a remote system @@ -314,7 +314,7 @@ lldb_private::Status PlatformPOSIX::GetFile( StreamString cp_command; cp_command.Printf("cp %s %s", src_path.c_str(), dst_path.c_str()); int status; - RunShellCommand(cp_command.GetData(), nullptr, &status, nullptr, nullptr, + RunShellCommand(cp_command.GetData(), FileSpec(), &status, nullptr, nullptr, std::chrono::seconds(10)); if (status != 0) return Status("unable to perform copy"); @@ -335,7 +335,7 @@ lldb_private::Status PlatformPOSIX::GetFile( dst_path.c_str()); LLDB_LOGF(log, "[GetFile] Running command: %s\n", command.GetData()); int retcode; - Host::RunShellCommand(command.GetData(), nullptr, &retcode, nullptr, + Host::RunShellCommand(command.GetData(), FileSpec(), &retcode, nullptr, nullptr, std::chrono::minutes(1)); if (retcode == 0) return Status(); diff --git a/lldb/source/Symbol/LocateSymbolFile.cpp b/lldb/source/Symbol/LocateSymbolFile.cpp index 0d0e5300668fc1..d2b39d6acd704b 100644 --- a/lldb/source/Symbol/LocateSymbolFile.cpp +++ b/lldb/source/Symbol/LocateSymbolFile.cpp @@ -230,19 +230,19 @@ static FileSpec LocateExecutableSymbolFileDsym(const ModuleSpec &module_spec) { ModuleSpec Symbols::LocateExecutableObjectFile(const ModuleSpec &module_spec) { ModuleSpec result; - const FileSpec *exec_fspec = module_spec.GetFileSpecPtr(); + const FileSpec &exec_fspec = module_spec.GetFileSpec(); const ArchSpec *arch = module_spec.GetArchitecturePtr(); const UUID *uuid = module_spec.GetUUIDPtr(); static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer( func_cat, "LocateExecutableObjectFile (file = %s, arch = %s, uuid = %p)", - exec_fspec ? exec_fspec->GetFilename().AsCString("") : "", + exec_fspec ? exec_fspec.GetFilename().AsCString("") : "", arch ? arch->GetArchitectureName() : "", (const void *)uuid); ModuleSpecList module_specs; ModuleSpec matched_module_spec; if (exec_fspec && - ObjectFile::GetModuleSpecifications(*exec_fspec, 0, 0, module_specs) && + ObjectFile::GetModuleSpecifications(exec_fspec, 0, 0, module_specs) && module_specs.FindMatchingModuleSpec(module_spec, matched_module_spec)) { result.GetFileSpec() = exec_fspec; } else { diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index ed76e753b17e90..01b9a92cafcf5c 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -404,8 +404,8 @@ Target::CreateAddressInModuleBreakpoint(lldb::addr_t file_addr, bool internal, bool request_hardware) { SearchFilterSP filter_sp( new SearchFilterForUnconstrainedSearches(shared_from_this())); - BreakpointResolverSP resolver_sp( - new BreakpointResolverAddress(nullptr, file_addr, file_spec)); + BreakpointResolverSP resolver_sp(new BreakpointResolverAddress( + nullptr, file_addr, file_spec ? *file_spec : FileSpec())); return CreateBreakpoint(filter_sp, resolver_sp, internal, request_hardware, false); } @@ -1425,8 +1425,7 @@ void Target::SetExecutableModule(ModuleSP &executable_sp, ModuleList added_modules; executable_objfile->GetDependentModules(dependent_files); for (uint32_t i = 0; i < dependent_files.GetSize(); i++) { - FileSpec dependent_file_spec( - dependent_files.GetFileSpecPointerAtIndex(i)); + FileSpec dependent_file_spec(dependent_files.GetFileSpecAtIndex(i)); FileSpec platform_dependent_file_spec; if (m_platform_sp) m_platform_sp->GetFileWithUUID(dependent_file_spec, nullptr, diff --git a/lldb/source/Utility/FileSpec.cpp b/lldb/source/Utility/FileSpec.cpp index de4714282adcdc..a9e542991f1797 100644 --- a/lldb/source/Utility/FileSpec.cpp +++ b/lldb/source/Utility/FileSpec.cpp @@ -75,15 +75,6 @@ FileSpec::FileSpec(llvm::StringRef path, Style style) : m_style(style) { FileSpec::FileSpec(llvm::StringRef path, const llvm::Triple &triple) : FileSpec{path, triple.isOSWindows() ? Style::windows : Style::posix} {} -// Copy constructor -FileSpec::FileSpec(const FileSpec *rhs) : m_directory(), m_filename() { - if (rhs) - *this = *rhs; -} - -// Virtual destructor in case anyone inherits from this class. -FileSpec::~FileSpec() {} - namespace { /// Safely get a character at the specified index. ///