[Lldb-commits] [PATCH] D32080: Introduce initial Debug Registers/NetBSD/amd64 support
krytarowski created this revision. krytarowski added a project: LLDB. This code offers Debug Registers (80386) model in LLDB/amd64. This is initial support and has one issue that will be addressed later, Debug Register trap (TRAP_DBREG) is registered as (TRAP_TRACE) for unknown reason. On the other hand this state is good enough to move on to add FPR/amd64 support. Improve the NativeProcessNetBSD::ReinitializeThreads() function, stop setting inside it SetStoppedByExec(). This fixes incorrect stop reason on attaching (SetStoppedBySignal(SIGSTOP)). This commits also has no functional style improvements from clang-format. Demo: $ lldb ./watch (lldb) target create "./watch" Current executable set to './watch' (x86_64). (lldb) c error: invalid process (lldb) r Process 1573 launched: './watch' (x86_64) Process 1573 stopped * thread #1, stop reason = breakpoint 1.1 frame #0: 0x0040087f watch`main(argc=1, argv=0x7f7fffa12b88) at watch.c:8 5{ 6int i, j, k; 7 -> 8for (i = 0; i < 3; i++) 9for (j = 0; j < 3; j++) 10 for (k = 0; k < 3; k++) 11 printf("Hello world! i=%d j=%d k=%d\n", i, j, k); (lldb) watch set var i Watchpoint created: Watchpoint 1: addr = 0x7f7fffa12b4c size = 4 state = enabled type = w declare @ '/public/lldb_devel/watch.c:6' watchpoint spec = 'i' new value: 0 (lldb) c Process 1573 resuming Hello world! i=0 j=0 k=0 Hello world! i=0 j=0 k=1 Hello world! i=0 j=0 k=2 Hello world! i=0 j=1 k=0 Hello world! i=0 j=1 k=1 Hello world! i=0 j=1 k=2 Hello world! i=0 j=2 k=0 Hello world! i=0 j=2 k=1 Hello world! i=0 j=2 k=2 Process 1573 stopped * thread #1, stop reason = trace frame #0: 0x004008cc watch`main(argc=1, argv=0x7f7fffa12b88) at watch.c:8 5{ 6int i, j, k; 7 -> 8for (i = 0; i < 3; i++) 9for (j = 0; j < 3; j++) 10 for (k = 0; k < 3; k++) 11 printf("Hello world! i=%d j=%d k=%d\n", i, j, k) Sponsored by Repository: rL LLVM https://reviews.llvm.org/D32080 Files: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp source/Plugins/Process/NetBSD/NativeThreadNetBSD.h source/Plugins/Process/Utility/RegisterInfos_x86_64.h Index: source/Plugins/Process/Utility/RegisterInfos_x86_64.h === --- source/Plugins/Process/Utility/RegisterInfos_x86_64.h +++ source/Plugins/Process/Utility/RegisterInfos_x86_64.h @@ -148,7 +148,7 @@ DR_OFFSET(i), eEncodingUint, eFormatHex, \ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - LLDB_INVALID_REGNUM }, \ + lldb_##reg##i##_x86_64 }, \ nullptr, nullptr, nullptr, 0\ } Index: source/Plugins/Process/NetBSD/NativeThreadNetBSD.h === --- source/Plugins/Process/NetBSD/NativeThreadNetBSD.h +++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.h @@ -12,6 +12,9 @@ #include "lldb/Host/common/NativeThreadProtocol.h" +#include +#include + namespace lldb_private { namespace process_netbsd { @@ -53,6 +56,7 @@ void SetStoppedByBreakpoint(); void SetStoppedByTrace(); void SetStoppedByExec(); + void SetStoppedByWatchpoint(uint32_t wp_index); void SetStopped(); void SetRunning(); void SetStepping(); @@ -64,6 +68,9 @@ ThreadStopInfo m_stop_info; NativeRegisterContextSP m_reg_context_sp; std::string m_stop_description; + using WatchpointIndexMap = std::map; + WatchpointIndexMap m_watchpoint_index_map; + WatchpointIndexMap m_hw_break_index_map; }; typedef std::shared_ptr NativeThreadNetBSDSP; Index: source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp === --- source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp +++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp @@ -16,6 +16,9 @@ #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" #include "lldb/Core/RegisterValue.h" #include "lldb/Core/State.h" +#
[Lldb-commits] [lldb] r300341 - Fixed to disassemble new packets and fixed the dumping of the 'x' packets.
Author: gclayton Date: Fri Apr 14 12:05:21 2017 New Revision: 300341 URL: http://llvm.org/viewvc/llvm-project?rev=300341&view=rev Log: Fixed to disassemble new packets and fixed the dumping of the 'x' packets. Modified: lldb/trunk/examples/python/gdbremote.py Modified: lldb/trunk/examples/python/gdbremote.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/gdbremote.py?rev=300341&r1=300340&r2=300341&view=diff == --- lldb/trunk/examples/python/gdbremote.py (original) +++ lldb/trunk/examples/python/gdbremote.py Fri Apr 14 12:05:21 2017 @@ -322,6 +322,15 @@ def is_hex_byte(str): return str[0] in string.hexdigits and str[1] in string.hexdigits return False +def get_hex_string_if_all_printable(str): +try: +s = binascii.unhexlify(str) +if all(c in string.printable for c in s): +return s +except TypeError: +pass +return None + # global register info list g_register_infos = list() g_max_register_info_name_len = 0 @@ -638,6 +647,14 @@ def cmd_qSymbol(options, cmd, args): else: print 'error: bad command format' +def cmd_QSetWithHexString(options, cmd, args): +print '%s("%s")' % (cmd[:-1], binascii.unhexlify(args)) + +def cmd_QSetWithString(options, cmd, args): +print '%s("%s")' % (cmd[:-1], args) + +def cmd_QSetWithUnsigned(options, cmd, args): +print '%s(%i)' % (cmd[:-1], int(args)) def rsp_qSymbol(options, cmd, cmd_args, rsp): if len(rsp) == 0: @@ -766,7 +783,11 @@ def dump_key_value_pairs(key_value_pairs for key_value_pair in key_value_pairs: key = key_value_pair[0] value = key_value_pair[1] -print "%*s = %s" % (max_key_len, key, value) +unhex_value = get_hex_string_if_all_printable(value) +if unhex_value: +print "%*s = %s (%s)" % (max_key_len, key, value, unhex_value) +else: +print "%*s = %s" % (max_key_len, key, value) def rsp_dump_key_value_pairs(options, cmd, cmd_args, rsp): @@ -910,26 +931,29 @@ def rsp_qThreadInfo(options, cmd, cmd_ar def rsp_hex_big_endian(options, cmd, cmd_args, rsp): -packet = Packet(rsp) -uval = packet.get_hex_uint('big') -print '%s: 0x%x' % (cmd, uval) +if rsp == '': +print "%s%s is not supported" % (cmd, cmd_args) +else: +packet = Packet(rsp) +uval = packet.get_hex_uint('big') +print '%s: 0x%x' % (cmd, uval) def cmd_read_mem_bin(options, cmd, args): # x0x7fff5fc39200,0x200 packet = Packet(args) -addr = packet.get_number() +addr = packet.get_hex_uint('big') comma = packet.get_char() -size = packet.get_number() +size = packet.get_hex_uint('big') print 'binary_read_memory (addr = 0x%16.16x, size = %u)' % (addr, size) return False def rsp_mem_bin_bytes(options, cmd, cmd_args, rsp): packet = Packet(cmd_args) -addr = packet.get_number() +addr = packet.get_hex_uint('big') comma = packet.get_char() -size = packet.get_number() +size = packet.get_hex_uint('big') print 'memory:' if size > 0: dump_hex_memory_buffer(addr, rsp) @@ -1192,11 +1216,11 @@ gdb_remote_commands = { 'QStartNoAckMode': {'cmd': cmd_query_packet, 'rsp': rsp_ok_means_supported, 'name': "query if no ack mode is supported"}, 'QThreadSuffixSupported': {'cmd': cmd_query_packet, 'rsp': rsp_ok_means_supported, 'name': "query if thread suffix is supported"}, 'QListThreadsInStopReply': {'cmd': cmd_query_packet, 'rsp': rsp_ok_means_supported, 'name': "query if threads in stop reply packets are supported"}, -'QSetDetachOnError': {'cmd': cmd_query_packet, 'rsp': rsp_ok_means_success, 'name': "set if we should detach on error"}, -'QSetDisableASLR': {'cmd': cmd_query_packet, 'rsp': rsp_ok_means_success, 'name': "set if we should disable ASLR"}, +'QSetDetachOnError:': {'cmd': cmd_QSetWithUnsigned, 'rsp': rsp_ok_means_success, 'name': "set if we should detach on error"}, +'QSetDisableASLR:': {'cmd': cmd_QSetWithUnsigned, 'rsp': rsp_ok_means_success, 'name': "set if we should disable ASLR"}, 'qLaunchSuccess': {'cmd': cmd_query_packet, 'rsp': rsp_ok_means_success, 'name': "check on launch success for the A packet"}, 'A': {'cmd': cmd_A, 'rsp': rsp_ok_means_success, 'name': "launch process"}, -'QLaunchArch': {'cmd': cmd_query_packet, 'rsp': rsp_ok_means_supported, 'name': "set if we should disable ASLR"}, +'QLaunchArch:': {'cmd': cmd_QSetWithString, 'rsp': rsp_ok_means_supported, 'name': "set the arch to launch in case the file contains multiple architectures"}, 'qVAttachOrWaitSupported': {'cmd': cmd_query_packet, 'rsp': rsp_ok_means_supported, 'name': "set the launch architecture"}, 'qHostInfo': {'cmd': cmd_query_packet, 'rsp': rsp_dump_key_value_pairs, 'name': "get host information"}, 'qC': {'cmd': cmd_qC, 'rsp'
[Lldb-commits] [lldb] r300342 - Increase the packet timeout for the jModulesInfo since it can take longer than the default 1 second timeout on some linux versions when many shared libraries are involv
Author: gclayton Date: Fri Apr 14 12:10:04 2017 New Revision: 300342 URL: http://llvm.org/viewvc/llvm-project?rev=300342&view=rev Log: Increase the packet timeout for the jModulesInfo since it can take longer than the default 1 second timeout on some linux versions when many shared libraries are involved. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=300342&r1=300341&r2=300342&view=diff == --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Fri Apr 14 12:10:04 2017 @@ -3270,6 +3270,9 @@ GDBRemoteCommunicationClient::GetModules payload.PutEscapedBytes(unescaped_payload.GetString().data(), unescaped_payload.GetSize()); + // Increase the timeout for jModulesInfo since this packet can take longer. + ScopedTimeout timeout(*this, std::chrono::seconds(10)); + StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse(payload.GetString(), response, false) != PacketResult::Success || ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32087: Modify GDBRemoteCommunication::ScopedTimeout to not ever decrease a timeout
clayborg created this revision. We use GDBRemoteCommunication::ScopedTimeout in many places to change the packet timeout that is used for individual packets. If someone modifies the default timeout manually or the GDB remote server requests a longer timeout in a 'q' packet, then don't ever reduce a timeout for a packet since that could make things fail. This patch checks the timeout to ensure the new timeout is larger before it modifies the timeout. The GDBRemoteCommunication::ScopedTimeout object also remembers if it did update the timeout and will restore the old timeout only if it did. https://reviews.llvm.org/D32087 Files: source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h === --- source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h @@ -89,6 +89,10 @@ private: GDBRemoteCommunication &m_gdb_comm; std::chrono::seconds m_saved_timeout; +// Don't ever reduce the timeout for a packet, only increase it. If the +// requested timeout if less than the current timeout, we don't set it +// and won't need to restore it. +bool m_timeout_modified; }; GDBRemoteCommunication(const char *comm_name, const char *listener_name); Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp === --- source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -1310,12 +1310,20 @@ GDBRemoteCommunication::ScopedTimeout::ScopedTimeout( GDBRemoteCommunication &gdb_comm, std::chrono::seconds timeout) -: m_gdb_comm(gdb_comm) { - m_saved_timeout = m_gdb_comm.SetPacketTimeout(timeout); + : m_gdb_comm(gdb_comm), m_timeout_modified(false) { +auto curr_timeout = gdb_comm.GetPacketTimeout(); +// Only update the timeout if the timeout is greater than the current +// timeout. If the current timeout is larger, then just use that. +if (curr_timeout < timeout) { + m_timeout_modified = true; + m_saved_timeout = m_gdb_comm.SetPacketTimeout(timeout); +} } GDBRemoteCommunication::ScopedTimeout::~ScopedTimeout() { - m_gdb_comm.SetPacketTimeout(m_saved_timeout); + // Only restore the timeout if we set it in the constructor. + if (m_timeout_modified) +m_gdb_comm.SetPacketTimeout(m_saved_timeout); } // This function is called via the Communications class read thread when bytes Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h === --- source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h @@ -89,6 +89,10 @@ private: GDBRemoteCommunication &m_gdb_comm; std::chrono::seconds m_saved_timeout; +// Don't ever reduce the timeout for a packet, only increase it. If the +// requested timeout if less than the current timeout, we don't set it +// and won't need to restore it. +bool m_timeout_modified; }; GDBRemoteCommunication(const char *comm_name, const char *listener_name); Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp === --- source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -1310,12 +1310,20 @@ GDBRemoteCommunication::ScopedTimeout::ScopedTimeout( GDBRemoteCommunication &gdb_comm, std::chrono::seconds timeout) -: m_gdb_comm(gdb_comm) { - m_saved_timeout = m_gdb_comm.SetPacketTimeout(timeout); + : m_gdb_comm(gdb_comm), m_timeout_modified(false) { +auto curr_timeout = gdb_comm.GetPacketTimeout(); +// Only update the timeout if the timeout is greater than the current +// timeout. If the current timeout is larger, then just use that. +if (curr_timeout < timeout) { + m_timeout_modified = true; + m_saved_timeout = m_gdb_comm.SetPacketTimeout(timeout); +} } GDBRemoteCommunication::ScopedTimeout::~ScopedTimeout() { - m_gdb_comm.SetPacketTimeout(m_saved_timeout); + // Only restore the timeout if we set it in the constructor. + if (m_timeout_modified) +m_gdb_comm.SetPacketTimeout(m_saved_timeout); } // This function is called via the Communications class read thread when bytes ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r300372 - [CMake] Support generating Config.h
Author: cbieneman Date: Fri Apr 14 17:03:45 2017 New Revision: 300372 URL: http://llvm.org/viewvc/llvm-project?rev=300372&view=rev Log: [CMake] Support generating Config.h Summary: This patch removes the hand maintained config files in favor of auto-generating the config file. We will still need to maintain the defines for the Xcode builds on Mac, but all CMake builds use the generated header instead. This will enable finer grained platform support tests and enable supporting LLDB on more platforms with less manual maintenance. I have only tested this patch on Darwin, and any help testing it out on other platforms would be greatly appreciated. I've probably messed something up somewhere. Reviewers: labath, zturner Reviewed By: labath Subscribers: krytarowski, emaste, srhines, lldb-commits, mgorny Differential Revision: https://reviews.llvm.org/D31969 Added: lldb/trunk/include/lldb/Host/Config.h.cmake Removed: lldb/trunk/include/lldb/Host/android/Config.h lldb/trunk/include/lldb/Host/freebsd/Config.h lldb/trunk/include/lldb/Host/linux/Config.h lldb/trunk/include/lldb/Host/macosx/Config.h lldb/trunk/include/lldb/Host/mingw/Config.h lldb/trunk/include/lldb/Host/msvc/Config.h lldb/trunk/include/lldb/Host/netbsd/Config.h lldb/trunk/include/lldb/Host/openbsd/Config.h Modified: lldb/trunk/cmake/modules/LLDBConfig.cmake lldb/trunk/include/lldb/Host/Config.h lldb/trunk/source/Host/common/File.cpp Modified: lldb/trunk/cmake/modules/LLDBConfig.cmake URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBConfig.cmake?rev=300372&r1=300371&r2=300372&view=diff == --- lldb/trunk/cmake/modules/LLDBConfig.cmake (original) +++ lldb/trunk/cmake/modules/LLDBConfig.cmake Fri Apr 14 17:03:45 2017 @@ -270,8 +270,8 @@ string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[ message(STATUS "LLDB version: ${LLDB_VERSION}") include_directories(BEFORE - ${CMAKE_CURRENT_BINARY_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_BINARY_DIR}/include ) if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) @@ -281,6 +281,17 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE +PATTERN ".cmake" EXCLUDE +PATTERN "Config.h" EXCLUDE +) + + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/ +COMPONENT lldb_headers +DESTINATION include +FILES_MATCHING +PATTERN "*.h" +PATTERN ".svn" EXCLUDE +PATTERN ".cmake" EXCLUDE ) endif() @@ -421,3 +432,18 @@ if ((CMAKE_SYSTEM_NAME MATCHES "Android" endif() find_package(Backtrace) + +check_include_file(termios.h HAVE_TERMIOS_H) + +# These checks exist in LLVM's configuration, so I want to match the LLVM names +# so that the check isn't duplicated, but we translate them into the LLDB names +# so that I don't have to change all the uses at the moment. +set(LLDB_CONFIG_TERMIOS_SUPPORTED ${HAVE_TERMIOS_H}) +if(NOT UNIX) + set(LLDB_DISABLE_POSIX 1) +endif() + +# This should be done at the end +configure_file( + ${LLDB_INCLUDE_ROOT}/lldb/Host/Config.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/include/lldb/Host/Config.h) Modified: lldb/trunk/include/lldb/Host/Config.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Config.h?rev=300372&r1=300371&r2=300372&view=diff == --- lldb/trunk/include/lldb/Host/Config.h (original) +++ lldb/trunk/include/lldb/Host/Config.h Fri Apr 14 17:03:45 2017 @@ -7,45 +7,21 @@ // //===--===// -#ifndef liblldb_Config_h_ -#define liblldb_Config_h_ - +#ifndef LLDB_HOST_CONFIG_H +#define LLDB_HOST_CONFIG_H + #if defined(__APPLE__) -#include "lldb/Host/macosx/Config.h" - -#elif defined(__ANDROID__) - -#include "lldb/Host/android/Config.h" - -#elif defined(__linux__) || defined(__GNU__) - -#include "lldb/Host/linux/Config.h" - -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - -#include "lldb/Host/freebsd/Config.h" - -#elif defined(__NetBSD__) - -#include "lldb/Host/netbsd/Config.h" - -#elif defined(__OpenBSD__) - -#include "lldb/Host/openbsd/Config.h" - -#elif defined(__MINGW__) || defined(__MINGW32__) - -#include "lldb/Host/mingw/Config.h" - -#elif defined(_MSC_VER) +// This block of code only exists to keep the Xcode project working in the +// absence of a configuration step. +#define LLDB_CONFIG_TERMIOS_SUPPORTED 1 -#include "lldb/Host/msvc/Config.h" +#define HAVE_SYS_EVENT_H 1 #else -#error undefined platform +#error This file is only used by the Xcode build. #endif -#endif // #ifndef liblldb_Config_h_ +#endif // #ifndef LLDB_HOST_CONFIG_H Added: lldb/trunk/include/lldb/Host/Config.h.cmake URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Config.h.cmake?rev=300372&view=auto ==
[Lldb-commits] [PATCH] D31969: [CMake] Support generating Config.h
This revision was automatically updated to reflect the committed changes. Closed by commit rL300372: [CMake] Support generating Config.h (authored by cbieneman). Changed prior to commit: https://reviews.llvm.org/D31969?vs=95024&id=95354#toc Repository: rL LLVM https://reviews.llvm.org/D31969 Files: lldb/trunk/cmake/modules/LLDBConfig.cmake lldb/trunk/include/lldb/Host/Config.h lldb/trunk/include/lldb/Host/Config.h.cmake lldb/trunk/include/lldb/Host/android/Config.h lldb/trunk/include/lldb/Host/freebsd/Config.h lldb/trunk/include/lldb/Host/linux/Config.h lldb/trunk/include/lldb/Host/macosx/Config.h lldb/trunk/include/lldb/Host/mingw/Config.h lldb/trunk/include/lldb/Host/msvc/Config.h lldb/trunk/include/lldb/Host/netbsd/Config.h lldb/trunk/include/lldb/Host/openbsd/Config.h lldb/trunk/source/Host/common/File.cpp Index: lldb/trunk/source/Host/common/File.cpp === --- lldb/trunk/source/Host/common/File.cpp +++ lldb/trunk/source/Host/common/File.cpp @@ -307,7 +307,7 @@ Error File::GetFileSpec(FileSpec &file_spec) const { Error error; -#ifdef LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED +#ifdef F_GETPATH if (IsValid()) { char path[PATH_MAX]; if (::fcntl(GetDescriptor(), F_GETPATH, path) == -1) Index: lldb/trunk/include/lldb/Host/freebsd/Config.h === --- lldb/trunk/include/lldb/Host/freebsd/Config.h +++ lldb/trunk/include/lldb/Host/freebsd/Config.h @@ -1,28 +0,0 @@ -//===-- Config.h ---*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===--===// - -//-- -// LLDB currently doesn't have a dynamic configuration mechanism, so we -// are going to hardcode things for now. Eventually these files will -// be auto generated by some configuration script that can detect -// platform functionality availability. -//-- - -#ifndef liblldb_Platform_Config_h_ -#define liblldb_Platform_Config_h_ - -#define LLDB_CONFIG_TERMIOS_SUPPORTED 1 - -#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1 - -//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1 - -//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1 - -#endif // #ifndef liblldb_Platform_Config_h_ Index: lldb/trunk/include/lldb/Host/Config.h === --- lldb/trunk/include/lldb/Host/Config.h +++ lldb/trunk/include/lldb/Host/Config.h @@ -7,45 +7,21 @@ // //===--===// -#ifndef liblldb_Config_h_ -#define liblldb_Config_h_ - +#ifndef LLDB_HOST_CONFIG_H +#define LLDB_HOST_CONFIG_H + #if defined(__APPLE__) -#include "lldb/Host/macosx/Config.h" - -#elif defined(__ANDROID__) - -#include "lldb/Host/android/Config.h" - -#elif defined(__linux__) || defined(__GNU__) - -#include "lldb/Host/linux/Config.h" - -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - -#include "lldb/Host/freebsd/Config.h" - -#elif defined(__NetBSD__) - -#include "lldb/Host/netbsd/Config.h" - -#elif defined(__OpenBSD__) - -#include "lldb/Host/openbsd/Config.h" - -#elif defined(__MINGW__) || defined(__MINGW32__) - -#include "lldb/Host/mingw/Config.h" - -#elif defined(_MSC_VER) +// This block of code only exists to keep the Xcode project working in the +// absence of a configuration step. +#define LLDB_CONFIG_TERMIOS_SUPPORTED 1 -#include "lldb/Host/msvc/Config.h" +#define HAVE_SYS_EVENT_H 1 #else -#error undefined platform +#error This file is only used by the Xcode build. #endif -#endif // #ifndef liblldb_Config_h_ +#endif // #ifndef LLDB_HOST_CONFIG_H Index: lldb/trunk/include/lldb/Host/openbsd/Config.h === --- lldb/trunk/include/lldb/Host/openbsd/Config.h +++ lldb/trunk/include/lldb/Host/openbsd/Config.h @@ -1,28 +0,0 @@ -//===-- Config.h ---*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===--===// - -//-- -// LLDB currently doesn't have a dynamic configuration mechanism, so we -// are going to hardcode things for now. Eventually these files will -// be auto generated by some configuration script that can detect -// platform functionality availability. -//---
[Lldb-commits] [lldb] r300373 - [Process/Utility] Remove dead code. NFCI.
Author: davide Date: Fri Apr 14 17:04:05 2017 New Revision: 300373 URL: http://llvm.org/viewvc/llvm-project?rev=300373&view=rev Log: [Process/Utility] Remove dead code. NFCI. Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp?rev=300373&r1=300372&r2=300373&view=diff == --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp Fri Apr 14 17:04:05 2017 @@ -67,11 +67,6 @@ struct UserArea { #include "RegisterInfos_x86_64.h" #undef DECLARE_REGISTER_INFOS_X86_64_STRUCT -static std::vector &GetSharedRegisterInfoVector() { - static std::vector register_infos; - return register_infos; -} - static const RegisterInfo * PrivateGetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch) { switch (target_arch.GetMachine()) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r300374 - Fix bot breakage from r300372
Author: cbieneman Date: Fri Apr 14 17:20:36 2017 New Revision: 300374 URL: http://llvm.org/viewvc/llvm-project?rev=300374&view=rev Log: Fix bot breakage from r300372 Use #cmakedefine instead of #cmakedefine01 because the uses are ifndef instead of if. Modified: lldb/trunk/include/lldb/Host/Config.h.cmake Modified: lldb/trunk/include/lldb/Host/Config.h.cmake URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Config.h.cmake?rev=300374&r1=300373&r2=300374&view=diff == --- lldb/trunk/include/lldb/Host/Config.h.cmake (original) +++ lldb/trunk/include/lldb/Host/Config.h.cmake Fri Apr 14 17:20:36 2017 @@ -10,7 +10,7 @@ #ifndef LLDB_HOST_CONFIG_H #define LLDB_HOST_CONFIG_H -#cmakedefine01 LLDB_CONFIG_TERMIOS_SUPPORTED +#cmakedefine LLDB_CONFIG_TERMIOS_SUPPORTED #cmakedefine LLDB_DISABLE_POSIX ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D31823: Update LLDB Host to support IPv6 over TCP
beanz updated this revision to Diff 95355. beanz added a comment. Herald added a subscriber: mgorny. Updating to use MainLoop class, and refactor MainLoop class to operate on Windows. I've added error cases to the MainLoop class for functionality that is not supported. Specifically non-socket IOObjects are not supported on Windows, and signal handling requires either kqueue or ppoll. In practice that means signal handling is not supported on Windows, older Linux OSs and some BSD variants. That is all controlled by proper configure-time checks. https://reviews.llvm.org/D31823 Files: cmake/modules/LLDBConfig.cmake include/lldb/Host/Config.h include/lldb/Host/Config.h.cmake include/lldb/Host/MainLoop.h include/lldb/Host/Socket.h include/lldb/Host/common/TCPSocket.h include/lldb/Host/common/UDPSocket.h include/lldb/Host/linux/AbstractSocket.h include/lldb/Host/posix/DomainSocket.h include/lldb/Host/posix/MainLoopPosix.h lldb.xcodeproj/project.pbxproj source/Host/CMakeLists.txt source/Host/common/MainLoop.cpp source/Host/common/Socket.cpp source/Host/common/TCPSocket.cpp source/Host/common/UDPSocket.cpp source/Host/linux/AbstractSocket.cpp source/Host/posix/ConnectionFileDescriptorPosix.cpp source/Host/posix/DomainSocket.cpp source/Host/posix/MainLoopPosix.cpp source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp tools/lldb-server/Acceptor.cpp unittests/Host/SocketTest.cpp unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp unittests/debugserver/RNBSocketTest.cpp Index: unittests/debugserver/RNBSocketTest.cpp === --- unittests/debugserver/RNBSocketTest.cpp +++ unittests/debugserver/RNBSocketTest.cpp @@ -96,7 +96,7 @@ ASSERT_EQ(bye, goodbye); } else { Socket *connected_socket; -err = server_socket->Accept(addr_wrap, false, connected_socket); +err = server_socket->Accept(connected_socket); if (err.Fail()) { llvm::errs() << err.AsCString(); abort(); Index: unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp === --- unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp +++ unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp @@ -33,15 +33,14 @@ void Connect(GDBRemoteCommunication &client, GDBRemoteCommunication &server) { bool child_processes_inherit = false; Error error; - TCPSocket listen_socket(child_processes_inherit, error); + TCPSocket listen_socket(true, child_processes_inherit); ASSERT_FALSE(error.Fail()); error = listen_socket.Listen("127.0.0.1:0", 5); ASSERT_FALSE(error.Fail()); Socket *accept_socket; std::future accept_error = std::async(std::launch::async, [&] { -return listen_socket.Accept("127.0.0.1:0", child_processes_inherit, -accept_socket); +return listen_socket.Accept(accept_socket); }); char connect_remote_address[64]; Index: unittests/Host/SocketTest.cpp === --- unittests/Host/SocketTest.cpp +++ unittests/Host/SocketTest.cpp @@ -44,8 +44,7 @@ const char *listen_remote_address, bool child_processes_inherit, Socket **accept_socket, Error *error) { -*error = listen_socket->Accept(listen_remote_address, - child_processes_inherit, *accept_socket); +*error = listen_socket->Accept(*accept_socket); } template @@ -56,7 +55,7 @@ bool child_processes_inherit = false; Error error; std::unique_ptr listen_socket_up( -new SocketType(child_processes_inherit, error)); +new SocketType(true, child_processes_inherit)); EXPECT_FALSE(error.Fail()); error = listen_socket_up->Listen(listen_remote_address, 5); EXPECT_FALSE(error.Fail()); @@ -70,7 +69,7 @@ std::string connect_remote_address = get_connect_addr(*listen_socket_up); std::unique_ptr connect_socket_up( -new SocketType(child_processes_inherit, error)); +new SocketType(true, child_processes_inherit)); EXPECT_FALSE(error.Fail()); error = connect_socket_up->Connect(connect_remote_address); EXPECT_FALSE(error.Fail()); @@ -141,6 +140,20 @@ EXPECT_STREQ("65535", port_str.c_str()); EXPECT_EQ(65535, port); EXPECT_TRUE(error.Success()); + + EXPECT_TRUE( + Socket::DecodeHostAndPort("[::1]:12345", host_str, port_str, port, &error)); + EXPECT_STREQ("::1", host_str.c_str()); + EXPECT_STREQ("12345", port_str.c_str()); + EXPECT_EQ(12345, port); + EXPECT_TRUE(error.Success()); + + EXPECT_TRUE( + Socket::DecodeHostAndPort("[abcd:12fg:AF58::1]:12345", host_str, port_str, port, &error)); + EXPECT_STREQ("abcd:12fg:AF58::1", host_str.c_str()); + EXPECT_STREQ("12345", port_str.c_str()); + EXPECT_EQ(12345, port); + EXPECT_TRUE(error.Success()); } #ifndef LLDB_D
[Lldb-commits] [lldb] r300375 - [ARM/Emulation] Remove an unneeded comparison and simplify. NFCI.
Author: davide Date: Fri Apr 14 17:27:28 2017 New Revision: 300375 URL: http://llvm.org/viewvc/llvm-project?rev=300375&view=rev Log: [ARM/Emulation] Remove an unneeded comparison and simplify. NFCI. reg0 is always zero and comparison to an unsigned always yields true. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp?rev=300375&r1=300374&r2=300375&view=diff == --- lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp Fri Apr 14 17:27:28 2017 @@ -66,7 +66,7 @@ bool EmulationStateARM::LoadPseudoRegist bool EmulationStateARM::StorePseudoRegisterValue(uint32_t reg_num, uint64_t value) { - if ((dwarf_r0 <= reg_num) && (reg_num <= dwarf_cpsr)) + if (reg_num <= dwarf_cpsr) m_gpr[reg_num - dwarf_r0] = (uint32_t)value; else if ((dwarf_s0 <= reg_num) && (reg_num <= dwarf_s31)) { uint32_t idx = reg_num - dwarf_s0; @@ -89,7 +89,7 @@ uint64_t EmulationStateARM::ReadPseudoRe uint64_t value = 0; success = true; - if ((dwarf_r0 <= reg_num) && (reg_num <= dwarf_cpsr)) + if (reg_num <= dwarf_cpsr) value = m_gpr[reg_num - dwarf_r0]; else if ((dwarf_s0 <= reg_num) && (reg_num <= dwarf_s31)) { uint32_t idx = reg_num - dwarf_s0; ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r300377 - [Interpreter] Make a static func a lambda and remove always_inline.
Author: davide Date: Fri Apr 14 17:36:08 2017 New Revision: 300377 URL: http://llvm.org/viewvc/llvm-project?rev=300377&view=rev Log: [Interpreter] Make a static func a lambda and remove always_inline. The attribute was fairly dubious as: a) we shouldn't tell the compiler when to inline functions, b) GCC complains that the function may be not always inlinable. Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=300377&r1=300376&r2=300377&view=diff == --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Fri Apr 14 17:36:08 2017 @@ -2542,14 +2542,6 @@ void CommandInterpreter::OutputFormatted OutputFormattedHelpText(strm, prefix_stream.GetString(), help_text); } -LLVM_ATTRIBUTE_ALWAYS_INLINE -static size_t nextWordLength(llvm::StringRef S) { - size_t pos = S.find_first_of(' '); - if (pos == llvm::StringRef::npos) -return S.size(); - return pos; -} - void CommandInterpreter::OutputHelpText(Stream &strm, llvm::StringRef word_text, llvm::StringRef separator, llvm::StringRef help_text, @@ -2568,6 +2560,11 @@ void CommandInterpreter::OutputHelpText( uint32_t chars_left = max_columns; + auto nextWordLength = [](llvm::StringRef S) { +size_t pos = S.find_first_of(' '); +return pos == llvm::StringRef::npos ? S.size() : pos; + }; + while (!text.empty()) { if (text.front() == '\n' || (text.front() == ' ' && nextWordLength(text.ltrim(' ')) < chars_left)) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32100: [Expression parser] Return both types and variables
spyffe created this revision. Many times a user wants to access a type when there's a variable of the same name, or a variable when there's a type of the same name. Depending on the precise context, currently the expression parser can fail to resolve one or the other. This is because `ClangExpressionDeclMap` has logic to limit the amount of information it searches, and that logic sometimes cuts down the search prematurely. This patch removes some of those early exits. In that sense, this patch trades performance (early exit is faster) for correctness. I've also included two new test cases showing examples of this behavior – as well as modifying an existing test case that gets it wrong. https://reviews.llvm.org/D32100 Files: packages/Python/lldbsuite/test/lang/cpp/llvm-style/Makefile packages/Python/lldbsuite/test/lang/cpp/llvm-style/TestLLVMStyle.py packages/Python/lldbsuite/test/lang/cpp/llvm-style/main.cc packages/Python/lldbsuite/test/lang/cpp/nsimport/TestCppNsImport.py packages/Python/lldbsuite/test/lang/cpp/symbols/Makefile packages/Python/lldbsuite/test/lang/cpp/symbols/TestSymbpls.py packages/Python/lldbsuite/test/lang/cpp/symbols/main.cc source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp Index: source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp === --- source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -814,9 +814,8 @@ FindExternalVisibleDecls(context, lldb::ModuleSP(), namespace_decl, current_id); } - - if (!context.m_found.variable && !context.m_found.local_vars_nsp) -ClangASTSource::FindExternalVisibleDecls(context); + + ClangASTSource::FindExternalVisibleDecls(context); } void ClangExpressionDeclMap::FindExternalVisibleDecls( @@ -1217,7 +1216,7 @@ } } - if (var) { + if (var && !variable_found) { variable_found = true; valobj = ValueObjectVariable::Create(frame, var); AddOneVariable(context, var, valobj, current_id); @@ -1248,303 +1247,297 @@ } } -if (!context.m_found.variable) { - const bool include_inlines = false; - const bool append = false; +const bool include_inlines = false; +const bool append = false; - if (namespace_decl && module_sp) { -const bool include_symbols = false; +if (namespace_decl && module_sp) { + const bool include_symbols = false; -module_sp->FindFunctions(name, &namespace_decl, eFunctionNameTypeBase, - include_symbols, include_inlines, append, - sc_list); - } else if (target && !namespace_decl) { -const bool include_symbols = true; + module_sp->FindFunctions(name, &namespace_decl, eFunctionNameTypeBase, + include_symbols, include_inlines, append, + sc_list); +} else if (target && !namespace_decl) { + const bool include_symbols = true; -// TODO Fix FindFunctions so that it doesn't return -// instance methods for eFunctionNameTypeBase. + // TODO Fix FindFunctions so that it doesn't return + // instance methods for eFunctionNameTypeBase. -target->GetImages().FindFunctions(name, eFunctionNameTypeFull, - include_symbols, include_inlines, - append, sc_list); - } + target->GetImages().FindFunctions(name, eFunctionNameTypeFull, +include_symbols, include_inlines, +append, sc_list); +} - // If we found more than one function, see if we can use the - // frame's decl context to remove functions that are shadowed - // by other functions which match in type but are nearer in scope. - // - // AddOneFunction will not add a function whose type has already been - // added, so if there's another function in the list with a matching - // type, check to see if their decl context is a parent of the current - // frame's or was imported via a and using statement, and pick the - // best match according to lookup rules. - if (sc_list.GetSize() > 1) { -// Collect some info about our frame's context. -StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr(); -SymbolContext frame_sym_ctx; -if (frame != nullptr) - frame_sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction | - lldb::eSymbolContextBlock); -CompilerDeclContext frame_decl_context = -frame_sym_ctx.block != nullptr -? frame_sym_ctx.block->GetDeclContext() -: CompilerDe
[Lldb-commits] [lldb] r300386 - Fix crash when completing in the current directory.
Author: zturner Date: Fri Apr 14 21:44:53 2017 New Revision: 300386 URL: http://llvm.org/viewvc/llvm-project?rev=300386&view=rev Log: Fix crash when completing in the current directory. Modified: lldb/trunk/source/Commands/CommandCompletions.cpp lldb/trunk/unittests/Interpreter/TestCompletion.cpp Modified: lldb/trunk/source/Commands/CommandCompletions.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=300386&r1=300385&r2=300386&view=diff == --- lldb/trunk/source/Commands/CommandCompletions.cpp (original) +++ lldb/trunk/source/Commands/CommandCompletions.cpp Fri Apr 14 21:44:53 2017 @@ -176,7 +176,10 @@ static int DiskFilesOrDirectories(const if (PartialItem == ".") PartialItem = llvm::StringRef(); - assert(!SearchDir.empty()); + if (SearchDir.empty()) { +llvm::sys::fs::current_path(Storage); +SearchDir = Storage; + } assert(!PartialItem.contains(path::get_separator())); // SearchDir now contains the directory to search in, and Prefix contains the Modified: lldb/trunk/unittests/Interpreter/TestCompletion.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Interpreter/TestCompletion.cpp?rev=300386&r1=300385&r2=300386&view=diff == --- lldb/trunk/unittests/Interpreter/TestCompletion.cpp (original) +++ lldb/trunk/unittests/Interpreter/TestCompletion.cpp Fri Apr 14 21:44:53 2017 @@ -43,6 +43,8 @@ protected: /// be placed. It is removed at the end of the test suite. static SmallString<128> BaseDir; + static SmallString<128> OriginalWorkingDir; + static SmallString<128> DirFoo; static SmallString<128> DirFooA; static SmallString<128> DirFooB; @@ -58,7 +60,11 @@ protected: static SmallString<128> FileBar; static SmallString<128> FileBaz; + void SetUp() override { llvm::sys::fs::set_current_path(OriginalWorkingDir); } + static void SetUpTestCase() { +llvm::sys::fs::current_path(OriginalWorkingDir); + ASSERT_NO_ERROR(fs::createUniqueDirectory("FsCompletion", BaseDir)); const char *DirNames[] = {"foo", "fooa", "foob", "fooc", "bar", "baz", "test_folder"}; @@ -106,9 +112,33 @@ protected: } return false; } + + void DoDirCompletions(const Twine &Prefix, +StandardTildeExpressionResolver &Resolver, +StringList &Results) { +// When a partial name matches, it returns all matches. If it matches both +// a full name AND some partial names, it returns all of them. +uint32_t Count = +CommandCompletions::DiskDirectories(Prefix + "foo", Results, Resolver); +ASSERT_EQ(4u, Count); +ASSERT_EQ(Count, Results.GetSize()); +EXPECT_TRUE(HasEquivalentFile(DirFoo, Results)); +EXPECT_TRUE(HasEquivalentFile(DirFooA, Results)); +EXPECT_TRUE(HasEquivalentFile(DirFooB, Results)); +EXPECT_TRUE(HasEquivalentFile(DirFooC, Results)); + +// If it matches only partial names, it still works as expected. +Count = CommandCompletions::DiskDirectories(Twine(Prefix) + "b", Results, +Resolver); +ASSERT_EQ(2u, Count); +ASSERT_EQ(Count, Results.GetSize()); +EXPECT_TRUE(HasEquivalentFile(DirBar, Results)); +EXPECT_TRUE(HasEquivalentFile(DirBaz, Results)); + } }; SmallString<128> CompletionTest::BaseDir; +SmallString<128> CompletionTest::OriginalWorkingDir; SmallString<128> CompletionTest::DirFoo; SmallString<128> CompletionTest::DirFooA; @@ -132,8 +162,11 @@ TEST_F(CompletionTest, DirCompletionAbso // by asserting an exact result count, and verifying against known // folders. + std::string Prefixes[] = {(Twine(BaseDir) + "/").str(), ""}; + StandardTildeExpressionResolver Resolver; StringList Results; + // When a directory is specified that doesn't end in a slash, it searches // for that directory, not items under it. size_t Count = @@ -143,8 +176,7 @@ TEST_F(CompletionTest, DirCompletionAbso EXPECT_TRUE(HasEquivalentFile(BaseDir, Results)); // When the same directory ends with a slash, it finds all children. - Count = CommandCompletions::DiskDirectories(Twine(BaseDir) + "/", Results, - Resolver); + Count = CommandCompletions::DiskDirectories(Prefixes[0], Results, Resolver); ASSERT_EQ(7u, Count); ASSERT_EQ(Count, Results.GetSize()); EXPECT_TRUE(HasEquivalentFile(DirFoo, Results)); @@ -155,24 +187,9 @@ TEST_F(CompletionTest, DirCompletionAbso EXPECT_TRUE(HasEquivalentFile(DirBaz, Results)); EXPECT_TRUE(HasEquivalentFile(DirTestFolder, Results)); - // When a partial name matches, it returns all matches. If it matches both - // a full name AND some partial names, it returns all of them. - Count = CommandCompletions::DiskDirectories(Twine(BaseDir) +
Re: [Lldb-commits] [lldb] r297585 - Make file / directory completion work properly on Windows.
Should be fixed in r300386, let me know if you're still experiencing problems. On Tue, Apr 11, 2017 at 5:59 PM Zachary Turner wrote: > Thanks for the heads up, I'll try to look at this tomorrow. > > On Tue, Apr 11, 2017 at 5:55 PM Jason Molenda wrote: > >> I noticed that the llvm.org sources crash when you do filename >> completion with a file in the current working directory: >> >> % build/Debug/lldb >> (lldb) file aaa[TAB]Assertion failed: (!SearchDir.empty()), function >> DiskFilesOrDirectories, file >> /Volumes/newwork/svn/lldb/source/Commands/CommandCompletions.cpp, line 179. >> Abort >> >> >> Or through the SB API: >> >> % build/Debug/lldb >> (lldb) scri >> >>> print lldb.debugger.GetCommandInterpreter().HandleCompletion("file >> /tmp/ll", 11, 0, -1, lldb.SBStringList()) >> 0 >> >>> print lldb.debugger.GetCommandInterpreter().HandleCompletion("file >> ll", 7, 0, -1, lldb.SBStringList()) >> Assertion failed: (!SearchDir.empty()), function DiskFilesOrDirectories, >> file /Volumes/newwork/svn/lldb/source/Commands/CommandCompletions.cpp, line >> 179. >> Abort >> >> >> maybe it's related from r297585? There have been a few overlapping >> changes to CommandCompletions.cpp by you and Pavel recently, not sure >> exactly which it might be. >> >> If this can't be tested through the unit test framework, it would be easy >> to add an SB API test case, see above. >> >> Thanks >> >> >> >> > On Mar 12, 2017, at 11:18 AM, Zachary Turner via lldb-commits < >> lldb-commits@lists.llvm.org> wrote: >> > >> > Author: zturner >> > Date: Sun Mar 12 13:18:50 2017 >> > New Revision: 297585 >> > >> > URL: http://llvm.org/viewvc/llvm-project?rev=297585&view=rev >> > Log: >> > Make file / directory completion work properly on Windows. >> > >> > There were a couple of problems with this function on Windows. Different >> > separators and differences in how tilde expressions are resolved for >> > starters, but in addition there was no clear indication of what the >> > function's inputs or outputs were supposed to be, and there were no >> tests >> > to demonstrate its use. >> > >> > To more easily paper over the differences between Windows paths, >> > non-Windows paths, and tilde expressions, I've ported this function to >> use >> > LLVM-based directory iteration (in fact, I would like to eliminate all >> of >> > LLDB's directory iteration code entirely since LLVM's is cleaner / more >> > efficient (i.e. it invokes fewer stat calls)). and llvm's portable path >> > manipulation library. >> > >> > Since file and directory completion assumes you are referring to files >> and >> > directories on your local machine, it's safe to assume the path syntax >> > properties of the host in doing so, so LLVM's APIs are perfect for this. >> > >> > I've also added a fairly robust set of unit tests. Since you can't >> really >> > predict what users will be on your machine, or what their home >> directories >> > will be, I added an interface called TildeExpressionResolver, and in the >> > unit test I've mocked up a fake implementation that acts like a unix >> > password database. This allows us to configure some fake users and home >> > directories in the test, so we can exercise all of those hard-to-test >> > codepaths that normally otherwise depend on the host. >> > >> > Differential Revision: https://reviews.llvm.org/D30789 >> > >> > Added: >> >lldb/trunk/include/lldb/Utility/TildeExpressionResolver.h >> >lldb/trunk/source/Utility/TildeExpressionResolver.cpp >> >lldb/trunk/unittests/Interpreter/TestCompletion.cpp >> > Modified: >> >lldb/trunk/include/lldb/Interpreter/CommandCompletions.h >> >lldb/trunk/source/Commands/CommandCompletions.cpp >> >lldb/trunk/source/Utility/CMakeLists.txt >> >lldb/trunk/unittests/Interpreter/CMakeLists.txt >> > >> > Modified: lldb/trunk/include/lldb/Interpreter/CommandCompletions.h >> > URL: >> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandCompletions.h?rev=297585&r1=297584&r2=297585&view=diff >> > >> == >> > --- lldb/trunk/include/lldb/Interpreter/CommandCompletions.h (original) >> > +++ lldb/trunk/include/lldb/Interpreter/CommandCompletions.h Sun Mar 12 >> 13:18:50 2017 >> > @@ -21,7 +21,10 @@ >> > #include "lldb/Utility/RegularExpression.h" >> > #include "lldb/lldb-private.h" >> > >> > +#include "llvm/ADT/Twine.h" >> > + >> > namespace lldb_private { >> > +struct TildeExpressionResolver; >> > class CommandCompletions { >> > public: >> > >> //-- >> > @@ -76,12 +79,19 @@ public: >> >int max_return_elements, SearchFilter *searcher, >> >bool &word_complete, StringList &matches); >> > >> > + static int DiskFiles(const llvm::Twine &partial_file_name, >> > + StringList &matches, TildeExpressionResolver >> &Resolver); >> > + >> > stat