GP-878: ObjectsProvider fixes. dbgeng termination/exit fixes.

This commit is contained in:
d-millar 2021-04-22 20:12:10 +00:00 committed by Dan
parent 75f950880e
commit 93b2f5cc64
16 changed files with 211 additions and 61 deletions

View file

@ -103,7 +103,11 @@ public class DebugSystemObjectsImpl1 implements DebugSystemObjectsInternal {
@Override
public int getNumberThreads() {
ULONGByReference pulNumber = new ULONGByReference();
COMUtils.checkRC(jnaSysobj.GetNumberThreads(pulNumber));
HRESULT hr = jnaSysobj.GetNumberThreads(pulNumber);
if (hr.equals(COMUtilsExtra.E_UNEXPECTED)) {
return 0;
}
COMUtils.checkRC(hr);
return pulNumber.getValue().intValue();
}

View file

@ -110,7 +110,8 @@ public class DbgDebugEventCallbacksAdapter extends DebugEventCallbacksAdapter {
DebugStatus status = DebugStatus.fromArgument(argument);
Msg.info(this, "***ExecutionStatus: " + status);
if (status.equals(DebugStatus.NO_DEBUGGEE)) {
event.setState(DbgState.SESSION_EXIT);
long processCount = manager.getProcessCount();
event.setState(processCount > 0 ? DbgState.SESSION_EXIT : DbgState.EXIT);
}
return checkInterrupt(manager.processEvent(event));
}
@ -131,10 +132,18 @@ public class DbgDebugEventCallbacksAdapter extends DebugEventCallbacksAdapter {
return checkInterrupt(DebugStatus.NO_CHANGE);
}
//@Override
//public DebugStatus changeDebuggeeState(BitmaskSet<ChangeDebuggeeState> flags, long argument) {
// System.err.println("CHANGE_DEBUGGEE_STATE: " + flags + ":" + argument);
// return DebugStatus.NO_CHANGE;
//}
/*
@Override
public DebugStatus changeDebuggeeState(BitmaskSet<ChangeDebuggeeState> flags, long argument) {
System.err.println("CHANGE_DEBUGGEE_STATE: " + flags + ":" + argument);
return DebugStatus.NO_CHANGE;
}
@Override
public DebugStatus sessionStatus(SessionStatus status) {
System.err.println("SESSION_STATUS: " + status);
return DebugStatus.NO_CHANGE;
}
*/
}

View file

@ -110,6 +110,7 @@ public class DbgManagerImpl implements DbgManager {
private volatile boolean waiting = false;
private boolean kernelMode = false;
private CompletableFuture<String> continuation;
private long processCount = 0;
/**
* Instantiate a new manager
@ -998,6 +999,12 @@ public class DbgManagerImpl implements DbgManager {
waiting = true;
Long info = evt.getInfo();
if (info.intValue() >= 0) {
processCount++;
}
else {
processCount--;
}
DebugProcessId id = new DebugProcessId(info.intValue());
String key = Integer.toHexString(id.id);
@ -1523,4 +1530,9 @@ public class DbgManagerImpl implements DbgManager {
public void setContinuation(CompletableFuture<String> continuation) {
this.continuation = continuation;
}
public long getProcessCount() {
return processCount;
}
}

View file

@ -27,11 +27,26 @@ import ghidra.dbg.target.*;
import ghidra.dbg.target.schema.*;
import ghidra.dbg.util.PathUtils;
@TargetObjectSchemaInfo(name = "Debugger", elements = {
@TargetElementType(type = Void.class) }, attributes = {
@TargetAttributeType(name = "Available", type = DbgModelTargetAvailableContainerImpl.class, required = true, fixed = true),
@TargetAttributeType(name = "Connectors", type = DbgModelTargetConnectorContainerImpl.class, required = true, fixed = true),
@TargetAttributeType(name = "Sessions", type = DbgModelTargetSessionContainerImpl.class, required = true, fixed = true),
@TargetObjectSchemaInfo(
name = "Debugger",
elements = {
@TargetElementType(type = Void.class) },
attributes = {
@TargetAttributeType(
name = "Available",
type = DbgModelTargetAvailableContainerImpl.class,
required = true,
fixed = true),
@TargetAttributeType(
name = "Connectors",
type = DbgModelTargetConnectorContainerImpl.class,
required = true,
fixed = true),
@TargetAttributeType(
name = "Sessions",
type = DbgModelTargetSessionContainerImpl.class,
required = true,
fixed = true),
@TargetAttributeType(type = Void.class) })
public class DbgModelTargetRootImpl extends DbgModelDefaultTargetModelRoot
implements DbgModelTargetRoot {
@ -120,9 +135,11 @@ public class DbgModelTargetRootImpl extends DbgModelDefaultTargetModelRoot
DbgReason reason) {
DbgModelTargetThread targetThread =
(DbgModelTargetThread) getModel().getModelObject(thread);
changeAttributes(List.of(), List.of(), Map.of( //
TargetEventScope.EVENT_OBJECT_ATTRIBUTE_NAME, targetThread //
), reason.desc());
if (targetThread != null) {
changeAttributes(List.of(), List.of(), Map.of( //
TargetEventScope.EVENT_OBJECT_ATTRIBUTE_NAME, targetThread //
), reason.desc());
}
}
@Override