mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
GP-2253: post-review fixes
GP-2253: first wave
This commit is contained in:
parent
a59c42dd96
commit
b65aaf5663
3 changed files with 43 additions and 25 deletions
|
@ -21,6 +21,7 @@ import java.io.IOException;
|
|||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
@ -207,24 +208,25 @@ public class JdiManagerImpl implements JdiManager {
|
|||
@Override
|
||||
public CompletableFuture<VirtualMachine> addVM(Connector cx,
|
||||
Map<String, Connector.Argument> args) {
|
||||
// TODO: Since this is making a blocking-on-the-network call, it should be supplyAsync
|
||||
try {
|
||||
curVM = connectVM(cx, args);
|
||||
JdiEventHandler eventHandler = new JdiEventHandler(curVM, globalEventHandler);
|
||||
eventHandler.start();
|
||||
eventHandler.setState(ThreadReference.THREAD_STATUS_NOT_STARTED, Causes.UNCLAIMED);
|
||||
eventHandlers.put(curVM, eventHandler);
|
||||
vms.put(curVM.name(), curVM);
|
||||
connectors.put(curVM, cx);
|
||||
}
|
||||
catch (VMDisconnectedException e) {
|
||||
System.out.println("Virtual Machine is disconnected.");
|
||||
return CompletableFuture.failedFuture(e);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return CompletableFuture.failedFuture(e);
|
||||
}
|
||||
return CompletableFuture.completedFuture(curVM);
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
try {
|
||||
curVM = connectVM(cx, args);
|
||||
JdiEventHandler eventHandler = new JdiEventHandler(curVM, globalEventHandler);
|
||||
eventHandler.start();
|
||||
eventHandler.setState(ThreadReference.THREAD_STATUS_NOT_STARTED, Causes.UNCLAIMED);
|
||||
eventHandlers.put(curVM, eventHandler);
|
||||
vms.put(curVM.name(), curVM);
|
||||
connectors.put(curVM, cx);
|
||||
}
|
||||
catch (VMDisconnectedException e) {
|
||||
System.out.println("Virtual Machine is disconnected.");
|
||||
return ExceptionUtils.rethrow(e);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return ExceptionUtils.rethrow(e);
|
||||
}
|
||||
return curVM;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -71,6 +71,11 @@ public class JdiModelImpl extends AbstractDebuggerObjectModel {
|
|||
return completedRoot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetObjectSchema getRootSchema() {
|
||||
return ROOT_SCHEMA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBrief() {
|
||||
return "JDI@" + Integer.toHexString(System.identityHashCode(this));
|
||||
|
|
|
@ -106,13 +106,24 @@ public class JdiModelTargetModuleContainer extends JdiModelTargetObjectImpl
|
|||
}
|
||||
|
||||
protected CompletableFuture<Void> doRefresh() {
|
||||
Map<String, ModuleReference> map = new HashMap<>();
|
||||
List<ModuleReference> allModules = vm.vm.allModules();
|
||||
for (ModuleReference ref : allModules) {
|
||||
map.put(JdiModelTargetModule.getUniqueId(ref), ref);
|
||||
}
|
||||
modulesByName.keySet().retainAll(map.keySet());
|
||||
return updateUsingModules(map);
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
Map<String, ModuleReference> map = new HashMap<>();
|
||||
boolean available = vm.vm.canGetModuleInfo();
|
||||
if (!available) {
|
||||
return map;
|
||||
}
|
||||
try {
|
||||
List<ModuleReference> allModules = vm.vm.allModules();
|
||||
for (ModuleReference ref : allModules) {
|
||||
map.put(JdiModelTargetModule.getUniqueId(ref), ref);
|
||||
}
|
||||
}
|
||||
catch (UnsupportedOperationException e) {
|
||||
Msg.error(this, "UnsupportedOperationException: " + e.getMessage());
|
||||
}
|
||||
modulesByName.keySet().retainAll(map.keySet());
|
||||
return map;
|
||||
}).thenCompose(this::updateUsingModules);
|
||||
}
|
||||
|
||||
protected synchronized JdiModelTargetModule getTargetModule(ModuleReference module) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue