summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormortimer <mortimer@openbsd.org>2021-02-14 16:16:02 +0000
committermortimer <mortimer@openbsd.org>2021-02-14 16:16:02 +0000
commit0f45e2961faae028025d2069e6591eddbfcaed50 (patch)
treeea3a9392fe023b5ebdf4248d027f594fe91a6cf2
parentPostpone installation of the periodic sensor task until at least one (diff)
downloadwireguard-openbsd-0f45e2961faae028025d2069e6591eddbfcaed50.tar.xz
wireguard-openbsd-0f45e2961faae028025d2069e6591eddbfcaed50.zip
Shuffle how lldb register contexts are built.
Instead of using #if defined(__arch__) to include / exclude the entire contents of the NativeRegisterContext implementations, use a single NativeRegisterContextOpenBSD_arch which includes the right arch specific register context, and provides a dummy implementation for unsupported architectures. This allows building lldb on architectures which do not have a register context implementation so it can be used as a remote client. ok patrick@
-rw-r--r--gnu/llvm/lldb/source/Plugins/Process/OpenBSD/CMakeLists.txt3
-rw-r--r--gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD.h2
-rw-r--r--gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arch.cpp35
-rw-r--r--gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arm64.cpp8
-rw-r--r--gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arm64.h4
-rw-r--r--gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_x86_64.cpp8
-rw-r--r--gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_x86_64.h4
-rw-r--r--gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeThreadOpenBSD.cpp8
-rw-r--r--gnu/usr.bin/clang/liblldbPluginProcess/Makefile5
9 files changed, 48 insertions, 29 deletions
diff --git a/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/CMakeLists.txt b/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/CMakeLists.txt
index 0c24116b57a..424dc348ae8 100644
--- a/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/CMakeLists.txt
+++ b/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/CMakeLists.txt
@@ -1,8 +1,7 @@
add_lldb_library(lldbPluginProcessOpenBSD PLUGIN
NativeProcessOpenBSD.cpp
NativeRegisterContextOpenBSD.cpp
- NativeRegisterContextOpenBSD_x86_64.cpp
- NativeRegisterContextOpenBSD_arm64.cpp
+ NativeRegisterContextOpenBSD_arch.cpp
NativeThreadOpenBSD.cpp
LINK_LIBS
diff --git a/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD.h b/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD.h
index 013fe893fc1..7d86a5b2d37 100644
--- a/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD.h
+++ b/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD.h
@@ -28,7 +28,7 @@ public:
// NativeRegisterContextOpenBSD. The implementations can't collide as only one
// NativeRegisterContextOpenBSD_* variant should be compiled into the final
// executable.
- static NativeRegisterContextOpenBSD *
+ static std::unique_ptr<NativeRegisterContextOpenBSD>
CreateHostNativeRegisterContextOpenBSD(const ArchSpec &target_arch,
NativeThreadProtocol &native_thread);
diff --git a/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arch.cpp b/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arch.cpp
new file mode 100644
index 00000000000..77c56e9f93d
--- /dev/null
+++ b/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arch.cpp
@@ -0,0 +1,35 @@
+//===-- NativeRegisterContextOpenBSD_arch.cpp ---------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// NativeRegisterContextOpenBSD_* contains the implementations for each
+// supported architecture, and includes the static initalizer
+// CreateHostNativeRegisterContextOpenBSD() implementation which returns a arch
+// specific register context. In order to facilitate compiling lldb
+// on architectures which do not have an RegisterContext implementation
+// this file will include the relevant backend, and otherwise will
+// include a stub implentation which just reports an error and exits.
+
+#if defined(__arm64__) || defined(__aarch64__)
+#include "NativeRegisterContextOpenBSD_arm64.cpp"
+#elif defined(__x86_64__)
+#include "NativeRegisterContextOpenBSD_x86_64.cpp"
+#else
+
+#include "Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD.h"
+
+using namespace lldb_private;
+using namespace lldb_private::process_openbsd;
+
+std::unique_ptr<NativeRegisterContextOpenBSD>
+NativeRegisterContextOpenBSD::CreateHostNativeRegisterContextOpenBSD(
+ const ArchSpec &target_arch, NativeThreadProtocol &native_thread) {
+ return std::unique_ptr<NativeRegisterContextOpenBSD>{};
+}
+
+#endif
diff --git a/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arm64.cpp b/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arm64.cpp
index d00d67b4acf..a385bcd6cbf 100644
--- a/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arm64.cpp
+++ b/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arm64.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#if defined(__arm64__) || defined(__aarch64__)
-
#include <elf.h>
#include <err.h>
#include <stdint.h>
@@ -108,10 +106,10 @@ static const RegisterSet g_reg_sets_arm64[k_num_register_sets] = {
{"Floating Point Registers", "fpu", k_num_fpr_registers_arm64,
g_fpu_regnums_arm64}};
-NativeRegisterContextOpenBSD *
+std::unique_ptr<NativeRegisterContextOpenBSD>
NativeRegisterContextOpenBSD::CreateHostNativeRegisterContextOpenBSD(
const ArchSpec &target_arch, NativeThreadProtocol &native_thread) {
- return new NativeRegisterContextOpenBSD_arm64(target_arch, native_thread);
+ return std::make_unique<NativeRegisterContextOpenBSD_arm64>(target_arch, native_thread);
}
// ----------------------------------------------------------------------------
@@ -558,5 +556,3 @@ int NativeRegisterContextOpenBSD_arm64::WriteRegisterSet(uint32_t set) {
}
return -1;
}
-
-#endif // defined(__arm64__) || defined(__aarch64__)
diff --git a/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arm64.h b/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arm64.h
index 8dc482c61c0..7cab092bdc5 100644
--- a/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arm64.h
+++ b/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_arm64.h
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#if defined(__arm64__) || defined(__aarch64__)
-
#ifndef lldb_NativeRegisterContextOpenBSD_arm64_h
#define lldb_NativeRegisterContextOpenBSD_arm64_h
@@ -83,5 +81,3 @@ private:
} // namespace lldb_private
#endif // #ifndef lldb_NativeRegisterContextOpenBSD_arm64_h
-
-#endif // defined(__arm64__) || defined(__aarch64__)
diff --git a/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_x86_64.cpp b/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_x86_64.cpp
index 0b7e8155988..6044d526a2f 100644
--- a/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_x86_64.cpp
+++ b/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_x86_64.cpp
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#if defined(__x86_64__)
-
#include <elf.h>
#include <err.h>
#include <stdint.h>
@@ -110,10 +108,10 @@ struct x86_fpu_addr {
#define REG_CONTEXT_SIZE (GetGPRSize() + GetFPRSize())
-NativeRegisterContextOpenBSD *
+std::unique_ptr<NativeRegisterContextOpenBSD>
NativeRegisterContextOpenBSD::CreateHostNativeRegisterContextOpenBSD(
const ArchSpec &target_arch, NativeThreadProtocol &native_thread) {
- return new NativeRegisterContextOpenBSD_x86_64(target_arch, native_thread);
+ return std::make_unique<NativeRegisterContextOpenBSD_x86_64>(target_arch, native_thread);
}
// ----------------------------------------------------------------------------
@@ -672,5 +670,3 @@ Status NativeRegisterContextOpenBSD_x86_64::WriteAllRegisterValues(
return error;
}
-
-#endif // defined(__x86_64__)
diff --git a/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_x86_64.h b/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_x86_64.h
index 8f66c89f22f..44497d758c0 100644
--- a/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_x86_64.h
+++ b/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeRegisterContextOpenBSD_x86_64.h
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#if defined(__x86_64__)
-
#ifndef lldb_NativeRegisterContextOpenBSD_x86_64_h
#define lldb_NativeRegisterContextOpenBSD_x86_64_h
@@ -70,5 +68,3 @@ private:
} // namespace lldb_private
#endif // #ifndef lldb_NativeRegisterContextOpenBSD_x86_64_h
-
-#endif // defined(__x86_64__)
diff --git a/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeThreadOpenBSD.cpp b/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeThreadOpenBSD.cpp
index f16beee474e..90f14244aa0 100644
--- a/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeThreadOpenBSD.cpp
+++ b/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeThreadOpenBSD.cpp
@@ -27,9 +27,11 @@ using namespace lldb_private::process_openbsd;
NativeThreadOpenBSD::NativeThreadOpenBSD(NativeProcessOpenBSD &process,
lldb::tid_t tid)
: NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid),
- m_stop_info(), m_reg_context_up(
-NativeRegisterContextOpenBSD::CreateHostNativeRegisterContextOpenBSD(process.GetArchitecture(), *this)
-), m_stop_description() {}
+ m_stop_info(), m_stop_description() {
+ m_reg_context_up = NativeRegisterContextOpenBSD::CreateHostNativeRegisterContextOpenBSD(process.GetArchitecture(), *this);
+ if (!m_reg_context_up)
+ llvm_unreachable("This architecture does not support debugging running processes.");
+}
void NativeThreadOpenBSD::SetStoppedBySignal(uint32_t signo,
const siginfo_t *info) {
diff --git a/gnu/usr.bin/clang/liblldbPluginProcess/Makefile b/gnu/usr.bin/clang/liblldbPluginProcess/Makefile
index 687a51eb8b1..87ca6ab426e 100644
--- a/gnu/usr.bin/clang/liblldbPluginProcess/Makefile
+++ b/gnu/usr.bin/clang/liblldbPluginProcess/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.7 2020/08/03 14:45:30 patrick Exp $
+# $OpenBSD: Makefile,v 1.8 2021/02/14 16:16:02 mortimer Exp $
LIB= lldbPluginProcess
NOPIC=
@@ -30,8 +30,7 @@ SRCS= AuxVector.cpp \
MipsLinuxSignals.cpp \
NativeProcessOpenBSD.cpp \
NativeRegisterContextOpenBSD.cpp \
- NativeRegisterContextOpenBSD_x86_64.cpp \
- NativeRegisterContextOpenBSD_arm64.cpp \
+ NativeRegisterContextOpenBSD_arch.cpp \
NativeRegisterContextRegisterInfo.cpp \
NativeThreadOpenBSD.cpp \
NetBSDSignals.cpp \