-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[LLDB][ELF Core] Support all the Generic (Negative) SI Codes. #140150
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
94d78d5
Update ThreadElfCore
Jlalond 5e5869e
Add sender option to LinuxSignals.cpp
Jlalond 49cd55f
Add test for sender case
Jlalond 01e0911
run GCF
Jlalond 958f1d5
Reconfigure the parsing to get the bytes and convert to value object,…
Jlalond 3e49ae9
Refactor from testing, discovered that the compiler type generated si…
Jlalond 6b0c953
Run GCF
Jlalond 6c7fe04
Set signo to 0 during initialization, fixes shell tests
Jlalond a64901e
Fix signal being overwritten
Jlalond 63d3008
Add checks for all sp's in LinuxSignals.cpp
Jlalond 503e58a
Move everything to platform
Jlalond a2abeb1
Fix coding standards in PlatformLinux, remove sinoinfo=0
Jlalond File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| #include <sys/utsname.h> | ||
| #endif | ||
|
|
||
| #include "Plugins/Process/Utility/LinuxSignals.h" | ||
| #include "Utility/ARM64_DWARF_Registers.h" | ||
| #include "lldb/Core/Debugger.h" | ||
| #include "lldb/Core/PluginManager.h" | ||
|
|
@@ -480,3 +481,111 @@ CompilerType PlatformLinux::GetSiginfoType(const llvm::Triple &triple) { | |
| ast->CompleteTagDeclarationDefinition(siginfo_type); | ||
| return siginfo_type; | ||
| } | ||
|
|
||
| static std::string GetDescriptionFromSiginfo(lldb::ValueObjectSP siginfo_sp) { | ||
| if (!siginfo_sp) | ||
| return ""; | ||
|
|
||
| lldb_private::LinuxSignals linux_signals; | ||
| int code = siginfo_sp->GetChildMemberWithName("si_code")->GetValueAsSigned(0); | ||
| int signo = | ||
| siginfo_sp->GetChildMemberWithName("si_signo")->GetValueAsSigned(-1); | ||
| // si_code = 0 is SI_NOINFO, we just want the description with nothing | ||
| // important | ||
| if (code == 0) | ||
| return linux_signals.GetSignalDescription(signo, code); | ||
|
|
||
| auto sifields = siginfo_sp->GetChildMemberWithName("_sifields"); | ||
| if (!sifields) | ||
| return linux_signals.GetSignalDescription(signo, code); | ||
|
|
||
| // declare everything that we can populate later. | ||
| std::optional<lldb::addr_t> addr; | ||
| std::optional<lldb::addr_t> upper; | ||
| std::optional<lldb::addr_t> lower; | ||
| std::optional<uint32_t> pid; | ||
| std::optional<uint32_t> uid; | ||
|
|
||
| // The negative si_codes are special and mean this signal was sent from user | ||
| // space not the kernel. These take precedence because they break some of the | ||
| // invariants around kernel sent signals. Such as SIGSEGV won't have an | ||
| // address. | ||
| if (code < 0) { | ||
| auto sikill = sifields->GetChildMemberWithName("_kill"); | ||
| if (sikill) { | ||
| auto pid_sp = sikill->GetChildMemberWithName("si_pid"); | ||
| if (pid_sp) | ||
| pid = pid_sp->GetValueAsUnsigned(-1); | ||
| auto uid_sp = sikill->GetChildMemberWithName("si_uid"); | ||
| if (uid_sp) | ||
| uid = uid_sp->GetValueAsUnsigned(-1); | ||
| } | ||
| } else { | ||
|
|
||
| switch (signo) { | ||
| case SIGILL: | ||
| case SIGFPE: | ||
| case SIGBUS: { | ||
| auto sigfault = sifields->GetChildMemberWithName("_sigfault"); | ||
| if (!sigfault) | ||
| break; | ||
|
|
||
| auto addr_sp = sigfault->GetChildMemberWithName("si_addr"); | ||
| if (addr_sp) | ||
| addr = addr_sp->GetValueAsUnsigned(-1); | ||
| break; | ||
| } | ||
| case SIGSEGV: { | ||
| auto sigfault = sifields->GetChildMemberWithName("_sigfault"); | ||
| if (!sigfault) | ||
| break; | ||
|
|
||
| auto addr_sp = sigfault->GetChildMemberWithName("si_addr"); | ||
| if (addr_sp) | ||
| addr = addr_sp->GetValueAsUnsigned(-1); | ||
|
|
||
| auto bounds_sp = sigfault->GetChildMemberWithName("_bounds"); | ||
| if (!bounds_sp) | ||
| break; | ||
|
|
||
| auto addr_bnds_sp = bounds_sp->GetChildMemberWithName("_addr_bnd"); | ||
| if (!addr_bnds_sp) | ||
| break; | ||
|
|
||
| auto lower_sp = addr_bnds_sp->GetChildMemberWithName("_lower"); | ||
| if (lower_sp) | ||
| lower = lower_sp->GetValueAsUnsigned(-1); | ||
|
|
||
| auto upper_sp = addr_bnds_sp->GetChildMemberWithName("_upper"); | ||
| if (upper_sp) | ||
| upper = upper_sp->GetValueAsUnsigned(-1); | ||
|
|
||
| break; | ||
| } | ||
| default: | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| return linux_signals.GetSignalDescription(signo, code, addr, lower, upper, | ||
| uid, pid); | ||
| } | ||
|
|
||
| lldb::StopInfoSP PlatformLinux::GetStopInfoFromSiginfo(Thread &thread) { | ||
| ValueObjectSP siginfo_sp = thread.GetSiginfoValue(); | ||
| if (!siginfo_sp) | ||
| return {}; | ||
| auto signo_sp = siginfo_sp->GetChildMemberWithName("si_signo"); | ||
| auto sicode_sp = siginfo_sp->GetChildMemberWithName("si_code"); | ||
| if (!signo_sp || !sicode_sp) | ||
| return {}; | ||
|
|
||
| std::string siginfo_description = GetDescriptionFromSiginfo(siginfo_sp); | ||
| if (siginfo_description.empty()) | ||
| return StopInfo::CreateStopReasonWithSignal( | ||
| thread, signo_sp->GetValueAsUnsigned(-1)); | ||
| else | ||
|
||
| return StopInfo::CreateStopReasonWithSignal( | ||
| thread, signo_sp->GetValueAsUnsigned(-1), siginfo_description.c_str(), | ||
| sicode_sp->GetValueAsUnsigned(0)); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I don't think it is. The only reference I can find is https://github.com/torvalds/linux/blob/94305e83eccb3120c921cd3a015cd74731140bac/arch/sparc/include/uapi/asm/siginfo.h#L14 and there it's set to 32767.
0 is SI_USER, which is used by
kill, so in theory uid/pid should be set. However, it's also used as a default value, so maybe not printing the uid/pid in this case is actually correct:https://github.com/torvalds/linux/blob/94305e83eccb3120c921cd3a015cd74731140bac/kernel/signal.c#L589-L599
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.
I'm not sure where I got this information, but it shouldn't matter because the code is not defined. Good eye.