[Lldb-commits] [PATCH] D31111: Delete various FileSystem functions that are either dead or have direct LLVM equivalents.
zturner updated this revision to Diff 92236. zturner added a comment. Forgot to remove `Stat` declaration from header file. https://reviews.llvm.org/D3 Files: lldb/include/lldb/Host/FileSystem.h lldb/source/Host/common/File.cpp lldb/source/Host/common/Host.cpp lldb/source/Host/macosx/Host.mm lldb/source/Host/posix/DomainSocket.cpp lldb/source/Host/posix/FileSystem.cpp lldb/source/Host/posix/PipePosix.cpp lldb/source/Host/windows/FileSystem.cpp lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp lldb/source/Target/ModuleCache.cpp lldb/source/Target/Platform.cpp Index: lldb/source/Target/Platform.cpp === --- lldb/source/Target/Platform.cpp +++ lldb/source/Target/Platform.cpp @@ -696,8 +696,7 @@ namespace fs = llvm::sys::fs; switch (fs::get_file_type(src.GetPath(), false)) { case fs::file_type::directory_file: { - if (GetFileExists(fixed_dst)) -Unlink(fixed_dst); + llvm::sys::fs::remove(fixed_dst.GetPath()); uint32_t permissions = src.GetPermissions(); if (permissions == 0) permissions = eFilePermissionsDirectoryDefault; @@ -716,14 +715,12 @@ } break; case fs::file_type::regular_file: - if (GetFileExists(fixed_dst)) -Unlink(fixed_dst); + llvm::sys::fs::remove(fixed_dst.GetPath()); error = PutFile(src, fixed_dst); break; case fs::file_type::symlink_file: { - if (GetFileExists(fixed_dst)) -Unlink(fixed_dst); + llvm::sys::fs::remove(fixed_dst.GetPath()); FileSpec src_resolved; error = FileSystem::Readlink(src, src_resolved); if (error.Success()) Index: lldb/source/Target/ModuleCache.cpp === --- lldb/source/Target/ModuleCache.cpp +++ lldb/source/Target/ModuleCache.cpp @@ -13,7 +13,6 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Host/File.h" -#include "lldb/Host/FileSystem.h" #include "lldb/Host/LockFile.h" #include "lldb/Utility/Log.h" #include "llvm/Support/FileSystem.h" @@ -101,11 +100,12 @@ module_uuid.GetAsString().c_str(), error.AsCString()); } - auto link_count = FileSystem::GetHardlinkCount(sysroot_module_path_spec); - if (link_count == -1) + namespace fs = llvm::sys::fs; + fs::file_status st; + if (status(sysroot_module_path_spec.GetPath(), st)) return; - if (link_count > 2) // module is referred by other hosts. + if (st.getLinkCount() > 2) // module is referred by other hosts. return; const auto module_spec_dir = GetModuleDirectory(root_dir_spec, module_uuid); @@ -119,11 +119,10 @@ DeleteExistingModule(root_dir_spec, sysroot_module_path_spec); // Remove sysroot link. - FileSystem::Unlink(sysroot_module_path_spec); + llvm::sys::fs::remove(sysroot_module_path_spec.GetPath()); FileSpec symfile_spec = GetSymbolFileSpec(sysroot_module_path_spec); - if (symfile_spec.Exists()) // delete module's symbol file if exists. -FileSystem::Unlink(symfile_spec); + llvm::sys::fs::remove(symfile_spec.GetPath()); } Error CreateHostSysRootModuleLink(const FileSpec &root_dir_spec, @@ -146,7 +145,8 @@ if (error.Fail()) return error; - return FileSystem::Hardlink(sysroot_module_path_spec, local_module_spec); + return llvm::sys::fs::create_hard_link(sysroot_module_path_spec.GetPath(), + local_module_spec.GetPath()); } } // namespace @@ -179,7 +179,7 @@ return; m_file.Close(); - FileSystem::Unlink(m_file_spec); + llvm::sys::fs::remove(m_file_spec.GetPath()); } / Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp === --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -642,14 +642,15 @@ std::string path; packet.GetHexByteString(path); if (!path.empty()) { -lldb::user_id_t retcode = FileSystem::GetFileSize(FileSpec(path, false)); +uint64_t Size; +if (llvm::sys::fs::file_size(path, Size)) + return SendErrorResponse(5); StreamString response; response.PutChar('F'); -response.PutHex64(retcode); -if (retcode == UINT64_MAX) { +response.PutHex64(Size); +if (Size == UINT64_MAX) { response.PutChar(','); - response.PutHex64( - retcode); // TODO: replace with Host::GetSyswideErrorCode() + response.PutHex64(Size); // TODO: replace with Host::GetSyswideErrorCode() } return SendPacketNoLock(response.GetString()); } @@ -681,7 +682,7 @@ std::string path; packet.GetHexByteString(path); if (!path.empty())
[Lldb-commits] [PATCH] D31111: Delete various FileSystem functions that are either dead or have direct LLVM equivalents.
zturner created this revision. Herald added a subscriber: emaste. https://reviews.llvm.org/D3 Files: lldb/include/lldb/Host/FileSystem.h lldb/source/Host/common/File.cpp lldb/source/Host/common/Host.cpp lldb/source/Host/macosx/Host.mm lldb/source/Host/posix/DomainSocket.cpp lldb/source/Host/posix/FileSystem.cpp lldb/source/Host/posix/PipePosix.cpp lldb/source/Host/windows/FileSystem.cpp lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp lldb/source/Target/ModuleCache.cpp lldb/source/Target/Platform.cpp Index: lldb/source/Target/Platform.cpp === --- lldb/source/Target/Platform.cpp +++ lldb/source/Target/Platform.cpp @@ -696,8 +696,7 @@ namespace fs = llvm::sys::fs; switch (fs::get_file_type(src.GetPath(), false)) { case fs::file_type::directory_file: { - if (GetFileExists(fixed_dst)) -Unlink(fixed_dst); + llvm::sys::fs::remove(fixed_dst.GetPath()); uint32_t permissions = src.GetPermissions(); if (permissions == 0) permissions = eFilePermissionsDirectoryDefault; @@ -716,14 +715,12 @@ } break; case fs::file_type::regular_file: - if (GetFileExists(fixed_dst)) -Unlink(fixed_dst); + llvm::sys::fs::remove(fixed_dst.GetPath()); error = PutFile(src, fixed_dst); break; case fs::file_type::symlink_file: { - if (GetFileExists(fixed_dst)) -Unlink(fixed_dst); + llvm::sys::fs::remove(fixed_dst.GetPath()); FileSpec src_resolved; error = FileSystem::Readlink(src, src_resolved); if (error.Success()) Index: lldb/source/Target/ModuleCache.cpp === --- lldb/source/Target/ModuleCache.cpp +++ lldb/source/Target/ModuleCache.cpp @@ -13,7 +13,6 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Host/File.h" -#include "lldb/Host/FileSystem.h" #include "lldb/Host/LockFile.h" #include "lldb/Utility/Log.h" #include "llvm/Support/FileSystem.h" @@ -101,11 +100,12 @@ module_uuid.GetAsString().c_str(), error.AsCString()); } - auto link_count = FileSystem::GetHardlinkCount(sysroot_module_path_spec); - if (link_count == -1) + namespace fs = llvm::sys::fs; + fs::file_status st; + if (status(sysroot_module_path_spec.GetPath(), st)) return; - if (link_count > 2) // module is referred by other hosts. + if (st.getLinkCount() > 2) // module is referred by other hosts. return; const auto module_spec_dir = GetModuleDirectory(root_dir_spec, module_uuid); @@ -119,11 +119,10 @@ DeleteExistingModule(root_dir_spec, sysroot_module_path_spec); // Remove sysroot link. - FileSystem::Unlink(sysroot_module_path_spec); + llvm::sys::fs::remove(sysroot_module_path_spec.GetPath()); FileSpec symfile_spec = GetSymbolFileSpec(sysroot_module_path_spec); - if (symfile_spec.Exists()) // delete module's symbol file if exists. -FileSystem::Unlink(symfile_spec); + llvm::sys::fs::remove(symfile_spec.GetPath()); } Error CreateHostSysRootModuleLink(const FileSpec &root_dir_spec, @@ -146,7 +145,8 @@ if (error.Fail()) return error; - return FileSystem::Hardlink(sysroot_module_path_spec, local_module_spec); + return llvm::sys::fs::create_hard_link(sysroot_module_path_spec.GetPath(), + local_module_spec.GetPath()); } } // namespace @@ -179,7 +179,7 @@ return; m_file.Close(); - FileSystem::Unlink(m_file_spec); + llvm::sys::fs::remove(m_file_spec.GetPath()); } / Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp === --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -642,14 +642,15 @@ std::string path; packet.GetHexByteString(path); if (!path.empty()) { -lldb::user_id_t retcode = FileSystem::GetFileSize(FileSpec(path, false)); +uint64_t Size; +if (llvm::sys::fs::file_size(path, Size)) + return SendErrorResponse(5); StreamString response; response.PutChar('F'); -response.PutHex64(retcode); -if (retcode == UINT64_MAX) { +response.PutHex64(Size); +if (Size == UINT64_MAX) { response.PutChar(','); - response.PutHex64( - retcode); // TODO: replace with Host::GetSyswideErrorCode() + response.PutHex64(Size); // TODO: replace with Host::GetSyswideErrorCode() } return SendPacketNoLock(response.GetString()); } @@ -681,7 +682,7 @@ std::string path; packet.GetHexByteString(path); if (!path.empty()) { -bool retcode = FileSystem::GetFileExists(FileSpec(pa
[Lldb-commits] [PATCH] D31086: Remove FileSystem::MakeDirectory
sas accepted this revision. sas added a comment. This revision is now accepted and ready to land. The second behavioral change seems good but the first thing you described is a bit odd. Creating folders with 770 does not seem like a common behavior, and 700 or 755 is usually more standard. Either way, I think this change is good. https://reviews.llvm.org/D31086 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31108: Delete LLDB code for MD5'ing a file. Use LLVM instead
sas accepted this revision. sas added a comment. This revision is now accepted and ready to land. So nice. https://reviews.llvm.org/D31108 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31108: Delete LLDB code for MD5'ing a file. Use LLVM instead
zturner created this revision. https://reviews.llvm.org/D31108 Files: lldb/source/Host/common/FileSystem.cpp lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp lldb/source/Target/Platform.cpp Index: lldb/source/Target/Platform.cpp === --- lldb/source/Target/Platform.cpp +++ lldb/source/Target/Platform.cpp @@ -1346,10 +1346,13 @@ bool Platform::CalculateMD5(const FileSpec &file_spec, uint64_t &low, uint64_t &high) { - if (IsHost()) -return FileSystem::CalculateMD5(file_spec, low, high); - else + if (!IsHost()) return false; + auto Result = llvm::sys::fs::md5_contents(file_spec.GetPath()); + if (!Result) +return false; + std::tie(high, low) = Result->words(); + return true; } void Platform::SetLocalCacheDirectory(const char *local) { Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp === --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -773,13 +773,14 @@ if (!path.empty()) { uint64_t a, b; StreamGDBRemote response; -if (!FileSystem::CalculateMD5(FileSpec(path, false), a, b)) { +auto Result = llvm::sys::fs::md5_contents(path); +if (!Result) { response.PutCString("F,"); response.PutCString("x"); } else { response.PutCString("F,"); - response.PutHex64(a); - response.PutHex64(b); + response.PutHex64(Result->low()); + response.PutHex64(Result->high()); } return SendPacketNoLock(response.GetString()); } @@ -1092,12 +1093,11 @@ StreamGDBRemote response; if (uuid_str.empty()) { -std::string md5_hash; -if (!FileSystem::CalculateMD5AsString(matched_module_spec.GetFileSpec(), - file_offset, file_size, md5_hash)) +auto Result = llvm::sys::fs::md5_contents(matched_module_spec.GetFileSpec().GetPath()); +if (!Result) return SendErrorResponse(5); response.PutCString("md5:"); -response.PutCStringAsRawHex8(md5_hash.c_str()); +response.PutCStringAsRawHex8(Result->digest().c_str()); } else { response.PutCString("uuid:"); response.PutCStringAsRawHex8(uuid_str.c_str()); Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp === --- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -25,7 +25,6 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/Timer.h" -#include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/StringConvert.h" @@ -297,11 +296,14 @@ // get the local and remote MD5 and compare if (m_remote_platform_sp) { // when going over the *slow* GDB remote transfer mechanism we first - // check - // the hashes of the files - and only do the actual transfer if they - // differ + // check the hashes of the files - and only do the actual transfer if + // they differ uint64_t high_local, high_remote, low_local, low_remote; - FileSystem::CalculateMD5(module_cache_spec, low_local, high_local); + auto MD5 = llvm::sys::fs::md5_contents(module_cache_spec.GetPath()); + if (!MD5) +return Error(MD5.getError()); + std::tie(high_local, low_local) = MD5->words(); + m_remote_platform_sp->CalculateMD5(module_spec.GetFileSpec(), low_remote, high_remote); if (low_local != low_remote || high_local != high_remote) { Index: lldb/source/Host/common/FileSystem.cpp === --- lldb/source/Host/common/FileSystem.cpp +++ lldb/source/Host/common/FileSystem.cpp @@ -10,86 +10,14 @@ #include "lldb/Host/FileSystem.h" #include "llvm/Support/FileSystem.h" -#include "llvm/Support/MD5.h" #include #include #include using namespace lldb; using namespace lldb_private; -namespace { - -bool CalcMD5(const FileSpec &file_spec, uint64_t offset, uint64_t length, - llvm::MD5::MD5Result &md5_result) { - llvm::MD5 md5_hash; - std::ifstream file(file_spec.GetPath(), std::ios::binary); - if (!file.is_open()) -return false; - - if (offset > 0) -file.seekg(offset, file.beg); - - std::vector read_buf(4096); - uint64_t total_read_bytes = 0; - while (!file.eof()) { -const uint64_t to_read = -(length > 0) ? std::min(static_cast(read_buf.size()), -length - total_read_bytes) - : read_buf.siz
[Lldb-commits] [lldb] r298123 - allow for specification of compiler/lldb executables basename
Author: penryu Date: Fri Mar 17 16:00:35 2017 New Revision: 298123 URL: http://llvm.org/viewvc/llvm-project?rev=298123&view=rev Log: allow for specification of compiler/lldb executables basename Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest.py?rev=298123&r1=298122&r2=298123&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/dotest.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py Fri Mar 17 16:00:35 2017 @@ -278,6 +278,8 @@ def parseOptionsAndInitTestdirs(): if args.compiler: configuration.compiler = os.path.realpath(args.compiler) if not is_exe(configuration.compiler): +configuration.compiler = which(args.compiler) +if not is_exe(configuration.compiler): logging.error( '%s is not a valid compiler executable; aborting...', args.compiler) @@ -370,6 +372,8 @@ def parseOptionsAndInitTestdirs(): # lldb executable is passed explicitly lldbtest_config.lldbExec = os.path.realpath(args.executable) if not is_exe(lldbtest_config.lldbExec): +lldbtest_config.lldbExec = which(args.executable) +if not is_exe(lldbtest_config.lldbExec): logging.error( '%s is not a valid executable to test; aborting...', args.executable) ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31089: Remove FileSystem::GetFilePermissions and FileSystem::SetFilePermissions
labath accepted this revision. labath added a comment. This revision is now accepted and ready to land. Cool. Nevermind me then. https://reviews.llvm.org/D31089 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31086: Remove FileSystem::MakeDirectory
labath added a comment. In https://reviews.llvm.org/D31086#704122, @zturner wrote: > That one is calling a file static function `MakeDirectory`, not > `FileSystem::MakeDirectory`, and the implementation of that function already > calls `llvm::sys::fs::create_directories()` to create the whole tree, so it > should be fine. Right, sorry about that. I was looking at an old checkout. I'm not sure about the PlatformDarwin stuff, but the rest seems fine. https://reviews.llvm.org/D31086 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31089: Remove FileSystem::GetFilePermissions and FileSystem::SetFilePermissions
zturner added inline comments. Comment at: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp:813 + auto perms = + static_cast(packet.GetHexMaxU32(false, UINT32_MAX)); if (packet.GetChar() == ',') { zturner wrote: > labath wrote: > > This doesn't seem right. At the very least I would expect to see a matching > > change in the client code (I assume llvm constants don't match whatever we > > have used here (?)). > > > > We don't care much about protocol compatibility, but the apple guys might. > > If that is the case then we will need some encode/decode functions here. > AFAICT both LLVM's enumeration and LLDB's enumeration map directly to the > unix file permissions bits. Here is the implementation of `setPermissions` in LLVM: ``` std::error_code setPermissions(const Twine &Path, perms Permissions) { SmallString<128> PathStorage; StringRef P = Path.toNullTerminatedStringRef(PathStorage); if (::chmod(P.begin(), Permissions)) return std::error_code(errno, std::generic_category()); return std::error_code(); } ``` So it's literally the same as LLDB's implementation which I've deleted, which was: ``` Error FileSystem::SetFilePermissions(const FileSpec &file_spec, uint32_t file_permissions) { Error error; if (::chmod(file_spec.GetCString(), file_permissions) != 0) error.SetErrorToErrno(); return error; } ``` https://reviews.llvm.org/D31089 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31089: Remove FileSystem::GetFilePermissions and FileSystem::SetFilePermissions
zturner added inline comments. Comment at: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp:813 + auto perms = + static_cast(packet.GetHexMaxU32(false, UINT32_MAX)); if (packet.GetChar() == ',') { labath wrote: > This doesn't seem right. At the very least I would expect to see a matching > change in the client code (I assume llvm constants don't match whatever we > have used here (?)). > > We don't care much about protocol compatibility, but the apple guys might. If > that is the case then we will need some encode/decode functions here. AFAICT both LLVM's enumeration and LLDB's enumeration map directly to the unix file permissions bits. https://reviews.llvm.org/D31089 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31089: Remove FileSystem::GetFilePermissions and FileSystem::SetFilePermissions
labath added a reviewer: jingham. labath added inline comments. Comment at: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp:813 + auto perms = + static_cast(packet.GetHexMaxU32(false, UINT32_MAX)); if (packet.GetChar() == ',') { This doesn't seem right. At the very least I would expect to see a matching change in the client code (I assume llvm constants don't match whatever we have used here (?)). We don't care much about protocol compatibility, but the apple guys might. If that is the case then we will need some encode/decode functions here. https://reviews.llvm.org/D31089 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31086: Remove FileSystem::MakeDirectory
zturner added a comment. That one is calling a file static function `MakeDirectory`, not `FileSystem::MakeDirectory`, and the implementation of that function already calls `llvm::sys::fs::create_directories()` to create the whole tree, so it should be fine. https://reviews.llvm.org/D31086 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31086: Remove FileSystem::MakeDirectory
labath added a comment. I think you missed one occurence in ModuleCache.cpp. This one creates a full directory structure, so you will probably need recursion there (unlike in the rest of these cases, which seem fine). Also unlike the rest of these cases, that one is actually covered by a unit test, so you should be able to verify that. :) https://reviews.llvm.org/D31086 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31079: Replace std::ofstream with llvm::raw_fd_ostream
labath added a comment. In https://reviews.llvm.org/D31079#703911, @zturner wrote: > In the places where you want to read from an `ifstream` and write to a > socket, you might consider using `llvm::sys::fs::copy_file`, declared in > `Support/FileSystem.h`. Currently it takes two paths, but all it does is > call `openFileForRead()` on the first one and `openFileForWrite()` on the > second one to get FDs. So you could probably add an overload that takes two > FDs, and have the path version just call the FD version. Then you could call > the FD version directly with an FD for your file and an FD for your socket. Unfortunately, that won't be enough. I need to split the data into chunks and add a header before each chunk. I guess I'll just stick with LLDB's File class for now (?) https://reviews.llvm.org/D31079 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r298111 - executables should be validated before spawning subprocesses
Author: penryu Date: Fri Mar 17 13:10:58 2017 New Revision: 298111 URL: http://llvm.org/viewvc/llvm-project?rev=298111&view=rev Log: executables should be validated before spawning subprocesses dotest.py script doesn't validate executables passed on the command line before spawning dozens of subprocesses, all of which fail silently, leaving an empty results file. We should validate the lldb and compiler executables on configuration, aborting when given invalid paths, to prevent numerous, cryptic, and spurious failures. Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest.py?rev=298111&r1=298110&r2=298111&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/dotest.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py Fri Mar 17 13:10:58 2017 @@ -25,6 +25,7 @@ from __future__ import print_function import atexit import os import errno +import logging import platform import re import signal @@ -275,7 +276,12 @@ def parseOptionsAndInitTestdirs(): do_help = True if args.compiler: -configuration.compiler = args.compiler +configuration.compiler = os.path.realpath(args.compiler) +if not is_exe(configuration.compiler): +logging.error( +'%s is not a valid compiler executable; aborting...', +args.compiler) +sys.exit(-1) else: # Use a compiler appropriate appropriate for the Apple SDK if one was # specified @@ -361,8 +367,14 @@ def parseOptionsAndInitTestdirs(): configuration.lldbFrameworkPath = args.framework if args.executable: +# lldb executable is passed explicitly lldbtest_config.lldbExec = os.path.realpath(args.executable) - +if not is_exe(lldbtest_config.lldbExec): +logging.error( +'%s is not a valid executable to test; aborting...', +args.executable) +sys.exit(-1) + if args.server: os.environ['LLDB_DEBUGSERVER_PATH'] = args.server ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31089: Remove FileSystem::GetFilePermissions and FileSystem::SetFilePermissions
zturner created this revision. Use the LLVM functions instead https://reviews.llvm.org/D31089 Files: lldb/include/lldb/Host/FileSystem.h lldb/source/Host/posix/FileSystem.cpp lldb/source/Host/windows/FileSystem.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp lldb/source/Target/Platform.cpp Index: lldb/source/Target/Platform.cpp === --- lldb/source/Target/Platform.cpp +++ lldb/source/Target/Platform.cpp @@ -773,9 +773,12 @@ Error Platform::GetFilePermissions(const FileSpec &file_spec, uint32_t &file_permissions) { - if (IsHost()) -return FileSystem::GetFilePermissions(file_spec, file_permissions); - else { + if (IsHost()) { +auto Value = llvm::sys::fs::getPermissions(file_spec.GetPath()); +if (Value) + file_permissions = Value.get(); +return Error(Value.getError()); + } else { Error error; error.SetErrorStringWithFormat("remote platform %s doesn't support %s", GetPluginName().GetCString(), @@ -786,9 +789,10 @@ Error Platform::SetFilePermissions(const FileSpec &file_spec, uint32_t file_permissions) { - if (IsHost()) -return FileSystem::SetFilePermissions(file_spec, file_permissions); - else { + if (IsHost()) { +auto Perms = static_cast(file_permissions); +return llvm::sys::fs::setPermissions(file_spec.GetPath(), Perms); + } else { Error error; error.SetErrorStringWithFormat("remote platform %s doesn't support %s", GetPluginName().GetCString(), Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp === --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -809,11 +809,12 @@ StringExtractorGDBRemote &packet) { packet.SetFilePos(::strlen("qPlatform_chmod:")); - mode_t mode = packet.GetHexMaxU32(false, UINT32_MAX); + auto perms = + static_cast(packet.GetHexMaxU32(false, UINT32_MAX)); if (packet.GetChar() == ',') { std::string path; packet.GetHexByteString(path); -Error error = FileSystem::SetFilePermissions(FileSpec{path, true}, mode); +Error error(llvm::sys::fs::setPermissions(path, perms)); StreamGDBRemote response; response.Printf("F%u", error.GetError()); Index: lldb/source/Host/windows/FileSystem.cpp === --- lldb/source/Host/windows/FileSystem.cpp +++ lldb/source/Host/windows/FileSystem.cpp @@ -30,34 +30,6 @@ return FileSpec::ePathSyntaxWindows; } -Error FileSystem::GetFilePermissions(const FileSpec &file_spec, - uint32_t &file_permissions) { - Error error; - // Beware that Windows's permission model is different from Unix's, and it's - // not clear if this API is supposed to check ACLs. To match the caller's - // expectations as closely as possible, we'll use Microsoft's _stat, which - // attempts to emulate POSIX stat. This should be good enough for basic - // checks like FileSpec::Readable. - struct _stat file_stats; - if (::_stat(file_spec.GetCString(), &file_stats) == 0) { -// The owner permission bits in "st_mode" currently match the definitions -// for the owner file mode bits. -file_permissions = file_stats.st_mode & (_S_IREAD | _S_IWRITE | _S_IEXEC); - } else { -error.SetErrorToErrno(); - } - - return error; -} - -Error FileSystem::SetFilePermissions(const FileSpec &file_spec, - uint32_t file_permissions) { - Error error; - error.SetErrorStringWithFormat("%s is not supported on this host", - LLVM_PRETTY_FUNCTION); - return error; -} - lldb::user_id_t FileSystem::GetFileSize(const FileSpec &file_spec) { return file_spec.GetByteSize(); } Index: lldb/source/Host/posix/FileSystem.cpp === --- lldb/source/Host/posix/FileSystem.cpp +++ lldb/source/Host/posix/FileSystem.cpp @@ -40,28 +40,6 @@ return FileSpec::ePathSyntaxPosix; } -Error FileSystem::GetFilePermissions(const FileSpec &file_spec, - uint32_t &file_permissions) { - Error error; - struct stat file_stats; - if (::stat(file_spec.GetCString(), &file_stats) == 0) { -// The bits in "st_mode" currently match the definitions -// for the file mode bits in unix. -file_permissions = file_stats.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); - } else { -error.SetErrorToErrno(); - } - return error; -} - -Error FileSystem::SetFilePermissions(const FileSpec &file_spec, - uint32_t file_permissions) { - Error error; - if (::chmod
[Lldb-commits] [PATCH] D31088: Remove FileSystem::GetFilePermissions and SetFilePermissions
zturner created this revision. Use the LLVM functions instead. https://reviews.llvm.org/D31088 Files: lldb/include/lldb/Host/FileSystem.h lldb/source/Host/posix/FileSystem.cpp lldb/source/Host/windows/FileSystem.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp lldb/source/Target/Platform.cpp Index: lldb/source/Target/Platform.cpp === --- lldb/source/Target/Platform.cpp +++ lldb/source/Target/Platform.cpp @@ -773,9 +773,12 @@ Error Platform::GetFilePermissions(const FileSpec &file_spec, uint32_t &file_permissions) { - if (IsHost()) -return FileSystem::GetFilePermissions(file_spec, file_permissions); - else { + if (IsHost()) { +auto Value = llvm::sys::fs::getPermissions(file_spec.GetPath()); +if (Value) + file_permissions = Value.get(); +return Error(Value.getError()); + } else { Error error; error.SetErrorStringWithFormat("remote platform %s doesn't support %s", GetPluginName().GetCString(), @@ -786,9 +789,10 @@ Error Platform::SetFilePermissions(const FileSpec &file_spec, uint32_t file_permissions) { - if (IsHost()) -return FileSystem::SetFilePermissions(file_spec, file_permissions); - else { + if (IsHost()) { +auto Perms = static_cast(file_permissions); +return llvm::sys::fs::setPermissions(file_spec.GetPath(), Perms); + } else { Error error; error.SetErrorStringWithFormat("remote platform %s doesn't support %s", GetPluginName().GetCString(), Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp === --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -809,11 +809,12 @@ StringExtractorGDBRemote &packet) { packet.SetFilePos(::strlen("qPlatform_chmod:")); - mode_t mode = packet.GetHexMaxU32(false, UINT32_MAX); + auto perms = + static_cast(packet.GetHexMaxU32(false, UINT32_MAX)); if (packet.GetChar() == ',') { std::string path; packet.GetHexByteString(path); -Error error = FileSystem::SetFilePermissions(FileSpec{path, true}, mode); +Error error(llvm::sys::fs::setPermissions(path, perms)); StreamGDBRemote response; response.Printf("F%u", error.GetError()); Index: lldb/source/Host/windows/FileSystem.cpp === --- lldb/source/Host/windows/FileSystem.cpp +++ lldb/source/Host/windows/FileSystem.cpp @@ -30,34 +30,6 @@ return FileSpec::ePathSyntaxWindows; } -Error FileSystem::GetFilePermissions(const FileSpec &file_spec, - uint32_t &file_permissions) { - Error error; - // Beware that Windows's permission model is different from Unix's, and it's - // not clear if this API is supposed to check ACLs. To match the caller's - // expectations as closely as possible, we'll use Microsoft's _stat, which - // attempts to emulate POSIX stat. This should be good enough for basic - // checks like FileSpec::Readable. - struct _stat file_stats; - if (::_stat(file_spec.GetCString(), &file_stats) == 0) { -// The owner permission bits in "st_mode" currently match the definitions -// for the owner file mode bits. -file_permissions = file_stats.st_mode & (_S_IREAD | _S_IWRITE | _S_IEXEC); - } else { -error.SetErrorToErrno(); - } - - return error; -} - -Error FileSystem::SetFilePermissions(const FileSpec &file_spec, - uint32_t file_permissions) { - Error error; - error.SetErrorStringWithFormat("%s is not supported on this host", - LLVM_PRETTY_FUNCTION); - return error; -} - lldb::user_id_t FileSystem::GetFileSize(const FileSpec &file_spec) { return file_spec.GetByteSize(); } Index: lldb/source/Host/posix/FileSystem.cpp === --- lldb/source/Host/posix/FileSystem.cpp +++ lldb/source/Host/posix/FileSystem.cpp @@ -40,28 +40,6 @@ return FileSpec::ePathSyntaxPosix; } -Error FileSystem::GetFilePermissions(const FileSpec &file_spec, - uint32_t &file_permissions) { - Error error; - struct stat file_stats; - if (::stat(file_spec.GetCString(), &file_stats) == 0) { -// The bits in "st_mode" currently match the definitions -// for the file mode bits in unix. -file_permissions = file_stats.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); - } else { -error.SetErrorToErrno(); - } - return error; -} - -Error FileSystem::SetFilePermissions(const FileSpec &file_spec, - uint32_t file_permissions) { - Error error; - if (::chmo
[Lldb-commits] [PATCH] D31088: Remove FileSystem::GetFilePermissions and SetFilePermissions
zturner abandoned this revision. zturner added a comment. Messed up reviewer / subscriber. https://reviews.llvm.org/D31088 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31086: Remove FileSystem::MakeDirectory
zturner created this revision. Use the LLVM function instead. There are two subtle behavioral changes here which I want to make clear so someone can determine whether this matters on their platform. 1. Previously all LLDB callers were passing `eFilePermissionsDirectoryDefault` which is equal to `eFilePermissionsUserRWX` (0o700). The LLVM default is equivalent to `eFilePermissionsUserRWX | eFilePermissionsGroupRWX` (0o770). If this is a problem it's easy to update all callsites to explicitly pass 0o700, but I don't think it is. 2. The implementation of `MakeDirectory` would first try to create the directory, then if it failed due to `ENOENT` would try to create the parent directory. But it only went up one level. So if `/foo` existed but not `/foo/bar`, and you tried to create `/foo/bar/baz`, it would create `/foo/bar` first and then `/foo/bar/baz`. On the other hand, if not even `/foo` existed, the function would fail. This seems like very strange behavior to me, but I don't know if anyone depends on it. I imagine if the tests pass everywhere, then nobody does. They pass on Windows. If someone could confirm that they pass on other platforms after this patch it would be helpful. https://reviews.llvm.org/D31086 Files: lldb/include/lldb/Host/FileSystem.h lldb/source/Host/common/Editline.cpp lldb/source/Host/common/HostInfoBase.cpp lldb/source/Host/posix/FileSystem.cpp lldb/source/Host/windows/FileSystem.cpp lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp lldb/source/Target/Platform.cpp lldb/tools/lldb-server/lldb-platform.cpp Index: lldb/tools/lldb-server/lldb-platform.cpp === --- lldb/tools/lldb-server/lldb-platform.cpp +++ lldb/tools/lldb-server/lldb-platform.cpp @@ -32,7 +32,6 @@ #include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h" #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/FileSpec.h" -#include "lldb/Host/FileSystem.h" #include "lldb/Host/HostGetOpt.h" #include "lldb/Host/OptionParser.h" #include "lldb/Host/common/TCPSocket.h" @@ -102,8 +101,7 @@ static Error save_socket_id_to_file(const std::string &socket_id, const FileSpec &file_spec) { FileSpec temp_file_spec(file_spec.GetDirectory().AsCString(), false); - auto error = FileSystem::MakeDirectory(temp_file_spec, - eFilePermissionsDirectoryDefault); + Error error(llvm::sys::fs::create_directory(temp_file_spec.GetPath())); if (error.Fail()) return Error("Failed to create directory %s: %s", temp_file_spec.GetCString(), error.AsCString()); Index: lldb/source/Target/Platform.cpp === --- lldb/source/Target/Platform.cpp +++ lldb/source/Target/Platform.cpp @@ -761,7 +761,7 @@ Error Platform::MakeDirectory(const FileSpec &file_spec, uint32_t permissions) { if (IsHost()) -return FileSystem::MakeDirectory(file_spec, permissions); +return llvm::sys::fs::create_directory(file_spec.GetPath(), permissions); else { Error error; error.SetErrorStringWithFormat("remote platform %s doesn't support %s", Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp === --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -794,7 +794,7 @@ if (packet.GetChar() == ',') { std::string path; packet.GetHexByteString(path); -Error error = FileSystem::MakeDirectory(FileSpec{path, false}, mode); +Error error(llvm::sys::fs::create_directory(path, mode)); StreamGDBRemote response; response.Printf("F%u", error.GetError()); Index: lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp === --- lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp +++ lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp @@ -22,7 +22,6 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Host/FileSpec.h" -#include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Symbol/ObjectFile.h" @@ -279,8 +278,7 @@ FileSpec module_cache_folder = module_cache_spec.CopyByRemovingLastPathComponent(); // try to make the local directory first - Error err = FileSystem::MakeDirectory(module_cache_folder, -eFilePermissionsDirectoryDefault); + Error err(llvm::sys::fs::create_directory(module_cache_folder.GetPath())); if (err.Fail()) return err; err = GetFile(pl
[Lldb-commits] [PATCH] D31079: Replace std::ofstream with llvm::raw_fd_ostream
zturner accepted this revision. zturner added a comment. This revision is now accepted and ready to land. In the places where you want to read from an `ifstream` and write to a socket, you might consider using `llvm::sys::fs::copy_file`, declared in `Support/FileSystem.h`. Currently it takes two paths, but all it does is call `openFileForRead()` on the first one and `openFileForWrite()` on the second one to get FDs. So you could probably add an overload that takes two FDs, and have the path version just call the FD version. Then you could call the FD version directly with an FD for your file and an FD for your socket. https://reviews.llvm.org/D31079 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D30927: Normalize the LLVM cmake path before appending it to the module path
This revision was automatically updated to reflect the committed changes. Closed by commit rL298100: CMake requires normalized paths when appending. (authored by zturner). Changed prior to commit: https://reviews.llvm.org/D30927?vs=91676&id=92157#toc Repository: rL LLVM https://reviews.llvm.org/D30927 Files: lldb/trunk/cmake/modules/LLDBStandalone.cmake Index: lldb/trunk/cmake/modules/LLDBStandalone.cmake === --- lldb/trunk/cmake/modules/LLDBStandalone.cmake +++ lldb/trunk/cmake/modules/LLDBStandalone.cmake @@ -69,6 +69,7 @@ set(LLVMCONFIG_FILE "${LLVM_CMAKE_PATH}/LLVMConfig.cmake") if(EXISTS ${LLVMCONFIG_FILE}) +file(TO_CMAKE_PATH "${LLVM_CMAKE_PATH}" LLVM_CMAKE_PATH) list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") include(${LLVMCONFIG_FILE}) else() Index: lldb/trunk/cmake/modules/LLDBStandalone.cmake === --- lldb/trunk/cmake/modules/LLDBStandalone.cmake +++ lldb/trunk/cmake/modules/LLDBStandalone.cmake @@ -69,6 +69,7 @@ set(LLVMCONFIG_FILE "${LLVM_CMAKE_PATH}/LLVMConfig.cmake") if(EXISTS ${LLVMCONFIG_FILE}) +file(TO_CMAKE_PATH "${LLVM_CMAKE_PATH}" LLVM_CMAKE_PATH) list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") include(${LLVMCONFIG_FILE}) else() ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r298100 - CMake requires normalized paths when appending.
Author: zturner Date: Fri Mar 17 11:33:37 2017 New Revision: 298100 URL: http://llvm.org/viewvc/llvm-project?rev=298100&view=rev Log: CMake requires normalized paths when appending. Patch by Hugh Bellamy Differential Revision: https://reviews.llvm.org/D30927 Modified: lldb/trunk/cmake/modules/LLDBStandalone.cmake Modified: lldb/trunk/cmake/modules/LLDBStandalone.cmake URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBStandalone.cmake?rev=298100&r1=298099&r2=298100&view=diff == --- lldb/trunk/cmake/modules/LLDBStandalone.cmake (original) +++ lldb/trunk/cmake/modules/LLDBStandalone.cmake Fri Mar 17 11:33:37 2017 @@ -69,6 +69,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR set(LLVMCONFIG_FILE "${LLVM_CMAKE_PATH}/LLVMConfig.cmake") if(EXISTS ${LLVMCONFIG_FILE}) +file(TO_CMAKE_PATH "${LLVM_CMAKE_PATH}" LLVM_CMAKE_PATH) list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") include(${LLVMCONFIG_FILE}) else() ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D30926: Fix MSVC signed/unsigned conversion and size_t conversion warnings in LLDB
This revision was automatically updated to reflect the committed changes. Closed by commit rL298099: Fix some signed/unsigned comparison warnings. (authored by zturner). Changed prior to commit: https://reviews.llvm.org/D30926?vs=91670&id=92156#toc Repository: rL LLVM https://reviews.llvm.org/D30926 Files: lldb/trunk/source/Core/FormatEntity.cpp Index: lldb/trunk/source/Core/FormatEntity.cpp === --- lldb/trunk/source/Core/FormatEntity.cpp +++ lldb/trunk/source/Core/FormatEntity.cpp @@ -64,14 +64,14 @@ #define ENTRY_CHILDREN(n, t, f, c) \ { \ n, nullptr, FormatEntity::Entry::Type::t, \ -FormatEntity::Entry::FormatType::f, 0, llvm::array_lengthof(c), c, \ -false \ +FormatEntity::Entry::FormatType::f, 0, \ +static_cast(llvm::array_lengthof(c)), c, false \ } #define ENTRY_CHILDREN_KEEP_SEP(n, t, f, c) \ { \ n, nullptr, FormatEntity::Entry::Type::t, \ -FormatEntity::Entry::FormatType::f, 0, llvm::array_lengthof(c), c, \ -true \ +FormatEntity::Entry::FormatType::f, 0, \ +static_cast(llvm::array_lengthof(c)), c, true \ } #define ENTRY_STRING(n, s) \ { \ Index: lldb/trunk/source/Core/FormatEntity.cpp === --- lldb/trunk/source/Core/FormatEntity.cpp +++ lldb/trunk/source/Core/FormatEntity.cpp @@ -64,14 +64,14 @@ #define ENTRY_CHILDREN(n, t, f, c) \ {\ n, nullptr, FormatEntity::Entry::Type::t, \ -FormatEntity::Entry::FormatType::f, 0, llvm::array_lengthof(c), c, \ -false \ +FormatEntity::Entry::FormatType::f, 0, \ +static_cast(llvm::array_lengthof(c)), c, false \ } #define ENTRY_CHILDREN_KEEP_SEP(n, t, f, c)\ {\ n, nullptr, FormatEntity::Entry::Type::t, \ -FormatEntity::Entry::FormatType::f, 0, llvm::array_lengthof(c), c, \ -true \ +FormatEntity::Entry::FormatType::f, 0, \ +static_cast(llvm::array_lengthof(c)), c, true\ } #define ENTRY_STRING(n, s) \ {\ ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r298099 - Fix some signed/unsigned comparison warnings.
Author: zturner Date: Fri Mar 17 11:32:43 2017 New Revision: 298099 URL: http://llvm.org/viewvc/llvm-project?rev=298099&view=rev Log: Fix some signed/unsigned comparison warnings. Patch by Hugh Bellamy Differential Revision: https://reviews.llvm.org/D30926 Modified: lldb/trunk/source/Core/FormatEntity.cpp Modified: lldb/trunk/source/Core/FormatEntity.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatEntity.cpp?rev=298099&r1=298098&r2=298099&view=diff == --- lldb/trunk/source/Core/FormatEntity.cpp (original) +++ lldb/trunk/source/Core/FormatEntity.cpp Fri Mar 17 11:32:43 2017 @@ -64,14 +64,14 @@ enum FileKind { FileError = 0, Basename, #define ENTRY_CHILDREN(n, t, f, c) \ { \ n, nullptr, FormatEntity::Entry::Type::t, \ -FormatEntity::Entry::FormatType::f, 0, llvm::array_lengthof(c), c, \ -false \ +FormatEntity::Entry::FormatType::f, 0, \ +static_cast(llvm::array_lengthof(c)), c, false \ } #define ENTRY_CHILDREN_KEEP_SEP(n, t, f, c) \ { \ n, nullptr, FormatEntity::Entry::Type::t, \ -FormatEntity::Entry::FormatType::f, 0, llvm::array_lengthof(c), c, \ -true \ +FormatEntity::Entry::FormatType::f, 0, \ +static_cast(llvm::array_lengthof(c)), c, true \ } #define ENTRY_STRING(n, s) \ { \ ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31079: Replace std::ofstream with llvm::raw_fd_ostream
labath created this revision. ofstream does not handle paths with non-ascii characters correctly on windows, so I am switching these to llvm streams to fix that. Ideally I'd like to replace the two occurences of ifstream as well, but it's not clear to me what is the right replacement, as llvm interfaces seem to be based around reading the full file, which seems wasteful, if all I'm going to do is to stream it to a socket. https://reviews.llvm.org/D31079 Files: source/Plugins/Platform/Android/AdbClient.cpp source/Target/Platform.cpp tools/lldb-server/lldb-platform.cpp Index: tools/lldb-server/lldb-platform.cpp === --- tools/lldb-server/lldb-platform.cpp +++ tools/lldb-server/lldb-platform.cpp @@ -108,23 +108,25 @@ return Error("Failed to create directory %s: %s", temp_file_spec.GetCString(), error.AsCString()); - llvm::SmallString temp_file_path; + llvm::SmallString<64> temp_file_path; temp_file_spec.AppendPathComponent("port-file.%%"); - auto err_code = llvm::sys::fs::createUniqueFile(temp_file_spec.GetCString(), + int FD; + auto err_code = llvm::sys::fs::createUniqueFile(temp_file_spec.GetPath(), FD, temp_file_path); if (err_code) return Error("Failed to create temp file: %s", err_code.message().c_str()); - llvm::FileRemover tmp_file_remover(temp_file_path.c_str()); + llvm::FileRemover tmp_file_remover(temp_file_path); { -std::ofstream temp_file(temp_file_path.c_str(), std::ios::out); -if (!temp_file.is_open()) - return Error("Failed to open temp file %s", temp_file_path.c_str()); +llvm::raw_fd_ostream temp_file(FD, true); temp_file << socket_id; +temp_file.close(); +if (temp_file.has_error()) + return Error("Failed to write to port file."); } - err_code = llvm::sys::fs::rename(temp_file_path.c_str(), file_spec.GetPath()); + err_code = llvm::sys::fs::rename(temp_file_path, file_spec.GetPath()); if (err_code) return Error("Failed to rename file %s to %s: %s", temp_file_path.c_str(), file_spec.GetPath().c_str(), err_code.message().c_str()); Index: source/Target/Platform.cpp === --- source/Target/Platform.cpp +++ source/Target/Platform.cpp @@ -1641,8 +1641,9 @@ const FileSpec &dst_file_spec) { Error error; - std::ofstream dst(dst_file_spec.GetPath(), std::ios::out | std::ios::binary); - if (!dst.is_open()) { + std::error_code EC; + llvm::raw_fd_ostream dst(dst_file_spec.GetPath(), EC, llvm::sys::fs::F_None); + if (EC) { error.SetErrorStringWithFormat("unable to open destination file: %s", dst_file_spec.GetPath().c_str()); return error; Index: source/Plugins/Platform/Android/AdbClient.cpp === --- source/Plugins/Platform/Android/AdbClient.cpp +++ source/Plugins/Platform/Android/AdbClient.cpp @@ -402,13 +402,14 @@ return error; const auto output_filename = output_file_spec.GetPath(); - std::ofstream dst(output_filename, std::ios::out | std::ios::binary); - if (!dst.is_open()) + std::error_code EC; + llvm::raw_fd_ostream dst(output_filename, EC, llvm::sys::fs::F_None); + if (EC) return Error("Unable to open local file %s", output_filename.c_str()); dst.write(&output_buffer[0], output_buffer.size()); dst.close(); - if (!dst) + if (dst.has_error()) return Error("Failed to write file %s", output_filename.c_str()); return Error(); } @@ -428,8 +429,9 @@ const auto local_file_path = local_file.GetPath(); llvm::FileRemover local_file_remover(local_file_path); - std::ofstream dst(local_file_path, std::ios::out | std::ios::binary); - if (!dst.is_open()) + std::error_code EC; + llvm::raw_fd_ostream dst(local_file_path, EC, llvm::sys::fs::F_None); + if (EC) return Error("Unable to open local file %s", local_file_path.c_str()); const auto remote_file_path = remote_file.GetPath(false); @@ -447,6 +449,9 @@ if (!eof) dst.write(&chunk[0], chunk.size()); } + dst.close(); + if (dst.has_error()) +return Error("Failed to write file %s", local_file_path.c_str()); local_file_remover.releaseFile(); return error; Index: tools/lldb-server/lldb-platform.cpp === --- tools/lldb-server/lldb-platform.cpp +++ tools/lldb-server/lldb-platform.cpp @@ -108,23 +108,25 @@ return Error("Failed to create directory %s: %s", temp_file_spec.GetCString(), error.AsCString()); - llvm::SmallString temp_file_path; + llvm::SmallString<64> temp_file_path; temp_file_spec.AppendPathComponent("port-file.%%"); - auto err_code = llvm::sys::fs::createUniqueFile(temp_file_spec.GetCString(), + int FD; + auto err_co
[Lldb-commits] [PATCH] D31073: Enable lldm-mi commands -stack-list-locals -stack-list-variables and -var-create to work only with variables in scope
ayuckhulk created this revision. ayuckhulk added a project: LLDB. https://reviews.llvm.org/D31073 Files: packages/Python/lldbsuite/test/tools/lldb-mi/lexical-scope/Makefile packages/Python/lldbsuite/test/tools/lldb-mi/lexical-scope/TestLexicalScope.py packages/Python/lldbsuite/test/tools/lldb-mi/lexical-scope/main.cpp tools/lldb-mi/MICmdCmdStack.cpp tools/lldb-mi/MICmdCmdVar.cpp Index: tools/lldb-mi/MICmdCmdVar.cpp === --- tools/lldb-mi/MICmdCmdVar.cpp +++ tools/lldb-mi/MICmdCmdVar.cpp @@ -182,7 +182,7 @@ const bool bArgs = true; const bool bLocals = true; const bool bStatics = true; -const bool bInScopeOnly = false; +const bool bInScopeOnly = true; const lldb::SBValueList valueList = frame.GetVariables(bArgs, bLocals, bStatics, bInScopeOnly); value = valueList.GetFirstValueByName(rStrExpression.c_str()); Index: tools/lldb-mi/MICmdCmdStack.cpp === --- tools/lldb-mi/MICmdCmdStack.cpp +++ tools/lldb-mi/MICmdCmdStack.cpp @@ -757,7 +757,8 @@ : thread.GetSelectedFrame(); CMICmnMIValueList miValueList(true); - const MIuint maskVarTypes = CMICmnLLDBDebugSessionInfo::eVariableType_Locals; + const MIuint maskVarTypes = CMICmnLLDBDebugSessionInfo::eVariableType_Locals | + CMICmnLLDBDebugSessionInfo::eVariableType_InScope; if (!rSessionInfo.MIResponseFormVariableInfo(frame, maskVarTypes, eVarInfoFormat, miValueList)) return MIstatus::failure; @@ -929,7 +930,8 @@ CMICmnMIValueList miValueList(true); const MIuint maskVarTypes = CMICmnLLDBDebugSessionInfo::eVariableType_Arguments | - CMICmnLLDBDebugSessionInfo::eVariableType_Locals; + CMICmnLLDBDebugSessionInfo::eVariableType_Locals | + CMICmnLLDBDebugSessionInfo::eVariableType_InScope; if (!rSessionInfo.MIResponseFormVariableInfo( frame, maskVarTypes, eVarInfoFormat, miValueList, 10, true)) return MIstatus::failure; Index: packages/Python/lldbsuite/test/tools/lldb-mi/lexical-scope/main.cpp === --- packages/Python/lldbsuite/test/tools/lldb-mi/lexical-scope/main.cpp +++ packages/Python/lldbsuite/test/tools/lldb-mi/lexical-scope/main.cpp @@ -0,0 +1,33 @@ +//===-- main.cpp *- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +void +some_func (void) +{ +} + +void test_sibling_scope (void) +{ + int a = 1; + { +int b = 2; +some_func(); // BP_first + } + { +short b = 3; +some_func(); // BP_second + } +} + +int +main (int argc, char **argv) +{ + test_sibling_scope(); + return 0; +} Index: packages/Python/lldbsuite/test/tools/lldb-mi/lexical-scope/TestLexicalScope.py === --- packages/Python/lldbsuite/test/tools/lldb-mi/lexical-scope/TestLexicalScope.py +++ packages/Python/lldbsuite/test/tools/lldb-mi/lexical-scope/TestLexicalScope.py @@ -0,0 +1,69 @@ +# coding=utf8 +""" +Test lldb-mi -stack-list-locals -stack-list-variables and -var-create commands +for variables with the same name in sibling lexical scopes. +""" + +from __future__ import print_function + + +import lldbmi_testcase +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class MiLexicalScopeTestCase(lldbmi_testcase.MiTestCaseBase): + +mydir = TestBase.compute_mydir(__file__) + +@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows +@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races +@skipIfRemote # We do not currently support remote debugging via the MI. +def test_lldbmi_var_create_in_sibling_scope(self): +"""Test that 'lldb-mi --interpreter' works with sibling lexical scopes.""" + +self.spawnLldbMi(args=None) + +# Load executable +self.runCmd("-file-exec-and-symbols %s" % self.myexe) +self.expect("\^done") + +# Breakpoint inside first scope +line = line_number('main.cpp', '// BP_first') +self.runCmd("-break-insert --file main.cpp:%d" % line) +self.expect("\^done,bkpt={number=\"\d+\"") + +# Breakpoint inside second scope +line = line_number('main.cpp', '// BP_second') +self.runCmd("-break-insert --file main.cpp:%d" % line) +self.expect("\^done,bkpt={number=\"\d+\"") + +# Run to the first scope +self.runCmd("-exec-run") +self.expect("\^running") +self.expect("\*
[Lldb-commits] [lldb] r298069 - Fix FreeBSD build broken by r298066
Author: labath Date: Fri Mar 17 06:33:57 2017 New Revision: 298069 URL: http://llvm.org/viewvc/llvm-project?rev=298069&view=rev Log: Fix FreeBSD build broken by r298066 Modified: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp Modified: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp?rev=298069&r1=298068&r2=298069&view=diff == --- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp (original) +++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp Fri Mar 17 06:33:57 2017 @@ -16,6 +16,7 @@ #include #include #include +#include // C++ Includes #include @@ -49,6 +50,7 @@ #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/DataBufferHeap.h" #include "lldb/Host/posix/Fcntl.h" @@ -912,11 +914,11 @@ const DataBufferSP ProcessFreeBSD::GetAu PlatformSP platform_sp = GetTarget().GetPlatform(); assert(platform_sp && platform_sp->IsHost()); - int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_AUXV, process->GetID()}; + int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_AUXV, (int)m_process->GetID()}; size_t auxv_size = AT_COUNT * sizeof(Elf_Auxinfo); DataBufferSP buf_sp(new DataBufferHeap(auxv_size, 0)); - if (::sysctl(mib, 4, buf_ap->GetBytes(), &auxv_size, NULL, 0) != 0) { + if (::sysctl(mib, 4, buf_sp->GetBytes(), &auxv_size, NULL, 0) != 0) { perror("sysctl failed on auxv"); buf_sp.reset(); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31031: Move GetAuxvData from Host to relevant process plugins
This revision was automatically updated to reflect the committed changes. Closed by commit rL298066: Move GetAuxvData from Host to relevant process plugins (authored by labath). Changed prior to commit: https://reviews.llvm.org/D31031?vs=92000&id=92125#toc Repository: rL LLVM https://reviews.llvm.org/D31031 Files: lldb/trunk/include/lldb/Host/Host.h lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h lldb/trunk/source/Host/CMakeLists.txt lldb/trunk/source/Host/freebsd/Host.cpp lldb/trunk/source/Host/linux/Host.cpp lldb/trunk/source/Host/macosx/Host.mm lldb/trunk/source/Host/netbsd/Host.cpp lldb/trunk/source/Host/windows/Host.cpp lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h lldb/trunk/source/Plugins/Process/gdb-remote/CMakeLists.txt lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h Index: lldb/trunk/include/lldb/Host/Host.h === --- lldb/trunk/include/lldb/Host/Host.h +++ lldb/trunk/include/lldb/Host/Host.h @@ -238,10 +238,6 @@ uint32_t timeout_sec, bool run_in_default_shell = true); - static lldb::DataBufferSP GetAuxvData(lldb_private::Process *process); - - static lldb::DataBufferSP GetAuxvData(lldb::pid_t pid); - static bool OpenFileInExternalEditor(const FileSpec &file_spec, uint32_t line_no); Index: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h === --- lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h +++ lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h @@ -10,16 +10,15 @@ #ifndef liblldb_NativeProcessProtocol_h_ #define liblldb_NativeProcessProtocol_h_ -#include -#include - #include "lldb/Host/MainLoop.h" #include "lldb/Utility/Error.h" #include "lldb/lldb-private-forward.h" #include "lldb/lldb-types.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/MemoryBuffer.h" +#include #include "NativeBreakpointList.h" #include "NativeWatchpointList.h" @@ -152,6 +151,9 @@ bool GetByteOrder(lldb::ByteOrder &byte_order) const; + virtual llvm::ErrorOr> + GetAuxvData() const = 0; + //-- // Exit Status //-- Index: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h === --- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h +++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h @@ -18,6 +18,7 @@ #include "lldb/Host/Debug.h" #include "lldb/Host/FileSpec.h" #include "lldb/Host/HostThread.h" +#include "lldb/Host/linux/Support.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/lldb-types.h" @@ -98,6 +99,11 @@ NativeThreadLinuxSP GetThreadByID(lldb::tid_t id); + llvm::ErrorOr> + GetAuxvData() const override { +return getProcFile(GetID(), "auxv"); + } + // - // Interface used by NativeRegisterContext-derived classes. // - Index: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp === --- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp +++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp @@ -10,6 +10,12 @@ // C Includes #include +#include +#include +#include +#include +#include +#include // C++ Includes #include @@ -904,15 +910,18 @@ const DataBufferSP ProcessFreeBSD::GetAuxvData() { // If we're the local platform, we can ask the host for auxv data. PlatformSP platform_sp = GetTarget().GetPlatform(); - if (platform_sp && platform_sp->IsHost()) -return lldb_private::Host::GetAuxvData(this); + assert(platform_sp && platform_sp->IsHost()); - // Somewhat unexpected - the process is not running locally or we don't have a - // platform. - assert( - false && - "no platform or not the host - how did we get here with ProcessFreeBSD?"); - return DataBufferSP(); + int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_AUXV, process->GetID()}; + size_t auxv_size = AT_COUNT * sizeof(Elf_Auxinfo); + DataBufferSP buf_sp(new DataBufferHeap(auxv_size, 0)); + + if (::sysctl(mib, 4, buf_ap->GetBytes(), &auxv_size, NULL, 0) != 0) { +perror("sysctl failed on auxv"); +buf_sp.reset(); + } + + return buf_sp; } struct EmulatorBaton { Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h ==
[Lldb-commits] [lldb] r298066 - Move GetAuxvData from Host to relevant process plugins
Author: labath Date: Fri Mar 17 06:08:40 2017 New Revision: 298066 URL: http://llvm.org/viewvc/llvm-project?rev=298066&view=rev Log: Move GetAuxvData from Host to relevant process plugins Summary: GetAuxvData was causing dependencies from host to target and linux process modules. It also does not fit netbsd use case, as there we can only read the auxiliary vector with ptrace, which is better done in the process plugin, with the other ptrace calls. I resolve these issues by moving the freebsd and linux versions into the relevant process plugins. In case of linux, this required adding an interface in NativeProcessProtocol. The empty definitions on other platforms can simply be removed. To get the code compiling I had to add ProcessGdbRemote -> ProcessLinux dependency, which was not caught before because we depended on it transitively. Reviewers: zturner, emaste Subscribers: srhines, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D31031 Modified: lldb/trunk/include/lldb/Host/Host.h lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h lldb/trunk/source/Host/CMakeLists.txt lldb/trunk/source/Host/freebsd/Host.cpp lldb/trunk/source/Host/linux/Host.cpp lldb/trunk/source/Host/macosx/Host.mm lldb/trunk/source/Host/netbsd/Host.cpp lldb/trunk/source/Host/windows/Host.cpp lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h lldb/trunk/source/Plugins/Process/gdb-remote/CMakeLists.txt lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h Modified: lldb/trunk/include/lldb/Host/Host.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=298066&r1=298065&r2=298066&view=diff == --- lldb/trunk/include/lldb/Host/Host.h (original) +++ lldb/trunk/include/lldb/Host/Host.h Fri Mar 17 06:08:40 2017 @@ -238,10 +238,6 @@ public: uint32_t timeout_sec, bool run_in_default_shell = true); - static lldb::DataBufferSP GetAuxvData(lldb_private::Process *process); - - static lldb::DataBufferSP GetAuxvData(lldb::pid_t pid); - static bool OpenFileInExternalEditor(const FileSpec &file_spec, uint32_t line_no); Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h?rev=298066&r1=298065&r2=298066&view=diff == --- lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h (original) +++ lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h Fri Mar 17 06:08:40 2017 @@ -10,9 +10,6 @@ #ifndef liblldb_NativeProcessProtocol_h_ #define liblldb_NativeProcessProtocol_h_ -#include -#include - #include "lldb/Host/MainLoop.h" #include "lldb/Utility/Error.h" #include "lldb/lldb-private-forward.h" @@ -20,6 +17,8 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/MemoryBuffer.h" +#include #include "NativeBreakpointList.h" #include "NativeWatchpointList.h" @@ -152,6 +151,9 @@ public: bool GetByteOrder(lldb::ByteOrder &byte_order) const; + virtual llvm::ErrorOr> + GetAuxvData() const = 0; + //-- // Exit Status //-- Modified: lldb/trunk/source/Host/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/CMakeLists.txt?rev=298066&r1=298065&r2=298066&view=diff == --- lldb/trunk/source/Host/CMakeLists.txt (original) +++ lldb/trunk/source/Host/CMakeLists.txt Fri Mar 17 06:08:40 2017 @@ -122,7 +122,6 @@ else() linux/LibcGlue.cpp linux/Support.cpp ) -list(APPEND LLDB_PLUGINS lldbPluginProcessLinux) if (CMAKE_SYSTEM_NAME MATCHES "Android") add_host_subdirectory(android android/HostInfoAndroid.cpp Modified: lldb/trunk/source/Host/freebsd/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/freebsd/Host.cpp?rev=298066&r1=298065&r2=298066&view=diff == --- lldb/trunk/source/Host/freebsd/Host.cpp (original) +++ lldb/trunk/source/Host/freebsd/Host.cpp Fri Mar 17 06:08:40 2017 @@ -243,23 +243,6 @@ bool Host::GetProcessInfo(lldb::pid_t pi return false; } -lldb::DataBufferSP Host::GetAuxvData(lldb_private::Process *process) { - int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_AUXV, 0}; - size_t auxv_size = AT_COUNT * sizeof(Elf_Auxinfo); - DataBufferSP buf_sp; - - std::un
[Lldb-commits] [lldb] r298063 - One more attempt to fix FreeBSD
Author: labath Date: Fri Mar 17 05:30:42 2017 New Revision: 298063 URL: http://llvm.org/viewvc/llvm-project?rev=298063&view=rev Log: One more attempt to fix FreeBSD It seems sysctl.h is not self-contained, as I get missing symbols in the header itself now. I am going to include all files that the file I moved this from included, and hope that is enough. Modified: lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp Modified: lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp?rev=298063&r1=298062&r2=298063&view=diff == --- lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp (original) +++ lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp Fri Mar 17 05:30:42 2017 @@ -9,8 +9,12 @@ // C Includes #include +#include +#include +#include #include #include +#include // C++ Includes // Other libraries and framework includes ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r298061 - Speculative build fix for FreeBSD
Author: labath Date: Fri Mar 17 05:09:56 2017 New Revision: 298061 URL: http://llvm.org/viewvc/llvm-project?rev=298061&view=rev Log: Speculative build fix for FreeBSD broken by r298058. Modified: lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp Modified: lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp?rev=298061&r1=298060&r2=298061&view=diff == --- lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp (original) +++ lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp Fri Mar 17 05:09:56 2017 @@ -9,6 +9,8 @@ // C Includes #include +#include +#include // C++ Includes // Other libraries and framework includes @@ -141,7 +143,7 @@ const char *FreeBSDThread::GetName() { } for (size_t i = 0; i < len / sizeof(*kp); i++) { - if (kp[i].ki_tid == (lwpid_t)tid) { + if (kp[i].ki_tid == (lwpid_t)GetID()) { m_thread_name.append(kp[i].ki_tdname, kp[i].ki_tdname + strlen(kp[i].ki_tdname)); break; ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D30981: Remove HostThreadLinux/Free/NetBSD
This revision was automatically updated to reflect the committed changes. Closed by commit rL298058: Remove HostThreadLinux/Free/NetBSD (authored by labath). Changed prior to commit: https://reviews.llvm.org/D30981?vs=91869&id=92115#toc Repository: rL LLVM https://reviews.llvm.org/D30981 Files: lldb/trunk/include/lldb/Host/HostNativeThread.h lldb/trunk/include/lldb/Host/HostNativeThreadForward.h lldb/trunk/include/lldb/Host/freebsd/HostThreadFreeBSD.h lldb/trunk/include/lldb/Host/linux/HostThreadLinux.h lldb/trunk/include/lldb/Host/netbsd/HostThreadNetBSD.h lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/Makefile lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/TestGdbRemoteThreadName.py lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/main.cpp lldb/trunk/source/Host/CMakeLists.txt lldb/trunk/source/Host/freebsd/HostThreadFreeBSD.cpp lldb/trunk/source/Host/linux/HostThreadLinux.cpp lldb/trunk/source/Host/netbsd/HostThreadNetBSD.cpp lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp Index: lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp === --- lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp +++ lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp @@ -19,6 +19,7 @@ #include "lldb/Core/State.h" #include "lldb/Host/HostNativeThread.h" #include "lldb/Host/linux/Ptrace.h" +#include "lldb/Host/linux/Support.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" #include "lldb/lldb-enumerations.h" @@ -90,15 +91,12 @@ m_stop_info(), m_reg_context_sp(), m_stop_description() {} std::string NativeThreadLinux::GetName() { - NativeProcessProtocolSP process_sp = m_process_wp.lock(); - if (!process_sp) -return ""; - - // const NativeProcessLinux *const process = - // reinterpret_cast (process_sp->get ()); - llvm::SmallString<32> thread_name; - HostNativeThread::GetName(GetID(), thread_name); - return thread_name.c_str(); + NativeProcessLinux &process = GetProcess(); + + auto BufferOrError = getProcFile(process.GetID(), GetID(), "comm"); + if (!BufferOrError) +return ""; + return BufferOrError.get()->getBuffer().rtrim('\n'); } lldb::StateType NativeThreadLinux::GetState() { return m_state; } Index: lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp === --- lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp +++ lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp @@ -113,9 +113,41 @@ const char *FreeBSDThread::GetName() { if (!m_thread_name_valid) { -llvm::SmallString<32> thread_name; -HostNativeThread::GetName(GetID(), thread_name); -m_thread_name = thread_name.c_str(); +m_thread_name.clear(); +int pid = GetProcess()->GetID(); + +struct kinfo_proc *kp = nullptr, *nkp; +size_t len = 0; +int error; +int ctl[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID | KERN_PROC_INC_THREAD, + pid}; + +while (1) { + error = sysctl(ctl, 4, kp, &len, nullptr, 0); + if (kp == nullptr || (error != 0 && errno == ENOMEM)) { +// Add extra space in case threads are added before next call. +len += sizeof(*kp) + len / 10; +nkp = (struct kinfo_proc *)realloc(kp, len); +if (nkp == nullptr) { + free(kp); + return nullptr; +} +kp = nkp; +continue; + } + if (error != 0) +len = 0; + break; +} + +for (size_t i = 0; i < len / sizeof(*kp); i++) { + if (kp[i].ki_tid == (lwpid_t)tid) { +m_thread_name.append(kp[i].ki_tdname, + kp[i].ki_tdname + strlen(kp[i].ki_tdname)); +break; + } +} +free(kp); m_thread_name_valid = true; } Index: lldb/trunk/source/Host/CMakeLists.txt === --- lldb/trunk/source/Host/CMakeLists.txt +++ lldb/trunk/source/Host/CMakeLists.txt @@ -119,7 +119,6 @@ linux/AbstractSocket.cpp linux/Host.cpp linux/HostInfoLinux.cpp - linux/HostThreadLinux.cpp linux/LibcGlue.cpp linux/Support.cpp ) @@ -134,14 +133,12 @@ add_host_subdirectory(freebsd freebsd/Host.cpp freebsd/HostInfoFreeBSD.cpp - freebsd/HostThreadFreeBSD.cpp ) elseif (CMAKE_SYSTEM_NAME MATCHES "NetBSD") add_host_subdirectory(netbsd netbsd/Host.cpp netbsd/HostInfoNetBSD.cpp - netbsd/HostThreadNetBSD.cpp ) endif() endif() Index: lldb/trunk/source/Host/freebsd/HostThreadFreeBSD.cpp === --- lldb/trunk/source/Host/freebsd/HostThreadFreeBSD.cpp +++ lldb/trunk/source/Host/freebsd/HostThreadFreeBSD
[Lldb-commits] [lldb] r298058 - Remove HostThreadLinux/Free/NetBSD
Author: labath Date: Fri Mar 17 04:51:23 2017 New Revision: 298058 URL: http://llvm.org/viewvc/llvm-project?rev=298058&view=rev Log: Remove HostThreadLinux/Free/NetBSD Summary: These classes existed only because of the GetName() static function, which can be moved to a more natural place anyway. I move the linux version to NativeProcessLinux (and get rid of ProcFileReader), the freebsd version to ProcessFreeBSD (and fix a bug where it was using the current process ID, instead of the inferior pid), and remove the NetBSD version (which was probably incorrect anyway, as it assumes the current process instead of the inferior. I also add an llgs test to that verifies thread names are read correctly. Reviewers: zturner, krytarowski, emaste Subscribers: lldb-commits, mgorny Differential Revision: https://reviews.llvm.org/D30981 Added: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/Makefile lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/TestGdbRemoteThreadName.py lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/main.cpp Removed: lldb/trunk/include/lldb/Host/freebsd/HostThreadFreeBSD.h lldb/trunk/include/lldb/Host/linux/HostThreadLinux.h lldb/trunk/include/lldb/Host/netbsd/HostThreadNetBSD.h lldb/trunk/source/Host/freebsd/HostThreadFreeBSD.cpp lldb/trunk/source/Host/linux/HostThreadLinux.cpp lldb/trunk/source/Host/netbsd/HostThreadNetBSD.cpp Modified: lldb/trunk/include/lldb/Host/HostNativeThread.h lldb/trunk/include/lldb/Host/HostNativeThreadForward.h lldb/trunk/source/Host/CMakeLists.txt lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp Modified: lldb/trunk/include/lldb/Host/HostNativeThread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/HostNativeThread.h?rev=298058&r1=298057&r2=298058&view=diff == --- lldb/trunk/include/lldb/Host/HostNativeThread.h (original) +++ lldb/trunk/include/lldb/Host/HostNativeThread.h Fri Mar 17 04:51:23 2017 @@ -14,14 +14,10 @@ #if defined(_WIN32) #include "lldb/Host/windows/HostThreadWindows.h" -#elif defined(__linux__) -#include "lldb/Host/linux/HostThreadLinux.h" -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -#include "lldb/Host/freebsd/HostThreadFreeBSD.h" -#elif defined(__NetBSD__) -#include "lldb/Host/netbsd/HostThreadNetBSD.h" #elif defined(__APPLE__) #include "lldb/Host/macosx/HostThreadMacOSX.h" +#else +#include "lldb/Host/posix/HostThreadPosix.h" #endif #endif Modified: lldb/trunk/include/lldb/Host/HostNativeThreadForward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/HostNativeThreadForward.h?rev=298058&r1=298057&r2=298058&view=diff == --- lldb/trunk/include/lldb/Host/HostNativeThreadForward.h (original) +++ lldb/trunk/include/lldb/Host/HostNativeThreadForward.h Fri Mar 17 04:51:23 2017 @@ -14,18 +14,12 @@ namespace lldb_private { #if defined(_WIN32) class HostThreadWindows; typedef HostThreadWindows HostNativeThread; -#elif defined(__linux__) -class HostThreadLinux; -typedef HostThreadLinux HostNativeThread; -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -class HostThreadFreeBSD; -typedef HostThreadFreeBSD HostNativeThread; -#elif defined(__NetBSD__) -class HostThreadNetBSD; -typedef HostThreadNetBSD HostNativeThread; #elif defined(__APPLE__) class HostThreadMacOSX; typedef HostThreadMacOSX HostNativeThread; +#else +class HostThreadPosix; +typedef HostThreadPosix HostNativeThread; #endif } Removed: lldb/trunk/include/lldb/Host/freebsd/HostThreadFreeBSD.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/freebsd/HostThreadFreeBSD.h?rev=298057&view=auto == --- lldb/trunk/include/lldb/Host/freebsd/HostThreadFreeBSD.h (original) +++ lldb/trunk/include/lldb/Host/freebsd/HostThreadFreeBSD.h (removed) @@ -1,29 +0,0 @@ -//===-- HostThreadFreeBSD.h -*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===--===// - -#ifndef lldb_Host_freebsd_HostThreadFreeBSD_h_ -#define lldb_Host_freebsd_HostThreadFreeBSD_h_ - -#include "lldb/Host/posix/HostThreadPosix.h" - -#include "llvm/ADT/SmallString.h" -#include "llvm/ADT/StringRef.h" - -namespace lldb_private { - -class HostThreadFreeBSD : public HostThreadPosix { -public: - HostThreadFreeBSD(); - HostThreadFreeBSD(lldb::thread_t thread); - - static void GetName