GP-5194: Remove Deprecated 'Legacy mode' for DBTrace.

This commit is contained in:
Dan 2025-06-27 16:00:08 +00:00
parent 8367ac7354
commit 7e7c8a5e86
312 changed files with 5925 additions and 9830 deletions

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -21,16 +21,16 @@ import java.util.function.BiFunction;
import java.util.function.Supplier;
import ghidra.debug.api.breakpoint.LogicalBreakpoint;
import ghidra.debug.api.breakpoint.LogicalBreakpointsChangeListener;
import ghidra.debug.api.breakpoint.LogicalBreakpoint.State;
import ghidra.debug.api.breakpoint.LogicalBreakpointsChangeListener;
import ghidra.framework.plugintool.ServiceInfo;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.Program;
import ghidra.program.util.CodeUnitLocation;
import ghidra.program.util.ProgramLocation;
import ghidra.trace.model.Trace;
import ghidra.trace.model.breakpoint.TraceBreakpoint;
import ghidra.trace.model.breakpoint.TraceBreakpointKind;
import ghidra.trace.model.breakpoint.TraceBreakpointLocation;
import ghidra.trace.model.program.TraceProgramView;
@ServiceInfo(
@ -99,10 +99,10 @@ public interface DebuggerLogicalBreakpointService {
* If the given trace breakpoint is not part of any logical breakpoint, e.g., because the trace
* is not opened in the tool or events are still being processed, then null is returned.
*
* @param bpt the trace breakpoint
* @param loc the trace breakpoint location
* @return the logical breakpoint, or null
*/
LogicalBreakpoint getBreakpoint(TraceBreakpoint bpt);
LogicalBreakpoint getBreakpoint(TraceBreakpointLocation loc);
/**
* Get the collected logical breakpoints (at present) at the given location.
@ -297,10 +297,10 @@ public interface DebuggerLogicalBreakpointService {
*
* <p>
* If the given location refers to a static image, this behaves as in
* {@link #placeBreakpointAt(Program, Address, TraceBreakpointKind)}. If it refers to a trace
* view, this behaves as in {@link #placeBreakpointAt(Trace, Address, TraceBreakpointKind)},
* ignoring the view's current snapshot in favor of the present. The name is only saved for a
* program breakpoint.
* {@link #placeBreakpointAt(Program, Address, long, Collection, String)}. If it refers to a
* trace view, this behaves as in *
* {@link #placeBreakpointAt(Trace, Address, long, Collection, String)}, ignoring the view's
* current snapshot in favor of the present. The name is only saved for a program breakpoint.
*
* @param loc the location
* @param length size of the breakpoint, may be ignored by debugger
@ -348,7 +348,7 @@ public interface DebuggerLogicalBreakpointService {
/**
* Disable a collection of logical breakpoints on target, if applicable
*
* @see #enableAll(Collection)
* @see #enableAll(Collection, Trace)
* @param col the collection
* @param trace a trace, if the command should be limited to the given trace
* @return a future which completes when all associated specifications have been disabled
@ -358,7 +358,7 @@ public interface DebuggerLogicalBreakpointService {
/**
* Delete, if possible, a collection of logical breakpoints on target, if applicable
*
* @see #enableAll(Collection)
* @see #enableAll(Collection, Trace)
* @param col the collection
* @param trace a trace, if the command should be limited to the given trace
* @return a future which completes when all associated specifications have been deleted
@ -371,7 +371,7 @@ public interface DebuggerLogicalBreakpointService {
* @param col the trace breakpoints
* @return a future which completes when the command has been processed
*/
CompletableFuture<Void> enableLocs(Collection<TraceBreakpoint> col);
CompletableFuture<Void> enableLocs(Collection<TraceBreakpointLocation> col);
/**
* Disable the given locations
@ -379,7 +379,7 @@ public interface DebuggerLogicalBreakpointService {
* @param col the trace breakpoints
* @return a future which completes when the command has been processed
*/
CompletableFuture<Void> disableLocs(Collection<TraceBreakpoint> col);
CompletableFuture<Void> disableLocs(Collection<TraceBreakpointLocation> col);
/**
* Delete the given locations
@ -387,7 +387,7 @@ public interface DebuggerLogicalBreakpointService {
* @param col the trace breakpoints
* @return a future which completes when the command has been processed
*/
CompletableFuture<Void> deleteLocs(Collection<TraceBreakpoint> col);
CompletableFuture<Void> deleteLocs(Collection<TraceBreakpointLocation> col);
/**
* Generate an informational message when toggling the breakpoints
@ -397,7 +397,8 @@ public interface DebuggerLogicalBreakpointService {
* is for toggling breakpoints. If the breakpoint set is empty, this should return null, since
* the usual behavior in that case is to prompt to place a new breakpoint.
*
* @see #generateStatusEnable(Collection, Trace))
* @see #generateStatusEnable(Collection, Trace)
* @param bs the set of logical breakpoints
* @param loc a representative location
* @return the status message, or null
*/
@ -407,12 +408,12 @@ public interface DebuggerLogicalBreakpointService {
* Generate an informational message when toggling the breakpoints at the given location
*
* <p>
* This works in the same manner as {@link #generateStatusEnable(Collection, Trace))}, except it
* This works in the same manner as {@link #generateStatusEnable(Collection, Trace)}, except it
* is for toggling breakpoints at a given location. If there are no breakpoints at the location,
* this should return null, since the usual behavior in that case is to prompt to place a new
* breakpoint.
*
* @see #generateStatusEnable(Collection)
* @see #generateStatusEnable(Collection, Trace)
* @param loc the location
* @return the status message, or null
*/

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -18,11 +18,11 @@ package ghidra.debug.api.action;
import ghidra.debug.api.tracemgr.DebuggerCoordinates;
import ghidra.framework.plugintool.ServiceProvider;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSpace;
import ghidra.program.util.ProgramLocation;
import ghidra.trace.model.TraceAddressSnapRange;
import ghidra.trace.model.guest.TracePlatform;
import ghidra.trace.model.stack.TraceStack;
import ghidra.trace.util.TraceAddressSpace;
/**
* The actual tracking logic for a location tracking spec
@ -73,8 +73,8 @@ public interface LocationTracker {
* @param coordinates the provider's current coordinates
* @return true if re-computation and "goto" is warranted
*/
boolean affectedByBytesChange(TraceAddressSpace space,
TraceAddressSnapRange range, DebuggerCoordinates coordinates);
boolean affectedByBytesChange(AddressSpace space, TraceAddressSnapRange range,
DebuggerCoordinates coordinates);
/**
* Check if the address should be recomputed given the indicated stack change

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -20,9 +20,8 @@ import javax.swing.Icon;
import ghidra.debug.api.tracemgr.DebuggerCoordinates;
import ghidra.framework.options.SaveState;
import ghidra.framework.plugintool.AutoConfigState.ConfigFieldCodec;
import ghidra.program.model.address.AddressSpace;
import ghidra.trace.model.TraceAddressSnapRange;
import ghidra.trace.model.memory.TraceMemorySpace;
import ghidra.trace.util.TraceAddressSpace;
/**
* A specification for automatic navigation of the dynamic listing
@ -67,21 +66,13 @@ public interface LocationTrackingSpec {
* @param current the current coordinates
* @return true if the change affects the tracked address for the given coordinates
*/
static boolean changeIsCurrent(TraceAddressSpace space, TraceAddressSnapRange range,
static boolean changeIsCurrent(AddressSpace space, TraceAddressSnapRange range,
DebuggerCoordinates current) {
if (space == null) {
return false;
}
if (!space.getAddressSpace().isMemorySpace()) {
if (current.getThread() == null) {
return false;
}
TraceMemorySpace memSpace = current.getTrace()
.getMemoryManager()
.getMemoryRegisterSpace(current.getThread(), current.getFrame(), false);
if (memSpace == null || memSpace.getAddressSpace() != space.getAddressSpace()) {
return false;
}
if (!space.isMemorySpace() && !current.isRegisterSpace(space)) {
return false;
}
if (!range.getLifespan().contains(current.getSnap())) {
return false;

View file

@ -28,8 +28,8 @@ import ghidra.program.model.listing.Bookmark;
import ghidra.program.model.listing.Program;
import ghidra.program.util.ProgramLocation;
import ghidra.trace.model.Trace;
import ghidra.trace.model.breakpoint.TraceBreakpoint;
import ghidra.trace.model.breakpoint.TraceBreakpointKind;
import ghidra.trace.model.breakpoint.TraceBreakpointLocation;
import resources.MultiIcon;
/**
@ -471,6 +471,8 @@ public interface LogicalBreakpoint {
*/
INCONSISTENT_MIXED(Mode.MIXED, Consistency.INCONSISTENT, NAME_MARKER_INCON_MIX, ICON_MARKER_INCON_MIX);
public static final List<State> VALUES = List.of(values());
public final Mode mode;
public final Consistency consistency;
public final String display;
@ -658,7 +660,7 @@ public interface LogicalBreakpoint {
* Get the sleigh injection when emulating this breakpoint
*
* @return the sleigh injection
* @see TraceBreakpoint#getEmuSleigh()
* @see TraceBreakpointLocation#getEmuSleigh(long)
*/
String getEmuSleigh();
@ -666,7 +668,7 @@ public interface LogicalBreakpoint {
* Set the sleigh injection when emulating this breakpoint
*
* @param sleigh the sleigh injection
* @see TraceBreakpoint#setEmuSleigh(String)
* @see TraceBreakpointLocation#setEmuSleigh(long,String)
*/
void setEmuSleigh(String sleigh);
@ -699,7 +701,7 @@ public interface LogicalBreakpoint {
*
* @return the set of trace breakpoints
*/
Set<TraceBreakpoint> getTraceBreakpoints();
Set<TraceBreakpointLocation> getTraceBreakpoints();
/**
* Get all trace breakpoints for the given trace which map to this logical breakpoint.
@ -707,15 +709,15 @@ public interface LogicalBreakpoint {
* @param trace the trace
* @return the set of trace breakpoints
*/
Set<TraceBreakpoint> getTraceBreakpoints(Trace trace);
Set<TraceBreakpointLocation> getTraceBreakpoints(Trace trace);
/**
* Get the traces for which this logical breakpoint has an address.
*
* <p>
* Note, this does not necessarily indicate that a {@link TraceBreakpoint} is present for each
* trace, but rather that for each returned trace, the logical breakpoint can be mapped to an
* address in that trace. See {@link #getParticipatingTraces()}.
* Note, this does not necessarily indicate that a {@link TraceBreakpointLocation} is present
* for each trace, but rather that for each returned trace, the logical breakpoint can be mapped
* to an address in that trace. See {@link #getParticipatingTraces()}.
*
* @return a copy of the set of traces
*/
@ -725,8 +727,8 @@ public interface LogicalBreakpoint {
* Get the traces for which this logical breakpoint has a trace breakpoint.
*
* <p>
* Note, unlike {@link #getMappedTraces()}, this does indicate that a {@link TraceBreakpoint} is
* present for each trace.
* Note, unlike {@link #getMappedTraces()}, this does indicate that a
* {@link TraceBreakpointLocation} is present for each trace.
*
* @return the set of traces
*/
@ -779,7 +781,7 @@ public interface LogicalBreakpoint {
* @param loc the location
* @return the state
*/
State computeStateForLocation(TraceBreakpoint loc);
State computeStateForLocation(TraceBreakpointLocation loc);
/**
* Compute the state for all involved traces and program.

View file

@ -17,7 +17,7 @@ package ghidra.debug.api.breakpoint;
import java.util.Collection;
import ghidra.trace.model.breakpoint.TraceBreakpoint;
import ghidra.trace.model.breakpoint.TraceBreakpointLocation;
public interface LogicalBreakpointsChangeListener {
default void breakpointAdded(LogicalBreakpoint added) {
@ -47,12 +47,12 @@ public interface LogicalBreakpointsChangeListener {
}
}
default void locationAdded(TraceBreakpoint added) {
default void locationAdded(TraceBreakpointLocation added) {
}
default void locationUpdated(TraceBreakpoint updated) {
default void locationUpdated(TraceBreakpointLocation updated) {
}
default void locationRemoved(TraceBreakpoint removed) {
default void locationRemoved(TraceBreakpointLocation removed) {
}
}

View file

@ -29,8 +29,7 @@ import ghidra.program.model.lang.Register;
import ghidra.program.model.lang.RegisterValue;
import ghidra.trace.model.Trace;
import ghidra.trace.model.TraceExecutionState;
import ghidra.trace.model.breakpoint.TraceBreakpoint;
import ghidra.trace.model.breakpoint.TraceBreakpointKind;
import ghidra.trace.model.breakpoint.*;
import ghidra.trace.model.guest.TracePlatform;
import ghidra.trace.model.memory.TraceMemoryState;
import ghidra.trace.model.stack.TraceStackFrame;
@ -617,12 +616,12 @@ public interface Target {
* @param breakpoint the breakpoint
* @return true if valid
*/
boolean isBreakpointValid(TraceBreakpoint breakpoint);
boolean isBreakpointValid(TraceBreakpointLocation breakpoint);
/**
* @see #deleteBreakpoint(TraceBreakpoint)
* @see #deleteBreakpoint(TraceBreakpointCommon)
*/
CompletableFuture<Void> deleteBreakpointAsync(TraceBreakpoint breakpoint);
CompletableFuture<Void> deleteBreakpointAsync(TraceBreakpointCommon breakpoint);
/**
* Delete the given breakpoint from the target
@ -633,12 +632,13 @@ public interface Target {
*
* @param breakpoint the breakpoint to delete
*/
void deleteBreakpoint(TraceBreakpoint breakpoint);
void deleteBreakpoint(TraceBreakpointCommon breakpoint);
/**
* @see #toggleBreakpoint(TraceBreakpoint, boolean)
* @see #toggleBreakpoint(TraceBreakpointLocation, boolean)
*/
CompletableFuture<Void> toggleBreakpointAsync(TraceBreakpoint breakpoint, boolean enabled);
CompletableFuture<Void> toggleBreakpointAsync(TraceBreakpointCommon breakpoint,
boolean enabled);
/**
* Toggle the given breakpoint on the target
@ -651,7 +651,7 @@ public interface Target {
* @param breakpoint the breakpoint to toggle
* @param enabled true to enable, false to disable
*/
void toggleBreakpoint(TraceBreakpoint breakpoint, boolean enabled);
void toggleBreakpoint(TraceBreakpointCommon breakpoint, boolean enabled);
/**
* @see #forceTerminate()

View file

@ -27,15 +27,16 @@ import ghidra.framework.model.*;
import ghidra.framework.options.SaveState;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.store.LockException;
import ghidra.program.model.address.AddressSpace;
import ghidra.trace.database.DBTraceContentHandler;
import ghidra.trace.model.Lifespan;
import ghidra.trace.model.Trace;
import ghidra.trace.model.guest.TracePlatform;
import ghidra.trace.model.program.TraceProgramView;
import ghidra.trace.model.stack.*;
import ghidra.trace.model.stack.TraceStack;
import ghidra.trace.model.stack.TraceStackFrame;
import ghidra.trace.model.target.TraceObject;
import ghidra.trace.model.target.path.KeyPath;
import ghidra.trace.model.thread.TraceObjectThread;
import ghidra.trace.model.thread.TraceThread;
import ghidra.trace.model.time.TraceSnapshot;
import ghidra.trace.model.time.schedule.TraceSchedule;
@ -315,36 +316,34 @@ public class DebuggerCoordinates {
return thread(trace.getThreadManager().getThread(thread.getKey()));
}
private static KeyPath resolvePath(TraceThread thread, Integer frameLevel,
TraceSchedule time) {
if (thread instanceof TraceObjectThread tot) {
TraceObject objThread = tot.getObject();
if (frameLevel == null) {
return objThread.getCanonicalPath();
}
TraceStack stack;
long snap = time.getSnap();
try {
stack = thread.getTrace().getStackManager().getStack(thread, snap, false);
}
catch (IllegalStateException e) {
// Schema does not specify a stack
return objThread.getCanonicalPath();
}
if (stack == null) {
return objThread.getCanonicalPath();
}
TraceStackFrame frame = stack.getFrame(snap, frameLevel, false);
if (frame == null) {
return objThread.getCanonicalPath();
}
return ((TraceObjectStackFrame) frame).getObject().getCanonicalPath();
private static KeyPath resolvePath(TraceThread thread, Integer frameLevel, TraceSchedule time) {
if (thread == null) {
return KeyPath.of();
}
return null;
TraceObject objThread = thread.getObject();
if (frameLevel == null) {
return objThread.getCanonicalPath();
}
TraceStack stack;
long snap = time.getSnap();
try {
stack = thread.getTrace().getStackManager().getStack(thread, snap, false);
}
catch (IllegalStateException e) {
// Schema does not specify a stack
return objThread.getCanonicalPath();
}
if (stack == null) {
return objThread.getCanonicalPath();
}
TraceStackFrame frame = stack.getFrame(snap, frameLevel, false);
if (frame == null) {
return objThread.getCanonicalPath();
}
return frame.getObject().getCanonicalPath();
}
private static KeyPath choose(KeyPath curPath,
KeyPath newPath) {
private static KeyPath choose(KeyPath curPath, KeyPath newPath) {
if (curPath == null) {
return newPath;
}
@ -525,9 +524,7 @@ public class DebuggerCoordinates {
if (object == null) {
return null;
}
return object.queryCanonicalAncestorsInterface(TraceObjectThread.class)
.findFirst()
.orElse(null);
return object.queryCanonicalAncestorsInterface(TraceThread.class).findFirst().orElse(null);
}
private static Integer resolveFrame(Trace trace, KeyPath path) {
@ -535,10 +532,9 @@ public class DebuggerCoordinates {
if (object == null) {
return null;
}
TraceObjectStackFrame frame =
object.queryCanonicalAncestorsInterface(TraceObjectStackFrame.class)
.findFirst()
.orElse(null);
TraceStackFrame frame = object.queryCanonicalAncestorsInterface(TraceStackFrame.class)
.findFirst()
.orElse(null);
return frame == null ? null : frame.getLevel();
}
@ -669,6 +665,11 @@ public class DebuggerCoordinates {
return registerContainer = object.findRegisterContainer(getFrame());
}
public boolean isRegisterSpace(AddressSpace space) {
TraceObject container = getRegisterContainer();
return container != null && container.getCanonicalPath().toString().equals(space.getName());
}
public synchronized long getViewSnap() {
if (viewSnap != null) {
return viewSnap;

View file

@ -53,7 +53,6 @@ import ghidra.trace.model.program.TraceProgramView;
import ghidra.trace.model.target.TraceObject;
import ghidra.trace.model.target.TraceObjectValue;
import ghidra.trace.model.target.path.KeyPath;
import ghidra.trace.model.thread.TraceObjectThread;
import ghidra.trace.model.thread.TraceThread;
import ghidra.trace.model.time.schedule.TraceSchedule;
import ghidra.util.MathUtilities;
@ -1452,11 +1451,7 @@ public interface FlatDebuggerAPI {
}
default ActionContext createContext(TraceThread thread) {
if (thread instanceof TraceObjectThread objThread) {
return createContext(objThread.getObject());
}
return new DebuggerSingleObjectPathActionContext(
KeyPath.parse(thread.getPath()));
return createContext(thread.getObject());
}
default ActionContext createContext(Trace trace) {