[Lldb-commits] [lldb] [lldb][FreeBSDKernel] Supply values for CS/SS registers (PR #192207)

Minsoo Choo via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 15 01:40:06 PDT 2026


https://github.com/mchoo7 updated https://github.com/llvm/llvm-project/pull/192207

>From deb506d5e68073c8e3ad9360bdb4c316dbc710cb Mon Sep 17 00:00:00 2001
From: Minsoo Choo <minsoochoo0122 at proton.me>
Date: Wed, 15 Apr 2026 17:05:31 +0900
Subject: [PATCH 1/2] [lldb][FreeBSDKernel] Supply values for CS/SS registers

Signed-off-by: Minsoo Choo <minsoochoo0122 at proton.me>
---
 .../RegisterContextFreeBSDKernelCore_x86_64.cpp       | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/Process/FreeBSD-Kernel-Core/RegisterContextFreeBSDKernelCore_x86_64.cpp b/lldb/source/Plugins/Process/FreeBSD-Kernel-Core/RegisterContextFreeBSDKernelCore_x86_64.cpp
index 8f833aa47e486..a0cb53526d331 100644
--- a/lldb/source/Plugins/Process/FreeBSD-Kernel-Core/RegisterContextFreeBSDKernelCore_x86_64.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD-Kernel-Core/RegisterContextFreeBSDKernelCore_x86_64.cpp
@@ -58,6 +58,9 @@ bool RegisterContextFreeBSDKernelCore_x86_64::ReadRegister(
     llvm::support::ulittle64_t rip;
   } pcb;
 
+  constexpr unsigned short CODE_SEL = 4 << 3;
+  constexpr unsigned short DATA_SEL = 5 << 3;
+
 #if defined(__FreeBSD__) && defined(__amd64__)
   static_assert(offsetof(struct pcb, pcb_r15) == offsetof(decltype(pcb), r15));
   static_assert(offsetof(struct pcb, pcb_r14) == offsetof(decltype(pcb), r14));
@@ -90,9 +93,13 @@ bool RegisterContextFreeBSDKernelCore_x86_64::ReadRegister(
     REG(rsp);
     REG(rbx);
     REG(rip);
-
 #undef REG
-
+  case lldb_cs_x86_64:
+    value.SetUInt(CODE_SEL, reg_info->byte_size);
+    break;
+  case lldb_ss_x86_64:
+    value.SetUInt(DATA_SEL, reg_info->byte_size);
+    break;
   default:
     return false;
   }

>From 7e09d443588085b1042853ec0969793f08ce8537 Mon Sep 17 00:00:00 2001
From: Minsoo Choo <minsoochoo0122 at proton.me>
Date: Wed, 15 Apr 2026 17:39:26 +0900
Subject: [PATCH 2/2] fixup! Supply values for CS/SS registers

Signed-off-by: Minsoo Choo <minsoochoo0122 at proton.me>
---
 .../RegisterContextFreeBSDKernelCore_x86_64.cpp           | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/Process/FreeBSD-Kernel-Core/RegisterContextFreeBSDKernelCore_x86_64.cpp b/lldb/source/Plugins/Process/FreeBSD-Kernel-Core/RegisterContextFreeBSDKernelCore_x86_64.cpp
index a0cb53526d331..198e15c2f2174 100644
--- a/lldb/source/Plugins/Process/FreeBSD-Kernel-Core/RegisterContextFreeBSDKernelCore_x86_64.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD-Kernel-Core/RegisterContextFreeBSDKernelCore_x86_64.cpp
@@ -58,8 +58,8 @@ bool RegisterContextFreeBSDKernelCore_x86_64::ReadRegister(
     llvm::support::ulittle64_t rip;
   } pcb;
 
-  constexpr unsigned short CODE_SEL = 4 << 3;
-  constexpr unsigned short DATA_SEL = 5 << 3;
+  constexpr unsigned short GCODE_SEL = 4 << 3;
+  constexpr unsigned short GDATA_SEL = 5 << 3;
 
 #if defined(__FreeBSD__) && defined(__amd64__)
   static_assert(offsetof(struct pcb, pcb_r15) == offsetof(decltype(pcb), r15));
@@ -95,10 +95,10 @@ bool RegisterContextFreeBSDKernelCore_x86_64::ReadRegister(
     REG(rip);
 #undef REG
   case lldb_cs_x86_64:
-    value.SetUInt(CODE_SEL, reg_info->byte_size);
+    value.SetUInt(GCODE_SEL, reg_info->byte_size);
     break;
   case lldb_ss_x86_64:
-    value.SetUInt(DATA_SEL, reg_info->byte_size);
+    value.SetUInt(GDATA_SEL, reg_info->byte_size);
     break;
   default:
     return false;



More information about the lldb-commits mailing list