summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/Linux
Commit message (Collapse)AuthorAgeFilesLines
...
* [LLDB][PPC64] Fixed next blocked forever at same linePavel Labath2018-02-211-5/+1
| | | | | | | | | | | | | | | | | | Summary: The PC corresponding to the breakpoint was being calculated wrongly, which was causing LLDB to never go past the first breakpoint, when there was a second one adjacent to it. Reviewers: clayborg, labath Reviewed By: clayborg, labath Subscribers: anajuliapc, alexandreyy, lbianc Differential Revision: https://reviews.llvm.org/D43344 Patch by Leandro Lupori <leandro.lupori@gmail.com>. llvm-svn: 325728
* Remove ObjectFile usage from HostLinux::GetProcessInfoPavel Labath2018-01-291-10/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The ObjectFile class was used to determine the architecture of a running process by inspecting it's main executable. There were two issues with this: - it's in the wrong layer - the call can be very expensive (it can end up computing the crc of the whole file). Since the process is running on the host, ideally we would be able to just query the data straight from the OS like darwin does, but there doesn't seem to be a reasonable way to do that. So, this fixes the layering issue by using the llvm object library to inspect the file. Since we know the process is already running on the host, we just need to peek at a few bytes of the elf header to determine whether it's 32- or 64-bit (which should make this faster as well). Pretty much the same logic was implemented in NativeProcessProtocol::ResolveProcessArchitecture, so I delete this logic and replace calls with GetProcessInfo. Reviewers: eugene, krytarowski Subscribers: mgorny, hintonda, lldb-commits Differential Revision: https://reviews.llvm.org/D42488 llvm-svn: 323637
* Reduce x86 register context boilerplate.Pavel Labath2017-12-181-49/+41
| | | | | | | | | | | | | | | | | | | | | | Summary: The x86 FPR struct was defined as a struct containing a union between two members: XSAVE and FXSAVE. This patch makes FPR a union directly to remove one layer of indirection when trying to access the members. The initial layout of these two structs is identical, which is recognised by the fact that XSAVE has FXSAVE as its first member, so we also considered removing one more layer and leave FPR identical to XSAVE struct, but stopped short of doing that, as the FPR may be used to store different layouts in the future (e.g., ones generated by the FSAVE instruction). Reviewers: clayborg, krytarowski Subscribers: emaste, lldb-commits Differential Revision: https://reviews.llvm.org/D41245 llvm-svn: 320966
* NPL: Clean up handling of inferior exitPavel Labath2017-12-181-47/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: lldb-server was sending the "exit" packet (W??) twice. This happened because it was handling both the pre-exit (PTRACE_EVENT_EXIT) and post-exit (WIFEXITED) as exit events. We had some code which was trying to detect when we've already sent the exit packet, but this stopped working quite a while ago. This never really caused any problems in practice because the client automatically closes the connection after receiving the first packet, so the only effect of this was some warning messages about extra packets from the lldb-server test suite, which were ignored because they didn't fail the test. The new test suite will be stricter about this, so I fix this issue ignoring the first event. I think this is the correct behavior, as the inferior is not really dead at that point, so it's premature to send the exit packet. There isn't an actual test yet which would verify the exit behavior, but in my next patch I will add a test which will also test this functionality. Reviewers: eugene Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D41069 llvm-svn: 320961
* Kill struct IOVECPavel Labath2017-12-013-3/+5
| | | | | | | | | | | struct iovec is used as an interface to system (posix) api's. As such, we shouldn't be using it in os-independent code, and we shouldn't be defining our own iovec replacements. Fortunately, its usage was not very widespread, so the removal was very easy -- I simply moved a couple declarations into os-specific code. llvm-svn: 319536
* Fix floating point register write on new x86 linux kernelsPavel Labath2017-11-282-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: New linux kernels (on systems that support the XSAVES instruction) will not update the inferior registers unless the corresponding flag in the XSAVE header is set. Normally this flag will be set in our image of the XSAVE area (since we obtained it from the kernel), but if the inferior has never used the corresponding register set, the respective flag can be clear. This fixes the issue by making sure we explicitly set the flags corresponding to the registers we modify. I don't try to precisely match the flags to set on each write, as the rules could get quite complicated -- I use a simpler over-approximation instead. This was already caught by test_fp_register_write, but that was only because the code that ran before main() did not use some of the register sets. Since nothing in this test relies on being stopped in main(), I modify the test to stop at the entry point instead, so we can be sure the inferior did not have a chance to access these registers. Reviewers: clayborg, valentinagiusti Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D40434 llvm-svn: 319161
* Move ArchSpec to the Utility modulePavel Labath2017-11-131-2/+1
| | | | | | | | | | | | | The rationale here is that ArchSpec is used throughout the codebase, including in places which should not depend on the rest of the code in the Core module. This commit touches many files, but most of it is just renaming of #include lines. In a couple of cases, I removed the #include ArchSpec line altogether, as the file was not using it. In one or two places, this necessitated adding other #includes like lldb-private-defines.h. llvm-svn: 318048
* Clean up NativeRegisterContextPavel Labath2017-11-1017-139/+100
| | | | | | | | | | | | | | | | | | | | | Summary: This commit removes the concrete_frame_idx member from NativeRegisterContext and related functions, which was always set to zero and never used. I also change the native thread class to store a NativeRegisterContext as a unique_ptr (documenting the ownership) and make sure it is always initialized (most of the code was already blindly dereferencing the register context pointer, assuming it would always be present -- this makes its treatment consistent). Reviewers: eugene, clayborg, krytarowski Subscribers: aemerson, sdardis, nemanjai, javed.absar, arichardson, kristof.beyls, kbarton, uweigand, alexandreyy, lldb-commits Differential Revision: https://reviews.llvm.org/D39837 llvm-svn: 317881
* Simplify NativeProcessProtocol::GetArchitecture/GetByteOrderPavel Labath2017-11-096-39/+12
| | | | | | | | | | | | | | | | | | | Summary: These functions used to return bool to signify whether they were able to retrieve the data. This is redundant because the ArchSpec and ByteOrder already have their own "invalid" states, *and* because both of the current implementations (linux, netbsd) can always provide a valid result. This allows us to simplify bits of the code handling these values. Reviewers: eugene, krytarowski Subscribers: javed.absar, lldb-commits Differential Revision: https://reviews.llvm.org/D39733 llvm-svn: 317779
* Add float/vector registers for ppc64lePavel Labath2017-11-032-15/+348
| | | | | | | | | | | | | | | Summary: Add read and write functions for VSX, VMX and float registers and fix watchpoint size Reviewers: clayborg Reviewed By: clayborg Subscribers: eugene, labath, clayborg, nemanjai, kbarton, JDevlieghere, anajuliapc, gut, lbianc, lldb-commits Differential Revision: https://reviews.llvm.org/D39487 Patch by: Alexandre Yukio Yamashita <alexandre.yamashita@eldorado.org.br> llvm-svn: 317329
* Add specific ppc64le hardware watchpoint handlerPavel Labath2017-10-272-1/+306
| | | | | | | | | | | | | | | Summary: Add hardware watchpoint funcionality for ppc64le Reviewers: clayborg, zturner Reviewed By: clayborg Subscribers: eugene, clayborg, zturner, lbianc, gut, nemanjai, alexandreyy, kbarton, lldb-commits Differential Revision: https://reviews.llvm.org/D38897 Patch by Ana Julia Caetano <ana.caetano@eldorado.org.br> llvm-svn: 316772
* Remove shared_pointer from NativeThreadProtocolPavel Labath2017-10-173-91/+61
| | | | | | | | | | | | | | | | | | | Summary: The NativeThread class is useless without the containing process (and in some places it is already assuming the process is always around). This makes it clear that the NativeProcessProtocol is the object owning the threads, and makes the destruction order deterministic (first threads, then process). The NativeProcess is the only thing holding a thread unique_ptr, and methods that used to hand out thread shared pointers now return raw pointers or references. Reviewers: krytarowski, eugene Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D35618 llvm-svn: 316007
* Enable breakpoints and read/write GPRs for ppc64leEugene Zemtsov2017-10-054-2/+330
| | | | | | | | | | | | Add support for ppc64le to create breakpoints and read/write general purpose registers. Other features for ppc64le and functions to read/write other registers are being implemented. Patch by Alexandre Yukio Yamashita (alexandreyy) Differential Revision: https://reviews.llvm.org/D38323 llvm-svn: 315008
* Clean up lldb-types.hPavel Labath2017-07-183-1/+3
| | | | | | | | | | | | | | | | | | | | Summary: It defined a couple of types (condition_t) which we don't use anymore, as we have c++11 goodies now. I remove these definitions. Also it unnecessarily included a couple of headers which weren't necessary for it's operation. I remove these, and place the includes in the relevant files (usually .cpp, usually in Host code) which use them. This allows us to reduce namespace pollution in most of the lldb files which don't need the OS-specific definitions. Reviewers: zturner, jingham Subscribers: ki.stfu, lldb-commits Differential Revision: https://reviews.llvm.org/D35113 llvm-svn: 308304
* Fix linux arm and mips builds broken by r308282Pavel Labath2017-07-182-4/+4
| | | | llvm-svn: 308292
* Remove shared pointer from NativeProcessProtocolPavel Labath2017-07-185-44/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The usage of shared_from_this forces us to separate construction and initialization phases, because shared_from_this() is not available in the constructor (or destructor). The shared semantics are not necessary, as we always have a clear owner of the native process class (GDBRemoteCommunicationServerLLDB object). Even if we need shared semantics in the future (which I think we should strongly avoid), reverting this will not be necessary -- the owners can still easily store the native process object in a shared pointer if they really want to -- this just prevents the knowledge of that from leaking into the class implementation. After this a NativeThread object will hold a reference to the parent process (instead of a weak_ptr) -- having a process instance always available allows us to simplify some logic in this class (some of it was already simplified because we were asserting that the process is available, but this makes it obvious). Reviewers: krytarowski, eugene, zturner Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D35123 llvm-svn: 308282
* NativeProcessLinux: Fix handling of raise(SIGTRAP)Pavel Labath2017-07-111-5/+3
| | | | | | | | | | | | | | | | | | | | | In NativeProcessLinux::MonitorSIGTRAP we were asserting that the si_code value is one of the codes we know about. However, that list was very incomplete -- for example, we were not handling SI_TKILL/SI_USER, generated by raise(SIGTRAP). A cursory examination show there are at least a dozen codes like these that an app can generate, and more can be added at any point. So, instead of trying to play catchup, I change the default behavior to treat an unknown si_code like an ordinary signal. The only reason we needed to inspect si_code in the first place is because watchpoint/breakpoints are notified as SIGTRAP, but we already know about those, and us starting to use a new debug event is far less likely than somebody introducing a new non-debug event. I add a test case to TestRaise to verify we are handling raise(SIGTRAP) in an application properly. llvm-svn: 307644
* NativeProcessLinux: Fix some compiler warningsPavel Labath2017-07-112-21/+6
| | | | llvm-svn: 307636
* Add a NativeProcessProtocol Factory classPavel Labath2017-07-072-213/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This replaces the static functions used for creating NativeProcessProtocol instances with a factory pattern, and modernizes the interface of the new class in the process -- I use llvm::Expected instead of the Status+value combo. I also move some of the common code (like the Delegate registration into the base class). The new arrangement has multiple benefits: - it removes the NativeProcess*** dependency from Process/gdb-remote (which for example means that liblldb no longer pulls in this code). - it enables unit testing of the GDBRemoteCommunicationServerLLGS class (by providing a mock Native Process). - serves as another example on how to use the llvm::Expected class (I couldn't get rid of the Initialize-type functions completely here because of the use of shared_from_this, but that's the next thing on my list here) Tests still pass on Linux and I've made sure NetBSD compiles after this. Reviewers: zturner, eugene, krytarowski Subscribers: srhines, lldb-commits, mgorny Differential Revision: https://reviews.llvm.org/D33778 llvm-svn: 307390
* Fix assorted compiler warnings (mismatched signedness and printf specifiers)Pavel Labath2017-07-051-1/+1
| | | | llvm-svn: 307161
* Fixing warnings for unused variables and copy ellisionRavitheja Addepally2017-07-031-20/+15
| | | | | | | | | | | | | | | | Summary: The std::move was preventing copy ellision when compiled with clang, the patch fixes the warning along with rearranging code to remove unused variables warnings on Linux machines with older perf_event interface. Reviewers: labath, ted Reviewed By: labath Differential Revision: https://reviews.llvm.org/D34946 llvm-svn: 307030
* Use llvm::sys::RetryAfterSignal instead of a manual while errno!=EINTR loopPavel Labath2017-07-031-12/+7
| | | | | | | | | | Reviewers: zturner, eugene, krytarowski Subscribers: emaste, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D33831 llvm-svn: 307009
* Move Timer and TraceOptions from Core to UtilityPavel Labath2017-06-291-5/+4
| | | | | | | | | | | | | | Summary: The classes have no dependencies, and they are used both by lldb and lldb-server, so it makes sense for them to live in the lowest layers. Reviewers: zturner, jingham Subscribers: emaste, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D34746 llvm-svn: 306682
* Implementation of Intel(R) Processor Trace support for LinuxRavitheja Addepally2017-06-285-1/+875
| | | | | | | | | | | | | | | | | | | | | | Summary: This patch implements support for Intel(R) Processor Trace in lldb server. The changes have support for starting/stopping and reading the trace data. The code is only available on Linux versions where the perf attributes for aux buffers are available. The patch also consists of Unit tests for testing the core buffer reading function. Reviewers: lldb-commits, labath, clayborg, zturner, tberghammer Reviewed By: labath, clayborg Subscribers: mgorny Differential Revision: https://reviews.llvm.org/D33674 llvm-svn: 306516
* Add pretty-printer for wait(2) statuses and modernize the code handling themPavel Labath2017-06-192-61/+15
| | | | | | | | | | | | | | | Summary: A number of places were trying to decode the result of wait(). Add a simple utility function that does that and a struct that encapsulates the decoded result. Then also provide a pretty-printer for that class. Reviewers: zturner, krytarowski, eugene Subscribers: lldb-commits, mgorny Differential Revision: https://reviews.llvm.org/D33998 llvm-svn: 305689
* replace uses of strerror with llvm::sys::StrErrorPavel Labath2017-06-061-5/+5
| | | | | | | | strerror is not thread-safe. llvm's StrError tries hard to retrieve the string in a thread-safe way and falls back to strerror only if it does not have another way. llvm-svn: 304795
* Fix Linux Buildbot.Zachary Turner2017-05-121-1/+1
| | | | llvm-svn: 302874
* Rename Error -> Status.Zachary Turner2017-05-1217-654/+674
| | | | | | | | | | | | | | | This renames the LLDB error class to Status, as discussed on the lldb-dev mailing list. A change of this magnitude cannot easily be done without find and replace, but that has potential to catch unwanted occurrences of common strings such as "Error". Every effort was made to find all the obvious things such as the word "Error" appearing in a string, etc, but it's possible there are still some lingering occurences left around. Hopefully nothing too serious. llvm-svn: 302872
* [LLDB][MIPS] Core Dump Support.Nitesh Jain2017-03-311-157/+29
| | | | | | | | | | Reviewers: labath, emaste Subscribers: jaydeep, bhushan, lldb-commits, slthakur Differential Revision: https://reviews.llvm.org/D30457 llvm-svn: 299200
* Move FileSpec from Host -> Utility.Zachary Turner2017-03-221-1/+1
| | | | llvm-svn: 298536
* Break the cycle between Host and PluginProcessUtility.Zachary Turner2017-03-221-1/+1
| | | | | | | | | | | There are only two users of NativeRegisterContextRegisterInfo, and both are in process plugins. Moving this code from Host to Plugins/Process/Utility thus makes sense, and as it is the only dependency from Host -> PluginProcessUtility, it also breaks this cycle, reducing LLDB's overall cycle count from 45 to 44. llvm-svn: 298466
* Remove ProcFileReaderPavel Labath2017-03-214-167/+25
| | | | | | | This removes the last usage of ProcFileReader from NativeProcessLinux and then deletes the class itself. llvm-svn: 298374
* Move GetAuxvData from Host to relevant process pluginsPavel Labath2017-03-171-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: GetAuxvData was causing dependencies from host to target and linux process modules. It also does not fit netbsd use case, as there we can only read the auxiliary vector with ptrace, which is better done in the process plugin, with the other ptrace calls. I resolve these issues by moving the freebsd and linux versions into the relevant process plugins. In case of linux, this required adding an interface in NativeProcessProtocol. The empty definitions on other platforms can simply be removed. To get the code compiling I had to add ProcessGdbRemote -> ProcessLinux dependency, which was not caught before because we depended on it transitively. Reviewers: zturner, emaste Subscribers: srhines, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D31031 llvm-svn: 298066
* Remove HostThreadLinux/Free/NetBSDPavel Labath2017-03-171-9/+7
| | | | | | | | | | | | | | | | | | | | | | Summary: These classes existed only because of the GetName() static function, which can be moved to a more natural place anyway. I move the linux version to NativeProcessLinux (and get rid of ProcFileReader), the freebsd version to ProcessFreeBSD (and fix a bug where it was using the current process ID, instead of the inferior pid), and remove the NetBSD version (which was probably incorrect anyway, as it assumes the current process instead of the inferior. I also add an llgs test to that verifies thread names are read correctly. Reviewers: zturner, krytarowski, emaste Subscribers: lldb-commits, mgorny Differential Revision: https://reviews.llvm.org/D30981 llvm-svn: 298058
* Resubmit FileSystem changes.Zachary Turner2017-03-081-3/+3
| | | | | | | | | | This was originall reverted due to some test failures in ModuleCache and TestCompDirSymlink. These issues have all been resolved and the code now passes all tests. Differential Revision: https://reviews.llvm.org/D30698 llvm-svn: 297300
* Revert "Use LLVM for all stat-related functionality."Pavel Labath2017-03-071-3/+3
| | | | | | | | | | | | | | | this reverts r297116 because it breaks the unittests and TestCompDirSymlink. The ModuleCache unit test is trivially fixable, but the CompDirSymlink failure is a symptom of a deeper problem: llvm's stat functionality is not a drop-in replacement for lldb's. The former is based on stat(2) (which does symlink resolution), while the latter is based on lstat(2) (which does not). This also reverts subsequent build fixes (r297128, r297120, 297117) and r297119 (Remove FileSpec dependency on FileSystem) which builds on top of this. llvm-svn: 297139
* Use LLVM for all stat-related functionality.Zachary Turner2017-03-071-3/+3
| | | | | | | | | | This deletes LLDB's FileType enumeration and replaces all users, and all calls to functions that check whether a file exists etc with corresponding calls to LLVM. Differential Revision: https://reviews.llvm.org/D30624 llvm-svn: 297116
* Move DataBuffer / DataExtractor and friends from Core -> Utility.Zachary Turner2017-03-046-6/+6
| | | | llvm-svn: 296943
* Move Log from Core -> Utility.Zachary Turner2017-03-036-6/+6
| | | | | | | | | All references to Host and Core have been removed, so this class can now safely be lowered into Utility. Differential Revision: https://reviews.llvm.org/D30559 llvm-svn: 296909
* Merge Linux and FreeBSD arm register contextsPavel Labath2017-02-271-2/+2
| | | | | | | | | | | | | | Summary: These two register contexts were identical, so this shouldn't cause any regressions, but I'd appreciate it if you can check that this at least compiles. Reviewers: emaste, sas Subscribers: aemerson, rengolin, lldb-commits, mgorny Differential Revision: https://reviews.llvm.org/D27126 llvm-svn: 296335
* Hardware breakpoints for Linux on Arm/AArch64 targetsOmair Javaid2017-02-248-111/+319
| | | | | | | | Please look at below differential link for upstream discussion. Differential revision: https://reviews.llvm.org/D29669 llvm-svn: 296119
* Implement QPassSignals GDB package in lldb-serverPavel Labath2017-02-241-0/+7
| | | | | | | | | | | | | | | Summary: QPassSignals package allows lldb client to tell lldb-server to ignore certain types of signals and re-inject them back to inferior without stopping execution. Reviewers: jmajors, labath Subscribers: danalbert, srhines, emaste, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D30286 Author: Eugene Zemtsov <ezemtsov@google.com> llvm-svn: 296101
* NPL: Fix an incorrect logging formatv callPavel Labath2017-02-171-2/+2
| | | | llvm-svn: 295457
* NPL: Fix one more bug in the single step workaroundPavel Labath2017-02-172-2/+9
| | | | | | | | | | | | | | | | | In the case we are stepping over the thread creation instruction, we will end up calling Thread::SingleStep back-to-back twice (because of the intermediate PTRACE_EVENT_CLONE stop). This will cause the cpu mask to be set inappropriately (because the old SingleStepCheck object will be destroyed after we create the new one), and the single-step will fail. Before the refactor the code was still incorrect in this case, but in a different way (the thread was left with the incorrect mask after the stepping was complete), so this was not easy to spot. This fixes TestCreateDuringInstructionStep on the affected devices. llvm-svn: 295440
* Finish breaking the dependency from Utility.Zachary Turner2017-02-161-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D29964 llvm-svn: 295368
* NPL: Fix single step workaroundPavel Labath2017-02-163-10/+13
| | | | | | | | | | | | While refactoring the code in r293046 I made a very basic error - relying on destructor side-effects of a copyable object. Fix that and make the object non-copyable. This fixes the tests on the platforms that need this workaround, but unfortunately we don't have a way to make a more platform-agnostic test right now. llvm-svn: 295345
* Remove the verbose category in the posix channelPavel Labath2017-02-061-9/+8
| | | | | | replace by LLDB_LOGV llvm-svn: 294223
* Fix missing include in NativeProcessLinuxPavel Labath2017-02-061-7/+4
| | | | llvm-svn: 294211
* Switch std::call_once to llvm::call_onceKamil Rytarowski2017-02-061-2/+2
| | | | | | | | | | | | | | | | | | | | | Summary: The std::call_once implementation in libstdc++ has problems on few systems: NetBSD, OpenBSD and Linux PPC. LLVM ships with a homegrown implementation llvm::call_once to help on these platforms. This change is required in the NetBSD LLDB port. std::call_once with libstdc++ results with crashing the debugger. Sponsored by <The NetBSD Foundation> Reviewers: labath, joerg, emaste, mehdi_amini, clayborg Reviewed By: labath, clayborg Subscribers: #lldb Tags: #lldb Differential Revision: https://reviews.llvm.org/D29288 llvm-svn: 294202
* Use LLDB_LOG in NativeRegisterContextLinux*** filesPavel Labath2017-02-034-182/+79
| | | | llvm-svn: 294023
OpenPOWER on IntegriCloud