mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-20 10:37:27 +08:00
Merge remote-tracking branch 'origin/GP-6663_d-millar_windoze_tests'
This commit is contained in:
@@ -511,6 +511,7 @@ def on_stop(event: lldb.SBEvent) -> bool:
|
||||
commands.put_threads()
|
||||
commands.put_frames()
|
||||
commands.activate()
|
||||
commands.put_breakpoints()
|
||||
return True
|
||||
|
||||
|
||||
|
||||
+14
-7
@@ -16,7 +16,7 @@
|
||||
package agent.dbgeng.rmi;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
import static org.junit.Assume.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
@@ -150,18 +150,25 @@ public abstract class AbstractDbgEngTraceRmiTest extends AbstractGhidraHeadedDeb
|
||||
public void setupTraceRmi() throws Throwable {
|
||||
traceRmi = addPlugin(tool, TraceRmiPlugin.class);
|
||||
|
||||
try {
|
||||
pythonPath = Paths.get(DummyProc.which("python3"));
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
pythonPath = Paths.get(DummyProc.which("python"));
|
||||
}
|
||||
pythonPath = getPathToPython();
|
||||
|
||||
assertTrue(pythonPath.toFile().exists());
|
||||
outFile = Files.createTempFile("pydbgout", null);
|
||||
errFile = Files.createTempFile("pydbgerr", null);
|
||||
}
|
||||
|
||||
protected Path getPathToPython() {
|
||||
try {
|
||||
String py3path = DummyProc.which("python3");
|
||||
if (py3path != null && !py3path.contains("msys")) {
|
||||
return Paths.get(py3path);
|
||||
}
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
}
|
||||
return Paths.get(DummyProc.which("python"));
|
||||
}
|
||||
|
||||
protected void addAllDebuggerPlugins() throws PluginException {
|
||||
PluginsConfiguration plugConf = new PluginsConfiguration() {
|
||||
@Override
|
||||
|
||||
+3
-2
@@ -52,13 +52,12 @@ import ghidra.trace.model.target.TraceObject;
|
||||
import ghidra.trace.model.target.TraceObjectValue;
|
||||
import ghidra.trace.model.target.path.PathFilter;
|
||||
import ghidra.trace.model.target.path.PathPattern;
|
||||
import ghidra.util.exception.TimeoutException;
|
||||
|
||||
@Category(NightlyCategory.class) // this may actually be an @PortSensitive test
|
||||
public class GdbMethodsTest extends AbstractGdbTraceRmiTest {
|
||||
|
||||
private final static long CAPTURE_PC_TIMEOUT_MILLIS = 3000;
|
||||
|
||||
|
||||
@Test
|
||||
public void testExecuteCapture() throws Exception {
|
||||
try (GdbAndConnection conn = startAndConnectGdb()) {
|
||||
@@ -467,6 +466,8 @@ public class GdbMethodsTest extends AbstractGdbTraceRmiTest {
|
||||
|
||||
@Test
|
||||
public void testActivateThread() throws Exception {
|
||||
// NB: The windows variant does not appear to support multi-process debugging
|
||||
assumeFalse(IS_WINDOWS);
|
||||
try (GdbAndConnection conn = startAndConnectGdb()) {
|
||||
String target = which("expPrint");
|
||||
conn.execute("""
|
||||
|
||||
+4
-4
@@ -28,7 +28,6 @@ import org.junit.experimental.categories.Category;
|
||||
|
||||
import generic.Unique;
|
||||
import generic.test.category.NightlyCategory;
|
||||
import generic.test.rule.Repeated;
|
||||
import ghidra.app.plugin.core.debug.utils.ManagedDomainObject;
|
||||
import ghidra.debug.api.tracermi.RemoteMethod;
|
||||
import ghidra.framework.OperatingSystem;
|
||||
@@ -52,6 +51,8 @@ public class LldbMethodsTest extends AbstractLldbTraceRmiTest {
|
||||
|
||||
@Test
|
||||
public void testExecuteCapture() throws Exception {
|
||||
// NB: print returns no value on Windows
|
||||
assumeTrue(OperatingSystem.CURRENT_OPERATING_SYSTEM == OperatingSystem.LINUX);
|
||||
try (LldbAndConnection conn = startAndConnectLldb()) {
|
||||
RemoteMethod execute = conn.getMethod("execute");
|
||||
assertEquals(false, execute.parameters().get("to_string").getDefaultValue());
|
||||
@@ -572,12 +573,11 @@ public class LldbMethodsTest extends AbstractLldbTraceRmiTest {
|
||||
TraceObject proc = Objects.requireNonNull(tb.objAny0("Processes[]"));
|
||||
launch.invoke(Map.ofEntries(
|
||||
Map.entry("process", proc),
|
||||
Map.entry("file", getSpecimenRead())));
|
||||
Map.entry("file", getSpecimenSpin())));
|
||||
|
||||
txPut(conn, "processes");
|
||||
|
||||
waitRunning(conn);
|
||||
Thread.sleep(100); // Give it plenty of time to block on read
|
||||
|
||||
conn.execute("process interrupt");
|
||||
txPut(conn, "processes");
|
||||
@@ -585,7 +585,7 @@ public class LldbMethodsTest extends AbstractLldbTraceRmiTest {
|
||||
waitStopped(conn);
|
||||
|
||||
String out = conn.executeCapture("bt");
|
||||
assertThat(out, containsString("read"));
|
||||
assertThat(out, containsString("stop"));
|
||||
}
|
||||
conn.success();
|
||||
}
|
||||
|
||||
+20
-13
@@ -59,7 +59,7 @@ public abstract class AbstractX64dbgTraceRmiTest extends AbstractGhidraHeadedDeb
|
||||
from x64dbg_automate.models import *
|
||||
""";
|
||||
// Connecting should be the first thing the script does, so use a tight timeout.
|
||||
protected static final int CONNECT_TIMEOUT_MS = 6000;
|
||||
protected static final int CONNECT_TIMEOUT_MS = 10000;
|
||||
protected static final int TIMEOUT_SECONDS = SystemUtilities.isInTestingBatchMode() ? 20 : 300;
|
||||
protected static final int QUIT_TIMEOUT_MS = 2000;
|
||||
|
||||
@@ -144,27 +144,34 @@ public abstract class AbstractX64dbgTraceRmiTest extends AbstractGhidraHeadedDeb
|
||||
public void setupTraceRmi() throws Throwable {
|
||||
traceRmi = addPlugin(tool, TraceRmiPlugin.class);
|
||||
|
||||
try {
|
||||
pythonPath = Paths.get(DummyProc.which("python3"));
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
pythonPath = Paths.get(DummyProc.which("python"));
|
||||
}
|
||||
pythonPath = getPathToPython();
|
||||
|
||||
assertTrue("Python must be installed.", pythonPath.toFile().exists());
|
||||
outFile = Files.createTempFile("pydbgout", null);
|
||||
errFile = Files.createTempFile("pydbgerr", null);
|
||||
}
|
||||
|
||||
|
||||
protected Path getPathToPython() {
|
||||
try {
|
||||
String py3path = DummyProc.which("python3");
|
||||
if (py3path != null && !py3path.contains("msys")) {
|
||||
return Paths.get(py3path);
|
||||
}
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
}
|
||||
return Paths.get(DummyProc.which("python"));
|
||||
}
|
||||
|
||||
@Before
|
||||
public void killAllx64dbgProcesses() throws IOException, InterruptedException {
|
||||
ProcessBuilder pb = new ProcessBuilder("taskkill", "/IM", "x64dbg.exe", "/F");
|
||||
|
||||
|
||||
pb.redirectErrorStream(true);
|
||||
Process process = pb.start();
|
||||
process.waitFor();
|
||||
|
||||
// don't care about the exit code.
|
||||
Process process = pb.start();
|
||||
process.waitFor();
|
||||
|
||||
// don't care about the exit code.
|
||||
}
|
||||
|
||||
protected void addAllDebuggerPlugins() throws PluginException {
|
||||
|
||||
+2
-2
@@ -401,7 +401,7 @@ public class X64dbgMethodsTest extends AbstractX64dbgTraceRmiTest {
|
||||
txPut(conn, "processes");
|
||||
|
||||
RemoteMethod removeProcess = conn.getMethod("remove_process");
|
||||
try (ManagedDomainObject mdo = openDomainObject("/New Traces/x64dbg/netstat.exe")) {
|
||||
try (ManagedDomainObject mdo = openDomainObject("/New Traces/x64dbg/NETSTAT.EXE")) {
|
||||
tb = new ToyDBTraceBuilder((Trace) mdo.get());
|
||||
|
||||
TraceObject proc2 = Objects.requireNonNull(tb.objAny0("Sessions[].Processes[]"));
|
||||
@@ -476,7 +476,7 @@ public class X64dbgMethodsTest extends AbstractX64dbgTraceRmiTest {
|
||||
txPut(conn, "processes");
|
||||
|
||||
RemoteMethod detach = conn.getMethod("detach");
|
||||
try (ManagedDomainObject mdo = openDomainObject("/New Traces/x64dbg/netstat.exe")) {
|
||||
try (ManagedDomainObject mdo = openDomainObject("/New Traces/x64dbg/NETSTAT.EXE")) {
|
||||
tb = new ToyDBTraceBuilder((Trace) mdo.get());
|
||||
|
||||
TraceObject proc = Objects.requireNonNull(tb.objAny0("Sessions[].Processes[]"));
|
||||
|
||||
Reference in New Issue
Block a user