[Lldb-commits] [lldb] [LLDB][ThreadELFCore] Set all the properties of ELFLinuxSigInfo to a non build dependent size (PR #117604)

Jacob Lalonde via lldb-commits lldb-commits at lists.llvm.org
Mon Nov 25 14:42:04 PST 2024


https://github.com/Jlalond updated https://github.com/llvm/llvm-project/pull/117604

>From 693f1039e10e5dd26ef0d600b03895f71f340b23 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde <jalalonde at fb.com>
Date: Mon, 25 Nov 2024 10:26:07 -0800
Subject: [PATCH 1/2] Set all the properties of ELFLinuxSigInfo to a non build
 dependent size

---
 lldb/source/Plugins/Process/elf-core/ThreadElfCore.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.h b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.h
index 4ebbaadebe9f90..e60ee86e5f5a03 100644
--- a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.h
+++ b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.h
@@ -83,10 +83,10 @@ struct ELFLinuxSigInfo {
   int32_t si_errno;
   int32_t si_code;
   // Copied from siginfo_t so we don't have to include signal.h on non 'Nix
-  // builds.
+  // builds. Slight modifications to ensure no 32b vs 64b differences.
   struct {
-    lldb::addr_t si_addr;  /* faulting insn/memory ref. */
-    short int si_addr_lsb; /* Valid LSB of the reported address.  */
+    lldb::addr_t si_addr; /* faulting insn/memory ref. */
+    int16_t si_addr_lsb;  /* Valid LSB of the reported address.  */
     union {
       /* used when si_code=SEGV_BNDERR */
       struct {
@@ -98,7 +98,8 @@ struct ELFLinuxSigInfo {
     } bounds;
   } sigfault;
 
-  enum { eUnspecified, eNT_SIGINFO } note_type;
+  enum SigInfoNoteType : uint8_t { eUnspecified, eNT_SIGINFO };
+  SigInfoNoteType note_type;
 
   ELFLinuxSigInfo();
 

>From 7578b03833c233f79a199adff07dc37519beb7df Mon Sep 17 00:00:00 2001
From: Jacob Lalonde <jalalonde at fb.com>
Date: Mon, 25 Nov 2024 14:41:52 -0800
Subject: [PATCH 2/2] Add alignas(8) to handle padding of the struct with union

---
 lldb/source/Plugins/Process/elf-core/ThreadElfCore.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.h b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.h
index e60ee86e5f5a03..6f8d41351a6bfb 100644
--- a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.h
+++ b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.h
@@ -84,7 +84,7 @@ struct ELFLinuxSigInfo {
   int32_t si_code;
   // Copied from siginfo_t so we don't have to include signal.h on non 'Nix
   // builds. Slight modifications to ensure no 32b vs 64b differences.
-  struct {
+  struct alignas(8) {
     lldb::addr_t si_addr; /* faulting insn/memory ref. */
     int16_t si_addr_lsb;  /* Valid LSB of the reported address.  */
     union {



More information about the lldb-commits mailing list