From 2ab0082d1ae0cf20de4c92ce9beb5908e677cc76 Mon Sep 17 00:00:00 2001 From: Kurt Miller Date: Mon, 16 Feb 2026 19:17:42 -0500 Subject: [PATCH 1/6] Add debugger support for OpenBSD. --- .../src/main/py/src/ghidragdb/arch.py | 2 + .../src/main/py/src/ghidralldb/arch.py | 1 + Ghidra/Features/FunctionID/build.gradle | 10 +++-- .../src/main/java/ghidra/pty/PtyFactory.java | 3 ++ .../ghidra/pty/openbsd/OpenBSDIoctls.java | 38 ++++++++++++++++++ .../ghidra/pty/openbsd/OpenBSDPtyFactory.java | 40 +++++++++++++++++++ .../pty/openbsd/OpenBSDPtySessionLeader.java | 33 +++++++++++++++ 7 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDIoctls.java create mode 100644 Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDPtyFactory.java create mode 100644 Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDPtySessionLeader.java diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/arch.py b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/arch.py index 28d40395a7..0cdfa5639d 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/arch.py +++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/arch.py @@ -103,6 +103,7 @@ data64_compiler_map: Dict[Optional[str], str] = { x86_compiler_map: Dict[Optional[str], str] = { 'GNU/Linux': 'gcc', + 'OpenBSD': 'gcc', 'Windows': 'windows', # This may seem wrong, but Ghidra cspecs really describe the ABI 'Cygwin': 'windows', @@ -110,6 +111,7 @@ x86_compiler_map: Dict[Optional[str], str] = { riscv_compiler_map: Dict[Optional[str], str] = { 'GNU/Linux': 'gcc', + 'OpenBSD': 'gcc', 'Cygwin': 'gcc', } diff --git a/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/arch.py b/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/arch.py index 4b4a12baa8..66f0d6046a 100644 --- a/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/arch.py +++ b/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/arch.py @@ -135,6 +135,7 @@ default_compiler_map: Dict[Optional[str], str] = { 'freebsd': 'gcc', 'linux': 'gcc', 'netbsd': 'gcc', + 'openbsd': 'gcc', 'ps4': 'gcc', 'ios': 'gcc', 'macosx': 'gcc', diff --git a/Ghidra/Features/FunctionID/build.gradle b/Ghidra/Features/FunctionID/build.gradle index 51c575ded4..e10f30ca4d 100644 --- a/Ghidra/Features/FunctionID/build.gradle +++ b/Ghidra/Features/FunctionID/build.gradle @@ -113,9 +113,10 @@ task buildFidHelpPdf(type: Exec) { // Check the OS before executing command. doFirst { if ( !(org.gradle.internal.os.OperatingSystem.current().isLinux() - || org.gradle.internal.os.OperatingSystem.current().isMacOsX())) { + || org.gradle.internal.os.OperatingSystem.current().isMacOsX() + || org.gradle.internal.os.OperatingSystem.current().isOpenBSD())) { throw new TaskExecutionException( it, - new Exception( "The '$it.name' task only works on Linux or Mac Os X" )) + new Exception( "The '$it.name' task only works on Linux, Mac Os X or OpenBSD" )) } } @@ -177,8 +178,9 @@ task buildFidHelpHtml(type: Exec) { // Check the OS before executing command. doFirst { - if (!getCurrentPlatformName().startsWith("linux")) { - throw new TaskExecutionException( it, new Exception("The '$it.name' task only works on Linux.")) + if (!(getCurrentPlatformName().startsWith("linux") + || getCurrentPlatformName().startsWith("openbsd"))) { + throw new TaskExecutionException( it, new Exception("The '$it.name' task only works on Linux or OpenBSD.")) } } diff --git a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/PtyFactory.java b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/PtyFactory.java index b9d77e44e8..ea30b93a20 100644 --- a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/PtyFactory.java +++ b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/PtyFactory.java @@ -19,6 +19,7 @@ import java.io.IOException; import ghidra.framework.OperatingSystem; import ghidra.pty.linux.LinuxPtyFactory; +import ghidra.pty.openbsd.OpenBSDPtyFactory; import ghidra.pty.macos.MacosPtyFactory; import ghidra.pty.windows.ConPtyFactory; @@ -40,6 +41,8 @@ public interface PtyFactory { return MacosPtyFactory.INSTANCE; case LINUX: return LinuxPtyFactory.INSTANCE; + case OPEN_BSD: + return OpenBSDPtyFactory.INSTANCE; case WINDOWS: return ConPtyFactory.INSTANCE; default: diff --git a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDIoctls.java b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDIoctls.java new file mode 100644 index 0000000000..82264e65f3 --- /dev/null +++ b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDIoctls.java @@ -0,0 +1,38 @@ +/* ### + * IP: GHIDRA + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package ghidra.pty.openbsd; + +import ghidra.pty.unix.PosixC.Ioctls; +import ghidra.pty.unix.UnixPtySessionLeader; + +public enum OpenBSDIoctls implements Ioctls { + INSTANCE; + + @Override + public Class leaderClass() { + return OpenBSDPtySessionLeader.class; + } + + @Override + public long TIOCSCTTY() { + return 0x20007461L; + } + + @Override + public long TIOCSWINSZ() { + return 0x80087467L; + } +} diff --git a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDPtyFactory.java b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDPtyFactory.java new file mode 100644 index 0000000000..a5fc108793 --- /dev/null +++ b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDPtyFactory.java @@ -0,0 +1,40 @@ +/* ### + * IP: GHIDRA + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package ghidra.pty.openbsd; + +import java.io.IOException; + +import ghidra.pty.Pty; +import ghidra.pty.PtyFactory; +import ghidra.pty.unix.UnixPty; + +public enum OpenBSDPtyFactory implements PtyFactory { + INSTANCE; + + @Override + public Pty openpty(short cols, short rows) throws IOException { + UnixPty pty = UnixPty.openpty(OpenBSDIoctls.INSTANCE); + if (cols != 0 && rows != 0) { + pty.getChild().setWindowSize(cols, rows); + } + return pty; + } + + @Override + public String getDescription() { + return "local (OpenBSD)"; + } +} diff --git a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDPtySessionLeader.java b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDPtySessionLeader.java new file mode 100644 index 0000000000..3e960981b2 --- /dev/null +++ b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDPtySessionLeader.java @@ -0,0 +1,33 @@ +/* ### + * IP: GHIDRA + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package ghidra.pty.openbsd; + +import ghidra.pty.unix.PosixC.Ioctls; +import ghidra.pty.unix.UnixPtySessionLeader; + +public class OpenBSDPtySessionLeader extends UnixPtySessionLeader { + + public static void main(String[] args) throws Exception { + OpenBSDPtySessionLeader leader = new OpenBSDPtySessionLeader(); + leader.parseArgs(args); + leader.run(); + } + + @Override + protected Ioctls ioctls() { + return OpenBSDIoctls.INSTANCE; + } +} From e6bc02583c7b50b9a894fc96c57c6d3153137eec Mon Sep 17 00:00:00 2001 From: Kurt Miller Date: Tue, 17 Feb 2026 21:36:55 -0500 Subject: [PATCH 2/6] Use installed protobuf package for protoc on OpenBSD --- gradle/hasProtobuf.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gradle/hasProtobuf.gradle b/gradle/hasProtobuf.gradle index 7a360b5a4e..537c51fb65 100644 --- a/gradle/hasProtobuf.gradle +++ b/gradle/hasProtobuf.gradle @@ -53,6 +53,9 @@ dependencies { protocArtifact "com.google.protobuf:protoc:${version}:osx-aarch_64@exe" } } + if (isCurrentOpenBSD()) { + protocArtifact files('/usr/local/bin/protoc') + } } /*protobuf { From 065617a6a90f656a75c6e33dfc41cc8734e33e69 Mon Sep 17 00:00:00 2001 From: Kurt Miller Date: Mon, 23 Feb 2026 08:33:56 -0500 Subject: [PATCH 3/6] Fix gdb on OpenBSD/amd64 by: * Filtering out registers that are "" when querying gdb for register list. * Force querying gdb for register list on OpenBSD. --- .../Debugger-agent-gdb/src/main/py/src/ghidragdb/util.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/util.py b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/util.py index 9cd311c358..7d16104cb6 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/util.py +++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/util.py @@ -19,6 +19,7 @@ import bisect from dataclasses import dataclass import re from typing import Callable, Dict, List, Optional, Sequence, Set, Tuple, Union +import platform import gdb @@ -467,7 +468,7 @@ class RegisterDesc: def get_register_descs(arch: gdb.Architecture, group: str = 'all') -> List[ Union[RegisterDesc, gdb.RegisterDescriptor]]: - if hasattr(arch, "registers"): + if hasattr(arch, "registers") and platform.system() != "OpenBSD": try: return list(arch.registers(group)) except ValueError: # No such group, or version too old @@ -481,7 +482,7 @@ def get_register_descs(arch: gdb.Architecture, group: str = 'all') -> List[ regset = gdb.execute( f"info registers", to_string=True).strip().split('\n') for line in regset: - if not line.startswith(" "): + if not line.startswith(" ") and "" not in line: tokens = line.strip().split() descs.append(RegisterDesc(tokens[0])) return descs From 6cc363160817af9adb36a0fc0ad0cc16f32c3981 Mon Sep 17 00:00:00 2001 From: Kurt Miller Date: Mon, 8 Jun 2026 07:10:49 -0400 Subject: [PATCH 4/6] Remove 'no debugger support' for OpenBSD --- GhidraDocs/GettingStarted.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GhidraDocs/GettingStarted.md b/GhidraDocs/GettingStarted.md index 3f20a3edc9..62ea9416e6 100644 --- a/GhidraDocs/GettingStarted.md +++ b/GhidraDocs/GettingStarted.md @@ -203,8 +203,8 @@ Ghidra supports running on the following additional platforms with user-built na * Linux ARM 64-bit * FreeBSD x86 64-bit (no debugger support) * FreeBSD ARM 64-bit (no debugger support) -* OpenBSD x86 64-bit (no debugger support) -* OpenBSD ARM 64-bit (no debugger support) +* OpenBSD x86 64-bit +* OpenBSD ARM 64-bit For supported systems where native binaries have not been supplied, or those that are supplied fail to run properly, it may be necessary to build the native Ghidra binaries. In order to build native From 319ab576d4f7bd8577a74c84a53fb017dffa3679 Mon Sep 17 00:00:00 2001 From: Kurt Miller Date: Mon, 6 Jul 2026 16:38:41 -0400 Subject: [PATCH 5/6] Revert "Fix gdb on OpenBSD/amd64 by:" This reverts commit 065617a6a90f656a75c6e33dfc41cc8734e33e69. --- .../Debugger-agent-gdb/src/main/py/src/ghidragdb/util.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/util.py b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/util.py index 7d16104cb6..9cd311c358 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/util.py +++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/util.py @@ -19,7 +19,6 @@ import bisect from dataclasses import dataclass import re from typing import Callable, Dict, List, Optional, Sequence, Set, Tuple, Union -import platform import gdb @@ -468,7 +467,7 @@ class RegisterDesc: def get_register_descs(arch: gdb.Architecture, group: str = 'all') -> List[ Union[RegisterDesc, gdb.RegisterDescriptor]]: - if hasattr(arch, "registers") and platform.system() != "OpenBSD": + if hasattr(arch, "registers"): try: return list(arch.registers(group)) except ValueError: # No such group, or version too old @@ -482,7 +481,7 @@ def get_register_descs(arch: gdb.Architecture, group: str = 'all') -> List[ regset = gdb.execute( f"info registers", to_string=True).strip().split('\n') for line in regset: - if not line.startswith(" ") and "" not in line: + if not line.startswith(" "): tokens = line.strip().split() descs.append(RegisterDesc(tokens[0])) return descs From cf3a09004f1944d5fe62b731cba32aeca4dcfe40 Mon Sep 17 00:00:00 2001 From: d-millar <33498836+d-millar@users.noreply.github.com> Date: Tue, 7 Jul 2026 14:41:48 +0000 Subject: [PATCH 6/6] GP-7047: pull request --- Ghidra/Framework/Pty/src/main/java/ghidra/pty/PtyFactory.java | 4 ++-- .../Pty/src/main/java/ghidra/pty/openbsd/OpenBSDIoctls.java | 4 ++-- .../src/main/java/ghidra/pty/openbsd/OpenBSDPtyFactory.java | 4 ++-- .../main/java/ghidra/pty/openbsd/OpenBSDPtySessionLeader.java | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/PtyFactory.java b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/PtyFactory.java index ea30b93a20..552a3268eb 100644 --- a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/PtyFactory.java +++ b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/PtyFactory.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDIoctls.java b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDIoctls.java index 82264e65f3..2f2cd7d67c 100644 --- a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDIoctls.java +++ b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDIoctls.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDPtyFactory.java b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDPtyFactory.java index a5fc108793..ed196e1958 100644 --- a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDPtyFactory.java +++ b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDPtyFactory.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDPtySessionLeader.java b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDPtySessionLeader.java index 3e960981b2..d3d915b92a 100644 --- a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDPtySessionLeader.java +++ b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/openbsd/OpenBSDPtySessionLeader.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.