Merge remote-tracking branch 'origin/GP-1824_d-millar_field_for_bpt_expressions'

This commit is contained in:
Ryan Kurtz 2022-03-19 01:29:57 -04:00
commit 0023a51836
8 changed files with 64 additions and 22 deletions

View file

@ -24,9 +24,16 @@ import ghidra.dbg.target.schema.*;
import ghidra.dbg.util.PathUtils; import ghidra.dbg.util.PathUtils;
import ghidra.program.model.address.*; import ghidra.program.model.address.*;
@TargetObjectSchemaInfo(name = "Module", elements = { @TargetObjectSchemaInfo(
@TargetElementType(type = Void.class) }, attributes = { name = "Module",
@TargetAttributeType(name = "Symbols", type = DbgModelTargetSymbolContainerImpl.class, required = true, fixed = true), elements = {
@TargetElementType(type = Void.class) },
attributes = {
@TargetAttributeType(
name = "Symbols",
type = DbgModelTargetSymbolContainerImpl.class,
required = true,
fixed = true),
@TargetAttributeType(name = "BaseAddress", type = Address.class), @TargetAttributeType(name = "BaseAddress", type = Address.class),
@TargetAttributeType(name = "ImageName", type = String.class), @TargetAttributeType(name = "ImageName", type = String.class),
@TargetAttributeType(name = "TimeStamp", type = Integer.class), @TargetAttributeType(name = "TimeStamp", type = Integer.class),

View file

@ -20,17 +20,22 @@ import java.util.Map;
import agent.dbgeng.manager.impl.DbgMinimalSymbol; import agent.dbgeng.manager.impl.DbgMinimalSymbol;
import agent.dbgeng.model.iface2.DbgModelTargetSymbol; import agent.dbgeng.model.iface2.DbgModelTargetSymbol;
import ghidra.dbg.target.TargetObject; import ghidra.dbg.target.*;
import ghidra.dbg.target.TargetSymbol;
import ghidra.dbg.target.schema.*; import ghidra.dbg.target.schema.*;
import ghidra.dbg.util.PathUtils; import ghidra.dbg.util.PathUtils;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
@TargetObjectSchemaInfo(name = "Symbol", elements = { @TargetObjectSchemaInfo(
@TargetElementType(type = Void.class) }, attributes = { name = "Symbol",
@TargetAttributeType(name = TargetSymbol.NAMESPACE_ATTRIBUTE_NAME, type = DbgModelTargetSymbolContainerImpl.class), elements = {
@TargetElementType(type = Void.class) },
attributes = {
@TargetAttributeType(
name = TargetSymbol.NAMESPACE_ATTRIBUTE_NAME,
type = DbgModelTargetSymbolContainerImpl.class),
@TargetAttributeType(name = TargetObject.VALUE_ATTRIBUTE_NAME, type = Address.class), @TargetAttributeType(name = TargetObject.VALUE_ATTRIBUTE_NAME, type = Address.class),
@TargetAttributeType(name = TargetSymbol.SIZE_ATTRIBUTE_NAME, type = long.class), @TargetAttributeType(name = TargetSymbol.SIZE_ATTRIBUTE_NAME, type = long.class),
@TargetAttributeType(name = TargetBreakpointSpec.AS_BPT_ATTRIBUTE_NAME, type = String.class),
@TargetAttributeType(name = "Name", type = String.class), @TargetAttributeType(name = "Name", type = String.class),
@TargetAttributeType(name = "Size", type = long.class), @TargetAttributeType(name = "Size", type = long.class),
@TargetAttributeType(name = "TypeId", type = int.class), @TargetAttributeType(name = "TypeId", type = int.class),
@ -58,11 +63,16 @@ public class DbgModelTargetSymbolImpl extends DbgModelTargetObjectImpl
this.value = symbols.getModel().getAddressSpace("ram").getAddress(symbol.getAddress()); this.value = symbols.getModel().getAddressSpace("ram").getAddress(symbol.getAddress());
this.size = symbol.getSize(); this.size = symbol.getSize();
TargetObject module = symbols.getParent();
String moduleName =
(String) module.getCachedAttribute(TargetObject.SHORT_DISPLAY_ATTRIBUTE_NAME);
changeAttributes(List.of(), List.of(), Map.of( // changeAttributes(List.of(), List.of(), Map.of( //
// TODO: DATA_TYPE // TODO: DATA_TYPE
NAMESPACE_ATTRIBUTE_NAME, symbols, // NAMESPACE_ATTRIBUTE_NAME, symbols, //
VALUE_ATTRIBUTE_NAME, value, // VALUE_ATTRIBUTE_NAME, value, //
SIZE_ATTRIBUTE_NAME, size, // SIZE_ATTRIBUTE_NAME, size, //
TargetBreakpointSpec.AS_BPT_ATTRIBUTE_NAME, //
moduleName + "!" + symbol.getName(), //
"Name", symbol.getName(), // "Name", symbol.getName(), //
"Size", size, // "Size", size, //
"TypeId", symbol.getTypeId(), // "TypeId", symbol.getTypeId(), //

View file

@ -20,8 +20,7 @@ import java.util.Map;
import agent.gdb.manager.impl.GdbMinimalSymbol; import agent.gdb.manager.impl.GdbMinimalSymbol;
import ghidra.dbg.agent.DefaultTargetObject; import ghidra.dbg.agent.DefaultTargetObject;
import ghidra.dbg.target.TargetObject; import ghidra.dbg.target.*;
import ghidra.dbg.target.TargetSymbol;
import ghidra.dbg.target.schema.*; import ghidra.dbg.target.schema.*;
import ghidra.dbg.util.PathUtils; import ghidra.dbg.util.PathUtils;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
@ -31,6 +30,7 @@ import ghidra.program.model.address.Address;
elements = { elements = {
@TargetElementType(type = Void.class) }, @TargetElementType(type = Void.class) },
attributes = { attributes = {
@TargetAttributeType(name = TargetBreakpointSpec.AS_BPT_ATTRIBUTE_NAME, type = String.class),
@TargetAttributeType(type = Void.class) }) @TargetAttributeType(type = Void.class) })
public class GdbModelTargetSymbol extends public class GdbModelTargetSymbol extends
DefaultTargetObject<TargetObject, GdbModelTargetSymbolContainer> implements TargetSymbol { DefaultTargetObject<TargetObject, GdbModelTargetSymbolContainer> implements TargetSymbol {
@ -58,7 +58,8 @@ public class GdbModelTargetSymbol extends
// TODO: DATA_TYPE // TODO: DATA_TYPE
VALUE_ATTRIBUTE_NAME, value, VALUE_ATTRIBUTE_NAME, value,
SIZE_ATTRIBUTE_NAME, size, SIZE_ATTRIBUTE_NAME, size,
DISPLAY_ATTRIBUTE_NAME, symbol.getName()), DISPLAY_ATTRIBUTE_NAME, symbol.getName(),
TargetBreakpointSpec.AS_BPT_ATTRIBUTE_NAME, symbol.getName()),
"Initialized"); "Initialized");
} }

View file

@ -21,11 +21,8 @@ import java.util.Map;
import SWIG.*; import SWIG.*;
import agent.lldb.model.iface2.LldbModelTargetSession; import agent.lldb.model.iface2.LldbModelTargetSession;
import agent.lldb.model.iface2.LldbModelTargetSymbol; import agent.lldb.model.iface2.LldbModelTargetSymbol;
import ghidra.dbg.target.TargetObject; import ghidra.dbg.target.*;
import ghidra.dbg.target.TargetSymbol; import ghidra.dbg.target.schema.*;
import ghidra.dbg.target.schema.TargetAttributeType;
import ghidra.dbg.target.schema.TargetElementType;
import ghidra.dbg.target.schema.TargetObjectSchemaInfo;
import ghidra.dbg.util.PathUtils; import ghidra.dbg.util.PathUtils;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
@ -39,6 +36,7 @@ import ghidra.program.model.address.Address;
type = LldbModelTargetSymbolContainerImpl.class), type = LldbModelTargetSymbolContainerImpl.class),
@TargetAttributeType(name = TargetObject.VALUE_ATTRIBUTE_NAME, type = Address.class), @TargetAttributeType(name = TargetObject.VALUE_ATTRIBUTE_NAME, type = Address.class),
@TargetAttributeType(name = TargetSymbol.SIZE_ATTRIBUTE_NAME, type = long.class), @TargetAttributeType(name = TargetSymbol.SIZE_ATTRIBUTE_NAME, type = long.class),
@TargetAttributeType(name = TargetBreakpointSpec.AS_BPT_ATTRIBUTE_NAME, type = String.class),
@TargetAttributeType(name = "Name", type = String.class), @TargetAttributeType(name = "Name", type = String.class),
@TargetAttributeType(name = "Size", type = long.class), @TargetAttributeType(name = "Size", type = long.class),
@TargetAttributeType(name = "TypeId", type = int.class), @TargetAttributeType(name = "TypeId", type = int.class),
@ -76,7 +74,8 @@ public class LldbModelTargetSymbolImpl extends LldbModelTargetObjectImpl
DISPLAY_ATTRIBUTE_NAME, getDescription(0), // DISPLAY_ATTRIBUTE_NAME, getDescription(0), //
NAMESPACE_ATTRIBUTE_NAME, symbols, // NAMESPACE_ATTRIBUTE_NAME, symbols, //
VALUE_ATTRIBUTE_NAME, value, // VALUE_ATTRIBUTE_NAME, value, //
SIZE_ATTRIBUTE_NAME, size // SIZE_ATTRIBUTE_NAME, size, //
TargetBreakpointSpec.AS_BPT_ATTRIBUTE_NAME, getDescription(0) //
/* /*
"Name", symbol.getName(), // "Name", symbol.getName(), //
"Size", size, // "Size", size, //

View file

@ -1655,6 +1655,7 @@ public class DebuggerObjectsProvider extends ComponentProviderAdapter
} }
public void performSetBreakpoint(ActionContext context) { public void performSetBreakpoint(ActionContext context) {
setText(context);
performAction(context, false, TargetBreakpointSpecContainer.class, container -> { performAction(context, false, TargetBreakpointSpecContainer.class, container -> {
breakpointDialog.setContainer(container); breakpointDialog.setContainer(container);
tool.showDialog(breakpointDialog); tool.showDialog(breakpointDialog);
@ -1662,6 +1663,21 @@ public class DebuggerObjectsProvider extends ComponentProviderAdapter
}, "Couldn't set breakpoint"); }, "Couldn't set breakpoint");
} }
private void setText(ActionContext context) {
breakpointDialog.setText("");
TargetObject obj = getObjectFromContext(context);
Object key = obj.getCachedAttribute(TargetBreakpointSpec.AS_BPT_ATTRIBUTE_NAME);
if (key != null) {
breakpointDialog.setText(key.toString());
}
else {
if (obj instanceof DummyTargetObject) {
DummyTargetObject dto = (DummyTargetObject) obj;
breakpointDialog.setText(dto.getValue().toString());
}
}
}
public void performToggle(ActionContext context) { public void performToggle(ActionContext context) {
performAction(context, false, TargetTogglable.class, t -> { performAction(context, false, TargetTogglable.class, t -> {
return t.toggle(!t.isEnabled()); return t.toggle(!t.isEnabled());

View file

@ -26,8 +26,8 @@ import javax.swing.*;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import ghidra.app.plugin.core.debug.gui.DebuggerResources.AbstractSetBreakpointAction; import ghidra.app.plugin.core.debug.gui.DebuggerResources.AbstractSetBreakpointAction;
import ghidra.app.plugin.core.debug.gui.objects.DebuggerObjectsProvider; import ghidra.app.plugin.core.debug.gui.objects.DebuggerObjectsProvider;
import ghidra.dbg.target.TargetBreakpointSpecContainer;
import ghidra.dbg.target.TargetBreakpointSpec.TargetBreakpointKind; import ghidra.dbg.target.TargetBreakpointSpec.TargetBreakpointKind;
import ghidra.dbg.target.TargetBreakpointSpecContainer;
import ghidra.util.MessageType; import ghidra.util.MessageType;
import ghidra.util.Msg; import ghidra.util.Msg;
import ghidra.util.layout.PairLayout; import ghidra.util.layout.PairLayout;
@ -91,4 +91,8 @@ public class DebuggerBreakpointDialog extends DialogComponentProvider {
this.container = container; this.container = container;
} }
public void setText(String text) {
expressionField.setText(text);
}
} }

View file

@ -181,8 +181,8 @@ public class DummyTargetObject implements TargetObject {
@Override @Override
public CompletableFuture<? extends Map<String, ?>> fetchAttributes() { public CompletableFuture<? extends Map<String, ?>> fetchAttributes() {
if (!key.equals(TargetObject.DISPLAY_ATTRIBUTE_NAME)) { if (!key.equals(TargetObject.DISPLAY_ATTRIBUTE_NAME)) {
if (value != null) { if (getValue() != null) {
String display = getName() + " : " + value; String display = getName() + " : " + getValue();
addAttribute(TargetObject.DISPLAY_ATTRIBUTE_NAME, display); addAttribute(TargetObject.DISPLAY_ATTRIBUTE_NAME, display);
} }
if (kind != null && !kind.equals("")) { if (kind != null && !kind.equals("")) {
@ -191,8 +191,8 @@ public class DummyTargetObject implements TargetObject {
else { else {
addAttribute(TargetObject.KIND_ATTRIBUTE_NAME, "OBJECT_INTRINSIC"); addAttribute(TargetObject.KIND_ATTRIBUTE_NAME, "OBJECT_INTRINSIC");
} }
if (value != null) { if (getValue() != null) {
addAttribute(TargetObject.VALUE_ATTRIBUTE_NAME, value); addAttribute(TargetObject.VALUE_ATTRIBUTE_NAME, getValue());
} }
if (type != null) { if (type != null) {
addAttribute(TargetObject.TYPE_ATTRIBUTE_NAME, type); addAttribute(TargetObject.TYPE_ATTRIBUTE_NAME, type);
@ -234,4 +234,8 @@ public class DummyTargetObject implements TargetObject {
public String toString() { public String toString() {
return getName(); return getName();
} }
public Object getValue() {
return value;
}
} }

View file

@ -69,6 +69,7 @@ public interface TargetBreakpointSpec extends TargetObject, /*@Transitional*/ Ta
String CONTAINER_ATTRIBUTE_NAME = PREFIX_INVISIBLE + "container"; String CONTAINER_ATTRIBUTE_NAME = PREFIX_INVISIBLE + "container";
String EXPRESSION_ATTRIBUTE_NAME = PREFIX_INVISIBLE + "expression"; String EXPRESSION_ATTRIBUTE_NAME = PREFIX_INVISIBLE + "expression";
String KINDS_ATTRIBUTE_NAME = PREFIX_INVISIBLE + "kinds"; String KINDS_ATTRIBUTE_NAME = PREFIX_INVISIBLE + "kinds";
String AS_BPT_ATTRIBUTE_NAME = PREFIX_INVISIBLE + "bpt";
/** /**
* Get the container of this breakpoint. * Get the container of this breakpoint.