From 513c1cdfaaa3432dc4674a2d3be3dcaec2b4343e Mon Sep 17 00:00:00 2001 From: Jacob Lalonde Date: Fri, 30 May 2025 14:21:33 -0700 Subject: [PATCH] [LLDB][Platform Linux] Flip uid and pid in get signal description (#142200) 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. --- .../Plugins/Platform/Linux/PlatformLinux.cpp | 2 +- lldb/test/Shell/Register/Core/Inputs/tkill.cpp | 10 ++++++++++ .../Register/Core/Inputs/x86-64-linux-tkill.core | Bin 0 -> 8048 bytes .../Shell/Register/Core/x86-64-linux-tkill.test | 5 +++++ 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 lldb/test/Shell/Register/Core/Inputs/tkill.cpp create mode 100644 lldb/test/Shell/Register/Core/Inputs/x86-64-linux-tkill.core create mode 100644 lldb/test/Shell/Register/Core/x86-64-linux-tkill.test diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp index 269105208a87..da14da44f593 100644 --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -580,7 +580,7 @@ static std::string GetDescriptionFromSiginfo(lldb::ValueObjectSP siginfo_sp) { } return linux_signals.GetSignalDescription(signo, code, addr, lower, upper, - uid, pid); + pid, uid); } lldb::StopInfoSP PlatformLinux::GetStopInfoFromSiginfo(Thread &thread) { 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 000000000000..677bd3e6cf49 --- /dev/null +++ b/lldb/test/Shell/Register/Core/Inputs/tkill.cpp @@ -0,0 +1,10 @@ +#include +#include + +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 0000000000000000000000000000000000000000..3d1a05a34e7ca001108fd3c45c6f68ba5d379a9a GIT binary patch literal 8048 zcmeHMO=w(I6h4iywfNKN!nXdPPf&@3%uHg8?Lv9Bq;X)-N7_hTO(vP3(J>h^6Dfk` z2`(xkOqUjfSa7KhXrb=nP8Y&JH@eGCbfH0TQ47ZV^L@|vZr?DS(wb7{Lf(1j-22^g z?zw;8o2*S1j}PqHB`kyTy!@w$_^gOYUk=L<^g-J9@+B#22a-D5Yaiy_Lw&IP?b(@R zTcc%QgVeY?waL>DRc5apm+)7+PF(2VocJUb=WZQeUO!Z6_K5QhN@U%|4cLkdrB$PR z2C$3& z^MIptaV_9l4z3LxWejKH4DYZFf|X>PfJq9@jF>pDo{p0}wuessym!)Z8y)gVf17Jb z9QtSeDfN0W>$8dRZCyLg%?!pT04eW0_WpF1vjr4*j-QD(a0nrEI*pSgmH4R~x34NUlZqp0;?g~Brvnq*`#lmsU!6R(MWb>QF{RW|qZw&4Ofi9ul-;A9)zY!vP6Wo8@ zO3s=3Dzj&|%hjoai`!kUf+jZy*Z!0Nk$Zzn|3y1=X<4p(nRaqum(x-QXXV@qIV?Eo zyUZUsDmdp)v_~A&a>}1+C&zR-BXw}XPuQLu5uERH#!n6iPIr)rCdUJ3dz^N1DwiWs z2M3Dgg`5Z+=YGaR&I1l}h<0)sa1^d_?lE!icIvph8K&?q$KCuC`{!Ma`(>PV=px^k zbujO*uow!WO55OuBGWaC?Dj&6pr-l)tE4;ydUe0J=J zGq#SE!gnNv#duZi1hb^OxfHa_2D``as9H()dw z`z1AKzGQDefBi1{8R#Jcxh|!LuCA+Tw{L@Pop$@xrW-!~tB#y_ak5x^E;qNhl$$Hp YUsuGZ*bU#W?`L2qGjMWd#{75tU*eM_V*mgE literal 0 HcmV?d00001 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 000000000000..64b99af2d83f --- /dev/null +++ b/lldb/test/Shell/Register/Core/x86-64-linux-tkill.test @@ -0,0 +1,5 @@ +# REQUIRES: system-linux +# RUN: %lldb -b -s %s -c %p/Inputs/x86-64-linux-tkill.core | FileCheck %s + +thread list +# CHECK: hread #1: tid = 2667987, 0x00007f9a265076cd, name = 'tkill.out', stop reason = SIGSEGV: sent by tkill system call (sender pid=2667987, uid=649752)