-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LLDB] Add SI_USER and SI_KERNEL to Linux signals #144800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-lldb Author: Jacob Lalonde (Jlalond) Changes@dmpots and I were investigating a crash when he was developing LLDB earlier. When I loaded the core I was surprised to see LLDB didn't have information for the SI_CODE. Upon inspection we had an si_code of These were overlooked in my last addition of the negative si_codes, and this patch adds SI_USER and SI_KERNEL to the list, covering us for all the codes available to all signals. I kept the code naming the same as what is defined in the Linux source code. SI_KERNEL to my understanding usually indicates something went awry in the Kernel itself, but I think adding that additional detail would not be helpful to most users. @DavidSpickett I'd appreciate your insight into that. Full diff: https://github.com/llvm/llvm-project/pull/144800.diff 1 Files Affected:
diff --git a/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp b/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
index 15a77ce227ec5..ef3d2f2f845da 100644
--- a/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
+++ b/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
@@ -65,6 +65,10 @@
// See siginfo.h in the Linux Kernel, these codes can be sent for any signal.
#define ADD_LINUX_SIGNAL(signo, name, ...) \
AddSignal(signo, name, __VA_ARGS__); \
+ ADD_SIGCODE(signo, signo, SI_USER, 0, "sent by kill, sigsend or raise", \
+ SignalCodePrintOption::Sender); \
+ ADD_SIGCODE(signo, signo, SI_KERNEL, 0x80, "Sent by kernel", \
+ SignalCodePrintOption::Sender); \
ADD_SIGCODE(signo, signo, SI_QUEUE, -1, "sent by sigqueue", \
SignalCodePrintOption::Sender); \
ADD_SIGCODE(signo, signo, SI_TIMER, -2, "sent by timer expiration", \
|
0b55d63
to
157b5a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SI_KERNEL to my understanding usually indicates something went awry in the Kernel itself
If by that you mean "a kernel bug" then the answer is no. It's really a catch-all code for signals originating from inside the kernel. Looking at the sources, it looks like this may be sent in case there's a problem with the page tables (which would be a kernel bug or a hardware issue), but it's also used for things like "insufficient space to set up a signal handler frame" (which is definitely an application issue) and "IO on fd is possible (and application did not request a specific signal to be sent)" (which isn't an issue at all).
Depending on the user's knowledge of / interpretation of how signals work, I don't think "sent by kernel" is enough for them to find their specific problem. Asking my nearest totally accurate AI model:
And you can argue this is just the implementation of signals, not the way applications are supposed to think about it, but I think it's one a lot of people would subscribe to. What you're saying here is that the cause of the generation of the signal (by whomever generates it), was located in a certain place. So the place that tried to execute the illegal instruction, not the place that wrapped up that exception data into a signal. It's crude but maybe just include SI_KERNEL in there? "sent by kernel (SI_KERNEL)". Then we don't have to explain the meaning of SI_KERNEL but I the user do have something I can look up and read about it. And if they do have a kernel side problem, doing some reading is what they'll need to do anyway. |
As @labath mentioned there are a lot of things that could cause this. So I think the crude approach is the right one! I've updated the patch. |
✅ With the latest revision this PR passed the C/C++ code formatter. |
8bf0011
to
a3ce967
Compare
a3ce967
to
67b397b
Compare
@dmpots and I were investigating a crash when he was developing LLDB earlier. When I loaded the core I was surprised to see LLDB didn't have information for the SI_CODE. Upon inspection we had an si_code of `128`, which is the decimal of SI_KERNEL at `0x80`. These were overlooked in my last addition of the negative si_codes, and this patch adds SI_USER and SI_KERNEL to the list, covering us for all the codes available to all signals. [Linux reference link](https://github.com/torvalds/linux/blob/74b4cc9b8780bfe8a3992c9ac0033bf22ac01f19/include/uapi/asm-generic/siginfo.h#L175)  I kept the code naming the same as what is defined in the Linux source code. SI_KERNEL to my understanding usually indicates something went awry in the Kernel itself, but I think adding that additional detail would not be helpful to most users. @DavidSpickett I'd appreciate your insight into that.
@dmpots and I were investigating a crash when he was developing LLDB earlier. When I loaded the core I was surprised to see LLDB didn't have information for the SI_CODE. Upon inspection we had an si_code of
128
, which is the decimal of SI_KERNEL at0x80
.These were overlooked in my last addition of the negative si_codes, and this patch adds SI_USER and SI_KERNEL to the list, covering us for all the codes available to all signals.
Linux reference link
I kept the code naming the same as what is defined in the Linux source code. SI_KERNEL to my understanding usually indicates something went awry in the Kernel itself, but I think adding that additional detail would not be helpful to most users. @DavidSpickett I'd appreciate your insight into that.