Add debugger support for OpenBSD.

This commit is contained in:
Kurt Miller
2026-02-16 19:17:42 -05:00
parent 47ae57a416
commit 2ab0082d1a
7 changed files with 123 additions and 4 deletions

View File

@@ -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',
}

View File

@@ -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',

View File

@@ -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."))
}
}

View File

@@ -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:

View File

@@ -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<? extends UnixPtySessionLeader> leaderClass() {
return OpenBSDPtySessionLeader.class;
}
@Override
public long TIOCSCTTY() {
return 0x20007461L;
}
@Override
public long TIOCSWINSZ() {
return 0x80087467L;
}
}

View File

@@ -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)";
}
}

View File

@@ -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;
}
}