mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-10 14:11:59 +00:00
Merge remote-tracking branch 'origin/GP-0_Dan_fixGdbTestsGdb15' into patch
This commit is contained in:
commit
1512897a24
@ -23,11 +23,11 @@ import java.net.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.junit.Before;
|
||||
@ -157,16 +157,22 @@ public abstract class AbstractGdbTraceRmiTest extends AbstractGhidraHeadedDebugg
|
||||
}
|
||||
|
||||
protected record GdbResult(boolean timedOut, int exitCode, String stdout, String stderr) {
|
||||
String filterLines(String in, Predicate<String> lineTest) {
|
||||
return Stream.of(in.split("\n")).filter(lineTest).collect(Collectors.joining("\n"));
|
||||
}
|
||||
|
||||
protected String handle() {
|
||||
if (!"".equals(stderr) | 0 != exitCode) {
|
||||
String filtErr = filterLines(stderr, line -> {
|
||||
return !line.contains("warning: could not find '.gnu_debugaltlink' file");
|
||||
});
|
||||
if (!filtErr.isBlank() | 0 != exitCode) {
|
||||
throw new GdbError(exitCode, stdout, stderr);
|
||||
}
|
||||
return stdout;
|
||||
}
|
||||
}
|
||||
|
||||
protected record ExecInGdb(Process gdb, CompletableFuture<GdbResult> future) {
|
||||
}
|
||||
protected record ExecInGdb(Process gdb, CompletableFuture<GdbResult> future) {}
|
||||
|
||||
@SuppressWarnings("resource") // Do not close stdin
|
||||
protected ExecInGdb execInGdb(String script) throws IOException {
|
||||
@ -345,8 +351,7 @@ public abstract class AbstractGdbTraceRmiTest extends AbstractGhidraHeadedDebugg
|
||||
return out.split(head)[1].split("---")[0].replace("(gdb)", "").trim();
|
||||
}
|
||||
|
||||
record MemDump(long address, byte[] data) {
|
||||
}
|
||||
record MemDump(long address, byte[] data) {}
|
||||
|
||||
protected MemDump parseHexDump(String dump) throws IOException {
|
||||
// First, get the address. Assume contiguous, so only need top line.
|
||||
|
@ -1020,7 +1020,7 @@ public class GdbCommandsTest extends AbstractGdbTraceRmiTest {
|
||||
starti
|
||||
ghidra trace start
|
||||
ghidra trace tx-start "Tx"
|
||||
break main
|
||||
break *main
|
||||
hbreak *main+10
|
||||
watch -l *((char*)(&main+20))
|
||||
rwatch -l *((char(*)[8])(&main+30))
|
||||
@ -1046,7 +1046,7 @@ public class GdbCommandsTest extends AbstractGdbTraceRmiTest {
|
||||
// NB. starti avoid use of temporary main breakpoint
|
||||
assertBreakLoc(infBreakLocVals.get(0), "[1.1]", main, 1,
|
||||
Set.of(TraceBreakpointKind.SW_EXECUTE),
|
||||
"main");
|
||||
"*main");
|
||||
assertBreakLoc(infBreakLocVals.get(1), "[2.1]", main.add(10), 1,
|
||||
Set.of(TraceBreakpointKind.HW_EXECUTE),
|
||||
"*main+10");
|
||||
|
@ -116,7 +116,7 @@ public class GdbMethodsTest extends AbstractGdbTraceRmiTest {
|
||||
waitStopped();
|
||||
|
||||
conn.execute("""
|
||||
break main
|
||||
break *main
|
||||
hbreak *main+10
|
||||
watch -l *((char*)(&main+20))
|
||||
rwatch -l *((char(*)[8])(&main+30))
|
||||
@ -138,7 +138,7 @@ public class GdbMethodsTest extends AbstractGdbTraceRmiTest {
|
||||
// NB. starti avoid use of temporary main breakpoint
|
||||
assertBreakLoc(infBreakLocVals.get(0), "[1.1]", main, 1,
|
||||
Set.of(TraceBreakpointKind.SW_EXECUTE),
|
||||
"main");
|
||||
"*main");
|
||||
assertBreakLoc(infBreakLocVals.get(1), "[2.1]", main.add(10), 1,
|
||||
Set.of(TraceBreakpointKind.HW_EXECUTE),
|
||||
"*main+10");
|
||||
@ -172,7 +172,7 @@ public class GdbMethodsTest extends AbstractGdbTraceRmiTest {
|
||||
|
||||
TraceObject locations = Objects.requireNonNull(tb.obj("Inferiors[1].Breakpoints"));
|
||||
conn.execute("""
|
||||
break main
|
||||
break *main
|
||||
hbreak *main+10
|
||||
watch -l *((char*)(&main+20))
|
||||
rwatch -l *((char(*)[8])(&main+30))
|
||||
@ -193,7 +193,7 @@ public class GdbMethodsTest extends AbstractGdbTraceRmiTest {
|
||||
// NB. starti avoid use of temporary main breakpoint
|
||||
assertBreakLoc(infBreakLocVals.get(0), "[1.1]", main, 1,
|
||||
Set.of(TraceBreakpointKind.SW_EXECUTE),
|
||||
"main");
|
||||
"*main");
|
||||
assertBreakLoc(infBreakLocVals.get(1), "[2.1]", main.add(10), 1,
|
||||
Set.of(TraceBreakpointKind.HW_EXECUTE),
|
||||
"*main+10");
|
||||
@ -935,7 +935,8 @@ public class GdbMethodsTest extends AbstractGdbTraceRmiTest {
|
||||
tb = new ToyDBTraceBuilder((Trace) mdo.get());
|
||||
waitStopped();
|
||||
|
||||
breakSwExecuteExpression.invoke(Map.of("expression", "main"));
|
||||
// Use *main instead of main, because some gdb will instead do <main+8>
|
||||
breakSwExecuteExpression.invoke(Map.of("expression", "*main"));
|
||||
|
||||
String out = conn.executeCapture("info break");
|
||||
assertThat(out, containsString("<main>"));
|
||||
@ -982,7 +983,7 @@ public class GdbMethodsTest extends AbstractGdbTraceRmiTest {
|
||||
tb = new ToyDBTraceBuilder((Trace) mdo.get());
|
||||
waitStopped();
|
||||
|
||||
breakHwExecuteExpression.invoke(Map.of("expression", "main"));
|
||||
breakHwExecuteExpression.invoke(Map.of("expression", "*main"));
|
||||
|
||||
String out = conn.executeCapture("info break");
|
||||
assertThat(out, containsString("<main>"));
|
||||
|
Loading…
Reference in New Issue
Block a user