[Lldb-commits] [lldb] [lldb][OpenBSD] Implement HostInfoOpenBSD::GetProgramFileSpec() (PR #235230)

via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 23 23:03:08 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Brad Smith (brad0)

<details>
<summary>Changes</summary>

GetProgramFileSpec() on OpenBSD always returned an empty FileSpec.
Use getexecpath(3) to look up the path of the running executable.

---
Full diff: https://github.com/llvm/llvm-project/pull/235230.diff


1 Files Affected:

- (modified) lldb/source/Host/openbsd/HostInfoOpenBSD.cpp (+9) 


``````````diff
diff --git a/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp b/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
index b30c7a83243c0..0a1f712a6b382 100644
--- a/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
+++ b/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
@@ -8,12 +8,14 @@
 
 #include "lldb/Host/openbsd/HostInfoOpenBSD.h"
 
+#include <climits>
 #include <cstdio>
 #include <cstring>
 #include <optional>
 #include <sys/sysctl.h>
 #include <sys/types.h>
 #include <sys/utsname.h>
+#include <unistd.h>
 
 using namespace lldb_private;
 
@@ -48,5 +50,12 @@ std::optional<std::string> HostInfoOpenBSD::GetOSBuildString() {
 
 FileSpec HostInfoOpenBSD::GetProgramFileSpec() {
   static FileSpec g_program_filespec;
+
+  if (!g_program_filespec) {
+    char path[PATH_MAX];
+
+    if (getexecpath(path, sizeof(path)) != -1)
+      g_program_filespec.SetFile(path, FileSpec::Style::native);
+  }
   return g_program_filespec;
 }

``````````

</details>


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


More information about the lldb-commits mailing list