mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GP-1585: Change TargetBreakpointLocation to range, not address,length
This commit is contained in:
parent
6a2cd80550
commit
cb16d8dd9e
23 changed files with 1143 additions and 1161 deletions
|
@ -70,7 +70,8 @@ import ghidra.framework.options.annotation.*;
|
|||
import ghidra.framework.plugintool.*;
|
||||
import ghidra.framework.plugintool.annotation.AutoConfigStateField;
|
||||
import ghidra.framework.plugintool.annotation.AutoServiceConsumed;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressRange;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.util.ProgramLocation;
|
||||
import ghidra.program.util.ProgramSelection;
|
||||
|
@ -2097,9 +2098,9 @@ public class DebuggerObjectsProvider extends ComponentProviderAdapter
|
|||
if (listingService == null || listingService == null) {
|
||||
return;
|
||||
}
|
||||
// TODO: Could probably inspect schema for any attribute of type Address[Range], or String
|
||||
if (value == null) {
|
||||
value =
|
||||
object.getCachedAttribute(TargetBreakpointLocation.ADDRESS_ATTRIBUTE_NAME);
|
||||
value = object.getCachedAttribute(TargetObject.PREFIX_INVISIBLE + "address");
|
||||
}
|
||||
if (value == null) {
|
||||
value = object.getCachedAttribute(TargetObject.PREFIX_INVISIBLE + "range");
|
||||
|
@ -2112,19 +2113,16 @@ public class DebuggerObjectsProvider extends ComponentProviderAdapter
|
|||
}
|
||||
|
||||
Address addr = null;
|
||||
if (value instanceof Address) {
|
||||
addr = (Address) value;
|
||||
if (value instanceof Address a) {
|
||||
addr = a;
|
||||
}
|
||||
else if (value instanceof AddressRangeImpl) {
|
||||
AddressRangeImpl range = (AddressRangeImpl) value;
|
||||
else if (value instanceof AddressRange range) {
|
||||
addr = range.getMinAddress();
|
||||
}
|
||||
else if (value instanceof Long) {
|
||||
Long lval = (Long) value;
|
||||
else if (value instanceof Long lval) {
|
||||
addr = object.getModel().getAddress("ram", lval);
|
||||
}
|
||||
else if (value instanceof String) {
|
||||
String sval = (String) value;
|
||||
else if (value instanceof String sval) {
|
||||
addr = stringToAddress(object, addr, sval);
|
||||
}
|
||||
if (addr != null) {
|
||||
|
|
|
@ -23,8 +23,7 @@ import ghidra.app.services.LogicalBreakpoint;
|
|||
import ghidra.app.services.TraceRecorder;
|
||||
import ghidra.dbg.target.*;
|
||||
import ghidra.dbg.target.TargetBreakpointSpec.TargetBreakpointKind;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressSet;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.util.ProgramLocation;
|
||||
import ghidra.trace.model.Trace;
|
||||
|
@ -394,10 +393,11 @@ public interface LogicalBreakpointInternal extends LogicalBreakpoint {
|
|||
Set<TargetBreakpointKind> tKinds = TraceRecorder.traceToTargetBreakpointKinds(kinds);
|
||||
Address targetAddr = computeTargetAddress();
|
||||
for (TargetBreakpointLocation loc : recorder.collectBreakpoints(null)) {
|
||||
if (!targetAddr.equals(loc.getAddress())) {
|
||||
AddressRange range = loc.getRange();
|
||||
if (!targetAddr.equals(range.getMinAddress())) {
|
||||
continue;
|
||||
}
|
||||
if (length != loc.getLength().longValue()) {
|
||||
if (length != range.getLength()) {
|
||||
continue;
|
||||
}
|
||||
TargetBreakpointSpec spec = loc.getSpecification();
|
||||
|
@ -413,10 +413,11 @@ public interface LogicalBreakpointInternal extends LogicalBreakpoint {
|
|||
Set<TargetBreakpointKind> tKinds = TraceRecorder.traceToTargetBreakpointKinds(kinds);
|
||||
Address targetAddr = computeTargetAddress();
|
||||
for (TargetBreakpointLocation loc : recorder.collectBreakpoints(null)) {
|
||||
if (!targetAddr.equals(loc.getAddress())) {
|
||||
AddressRange range = loc.getRange();
|
||||
if (!targetAddr.equals(range.getMinAddress())) {
|
||||
continue;
|
||||
}
|
||||
if (length != loc.getLength().longValue()) {
|
||||
if (length != range.getLength()) {
|
||||
continue;
|
||||
}
|
||||
TargetBreakpointSpec spec = loc.getSpecification();
|
||||
|
|
|
@ -31,18 +31,6 @@ import ghidra.util.exception.DuplicateNameException;
|
|||
|
||||
public class DefaultBreakpointRecorder implements ManagedBreakpointRecorder {
|
||||
|
||||
public static AddressRange range(Address min, Integer length) {
|
||||
if (length == null) {
|
||||
length = 1;
|
||||
}
|
||||
try {
|
||||
return new AddressRangeImpl(min, length);
|
||||
}
|
||||
catch (AddressOverflowException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected static String nameBreakpoint(TargetBreakpointLocation bpt) {
|
||||
if (bpt instanceof TargetBreakpointSpec) {
|
||||
return bpt.getIndex();
|
||||
|
@ -93,8 +81,7 @@ public class DefaultBreakpointRecorder implements ManagedBreakpointRecorder {
|
|||
}
|
||||
String path = PathUtils.toString(loc.getPath());
|
||||
String name = nameBreakpoint(loc);
|
||||
Address traceAddr = recorder.getMemoryMapper().targetToTrace(loc.getAddress());
|
||||
AddressRange traceRange = range(traceAddr, loc.getLength());
|
||||
AddressRange traceRange = recorder.getMemoryMapper().targetToTrace(loc.getRange());
|
||||
try {
|
||||
TargetBreakpointSpec spec = loc.getSpecification();
|
||||
boolean enabled = spec.isEnabled();
|
||||
|
@ -151,11 +138,9 @@ public class DefaultBreakpointRecorder implements ManagedBreakpointRecorder {
|
|||
}, path);
|
||||
}
|
||||
|
||||
protected void doBreakpointLocationChanged(long snap, int length, Address traceAddr,
|
||||
String path) {
|
||||
protected void doBreakpointLocationChanged(long snap, AddressRange traceRng, String path) {
|
||||
for (TraceBreakpoint traceBpt : breakpointManager.getBreakpointsByPath(path)) {
|
||||
AddressRange range = range(traceAddr, length);
|
||||
if (traceBpt.getRange().equals(range)) {
|
||||
if (traceBpt.getRange().equals(traceRng)) {
|
||||
continue; // Nothing to change
|
||||
}
|
||||
// TODO: Verify all other attributes match?
|
||||
|
@ -167,7 +152,7 @@ public class DefaultBreakpointRecorder implements ManagedBreakpointRecorder {
|
|||
traceBpt.setClearedSnap(snap - 1);
|
||||
}
|
||||
TraceBreakpoint newtraceBpt =
|
||||
breakpointManager.placeBreakpoint(path, snap, range,
|
||||
breakpointManager.placeBreakpoint(path, snap, traceRng,
|
||||
traceBpt.getThreads(), traceBpt.getKinds(), traceBpt.isEnabled(snap),
|
||||
traceBpt.getComment());
|
||||
// placeBreakpoint resets the name - maybe pass name in?
|
||||
|
@ -182,11 +167,11 @@ public class DefaultBreakpointRecorder implements ManagedBreakpointRecorder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void breakpointLocationChanged(int length, Address traceAddr, String path)
|
||||
public void breakpointLocationChanged(AddressRange traceRng, String path)
|
||||
throws AssertionError {
|
||||
long snap = recorder.getSnap();
|
||||
recorder.parTx.execute("Breakpoint length changed", () -> {
|
||||
doBreakpointLocationChanged(snap, length, traceAddr, path);
|
||||
doBreakpointLocationChanged(snap, traceRng, path);
|
||||
}, path);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import ghidra.async.AsyncLazyMap;
|
|||
import ghidra.dbg.target.*;
|
||||
import ghidra.dbg.util.PathUtils;
|
||||
import ghidra.dbg.util.PathUtils.PathComparator;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressRange;
|
||||
import ghidra.trace.model.breakpoint.TraceBreakpoint;
|
||||
import ghidra.trace.model.breakpoint.TraceBreakpointKind;
|
||||
import ghidra.trace.model.memory.TraceMemoryRegion;
|
||||
|
@ -496,12 +496,10 @@ public class TraceObjectManager {
|
|||
|
||||
public void attributesChangedBreakpointLocation(TargetObject obj, Map<String, ?> added) {
|
||||
TargetBreakpointLocation loc = (TargetBreakpointLocation) obj;
|
||||
if (added.containsKey(TargetBreakpointLocation.LENGTH_ATTRIBUTE_NAME) ||
|
||||
added.containsKey(TargetBreakpointLocation.ADDRESS_ATTRIBUTE_NAME)) {
|
||||
Address traceAddr = recorder.getMemoryMapper().targetToTrace(loc.getAddress());
|
||||
if (added.containsKey(TargetBreakpointLocation.RANGE_ATTRIBUTE_NAME)) {
|
||||
AddressRange traceRng = recorder.getMemoryMapper().targetToTrace(loc.getRange());
|
||||
String path = loc.getJoinedPath(".");
|
||||
int length = loc.getLengthOrDefault(1);
|
||||
recorder.breakpointRecorder.breakpointLocationChanged(length, traceAddr, path);
|
||||
recorder.breakpointRecorder.breakpointLocationChanged(traceRng, path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import java.util.Collection;
|
|||
import java.util.Set;
|
||||
|
||||
import ghidra.dbg.target.*;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressRange;
|
||||
import ghidra.trace.model.breakpoint.TraceBreakpoint;
|
||||
import ghidra.trace.model.breakpoint.TraceBreakpointKind;
|
||||
import ghidra.trace.model.thread.TraceThread;
|
||||
|
@ -41,11 +41,10 @@ public interface ManagedBreakpointRecorder {
|
|||
/**
|
||||
* The range of a breakpoint location has changed
|
||||
*
|
||||
* @param length the new length
|
||||
* @param traceAddr the address of the location in the trace
|
||||
* @param traceRng the address range of the location in the trace
|
||||
* @param path the dot-separated path of the breakpoint location in the model
|
||||
*/
|
||||
void breakpointLocationChanged(int length, Address traceAddr, String path);
|
||||
void breakpointLocationChanged(AddressRange traceRng, String path);
|
||||
|
||||
/**
|
||||
* A breakpoint specification has changed (typically, toggled)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue