summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/common
Commit message (Collapse)AuthorAgeFilesLines
* [lldb][NFC] Use static_cast instead of reinterpret_cast where possibleRaphael Isemann2020-01-071-2/+2
| | | | | | | | | | | | | | Summary: There are a few places in LLDB where we do a `reinterpret_cast` for conversions that we could also do with `static_cast`. This patch moves all this code to `static_cast`. Reviewers: shafik, JDevlieghere, labath Reviewed By: labath Subscribers: arphaman, usaxena95, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D72161
* [lldb][NFC] Take a llvm::Triple in ClangASTContext constructorRaphael Isemann2020-01-071-3/+3
| | | | | | This constructor is supposed to take a string representing an llvm::Triple. We might as well take a llvm::Triple here which saves us all the string conversions in the call sites and we make this more type safe.
* [lldb] Fix ARM32 inferior callsJan Kratochvil2019-12-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | echo -e '#include <unistd.h>\nint main(void){\nsync();return 0;}'|./bin/clang -g -x c -;./bin/lldb -o 'file ./a.out' -o 'b main' -o r -o 'p (void)sync()' Actual: error: Expression can't be run, because there is no JIT compiled function Expected: <nothing, sync() has been executed> This patch has been checked by: D71707: clang-tidy: new bugprone-pointer-cast-widening https://reviews.llvm.org/D71707 Casting from 32-bit `void *` to `uint64_t` requires an intermediate `uintptr_t` cast otherwise the pointer gets sign-extended: echo -e '#include <stdio.h>\n#include <stdint.h>\nint main(void){void *p=(void *)0x80000000;unsigned long long ull=(unsigned long long)p;unsigned long long ull2=(unsigned long long)(uintptr_t)p;printf("p=%p ull=0x%llx ull2=0x%llx\\n",p,ull,ull2);return 0;}'|gcc -Wall -m32 -x c -;./a.out <stdin>: In function ‘main’: <stdin>:3:66: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] p=0x80000000 ull=0xffffffff80000000 ull2=0x80000000 With debug output: Actual: IRMemoryMap::WriteMemory (0xb6ff8640, 0xffffffffb6f82158, 0x112) went to [0xb6ff8640..0xb6ff86b3) Code can be run in the target. Found function, has local address 0xffffffffb6f84000 and remote address 0xffffffffffffffff Couldn't disassemble function : Couldn't find code range for function _Z12$__lldb_exprPv Sections: [0xb6f84000+0x3c]->0xb6ff9020 (alignment 4, section ID 0, name .text) ... HandleCommand, command did not succeed error: Expression can't be run, because there is no JIT compiled function Expected: IRMemoryMap::WriteMemory (0xb6ff8640, 0xb6faa15c, 0x128) went to [0xb6ff8640..0xb6ff86c3) IRExecutionUnit::GetRemoteAddressForLocal() found 0xb6fac000 in [0xb6fac000..0xb6fac040], and returned 0xb6ff9020 from [0xb6ff9020..0xb6ff9060]. Code can be run in the target. Found function, has local address 0xb6fac000 and remote address 0xb6ff9020 Function's code range is [0xb6ff9020+0x40] ... Function data has contents: 0xb6ff9020: 10 4c 2d e9 08 b0 8d e2 08 d0 4d e2 00 40 a0 e1 ... Function disassembly: 0xb6ff9020: 0xe92d4c10 push {r4, r10, r11, lr} Differential revision: https://reviews.llvm.org/D71498
* [lldb] Make that we can call HostInfo::Initialize and HostInfo::Terminate ↵Raphael Isemann2019-12-201-44/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | multiple times Summary: HostInfo's state isn't actually fully rested after calling ::Terminate. Currently we only reset the values of all the `HostInfoBaseFields` but not all the variables with static storage that keep track of whether the fields need to be initialised. This breaks random unit tests as running them twice (or running multiple test instances in one run) will cause that the second time we ask HostInfo for any information we get the default value back for any field. This patch moves all the once_flag's into the `HostInfoBaseFields` so that they also get reseted by ::Terminate and removes all the `success` bools. We should also rewrite half this code but I would prefer if my tests aren't broken over the holidays so let's just put some duct tape on it for now. Reviewers: labath Reviewed By: labath Subscribers: abidh, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71748
* [lldb/Host] Use cmakedefine01 for LLDB_ENABLE_POSIXJonas Devlieghere2019-12-135-10/+10
| | | | | Rename LLDB_DISABLE_POSIX to LLDB_ENABLE_POSIX and use cmakedefine01 for consistency.
* [lldb/Host] Use cmakedefine01 for LLDB_ENABLE_TERMIOSJonas Devlieghere2019-12-121-13/+13
| | | | | | | This renames LLDB_CONFIG_TERMIOS_SUPPORTED to LLDB_ENABLE_TERMIOS. It now also uses cmakedefine01 to keep things consistent with out other optional dependencies. But more importantly it won't silently fail when you forget to include Config.h.
* [lldb/Host] Use cmakedefine01 for LLDB_ENABLE_LIBXML2Jonas Devlieghere2019-12-121-29/+29
| | | | | | This keeps things consistent with out other optional dependencies. But more importantly it won't silently fail when you forget to include Config.h.
* [lldb/Host] Use Host/Config.h for LibXML2 instead of a global defineJonas Devlieghere2019-12-111-29/+30
| | | | | Rename LIBXML2_DEFINED to LLDB_ENABLE_LIBXML2 and pass it through Config.h instead of a global define.
* [lldb] Add #include to appease the modules buildVedant Kumar2019-12-101-0/+1
| | | | | | | | | | | | | | | | | This #include appears to be completely unnecessary, but it does fix the following build failure: http://green.lab.llvm.org/green/job/lldb-cmake/4565/consoleText FAILED: tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/MainLoop.cpp.o /Users/buildslave/jenkins/workspace/lldb-cmake/host-compiler/bin/clang++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -DLIBXML2_DEFINED -DLLDB_CONFIGURATION_RELEASE -DLLDB_USE_OS_LOG -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/lldb/source/Host -I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/source/Host -Itools/lldb/source -I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/include -Itools/lldb/include -Iinclude -I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include -I/usr/local/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/../clang/include -Itools/lldb/../clang/include -I/usr/local/include -I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/source/. -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2 -Wdocumentation -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -fmodules -fmodules-cache-path=/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/module.cache -fcxx-modules -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register -Wno-vla-extension -O3 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -UNDEBUG -fno-exceptions -fno-rtti -std=c++14 -MD -MT tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/MainLoop.cpp.o -MF tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/MainLoop.cpp.o.d -o tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/MainLoop.cpp.o -c /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/source/Host/common/MainLoop.cpp /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/source/Host/common/MainLoop.cpp:211:7: error: use of undeclared identifier 'ppoll' if (ppoll(read_fds.data(), read_fds.size(), nullptr, &sigmask) == -1 && ^ /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/source/Host/common/MainLoop.cpp:336:25: error: use of undeclared identifier 'HAVE_SYS_EVENT_H' ret = pthread_sigmask(HAVE_SYS_EVENT_H ? SIG_UNBLOCK : SIG_BLOCK, ^ 2 errors generated.
* Fix a -Wsign-compare error around wchar_t vs unsigned int.Eric Christopher2019-12-101-1/+1
|
* [lldb/Editline] Fix a -Wreturn-type warning with gccPavel Labath2019-12-041-0/+1
|
* [EditLine] Fix RecallHistory to make it go in the right direction.Jonas Devlieghere2019-12-031-25/+72
| | | | | | | | | | | | | | | | | | | The naming used by editline for the history operations is counter intuitive to how it's used in lldb for the REPL. - The H_PREV operation returns the previous element in the history, which is newer than the current one. - The H_NEXT operation returns the next element in the history, which is older than the current one. This exposed itself as a bug in the REPL where the behavior of up- and down-arrow was inverted. This wasn't immediately obvious because of how we save the current "live" entry. This patch fixes the bug and introduces and enum to wrap the editline operations that match the semantics of lldb. Differential revision: https://reviews.llvm.org/D70932
* [-gmodules] Let LLDB log a warning if the Clang module hash mismatches.Adrian Prantl2019-11-151-4/+15
| | | | | | | | This feature is mostly there to aid debugging of Clang module issues, since the only useful actual the end-user can to is to recompile their program. Differential Revision: https://reviews.llvm.org/D70272
* [lldb][Editline] Support ctrl+left/right arrow word navigation.Jordan Rupprecht2019-11-141-0/+9
| | | | | | | | | | | | | | | | | Summary: This adds several 5C/5D escape codes that allow moving forward/backward words similar to bash command line navigation. On my terminal, `ctrl+v ctrl+<left arrow>` prints `^[[1;5D`. However, it seems inputrc also maps other escape variants of this to forward/backward word, so I've included those too. Similar for 5C = ctrl+right arrow. Reviewers: JDevlieghere, labath Reviewed By: JDevlieghere, labath Subscribers: merge_guards_bot, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D70137
* [lldb] Fix more -Wdeprecated-copy warningsPavel Labath2019-11-122-10/+4
| | | | | | | This warning triggers when a class defines a copy constructor but not a copy-assignment operator (which then gets auto-generated by the compiler). Fix the warning by deleting the other operator too, as the default implementation works just fine.
* [LLDB][Python] fix another fflush issue on NetBSDLawrence D'Anna2019-10-291-1/+1
| | | | | | | | | | | | | | | | Summary: Here's another instance where we were calling fflush on an input stream, which is illegal on NetBSD. Reviewers: labath, mgorny Reviewed By: mgorny Subscribers: krytarowski, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D69488
* delete SWIG typemaps for FILE*Lawrence D'Anna2019-10-171-14/+0
| | | | | | | | | | | | | | | | | | Summary: The SWIG typemaps for FILE* are no longer used, so this patch deletes them. Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68963 llvm-svn: 375073
* Add arm64_32 support to lldb, an ILP32 codegen Jason Molenda2019-10-161-0/+2
| | | | | | | | | | that runs on arm64 ISA targets, specifically Apple watches. Differential Revision: https://reviews.llvm.org/D68858 llvm-svn: 375032
* SBFile::GetFile: convert SBFile back into python native files.Lawrence D'Anna2019-10-151-1/+13
| | | | | | | | | | | | | | | | | | | | | | Summary: This makes SBFile::GetFile public and adds a SWIG typemap to convert the result back into a python native file. If the underlying File itself came from a python file, it is returned identically. Otherwise a new python file object is created using the file descriptor. Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68737 llvm-svn: 374911
* uint32_t options -> File::OpenOptions optionsLawrence D'Anna2019-10-143-29/+41
| | | | | | | | | | | | | | | | | | | | | | | Summary: This patch re-types everywhere that passes a File::OpenOptions as a uint32_t so it actually uses File::OpenOptions. It also converts some OpenOptions related functions that fail by returning 0 or NULL into llvm::Expected split off from https://reviews.llvm.org/D68737 Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68853 llvm-svn: 374817
* File: Handle more cases in GetOptionsFromModePavel Labath2019-10-101-9/+11
| | | | | | | | | | The "b" (binary) flag is meaningless most of the time, but the relevant standars allow it. The standards permit one to spell it both as "r+b" and "rb+", so handle both cases. This fixes TestFileHandle.test_binary_inout with python2. llvm-svn: 374331
* Simplify LZMA decoding by using ArrayRef::take_backKonrad Kleine2019-10-081-6/+6
| | | | | | | | | | | | | | Summary: Follow-up for D66791#inline-616303 Reviewers: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68647 llvm-svn: 374069
* [lldb][ELF] Read symbols from .gnu_debugdata sect.Konrad Kleine2019-10-071-0/+146
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: If the .symtab section is stripped from the binary it might be that there's a .gnu_debugdata section which contains a smaller .symtab in order to provide enough information to create a backtrace with function names or to set and hit a breakpoint on a function name. This change looks for a .gnu_debugdata section in the ELF object file. The .gnu_debugdata section contains a xz-compressed ELF file with a .symtab section inside. Symbols from that compressed .symtab section are merged with the main object file's .dynsym symbols (if any). In addition we always load the .dynsym even if there's a .symtab section. For example, the Fedora and RHEL operating systems strip their binaries but keep a .gnu_debugdata section. While gdb already can read this section, LLDB until this patch couldn't. To test this patch on a Fedora or RHEL operating system, try to set a breakpoint on the "help" symbol in the "zip" binary. Before this patch, only GDB can set this breakpoint; now LLDB also can do so without installing extra debug symbols: lldb /usr/bin/zip -b -o "b help" -o "r" -o "bt" -- -h The above line runs LLDB in batch mode and on the "/usr/bin/zip -h" target: (lldb) target create "/usr/bin/zip" Current executable set to '/usr/bin/zip' (x86_64). (lldb) settings set -- target.run-args "-h" Before the program starts, we set a breakpoint on the "help" symbol: (lldb) b help Breakpoint 1: where = zip`help, address = 0x00000000004093b0 Once the program is run and has hit the breakpoint we ask for a backtrace: (lldb) r Process 10073 stopped * thread #1, name = 'zip', stop reason = breakpoint 1.1 frame #0: 0x00000000004093b0 zip`help zip`help: -> 0x4093b0 <+0>: pushq %r12 0x4093b2 <+2>: movq 0x2af5f(%rip), %rsi ; + 4056 0x4093b9 <+9>: movl $0x1, %edi 0x4093be <+14>: xorl %eax, %eax Process 10073 launched: '/usr/bin/zip' (x86_64) (lldb) bt * thread #1, name = 'zip', stop reason = breakpoint 1.1 * frame #0: 0x00000000004093b0 zip`help frame #1: 0x0000000000403970 zip`main + 3248 frame #2: 0x00007ffff7d8bf33 libc.so.6`__libc_start_main + 243 frame #3: 0x0000000000408cee zip`_start + 46 In order to support the .gnu_debugdata section, one has to have LZMA development headers installed. The CMake section, that controls this part looks for the LZMA headers and enables .gnu_debugdata support by default if they are found; otherwise or if explicitly requested, the minidebuginfo support is disabled. GDB supports the "mini debuginfo" section .gnu_debugdata since v7.6 (2013). Reviewers: espindola, labath, jankratochvil, alexshap Reviewed By: labath Subscribers: rnkovacs, wuzish, shafik, emaste, mgorny, arichardson, hiraditya, MaskRay, lldb-commits Tags: #lldb, #llvm Differential Revision: https://reviews.llvm.org/D66791 llvm-svn: 373891
* factor out an abstract base class for FileLawrence D'Anna2019-10-032-107/+170
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch factors out File as an abstract base class and moves most of its actual functionality into a subclass called NativeFile. In the next patch, I'm going to be adding subclasses of File that don't necessarily have any connection to actual OS files, so they will not inherit from NativeFile. This patch was split out as a prerequisite for https://reviews.llvm.org/D68188 Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68317 llvm-svn: 373564
* new api class: SBFileLawrence D'Anna2019-10-031-3/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: SBFile is a scripting API wrapper for lldb_private::File This is the first step in a project to enable arbitrary python io.IOBase file objects -- including those that override the read() and write() methods -- to be used as the main debugger IOStreams. Currently this is impossible because python file objects must first be converted into FILE* streams by SWIG in order to be passed into the debugger. full prototype: https://github.com/smoofra/llvm-project/tree/files Reviewers: JDevlieghere, jasonmolenda, zturner, jingham, labath Reviewed By: labath Subscribers: labath, mgorny, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D67793 llvm-svn: 373562
* File::Clear() -> File::TakeStreamAndClear()Lawrence D'Anna2019-10-011-2/+5
| | | | | | | | | | | | | | | | | | | | | | | Summary: File::Clear() is an ugly function. It's only used in one place, which is the swig typemaps for FILE*. This patch refactors and renames that function to make it clear what it's really for and why nobody else should use it. Both File::TakeStreamAndClear() and the FILE* typemaps will be removed in later patches after a suitable replacement is in place. Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68160 llvm-svn: 373285
* refactor: move IOObject::m_should_close_fd into subclassesLawrence D'Anna2019-09-272-7/+8
| | | | | | | | | | | | | | | | | | Summary: m_should_close_fd doesn't need to be in IOObject. It will be useful for my next change to move it down into File and Socket. Reviewers: labath, JDevlieghere, jasonmolenda Reviewed By: JDevlieghere Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68152 llvm-svn: 373126
* remove File::SetStream(), make new files instead.Lawrence D'Anna2019-09-271-15/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch removes File::SetStream() and File::SetDescriptor(), and replaces most direct uses of File with pointers to File. Instead of calling SetStream() on a file, we make a new file and replace it. My ultimate goal here is to introduce a new API class SBFile, which has full support for python io.IOStream file objects. These can redirect read() and write() to python code, so lldb::Files will need a way to dispatch those methods. Additionally it will need some form of sharing and assigning files, as a SBFile will be passed in and assigned to the main IO streams of the debugger. In my prototype patch queue, I make File itself copyable and add a secondary class FileOps to manage the sharing and dispatch. In that case SBFile was a unique_ptr<File>. (here: https://github.com/smoofra/llvm-project/tree/files) However in review, Pavel Labath suggested that it be shared_ptr instead. (here: https://reviews.llvm.org/D67793) In order for SBFile to use shared_ptr<File>, everything else should as well. If this patch is accepted, I will make SBFile use a shared_ptr I will remove FileOps from future patches and use subclasses of File instead. Reviewers: JDevlieghere, jasonmolenda, zturner, jingham, labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D67891 llvm-svn: 373090
* Convert FileSystem::Open() to return Expected<FileUP>Lawrence D'Anna2019-09-262-30/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch converts FileSystem::Open from this prototype: Status Open(File &File, const FileSpec &file_spec, ...); to this one: llvm::Expected<std::unique_ptr<File>> Open(const FileSpec &file_spec, ...); This is beneficial on its own, as llvm::Expected is a more modern and recommended error type than Status. It is also a necessary step towards https://reviews.llvm.org/D67891, and further developments for lldb_private::File. Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: mgorny, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D67996 llvm-svn: 373003
* File::SetDescriptor() should require optionsJonas Devlieghere2019-09-232-4/+4
| | | | | | | | | | | | | | | | | | | | | | lvm_private::File::GetStream() can fail if m_options == 0 It's not clear from the header a File created with a descriptor will be not be usable by many parts of LLDB unless SetOptions is also called, but it is. This is because those parts of LLDB rely on GetStream() to use the file, and that in turn relies on calling fdopen on the descriptor. When calling fdopen, GetStream relies on m_options to determine the access mode. If m_options has never been set, GetStream() will fail. This patch adds options as a required argument to File::SetDescriptor and the corresponding constructor. Patch by: Lawrence D'Anna Differential revision: https://reviews.llvm.org/D67792 llvm-svn: 372652
* [Host] File::GetWaitableHandle() should call fileno()Jonas Devlieghere2019-09-231-1/+1
| | | | | | | | | | | | If the file has m_stream, it may not have a m_descriptor. GetWaitableHandle() should call GetDescriptor(), which will call fileno(), so it will get waitable descriptor whenever one is available. Patch by: Lawrence D'Anna Differential revision: https://reviews.llvm.org/D67789 llvm-svn: 372644
* [LLDB] Check for _WIN32 instead of _MSC_VER for code specific to windows in ↵Martin Storsjo2019-09-231-1/+1
| | | | | | | | | | | general These ifdefs contain code that isn't specific to MSVC but useful for any windows target, like MinGW. Differential Revision: https://reviews.llvm.org/D67893 llvm-svn: 372592
* [LLDB] Cast -1 (as invalid socket) to the socket type before comparingMartin Storsjo2019-09-211-4/+4
| | | | | | | | | | This silences warnings about comparison of integers between unsigned long long (which is what the Windows SOCKET type is) and signed int when building in MinGW mode. Differential Revision: https://reviews.llvm.org/D67863 llvm-svn: 372486
* [lldb][NFC] Make ArgEntry::quote private and provide a getterRaphael Isemann2019-09-131-1/+1
| | | | llvm-svn: 371823
* [lldb] Fix log statement in Socket::WriteRaphael Isemann2019-09-041-1/+2
| | | | | | | | We change num_bytes in this method, so this doesn't actually log the parameter that we called the function with. No test as we don't test logging code. llvm-svn: 370887
* [lldb][NFC] Remove unused overload of File::ReadRaphael Isemann2019-09-031-44/+0
| | | | | | | | | | | | | | | | Summary: It's neither used or tested here and in swift-lldb, so let's get rid of it. Reviewers: #lldb, davide Reviewed By: #lldb, davide Subscribers: davide, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D67116 llvm-svn: 370802
* [lldb] Allow partial completions to fix directory completion.Raphael Isemann2019-08-271-0/+6
| | | | | | | | | | | | On the command line we usually insert a space after a completion to indicate that the completion was successful. After the completion API refactoring, this also happens with directories which essentially breaks file path completion (as adding a space terminates the path and starts a new arg). This patch restores the old behavior by again allowing partial completions. Also extends the iohandler and SB API tests as the implementation for this is different in Editline and SB API. llvm-svn: 370043
* Fix an unused variable warning in no-assert buildsPavel Labath2019-08-271-0/+1
| | | | llvm-svn: 370026
* [lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and ↵Raphael Isemann2019-08-221-72/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | remove any undocumented/redundant return values Summary: We still have some leftovers of the old completion API in the internals of LLDB that haven't been replaced by the new CompletionRequest. These leftovers are: * The return values (int/size_t) in all completion functions. * Our result array that starts indexing at 1. * `WordComplete` mode. I didn't replace them back then because it's tricky to figure out what exactly they are used for and the completion code is relatively untested. I finally got around to writing more tests for the API and understanding the semantics, so I think it's a good time to get rid of them. A few words why those things should be removed/replaced: * The return values are really cryptic, partly redundant and rarely documented. They are also completely ignored by Xcode, so whatever information they contain will end up breaking Xcode's completion mechanism. They are also partly impossible to even implement as we assign negative values special meaning and our completion API sometimes returns size_t. Completion functions are supposed to return -2 to rewrite the current line. We seem to use this in some untested code path to expand the history repeat character to the full command, but I haven't figured out why that doesn't work at the moment. Completion functions return -1 to 'insert the completion character', but that isn't implemented (even though we seem to activate this feature in LLDB sometimes). All positive values have to match the number of results. This is obviously just redundant information as the user can just look at the result list to get that information (which is what Xcode does). * The result array that starts indexing at 1 is obviously unexpected. The first element of the array is reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is that we calculate this to make the life of the API caller easier, but obviously forcing people to have 1-based indices is not helpful (or even worse, forces them to manually copy the results to make it 0-based like Xcode has to do). * The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The idea is that we let the top-level API know that we just provided a full completion. Interestingly we `WordComplete` is just a single bool that somehow represents all N completions. And we always provide full completions in LLDB, so in theory it should always be true. The only use it currently serves is providing redundant information about whether we have a single definitive completion or not (which we already know from the number of results we get). This patch essentially removes `WordComplete` mode and makes the result array indexed from 0. It also removes all return values from all internal completion functions. The only non-redundant information they contain is about rewriting the current line (which is broken), so that functionality was moved to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)` to do the same. For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we didn't even implement them in the Editline handler (e.g. -1). I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code, but I would prefer doing this in follow-up NFC commits Reviewers: JDevlieghere Reviewed By: JDevlieghere Subscribers: arphaman, abidh, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D66536 llvm-svn: 369624
* [Utility] Reimplement RegularExpression on top of llvm::RegexJonas Devlieghere2019-08-161-19/+17
| | | | | | | | | | | | | | | Originally I wanted to remove the RegularExpression class in Utility and replace it with llvm::Regex. However, during that transition I noticed that there are several places where need the regular expression string. So instead I propose to keep the RegularExpression class and make it a thin wrapper around llvm::Regex. This patch also removes the workaround for empty regular expressions. The result is that we are now (more or less) POSIX conformant. Differential revision: https://reviews.llvm.org/D66174 llvm-svn: 369153
* [lldb][NFC] Refactor remaining completion logic to use CompletionRequestsRaphael Isemann2019-08-151-3/+12
| | | | | | | | | | | | | | | | | | | | This patch moves the remaining completion functions from the old completion API (that used several variables) to just passing a single CompletionRequest. This is for the most part a simple change as we just replace the old arguments with a single CompletionRequest argument. There are a few places where I had to create new CompletionRequests in the called functions as CompletionRequests itself are immutable and don't expose their internal match list anymore. This means that if a function wanted to change the CompletionRequest or directly access the result list, we need to work around this by creating a new CompletionRequest and a temporary match/description list. Preparation work for rdar://53769355 llvm-svn: 369000
* [LLDB] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-4/+4
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368933
* [CompletionRequest] Remove unimplemented members.Jonas Devlieghere2019-07-311-2/+0
| | | | | | | | | | Completion requests have two fields that are essentially unimplemented: `m_match_start_point` and `m_max_return_elements`. This would've been okay, if it wasn't for the fact that this caused a bunch of useless parameters to be passed around. Occasionally there would be a comment or assert saying that they are not supported. This patch removes them. llvm-svn: 367385
* [Reproducers] Pass FileCollector around as a shared_ptr (NFC)Jonas Devlieghere2019-07-291-1/+1
| | | | | | | | | | | Instead of passing the FileCollector around as a reference or raw pointer, use a shared_ptr. This change's motivation is twofold. First it adds compatibility for the newly added `FileCollectorFileSystem`. Secondly, it addresses a lifetime issue we only see when LLDB is used from Xcode, where a reference to the FileCollector outlives the reproducer instance. llvm-svn: 367258
* [FileCollector] Remove LLDB shim around llvm::FileCollector (NFC)Jonas Devlieghere2019-07-251-2/+2
| | | | | | | | The FileCollector got lifted into LLVM and a shim was introduced in LLDB to keep the old API that takes FileSpecs. This patch removes that shim and converts the arguments in place. llvm-svn: 366975
* [FileSystem] Fix ambiguous symbol on Windows.Jonas Devlieghere2019-07-251-1/+1
| | | | | | | The using declarations make FileCollector ambiguous. Specify that FileSystem takes an lldb_private::FileCollector. llvm-svn: 366974
* [FileCollector] Change coding style from LLDB to LLVM (NFC)Jonas Devlieghere2019-07-251-2/+2
| | | | | | | | This patch changes the coding style of the FileCollector from the LLDB to the LLVM coding style. Alex recently lifted it into LLVM and I volunteered to do the conversion. llvm-svn: 366966
* [Logging] Replace Log::Printf with LLDB_LOG macro (NFC)Jonas Devlieghere2019-07-248-89/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch replaces explicit calls to log::Printf with the new LLDB_LOGF macro. The macro is similar to LLDB_LOG but supports printf-style format strings, instead of formatv-style format strings. So instead of writing: if (log) log->Printf("%s\n", str); You'd write: LLDB_LOG(log, "%s\n", str); This change was done mechanically with the command below. I replaced the spurious if-checks with vim, since I know how to do multi-line replacements with it. find . -type f -name '*.cpp' -exec \ sed -i '' -E 's/log->Printf\(/LLDB_LOGF\(log, /g' "{}" + Differential revision: https://reviews.llvm.org/D65128 llvm-svn: 366936
* Revert "Revert "Add ReadCStringFromMemory for faster string reads""Antonio Afonso2019-07-231-0/+54
| | | | | | This reverts commit 9c10b620c0619611dfe062216459431955ac4801. llvm-svn: 366848
* Options: Reduce code duplicationPavel Labath2019-07-101-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: While investigating breakages caused by D63110, I noticed we were building the short options strings in three places. Some of them used a leading ':' to detect missing arguments, and some didn't. This was the indirect cause of D63110. Here, I move the common code into a utility function. Also, unify the code which appends the sentinel value at the end of the option vector, and make it harder for users to pass invalid argc-argv combos to getopt (another component of D63110) by having the OptionParser::Parse function take a (Mutable)ArrayRef. This unification has uncovered that we don't handle missing arguments while building aliases, However, it's not possible to write an effective test for this, as right now it is not possible to return an error out of the alias parsing code (which means we are printing the generic "failure" message even after this patch). Reviewers: mgorny, aprantl Reviewed By: mgorny Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D63770 llvm-svn: 365665
OpenPOWER on IntegriCloud