diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/manager/impl/GdbManagerImpl.java b/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/manager/impl/GdbManagerImpl.java index 192881bf4a..0fdc9e71b1 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/manager/impl/GdbManagerImpl.java +++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/manager/impl/GdbManagerImpl.java @@ -37,16 +37,19 @@ import agent.gdb.manager.impl.cmd.*; import agent.gdb.manager.parsing.GdbMiParser; import agent.gdb.manager.parsing.GdbParsingUtils.GdbParseError; import agent.gdb.pty.*; +import ghidra.GhidraApplicationLayout; import ghidra.async.*; import ghidra.async.AsyncLock.Hold; import ghidra.dbg.error.DebuggerModelTerminatingException; import ghidra.dbg.util.HandlerMap; import ghidra.dbg.util.PrefixMap; import ghidra.framework.Application; +import ghidra.framework.GhidraApplicationConfiguration; import ghidra.lifecycle.Internal; import ghidra.util.Msg; import ghidra.util.SystemUtilities; import ghidra.util.datastruct.ListenerSet; +import ghidra.util.task.ConsoleTaskMonitor; import sun.misc.Signal; import sun.misc.SignalHandler; @@ -206,7 +209,8 @@ public class GdbManagerImpl implements GdbManager { private void initLog() { try { - File userSettings = Application.getUserSettingsDirectory(); + GhidraApplicationLayout layout = new GhidraApplicationLayout(); + File userSettings = layout.getUserSettingsDir(); File logFile = new File(userSettings, "GDB.log"); try { logFile.createNewFile(); @@ -216,7 +220,7 @@ public class GdbManagerImpl implements GdbManager { } DBG_LOG = new PrintWriter(new FileOutputStream(logFile)); } - catch (FileNotFoundException e) { + catch (IOException e) { throw new AssertionError(e); } } diff --git a/Ghidra/Debug/Debugger-gadp/src/main/java/ghidra/dbg/gadp/server/AbstractGadpLocalDebuggerModelFactory.java b/Ghidra/Debug/Debugger-gadp/src/main/java/ghidra/dbg/gadp/server/AbstractGadpLocalDebuggerModelFactory.java index 3e0e19ede9..7f30d45033 100644 --- a/Ghidra/Debug/Debugger-gadp/src/main/java/ghidra/dbg/gadp/server/AbstractGadpLocalDebuggerModelFactory.java +++ b/Ghidra/Debug/Debugger-gadp/src/main/java/ghidra/dbg/gadp/server/AbstractGadpLocalDebuggerModelFactory.java @@ -47,6 +47,11 @@ public abstract class AbstractGadpLocalDebuggerModelFactory implements DebuggerM public final Property jdwpPortOption = Property.fromAccessors(int.class, this::getJdwpPort, this::setJdwpPort); + protected boolean jdwpSuspend = false; + @FactoryOption("Suspend for JDWP") + public final Property jdwpSuspendOption = + Property.fromAccessors(boolean.class, this::isJdwpSuspend, this::setJdwpSuspend); + /** * Get the name of the thread which processes the agent's stdout */ @@ -86,6 +91,14 @@ public abstract class AbstractGadpLocalDebuggerModelFactory implements DebuggerM this.jdwpPort = jdwpPort; } + public boolean isJdwpSuspend() { + return jdwpSuspend; + } + + public void setJdwpSuspend(boolean jdwpSuspend) { + this.jdwpSuspend = jdwpSuspend; + } + class AgentThread extends Thread { int port; Process process; @@ -104,7 +117,7 @@ public abstract class AbstractGadpLocalDebuggerModelFactory implements DebuggerM cmd.addAll(List.of("-cp", System.getProperty("java.class.path"))); if (jdwpPort >= 0) { cmd.add("-agentlib:jdwp=server=y,transport=dt_socket,address=" + jdwpPort + - ",suspend=n"); + ",suspend=" + (jdwpSuspend ? "y" : "n")); } completeCommandLine(cmd); builder.command(cmd);