GP-595: Fixing path and schema issues in JPDA/JDI

This commit is contained in:
d-millar 2021-01-14 16:21:34 -05:00 committed by Dan
parent aa18341dca
commit 9c6cbcbc81
36 changed files with 149 additions and 114 deletions

View file

@ -83,7 +83,7 @@ public class JdiModelTargetBreakpointContainer extends JdiModelTargetObjectImpl
JdiModelTargetLocation targetLocation = JdiModelTargetLocation targetLocation =
(JdiModelTargetLocation) getTargetObject(location); (JdiModelTargetLocation) getTargetObject(location);
if (targetLocation == null) { if (targetLocation == null) {
targetLocation = new JdiModelTargetLocation(this, location); targetLocation = new JdiModelTargetLocation(this, location, true);
} }
JdiBreakpointInfo info = targetLocation.addBreakpoint(); JdiBreakpointInfo info = targetLocation.addBreakpoint();
breakpointCreated(info, JdiCause.Causes.UNCLAIMED); breakpointCreated(info, JdiCause.Causes.UNCLAIMED);
@ -122,7 +122,8 @@ public class JdiModelTargetBreakpointContainer extends JdiModelTargetObjectImpl
public synchronized JdiModelTargetBreakpointSpec getTargetBreakpointSpec( public synchronized JdiModelTargetBreakpointSpec getTargetBreakpointSpec(
JdiBreakpointInfo info) { JdiBreakpointInfo info) {
return specsByInfo.computeIfAbsent(info, i -> new JdiModelTargetBreakpointSpec(this, info)); return specsByInfo.computeIfAbsent(info,
i -> new JdiModelTargetBreakpointSpec(this, info, true));
} }
protected void updateUsingBreakpoints(Map<Long, JdiBreakpointInfo> byNumber) { protected void updateUsingBreakpoints(Map<Long, JdiBreakpointInfo> byNumber) {

View file

@ -53,8 +53,8 @@ public class JdiModelTargetBreakpointSpec extends JdiModelTargetObjectImpl imple
}; };
public JdiModelTargetBreakpointSpec(JdiModelTargetBreakpointContainer breakpoints, public JdiModelTargetBreakpointSpec(JdiModelTargetBreakpointContainer breakpoints,
JdiBreakpointInfo info) { JdiBreakpointInfo info, boolean isElement) {
super(breakpoints, info.toString(), info); super(breakpoints, info.toString(), info, isElement);
} }
@Override @Override

View file

@ -46,8 +46,9 @@ public class JdiModelTargetConnector extends JdiModelTargetObjectImpl
protected final Connector cx; protected final Connector cx;
protected final TargetParameterMap paramDescs; protected final TargetParameterMap paramDescs;
public JdiModelTargetConnector(JdiModelTargetConnectorContainer connectors, Connector cx) { public JdiModelTargetConnector(JdiModelTargetConnectorContainer connectors, Connector cx,
super(connectors, cx.name(), cx); boolean isElement) {
super(connectors, cx.name(), cx, isElement);
this.connectors = connectors; this.connectors = connectors;
this.cx = cx; this.cx = cx;

View file

@ -79,7 +79,7 @@ public class JdiModelTargetConnectorContainer extends JdiModelTargetObjectImpl {
protected synchronized JdiModelTargetConnector getTargetConnector(Connector cx) { protected synchronized JdiModelTargetConnector getTargetConnector(Connector cx) {
return connectorsByName.computeIfAbsent(cx.name(), return connectorsByName.computeIfAbsent(cx.name(),
n -> new JdiModelTargetConnector(this, cx)); n -> new JdiModelTargetConnector(this, cx, true));
} }
public synchronized JdiModelTargetConnector getTargetConnectorIfPresent(String name) { public synchronized JdiModelTargetConnector getTargetConnectorIfPresent(String name) {

View file

@ -36,8 +36,9 @@ public class JdiModelTargetConstantPool extends JdiModelTargetObjectImpl impleme
private AddressRange range; private AddressRange range;
private byte[] pool; private byte[] pool;
public JdiModelTargetConstantPool(JdiModelTargetSectionContainer parent, byte[] pool) { public JdiModelTargetConstantPool(JdiModelTargetSectionContainer parent, byte[] pool,
super(parent, "Constant Pool", pool); boolean isElement) {
super(parent, "Constant Pool", pool, isElement);
this.pool = pool; this.pool = pool;
this.range = impl.getAddressRange(getClassType(), pool.length); this.range = impl.getAddressRange(getClassType(), pool.length);

View file

@ -24,11 +24,10 @@ import com.sun.jdi.request.*;
import ghidra.dbg.jdi.manager.breakpoint.JdiBreakpointInfo; import ghidra.dbg.jdi.manager.breakpoint.JdiBreakpointInfo;
import ghidra.dbg.jdi.model.iface2.JdiModelTargetObject; import ghidra.dbg.jdi.model.iface2.JdiModelTargetObject;
import ghidra.dbg.target.schema.TargetAttributeType; import ghidra.dbg.target.schema.*;
import ghidra.dbg.target.schema.TargetObjectSchemaInfo;
@TargetObjectSchemaInfo(name = "Field", elements = { // @TargetObjectSchemaInfo(name = "Field", elements = { //
//@TargetElementType(type = Void.class) // @TargetElementType(type = Void.class) //
}, attributes = { // }, attributes = { //
@TargetAttributeType(name = "Attributes", type = JdiModelTargetAttributesContainer.class), // @TargetAttributeType(name = "Attributes", type = JdiModelTargetAttributesContainer.class), //
@TargetAttributeType(type = Void.class) // @TargetAttributeType(type = Void.class) //
@ -41,8 +40,8 @@ public class JdiModelTargetField extends JdiModelTargetObjectImpl {
private JdiModelTargetReferenceType declaringType; private JdiModelTargetReferenceType declaringType;
private JdiModelTargetAttributesContainer addedAttributes; private JdiModelTargetAttributesContainer addedAttributes;
public JdiModelTargetField(JdiModelTargetObject fields, Field field) { public JdiModelTargetField(JdiModelTargetObject fields, Field field, boolean isElement) {
super(fields, field.toString(), field); super(fields, field.toString(), field, isElement);
this.field = field; this.field = field;
changeAttributes(List.of(), List.of(), Map.of( // changeAttributes(List.of(), List.of(), Map.of( //

View file

@ -41,8 +41,8 @@ public class JdiModelTargetLocalVariable extends JdiModelTargetObjectImpl {
private JdiModelTargetAttributesContainer addedAttributes; private JdiModelTargetAttributesContainer addedAttributes;
public JdiModelTargetLocalVariable(JdiModelTargetLocalVariableContainer variables, public JdiModelTargetLocalVariable(JdiModelTargetLocalVariableContainer variables,
LocalVariable var) { LocalVariable var, boolean isElement) {
super(variables, var.name(), var); super(variables, var.name(), var, isElement);
this.var = var; this.var = var;
changeAttributes(List.of(), List.of(), Map.of( // changeAttributes(List.of(), List.of(), Map.of( //

View file

@ -75,7 +75,7 @@ public class JdiModelTargetLocalVariableContainer extends JdiModelTargetObjectIm
protected synchronized JdiModelTargetLocalVariable getTargetVariable(LocalVariable var) { protected synchronized JdiModelTargetLocalVariable getTargetVariable(LocalVariable var) {
return variablesByName.computeIfAbsent(var.name(), return variablesByName.computeIfAbsent(var.name(),
n -> new JdiModelTargetLocalVariable(this, var)); n -> new JdiModelTargetLocalVariable(this, var, true));
} }
public synchronized JdiModelTargetLocalVariable getTargetVariableIfPresent(String name) { public synchronized JdiModelTargetLocalVariable getTargetVariableIfPresent(String name) {

View file

@ -49,8 +49,9 @@ public class JdiModelTargetLocation extends JdiModelTargetObjectImpl {
private JdiModelTargetReferenceType declaringType; private JdiModelTargetReferenceType declaringType;
private Address address; private Address address;
public JdiModelTargetLocation(JdiModelTargetObject parent, Location location) { public JdiModelTargetLocation(JdiModelTargetObject parent, Location location,
super(parent, getUniqueId(location), location); boolean isElement) {
super(parent, getUniqueId(location), location, isElement);
this.location = location; this.location = location;
impl.registerMethod(location.method()); impl.registerMethod(location.method());
@ -105,13 +106,17 @@ public class JdiModelTargetLocation extends JdiModelTargetObjectImpl {
if (address != null) { if (address != null) {
return address; return address;
} }
getInstance(location.method()); return getAddressFromLocation(impl, location);
}
public static Address getAddressFromLocation(JdiModelImpl impl, Location location) {
AddressRange addressRange = impl.getAddressRange(location.method()); AddressRange addressRange = impl.getAddressRange(location.method());
if (addressRange == null) { if (addressRange == null) {
return impl.getAddressSpace("ram").getAddress(-1L); return impl.getAddressSpace("ram").getAddress(-1L);
} }
long codeIndex = location.codeIndex(); long codeIndex = location.codeIndex();
return addressRange.getMinAddress().add(codeIndex < 0 ? 0 : codeIndex); return addressRange.getMinAddress().add(codeIndex < 0 ? 0 : codeIndex);
} }
public JdiBreakpointInfo addBreakpoint() { public JdiBreakpointInfo addBreakpoint() {

View file

@ -72,7 +72,7 @@ public class JdiModelTargetLocationContainer extends JdiModelTargetObjectImpl {
protected synchronized JdiModelTargetLocation getTargetLocation(Location loc) { protected synchronized JdiModelTargetLocation getTargetLocation(Location loc) {
return locationsByName.computeIfAbsent(loc.toString(), return locationsByName.computeIfAbsent(loc.toString(),
n -> new JdiModelTargetLocation(this, loc)); n -> new JdiModelTargetLocation(this, loc, true));
} }
public synchronized JdiModelTargetLocation getTargetLocationsIfPresent(String name) { public synchronized JdiModelTargetLocation getTargetLocationsIfPresent(String name) {

View file

@ -21,11 +21,10 @@ import java.util.concurrent.CompletableFuture;
import com.sun.jdi.*; import com.sun.jdi.*;
import ghidra.dbg.jdi.model.iface2.JdiModelTargetObject; import ghidra.dbg.jdi.model.iface2.JdiModelTargetObject;
import ghidra.dbg.target.schema.TargetAttributeType; import ghidra.dbg.target.schema.*;
import ghidra.dbg.target.schema.TargetObjectSchemaInfo;
@TargetObjectSchemaInfo(name = "Method", elements = { // @TargetObjectSchemaInfo(name = "Method", elements = { //
//@TargetElementType(type = Void.class) // @TargetElementType(type = Void.class) //
}, attributes = { // }, attributes = { //
@TargetAttributeType(name = "Attributes", type = JdiModelTargetAttributesContainer.class), // @TargetAttributeType(name = "Attributes", type = JdiModelTargetAttributesContainer.class), //
@TargetAttributeType(type = Object.class) // @TargetAttributeType(type = Object.class) //
@ -42,8 +41,8 @@ public class JdiModelTargetMethod extends JdiModelTargetObjectImpl {
private JdiModelTargetLocalVariableContainer variables; private JdiModelTargetLocalVariableContainer variables;
private JdiModelTargetType returnType; private JdiModelTargetType returnType;
public JdiModelTargetMethod(JdiModelTargetObject parent, Method method) { public JdiModelTargetMethod(JdiModelTargetObject parent, Method method, boolean isElement) {
super(parent, method.toString(), method); super(parent, method.toString(), method, isElement);
this.method = method; this.method = method;
changeAttributes(List.of(), List.of(), Map.of( // changeAttributes(List.of(), List.of(), Map.of( //
@ -94,7 +93,7 @@ public class JdiModelTargetMethod extends JdiModelTargetObjectImpl {
), "Initialized"); ), "Initialized");
this.location = method.location() == null ? null this.location = method.location() == null ? null
: new JdiModelTargetLocation(parent, method.location()); : new JdiModelTargetLocation(parent, method.location(), false);
if (location != null) { if (location != null) {
changeAttributes(List.of(), List.of( // changeAttributes(List.of(), List.of( //
location // location //

View file

@ -26,7 +26,8 @@ import ghidra.dbg.target.schema.*;
@TargetObjectSchemaInfo(name = "Module", elements = { // @TargetObjectSchemaInfo(name = "Module", elements = { //
@TargetElementType(type = Void.class) // @TargetElementType(type = Void.class) //
}, attributes = { // }, attributes = { //
@TargetAttributeType(type = Void.class) // @TargetAttributeType(name = "UID", type = Long.class, fixed = true), //
@TargetAttributeType(type = Object.class) //
}) })
public class JdiModelTargetModule extends JdiModelTargetObjectReference { public class JdiModelTargetModule extends JdiModelTargetObjectReference {
@ -38,8 +39,9 @@ public class JdiModelTargetModule extends JdiModelTargetObjectReference {
///protected final JdiModelTargetSymbolContainer symbols; ///protected final JdiModelTargetSymbolContainer symbols;
public JdiModelTargetModule(JdiModelTargetModuleContainer modules, ModuleReference module) { public JdiModelTargetModule(JdiModelTargetModuleContainer modules, ModuleReference module,
super(modules, module); boolean isElement) {
super(modules, module, isElement);
this.module = module; this.module = module;
changeAttributes(List.of(), List.of(), Map.of( // changeAttributes(List.of(), List.of(), Map.of( //

View file

@ -111,7 +111,7 @@ public class JdiModelTargetModuleContainer extends JdiModelTargetObjectImpl
protected synchronized JdiModelTargetModule getTargetModule(ModuleReference module) { protected synchronized JdiModelTargetModule getTargetModule(ModuleReference module) {
return modulesByName.computeIfAbsent(JdiModelTargetModule.getUniqueId(module), return modulesByName.computeIfAbsent(JdiModelTargetModule.getUniqueId(module),
n -> new JdiModelTargetModule(this, module)); n -> new JdiModelTargetModule(this, module, true));
} }
public synchronized JdiModelTargetModule getTargetModuleIfPresent(String name) { public synchronized JdiModelTargetModule getTargetModuleIfPresent(String name) {

View file

@ -63,8 +63,9 @@ public class JdiModelTargetObjectImpl extends
), "Initialized"); ), "Initialized");
} }
public JdiModelTargetObjectImpl(JdiModelTargetObject parent, String id, Object object) { public JdiModelTargetObjectImpl(JdiModelTargetObject parent, String id, Object object,
super(parent.getModel(), parent, keyObject(id), "Object"); boolean isElement) {
super(parent.getModel(), parent, isElement ? keyObject(id) : id, "Object");
this.impl = parent.getModelImpl(); this.impl = parent.getModelImpl();
this.mirror = object instanceof Mirror ? (Mirror) object : null; this.mirror = object instanceof Mirror ? (Mirror) object : null;
this.object = object; this.object = object;
@ -118,7 +119,7 @@ public class JdiModelTargetObjectImpl extends
if (targetVM != null) { if (targetVM != null) {
return targetVM.getTargetObject(obj); return targetVM.getTargetObject(obj);
} }
System.err.println("Attempt to getTargetObject from class without Mirror " + this); //System.err.println("Attempt to getTargetObject from class without Mirror " + this);
return null; return null;
} }

View file

@ -22,11 +22,10 @@ import java.util.concurrent.CompletableFuture;
import com.sun.jdi.*; import com.sun.jdi.*;
import ghidra.dbg.jdi.model.iface2.JdiModelTargetObject; import ghidra.dbg.jdi.model.iface2.JdiModelTargetObject;
import ghidra.dbg.target.schema.TargetAttributeType; import ghidra.dbg.target.schema.*;
import ghidra.dbg.target.schema.TargetObjectSchemaInfo;
@TargetObjectSchemaInfo(name = "ObjectReference", elements = { // @TargetObjectSchemaInfo(name = "ObjectReference", elements = { //
//@TargetElementType(type = Void.class) // @TargetElementType(type = Void.class) //
}, attributes = { // }, attributes = { //
@TargetAttributeType(name = "UID", type = Long.class, required = true, fixed = true), // @TargetAttributeType(name = "UID", type = Long.class, required = true, fixed = true), //
@TargetAttributeType(type = Object.class) // @TargetAttributeType(type = Object.class) //
@ -40,13 +39,14 @@ public class JdiModelTargetObjectReference extends JdiModelTargetValue {
protected JdiModelTargetThread owner; protected JdiModelTargetThread owner;
private JdiModelTargetReferenceType referenceType; private JdiModelTargetReferenceType referenceType;
public JdiModelTargetObjectReference(JdiModelTargetObject object, ObjectReference objref) { public JdiModelTargetObjectReference(JdiModelTargetObject object, ObjectReference objref,
this(object, Long.toHexString(objref.uniqueID()), objref); boolean isElement) {
this(object, Long.toString(objref.uniqueID()), objref, isElement);
} }
public JdiModelTargetObjectReference(JdiModelTargetObject object, String id, public JdiModelTargetObjectReference(JdiModelTargetObject object, String id,
ObjectReference objref) { ObjectReference objref, boolean isElement) {
super(object, id, objref); super(object, id, objref, isElement);
this.objref = objref; this.objref = objref;
changeAttributes(List.of(), List.of(), Map.of( // changeAttributes(List.of(), List.of(), Map.of( //

View file

@ -44,17 +44,18 @@ public class JdiModelTargetObjectReferenceContainer extends JdiModelTargetObject
} }
protected CompletableFuture<Void> updateUsingReferences(Map<String, ObjectReference> byName) { protected CompletableFuture<Void> updateUsingReferences(Map<String, ObjectReference> byName) {
List<JdiModelTargetObjectReference> objects; Map<String, JdiModelTargetObjectReference> objects;
synchronized (this) { synchronized (this) {
objects = objects = byName.entrySet()
byName.values().stream().map(this::getTargetObject).collect(Collectors.toList()); .stream()
.collect(Collectors.toMap(e -> e.getKey(), e -> getTargetObject(e.getValue())));
} }
AsyncFence fence = new AsyncFence(); AsyncFence fence = new AsyncFence();
for (JdiModelTargetObjectReference m : objects) { for (JdiModelTargetObjectReference m : objects.values()) {
fence.include(m.init()); fence.include(m.init());
} }
return fence.ready().thenAccept(__ -> { return fence.ready().thenAccept(__ -> {
changeElements(List.of(), objects, Map.of(), "Refreshed"); changeElements(List.of(), List.of(), objects, "Refreshed");
}); });
} }

View file

@ -53,8 +53,8 @@ public class JdiModelTargetProcess extends JdiModelTargetObjectImpl implements /
private Thread input; private Thread input;
private Thread error; private Thread error;
public JdiModelTargetProcess(JdiModelTargetVM vm, Process process) { public JdiModelTargetProcess(JdiModelTargetVM vm, Process process, boolean isElement) {
super(vm, getUniqueId(process), process); super(vm, getUniqueId(process), process, isElement);
this.process = process; this.process = process;
//writer = new PrintWriter(process.getOutputStream()); //writer = new PrintWriter(process.getOutputStream());

View file

@ -23,13 +23,12 @@ import com.sun.jdi.*;
import ghidra.async.AsyncFence; import ghidra.async.AsyncFence;
import ghidra.dbg.jdi.model.iface2.JdiModelTargetObject; import ghidra.dbg.jdi.model.iface2.JdiModelTargetObject;
import ghidra.dbg.target.TargetModule; import ghidra.dbg.target.TargetModule;
import ghidra.dbg.target.schema.TargetAttributeType; import ghidra.dbg.target.schema.*;
import ghidra.dbg.target.schema.TargetObjectSchemaInfo;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressRangeImpl; import ghidra.program.model.address.AddressRangeImpl;
@TargetObjectSchemaInfo(name = "ReferenceType", elements = { // @TargetObjectSchemaInfo(name = "ReferenceType", elements = { //
//@TargetElementType(type = Void.class) // @TargetElementType(type = Void.class) //
}, attributes = { // }, attributes = { //
@TargetAttributeType(name = "Attributes", type = JdiModelTargetAttributesContainer.class), // @TargetAttributeType(name = "Attributes", type = JdiModelTargetAttributesContainer.class), //
@TargetAttributeType(type = Object.class) // @TargetAttributeType(type = Object.class) //
@ -52,13 +51,14 @@ public class JdiModelTargetReferenceType extends JdiModelTargetType implements /
private JdiModelTargetAttributesContainer addedAttributes; private JdiModelTargetAttributesContainer addedAttributes;
protected JdiModelTargetSectionContainer sections; protected JdiModelTargetSectionContainer sections;
public JdiModelTargetReferenceType(JdiModelTargetObject parent, ReferenceType reftype) { public JdiModelTargetReferenceType(JdiModelTargetObject parent, ReferenceType reftype,
this(parent, reftype.name(), reftype); boolean isElement) {
this(parent, reftype.name(), reftype, isElement);
} }
public JdiModelTargetReferenceType(JdiModelTargetObject parent, String id, public JdiModelTargetReferenceType(JdiModelTargetObject parent, String id,
ReferenceType reftype) { ReferenceType reftype, boolean isElement) {
super(parent, id, reftype); super(parent, id, reftype, isElement);
this.reftype = reftype; this.reftype = reftype;
if (reftype instanceof ClassType) { if (reftype instanceof ClassType) {
@ -120,7 +120,7 @@ public class JdiModelTargetReferenceType extends JdiModelTargetType implements /
this.instances = new JdiModelTargetObjectReferenceContainer(this, "Objects", this.instances = new JdiModelTargetObjectReferenceContainer(this, "Objects",
reftype.instances(maxInstances)); reftype.instances(maxInstances));
this.classLoader = reftype.classLoader() == null ? null this.classLoader = reftype.classLoader() == null ? null
: new JdiModelTargetObjectReference(this, reftype.classLoader()); : new JdiModelTargetObjectReference(this, reftype.classLoader(), false);
this.classObject = (JdiModelTargetObjectReference) getInstance(reftype.classObject()); this.classObject = (JdiModelTargetObjectReference) getInstance(reftype.classObject());
populateAttributes(); populateAttributes();

View file

@ -23,13 +23,12 @@ import com.sun.jdi.Location;
import ghidra.dbg.jdi.model.iface2.JdiModelTargetObject; import ghidra.dbg.jdi.model.iface2.JdiModelTargetObject;
import ghidra.dbg.target.TargetRegister; import ghidra.dbg.target.TargetRegister;
import ghidra.dbg.target.schema.TargetAttributeType; import ghidra.dbg.target.schema.*;
import ghidra.dbg.target.schema.TargetObjectSchemaInfo;
import ghidra.dbg.util.ConversionUtils; import ghidra.dbg.util.ConversionUtils;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
@TargetObjectSchemaInfo(name = "RegisterDescriptor", elements = { // @TargetObjectSchemaInfo(name = "RegisterDescriptor", elements = { //
//@TargetElementType(type = Void.class) // @TargetElementType(type = Void.class) //
}, attributes = { // }, attributes = { //
@TargetAttributeType( // @TargetAttributeType( //
name = TargetRegister.CONTAINER_ATTRIBUTE_NAME, // name = TargetRegister.CONTAINER_ATTRIBUTE_NAME, //
@ -42,8 +41,8 @@ public class JdiModelTargetRegister extends JdiModelTargetObjectImpl implements
protected final String name; protected final String name;
protected Address addr; protected Address addr;
public JdiModelTargetRegister(JdiModelTargetObject parent, String name) { public JdiModelTargetRegister(JdiModelTargetObject parent, String name, boolean isElement) {
super(parent, name, name); super(parent, name, name, isElement);
this.name = name; this.name = name;
changeAttributes(List.of(), List.of(), Map.of( // changeAttributes(List.of(), List.of(), Map.of( //
@ -77,9 +76,8 @@ public class JdiModelTargetRegister extends JdiModelTargetObjectImpl implements
} }
public byte[] readRegister(Location location) { public byte[] readRegister(Location location) {
JdiModelTargetLocation targetLocation = new JdiModelTargetLocation(this, location);
Address oldval = (Address) getCachedAttribute(VALUE_ATTRIBUTE_NAME); Address oldval = (Address) getCachedAttribute(VALUE_ATTRIBUTE_NAME);
addr = targetLocation.getAddress(); addr = JdiModelTargetLocation.getAddressFromLocation(impl, location);
changeAttributes(List.of(), List.of(), Map.of( // changeAttributes(List.of(), List.of(), Map.of( //
DISPLAY_ATTRIBUTE_NAME, getDisplay(), // DISPLAY_ATTRIBUTE_NAME, getDisplay(), //

View file

@ -45,9 +45,9 @@ public class JdiModelTargetRegisterContainer extends JdiModelTargetObjectImpl
public JdiModelTargetRegisterContainer(JdiModelTargetThread thread) { public JdiModelTargetRegisterContainer(JdiModelTargetThread thread) {
super(thread, "Registers"); super(thread, "Registers");
this.thread = thread; this.thread = thread;
this.pc = new JdiModelTargetRegister(this, "PC"); this.pc = new JdiModelTargetRegister(this, "PC", true);
this.sp = new JdiModelTargetRegister(this, "SP"); this.sp = new JdiModelTargetRegister(this, "SP", true);
this.retAddr = new JdiModelTargetRegister(this, "return_address"); this.retAddr = new JdiModelTargetRegister(this, "return_address", true);
registersByName.put(pc.getName(), pc); registersByName.put(pc.getName(), pc);
registersByName.put(sp.getName(), sp); registersByName.put(sp.getName(), sp);
registersByName.put(retAddr.getName(), retAddr); registersByName.put(retAddr.getName(), retAddr);
@ -80,7 +80,8 @@ public class JdiModelTargetRegisterContainer extends JdiModelTargetObjectImpl
*/ */
protected synchronized JdiModelTargetRegister getTargetRegister(String rname) { protected synchronized JdiModelTargetRegister getTargetRegister(String rname) {
return registersByName.computeIfAbsent(rname, n -> new JdiModelTargetRegister(this, rname)); return registersByName.computeIfAbsent(rname,
n -> new JdiModelTargetRegister(this, rname, true));
} }
public synchronized JdiModelTargetRegister getTargetMethodIfPresent(String rname) { public synchronized JdiModelTargetRegister getTargetMethodIfPresent(String rname) {

View file

@ -38,8 +38,9 @@ public class JdiModelTargetSection extends JdiModelTargetObjectImpl implements /
protected final Method method; protected final Method method;
private AddressRange range; private AddressRange range;
public JdiModelTargetSection(JdiModelTargetSectionContainer parent, Method method) { public JdiModelTargetSection(JdiModelTargetSectionContainer parent, Method method,
super(parent, method.toString(), method); boolean isElement) {
super(parent, method.toString(), method, isElement);
this.method = method; this.method = method;
this.range = impl.getAddressRange(method); this.range = impl.getAddressRange(method);

View file

@ -54,7 +54,7 @@ public class JdiModelTargetSectionContainer extends JdiModelTargetObjectImpl
@Override @Override
protected CompletableFuture<Void> requestAttributes(boolean refresh) { protected CompletableFuture<Void> requestAttributes(boolean refresh) {
constantPool = new JdiModelTargetConstantPool(this, reftype.reftype.constantPool()); constantPool = new JdiModelTargetConstantPool(this, reftype.reftype.constantPool(), false);
changeAttributes(List.of(), List.of( // changeAttributes(List.of(), List.of( //
constantPool // constantPool //
), Map.of(), "Initialized"); ), Map.of(), "Initialized");
@ -70,7 +70,7 @@ public class JdiModelTargetSectionContainer extends JdiModelTargetObjectImpl
protected synchronized JdiModelTargetSection getTargetSection(Method method) { protected synchronized JdiModelTargetSection getTargetSection(Method method) {
return sectionsByName.computeIfAbsent(JdiModelImpl.methodToKey(method), return sectionsByName.computeIfAbsent(JdiModelImpl.methodToKey(method),
n -> new JdiModelTargetSection(this, method)); n -> new JdiModelTargetSection(this, method, true));
} }
public synchronized JdiModelTargetSection getTargetSectionIfPresent(String name) { public synchronized JdiModelTargetSection getTargetSectionIfPresent(String name) {

View file

@ -68,7 +68,7 @@ public class JdiModelTargetStack extends JdiModelTargetObjectImpl
return framesByLocation.compute(frame.location(), (l, f) -> { return framesByLocation.compute(frame.location(), (l, f) -> {
if (f == null || f.getFrameLevel() != level) { if (f == null || f.getFrameLevel() != level) {
JdiModelTargetStackFrame tf = JdiModelTargetStackFrame tf =
new JdiModelTargetStackFrame(this, thread, level, frame); new JdiModelTargetStackFrame(this, thread, level, frame, true);
framesByLevel.put(level, tf); framesByLevel.put(level, tf);
return tf; return tf;
} }

View file

@ -30,13 +30,12 @@ import ghidra.dbg.jdi.manager.JdiEventsListenerAdapter;
import ghidra.dbg.jdi.model.iface1.JdiModelSelectableObject; import ghidra.dbg.jdi.model.iface1.JdiModelSelectableObject;
import ghidra.dbg.jdi.model.iface1.JdiModelTargetFocusScope; import ghidra.dbg.jdi.model.iface1.JdiModelTargetFocusScope;
import ghidra.dbg.target.TargetStackFrame; import ghidra.dbg.target.TargetStackFrame;
import ghidra.dbg.target.schema.TargetAttributeType; import ghidra.dbg.target.schema.*;
import ghidra.dbg.target.schema.TargetObjectSchemaInfo;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.util.Msg; import ghidra.util.Msg;
@TargetObjectSchemaInfo(name = "StackFrame", elements = { // @TargetObjectSchemaInfo(name = "StackFrame", elements = { //
//@TargetElementType(type = Void.class) // @TargetElementType(type = Void.class) //
}, attributes = { // }, attributes = { //
@TargetAttributeType(type = Object.class) // @TargetAttributeType(type = Object.class) //
}) })
@ -65,13 +64,13 @@ public class JdiModelTargetStackFrame extends JdiModelTargetObjectImpl
protected long level; protected long level;
public JdiModelTargetStackFrame(JdiModelTargetStack stack, JdiModelTargetThread thread, public JdiModelTargetStackFrame(JdiModelTargetStack stack, JdiModelTargetThread thread,
int level, StackFrame frame) { int level, StackFrame frame, boolean isElement) {
super(stack, getUniqueId(level), frame); super(stack, getUniqueId(level), frame, isElement);
this.thread = thread; this.thread = thread;
this.level = level; this.level = level;
this.frame = frame; this.frame = frame;
this.location = new JdiModelTargetLocation(this, frame.location()); this.location = new JdiModelTargetLocation(this, frame.location(), false);
changeAttributes(List.of(), List.of(), Map.of( // changeAttributes(List.of(), List.of(), Map.of( //
DISPLAY_ATTRIBUTE_NAME, getDisplay(), // DISPLAY_ATTRIBUTE_NAME, getDisplay(), //

View file

@ -30,18 +30,18 @@ import ghidra.dbg.jdi.manager.*;
import ghidra.dbg.jdi.model.iface1.*; import ghidra.dbg.jdi.model.iface1.*;
import ghidra.dbg.jdi.model.iface2.JdiModelTargetObject; import ghidra.dbg.jdi.model.iface2.JdiModelTargetObject;
import ghidra.dbg.target.TargetThread; import ghidra.dbg.target.TargetThread;
import ghidra.dbg.target.schema.TargetAttributeType; import ghidra.dbg.target.schema.*;
import ghidra.dbg.target.schema.TargetObjectSchemaInfo;
import ghidra.lifecycle.Internal; import ghidra.lifecycle.Internal;
import ghidra.util.Msg; import ghidra.util.Msg;
@TargetObjectSchemaInfo(name = "Thread", elements = { // @TargetObjectSchemaInfo(name = "Thread", elements = { //
//@TargetElementType(type = TargetObject.class) // @TargetElementType(type = Void.class) //
}, attributes = { // }, attributes = { //
@TargetAttributeType(name = "Attributes", type = JdiModelTargetAttributesContainer.class), // @TargetAttributeType(name = "Attributes", type = JdiModelTargetAttributesContainer.class), //
@TargetAttributeType(name = "Registers", type = JdiModelTargetRegisterContainer.class, required = true, fixed = true), // @TargetAttributeType(name = "Registers", type = JdiModelTargetRegisterContainer.class, required = true, fixed = true), //
@TargetAttributeType(name = "Stack", type = JdiModelTargetStack.class, required = true, fixed = true), // @TargetAttributeType(name = "Stack", type = JdiModelTargetStack.class, required = true, fixed = true), //
@TargetAttributeType(name = "Status", type = Integer.class), // @TargetAttributeType(name = "Status", type = Integer.class), //
@TargetAttributeType(name = "UID", type = Long.class, fixed = true), //
@TargetAttributeType(type = Object.class) // @TargetAttributeType(type = Object.class) //
}, canonicalContainer = true) }, canonicalContainer = true)
public class JdiModelTargetThread extends JdiModelTargetObjectReference implements // public class JdiModelTargetThread extends JdiModelTargetObjectReference implements //
@ -72,8 +72,9 @@ public class JdiModelTargetThread extends JdiModelTargetObjectReference implemen
protected JdiModelTargetObjectReferenceContainer ownedMonitors; protected JdiModelTargetObjectReferenceContainer ownedMonitors;
protected JdiModelTargetAttributesContainer addedAttributes; protected JdiModelTargetAttributesContainer addedAttributes;
public JdiModelTargetThread(JdiModelTargetObject parent, ThreadReference thread) { public JdiModelTargetThread(JdiModelTargetObject parent, ThreadReference thread,
super(parent, thread.name(), thread); boolean isElement) {
super(parent, thread.name(), thread, isElement);
this.thread = thread; this.thread = thread;
this.eventManager = thread.virtualMachine().eventRequestManager(); this.eventManager = thread.virtualMachine().eventRequestManager();
@ -160,7 +161,8 @@ public class JdiModelTargetThread extends JdiModelTargetObjectReference implemen
} }
} }
ThreadGroupReference tg = thread.threadGroup(); ThreadGroupReference tg = thread.threadGroup();
this.threadGroup = tg == null ? null : new JdiModelTargetThreadGroupContainer(this, tg); this.threadGroup =
tg == null ? null : new JdiModelTargetThreadGroupContainer(this, tg, false);
if (threadGroup != null) { if (threadGroup != null) {
changeAttributes(List.of(), List.of(), Map.of( // changeAttributes(List.of(), List.of(), Map.of( //
"Thread Group", thread.threadGroup() // "Thread Group", thread.threadGroup() //
@ -381,7 +383,7 @@ public class JdiModelTargetThread extends JdiModelTargetObjectReference implemen
} }
public void setLocation(Location location) { public void setLocation(Location location) {
this.location = new JdiModelTargetLocation(this, location); this.location = new JdiModelTargetLocation(this, location, false);
Method method = location.method(); Method method = location.method();
impl.registerMethod(method); impl.registerMethod(method);
} }

View file

@ -51,8 +51,8 @@ public class JdiModelTargetThreadGroupContainer extends JdiModelTargetObjectImpl
} }
public JdiModelTargetThreadGroupContainer(JdiModelTargetObject parent, public JdiModelTargetThreadGroupContainer(JdiModelTargetObject parent,
ThreadGroupReference group) { ThreadGroupReference group, boolean isElement) {
super(parent, keyGroup(group)); super(parent, isElement ? keyGroup(group) : group.name());
this.baseGroup = group; this.baseGroup = group;
} }
@ -89,7 +89,7 @@ public class JdiModelTargetThreadGroupContainer extends JdiModelTargetObjectImpl
public synchronized JdiModelTargetThreadGroupContainer getTargetThreadGroup( public synchronized JdiModelTargetThreadGroupContainer getTargetThreadGroup(
ThreadGroupReference group) { ThreadGroupReference group) {
return threadGroupsById.computeIfAbsent(group.name(), return threadGroupsById.computeIfAbsent(group.name(),
i -> new JdiModelTargetThreadGroupContainer(this, group)); i -> new JdiModelTargetThreadGroupContainer(this, group, true));
} }
} }

View file

@ -21,11 +21,10 @@ import java.util.Map;
import com.sun.jdi.Type; import com.sun.jdi.Type;
import ghidra.dbg.jdi.model.iface2.JdiModelTargetObject; import ghidra.dbg.jdi.model.iface2.JdiModelTargetObject;
import ghidra.dbg.target.schema.TargetAttributeType; import ghidra.dbg.target.schema.*;
import ghidra.dbg.target.schema.TargetObjectSchemaInfo;
@TargetObjectSchemaInfo(name = "Type", elements = { // @TargetObjectSchemaInfo(name = "Type", elements = { //
//@TargetElementType(type = Void.class) // @TargetElementType(type = Void.class) //
}, attributes = { // }, attributes = { //
@TargetAttributeType(name = "Signature", type = String.class), // @TargetAttributeType(name = "Signature", type = String.class), //
@TargetAttributeType(type = Void.class) // @TargetAttributeType(type = Void.class) //
@ -34,12 +33,13 @@ public class JdiModelTargetType extends JdiModelTargetObjectImpl {
protected final Type type; protected final Type type;
public JdiModelTargetType(JdiModelTargetObject object, Type type) { public JdiModelTargetType(JdiModelTargetObject object, Type type, boolean isElement) {
this(object, type.toString(), type); this(object, type.toString(), type, isElement);
} }
public JdiModelTargetType(JdiModelTargetObject object, String id, Type type) { public JdiModelTargetType(JdiModelTargetObject object, String id, Type type,
super(object, id, type); boolean isElement) {
super(object, id, type, isElement);
this.type = type; this.type = type;
changeAttributes(List.of(), List.of(), Map.of( // changeAttributes(List.of(), List.of(), Map.of( //

View file

@ -49,7 +49,11 @@ import ghidra.lifecycle.Internal;
// @TargetElementType(type = Void.class) // // @TargetElementType(type = Void.class) //
}, attributes = { // }, attributes = { //
@TargetAttributeType(name = "Attributes", type = JdiModelTargetAttributesContainer.class), // @TargetAttributeType(name = "Attributes", type = JdiModelTargetAttributesContainer.class), //
@TargetAttributeType(name = "Breakpoints", type = JdiModelTargetBreakpointContainer.class, fixed = true), //
@TargetAttributeType(name = "Classes", type = JdiModelTargetClassContainer.class, fixed = true), //
@TargetAttributeType(name = "Modules", type = JdiModelTargetModuleContainer.class, fixed = true), //
@TargetAttributeType(name = "Threads", type = JdiModelTargetThreadContainer.class, required = true, fixed = true), // @TargetAttributeType(name = "Threads", type = JdiModelTargetThreadContainer.class, required = true, fixed = true), //
@TargetAttributeType(name = "ThreadGroups", type = JdiModelTargetThreadGroupContainer.class, fixed = true), //
@TargetAttributeType(type = Object.class) // @TargetAttributeType(type = Object.class) //
}, canonicalContainer = true) }, canonicalContainer = true)
public class JdiModelTargetVM extends JdiModelTargetObjectImpl implements // public class JdiModelTargetVM extends JdiModelTargetObjectImpl implements //
@ -91,8 +95,8 @@ public class JdiModelTargetVM extends JdiModelTargetObjectImpl implements //
private final MonitorContendedEnterRequest monitorEnterRequest; private final MonitorContendedEnterRequest monitorEnterRequest;
private final MonitorContendedEnteredRequest monitorEnteredRequest; private final MonitorContendedEnteredRequest monitorEnteredRequest;
public JdiModelTargetVM(JdiModelTargetVMContainer vms, VirtualMachine vm) { public JdiModelTargetVM(JdiModelTargetVMContainer vms, VirtualMachine vm, boolean isElement) {
super(vms, vm.name(), vm); super(vms, vm.name(), vm, isElement);
vms.vmsById.put(vm.name(), this); vms.vmsById.put(vm.name(), this);
this.vm = vm; this.vm = vm;
this.eventManager = vm.eventRequestManager(); this.eventManager = vm.eventRequestManager();
@ -124,7 +128,7 @@ public class JdiModelTargetVM extends JdiModelTargetObjectImpl implements //
Process proc = vm.process(); Process proc = vm.process();
if (proc != null) { if (proc != null) {
this.process = new JdiModelTargetProcess(this, proc); this.process = new JdiModelTargetProcess(this, proc, false);
} }
else { else {
this.process = null; this.process = null;

View file

@ -170,12 +170,12 @@ public class JdiModelTargetVMContainer extends JdiModelTargetObjectImpl
public synchronized JdiModelTargetVM getTargetVM(VirtualMachine vm) { public synchronized JdiModelTargetVM getTargetVM(VirtualMachine vm) {
return vmsById.computeIfAbsent(vm.name(), return vmsById.computeIfAbsent(vm.name(),
i -> new JdiModelTargetVM(this, impl.getManager().getKnownVMs().get(i))); i -> new JdiModelTargetVM(this, impl.getManager().getKnownVMs().get(i), true));
} }
public synchronized JdiModelTargetVM getTargetVMByName(String name) { public synchronized JdiModelTargetVM getTargetVMByName(String name) {
return vmsById.computeIfAbsent(name, return vmsById.computeIfAbsent(name,
i -> new JdiModelTargetVM(this, impl.getManager().getKnownVMs().get(i))); i -> new JdiModelTargetVM(this, impl.getManager().getKnownVMs().get(i), true));
} }
protected void invalidateMemoryAndRegisterCaches() { protected void invalidateMemoryAndRegisterCaches() {

View file

@ -31,12 +31,13 @@ public class JdiModelTargetValue extends JdiModelTargetObjectImpl {
protected final Value value; protected final Value value;
protected final Type type; protected final Type type;
public JdiModelTargetValue(JdiModelTargetObject object, Value value) { public JdiModelTargetValue(JdiModelTargetObject object, Value value, boolean isElement) {
this(object, value.toString(), value); this(object, value.toString(), value, isElement);
} }
public JdiModelTargetValue(JdiModelTargetObject object, String id, Value value) { public JdiModelTargetValue(JdiModelTargetObject object, String id, Value value,
super(object, id, value); boolean isElement) {
super(object, id, value, isElement);
this.value = value; this.value = value;
this.type = value.type(); this.type = value.type();
} }

View file

@ -74,7 +74,7 @@ public class JdiModelTargetValueContainer extends JdiModelTargetObjectImpl {
protected synchronized JdiModelTargetValue getTargetValue(Value val) { protected synchronized JdiModelTargetValue getTargetValue(Value val) {
return valuesByName.computeIfAbsent(val.toString(), return valuesByName.computeIfAbsent(val.toString(),
n -> new JdiModelTargetValue(this, val)); n -> new JdiModelTargetValue(this, val, true));
} }
public synchronized JdiModelTargetValue getTargetValueIfPresent(String name) { public synchronized JdiModelTargetValue getTargetValueIfPresent(String name) {

View file

@ -68,7 +68,8 @@ public class JdiModelTargetValueMap extends JdiModelTargetObjectImpl {
} }
protected synchronized JdiModelTargetValue getTargetValue(LocalVariable var, Value val) { protected synchronized JdiModelTargetValue getTargetValue(LocalVariable var, Value val) {
return valuesByVariable.computeIfAbsent(var, n -> new JdiModelTargetValue(this, val)); return valuesByVariable.computeIfAbsent(var,
n -> new JdiModelTargetValue(this, val, false));
} }
public synchronized JdiModelTargetValue getTargetValueIfPresent(LocalVariable var) { public synchronized JdiModelTargetValue getTargetValueIfPresent(LocalVariable var) {

View file

@ -25,6 +25,9 @@ import ghidra.dbg.agent.InvalidatableTargetObjectIf;
import ghidra.dbg.jdi.manager.JdiManager; import ghidra.dbg.jdi.manager.JdiManager;
import ghidra.dbg.jdi.model.*; import ghidra.dbg.jdi.model.*;
import ghidra.dbg.target.TargetObject; import ghidra.dbg.target.TargetObject;
import ghidra.dbg.target.schema.EnumerableTargetObjectSchema;
import ghidra.dbg.target.schema.TargetObjectSchema;
import ghidra.dbg.target.schema.TargetObjectSchema.SchemaName;
import ghidra.dbg.util.CollectionUtils.Delta; import ghidra.dbg.util.CollectionUtils.Delta;
import ghidra.util.datastruct.ListenerSet; import ghidra.util.datastruct.ListenerSet;
@ -61,27 +64,29 @@ public interface JdiModelTargetObject extends TargetObject, InvalidatableTargetO
if (targetObject == null) { if (targetObject == null) {
if (object instanceof ThreadReference) { if (object instanceof ThreadReference) {
ThreadReference thread = (ThreadReference) object; ThreadReference thread = (ThreadReference) object;
targetObject = new JdiModelTargetThread(this, thread); targetObject = new JdiModelTargetThread(this, thread, acceptsElement("Thread"));
} }
else if (object instanceof ObjectReference) { else if (object instanceof ObjectReference) {
ObjectReference ref = (ObjectReference) object; ObjectReference ref = (ObjectReference) object;
targetObject = new JdiModelTargetObjectReference(this, ref); targetObject =
new JdiModelTargetObjectReference(this, ref, acceptsElement("ObjectReference"));
} }
else if (object instanceof ReferenceType) { else if (object instanceof ReferenceType) {
ReferenceType reftype = (ReferenceType) object; ReferenceType reftype = (ReferenceType) object;
targetObject = new JdiModelTargetReferenceType(this, reftype); targetObject =
new JdiModelTargetReferenceType(this, reftype, acceptsElement("ReferenceType"));
} }
else if (object instanceof Field) { else if (object instanceof Field) {
Field field = (Field) object; Field field = (Field) object;
targetObject = new JdiModelTargetField(this, field); targetObject = new JdiModelTargetField(this, field, acceptsElement("Field"));
} }
else if (object instanceof Method) { else if (object instanceof Method) {
Method method = (Method) object; Method method = (Method) object;
targetObject = new JdiModelTargetMethod(this, method); targetObject = new JdiModelTargetMethod(this, method, acceptsElement("Method"));
} }
else if (object instanceof Type) { else if (object instanceof Type) {
Type type = (Type) object; Type type = (Type) object;
targetObject = new JdiModelTargetType(this, type); targetObject = new JdiModelTargetType(this, type, acceptsElement("Type"));
} }
else { else {
throw new RuntimeException(); throw new RuntimeException();
@ -90,6 +95,15 @@ public interface JdiModelTargetObject extends TargetObject, InvalidatableTargetO
return targetObject; return targetObject;
} }
public default boolean acceptsElement(String schemaName) {
TargetObjectSchema schema = this.getSchema();
if (schema.equals(EnumerableTargetObjectSchema.ANY)) {
return true;
}
SchemaName s = schema.getElementSchema(schemaName);
return s.toString().equals(schemaName);
}
public JdiModelTargetObject getTargetObject(Object object); public JdiModelTargetObject getTargetObject(Object object);
public Object getObject(); public Object getObject();

View file

@ -588,11 +588,12 @@ public class DebuggerObjectsProvider extends ComponentProviderAdapter implements
else { else {
addToPanel(buildTableFromAttributes(oc)); addToPanel(buildTableFromAttributes(oc));
} }
seq.exit();
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
}).finish(); }).finish().completeExceptionally(new RuntimeException("Unable to add table"));
} }
private ObjectTable<ObjectAttributeRow> buildTableFromAttributes(ObjectContainer container) { private ObjectTable<ObjectAttributeRow> buildTableFromAttributes(ObjectContainer container) {

View file

@ -27,6 +27,7 @@ import ghidra.app.plugin.core.debug.gui.objects.DebuggerObjectsProvider;
import ghidra.app.plugin.core.debug.gui.objects.ObjectContainer; import ghidra.app.plugin.core.debug.gui.objects.ObjectContainer;
import ghidra.dbg.target.*; import ghidra.dbg.target.*;
import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionState; import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionState;
import ghidra.util.Msg;
import ghidra.util.exception.CancelledException; import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
import resources.ResourceManager; import resources.ResourceManager;
@ -90,6 +91,8 @@ public class ObjectNode extends GTreeSlowLoadingNode { //extends GTreeNode
} }
catch (InterruptedException | ExecutionException e) { catch (InterruptedException | ExecutionException e) {
// Ignore // Ignore
Msg.warn(this, e);
//e.printStackTrace();
} }
} }
return new ArrayList<>(); return new ArrayList<>();

View file

@ -193,7 +193,7 @@ public class DefaultTargetObject<E extends TargetObject, P extends TargetObject>
Map<String, E> asMap = new LinkedHashMap<>(); Map<String, E> asMap = new LinkedHashMap<>();
for (E e : canonical) { for (E e : canonical) {
if (!PathUtils.parent(e.getPath()).equals(getPath())) { if (!PathUtils.parent(e.getPath()).equals(getPath())) {
Msg.error(this, "Link found in canonical elements: " + e); Msg.error(this, "Link found in canonical elements of " + parent + ": " + e);
} }
asMap.put(e.getIndex(), e); asMap.put(e.getIndex(), e);
} }