mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-19 16:40:38 -09:00
GP-2623: Improve connect dialog and factory descriptions
This commit is contained in:
@@ -25,15 +25,16 @@ import ghidra.dbg.DebuggerModelFactory;
|
||||
import ghidra.dbg.DebuggerObjectModel;
|
||||
import ghidra.dbg.util.ConfigurableFactory.FactoryDescription;
|
||||
import ghidra.dbg.util.ShellUtils;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
/**
|
||||
* Note this is in the testing source because it's not meant to be shipped in the release.... That
|
||||
* may change if it proves stable, though, no?
|
||||
*/
|
||||
@FactoryDescription( //
|
||||
brief = "IN-VM GNU gdb local debugger", //
|
||||
htmlDetails = "Launch a GDB session in this same JVM" //
|
||||
)
|
||||
@FactoryDescription(
|
||||
brief = "gdb",
|
||||
htmlDetails = """
|
||||
Connect to gdb.
|
||||
This is best for most Linux and Unix userspace targets, and many embedded targets.
|
||||
It may also be used with gdbserver by connecting to gdb, then using <code>target remote
|
||||
...</code>.
|
||||
This will access the native API, which may put Ghidra's JVM at risk.""")
|
||||
public class GdbInJvmDebuggerModelFactory implements DebuggerModelFactory {
|
||||
|
||||
private String gdbCmd = GdbManager.DEFAULT_GDB_CMD;
|
||||
@@ -59,8 +60,17 @@ public class GdbInJvmDebuggerModelFactory implements DebuggerModelFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompatible() {
|
||||
return GdbCompatibility.INSTANCE.isCompatible(gdbCmd);
|
||||
public int getPriority(Program program) {
|
||||
if (!GdbCompatibility.INSTANCE.isCompatible(gdbCmd)) {
|
||||
return -1;
|
||||
}
|
||||
if (program != null) {
|
||||
String exe = program.getExecutablePath();
|
||||
if (exe == null || exe.isBlank()) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 80;
|
||||
}
|
||||
|
||||
public String getGdbCommand() {
|
||||
|
||||
@@ -24,10 +24,14 @@ import ghidra.dbg.DebuggerModelFactory;
|
||||
import ghidra.dbg.DebuggerObjectModel;
|
||||
import ghidra.dbg.util.ShellUtils;
|
||||
import ghidra.dbg.util.ConfigurableFactory.FactoryDescription;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
@FactoryDescription(
|
||||
brief = "GNU gdb via SSH",
|
||||
htmlDetails = "Launch a GDB session over an SSH connection")
|
||||
brief = "gdb via SSH",
|
||||
htmlDetails = """
|
||||
Connect to gdb using SSH.
|
||||
This is best for remote Linux and Unix userspace targets when gdb is installed on the
|
||||
remote host.""")
|
||||
public class GdbOverSshDebuggerModelFactory implements DebuggerModelFactory {
|
||||
|
||||
private String gdbCmd = "/usr/bin/gdb";
|
||||
@@ -91,8 +95,14 @@ public class GdbOverSshDebuggerModelFactory implements DebuggerModelFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompatible() {
|
||||
return true;
|
||||
public int getPriority(Program program) {
|
||||
if (program != null) {
|
||||
String exe = program.getExecutablePath();
|
||||
if (exe == null || exe.isBlank()) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 75;
|
||||
}
|
||||
|
||||
public String getGdbCommand() {
|
||||
|
||||
@@ -22,14 +22,17 @@ import agent.gdb.manager.GdbManager;
|
||||
import ghidra.dbg.gadp.server.AbstractGadpLocalDebuggerModelFactory;
|
||||
import ghidra.dbg.util.ConfigurableFactory.FactoryDescription;
|
||||
import ghidra.dbg.util.ShellUtils;
|
||||
import ghidra.util.classfinder.ExtensionPointProperties;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
@FactoryDescription( //
|
||||
brief = "GNU gdb local agent via GADP/TCP", //
|
||||
htmlDetails = "Launch a new agent using GDB. This may start a new session or join an existing one." //
|
||||
)
|
||||
@ExtensionPointProperties(priority = 100)
|
||||
public class GdbLocalDebuggerModelFactory extends AbstractGadpLocalDebuggerModelFactory {
|
||||
@FactoryDescription(
|
||||
brief = "gdb via GADP",
|
||||
htmlDetails = """
|
||||
Connect to gdb.
|
||||
This is best for most Linux and Unix userspace targets, and many embedded targets.
|
||||
This will protect Ghidra's JVM by using a subprocess to access the native API.
|
||||
If you are using <b>gdbserver</b>, you must connect to gdb first (consider the non-GADP
|
||||
connector), then use <code>target remote ...</code> to connect to your target.""")
|
||||
public class GdbGadpDebuggerModelFactory extends AbstractGadpLocalDebuggerModelFactory {
|
||||
|
||||
private String gdbCmd = GdbManager.DEFAULT_GDB_CMD;
|
||||
@FactoryOption("GDB launch command")
|
||||
@@ -44,9 +47,17 @@ public class GdbLocalDebuggerModelFactory extends AbstractGadpLocalDebuggerModel
|
||||
// TODO: newLine option?
|
||||
|
||||
@Override
|
||||
public boolean isCompatible() {
|
||||
// TODO: Could potentially support GDB on Windows, but the pty thing would need porting.
|
||||
return GdbCompatibility.INSTANCE.isCompatible(gdbCmd);
|
||||
public int getPriority(Program program) {
|
||||
if (!GdbCompatibility.INSTANCE.isCompatible(gdbCmd)) {
|
||||
return -1;
|
||||
}
|
||||
if (program != null) {
|
||||
String exe = program.getExecutablePath();
|
||||
if (exe == null || exe.isBlank()) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 60;
|
||||
}
|
||||
|
||||
public String getGdbCommand() {
|
||||
@@ -20,7 +20,7 @@ import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import agent.gdb.gadp.GdbLocalDebuggerModelFactory;
|
||||
import agent.gdb.gadp.GdbGadpDebuggerModelFactory;
|
||||
import agent.gdb.model.AbstractGdbModelHost;
|
||||
import ghidra.dbg.DebuggerModelFactory;
|
||||
import ghidra.util.SystemUtilities;
|
||||
@@ -30,6 +30,6 @@ class GadpGdbModelHost extends AbstractGdbModelHost {
|
||||
public DebuggerModelFactory getModelFactory() {
|
||||
assumeFalse("Not ready for CI", SystemUtilities.isInTestingBatchMode());
|
||||
assumeTrue("GDB cannot be found", new File("/usr/bin/gdb").canExecute());
|
||||
return new GdbLocalDebuggerModelFactory();
|
||||
return new GdbGadpDebuggerModelFactory();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user