aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Target/UnixSignals.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-05-29Reapply "[LLDB][ELF Core] Support all the Generic (Negative) SI Codes." ↵Jacob Lalonde1-6/+9
(#141670) After some debugging, I found out ProcessELFCore never updates the platform. I've updated ProcessElfCore to set the arch and platform before we parse the Notes.
2025-05-27Revert "[LLDB][ELF Core] Support all the Generic (Negative) SI Codes." (#141645)Jacob Lalonde1-9/+6
Reverts llvm/llvm-project#140150 Broke the Darwin tests, but they pass on Linux. Reverting to make the build healthy while I investigate
2025-05-27[LLDB][ELF Core] Support all the Generic (Negative) SI Codes. (#140150)Jacob Lalonde1-6/+9
Recently, I was on an issue that generated a large number of Coredumps, and every time in both LLDB and GDB the signal was just `SIGSEGV`. This was frustrating because we would expect a `SIGSEGV` to have an address, or ideally even bounds. After some digging I found the `si_code` consistently was -6. With some help from [@cdown](https://github.com/cdown), we found neither LLDB or GDB supports the si_codes sent from [user space](https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/siginfo.h#L185). Excerpted from the sigaction man page. ``` For a regular signal, the following list shows the values which can be placed in si_code for any signal, along with the reason that the signal was generated. ``` For which I added all of the si_codes to every Linux signal. Now for the Coredump that triggered this whole investigation we get the accurate and now very informative summary. <img width="524" alt="image" src="https://github.com/user-attachments/assets/5149f781-ef21-4491-a077-8fac862fbc20" /> Additionally from @labath's suggestion to move this to platform and leverage the existing `getSiginfo()` call on thread, we can now inspect the siginfo struct itself via `thread siginfo`. Giving us another towards GDB parity on elf cores.
2025-01-23[lldb] Enable "frame diagnose" on linux (#123217)Pavel Labath1-4/+4
.. by changing the signal stop reason format :facepalm: The reason this did not work is because the code in `StopInfo::GetCrashingDereference` was looking for the string "address=" to extract the address of the crash. Macos stop reason strings have the form ``` EXC_BAD_ACCESS (code=1, address=0xdead) ``` while on linux they look like: ``` signal SIGSEGV: address not mapped to object (fault address: 0xdead) ``` Extracting the address from a string sounds like a bad idea, but I suppose there's some value in using a consistent format across platforms, so this patch changes the signal format to use the equals sign as well. All of the diagnose tests pass except one, which appears to fail due to something similar #115453 (disassembler reports unrelocated call targets). I've left the tests disabled on windows, as the stop reason reporting code works very differently there, and I suspect it won't work out of the box. If I'm wrong -- the XFAIL will let us know.
2025-01-15[lldb] Add OpenBSD signals (#123005)Brad Smith1-1/+3
Signals 1-32 are matching the default UNIX platform. There are platform specific ones above 32.
2023-09-14[lldb][NFCI] Remove use of ConstString from UnixSignalsAlex Langford1-23/+18
The majority of UnixSignals strings are static in the sense that they do not change. The overwhelming majority of these strings are string literals. Using ConstString to manage their lifetime does not make sense. The only exception to this is one of the subclasses of UnixSignals, for which I have created a StringSet local to that file which will guarantee the lifetimes of these StringRefs. As for the other benefits of ConstString, string uniqueness is not a concern (as many of them are already string literals) and comparing signal names and aliases should not be a hot path. Differential Revision: https://reviews.llvm.org/D159011
2023-08-22[lldb][NFCI] Change return type of UnixSignals::GetSignalInfoAlex Langford1-12/+10
There's no reason for GetSignalInfo to return the signal name. All users of this method only use the return value to determine if the method succeeded in filling in the output parameters, so let's explicitly make it a bool instead of a pointer. Differential Revision: https://reviews.llvm.org/D158457
2023-08-21[lldb] Change UnixSignals::GetSignalAsCString to GetSignalAsStringRefAlex Langford1-5/+4
This is in preparation to remove the uses of ConstString from UnixSignals. Differential Revision: https://reviews.llvm.org/D158209
2023-06-12[lldb] Change return type of UnixSignals::GetShortNameAlex Langford1-4/+2
The short names of each signal name and alias only exist as ConstStrings in this one scenario. For example, GetShortName("SIGHUP") will just give you "HUP". There's not a good reason the string "HUP" needs to be in the ConstString StringPool, and that's true for just about every signal name. Differential Revision: https://reviews.llvm.org/D152582
2023-06-01[lldb][NFCI] Remove use of ConstString from UnixSignals::SignalCodeAlex Langford1-5/+6
On llvm.org and all downstream forks that I'm aware of, SignalCodes are always created from C string literals. They are never compared to anything so they take up space in the ConstString StringPool for no tangible benefit. I've changed the type here to `const llvm::StringLiteral` instead of using a `StringRef` or a `const char *` to express intent -- These strings come from constant data whose lifetime is directly tied to that of the running process (and are thus safe to store). Differential Revision: https://reviews.llvm.org/D151516
2023-03-27Revert "[lldb] Move UnixSignals creation into Platform plugins"Alex Langford1-18/+19
This reverts commit ee232506b870ce5282cc4da5ca493d41d361feb3. As discussed in https://reviews.llvm.org/D146668 we'll find another way forward.
2023-03-20[lldb] Move UnixSignals creation into Platform pluginsAlex Langford1-19/+18
The high level goal of this change is to remove lldbTarget's dependency on lldbPluginProcessUtility. The reason for this existing dependency is so that we can create the appropriate UnixSignals object based on an ArchSpec. Instead of using the ArchSpec, we can instead take advantage of the Platform associated with the current Target. This is accomplished by adding a new method to Platform, CreateUnixSignals, which will create the correct UnixSignals object for us. We then can use `Platform::GetUnixSignals` and rely on that to give us the correct signals as needed. Differential Revision: https://reviews.llvm.org/D146263
2023-03-20[lldb] Implement CrashReason using UnixSignalsDavid Spickett1-0/+63
By adding signal codes to UnixSignals and adding a new function where you can get a string with optional address and bounds. Added signal codes to the Linux, FreeBSD and NetBSD signal sets. I've checked the numbers against the relevant sources. Each signal code has a code number, description and printing options. By default you just get the descripton, you can opt into adding either a fault address or bounds information. Bounds signals we'll use the description, unless we have the bounds values in which case we say whether it is an upper or lower bound issue. GetCrashReasonString remains in CrashReason because we need it to be compiled only for platforms with siginfo_t. Ideally it would move into NativeProcessProtocol, but that is also used by NativeRegisterContextWindows, where there would be no siginfo_t. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D146044
2023-03-13[lldb] Remove MIPS Linux UnixSignalsAlex Langford1-12/+2
MIPS Linux support was removed in ce03a862372a6f36d2fcf80dc80052aa155fcae8
2023-01-07[lldb] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata1-3/+3
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to clean up the "using" declarations, #include "llvm/ADT/Optional.h", etc. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-07[lldb] Add #include <optional> (NFC)Kazu Hirata1-0/+1
This patch adds #include <optional> to those files containing llvm::Optional<...> or Optional<...>. I'll post a separate patch to actually replace llvm::Optional with std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-17[lldb] llvm::Optional::value => operator*/operator->Fangrui Song1-3/+3
std::optional::value() has undesired exception checking semantics and is unavailable in some older Xcode. The call sites block std::optional migration.
2022-07-15Use value instead of getValue (NFC)Kazu Hirata1-4/+3
2022-06-26[lld] Don't use Optional::hasValue (NFC)Kazu Hirata1-3/+3
This patch replaces x.hasValue() with x where x is contextually convertible to bool.
2022-06-25Revert "Don't use Optional::hasValue (NFC)"Kazu Hirata1-3/+4
This reverts commit aa8feeefd3ac6c78ee8f67bf033976fc7d68bc6d.
2022-06-25Don't use Optional::hasValue (NFC)Kazu Hirata1-4/+3
2022-05-26Store a by name list of signals with their actions in the TargetJim Ingham1-1/+23
so that they can be used to prime new Process runs. "process handle" was also changed to populate the dummy target if there's no selected target, so that the settings will get copied into new targets. Differential Revision: https://reviews.llvm.org/D126259
2021-10-27Add unix signal hit counts to the target statistics.Greg Clayton1-0/+18
Android and other platforms make wide use of signals when running applications and this can slow down debug sessions. Tracking this statistic can help us to determine why a debug session is slow. The new data appears inside each target object and reports the signal hit counts: "signals": [ { "SIGSTOP": 1 }, { "SIGUSR1": 1 } ], Differential Revision: https://reviews.llvm.org/D112683
2021-09-25[lldb] Convert misc. StringConvert usesMichał Górny1-4/+2
Replace misc. StringConvert uses with llvm::to_integer() and llvm::to_float(), except for cases where further refactoring is planned. The purpose of this change is to eliminate the StringConvert API that is duplicate to LLVM, and less correct in behavior at the same time. Differential Revision: https://reviews.llvm.org/D110447
2020-10-08[lldb] Format remaining signal table (NFC)Jonas Devlieghere1-33/+33
Restore the signal tables to its original glory and mark it as not to be clang-formatted.
2020-10-08Change the default handling of SIGCONT to nosuppress/nostop/notifyJim Ingham1-1/+1
Except for the few people actually debugging shells, stopping on a SIGCONT doesn't add any value. And for people trying to run tests under the debugger, stopping here is actively inconvenient. So this patch switches the default behavior to not stop. Differential Revision: https://reviews.llvm.org/D89019
2020-10-06[lldb] Format unix signal table (NFC)Jonas Devlieghere1-46/+40
Restore unix signal table to its original glory and mark it as not to be clang-formatted.
2020-02-11[lldb][NFC] Remove several inefficient ConstString -> const char * -> ↵Raphael Isemann1-4/+2
StringRef conversions StringRef will call strlen on the C string which is inefficient (as ConstString already knows the string lenght and so does StringRef). This patch replaces all those calls with GetStringRef() which doesn't recompute the length.
2020-01-24[lldb][NFC] Fix all formatting errors in .cpp file headersRaphael Isemann1-1/+1
Summary: A *.cpp file header in LLDB (and in LLDB) should like this: ``` //===-- TestUtilities.cpp -------------------------------------------------===// ``` However in LLDB most of our source files have arbitrary changes to this format and these changes are spreading through LLDB as folks usually just use the existing source files as templates for their new files (most notably the unnecessary editor language indicator `-*- C++ -*-` is spreading and in every review someone is pointing out that this is wrong, resulting in people pointing out that this is done in the same way in other files). This patch removes most of these inconsistencies including the editor language indicators, all the different missing/additional '-' characters, files that center the file name, missing trailing `===//` (mostly caused by clang-format breaking the line). Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere Reviewed By: JDevlieghere Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D73258
2019-04-10[NFC] Remove ASCII lines from commentsJonas Devlieghere1-2/+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
2019-03-06Resubmit "Don't include UnixSignals.h from Host."Zachary Turner1-0/+7
This was reverted because it breaks the GreenDragon bot, but the reason for the breakage is lost, so I'm resubmitting this now so we can find out what the problem is. llvm-svn: 355528
2019-02-15Revert "Don't include UnixSignals.h from Host."Davide Italiano1-7/+0
It broke the modules green dragon buildbot. llvm-svn: 354177
2019-02-15Don't include UnixSignals.h from Host.Zachary Turner1-0/+7
Host had a function to get the UnixSignals instance corresponding to the current host architecture. This means that Host had to include a file from Target. To break this dependency, just make this a static function directly in UnixSignals. We already have the function UnixSignals::Create(ArchSpec) anyway, so we just need to have UnixSignals::CreateForHost() which determines which value to pass for the ArchSpec. The goal here is to eventually break the Host->Target->Host circular dependency. Differential Revision: https://reviews.llvm.org/D57780 llvm-svn: 354168
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
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
2018-11-11Remove header grouping comments.Jonas Devlieghere1-4/+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
2018-10-12Change the default handling for SIGPIPE to pass/,no-stop/no-notify.Jim Ingham1-1/+1
Most of the time SIGPIPE is just annoying, and so we should pass it on silently it by default. <rdar://problem/39359145> llvm-svn: 344418
2018-04-30Reflow paragraphs in comments.Adrian Prantl1-5/+4
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
2017-11-13Move ArchSpec to the Utility modulePavel Labath1-1/+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
2017-03-07Make LLDB skip server-client roundtrip for signals that don't require any ↵Eugene Zemtsov1-0/+39
actions If QPassSignals packaet is supported by lldb-server, lldb-client will utilize it and ask the server to ignore signals that don't require stops or notifications. Such signals will be immediately re-injected into inferior to continue normal execution. Differential Revision: https://reviews.llvm.org/D30520 llvm-svn: 297231
2016-09-06*** This commit represents a complete reformatting of the LLDB source codeKate Stone1-269/+209
*** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
2016-09-04[NFC] Darwin llgs support from Week of CodeTodd Fiala1-0/+2
This code represents the Week of Code work I did on bringing up lldb-server LLGS support for Darwin. It does not include the Xcode project changes needed, as we don't want to throw that switch until more support is implemented (i.e. this change is inert, no build systems use it yet. I've verified on Ubuntu 16.04, macOS Xcode and macOS cmake builds). This change does some minimal refactoring of code that is shared with the Linux LLGS portion, moving it from NativeProcessLinux into NativeProcessProtocol. That code is also used by NativeProcessDarwin. Current state on Darwin: * Process launching is implemented. (Attach is not). Launching on devices has not yet been tested (FBS/BKS might need a bit of work). * Inferior waitpid monitoring and communication of exit status via MainLoop callback is implemented. * Memory read/write, breakpoints, thread register context, etc. are not yet implemented. This impacts process stop/resume, as the initial launch suspended immediately starts the process up and running because it doesn't know it is supposed to remain stopped. * I implemented the equivalent of MachThreadList as NativeThreadListDarwin, in anticipation that we might want to factor out common parts into NativeThreadList{Protocol} and share some code here. After writing it, though, the fallout from merging Mach Task/Process into a single concept plus some other minor changes makes the whole NativeThreadListDarwin concept nothing more than dead weight. I am likely going to get rid of this class and just manage it directly in NativeProcessDarwin, much like I did for NativeProcessLinux. * There is a stub-out call for starting a STDIO thread. That will go away and adopt the MainLoop pselect-based IOObject reading. I am developing the fully-integrated changes in the following repo, which contains the necessary Xcode bits and the glue that enables lldb-debugserver on a macOS system: https://github.com/tfiala/lldb/tree/llgs-darwin This change also breaks out a few of the lldb-server tests into their own directory, and adds some $qHostInfo tests (not sure why I didn't write those tests back when I initially implemented that on the Linux side). llvm-svn: 280604
2016-02-18Fix Clang-tidy modernize-use-nullptr warnings in some files in ↵Eugene Zelenko1-37/+21
source/Target; other minor fixes. llvm-svn: 261242
2016-01-22Target: fix -Wcast-qual warningSaleem Abdulrasool1-1/+1
We were unnecessarily stripping the const qualifier on the temporary variable. Restore the constness to avoid the warning. NFC. llvm-svn: 258547
2015-12-15Welcome to NetBSD signalsKamil Rytarowski1-1/+3
Summary: Signals 1-32 are matching the default UNIX platform. There are platform specific ones above 32. From the `/usr/include/sys/signal.h` header: ``` #define SIGPWR 32 /* power fail/restart (not reset when caught) */ #ifdef _KERNEL #define SIGRTMIN 33 /* Kernel only; not exposed to userland yet */ #define SIGRTMAX 63 /* Kernel only; not exposed to userland yet */ #endif ``` Reviewers: emaste, joerg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D15482 llvm-svn: 255592
2015-10-20Fix build and some warnings after r250798Tamas Berghammer1-2/+2
llvm-svn: 250810
2015-10-20[LLDB] Insert names with same signo as alias instead of a new entryMohit K. Bhakkad1-41/+52
Reviewers: clayborg, labath. Subscribers: jaydeep, dsanders, bhushan, sagar, nitesh.jain, emaste,lldb-commits. Differential Revision: http://reviews.llvm.org/D13646 llvm-svn: 250801
2015-07-14Refactor Unix signals.Chaoren Lin1-5/+59
Summary: - Consolidate Unix signals selection in UnixSignals. - Make Unix signals available from platform. - Add jSignalsInfo packet to retrieve Unix signals from remote platform. - Get a copy of the platform signal for each remote process. - Update SB API for signals. - Update signal utility in test suite. Reviewers: ovyalov, clayborg Subscribers: chaoren, jingham, labath, emaste, tberghammer, lldb-commits Differential Revision: http://reviews.llvm.org/D11094 llvm-svn: 242101
2015-01-15Moved Args::StringToXIntYZ to StringConvert::ToXIntYZVince Harron1-2/+2
The refactor was motivated by some comments that Greg made http://reviews.llvm.org/D6918 and also to break a dependency cascade that caused functions linking in string->int conversion functions to pull in most of lldb llvm-svn: 226199
2013-10-28Change the default handling for SIGALRM and SIGCHLD to not notify.Jim Ingham1-2/+2
<rdar://problem/15208799> llvm-svn: 193530
2011-07-06Fixed some issues with ARM backtraces by not processing any push/pop Greg Clayton1-33/+33
instructions if they are conditional. Also fixed issues where the PC wasn't getting bit zero stripped for ARM targets when a stack frame was thumb. We now properly call through the GetOpcodeLoadAddress() functions to make sure the addresses are properly stripped for any targets that may decorate up their addresses. We now don't pass the SIGSTOP signals along. We can revisit this soon, but currently this was interfering with debugging some older ARM targets that don't have vCont support in the GDB server. llvm-svn: 134461