summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/NetBSD
Commit message (Collapse)AuthorAgeFilesLines
* [lldb] [Process/NetBSD] Remove unused orig_*ax useMichał Górny2020-01-061-5/+0
| | | | | | | orig_*ax logic is Linux-specific, and was never used on NetBSD. In fact, its support seems to be a dead code entirely. Differential Revision: https://reviews.llvm.org/D72195
* [lldb] Adapt for NetBSD-9.99.30 ptrace(2) API changesKamil Rytarowski2019-12-242-2/+21
| | | | | | | | Switch from PT_LWPINFO to PT_LWPSTATUS/PT_LWPNEXT. Keep compat support for < 9.99.30. No functional change intended.
* [lldb] [Process/NetBSD] Fix handling concurrent watchpoint eventsMichał Górny2019-11-254-24/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix handling concurrent watchpoint events so that they are reported correctly in LLDB. If multiple watchpoints are hit concurrently, the NetBSD kernel reports them as series of SIGTRAPs with a thread specified, and the debugger investigates DR6 in order to establish which watchpoint was hit. This is normally fine. However, LLDB disables and reenables the watchpoint on all threads after each hit, which results in the hit status from DR6 being wiped. As a result, it can't establish which watchpoint was hit in successive SIGTRAP processing. In order to workaround this problem, clear DR6 only if the breakpoint is overwritten with a new one. More specifically, move cleaning DR6 from ClearHardwareWatchpoint() to SetHardwareWatchpointWithIndex(), and do that only if the newly requested watchpoint is different from the one being set previously. This ensures that the disable-enable logic of LLDB does not clear watchpoint hit status for the remaining threads. This also involves refactoring of watchpoint logic. With the old logic, clearing watchpoint involved wiping dr6 & dr7, and setting it setting dr{0..3} & dr7. With the new logic, only enable bit is cleared from dr7, and the remaining bits are cleared/overwritten while setting new watchpoint. Differential Revision: https://reviews.llvm.org/D70025
* [lldb] [Process/NetBSD] Copy watchpoints to newly-created threadsMichał Górny2019-11-257-8/+54
| | | | | | | | | | | | | NetBSD ptrace interface does not populate watchpoints to newly-created threads. Solve this via copying the watchpoints from the current thread when new thread is reported via TRAP_LWP. Add a test that verifies that when the user does not have permissions to set watchpoints on NetBSD, the 'watchpoint set' errors out gracefully and thread monitoring does not crash on being unable to copy watchpoints to new threads. Differential Revision: https://reviews.llvm.org/D70023
* [lldb] [Process/NetBSD] Improve threading supportMichał Górny2019-11-254-86/+256
| | | | | | | | | | | | | | | | | | | | | | | | | Implement major improvements to multithreaded program support. Notably, support tracking new and exited threads, associate signals and events with correct threads and support controlling individual threads when resuming. Firstly, use PT_SET_EVENT_MASK to enable reporting of created and exited threads via SIGTRAP. Handle TRAP_LWP events to keep track of the currently running threads. Secondly, update the signal (both generic and SIGTRAP) handling code to account for per-thread signals correctly. Signals delivered to the whole process are reported on all threads, while per-thread signals and events are reported only to the specific thread. The remaining threads are marked as 'stopped with no reason'. Note that NetBSD always stops all threads on debugger events. Thirdly, implement the ability to set every thread as running, stopped or single-stepping separately while continuing the process. This also provides the ability to send a signal to the whole process or to one of its thread while resuming. Differential Revision: https://reviews.llvm.org/D70022
* [lldb] [Process/NetBSD] Implement thread name gettingMichał Górny2019-11-181-1/+38
| | | | | | | Implement thread name getting sysctl() on NetBSD. Also fix the incorrect type in pthread_setname_np() in the relevant test. Differential Revision: https://reviews.llvm.org/D70363
* [lldb] [Process/NetBSD] Use PT_STOP to stop the process [NFCI]Michał Górny2019-11-122-6/+7
| | | | Differential Revision: https://reviews.llvm.org/D70060
* [lldb] [Process/NetBSD] Add register info for missing register setsMichał Górny2019-11-042-2/+60
| | | | | | | | | | | | | | | | | | | | | | Add info for all register sets supported in NetBSD, particularly for all registers 'expected' by LLDB. This is necessary in order to fix python_api/lldbutil/iter/TestRegistersIterator.py test that currently fails due to missing names of register sets (None). This copies fpreg descriptions from Linux, and combines Linux' AVX and MPX registers into a single XState group, to fit NetBSD register group design. Technically, we do not support MPX registers at the moment but gdb-remote insists on passing their errors anyway, and if we do not include it in any group, they end up in a separate anonymous group that breaks the test. While at it, swap the enums for XState and DBRegs to match register set ordering. This also adds a few consts to the lldb-x86-register-enums.h to provide more consistency between user registers and debug registers. Differential Revision: https://reviews.llvm.org/D69667
* [lldb] [Process/NetBSD] Fix handling LLDB_INVALID_SIGNAL_NUMBERMichal Gorny2019-09-241-2/+4
| | | | | | | | | Fix NativeProcessNetBSD::Resume() to handle LLDB_INVALID_SIGNAL_NUMBER correctly. Fixes breakage caused by r372090 and r372300. I have major rewrite of that function pending; however, the fixes to gdb-remote were committed prior to that. llvm-svn: 372755
* [LLDB] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-1/+1
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368933
* [lldb] [Process/NetBSD] Report stopped process on SIGSTOPMichal Gorny2019-07-251-0/+1
| | | | | | | | | | | | | Mark the process as stopped when SIGSTOP arrives. This is necessary for lldb-server to generate correct response to 'process interrupt', and therefore to prevent the whole stack crashing when process is stopped. Thanks to Pavel Labath for the tip. Differential Revision: https://reviews.llvm.org/D65289 llvm-svn: 367047
* [Logging] Replace Log::Printf with LLDB_LOG macro (NFC)Jonas Devlieghere2019-07-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch replaces explicit calls to log::Printf with the new LLDB_LOGF macro. The macro is similar to LLDB_LOG but supports printf-style format strings, instead of formatv-style format strings. So instead of writing: if (log) log->Printf("%s\n", str); You'd write: LLDB_LOG(log, "%s\n", str); This change was done mechanically with the command below. I replaced the spurious if-checks with vim, since I know how to do multi-line replacements with it. find . -type f -name '*.cpp' -exec \ sed -i '' -E 's/log->Printf\(/LLDB_LOGF\(log, /g' "{}" + Differential revision: https://reviews.llvm.org/D65128 llvm-svn: 366936
* Revert "Revert "[lldb] [Process/NetBSD] Fix constructor after r363707""Michal Gorny2019-07-241-1/+1
| | | | | | The relevant changes have been reapplied, and broke build again. llvm-svn: 366889
* Revert "Revert "Implement xfer:libraries-svr4:read packet""Antonio Afonso2019-07-231-2/+2
| | | | | | This reverts commit 08c38f77c5fb4d3735ec215032fed8ee6730b3db. llvm-svn: 366847
* [lldb] [Process/NetBSD] Use global enable bits for watchpointsMichal Gorny2019-07-011-2/+2
| | | | | | | | | | | Set global enable bits (i.e. bits 1, 3, 5, 7) to enable watchpoints on NetBSD rather than the local enable bits (0, 2, 4, 6). The former are necessary for watchpoints to be correctly recognized by the NetBSD kernel. The latter cause them to be reported as trace points. Differential Revision: https://reviews.llvm.org/D63792 llvm-svn: 364781
* [lldb] [Process/NetBSD] Fix segfault when handling watchpointMichal Gorny2019-07-011-10/+21
| | | | | | | | | | | | | | | Fix the watchpoint/breakpoint code to search for matching thread entry in m_threads explicitly rather than assuming that it will be present at specified index. The previous code segfault since it wrongly assumed that the index will match LWP ID which was incorrect even for a single thread (where index was 0 and LWP ID was 1). While fixing that off-by-one error would help for this specific task, I believe it is better to be explicit in what we are searching for. Differential Revision: https://reviews.llvm.org/D63791 llvm-svn: 364780
* [lldb] [Process/NetBSD] Support reading YMM registers via PT_*XSTATEMichal Gorny2019-07-012-2/+97
| | | | | | | | | | | | | Provide a (conditional) support for the new PT_GETXSTATE and PT_SETXSTATE ptrace() requests, and use them to implement getting and setting YMM registers. The functions used for splitting and recombining YMM register data are based on matching functions in FreeBSD plugin, with some simplification and updates to match NetBSD structures. Differential Revision: https://reviews.llvm.org/D63545 llvm-svn: 364779
* Revert "[lldb] [Process/NetBSD] Fix constructor after r363707"Michal Gorny2019-07-011-1/+1
| | | | | | | Now that r364751 has been reverted, we need to revert this fixup as well. llvm-svn: 364776
* Don't check the validity of newly contructed data buffersPavel Labath2019-07-011-7/+0
| | | | | | | | | | A bunch of places were checking that DataBufferHeap::GetBytes returns a non-null pointer right after constructing it. The only time when GetBytes returns a null pointer is if it is empty (and I'm not sure that even this is a good idea), but that is clearly not the case here, as the buffer was constructed with a non-zero size just a couple of lines back. llvm-svn: 364754
* Revert "Implement xfer:libraries-svr4:read packet"Pavel Labath2019-07-011-2/+2
| | | | | | | | | | | | | | | | | | | D62502, together with D62503 have broken the builds which have XML support enabled. Reverting D62503 (r364355) fixed that, but has broken has left some of the tests introduced by D62502 broken more or less nondeternimistically (it depended on whether the system happens to place the library list near unreadable pages of memory). I attempted to make a partial fix for this in r364748, but Jan Kratochvil pointed out that this reintroduces the problem which reverting D62503 was trying to solve. So instead, I back out the whole thing so we can get back to a clean slate that works for everyone. We can figure out a way forward from there. This reverts r364748, r363772 and r363707. llvm-svn: 364751
* Remove null checks of results of new expressionsPavel Labath2019-07-011-7/+0
| | | | | | | | operator new doesn't return a null pointer, even if one turns off exceptions (it calls std::terminate instead). Therefore, all of this is dead code. llvm-svn: 364744
* [lldb] [Process/NetBSD] Remove unnecessary register buffer abstractionMichal Gorny2019-06-204-117/+12
| | | | | | | | | | | | | | | | | Remove most of the abstraction over ptrace() register operations, as it has little value and introduces more code than it saves. Instead, leave a single ptrace() wrapper method and call it directly from ReadRegisterSet() and WriteRegisterSet() with correct PT_* request and buffer. Remove the remaining direct ReadGPR() and WriteGPR() invocations with ReadRegisterSet() and WriteRegisterSet(). Cleanup suggested by Pavel Labath in D63545. Differential Revision: https://reviews.llvm.org/D63594 llvm-svn: 363923
* [lldb] [Process/NetBSD] Fix constructor after r363707Michal Gorny2019-06-191-1/+1
| | | | llvm-svn: 363827
* [lldb] [Process/NetBSD] Remove unnecessary FPU presence checks for x86_64Michal Gorny2019-06-191-53/+1
| | | | | | | | | | Remove the checks for FPU presence, FXSAVE support and usage from the code for x86_64. Those are always true for this architecture, and in fact are hardcoded to true inside NetBSD kernel. Differential Revision: https://reviews.llvm.org/D63554 llvm-svn: 363823
* Implement xfer:libraries-svr4:read packetAntonio Afonso2019-06-181-2/+2
| | | | | | | | | | | | | | | | | | | Summary: This is the fourth patch to improve module loading in a series that started here (where I explain the motivation and solution): D62499 Implement the `xfer:libraries-svr4` packet by adding a new function that generates the list and then in Handle_xfer I generate the XML for it. The XML is really simple so I'm just using string concatenation because I believe it's more readable than having to deal with a DOM api. Reviewers: clayborg, xiaobai, labath Reviewed By: labath Subscribers: emaste, mgorny, srhines, krytarowski, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D62502 llvm-svn: 363707
* [lldb] [Process/NetBSD] Fix error handling in register operationsMichal Gorny2019-06-102-38/+18
| | | | | | | | | | Ensure that errors are passed through correctly when performing register read/write operations. Currently, any ptrace() errors are silently discarded and LLDB behaves as if operation was successful. Differential Revision: https://reviews.llvm.org/D63054 llvm-svn: 362946
* [lldb] [Process/NetBSD] Fix handling piod_len from PT_IO callsMichal Gorny2019-04-301-4/+4
| | | | | | | | | | | | | | | | | | | | | | Fix bugs in piod_len return value processing in ReadMemory() and WriteMemory() methods. In particular, add support for piod_len == 0 indicating EOF, and fix summing bytes_read/bytes_written when PT_IO does partial reads/writes. The EOF condition could happen if LLDB attempts to read past vm.maxaddress, e.g. as a result of RBP containing large (invalid) value. Previously, the 0 return caused the function to retry reading via PT_IO indefinitely, effectively deadlooping lldb-server. Partial reads probably did not occur in practice, yet they would cause ReadMemory() to return incorrect bytes_read and/or overwrite previously read data. WriteMemory() suffered from analoguous problems. Differential Revision: https://reviews.llvm.org/D61310 llvm-svn: 359572
* [lldb] [Process/NetBSD] Fix wrongly mapping mm* registersMichal Gorny2019-04-111-2/+2
| | | | | | | | | | | | | Fix mistake that mapped mm* registers into the space for xmm* registers, rather than the one shared with st* registers. In other words, 'register read mmN' now correctly shows the mmN register rather than part of xmmN. Includes a minimal lit regression test. Differential Revision: https://reviews.llvm.org/D60325 llvm-svn: 358178
* [NFC] Remove ASCII lines from commentsJonas Devlieghere2019-04-104-20/+0
| | | | | | | | | | | | | | | | | | | | | | | A lot of comments in LLDB are surrounded by an ASCII line to delimit the begging and end of the comment. Its use is not really consistent across the code base, sometimes the lines are longer, sometimes they are shorter and sometimes they are omitted. Furthermore, it looks kind of weird with the 80 column limit, where the comment actually extends past the line, but not by much. Furthermore, when /// is used for Doxygen comments, it looks particularly odd. And when // is used, it incorrectly gives the impression that it's actually a Doxygen comment. I assume these lines were added to improve distinguishing between comments and code. However, given that todays editors and IDEs do a great job at highlighting comments, I think it's worth to drop this for the sake of consistency. The alternative is fixing all the inconsistencies, which would create a lot more churn. Differential revision: https://reviews.llvm.org/D60508 llvm-svn: 358135
* [lldb] [Process/NetBSD] Use nullptr to fix template arg deductionMichal Gorny2019-03-251-1/+1
| | | | llvm-svn: 356960
* [lldb] Add missing EINTR handlingMichal Gorny2019-03-211-1/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D59606 llvm-svn: 356703
* Bring Doxygen comment syntax in sync with LLVM coding style.Adrian Prantl2019-03-111-1/+1
| | | | | | This changes '@' prefix to '\'. llvm-svn: 355841
* [Process/NetBSD] Add missing linkage to -lutilMichal Gorny2019-01-241-0/+1
| | | | | | | | | | | | Add missing linkage to fix build failure with LLD: ld: error: undefined symbol: kinfo_getvmmap >>> referenced by NativeProcessNetBSD.cpp >>> NativeProcessNetBSD.cpp.o:(lldb_private::process_netbsd::NativeProcessNetBSD::PopulateMemoryRegionCache()) in archive lib/liblldbPluginProcessNetBSD.a Differential Revision: https://reviews.llvm.org/D57193 llvm-svn: 352116
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-198-32/+24
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Remove header grouping comments.Jonas Devlieghere2018-11-111-3/+0
| | | | | | | | This patch removes the comments grouping header includes. They were added after running IWYU over the LLDB codebase. However they add little value, are often outdates and burdensome to maintain. llvm-svn: 346626
* Fix NetBSD build after "Move path resolution logic out of FileSpec"Kamil Rytarowski2018-11-041-1/+1
| | | | | | D53915 llvm-svn: 346100
* NativeProcessProtocol: Simplify breakpoint setting codePavel Labath2018-11-041-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: A fairly simple operation as setting a breakpoint (writing a breakpoint opcode) at a given address was going through three classes: NativeProcessProtocol which called NativeBreakpointList, which then called SoftwareBrekpoint, only to end up again in NativeProcessProtocol to do the actual writing itself. This is unnecessarily complex and can be simplified by moving all of the logic into NativeProcessProtocol class itself, removing a lot of boilerplate. One of the reeasons for this complexity was that (it seems) NativeBreakpointList class was meant to hold both software and hardware breakpoints. However, that never materialized, and hardware breakpoints are stored in a separate map holding only hardware breakpoints. Essentially, this patch makes software breakpoints follow that approach by replacing the heavy SoftwareBraekpoint with a light struct of the same name, which holds only the data necessary to describe one breakpoint. The rest of the logic is in the main class. As, at the lldb-server level, handling software and hardware breakpoints is very different, this seems like a reasonable state of things. Reviewers: krytarowski, zturner, clayborg Subscribers: mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D52941 llvm-svn: 346093
* Pull FixupBreakpointPCAsNeeded into base classPavel Labath2018-10-032-76/+0
| | | | | | | | | | | | | | | | | Summary: This function existed (with identical code) in both NativeProcessLinux and NativeProcessNetBSD, and it is likely that it would be useful to any future implementation of NativeProcessProtocol. Therefore I move it to the base class. Reviewers: krytarowski Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D52719 llvm-svn: 343683
* Fix NetBSD build for r343409Pavel Labath2018-09-301-1/+0
| | | | | | Forgot to remove the method declaration from the header. llvm-svn: 343411
* Pull GetSoftwareBreakpointPCOffset into base classPavel Labath2018-09-301-22/+3
| | | | | | | | | | | | | | | | | | | | | | Summary: This function encodes the knowledge of whether the PC points to the breakpoint instruction of the one following it after the breakpoint is "hit". This behavior mainly(*) depends on the architecture and not on the OS, so it makes sense for it to be implemented in the base class, where it can be shared between different implementations (Linux and NetBSD atm). (*) It is possible for an OS to expose a different API, perhaps by doing some fixups in the kernel. In this case, the implementation can override this function to implement custom behavior. Reviewers: krytarowski, zturner Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D52532 llvm-svn: 343409
* NativeProcessProtocol: Sink ReadMemoryWithoutTrap into base classPavel Labath2018-09-132-12/+0
| | | | | | | | The two existing implementations have the function implemented identically, and there's no reason to believe that this would be different for other implementations. llvm-svn: 342167
* Re-commit "Modernize NativeProcessProtocol::GetSoftwareBreakpointTrapOpcode"Pavel Labath2018-09-092-27/+0
| | | | | | | | | | | | | This recommits r341487, which was reverted due to failing tests with clang. It turned out I had incorrectly expected that the literal arrays passed to ArrayRef constructor will have static (permanent) storage. This was only the case with gcc, while clang was constructing them on stack, leading to dangling pointers when the function returns. The fix is to explicitly assign static storage duration to the opcode arrays. llvm-svn: 341758
* Revert "Modernize NativeProcessProtocol::GetSoftwareBreakpointTrapOpcode"Pavel Labath2018-09-082-0/+27
| | | | | | | This reverts commit r341487. Jan Kratochvil reports it breaks LLDB when compiling with clang. llvm-svn: 341747
* Modernize NativeProcessProtocol::GetSoftwareBreakpointTrapOpcodePavel Labath2018-09-052-27/+0
| | | | | | | | | | | | return the opcode as a Expected<ArrayRef> instead of a Status+pointer+size combo. I also move the linux implementation to the base class, as the trap opcodes are likely to be the same for all/most implementations of the class (except the arm one, where linux chooses a different opcode than what the arm spec recommends, which I keep linux-specific). llvm-svn: 341487
* Move RegisterValue,Scalar,State from Core to UtilityPavel Labath2018-08-074-5/+4
| | | | | | | | | | | | | These three classes have no external dependencies, but they are used from various low-level APIs. Moving them down to Utility improves overall code layering (although it still does not break any particular dependency completely). The XCode project will need to be updated after this change. Differential Revision: https://reviews.llvm.org/D49740 llvm-svn: 339127
* Normalize some lldb #include statements.James Y Knight2018-05-221-4/+0
| | | | | | | | | | | Most non-local includes of header files living under lldb/sources/ were specified with the full path starting after sources/. However, in a few instances, other sub-directories were added to include paths, or Normalize those few instances to follow the style used by the rest of the codebase, to make it easier to understand. llvm-svn: 333035
* Enable AUTOBRIEF in doxygen configuration.Adrian Prantl2018-05-021-3/+3
| | | | | | | | | | | | | | This brings the LLDB configuration closer to LLVM's and removes visual clutter in the source code by removing the @brief commands from comments. This patch also reflows the paragraphs in all doxygen comments. See also https://reviews.llvm.org/D46290. Differential Revision: https://reviews.llvm.org/D46321 llvm-svn: 331373
* Reflow paragraphs in comments.Adrian Prantl2018-04-302-22/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is intended as a clean up after the big clang-format commit (r280751), which unfortunately resulted in many of the comment paragraphs in LLDB being very hard to read. FYI, the script I used was: import textwrap import commands import os import sys import re tmp = "%s.tmp"%sys.argv[1] out = open(tmp, "w+") with open(sys.argv[1], "r") as f: header = "" text = "" comment = re.compile(r'^( *//) ([^ ].*)$') special = re.compile(r'^((([A-Z]+[: ])|([0-9]+ )).*)|(.*;)$') for line in f: match = comment.match(line) if match and not special.match(match.group(2)): # skip intentionally short comments. if not text and len(match.group(2)) < 40: out.write(line) continue if text: text += " " + match.group(2) else: header = match.group(1) text = match.group(2) continue if text: filled = textwrap.wrap(text, width=(78-len(header)), break_long_words=False) for l in filled: out.write(header+" "+l+'\n') text = "" out.write(line) os.rename(tmp, sys.argv[1]) Differential Revision: https://reviews.llvm.org/D46144 llvm-svn: 331197
* Fix a crash in *NetBSD::Factory::LaunchKamil Rytarowski2018-02-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: We cannot call process_up->SetState() inside the NativeProcessNetBSD::Factory::Launch function because it triggers a NULL pointer deference. The generic code for launching a process in: GDBRemoteCommunicationServerLLGS::LaunchProcess sets the m_debugged_process_up pointer after a successful call to m_process_factory.Launch(). If we attempt to call process_up->SetState() inside a platform specific Launch function we end up dereferencing a NULL pointer in NativeProcessProtocol::GetCurrentThreadID(). Use the proper call process_up->SetState(,false) that sets notify_delegates to false. Sponsored by <The NetBSD Foundation> Reviewers: labath, joerg Reviewed By: labath Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D42868 llvm-svn: 324234
* Fix NetBsd build broken by r323637Pavel Labath2018-01-291-1/+1
| | | | llvm-svn: 323639
OpenPOWER on IntegriCloud