Skip to content

Reapply "[LLDB][ELF Core] Support all the Generic (Negative) SI Codes." #141670

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 6 commits into from
May 29, 2025

Conversation

Jlalond
Copy link
Contributor

@Jlalond Jlalond commented May 27, 2025

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.

@Jlalond Jlalond requested a review from JDevlieghere as a code owner May 27, 2025 20:57
@llvmbot llvmbot added the lldb label May 27, 2025
@Jlalond
Copy link
Contributor Author

Jlalond commented May 27, 2025

@JDevlieghere Is there a way to trigger GreenDragon/Mac CI for this?

@llvmbot
Copy link
Member

llvmbot commented May 27, 2025

@llvm/pr-subscribers-lldb

Author: Jacob Lalonde (Jlalond)

Changes

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.


Patch is 39.84 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/141670.diff

10 Files Affected:

  • (modified) lldb/include/lldb/Target/Platform.h (+3)
  • (modified) lldb/include/lldb/Target/UnixSignals.h (+4-2)
  • (modified) lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp (+105)
  • (modified) lldb/source/Plugins/Platform/Linux/PlatformLinux.h (+2)
  • (modified) lldb/source/Plugins/Process/Utility/LinuxSignals.cpp (+88-66)
  • (modified) lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp (+20-22)
  • (modified) lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp (+44-92)
  • (modified) lldb/source/Plugins/Process/elf-core/ThreadElfCore.h (+22-53)
  • (modified) lldb/source/Target/UnixSignals.cpp (+9-6)
  • (modified) lldb/unittests/Signals/UnixSignalsTest.cpp (+9)
diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h
index a702abb540fd9..35ffdabf907e7 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -21,6 +21,7 @@
 #include "lldb/Core/UserSettingsController.h"
 #include "lldb/Host/File.h"
 #include "lldb/Interpreter/Options.h"
+#include "lldb/Target/StopInfo.h"
 #include "lldb/Utility/ArchSpec.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/FileSpec.h"
@@ -960,6 +961,8 @@ class Platform : public PluginInterface {
 
   virtual CompilerType GetSiginfoType(const llvm::Triple &triple);
 
+  virtual lldb::StopInfoSP GetStopInfoFromSiginfo(Thread &thread) { return {}; }
+
   virtual Args GetExtraStartupCommands();
 
   typedef std::function<Status(const ModuleSpec &module_spec,
diff --git a/lldb/include/lldb/Target/UnixSignals.h b/lldb/include/lldb/Target/UnixSignals.h
index b3605ccefddbe..a1807d69f329b 100644
--- a/lldb/include/lldb/Target/UnixSignals.h
+++ b/lldb/include/lldb/Target/UnixSignals.h
@@ -36,7 +36,9 @@ class UnixSignals {
                        std::optional<int32_t> code = std::nullopt,
                        std::optional<lldb::addr_t> addr = std::nullopt,
                        std::optional<lldb::addr_t> lower = std::nullopt,
-                       std::optional<lldb::addr_t> upper = std::nullopt) const;
+                       std::optional<lldb::addr_t> upper = std::nullopt,
+                       std::optional<uint32_t> pid = std::nullopt,
+                       std::optional<uint32_t> uid = std::nullopt) const;
 
   bool SignalIsValid(int32_t signo) const;
 
@@ -105,7 +107,7 @@ class UnixSignals {
                  llvm::StringRef description,
                  llvm::StringRef alias = llvm::StringRef());
 
-  enum SignalCodePrintOption { None, Address, Bounds };
+  enum SignalCodePrintOption { None, Address, Bounds, Sender };
 
   // Instead of calling this directly, use a ADD_SIGCODE macro to get compile
   // time checks when on the native platform.
diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
index 9db2c83acc125..cb60caf1cb422 100644
--- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -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,107 @@ 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);
+
+  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));
+
+  return StopInfo::CreateStopReasonWithSignal(
+      thread, signo_sp->GetValueAsUnsigned(-1), siginfo_description.c_str(),
+      sicode_sp->GetValueAsUnsigned(0));
+}
diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.h b/lldb/source/Plugins/Platform/Linux/PlatformLinux.h
index 89f0bd709ef60..0fd33b03dcd23 100644
--- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.h
+++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.h
@@ -62,6 +62,8 @@ class PlatformLinux : public PlatformPOSIX {
 
   CompilerType GetSiginfoType(const llvm::Triple &triple) override;
 
+  lldb::StopInfoSP GetStopInfoFromSiginfo(Thread &thread) override;
+
   std::vector<ArchSpec> m_supported_architectures;
 
 private:
diff --git a/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp b/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
index 9c4fe55147a28..76c32e376eb4b 100644
--- a/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
+++ b/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
@@ -38,6 +38,28 @@
 #define ADD_SIGCODE(signal_name, signal_value, code_name, code_value, ...)     \
   AddSignalCode(signal_value, code_value, __VA_ARGS__)
 #endif /* if defined(__linux__) && !defined(__mips__) */
+// 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_QUEUE, -1, "sent by sigqueue",                  \
+              SignalCodePrintOption::Sender);                                  \
+  ADD_SIGCODE(signo, signo, SI_TIMER, -2, "sent by timer expiration",          \
+              SignalCodePrintOption::Sender);                                  \
+  ADD_SIGCODE(signo, signo, SI_MESGQ, -3,                                      \
+              "sent by real time mesq state change",                           \
+              SignalCodePrintOption::Sender);                                  \
+  ADD_SIGCODE(signo, signo, SI_ASYNCIO, -4, "sent by AIO completion",          \
+              SignalCodePrintOption::Sender);                                  \
+  ADD_SIGCODE(signo, signo, SI_SIGIO, -5, "sent by queued SIGIO",              \
+              SignalCodePrintOption::Sender);                                  \
+  ADD_SIGCODE(signo, signo, SI_TKILL, -6, "sent by tkill system call",         \
+              SignalCodePrintOption::Sender);                                  \
+  ADD_SIGCODE(signo, signo, SI_DETHREAD, -7,                                   \
+              "sent by execve() killing subsidiary threads",                   \
+              SignalCodePrintOption::Sender);                                  \
+  ADD_SIGCODE(signo, signo, SI_ASYNCNL, -60,                                   \
+              "sent by glibc async name lookup completion",                    \
+              SignalCodePrintOption::Sender);
 
 using namespace lldb_private;
 
@@ -46,13 +68,13 @@ LinuxSignals::LinuxSignals() : UnixSignals() { Reset(); }
 void LinuxSignals::Reset() {
   m_signals.clear();
   // clang-format off
-  //        SIGNO   NAME            SUPPRESS  STOP    NOTIFY  DESCRIPTION
-  //        ======  ==============  ========  ======  ======  ===================================================
-  AddSignal(1,      "SIGHUP",       false,    true,   true,   "hangup");
-  AddSignal(2,      "SIGINT",       true,     true,   true,   "interrupt");
-  AddSignal(3,      "SIGQUIT",      false,    true,   true,   "quit");
+  //               SIGNO   NAME            SUPPRESS  STOP    NOTIFY  DESCRIPTION
+  //               ======  ==============  ========  ======  ======  ===================================================
+  ADD_LINUX_SIGNAL(1,      "SIGHUP",       false,    true,   true,   "hangup");
+  ADD_LINUX_SIGNAL(2,      "SIGINT",       true,     true,   true,   "interrupt");
+  ADD_LINUX_SIGNAL(3,      "SIGQUIT",      false,    true,   true,   "quit");
 
-  AddSignal(4,      "SIGILL",       false,    true,   true,   "illegal instruction");
+  ADD_LINUX_SIGNAL(4,      "SIGILL",       false,    true,   true,   "illegal instruction");
   ADD_SIGCODE(SIGILL, 4, ILL_ILLOPC, 1, "illegal opcode");
   ADD_SIGCODE(SIGILL, 4, ILL_ILLOPN, 2, "illegal operand");
   ADD_SIGCODE(SIGILL, 4, ILL_ILLADR, 3, "illegal addressing mode");
@@ -62,15 +84,15 @@ void LinuxSignals::Reset() {
   ADD_SIGCODE(SIGILL, 4, ILL_COPROC, 7, "coprocessor error");
   ADD_SIGCODE(SIGILL, 4, ILL_BADSTK, 8, "internal stack error");
 
-  AddSignal(5,      "SIGTRAP",      true,     true,   true,   "trace trap (not reset when caught)");
-  AddSignal(6,      "SIGABRT",      false,    true,   true,   "abort()/IOT trap", "SIGIOT");
+  ADD_LINUX_SIGNAL(5,      "SIGTRAP",      true,     true,   true,   "trace trap (not reset when caught)");
+  ADD_LINUX_SIGNAL(6,      "SIGABRT",      false,    true,   true,   "abort()/IOT trap", "SIGIOT");
 
-  AddSignal(7,      "SIGBUS",       false,    true,   true,   "bus error");
+  ADD_LINUX_SIGNAL(7,      "SIGBUS",       false,    true,   true,   "bus error");
   ADD_SIGCODE(SIGBUS, 7, BUS_ADRALN, 1, "illegal alignment");
   ADD_SIGCODE(SIGBUS, 7, BUS_ADRERR, 2, "illegal address");
   ADD_SIGCODE(SIGBUS, 7, BUS_OBJERR, 3, "hardware error");
 
-  AddSignal(8,      "SIGFPE",       false,    true,   true,   "floating point exception");
+  ADD_LINUX_SIGNAL(8,      "SIGFPE",       false,    true,   true,   "floating point exception");
   ADD_SIGCODE(SIGFPE, 8, FPE_INTDIV, 1, "integer divide by zero");
   ADD_SIGCODE(SIGFPE, 8, FPE_INTOVF, 2, "integer overflow");
   ADD_SIGCODE(SIGFPE, 8, FPE_FLTDIV, 3, "floating point divide by zero");
@@ -80,10 +102,10 @@ void LinuxSignals::Reset() {
   ADD_SIGCODE(SIGFPE, 8, FPE_FLTINV, 7, "floating point invalid operation");
   ADD_SIGCODE(SIGFPE, 8, FPE_FLTSUB, 8, "subscript out of range");
 
-  AddSignal(9,      "SIGKILL",      false,    true,   true,   "kill");
-  AddSignal(10,     "SIGUSR1",      false,    true,   true,   "user defined signal 1");
+  ADD_LINUX_SIGNAL(9,      "SIGKILL",      false,    true,   true,   "kill");
+  ADD_LINUX_SIGNAL(10,     "SIGUSR1",      false,    true,   true,   "user defined signal 1");
 
-  AddSignal(11,     "SIGSEGV",      false,    true,   true,   "segmentation violation");
+  ADD_LINUX_SIGNAL(11,     "SIGSEGV",      false,    true,   true,   "segmentation violation");
   ADD_SIGCODE(SIGSEGV, 11, SEGV_MAPERR,  1, "address not mapped to object", SignalCodePrintOption::Address);
   ADD_SIGCODE(SIGSEGV, 11, SEGV_ACCERR,  2, "invalid permissions for mapped object", SignalCodePrintOption::Address);
   ADD_SIGCODE(SIGSEGV, 11, SEGV_BNDERR,  3, "failed address bounds checks", SignalCodePrintOption::Bounds);
@@ -94,58 +116,58 @@ void LinuxSignals::Reset() {
   // codes. One way to get this is via unaligned SIMD loads. Treat it as invalid address.
   ADD_SIGCODE(SIGSEGV, 11, SI_KERNEL, 0x80, "invalid address", SignalCodePrintOption::Address);
 
-  AddSignal(12,     "SIGUSR2",      false,    true,   true,   "user defined signal 2");
-  AddSignal(13,     "SIGPIPE",      false,    true,   true,   "write to pipe with reading end closed");
-  AddSignal(14,     "SIGALRM",      false,    false,  false,  "alarm");
-  AddSignal(15,     "SIGTERM",      false,    true,   true,   "termination requested");
-  AddSignal(16,     "SIGSTKFLT",    false,    true,   true,   "stack fault");
-  AddSignal(17,     "SIGCHLD",      false,    false,  true,   "child status has changed", "SIGCLD");
-  AddSignal(18,     "SIGCONT",      false,    false,  true,   "process continue");
-  AddSignal(19,     "SIGSTOP",      true,     true,   true,   "process stop");
-  AddSignal(20,     "SIGTSTP",      false,    true,   true,   "tty stop");
-  AddSignal(21,     "SIGTTIN",      false,    true,   true,   "background tty read");
-  AddSignal(22,     "SIGTTOU",      false,    true,   true,   "background tty write");
-  AddSignal(23,     "SIGURG",       false,    true,   true,   "urgent data on socket");
-  AddSignal(24,     "SIGXCPU",      false,    true,   true,   "CPU resource exceeded");
-  AddSignal(25,     "SIGXFSZ",      false,    true,   true,   "file size limit exceeded");
-  AddSignal(26,     "SIGVTALRM",    false,    true,   true,   "virtual time alarm");
-  AddSignal(27,     "SIGPROF",      false,    false,  false,  "profiling time alarm");
-  AddSignal(28,     "SIGWINCH",     false,    true,   true,   "window size changes");
-  AddSignal(29,     "SIGIO",        false,    true,   true,   "input/output ready/Pollable event", "SIGPOLL");
-  AddSignal(30,     "SIGPWR",       false,    true,   true,   "power failure");
-  AddSignal(31,     "SIGSYS",       false,    true,   true,   "invalid system call");
-  AddSignal(32,     "SIG32",        false,    false,  false,  "threading library internal signal 1");
-  AddSignal(33,     "SIG33",        false,    false,  false,  "threading library internal signal 2");
-  AddSignal(34,     "SIGRTMIN",     false,    false,  false,  "real time signal 0");
-  AddSignal(35,     "SIGRTMIN+1",   false,    false,  false,  "real time signal 1");
-  AddSignal(36,     "SIGRTMIN+2",   false,    false,  false,  "real time signal 2");
-  AddSignal(37,     "SIGRTMIN+3",   false,    false,  false,  "real time signal 3");
-  AddSignal(38,     "SIGRTMIN+4",   false,    false,  false,  "real time signal 4");
-  AddSignal(39,     "SIGRTMIN+5",   false,    false,  false,  "real time signal 5");
-  AddSignal(40,     "SIGRTMIN+6",   false,    false,  false,  "real time signal 6");
-  AddSignal(41,     "SIGRTMIN+7",   false,    false,  false,  "real time signal 7");
-  AddSignal(42,     "SIGRTMIN+8",   false,    false,  false,  "real time signal 8");
-  AddSignal(43,     "SIGRTMIN+9",   false,    false,  false,  "real time signal 9");
-  AddSignal(44,     "SIGRTMIN+10",  false,    false,  false,  "real time signal 10");
-  AddSignal(45,     "SIGRTMIN+11",  false,    false,  false,  "real time signal 11");
-  AddSignal(46,     "SIGRTMIN+12",  false,    false,  false,  "real time signal 12");
-  AddSignal(47,     "SIGRTMIN+13",  false,    false,  false,  "real time signal 13");
-  AddSignal(48,     "SIGRTMIN+14",  false,    false,  false,  "real time signal 14");
-  AddSignal(49,     "SIGRTMIN+15",  false,    false,  false,  "real time signal 15");
-  AddSignal(50,     "SIGRTMAX-14",  false,    false,  false,  "real time signal 16"); // switching to SIGRTMAX-xxx to match "kill -l" output
-  AddSignal(51,     "SIGRTMAX-13",  false,    false,  false,  "real time signal 17");
-  AddSignal(52,     "SIGRTMAX-12",  false,    false,  false,  "real time signal 18");
-  AddSignal(53,     "SIGRTMAX-11",  false,    false,  false,  "real time signal 19");
-  AddSignal(54,     "SIGRTMAX-10",  false,    false,  false,  "real time signal 20");
-  AddSignal(55,     "SIGRTMAX-9",   false,    false,  false,  "real time signal 21");
-  AddSignal(56,     "SIGRTMAX-8",   false,    false,  false,  "real time signal 22");
-  AddSignal(57,     "SIGRTMAX-7",   false,    false,  false,  "real time signal 23");
-  AddSignal(58,     "SIGRTMAX-6",   false,    false,  false,  "real time signal 24");
-  AddSignal(59,     "SIGRTMAX-5",   false,    false,  false,  "real time signal 25");
-  AddSignal(60,     "SIGRTMAX-4",   false,    false,  false,  "real time signal 26");
-  AddSignal(61,     "SIGRTMAX-3",   false,    false,  false,  "real time signal 27");
-  AddSignal(62,     "SIGRTMAX-2",   false,    false,  false,  "real time signal 28");
-  AddSignal(63,     "SIGRTMAX-1",   false,    false,  false,  "real time signal 29");
-  AddSignal(64,     "SIGRTMAX",     false,    false,  false,  "real time signal 30");
+  ADD_LINUX_SIGNAL(12,     "SIGUSR2",      false,    true,   true,   "user defined signal 2");
+  ADD_LINUX_SIGNAL(13,     "SIGPIPE",      false,    true,   true,   "write to pipe with reading end closed");
+  ADD_LINUX_SIGNAL(14,     "SIGALRM",      false,    false,  false,  "alarm");
+  ADD_LINUX_SIGNAL(15,     "SIGTERM",      false,    true,   true,   "termination requested");
+  ADD_LINUX_SIGNAL(16,     "SIGSTKFLT",    false,    true,   true,   "stack fault");
+  ADD_LINUX_SIGNAL(17,     "SIGCHLD",      false,    false,  true,   "child status has changed", "SIGCLD");
+  ADD_LINUX_SIGNAL(18,     "SIGCONT",      false,    false,  true,   "process continue");
+  ADD_LINUX_SIGNAL(19,     "SIGSTOP",      true,     true,   true,   "process stop");
+  ADD_LINUX_SIGNAL(20,     "SIGTSTP",      false,    true,   true,   "tty stop");
+  ADD_LINUX_SIGNAL(21,     "SIGTTIN",      false,    true,   true,   "background tty read");
+  ADD_LINUX_SIGNAL(22,     "SIGTTOU",      false,    true,   true,   "background tty write");
+  ADD_LINUX_SIGNAL(23,     "SIGURG",       false,    true,   true,   "urgent data on socket");
+  ADD_LINUX_SIGNAL(24,     "SIGXCPU",      false,    true,   true,   "CPU resource exceeded");
+  ADD_LINUX_SIGNAL(25,     "SIGXFSZ",      false,    true,   true,   "file size limit exceeded");
+  ADD_LINUX_SIGNAL(26,     "SIGVTALRM",    false,    true,   true,   "virtual time alarm");
+  ADD_LINUX_SIGNAL(27,     "SIGPROF",      false,    false,  false,  "profiling time alarm");
+  ADD_LINUX_SIGNAL(28,     "SIGWINCH",     false,    true,   true,   "window size changes");
+  ADD_LINUX_SIGNAL(29,     "SIGIO",        false,    true,   true,   "input/output ready/Pollable event", "SIGPOLL");
+  ADD_LINUX_SIGNAL(30,     "SIGPWR",       false,    true,   true,   "power failure");
+  ADD_LINUX_SIGNAL(31,     "SIGSYS",       false,    true,   true,   "invalid system call");
+  ADD_LINUX_SIGNAL(32,     "SIG32",        false,    false,  false,  "threading library internal signal 1");
+  ADD_LINUX_SIGNAL(33,     "SIG33",        false,    false,  false,  "threading library internal signal 2");
+  ADD_LINUX_SIGNAL(34,     "SIGRTMIN",     false,    false,  false,  "real time signal 0");
+  ADD_LINUX_SIGNAL(35,     "SIGRTMIN+1",   false,    false,  false,  "real time signal 1");
+  ADD_LINUX_SIGNAL(36,     "SIGRTMIN+2",   false,    false,  false,  "real time signal 2");
+  ADD_LINUX_SIGNAL(37,     "SIGRTMIN+3",   false,    false,  false,  "real time signal 3");
+  ADD_LINUX_SIGNAL(38,     "SIGRTMIN+4",   false,    false,  false,  "real time signal 4");
+  ADD_LINUX_SIGNAL(39,     "SIGRTMIN+5",   false,    false,  false,  "real time signal 5");
+  ADD_LINUX_SIGNAL(40,     "SIGRTMIN+6",   false,    false,  false,  "real time s...
[truncated]

@JDevlieghere
Copy link
Member

@JDevlieghere Is there a way to trigger GreenDragon/Mac CI for this?

Unfortunately not, but I can apply this patch locally and tell you if it passes if that helps?

Copy link

github-actions bot commented May 27, 2025

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

@Jlalond Jlalond force-pushed the negative-si-code-fix branch from b0e7574 to 7fcf30e Compare May 27, 2025 21:01
@Jlalond
Copy link
Contributor Author

Jlalond commented May 27, 2025

@JDevlieghere Is there a way to trigger GreenDragon/Mac CI for this?

Unfortunately not, but I can apply this patch locally and tell you if it passes if that helps?

That would be incredibly nice! I did some manual testing but I'm fighting my Mac on getting the tests to not come up as unsupported. I'd feel a lot more confident with a second double-check

@JDevlieghere
Copy link
Member

functionalities/postmortem/elf-core/TestLinuxCore.py is still failing:

FAIL: lldb-api :: functionalities/postmortem/elf-core/TestLinuxCore.py (4 of 1276)
******************** TEST 'lldb-api :: functionalities/postmortem/elf-core/TestLinuxCore.py' FAILED ********************
Command Output (stdout):
--
lldb version 21.0.0git (git@github.com:llvm/llvm-project.git revision c720f920094e445af23ce8e214813f57694ab716)
  clang revision c720f920094e445af23ce8e214813f57694ab716
  llvm revision c720f920094e445af23ce8e214813f57694ab716
Skipping the following test categories: ['libstdcxx', 'dwo', 'llgs', 'fork']

--
Command Output (stderr):
--
PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_FPR_SSE (TestLinuxCore.LinuxCoreTestCase)
PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_aarch64 (TestLinuxCore.LinuxCoreTestCase)
PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_aarch64_pac (TestLinuxCore.LinuxCoreTestCase)
PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_aarch64_pac_regs (TestLinuxCore.LinuxCoreTestCase)
PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_aarch64_regs (TestLinuxCore.LinuxCoreTestCase)
PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_aarch64_sve_regs_fpsimd (TestLinuxCore.LinuxCoreTestCase)
PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_aarch64_sve_regs_full (TestLinuxCore.LinuxCoreTestCase)
PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_arm_core (TestLinuxCore.LinuxCoreTestCase)
PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_get_core_file_api (TestLinuxCore.LinuxCoreTestCase)
PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_i386 (TestLinuxCore.LinuxCoreTestCase)
PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_i386_sysroot (TestLinuxCore.LinuxCoreTestCase)
FAIL: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_loongarch64 (TestLinuxCore.LinuxCoreTestCase)
FAIL: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_loongarch64_regs (TestLinuxCore.LinuxCoreTestCase)
PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_object_map (TestLinuxCore.LinuxCoreTestCase)
FAIL: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_ppc64le (TestLinuxCore.LinuxCoreTestCase)
PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_read_memory (TestLinuxCore.LinuxCoreTestCase)
PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_read_only_cstring (TestLinuxCore.LinuxCoreTestCase)
FAIL: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_riscv64_gpr_fpr (TestLinuxCore.LinuxCoreTestCase)
FAIL: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_riscv64_gpr_only (TestLinuxCore.LinuxCoreTestCase)
FAIL: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_riscv64_regs_gpr_fpr (TestLinuxCore.LinuxCoreTestCase)
FAIL: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_riscv64_regs_gpr_only (TestLinuxCore.LinuxCoreTestCase)
PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_s390x (TestLinuxCore.LinuxCoreTestCase)
PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_same_pid_running (TestLinuxCore.LinuxCoreTestCase)
PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_two_cores_same_pid (TestLinuxCore.LinuxCoreTestCase)
PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_write_register (TestLinuxCore.LinuxCoreTestCase)
PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_x86_64 (TestLinuxCore.LinuxCoreTestCase)
PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-arm64) :: test_x86_64_sysroot (TestLinuxCore.LinuxCoreTestCase)
======================================================================
FAIL: test_loongarch64 (TestLinuxCore.LinuxCoreTestCase)
    Test that lldb can read the process information from an loongarch64 linux core file.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jonas/llvm/llvm-project/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py", line 90, in test_loongarch64
    self.do_test(
  File "/Users/jonas/llvm/llvm-project/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py", line 1128, in do_test
    self.check_all(process, pid, region_count, thread_name)
  File "/Users/jonas/llvm/llvm-project/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py", line 1114, in check_all
    self.assertTrue(process, PROCESS_IS_VALID)
AssertionError: No value is not true : Process is valid
Config=arm64-/Users/jonas/llvm/build-ra/bin/clang
======================================================================
FAIL: test_loongarch64_regs (TestLinuxCore.LinuxCoreTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jonas/llvm/llvm-project/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py", line 951, in test_loongarch64_regs
    self.expect(
  File "/Users/jonas/llvm/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 2406, in expect
    self.runCmd(
  File "/Users/jonas/llvm/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 1005, in runCmd
    self.assertTrue(self.res.Succeeded(), msg + output)
AssertionError: False is not true : Command 'register read r0' did not return successfully
Error output:
error: Command requires a process which is currently stopped.

Config=arm64-/Users/jonas/llvm/build-ra/bin/clang
======================================================================
FAIL: test_ppc64le (TestLinuxCore.LinuxCoreTestCase)
    Test that lldb can read the process information from an ppc64le linux core file.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jonas/llvm/llvm-project/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py", line 49, in test_ppc64le
    self.do_test(
  File "/Users/jonas/llvm/llvm-project/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py", line 1128, in do_test
    self.check_all(process, pid, region_count, thread_name)
  File "/Users/jonas/llvm/llvm-project/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py", line 1114, in check_all
    self.assertTrue(process, PROCESS_IS_VALID)
AssertionError: No value is not true : Process is valid
Config=arm64-/Users/jonas/llvm/build-ra/bin/clang
======================================================================
FAIL: test_riscv64_gpr_fpr (TestLinuxCore.LinuxCoreTestCase)
    Test that lldb can read the process information from an riscv64 linux core file.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jonas/llvm/llvm-project/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py", line 69, in test_riscv64_gpr_fpr
    self.do_test(
  File "/Users/jonas/llvm/llvm-project/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py", line 1128, in do_test
    self.check_all(process, pid, region_count, thread_name)
  File "/Users/jonas/llvm/llvm-project/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py", line 1114, in check_all
    self.assertTrue(process, PROCESS_IS_VALID)
AssertionError: No value is not true : Process is valid
Config=arm64-/Users/jonas/llvm/build-ra/bin/clang
======================================================================
FAIL: test_riscv64_gpr_only (TestLinuxCore.LinuxCoreTestCase)
    Test that lldb can read the process information from an riscv64 linux core file
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jonas/llvm/llvm-project/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py", line 80, in test_riscv64_gpr_only
    self.do_test(
  File "/Users/jonas/llvm/llvm-project/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py", line 1128, in do_test
    self.check_all(process, pid, region_count, thread_name)
  File "/Users/jonas/llvm/llvm-project/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py", line 1114, in check_all
    self.assertTrue(process, PROCESS_IS_VALID)
AssertionError: No value is not true : Process is valid
Config=arm64-/Users/jonas/llvm/build-ra/bin/clang
======================================================================
FAIL: test_riscv64_regs_gpr_fpr (TestLinuxCore.LinuxCoreTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jonas/llvm/llvm-project/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py", line 782, in test_riscv64_regs_gpr_fpr
    self.expect(
  File "/Users/jonas/llvm/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 2406, in expect
    self.runCmd(
  File "/Users/jonas/llvm/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 1005, in runCmd
    self.assertTrue(self.res.Succeeded(), msg + output)
AssertionError: False is not true : Command 'register read pc' did not return successfully
Error output:
error: Command requires a process which is currently stopped.

Config=arm64-/Users/jonas/llvm/build-ra/bin/clang
======================================================================
FAIL: test_riscv64_regs_gpr_only (TestLinuxCore.LinuxCoreTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jonas/llvm/llvm-project/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py", line 845, in test_riscv64_regs_gpr_only
    self.expect(
  File "/Users/jonas/llvm/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 2406, in expect
    self.runCmd(
  File "/Users/jonas/llvm/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 1005, in runCmd
    self.assertTrue(self.res.Succeeded(), msg + output)
AssertionError: False is not true : Command 'register read pc' did not return successfully
Error output:
error: Command requires a process which is currently stopped.

Config=arm64-/Users/jonas/llvm/build-ra/bin/clang
----------------------------------------------------------------------
Ran 27 tests in 22.402s

FAILED (failures=7)

@Jlalond
Copy link
Contributor Author

Jlalond commented May 28, 2025

@labath

We need to handle situations where the core won't have a valid platform, and then fallback to other info (like PRSTATUS).

Please check the last commit in this patch. I think this will almost exclusively be an artifact of our tests, but I'm not sure how else to handle this

@Jlalond Jlalond force-pushed the negative-si-code-fix branch from 46af35d to b6fa2d2 Compare May 28, 2025 01:27
@labath
Copy link
Collaborator

labath commented May 28, 2025

@labath

We need to handle situations where the core won't have a valid platform, and then fallback to other info (like PRSTATUS).

Please check the last commit in this patch. I think this will almost exclusively be an artifact of our tests, but I'm not sure how else to handle this

So, this particular failure is due to broken/incomplete support for these architectures (they weren't added to this list). The list only matters on mac because we probably end up somehow falling back to the host platform.

I expect adding them there would fix this. However I also think it makes sense to not fail catastrophically in case we cannot read/parse signal info, so I'm fine with the change you made in principle, but the I find the implementation somewhat unelegant. Do we actually need to access the platform class from ELFLinuxSigInfo::Parse? The data extractor should have already been set to the size of the siginfo note, right? Could we postpone the size check and move it closer to the place which actually uses the type? Thread::GetSiginfoValue maybe?

@Jlalond
Copy link
Contributor Author

Jlalond commented May 28, 2025

but the I find the implementation somewhat unelegant.

😎 That's certainly me!

In all seriousness, I am still drinking from the proverbial firehouse. So I appreciate the patience as I learn the codebase (even a year later).

You are correct, the checks are now unimportant because Thread::GetSiginfoValue will handle this for us directly, and we have a fallback clause in CalculateStopInfo that handled that error case. I've removed this clause. I still need to address Petr's build concern before we reapply this. I didn't see the comment on the other patch, this is good to go

@Jlalond Jlalond force-pushed the negative-si-code-fix branch from 76891c7 to c083af6 Compare May 28, 2025 16:29
@Jlalond Jlalond requested a review from labath May 28, 2025 17:51
@Jlalond
Copy link
Contributor Author

Jlalond commented May 29, 2025

@JDevlieghere I did run this on my local Mac (Very slowly on an M1 🥲). Got no failures, but still FYI

@Jlalond Jlalond merged commit 5fe9aea into llvm:main May 29, 2025
10 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented May 29, 2025

LLVM Buildbot has detected a new failure on builder lldb-remote-linux-win running on as-builder-10 while building lldb at step 8 "build-default".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/197/builds/5997

Here is the relevant piece of the build log for the reference
Step 8 (build-default) failure: cmake (failure)
...
110.921 [633/130/4709]Building CXX object tools\lldb\source\API\CMakeFiles\liblldb.dir\SBWatchpoint.cpp.obj
110.945 [632/130/4710]Building CXX object tools\lldb\source\API\CMakeFiles\liblldb.dir\SBTypeEnumMember.cpp.obj
111.136 [631/130/4711]Building CXX object tools\lldb\source\API\CMakeFiles\liblldb.dir\SBValueList.cpp.obj
111.178 [630/130/4712]Building CXX object tools\lldb\source\API\CMakeFiles\liblldb.dir\SBVariablesOptions.cpp.obj
111.399 [629/130/4713]Building CXX object tools\lldb\source\API\CMakeFiles\liblldb.dir\SBWatchpointOptions.cpp.obj
111.622 [628/130/4714]Building CXX object tools\lldb\source\API\CMakeFiles\liblldb.dir\SBValue.cpp.obj
111.676 [627/130/4715]Linking CXX static library lib\lldbValueObject.lib
111.824 [626/130/4716]Building CXX object tools\lldb\tools\lldb-dap\CMakeFiles\lldbDAP.dir\DAPLog.cpp.obj
112.070 [625/130/4717]Building CXX object tools\lldb\tools\lldb-dap\CMakeFiles\lldbDAP.dir\DAPError.cpp.obj
112.170 [624/130/4718]Building CXX object tools\lldb\source\Plugins\Platform\Linux\CMakeFiles\lldbPluginPlatformLinux.dir\PlatformLinux.cpp.obj
FAILED: tools/lldb/source/Plugins/Platform/Linux/CMakeFiles/lldbPluginPlatformLinux.dir/PlatformLinux.cpp.obj 
ccache C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1444~1.352\bin\Hostx64\x64\cl.exe  /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:\buildbot\as-builder-10\lldb-x-aarch64\build\tools\lldb\source\Plugins\Platform\Linux -IC:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\source\Plugins\Platform\Linux -IC:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\include -IC:\buildbot\as-builder-10\lldb-x-aarch64\build\tools\lldb\include -IC:\buildbot\as-builder-10\lldb-x-aarch64\build\include -IC:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\llvm\include -IC:\Python312\include -IC:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\llvm\..\clang\include -IC:\buildbot\as-builder-10\lldb-x-aarch64\build\tools\lldb\..\clang\include -IC:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\source -IC:\buildbot\as-builder-10\lldb-x-aarch64\build\tools\lldb\source -D__OPTIMIZE__ /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD   -wd4018 -wd4068 -wd4150 -wd4201 -wd4251 -wd4521 -wd4530 -wd4589  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\lldb\source\Plugins\Platform\Linux\CMakeFiles\lldbPluginPlatformLinux.dir\PlatformLinux.cpp.obj /Fdtools\lldb\source\Plugins\Platform\Linux\CMakeFiles\lldbPluginPlatformLinux.dir\lldbPluginPlatformLinux.pdb /FS -c C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\source\Plugins\Platform\Linux\PlatformLinux.cpp
C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\source\Plugins\Platform\Linux\PlatformLinux.cpp(524): error C2065: 'SIGBUS': undeclared identifier
C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\source\Plugins\Platform\Linux\PlatformLinux.cpp(524): error C2131: expression did not evaluate to a constant
C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\source\Plugins\Platform\Linux\PlatformLinux.cpp(524): note: a non-constant (sub-)expression was encountered
C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\source\Plugins\Platform\Linux\PlatformLinux.cpp(524): error C2051: case expression not constant
112.294 [624/129/4719]Building CXX object tools\lldb\tools\lldb-dap\CMakeFiles\lldbDAP.dir\BreakpointBase.cpp.obj
112.330 [624/128/4720]Building CXX object tools\lldb\source\Plugins\Language\CPlusPlus\CMakeFiles\lldbPluginCPlusPlusLanguage.dir\Coroutines.cpp.obj
112.357 [624/127/4721]Building CXX object tools\lldb\source\API\CMakeFiles\liblldb.dir\__\__\bindings\python\LLDBWrapPython.cpp.obj
cl : Command line warning D9025 : overriding '/W4' with '/W0'
112.365 [624/126/4722]Building RC object tools\lldb\source\API\CMakeFiles\liblldb.dir\C_\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\llvm\resources\windows_version_resource.rc.res
112.370 [624/125/4723]Building CXX object tools\lldb\tools\lldb-dap\CMakeFiles\lldbDAP.dir\Breakpoint.cpp.obj
112.554 [624/124/4724]Building CXX object tools\lldb\source\Plugins\Language\CPlusPlus\CMakeFiles\lldbPluginCPlusPlusLanguage.dir\GenericBitset.cpp.obj
112.810 [624/123/4725]Building CXX object tools\lldb\source\Plugins\SymbolLocator\Default\CMakeFiles\lldbPluginSymbolLocatorDefault.dir\SymbolLocatorDefault.cpp.obj
113.044 [624/122/4726]Building CXX object tools\lldb\source\Symbol\CMakeFiles\lldbSymbol.dir\CompactUnwindInfo.cpp.obj
113.215 [624/121/4727]Building CXX object tools\lldb\source\Plugins\Process\gdb-remote\CMakeFiles\lldbPluginProcessGDBRemote.dir\GDBRemoteCommunication.cpp.obj
113.298 [624/120/4728]Building CXX object tools\lldb\source\Target\CMakeFiles\lldbTarget.dir\UnixSignals.cpp.obj
113.558 [624/119/4729]Building CXX object tools\lldb\source\Plugins\TraceExporter\ctf\CMakeFiles\lldbPluginTraceExporterCTF.dir\TraceExporterCTF.cpp.obj
114.341 [624/118/4730]Building CXX object tools\lldb\source\Plugins\Process\elf-core\CMakeFiles\lldbPluginProcessElfCore.dir\ProcessElfCore.cpp.obj
114.755 [624/117/4731]Building CXX object tools\lldb\source\Symbol\CMakeFiles\lldbSymbol.dir\CompilerType.cpp.obj
114.856 [624/116/4732]Building CXX object tools\lldb\source\Plugins\Language\CPlusPlus\CMakeFiles\lldbPluginCPlusPlusLanguage.dir\GenericOptional.cpp.obj
115.423 [624/115/4733]Building CXX object tools\lldb\source\Expression\CMakeFiles\lldbExpression.dir\IRInterpreter.cpp.obj
115.429 [624/114/4734]Building CXX object tools\lldb\source\Plugins\Process\minidump\CMakeFiles\lldbPluginProcessMinidump.dir\ProcessMinidump.cpp.obj
115.547 [624/113/4735]Building CXX object tools\lldb\source\Plugins\DynamicLoader\MacOSX-DYLD\CMakeFiles\lldbPluginDynamicLoaderMacOSXDYLD.dir\DynamicLoaderDarwin.cpp.obj
115.822 [624/112/4736]Building CXX object tools\lldb\source\Symbol\CMakeFiles\lldbSymbol.dir\SymbolLocator.cpp.obj
115.854 [624/111/4737]Building CXX object tools\lldb\source\Plugins\Language\CPlusPlus\CMakeFiles\lldbPluginCPlusPlusLanguage.dir\LibCxxUnorderedMap.cpp.obj
115.947 [624/110/4738]Building CXX object tools\lldb\source\Plugins\SymbolLocator\Debuginfod\CMakeFiles\lldbPluginSymbolLocatorDebuginfod.dir\SymbolLocatorDebuginfod.cpp.obj
116.766 [624/109/4739]Building CXX object tools\lldb\source\Plugins\Language\CPlusPlus\CMakeFiles\lldbPluginCPlusPlusLanguage.dir\LibCxxList.cpp.obj
116.993 [624/108/4740]Building CXX object tools\lldb\source\Plugins\Language\CPlusPlus\CMakeFiles\lldbPluginCPlusPlusLanguage.dir\LibStdcpp.cpp.obj
117.003 [624/107/4741]Building CXX object tools\lldb\source\Plugins\ObjectFile\Mach-O\CMakeFiles\lldbPluginObjectFileMachO.dir\ObjectFileMachO.cpp.obj
117.008 [624/106/4742]Building CXX object tools\lldb\source\Symbol\CMakeFiles\lldbSymbol.dir\Symbol.cpp.obj
117.151 [624/105/4743]Building CXX object tools\lldb\source\Plugins\Language\ObjC\CMakeFiles\lldbPluginObjCLanguage.dir\CF.cpp.obj
118.325 [624/104/4744]Building CXX object tools\lldb\source\Plugins\Process\gdb-remote\CMakeFiles\lldbPluginProcessGDBRemote.dir\GDBRemoteCommunicationClient.cpp.obj
118.711 [624/103/4745]Building CXX object tools\lldb\source\Symbol\CMakeFiles\lldbSymbol.dir\Function.cpp.obj
119.531 [624/102/4746]Linking CXX shared library bin\libclang.dll
119.590 [624/101/4747]Building CXX object tools\lldb\source\Plugins\LanguageRuntime\ObjC\GNUstepObjCRuntime\CMakeFiles\lldbPluginGNUstepObjCRuntime.dir\GNUstepObjCRuntime.cpp.obj
119.769 [624/100/4748]Building CXX object tools\lldb\source\Target\CMakeFiles\lldbTarget.dir\RemoteAwarePlatform.cpp.obj
120.484 [624/99/4749]Building CXX object tools\lldb\source\Symbol\CMakeFiles\lldbSymbol.dir\DWARFCallFrameInfo.cpp.obj
120.576 [624/98/4750]Building CXX object tools\lldb\source\Plugins\ScriptInterpreter\Python\CMakeFiles\lldbPluginScriptInterpreterPython.dir\ScriptInterpreterPython.cpp.obj

@Jlalond
Copy link
Contributor Author

Jlalond commented May 29, 2025

Put up a fix for Windows on #141971

@Jlalond
Copy link
Contributor Author

Jlalond commented May 29, 2025

Hey @felipepiovezan am I reading green dragon right https://green.lab.llvm.org/job/llvm.org/job/as-lldb-cmake/changes

Looks like the build with my changes failed (with I believe unrelated test failures), then went green? Does that mean we're working on Darwin?

Jlalond added a commit that referenced this pull request May 29, 2025
Another iteration of fixes for #141670. Platform linux can be used by
other platforms, so we need to supply the signal values if they're not
defined.

Values are from the
[manpage](https://man7.org/linux/man-pages/man7/signal.7.html)
svkeerthy pushed a commit that referenced this pull request May 29, 2025
…." (#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.
svkeerthy pushed a commit that referenced this pull request May 29, 2025
Another iteration of fixes for #141670. Platform linux can be used by
other platforms, so we need to supply the signal values if they're not
defined.

Values are from the
[manpage](https://man7.org/linux/man-pages/man7/signal.7.html)
google-yfyang pushed a commit to google-yfyang/llvm-project that referenced this pull request May 29, 2025
…." (llvm#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.
google-yfyang pushed a commit to google-yfyang/llvm-project that referenced this pull request May 29, 2025
Another iteration of fixes for llvm#141670. Platform linux can be used by
other platforms, so we need to supply the signal values if they're not
defined.

Values are from the
[manpage](https://man7.org/linux/man-pages/man7/signal.7.html)
@DavidSpickett
Copy link
Collaborator

DavidSpickett commented May 30, 2025

After this and the Windows ifdef fixup, TestLinuxCore.py is hanging on Windows. I cut it down and found that ppc64, riscv and loongarch cores can no longer be loaded.

.\bin\lldb.exe C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\API\functionalities\postmortem\elf-core\linux-loongarch64.out --core C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\API\functionalities\postmortem\elf-core\linux-loongarch64.core
(lldb) target create "C:\\Users\\tcwg\\llvm-worker\\lldb-aarch64-windows\\llvm-project\\lldb\\test\\API\\functionalities\\postmortem\\elf-core\\linux-loongarch64.out" --core "C:\\Users\\tcwg\\llvm-worker\\lldb-aarch64-windows\\llvm-project\\lldb\\test\\API\\functionalities\\postmortem\\elf-core\\linux-loongarch64.core"
<...stalls forever...>

I'm trying to find the cause.

NetBSD and FreeBSD cores still work but we don't have any non-x86 cores for those. Linux x86, Arm, AArch64, s390x are working too.

So I suspect some method is not filled in for the 3 broken targets but it's proving tricky to find.

No signs of issues on Linux hosts either, so it could be some assumption we have to make if we are compiled on a non-Linux host, that does not hold true for those 3 architectures or they haven't implemented the fallback method for it.

Doesn't help that all 3 of them don't have upstream bots, because they might be failing in their own native builds too but we wouldn't know.

If I don't find anything in the next couple of hours I'm going to revert this so we don't have failures piling up over the weekend. I will continue to investigate though.

DavidSpickett added a commit to DavidSpickett/llvm-project that referenced this pull request May 30, 2025
After llvm#141670,
TestLinuxCore.py was timing out on our Windows on Arm bot.

Non-Linux core files were ok, as were Linux core files unless
it was ppc64le, riscv64 or loongarch.

I eventually noticed that it was attempting to create
PlatformLinux many times before trying PlatformAndroid,
PlatformMac etc., which it should never need to do.

The tests passed on a Linux host too, to add to the mystery.

Turns out, all I needed to do was mark those architectures
as supported in the PlatformLinux constructor.

If they're not listed there we get stuck here:
```
    // Wait for a stopped event since we just posted one above...
	printf("waiting for process to stop...\n");
    lldb::EventSP event_sp;
    StateType state =
        WaitForProcessToStop(std::nullopt, &event_sp, true, listener_sp,
                             nullptr, true, SelectMostRelevantFrame);
    printf("process stopped\n");
```
Waiting for a stop event that never comes, because it appears we
try to treat the core as a real process?
```
 DynamicLoaderPOSIXDYLD::virtual DynamicLoaderPOSIXDYLD::DidAttach pid 28147 executable '<null executable>', load_offset 0xffffffffffffffff
<...>
 Process::ShouldBroadcastEvent (000002ABC43FF4A0) Restarting process from state: stopped
 Process::PrivateResume() m_stop_id = 1, public state: unloaded private state: stopped
 Process::PrivateResume() got an error "error: elf-core does not support resuming processes".
 Process::ShouldBroadcastEvent (000002ABC43FF4A0) => new state: stopped, last broadcast state: invalid - NO
```

Some sort of actionable feedback here would be nice, but all I care
about for now is that the tests run again.

I have not added riscv32 as that appears to only be supported
for Darwin at the moment (though I expect someone will get
burned by this when it is).

I think debug on these architectures worked if they were also
the host arch, if someone tried to remote debug them, I think
it would fail.
DavidSpickett added a commit that referenced this pull request May 30, 2025
After #141670, TestLinuxCore.py
was timing out on our Windows on Arm bot.

Non-Linux core files were ok, as were Linux core files unless it was
ppc64le, riscv64 or loongarch.

I eventually noticed that it was attempting to create PlatformLinux many
times before trying PlatformAndroid, PlatformMac etc., which it should
never need to do.

The tests passed on a Linux host too, to add to the mystery.

Turns out, all I needed to do was mark those architectures as supported
in the PlatformLinux constructor. If they're not listed there we get
stuck here:
```
    // Wait for a stopped event since we just posted one above...
	printf("waiting for process to stop...\n");
    lldb::EventSP event_sp;
    StateType state =
        WaitForProcessToStop(std::nullopt, &event_sp, true, listener_sp,
                             nullptr, true, SelectMostRelevantFrame);
    printf("process stopped\n");
```
Waiting for a stop event that never comes, because it appears we try to
treat the core as a real process?
```
 DynamicLoaderPOSIXDYLD::virtual DynamicLoaderPOSIXDYLD::DidAttach pid 28147 executable '<null executable>', load_offset 0xffffffffffffffff
<...>
 Process::ShouldBroadcastEvent (000002ABC43FF4A0) Restarting process from state: stopped
 Process::PrivateResume() m_stop_id = 1, public state: unloaded private state: stopped
 Process::PrivateResume() got an error "error: elf-core does not support resuming processes".
 Process::ShouldBroadcastEvent (000002ABC43FF4A0) => new state: stopped, last broadcast state: invalid - NO
```
Some actionable feedback here would be nice, but all I care about for
now is that the tests run again.

I have not added riscv32 as that appears to only be supported for Darwin
at the moment (I expect someone will get burned by this when it is).

I think debug on these architectures worked if they were also the host
arch, if someone tried to remote debug them, I think it would have
failed.
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request May 30, 2025
After llvm/llvm-project#141670, TestLinuxCore.py
was timing out on our Windows on Arm bot.

Non-Linux core files were ok, as were Linux core files unless it was
ppc64le, riscv64 or loongarch.

I eventually noticed that it was attempting to create PlatformLinux many
times before trying PlatformAndroid, PlatformMac etc., which it should
never need to do.

The tests passed on a Linux host too, to add to the mystery.

Turns out, all I needed to do was mark those architectures as supported
in the PlatformLinux constructor. If they're not listed there we get
stuck here:
```
    // Wait for a stopped event since we just posted one above...
	printf("waiting for process to stop...\n");
    lldb::EventSP event_sp;
    StateType state =
        WaitForProcessToStop(std::nullopt, &event_sp, true, listener_sp,
                             nullptr, true, SelectMostRelevantFrame);
    printf("process stopped\n");
```
Waiting for a stop event that never comes, because it appears we try to
treat the core as a real process?
```
 DynamicLoaderPOSIXDYLD::virtual DynamicLoaderPOSIXDYLD::DidAttach pid 28147 executable '<null executable>', load_offset 0xffffffffffffffff
<...>
 Process::ShouldBroadcastEvent (000002ABC43FF4A0) Restarting process from state: stopped
 Process::PrivateResume() m_stop_id = 1, public state: unloaded private state: stopped
 Process::PrivateResume() got an error "error: elf-core does not support resuming processes".
 Process::ShouldBroadcastEvent (000002ABC43FF4A0) => new state: stopped, last broadcast state: invalid - NO
```
Some actionable feedback here would be nice, but all I care about for
now is that the tests run again.

I have not added riscv32 as that appears to only be supported for Darwin
at the moment (I expect someone will get burned by this when it is).

I think debug on these architectures worked if they were also the host
arch, if someone tried to remote debug them, I think it would have
failed.
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
…." (llvm#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.
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
Another iteration of fixes for llvm#141670. Platform linux can be used by
other platforms, so we need to supply the signal values if they're not
defined.

Values are from the
[manpage](https://man7.org/linux/man-pages/man7/signal.7.html)
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
After llvm#141670, TestLinuxCore.py
was timing out on our Windows on Arm bot.

Non-Linux core files were ok, as were Linux core files unless it was
ppc64le, riscv64 or loongarch.

I eventually noticed that it was attempting to create PlatformLinux many
times before trying PlatformAndroid, PlatformMac etc., which it should
never need to do.

The tests passed on a Linux host too, to add to the mystery.

Turns out, all I needed to do was mark those architectures as supported
in the PlatformLinux constructor. If they're not listed there we get
stuck here:
```
    // Wait for a stopped event since we just posted one above...
	printf("waiting for process to stop...\n");
    lldb::EventSP event_sp;
    StateType state =
        WaitForProcessToStop(std::nullopt, &event_sp, true, listener_sp,
                             nullptr, true, SelectMostRelevantFrame);
    printf("process stopped\n");
```
Waiting for a stop event that never comes, because it appears we try to
treat the core as a real process?
```
 DynamicLoaderPOSIXDYLD::virtual DynamicLoaderPOSIXDYLD::DidAttach pid 28147 executable '<null executable>', load_offset 0xffffffffffffffff
<...>
 Process::ShouldBroadcastEvent (000002ABC43FF4A0) Restarting process from state: stopped
 Process::PrivateResume() m_stop_id = 1, public state: unloaded private state: stopped
 Process::PrivateResume() got an error "error: elf-core does not support resuming processes".
 Process::ShouldBroadcastEvent (000002ABC43FF4A0) => new state: stopped, last broadcast state: invalid - NO
```
Some actionable feedback here would be nice, but all I care about for
now is that the tests run again.

I have not added riscv32 as that appears to only be supported for Darwin
at the moment (I expect someone will get burned by this when it is).

I think debug on these architectures worked if they were also the host
arch, if someone tried to remote debug them, I think it would have
failed.
GeorgeHuyubo added a commit that referenced this pull request Jun 12, 2025
…#143793)

Since this PR: #141670 We
started to override the Platform/Arch for a target if needed. However we
may have already registered locate module callback with the old
platform.

This PR will move the locate module callback to the new Platform
whenever Target changes architecture.

Co-authored-by: George Hu <georgehuyubo@gmail.com>
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Jun 12, 2025
…change arch (#143793)

Since this PR: llvm/llvm-project#141670 We
started to override the Platform/Arch for a target if needed. However we
may have already registered locate module callback with the old
platform.

This PR will move the locate module callback to the new Platform
whenever Target changes architecture.

Co-authored-by: George Hu <georgehuyubo@gmail.com>
tomtor pushed a commit to tomtor/llvm-project that referenced this pull request Jun 14, 2025
…llvm#143793)

Since this PR: llvm#141670 We
started to override the Platform/Arch for a target if needed. However we
may have already registered locate module callback with the old
platform.

This PR will move the locate module callback to the new Platform
whenever Target changes architecture.

Co-authored-by: George Hu <georgehuyubo@gmail.com>
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.

6 participants