summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Share crash information between LLGS and local POSIX debugging withChaoren Lin2015-02-031-161/+8
| | | | | | | CrashReason class. Deliver crash information from LLGS to lldb via description field of thread stop packet. llvm-svn: 227926
* LLGS Android target support - for Andy Chien : http://reviews.llvm.org/D6166Shawn Best2014-11-081-1/+6
| | | | llvm-svn: 221570
* Enable llgs to build against experimental Android AOSP ↵Todd Fiala2014-09-271-2/+9
| | | | | | | | | | | | 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
* Fix up the HostThread interface, making the interface simpler.Zachary Turner2014-09-231-8/+6
| | | | | | | Reviewed by: Greg Clayton Differential Revision: http://reviews.llvm.org/D5417 llvm-svn: 218325
* Fix typo in Linux ASLR logging.Todd Fiala2014-09-191-1/+1
| | | | llvm-svn: 218133
* lldb fix ARM64 register accessTodd Fiala2014-09-121-0/+93
| | | | | | | | | | 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
* Create a HostThread abstraction.Zachary Turner2014-09-091-20/+16
| | | | | | | | | | | | | 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
* Fix build break on Ubuntu 12.04 with ARM64 changes.Todd Fiala2014-09-041-1/+3
| | | | | | | | | | 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
* Add Linux support for get thread area on ARM64 using ProcessMonitor debugging.Todd Fiala2014-08-271-5/+14
| | | | | | | | See http://reviews.llvm.org/D5073. Change by Paul Osmialowski. llvm-svn: 216553
* Enable more Linux aarch64 PTRACE support for local and remote debugging.Todd Fiala2014-08-211-15/+51
| | | | | | | | See http://reviews.llvm.org/D4803 for more details. Change by Paul Osmialowski. llvm-svn: 216185
* Fix Linux to respect ASLR settings when launching processes to debug locally ↵Todd Fiala2014-08-171-3/+41
| | | | | | | | | | 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
* linux process: silence GCC switch coverage warningSaleem Abdulrasool2014-07-201-0/+2
| | | | | | | Add missing entry for eExecMessage message type to silence GCC switch coverage warning. llvm-svn: 213470
* Use native ::pid_t in Linux ProcessMonitor (local debugging).Todd Fiala2014-07-011-14/+19
| | | | | | | | | | 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
* Add lldb-gdbserver support for Linux x86_64.Todd Fiala2014-06-301-1/+5
| | | | | | | | | | | | | | | | | | | | | 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
* lldb: deal with non-portable PTRACE-related constantsTodd Fiala2014-06-231-0/+20
| | | | | | | | See http://reviews.llvm.org/D4091 for details. Change by Paul Osmialowski. llvm-svn: 211503
* Move x86-specific struct user code for Linux ProcessMonitor behind #define ↵Todd Fiala2014-06-161-0/+4
| | | | | | | | | | guards. See http://reviews.llvm.org/D4092 for details. Change by Paul Osmialowski. (Minor tweaks to the comment by Todd.) llvm-svn: 211026
* Use getpgid() with waitpid() in case the process pgid is not equal to its ↵Andrew MacPherson2014-04-021-1/+1
| | | | | | pid, as is the case with a forked subprocess. Also a couple of fixes for unit test failures from Todd Fiala. llvm-svn: 205405
* sanitise sign comparisonsSaleem Abdulrasool2014-04-021-3/+3
| | | | | | | | 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
* Implement ProcessMonitor::Kill for LinuxEd Maste2014-04-011-30/+2
| | | | | | | | | | | | | | | | | | | | | 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
* Correct copy-and-pasted comments for DetachOperationEd Maste2014-03-171-2/+2
| | | | llvm-svn: 204064
* Get Linux i386 running.Todd Fiala2014-03-041-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix linux x86 debugging on a linux x86 host (32-bit on 32-bit).Todd Fiala2014-02-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix ptrace log on i386 and include return valueEd Maste2014-02-241-4/+4
| | | | | | Patch by Matthew Gardiner llvm-svn: 202036
* Fix group stop signal handling issue on Linux.Todd Fiala2014-01-271-5/+14
| | | | | | | | | | 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
* Fix crash on Linux if sem_wait() is interrupted.Todd Fiala2014-01-241-2/+12
| | | | | | Patch by Andrew MacPherson. llvm-svn: 200049
* Removed unnecessary call to OpenFirstAvailableMaster.Richard Mitton2013-10-171-8/+0
| | | | | | | | ::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
* Added support for reading thread-local storage variables, as defined using ↵Richard Mitton2013-10-171-0/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add exec support for Linux including common support for POSIX.Matt Kopec2013-10-091-2/+4
| | | | llvm-svn: 192319
* Clean up RegisterContextPOSIX i386 code.Michael Sartain2013-10-091-1/+2
| | | | | | | | | | | 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
* If setgid fails for any reason, exit lldb.Sylvestre Ledru2013-09-281-2/+7
| | | | | | | 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
* Warning cleanup.Michael Sartain2013-09-181-6/+5
| | | | llvm-svn: 190942
* Fixing a problem with thread creation signal order dependencyAndrew Kaylor2013-09-171-0/+74
| | | | llvm-svn: 190831
* Improve stability of Linux ProcessMonitor by not using fds for synchronization:Daniel Malea2013-09-161-104/+25
| | | | | | | | | | | | | | | | | | - 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
* Stop closing terminal fd from ProcessMonitor. It is owned by ↵Andrew Kaylor2013-09-141-1/+4
| | | | | | ConnectionFileDescriptor. llvm-svn: 190733
* Fixing a problem with inferior exit caused by signalAndrew Kaylor2013-09-041-0/+6
| | | | llvm-svn: 189953
* Handle SI_KERNEL signal code for SIGSEGV exceptions.Matt Kopec2013-08-091-0/+6
| | | | | | Patch by Richard Mitton. llvm-svn: 188075
* Fix thread name updating in Linux. "thread list" should report correct names ↵Michael Sartain2013-07-311-10/+2
| | | | | | | | | | | always now. Created new LinuxThread class inherited from POSIXThread and removed linux / freebsd ifdefs Removed several un-needed set thread name calls CR (and multiple suggestions): mkopec llvm-svn: 187545
* Correct comment to match class nameEd Maste2013-07-171-1/+1
| | | | llvm-svn: 186509
* Fix unhandled SIGTRAP signal on Linux causing assertion.Matt Kopec2013-07-111-0/+7
| | | | llvm-svn: 186112
* Add support for listing inferior thread names on Linux.Matt Kopec2013-07-101-0/+10
| | | | llvm-svn: 186033
* Reverting ProcessMonitor shared pointer changesAndrew Kaylor2013-07-091-5/+5
| | | | llvm-svn: 185981
* Use shared pointers to hold the process in ProcessMonitorAndrew Kaylor2013-07-091-5/+5
| | | | llvm-svn: 185946
* Fix signal handling for POSIX (only tested on Linux) processes in ↵Matt Kopec2013-07-091-3/+25
| | | | | | | | multi-threaded programs. Also fix a related issue where if a thread exits after a thread continue, lldb would hang. llvm-svn: 185944
* Update comment to match class nameEd Maste2013-06-241-1/+1
| | | | llvm-svn: 184745
* Fix various build warnings.Matt Kopec2013-06-031-2/+2
| | | | llvm-svn: 183140
* Add ability to attach/detach to multi-threaded inferiors on Linux.Matt Kopec2013-05-311-41/+99
| | | | | | All running threads will be detected and stopped on attach and all threads get resumed on detach. llvm-svn: 183049
* Adding support for stopping all threads of multithreaded inferiors on Linux. ↵Andrew Kaylor2013-05-281-6/+203
| | | | | | Also adding multithreaded test cases. llvm-svn: 182809
* The Linux process plugin wasn't returning the correct linux signals. This ↵Matt Kopec2013-05-171-11/+0
| | | | | | | | fixes that. Thus, this patch also negates a previous fix for handling SIGCHLD. llvm-svn: 182166
* ProcessMonitor improvements for Linux.Matt Kopec2013-05-171-3/+28
| | | | | | | | -Remove tracing of fork/vfork until we add support for tracing inferiors' children on Linux. -Add trace exec option for ptrace so that we don't receive legacy SIGTRAP signals on execve calls. -Add handling of SIGCHLD sent by kernel (for now, deliver the signal to the inferior). llvm-svn: 182153
* Fix Linux warning about missing virtual destructor in Operation classesDaniel Malea2013-05-131-0/+1
| | | | llvm-svn: 181712
OpenPOWER on IntegriCloud