[Lldb-commits] [lldb] [llvm] [lldb][Process/FreeBSDKernel] Add arm support (PR #180674)

Minsoo Choo via lldb-commits lldb-commits at lists.llvm.org
Thu Feb 12 07:20:32 PST 2026


================
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the definition of the RegisterContextFreeBSDKernel_arm
+/// class, which is used for reading registers from PCB on arm kernel dump.
+///
+//===----------------------------------------------------------------------===//
+
+#include "RegisterContextFreeBSDKernel_arm.h"
+#include "Plugins/Process/Utility/lldb-arm-register-enums.h"
+
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Thread.h"
+#include "lldb/Utility/RegisterValue.h"
+#include "llvm/Support/Endian.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+RegisterContextFreeBSDKernel_arm::RegisterContextFreeBSDKernel_arm(
+    Thread &thread, std::unique_ptr<RegisterInfoPOSIX_arm> register_info_up,
+    lldb::addr_t pcb_addr)
+    : RegisterContextPOSIX_arm(thread, std::move(register_info_up)),
+      m_pcb_addr(pcb_addr) {}
+
+bool RegisterContextFreeBSDKernel_arm::ReadGPR() { return true; }
+
+bool RegisterContextFreeBSDKernel_arm::ReadFPR() { return true; }
+
+bool RegisterContextFreeBSDKernel_arm::WriteGPR() {
+  assert(0);
+  return false;
+}
+
+bool RegisterContextFreeBSDKernel_arm::WriteFPR() {
+  assert(0);
+  return false;
+}
+
+bool RegisterContextFreeBSDKernel_arm::ReadRegister(
+    const RegisterInfo *reg_info, RegisterValue &value) {
+  if (m_pcb_addr == LLDB_INVALID_ADDRESS)
+    return false;
+
+  // https://cgit.freebsd.org/src/tree/sys/arm/include/frame.h
+  // struct pcb's first field is struct switchframe which is the only field used
+  // by debugger and should be aligned by 8 bytes.
+  struct {
+    llvm::support::ulittle32_t r4;
+    llvm::support::ulittle32_t r5;
+    llvm::support::ulittle32_t r6;
+    llvm::support::ulittle32_t r7;
+    llvm::support::ulittle32_t r8;
+    llvm::support::ulittle32_t r9;
+    llvm::support::ulittle32_t r10;
+    llvm::support::ulittle64_t r11;
+    llvm::support::ulittle64_t r12;
+    llvm::support::ulittle64_t sp;
+    llvm::support::ulittle64_t lr;
+    llvm::support::ulittle64_t pc;
+  } pcb;
----------------
mchoo7 wrote:

```cpp
  struct {
    llvm::support::ulittle32_t r4; // Aka switchframe.sf_r4.
    llvm::support::ulittle32_t r5;
    llvm::support::ulittle32_t r6;
    llvm::support::ulittle32_t r7;
    llvm::support::ulittle32_t r8;
    llvm::support::ulittle32_t r9;
    llvm::support::ulittle32_t r10;
    llvm::support::ulittle32_t r11;
    llvm::support::ulittle32_t r12;
    llvm::support::ulittle32_t sp;
    llvm::support::ulittle32_t lr;
    llvm::support::ulittle32_t pc;
    // switchframe.sf_tpidrurw is unused.
    // switchframe.sf_spare0 unused.
  } pcb;
```

I'm good with this, but I don't think we need to state unused fields. Fields that are not used by kernel debuggers are considered unstable and they are subject to change at any time. Actually, a FreeBSD developer is currently working on separating stable pcb and KBI pcb. https://lists.freebsd.org/archives/dev-commits-src-all/2026-February/068344.html

https://github.com/llvm/llvm-project/pull/180674


More information about the lldb-commits mailing list