summaryrefslogtreecommitdiff
path: root/gnu/llvm
diff options
context:
space:
mode:
authorASOU Masato <asou@cvs.openbsd.org>2024-08-01 01:43:09 +0000
committerASOU Masato <asou@cvs.openbsd.org>2024-08-01 01:43:09 +0000
commit48c55240f7ced75c33996964fd6fd963a5d50337 (patch)
treecf4c9950c5e34e21f1a526be72592ee4c7270dfb /gnu/llvm
parent1574d3386ffdb3f3c70c60f2905047169ea0a2be (diff)
Possible to read the core file of a process.
Diffstat (limited to 'gnu/llvm')
-rw-r--r--gnu/llvm/lldb/source/Plugins/Process/OpenBSDKernel/ProcessOpenBSDKernel.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/gnu/llvm/lldb/source/Plugins/Process/OpenBSDKernel/ProcessOpenBSDKernel.cpp b/gnu/llvm/lldb/source/Plugins/Process/OpenBSDKernel/ProcessOpenBSDKernel.cpp
index 57724ca9efb..e6b0a3626f4 100644
--- a/gnu/llvm/lldb/source/Plugins/Process/OpenBSDKernel/ProcessOpenBSDKernel.cpp
+++ b/gnu/llvm/lldb/source/Plugins/Process/OpenBSDKernel/ProcessOpenBSDKernel.cpp
@@ -19,6 +19,7 @@
#define _KERNEL
#include <machine/cpu.h>
#include <sys/proc.h>
+#include <sys/exec_elf.h>
#undef _KERNEL
#endif
@@ -60,6 +61,14 @@ lldb::ProcessSP ProcessOpenBSDKernel::CreateInstance(lldb::TargetSP target_sp,
ModuleSP executable = target_sp->GetExecutableModule();
if (crash_file && !can_connect && executable) {
#if defined(__OpenBSD__)
+ char buf[4];
+ FILE *fp = fopen(crash_file->GetPath().c_str(), "r");
+ if (fp == NULL)
+ return nullptr;
+ size_t r = fread(buf, 1, sizeof(buf), fp);
+ fclose(fp);
+ if (r != sizeof(buf) || memcmp(buf, ELFMAG, sizeof(buf)) == 0)
+ return nullptr;
kvm_t *kvm =
kvm_open(executable->GetFileSpec().GetPath().c_str(),
crash_file->GetPath().c_str(), nullptr, O_RDONLY, nullptr);