Skip to content

[LLDB][Platform Linux] Flip uid and pid in get signal description #142200

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 3 commits into from
May 30, 2025

Conversation

Jlalond
Copy link
Contributor

@Jlalond Jlalond commented May 30, 2025

Despite a great review from @labath, I accidentally landed the signal with the UID and PID properties flipped. I was actually trying to write tests for this feature when I discovered it.

This fixes that bug, and add a shell test that runs only on Nix systems.

@Jlalond Jlalond requested a review from JDevlieghere as a code owner May 30, 2025 19:04
@llvmbot llvmbot added the lldb label May 30, 2025
@llvmbot
Copy link
Member

llvmbot commented May 30, 2025

@llvm/pr-subscribers-lldb

Author: Jacob Lalonde (Jlalond)

Changes

Despite a great review from @labath, I accidentally landed the signal with the UID and PID properties flipped. I was actually trying to write tests for this feature when I discovered it.

This fixes that bug, and add a shell test that runs only on Nix systems.


Full diff: https://github.com/llvm/llvm-project/pull/142200.diff

3 Files Affected:

  • (added) lldb/test/Shell/Register/Core/Inputs/tkill.cpp (+10)
  • (added) lldb/test/Shell/Register/Core/Inputs/x86-64-linux-tkill.core ()
  • (added) lldb/test/Shell/Register/Core/x86-64-linux-tkill.test (+6)
diff --git a/lldb/test/Shell/Register/Core/Inputs/tkill.cpp b/lldb/test/Shell/Register/Core/Inputs/tkill.cpp
new file mode 100644
index 0000000000000..79310c7f26b52
--- /dev/null
+++ b/lldb/test/Shell/Register/Core/Inputs/tkill.cpp
@@ -0,0 +1,10 @@
+#include <sys/syscall.h>
+#include <signal.h>
+
+int main() {
+    // Get the current thread ID
+    pid_t tid = syscall(SYS_gettid);
+    // Send a SIGSEGV signal to the current thread
+    syscall(SYS_tkill, tid, SIGSEGV);
+    return 0;
+}
diff --git a/lldb/test/Shell/Register/Core/Inputs/x86-64-linux-tkill.core b/lldb/test/Shell/Register/Core/Inputs/x86-64-linux-tkill.core
new file mode 100644
index 0000000000000..3d1a05a34e7ca
Binary files /dev/null and b/lldb/test/Shell/Register/Core/Inputs/x86-64-linux-tkill.core differ
diff --git a/lldb/test/Shell/Register/Core/x86-64-linux-tkill.test b/lldb/test/Shell/Register/Core/x86-64-linux-tkill.test
new file mode 100644
index 0000000000000..240b1e9f8b2d6
--- /dev/null
+++ b/lldb/test/Shell/Register/Core/x86-64-linux-tkill.test
@@ -0,0 +1,6 @@
+# XFAIL: system-darwin
+# XFAIL: system-windows
+# RUN: %lldb -b -s %s -c %p/Inputs/x86-64-linux-tkill.test | FileCheck %s
+
+thread list
+# CHECK: * thread #1, name = 'tkill.out', stop reason = SIGSEGV: sent by tkill system call (sender pid=649752, uid=2667987)

Copy link

github-actions bot commented May 30, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@Jlalond Jlalond force-pushed the flip-uid-pid-platform-linux branch from b19ac1c to ac33700 Compare May 30, 2025 19:11
@Jlalond Jlalond force-pushed the flip-uid-pid-platform-linux branch from ac33700 to 05f09fa Compare May 30, 2025 19:12
@Jlalond Jlalond changed the title [LLDB][Platform Linux] Flip and add test [LLDB][Platform Linux] Flip uid and pid in get signal description May 30, 2025
@Jlalond Jlalond requested a review from clayborg May 30, 2025 19:44
@@ -0,0 +1,10 @@
#include <signal.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The location of this test is under the "Register" directory, which looks like it is for testing things like register read. Since this is not about examining registers can we find a more suitable location?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think it's weird. Strangely enough all the existing SIGINFO shell tests also live in this directory. I think it would lead to more confusion to break that, but it's a great refactoring opportunity

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strangely enough all the existing SIGINFO shell tests also live in this directory

FWIW, I do see a command-thread-siginfo.test that lives outside this directory.

Copy link
Contributor

@dmpots dmpots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Jlalond Jlalond merged commit 513c1cd into llvm:main May 30, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants