mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
GP-860: Windows debuggers take their prompts from the engine.
This commit is contained in:
parent
b7a1d4bfd4
commit
d4182c2410
5 changed files with 61 additions and 13 deletions
|
@ -15,10 +15,10 @@
|
||||||
*/
|
*/
|
||||||
package agent.dbgeng.manager.cmd;
|
package agent.dbgeng.manager.cmd;
|
||||||
|
|
||||||
|
import agent.dbgeng.dbgeng.DebugControl;
|
||||||
import agent.dbgeng.manager.DbgEvent;
|
import agent.dbgeng.manager.DbgEvent;
|
||||||
import agent.dbgeng.manager.DbgManager;
|
import agent.dbgeng.manager.DbgManager;
|
||||||
import agent.dbgeng.manager.evt.AbstractDbgCompletedCommandEvent;
|
import agent.dbgeng.manager.evt.*;
|
||||||
import agent.dbgeng.manager.evt.DbgConsoleOutputEvent;
|
|
||||||
import agent.dbgeng.manager.impl.DbgManagerImpl;
|
import agent.dbgeng.manager.impl.DbgManagerImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,6 +63,8 @@ public class DbgConsoleExecCommand extends AbstractDbgCommand<String> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invoke() {
|
public void invoke() {
|
||||||
manager.getControl().execute(command);
|
DebugControl control = manager.getControl();
|
||||||
|
control.execute(command);
|
||||||
|
manager.processEvent(new DbgPromptChangedEvent(control.getPromptText()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package agent.dbgeng.manager.evt;
|
||||||
|
|
||||||
|
public class DbgPromptChangedEvent extends AbstractDbgEvent<String> {
|
||||||
|
public DbgPromptChangedEvent(String prompt) {
|
||||||
|
super(prompt);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrompt() {
|
||||||
|
return getInfo();
|
||||||
|
}
|
||||||
|
}
|
|
@ -41,7 +41,8 @@ import agent.dbgeng.manager.breakpoint.DbgBreakpointInfo;
|
||||||
import agent.dbgeng.manager.breakpoint.DbgBreakpointType;
|
import agent.dbgeng.manager.breakpoint.DbgBreakpointType;
|
||||||
import agent.dbgeng.manager.cmd.*;
|
import agent.dbgeng.manager.cmd.*;
|
||||||
import agent.dbgeng.manager.evt.*;
|
import agent.dbgeng.manager.evt.*;
|
||||||
import agent.dbgeng.model.iface1.*;
|
import agent.dbgeng.model.iface1.DbgModelTargetActiveScope;
|
||||||
|
import agent.dbgeng.model.iface1.DbgModelTargetFocusScope;
|
||||||
import agent.dbgeng.model.iface2.DbgModelTargetObject;
|
import agent.dbgeng.model.iface2.DbgModelTargetObject;
|
||||||
import agent.dbgeng.model.iface2.DbgModelTargetThread;
|
import agent.dbgeng.model.iface2.DbgModelTargetThread;
|
||||||
import ghidra.async.*;
|
import ghidra.async.*;
|
||||||
|
@ -597,6 +598,7 @@ public class DbgManagerImpl implements DbgManager {
|
||||||
handlerMap.putVoid(DbgStoppedEvent.class, this::processDefault);
|
handlerMap.putVoid(DbgStoppedEvent.class, this::processDefault);
|
||||||
handlerMap.putVoid(DbgRunningEvent.class, this::processDefault);
|
handlerMap.putVoid(DbgRunningEvent.class, this::processDefault);
|
||||||
handlerMap.putVoid(DbgConsoleOutputEvent.class, this::processConsoleOutput);
|
handlerMap.putVoid(DbgConsoleOutputEvent.class, this::processConsoleOutput);
|
||||||
|
handlerMap.putVoid(DbgPromptChangedEvent.class, this::processPromptChanged);
|
||||||
handlerMap.putVoid(DbgBreakpointCreatedEvent.class, this::processBreakpointCreated);
|
handlerMap.putVoid(DbgBreakpointCreatedEvent.class, this::processBreakpointCreated);
|
||||||
handlerMap.putVoid(DbgBreakpointModifiedEvent.class, this::processBreakpointModified);
|
handlerMap.putVoid(DbgBreakpointModifiedEvent.class, this::processBreakpointModified);
|
||||||
handlerMap.putVoid(DbgBreakpointDeletedEvent.class, this::processBreakpointDeleted);
|
handlerMap.putVoid(DbgBreakpointDeletedEvent.class, this::processBreakpointDeleted);
|
||||||
|
@ -925,6 +927,7 @@ public class DbgManagerImpl implements DbgManager {
|
||||||
dbgState = DbgState.STOPPED;
|
dbgState = DbgState.STOPPED;
|
||||||
//System.err.println("STOPPED " + id);
|
//System.err.println("STOPPED " + id);
|
||||||
processEvent(new DbgStoppedEvent(eventThread.getId()));
|
processEvent(new DbgStoppedEvent(eventThread.getId()));
|
||||||
|
processEvent(new DbgPromptChangedEvent(getControl().getPromptText()));
|
||||||
}
|
}
|
||||||
if (status.threadState.equals(ExecutionState.RUNNING)) {
|
if (status.threadState.equals(ExecutionState.RUNNING)) {
|
||||||
//System.err.println("RUNNING " + id);
|
//System.err.println("RUNNING " + id);
|
||||||
|
@ -949,6 +952,7 @@ public class DbgManagerImpl implements DbgManager {
|
||||||
if (process != null) {
|
if (process != null) {
|
||||||
processEvent(new DbgProcessSelectedEvent(process));
|
processEvent(new DbgProcessSelectedEvent(process));
|
||||||
}
|
}
|
||||||
|
processEvent(new DbgPromptChangedEvent(getControl().getPromptText()));
|
||||||
return DebugStatus.BREAK;
|
return DebugStatus.BREAK;
|
||||||
}
|
}
|
||||||
if (status.equals(DebugStatus.GO)) {
|
if (status.equals(DebugStatus.GO)) {
|
||||||
|
@ -972,6 +976,7 @@ public class DbgManagerImpl implements DbgManager {
|
||||||
if (thread != null) {
|
if (thread != null) {
|
||||||
getEventListeners().fire.threadSelected(thread, null, evt.getCause());
|
getEventListeners().fire.threadSelected(thread, null, evt.getCause());
|
||||||
}
|
}
|
||||||
|
processEvent(new DbgPromptChangedEvent(getControl().getPromptText()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1033,6 +1038,10 @@ public class DbgManagerImpl implements DbgManager {
|
||||||
getEventListeners().fire.consoleOutput(evt.getInfo(), evt.getMask());
|
getEventListeners().fire.consoleOutput(evt.getInfo(), evt.getMask());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void processPromptChanged(DbgPromptChangedEvent evt, Void v) {
|
||||||
|
getEventListeners().fire.promptChanged(evt.getPrompt());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for breakpoint-created event
|
* Handler for breakpoint-created event
|
||||||
*
|
*
|
||||||
|
@ -1480,8 +1489,8 @@ public class DbgManagerImpl implements DbgManager {
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Void> console(String command) {
|
public CompletableFuture<Void> console(String command) {
|
||||||
if (continuation != null) {
|
if (continuation != null) {
|
||||||
String prompt = command.equals("") ? DbgModelTargetInterpreter.DBG_PROMPT : ">>>";
|
//String prompt = command.equals("") ? DbgModelTargetInterpreter.DBG_PROMPT : ">>>";
|
||||||
getEventListeners().fire.promptChanged(prompt);
|
//getEventListeners().fire.promptChanged(prompt);
|
||||||
continuation.complete(command);
|
continuation.complete(command);
|
||||||
setContinuation(null);
|
setContinuation(null);
|
||||||
return AsyncUtils.NIL;
|
return AsyncUtils.NIL;
|
||||||
|
|
|
@ -18,6 +18,7 @@ package agent.dbgmodel.dbgmodel;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -44,7 +45,7 @@ public class DbgModelSetContextMWETest extends AbstractGhidraHeadlessIntegration
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMWE() {
|
public void testMWE() throws IOException {
|
||||||
HostDataModelAccess access = DbgModel.debugCreate();
|
HostDataModelAccess access = DbgModel.debugCreate();
|
||||||
DebugClient client = access.getClient();
|
DebugClient client = access.getClient();
|
||||||
DebugControl control = client.getControl();
|
DebugControl control = client.getControl();
|
||||||
|
@ -272,12 +273,6 @@ public class DbgModelSetContextMWETest extends AbstractGhidraHeadlessIntegration
|
||||||
DebugStatus status = super.exitThread(exitCode);
|
DebugStatus status = super.exitThread(exitCode);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DebugStatus changeSymbolState(BitmaskSet<ChangeSymbolState> flags,
|
|
||||||
long argument) {
|
|
||||||
return defaultStatus;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
try (ProcMaker maker = new ProcMaker(client, "C:\\Software\\Winmine__XP.exe")) {
|
try (ProcMaker maker = new ProcMaker(client, "C:\\Software\\Winmine__XP.exe")) {
|
||||||
|
@ -317,6 +312,17 @@ public class DbgModelSetContextMWETest extends AbstractGhidraHeadlessIntegration
|
||||||
}
|
}
|
||||||
cb.dumpFrame0ViaDX();
|
cb.dumpFrame0ViaDX();
|
||||||
|
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
||||||
|
while (true) {
|
||||||
|
System.err.print(control.getPromptText());
|
||||||
|
//control.prompt(BitmaskSet.of(), "Hello?>");
|
||||||
|
String cmd = in.readLine();
|
||||||
|
control.execute(cmd);
|
||||||
|
if (control.getExecutionStatus().shouldWait) {
|
||||||
|
control.waitForEvent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Didn't finish because the SetContext failed issue turned out to be mixed and/or
|
* TODO: Didn't finish because the SetContext failed issue turned out to be mixed and/or
|
||||||
* broken DLLs.
|
* broken DLLs.
|
||||||
|
|
|
@ -1124,4 +1124,9 @@ public class DbgModelTest extends AbstractGhidraHeadlessIntegrationTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPrompt() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue