mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
Merge remote-tracking branch
'origin/GP-1812_d-millar_windows_bpt_issues--SQUASHED' (Closes #4059)
This commit is contained in:
commit
b870139e50
7 changed files with 57 additions and 17 deletions
|
@ -50,11 +50,16 @@ public class DbgListMemoryRegionsCommand extends AbstractDbgCommand<List<DbgModu
|
||||||
}
|
}
|
||||||
manager.addMemory(region);
|
manager.addMemory(region);
|
||||||
}
|
}
|
||||||
|
List<Long> toRemove = new ArrayList<>();
|
||||||
for (Entry<Long, DbgModuleMemory> entry : memory.entrySet()) {
|
for (Entry<Long, DbgModuleMemory> entry : memory.entrySet()) {
|
||||||
if (memoryRegions.contains(entry.getValue())) {
|
if (memoryRegions.contains(entry.getValue())) {
|
||||||
continue; // Do nothing, we're in sync
|
continue; // Do nothing, we're in sync
|
||||||
}
|
}
|
||||||
manager.removeMemory(entry.getKey());
|
toRemove.add(entry.getKey());
|
||||||
|
//manager.removeMemory(entry.getKey());
|
||||||
|
}
|
||||||
|
for (Long key : toRemove) {
|
||||||
|
manager.removeMemory(key);
|
||||||
}
|
}
|
||||||
return memoryRegions;
|
return memoryRegions;
|
||||||
}
|
}
|
||||||
|
|
|
@ -406,10 +406,12 @@ public class DbgManagerImpl implements DbgManager {
|
||||||
//TODO: server.terminate();
|
//TODO: server.terminate();
|
||||||
engThread.execute(100, dbgeng -> {
|
engThread.execute(100, dbgeng -> {
|
||||||
Msg.debug(this, "Disconnecting DebugClient from session");
|
Msg.debug(this, "Disconnecting DebugClient from session");
|
||||||
dbgeng.endSession(DebugEndSessionFlags.DEBUG_END_DISCONNECT);
|
dbgeng.endSession(DebugEndSessionFlags.DEBUG_END_PASSIVE);
|
||||||
dbgeng.setOutputCallbacks(null);
|
dbgeng.setOutputCallbacks(null);
|
||||||
});
|
dbgeng.setEventCallbacks(null);
|
||||||
|
dbgeng.setInputCallbacks(null);
|
||||||
engThread.shutdown();
|
engThread.shutdown();
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
engThread.awaitTermination(5000, TimeUnit.MILLISECONDS);
|
engThread.awaitTermination(5000, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
@ -942,7 +944,8 @@ public class DbgManagerImpl implements DbgManager {
|
||||||
//System.err.println("RUNNING " + id);
|
//System.err.println("RUNNING " + id);
|
||||||
dbgState = DbgState.RUNNING;
|
dbgState = DbgState.RUNNING;
|
||||||
// NB: Needed by GADP variants, but not IN-VM
|
// NB: Needed by GADP variants, but not IN-VM
|
||||||
getEventListeners().fire.memoryChanged(currentProcess, 0L, 0, evt.getCause());
|
getEventListeners().fire.memoryChanged(currentProcess, 0L, 0,
|
||||||
|
evt.getCause());
|
||||||
processEvent(new DbgRunningEvent(eventThread.getId()));
|
processEvent(new DbgRunningEvent(eventThread.getId()));
|
||||||
}
|
}
|
||||||
if (!threads.containsValue(eventThread)) {
|
if (!threads.containsValue(eventThread)) {
|
||||||
|
@ -1483,11 +1486,13 @@ public class DbgManagerImpl implements DbgManager {
|
||||||
|
|
||||||
public CompletableFuture<Void> setActiveFrame(DbgThread thread, int index) {
|
public CompletableFuture<Void> setActiveFrame(DbgThread thread, int index) {
|
||||||
currentThread = thread;
|
currentThread = thread;
|
||||||
|
currentProcess = thread.getProcess();
|
||||||
return execute(new DbgSetActiveThreadCommand(this, thread, index));
|
return execute(new DbgSetActiveThreadCommand(this, thread, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<Void> setActiveThread(DbgThread thread) {
|
public CompletableFuture<Void> setActiveThread(DbgThread thread) {
|
||||||
currentThread = thread;
|
currentThread = thread;
|
||||||
|
currentProcess = thread.getProcess();
|
||||||
return execute(new DbgSetActiveThreadCommand(this, thread, null));
|
return execute(new DbgSetActiveThreadCommand(this, thread, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ import java.util.concurrent.CompletableFuture;
|
||||||
import agent.dbgeng.dbgeng.DebugSystemObjects;
|
import agent.dbgeng.dbgeng.DebugSystemObjects;
|
||||||
import agent.dbgeng.dbgeng.DebugThreadId;
|
import agent.dbgeng.dbgeng.DebugThreadId;
|
||||||
import agent.dbgeng.manager.*;
|
import agent.dbgeng.manager.*;
|
||||||
import agent.dbgeng.manager.cmd.DbgSetActiveThreadCommand;
|
|
||||||
import agent.dbgeng.manager.impl.*;
|
import agent.dbgeng.manager.impl.*;
|
||||||
import agent.dbgeng.model.iface1.*;
|
import agent.dbgeng.model.iface1.*;
|
||||||
import agent.dbgeng.model.impl.DbgModelTargetStackImpl;
|
import agent.dbgeng.model.impl.DbgModelTargetStackImpl;
|
||||||
|
@ -58,8 +57,9 @@ public interface DbgModelTargetThread extends //
|
||||||
@Override
|
@Override
|
||||||
public default CompletableFuture<Void> setActive() {
|
public default CompletableFuture<Void> setActive() {
|
||||||
DbgManagerImpl manager = getManager();
|
DbgManagerImpl manager = getManager();
|
||||||
DbgThread thread = getThread();
|
DbgProcessImpl process = (DbgProcessImpl) getParentProcess().getProcess();
|
||||||
return manager.execute(new DbgSetActiveThreadCommand(manager, thread, null));
|
manager.setActiveProcess(process);
|
||||||
|
return manager.setActiveThread(getThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbgModelTargetStackImpl getStack();
|
public DbgModelTargetStackImpl getStack();
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import agent.dbgeng.manager.DbgCause;
|
import agent.dbgeng.manager.DbgCause;
|
||||||
|
import agent.dbgeng.manager.DbgProcess;
|
||||||
import agent.dbgeng.manager.breakpoint.DbgBreakpointInfo;
|
import agent.dbgeng.manager.breakpoint.DbgBreakpointInfo;
|
||||||
import agent.dbgeng.manager.impl.DbgManagerImpl;
|
import agent.dbgeng.manager.impl.DbgManagerImpl;
|
||||||
import agent.dbgeng.model.iface2.*;
|
import agent.dbgeng.model.iface2.*;
|
||||||
|
@ -54,19 +55,34 @@ public class DbgModelTargetBreakpointContainerImpl extends DbgModelTargetObjectI
|
||||||
), "Initialized");
|
), "Initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isMatch(DbgBreakpointInfo info) {
|
||||||
|
DbgProcess bptProc = info.getProc();
|
||||||
|
DbgModelTargetProcess parentProcess = getParentProcess();
|
||||||
|
return parentProcess.getProcess().equals(bptProc);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakpointCreated(DbgBreakpointInfo info, DbgCause cause) {
|
public void breakpointCreated(DbgBreakpointInfo info, DbgCause cause) {
|
||||||
|
if (!isMatch(info)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
changeElements(List.of(), List.of(getTargetBreakpointSpec(info)), Map.of(), "Created");
|
changeElements(List.of(), List.of(getTargetBreakpointSpec(info)), Map.of(), "Created");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakpointModified(DbgBreakpointInfo newInfo, DbgBreakpointInfo oldInfo,
|
public void breakpointModified(DbgBreakpointInfo newInfo, DbgBreakpointInfo oldInfo,
|
||||||
DbgCause cause) {
|
DbgCause cause) {
|
||||||
|
if (!isMatch(newInfo)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
getTargetBreakpointSpec(oldInfo).updateInfo(oldInfo, newInfo, "Modified");
|
getTargetBreakpointSpec(oldInfo).updateInfo(oldInfo, newInfo, "Modified");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakpointDeleted(DbgBreakpointInfo info, DbgCause cause) {
|
public void breakpointDeleted(DbgBreakpointInfo info, DbgCause cause) {
|
||||||
|
if (!isMatch(info)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
DbgModelImpl impl = (DbgModelImpl) model;
|
DbgModelImpl impl = (DbgModelImpl) model;
|
||||||
impl.deleteModelObject(info.getDebugBreakpoint());
|
impl.deleteModelObject(info.getDebugBreakpoint());
|
||||||
changeElements(List.of( //
|
changeElements(List.of( //
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class DbgModelTargetProcessContainerImpl extends DbgModelTargetObjectImpl
|
||||||
}
|
}
|
||||||
DbgModelTargetMemoryContainer memory = process.getMemory();
|
DbgModelTargetMemoryContainer memory = process.getMemory();
|
||||||
if (memory != null) {
|
if (memory != null) {
|
||||||
memory.requestElements(false);
|
memory.requestElements(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import agent.dbgeng.dbgeng.DebugThreadId;
|
import agent.dbgeng.dbgeng.DebugThreadId;
|
||||||
import agent.dbgeng.manager.*;
|
import agent.dbgeng.manager.*;
|
||||||
import agent.dbgeng.manager.cmd.DbgSetActiveThreadCommand;
|
|
||||||
import agent.dbgeng.manager.impl.DbgManagerImpl;
|
import agent.dbgeng.manager.impl.DbgManagerImpl;
|
||||||
import agent.dbgeng.model.iface1.DbgModelTargetFocusScope;
|
import agent.dbgeng.model.iface1.DbgModelTargetFocusScope;
|
||||||
import agent.dbgeng.model.iface2.*;
|
import agent.dbgeng.model.iface2.*;
|
||||||
|
@ -30,10 +29,21 @@ import ghidra.dbg.target.TargetFocusScope;
|
||||||
import ghidra.dbg.target.schema.*;
|
import ghidra.dbg.target.schema.*;
|
||||||
import ghidra.dbg.util.PathUtils;
|
import ghidra.dbg.util.PathUtils;
|
||||||
|
|
||||||
@TargetObjectSchemaInfo(name = "Thread", elements = {
|
@TargetObjectSchemaInfo(
|
||||||
@TargetElementType(type = Void.class) }, attributes = {
|
name = "Thread",
|
||||||
@TargetAttributeType(name = "Registers", type = DbgModelTargetRegisterContainerImpl.class, required = true, fixed = true),
|
elements = {
|
||||||
@TargetAttributeType(name = "Stack", type = DbgModelTargetStackImpl.class, required = true, fixed = true),
|
@TargetElementType(type = Void.class) },
|
||||||
|
attributes = {
|
||||||
|
@TargetAttributeType(
|
||||||
|
name = "Registers",
|
||||||
|
type = DbgModelTargetRegisterContainerImpl.class,
|
||||||
|
required = true,
|
||||||
|
fixed = true),
|
||||||
|
@TargetAttributeType(
|
||||||
|
name = "Stack",
|
||||||
|
type = DbgModelTargetStackImpl.class,
|
||||||
|
required = true,
|
||||||
|
fixed = true),
|
||||||
@TargetAttributeType(name = TargetEnvironment.ARCH_ATTRIBUTE_NAME, type = String.class),
|
@TargetAttributeType(name = TargetEnvironment.ARCH_ATTRIBUTE_NAME, type = String.class),
|
||||||
@TargetAttributeType(type = Void.class) })
|
@TargetAttributeType(type = Void.class) })
|
||||||
public class DbgModelTargetThreadImpl extends DbgModelTargetObjectImpl
|
public class DbgModelTargetThreadImpl extends DbgModelTargetObjectImpl
|
||||||
|
@ -146,7 +156,7 @@ public class DbgModelTargetThreadImpl extends DbgModelTargetObjectImpl
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Void> setActive() {
|
public CompletableFuture<Void> setActive() {
|
||||||
DbgManagerImpl manager = getManager();
|
DbgManagerImpl manager = getManager();
|
||||||
return manager.execute(new DbgSetActiveThreadCommand(manager, thread, null));
|
return manager.setActiveThread(thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbgModelTargetRegisterContainerAndBank getRegisters() {
|
public DbgModelTargetRegisterContainerAndBank getRegisters() {
|
||||||
|
|
|
@ -166,9 +166,13 @@ public class DefaultBreakpointRecorder implements ManagedBreakpointRecorder {
|
||||||
else {
|
else {
|
||||||
traceBpt.setClearedSnap(snap - 1);
|
traceBpt.setClearedSnap(snap - 1);
|
||||||
}
|
}
|
||||||
|
TraceBreakpoint newtraceBpt =
|
||||||
breakpointManager.placeBreakpoint(path, snap, range,
|
breakpointManager.placeBreakpoint(path, snap, range,
|
||||||
traceBpt.getThreads(), traceBpt.getKinds(), traceBpt.isEnabled(snap),
|
traceBpt.getThreads(), traceBpt.getKinds(), traceBpt.isEnabled(snap),
|
||||||
traceBpt.getComment());
|
traceBpt.getComment());
|
||||||
|
// placeBreakpoint resets the name - maybe pass name in?
|
||||||
|
newtraceBpt.setName(traceBpt.getName());
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (DuplicateNameException e) {
|
catch (DuplicateNameException e) {
|
||||||
// Split, and length matters not
|
// Split, and length matters not
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue