Merge remote-tracking branch 'origin/patch'

This commit is contained in:
Ryan Kurtz 2021-10-08 08:41:11 -04:00
commit baf34d607c
2 changed files with 21 additions and 2 deletions

View file

@ -71,13 +71,20 @@ public class GdbModelTargetBreakpointContainer
GdbModelTargetBreakpointSpec spec = getTargetBreakpointSpec(info);
spec.init().thenRun(() -> {
changeElements(List.of(), List.of(spec), "Created");
}).exceptionally(ex -> {
model.reportError(this, "Could not update created breakpoint", ex);
return null;
});
}
@Override
public void breakpointModified(GdbBreakpointInfo newInfo, GdbBreakpointInfo oldInfo,
GdbCause cause) {
getTargetBreakpointSpec(oldInfo).updateInfo(oldInfo, newInfo, "Modified");
GdbModelTargetBreakpointSpec spec = getTargetBreakpointSpec(oldInfo);
spec.updateInfo(oldInfo, newInfo, "Modified").exceptionally(ex -> {
model.reportError(this, "Could not updated modified breakpoint", ex);
return null;
});
}
protected GdbModelTargetBreakpointLocation breakpointHit(long bpId,

View file

@ -29,6 +29,7 @@ import ghidra.dbg.target.TargetObject;
import ghidra.dbg.target.schema.*;
import ghidra.dbg.util.PathUtils;
import ghidra.program.model.address.Address;
import ghidra.util.Msg;
@TargetObjectSchemaInfo(
name = "BreakpointLocation",
@ -39,6 +40,10 @@ import ghidra.program.model.address.Address;
public class GdbModelTargetBreakpointLocation
extends DefaultTargetObject<TargetObject, GdbModelTargetBreakpointSpec>
implements TargetBreakpointLocation {
/** prefix used in GDB's watchpoint specs for static locations */
protected static final String LOC_PREFIX = "-location";
protected static String indexLocation(GdbBreakpointLocation loc) {
return PathUtils.makeIndex(loc.getSub());
}
@ -90,7 +95,8 @@ public class GdbModelTargetBreakpointLocation
*/
protected CompletableFuture<Void> initWpt() {
assert loc.getAddr() == null;
String exp = parent.info.getWhat();
String what = parent.info.getWhat();
String exp = what.startsWith(LOC_PREFIX) ? what.substring(LOC_PREFIX.length()) : what;
int iid = Unique.assertOne(loc.getInferiorIds());
GdbModelTargetInferior inf = impl.session.inferiors.getTargetInferior(iid);
String addrSizeExp = String.format("{(long long)&(%s), (long long)sizeof(%s)}", exp, exp);
@ -109,6 +115,12 @@ public class GdbModelTargetBreakpointLocation
address = impl.space.getAddress(vals.get(0));
length = vals.get(1).intValue();
doChangeAttributes("Initialized");
}).exceptionally(ex -> {
Msg.warn(this, "Could not evaluated breakpoint location and/or size: " + ex);
address = impl.space.getAddress(0);
length = 1;
doChangeAttributes("Defaulted for eval/parse error");
return null;
});
}