aboutsummaryrefslogtreecommitdiff
path: root/source/Host
AgeCommit message (Collapse)Author
2019-10-17delete SWIG typemaps for FILE*Lawrence D'Anna
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@375073 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-16Add arm64_32 support to lldb, an ILP32 codegen Jason Molenda
that runs on arm64 ISA targets, specifically Apple watches. Differential Revision: https://reviews.llvm.org/D68858 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@375032 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-15SBFile::GetFile: convert SBFile back into python native files.Lawrence D'Anna
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@374911 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-15[lldb-server/android] Show more processes by relaxing some checksWalter Erquinigo
By default `platform process list` only shows the processes of the current user that lldb-server can parse. There are several problems: - apk programs don't have an executable file. They instead use a package name as identifier. We should show them instead. - each apk also runs under a different user. That's how android works - because of the user permission, some files like /proc/<pid>/{environ,exe} can't be read. This results in a very small process list. This is a local run on my machine ``` (lldb) platform process list 2 matching processes were found on "remote-android" PID PARENT USER TRIPLE NAME ====== ====== ========== ======================== ============================ 23291 3177 aarch64-unknown-linux-android sh 23301 23291 aarch64-unknown-linux-android lldb-server ``` However, I have 700 processes running at this time. By implementing a few fallbacks for android, I've expanded this list to 202, filtering out kernel processes, which would presumably appear in this list if the device was rooted. ``` (lldb) platform process list 202 matching processes were found on "remote-android" PID PARENT USER TRIPLE NAME ====== ====== ========== ======================== ============================ ... 12647 3208 aarch64-unknown-linux-android sh 12649 12647 aarch64-unknown-linux-android lldb-server 12653 982 com.samsung.faceservice 13185 982 com.samsung.vvm 15899 982 com.samsung.android.spay 16220 982 com.sec.spp.push 17126 982 com.sec.spp.push:RemoteDlcProcess 19772 983 com.android.chrome 20209 982 com.samsung.cmh:CMH 20380 982 com.google.android.inputmethod.latin 20879 982 com.samsung.android.oneconnect:Receiver 21212 983 com.tencent.mm 24459 1 aarch64-unknown-linux-android wpa_supplicant 25974 982 com.samsung.android.contacts 26293 982 com.samsung.android.messaging 28714 982 com.samsung.android.dialer 31605 982 com.samsung.android.MtpApplication 32256 982 com.bezobidny ``` Something to notice is that the architecture is unkonwn for all apks. And that's fine, because run-as would be required to gather this information and that would make this entire functionality massively slow. There are still several improvements to make here, like displaying actual user names, which I'll try to do in a following diff. Note: Regarding overall apk debugging support from lldb. I'm planning on having lldb spawn lldb-server by itself with the correct user, so that everything works well. The initial lldb-server used for connecting to the remote platform can be reused for such purpose. Furthermore, eventually lldb could also launch that initial lldb-server on its own. Differential Revision: D68289 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@374853 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-14Revert "fix"Walter Erquinigo
This reverts commit d8af64c9a0228301f6fd0e1c841e4abe0b6f4801. git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@374852 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-14fixWalter Erquinigo
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@374846 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-14uint32_t options -> File::OpenOptions optionsLawrence D'Anna
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@374817 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-11ProcessInstanceInfoMatch: Don't match processes with no name if a name match ↵Pavel Labath
was requested, take 2 Summary: The previous attempt at making nameless process not match when searching for a given name failed because the macos implementation was depending on this detail in its partial matching strategy. Doing partial matching to avoid expensive lookups is a perfectly valid thing to do, the way it was implemented seems somewhat unexpected. This patch implements it differently by providing special methods in the ProcessInstanceInfoMatch which match only a subset of fields, and changes mac host code to use those instead. Then, it re-applies r373925 to get make the ProcessInstanceInfoMatch with a name *not* match a nameless process. Reviewers: JDevlieghere, teemperor, jingham Subscribers: wallace, lldb-commits Differential Revision: https://reviews.llvm.org/D68631 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@374529 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-10File: Handle more cases in GetOptionsFromModePavel Labath
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. git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@374331 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-08Simplify LZMA decoding by using ArrayRef::take_backKonrad Kleine
Summary: Follow-up for D66791#inline-616303 Reviewers: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68647 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@374069 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-08Revert "[lldb-server/android] Show more processes and package name when ↵Pavel Labath
necessary" This reverts r373758 because it causes several to test to be flaky (= failing ~90% of the time) on linux. git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@374030 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-07[lldb][ELF] Read symbols from .gnu_debugdata sect.Konrad Kleine
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@373891 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-04[Host] Return status directly from RunShellCommandJonas Devlieghere
Thanks for catching this, Pavel! git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@373783 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-04[Host] Don't discard return value from RunShellCommandJonas Devlieghere
The recent change to expand arguments with the user's shell sometimes caused a timeout and the error was not propagated. git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@373776 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-04[process info] Remove assert in DoGetGroupNameWalter Erquinigo
Summary: Disabling this assert prevents lldb-server from crashing, which prevents it from finding the user and group names of a given process list. Before this change, the process list didn't contain names: ``` PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE ARGUMENTS ====== ====== ========== ========== ========== ========== ============================== ============================ 27585 982 10098 10098 10098 10098 com.LogiaGroup.LogiaDeck 27623 982 10098 10098 10098 10098 com.digitalturbine.ignite.suspend.DataUsageRecorderService 28024 982 10199 10199 10199 10199 com.google.vr.vrcore 28061 983 10353 10353 10353 10353 com.instagram.android:videoplayer 28121 982 10045 10045 10045 10045 com.sec.spp.push 28325 982 10247 10247 10247 10247 com.facebook.orca 28714 982 10367 10367 10367 10367 com.samsung.android.dialer 29867 3208 2000 2000 2000 2000 aarch64-unknown-linux-android /system/bin/sh-c /data/local/tmp/lldb-server platform --listen *:5557 --server --log-file /data/local/tmp/logs --log-channels gdb-remote all --log-channels lldb all ``` After this change, the list looks much better ``` PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE ARGUMENTS ====== ====== ========== ========== ========== ========== ============================== ============================ 24459 1 wifi 1010 wifi 1010 aarch64-unknown-linux-android /vendor/bin/hw/wpa_supplicant-O/data/vendor/wifi/wpa/sockets -puse_p2p_group_interface=1 -g@android:wpa_wlan0 25098 982 u0_a42 10042 u0_a42 10042 com.samsung.android.messaging 25442 982 u0_a65 10065 u0_a65 10065 com.samsung.android.mobileservice 25974 982 u0_a9 10009 u0_a9 10009 com.samsung.android.contacts 26377 982 radio 1001 radio 1001 com.samsung.android.incallui 26390 983 u0_a26 10026 u0_a26 10026 com.samsung.android.game.gametools 26876 983 u0_a306 10306 u0_a306 10306 com.tencent.mm:push ``` Reviewers: clayborg,aadsm,xiaobai,labath Subscribers: git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@373760 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-04[lldb-server/android] Show more processes and package name when necessaryWalter Erquinigo
Summary: By default `platform process list` only shows the processes of the current user that lldb-server can parse. There are several problems: - apk programs don't have an executable file. They instead use a package name as identifier. - each apk also runs under a different user. That's how android works - because of the user permission, some files like /proc/<pid>/{environ,exe} can't be read. This results in a very small process list. This is a local run on my machine ``` (lldb) platform process list 2 matching processes were found on "remote-android" PID PARENT USER TRIPLE NAME ====== ====== ========== ======================== ============================ 23291 3177 aarch64-unknown-linux-android sh 23301 23291 aarch64-unknown-linux-android lldb-server ``` However, I have 700 processes running at this time. By implementing a few fallbacks for android, I've expanded this list to 202, filtering out kernel processes, which would presumably appear in this list if the device was rooted. ``` (lldb) platform process list 202 matching processes were found on "remote-android" PID PARENT USER TRIPLE NAME ====== ====== ========== ======================== ============================ ... 12647 3208 aarch64-unknown-linux-android sh 12649 12647 aarch64-unknown-linux-android lldb-server 12653 982 com.samsung.faceservice 13185 982 com.samsung.vvm 15899 982 com.samsung.android.spay 16220 982 com.sec.spp.push 17126 982 com.sec.spp.push:RemoteDlcProcess 19772 983 com.android.chrome 20209 982 com.samsung.cmh:CMH 20380 982 com.google.android.inputmethod.latin 20879 982 com.samsung.android.oneconnect:Receiver 21212 983 com.tencent.mm 24459 1 aarch64-unknown-linux-android wpa_supplicant 25974 982 com.samsung.android.contacts 26293 982 com.samsung.android.messaging 28714 982 com.samsung.android.dialer 31605 982 com.samsung.android.MtpApplication 32256 982 com.bezobidny ``` Something to notice is that the architecture is unkonwn for all apks. And that's fine, because run-as would be required to gather this information and that would make this entire functionality massively slow. There are still several improvements to make here, like displaying actual user names, which I'll try to do in a following diff. Note: Regarding overall apk debugging support from lldb. I'm planning on having lldb spawn lldb-server by itself with the correct user, so that everything works well. The initial lldb-server used for connecting to the remote platform can be reused for such purpose. Furthermore, eventually lldb could also launch that initial lldb-server on its own. Reviewers: clayborg, aadsm, labath, xiaobai Subscribers: srhines, krytarowski, kristof.beyls, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68289 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@373758 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-03[Host] Return the user's shell from GetDefaultShellJonas Devlieghere
LLDB handles shell expansion by running lldb-argdumper under a shell. Currently, this is always /bin/sh on POSIX. This potentially leads to different behavior between lldb and the user's current shell. Here's an example of different expansions between shells: $ /bin/bash -c 'echo -config={Options:[{key:foo_key,value:foo_value}]}' -config={Options:[key:foo_key]} -config={Options:[value:foo_value]} $ /bin/zsh -c 'echo -config={Options:[{key:foo_key,value:foo_value}]}' zsh:1: no matches found: -config={Options:[key:foo_key]} $ /bin/sh -c 'echo -config={Options:[{key:foo_key,value:foo_value}]}' -config={Options:[key:foo_key]} -config={Options:[value:foo_value]} $ /bin/fish -c 'echo -config={Options:[{key:foo_key,value:foo_value}]}' -config=Options:[key:foo_key] -config=Options:[value:foo_value] To reduce surprises, this patch returns the user's current shell. It first looks at the SHELL environment variable. If that isn't set, it'll ask for the user's default shell. Only if that fails, we'll fallback to /bin/sh, which should always be available. Differential revision: https://reviews.llvm.org/D68316 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@373644 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-03factor out an abstract base class for FileLawrence D'Anna
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@373564 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-03new api class: SBFileLawrence D'Anna
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@373562 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-02[ARM64] XPC services are unsupported on device.Davide Italiano
While around, clean up support for a 8 years old OS. <rdar://problem/55916729> git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@373510 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-01File::Clear() -> File::TakeStreamAndClear()Lawrence D'Anna
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@373285 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-27refactor: move IOObject::m_should_close_fd into subclassesLawrence D'Anna
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@373126 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-27remove File::SetStream(), make new files instead.Lawrence D'Anna
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@373090 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-26Convert FileSystem::Open() to return Expected<FileUP>Lawrence D'Anna
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@373003 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-25Revert r372788 "Host: use the platform identifiers from LLVM (NFC)"Hans Wennborg
> Use symbolic constants for the platform identifiers rather than replicating them > locally. This broke the build of LLDB on Windows, see http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/9182 which fails with e.g. E:\build_slave\lldb-x64-windows-ninja\llvm\include\llvm/BinaryFormat/COFF.h(96): error C2059: syntax error: 'constant' E:\build_slave\lldb-x64-windows-ninja\llvm\include\llvm/BinaryFormat/COFF.h(96): error C3805: 'constant': unexpected token, expected either '}' or a ',' E:\build_slave\lldb-x64-windows-ninja\llvm\include\llvm/BinaryFormat/COFF.h(128): error C2059: syntax error: 'constant' ... git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@372847 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-24Host: use the platform identifiers from LLVM (NFC)Saleem Abdulrasool
Use symbolic constants for the platform identifiers rather than replicating them locally. git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@372788 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-23[LLDB] [Windows] Map COFF ARM machine ids to the right triple architecturesMartin Storsjo
Differential Revision: https://reviews.llvm.org/D67913 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@372658 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-23File::SetDescriptor() should require optionsJonas Devlieghere
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@372652 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-23[Host] File::GetWaitableHandle() should call fileno()Jonas Devlieghere
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@372644 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-23[LLDB] Check for _WIN32 instead of _MSC_VER for code specific to windows in ↵Martin Storsjo
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@372592 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-23[LLDB] Remove a now redundant windows specific workaroundMartin Storsjo
vsnprintf(NULL, 0, ...) works for measuring the needed string size on all supported Windows variants; it's supported since at least MSVC 2015 (and LLVM requires a newer version than that), and works on both msvcrt.dll (since at least XP) and UCRT with MinGW. The previous use of ifdefs was wrong as well, as __MINGW64__ only is defined for 64 bit targets, and the define without trailing underscores is never defined automatically (neither by clang nor by gcc). Differential Revision: https://reviews.llvm.org/D67861 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@372591 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-23[LLDB] Add a void* cast when passing object pointers to printf %pMartin Storsjo
This fixes build warnings in MinGW mode. Also remove leftover if (log) {} around the log macro. Differential Revision: https://reviews.llvm.org/D67896 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@372590 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-21[LLDB] Cast -1 (as invalid socket) to the socket type before comparingMartin Storsjo
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@372486 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-13Fix error in ProcessLauncherWindows.cppAdrian McCarthy
Restored missing parens on a function call. git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@371882 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-13[lldb][NFC] Make ArgEntry::quote private and provide a getterRaphael Isemann
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@371823 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-11[LLDB] Do not try to canonicalize gethostname() resultDavid Zarzycki
This code is trying too hard and failing. Either the result of gethostname() is canonical or it is not. If it is not, then trying to canonicalize it is – for various reasons – a lost cause. For example, a given machine might have multiple network interfaces with multiple addresses per interface, each with a different canonical name. Separably, the result of HostInfoPosix::GetHostname() and latency thereof shouldn't depend on whether networking is up or down or what network the machine happened to be attached to at any given moment (like a laptop that travels between work and home). https://reviews.llvm.org/D67230 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@371596 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-10[LLDB] FreeBSD fix new SetFile call.David Carlier
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@371491 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-10[Utility] Replace `lldb_private::CleanUp` by `llvm::scope_exit`Jonas Devlieghere
This removes the CleanUp class and replaces its usages with llvm's ScopeExit, which has similar semantics. Differential revision: https://reviews.llvm.org/D67378 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@371474 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-09LLDB - Simplify GetProgramFileSpecDavid Carlier
Reviewers: zturner, emaste Reviewed By: emaste Differential Revision: https://reviews.llvm.org/D46518 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@371417 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-06Remove call to obsolete gethostbyname, using getaddrinfoSerge Guelton
Differential Revision: https://reviews.llvm.org/D67230 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@371195 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-04Upstream macCatalyst support in debugserver and the macOS dynamic loaderAdrian Prantl
plugin. Unfortunately the test is currently XFAILed because of missing changes to the clang driver. Differential Revision: https://reviews.llvm.org/D67124 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@370931 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-04[lldb] Fix log statement in Socket::WriteRaphael Isemann
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. git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@370887 91177308-0d34-0410-b5e6-96231b3b80d8
2019-09-03[lldb][NFC] Remove unused overload of File::ReadRaphael Isemann
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@370802 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-27[lldb] Allow partial completions to fix directory completion.Raphael Isemann
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. git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@370043 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-27Fix an unused variable warning in no-assert buildsPavel Labath
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@370026 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-27[ConnectionFileDescriptor] Add shutdown check in ::Write.Jonas Devlieghere
The disconnect method sets the shutdown flag to true. This currently only prevents any reads from happening, but not writes, which is incorrect. Presumably this was just an oversight when adding synchronization to the class. This adds the same shutdown check to the Write method. Over-the-shoulder reviewed by Jim! git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@370002 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-22[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and ↵Raphael Isemann
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@369624 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-16[Utility] Reimplement RegularExpression on top of llvm::RegexJonas Devlieghere
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@369153 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-15[lldb][NFC] Refactor remaining completion logic to use CompletionRequestsRaphael Isemann
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@369000 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-14[LLDB] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@368933 91177308-0d34-0410-b5e6-96231b3b80d8