mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +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
|
@ -16,12 +16,12 @@
|
|||
package agent.dbgeng.model.iface2;
|
||||
|
||||
import ghidra.dbg.target.TargetBreakpointLocation;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressRange;
|
||||
|
||||
public interface DbgModelTargetBreakpointLocation
|
||||
extends DbgModelTargetObject, TargetBreakpointLocation {
|
||||
|
||||
@Override
|
||||
public Address getAddress();
|
||||
public AddressRange getRange();
|
||||
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import agent.dbgeng.model.iface1.DbgModelTargetBptHelper;
|
|||
import ghidra.dbg.target.*;
|
||||
import ghidra.dbg.target.TargetBreakpointSpecContainer.TargetBreakpointKindSet;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.util.Msg;
|
||||
|
||||
public interface DbgModelTargetBreakpointSpec extends //
|
||||
DbgModelTargetObject, //
|
||||
|
@ -99,12 +100,13 @@ public interface DbgModelTargetBreakpointSpec extends //
|
|||
setBreakpointId(idstr);
|
||||
//String uidstr = unique.getCachedAttribute(VALUE_ATTRIBUTE_NAME).toString();
|
||||
String enstr = enabled.getCachedAttribute(VALUE_ATTRIBUTE_NAME).toString();
|
||||
Address address = null;
|
||||
try {
|
||||
Address address = space.getAddress(addstr);
|
||||
map.put(ADDRESS_ATTRIBUTE_NAME, address);
|
||||
address = space.getAddress(addstr);
|
||||
//map.put(ADDRESS_ATTRIBUTE_NAME, address);
|
||||
}
|
||||
catch (AddressFormatException e) {
|
||||
e.printStackTrace();
|
||||
Msg.error(this, "Could not parse breakpoint address", e);
|
||||
}
|
||||
map.put(SPEC_ATTRIBUTE_NAME, this);
|
||||
map.put(EXPRESSION_ATTRIBUTE_NAME, addstr);
|
||||
|
@ -113,7 +115,15 @@ public interface DbgModelTargetBreakpointSpec extends //
|
|||
map.put(ENABLED_ATTRIBUTE_NAME, enstr.equals("-1"));
|
||||
setEnabled(enstr.equals("-1"), "Refreshed");
|
||||
int size = getBreakpointInfo().getSize();
|
||||
map.put(LENGTH_ATTRIBUTE_NAME, size);
|
||||
//map.put(LENGTH_ATTRIBUTE_NAME, size);
|
||||
if (address != null) {
|
||||
try {
|
||||
map.put(RANGE_ATTRIBUTE_NAME, new AddressRangeImpl(address, size));
|
||||
}
|
||||
catch (AddressOverflowException e) {
|
||||
Msg.error(this, "Address overflow in breakpoint range", e);
|
||||
}
|
||||
}
|
||||
|
||||
String oldval = (String) getCachedAttribute(DISPLAY_ATTRIBUTE_NAME);
|
||||
String display = "[" + idstr + "] " + addstr;
|
||||
|
@ -125,9 +135,13 @@ public interface DbgModelTargetBreakpointSpec extends //
|
|||
|
||||
private long orZero(Long l) {
|
||||
if (l == null) {
|
||||
return 0;
|
||||
Msg.warn(this, "Breakpoint had null offset. Defaulting to ram:00000000");
|
||||
}
|
||||
return l;
|
||||
return l == null ? 0 : l;
|
||||
}
|
||||
|
||||
private int orOne(Integer i) {
|
||||
return i == null ? 1 : i;
|
||||
}
|
||||
|
||||
public default Address doGetAddress() {
|
||||
|
@ -135,6 +149,14 @@ public interface DbgModelTargetBreakpointSpec extends //
|
|||
return getModel().getAddress("ram", orZero(info.getOffset()));
|
||||
}
|
||||
|
||||
public default AddressRange doGetRange() {
|
||||
DbgBreakpointInfo info = getBreakpointInfo();
|
||||
AddressSpace ram = getModel().getAddressSpace("ram");
|
||||
Address min = ram.getAddress(orZero(info.getOffset()));
|
||||
Address max = min.add(orOne(info.getSize()) - 1);
|
||||
return new AddressRangeImpl(min, max);
|
||||
}
|
||||
|
||||
public default void updateInfo(DbgBreakpointInfo oldInfo, DbgBreakpointInfo newInfo,
|
||||
String reason) {
|
||||
synchronized (this) {
|
||||
|
@ -147,6 +169,7 @@ public interface DbgModelTargetBreakpointSpec extends //
|
|||
/**
|
||||
* Update the enabled field
|
||||
*
|
||||
* <p>
|
||||
* This does not actually toggle the breakpoint. It just updates the field and calls the proper
|
||||
* listeners. To actually toggle the breakpoint, use {@link #toggle(boolean)} instead, which if
|
||||
* effective, should eventually cause this method to be called.
|
||||
|
|
|
@ -67,20 +67,18 @@ public class DbgModelTargetBreakpointSpecImpl extends DbgModelTargetObjectImpl
|
|||
protected boolean enabled;
|
||||
|
||||
public void changeAttributeSet(String reason) {
|
||||
this.changeAttributes(List.of(), List.of(), Map.of( //
|
||||
DISPLAY_ATTRIBUTE_NAME, "[" + info.getNumber() + "] " + info.getExpression(), //
|
||||
ADDRESS_ATTRIBUTE_NAME, doGetAddress(), //
|
||||
LENGTH_ATTRIBUTE_NAME, info.getSize(), //
|
||||
SPEC_ATTRIBUTE_NAME, this, //
|
||||
EXPRESSION_ATTRIBUTE_NAME, info.getExpression(), //
|
||||
KINDS_ATTRIBUTE_NAME, getKinds() //
|
||||
), reason);
|
||||
this.changeAttributes(List.of(), List.of(), Map.of( //
|
||||
BPT_TYPE_ATTRIBUTE_NAME, info.getType().name(), //
|
||||
BPT_DISP_ATTRIBUTE_NAME, info.getDisp().name(), //
|
||||
BPT_PENDING_ATTRIBUTE_NAME, info.getPending(), //
|
||||
BPT_TIMES_ATTRIBUTE_NAME, info.getTimes() //
|
||||
), reason);
|
||||
this.changeAttributes(List.of(), List.of(), Map.of(
|
||||
DISPLAY_ATTRIBUTE_NAME, "[" + info.getNumber() + "] " + info.getExpression(),
|
||||
RANGE_ATTRIBUTE_NAME, doGetRange(),
|
||||
SPEC_ATTRIBUTE_NAME, this,
|
||||
EXPRESSION_ATTRIBUTE_NAME, info.getExpression(),
|
||||
KINDS_ATTRIBUTE_NAME, getKinds(),
|
||||
|
||||
BPT_TYPE_ATTRIBUTE_NAME, info.getType().name(),
|
||||
BPT_DISP_ATTRIBUTE_NAME, info.getDisp().name(),
|
||||
BPT_PENDING_ATTRIBUTE_NAME, info.getPending(),
|
||||
BPT_TIMES_ATTRIBUTE_NAME, info.getTimes()),
|
||||
reason);
|
||||
}
|
||||
|
||||
private final ListenerSet<TargetBreakpointAction> actions =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue