From c70014fe404946f86bbbf70d4edc4bb8849a75ff Mon Sep 17 00:00:00 2001 From: d-millar <33498836+d-millar@users.noreply.github.com> Date: Tue, 12 Sep 2023 10:33:43 -0400 Subject: [PATCH 1/2] GP-3825: changes suggested from review GP-3825: fix for local line-ending issue --- .../gdb/GdbInJvmDebuggerModelFactory.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/GdbInJvmDebuggerModelFactory.java b/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/GdbInJvmDebuggerModelFactory.java index 16a41d0c33..f1943a6bf8 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/GdbInJvmDebuggerModelFactory.java +++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/GdbInJvmDebuggerModelFactory.java @@ -47,18 +47,35 @@ public class GdbInJvmDebuggerModelFactory implements DebuggerModelFactory { public final Property useExistingOption = Property.fromAccessors(boolean.class, this::isUseExisting, this::setUseExisting); - // TODO: newLine option? + private boolean useCrlf = System.lineSeparator().equals("\r\n");; + @FactoryOption("Use DOS line endings (unchecked for UNIX remote)") + public final Property crlfNewLineOption = + Property.fromAccessors(Boolean.class, this::isUseCrlf, this::setUseCrlf); @Override public CompletableFuture build() { List gdbCmdLine = ShellUtils.parseArgs(gdbCmd); GdbModelImpl model = new GdbModelImpl(PtyFactory.local()); + if (useCrlf) { + model.setDosNewLine(); + } + else { + model.setUnixNewLine(); + } return model .startGDB(existing ? null : gdbCmdLine.get(0), gdbCmdLine.subList(1, gdbCmdLine.size()).toArray(String[]::new)) .thenApply(__ -> model); } + public boolean isUseCrlf() { + return useCrlf; + } + + public void setUseCrlf(boolean useCrlf) { + this.useCrlf = useCrlf; + } + @Override public int getPriority(Program program) { if (!GdbCompatibility.INSTANCE.isCompatible(gdbCmd)) { From 06ffa6c4d47076d5ce92bf706024786a20864ef9 Mon Sep 17 00:00:00 2001 From: d-millar <33498836+d-millar@users.noreply.github.com> Date: Tue, 12 Sep 2023 11:15:41 -0400 Subject: [PATCH 2/2] GP-3825(SQ): post squash change --- .../src/main/java/agent/gdb/GdbInJvmDebuggerModelFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/GdbInJvmDebuggerModelFactory.java b/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/GdbInJvmDebuggerModelFactory.java index f1943a6bf8..97c7e27f89 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/GdbInJvmDebuggerModelFactory.java +++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/GdbInJvmDebuggerModelFactory.java @@ -48,7 +48,7 @@ public class GdbInJvmDebuggerModelFactory implements DebuggerModelFactory { Property.fromAccessors(boolean.class, this::isUseExisting, this::setUseExisting); private boolean useCrlf = System.lineSeparator().equals("\r\n");; - @FactoryOption("Use DOS line endings (unchecked for UNIX remote)") + @FactoryOption("Use DOS line endings (unchecked for UNIX and Cygwin))") public final Property crlfNewLineOption = Property.fromAccessors(Boolean.class, this::isUseCrlf, this::setUseCrlf);