summaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp
AgeCommit message (Collapse)Author
2015-06-24Remove old local-only linux debugging codePavel Labath
Summary: Currently, the local-only path fails about 50% of the tests, which means that: a) nobody is using it; and b) the remote debugging path is much more stable. This commit removes the local-only linux debugging code (ProcessLinux) and makes remote-loopback the only way to debug local applications (the same architecture as OSX). The ProcessPOSIX code is moved to the FreeBSD directory, which is now the only user of this class. Hopefully, FreeBSD will soon move to the new architecture as well and then this code can be removed completely. Test Plan: Test suite passes via remote stub. Reviewers: emaste, vharron, ovyalov, clayborg Subscribers: tberghammer, emaste, lldb-commits Differential Revision: http://reviews.llvm.org/D10661 llvm-svn: 240543
2015-05-29Refactor many file functions to use FileSpec over strings.Chaoren Lin
Summary: This should solve the issue of sending denormalized paths over gdb-remote if we stick to GetPath(false) in GDBRemoteCommunicationClient, and let the server handle any denormalization. Reviewers: ovyalov, zturner, vharron, clayborg Reviewed By: clayborg Subscribers: tberghammer, emaste, lldb-commits Differential Revision: http://reviews.llvm.org/D9728 llvm-svn: 238604
2015-05-29Don't #include "lldb-python.h" from anywhere.Zachary Turner
Since interaction with the python interpreter is moving towards being more isolated, we won't be able to include this header from normal files anymore, all includes of it should be localized to the python library which will live under source/bindings/API/Python after a future patch. None of the files that were including this header actually depended on it anyway, so it was just a dead include in every single instance. llvm-svn: 238581
2015-05-16Fixed arm64 build errorVince Harron
llvm-svn: 237493
2015-05-15This patch adds support for setting/clearing hardware watchpoints and ↵Omair Javaid
breakpoints on AArch64 (Arm v8) 64-bit hardware. http://reviews.llvm.org/D9706 llvm-svn: 237419
2015-05-13Fixed a ton of gcc compile warningsVince Harron
Removed some unused variables, added some consts, changed some casts to const_cast. I don't think any of these changes are very controversial. Differential Revision: http://reviews.llvm.org/D9674 llvm-svn: 237218
2015-05-12Get lldb-server building on android-9Vince Harron
Build lldb-server with an android-9 sysroot. llvm-svn: 237078
2015-03-31Move several plugin to its own namespaceTamas Berghammer
Affected paths: * Plugins/Platform/Android/* * Plugins/Platform/Linux/* * Plugins/Platform/gdb-server/* * Plugins/Process/Linux/* * Plugins/Process/gdb-remote/* Differential revision: http://reviews.llvm.org/D8654 llvm-svn: 233679
2015-03-25Remove virtual and add override for lots of function.Tamas Berghammer
Effeted pathes: * Host/posix/* * Platform/gdb-server/* * Process/Linux/* * Process/POSIX/* llvm-svn: 233193
2015-03-13Create NativeRegisterContext for android-arm64Tamas Berghammer
Differential revision: http://reviews.llvm.org/D8058 llvm-svn: 232160
2015-03-13Add code to exit the NativeProcessLinux Monitor thread on androidTamas Berghammer
This CL change the logic used to terminate the monitor thread of NativeProcessLinux to use a signal instead of pthread_cancel as pthread_cancel is not supported on android. Differential revision: http://reviews.llvm.org/D8205 llvm-svn: 232155
2015-03-03Further reduce the header footprint of Process.hZachary Turner
No functional change here, only deletes unnecessary headers and moves one function's body from the .h file to the .cpp. llvm-svn: 231145
2015-02-28Casting pid to ::pid_t when invoking syscall.Chaoren Lin
Summary: syscalls involving pid/tid on 32 bit binaries are failing with "Invalid argument" because the uint64_t arguments are too wide. Reviewers: clayborg, ovyalov, sivachandra Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D7963 llvm-svn: 230817
2015-02-06Fix TestProcesslaunch regression caused by D7372Pavel Labath
Summary: After closing all the leaked file descriptors to the inferior tty, the following problem occured: - when stdin, stdout and stderr are redirected, there are no slave descriptors open (which is good) - lldb has a reader thread, which attempts to read from the master end of the tty - this thread receives an EOF - in response, it closes it's master end - as this is the last open file descriptor for the master end, this deletes the tty and sends SIGHUP to the inferior (this is bad) I fix this problem by making sure the master end remains open for the duration of the inferior process by storing a copy of the file descriptor in ProcessMonitor. I create a copy to avoid ownership issues with the reading thread. Reviewers: ovyalov, emaste Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D7440 llvm-svn: 228391
2015-02-06Fix build of lldb-gdbserver and lldb-platform for android (arm32, x86)Tamas Berghammer
* Fix cmake script for android x86 * Reorder includes to avoid collision between system macros and local variables in clang framework Differential Revision: http://reviews.llvm.org/D7435 llvm-svn: 228388
2015-02-04Avoid leakage of file descriptors in LLDB and LLGSPavel Labath
Summary: Both LLDB and LLGS are leaking file descriptors into the debugged process. This plugs the leak by closing the unneeded descriptors. In one case I use O_CLOEXEC, which I hope is supported on relevant platforms. I also added a regression test and plugged a fd leak in dosep.py. Reviewers: vharron, clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D7372 llvm-svn: 228130
2015-02-03Share crash information between LLGS and local POSIX debugging withChaoren Lin
CrashReason class. Deliver crash information from LLGS to lldb via description field of thread stop packet. llvm-svn: 227926
2014-11-08LLGS Android target support - for Andy Chien : http://reviews.llvm.org/D6166Shawn Best
llvm-svn: 221570
2014-09-27Enable llgs to build against experimental Android AOSP ↵Todd Fiala
lldb/llvm/clang/compiler-rt repos. See http://reviews.llvm.org/D5495 for more details. These are changes that are part of an effort to support building llgs, within the AOSP source tree, using the Android.mk build system, when using the llvm/clang/lldb git repos from AOSP replaced with the experimental ones currently in github.com/tfiala/aosp-{llvm,clang,lldb,compiler-rt}. llvm-svn: 218568
2014-09-23Fix up the HostThread interface, making the interface simpler.Zachary Turner
Reviewed by: Greg Clayton Differential Revision: http://reviews.llvm.org/D5417 llvm-svn: 218325
2014-09-19Fix typo in Linux ASLR logging.Todd Fiala
llvm-svn: 218133
2014-09-12lldb fix ARM64 register accessTodd Fiala
Apparently, PEEKUSER/POKEUSER is something x86 specific, so I had to rework it for AArch64. This fixes assertion that occurs whenever lldb started on AArch64 device tried to read PC register (or any other register) See http://reviews.llvm.org/D5232 for more details. Change by Paul Osmialowski. llvm-svn: 217691
2014-09-09Create a HostThread abstraction.Zachary Turner
This patch moves creates a thread abstraction that represents a thread running inside the LLDB process. This is a replacement for otherwise using lldb::thread_t, and provides a platform agnostic interface to managing these threads. Differential Revision: http://reviews.llvm.org/D5198 Reviewed by: Jim Ingham llvm-svn: 217460
2014-09-04Fix build break on Ubuntu 12.04 with ARM64 changes.Todd Fiala
See http://llvm.org/bugs/show_bug.cgi?id=20824 for more details. Tested: Ubuntu 12.04 x86_64, gcc-4.9.1-built lldb Ubuntu 14.04 x86_64, clang-3.5-build lldb llvm-svn: 217169
2014-08-27Add Linux support for get thread area on ARM64 using ProcessMonitor debugging.Todd Fiala
See http://reviews.llvm.org/D5073. Change by Paul Osmialowski. llvm-svn: 216553
2014-08-21Enable more Linux aarch64 PTRACE support for local and remote debugging.Todd Fiala
See http://reviews.llvm.org/D4803 for more details. Change by Paul Osmialowski. llvm-svn: 216185
2014-08-17Fix Linux to respect ASLR settings when launching processes to debug locally ↵Todd Fiala
and remotely. See the following links for details: http://llvm.org/bugs/show_bug.cgi?id=20658 See http://reviews.llvm.org/D4941 llvm-svn: 215822
2014-07-20linux process: silence GCC switch coverage warningSaleem Abdulrasool
Add missing entry for eExecMessage message type to silence GCC switch coverage warning. llvm-svn: 213470
2014-07-01Use native ::pid_t in Linux ProcessMonitor (local debugging).Todd Fiala
There were a few places where we were not catching the possibility of negative error codes in waitpid() calls. This change fixes those remaining after the llgs branch fixes to ProcessMonitor. Change by Shawn Best. llvm-svn: 212107
2014-06-30Add lldb-gdbserver support for Linux x86_64.Todd Fiala
This change brings in lldb-gdbserver (llgs) specifically for Linux x86_64. (More architectures coming soon). Not every debugserver option is covered yet. Currently the lldb-gdbserver command line can start unattached, start attached to a pid (process-name attach not supported yet), or accept lldb attaching and launching a process or connecting by process id. The history of this large change can be found here: https://github.com/tfiala/lldb/tree/dev-tfiala-native-protocol-linux-x86_64 Until mid/late April, I was not sharing the work and continued to rebase it off of head (developed via id tfiala@google.com). I switched over to user todd.fiala@gmail.com in the middle, and once I went to github, I did merges rather than rebasing so I could share with others. llvm-svn: 212069
2014-06-23lldb: deal with non-portable PTRACE-related constantsTodd Fiala
See http://reviews.llvm.org/D4091 for details. Change by Paul Osmialowski. llvm-svn: 211503
2014-06-16Move x86-specific struct user code for Linux ProcessMonitor behind #define ↵Todd Fiala
guards. See http://reviews.llvm.org/D4092 for details. Change by Paul Osmialowski. (Minor tweaks to the comment by Todd.) llvm-svn: 211026
2014-04-02Use getpgid() with waitpid() in case the process pgid is not equal to its ↵Andrew MacPherson
pid, as is the case with a forked subprocess. Also a couple of fixes for unit test failures from Todd Fiala. llvm-svn: 205405
2014-04-02sanitise sign comparisonsSaleem Abdulrasool
This is a mechanical change addressing the various sign comparison warnings that are identified by both clang and gcc. This helps cleanup some of the warning spew that occurs during builds. llvm-svn: 205390
2014-04-01Implement ProcessMonitor::Kill for LinuxEd Maste
On FreeBSD ptrace(PT_KILL) is used to terminate the traced process (as if PT_CONTINUE had been used with SIGKILL as the signal to be delivered), and is the desired behaviour for ProcessPOSIX::DoDestroy. On Linux, after ptrace(PTRACE_KILL) the traced process still exists and can be interrogated. It is only upon resume that it exits as though it received SIGKILL. As the Linux PTRACE_KILL behaviour is not used by LLDB, rename BringProcessIntoLimbo to Kill, and change the implementation to simply call kill() instead of using ptrace. Thanks to Todd F for testing (Ubuntu 12.04, gcc 4.8.2). Sponsored by: DARPA, AFRL Differential Revision: http://llvm-reviews.chandlerc.com/D3159 llvm-svn: 205337
2014-03-17Correct copy-and-pasted comments for DetachOperationEd Maste
llvm-svn: 204064
2014-03-04Get Linux i386 running.Todd Fiala
This change uses a fixed known offset for the Linux i386 DR0 register. This change also undoes the 32-bit wordsize change from r169645 that revolved around being 32-bit/64-bit friendly in WriteRegOperation::Execute within the Linux ProcessMonitor.cpp. I ran all the tests on x86_64 Linux with no failures. I also ran some simple tests with 32-bit Linux exe on x86_64 host and 32-bit linux exe on i686 32-bit host and these worked fine. Note (from Todd): the UserData struct in the Linux i386 register context (only used by Linux i386 host running Linux 32-bit inferior) is out of sync with what shows up in the sys/user.h for an 32-bit Linux build (per an earlier change of mine to make it look more like x86_64 host running x86 exe). I think we should (1) make i386 Linux targets run using the same register context (and correct ones) on i386 and x86_64 linux hosts if that is possible, and (2) we could use some tests around the register handling, particularly to verify things like DR0 registers are in the right spots on host/target combos that we can verify vs. known correct values. Change by Matthew Gardiner. llvm-svn: 202887
2014-02-27Fix linux x86 debugging on a linux x86 host (32-bit on 32-bit).Todd Fiala
This change fixes up issues with specifying the size of the i386 register infos for FPU registers. The bug was that for the i386 register context, the size of the FPU registers were still being computed based on the x86_64 FXSAVE structure. This change permits the FPR_SIZE macro to optionally be defined outside of RegisterInfos_i386.h, which RegisterContextLinux_i386.cpp does properly. It redefines the FPR_i386 structure with all the accessible parts that RegisterInfos_i386.h wants to see, which we had not done before when we made the overall size of the structure properly sized a recently. This change also modifies POSIXThread to create a RegisterContextLinux_i386 only when the host is 32-bit; otherwise, it uses the RegisterContextLinux_x86_64, which works properly for 32-bit and 64-bit inferiors on a 64-bit host. I tested this debugging a Linux x86 exe on an x86 host (Ubuntu 13.10 x86), and debugging a Linux x86 exe and a Linux x86-64 exe on an x86-64 host (Ubuntu 12.04 LTS). Those cases all worked. Thanks to Matthew Gardiner who discoverd may key insights into tracking down the issue. The motivation for this change and some of the code originates from him via this thread: http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20140224/010554.html llvm-svn: 202428
2014-02-24Fix ptrace log on i386 and include return valueEd Maste
Patch by Matthew Gardiner llvm-svn: 202036
2014-01-27Fix group stop signal handling issue on Linux.Todd Fiala
This patch addresses a bug where in a multi-threaded program a new signal from the inferior may be received before all group-stop messages from an earlier signal have been handled. Patch by Andrew MacPherson llvm-svn: 200226
2014-01-24Fix crash on Linux if sem_wait() is interrupted.Todd Fiala
Patch by Andrew MacPherson. llvm-svn: 200049
2013-10-17Removed unnecessary call to OpenFirstAvailableMaster.Richard Mitton
::Fork already does this internally, so this was simply leaking file handles. This fixes the problem where the test suite would occasionally run out of file handles. llvm-svn: 192929
2013-10-17Added support for reading thread-local storage variables, as defined using ↵Richard Mitton
the __thread modifier. To make this work this patch extends LLDB to: - Explicitly track the link_map address for each module. This is effectively the module handle, not sure why it wasn't already being stored off anywhere. As an extension later, it would be nice if someone were to add support for printing this as part of the modules list. - Allow reading the per-thread data pointer via ptrace. I have added support for Linux here. I'll be happy to add support for FreeBSD once this is reviewed. OS X does not appear to have __thread variables, so maybe we don't need it there. Windows support should eventually be workable along the same lines. - Make DWARF expressions track which module they originated from. - Add support for the DW_OP_GNU_push_tls_address DWARF opcode, as generated by gcc and recent versions of clang. Earlier versions of clang (such as 3.2, which is default on Ubuntu right now) do not generate TLS debug info correctly so can not be supported here. - Understand the format of the pthread DTV block. This is where it gets tricky. We have three basic options here: 1) Call "dlinfo" or "__tls_get_addr" on the inferior and ask it directly. However this won't work on core dumps, and generally speaking it's not a good idea for the debugger to call functions itself, as it has the potential to not work depending on the state of the target. 2) Use libthread_db. This is what GDB does. However this option requires having a version of libthread_db on the host cross-compiled for each potential target. This places a large burden on the user, and would make it very hard to cross-debug from Windows to Linux, for example. Trying to build a library intended exclusively for one OS on a different one is not pleasant. GDB sidesteps the problem and asks the user to figure it out. 3) Parse the DTV structure ourselves. On initial inspection this seems to be a bad option, as the DTV structure (the format used by the runtime to manage TLS data) is not in fact a kernel data structure, it is implemented entirely in useerland in libc. Therefore the layout of it's fields are version and OS dependent, and are not standardized. However, it turns out not to be such a problem. All OSes use basically the same algorithm (a per-module lookup table) as detailed in Ulrich Drepper's TLS ELF ABI document, so we can easily write code to decode it ourselves. The only question therefore is the exact field layouts required. Happily, the implementors of libpthread expose the structure of the DTV via metadata exported as symbols from the .so itself, designed exactly for this kind of thing. So this patch simply reads that metadata in, and re-implements libthread_db's algorithm itself. We thereby get cross-platform TLS lookup without either requiring third-party libraries, while still being independent of the version of libpthread being used. Test case included. llvm-svn: 192922
2013-10-09Add exec support for Linux including common support for POSIX.Matt Kopec
llvm-svn: 192319
2013-10-09Clean up RegisterContextPOSIX i386 code.Michael Sartain
Use 32-bit register enums without gaps on 64-bit hosts. Don't show 64-bit registers when debugging 32-bit targets. Add psuedo gpr registers (ax, ah, al, etc.) Add mmx registers. Fix TestRegisters.py to not read ymm15 register on 32-bit targets. Fill out and move gcc/dwarf/gdb register enums to RegisterContext_x86.h llvm-svn: 192263
2013-09-28If setgid fails for any reason, exit lldb.Sylvestre Ledru
scan-build was complaining about: The return value from the call to 'setgid' is not checked. If an error occurs in 'setgid', the following code may execute with unexpected privileges llvm-svn: 191618
2013-09-18Warning cleanup.Michael Sartain
llvm-svn: 190942
2013-09-17Fixing a problem with thread creation signal order dependencyAndrew Kaylor
llvm-svn: 190831
2013-09-16Improve stability of Linux ProcessMonitor by not using fds for synchronization:Daniel Malea
- ProcessMonitor::[Do|Serve]Operation no longer depend on file descriptors! - removed unused member functions CloseFD and EnableIPC - add semaphores to signal when an Operation is ready to be processed/complete. This commit fixes a bug that was identified under stress-testing (i.e. build LLVM while running tests) that led to LLDB becoming unresponsive because the read/write operations on file descriptors in ProcessMonitor were not checked. Other test runner improvement/convenience: - pickup environment variables LLDB_LINUX_LOG and LLDB_LINUX_LOG_OPTIONS to enable (Linux) logging when running the test suite. Example usage: $ LLDB_LINUX_LOG="mylog.txt" LLDB_LINUX_LOG_OPTIONS="process thread" python dotest.py llvm-svn: 190820
2013-09-14Stop closing terminal fd from ProcessMonitor. It is owned by ↵Andrew Kaylor
ConnectionFileDescriptor. llvm-svn: 190733