Ghidra is a software reverse engineering (SRE) framework
GP-897: Made toggle breakpoint without disassembly work better.
Dan164cb7d1ba1a
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointMarkerPlugin.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointMarkerPlugin.javaindex f6f50b5ea3..4ba11b3cca 100644--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointMarkerPlugin.java+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointMarkerPlugin.java@@ -173,7 +173,8 @@ public class DebuggerBreakpointMarkerPlugin extends Pluginprotected static long computeDefaultLength(ActionContext context,Collection<TraceBreakpointKind> selected) {- if (selected.contains(TraceBreakpointKind.HW_EXECUTE) ||+ if (selected.isEmpty() ||+ selected.contains(TraceBreakpointKind.HW_EXECUTE) ||selected.contains(TraceBreakpointKind.SW_EXECUTE)) {return 1;}@@ -529,11 +530,13 @@ public class DebuggerBreakpointMarkerPlugin extends Plugin}Set<LogicalBreakpoint> bs = breakpointService.getBreakpointsAt(loc);if (bs == null || bs.isEmpty()) {- Set<TraceBreakpointKind> kinds = getApplicableKindsFromContext(context);- if (kinds.isEmpty()) {- Msg.showError(this, null, NAME, "Cannot determine appropriate breakpoint kind");+ Set<TraceBreakpointKind> supported = getSupportedKindsFromContext(context);+ if (supported.isEmpty()) {+ Msg.showError(this, null, NAME,+ "It seems this target does not support breakpoints.");return;}+ Set<TraceBreakpointKind> kinds = computeDefaultKinds(context, supported);long length = computeDefaultLength(context, kinds);placeBreakpointDialog.prompt(tool, breakpointService, NAME, loc, length, kinds);return;@@ -939,14 +942,13 @@ public class DebuggerBreakpointMarkerPlugin extends Pluginreturn true;}- protected Set<TraceBreakpointKind> getApplicableKindsFromContext(ActionContext context) {+ protected Set<TraceBreakpointKind> getSupportedKindsFromContext(ActionContext context) {Set<TraceRecorder> recorders = getRecordersFromContext(context);if (recorders.isEmpty()) {- return computeDefaultKinds(context, EnumSet.allOf(TraceBreakpointKind.class));+ return EnumSet.allOf(TraceBreakpointKind.class);}return recorders.stream()- .flatMap(rec -> computeDefaultKinds(context,- rec.getSupportedBreakpointKinds()).stream())+ .flatMap(rec -> rec.getSupportedBreakpointKinds().stream()).collect(Collectors.toSet());}@@ -978,7 +980,10 @@ public class DebuggerBreakpointMarkerPlugin extends PluginAddress start = bEnt.getKey();for (Map.Entry<Long, Enablement> eEnt : en.entrySet()) {Address end = start.add(eEnt.getKey() - 1);- marks.get(eEnt.getValue()).add(start, end);+ MarkerSet set = marks.get(eEnt.getValue());+ if (set != null) {+ set.add(start, end);+ }}}}diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerPlaceBreakpointDialog.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerPlaceBreakpointDialog.javaindex 409764e74b..ecfd541b0f 100644--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerPlaceBreakpointDialog.java+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerPlaceBreakpointDialog.java@@ -87,12 +87,11 @@ public class DebuggerPlaceBreakpointDialog extends DialogComponentProvider {addCancelButton();}- @SuppressWarnings("hiding")public void prompt(PluginTool tool, DebuggerLogicalBreakpointService service, String title,ProgramLocation loc, long length, Collection<TraceBreakpointKind> kinds) {this.service = service;this.program = loc.getProgram();- this.address = loc.getAddress();+ this.address = loc.getAddress(); // byte address can be confusing here.this.length = length;this.kinds = Set.copyOf(kinds);diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/breakpoint/DebuggerLogicalBreakpointServicePlugin.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/breakpoint/DebuggerLogicalBreakpointServicePlugin.javaindex 34b49034c1..8469ae9020 100644--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/breakpoint/DebuggerLogicalBreakpointServicePlugin.java+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/breakpoint/DebuggerLogicalBreakpointServicePlugin.java@@ -558,7 +558,7 @@ public class DebuggerLogicalBreakpointServicePlugin extends Pluginif (progLoc != null) {InfoPerProgram progInfo = programInfos.get(progLoc.getProgram());lb = progInfo- .getOrCreateLogicalBreakpointFor(progLoc.getAddress(), breakpoint, c);+ .getOrCreateLogicalBreakpointFor(progLoc.getByteAddress(), breakpoint, c);}else {lb = getOrCreateLogicalBreakpointFor(traceAddr, breakpoint, c);@@ -712,7 +712,7 @@ public class DebuggerLogicalBreakpointServicePlugin extends PluginforgetProgramBreakpoint(bm, r);continue;}- if (!lb.getProgramLocation().getAddress().equals(bm.getAddress())) {+ if (!lb.getProgramLocation().getByteAddress().equals(bm.getAddress())) {forgetProgramBreakpoint(bm, r);continue;}@@ -786,7 +786,7 @@ public class DebuggerLogicalBreakpointServicePlugin extends Pluginif (pLoc != null) {InfoPerProgram info = programInfos.get(pLoc.getProgram());if (info != null) { // Maybe the program was just closed- info.removeLogicalBreakpoint(pLoc.getAddress(), lb);+ info.removeLogicalBreakpoint(pLoc.getByteAddress(), lb);}}for (Trace t : lb.getMappedTraces()) {diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/breakpoint/MappedLogicalBreakpoint.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/breakpoint/MappedLogicalBreakpoint.javaindex 199a6c736a..9f45c67d1e 100644--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/breakpoint/MappedLogicalBreakpoint.java+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/breakpoint/MappedLogicalBreakpoint.java@@ -278,7 +278,7 @@ public class MappedLogicalBreakpoint implements LogicalBreakpointInternal {@Overridepublic Address getAddress() {- return progBreak.getLocation().getAddress();+ return progBreak.getLocation().getByteAddress();}@Overridediff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/DebuggerStaticMappingServicePlugin.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/DebuggerStaticMappingServicePlugin.javaindex e51bc4fc23..937cacbcb1 100644--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/DebuggerStaticMappingServicePlugin.java+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/DebuggerStaticMappingServicePlugin.java@@ -944,7 +944,7 @@ public class DebuggerStaticMappingServicePlugin extends PluginAddress start = from.getAddress();Address end = start.addNoWrap(length - 1);// Also check end in the destination- Address toAddress = to.getAddress();+ Address toAddress = to.getByteAddress();toAddress.addNoWrap(length - 1); // Anticipate possible AddressOverflowAddressRangeImpl range = new AddressRangeImpl(start, end);if (truncateExisting) {@@ -1117,12 +1117,13 @@ public class DebuggerStaticMappingServicePlugin extends PluginTraceProgramView view = (TraceProgramView) loc.getProgram();Trace trace = view.getTrace();TraceLocation tloc = new DefaultTraceLocation(trace, null,- Range.singleton(getNonScratchSnap(view)), loc.getAddress());+ Range.singleton(getNonScratchSnap(view)), loc.getByteAddress());ProgramLocation mapped = getOpenMappedLocation(tloc);if (mapped == null) {return null;}- return ProgramLocationUtils.replaceAddress(loc, mapped.getProgram(), mapped.getAddress());+ return ProgramLocationUtils.replaceAddress(loc, mapped.getProgram(),+ mapped.getByteAddress());}@Override@@ -1131,7 +1132,7 @@ public class DebuggerStaticMappingServicePlugin extends Pluginif (info == null) {return null;}- return info.getOpenMappedTraceLocations(loc.getAddress());+ return info.getOpenMappedTraceLocations(loc.getByteAddress());}@Override@@ -1140,7 +1141,7 @@ public class DebuggerStaticMappingServicePlugin extends Pluginif (info == null) {return null;}- return info.getOpenMappedTraceLocation(trace, loc.getAddress(), snap);+ return info.getOpenMappedTraceLocation(trace, loc.getByteAddress(), snap);}@Overridediff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/services/DebuggerLogicalBreakpointService.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/services/DebuggerLogicalBreakpointService.javaindex 8fba518f7c..c2e8619c14 100644--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/services/DebuggerLogicalBreakpointService.java+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/services/DebuggerLogicalBreakpointService.java@@ -141,9 +141,9 @@ public interface DebuggerLogicalBreakpointService {Program progOrView = loc.getProgram();if (progOrView instanceof TraceProgramView) {TraceProgramView view = (TraceProgramView) progOrView;- return traceFunc.apply(view.getTrace(), loc.getAddress());+ return traceFunc.apply(view.getTrace(), loc.getByteAddress());}- return progFunc.apply(progOrView, loc.getAddress());+ return progFunc.apply(progOrView, loc.getByteAddress());}default Enablement computeEnablement(Collection<LogicalBreakpoint> col) {