Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-3857: Port most Debugger components to TraceRmi.

Danfd4380c07a59
diff --git a/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/local-gdb.sh b/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/local-gdb.sh
index a4fe7b665b..e27b0210ff 100755
--- a/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/local-gdb.sh
+++ b/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/local-gdb.sh
@@ -46,7 +46,10 @@ shift
target_args="$@"
"$OPT_GDB_PATH" \
+ -q \
-ex "set pagination off" \
+ -ex "set confirm off" \
+ -ex "show version" \
-ex "python import ghidragdb" \
-ex "file \"$target_image\"" \
-ex "set args $target_args" \
@@ -55,4 +58,5 @@ target_args="$@"
-ex "ghidra trace start" \
-ex "ghidra trace sync-enable" \
-ex "$OPT_START_CMD" \
+ -ex "set confirm on" \
-ex "set pagination on"
diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/arch.py b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/arch.py
index 473639b076..afceea5fee 100644
--- a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/arch.py
+++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/arch.py
@@ -239,11 +239,18 @@ class DefaultRegisterMapper(object):
.format(name, value, value.type))
return RegVal(self.map_name(inf, name), av)
+ def convert_value_back(self, value, size=None):
+ if size is not None:
+ value = value[-size:].rjust(size, b'\0')
+ if self.byte_order == 'little':
+ value = bytes(reversed(value))
+ return value
+
def map_name_back(self, inf, name):
return name
def map_value_back(self, inf, name, value):
- return RegVal(self.map_name_back(inf, name), value)
+ return RegVal(self.map_name_back(inf, name), self.convert_value_back(value))
class Intel_x86_64_RegisterMapper(DefaultRegisterMapper):
@@ -268,6 +275,7 @@ class Intel_x86_64_RegisterMapper(DefaultRegisterMapper):
def map_name_back(self, inf, name):
if name == 'rflags':
return 'eflags'
+ return name
DEFAULT_BE_REGISTER_MAPPER = DefaultRegisterMapper('big')
diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/commands.py b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/commands.py
index 3eca459ef1..d809d9e844 100644
--- a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/commands.py
+++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/commands.py
@@ -50,6 +50,8 @@ STACK_PATTERN = THREAD_PATTERN + '.Stack'
FRAME_KEY_PATTERN = '[{level}]'
FRAME_PATTERN = STACK_PATTERN + FRAME_KEY_PATTERN
REGS_PATTERN = FRAME_PATTERN + '.Registers'
+REG_KEY_PATTERN = '[{regname}]'
+REG_PATTERN = REGS_PATTERN + REG_KEY_PATTERN
MEMORY_PATTERN = INFERIOR_PATTERN + '.Memory'
REGION_KEY_PATTERN = '[{start:08x}]'
REGION_PATTERN = MEMORY_PATTERN + REGION_KEY_PATTERN
@@ -564,15 +566,26 @@ def putreg(frame, reg_descs):
space = REGS_PATTERN.format(infnum=inf.num, tnum=gdb.selected_thread().num,
level=frame.level())
STATE.trace.create_overlay_space('register', space)
- robj = STATE.trace.create_object(space)
- robj.insert()
+ cobj = STATE.trace.create_object(space)
+ cobj.insert()
mapper = STATE.trace.register_mapper
+ keys = []
values = []
for desc in reg_descs:
v = frame.read_register(desc)
- values.append(mapper.map_value(inf, desc.name, v))
+ rv = mapper.map_value(inf, desc.name, v)
+ values.append(rv)
+ # TODO: Key by gdb's name or mapped name? I think gdb's.
+ rpath = REG_PATTERN.format(infnum=inf.num, tnum=gdb.selected_thread(
+ ).num, level=frame.level(), regname=desc.name)
+ keys.append(REG_KEY_PATTERN.format(regname=desc.name))
+ robj = STATE.trace.create_object(rpath)
+ robj.set_value('_value', rv.value)
+ robj.insert()
+ cobj.retain_values(keys)
# TODO: Memorize registers that failed for this arch, and omit later.
- return {'missing': STATE.trace.put_registers(space, values)}
+ missing = STATE.trace.put_registers(space, values)
+ return {'missing': missing}
@cmd('ghidra trace putreg', '-ghidra-trace-putreg', gdb.COMMAND_DATA, True)
@@ -585,7 +598,8 @@ def ghidra_trace_putreg(group='all', *, is_mi, **kwargs):
STATE.require_tx()
frame = gdb.selected_frame()
- return putreg(frame, frame.architecture().registers(group))
+ with STATE.client.batch() as b:
+ return putreg(frame, frame.architecture().registers(group))
@cmd('ghidra trace delreg', '-ghidra-trace-delreg', gdb.COMMAND_DATA, True)
@@ -977,6 +991,17 @@ def compute_inf_state(inf):
return 'STOPPED'
+def put_inferior_state(inf):
+ ipath = INFERIOR_PATTERN.format(infnum=inf.num)
+ infobj = STATE.trace.proxy_object_path(ipath)
+ istate = compute_inf_state(inf)
+ infobj.set_value('_state', istate)
+ for t in inf.threads():
+ tpath = THREAD_PATTERN.format(infnum=inf.num, tnum=t.num)
+ tobj = STATE.trace.proxy_object_path(tpath)
+ tobj.set_value('_state', convert_state(t))
+
+
def put_inferiors():
# TODO: Attributes like _exit_code, _state?
# _state would be derived from threads
@@ -1034,6 +1059,7 @@ def put_single_breakpoint(b, ibobj, inf, ikeys):
mapper = STATE.trace.memory_mapper
bpath = BREAKPOINT_PATTERN.format(breaknum=b.number)
brkobj = STATE.trace.create_object(bpath)
+ brkobj.set_value('_enabled', b.enabled)
if b.type == gdb.BP_BREAKPOINT:
brkobj.set_value('_expression', b.location)
brkobj.set_value('_kinds', 'SW_EXECUTE')
@@ -1073,6 +1099,7 @@ def put_single_breakpoint(b, ibobj, inf, ikeys):
if inf.num not in l.thread_groups:
continue
locobj = STATE.trace.create_object(bpath + k)
+ locobj.set_value('_enabled', l.enabled)
ik = INF_BREAK_KEY_PATTERN.format(breaknum=b.number, locnum=i+1)
ikeys.append(ik)
if b.location is not None: # Implies execution break
diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/hooks.py b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/hooks.py
index 4ae8a135d9..dc1654a7de 100644
--- a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/hooks.py
+++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/hooks.py
@@ -31,12 +31,13 @@ GhidraHookPrefix()
class HookState(object):
- __slots__ = ('installed', 'mem_catchpoint', 'batch')
+ __slots__ = ('installed', 'mem_catchpoint', 'batch', 'skip_continue')
def __init__(self):
self.installed = False
self.mem_catchpoint = None
self.batch = None
+ self.skip_continue = False
def ensure_batch(self):
if self.batch is None:
@@ -48,6 +49,11 @@ class HookState(object):
commands.STATE.client.end_batch()
self.batch = None
+ def check_skip_continue(self):
+ skip = self.skip_continue
+ self.skip_continue = False
+ return skip
+
class InferiorState(object):
__slots__ = ('first', 'regions', 'modules', 'threads', 'breaks', 'visited')
@@ -70,6 +76,8 @@ class InferiorState(object):
if first:
commands.put_inferiors()
commands.put_environment()
+ else:
+ commands.put_inferior_state(gdb.selected_inferior())
if self.threads:
commands.put_threads()
self.threads = False
@@ -81,7 +89,8 @@ class InferiorState(object):
frame = gdb.selected_frame()
hashable_frame = (thread, frame.level())
if first or hashable_frame not in self.visited:
- commands.putreg(frame, frame.architecture().registers())
+ commands.putreg(
+ frame, frame.architecture().registers('general'))
commands.putmem("$pc", "1", from_tty=False)
commands.putmem("$sp", "1", from_tty=False)
self.visited.add(hashable_frame)
@@ -224,7 +233,6 @@ def on_memory_changed(event):
def on_register_changed(event):
- gdb.write("Register changed: {}".format(dir(event)))
inf = gdb.selected_inferior()
if inf.num not in INF_STATES:
return
@@ -240,6 +248,8 @@ def on_register_changed(event):
def on_cont(event):
+ if (HOOK_STATE.check_skip_continue()):
+ return
inf = gdb.selected_inferior()
if inf.num not in INF_STATES:
return
@@ -254,6 +264,7 @@ def on_cont(event):
def on_stop(event):
if hasattr(event, 'breakpoints') and HOOK_STATE.mem_catchpoint in event.breakpoints:
+ HOOK_STATE.skip_continue = True
return
inf = gdb.selected_inferior()
if inf.num not in INF_STATES:
@@ -337,6 +348,8 @@ def on_breakpoint_created(b):
def on_breakpoint_modified(b):
+ if b == HOOK_STATE.mem_catchpoint:
+ return
inf = gdb.selected_inferior()
notify_others_breaks(inf)
if inf.num not in INF_STATES:
@@ -438,6 +451,16 @@ def hook_frame():
on_frame_selected()
+@cmd_hook('hookpost-up')
+def hook_frame_up():
+ on_frame_selected()
+
+
+@cmd_hook('hookpost-down')
+def hook_frame_down():
+ on_frame_selected()
+
+
# TODO: Checks and workarounds for events missing in gdb 8
def install_hooks():
if HOOK_STATE.installed:
@@ -451,6 +474,8 @@ def install_hooks():
gdb.events.new_thread.connect(on_new_thread)
hook_thread.hook()
hook_frame.hook()
+ hook_frame_up.hook()
+ hook_frame_down.hook()
# Respond to user-driven state changes: (Not target-driven)
gdb.events.memory_changed.connect(on_memory_changed)
@@ -508,6 +533,8 @@ def remove_hooks():
gdb.events.new_thread.disconnect(on_new_thread)
hook_thread.unhook()
hook_frame.unhook()
+ hook_frame_up.unhook()
+ hook_frame_down.unhook()
gdb.events.memory_changed.disconnect(on_memory_changed)
gdb.events.register_changed.disconnect(on_register_changed)
diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/methods.py b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/methods.py
index 3779016263..9a38dd3f2e 100644
--- a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/methods.py
+++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/methods.py
@@ -14,6 +14,7 @@
# limitations under the License.
##
from concurrent.futures import Future, Executor
+from contextlib import contextmanager
import re
from ghidratrace import sch
@@ -24,13 +25,30 @@ import gdb
from . import commands, hooks, util
+@contextmanager
+def no_pagination():
+ before = gdb.parameter('pagination')
+ gdb.set_parameter('pagination', False)
+ yield
+ gdb.set_parameter('pagination', before)
+
+
+@contextmanager
+def no_confirm():
+ before = gdb.parameter('confirm')
+ gdb.set_parameter('confirm', False)
+ yield
+ gdb.set_parameter('confirm', before)
+
+
class GdbExecutor(Executor):
def submit(self, fn, *args, **kwargs):
fut = Future()
def _exec():
try:
- result = fn(*args, **kwargs)
+ with no_pagination():
+ result = fn(*args, **kwargs)
hooks.HOOK_STATE.end_batch()
fut.set_result(result)
except Exception as e:
@@ -186,7 +204,9 @@ def find_frame_by_regs_obj(object):
# Because there's no method to get a register by name....
def find_reg_by_name(f, name):
for reg in f.architecture().registers():
- if reg.name == name:
+ # TODO: gdb appears to be case sensitive, but until we encounter a
+ # situation where case matters, we'll be insensitive
+ if reg.name.lower() == name.lower():
return reg
raise KeyError(f"No such register: {name}")
@@ -453,7 +473,8 @@ def launch_run(inferior: sch.Schema('Inferior'),
def kill(inferior: sch.Schema('Inferior')):
"""Kill execution of the inferior."""
switch_inferior(find_inf_by_obj(inferior))
- gdb.execute('kill')
+ with no_confirm():
+ gdb.execute('kill')
@REGISTRY.method
@@ -463,8 +484,11 @@ def resume(inferior: sch.Schema('Inferior')):
gdb.execute('continue')
+# Technically, inferior is not required, but it hints that the affected object
+# is the current inferior. This in turn queues the UI to enable or disable the
+# button appropriately
@REGISTRY.method
-def interrupt():
+def interrupt(inferior: sch.Schema('Inferior')):
"""Interrupt the execution of the debugged program."""
gdb.execute('interrupt')
@@ -490,7 +514,7 @@ def step_out(thread: sch.Schema('Thread')):
gdb.execute('finish')
[email protected](action='step_ext')
[email protected](action='step_ext', name='Advance')
def step_advance(thread: sch.Schema('Thread'), address: Address):
"""Continue execution up to the given address (advance)."""
t = find_thread_by_obj(thread)
@@ -499,7 +523,7 @@ def step_advance(thread: sch.Schema('Thread'), address: Address):
gdb.execute(f'advance *0x{offset:x}')
[email protected](action='step_ext')
[email protected](action='step_ext', name='Return')
def step_return(thread: sch.Schema('Thread'), value: int=None):
"""Skip the remainder of the current function (return)."""
find_thread_by_obj(thread).switch()
@@ -641,13 +665,13 @@ def write_mem(inferior: sch.Schema('Inferior'), address: Address, data: bytes):
@REGISTRY.method
-def write_reg(frame: sch.Schema('Frame'), name: str, value: bytes):
+def write_reg(frame: sch.Schema('StackFrame'), name: str, value: bytes):
"""Write a register."""
f = find_frame_by_obj(frame)
f.select()
inf = gdb.selected_inferior()
mname, mval = frame.trace.register_mapper.map_value_back(inf, name, value)
reg = find_reg_by_name(f, mname)
- size = int(gdb.parse_and_eval(f'sizeof(${mname})'))
+ size = int(gdb.parse_and_eval(f'sizeof(${reg.name})'))
arr = '{' + ','.join(str(b) for b in mval) + '}'
- gdb.execute(f'set ((unsigned char[{size}])${mname}) = {arr}')
+ gdb.execute(f'set ((unsigned char[{size}])${reg.name}) = {arr}')
diff --git a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/app/services/TraceRmiLauncherService.java b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/app/services/TraceRmiLauncherService.java
index cc2ab03359..8d769d7ad2 100644
--- a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/app/services/TraceRmiLauncherService.java
+++ b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/app/services/TraceRmiLauncherService.java
@@ -18,7 +18,6 @@ package ghidra.app.services;
import java.util.Collection;
import ghidra.debug.api.tracermi.TraceRmiLaunchOffer;
-import ghidra.debug.api.tracermi.TraceRmiLaunchOpinion;
import ghidra.framework.plugintool.ServiceInfo;
import ghidra.program.model.listing.Program;
@@ -29,13 +28,6 @@ import ghidra.program.model.listing.Program;
description = "Manages and presents launchers for Trace RMI Targets",
defaultProviderName = "ghidra.app.plugin.core.debug.gui.tracermi.launcher.TraceRmiLauncherServicePlugin")
public interface TraceRmiLauncherService {
- /**
- * Get all of the installed opinions
- *
- * @return the opinions
- */
- Collection<TraceRmiLaunchOpinion> getOpinions();
-
/**
* Get all offers for the given program
*
diff --git a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/action/LocationTracker.java b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/action/LocationTracker.java
index 28e6267046..49247ebb9d 100644
--- a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/action/LocationTracker.java
+++ b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/action/LocationTracker.java
@@ -87,4 +87,14 @@ public interface LocationTracker {
* @return true if re-computation and "goto" is warranted
*/
boolean affectedByStackChange(TraceStack stack, DebuggerCoordinates coordinates);
+
+ /**
+ * Indicates whether the user should expect instructions at the tracked location.
+ *
+ * <p>
+ * Essentially, is this tracking the program counter?
+ *
+ * @return true to disassemble, false not to
+ */
+ boolean shouldDisassemble();
}
diff --git a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/target/ActionName.java b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/target/ActionName.java
index 93161f2647..9d31777cea 100644
--- a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/target/ActionName.java
+++ b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/target/ActionName.java
@@ -15,6 +15,9 @@
*/
package ghidra.debug.api.target;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* A name for a commonly-recognized target action.
*
@@ -31,15 +34,43 @@ package ghidra.debug.api.target;
* effort to match its methods to these stock actions where applicable, but ultimately, it is up to
* the UI to decide what is presented where.
*/
-public record ActionName(String name) {
- public static final ActionName REFRESH = new ActionName("refresh");
+public record ActionName(String name, boolean builtIn) {
+ private static final Map<String, ActionName> NAMES = new HashMap<>();
+
+ public static ActionName name(String name) {
+ synchronized (NAMES) {
+ return NAMES.computeIfAbsent(name, n -> new ActionName(n, false));
+ }
+ }
+
+ private static ActionName builtIn(String name) {
+ synchronized (NAMES) {
+ ActionName action = new ActionName(name, true);
+ if (NAMES.put(name, action) != null) {
+ throw new AssertionError();
+ }
+ return action;
+ }
+ }
+
+ private static ActionName extended(String name) {
+ synchronized (NAMES) {
+ ActionName action = new ActionName(name, false);
+ if (NAMES.put(name, action) != null) {
+ throw new AssertionError();
+ }
+ return action;
+ }
+ }
+
+ public static final ActionName REFRESH = builtIn("refresh");
/**
* Activate a given object and optionally a time
*
* <p>
* Forms: (focus:Object), (focus:Object, snap:LONG), (focus:Object, time:STR)
*/
- public static final ActionName ACTIVATE = new ActionName("activate");
+ public static final ActionName ACTIVATE = builtIn("activate");
/**
* A weaker form of activate.
*
@@ -48,9 +79,9 @@ public record ActionName(String name) {
* used to communicate selection (i.e., highlight) of the object. Whereas, double-clicking or
* pressing enter would more likely invoke 'activate.'
*/
- public static final ActionName FOCUS = new ActionName("focus");
- public static final ActionName TOGGLE = new ActionName("toggle");
- public static final ActionName DELETE = new ActionName("delete");
+ public static final ActionName FOCUS = builtIn("focus");
+ public static final ActionName TOGGLE = builtIn("toggle");
+ public static final ActionName DELETE = builtIn("delete");
/**
* Execute a CLI command
@@ -58,7 +89,7 @@ public record ActionName(String name) {
* <p>
* Forms: (cmd:STRING):STRING; Optional arguments: capture:BOOL
*/
- public static final ActionName EXECUTE = new ActionName("execute");
+ public static final ActionName EXECUTE = builtIn("execute");
/**
* Connect the back-end to a (usually remote) target
@@ -66,23 +97,23 @@ public record ActionName(String name) {
* <p>
* Forms: (spec:STRING)
*/
- public static final ActionName CONNECT = new ActionName("connect");
+ public static final ActionName CONNECT = extended("connect");
/**
* Forms: (target:Attachable), (pid:INT), (spec:STRING)
*/
- public static final ActionName ATTACH = new ActionName("attach");
- public static final ActionName DETACH = new ActionName("detach");
+ public static final ActionName ATTACH = extended("attach");
+ public static final ActionName DETACH = extended("detach");
/**
* Forms: (command_line:STRING), (file:STRING,args:STRING), (file:STRING,args:STRING_ARRAY),
* (ANY*)
*/
- public static final ActionName LAUNCH = new ActionName("launch");
- public static final ActionName KILL = new ActionName("kill");
+ public static final ActionName LAUNCH = extended("launch");
+ public static final ActionName KILL = builtIn("kill");
- public static final ActionName RESUME = new ActionName("resume");
- public static final ActionName INTERRUPT = new ActionName("interrupt");
+ public static final ActionName RESUME = builtIn("resume");
+ public static final ActionName INTERRUPT = builtIn("interrupt");
/**
* All of these will show in the "step" portion of the control toolbar, if present. The
@@ -93,25 +124,25 @@ public record ActionName(String name) {
* context. (Multiple will appear, but may confuse the user.) You can have as many extended step
* actions as you like. They will be ordered lexicographically by name.
*/
- public static final ActionName STEP_INTO = new ActionName("step_into");
- public static final ActionName STEP_OVER = new ActionName("step_over");
- public static final ActionName STEP_OUT = new ActionName("step_out");
+ public static final ActionName STEP_INTO = builtIn("step_into");
+ public static final ActionName STEP_OVER = builtIn("step_over");
+ public static final ActionName STEP_OUT = builtIn("step_out");
/**
* Skip is not typically available, except in emulators. If the back-end debugger does not have
* a command for this action out-of-the-box, we do not recommend trying to implement it
* yourself. The purpose of these actions just to expose/map each command to the UI, not to
* invent new features for the back-end debugger.
*/
- public static final ActionName STEP_SKIP = new ActionName("step_skip");
+ public static final ActionName STEP_SKIP = builtIn("step_skip");
/**
* Step back is not typically available, except in emulators and timeless (or time-travel)
* debuggers.
*/
- public static final ActionName STEP_BACK = new ActionName("step_back");
+ public static final ActionName STEP_BACK = builtIn("step_back");
/**
* The action for steps that don't fit one of the common stepping actions.
*/
- public static final ActionName STEP_EXT = new ActionName("step_ext");
+ public static final ActionName STEP_EXT = extended("step_ext");
/**
* Forms: (addr:ADDRESS), R/W(rng:RANGE), (expr:STRING)
@@ -123,25 +154,25 @@ public record ActionName(String name) {
* The client may pass either null or "" for condition and/or commands to indicate omissions of
* those arguments.
*/
- public static final ActionName BREAK_SW_EXECUTE = new ActionName("break_sw_execute");
- public static final ActionName BREAK_HW_EXECUTE = new ActionName("break_hw_execute");
- public static final ActionName BREAK_READ = new ActionName("break_read");
- public static final ActionName BREAK_WRITE = new ActionName("break_write");
- public static final ActionName BREAK_ACCESS = new ActionName("break_access");
- public static final ActionName BREAK_EXT = new ActionName("break_ext");
+ public static final ActionName BREAK_SW_EXECUTE = builtIn("break_sw_execute");
+ public static final ActionName BREAK_HW_EXECUTE = builtIn("break_hw_execute");
+ public static final ActionName BREAK_READ = builtIn("break_read");
+ public static final ActionName BREAK_WRITE = builtIn("break_write");
+ public static final ActionName BREAK_ACCESS = builtIn("break_access");
+ public static final ActionName BREAK_EXT = extended("break_ext");
/**
* Forms: (rng:RANGE)
*/
- public static final ActionName READ_MEM = new ActionName("read_mem");
+ public static final ActionName READ_MEM = builtIn("read_mem");
/**
* Forms: (addr:ADDRESS,data:BYTES)
*/
- public static final ActionName WRITE_MEM = new ActionName("write_mem");
+ public static final ActionName WRITE_MEM = builtIn("write_mem");
// NOTE: no read_reg. Use refresh(RegContainer), refresh(RegGroup), refresh(Register)
/**
* Forms: (frame:Frame,name:STRING,value:BYTES), (register:Register,value:BYTES)
*/
- public static final ActionName WRITE_REG = new ActionName("write_reg");
+ public static final ActionName WRITE_REG = builtIn("write_reg");
}
diff --git a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/target/Target.java b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/target/Target.java
index 108f43f64c..96822accca 100644
--- a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/target/Target.java
+++ b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/target/Target.java
@@ -19,14 +19,11 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.*;
import java.util.function.BooleanSupplier;
-import java.util.function.Supplier;
-
-import org.apache.commons.lang3.exception.ExceptionUtils;
+import java.util.function.Function;
import docking.ActionContext;
import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionState;
import ghidra.debug.api.tracemgr.DebuggerCoordinates;
-import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.*;
import ghidra.program.model.lang.Register;
import ghidra.program.model.lang.RegisterValue;
@@ -38,39 +35,81 @@ import ghidra.trace.model.memory.TraceMemoryState;
import ghidra.trace.model.stack.TraceStackFrame;
import ghidra.trace.model.target.TraceObjectKeyPath;
import ghidra.trace.model.thread.TraceThread;
-import ghidra.util.Msg;
import ghidra.util.Swing;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor;
+/**
+ * The interface between the front-end UI and the back-end connector.
+ *
+ * <p>
+ * Anything the UI might command a target to do must be defined as a method here. Each
+ * implementation can then sort out, using context from the UI as appropriate, how best to effect
+ * the command using the protocol and resources available on the back-end.
+ */
public interface Target {
long TIMEOUT_MILLIS = 10000;
+ /**
+ * A description of a UI action provided by this target.
+ *
+ * <p>
+ * In most cases, this will generate a menu entry or a toolbar button, but in some cases, it's
+ * just invoked implicitly. Often, the two suppliers are implemented using lambda functions, and
+ * those functions will keep whatever some means of querying UI and/or target context in their
+ * closures.
+ *
+ * @param display the text to display on UI actions associated with this entry
+ * @param name the name of a common debugger command this action implements
+ * @param details text providing more details, usually displayed in a tool tip
+ * @param requiresPrompt true if invoking the action requires further user interaction
+ * @param enabled a supplier to determine whether an associated action in the UI is enabled.
+ * @param action a function for invoking this action asynchronously
+ */
record ActionEntry(String display, ActionName name, String details, boolean requiresPrompt,
- BooleanSupplier enabled, Supplier<CompletableFuture<?>> action) {
+ BooleanSupplier enabled, Function<Boolean, CompletableFuture<?>> action) {
+ /**
+ * Check if this action is currently enabled
+ *
+ * @return true if enabled
+ */
public boolean isEnabled() {
return enabled.getAsBoolean();
}
+ /**
+ * Invoke the action asynchronously, prompting if desired
+ *
+ * <p>
+ * Note this will impose a timeout of {@value Target#TIMEOUT_MILLIS} milliseconds.
+ *
+ * @param prompt whether or not to prompt the user for arguments
+ * @return the future result, often {@link Void}
+ */
public CompletableFuture<?> invokeAsync(boolean prompt) {
- return action.get().orTimeout(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
- }
-
- public CompletableFuture<?> invokeAsyncLogged(boolean prompt, PluginTool tool) {
- return invokeAsync(prompt).exceptionally(ex -> {
- if (tool != null) {
- tool.setStatusInfo(display + " failed: " + ex, true);
- }
- Msg.error(this, display + " failed: " + ex, ex);
- return ExceptionUtils.rethrow(ex);
- });
+ return action.apply(prompt).orTimeout(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
}
+ /**
+ * Invoke the action synchronously
+ *
+ * <p>
+ * To avoid blocking the Swing thread on a remote socket, this method cannot be called on
+ * the Swing thread.
+ *
+ * @param prompt whether or not to prompt the user for arguments
+ */
public void run(boolean prompt) {
get(prompt);
}
+ /**
+ * Invoke the action synchronously, getting its result
+ *
+ * @param prompt whether or not to prompt the user for arguments
+ * @return the resulting value, if applicable
+ */
public Object get(boolean prompt) {
if (Swing.isSwingThread()) {
throw new AssertionError("Refusing to block the Swing thread. Use a Task.");
@@ -82,30 +121,107 @@ public interface Target {
throw new RuntimeException(e);
}
}
+
+ /**
+ * Check if this action's name is built in
+ *
+ * @return true if built in.
+ */
+ public boolean builtIn() {
+ return name != null && name.builtIn();
+ }
}
+ /**
+ * Check if the target is still valid
+ *
+ * @return true if valid
+ */
boolean isValid();
+ /**
+ * Get the trace into which this target is recorded
+ *
+ * @return the trace
+ */
Trace getTrace();
+ /**
+ * Get the current snapshot key for the target
+ *
+ * <p>
+ * For most targets, this is the most recently created snapshot.
+ *
+ * @return the snapshot
+ */
+ // TODO: Should this be TraceSchedule getTime()?
long getSnap();
+ /**
+ * Collect all actions that implement the given common debugger command
+ *
+ * @param name the action name
+ * @param context applicable context from the UI
+ * @return the collected actions
+ */
Map<String, ActionEntry> collectActions(ActionName name, ActionContext context);
+ /**
+ * Get the trace thread that contains the given object
+ *
+ * @param path the path of the object
+ * @return the thread, or null
+ */
TraceThread getThreadForSuccessor(TraceObjectKeyPath path);
+ /**
+ * Get the execution state of the given thread
+ *
+ * @param thread the thread
+ * @return the state
+ */
TargetExecutionState getThreadExecutionState(TraceThread thread);
+ /**
+ * Get the trace stack frame that contains the given object
+ *
+ * @param path the path of the object
+ * @return the stack frame, or null
+ */
TraceStackFrame getStackFrameForSuccessor(TraceObjectKeyPath path);
+ /**
+ * Check if the target supports synchronizing focus
+ *
+ * @return true if supported
+ */
boolean isSupportsFocus();
+ /**
+ * Get the object that currently has focus on the back end's UI
+ *
+ * @return the focused object's path, or null
+ */
TraceObjectKeyPath getFocus();
+ /**
+ * @see #activate(DebuggerCoordinates, DebuggerCoordinates)
+ */
CompletableFuture<Void> activateAsync(DebuggerCoordinates prev, DebuggerCoordinates coords);
+ /**
+ * Request that the back end's focus be set to the same as the front end's (Ghidra's) GUI.
+ *
+ * @param prev the GUI's immediately previous coordinates
+ * @param coords the GUI's current coordinates
+ */
void activate(DebuggerCoordinates prev, DebuggerCoordinates coords);
+ /**
+ * @see #invalidateMemoryCaches()
+ */
+ CompletableFuture<Void> invalidateMemoryCachesAsync();
+
/**
* Invalidate any caches on the target's back end or on the client side of the connection.
*
@@ -118,11 +234,6 @@ public interface Target {
* <b>NOTE:</b> This method exists for invalidating model-based target caches. It may be
* deprecated and removed, unless it turns out we need this for Trace RMI, too.
*/
- CompletableFuture<Void> invalidateMemoryCachesAsync();
-
- /**
- * See {@link #invalidateMemoryCachesAsync()}
- */
void invalidateMemoryCaches();
/**
@@ -135,11 +246,11 @@ public interface Target {
*
* <p>
* The target may read more than the requested memory, usually because it will read all pages
- * containing any portion of the requested set.
- *
- * <p>
- * This task is relatively error tolerant. If a range cannot be captured -- a common occurrence
- * -- the error is logged without throwing an exception.
+ * containing any portion of the requested set. The target should attempt to read at least the
+ * given memory. To the extent it is successful, it must cause the values to be recorded into
+ * the trace <em>before</em> this method returns. Only if the request is <em>entirely</em>
+ * unsuccessful should this method throw an exception. Otherwise, the failed portions, if any,
+ * should be logged without throwing an exception.
*
* @param set the addresses to capture
* @param monitor a monitor for displaying task steps
@@ -147,30 +258,97 @@ public interface Target {
*/
void readMemory(AddressSetView set, TaskMonitor monitor) throws CancelledException;
+ /**
+ * @see #readMemory(AddressSetView, TaskMonitor)
+ */
CompletableFuture<Void> writeMemoryAsync(Address address, byte[] data);
+ /**
+ * Write data to the target's memory
+ *
+ * <p>
+ * The target should attempt to write the memory. To the extent it is successful, it must cause
+ * the effects to be recorded into the trace <em>before</em> this method returns. Only if the
+ * request is <em>entirely</em> unsuccessful should this method throw an exception. Otherwise,
+ * the failed portions, if any, should be logged without throwing an exception.
+ *
+ * @param address the starting address
+ * @param data the bytes to write
+ */
void writeMemory(Address address, byte[] data);
+ /**
+ * @see #readRegisters(TracePlatform, TraceThread, int, Set)
+ */
CompletableFuture<Void> readRegistersAsync(TracePlatform platform, TraceThread thread,
int frame, Set<Register> registers);
+ /**
+ * Read and capture the named target registers for the given platform, thread, and frame.
+ *
+ * <p>
+ * Target target should read the registers and, to the extent it is successful, cause the values
+ * to be recorded into the trace <em>before</em> this method returns. Only if the request is
+ * <em>entirely</em> unsuccessful should this method throw an exception. Otherwise, the failed
+ * registers, if any, should be logged without throwing an exception.
+ *
+ * @param platform the platform defining the registers
+ * @param thread the thread whose context contains the register values
+ * @param frame the frame, if applicable, for saved register values. 0 for current values.
+ * @param registers the registers to read
+ */
void readRegisters(TracePlatform platform, TraceThread thread, int frame,
Set<Register> registers);
+ /**
+ * @see #readRegistersAsync(TracePlatform, TraceThread, int, AddressSetView)
+ */
CompletableFuture<Void> readRegistersAsync(TracePlatform platform, TraceThread thread,
int frame, AddressSetView guestSet);
+ /**
+ * Read and capture the target registers in the given address set.
+ *
+ * <p>
+ * Aside from how registers are named, this works equivalently to
+ * {@link #readRegisters(TracePlatform, TraceThread, int, Set)}.
+ */
void readRegisters(TracePlatform platform, TraceThread thread, int frame,
AddressSetView guestSet);
+ /**
+ * @see #writeRegister(TracePlatform, TraceThread, int, RegisterValue)
+ */
CompletableFuture<Void> writeRegisterAsync(TracePlatform platform, TraceThread thread,
int frame, RegisterValue value);
+ /**
+ * Write a value to a target register for the given platform, thread, and frame
+ *
+ * <p>
+ * The target should attempt to write the register. If successful, it must cause the effects to
+ * be recorded into the trace <em>before</em> this method returns. If the request is
+ * unsuccessful, this method throw an exception.
+ *
+ * @param address the starting address
+ * @param data the bytes to write
+ */
void writeRegister(TracePlatform platform, TraceThread thread, int frame, RegisterValue value);
+ /**
+ * @see #writeRegister(TracePlatform, TraceThread, int, Address, byte[])
+ */
CompletableFuture<Void> writeRegisterAsync(TracePlatform platform, TraceThread thread,
int frame, Address address, byte[] data);
+ /**
+ * Write a value to a target register by its address
+ *
+ * <p>
+ * Aside from how the register is named, this works equivalently to
+ * {@link #writeRegister(TracePlatform, TraceThread, int, RegisterValue)}. The address is the
+ * one defined by Ghidra.
+ */
void writeRegister(TracePlatform platform, TraceThread thread, int frame, Address address,
byte[] data);
@@ -179,7 +357,7 @@ public interface Target {
*
* @param platform the platform whose language defines the registers
* @param thread if a register, the thread whose registers to examine
- * @param frameLevel the frame, usually 0.
+ * @param frame the frame level, usually 0.
* @param address the address of the variable
* @param size the size of the variable. Ignored for memory
* @return true if the variable can be mapped to the target
@@ -211,11 +389,35 @@ public interface Target {
void writeVariable(TracePlatform platform, TraceThread thread, int frame, Address address,
byte[] data);
+ /**
+ * Get the kinds of breakpoints supported by the target.
+ *
+ * @return the set of kinds
+ */
Set<TraceBreakpointKind> getSupportedBreakpointKinds();
+ /**
+ * @see #placeBreakpoint(AddressRange, Set, String, String)
+ */
CompletableFuture<Void> placeBreakpointAsync(AddressRange range,
Set<TraceBreakpointKind> kinds, String condition, String commands);
+ /**
+ * Place a new breakpoint of the given kind(s) over the given range
+ *
+ * <p>
+ * If successful, this method must cause the breakpoint to be recorded into the trace.
+ * Otherwise, it should throw an exception.
+ *
+ * @param range the range. NOTE: The target is only required to support length-1 execution
+ * breakpoints.
+ * @param kinds the kind(s) of the breakpoint.
+ * @param condition optionally, a condition for the breakpoint, expressed in the back-end's
+ * language. NOTE: May be silently ignored by the implementation, if not supported.
+ * @param commands optionally, a command to execute upon hitting the breakpoint, expressed in
+ * the back-end's language. NOTE: May be silently ignored by the implementation, if
+ * not supported.
+ */
void placeBreakpoint(AddressRange range, Set<TraceBreakpointKind> kinds, String condition,
String commands);
@@ -227,23 +429,57 @@ public interface Target {
*/
boolean isBreakpointValid(TraceBreakpoint breakpoint);
+ /**
+ * @see #deleteBreakpoint(TraceBreakpoint)
+ */
CompletableFuture<Void> deleteBreakpointAsync(TraceBreakpoint breakpoint);
+ /**
+ * Delete the given breakpoint from the target
+ *
+ * <p>
+ * If successful, this method must cause the breakpoint removal to be recorded in the trace.
+ * Otherwise, it should throw an exception.
+ *
+ * @param breakpoint the breakpoint to delete
+ */
void deleteBreakpoint(TraceBreakpoint breakpoint);
+ /**
+ * @see #toggleBreakpoint(TraceBreakpoint, boolean)
+ */
CompletableFuture<Void> toggleBreakpointAsync(TraceBreakpoint breakpoint, boolean enabled);
+ /**
+ * Toggle the given breakpoint on the target
+ *
+ * <p>
+ * If successful, this method must cause the breakpoint toggle to be recorded in the trace. If
+ * the state is already as desired, this method may have no effect. If unsuccessful, this method
+ * should throw an exception.
+ *
+ * @param breakpoint the breakpoint to toggle
+ * @param enabled true to enable, false to disable
+ */
void toggleBreakpoint(TraceBreakpoint breakpoint, boolean enabled);
/**
- * Terminate the target and its connection
+ * @see #forceTerminate()
+ */
+ CompletableFuture<Void> forceTerminateAsync();
+
+ /**
+ * Forcefully terminate the target
*
* <p>
- * <b>WARNING:</b> This terminates the connection, even if there are other live targets still
- * using it. One example where this might happen is if the target process launches a child, and
- * the debugger is configured to remain attached to both. Whether this is expected or acceptable
- * behavior has not been decided.
- *
+ * This will first attempt to kill the target gracefully. In addition, and whether or not the
+ * target is successfully terminated, the target will be dissociated from its trace, and the
+ * target will be invalidated. To attempt only a graceful termination, check
+ * {@link #collectActions(ActionName, ActionContext)} with {@link ActionName#KILL}.
+ */
+ void forceTerminate();
+
+ /**
* @see #disconnect()
*/
CompletableFuture<Void> disconnectAsync();
@@ -252,6 +488,12 @@ public interface Target {
* Terminate the target and its connection
*
* <p>
+ * <b>WARNING:</b> This terminates the connection, even if there are other live targets still
+ * using it. One example where this might happen is if the target process launches a child, and
+ * the debugger is configured to remain attached to both. Whether this is expected or acceptable
+ * behavior has not been decided.
+ *
+ * <p>
* <b>NOTE:</b> This method cannot be invoked on the Swing thread, because it may block on I/O.
*
* @see #disconnectAsync()
diff --git a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/target/TargetPublicationListener.java b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/target/TargetPublicationListener.java
index 6a4a63787d..cfd114e290 100644
--- a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/target/TargetPublicationListener.java
+++ b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/target/TargetPublicationListener.java
@@ -15,8 +15,21 @@
*/
package ghidra.debug.api.target;
+/**
+ * A listener for changes to the set of published targets
+ */
public interface TargetPublicationListener {
+ /**
+ * The given target was published
+ *
+ * @param target the published target
+ */
void targetPublished(Target target);
+ /**
+ * The given target was withdrawn, usually because it's no longer valid
+ *
+ * @param target the withdrawn target
+ */
void targetWithdrawn(Target target);
}
diff --git a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracemgr/DebuggerCoordinates.java b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracemgr/DebuggerCoordinates.java
index bb896cf43d..665ea747dd 100644
--- a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracemgr/DebuggerCoordinates.java
+++ b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracemgr/DebuggerCoordinates.java
@@ -658,13 +658,12 @@ public class DebuggerCoordinates {
projData = new DefaultProjectData(projLoc, false, false);
}
catch (NotOwnerException e) {
- Msg.showError(DebuggerCoordinates.class, tool.getToolFrame(), "Trace Open Failed",
+ Msg.error(DebuggerCoordinates.class,
"Not project owner: " + projLoc + "(" + pathname + ")");
return null;
}
catch (IOException | LockException e) {
- Msg.showError(DebuggerCoordinates.class, tool.getToolFrame(), "Trace Open Failed",
- "Project error: " + e.getMessage());
+ Msg.error(DebuggerCoordinates.class, "Project error: " + e.getMessage());
return null;
}
}
@@ -676,8 +675,7 @@ public class DebuggerCoordinates {
if (version != DomainFile.DEFAULT_VERSION) {
message += " version " + version;
}
- String title = df == null ? "Trace Not Found" : "Wrong File Type";
- Msg.showError(DebuggerCoordinates.class, tool.getToolFrame(), title, message);
+ Msg.error(DebuggerCoordinates.class, message);
return null;
}
return df;
diff --git a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/app/services/DebuggerWorkflowFrontEndService.java b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracermi/TerminalSession.java
similarity index 50%
rename from Ghidra/Debug/Debugger-api/src/main/java/ghidra/app/services/DebuggerWorkflowFrontEndService.java
rename to Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracermi/TerminalSession.java
index 7c82695c0b..c9269758d8 100644
--- a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/app/services/DebuggerWorkflowFrontEndService.java
+++ b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracermi/TerminalSession.java
@@ -13,21 +13,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package ghidra.app.services;
+package ghidra.debug.api.tracermi;
-import java.util.Collection;
+import java.io.IOException;
-import ghidra.framework.plugintool.PluginTool;
-import ghidra.framework.plugintool.ServiceInfo;
+/**
+ * A terminal with some back-end element attached to it
+ */
+public interface TerminalSession extends AutoCloseable {
+ @Override
+ void close() throws IOException;
+
+ /**
+ * Terminate the session without closing the terminal
+ */
+ void terminate() throws IOException;
+
+ /**
+ * Check whether the terminal session is terminated or still active
+ *
+ * @return true for terminated, false for active
+ */
+ boolean isTerminated();
-@ServiceInfo(
- defaultProviderName = "ghidra.app.plugin.core.debug.service.workflow.DebuggerWorkflowServicePlugin",
- description = "Service for managing automatic debugger actions and analysis")
-public interface DebuggerWorkflowFrontEndService extends DebuggerWorkflowService {
/**
- * Get all the tools with the corresponding {@link DebuggerWorkflowToolService}
+ * Provide a human-readable description of the session
*
- * @return the tools proxying this service
+ * @return the description
*/
- Collection<PluginTool> getProxyingPluginTools();
+ String description();
}
diff --git a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracermi/TraceRmiConnection.java b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracermi/TraceRmiConnection.java
index fd0afe7ca0..decddb02b8 100644
--- a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracermi/TraceRmiConnection.java
+++ b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracermi/TraceRmiConnection.java
@@ -17,23 +17,124 @@ package ghidra.debug.api.tracermi;
import java.io.IOException;
import java.net.SocketAddress;
+import java.util.NoSuchElementException;
import java.util.concurrent.TimeoutException;
import ghidra.trace.model.Trace;
+/**
+ * A connection to a TraceRmi back end
+ *
+ * <p>
+ * TraceRmi is a two-way request-reply channel, usually over TCP. The back end, i.e., the trace-rmi
+ * plugin hosted in the target platform's actual debugger, is granted a fixed set of
+ * methods/messages for creating and populating a {@link Trace}. Each such trace is designated as a
+ * target. The back end provides a set of methods for the front-end to use to control the connection
+ * and its targets. For a given connection, the methods are fixed, but each back end may provide a
+ * different set of methods to best describe/model its command set. The same methods are applicable
+ * to all of the back end's target. While uncommon, one back end may create several targets. E.g.,
+ * if a target creates a child process, and the back-end debugger is configured to remain attached
+ * to both parent and child, then it should create and publish a second target.
+ */
public interface TraceRmiConnection extends AutoCloseable {
+ /**
+ * Get the address of the back end debugger
+ *
+ * @return the address, usually IP of the host and port for the trace-rmi plugin.
+ */
SocketAddress getRemoteAddress();
+ /**
+ * Get the methods provided by the back end
+ *
+ * @return the method registry
+ */
RemoteMethodRegistry getMethods();
+ /**
+ * Wait for the first trace created by the back end.
+ *
+ * <p>
+ * Typically, a connection handles only a single target. A shell script handles launching the
+ * back-end debugger, creating its first target, and connecting back to the front end via
+ * TraceRmi. If a secondary target does appear, it usually happens only after the initial target
+ * has run. Thus, this method is useful for waiting on and getting and handle to that initial
+ * target.
+ *
+ * @param timeoutMillis the number of milliseconds to wait for the target
+ * @return the trace
+ * @throws TimeoutException if no trace is created after the given timeout. This usually
+ * indicates there was an error launching the initial target, e.g., the target's
+ * binary was not found on the target's host.
+ */
Trace waitForTrace(long timeoutMillis) throws TimeoutException;
+ /**
+ * Get the last snapshot created by the back end for the given trace.
+ *
+ * <p>
+ * Back ends that support timeless or time-travel debugging have not been integrated yet, but in
+ * those cases, we anticipate this method returning the current snapshot (however the back end
+ * defines that with respect to its own definition of time), whether or not it is the last
+ * snapshot it created. If the back end has not created a snapshot yet, 0 is returned.
+ *
+ * @param trace
+ * @return the snapshot number
+ * @throws NoSuchElementException if the given trace is not a target for this connection
+ */
long getLastSnapshot(Trace trace);
+ /**
+ * Forcefully remove the given trace from the connection.
+ *
+ * <p>
+ * This removes the back end's access to the given trace and removes this connection from the
+ * trace's list of consumers (thus, freeing it if this was the only remaining consumer.) For all
+ * intents and purposes, the given trace is no longer a target for this connection.
+ *
+ * <p>
+ * <b>NOTE:</b> This method should only be used if gracefully killing the target has failed. In
+ * some cases, it may be better to terminate the entire connection (See {@link #close()}) or to
+ * terminate the back end debugger. The back end gets no notification that its trace was
+ * forcefully removed. However, subsequent requests involving that trace will result in errors.
+ *
+ * @param trace the trace to remove
+ */
+ void forceCloseTrace(Trace trace);
+
+ /**
+ * Close the TraceRmi connection.
+ *
+ * <p>
+ * {@inheritDoc}
+ *
+ * <p>
+ * Upon closing, all the connection's targets (there's usually only one) will be withdrawn and
+ * invalidated.
+ */
@Override
void close() throws IOException;
+ /**
+ * Check if the connection has been closed
+ *
+ * @return true if closed, false if still open/valid
+ */
boolean isClosed();
+ /**
+ * Wait for the connection to become closed.
+ *
+ * <p>
+ * This is usually just for clean-up purposes during automated testing.
+ */
void waitClosed();
+
+ /**
+ * Check if the given trace represents one of this connection's targets.
+ *
+ * @param trace the trace
+ * @return true if the trace is a target, false otherwise.
+ */
+ boolean isTarget(Trace trace);
}
diff --git a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracermi/TraceRmiLaunchOffer.java b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracermi/TraceRmiLaunchOffer.java
index 4a510e9963..9ef8efb73a 100644
--- a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracermi/TraceRmiLaunchOffer.java
+++ b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracermi/TraceRmiLaunchOffer.java
@@ -15,7 +15,6 @@
*/
package ghidra.debug.api.tracermi;
-import java.io.IOException;
import java.util.List;
import java.util.Map;
@@ -37,19 +36,6 @@ import ghidra.util.task.TaskMonitor;
*/
public interface TraceRmiLaunchOffer {
- /**
- * A terminal with some back-end element attached to it
- */
- interface TerminalSession extends AutoCloseable {
- @Override
- void close() throws IOException;
-
- /**
- * Terminate the session without closing the terminal
- */
- void terminate() throws IOException;
- }
-
/**
* The result of launching a program
*
diff --git a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/workflow/DebuggerBot.java b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/workflow/DebuggerBot.java
deleted file mode 100644
index b4ee473e6d..0000000000
--- a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/workflow/DebuggerBot.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/* ###
- * IP: GHIDRA
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.debug.api.workflow;
-
-import ghidra.app.services.DebuggerWorkflowFrontEndService;
-import ghidra.framework.options.AutoOptions;
-import ghidra.framework.plugintool.PluginTool;
-import ghidra.lifecycle.Internal;
-import ghidra.program.model.listing.Program;
-import ghidra.trace.model.Trace;
-import ghidra.util.HelpLocation;
-import ghidra.util.Msg;
-import ghidra.util.classfinder.ExtensionPoint;
-
-/**
- * A bot (or analyzer) that aids the user in the debugging workflow
- *
- * <p>
- * These are a sort of miniature front-end plugin (TODO: consider tool-only bots) with a number of
- * conveniences allowing the specification of automatic actions taken under given circumstances,
- * e.g., "Open the interpreter for new debugger connections." Such actions may include analysis of
- * open traces, e.g., "Disassemble memory at the Program Counter."
- *
- * <p>
- * Bots which react to target state changes should take care to act quickly in most, if not all,
- * circumstances. Otherwise, the UI could become sluggish. It is vitally important that the UI not
- * become sluggish when the user is stepping a target. Bots should also be wary of prompts. If too
- * many bots are prompting the user for input, they may collectively become a source of extreme
- * annoyance. In most cases, the bot should use its best judgment and just perform the action, so
- * long as it's not potentially destructive. That way, the user can undo the action and/or disable
- * the bot. For cases where the bot, in its best judgment, cannot make a decision, it's probably
- * best to simply log an informational message and do nothing. There are exceptions, just consider
- * them carefully, and be mindful of prompting the user unexpectedly or incessantly.
- */
-public interface DebuggerBot extends ExtensionPoint {
-
- /**
- * Log a missing-info-annotation error
- *
- * @param cls the bot's class missing the annotation
- * @param methodName the name of the method requesting the info
- */
- @Internal
- static void noAnnot(Class<?> cls, String methodName) {
- Msg.error(DebuggerBot.class, "Debugger bot " + cls + " must apply @" +
- DebuggerBotInfo.class.getSimpleName() + " or override getDescription()");
- }
-
- /**
- * Utility for obtaining and bot's info annotation
- *
- * <p>
- * If the annotation is not present, an error is logged for the developer's sake.
- *
- * @param cls the bot's class
- * @param methodName the name of the method requesting the info, for error-reporting purposes
- * @return the annotation, or {@code null}
- */
- @Internal
- static DebuggerBotInfo getInfo(Class<?> cls, String methodName) {
- DebuggerBotInfo info = cls.getAnnotation(DebuggerBotInfo.class);
- if (info == null) {
- noAnnot(cls, methodName);
- }
- return info;
- }
-
- /**
- * Get a description of the bot
- *
- * @see DebuggerBotInfo#description()
- * @return the description
- */
- default String getDescription() {
- DebuggerBotInfo info = getInfo(getClass(), "getDescription");
- if (info == null) {
- return "<NO DESCRIPTION>";
- }
- return info.description();
- }
-
- /**
- * Get a detailed description of the bot
- *
- * @see DebuggerBotInfo#details()
- * @return the details
- */
- default String getDetails() {
- DebuggerBotInfo info = getInfo(getClass(), "getDetails");
- if (info == null) {
- return "";
- }
- return info.details();
- }
-
- /**
- * Get the help location for information about the bot
- *
- * @see DebuggerBotInfo#help()
- * @return the help location
- */
- default HelpLocation getHelpLocation() {
- DebuggerBotInfo info = getInfo(getClass(), "getHelpLocation");
- if (info == null) {
- return null;
- }
- return AutoOptions.getHelpLocation("DebuggerBots", info.help());
- }
-
- /**
- * Check whether this bot is enabled by default
- *
- * <p>
- * Assuming the user has never configured this bot before, determine whether it should be
- * enabled.
- *
- * @return true if enabled by default, false otherwise
- */
- default boolean isEnabledByDefault() {
- DebuggerBotInfo info = getInfo(getClass(), "isEnabledByDefault");
- if (info == null) {
- return false;
- }
- return info.enabledByDefault();
- }
-
- /**
- * Check if this bot is enabled
- *
- * @return true if enabled, false otherwise
- */
- boolean isEnabled();
-
- /**
- * Enable or disable the bot
- *
- * <p>
- * If {@link #isEnabled()} is already equal to the given -enabled- value, this method has no
- * effect.
- *
- * @param service the front-end service, required if -enabled- is set
- * @param enabled true to enable, false to disable
- */
- default void setEnabled(DebuggerWorkflowFrontEndService service, boolean enabled) {
- if (isEnabled() == enabled) {
- return;
- }
- if (enabled) {
- enable(service);
- }
- else {
- disable();
- }
- }
-
- /**
- * Enable and initialize the bot
- *
- * @param service the front-end service
- */
- void enable(DebuggerWorkflowFrontEndService service);
-
- /**
- * Disable and dispose the bot
- *
- * <p>
- * Note the bot must be prepared to be enabled again. In other words, it will not be
- * re-instantiated. It should return to the same state after construction but before being
- * enabled the first time.
- */
- void disable();
-
- /**
- * A program has been opened in a tool
- *
- * @param tool the tool which opened the program
- * @param program the program that was opened
- */
- default void programOpened(PluginTool tool, Program program) {
- }
-
- /**
- * A program has been closed in a tool
- *
- * @param tool the tool which closed the program
- * @param program the program that was closed
- */
- default void programClosed(PluginTool tool, Program program) {
- }
-
- /**
- * A trace has been opened in a tool
- *
- * @param tool the tool which opened the trace
- * @param trace the trace that was opened
- */
- default void traceOpened(PluginTool tool, Trace trace) {
- }
-
- /**
- * A trace has been closed in a tool
- *
- * @param tool the tool which closed the trace
- * @param trace the trace that was closed
- */
- default void traceClosed(PluginTool tool, Trace trace) {
- }
-}
diff --git a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/workflow/DebuggerBotInfo.java b/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/workflow/DebuggerBotInfo.java
deleted file mode 100644
index 2fb237accb..0000000000
--- a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/workflow/DebuggerBotInfo.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/* ###
- * IP: GHIDRA
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.debug.api.workflow;
-
-import java.lang.annotation.*;
-
-import ghidra.framework.options.annotation.HelpInfo;
-
-/**
- * Required information annotation on {@link DebuggerBot}s
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface DebuggerBotInfo {
- /**
- * A quick one-line description of the actor
- *
- * This is used as the option name to enable and disable the actor, to please, keep it short.
- * Use {@link #details()} or {@link #help()} to provide more details.
- *
- * @return the description
- */
- String description();
-
- /**
- * A longer description of this actor
- *
- * A one-to-three-sentence detailed description of the actor. Again, it should be relatively
- * short, as it used as the tool-tip popup in the plugin's options dialog. On some systems, such
- * tips only display for a short time.
- *
- * @return the detailed description
- */
- String details();
-
- /**
- * The location for help about this actor
- *
- * Help is the best place to put lengthy descriptions of the actor and/or describe the caveats
- * of using it. Since, in most cases, the actor is simply performing automatic actions, it is
- * useful to show the reader how to perform those same actions manually. This way, if/when the
- * actor takes an unreasonable action, the user can manually correct it.
- *
- * @return the link to detailed help about the actor
- */
- HelpInfo help() default @HelpInfo(topic = {});
-
- /**
- * Check whether the actor should be enabled by default
- *
- * For the stock plugin, a collection of actors should be enabled by default that make the
- * debugger most accessible, erring toward ease of use, rather than toward correctness. Advanced
- * users can always disable unwanted actors, tweak the options (TODO: Allow actors to present
- * additional options in the tool config), and/or write their own actors and scripts.
- *
- * For extensions, consider the user's expectations upon installing your extension. For example,
- * if the extension consists of just an actor and some supporting classes, it should probably be
- * enabled by default.
- *
- * @return true to enable by default, false to leave disabled by default
- */
- boolean enabledByDefault() default false;
-}
diff --git a/Ghidra/Debug/Debugger-rmi-trace/DEVNOTES.txt b/Ghidra/Debug/Debugger-rmi-trace/DEVNOTES.txt
index 0c6907099d..9815847397 100644
--- a/Ghidra/Debug/Debugger-rmi-trace/DEVNOTES.txt
+++ b/Ghidra/Debug/Debugger-rmi-trace/DEVNOTES.txt
@@ -280,8 +280,35 @@ For the user to open a second transaction may be considered an error.
Take care as you're coding (and likely re-using command logic) that you don't accidentally take or otherwise conflict with the CLI's transaction manager when processing an event.
-
# Regarding launcher shell scripts:
Need to document all the @metadata stuff
In particular, "Image" is a special parameter that will get the program executable by default.
+
+
+# Regarding the schema and method signatures
+
+An interface like Togglable requires that a TOGGLE action takes the given schema as a parameter
+(e.g., a BreakpointLocation)
+
+
+# Regarding registers
+
+The register container has to exist, even if its left empty in favor of the register space.
+
+1. The space is named after the container
+2. The UI uses the container as an anchor in its searches
+
+To allow register writes, each writable register must exist as an object it the register container.
+
+1. I might like to relax this....
+2. The UI it to validate the register is editable, even though the RemoteMethod may accept
+ frame/thread,name,val.
+
+
+# Regarding reading and writing memory
+
+The process parameter, if accepted, is technically redundant.
+Because all address spaces among all targets must be unique, the address space encodes the process (or other target object).
+If taken, the back end must validate that the address space belongs to the given process.
+Otherwise, the back end must figure out the applicable target based on the space name.
diff --git a/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/RemoteMethodInvocationDialog.java b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/RemoteMethodInvocationDialog.java
new file mode 100644
index 0000000000..2e0f36bd5f
--- /dev/null
+++ b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/RemoteMethodInvocationDialog.java
@@ -0,0 +1,387 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.tracermi;
+
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.beans.*;
+import java.util.*;
+import java.util.List;
+
+import javax.swing.*;
+import javax.swing.border.EmptyBorder;
+
+import org.apache.commons.collections4.BidiMap;
+import org.apache.commons.collections4.bidimap.DualLinkedHashBidiMap;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.text.StringEscapeUtils;
+import org.jdom.Element;
+
+import docking.DialogComponentProvider;
+import ghidra.app.plugin.core.debug.gui.DebuggerResources;
+import ghidra.app.plugin.core.debug.utils.MiscellaneousUtils;
+import ghidra.dbg.target.schema.SchemaContext;
+import ghidra.debug.api.tracermi.RemoteParameter;
+import ghidra.framework.options.SaveState;
+import ghidra.framework.plugintool.AutoConfigState.ConfigStateField;
+import ghidra.framework.plugintool.PluginTool;
+import ghidra.util.Msg;
+import ghidra.util.layout.PairLayout;
+
+public class RemoteMethodInvocationDialog extends DialogComponentProvider
+ implements PropertyChangeListener {
+ private static final String KEY_MEMORIZED_ARGUMENTS = "memorizedArguments";
+
+ static class ChoicesPropertyEditor implements PropertyEditor {
+ private final List<?> choices;
+ private final String[] tags;
+
+ private final List<PropertyChangeListener> listeners = new ArrayList<>();
+
+ private Object value;
+
+ public ChoicesPropertyEditor(Set<?> choices) {
+ this.choices = List.copyOf(choices);
+ this.tags = choices.stream().map(Objects::toString).toArray(String[]::new);
+ }
+
+ @Override
+ public void setValue(Object value) {
+ if (Objects.equals(value, this.value)) {
+ return;
+ }
+ if (!choices.contains(value)) {
+ throw new IllegalArgumentException("Unsupported value: " + value);
+ }
+ Object oldValue;
+ List<PropertyChangeListener> listeners;
+ synchronized (this.listeners) {
+ oldValue = this.value;
+ this.value = value;
+ if (this.listeners.isEmpty()) {
+ return;
+ }
+ listeners = List.copyOf(this.listeners);
+ }
+ PropertyChangeEvent evt = new PropertyChangeEvent(this, null, oldValue, value);
+ for (PropertyChangeListener l : listeners) {
+ l.propertyChange(evt);
+ }
+ }
+
+ @Override
+ public Object getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean isPaintable() {
+ return false;
+ }
+
+ @Override
+ public void paintValue(Graphics gfx, Rectangle box) {
+ // Not paintable
+ }
+
+ @Override
+ public String getJavaInitializationString() {
+ if (value == null) {
+ return "null";
+ }
+ if (value instanceof String str) {
+ return "\"" + StringEscapeUtils.escapeJava(str) + "\"";
+ }
+ return Objects.toString(value);
+ }
+
+ @Override
+ public String getAsText() {
+ return Objects.toString(value);
+ }
+
+ @Override
+ public void setAsText(String text) throws IllegalArgumentException {
+ int index = ArrayUtils.indexOf(tags, text);
+ if (index < 0) {
+ throw new IllegalArgumentException("Unsupported value: " + text);
+ }
+ setValue(choices.get(index));
+ }
+
+ @Override
+ public String[] getTags() {
+ return tags.clone();
+ }
+
+ @Override
+ public Component getCustomEditor() {
+ return null;
+ }
+
+ @Override
+ public boolean supportsCustomEditor() {
+ return false;
+ }
+
+ @Override
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ synchronized (listeners) {
+ listeners.add(listener);
+ }
+ }
+
+ @Override
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ synchronized (listeners) {
+ listeners.remove(listener);
+ }
+ }
+ }
+
+ record NameTypePair(String name, Class<?> type) {
+ public static NameTypePair fromParameter(SchemaContext ctx, RemoteParameter parameter) {
+ return new NameTypePair(parameter.name(), ctx.getSchema(parameter.type()).getType());
+ }
+
+ public static NameTypePair fromString(String name) throws ClassNotFoundException {
+ String[] parts = name.split(",", 2);
+ if (parts.length != 2) {
+ // This appears to be a bad assumption - empty fields results in solitary labels
+ return new NameTypePair(parts[0], String.class);
+ //throw new IllegalArgumentException("Could not parse name,type");
+ }
+ return new NameTypePair(parts[0], Class.forName(parts[1]));
+ }
+ }
+
+ private final BidiMap<RemoteParameter, PropertyEditor> paramEditors =
+ new DualLinkedHashBidiMap<>();
+
+ private JPanel panel;
+ private JLabel descriptionLabel;
+ private JPanel pairPanel;
+ private PairLayout layout;
+
+ protected JButton invokeButton;
+ protected JButton resetButton;
+
+ private final PluginTool tool;
+ private SchemaContext ctx;
+ private Map<String, RemoteParameter> parameters;
+ private Map<String, Object> defaults;
+
+ // TODO: Not sure this is the best keying, but I think it works.
+ private Map<NameTypePair, Object> memorized = new HashMap<>();
+ private Map<String, Object> arguments;
+
+ public RemoteMethodInvocationDialog(PluginTool tool, String title, String buttonText,
+ Icon buttonIcon) {
+ super(title, true, true, true, false);
+ this.tool = tool;
+
+ populateComponents(buttonText, buttonIcon);
+ setRememberSize(false);
+ }
+
+ protected Object computeMemorizedValue(RemoteParameter parameter) {
+ return memorized.computeIfAbsent(NameTypePair.fromParameter(ctx, parameter),
+ ntp -> parameter.getDefaultValue());
+ }
+
+ public Map<String, Object> promptArguments(SchemaContext ctx,
+ Map<String, RemoteParameter> parameterMap, Map<String, Object> defaults) {
+ setParameters(ctx, parameterMap);
+ setDefaults(defaults);
+ tool.showDialog(this);
+
+ return getArguments();
+ }
+
+ public void setParameters(SchemaContext ctx, Map<String, RemoteParameter> parameterMap) {
+ this.ctx = ctx;
+ this.parameters = parameterMap;
+ populateOptions();
+ }
+
+ public void setDefaults(Map<String, Object> defaults) {
+ this.defaults = defaults;
+ }
+
+ private void populateComponents(String buttonText, Icon buttonIcon) {
+ panel = new JPanel(new BorderLayout());
+ panel.setBorder(new EmptyBorder(10, 10, 10, 10));
+
+ layout = new PairLayout(5, 5);
+ pairPanel = new JPanel(layout);
+
+ JPanel centering = new JPanel(new FlowLayout(FlowLayout.CENTER));
+ JScrollPane scrolling = new JScrollPane(centering, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ //scrolling.setPreferredSize(new Dimension(100, 130));
+ panel.add(scrolling, BorderLayout.CENTER);
+ centering.add(pairPanel);
+
+ descriptionLabel = new JLabel();
+ descriptionLabel.setMaximumSize(new Dimension(300, 100));
+ panel.add(descriptionLabel, BorderLayout.NORTH);
+
+ addWorkPanel(panel);
+
+ invokeButton = new JButton(buttonText, buttonIcon);
+ addButton(invokeButton);
+ resetButton = new JButton("Reset", DebuggerResources.ICON_REFRESH);
+ addButton(resetButton);
+ addCancelButton();
+
+ invokeButton.addActionListener(this::invoke);
+ resetButton.addActionListener(this::reset);
+ }
+
+ @Override
+ protected void cancelCallback() {
+ this.arguments = null;
+ close();
+ }
+
+ protected void invoke(ActionEvent evt) {
+ this.arguments = collectArguments();
+ close();
+ }
+
+ private void reset(ActionEvent evt) {
+ this.arguments = new HashMap<>();
+ for (RemoteParameter param : parameters.values()) {
+ if (defaults.containsKey(param.name())) {
+ arguments.put(param.name(), defaults.get(param.name()));
+ }
+ else {
+ arguments.put(param.name(), param.getDefaultValue());
+ }
+ }
+ populateValues();
+ }
+
+ protected PropertyEditor createEditor(RemoteParameter param) {
+ Class<?> type = ctx.getSchema(param.type()).getType();
+ PropertyEditor editor = PropertyEditorManager.findEditor(type);
+ if (editor != null) {
+ return editor;
+ }
+ Msg.warn(this, "No editor for " + type + "? Trying String instead");
+ return PropertyEditorManager.findEditor(String.class);
+ }
+
+ void populateOptions() {
+ pairPanel.removeAll();
+ paramEditors.clear();
+ for (RemoteParameter param : parameters.values()) {
+ JLabel label = new JLabel(param.display());
+ label.setToolTipText(param.description());
+ pairPanel.add(label);
+
+ PropertyEditor editor = createEditor(param);
+ Object val = computeMemorizedValue(param);
+ editor.setValue(val);
+ editor.addPropertyChangeListener(this);
+ pairPanel.add(MiscellaneousUtils.getEditorComponent(editor));
+ paramEditors.put(param, editor);
+ }
+ }
+
+ void populateValues() {
+ for (Map.Entry<String, Object> ent : arguments.entrySet()) {
+ RemoteParameter param = parameters.get(ent.getKey());
+ if (param == null) {
+ Msg.warn(this, "No parameter for argument: " + ent);
+ continue;
+ }
+ PropertyEditor editor = paramEditors.get(param);
+ editor.setValue(ent.getValue());
+ }
+ }
+
+ protected Map<String, Object> collectArguments() {
+ Map<String, Object> map = new LinkedHashMap<>();
+ for (RemoteParameter param : paramEditors.keySet()) {
+ Object val = memorized.get(NameTypePair.fromParameter(ctx, param));
+ if (val != null) {
+ map.put(param.name(), val);
+ }
+ }
+ return map;
+ }
+
+ public Map<String, Object> getArguments() {
+ return arguments;
+ }
+
+ public <T> void setMemorizedArgument(String name, Class<T> type, T value) {
+ if (value == null) {
+ return;
+ }
+ memorized.put(new NameTypePair(name, type), value);
+ }
+
+ public <T> T getMemorizedArgument(String name, Class<T> type) {
+ return type.cast(memorized.get(new NameTypePair(name, type)));
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ PropertyEditor editor = (PropertyEditor) evt.getSource();
+ RemoteParameter param = paramEditors.getKey(editor);
+ memorized.put(NameTypePair.fromParameter(ctx, param), editor.getValue());
+ }
+
+ public void writeConfigState(SaveState saveState) {
+ SaveState subState = new SaveState();
+ for (Map.Entry<NameTypePair, Object> ent : memorized.entrySet()) {
+ NameTypePair ntp = ent.getKey();
+ ConfigStateField.putState(subState, ntp.type().asSubclass(Object.class), ntp.name(),
+ ent.getValue());
+ }
+ saveState.putXmlElement(KEY_MEMORIZED_ARGUMENTS, subState.saveToXml());
+ }
+
+ public void readConfigState(SaveState saveState) {
+ Element element = saveState.getXmlElement(KEY_MEMORIZED_ARGUMENTS);
+ if (element == null) {
+ return;
+ }
+ SaveState subState = new SaveState(element);
+ for (String name : subState.getNames()) {
+ try {
+ NameTypePair ntp = NameTypePair.fromString(name);
+ memorized.put(ntp, ConfigStateField.getState(subState, ntp.type(), ntp.name()));
+ }
+ catch (Exception e) {
+ Msg.error(this, "Error restoring memorized parameter " + name, e);
+ }
+ }
+ }
+
+ public void setDescription(String htmlDescription) {
+ if (htmlDescription == null) {
+ descriptionLabel.setBorder(BorderFactory.createEmptyBorder());
+ descriptionLabel.setText("");
+ }
+ else {
+ descriptionLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
+ descriptionLabel.setText(htmlDescription);
+ }
+ }
+}
diff --git a/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/AbstractTraceRmiLaunchOffer.java b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/AbstractTraceRmiLaunchOffer.java
index 9d8d73c8e4..a223d5a894 100644
--- a/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/AbstractTraceRmiLaunchOffer.java
+++ b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/AbstractTraceRmiLaunchOffer.java
@@ -30,10 +30,14 @@ import org.jdom.Element;
import org.jdom.JDOMException;
import db.Transaction;
+import docking.widgets.OptionDialog;
import ghidra.app.plugin.core.debug.gui.DebuggerResources;
import ghidra.app.plugin.core.debug.gui.objects.components.DebuggerMethodInvocationDialog;
+import ghidra.app.plugin.core.debug.service.rmi.trace.DefaultTraceRmiAcceptor;
+import ghidra.app.plugin.core.debug.service.rmi.trace.TraceRmiHandler;
import ghidra.app.plugin.core.terminal.TerminalListener;
import ghidra.app.services.*;
+import ghidra.app.services.DebuggerTraceManagerService.ActivationCause;
import ghidra.async.AsyncUtils;
import ghidra.dbg.target.TargetMethod.ParameterDescription;
import ghidra.dbg.util.ShellUtils;
@@ -50,8 +54,7 @@ import ghidra.pty.*;
import ghidra.trace.model.Trace;
import ghidra.trace.model.TraceLocation;
import ghidra.trace.model.modules.TraceModule;
-import ghidra.util.MessageType;
-import ghidra.util.Msg;
+import ghidra.util.*;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.Task;
import ghidra.util.task.TaskMonitor;
@@ -77,6 +80,16 @@ public abstract class AbstractTraceRmiLaunchOffer implements TraceRmiLaunchOffer
pty.close();
waiter.interrupt();
}
+
+ @Override
+ public boolean isTerminated() {
+ return terminal.isTerminated();
+ }
+
+ @Override
+ public String description() {
+ return session.description();
+ }
}
protected record NullPtyTerminalSession(Terminal terminal, Pty pty, String name)
@@ -92,6 +105,16 @@ public abstract class AbstractTraceRmiLaunchOffer implements TraceRmiLaunchOffer
terminal.terminated();
pty.close();
}
+
+ @Override
+ public boolean isTerminated() {
+ return terminal.isTerminated();
+ }
+
+ @Override
+ public String description() {
+ return name;
+ }
}
static class TerminateSessionTask extends Task {
@@ -113,13 +136,15 @@ public abstract class AbstractTraceRmiLaunchOffer implements TraceRmiLaunchOffer
}
}
+ protected final TraceRmiLauncherServicePlugin plugin;
protected final Program program;
protected final PluginTool tool;
protected final TerminalService terminalService;
- public AbstractTraceRmiLaunchOffer(Program program, PluginTool tool) {
+ public AbstractTraceRmiLaunchOffer(TraceRmiLauncherServicePlugin plugin, Program program) {
+ this.plugin = Objects.requireNonNull(plugin);
this.program = Objects.requireNonNull(program);
- this.tool = Objects.requireNonNull(tool);
+ this.tool = plugin.getTool();
this.terminalService = Objects.requireNonNull(tool.getService(TerminalService.class));
}
@@ -151,9 +176,8 @@ public abstract class AbstractTraceRmiLaunchOffer implements TraceRmiLaunchOffer
return null; // I guess we won't wait for a mapping, then
}
- protected CompletableFuture<Void> listenForMapping(
- DebuggerStaticMappingService mappingService, TraceRmiConnection connection,
- Trace trace) {
+ protected CompletableFuture<Void> listenForMapping(DebuggerStaticMappingService mappingService,
+ TraceRmiConnection connection, Trace trace) {
Address probeAddress = getMappingProbeAddress();
if (probeAddress == null) {
return AsyncUtils.nil(); // No need to wait on mapping of nothing
@@ -469,9 +493,20 @@ public abstract class AbstractTraceRmiLaunchOffer implements TraceRmiLaunchOffer
Map<String, TerminalSession> sessions, Map<String, ?> args, SocketAddress address)
throws Exception;
+ static class NoStaticMappingException extends Exception {
+ public NoStaticMappingException(String message) {
+ super(message);
+ }
+
+ @Override
+ public String toString() {
+ return getMessage();
+ }
+ }
+
@Override
public LaunchResult launchProgram(TaskMonitor monitor, LaunchConfigurator configurator) {
- TraceRmiService service = tool.getService(TraceRmiService.class);
+ InternalTraceRmiService service = tool.getService(InternalTraceRmiService.class);
DebuggerStaticMappingService mappingService =
tool.getService(DebuggerStaticMappingService.class);
DebuggerTraceManagerService traceManager =
@@ -479,9 +514,9 @@ public abstract class AbstractTraceRmiLaunchOffer implements TraceRmiLaunchOffer
final PromptMode mode = configurator.getPromptMode();
boolean prompt = mode == PromptMode.ALWAYS;
- TraceRmiAcceptor acceptor = null;
+ DefaultTraceRmiAcceptor acceptor = null;
Map<String, TerminalSession> sessions = new LinkedHashMap<>();
- TraceRmiConnection connection = null;
+ TraceRmiHandler connection = null;
Trace trace = null;
Throwable lastExc = null;
@@ -509,10 +544,12 @@ public abstract class AbstractTraceRmiLaunchOffer implements TraceRmiLaunchOffer
monitor.setMessage("Waiting for connection");
acceptor.setTimeout(getTimeoutMillis());
connection = acceptor.accept();
+ connection.registerTerminals(sessions.values());
monitor.setMessage("Waiting for trace");
trace = connection.waitForTrace(getTimeoutMillis());
traceManager.openTrace(trace);
- traceManager.activateTrace(trace);
+ traceManager.activate(traceManager.resolveTrace(trace),
+ ActivationCause.START_RECORDING);
monitor.setMessage("Waiting for module mapping");
try {
listenForMapping(mappingService, connection, trace).get(getTimeoutMillis(),
@@ -529,25 +566,132 @@ public abstract class AbstractTraceRmiLaunchOffer implements TraceRmiLaunchOffer
throw new CancellationException(e.getMessage());
}
if (mapped.isEmpty()) {
- monitor.setMessage(
- "Could not formulate a mapping with the target program. " +
- "Continuing without one.");
- Msg.showWarn(this, null, "Launch " + program,
- "The resulting target process has no mapping to the static image " +
- program + ". Intervention is required before static and dynamic " +
- "addresses can be translated. Check the target's module list.");
+ throw new NoStaticMappingException(
+ "The resulting target process has no mapping to the static image.");
}
}
}
catch (Exception e) {
lastExc = e;
prompt = mode != PromptMode.NEVER;
+ LaunchResult result =
+ new LaunchResult(program, sessions, connection, trace, lastExc);
if (prompt) {
+ switch (promptError(result)) {
+ case KEEP:
+ return result;
+ case RETRY:
+ try {
+ result.close();
+ }
+ catch (Exception e1) {
+ Msg.error(this, "Could not close", e1);
+ }
+ continue;
+ case TERMINATE:
+ try {
+ result.close();
+ }
+ catch (Exception e1) {
+ Msg.error(this, "Could not close", e1);
+ }
+ return new LaunchResult(program, Map.of(), null, null, lastExc);
+ }
continue;
}
- return new LaunchResult(program, sessions, connection, trace, lastExc);
+ return result;
}
return new LaunchResult(program, sessions, connection, trace, null);
}
}
+
+ enum ErrPromptResponse {
+ KEEP, RETRY, TERMINATE;
+ }
+
+ protected ErrPromptResponse promptError(LaunchResult result) {
+ String message = """
+ <html><body width="400px">
+ <h3>Failed to launch %s due to an exception:</h3>
+
+ <tt>%s</tt>
+
+ <h3>Troubleshooting</h3>
+ <p>
+ <b>Check the Terminal!</b>
+ If no terminal is visible, check the menus: <b>Window &rarr; Terminals &rarr;
+ ...</b>.
+ A path or other configuration parameter may be incorrect.
+ The back-end debugger may have paused for user input.
+ There may be a missing dependency.
+ There may be an incorrect version, etc.</p>
+
+ <h3>These resources remain after the failed launch:</h3>
+ <ul>
+ %s
+ </ul>
+
+ <h3>Do you want to keep these resources?</h3>
+ <ul>
+ <li>Choose <b>Yes</b> to stop here and diagnose or complete the launch manually.
+ </li>
+ <li>Choose <b>No</b> to clean up and retry at the launch dialog.</li>
+ <li>Choose <b>Cancel</b> to clean up without retrying.</li>
+ """.formatted(
+ htmlProgramName(result), htmlExceptionMessage(result), htmlResources(result));
+ return LaunchFailureDialog.show(message);
+ }
+
+ static class LaunchFailureDialog extends OptionDialog {
+ public LaunchFailureDialog(String message) {
+ super("Launch Failed", message, "&Yes", "&No", OptionDialog.ERROR_MESSAGE, null,
+ true, "No");
+ }
+
+ static ErrPromptResponse show(String message) {
+ return switch (new LaunchFailureDialog(message).show()) {
+ case OptionDialog.YES_OPTION -> ErrPromptResponse.KEEP;
+ case OptionDialog.NO_OPTION -> ErrPromptResponse.RETRY;
+ case OptionDialog.CANCEL_OPTION -> ErrPromptResponse.TERMINATE;
+ default -> throw new AssertionError();
+ };
+ }
+ }
+
+ protected String htmlProgramName(LaunchResult result) {
+ if (result.program() == null) {
+ return "";
+ }
+ return "<tt>" + HTMLUtilities.escapeHTML(result.program().getName()) + "</tt>";
+ }
+
+ protected String htmlExceptionMessage(LaunchResult result) {
+ if (result.exception() == null) {
+ return "(No exception)";
+ }
+ return HTMLUtilities.escapeHTML(result.exception().toString());
+ }
+
+ protected String htmlResources(LaunchResult result) {
+ StringBuilder sb = new StringBuilder();
+ for (Entry<String, TerminalSession> ent : result.sessions().entrySet()) {
+ TerminalSession session = ent.getValue();
+ sb.append("<li>Terminal: " + HTMLUtilities.escapeHTML(ent.getKey()) + " &rarr; <tt>" +
+ HTMLUtilities.escapeHTML(session.description()) + "</tt>");
+ if (session.isTerminated()) {
+ sb.append(" (Terminated)");
+ }
+ sb.append("</li>\n");
+ }
+ if (result.connection() != null) {
+ sb.append("<li>Connection: <tt>" +
+ HTMLUtilities.escapeHTML(result.connection().getRemoteAddress().toString()) +
+ "</tt></li>\n");
+ }
+ if (result.trace() != null) {
+ sb.append(
+ "<li>Trace: " + HTMLUtilities.escapeHTML(result.trace().getName()) + "</li>\n");
+ }
+ return sb.toString();
+ }
}
diff --git a/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/TraceRmiLauncherServicePlugin.java b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/TraceRmiLauncherServicePlugin.java
index 521643db6a..7756636506 100644
--- a/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/TraceRmiLauncherServicePlugin.java
+++ b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/TraceRmiLauncherServicePlugin.java
@@ -31,7 +31,7 @@ import ghidra.app.services.*;
import ghidra.debug.api.tracermi.TraceRmiLaunchOffer;
import ghidra.debug.api.tracermi.TraceRmiLaunchOffer.LaunchConfigurator;
import ghidra.debug.api.tracermi.TraceRmiLaunchOffer.PromptMode;
-import ghidra.debug.api.tracermi.TraceRmiLaunchOpinion;
+import ghidra.debug.spi.tracermi.TraceRmiLaunchOpinion;
import ghidra.framework.options.OptionsChangeListener;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.*;
@@ -67,6 +67,13 @@ public class TraceRmiLauncherServicePlugin extends Plugin
implements TraceRmiLauncherService, OptionsChangeListener {
protected static final String OPTION_NAME_SCRIPT_PATHS = "Script Paths";
+ private final static LaunchConfigurator RELAUNCH = new LaunchConfigurator() {
+ @Override
+ public PromptMode getPromptMode() {
+ return PromptMode.ON_ERROR;
+ }
+ };
+
private final static LaunchConfigurator PROMPT = new LaunchConfigurator() {
@Override
public PromptMode getPromptMode() {
@@ -90,7 +97,7 @@ public class TraceRmiLauncherServicePlugin extends Plugin
@Override
public void run(TaskMonitor monitor) throws CancelledException {
- offer.launchProgram(monitor);
+ offer.launchProgram(monitor, RELAUNCH);
}
}
@@ -165,11 +172,6 @@ public class TraceRmiLauncherServicePlugin extends Plugin
}
}
- @Override
- public Collection<TraceRmiLaunchOpinion> getOpinions() {
- return ClassSearcher.getInstances(TraceRmiLaunchOpinion.class);
- }
-
@Override
public Collection<TraceRmiLaunchOffer> getOffers(Program program) {
if (program == null) {
@@ -177,7 +179,7 @@ public class TraceRmiLauncherServicePlugin extends Plugin
}
return ClassSearcher.getInstances(TraceRmiLaunchOpinion.class)
.stream()
- .flatMap(op -> op.getOffers(program, getTool()).stream())
+ .flatMap(op -> op.getOffers(this, program).stream())
.toList();
}
diff --git a/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/UnixShellScriptTraceRmiLaunchOffer.java b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/UnixShellScriptTraceRmiLaunchOffer.java
index 09904e35b6..787eb7a54a 100644
--- a/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/UnixShellScriptTraceRmiLaunchOffer.java
+++ b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/UnixShellScriptTraceRmiLaunchOffer.java
@@ -27,8 +27,8 @@ import generic.theme.GIcon;
import generic.theme.Gui;
import ghidra.dbg.target.TargetMethod.ParameterDescription;
import ghidra.dbg.util.ShellUtils;
+import ghidra.debug.api.tracermi.TerminalSession;
import ghidra.framework.Application;
-import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.listing.Program;
import ghidra.util.HelpLocation;
import ghidra.util.Msg;
@@ -471,8 +471,8 @@ public class UnixShellScriptTraceRmiLaunchOffer extends AbstractTraceRmiLaunchOf
* the target image is mapped in the resulting target trace.
* @throws FileNotFoundException
*/
- public static UnixShellScriptTraceRmiLaunchOffer create(Program program, PluginTool tool,
- File script) throws FileNotFoundException {
+ public static UnixShellScriptTraceRmiLaunchOffer create(TraceRmiLauncherServicePlugin plugin,
+ Program program, File script) throws FileNotFoundException {
try (BufferedReader reader =
new BufferedReader(new InputStreamReader(new FileInputStream(script)))) {
AttributesParser attrs = new AttributesParser();
@@ -491,7 +491,7 @@ public class UnixShellScriptTraceRmiLaunchOffer extends AbstractTraceRmiLaunchOf
}
}
attrs.validate(script.getName());
- return new UnixShellScriptTraceRmiLaunchOffer(program, tool, script,
+ return new UnixShellScriptTraceRmiLaunchOffer(plugin, program, script,
"UNIX_SHELL:" + script.getName(), attrs.title, attrs.getDescription(),
attrs.menuPath, attrs.menuGroup, attrs.menuOrder, new GIcon(attrs.iconId),
attrs.helpLocation, attrs.parameters, attrs.extraTtys);
@@ -517,11 +517,11 @@ public class UnixShellScriptTraceRmiLaunchOffer extends AbstractTraceRmiLaunchOf
protected final Map<String, ParameterDescription<?>> parameters;
protected final List<String> extraTtys;
- public UnixShellScriptTraceRmiLaunchOffer(Program program, PluginTool tool, File script,
- String configName, String title, String description, List<String> menuPath,
+ public UnixShellScriptTraceRmiLaunchOffer(TraceRmiLauncherServicePlugin plugin, Program program,
+ File script, String configName, String title, String description, List<String> menuPath,
String menuGroup, String menuOrder, Icon icon, HelpLocation helpLocation,
Map<String, ParameterDescription<?>> parameters, Collection<String> extraTtys) {
- super(program, tool);
+ super(plugin, program);
this.script = script;
this.configName = configName;
this.title = title;
diff --git a/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/UnixShellScriptTraceRmiLaunchOpinion.java b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/UnixShellScriptTraceRmiLaunchOpinion.java
index 5c99c800d1..d1ac0dc9f5 100644
--- a/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/UnixShellScriptTraceRmiLaunchOpinion.java
+++ b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/UnixShellScriptTraceRmiLaunchOpinion.java
@@ -22,7 +22,7 @@ import java.util.stream.Stream;
import generic.jar.ResourceFile;
import ghidra.app.plugin.core.debug.DebuggerPluginPackage;
import ghidra.debug.api.tracermi.TraceRmiLaunchOffer;
-import ghidra.debug.api.tracermi.TraceRmiLaunchOpinion;
+import ghidra.debug.spi.tracermi.TraceRmiLaunchOpinion;
import ghidra.framework.Application;
import ghidra.framework.options.OptionType;
import ghidra.framework.options.Options;
@@ -63,12 +63,13 @@ public class UnixShellScriptTraceRmiLaunchOpinion implements TraceRmiLaunchOpini
}
@Override
- public Collection<TraceRmiLaunchOffer> getOffers(Program program, PluginTool tool) {
- return getScriptPaths(tool)
+ public Collection<TraceRmiLaunchOffer> getOffers(TraceRmiLauncherServicePlugin plugin,
+ Program program) {
+ return getScriptPaths(plugin.getTool())
.flatMap(rf -> Stream.of(rf.listFiles(crf -> crf.getName().endsWith(".sh"))))
.flatMap(sf -> {
try {
- return Stream.of(UnixShellScriptTraceRmiLaunchOffer.create(program, tool,
+ return Stream.of(UnixShellScriptTraceRmiLaunchOffer.create(plugin, program,
sf.getFile(false)));
}
catch (Exception e) {
diff --git a/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/service/rmi/trace/TraceRmiHandler.java b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/service/rmi/trace/TraceRmiHandler.java
index 05405dfb04..4b7c95bbad 100644
--- a/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/service/rmi/trace/TraceRmiHandler.java
+++ b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/service/rmi/trace/TraceRmiHandler.java
@@ -36,11 +36,14 @@ import com.google.protobuf.ByteString;
import db.Transaction;
import ghidra.app.plugin.core.debug.disassemble.DebuggerDisassemblerPlugin;
import ghidra.app.plugin.core.debug.disassemble.TraceDisassembleCommand;
+import ghidra.app.services.DebuggerControlService;
import ghidra.app.services.DebuggerTraceManagerService;
+import ghidra.app.services.DebuggerTraceManagerService.ActivationCause;
import ghidra.dbg.target.schema.TargetObjectSchema.SchemaName;
import ghidra.dbg.target.schema.XmlSchemaContext;
import ghidra.dbg.util.PathPattern;
import ghidra.dbg.util.PathUtils;
+import ghidra.debug.api.control.ControlMode;
import ghidra.debug.api.target.ActionName;
import ghidra.debug.api.tracemgr.DebuggerCoordinates;
import ghidra.debug.api.tracermi.*;
@@ -48,7 +51,6 @@ import ghidra.framework.model.*;
import ghidra.framework.plugintool.AutoService;
import ghidra.framework.plugintool.AutoService.Wiring;
import ghidra.framework.plugintool.annotation.AutoServiceConsumed;
-import ghidra.lifecycle.Internal;
import ghidra.program.model.address.*;
import ghidra.program.model.lang.*;
import ghidra.program.util.DefaultLanguageService;
@@ -158,6 +160,16 @@ public class TraceRmiHandler implements TraceRmiConnection {
return removed;
}
+ public synchronized OpenTrace removeByTrace(Trace trace) {
+ OpenTrace removed = byTrace.remove(trace);
+ if (removed == null) {
+ return null;
+ }
+ byId.remove(removed.doId);
+ plugin.withdrawTarget(removed.target);
+ return removed;
+ }
+
public synchronized OpenTrace getById(DoId doId) {
return byId.get(doId);
}
@@ -185,6 +197,7 @@ public class TraceRmiHandler implements TraceRmiConnection {
private final OutputStream out;
private final CompletableFuture<Void> negotiate = new CompletableFuture<>();
private final CompletableFuture<Void> closed = new CompletableFuture<>();
+ private final Set<TerminalSession> terminals = new LinkedHashSet<>();
private final OpenTraceMap openTraces = new OpenTraceMap();
private final Map<Tid, OpenTx> openTxes = new HashMap<>();
@@ -195,6 +208,8 @@ public class TraceRmiHandler implements TraceRmiConnection {
@AutoServiceConsumed
private DebuggerTraceManagerService traceManager;
+ @AutoServiceConsumed
+ private DebuggerControlService controlService;
@SuppressWarnings("unused")
private final Wiring autoServiceWiring;
@@ -230,9 +245,30 @@ public class TraceRmiHandler implements TraceRmiConnection {
}
}
+ protected void terminateTerminals() {
+ List<TerminalSession> terminals;
+ synchronized (this.terminals) {
+ terminals = List.copyOf(this.terminals);
+ this.terminals.clear();
+ }
+ for (TerminalSession term : terminals) {
+ CompletableFuture.runAsync(() -> {
+ try {
+ term.terminate();
+ }
+ catch (Exception e) {
+ Msg.error(this, "Could not terminate " + term + ": " + e);
+ }
+ });
+ }
+ }
+
public void dispose() throws IOException {
plugin.removeHandler(this);
flushXReqQueue(new TraceRmiError("Socket closed"));
+
+ terminateTerminals();
+
socket.close();
while (!openTxes.isEmpty()) {
Tid nextKey = openTxes.keySet().iterator().next();
@@ -467,6 +503,10 @@ public class TraceRmiHandler implements TraceRmiConnection {
case REQUEST_START_TX -> "startTx(%d,%s)".formatted(
req.getRequestStartTx().getTxid().getId(),
req.getRequestStartTx().getDescription());
+ case REQUEST_SET_VALUE -> "setValue(%d,%s,%s)".formatted(
+ req.getRequestSetValue().getValue().getParent().getId(),
+ req.getRequestSetValue().getValue().getParent().getPath().getPath(),
+ req.getRequestSetValue().getValue().getKey());
default -> null;
};
}
@@ -751,25 +791,26 @@ public class TraceRmiHandler implements TraceRmiConnection {
OpenTrace open = requireOpenTrace(req.getOid());
TraceObject object = open.getObject(req.getObject(), true);
DebuggerCoordinates coords = traceManager.getCurrent();
- if (coords.getTrace() == object.getTrace()) {
- coords = coords.object(object);
- }
- else {
- coords = DebuggerCoordinates.NOWHERE.object(object);
+ if (coords.getTrace() != open.trace) {
+ coords = DebuggerCoordinates.NOWHERE;
}
- if (open.lastSnapshot != null) {
+ ControlMode mode = controlService.getCurrentMode(open.trace);
+ if (open.lastSnapshot != null && mode.followsPresent()) {
coords = coords.snap(open.lastSnapshot.getKey());
}
- if (!traceManager.getOpenTraces().contains(open.trace)) {
- traceManager.openTrace(open.trace);
- traceManager.activate(coords);
- }
- else {
- Trace currentTrace = traceManager.getCurrentTrace();
- if (currentTrace == null || openTraces.getByTrace(currentTrace) != null) {
- traceManager.activate(coords);
+ DebuggerCoordinates finalCoords = coords.object(object);
+ Swing.runLater(() -> {
+ if (!traceManager.getOpenTraces().contains(open.trace)) {
+ traceManager.openTrace(open.trace);
+ traceManager.activate(finalCoords, ActivationCause.SYNC_MODEL);
}
- }
+ else {
+ Trace currentTrace = traceManager.getCurrentTrace();
+ if (currentTrace == null || openTraces.getByTrace(currentTrace) != null) {
+ traceManager.activate(finalCoords, ActivationCause.SYNC_MODEL);
+ }
+ }
+ });
return ReplyActivate.getDefaultInstance();
}
@@ -965,7 +1006,7 @@ public class TraceRmiHandler implements TraceRmiConnection {
}
for (Method m : req.getMethodsList()) {
RemoteMethod rm = new RecordRemoteMethod(this, m.getName(),
- new ActionName(m.getAction()),
+ ActionName.name(m.getAction()),
m.getDescription(), m.getParametersList()
.stream()
.collect(Collectors.toMap(MethodParameter::getName, this::makeParameter)),
@@ -996,7 +1037,7 @@ public class TraceRmiHandler implements TraceRmiConnection {
for (RegVal rv : req.getValuesList()) {
Register register = open.getRegister(rv.getName(), false);
if (register == null) {
- Msg.warn(this, "Ignoring unrecognized register: " + rv.getName());
+ Msg.trace(this, "Ignoring unrecognized register: " + rv.getName());
rep.addSkippedNames(rv.getName());
continue;
}
@@ -1182,9 +1223,12 @@ public class TraceRmiHandler implements TraceRmiConnection {
}
@Override
- @Internal
public long getLastSnapshot(Trace trace) {
- TraceSnapshot lastSnapshot = openTraces.getByTrace(trace).lastSnapshot;
+ OpenTrace byTrace = openTraces.getByTrace(trace);
+ if (byTrace == null) {
+ throw new NoSuchElementException();
+ }
+ TraceSnapshot lastSnapshot = byTrace.lastSnapshot;
if (lastSnapshot == null) {
return 0;
}
@@ -1200,4 +1244,21 @@ public class TraceRmiHandler implements TraceRmiConnection {
throw new TraceRmiError(e);
}
}
+
+ @Override
+ public void forceCloseTrace(Trace trace) {
+ OpenTrace open = openTraces.removeByTrace(trace);
+ open.trace.release(this);
+ }
+
+ @Override
+ public boolean isTarget(Trace trace) {
+ return openTraces.getByTrace(trace) != null;
+ }
+
+ public void registerTerminals(Collection<TerminalSession> terminals) {
+ synchronized (this.terminals) {
+ this.terminals.addAll(terminals);
+ }
+ }
}
diff --git a/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/service/rmi/trace/TraceRmiPlugin.java b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/service/rmi/trace/TraceRmiPlugin.java
index 089a148579..c776a1929e 100644
--- a/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/service/rmi/trace/TraceRmiPlugin.java
+++ b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/service/rmi/trace/TraceRmiPlugin.java
@@ -23,8 +23,7 @@ import ghidra.app.plugin.PluginCategoryNames;
import ghidra.app.plugin.core.debug.DebuggerPluginPackage;
import ghidra.app.plugin.core.debug.event.TraceActivatedPluginEvent;
import ghidra.app.plugin.core.debug.event.TraceClosedPluginEvent;
-import ghidra.app.services.DebuggerTargetService;
-import ghidra.app.services.TraceRmiService;
+import ghidra.app.services.*;
import ghidra.debug.api.tracermi.TraceRmiConnection;
import ghidra.framework.plugintool.*;
import ghidra.framework.plugintool.AutoService.Wiring;
@@ -52,8 +51,9 @@ import ghidra.util.task.TaskMonitor;
},
servicesProvided = {
TraceRmiService.class,
+ InternalTraceRmiService.class,
})
-public class TraceRmiPlugin extends Plugin implements TraceRmiService {
+public class TraceRmiPlugin extends Plugin implements InternalTraceRmiService {
private static final int DEFAULT_PORT = 15432;
@AutoServiceConsumed
diff --git a/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/service/rmi/trace/TraceRmiTarget.java b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/service/rmi/trace/TraceRmiTarget.java
index 312d53c439..f85884fbdb 100644
--- a/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/service/rmi/trace/TraceRmiTarget.java
+++ b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/service/rmi/trace/TraceRmiTarget.java
@@ -17,10 +17,8 @@ package ghidra.app.plugin.core.debug.service.rmi.trace;
import java.io.IOException;
import java.util.*;
-import java.util.Map.Entry;
import java.util.concurrent.CompletableFuture;
-import java.util.function.BooleanSupplier;
-import java.util.function.Predicate;
+import java.util.function.*;
import java.util.stream.Collectors;
import org.apache.commons.lang3.exception.ExceptionUtils;
@@ -28,7 +26,9 @@ import org.apache.commons.lang3.exception.ExceptionUtils;
import docking.ActionContext;
import ghidra.app.context.ProgramLocationActionContext;
import ghidra.app.plugin.core.debug.gui.model.DebuggerObjectActionContext;
+import ghidra.app.plugin.core.debug.gui.tracermi.RemoteMethodInvocationDialog;
import ghidra.app.plugin.core.debug.service.target.AbstractTarget;
+import ghidra.app.services.DebuggerConsoleService;
import ghidra.app.services.DebuggerTraceManagerService;
import ghidra.async.*;
import ghidra.dbg.target.*;
@@ -49,7 +49,9 @@ import ghidra.program.model.lang.RegisterValue;
import ghidra.trace.model.Lifespan;
import ghidra.trace.model.Trace;
import ghidra.trace.model.breakpoint.*;
+import ghidra.trace.model.breakpoint.TraceBreakpointKind.TraceBreakpointKindSet;
import ghidra.trace.model.guest.TracePlatform;
+import ghidra.trace.model.memory.TraceObjectMemoryRegion;
import ghidra.trace.model.stack.*;
import ghidra.trace.model.target.*;
import ghidra.trace.model.thread.TraceObjectThread;
@@ -63,10 +65,12 @@ public class TraceRmiTarget extends AbstractTarget {
private static final String BREAK_READ = "breakRead";
private static final String BREAK_WRITE = "breakWrite";
private static final String BREAK_ACCESS = "breakAccess";
+
private final TraceRmiConnection connection;
private final Trace trace;
private final Matches matches = new Matches();
+ private final RequestCaches requestCaches = new RequestCaches();
private final Set<TraceBreakpointKind> supportedBreakpointKinds;
public TraceRmiTarget(PluginTool tool, TraceRmiConnection connection, Trace trace) {
@@ -78,7 +82,7 @@ public class TraceRmiTarget extends AbstractTarget {
@Override
public boolean isValid() {
- return !connection.isClosed();
+ return !connection.isClosed() && connection.isTarget(trace);
}
@Override
@@ -88,7 +92,12 @@ public class TraceRmiTarget extends AbstractTarget {
@Override
public long getSnap() {
- return connection.getLastSnapshot(trace);
+ try {
+ return connection.getLastSnapshot(trace);
+ }
+ catch (NoSuchElementException e) {
+ return 0;
+ }
}
@Override
@@ -122,52 +131,72 @@ public class TraceRmiTarget extends AbstractTarget {
.orElse(null);
}
- protected TraceObject findObject(ActionContext context) {
- if (context instanceof DebuggerObjectActionContext ctx) {
- List<TraceObjectValue> values = ctx.getObjectValues();
- if (values.size() == 1) {
- TraceObjectValue ov = values.get(0);
- if (ov.isObject()) {
- return ov.getChild();
+ protected TraceObject findObject(ActionContext context, boolean allowContextObject,
+ boolean allowCoordsObject) {
+ if (allowContextObject) {
+ if (context instanceof DebuggerObjectActionContext ctx) {
+ List<TraceObjectValue> values = ctx.getObjectValues();
+ if (values.size() == 1) {
+ TraceObjectValue ov = values.get(0);
+ if (ov.isObject()) {
+ return ov.getChild();
+ }
}
}
}
- DebuggerTraceManagerService traceManager =
- tool.getService(DebuggerTraceManagerService.class);
- if (traceManager != null) {
- return traceManager.getCurrentObject();
+ if (allowCoordsObject) {
+ DebuggerTraceManagerService traceManager =
+ tool.getService(DebuggerTraceManagerService.class);
+ if (traceManager == null) {
+ return null;
+ }
+ return traceManager.getCurrentFor(trace).getObject();
}
return null;
}
- protected Object findArgumentForSchema(ActionContext context, TargetObjectSchema schema) {
+ protected Object findArgumentForSchema(ActionContext context, TargetObjectSchema schema,
+ boolean allowContextObject, boolean allowCoordsObject, boolean allowSuitableObject) {
if (schema instanceof EnumerableTargetObjectSchema prim) {
return switch (prim) {
- case OBJECT -> findObject(context);
+ case OBJECT -> findObject(context, allowContextObject, allowCoordsObject);
case ADDRESS -> findAddress(context);
case RANGE -> findRange(context);
default -> null;
};
}
- TraceObject object = findObject(context);
+ TraceObject object = findObject(context, allowContextObject, allowCoordsObject);
if (object == null) {
return null;
}
- return object.querySuitableSchema(schema);
+ if (allowSuitableObject) {
+ return object.querySuitableSchema(schema);
+ }
+ if (object.getTargetSchema() == schema) {
+ return object;
+ }
+ return null;
}
private enum Missing {
MISSING; // The argument requires a prompt
}
- protected Object findArgument(RemoteParameter parameter, ActionContext context) {
+ protected Object findArgument(RemoteParameter parameter, ActionContext context,
+ boolean allowContextObject, boolean allowCoordsObject, boolean allowSuitableObject) {
SchemaName type = parameter.type();
- TargetObjectSchema schema = getSchemaContext().getSchema(type);
+ SchemaContext ctx = getSchemaContext();
+ if (ctx == null) {
+ Msg.trace(this, "No root schema, yet: " + trace);
+ return null;
+ }
+ TargetObjectSchema schema = ctx.getSchema(type);
if (schema == null) {
Msg.error(this, "Schema " + type + " not in trace! " + trace);
return null;
}
- Object arg = findArgumentForSchema(context, schema);
+ Object arg = findArgumentForSchema(context, schema, allowContextObject, allowCoordsObject,
+ allowSuitableObject);
if (arg != null) {
return arg;
}
@@ -177,27 +206,46 @@ public class TraceRmiTarget extends AbstractTarget {
return Missing.MISSING;
}
- protected Map<String, Object> collectArguments(RemoteMethod method, ActionContext context) {
- return method.parameters()
- .entrySet()
- .stream()
- .collect(
- Collectors.toMap(Entry::getKey, e -> findArgument(e.getValue(), context)));
+ protected Map<String, Object> collectArguments(RemoteMethod method, ActionContext context,
+ boolean allowContextObject, boolean allowCoordsObject, boolean allowSuitableObject) {
+ Map<String, Object> args = new HashMap<>();
+ for (RemoteParameter param : method.parameters().values()) {
+ Object found = findArgument(param, context, allowContextObject, allowCoordsObject,
+ allowSuitableObject);
+ if (found != null) {
+ args.put(param.name(), found);
+ }
+ }
+ return args;
}
private TargetExecutionState getStateOf(TraceObject object) {
- return object.getExecutionState(getSnap());
+ try {
+ return object.getExecutionState(getSnap());
+ }
+ catch (NoSuchElementException e) {
+ return TargetExecutionState.TERMINATED;
+ }
}
- private boolean stateOrNull(TraceObject object,
+ private boolean whenState(TraceObject object,
Predicate<TargetExecutionState> predicate) {
- TargetExecutionState state = getStateOf(object);
- return state == null || predicate.test(state);
+ try {
+ TargetExecutionState state = getStateOf(object);
+ return state == null || predicate.test(state);
+ }
+ catch (Exception e) {
+ Msg.error(this, "Could not get state: " + e);
+ return false;
+ }
}
protected BooleanSupplier chooseEnabler(RemoteMethod method, Map<String, Object> args) {
ActionName name = method.action();
SchemaContext ctx = getSchemaContext();
+ if (ctx == null) {
+ return () -> true;
+ }
RemoteParameter firstParam = method.parameters()
.values()
.stream()
@@ -207,7 +255,12 @@ public class TraceRmiTarget extends AbstractTarget {
if (firstParam == null) {
return () -> true;
}
- TraceObject firstArg = (TraceObject) args.get(firstParam.name());
+ Object firstArg = args.get(firstParam.name());
+ if (firstArg == null || firstArg == Missing.MISSING) {
+ Msg.trace(this, "MISSING first argument for " + method + "(" + firstParam + ")");
+ return () -> false;
+ }
+ TraceObject obj = (TraceObject) firstArg;
if (ActionName.RESUME.equals(name) ||
ActionName.STEP_BACK.equals(name) ||
ActionName.STEP_EXT.equals(name) ||
@@ -215,29 +268,74 @@ public class TraceRmiTarget extends AbstractTarget {
ActionName.STEP_OUT.equals(name) ||
ActionName.STEP_OVER.equals(name) ||
ActionName.STEP_SKIP.equals(name)) {
- return () -> stateOrNull(firstArg, TargetExecutionState::isStopped);
+ return () -> whenState(obj, state -> state != null && state.isStopped());
}
else if (ActionName.INTERRUPT.equals(name)) {
- return () -> stateOrNull(firstArg, TargetExecutionState::isRunning);
+ return () -> whenState(obj, state -> state == null || state.isRunning());
}
else if (ActionName.KILL.equals(name)) {
- return () -> stateOrNull(firstArg, TargetExecutionState::isAlive);
+ return () -> whenState(obj, state -> state == null || state.isAlive());
}
return () -> true;
}
- protected ActionEntry createEntry(RemoteMethod method, ActionContext context) {
- Map<String, Object> args = collectArguments(method, context);
+ private Map<String, Object> promptArgs(RemoteMethod method, Map<String, Object> defaults) {
+ SchemaContext ctx = getSchemaContext();
+ RemoteMethodInvocationDialog dialog = new RemoteMethodInvocationDialog(tool,
+ method.name(), method.name(), null);
+ while (true) {
+ for (RemoteParameter param : method.parameters().values()) {
+ Object val = defaults.get(param.name());
+ if (val != null) {
+ Class<?> type = ctx.getSchema(param.type()).getType();
+ dialog.setMemorizedArgument(param.name(), type.asSubclass(Object.class),
+ val);
+ }
+ }
+ Map<String, Object> args = dialog.promptArguments(ctx, method.parameters(), defaults);
+ if (args == null) {
+ // Cancelled
+ return null;
+ }
+ return args;
+ }
+ }
+
+ private CompletableFuture<?> invokeMethod(boolean prompt, RemoteMethod method,
+ Map<String, Object> arguments) {
+ Map<String, Object> chosenArgs;
+ if (prompt) {
+ chosenArgs = promptArgs(method, arguments);
+ }
+ else {
+ chosenArgs = arguments;
+ }
+ return method.invokeAsync(chosenArgs).thenAccept(result -> {
+ DebuggerConsoleService consoleService =
+ tool.getService(DebuggerConsoleService.class);
+ Class<?> retType = getSchemaContext().getSchema(method.retType()).getType();
+ if (consoleService != null && retType != Void.class && retType != Object.class) {
+ consoleService.log(null, method.name() + " returned " + result);
+ }
+ }).toCompletableFuture();
+ }
+
+ protected ActionEntry createEntry(RemoteMethod method, ActionContext context,
+ boolean allowContextObject, boolean allowCoordsObject, boolean allowSuitableObject) {
+ Map<String, Object> args = collectArguments(method, context, allowContextObject,
+ allowCoordsObject, allowSuitableObject);
boolean requiresPrompt = args.values().contains(Missing.MISSING);
return new ActionEntry(method.name(), method.action(), method.description(), requiresPrompt,
- chooseEnabler(method, args), () -> method.invokeAsync(args).toCompletableFuture());
+ chooseEnabler(method, args), prompt -> invokeMethod(prompt, method, args));
}
protected Map<String, ActionEntry> collectFromMethods(Collection<RemoteMethod> methods,
- ActionContext context) {
+ ActionContext context, boolean allowContextObject, boolean allowCoordsObject,
+ boolean allowSuitableObject) {
Map<String, ActionEntry> result = new HashMap<>();
for (RemoteMethod m : methods) {
- result.put(m.name(), createEntry(m, context));
+ result.put(m.name(), createEntry(m, context, allowContextObject, allowCoordsObject,
+ allowSuitableObject));
}
return result;
}
@@ -246,7 +344,15 @@ public class TraceRmiTarget extends AbstractTarget {
return method.parameters()
.values()
.stream()
- .filter(p -> ctx.getSchema(p.type()).getType() == Address.class)
+ .filter(p -> {
+ TargetObjectSchema schema = ctx.getSchemaOrNull(p.type());
+ if (schema == null) {
+ Msg.error(this,
+ "Method " + method + " refers to invalid schema name: " + p.type());
+ return false;
+ }
+ return schema.getType() == Address.class;
+ })
.count() == 1;
}
@@ -258,18 +364,20 @@ public class TraceRmiTarget extends AbstractTarget {
if (!isAddressMethod(m, ctx)) {
continue;
}
- result.put(m.name(), createEntry(m, context));
+ result.put(m.name(), createEntry(m, context, true, true, true));
}
return result;
}
@Override
protected Map<String, ActionEntry> collectAllActions(ActionContext context) {
- return collectFromMethods(connection.getMethods().all().values(), context);
+ return collectFromMethods(connection.getMethods().all().values(), context, true, false,
+ false);
}
protected Map<String, ActionEntry> collectByName(ActionName name, ActionContext context) {
- return collectFromMethods(connection.getMethods().getByAction(name), context);
+ return collectFromMethods(connection.getMethods().getByAction(name), context, false, true,
+ true);
}
@Override
@@ -311,7 +419,7 @@ public class TraceRmiTarget extends AbstractTarget {
public boolean isSupportsFocus() {
TargetObjectSchema schema = trace.getObjectManager().getRootSchema();
if (schema == null) {
- Msg.warn(this, "Checked for focus support before root schema is available");
+ Msg.trace(this, "Checked for focus support before root schema is available");
return false;
}
return schema
@@ -370,10 +478,17 @@ public class TraceRmiTarget extends AbstractTarget {
}
}
- protected static boolean typeMatches(RemoteParameter param, SchemaContext ctx, Class<?> type) {
- TargetObjectSchema sch = ctx.getSchema(param.type());
+ protected static boolean typeMatches(RemoteMethod method, RemoteParameter param,
+ SchemaContext ctx, Class<?> type) {
+ TargetObjectSchema sch = ctx.getSchemaOrNull(param.type());
+ if (sch == null) {
+ throw new RuntimeException(
+ "The parameter '%s' of method '%s' refers to a non-existent schema '%s'"
+ .formatted(param.name(), method.name(), param.type()));
+ }
if (type == TargetObject.class) {
- return sch.getType() == type;
+ // The method cannot impose any further restriction. It must accept any object.
+ return sch == EnumerableTargetObjectSchema.OBJECT;
}
else if (TargetObject.class.isAssignableFrom(type)) {
return sch.getInterfaces().contains(type);
@@ -389,13 +504,28 @@ public class TraceRmiTarget extends AbstractTarget {
RemoteParameter find(RemoteMethod method, SchemaContext ctx);
}
+ record SchemaParamSpec(String name, SchemaName schema) implements ParamSpec {
+ @Override
+ public RemoteParameter find(RemoteMethod method, SchemaContext ctx) {
+ List<RemoteParameter> withType = method.parameters()
+ .values()
+ .stream()
+ .filter(p -> schema.equals(p.type()))
+ .toList();
+ if (withType.size() != 1) {
+ return null;
+ }
+ return withType.get(0);
+ }
+ }
+
record TypeParamSpec(String name, Class<?> type) implements ParamSpec {
@Override
public RemoteParameter find(RemoteMethod method, SchemaContext ctx) {
List<RemoteParameter> withType = method.parameters()
.values()
.stream()
- .filter(p -> typeMatches(p, ctx, type))
+ .filter(p -> typeMatches(method, p, ctx, type))
.toList();
if (withType.size() != 1) {
return null;
@@ -408,16 +538,15 @@ public class TraceRmiTarget extends AbstractTarget {
@Override
public RemoteParameter find(RemoteMethod method, SchemaContext ctx) {
RemoteParameter param = method.parameters().get(name);
- if (typeMatches(param, ctx, type)) {
+ if (param != null && typeMatches(method, param, ctx, type)) {
return param;
}
return null;
}
}
- @SafeVarargs
- protected static <T extends MethodMatcher> List<T> matchers(T... list) {
- List<T> result = List.of(list);
+ protected static <T extends MethodMatcher> List<T> matchers(List<T> list) {
+ List<T> result = new ArrayList<>(list);
result.sort(Comparator.comparing(MethodMatcher::score).reversed());
if (result.isEmpty()) {
throw new AssertionError("empty matchers list?");
@@ -429,33 +558,60 @@ public class TraceRmiTarget extends AbstractTarget {
throw new AssertionError("duplicate scores: " + curScore);
}
}
- return result;
+ return List.copyOf(result);
+ }
+
+ @SafeVarargs
+ protected static <T extends MethodMatcher> List<T> matchers(T... list) {
+ return matchers(Arrays.asList(list));
}
record ActivateMatcher(int score, List<ParamSpec> spec) implements MethodMatcher {
- static final ActivateMatcher HAS_FOCUS_TIME = new ActivateMatcher(3, List.of(
- new TypeParamSpec("focus", TargetObject.class),
- new TypeParamSpec("time", String.class)));
- static final ActivateMatcher HAS_FOCUS_SNAP = new ActivateMatcher(2, List.of(
- new TypeParamSpec("focus", TargetObject.class),
- new TypeParamSpec("snap", Long.class)));
- static final ActivateMatcher HAS_FOCUS = new ActivateMatcher(1, List.of(
- new TypeParamSpec("focus", TargetObject.class)));
- static final List<ActivateMatcher> ALL =
- matchers(HAS_FOCUS_TIME, HAS_FOCUS_SNAP, HAS_FOCUS);
+ static List<ActivateMatcher> makeAllFor(int addScore, ParamSpec focusSpec) {
+ ActivateMatcher hasFocusTime = new ActivateMatcher(addScore + 3, List.of(
+ focusSpec,
+ new TypeParamSpec("time", String.class)));
+ ActivateMatcher hasFocusSnap = new ActivateMatcher(addScore + 2, List.of(
+ focusSpec,
+ new TypeParamSpec("snap", Long.class)));
+ ActivateMatcher hasFocus = new ActivateMatcher(addScore + 1, List.of(
+ focusSpec));
+ return matchers(hasFocusTime, hasFocusSnap, hasFocus);
+ }
+
+ static List<ActivateMatcher> makeBySpecificity(TargetObjectSchema rootSchema,
+ TraceObjectKeyPath path) {
+ List<ActivateMatcher> result = new ArrayList<>();
+ List<String> keyList = path.getKeyList();
+ result.addAll(makeAllFor((keyList.size() + 1) * 3,
+ new TypeParamSpec("focus", TargetObject.class)));
+ List<TargetObjectSchema> schemas = rootSchema.getSuccessorSchemas(keyList);
+ for (int i = keyList.size(); i > 0; i--) { // Inclusive on both ends
+ result.addAll(
+ makeAllFor(i * 3, new SchemaParamSpec("focus", schemas.get(i).getName())));
+ }
+ return matchers(result);
+ }
}
record ReadMemMatcher(int score, List<ParamSpec> spec) implements MethodMatcher {
+ static final ReadMemMatcher HAS_PROC_RANGE = new ReadMemMatcher(2, List.of(
+ new TypeParamSpec("process", TargetProcess.class),
+ new TypeParamSpec("range", AddressRange.class)));
static final ReadMemMatcher HAS_RANGE = new ReadMemMatcher(1, List.of(
new TypeParamSpec("range", AddressRange.class)));
- static final List<ReadMemMatcher> ALL = matchers(HAS_RANGE);
+ static final List<ReadMemMatcher> ALL = matchers(HAS_PROC_RANGE, HAS_RANGE);
}
record WriteMemMatcher(int score, List<ParamSpec> spec) implements MethodMatcher {
- static final WriteMemMatcher HAS_RANGE = new WriteMemMatcher(1, List.of(
+ static final WriteMemMatcher HAS_PROC_START_DATA = new WriteMemMatcher(2, List.of(
+ new TypeParamSpec("process", TargetProcess.class),
+ new TypeParamSpec("start", Address.class),
+ new TypeParamSpec("data", byte[].class)));
+ static final WriteMemMatcher HAS_START_DATA = new WriteMemMatcher(1, List.of(
new TypeParamSpec("start", Address.class),
new TypeParamSpec("data", byte[].class)));
- static final List<WriteMemMatcher> ALL = matchers(HAS_RANGE);
+ static final List<WriteMemMatcher> ALL = matchers(HAS_PROC_START_DATA, HAS_START_DATA);
}
record ReadRegsMatcher(int score, List<ParamSpec> spec) implements MethodMatcher {
@@ -469,10 +625,14 @@ public class TraceRmiTarget extends AbstractTarget {
}
record WriteRegMatcher(int score, List<ParamSpec> spec) implements MethodMatcher {
- static final WriteRegMatcher HAS_FRAME_NAME_VALUE = new WriteRegMatcher(2, List.of(
+ static final WriteRegMatcher HAS_FRAME_NAME_VALUE = new WriteRegMatcher(3, List.of(
new TypeParamSpec("frame", TargetStackFrame.class),
new TypeParamSpec("name", String.class),
new TypeParamSpec("value", byte[].class)));
+ static final WriteRegMatcher HAS_THREAD_NAME_VALUE = new WriteRegMatcher(2, List.of(
+ new TypeParamSpec("thread", TargetThread.class),
+ new TypeParamSpec("name", String.class),
+ new TypeParamSpec("value", byte[].class)));
static final WriteRegMatcher HAS_REG_VALUE = new WriteRegMatcher(1, List.of(
new TypeParamSpec("register", TargetRegister.class),
new TypeParamSpec("value", byte[].class)));
@@ -480,6 +640,22 @@ public class TraceRmiTarget extends AbstractTarget {
}
record BreakExecMatcher(int score, List<ParamSpec> spec) implements MethodMatcher {
+ static final BreakExecMatcher HAS_PROC_ADDR_COND_CMDS = new BreakExecMatcher(8, List.of(
+ new TypeParamSpec("process", TargetProcess.class),
+ new TypeParamSpec("address", Address.class),
+ new NameParamSpec("condition", String.class),
+ new NameParamSpec("commands", String.class)));
+ static final BreakExecMatcher HAS_PROC_ADDR_COND = new BreakExecMatcher(7, List.of(
+ new TypeParamSpec("process", TargetProcess.class),
+ new TypeParamSpec("address", Address.class),
+ new NameParamSpec("condition", String.class)));
+ static final BreakExecMatcher HAS_PROC_ADDR_CMDS = new BreakExecMatcher(6, List.of(
+ new TypeParamSpec("process", TargetProcess.class),
+ new TypeParamSpec("address", Address.class),
+ new NameParamSpec("commands", String.class)));
+ static final BreakExecMatcher HAS_PROC_ADDR = new BreakExecMatcher(5, List.of(
+ new TypeParamSpec("process", TargetProcess.class),
+ new TypeParamSpec("address", Address.class)));
static final BreakExecMatcher HAS_ADDR_COND_CMDS = new BreakExecMatcher(4, List.of(
new TypeParamSpec("address", Address.class),
new NameParamSpec("condition", String.class),
@@ -493,10 +669,28 @@ public class TraceRmiTarget extends AbstractTarget {
static final BreakExecMatcher HAS_ADDR = new BreakExecMatcher(1, List.of(
new TypeParamSpec("address", Address.class)));
static final List<BreakExecMatcher> ALL =
- matchers(HAS_ADDR_COND_CMDS, HAS_ADDR_COND, HAS_ADDR_CMDS, HAS_ADDR);
+ matchers(HAS_PROC_ADDR_COND_CMDS, HAS_PROC_ADDR_COND, HAS_PROC_ADDR_CMDS, HAS_PROC_ADDR,
+ HAS_ADDR_COND_CMDS, HAS_ADDR_COND, HAS_ADDR_CMDS, HAS_ADDR);
}
+ // TODO: Probably need a better way to deal with optional requirements
record BreakAccMatcher(int score, List<ParamSpec> spec) implements MethodMatcher {
+ static final BreakAccMatcher HAS_PROC_RNG_COND_CMDS = new BreakAccMatcher(8, List.of(
+ new TypeParamSpec("process", TargetProcess.class),
+ new TypeParamSpec("range", AddressRange.class),
+ new NameParamSpec("condition", String.class),
+ new NameParamSpec("commands", String.class)));
+ static final BreakAccMatcher HAS_PROC_RNG_COND = new BreakAccMatcher(7, List.of(
+ new TypeParamSpec("process", TargetProcess.class),
+ new TypeParamSpec("range", AddressRange.class),
+ new NameParamSpec("condition", String.class)));
+ static final BreakAccMatcher HAS_PROC_RNG_CMDS = new BreakAccMatcher(6, List.of(
+ new TypeParamSpec("process", TargetProcess.class),
+ new TypeParamSpec("range", AddressRange.class),
+ new NameParamSpec("commands", String.class)));
+ static final BreakAccMatcher HAS_PROC_RNG = new BreakAccMatcher(5, List.of(
+ new TypeParamSpec("process", TargetProcess.class),
+ new TypeParamSpec("range", AddressRange.class)));
static final BreakAccMatcher HAS_RNG_COND_CMDS = new BreakAccMatcher(4, List.of(
new TypeParamSpec("range", AddressRange.class),
new NameParamSpec("condition", String.class),
@@ -510,7 +704,8 @@ public class TraceRmiTarget extends AbstractTarget {
static final BreakAccMatcher HAS_RNG = new BreakAccMatcher(1, List.of(
new TypeParamSpec("range", AddressRange.class)));
static final List<BreakAccMatcher> ALL =
- matchers(HAS_RNG_COND_CMDS, HAS_RNG_COND, HAS_RNG_CMDS, HAS_RNG);
+ matchers(HAS_PROC_RNG_COND_CMDS, HAS_PROC_RNG_COND, HAS_PROC_RNG_CMDS, HAS_PROC_RNG,
+ HAS_RNG_COND_CMDS, HAS_RNG_COND, HAS_RNG_CMDS, HAS_RNG);
}
record DelBreakMatcher(int score, List<ParamSpec> spec) implements MethodMatcher {
@@ -536,6 +731,11 @@ public class TraceRmiTarget extends AbstractTarget {
protected class Matches {
private final Map<String, MatchedMethod> map = new HashMap<>();
+ public MatchedMethod getBest(String name, ActionName action,
+ Supplier<List<? extends MethodMatcher>> preferredSupplier) {
+ return map.computeIfAbsent(name, n -> chooseBest(action, preferredSupplier.get()));
+ }
+
public MatchedMethod getBest(String name, ActionName action,
List<? extends MethodMatcher> preferred) {
return map.computeIfAbsent(name, n -> chooseBest(action, preferred));
@@ -554,24 +754,57 @@ public class TraceRmiTarget extends AbstractTarget {
.max(MatchedMethod::compareTo)
.orElse(null);
if (best == null) {
- Msg.error(this, "No suitable " + name + " method");
+ Msg.debug(this, "No suitable " + name + " method");
}
return best;
}
}
+ protected static class RequestCaches {
+ final Map<TraceObject, CompletableFuture<Void>> readRegs = new HashMap<>();
+ final Map<Address, CompletableFuture<Void>> readBlock = new HashMap<>();
+
+ public synchronized void invalidate() {
+ readRegs.clear();
+ readBlock.clear();
+ }
+
+ public synchronized CompletableFuture<Void> readRegs(TraceObject obj, RemoteMethod method,
+ Map<String, Object> args) {
+ return readRegs.computeIfAbsent(obj,
+ o -> method.invokeAsync(args).toCompletableFuture().thenApply(__ -> null));
+ }
+
+ public synchronized CompletableFuture<Void> readBlock(Address min, RemoteMethod method,
+ Map<String, Object> args) {
+ return readBlock.computeIfAbsent(min,
+ m -> method.invokeAsync(args).toCompletableFuture().thenApply(__ -> null));
+ }
+ }
+
@Override
public CompletableFuture<Void> activateAsync(DebuggerCoordinates prev,
DebuggerCoordinates coords) {
- MatchedMethod activate =
- matches.getBest("activate", ActionName.ACTIVATE, ActivateMatcher.ALL);
+ if (prev.getSnap() != coords.getSnap()) {
+ requestCaches.invalidate();
+ }
+ TraceObject object = coords.getObject();
+ if (object == null) {
+ return AsyncUtils.nil();
+ }
+
+ SchemaName name = object.getTargetSchema().getName();
+ MatchedMethod activate = matches.getBest("activate_" + name, ActionName.ACTIVATE,
+ () -> ActivateMatcher.makeBySpecificity(trace.getObjectManager().getRootSchema(),
+ object.getCanonicalPath()));
if (activate == null) {
return AsyncUtils.nil();
}
Map<String, Object> args = new HashMap<>();
RemoteParameter paramFocus = activate.params.get("focus");
- args.put(paramFocus.name(), coords.getObject());
+ args.put(paramFocus.name(),
+ object.querySuitableSchema(getSchemaContext().getSchema(paramFocus.type())));
RemoteParameter paramTime = activate.params.get("time");
if (paramTime != null) {
args.put(paramTime.name(), coords.getTime().toString());
@@ -605,7 +838,29 @@ public class TraceRmiTarget extends AbstractTarget {
}
protected SchemaContext getSchemaContext() {
- return trace.getObjectManager().getRootSchema().getContext();
+ TargetObjectSchema rootSchema = trace.getObjectManager().getRootSchema();
+ if (rootSchema == null) {
+ return null;
+ }
+ return rootSchema.getContext();
+ }
+
+ protected TraceObject getProcessForSpace(AddressSpace space) {
+ for (TraceObjectValue objVal : trace.getObjectManager()
+ .getValuesIntersecting(Lifespan.at(getSnap()),
+ new AddressRangeImpl(space.getMinAddress(), space.getMaxAddress()))) {
+ if (!TargetMemoryRegion.RANGE_ATTRIBUTE_NAME.equals(objVal.getEntryKey())) {
+ continue;
+ }
+ TraceObject obj = objVal.getParent();
+ if (!obj.getInterfaces().contains(TraceObjectMemoryRegion.class)) {
+ continue;
+ }
+ return obj.queryCanonicalAncestorsTargetInterface(TargetProcess.class)
+ .findFirst()
+ .orElse(null);
+ }
+ return null;
}
@Override
@@ -619,6 +874,15 @@ public class TraceRmiTarget extends AbstractTarget {
return AsyncUtils.nil();
}
RemoteParameter paramRange = readMem.params.get("range");
+ RemoteParameter paramProcess = readMem.params.get("process");
+
+ final Map<AddressSpace, TraceObject> procsBySpace;
+ if (paramProcess != null) {
+ procsBySpace = new HashMap<>();
+ }
+ else {
+ procsBySpace = null;
+ }
int total = 0;
AddressSetView quantized = quantize(set);
@@ -630,10 +894,32 @@ public class TraceRmiTarget extends AbstractTarget {
// NOTE: Don't read in parallel, lest we overload the connection
return AsyncUtils.each(TypeSpec.VOID, quantized.iterator(), (r, loop) -> {
AddressRangeChunker blocks = new AddressRangeChunker(r, BLOCK_SIZE);
+ if (r.getAddressSpace().isRegisterSpace()) {
+ Msg.warn(this, "Request to read registers via readMemory: " + r + ". Ignoring.");
+ loop.repeatWhile(!monitor.isCancelled());
+ return;
+ }
AsyncUtils.each(TypeSpec.VOID, blocks.iterator(), (blk, inner) -> {
monitor.incrementProgress(1);
- RemoteAsyncResult future =
- readMem.method.invokeAsync(Map.of(paramRange.name(), blk));
+ final Map<String, Object> args;
+ if (paramProcess != null) {
+ TraceObject process = procsBySpace.computeIfAbsent(blk.getAddressSpace(),
+ this::getProcessForSpace);
+ if (process == null) {
+ Msg.warn(this, "Cannot find process containing " + blk.getMinAddress());
+ inner.repeatWhile(!monitor.isCancelled());
+ return;
+ }
+ args = Map.ofEntries(
+ Map.entry(paramProcess.name(), process),
+ Map.entry(paramRange.name(), blk));
+ }
+ else {
+ args = Map.ofEntries(
+ Map.entry(paramRange.name(), blk));
+ }
+ CompletableFuture<Void> future =
+ requestCaches.readBlock(blk.getMinAddress(), readMem.method, args);
future.exceptionally(e -> {
Msg.error(this, "Could not read " + blk + ": " + e);
return null; // Continue looping on errors
@@ -652,6 +938,14 @@ public class TraceRmiTarget extends AbstractTarget {
Map<String, Object> args = new HashMap<>();
args.put(writeMem.params.get("start").name(), address);
args.put(writeMem.params.get("data").name(), data);
+ RemoteParameter paramProcess = writeMem.params.get("process");
+ if (paramProcess != null) {
+ TraceObject process = getProcessForSpace(address.getAddressSpace());
+ if (process == null) {
+ throw new IllegalStateException("Cannot find process containing " + address);
+ }
+ args.put(paramProcess.name(), process);
+ }
return writeMem.method.invokeAsync(args).toCompletableFuture().thenApply(__ -> null);
}
@@ -668,11 +962,15 @@ public class TraceRmiTarget extends AbstractTarget {
return AsyncUtils.nil();
}
TraceObject container = tot.getObject().queryRegisterContainer(frame);
+ if (container == null) {
+ Msg.error(this,
+ "Cannot find register container for thread,frame: " + thread + "," + frame);
+ return AsyncUtils.nil();
+ }
RemoteParameter paramContainer = readRegs.params.get("container");
if (paramContainer != null) {
- return readRegs.method.invokeAsync(Map.of(paramContainer.name(), container))
- .toCompletableFuture()
- .thenApply(__ -> null);
+ return requestCaches.readRegs(container, readRegs.method, Map.of(
+ paramContainer.name(), container));
}
Set<String> keys = new HashSet<>();
for (Register r : registers) {
@@ -695,8 +993,8 @@ public class TraceRmiTarget extends AbstractTarget {
.collect(Collectors.toSet());
AsyncFence fence = new AsyncFence();
banks.stream().forEach(b -> {
- fence.include(
- readRegs.method.invokeAsync(Map.of(paramBank.name(), b)).toCompletableFuture());
+ fence.include(requestCaches.readRegs(b, readRegs.method, Map.of(
+ paramBank.name(), b)));
});
return fence.ready();
}
@@ -704,8 +1002,8 @@ public class TraceRmiTarget extends AbstractTarget {
if (paramRegister != null) {
AsyncFence fence = new AsyncFence();
regs.stream().forEach(r -> {
- fence.include(readRegs.method.invokeAsync(Map.of(paramRegister.name(), r))
- .toCompletableFuture());
+ fence.include(requestCaches.readRegs(r, readRegs.method, Map.of(
+ paramRegister.name(), r)));
});
return fence.ready();
}
@@ -733,7 +1031,7 @@ public class TraceRmiTarget extends AbstractTarget {
@Override
public CompletableFuture<Void> writeRegisterAsync(TracePlatform platform, TraceThread thread,
- int frame, RegisterValue value) {
+ int frameLevel, RegisterValue value) {
MatchedMethod writeReg =
matches.getBest("writeReg", ActionName.WRITE_REG, WriteRegMatcher.ALL);
if (writeReg == null) {
@@ -748,24 +1046,38 @@ public class TraceRmiTarget extends AbstractTarget {
byte[] data =
Utils.bigIntegerToBytes(value.getUnsignedValue(), register.getMinimumByteSize(), true);
+ RemoteParameter paramThread = writeReg.params.get("thread");
+ if (paramThread != null) {
+ return writeReg.method.invokeAsync(Map.ofEntries(
+ Map.entry(paramThread.name(), tot.getObject()),
+ Map.entry(writeReg.params.get("name").name(), regName),
+ Map.entry(writeReg.params.get("value").name(), data)))
+ .toCompletableFuture()
+ .thenApply(__ -> null);
+ }
+
RemoteParameter paramFrame = writeReg.params.get("frame");
if (paramFrame != null) {
TraceStack stack = trace.getStackManager().getLatestStack(thread, getSnap());
- TraceStackFrame frameObj = stack.getFrame(frame, false);
+ TraceStackFrame frame = stack.getFrame(frameLevel, false);
+ if (!(frame instanceof TraceObjectStackFrame tof)) {
+ Msg.error(this, "Non-object trace with TraceRmi!");
+ return AsyncUtils.nil();
+ }
return writeReg.method.invokeAsync(Map.ofEntries(
- Map.entry(paramFrame.name(), frameObj),
+ Map.entry(paramFrame.name(), tof.getObject()),
Map.entry(writeReg.params.get("name").name(), regName),
- Map.entry(writeReg.params.get("data").name(), data)))
+ Map.entry(writeReg.params.get("value").name(), data)))
.toCompletableFuture()
.thenApply(__ -> null);
}
- TraceObject regObj = findRegisterObject(tot, frame, regName);
+ TraceObject regObj = findRegisterObject(tot, frameLevel, regName);
if (regObj == null) {
return AsyncUtils.nil();
}
return writeReg.method.invokeAsync(Map.ofEntries(
Map.entry(writeReg.params.get("frame").name(), regObj),
- Map.entry(writeReg.params.get("data").name(), data)))
+ Map.entry(writeReg.params.get("value").name(), data)))
.toCompletableFuture()
.thenApply(__ -> null);
}
@@ -830,6 +1142,18 @@ public class TraceRmiTarget extends AbstractTarget {
protected void putOptionalBreakArgs(Map<String, Object> args, MatchedMethod brk,
String condition, String commands) {
+ RemoteParameter paramProc = brk.params.get("process");
+ if (paramProc != null) {
+ Object proc =
+ findArgumentForSchema(null, getSchemaContext().getSchema(paramProc.type()), true,
+ true, true);
+ if (proc == null) {
+ Msg.error(this, "Cannot find required process argument for " + brk.method);
+ }
+ else {
+ args.put(paramProc.name(), proc);
+ }
+ }
if (condition != null && !condition.isBlank()) {
RemoteParameter paramCond = brk.params.get("condition");
if (paramCond == null) {
@@ -920,21 +1244,21 @@ public class TraceRmiTarget extends AbstractTarget {
public CompletableFuture<Void> placeBreakpointAsync(AddressRange range,
Set<TraceBreakpointKind> kinds, String condition, String commands) {
Set<TraceBreakpointKind> copyKinds = Set.copyOf(kinds);
- if (copyKinds.equals(Set.of(TraceBreakpointKind.HW_EXECUTE))) {
+ if (copyKinds.equals(TraceBreakpointKindSet.HW_EXECUTE)) {
return placeHwExecBreakAsync(expectSingleAddr(range, TraceBreakpointKind.HW_EXECUTE),
condition, commands);
}
- if (copyKinds.equals(Set.of(TraceBreakpointKind.SW_EXECUTE))) {
+ if (copyKinds.equals(TraceBreakpointKindSet.SW_EXECUTE)) {
return placeSwExecBreakAsync(expectSingleAddr(range, TraceBreakpointKind.SW_EXECUTE),
condition, commands);
}
- if (copyKinds.equals(Set.of(TraceBreakpointKind.READ))) {
+ if (copyKinds.equals(TraceBreakpointKindSet.READ)) {
return placeReadBreakAsync(range, condition, commands);
}
- if (copyKinds.equals(Set.of(TraceBreakpointKind.WRITE))) {
+ if (copyKinds.equals(TraceBreakpointKindSet.WRITE)) {
return placeWriteBreakAsync(range, condition, commands);
}
- if (copyKinds.equals(Set.of(TraceBreakpointKind.READ, TraceBreakpointKind.WRITE))) {
+ if (copyKinds.equals(TraceBreakpointKindSet.ACCESS)) {
return placeAccessBreakAsync(range, condition, commands);
}
Msg.error(this, "Invalid kinds in combination: " + kinds);
@@ -986,20 +1310,22 @@ public class TraceRmiTarget extends AbstractTarget {
return AsyncUtils.nil();
}
return delBreak.method
- .invokeAsync(Map.of(delBreak.params.get("specification").name(), spec))
+ .invokeAsync(Map.of(delBreak.params.get("specification").name(), spec.getObject()))
.toCompletableFuture()
.thenApply(__ -> null);
}
+ // TODO: Would this make sense for any debugger? To delete individual locations?
protected CompletableFuture<Void> deleteBreakpointLocAsync(TraceObjectBreakpointLocation loc) {
MatchedMethod delBreak =
matches.getBest("delBreakLoc", ActionName.DELETE, DelBreakMatcher.ALL);
if (delBreak == null) {
- return AsyncUtils.nil();
+ Msg.debug(this, "Falling back to delete spec");
+ return deleteBreakpointSpecAsync(loc.getSpecification());
}
RemoteParameter paramLocation = delBreak.params.get("location");
if (paramLocation != null) {
- return delBreak.method.invokeAsync(Map.of(paramLocation.name(), loc))
+ return delBreak.method.invokeAsync(Map.of(paramLocation.name(), loc.getObject()))
.toCompletableFuture()
.thenApply(__ -> null);
}
@@ -1027,7 +1353,7 @@ public class TraceRmiTarget extends AbstractTarget {
}
return delBreak.method
.invokeAsync(Map.ofEntries(
- Map.entry(delBreak.params.get("specification").name(), spec),
+ Map.entry(delBreak.params.get("specification").name(), spec.getObject()),
Map.entry(delBreak.params.get("enabled").name(), enabled)))
.toCompletableFuture()
.thenApply(__ -> null);
@@ -1038,18 +1364,19 @@ public class TraceRmiTarget extends AbstractTarget {
MatchedMethod delBreak =
matches.getBest("toggleBreakLoc", ActionName.TOGGLE, ToggleBreakMatcher.ALL);
if (delBreak == null) {
- return AsyncUtils.nil();
+ Msg.debug(this, "Falling back to toggle spec");
+ return toggleBreakpointSpecAsync(loc.getSpecification(), enabled);
}
RemoteParameter paramLocation = delBreak.params.get("location");
if (paramLocation != null) {
return delBreak.method
.invokeAsync(Map.ofEntries(
- Map.entry(paramLocation.name(), loc),
+ Map.entry(paramLocation.name(), loc.getObject()),
Map.entry(delBreak.params.get("enabled").name(), enabled)))
.toCompletableFuture()
.thenApply(__ -> null);
}
- return deleteBreakpointSpecAsync(loc.getSpecification());
+ return toggleBreakpointSpecAsync(loc.getSpecification(), enabled);
}
@Override
@@ -1065,6 +1392,23 @@ public class TraceRmiTarget extends AbstractTarget {
return AsyncUtils.nil();
}
+ @Override
+ public CompletableFuture<Void> forceTerminateAsync() {
+ Map<String, ActionEntry> kills = collectKillActions(null);
+ for (ActionEntry kill : kills.values()) {
+ if (kill.requiresPrompt()) {
+ continue;
+ }
+ return kill.invokeAsync(false).handle((v, e) -> {
+ connection.forceCloseTrace(trace);
+ return null;
+ });
+ }
+ Msg.warn(this, "Cannot find way to gracefully kill. Forcing close regardless.");
+ connection.forceCloseTrace(trace);
+ return AsyncUtils.nil();
+ }
+
@Override
public CompletableFuture<Void> disconnectAsync() {
return CompletableFuture.runAsync(() -> {
diff --git a/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/services/InternalTraceRmiService.java b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/services/InternalTraceRmiService.java
new file mode 100644
index 0000000000..056f0d74a0
--- /dev/null
+++ b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/services/InternalTraceRmiService.java
@@ -0,0 +1,35 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.services;
+
+import java.io.IOException;
+import java.net.SocketAddress;
+
+import ghidra.app.plugin.core.debug.service.rmi.trace.DefaultTraceRmiAcceptor;
+import ghidra.app.plugin.core.debug.service.rmi.trace.TraceRmiHandler;
+import ghidra.debug.spi.tracermi.TraceRmiLaunchOpinion;
+
+/**
+ * The same as the {@link TraceRmiService}, but grants access to the internal types (without
+ * casting) to implementors of {@link TraceRmiLaunchOpinion}.
+ */
+public interface InternalTraceRmiService extends TraceRmiService {
+ @Override
+ DefaultTraceRmiAcceptor acceptOne(SocketAddress address) throws IOException;
+
+ @Override
+ TraceRmiHandler connect(SocketAddress address) throws IOException;
+}
diff --git a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracermi/TraceRmiLaunchOpinion.java b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/debug/spi/tracermi/TraceRmiLaunchOpinion.java
similarity index 74%
rename from Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracermi/TraceRmiLaunchOpinion.java
rename to Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/debug/spi/tracermi/TraceRmiLaunchOpinion.java
index 519360b750..28e1f57164 100644
--- a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracermi/TraceRmiLaunchOpinion.java
+++ b/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/debug/spi/tracermi/TraceRmiLaunchOpinion.java
@@ -13,10 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package ghidra.debug.api.tracermi;
+package ghidra.debug.spi.tracermi;
import java.util.Collection;
+import ghidra.app.plugin.core.debug.gui.tracermi.launcher.TraceRmiLauncherServicePlugin;
+import ghidra.app.plugin.core.debug.service.rmi.trace.TraceRmiHandler;
+import ghidra.app.services.InternalTraceRmiService;
+import ghidra.debug.api.tracermi.TraceRmiLaunchOffer;
import ghidra.framework.options.Options;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.listing.Program;
@@ -68,11 +72,16 @@ public interface TraceRmiLaunchOpinion extends ExtensionPoint {
* I.e., the entries there are already validated; they've worked at least once before.</li>
* </ol>
*
+ * @param plugin the Trace RMI launcher service plugin. <b>NOTE:</b> to get access to the Trace
+ * RMI (connection) service, use the {@link InternalTraceRmiService}, so that the
+ * offers can register the connection's resources. See
+ * {@link TraceRmiHandler#registerResources(Collection)}. Resource registration is
+ * required for the Disconnect button to completely terminate the back end.
* @param program the current program. While this is not <em>always</em> used by the launcher,
* it is implied that the user expects the debugger to do something with the current
* program, even if it's just informing the back-end debugger of the target image.
- * @param tool the current tool for context and services
- * @return the offers. The order is not important since items are displayed alphabetically.
+ * @return the offers. The order is ignored, since items are displayed alphabetically.
*/
- public Collection<TraceRmiLaunchOffer> getOffers(Program program, PluginTool tool);
+ public Collection<TraceRmiLaunchOffer> getOffers(TraceRmiLauncherServicePlugin plugin,
+ Program program);
}
diff --git a/Ghidra/Debug/Debugger-rmi-trace/src/main/py/src/ghidratrace/util.py b/Ghidra/Debug/Debugger-rmi-trace/src/main/py/src/ghidratrace/util.py
index e1fe43f175..1958545d62 100644
--- a/Ghidra/Debug/Debugger-rmi-trace/src/main/py/src/ghidratrace/util.py
+++ b/Ghidra/Debug/Debugger-rmi-trace/src/main/py/src/ghidratrace/util.py
@@ -17,23 +17,14 @@ import socket
import traceback
-def send_all(s, data):
- sent = 0
- while sent < len(data):
- l = s.send(data[sent:])
- if l == 0:
- raise Exception("Socket closed")
- sent += l
-
-
def send_length(s, value):
- send_all(s, value.to_bytes(4, 'big'))
+ s.sendall(value.to_bytes(4, 'big'))
def send_delimited(s, msg):
data = msg.SerializeToString()
send_length(s, len(data))
- send_all(s, data)
+ s.sendall(data)
def recv_all(s, size):
@@ -44,7 +35,7 @@ def recv_all(s, size):
return buf
buf += part
return buf
- #return s.recv(size, socket.MSG_WAITALL)
+ # return s.recv(size, socket.MSG_WAITALL)
def recv_length(s):
diff --git a/Ghidra/Debug/Debugger-rmi-trace/src/test/java/ghidra/app/plugin/core/debug/service/rmi/trace/TestTraceRmiConnection.java b/Ghidra/Debug/Debugger-rmi-trace/src/test/java/ghidra/app/plugin/core/debug/service/rmi/trace/TestTraceRmiConnection.java
new file mode 100644
index 0000000000..088f29763f
--- /dev/null
+++ b/Ghidra/Debug/Debugger-rmi-trace/src/test/java/ghidra/app/plugin/core/debug/service/rmi/trace/TestTraceRmiConnection.java
@@ -0,0 +1,188 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.service.rmi.trace;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import ghidra.app.services.DebuggerTargetService;
+import ghidra.async.AsyncPairingQueue;
+import ghidra.async.AsyncUtils;
+import ghidra.dbg.target.schema.TargetObjectSchema.SchemaName;
+import ghidra.debug.api.target.ActionName;
+import ghidra.debug.api.tracermi.*;
+import ghidra.framework.plugintool.PluginTool;
+import ghidra.trace.model.Trace;
+
+public class TestTraceRmiConnection implements TraceRmiConnection {
+
+ protected final TestRemoteMethodRegistry registry = new TestRemoteMethodRegistry();
+ protected final CompletableFuture<Trace> firstTrace = new CompletableFuture<>();
+ protected final Map<Trace, Long> snapshots = new HashMap<>();
+ protected final CompletableFuture<Void> closed = new CompletableFuture<>();
+ protected final Map<Trace, TraceRmiTarget> targets = new HashMap<>();
+
+ public static class TestRemoteMethodRegistry extends DefaultRemoteMethodRegistry {
+ @Override
+ public void add(RemoteMethod method) {
+ super.add(method);
+ }
+ }
+
+ public record TestRemoteMethod(String name, ActionName action, String description,
+ Map<String, RemoteParameter> parameters, SchemaName retType,
+ AsyncPairingQueue<Map<String, Object>> argQueue, AsyncPairingQueue<Object> retQueue)
+ implements RemoteMethod {
+ public TestRemoteMethod(String name, ActionName action, String description,
+ Map<String, RemoteParameter> parameters, SchemaName retType) {
+ this(name, action, description, parameters, retType, new AsyncPairingQueue<>(),
+ new AsyncPairingQueue<>());
+ }
+
+ public TestRemoteMethod(String name, ActionName action, String description,
+ SchemaName retType, RemoteParameter... parameters) {
+ this(name, action, description, Stream.of(parameters)
+ .collect(Collectors.toMap(RemoteParameter::name, p -> p)),
+ retType);
+ }
+
+ @Override
+ public RemoteAsyncResult invokeAsync(Map<String, Object> arguments) {
+ argQueue.give().complete(arguments);
+ DefaultRemoteAsyncResult result = new DefaultRemoteAsyncResult();
+ retQueue.take().handle(AsyncUtils.copyTo(result));
+ return result;
+ }
+
+ public Map<String, Object> expect() throws InterruptedException, ExecutionException {
+ return argQueue.take().get();
+ }
+
+ public void result(Object ret) {
+ retQueue.give().complete(ret);
+ }
+ }
+
+ public record TestRemoteParameter(String name, SchemaName type, boolean required,
+ Object defaultValue, String display, String description) implements RemoteParameter {
+ @Override
+ public Object getDefaultValue() {
+ return defaultValue;
+ }
+ }
+
+ @Override
+ public SocketAddress getRemoteAddress() {
+ return new InetSocketAddress("localhost", 0);
+ }
+
+ @Override
+ public TestRemoteMethodRegistry getMethods() {
+ return registry;
+ }
+
+ public void injectTrace(Trace trace) {
+ firstTrace.complete(trace);
+ }
+
+ public TraceRmiTarget publishTarget(PluginTool tool, Trace trace) {
+ injectTrace(trace);
+ TraceRmiTarget target = new TraceRmiTarget(tool, this, trace);
+ synchronized (targets) {
+ targets.put(trace, target);
+ }
+ DebuggerTargetService targetService = tool.getService(DebuggerTargetService.class);
+ targetService.publishTarget(target);
+ return target;
+ }
+
+ @Override
+ public Trace waitForTrace(long timeoutMillis) throws TimeoutException {
+ try {
+ return firstTrace.get(timeoutMillis, TimeUnit.MILLISECONDS);
+ }
+ catch (InterruptedException | ExecutionException e) {
+ throw new AssertionError(e);
+ }
+ }
+
+ public void setLastSnapshot(Trace trace, long snap) {
+ synchronized (snapshots) {
+ snapshots.put(trace, snap);
+ }
+ }
+
+ @Override
+ public long getLastSnapshot(Trace trace) {
+ synchronized (snapshots) {
+ Long snap = snapshots.get(trace);
+ return snap == null ? 0 : snap;
+ }
+ }
+
+ @Override
+ public void forceCloseTrace(Trace trace) {
+ TraceRmiTarget target;
+ synchronized (targets) {
+ target = targets.remove(trace);
+ }
+ DebuggerTargetService targetService =
+ target.getTool().getService(DebuggerTargetService.class);
+ targetService.withdrawTarget(target);
+ }
+
+ @Override
+ public boolean isTarget(Trace trace) {
+ synchronized (this.targets) {
+ return targets.containsKey(trace);
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ Set<TraceRmiTarget> targets;
+ synchronized (this.targets) {
+ targets = new HashSet<>(this.targets.values());
+ this.targets.clear();
+ }
+ for (TraceRmiTarget target : targets) {
+ DebuggerTargetService targetService =
+ target.getTool().getService(DebuggerTargetService.class);
+ targetService.withdrawTarget(target);
+ }
+ closed.complete(null);
+ }
+
+ @Override
+ public boolean isClosed() {
+ return closed.isDone();
+ }
+
+ @Override
+ public void waitClosed() {
+ try {
+ closed.get();
+ }
+ catch (InterruptedException | ExecutionException e) {
+ throw new AssertionError(e);
+ }
+ }
+}
diff --git a/Ghidra/Debug/Debugger/data/ExtensionPoint.manifest b/Ghidra/Debug/Debugger/data/ExtensionPoint.manifest
index f19255fbc1..d57c51f6d0 100644
--- a/Ghidra/Debug/Debugger/data/ExtensionPoint.manifest
+++ b/Ghidra/Debug/Debugger/data/ExtensionPoint.manifest
@@ -1,3 +1,4 @@
+AutoMapSpec
AutoReadMemorySpec
DebuggerBot
DebuggerMappingOpinion
diff --git a/Ghidra/Debug/Debugger/ghidra_scripts/MonitorModelEventsScript.java b/Ghidra/Debug/Debugger/ghidra_scripts/MonitorModelEventsScript.java
new file mode 100644
index 0000000000..0e2923aada
--- /dev/null
+++ b/Ghidra/Debug/Debugger/ghidra_scripts/MonitorModelEventsScript.java
@@ -0,0 +1,60 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.util.*;
+
+import ghidra.app.script.GhidraScript;
+import ghidra.dbg.DebuggerModelListener;
+import ghidra.dbg.target.TargetEventScope.TargetEventType;
+import ghidra.dbg.target.TargetObject;
+import ghidra.dbg.target.TargetThread;
+import ghidra.debug.flatapi.FlatDebuggerAPI;
+
+public class MonitorModelEventsScript extends GhidraScript implements FlatDebuggerAPI {
+ static DebuggerModelListener listener = new DebuggerModelListener() {
+ @Override
+ public void attributesChanged(TargetObject object, Collection<String> removed,
+ Map<String, ?> added) {
+ System.err.println("attributesChanged(%s, removed=%s, added=%s)"
+ .formatted(object.getJoinedPath("."), removed, added));
+ }
+
+ @Override
+ public void elementsChanged(TargetObject object, Collection<String> removed,
+ Map<String, ? extends TargetObject> added) {
+ System.err.println("elementsChanged(%s, removed=%s, added=%s)"
+ .formatted(object.getJoinedPath("."), removed, added));
+ }
+
+ @Override
+ public void event(TargetObject object, TargetThread eventThread, TargetEventType type,
+ String description, List<Object> parameters) {
+ System.err.println(
+ "event(%s, thread=%s, type=%s, desc=%s)".formatted(object.getJoinedPath("."),
+ eventThread == null ? "<null>" : eventThread.getJoinedPath("."), type,
+ description));
+ }
+
+ @Override
+ public void invalidateCacheRequested(TargetObject object) {
+ System.err.println("invalidateCache(%s)".formatted(object.getJoinedPath(".")));
+ }
+ };
+
+ @Override
+ protected void run() throws Exception {
+ getModelService().getCurrentModel().addModelListener(listener);
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/DisassemblyInject.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/disassemble/DisassemblyInject.java
similarity index 95%
rename from Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/DisassemblyInject.java
rename to Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/disassemble/DisassemblyInject.java
index d3a8bd3aba..b58f3e9ad3 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/DisassemblyInject.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/disassemble/DisassemblyInject.java
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package ghidra.app.plugin.core.debug.workflow;
+package ghidra.app.plugin.core.debug.disassemble;
-import ghidra.app.plugin.core.debug.disassemble.TraceDisassembleCommand;
-import ghidra.app.plugin.core.debug.workflow.DisassemblyInjectInfo.CompilerInfo;
+import ghidra.app.plugin.core.debug.disassemble.DisassemblyInjectInfo.CompilerInfo;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.lang.Language;
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/DisassemblyInjectInfo.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/disassemble/DisassemblyInjectInfo.java
similarity index 97%
rename from Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/DisassemblyInjectInfo.java
rename to Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/disassemble/DisassemblyInjectInfo.java
index aa6cbd1475..1724219ecf 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/DisassemblyInjectInfo.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/disassemble/DisassemblyInjectInfo.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package ghidra.app.plugin.core.debug.workflow;
+package ghidra.app.plugin.core.debug.disassemble;
import java.lang.annotation.*;
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/DebuggerResources.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/DebuggerResources.java
index 4e092eacc4..0b5c9b7ba5 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/DebuggerResources.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/DebuggerResources.java
@@ -296,7 +296,7 @@ public interface DebuggerResources {
boolean DEFAULT_COLOR_INEFF_DIS_BREAKPOINT_COLORING_BACKGROUND = false;
String OPTION_NAME_LOG_BUFFER_LIMIT = "Log Buffer Size";
- int DEFAULT_LOG_BUFFER_LIMIT = 100;
+ int DEFAULT_LOG_BUFFER_LIMIT = 20;
// TODO: Re-assign/name groups
String GROUP_GENERAL = "Dbg1. General";
@@ -878,7 +878,8 @@ public interface DebuggerResources {
static <T> MultiStateActionBuilder<T> builder(Plugin owner) {
String ownerName = owner.getName();
- return new MultiStateActionBuilder<T>(NAME, ownerName).description(DESCRIPTION)
+ return new MultiStateActionBuilder<T>(NAME, ownerName)
+ .description(DESCRIPTION)
.helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
}
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/AutoMapSpec.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/AutoMapSpec.java
new file mode 100644
index 0000000000..7b2fd59542
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/AutoMapSpec.java
@@ -0,0 +1,124 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.action;
+
+import java.util.*;
+
+import javax.swing.Icon;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+import ghidra.app.plugin.core.debug.gui.DebuggerResources;
+import ghidra.app.plugin.core.debug.utils.MiscellaneousUtils;
+import ghidra.app.services.DebuggerStaticMappingService;
+import ghidra.app.services.ProgramManager;
+import ghidra.framework.cmd.BackgroundCommand;
+import ghidra.framework.model.DomainObject;
+import ghidra.framework.options.SaveState;
+import ghidra.framework.plugintool.AutoConfigState.ConfigFieldCodec;
+import ghidra.framework.plugintool.PluginTool;
+import ghidra.trace.model.Trace;
+import ghidra.trace.util.TraceChangeType;
+import ghidra.util.classfinder.ClassSearcher;
+import ghidra.util.classfinder.ExtensionPoint;
+import ghidra.util.exception.CancelledException;
+import ghidra.util.task.TaskMonitor;
+
+/**
+ * An interface for specifying how to automatically map dynamic memory to static memory.
+ */
+public interface AutoMapSpec extends ExtensionPoint {
+ class Private {
+ private final Map<String, AutoMapSpec> specsByName = new TreeMap<>();
+ private final ChangeListener classListener = this::classesChanged;
+
+ private Private() {
+ ClassSearcher.addChangeListener(classListener);
+ }
+
+ private synchronized void classesChanged(ChangeEvent evt) {
+ MiscellaneousUtils.collectUniqueInstances(AutoMapSpec.class, specsByName,
+ AutoMapSpec::getConfigName);
+ }
+ }
+
+ Private PRIVATE = new Private();
+
+ public static class AutoMapSpecConfigFieldCodec implements ConfigFieldCodec<AutoMapSpec> {
+ @Override
+ public AutoMapSpec read(SaveState state, String name,
+ AutoMapSpec current) {
+ String specName = state.getString(name, null);
+ return fromConfigName(specName);
+ }
+
+ @Override
+ public void write(SaveState state, String name, AutoMapSpec value) {
+ state.putString(name, value.getConfigName());
+ }
+ }
+
+ static AutoMapSpec fromConfigName(String name) {
+ synchronized (PRIVATE) {
+ return PRIVATE.specsByName.get(name);
+ }
+ }
+
+ static Map<String, AutoMapSpec> allSpecs() {
+ synchronized (PRIVATE) {
+ return new TreeMap<>(PRIVATE.specsByName);
+ }
+ }
+
+ String getConfigName();
+
+ String getMenuName();
+
+ default Icon getMenuIcon() {
+ return DebuggerResources.ICON_CONFIG;
+ }
+
+ Collection<TraceChangeType<?, ?>> getChangeTypes();
+
+ default String getTaskTitle() {
+ return getMenuName();
+ }
+
+ default void runTask(PluginTool tool, Trace trace) {
+ DebuggerStaticMappingService mappingService =
+ tool.getService(DebuggerStaticMappingService.class);
+ ProgramManager programManager = tool.getService(ProgramManager.class);
+ if (mappingService == null || programManager == null) {
+ return;
+ }
+ BackgroundCommand cmd = new BackgroundCommand(getTaskTitle(), true, true, false) {
+ @Override
+ public boolean applyTo(DomainObject obj, TaskMonitor monitor) {
+ try {
+ performMapping(mappingService, trace, programManager, monitor);
+ return true;
+ }
+ catch (CancelledException e) {
+ return false;
+ }
+ }
+ };
+ tool.executeBackgroundCommand(cmd, trace);
+ }
+
+ void performMapping(DebuggerStaticMappingService mappingService, Trace trace,
+ ProgramManager programManager, TaskMonitor monitor) throws CancelledException;
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/AutoReadMemorySpec.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/AutoReadMemorySpec.java
index d36df7e09e..94521c5d39 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/AutoReadMemorySpec.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/AutoReadMemorySpec.java
@@ -15,7 +15,8 @@
*/
package ghidra.app.plugin.core.debug.gui.action;
-import java.util.*;
+import java.util.Map;
+import java.util.TreeMap;
import java.util.concurrent.CompletableFuture;
import javax.swing.Icon;
@@ -31,9 +32,12 @@ import ghidra.program.model.address.AddressSetView;
import ghidra.util.classfinder.ClassSearcher;
import ghidra.util.classfinder.ExtensionPoint;
+/**
+ * An interface for specifying how to automatically read target memory.
+ */
public interface AutoReadMemorySpec extends ExtensionPoint {
class Private {
- private final Map<String, AutoReadMemorySpec> specsByName = new HashMap<>();
+ private final Map<String, AutoReadMemorySpec> specsByName = new TreeMap<>();
private final ChangeListener classListener = this::classesChanged;
private Private() {
@@ -86,13 +90,14 @@ public interface AutoReadMemorySpec extends ExtensionPoint {
*
* <p>
* Note, the implementation should perform all the error handling. The returned future is for
- * follow-up purposes only, and should always complete normally.
+ * follow-up purposes only, and should always complete normally. It should complete with true if
+ * any memory was actually loaded. Otherwise, it should complete with false.
*
* @param tool the tool containing the provider
* @param coordinates the provider's current coordinates
* @param visible the provider's visible addresses
* @return a future that completes when the memory has been read
*/
- CompletableFuture<?> readMemory(PluginTool tool, DebuggerCoordinates coordinates,
+ CompletableFuture<Boolean> readMemory(PluginTool tool, DebuggerCoordinates coordinates,
AddressSetView visible);
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/MapModulesDebuggerBot.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/ByModuleAutoMapSpec.java
similarity index 53%
rename from Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/MapModulesDebuggerBot.java
rename to Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/ByModuleAutoMapSpec.java
index 7931cb3413..420308e64d 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/MapModulesDebuggerBot.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/ByModuleAutoMapSpec.java
@@ -13,17 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package ghidra.app.plugin.core.debug.workflow;
+package ghidra.app.plugin.core.debug.gui.action;
import java.util.*;
import ghidra.app.services.DebuggerStaticMappingService;
+import ghidra.app.services.ProgramManager;
import ghidra.debug.api.modules.MapProposal;
import ghidra.debug.api.modules.ModuleMapProposal;
import ghidra.debug.api.modules.ModuleMapProposal.ModuleMapEntry;
-import ghidra.debug.api.workflow.DebuggerBotInfo;
-import ghidra.framework.options.annotation.HelpInfo;
-import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.listing.Program;
import ghidra.trace.model.Trace;
import ghidra.trace.model.Trace.TraceMemoryRegionChangeType;
@@ -32,30 +30,33 @@ import ghidra.trace.util.TraceChangeType;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor;
-@DebuggerBotInfo(
- description = "Map modules to open programs",
- details = "Monitors open traces and programs, attempting to map modules by \"best\" match.",
- help = @HelpInfo(anchor = "map_modules"),
- enabledByDefault = true)
-public class MapModulesDebuggerBot extends AbstractMapDebuggerBot {
+public class ByModuleAutoMapSpec implements AutoMapSpec {
+ public static final String CONFIG_NAME = "1_MAP_BY_MODULE";
@Override
- protected Collection<TraceChangeType<?, ?>> getChangeTypes() {
+ public String getConfigName() {
+ return CONFIG_NAME;
+ }
+
+ @Override
+ public String getMenuName() {
+ return "Auto-Map by Module";
+ }
+
+ @Override
+ public Collection<TraceChangeType<?, ?>> getChangeTypes() {
return List.of(TraceModuleChangeType.ADDED, TraceModuleChangeType.CHANGED,
TraceMemoryRegionChangeType.ADDED, TraceMemoryRegionChangeType.CHANGED);
}
@Override
- protected void doAnalysis(PluginTool tool, Trace trace, Set<Program> programs,
- TaskMonitor monitor) throws CancelledException {
- DebuggerStaticMappingService mappingService =
- tool.getService(DebuggerStaticMappingService.class);
- if (mappingService != null) {
- Map<?, ModuleMapProposal> maps = mappingService
- .proposeModuleMaps(trace.getModuleManager().getAllModules(), programs);
- Collection<ModuleMapEntry> entries = MapProposal.flatten(maps.values());
- entries = MapProposal.removeOverlapping(entries);
- mappingService.addModuleMappings(entries, monitor, false);
- }
+ public void performMapping(DebuggerStaticMappingService mappingService, Trace trace,
+ ProgramManager programManager, TaskMonitor monitor) throws CancelledException {
+ List<Program> programs = Arrays.asList(programManager.getAllOpenPrograms());
+ Map<?, ModuleMapProposal> maps = mappingService
+ .proposeModuleMaps(trace.getModuleManager().getAllModules(), programs);
+ Collection<ModuleMapEntry> entries = MapProposal.flatten(maps.values());
+ entries = MapProposal.removeOverlapping(entries);
+ mappingService.addModuleMappings(entries, monitor, false);
}
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/MapRegionsDebuggerBot.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/ByRegionAutoMapSpec.java
similarity index 50%
rename from Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/MapRegionsDebuggerBot.java
rename to Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/ByRegionAutoMapSpec.java
index 0c72dde00b..cc88074a6c 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/MapRegionsDebuggerBot.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/ByRegionAutoMapSpec.java
@@ -13,17 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package ghidra.app.plugin.core.debug.workflow;
+package ghidra.app.plugin.core.debug.gui.action;
import java.util.*;
import ghidra.app.services.DebuggerStaticMappingService;
+import ghidra.app.services.ProgramManager;
import ghidra.debug.api.modules.MapProposal;
import ghidra.debug.api.modules.RegionMapProposal;
import ghidra.debug.api.modules.RegionMapProposal.RegionMapEntry;
-import ghidra.debug.api.workflow.DebuggerBotInfo;
-import ghidra.framework.options.annotation.HelpInfo;
-import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.listing.Program;
import ghidra.trace.model.Trace;
import ghidra.trace.model.Trace.TraceMemoryRegionChangeType;
@@ -31,29 +29,32 @@ import ghidra.trace.util.TraceChangeType;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor;
-@DebuggerBotInfo(
- description = "Map regions to open programs",
- details = "Monitors open traces and programs, attempting to map regions by \"best\" match.",
- help = @HelpInfo(anchor = "map_regions"),
- enabledByDefault = false)
-public class MapRegionsDebuggerBot extends AbstractMapDebuggerBot {
+public class ByRegionAutoMapSpec implements AutoMapSpec {
+ public static final String CONFIG_NAME = "1_MAP_BY_REGION";
@Override
- protected Collection<TraceChangeType<?, ?>> getChangeTypes() {
+ public String getConfigName() {
+ return CONFIG_NAME;
+ }
+
+ @Override
+ public String getMenuName() {
+ return "Auto-Map by Region";
+ }
+
+ @Override
+ public Collection<TraceChangeType<?, ?>> getChangeTypes() {
return List.of(TraceMemoryRegionChangeType.ADDED);
}
@Override
- protected void doAnalysis(PluginTool tool, Trace trace, Set<Program> programs,
- TaskMonitor monitor) throws CancelledException {
- DebuggerStaticMappingService mappingService =
- tool.getService(DebuggerStaticMappingService.class);
- if (mappingService != null) {
- Map<?, RegionMapProposal> maps = mappingService
- .proposeRegionMaps(trace.getMemoryManager().getAllRegions(), programs);
- Collection<RegionMapEntry> entries = MapProposal.flatten(maps.values());
- entries = MapProposal.removeOverlapping(entries);
- mappingService.addRegionMappings(entries, monitor, false);
- }
+ public void performMapping(DebuggerStaticMappingService mappingService, Trace trace,
+ ProgramManager programManager, TaskMonitor monitor) throws CancelledException {
+ List<Program> programs = Arrays.asList(programManager.getAllOpenPrograms());
+ Map<?, RegionMapProposal> maps = mappingService
+ .proposeRegionMaps(trace.getMemoryManager().getAllRegions(), programs);
+ Collection<RegionMapEntry> entries = MapProposal.flatten(maps.values());
+ entries = MapProposal.removeOverlapping(entries);
+ mappingService.addRegionMappings(entries, monitor, false);
}
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/MapSectionsDebuggerBot.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/BySectionAutoMapSpec.java
similarity index 50%
rename from Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/MapSectionsDebuggerBot.java
rename to Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/BySectionAutoMapSpec.java
index c5251767a4..bfb34a49c7 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/MapSectionsDebuggerBot.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/BySectionAutoMapSpec.java
@@ -13,17 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package ghidra.app.plugin.core.debug.workflow;
+package ghidra.app.plugin.core.debug.gui.action;
import java.util.*;
import ghidra.app.services.DebuggerStaticMappingService;
+import ghidra.app.services.ProgramManager;
import ghidra.debug.api.modules.MapProposal;
import ghidra.debug.api.modules.SectionMapProposal;
import ghidra.debug.api.modules.SectionMapProposal.SectionMapEntry;
-import ghidra.debug.api.workflow.DebuggerBotInfo;
-import ghidra.framework.options.annotation.HelpInfo;
-import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.listing.Program;
import ghidra.trace.model.Trace;
import ghidra.trace.model.Trace.TraceSectionChangeType;
@@ -31,29 +29,32 @@ import ghidra.trace.util.TraceChangeType;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor;
-@DebuggerBotInfo(
- description = "Map sections to open programs",
- details = "Monitors open traces and programs, attempting to map sections by \"best\" match.",
- help = @HelpInfo(anchor = "map_sections"),
- enabledByDefault = false)
-public class MapSectionsDebuggerBot extends AbstractMapDebuggerBot {
+public class BySectionAutoMapSpec implements AutoMapSpec {
+ public static final String CONFIG_NAME = "1_MAP_BY_SECTION";
@Override
- protected Collection<TraceChangeType<?, ?>> getChangeTypes() {
+ public String getConfigName() {
+ return CONFIG_NAME;
+ }
+
+ @Override
+ public String getMenuName() {
+ return "Auto-Map by Section";
+ }
+
+ @Override
+ public Collection<TraceChangeType<?, ?>> getChangeTypes() {
return List.of(TraceSectionChangeType.ADDED);
}
@Override
- protected void doAnalysis(PluginTool tool, Trace trace, Set<Program> programs,
- TaskMonitor monitor) throws CancelledException {
- DebuggerStaticMappingService mappingService =
- tool.getService(DebuggerStaticMappingService.class);
- if (mappingService != null) {
- Map<?, SectionMapProposal> maps = mappingService
- .proposeSectionMaps(trace.getModuleManager().getAllModules(), programs);
- Collection<SectionMapEntry> entries = MapProposal.flatten(maps.values());
- entries = MapProposal.removeOverlapping(entries);
- mappingService.addSectionMappings(entries, monitor, false);
- }
+ public void performMapping(DebuggerStaticMappingService mappingService, Trace trace,
+ ProgramManager programManager, TaskMonitor monitor) throws CancelledException {
+ List<Program> programs = Arrays.asList(programManager.getAllOpenPrograms());
+ Map<?, SectionMapProposal> maps = mappingService
+ .proposeSectionMaps(trace.getModuleManager().getAllModules(), programs);
+ Collection<SectionMapEntry> entries = MapProposal.flatten(maps.values());
+ entries = MapProposal.removeOverlapping(entries);
+ mappingService.addSectionMappings(entries, monitor, false);
}
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/DebuggerReadsMemoryTrait.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/DebuggerReadsMemoryTrait.java
index 12c43b0a19..9b71cf3db5 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/DebuggerReadsMemoryTrait.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/DebuggerReadsMemoryTrait.java
@@ -36,8 +36,7 @@ import ghidra.framework.model.DomainObject;
import ghidra.framework.options.SaveState;
import ghidra.framework.plugintool.*;
import ghidra.framework.plugintool.annotation.AutoConfigStateField;
-import ghidra.program.model.address.AddressSetView;
-import ghidra.program.model.address.AddressSpace;
+import ghidra.program.model.address.*;
import ghidra.trace.model.*;
import ghidra.trace.model.Trace.TraceMemoryStateChangeType;
import ghidra.trace.model.Trace.TraceSnapshotChangeType;
@@ -79,6 +78,7 @@ public abstract class DebuggerReadsMemoryTrait {
target.invalidateMemoryCaches();
try {
target.readMemory(sel, monitor);
+ memoryWasRead(sel);
}
catch (CancelledException e) {
return false;
@@ -219,7 +219,12 @@ public abstract class DebuggerReadsMemoryTrait {
if (!isConsistent()) {
return;
}
- autoSpec.readMemory(tool, current, visible).exceptionally(ex -> {
+ AddressSet visible = new AddressSet(this.visible);
+ autoSpec.readMemory(tool, current, visible).thenAccept(b -> {
+ if (b) {
+ memoryWasRead(visible);
+ }
+ }).exceptionally(ex -> {
Msg.error(this, "Could not auto-read memory: " + ex);
return null;
});
@@ -286,4 +291,8 @@ public abstract class DebuggerReadsMemoryTrait {
protected abstract AddressSetView getSelection();
protected abstract void repaintPanel();
+
+ protected void memoryWasRead(AddressSetView read) {
+ // Extension point
+ }
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/LoadEmulatorAutoReadMemorySpec.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/LoadEmulatorAutoReadMemorySpec.java
index 8bac873914..891d373b47 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/LoadEmulatorAutoReadMemorySpec.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/LoadEmulatorAutoReadMemorySpec.java
@@ -26,7 +26,6 @@ import ghidra.app.plugin.core.debug.service.emulation.ProgramEmulationUtils;
import ghidra.app.plugin.core.debug.service.model.record.RecorderUtils;
import ghidra.app.plugin.core.debug.utils.AbstractMappedMemoryBytesVisitor;
import ghidra.app.services.DebuggerStaticMappingService;
-import ghidra.async.AsyncUtils;
import ghidra.debug.api.tracemgr.DebuggerCoordinates;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.*;
@@ -37,7 +36,7 @@ import ghidra.trace.model.memory.TraceMemoryManager;
import ghidra.trace.model.memory.TraceMemoryState;
public class LoadEmulatorAutoReadMemorySpec implements AutoReadMemorySpec {
- public static final String CONFIG_NAME = "LOAD_EMULATOR";
+ public static final String CONFIG_NAME = "2_LOAD_EMULATOR";
@Override
public String getConfigName() {
@@ -55,18 +54,18 @@ public class LoadEmulatorAutoReadMemorySpec implements AutoReadMemorySpec {
}
@Override
- public CompletableFuture<?> readMemory(PluginTool tool, DebuggerCoordinates coordinates,
+ public CompletableFuture<Boolean> readMemory(PluginTool tool, DebuggerCoordinates coordinates,
AddressSetView visible) {
DebuggerStaticMappingService mappingService =
tool.getService(DebuggerStaticMappingService.class);
if (mappingService == null) {
- return AsyncUtils.nil();
+ return CompletableFuture.completedFuture(false);
}
Trace trace = coordinates.getTrace();
if (trace == null || coordinates.isAlive() ||
!ProgramEmulationUtils.isEmulatedProgram(trace)) {
// Never interfere with a live target
- return AsyncUtils.nil();
+ return CompletableFuture.completedFuture(false);
}
TraceMemoryManager mm = trace.getMemoryManager();
AddressSet toRead = new AddressSet(RecorderUtils.INSTANCE.quantize(12, visible));
@@ -80,7 +79,7 @@ public class LoadEmulatorAutoReadMemorySpec implements AutoReadMemorySpec {
}
if (toRead.isEmpty()) {
- return AsyncUtils.nil();
+ return CompletableFuture.completedFuture(false);
}
long snap = coordinates.getSnap();
@@ -94,7 +93,7 @@ public class LoadEmulatorAutoReadMemorySpec implements AutoReadMemorySpec {
mm.putBytes(snap, hostAddr, buf);
}
}.visit(trace, snap, toRead);
- return AsyncUtils.nil();
+ return CompletableFuture.completedFuture(true);
}
catch (MemoryAccessException e) {
throw new AssertionError(e);
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/NoneAutoMapSpec.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/NoneAutoMapSpec.java
new file mode 100644
index 0000000000..84524326f1
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/NoneAutoMapSpec.java
@@ -0,0 +1,56 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.action;
+
+import java.util.Collection;
+import java.util.List;
+
+import ghidra.app.services.DebuggerStaticMappingService;
+import ghidra.app.services.ProgramManager;
+import ghidra.framework.plugintool.PluginTool;
+import ghidra.trace.model.Trace;
+import ghidra.trace.util.TraceChangeType;
+import ghidra.util.exception.CancelledException;
+import ghidra.util.task.TaskMonitor;
+
+public class NoneAutoMapSpec implements AutoMapSpec {
+ public static final String CONFIG_NAME = "0_MAP_NONE";
+
+ @Override
+ public String getConfigName() {
+ return CONFIG_NAME;
+ }
+
+ @Override
+ public String getMenuName() {
+ return "Do Not Auto-Map";
+ }
+
+ @Override
+ public Collection<TraceChangeType<?, ?>> getChangeTypes() {
+ return List.of();
+ }
+
+ @Override
+ public void runTask(PluginTool tool, Trace trace) {
+ // Don't bother launching a task that does nothing
+ }
+
+ @Override
+ public void performMapping(DebuggerStaticMappingService mappingService, Trace trace,
+ ProgramManager programManager, TaskMonitor monitor) throws CancelledException {
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/NoneAutoReadMemorySpec.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/NoneAutoReadMemorySpec.java
index de4780d444..d603e40ae5 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/NoneAutoReadMemorySpec.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/NoneAutoReadMemorySpec.java
@@ -20,13 +20,12 @@ import java.util.concurrent.CompletableFuture;
import javax.swing.Icon;
import ghidra.app.plugin.core.debug.gui.DebuggerResources.AutoReadMemoryAction;
-import ghidra.async.AsyncUtils;
import ghidra.debug.api.tracemgr.DebuggerCoordinates;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.AddressSetView;
public class NoneAutoReadMemorySpec implements AutoReadMemorySpec {
- public static final String CONFIG_NAME = "READ_NONE";
+ public static final String CONFIG_NAME = "0_READ_NONE";
@Override
public String getConfigName() {
@@ -44,8 +43,8 @@ public class NoneAutoReadMemorySpec implements AutoReadMemorySpec {
}
@Override
- public CompletableFuture<Void> readMemory(PluginTool tool, DebuggerCoordinates coordinates,
+ public CompletableFuture<Boolean> readMemory(PluginTool tool, DebuggerCoordinates coordinates,
AddressSetView visible) {
- return AsyncUtils.nil();
+ return CompletableFuture.completedFuture(false);
}
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/NoneLocationTrackingSpec.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/NoneLocationTrackingSpec.java
index b51f3355bc..e734be0cf2 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/NoneLocationTrackingSpec.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/NoneLocationTrackingSpec.java
@@ -90,4 +90,9 @@ public enum NoneLocationTrackingSpec implements LocationTrackingSpec, LocationTr
public boolean affectedByStackChange(TraceStack stack, DebuggerCoordinates coordinates) {
return false;
}
+
+ @Override
+ public boolean shouldDisassemble() {
+ return false;
+ }
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/OneToOneAutoMapSpec.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/OneToOneAutoMapSpec.java
new file mode 100644
index 0000000000..567d179355
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/OneToOneAutoMapSpec.java
@@ -0,0 +1,64 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.action;
+
+import java.util.Collection;
+import java.util.List;
+
+import ghidra.app.services.DebuggerStaticMappingService;
+import ghidra.app.services.ProgramManager;
+import ghidra.program.model.listing.Program;
+import ghidra.trace.model.Lifespan;
+import ghidra.trace.model.Trace;
+import ghidra.trace.model.modules.TraceConflictedMappingException;
+import ghidra.trace.util.TraceChangeType;
+import ghidra.util.exception.CancelledException;
+import ghidra.util.task.TaskMonitor;
+
+public class OneToOneAutoMapSpec implements AutoMapSpec {
+ public static final String CONFIG_NAME = "2_MAP_ONE_TO_ONE";
+
+ @Override
+ public String getConfigName() {
+ return CONFIG_NAME;
+ }
+
+ @Override
+ public String getMenuName() {
+ return "Auto-Map Identically (1-to-1)";
+ }
+
+ @Override
+ public Collection<TraceChangeType<?, ?>> getChangeTypes() {
+ return List.of();
+ }
+
+ @Override
+ public void performMapping(DebuggerStaticMappingService mappingService, Trace trace,
+ ProgramManager programManager, TaskMonitor monitor) throws CancelledException {
+ Program program = programManager.getCurrentProgram();
+ if (program == null) {
+ return;
+ }
+ try {
+ mappingService.addIdentityMapping(trace, program,
+ Lifespan.nowOn(trace.getProgramView().getSnap()), false);
+ }
+ catch (TraceConflictedMappingException e) {
+ // aww well
+ }
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/PCByRegisterLocationTrackingSpec.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/PCByRegisterLocationTrackingSpec.java
index 4250d7ff3f..fc1ba8bbd8 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/PCByRegisterLocationTrackingSpec.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/PCByRegisterLocationTrackingSpec.java
@@ -61,4 +61,9 @@ public enum PCByRegisterLocationTrackingSpec implements RegisterLocationTracking
public AddressSpace computeDefaultAddressSpace(DebuggerCoordinates coordinates) {
return coordinates.getPlatform().getLanguage().getDefaultSpace();
}
+
+ @Override
+ public boolean shouldDisassemble() {
+ return true;
+ }
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/PCByStackLocationTrackingSpec.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/PCByStackLocationTrackingSpec.java
index 72702963ba..d11247ea42 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/PCByStackLocationTrackingSpec.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/PCByStackLocationTrackingSpec.java
@@ -125,4 +125,9 @@ public enum PCByStackLocationTrackingSpec implements LocationTrackingSpec, Locat
DebuggerCoordinates coordinates) {
return false;
}
+
+ @Override
+ public boolean shouldDisassemble() {
+ return true;
+ }
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/PCLocationTrackingSpec.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/PCLocationTrackingSpec.java
index 05df644bec..c3cfdfd99d 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/PCLocationTrackingSpec.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/PCLocationTrackingSpec.java
@@ -100,4 +100,9 @@ public enum PCLocationTrackingSpec implements LocationTrackingSpec, LocationTrac
DebuggerCoordinates coordinates) {
return BY_REG.affectedByBytesChange(space, range, coordinates);
}
+
+ @Override
+ public boolean shouldDisassemble() {
+ return true;
+ }
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/SPLocationTrackingSpec.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/SPLocationTrackingSpec.java
index f3dc396ad3..7e7722bdfe 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/SPLocationTrackingSpec.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/SPLocationTrackingSpec.java
@@ -61,4 +61,9 @@ public enum SPLocationTrackingSpec implements RegisterLocationTrackingSpec {
public AddressSpace computeDefaultAddressSpace(DebuggerCoordinates coordinates) {
return coordinates.getTrace().getBaseLanguage().getDefaultDataSpace();
}
+
+ @Override
+ public boolean shouldDisassemble() {
+ return false;
+ }
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/VisibleAutoReadMemorySpec.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/VisibleAutoReadMemorySpec.java
index 492977f8db..9b1b1d951a 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/VisibleAutoReadMemorySpec.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/VisibleAutoReadMemorySpec.java
@@ -20,7 +20,6 @@ import java.util.concurrent.CompletableFuture;
import javax.swing.Icon;
import ghidra.app.plugin.core.debug.gui.DebuggerResources.AutoReadMemoryAction;
-import ghidra.async.AsyncUtils;
import ghidra.debug.api.target.Target;
import ghidra.debug.api.tracemgr.DebuggerCoordinates;
import ghidra.framework.plugintool.PluginTool;
@@ -31,7 +30,7 @@ import ghidra.trace.model.memory.TraceMemoryState;
import ghidra.util.task.TaskMonitor;
public class VisibleAutoReadMemorySpec implements AutoReadMemorySpec {
- public static final String CONFIG_NAME = "READ_VISIBLE";
+ public static final String CONFIG_NAME = "1_READ_VISIBLE";
@Override
public String getConfigName() {
@@ -49,10 +48,10 @@ public class VisibleAutoReadMemorySpec implements AutoReadMemorySpec {
}
@Override
- public CompletableFuture<?> readMemory(PluginTool tool, DebuggerCoordinates coordinates,
+ public CompletableFuture<Boolean> readMemory(PluginTool tool, DebuggerCoordinates coordinates,
AddressSetView visible) {
if (!coordinates.isAliveAndReadsPresent()) {
- return AsyncUtils.nil();
+ return CompletableFuture.completedFuture(false);
}
Target target = coordinates.getTarget();
TraceMemoryManager mm = coordinates.getTrace().getMemoryManager();
@@ -61,9 +60,9 @@ public class VisibleAutoReadMemorySpec implements AutoReadMemorySpec {
AddressSet toRead = visible.subtract(alreadyKnown);
if (toRead.isEmpty()) {
- return AsyncUtils.nil();
+ return CompletableFuture.completedFuture(false);
}
- return target.readMemoryAsync(toRead, TaskMonitor.DUMMY);
+ return target.readMemoryAsync(toRead, TaskMonitor.DUMMY).thenApply(__ -> true);
}
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/VisibleROOnceAutoReadMemorySpec.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/VisibleROOnceAutoReadMemorySpec.java
index af3828a1e2..6a6279f4fc 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/VisibleROOnceAutoReadMemorySpec.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/VisibleROOnceAutoReadMemorySpec.java
@@ -21,7 +21,6 @@ import java.util.concurrent.CompletableFuture;
import javax.swing.Icon;
import ghidra.app.plugin.core.debug.gui.DebuggerResources.AutoReadMemoryAction;
-import ghidra.async.AsyncUtils;
import ghidra.debug.api.target.Target;
import ghidra.debug.api.tracemgr.DebuggerCoordinates;
import ghidra.framework.plugintool.PluginTool;
@@ -32,7 +31,7 @@ import ghidra.trace.model.memory.*;
import ghidra.util.task.TaskMonitor;
public class VisibleROOnceAutoReadMemorySpec implements AutoReadMemorySpec {
- public static final String CONFIG_NAME = "READ_VIS_RO_ONCE";
+ public static final String CONFIG_NAME = "1_READ_VIS_RO_ONCE";
@Override
public String getConfigName() {
@@ -50,10 +49,10 @@ public class VisibleROOnceAutoReadMemorySpec implements AutoReadMemorySpec {
}
@Override
- public CompletableFuture<?> readMemory(PluginTool tool, DebuggerCoordinates coordinates,
+ public CompletableFuture<Boolean> readMemory(PluginTool tool, DebuggerCoordinates coordinates,
AddressSetView visible) {
if (!coordinates.isAliveAndReadsPresent()) {
- return AsyncUtils.nil();
+ return CompletableFuture.completedFuture(false);
}
Target target = coordinates.getTarget();
TraceMemoryManager mm = coordinates.getTrace().getMemoryManager();
@@ -62,7 +61,7 @@ public class VisibleROOnceAutoReadMemorySpec implements AutoReadMemorySpec {
AddressSet toRead = visible.subtract(alreadyKnown);
if (toRead.isEmpty()) {
- return AsyncUtils.nil();
+ return CompletableFuture.completedFuture(false);
}
AddressSet everKnown = new AddressSet();
@@ -85,9 +84,9 @@ public class VisibleROOnceAutoReadMemorySpec implements AutoReadMemorySpec {
toRead.delete(everKnown.intersect(readOnly));
if (toRead.isEmpty()) {
- return AsyncUtils.nil();
+ return CompletableFuture.completedFuture(false);
}
- return target.readMemoryAsync(toRead, TaskMonitor.DUMMY);
+ return target.readMemoryAsync(toRead, TaskMonitor.DUMMY).thenApply(__ -> true);
}
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/WatchLocationTrackingSpec.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/WatchLocationTrackingSpec.java
index ae814d73d4..d3af101d9f 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/WatchLocationTrackingSpec.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/WatchLocationTrackingSpec.java
@@ -165,6 +165,11 @@ public class WatchLocationTrackingSpec implements LocationTrackingSpec {
public boolean affectedByStackChange(TraceStack stack, DebuggerCoordinates coordinates) {
return false;
}
+
+ @Override
+ public boolean shouldDisassemble() {
+ return false;
+ }
}
@Override
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsProvider.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsProvider.java
index 476470bae1..9b79a86d39 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsProvider.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsProvider.java
@@ -620,7 +620,8 @@ public class DebuggerBreakpointsProvider extends ComponentProviderAdapter
private boolean isVisible(TraceBreakpoint location) {
long snap = traceManager.getCurrentFor(trace).getSnap();
- return location.getLifespan().contains(snap);
+ Lifespan span = location.getLifespan();
+ return span != null && span.contains(snap);
}
private void locationAdded(TraceBreakpoint location) {
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/console/DebuggerConsolePlugin.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/console/DebuggerConsolePlugin.java
index 417ab1222f..1c4162222c 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/console/DebuggerConsolePlugin.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/console/DebuggerConsolePlugin.java
@@ -86,15 +86,15 @@ public class DebuggerConsolePlugin extends Plugin implements DebuggerConsoleServ
provider = new DebuggerConsoleProvider(this);
rootLogger = (Logger) LogManager.getRootLogger();
- appender.start();
- rootLogger.addAppender(appender);
+ //appender.start();
+ //rootLogger.addAppender(appender);
}
@Override
protected void dispose() {
if (rootLogger != null) {
- rootLogger.removeAppender(appender);
- appender.stop();
+ //rootLogger.removeAppender(appender);
+ //appender.stop();
provider.dispose();
tool.removeComponentProvider(provider);
diff --git a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/app/services/DebuggerWorkflowToolService.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/ControlAction.java
similarity index 62%
rename from Ghidra/Debug/Debugger-api/src/main/java/ghidra/app/services/DebuggerWorkflowToolService.java
rename to Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/ControlAction.java
index 6ea2e160da..40aa678f98 100644
--- a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/app/services/DebuggerWorkflowToolService.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/ControlAction.java
@@ -13,13 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package ghidra.app.services;
+package ghidra.app.plugin.core.debug.gui.control;
-import ghidra.framework.plugintool.ServiceInfo;
+import ghidra.app.plugin.core.debug.gui.DebuggerResources;
-@ServiceInfo(
- defaultProviderName = "ghidra.app.plugin.core.debug.service.workflow.DebuggerWorkflowServiceProxyPlugin",
- description = "Service for managing automatic debugger actions and analysis")
-public interface DebuggerWorkflowToolService extends DebuggerWorkflowService {
+interface ControlAction {
+ String GROUP = DebuggerResources.GROUP_CONTROL;
+ static String intSubGroup(int subGroup) {
+ return String.format("%02d", subGroup);
+ }
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/ControlModeAction.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/ControlModeAction.java
new file mode 100644
index 0000000000..10b93e4012
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/ControlModeAction.java
@@ -0,0 +1,64 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.control;
+
+import java.util.stream.Collectors;
+
+import docking.ActionContext;
+import docking.action.ToolBarData;
+import docking.menu.ActionState;
+import docking.menu.MultiStateDockingAction;
+import docking.widgets.EventTrigger;
+import ghidra.app.plugin.core.debug.gui.DebuggerResources;
+import ghidra.debug.api.control.ControlMode;
+import ghidra.util.HelpLocation;
+
+class ControlModeAction extends MultiStateDockingAction<ControlMode> {
+ public static final String NAME = "Control Mode";
+ public static final String DESCRIPTION = "Choose what to control and edit in dynamic views";
+ public static final String GROUP = DebuggerResources.GROUP_CONTROL;
+ public static final String HELP_ANCHOR = "control_mode";
+
+ private final DebuggerControlPlugin plugin;
+
+ public ControlModeAction(DebuggerControlPlugin plugin) {
+ super(NAME, plugin.getName());
+ this.plugin = plugin;
+ setDescription(DESCRIPTION);
+ setToolBarData(new ToolBarData(DebuggerResources.ICON_BLANK, GROUP, ""));
+ setHelpLocation(new HelpLocation(getOwner(), HELP_ANCHOR));
+ setActionStates(ControlMode.ALL.stream()
+ .map(m -> new ActionState<>(m.name, m.icon, m))
+ .collect(Collectors.toList()));
+ setEnabled(false);
+ }
+
+ @Override
+ public boolean isEnabledForContext(ActionContext context) {
+ return plugin.current.getTrace() != null;
+ }
+
+ @Override
+ protected boolean isStateEnabled(ActionState<ControlMode> state) {
+ return state.getUserData().isSelectable(plugin.current);
+ }
+
+ @Override
+ public void actionStateChanged(ActionState<ControlMode> newActionState,
+ EventTrigger trigger) {
+ plugin.activateControlMode(newActionState, trigger);
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/DebuggerControlPlugin.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/DebuggerControlPlugin.java
index e5bf53a03b..592599b71f 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/DebuggerControlPlugin.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/DebuggerControlPlugin.java
@@ -15,28 +15,22 @@
*/
package ghidra.app.plugin.core.debug.gui.control;
-import java.awt.event.KeyEvent;
import java.util.*;
-import java.util.function.BiFunction;
-import java.util.stream.Collectors;
-
-import javax.swing.Icon;
-import javax.swing.KeyStroke;
import docking.ActionContext;
import docking.DockingContextListener;
-import docking.action.*;
-import docking.action.builder.ActionBuilder;
+import docking.action.DockingAction;
+import docking.action.DockingActionIf;
import docking.menu.ActionState;
import docking.menu.MultiStateDockingAction;
import docking.widgets.EventTrigger;
+import ghidra.app.context.ProgramLocationActionContext;
import ghidra.app.plugin.PluginCategoryNames;
import ghidra.app.plugin.core.debug.AbstractDebuggerPlugin;
import ghidra.app.plugin.core.debug.DebuggerPluginPackage;
import ghidra.app.plugin.core.debug.event.TraceActivatedPluginEvent;
import ghidra.app.plugin.core.debug.event.TraceClosedPluginEvent;
-import ghidra.app.plugin.core.debug.gui.DebuggerResources;
-import ghidra.app.plugin.core.debug.service.model.TraceRecorderTarget;
+import ghidra.app.plugin.core.debug.gui.model.DebuggerObjectActionContext;
import ghidra.app.services.*;
import ghidra.app.services.DebuggerControlService.ControlModeChangeListener;
import ghidra.app.services.DebuggerEmulationService.CachedEmulator;
@@ -52,12 +46,15 @@ import ghidra.debug.api.tracemgr.DebuggerCoordinates;
import ghidra.framework.plugintool.*;
import ghidra.framework.plugintool.annotation.AutoServiceConsumed;
import ghidra.framework.plugintool.util.PluginStatus;
+import ghidra.program.model.address.Address;
+import ghidra.program.model.listing.Program;
import ghidra.trace.model.*;
import ghidra.trace.model.Trace.TraceObjectChangeType;
import ghidra.trace.model.target.TraceObjectValue;
import ghidra.trace.model.time.schedule.Scheduler;
import ghidra.trace.model.time.schedule.TraceSchedule;
-import ghidra.util.*;
+import ghidra.util.Msg;
+import ghidra.util.Swing;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.Task;
import ghidra.util.task.TaskMonitor;
@@ -79,316 +76,6 @@ import ghidra.util.task.TaskMonitor;
public class DebuggerControlPlugin extends AbstractDebuggerPlugin
implements DockingContextListener {
- static String intSubGroup(int subGroup) {
- return String.format("%02d", subGroup);
- }
-
- interface ControlAction {
- String GROUP = DebuggerResources.GROUP_CONTROL;
- }
-
- protected class ControlModeAction extends MultiStateDockingAction<ControlMode> {
- public static final String NAME = "Control Mode";
- public static final String DESCRIPTION = "Choose what to control and edit in dynamic views";
- public static final String GROUP = DebuggerResources.GROUP_CONTROL;
- public static final String HELP_ANCHOR = "control_mode";
-
- public ControlModeAction() {
- super(NAME, DebuggerControlPlugin.this.getName());
- setDescription(DESCRIPTION);
- setToolBarData(new ToolBarData(DebuggerResources.ICON_BLANK, GROUP, ""));
- setHelpLocation(new HelpLocation(getOwner(), HELP_ANCHOR));
- setActionStates(ControlMode.ALL.stream()
- .map(m -> new ActionState<>(m.name, m.icon, m))
- .collect(Collectors.toList()));
- setEnabled(false);
- }
-
- @Override
- public boolean isEnabledForContext(ActionContext context) {
- return current.getTrace() != null;
- }
-
- @Override
- protected boolean isStateEnabled(ActionState<ControlMode> state) {
- return state.getUserData().isSelectable(current);
- }
-
- @Override
- public void actionStateChanged(ActionState<ControlMode> newActionState,
- EventTrigger trigger) {
- activateControlMode(newActionState, trigger);
- }
- }
-
- interface ResumeAction extends ControlAction {
- Icon ICON = DebuggerResources.ICON_RESUME;
- int SUB_GROUP = 0;
- KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0);
- }
-
- interface TargetResumeAction extends ResumeAction {
- String HELP_ANCHOR = "target_resume";
-
- static ActionBuilder builder(String name, DebuggerControlPlugin owner) {
- String ownerName = owner.getName();
- return new ActionBuilder(name, ownerName)
- .toolBarIcon(ICON)
- .toolBarGroup(GROUP, intSubGroup(SUB_GROUP))
- .keyBinding(KEY_BINDING)
- .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
- }
- }
-
- interface EmulateResumeAction extends ResumeAction {
- String NAME = "Resume Emulator";
- String DESCRIPTION = "Resume, i.e., go or continue execution of the integrated emulator";
- String HELP_ANCHOR = "emu_resume";
-
- static ActionBuilder builder(Plugin owner) {
- String ownerName = owner.getName();
- return new ActionBuilder(NAME, ownerName)
- .description(DESCRIPTION)
- .toolBarIcon(ICON)
- .toolBarGroup(GROUP, intSubGroup(SUB_GROUP))
- .keyBinding(KEY_BINDING)
- .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
- }
- }
-
- interface InterruptAction extends ControlAction {
- Icon ICON = DebuggerResources.ICON_INTERRUPT;
- int SUB_GROUP = 1;
- KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_I, KeyEvent.CTRL_DOWN_MASK);
- }
-
- interface TargetInterruptAction extends InterruptAction {
- String HELP_ANCHOR = "target_interrupt";
-
- static ActionBuilder builder(String name, DebuggerControlPlugin owner) {
- String ownerName = owner.getName();
- return new ActionBuilder(name, ownerName)
- .toolBarIcon(ICON)
- .toolBarGroup(GROUP, intSubGroup(SUB_GROUP))
- .keyBinding(KEY_BINDING)
- .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
- }
- }
-
- interface EmulateInterruptAction extends InterruptAction {
- String NAME = "Interrupt Emulator";
- String DESCRIPTION = "Interrupt, i.e., suspend, the integrated emulator";
- String HELP_ANCHOR = "emu_interrupt";
-
- static ActionBuilder builder(Plugin owner) {
- String ownerName = owner.getName();
- return new ActionBuilder(NAME, ownerName)
- .description(DESCRIPTION)
- .toolBarIcon(ICON)
- .toolBarGroup(GROUP, intSubGroup(SUB_GROUP))
- .keyBinding(KEY_BINDING)
- .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
- }
- }
-
- interface TargetKillAction extends ControlAction {
- Icon ICON = DebuggerResources.ICON_KILL;
- String HELP_ANCHOR = "target_kill";
- int SUB_GROUP = 2;
- KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_K,
- KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK);
-
- static ActionBuilder builder(String name, DebuggerControlPlugin owner) {
- String ownerName = owner.getName();
- return new ActionBuilder(name, ownerName)
- .toolBarIcon(ICON)
- .toolBarGroup(GROUP, intSubGroup(SUB_GROUP))
- .keyBinding(KEY_BINDING)
- .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
- }
- }
-
- interface DisconnectAction extends ControlAction {
- String NAME = "Disconnect";
- String DESCRIPTION = "Close the connection to the debugging agent";
- Icon ICON = DebuggerResources.ICON_DISCONNECT;
- String HELP_ANCHOR = "target_disconnect";
- int SUB_GROUP = 3;
- KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_K,
- KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK);
-
- static ActionBuilder builder(Plugin owner) {
- String ownerName = owner.getName();
- return new ActionBuilder(NAME, ownerName)
- .description(DESCRIPTION)
- .toolBarIcon(ICON)
- .toolBarGroup(GROUP, intSubGroup(SUB_GROUP))
- .keyBinding(KEY_BINDING)
- .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
- }
- }
-
- interface EmulateStepBackAction extends ControlAction {
- String NAME = "Step Emulator Back";
- String DESCRIPTION = "Step the integrated emulator a single instruction backward";
- Icon ICON = DebuggerResources.ICON_STEP_BACK;
- String HELP_ANCHOR = "emu_step_back";
- int SUB_GROUP = 4;
- KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0);
-
- static ActionBuilder builder(Plugin owner) {
- String ownerName = owner.getName();
- return new ActionBuilder(NAME, ownerName)
- .description(DESCRIPTION)
- .toolBarIcon(ICON)
- .toolBarGroup(GROUP, intSubGroup(SUB_GROUP))
- .keyBinding(KEY_BINDING)
- .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
- }
- }
-
- interface StepIntoAction extends ControlAction {
- Icon ICON = DebuggerResources.ICON_STEP_INTO;
- int SUB_GROUP = 5;
- KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0);
- }
-
- interface TargetStepIntoAction extends StepIntoAction {
- String HELP_ANCHOR = "target_step_into";
-
- static ActionBuilder builder(String name, DebuggerControlPlugin owner) {
- String ownerName = owner.getName();
- return new ActionBuilder(name, ownerName)
- .toolBarIcon(ICON)
- .toolBarGroup(GROUP, intSubGroup(SUB_GROUP))
- .keyBinding(KEY_BINDING)
- .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
- }
- }
-
- interface EmulateStepIntoAction extends StepIntoAction {
- String NAME = "Step Emulator Into";
- String DESCRIPTION =
- "Step the integrated emulator a single instruction, descending into calls";
- String HELP_ANCHOR = "emu_step_into";
-
- static ActionBuilder builder(Plugin owner) {
- String ownerName = owner.getName();
- return new ActionBuilder(NAME, ownerName)
- .description(DESCRIPTION)
- .toolBarIcon(ICON)
- .toolBarGroup(GROUP, intSubGroup(SUB_GROUP))
- .keyBinding(KEY_BINDING)
- .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
- }
- }
-
- interface TargetStepOverAction extends ControlAction {
- Icon ICON = DebuggerResources.ICON_STEP_OVER;
- String HELP_ANCHOR = "target_step_over";
- int SUB_GROUP = 6;
- KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_F10, 0);
-
- static ActionBuilder builder(String name, DebuggerControlPlugin owner) {
- String ownerName = owner.getName();
- return new ActionBuilder(name, ownerName)
- .toolBarIcon(ICON)
- .toolBarGroup(GROUP, intSubGroup(SUB_GROUP))
- .keyBinding(KEY_BINDING)
- .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
- }
- }
-
- interface EmulateSkipOverAction extends ControlAction {
- String NAME = "Skip Emulator";
- String DESCRIPTION =
- "Skip the integrated emulator a single instruction, ignoring its effects";
- Icon ICON = DebuggerResources.ICON_SKIP_OVER;
- String HELP_ANCHOR = "emu_skip_over";
- int SUB_GROUP = 7;
- KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_F10, KeyEvent.CTRL_DOWN_MASK);
-
- static ActionBuilder builder(Plugin owner) {
- String ownerName = owner.getName();
- return new ActionBuilder(NAME, ownerName)
- .description(DESCRIPTION)
- .toolBarIcon(ICON)
- .toolBarGroup(GROUP, intSubGroup(SUB_GROUP))
- .keyBinding(KEY_BINDING)
- .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
- }
- }
-
- interface TargetStepOutAction extends ControlAction {
- Icon ICON = DebuggerResources.ICON_STEP_FINISH;
- String HELP_ANCHOR = "target_step_out";
- int SUB_GROUP = 8;
- KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0);
-
- static ActionBuilder builder(String name, DebuggerControlPlugin owner) {
- String ownerName = owner.getName();
- return new ActionBuilder(name, ownerName)
- .toolBarIcon(ICON)
- .toolBarGroup(GROUP, intSubGroup(SUB_GROUP))
- .keyBinding(KEY_BINDING)
- .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
- }
- }
-
- interface TargetStepExtAction extends ControlAction {
- Icon ICON = DebuggerResources.ICON_STEP_LAST;
- String HELP_ANCHOR = "target_step_ext";
- int SUB_GROUP = 9;
- KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_F8, KeyEvent.CTRL_DOWN_MASK);
-
- static ActionBuilder builder(String name, DebuggerControlPlugin owner) {
- String ownerName = owner.getName();
- return new ActionBuilder(name, ownerName)
- .toolBarIcon(ICON)
- .toolBarGroup(GROUP, intSubGroup(SUB_GROUP) + name)
- .keyBinding(KEY_BINDING)
- .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
- }
- }
-
- interface TraceSnapBackwardAction extends ControlAction {
- String NAME = "Trace Snapshot Backward";
- String DESCRIPTION = "Navigate the trace recording backward one snapshot";
- Icon ICON = DebuggerResources.ICON_SNAP_BACKWARD;
- String HELP_ANCHOR = "trace_snap_backward";
- int SUB_GROUP = 10;
- KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0);
-
- static ActionBuilder builder(Plugin owner) {
- String ownerName = owner.getName();
- return new ActionBuilder(NAME, ownerName)
- .description(DESCRIPTION)
- .toolBarIcon(ICON)
- .toolBarGroup(GROUP, intSubGroup(SUB_GROUP))
- .keyBinding(KEY_BINDING)
- .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
- }
- }
-
- interface TraceSnapForwardAction extends ControlAction {
- String NAME = "Trace Snapshot Forward";
- String DESCRIPTION = "Navigate the trace recording forward one snapshot";
- Icon ICON = DebuggerResources.ICON_SNAP_FORWARD;
- String HELP_ANCHOR = "trace_snap_backward";
- int SUB_GROUP = 11;
- KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0);
-
- static ActionBuilder builder(Plugin owner) {
- String ownerName = owner.getName();
- return new ActionBuilder(NAME, ownerName)
- .description(DESCRIPTION)
- .toolBarIcon(ICON)
- .toolBarGroup(GROUP, intSubGroup(SUB_GROUP))
- .keyBinding(KEY_BINDING)
- .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
- }
- }
-
private final TraceDomainObjectListener listenerForObjects = new TraceDomainObjectListener() {
{
listenFor(TraceObjectChangeType.VALUE_CREATED, this::valueChanged);
@@ -427,8 +114,16 @@ public class DebuggerControlPlugin extends AbstractDebuggerPlugin
protected MultiStateDockingAction<ControlMode> actionControlMode;
+ DockingAction actionTargetResume;
+ DockingAction actionTargetInterrupt;
+ DockingAction actionTargetKill;
+ DockingAction actionTargetStepInto;
+ DockingAction actionTargetStepOver;
+ DockingAction actionTargetStepOut;
DockingAction actionTargetDisconnect;
- final Set<DockingAction> actionsTarget = new HashSet<>();
+ Set<DockingAction> actionsTarget;
+ final Set<DockingAction> actionsTargetStepExt = new HashSet<>();
+ final Set<DockingAction> actionsTargetAll = new HashSet<>();
DockingAction actionEmulateResume;
DockingAction actionEmulateInterrupt;
@@ -442,7 +137,6 @@ public class DebuggerControlPlugin extends AbstractDebuggerPlugin
Set<DockingAction> actionsTrace;
Set<Set<DockingAction>> actionSets;
- Collection<? extends DockingActionIf> curActionSet;
ActionContext context;
@@ -463,7 +157,7 @@ public class DebuggerControlPlugin extends AbstractDebuggerPlugin
switch (mode) {
case RO_TARGET:
case RW_TARGET:
- return actionsTarget;
+ return actionsTargetAll;
case RO_TRACE:
case RW_TRACE:
return actionsTrace;
@@ -475,7 +169,7 @@ public class DebuggerControlPlugin extends AbstractDebuggerPlugin
}
protected Set<DockingAction> getActionSet() {
- return getActionSet(computeCurrentEditingMode());
+ return getActionSet(computeCurrentControlMode());
}
protected void updateActionsEnabled(ControlMode mode) {
@@ -485,24 +179,70 @@ public class DebuggerControlPlugin extends AbstractDebuggerPlugin
}
protected void updateActionsEnabled() {
- updateActionsEnabled(computeCurrentEditingMode());
+ updateActionsEnabled(computeCurrentControlMode());
+ }
+
+ protected static boolean isSameContext(ActionContext ctx1, ActionContext ctx2) {
+ if (ctx1 instanceof ProgramLocationActionContext locCtx1) {
+ if (!(ctx2 instanceof ProgramLocationActionContext locCtx2)) {
+ return false;
+ }
+ Program prog1 = locCtx1.getProgram();
+ Program prog2 = locCtx2.getProgram();
+ if (prog1 != prog2) {
+ return false;
+ }
+ Address addr1 = locCtx1.getAddress();
+ Address addr2 = locCtx2.getAddress();
+ if (!Objects.equals(addr1, addr2)) {
+ return false;
+ }
+ return true;
+ }
+ if (ctx1 instanceof DebuggerObjectActionContext objCtx1) {
+ if (!(ctx2 instanceof DebuggerObjectActionContext objCtx2)) {
+ return false;
+ }
+ return Objects.equals(objCtx1.getObjectValues(), objCtx2.getObjectValues());
+ }
+ return true; // Treat all unknowns as same.
}
@Override
public void contextChanged(ActionContext context) {
+ boolean same = isSameContext(this.context, context);
this.context = context;
- updateActionsEnabled();
+ if (same) {
+ return;
+ }
+ updateTargetStepExtActions();
+ updateActions();
}
protected void createActions() {
- actionControlMode = new ControlModeAction();
+ actionControlMode = new ControlModeAction(this);
tool.addAction(actionControlMode);
+ actionTargetResume = TargetResumeAction.builder(this)
+ .build();
+ actionTargetInterrupt = TargetInterruptAction.builder(this)
+ .build();
+ actionTargetKill = TargetKillAction.builder(this)
+ .build();
+ actionTargetStepInto = TargetStepIntoAction.builder(this)
+ .build();
+ actionTargetStepOver = TargetStepOverAction.builder(this)
+ .build();
+ actionTargetStepOut = TargetStepOutAction.builder(this)
+ .build();
actionTargetDisconnect = DisconnectAction.builder(this)
.enabledWhen(this::isActionTargetDisconnectEnabled)
.onAction(this::activatedTargetDisconnect)
.build();
- updateTargetActions();
+ actionsTarget = Set.of(actionTargetResume, actionTargetInterrupt, actionTargetKill,
+ actionTargetStepInto, actionTargetStepOver, actionTargetStepOut,
+ actionTargetDisconnect);
+ updateTargetStepExtActions();
actionEmulateResume = EmulateResumeAction.builder(this)
.enabledWhen(this::isActionEmulateResumeEnabled)
@@ -537,51 +277,37 @@ public class DebuggerControlPlugin extends AbstractDebuggerPlugin
.build();
actionsTrace = Set.of(actionTraceSnapBackward, actionTraceSnapForward);
- actionSets = Set.of(actionsTarget, actionsEmulate, actionsTrace);
+ actionSets = Set.of(actionsTargetAll, actionsEmulate, actionsTrace);
updateActions();
}
- protected interface TargetActionBuilderFactory
- extends BiFunction<String, DebuggerControlPlugin, ActionBuilder> {
+ protected void runTask(String title, ActionEntry entry) {
+ tool.execute(new TargetActionTask(title, entry));
}
- protected DockingAction buildTargetAction(TargetActionBuilderFactory factory,
- ActionEntry entry) {
- return factory.apply(entry.display(), this)
- .description(entry.details())
- .enabledWhen(ctx -> entry.isEnabled())
- .onAction(ctx -> runTask(entry))
- .build();
- }
-
- protected void runTask(ActionEntry entry) {
- tool.execute(new TargetActionTask(entry));
- }
-
- protected void addTargetActionsForName(Target target, ActionName name,
- TargetActionBuilderFactory factory) {
- for (ActionEntry entry : target.collectActions(name, context).values()) {
+ protected void addTargetStepExtActions(Target target) {
+ for (ActionEntry entry : target.collectActions(ActionName.STEP_EXT, context).values()) {
if (entry.requiresPrompt()) {
continue;
}
- actionsTarget.add(buildTargetAction(factory, entry));
+ actionsTargetStepExt.add(TargetStepExtAction.builder(entry.display(), this)
+ .description(entry.details())
+ .enabledWhen(ctx -> entry.isEnabled())
+ .onAction(ctx -> runTask(entry.display(), entry))
+ .build());
}
}
/**
- * This is for testing purposes only. Fetch an action from "targetActions" whose name matches
- * that given.
- *
- * <p>
- * Since the tests are still assuming {@link TraceRecorderTarget}s, actions can be reliably
- * retrieved by name.
+ * This is for testing purposes only. Fetch an action from {@link #actionsTargetStepExt} whose
+ * name matches that given.
*
* @param name the action name
* @return the action, or null
*/
- /* testing */ DockingAction getTargetAction(String name) {
- for (DockingAction action : actionsTarget) {
+ /* testing */ DockingAction getTargetStepExtAction(String name) {
+ for (DockingAction action : actionsTargetStepExt) {
if (name.equals(action.getName())) {
return action;
}
@@ -589,23 +315,19 @@ public class DebuggerControlPlugin extends AbstractDebuggerPlugin
return null;
}
- protected void updateTargetActions() {
- hideActions(actionsTarget);
- actionsTarget.clear();
- actionsTarget.add(actionTargetDisconnect);
+ protected void updateTargetStepExtActions() {
+ hideActions(actionsTargetStepExt);
+ actionsTargetStepExt.clear();
+ actionsTargetAll.clear();
+ actionsTargetAll.addAll(actionsTarget);
Target target = current.getTarget();
if (target == null || !target.isValid()) {
return;
}
- addTargetActionsForName(target, ActionName.RESUME, TargetResumeAction::builder);
- addTargetActionsForName(target, ActionName.INTERRUPT, TargetInterruptAction::builder);
- addTargetActionsForName(target, ActionName.KILL, TargetKillAction::builder);
- addTargetActionsForName(target, ActionName.STEP_INTO, TargetStepIntoAction::builder);
- addTargetActionsForName(target, ActionName.STEP_OVER, TargetStepOverAction::builder);
- addTargetActionsForName(target, ActionName.STEP_OUT, TargetStepOutAction::builder);
- addTargetActionsForName(target, ActionName.STEP_EXT, TargetStepExtAction::builder);
+ addTargetStepExtActions(target);
+ actionsTargetAll.addAll(actionsTargetStepExt);
}
protected void activateControlMode(ActionState<ControlMode> state, EventTrigger trigger) {
@@ -792,7 +514,9 @@ public class DebuggerControlPlugin extends AbstractDebuggerPlugin
}
protected void coordinatesActivated(DebuggerCoordinates coords) {
+ boolean sameTrace = true;
if (current.getTrace() != coords.getTrace()) {
+ sameTrace = false;
if (current.getTrace() != null) {
current.getTrace().removeListener(listenerForObjects);
}
@@ -801,11 +525,13 @@ public class DebuggerControlPlugin extends AbstractDebuggerPlugin
}
}
current = coords;
- updateTargetActions();
+ if (!sameTrace) {
+ updateTargetStepExtActions();
+ }
updateActions();
}
- private ControlMode computeCurrentEditingMode() {
+ private ControlMode computeCurrentControlMode() {
if (controlService == null) {
return ControlMode.DEFAULT;
}
@@ -819,9 +545,6 @@ public class DebuggerControlPlugin extends AbstractDebuggerPlugin
if (tool == null) {
return;
}
- if (curActionSet == actions) {
- curActionSet = null;
- }
for (DockingActionIf action : actions) {
tool.removeAction(action);
}
@@ -831,17 +554,16 @@ public class DebuggerControlPlugin extends AbstractDebuggerPlugin
if (tool == null) {
return;
}
- if (curActionSet == actions) {
- return;
- }
+ Set<DockingActionIf> already = tool.getDockingActionsByOwnerName(name);
for (DockingActionIf action : actions) {
- tool.addAction(action);
+ if (!already.contains(action)) {
+ tool.addAction(action);
+ }
}
- curActionSet = actions;
}
private void updateActions() {
- ControlMode mode = computeCurrentEditingMode();
+ ControlMode mode = computeCurrentControlMode();
actionControlMode.setCurrentActionStateByUserData(mode);
Set<DockingAction> actions = getActionSet(mode);
@@ -860,6 +582,7 @@ public class DebuggerControlPlugin extends AbstractDebuggerPlugin
if (current.getTrace() == trace) {
trace.removeListener(listenerForObjects);
current = DebuggerCoordinates.NOWHERE;
+ updateTargetStepExtActions();
}
updateActions();
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/DebuggerMethodActionsPlugin.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/DebuggerMethodActionsPlugin.java
index e4f5ef7eeb..9ffcd44382 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/DebuggerMethodActionsPlugin.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/DebuggerMethodActionsPlugin.java
@@ -23,8 +23,10 @@ import docking.Tool;
import docking.action.*;
import docking.actions.PopupActionProvider;
import ghidra.app.context.ProgramActionContext;
+import ghidra.app.context.ProgramLocationActionContext;
import ghidra.app.plugin.PluginCategoryNames;
import ghidra.app.plugin.core.debug.DebuggerPluginPackage;
+import ghidra.app.plugin.core.debug.gui.model.DebuggerObjectActionContext;
import ghidra.app.services.*;
import ghidra.debug.api.control.ControlMode;
import ghidra.debug.api.target.Target;
@@ -62,7 +64,7 @@ public class DebuggerMethodActionsPlugin extends Plugin implements PopupActionPr
@Override
public void actionPerformed(ActionContext context) {
- tool.execute(new TargetActionTask(entry));
+ tool.execute(new TargetActionTask(entry.display(), entry));
}
}
@@ -95,11 +97,28 @@ public class DebuggerMethodActionsPlugin extends Plugin implements PopupActionPr
return mode.isTarget();
}
+ /**
+ * While it may be possible to retrieve sufficient context from the "current state," it's not
+ * always appropriate to display all of these actions. They should really only appear when an
+ * address is clearly intended, or when a trace object is clearly intended. We'll have to see
+ * how/if this works in the type-specific trace object tables, e.g., the Modules panel.
+ */
+ protected boolean isAppropriate(ActionContext context) {
+ if (context instanceof ProgramLocationActionContext) {
+ return true;
+ }
+ if (context instanceof DebuggerObjectActionContext) {
+ return true;
+ }
+ return false;
+ }
+
@Override
public List<DockingActionIf> getPopupActions(Tool tool, ActionContext context) {
- if (!isControlTarget()) {
+ if (!isControlTarget() || !isAppropriate(context)) {
return List.of();
}
+
Target target = getTarget(context);
if (target == null) {
return List.of();
@@ -107,6 +126,9 @@ public class DebuggerMethodActionsPlugin extends Plugin implements PopupActionPr
List<DockingActionIf> result = new ArrayList<>();
for (ActionEntry entry : target.collectActions(null, context).values()) {
+ if (entry.requiresPrompt() || entry.builtIn()) {
+ continue;
+ }
result.add(new InvokeActionEntryAction(entry));
}
return result;
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/DisconnectAction.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/DisconnectAction.java
new file mode 100644
index 0000000000..69260c5a0b
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/DisconnectAction.java
@@ -0,0 +1,46 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.control;
+
+import java.awt.event.KeyEvent;
+
+import javax.swing.Icon;
+import javax.swing.KeyStroke;
+
+import docking.action.builder.ActionBuilder;
+import ghidra.app.plugin.core.debug.gui.DebuggerResources;
+import ghidra.framework.plugintool.Plugin;
+import ghidra.util.HelpLocation;
+
+interface DisconnectAction extends ControlAction {
+ String NAME = "Disconnect";
+ String DESCRIPTION = "Close the connection to the debugging agent";
+ Icon ICON = DebuggerResources.ICON_DISCONNECT;
+ String HELP_ANCHOR = "target_disconnect";
+ int SUB_GROUP = 3;
+ KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_K,
+ KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK);
+
+ static ActionBuilder builder(Plugin owner) {
+ String ownerName = owner.getName();
+ return new ActionBuilder(NAME, ownerName)
+ .description(DESCRIPTION)
+ .toolBarIcon(ICON)
+ .toolBarGroup(GROUP, ControlAction.intSubGroup(SUB_GROUP))
+ .keyBinding(KEY_BINDING)
+ .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/EmulateInterruptAction.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/EmulateInterruptAction.java
new file mode 100644
index 0000000000..b7c90d9aec
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/EmulateInterruptAction.java
@@ -0,0 +1,36 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.control;
+
+import docking.action.builder.ActionBuilder;
+import ghidra.framework.plugintool.Plugin;
+import ghidra.util.HelpLocation;
+
+interface EmulateInterruptAction extends InterruptAction {
+ String NAME = "Interrupt Emulator";
+ String DESCRIPTION = "Interrupt, i.e., suspend, the integrated emulator";
+ String HELP_ANCHOR = "emu_interrupt";
+
+ static ActionBuilder builder(Plugin owner) {
+ String ownerName = owner.getName();
+ return new ActionBuilder(NAME, ownerName)
+ .description(DESCRIPTION)
+ .toolBarIcon(ICON)
+ .toolBarGroup(GROUP, ControlAction.intSubGroup(SUB_GROUP))
+ .keyBinding(KEY_BINDING)
+ .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/EmulateResumeAction.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/EmulateResumeAction.java
new file mode 100644
index 0000000000..7a62b3e126
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/EmulateResumeAction.java
@@ -0,0 +1,36 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.control;
+
+import docking.action.builder.ActionBuilder;
+import ghidra.framework.plugintool.Plugin;
+import ghidra.util.HelpLocation;
+
+interface EmulateResumeAction extends ResumeAction {
+ String NAME = "Resume Emulator";
+ String DESCRIPTION = "Resume, i.e., go or continue execution of the integrated emulator";
+ String HELP_ANCHOR = "emu_resume";
+
+ static ActionBuilder builder(Plugin owner) {
+ String ownerName = owner.getName();
+ return new ActionBuilder(NAME, ownerName)
+ .description(DESCRIPTION)
+ .toolBarIcon(ICON)
+ .toolBarGroup(GROUP, ControlAction.intSubGroup(SUB_GROUP))
+ .keyBinding(KEY_BINDING)
+ .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/EmulateSkipOverAction.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/EmulateSkipOverAction.java
new file mode 100644
index 0000000000..2d669dfe8a
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/EmulateSkipOverAction.java
@@ -0,0 +1,46 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.control;
+
+import java.awt.event.KeyEvent;
+
+import javax.swing.Icon;
+import javax.swing.KeyStroke;
+
+import docking.action.builder.ActionBuilder;
+import ghidra.app.plugin.core.debug.gui.DebuggerResources;
+import ghidra.framework.plugintool.Plugin;
+import ghidra.util.HelpLocation;
+
+interface EmulateSkipOverAction extends ControlAction {
+ String NAME = "Skip Emulator";
+ String DESCRIPTION =
+ "Skip the integrated emulator a single instruction, ignoring its effects";
+ Icon ICON = DebuggerResources.ICON_SKIP_OVER;
+ String HELP_ANCHOR = "emu_skip_over";
+ int SUB_GROUP = 7;
+ KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_F10, KeyEvent.CTRL_DOWN_MASK);
+
+ static ActionBuilder builder(Plugin owner) {
+ String ownerName = owner.getName();
+ return new ActionBuilder(NAME, ownerName)
+ .description(DESCRIPTION)
+ .toolBarIcon(ICON)
+ .toolBarGroup(GROUP, ControlAction.intSubGroup(SUB_GROUP))
+ .keyBinding(KEY_BINDING)
+ .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/EmulateStepBackAction.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/EmulateStepBackAction.java
new file mode 100644
index 0000000000..87b6b7a32e
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/EmulateStepBackAction.java
@@ -0,0 +1,45 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.control;
+
+import java.awt.event.KeyEvent;
+
+import javax.swing.Icon;
+import javax.swing.KeyStroke;
+
+import docking.action.builder.ActionBuilder;
+import ghidra.app.plugin.core.debug.gui.DebuggerResources;
+import ghidra.framework.plugintool.Plugin;
+import ghidra.util.HelpLocation;
+
+interface EmulateStepBackAction extends ControlAction {
+ String NAME = "Step Emulator Back";
+ String DESCRIPTION = "Step the integrated emulator a single instruction backward";
+ Icon ICON = DebuggerResources.ICON_STEP_BACK;
+ String HELP_ANCHOR = "emu_step_back";
+ int SUB_GROUP = 4;
+ KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0);
+
+ static ActionBuilder builder(Plugin owner) {
+ String ownerName = owner.getName();
+ return new ActionBuilder(NAME, ownerName)
+ .description(DESCRIPTION)
+ .toolBarIcon(ICON)
+ .toolBarGroup(GROUP, ControlAction.intSubGroup(SUB_GROUP))
+ .keyBinding(KEY_BINDING)
+ .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/EmulateStepIntoAction.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/EmulateStepIntoAction.java
new file mode 100644
index 0000000000..e05de1d134
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/EmulateStepIntoAction.java
@@ -0,0 +1,37 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.control;
+
+import docking.action.builder.ActionBuilder;
+import ghidra.framework.plugintool.Plugin;
+import ghidra.util.HelpLocation;
+
+interface EmulateStepIntoAction extends StepIntoAction {
+ String NAME = "Step Emulator Into";
+ String DESCRIPTION =
+ "Step the integrated emulator a single instruction, descending into calls";
+ String HELP_ANCHOR = "emu_step_into";
+
+ static ActionBuilder builder(Plugin owner) {
+ String ownerName = owner.getName();
+ return new ActionBuilder(NAME, ownerName)
+ .description(DESCRIPTION)
+ .toolBarIcon(ICON)
+ .toolBarGroup(GROUP, ControlAction.intSubGroup(SUB_GROUP))
+ .keyBinding(KEY_BINDING)
+ .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
+ }
+}
diff --git a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/app/services/DebuggerWorkflowService.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/InterruptAction.java
similarity index 59%
rename from Ghidra/Debug/Debugger-api/src/main/java/ghidra/app/services/DebuggerWorkflowService.java
rename to Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/InterruptAction.java
index 94d250c86f..fb1bd82c1c 100644
--- a/Ghidra/Debug/Debugger-api/src/main/java/ghidra/app/services/DebuggerWorkflowService.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/InterruptAction.java
@@ -13,23 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package ghidra.app.services;
+package ghidra.app.plugin.core.debug.gui.control;
-import java.util.Set;
+import java.awt.event.KeyEvent;
-import ghidra.debug.api.workflow.DebuggerBot;
-import ghidra.framework.plugintool.PluginTool;
+import javax.swing.Icon;
+import javax.swing.KeyStroke;
-public interface DebuggerWorkflowService {
- PluginTool getTool();
+import ghidra.app.plugin.core.debug.gui.DebuggerResources;
- Set<DebuggerBot> getAllBots();
-
- Set<DebuggerBot> getEnabledBots();
-
- Set<DebuggerBot> getDisabledBots();
-
- void enableBots(Set<DebuggerBot> actors);
-
- void disableBots(Set<DebuggerBot> actors);
+interface InterruptAction extends ControlAction {
+ Icon ICON = DebuggerResources.ICON_INTERRUPT;
+ int SUB_GROUP = 1;
+ KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_I, KeyEvent.CTRL_DOWN_MASK);
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/ResumeAction.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/ResumeAction.java
new file mode 100644
index 0000000000..a3daffc7d3
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/ResumeAction.java
@@ -0,0 +1,29 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.control;
+
+import java.awt.event.KeyEvent;
+
+import javax.swing.Icon;
+import javax.swing.KeyStroke;
+
+import ghidra.app.plugin.core.debug.gui.DebuggerResources;
+
+interface ResumeAction extends ControlAction {
+ Icon ICON = DebuggerResources.ICON_RESUME;
+ int SUB_GROUP = 0;
+ KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0);
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/StepIntoAction.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/StepIntoAction.java
new file mode 100644
index 0000000000..124ad7556a
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/StepIntoAction.java
@@ -0,0 +1,29 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.control;
+
+import java.awt.event.KeyEvent;
+
+import javax.swing.Icon;
+import javax.swing.KeyStroke;
+
+import ghidra.app.plugin.core.debug.gui.DebuggerResources;
+
+interface StepIntoAction extends ControlAction {
+ Icon ICON = DebuggerResources.ICON_STEP_INTO;
+ int SUB_GROUP = 5;
+ KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0);
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetActionBuilder.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetActionBuilder.java
new file mode 100644
index 0000000000..8bac04b8cc
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetActionBuilder.java
@@ -0,0 +1,70 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.control;
+
+import docking.ActionContext;
+import docking.action.builder.AbstractActionBuilder;
+import ghidra.debug.api.target.ActionName;
+
+class TargetActionBuilder
+ extends AbstractActionBuilder<TargetDockingAction, ActionContext, TargetActionBuilder> {
+ private final DebuggerControlPlugin plugin;
+
+ private ActionName action;
+ private String defaultDescription;
+
+ public TargetActionBuilder(String name, DebuggerControlPlugin plugin) {
+ super(name, plugin.getName());
+ this.plugin = plugin;
+ }
+
+ @Override
+ protected TargetActionBuilder self() {
+ return this;
+ }
+
+ @Override
+ protected void validate() {
+ super.validate();
+ if (action == null) {
+ throw new IllegalStateException(
+ "Can't build a " + TargetDockingAction.class.getSimpleName() +
+ " without an action name");
+ }
+ }
+
+ public TargetActionBuilder action(ActionName action) {
+ this.action = action;
+ return self();
+ }
+
+ public TargetActionBuilder defaultDescription(String defaultDescription) {
+ this.defaultDescription = defaultDescription;
+ return self();
+ }
+
+ @Override
+ public TargetDockingAction build() {
+ onAction(ctx -> {
+ // Make the super.validate() hush
+ });
+ validate();
+ TargetDockingAction result = new TargetDockingAction(name, owner, keyBindingType, plugin,
+ action, defaultDescription);
+ decorateAction(result);
+ return result;
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetActionTask.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetActionTask.java
index 5839abb4c6..bcfcec2358 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetActionTask.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetActionTask.java
@@ -23,8 +23,8 @@ import ghidra.util.task.TaskMonitor;
class TargetActionTask extends Task {
private ActionEntry entry;
- public TargetActionTask(ActionEntry entry) {
- super(entry.display(), false, false, false);
+ public TargetActionTask(String title, ActionEntry entry) {
+ super(title, false, false, false);
this.entry = entry;
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetDockingAction.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetDockingAction.java
new file mode 100644
index 0000000000..17d1028065
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetDockingAction.java
@@ -0,0 +1,78 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.control;
+
+import docking.ActionContext;
+import docking.action.DockingAction;
+import docking.action.KeyBindingType;
+import ghidra.debug.api.target.ActionName;
+import ghidra.debug.api.target.Target;
+import ghidra.debug.api.target.Target.ActionEntry;
+
+class TargetDockingAction extends DockingAction {
+ private final DebuggerControlPlugin plugin;
+ private final ActionName action;
+ private final String defaultDescription;
+
+ private ActionEntry entry;
+
+ public TargetDockingAction(String name, String owner, KeyBindingType keyBindingType,
+ DebuggerControlPlugin plugin, ActionName action, String defaultDescription) {
+ super(name, owner, keyBindingType);
+ this.plugin = plugin;
+ this.action = action;
+ this.defaultDescription = defaultDescription;
+ }
+
+ private ActionEntry findEntry(ActionContext context) {
+ Target target = plugin.current.getTarget();
+ if (target == null) {
+ return null;
+ }
+ for (ActionEntry ent : target.collectActions(action, context).values()) {
+ if (ent.requiresPrompt()) {
+ continue;
+ }
+ return ent;
+ // TODO: What if multiple match? Do I care to display the extras?
+ }
+ return null;
+ }
+
+ protected void updateFromContext(ActionContext context) {
+ entry = findEntry(context);
+ if (entry == null) {
+ setDescription(defaultDescription);
+ }
+ else {
+ setDescription(entry.details());
+ }
+ }
+
+ @Override
+ public boolean isEnabledForContext(ActionContext context) {
+ updateFromContext(context);
+ return entry != null && entry.isEnabled();
+ }
+
+ @Override
+ public void actionPerformed(ActionContext context) {
+ if (entry == null) {
+ return;
+ }
+ plugin.runTask(getName(), entry);
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetInterruptAction.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetInterruptAction.java
new file mode 100644
index 0000000000..71161a0288
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetInterruptAction.java
@@ -0,0 +1,36 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.control;
+
+import ghidra.debug.api.target.ActionName;
+import ghidra.util.HelpLocation;
+
+interface TargetInterruptAction extends InterruptAction {
+ String NAME = "Interrupt";
+ String DESCRIPTION = "Interrupt the target";
+ String HELP_ANCHOR = "target_interrupt";
+
+ static TargetActionBuilder builder(DebuggerControlPlugin owner) {
+ String ownerName = owner.getName();
+ return new TargetActionBuilder(NAME, owner)
+ .action(ActionName.INTERRUPT)
+ .toolBarIcon(ICON)
+ .toolBarGroup(GROUP, ControlAction.intSubGroup(SUB_GROUP))
+ .keyBinding(KEY_BINDING)
+ .defaultDescription(DESCRIPTION)
+ .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetKillAction.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetKillAction.java
new file mode 100644
index 0000000000..95e9b227c8
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetKillAction.java
@@ -0,0 +1,46 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.control;
+
+import java.awt.event.KeyEvent;
+
+import javax.swing.Icon;
+import javax.swing.KeyStroke;
+
+import ghidra.app.plugin.core.debug.gui.DebuggerResources;
+import ghidra.debug.api.target.ActionName;
+import ghidra.util.HelpLocation;
+
+interface TargetKillAction extends ControlAction {
+ String NAME = "Kill";
+ String DESCRIPTION = "Kill the target";
+ Icon ICON = DebuggerResources.ICON_KILL;
+ String HELP_ANCHOR = "target_kill";
+ int SUB_GROUP = 2;
+ KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_K,
+ KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK);
+
+ static TargetActionBuilder builder(DebuggerControlPlugin owner) {
+ String ownerName = owner.getName();
+ return new TargetActionBuilder(NAME, owner)
+ .action(ActionName.KILL)
+ .toolBarIcon(ICON)
+ .toolBarGroup(GROUP, ControlAction.intSubGroup(SUB_GROUP))
+ .keyBinding(KEY_BINDING)
+ .defaultDescription(DESCRIPTION)
+ .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetResumeAction.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetResumeAction.java
new file mode 100644
index 0000000000..7f32e4c655
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetResumeAction.java
@@ -0,0 +1,36 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.control;
+
+import ghidra.debug.api.target.ActionName;
+import ghidra.util.HelpLocation;
+
+interface TargetResumeAction extends ResumeAction {
+ String NAME = "Resume";
+ String DESCRIPTION = "Resume the target";
+ String HELP_ANCHOR = "target_resume";
+
+ static TargetActionBuilder builder(DebuggerControlPlugin owner) {
+ String ownerName = owner.getName();
+ return new TargetActionBuilder(NAME, owner)
+ .action(ActionName.RESUME)
+ .toolBarIcon(ICON)
+ .toolBarGroup(GROUP, ControlAction.intSubGroup(SUB_GROUP))
+ .keyBinding(KEY_BINDING)
+ .defaultDescription(DESCRIPTION)
+ .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetStepExtAction.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetStepExtAction.java
new file mode 100644
index 0000000000..2167102f5c
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetStepExtAction.java
@@ -0,0 +1,41 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.control;
+
+import java.awt.event.KeyEvent;
+
+import javax.swing.Icon;
+import javax.swing.KeyStroke;
+
+import docking.action.builder.ActionBuilder;
+import ghidra.app.plugin.core.debug.gui.DebuggerResources;
+import ghidra.util.HelpLocation;
+
+interface TargetStepExtAction extends ControlAction {
+ Icon ICON = DebuggerResources.ICON_STEP_LAST;
+ String HELP_ANCHOR = "target_step_ext";
+ int SUB_GROUP = 9;
+ KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_F8, KeyEvent.CTRL_DOWN_MASK);
+
+ static ActionBuilder builder(String name, DebuggerControlPlugin owner) {
+ String ownerName = owner.getName();
+ return new ActionBuilder(name, ownerName)
+ .toolBarIcon(ICON)
+ .toolBarGroup(GROUP, ControlAction.intSubGroup(SUB_GROUP) + name)
+ .keyBinding(KEY_BINDING)
+ .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetStepIntoAction.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetStepIntoAction.java
new file mode 100644
index 0000000000..1e75b04259
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetStepIntoAction.java
@@ -0,0 +1,36 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.control;
+
+import ghidra.debug.api.target.ActionName;
+import ghidra.util.HelpLocation;
+
+interface TargetStepIntoAction extends StepIntoAction {
+ String NAME = "Step Into";
+ String DESCRIPTION = "Step the target into";
+ String HELP_ANCHOR = "target_step_into";
+
+ static TargetActionBuilder builder(DebuggerControlPlugin owner) {
+ String ownerName = owner.getName();
+ return new TargetActionBuilder(NAME, owner)
+ .action(ActionName.STEP_INTO)
+ .toolBarIcon(ICON)
+ .toolBarGroup(GROUP, ControlAction.intSubGroup(SUB_GROUP))
+ .keyBinding(KEY_BINDING)
+ .defaultDescription(DESCRIPTION)
+ .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetStepOutAction.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetStepOutAction.java
new file mode 100644
index 0000000000..3e9b510de2
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetStepOutAction.java
@@ -0,0 +1,45 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.control;
+
+import java.awt.event.KeyEvent;
+
+import javax.swing.Icon;
+import javax.swing.KeyStroke;
+
+import ghidra.app.plugin.core.debug.gui.DebuggerResources;
+import ghidra.debug.api.target.ActionName;
+import ghidra.util.HelpLocation;
+
+interface TargetStepOutAction extends ControlAction {
+ String NAME = "Step Out";
+ String DESCRIPTION = "Step the target out";
+ Icon ICON = DebuggerResources.ICON_STEP_FINISH;
+ String HELP_ANCHOR = "target_step_out";
+ int SUB_GROUP = 8;
+ KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0);
+
+ static TargetActionBuilder builder(DebuggerControlPlugin owner) {
+ String ownerName = owner.getName();
+ return new TargetActionBuilder(NAME, owner)
+ .action(ActionName.STEP_OUT)
+ .toolBarIcon(ICON)
+ .toolBarGroup(GROUP, ControlAction.intSubGroup(SUB_GROUP))
+ .keyBinding(KEY_BINDING)
+ .defaultDescription(DESCRIPTION)
+ .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetStepOverAction.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetStepOverAction.java
new file mode 100644
index 0000000000..c19b428a7b
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TargetStepOverAction.java
@@ -0,0 +1,45 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.control;
+
+import java.awt.event.KeyEvent;
+
+import javax.swing.Icon;
+import javax.swing.KeyStroke;
+
+import ghidra.app.plugin.core.debug.gui.DebuggerResources;
+import ghidra.debug.api.target.ActionName;
+import ghidra.util.HelpLocation;
+
+interface TargetStepOverAction extends ControlAction {
+ String NAME = "Step Over";
+ String DESCRIPTION = "Step the target over";
+ Icon ICON = DebuggerResources.ICON_STEP_OVER;
+ String HELP_ANCHOR = "target_step_over";
+ int SUB_GROUP = 6;
+ KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_F10, 0);
+
+ static TargetActionBuilder builder(DebuggerControlPlugin owner) {
+ String ownerName = owner.getName();
+ return new TargetActionBuilder(NAME, owner)
+ .action(ActionName.STEP_OVER)
+ .toolBarIcon(ICON)
+ .toolBarGroup(GROUP, ControlAction.intSubGroup(SUB_GROUP))
+ .keyBinding(KEY_BINDING)
+ .defaultDescription(DESCRIPTION)
+ .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TraceSnapBackwardAction.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TraceSnapBackwardAction.java
new file mode 100644
index 0000000000..5a1dcf67ab
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TraceSnapBackwardAction.java
@@ -0,0 +1,45 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.control;
+
+import java.awt.event.KeyEvent;
+
+import javax.swing.Icon;
+import javax.swing.KeyStroke;
+
+import docking.action.builder.ActionBuilder;
+import ghidra.app.plugin.core.debug.gui.DebuggerResources;
+import ghidra.framework.plugintool.Plugin;
+import ghidra.util.HelpLocation;
+
+interface TraceSnapBackwardAction extends ControlAction {
+ String NAME = "Trace Snapshot Backward";
+ String DESCRIPTION = "Navigate the trace recording backward one snapshot";
+ Icon ICON = DebuggerResources.ICON_SNAP_BACKWARD;
+ String HELP_ANCHOR = "trace_snap_backward";
+ int SUB_GROUP = 10;
+ KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0);
+
+ static ActionBuilder builder(Plugin owner) {
+ String ownerName = owner.getName();
+ return new ActionBuilder(NAME, ownerName)
+ .description(DESCRIPTION)
+ .toolBarIcon(ICON)
+ .toolBarGroup(GROUP, ControlAction.intSubGroup(SUB_GROUP))
+ .keyBinding(KEY_BINDING)
+ .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TraceSnapForwardAction.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TraceSnapForwardAction.java
new file mode 100644
index 0000000000..6afef2552b
--- /dev/null
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/control/TraceSnapForwardAction.java
@@ -0,0 +1,45 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.control;
+
+import java.awt.event.KeyEvent;
+
+import javax.swing.Icon;
+import javax.swing.KeyStroke;
+
+import docking.action.builder.ActionBuilder;
+import ghidra.app.plugin.core.debug.gui.DebuggerResources;
+import ghidra.framework.plugintool.Plugin;
+import ghidra.util.HelpLocation;
+
+interface TraceSnapForwardAction extends ControlAction {
+ String NAME = "Trace Snapshot Forward";
+ String DESCRIPTION = "Navigate the trace recording forward one snapshot";
+ Icon ICON = DebuggerResources.ICON_SNAP_FORWARD;
+ String HELP_ANCHOR = "trace_snap_backward";
+ int SUB_GROUP = 11;
+ KeyStroke KEY_BINDING = KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0);
+
+ static ActionBuilder builder(Plugin owner) {
+ String ownerName = owner.getName();
+ return new ActionBuilder(NAME, ownerName)
+ .description(DESCRIPTION)
+ .toolBarIcon(ICON)
+ .toolBarGroup(GROUP, ControlAction.intSubGroup(SUB_GROUP))
+ .keyBinding(KEY_BINDING)
+ .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/listing/DebuggerListingProvider.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/listing/DebuggerListingProvider.java
index 739106df93..5a71334840 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/listing/DebuggerListingProvider.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/listing/DebuggerListingProvider.java
@@ -38,6 +38,7 @@ import docking.ActionContext;
import docking.WindowPosition;
import docking.action.DockingAction;
import docking.action.ToggleDockingAction;
+import docking.action.builder.ToggleActionBuilder;
import docking.menu.MultiStateDockingAction;
import docking.widgets.EventTrigger;
import docking.widgets.fieldpanel.support.ViewerPosition;
@@ -47,6 +48,7 @@ import ghidra.app.nav.ListingPanelContainer;
import ghidra.app.plugin.core.clipboard.CodeBrowserClipboardProvider;
import ghidra.app.plugin.core.codebrowser.CodeViewerProvider;
import ghidra.app.plugin.core.codebrowser.MarkerServiceBackgroundColorModel;
+import ghidra.app.plugin.core.debug.disassemble.TraceDisassembleCommand;
import ghidra.app.plugin.core.debug.gui.DebuggerLocationLabel;
import ghidra.app.plugin.core.debug.gui.DebuggerResources;
import ghidra.app.plugin.core.debug.gui.DebuggerResources.FollowsCurrentThreadAction;
@@ -61,6 +63,8 @@ import ghidra.app.services.*;
import ghidra.app.services.DebuggerListingService.LocationTrackingSpecChangeListener;
import ghidra.app.util.viewer.format.FormatManager;
import ghidra.app.util.viewer.listingpanel.ListingPanel;
+import ghidra.async.AsyncDebouncer;
+import ghidra.async.AsyncTimer;
import ghidra.debug.api.action.GoToInput;
import ghidra.debug.api.action.LocationTrackingSpec;
import ghidra.debug.api.control.ControlMode;
@@ -69,11 +73,11 @@ import ghidra.debug.api.modules.DebuggerStaticMappingChangeListener;
import ghidra.debug.api.tracemgr.DebuggerCoordinates;
import ghidra.framework.model.DomainFile;
import ghidra.framework.options.SaveState;
-import ghidra.framework.plugintool.AutoConfigState;
-import ghidra.framework.plugintool.AutoService;
+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.listing.Instruction;
import ghidra.program.model.listing.Program;
import ghidra.program.util.ProgramLocation;
import ghidra.program.util.ProgramSelection;
@@ -114,6 +118,20 @@ public class DebuggerListingProvider extends CodeViewerProvider {
return true;
}
+ interface AutoDisassembleAction {
+ String NAME = "Auto-Disassembly";
+ String DESCRIPTION = "If the tracking spec follows the PC, disassemble automatically.";
+ String HELP_ANCHOR = "auto_disassembly";
+
+ static ToggleActionBuilder builder(Plugin owner) {
+ String ownerName = owner.getName();
+ return new ToggleActionBuilder(NAME, ownerName)
+ .description(DESCRIPTION)
+ .menuPath(NAME)
+ .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
+ }
+ }
+
protected class MarkerSetChangeListener implements ChangeListener {
@Override
public void stateChanged(ChangeEvent e) {
@@ -223,6 +241,14 @@ public class DebuggerListingProvider extends CodeViewerProvider {
@Override
protected void locationTracked() {
doGoToTracked();
+ if (!autoDisassemble || !trackingTrait.shouldDisassemble()) {
+ return;
+ }
+ disassemblyDebouncer.contact(trackedLocation.getByteAddress());
+ }
+
+ boolean shouldDisassemble() {
+ return trackedLocation != null && tracker.shouldDisassemble();
}
}
@@ -241,6 +267,18 @@ public class DebuggerListingProvider extends CodeViewerProvider {
protected void repaintPanel() {
getListingPanel().getFieldPanel().repaint();
}
+
+ @Override
+ protected void memoryWasRead(AddressSetView read) {
+ if (!autoDisassemble || !trackingTrait.shouldDisassemble()) {
+ return;
+ }
+ ProgramLocation loc = trackingTrait.getTrackedLocation();
+ if (!read.contains(loc.getByteAddress())) {
+ return;
+ }
+ disassemblyDebouncer.contact(loc.getByteAddress());
+ }
}
private final DebuggerListingPlugin plugin;
@@ -276,6 +314,7 @@ public class DebuggerListingProvider extends CodeViewerProvider {
protected DockingAction actionSyncSelectionIntoStaticListing;
protected DockingAction actionSyncSelectionFromStaticListing;
protected ToggleDockingAction actionFollowsCurrentThread;
+ protected ToggleDockingAction actionAutoDisassemble;
protected MultiStateDockingAction<AutoReadMemorySpec> actionAutoReadMemory;
protected DockingAction actionRefreshSelectedMemory;
protected DockingAction actionOpenProgram;
@@ -284,12 +323,17 @@ public class DebuggerListingProvider extends CodeViewerProvider {
@AutoConfigStateField
protected boolean followsCurrentThread = true;
// TODO: followsCurrentSnap?
+ @AutoConfigStateField
+ protected boolean autoDisassemble = true;
protected final ForListingSyncTrait syncTrait;
protected final ForListingGoToTrait goToTrait;
protected final ForListingTrackingTrait trackingTrait;
protected final ForListingReadsMemoryTrait readsMemTrait;
+ protected final AsyncDebouncer<Address> disassemblyDebouncer =
+ new AsyncDebouncer<>(AsyncTimer.DEFAULT_TIMER, 100);
+
protected final ListenerSet<LocationTrackingSpecChangeListener> trackingSpecChangeListeners =
new ListenerSet<>(LocationTrackingSpecChangeListener.class, true);
@@ -322,6 +366,8 @@ public class DebuggerListingProvider extends CodeViewerProvider {
trackingTrait = new ForListingTrackingTrait();
readsMemTrait = new ForListingReadsMemoryTrait();
+ disassemblyDebouncer.addListener(this::doAutoDisassemble);
+
ListingPanel listingPanel = getListingPanel();
colorModel = plugin.createListingBackgroundColorModel(listingPanel);
colorModel.addModel(trackingTrait.createListingBackgroundColorModel(listingPanel));
@@ -467,6 +513,7 @@ public class DebuggerListingProvider extends CodeViewerProvider {
actionFollowsCurrentThread.setSelected(followsCurrentThread);
updateBorder();
}
+ actionAutoDisassemble.setSelected(autoDisassemble);
}
@Override
@@ -705,6 +752,12 @@ public class DebuggerListingProvider extends CodeViewerProvider {
.buildAndInstallLocal(this);
}
+ actionAutoDisassemble = AutoDisassembleAction.builder(plugin)
+ .enabled(true)
+ .selected(true)
+ .onAction(ctx -> doSetAutoDisassemble(actionAutoDisassemble.isSelected()))
+ .buildAndInstallLocal(this);
+
actionSyncSelectionIntoStaticListing =
syncTrait.installSyncSelectionIntoStaticListingAction();
actionSyncSelectionFromStaticListing =
@@ -757,17 +810,16 @@ public class DebuggerListingProvider extends CodeViewerProvider {
* which applies to many things in general. This one is for changes in the listing model's
* "size", i.e., the memory mapping or assigned view has changed. This should be the perfect
* place to ensure the tracked location is centered, if applicable.
+ *
+ * <p>
+ * It seems this method gets called a bit spuriously. A change in bytes, which does not imply a
+ * change in layout, will also land us here. Thus, we do some simple test here to verify that
+ * the layout has actually changed. A good proxy is if the number of addresses in the listing
+ * has changed. To detect that, we have to record what we've seen each change.
*/
@Override
public void stateChanged(ChangeEvent e) {
super.stateChanged(e);
- /*
- * It seems this method gets called a bit spuriously. A change in bytes, which does not
- * imply a change in layout, will also land us here. Thus, we do some simple test here to
- * verify that the layout has actually changed. A good proxy is if the number of addresses
- * in the listing has changed. To detect that, we have to record what we've seen each
- * change.
- */
long newCountAddressesInIndex =
getListingPanel().getAddressIndexMap().getIndexedAddressSet().getNumAddresses();
if (this.countAddressesInIndex == newCountAddressesInIndex) {
@@ -776,7 +828,12 @@ public class DebuggerListingProvider extends CodeViewerProvider {
this.countAddressesInIndex = newCountAddressesInIndex;
ProgramLocation trackedLocation = trackingTrait.getTrackedLocation();
if (trackedLocation != null && !isEffectivelyDifferent(getLocation(), trackedLocation)) {
- cbGoTo.invoke(() -> getListingPanel().goTo(trackedLocation, true));
+ cbGoTo.invoke(() -> Swing.runLater(() -> {
+ boolean goneTo = getListingPanel().goTo(trackedLocation, true);
+ if (goneTo) {
+ getListingPanel().center(trackedLocation);
+ }
+ }));
}
}
@@ -1037,6 +1094,15 @@ public class DebuggerListingProvider extends CodeViewerProvider {
coordinatesActivated(traceManager.getCurrent());
}
+ public void setAutoDisassemble(boolean auto) {
+ actionAutoDisassemble.setSelected(true);
+ doSetAutoDisassemble(auto);
+ }
+
+ protected void doSetAutoDisassemble(boolean auto) {
+ this.autoDisassemble = auto;
+ }
+
protected void updateBorder() {
// TODO: Probably make this accessible from abstract class, instead
ListingPanelContainer decoration = (ListingPanelContainer) getComponent();
@@ -1047,6 +1113,10 @@ public class DebuggerListingProvider extends CodeViewerProvider {
return followsCurrentThread;
}
+ public boolean isAutoDisassemble() {
+ return autoDisassemble;
+ }
+
public void setAutoReadMemorySpec(AutoReadMemorySpec spec) {
readsMemTrait.setAutoSpec(spec);
}
@@ -1113,6 +1183,27 @@ public class DebuggerListingProvider extends CodeViewerProvider {
}
}
+ protected void doAutoDisassemble(Address start) {
+ TraceProgramView view = current.getView();
+ if (view == null) {
+ return;
+ }
+ /**
+ * We'll avoid re-disassembly only if there already exists an instruction <em>at the start
+ * address</em>. If it's in the middle, then we're off cut and should re-disassemble at the
+ * new start.
+ */
+ Instruction exists = view.getListing().getInstructionAt(start);
+ if (exists != null) {
+ return;
+ }
+ AddressSpace space = start.getAddressSpace();
+ AddressSet set = new AddressSet(space.getMinAddress(), space.getMaxAddress());
+ TraceDisassembleCommand dis =
+ new TraceDisassembleCommand(current.getPlatform(), start, set);
+ dis.run(tool, view);
+ }
+
@Override
public void dispose() {
super.dispose();
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/AbstractObjectsTableBasedPanel.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/AbstractObjectsTableBasedPanel.java
index bb2de30f08..e212883c10 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/AbstractObjectsTableBasedPanel.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/AbstractObjectsTableBasedPanel.java
@@ -115,7 +115,7 @@ public abstract class AbstractObjectsTableBasedPanel<U extends TraceObjectInterf
List<ValueRow> sel = getSelectedItems();
if (!sel.isEmpty()) {
myActionContext = new DebuggerObjectActionContext(
- sel.stream().map(r -> r.getValue()).collect(Collectors.toList()), provider, this);
+ sel.stream().map(r -> r.getValue()).collect(Collectors.toList()), provider, table);
}
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/DisplaysObjectValues.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/DisplaysObjectValues.java
index 523c380897..e2ef7d4d03 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/DisplaysObjectValues.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/DisplaysObjectValues.java
@@ -15,10 +15,15 @@
*/
package ghidra.app.plugin.core.debug.gui.model;
+import java.util.stream.*;
+
+import org.apache.commons.lang3.ArrayUtils;
+
import ghidra.dbg.target.TargetObject;
import ghidra.trace.model.target.TraceObject;
import ghidra.trace.model.target.TraceObjectValue;
import ghidra.util.HTMLUtilities;
+import ghidra.util.NumericUtilities;
public interface DisplaysObjectValues {
long getSnap();
@@ -27,6 +32,38 @@ public interface DisplaysObjectValues {
return "";
}
+ default String getBoolsDisplay(boolean[] bools) {
+ return Stream.of(ArrayUtils.toObject(bools))
+ .map(b -> b ? "T" : "F")
+ .collect(Collectors.joining(":"));
+ }
+
+ default String getBytesDisplay(byte[] bytes) {
+ return NumericUtilities.convertBytesToString(bytes, ":");
+ }
+
+ default String getCharsDisplay(char[] chars) {
+ return new String(chars);
+ }
+
+ default String getShortsDisplay(short[] shorts) {
+ return Stream.of(ArrayUtils.toObject(shorts))
+ .map(s -> "%04x".formatted(s))
+ .collect(Collectors.joining(":"));
+ }
+
+ default String getIntsDisplay(int[] ints) {
+ return IntStream.of(ints)
+ .mapToObj(i -> "%08x".formatted(i))
+ .collect(Collectors.joining(":"));
+ }
+
+ default String getLongsDisplay(long[] longs) {
+ return LongStream.of(longs)
+ .mapToObj(l -> "%016x".formatted(l))
+ .collect(Collectors.joining(":"));
+ }
+
default String getPrimitiveValueDisplay(Object value) {
assert !(value instanceof TraceObject);
assert !(value instanceof TraceObjectValue);
@@ -34,6 +71,24 @@ public interface DisplaysObjectValues {
if (value == null) {
return getNullDisplay();
}
+ if (value instanceof boolean[] bools) {
+ return getBoolsDisplay(bools);
+ }
+ if (value instanceof byte[] bytes) {
+ return getBytesDisplay(bytes);
+ }
+ if (value instanceof char[] chars) {
+ return getCharsDisplay(chars);
+ }
+ if (value instanceof short[] shorts) {
+ return getShortsDisplay(shorts);
+ }
+ if (value instanceof int[] ints) {
+ return getIntsDisplay(ints);
+ }
+ if (value instanceof long[] longs) {
+ return getLongsDisplay(longs);
+ }
return value.toString();
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/ObjectTableModel.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/ObjectTableModel.java
index af156d8b08..91f9a0965e 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/ObjectTableModel.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/ObjectTableModel.java
@@ -17,8 +17,9 @@ package ghidra.app.plugin.core.debug.gui.model;
import java.awt.Color;
import java.util.*;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
+import java.util.stream.*;
+
+import org.apache.commons.lang3.ArrayUtils;
import docking.widgets.table.DynamicTableColumn;
import docking.widgets.table.RangeCursorTableHeaderRenderer.SeekListener;
@@ -38,6 +39,7 @@ import ghidra.trace.model.Trace;
import ghidra.trace.model.target.TraceObject;
import ghidra.trace.model.target.TraceObjectValue;
import ghidra.util.HTMLUtilities;
+import ghidra.util.NumericUtilities;
public class ObjectTableModel extends AbstractQueryTableModel<ValueRow> {
@@ -61,7 +63,36 @@ public class ObjectTableModel extends AbstractQueryTableModel<ValueRow> {
default public String getDisplay() {
T value = getValue();
- return value == null ? "" : value.toString();
+ if (value == null) {
+ return "";
+ }
+ if (value instanceof boolean[] bools) {
+ return Stream.of(ArrayUtils.toObject(bools))
+ .map(b -> b ? "T" : "F")
+ .collect(Collectors.joining(":"));
+ }
+ if (value instanceof byte[] bytes) {
+ return NumericUtilities.convertBytesToString(bytes, ":");
+ }
+ if (value instanceof char[] chars) {
+ return new String(chars);
+ }
+ if (value instanceof short[] shorts) {
+ return Stream.of(ArrayUtils.toObject(shorts))
+ .map(s -> "%04x".formatted(s))
+ .collect(Collectors.joining(":"));
+ }
+ if (value instanceof int[] ints) {
+ return IntStream.of(ints)
+ .mapToObj(i -> "%08x".formatted(i))
+ .collect(Collectors.joining(":"));
+ }
+ if (value instanceof long[] longs) {
+ return LongStream.of(longs)
+ .mapToObj(l -> "%016x".formatted(l))
+ .collect(Collectors.joining(":"));
+ }
+ return value.toString();
}
default public String getHtmlDisplay() {
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesPlugin.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesPlugin.java
index 450f4de9d3..c8412106e0 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesPlugin.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesPlugin.java
@@ -21,6 +21,7 @@ import ghidra.app.plugin.core.debug.AbstractDebuggerPlugin;
import ghidra.app.plugin.core.debug.DebuggerPluginPackage;
import ghidra.app.plugin.core.debug.event.TraceActivatedPluginEvent;
import ghidra.app.services.*;
+import ghidra.framework.options.SaveState;
import ghidra.framework.plugintool.*;
import ghidra.framework.plugintool.util.PluginStatus;
@@ -81,4 +82,14 @@ public class DebuggerModulesPlugin extends AbstractDebuggerPlugin {
provider.coordinatesActivated(ev.getActiveCoordinates());
}
}
+
+ @Override
+ public void readConfigState(SaveState saveState) {
+ provider.readConfigState(saveState);
+ }
+
+ @Override
+ public void writeConfigState(SaveState saveState) {
+ provider.writeConfigState(saveState);
+ }
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProvider.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProvider.java
index 46f98cee07..b29fa6cfec 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProvider.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProvider.java
@@ -17,6 +17,7 @@ package ghidra.app.plugin.core.debug.gui.modules;
import java.awt.event.MouseEvent;
import java.io.File;
+import java.lang.invoke.MethodHandles;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;
@@ -28,12 +29,20 @@ import org.apache.commons.lang3.ArrayUtils;
import docking.*;
import docking.action.*;
import docking.action.builder.ActionBuilder;
+import docking.action.builder.MultiStateActionBuilder;
+import docking.menu.ActionState;
+import docking.menu.MultiStateDockingAction;
+import docking.widgets.EventTrigger;
import docking.widgets.filechooser.GhidraFileChooser;
import ghidra.app.plugin.core.debug.DebuggerPluginPackage;
import ghidra.app.plugin.core.debug.gui.DebuggerBlockChooserDialog;
import ghidra.app.plugin.core.debug.gui.DebuggerResources;
import ghidra.app.plugin.core.debug.gui.DebuggerResources.*;
+import ghidra.app.plugin.core.debug.gui.action.AutoMapSpec;
+import ghidra.app.plugin.core.debug.gui.action.AutoMapSpec.AutoMapSpecConfigFieldCodec;
+import ghidra.app.plugin.core.debug.gui.action.ByModuleAutoMapSpec;
import ghidra.app.plugin.core.debug.gui.model.DebuggerObjectActionContext;
+import ghidra.app.plugin.core.debug.service.model.TraceRecorderTarget;
import ghidra.app.plugin.core.debug.service.modules.MapModulesBackgroundCommand;
import ghidra.app.plugin.core.debug.service.modules.MapSectionsBackgroundCommand;
import ghidra.app.services.*;
@@ -44,7 +53,9 @@ import ghidra.debug.api.tracemgr.DebuggerCoordinates;
import ghidra.framework.main.AppInfo;
import ghidra.framework.main.DataTreeDialog;
import ghidra.framework.model.*;
+import ghidra.framework.options.SaveState;
import ghidra.framework.plugintool.*;
+import ghidra.framework.plugintool.annotation.AutoConfigStateField;
import ghidra.framework.plugintool.annotation.AutoServiceConsumed;
import ghidra.framework.plugintool.util.PluginException;
import ghidra.program.model.address.*;
@@ -53,11 +64,15 @@ import ghidra.program.model.mem.MemoryBlock;
import ghidra.program.util.ProgramLocation;
import ghidra.program.util.ProgramSelection;
import ghidra.trace.model.*;
+import ghidra.trace.model.Trace.TraceMemoryBytesChangeType;
import ghidra.trace.model.modules.*;
+import ghidra.trace.util.TraceChangeType;
import ghidra.util.HelpLocation;
import ghidra.util.Msg;
public class DebuggerModulesProvider extends ComponentProviderAdapter {
+ protected static final AutoConfigState.ClassHandler<DebuggerModulesProvider> CONFIG_STATE_HANDLER =
+ AutoConfigState.wireHandler(DebuggerModulesProvider.class, MethodHandles.lookup());
protected static boolean sameCoordinates(DebuggerCoordinates a, DebuggerCoordinates b) {
if (!Objects.equals(a.getTrace(), b.getTrace())) {
@@ -179,6 +194,53 @@ public class DebuggerModulesProvider extends ComponentProviderAdapter {
}
}
+ interface AutoMapAction {
+ String NAME = "Auto-Map Target Memory";
+ Icon ICON = DebuggerResources.ICON_CONFIG;
+ String DESCRIPTION = "Automatically map dynamic memory to static counterparts";
+ String GROUP = DebuggerResources.GROUP_MAPPING;
+ String HELP_ANCHOR = "auto_map";
+
+ static MultiStateActionBuilder<AutoMapSpec> builder(Plugin owner) {
+ String ownerName = owner.getName();
+ MultiStateActionBuilder<AutoMapSpec> builder =
+ new MultiStateActionBuilder<AutoMapSpec>(NAME, ownerName)
+ .description(DESCRIPTION)
+ .toolBarGroup(GROUP)
+ .toolBarIcon(ICON)
+ .useCheckboxForIcons(true)
+ .helpLocation(new HelpLocation(ownerName, HELP_ANCHOR));
+ for (AutoMapSpec spec : AutoMapSpec.allSpecs().values()) {
+ builder.addState(spec.getMenuName(), spec.getMenuIcon(), spec);
+ }
+ return builder;
+ }
+ }
+
+ protected class ForMappingTraceListener extends TraceDomainObjectListener {
+ public ForMappingTraceListener(AutoMapSpec spec) {
+ for (TraceChangeType<?, ?> type : spec.getChangeTypes()) {
+ listenFor(type, this::changed);
+ }
+
+ // TODO: Delete this if/when TraceRecorderTarget is removed
+ listenFor(TraceMemoryBytesChangeType.CHANGED, this::memoryChanged);
+ }
+
+ private void changed() {
+ cueAutoMap = true;
+ }
+
+ private void memoryChanged(TraceAddressSnapRange range) {
+ if (range.getRange().getAddressSpace().isRegisterSpace()) {
+ return;
+ }
+ if (current.getTarget() instanceof TraceRecorderTarget) {
+ doCuedAutoMap();
+ }
+ }
+ }
+
protected static Set<TraceModule> getSelectedModules(ActionContext context) {
if (context instanceof DebuggerModuleActionContext ctx) {
return DebuggerLegacyModulesPanel.getSelectedModulesFromContext(ctx);
@@ -332,6 +394,14 @@ public class DebuggerModulesProvider extends ComponentProviderAdapter {
DockingAction actionMapSectionTo;
DockingAction actionMapSectionsTo;
+ MultiStateDockingAction<AutoMapSpec> actionAutoMap;
+ private final AutoMapSpec defaultAutoMapSpec =
+ AutoMapSpec.fromConfigName(ByModuleAutoMapSpec.CONFIG_NAME);
+ @AutoConfigStateField(codec = AutoMapSpecConfigFieldCodec.class)
+ AutoMapSpec autoMapSpec = defaultAutoMapSpec;
+ boolean cueAutoMap;
+ private ForMappingTraceListener forMappingListener;
+
DockingAction actionImportMissingModule;
DockingAction actionMapMissingModule;
@@ -492,6 +562,11 @@ public class DebuggerModulesProvider extends ComponentProviderAdapter {
.onAction(this::activatedMapSectionsTo)
.buildAndInstallLocal(this);
+ actionAutoMap = AutoMapAction.builder(plugin)
+ .onActionStateChanged(this::changedAutoMapSpec)
+ .buildAndInstallLocal(this);
+ actionAutoMap.setCurrentActionStateByUserData(defaultAutoMapSpec);
+
actionImportMissingModule = ImportMissingModuleAction.builder(plugin)
.withContext(DebuggerMissingModuleActionContext.class)
.onAction(this::activatedImportMissingModule)
@@ -535,7 +610,13 @@ public class DebuggerModulesProvider extends ComponentProviderAdapter {
if (sel == null || sel.isEmpty()) {
return false;
}
- return sel.stream().map(TraceSection::getModule).distinct().count() == 1;
+ try {
+ return sel.stream().map(TraceSection::getModule).distinct().count() == 1;
+ }
+ catch (Exception e) {
+ Msg.error(this, "Could not check section selection context: " + e);
+ return false;
+ }
}
private void activatedMapIdentically(ActionContext ignored) {
@@ -544,7 +625,7 @@ public class DebuggerModulesProvider extends ComponentProviderAdapter {
}
try {
staticMappingService.addIdentityMapping(current.getTrace(), currentProgram,
- Lifespan.nowOn(traceManager.getCurrentSnap()), false);
+ Lifespan.nowOn(traceManager.getCurrentSnap()), true);
}
catch (TraceConflictedMappingException e) {
Msg.showError(this, null, "Map Identically", e.getMessage());
@@ -611,6 +692,19 @@ public class DebuggerModulesProvider extends ComponentProviderAdapter {
mapSectionTo(sel.iterator().next());
}
+ private void changedAutoMapSpec(ActionState<AutoMapSpec> newState, EventTrigger trigger) {
+ doSetAutoMapSpec(newState.getUserData());
+ }
+
+ private void doSetAutoMapSpec(AutoMapSpec autoMapSpec) {
+ if (this.autoMapSpec == autoMapSpec) {
+ return;
+ }
+ removeOldTraceListener();
+ this.autoMapSpec = autoMapSpec;
+ addNewTraceListener();
+ }
+
private void activatedImportMissingModule(DebuggerMissingModuleActionContext context) {
if (importerService == null) {
Msg.error(this, "Import service is not present");
@@ -877,13 +971,37 @@ public class DebuggerModulesProvider extends ComponentProviderAdapter {
}
}
+ protected void addNewTraceListener() {
+ if (current.getTrace() != null && autoMapSpec != null) {
+ forMappingListener = new ForMappingTraceListener(autoMapSpec);
+ current.getTrace().addListener(forMappingListener);
+ }
+ }
+
+ protected void removeOldTraceListener() {
+ if (forMappingListener != null) {
+ if (current.getTrace() != null) {
+ current.getTrace().removeListener(forMappingListener);
+ }
+ forMappingListener = null;
+ }
+ }
+
public void coordinatesActivated(DebuggerCoordinates coordinates) {
if (sameCoordinates(current, coordinates)) {
current = coordinates;
return;
}
+ boolean changeTrace = current.getTrace() != coordinates.getTrace();
+ if (changeTrace) {
+ myActionContext = null;
+ removeOldTraceListener();
+ }
current = coordinates;
+ if (changeTrace) {
+ addNewTraceListener();
+ }
if (Trace.isLegacy(coordinates.getTrace())) {
modulesPanel.coordinatesActivated(DebuggerCoordinates.NOWHERE);
@@ -913,6 +1031,22 @@ public class DebuggerModulesProvider extends ComponentProviderAdapter {
}
contextChanged();
+
+ if (coordinates.getTarget() instanceof TraceRecorderTarget) {
+ // HACK while TraceRecorderTarget is still around
+ cueAutoMap = true;
+ }
+ doCuedAutoMap();
+ }
+
+ private void doCuedAutoMap() {
+ if (cueAutoMap) {
+ cueAutoMap = false;
+ Trace trace = current.getTrace();
+ if (autoMapSpec != null && trace != null) {
+ autoMapSpec.runTask(tool, trace);
+ }
+ }
}
public void setSelectedModules(Set<TraceModule> sel) {
@@ -963,4 +1097,21 @@ public class DebuggerModulesProvider extends ComponentProviderAdapter {
return blockChooserDialog.chooseBlock(getTool(), section,
List.of(programManager.getAllOpenPrograms()));
}
+
+ public void setAutoMapSpec(AutoMapSpec spec) {
+ actionAutoMap.setCurrentActionStateByUserData(spec);
+ }
+
+ public AutoMapSpec getAutoMapSpec() {
+ return autoMapSpec;
+ }
+
+ public void writeConfigState(SaveState saveState) {
+ CONFIG_STATE_HANDLER.writeConfigState(this, saveState);
+ }
+
+ public void readConfigState(SaveState saveState) {
+ CONFIG_STATE_HANDLER.readConfigState(this, saveState);
+ actionAutoMap.setCurrentActionStateByUserData(autoMapSpec);
+ }
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerThreadsPanel.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerThreadsPanel.java
index fba8b4e73e..5c3b4c98ce 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerThreadsPanel.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerThreadsPanel.java
@@ -18,10 +18,11 @@ package ghidra.app.plugin.core.debug.gui.thread;
import java.util.List;
import javax.swing.JTable;
+import javax.swing.event.ListSelectionEvent;
import docking.widgets.table.RangeCursorTableHeaderRenderer.SeekListener;
-import docking.widgets.table.threaded.ThreadedTableModelListener;
import docking.widgets.table.TableColumnDescriptor;
+import docking.widgets.table.threaded.ThreadedTableModelListener;
import ghidra.app.plugin.core.debug.gui.model.*;
import ghidra.app.plugin.core.debug.gui.model.ObjectTableModel.*;
import ghidra.app.plugin.core.debug.gui.model.columns.*;
@@ -165,6 +166,8 @@ public class DebuggerThreadsPanel extends AbstractObjectsTableBasedPanel<TraceOb
@AutoServiceConsumed
protected DebuggerTraceManagerService traceManager;
+ private final DebuggerThreadsProvider provider;
+
private final SeekListener seekListener = pos -> {
long snap = Math.round(pos);
if (current.getTrace() == null || snap < 0) {
@@ -175,6 +178,7 @@ public class DebuggerThreadsPanel extends AbstractObjectsTableBasedPanel<TraceOb
public DebuggerThreadsPanel(DebuggerThreadsProvider provider) {
super(provider.plugin, provider, TraceObjectThread.class);
+ this.provider = provider;
setLimitToSnap(false); // TODO: Toggle for this?
addSeekListener(seekListener);
@@ -239,4 +243,13 @@ public class DebuggerThreadsPanel extends AbstractObjectsTableBasedPanel<TraceOb
traceManager.activateObject(item.getValue().getChild());
}
}
+
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ super.valueChanged(e);
+ if (e.getValueIsAdjusting()) {
+ return;
+ }
+ provider.threadsPanelContextChanged();
+ }
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerThreadsProvider.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerThreadsProvider.java
index 151e41cde3..e3cf7cbd70 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerThreadsProvider.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerThreadsProvider.java
@@ -207,6 +207,10 @@ public class DebuggerThreadsProvider extends ComponentProviderAdapter {
super.addLocalAction(action);
}
+ void threadsPanelContextChanged() {
+ myActionContext = panel.getActionContext();
+ }
+
void legacyThreadsPanelContextChanged() {
myActionContext = legacyPanel.getActionContext();
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerTraceTabPanel.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerTraceTabPanel.java
index 5e2debd326..ce3977fd95 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerTraceTabPanel.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerTraceTabPanel.java
@@ -192,10 +192,14 @@ public class DebuggerTraceTabPanel extends HorizontalTabPanel<Trace>
return;
}
if (event instanceof TraceOpenedPluginEvent evt) {
- addItem(evt.getTrace());
+ try (Suppression supp = cbCoordinateActivation.suppress(null)) {
+ addItem(evt.getTrace());
+ }
}
else if (event instanceof TraceClosedPluginEvent evt) {
- removeItem(evt.getTrace());
+ try (Suppression supp = cbCoordinateActivation.suppress(null)) {
+ removeItem(evt.getTrace());
+ }
}
}
@@ -204,6 +208,8 @@ public class DebuggerTraceTabPanel extends HorizontalTabPanel<Trace>
return;
}
Trace newTrace = setTraceTabActionContext(null);
- cbCoordinateActivation.invoke(() -> traceManager.activateTrace(newTrace));
+ cbCoordinateActivation.invoke(() -> {
+ traceManager.activateTrace(newTrace);
+ });
}
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DebuggerWatchesPlugin.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DebuggerWatchesPlugin.java
index 56aef1615c..e588dd693f 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DebuggerWatchesPlugin.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DebuggerWatchesPlugin.java
@@ -19,6 +19,7 @@ import ghidra.app.plugin.PluginCategoryNames;
import ghidra.app.plugin.core.debug.AbstractDebuggerPlugin;
import ghidra.app.plugin.core.debug.DebuggerPluginPackage;
import ghidra.app.plugin.core.debug.event.TraceActivatedPluginEvent;
+import ghidra.app.plugin.core.debug.event.TraceClosedPluginEvent;
import ghidra.app.services.*;
import ghidra.framework.options.SaveState;
import ghidra.framework.plugintool.*;
@@ -32,6 +33,7 @@ import ghidra.framework.plugintool.util.PluginStatus;
status = PluginStatus.RELEASED,
eventsConsumed = {
TraceActivatedPluginEvent.class,
+ TraceClosedPluginEvent.class,
},
servicesProvided = {
DebuggerWatchesService.class,
@@ -64,10 +66,13 @@ public class DebuggerWatchesPlugin extends AbstractDebuggerPlugin {
@Override
public void processEvent(PluginEvent event) {
super.processEvent(event);
- if (event instanceof TraceActivatedPluginEvent) {
- TraceActivatedPluginEvent ev = (TraceActivatedPluginEvent) event;
+ if (event instanceof TraceActivatedPluginEvent ev) {
provider.coordinatesActivated(ev.getActiveCoordinates());
}
+ else if (event instanceof TraceClosedPluginEvent ev) {
+ // Activation not good enough. Need to know if "previous" was closed
+ provider.traceClosed(ev.getTrace());
+ }
}
@Override
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DebuggerWatchesProvider.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DebuggerWatchesProvider.java
index 446fbd7716..c9f9a794e2 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DebuggerWatchesProvider.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DebuggerWatchesProvider.java
@@ -875,14 +875,34 @@ public class DebuggerWatchesProvider extends ComponentProviderAdapter
language = null;
}
- asyncWatchExecutor = current.getPlatform() == null ? null
- : DebuggerPcodeUtils.buildWatchExecutor(tool, current);
- prevValueExecutor = current.getPlatform() == null || previous.getPlatform() == null ? null
- : TraceSleighUtils.buildByteExecutor(previous.getPlatform(),
- previous.getViewSnap(), previous.getThread(), previous.getFrame());
+ try {
+ asyncWatchExecutor = current.getPlatform() == null ? null
+ : DebuggerPcodeUtils.buildWatchExecutor(tool, current);
+ }
+ catch (Exception e) {
+ Msg.error(this, "Error constructing watch executor: " + e);
+ asyncWatchExecutor = null;
+ }
+ try {
+ prevValueExecutor =
+ current.getPlatform() == null || previous.getPlatform() == null ? null
+ : TraceSleighUtils.buildByteExecutor(previous.getPlatform(),
+ previous.getViewSnap(), previous.getThread(), previous.getFrame());
+ }
+ catch (Exception e) {
+ Msg.error(this, "Error constructing previous-value executor: " + e);
+ prevValueExecutor = null;
+ }
reevaluate();
}
+ public void traceClosed(Trace trace) {
+ if (previous.getTrace() == trace) {
+ previous = DebuggerCoordinates.NOWHERE;
+ prevValueExecutor = null;
+ }
+ }
+
protected void clearCachedState() {
if (asyncWatchExecutor != null) {
asyncWatchExecutor.getState().clear();
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/mapping/AbstractDebuggerPlatformMapper.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/mapping/AbstractDebuggerPlatformMapper.java
index 19332dfc8b..4fe13fc053 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/mapping/AbstractDebuggerPlatformMapper.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/mapping/AbstractDebuggerPlatformMapper.java
@@ -18,8 +18,8 @@ package ghidra.app.plugin.core.debug.mapping;
import java.util.Collection;
import java.util.Set;
+import ghidra.app.plugin.core.debug.disassemble.DisassemblyInject;
import ghidra.app.plugin.core.debug.disassemble.TraceDisassembleCommand;
-import ghidra.app.plugin.core.debug.workflow.DisassemblyInject;
import ghidra.debug.api.platform.DebuggerPlatformMapper;
import ghidra.debug.api.platform.DisassemblyResult;
import ghidra.framework.plugintool.PluginTool;
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/mapping/legacy/LegacyDebuggerPlatformOpinion.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/mapping/legacy/LegacyDebuggerPlatformOpinion.java
index bcdcdd2bfc..88d187007c 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/mapping/legacy/LegacyDebuggerPlatformOpinion.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/mapping/legacy/LegacyDebuggerPlatformOpinion.java
@@ -18,8 +18,8 @@ package ghidra.app.plugin.core.debug.mapping.legacy;
import java.util.*;
import java.util.stream.Collectors;
+import ghidra.app.plugin.core.debug.disassemble.DisassemblyInject;
import ghidra.app.plugin.core.debug.mapping.*;
-import ghidra.app.plugin.core.debug.workflow.DisassemblyInject;
import ghidra.debug.api.platform.DebuggerPlatformMapper;
import ghidra.framework.plugintool.PluginTool;
import ghidra.lifecycle.Transitional;
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/platform/arm/ArmDisassemblyInject.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/platform/arm/ArmDisassemblyInject.java
index d84e84e393..efed76639c 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/platform/arm/ArmDisassemblyInject.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/platform/arm/ArmDisassemblyInject.java
@@ -17,10 +17,8 @@ package ghidra.app.plugin.core.debug.platform.arm;
import java.math.BigInteger;
-import ghidra.app.plugin.core.debug.disassemble.TraceDisassembleCommand;
-import ghidra.app.plugin.core.debug.workflow.DisassemblyInject;
-import ghidra.app.plugin.core.debug.workflow.DisassemblyInjectInfo;
-import ghidra.app.plugin.core.debug.workflow.DisassemblyInjectInfo.CompilerInfo;
+import ghidra.app.plugin.core.debug.disassemble.*;
+import ghidra.app.plugin.core.debug.disassemble.DisassemblyInjectInfo.CompilerInfo;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.lang.*;
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/platform/dbgeng/DbgengDebuggerPlatformOpinion.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/platform/dbgeng/DbgengDebuggerPlatformOpinion.java
index 8135cc7dbf..b9c3d56f02 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/platform/dbgeng/DbgengDebuggerPlatformOpinion.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/platform/dbgeng/DbgengDebuggerPlatformOpinion.java
@@ -18,8 +18,8 @@ package ghidra.app.plugin.core.debug.platform.dbgeng;
import java.util.Collection;
import java.util.Set;
+import ghidra.app.plugin.core.debug.disassemble.DisassemblyInject;
import ghidra.app.plugin.core.debug.mapping.*;
-import ghidra.app.plugin.core.debug.workflow.DisassemblyInject;
import ghidra.debug.api.platform.DebuggerPlatformMapper;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.lang.*;
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/platform/dbgeng/DbgengX64DisassemblyInject.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/platform/dbgeng/DbgengX64DisassemblyInject.java
index 0e4ed34502..3c6b3960c6 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/platform/dbgeng/DbgengX64DisassemblyInject.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/platform/dbgeng/DbgengX64DisassemblyInject.java
@@ -21,10 +21,8 @@ import java.util.Collection;
import java.util.Set;
import java.util.stream.Collectors;
-import ghidra.app.plugin.core.debug.disassemble.TraceDisassembleCommand;
-import ghidra.app.plugin.core.debug.workflow.DisassemblyInject;
-import ghidra.app.plugin.core.debug.workflow.DisassemblyInjectInfo;
-import ghidra.app.plugin.core.debug.workflow.DisassemblyInjectInfo.CompilerInfo;
+import ghidra.app.plugin.core.debug.disassemble.*;
+import ghidra.app.plugin.core.debug.disassemble.DisassemblyInjectInfo.CompilerInfo;
import ghidra.app.services.DebuggerTargetService;
import ghidra.app.util.bin.ByteProvider;
import ghidra.app.util.bin.MemBufferByteProvider;
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.java
index b27dba210e..7303da5649 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
@@ -228,7 +228,8 @@ public class DebuggerLogicalBreakpointServicePlugin extends Plugin
}
private void breakpointAdded(TraceBreakpoint tb) {
- if (!tb.getLifespan().contains(info.snap)) {
+ Lifespan span = tb.getLifespan();
+ if (span == null || !span.contains(info.snap)) {
return;
}
try {
@@ -600,6 +601,9 @@ public class DebuggerLogicalBreakpointServicePlugin extends Plugin
return;
}
Address traceAddr = tb.getMinAddress();
+ if (traceAddr == null) {
+ return; // Will update via breakpointChanged when address is set
+ }
ProgramLocation progLoc = computeStaticLocation(tb);
LogicalBreakpointInternal lb;
if (progLoc != null) {
@@ -1112,7 +1116,11 @@ public class DebuggerLogicalBreakpointServicePlugin extends Plugin
public LogicalBreakpoint getBreakpoint(TraceBreakpoint bpt) {
Trace trace = bpt.getTrace();
synchronized (lock) {
- for (LogicalBreakpoint lb : getBreakpointsAt(trace, bpt.getMinAddress())) {
+ Address address = bpt.getMinAddress();
+ if (address == null) {
+ return null;
+ }
+ for (LogicalBreakpoint lb : getBreakpointsAt(trace, address)) {
if (lb.getTraceBreakpoints(trace).contains(bpt)) {
return lb;
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/breakpoint/PlaceEmuBreakpointActionItem.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/breakpoint/PlaceEmuBreakpointActionItem.java
index 441f91e879..6c17dfcf21 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/breakpoint/PlaceEmuBreakpointActionItem.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/breakpoint/PlaceEmuBreakpointActionItem.java
@@ -20,9 +20,9 @@ import java.util.concurrent.CompletableFuture;
import db.Transaction;
import ghidra.async.AsyncUtils;
-import ghidra.dbg.target.TargetBreakpointSpec;
-import ghidra.dbg.target.TargetBreakpointSpecContainer;
+import ghidra.dbg.target.*;
import ghidra.dbg.util.PathMatcher;
+import ghidra.dbg.util.PathPattern;
import ghidra.program.model.address.*;
import ghidra.trace.model.Lifespan;
import ghidra.trace.model.Trace;
@@ -88,11 +88,21 @@ public record PlaceEmuBreakpointActionItem(Trace trace, long snap, Address addre
if (specMatcher == null) {
throw new IllegalArgumentException("Cannot find path to breakpoint specifications");
}
- List<String> relPath = specMatcher.applyKeys(name).getSingletonPath();
- if (relPath == null) {
+ List<String> specRelPath = specMatcher.applyKeys(name).getSingletonPath();
+ if (specRelPath == null) {
throw new IllegalArgumentException("Too many wildcards to breakpoint specification");
}
- return container.getCanonicalPath().extend(relPath).toString();
+ PathMatcher locMatcher = container.getTargetSchema()
+ .getSuccessorSchema(specRelPath)
+ .searchFor(TargetBreakpointLocation.class, true);
+ if (locMatcher == null) {
+ throw new IllegalArgumentException("Cannot find path to breakpoint locations");
+ }
+ List<String> locRelPath = locMatcher.applyIntKeys(0).getSingletonPath();
+ if (locRelPath == null) {
+ throw new IllegalArgumentException("Too many wildcards to breakpoint location");
+ }
+ return container.getCanonicalPath().extend(specRelPath).extend(locRelPath).toString();
}
@Override
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/model/TraceRecorderTarget.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/model/TraceRecorderTarget.java
index 5f82570935..1271c2737d 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/model/TraceRecorderTarget.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/model/TraceRecorderTarget.java
@@ -24,6 +24,7 @@ import java.util.function.Predicate;
import docking.ActionContext;
import ghidra.app.context.ProgramLocationActionContext;
import ghidra.app.plugin.core.debug.gui.model.DebuggerObjectActionContext;
+import ghidra.app.plugin.core.debug.gui.objects.components.DebuggerMethodInvocationDialog;
import ghidra.app.plugin.core.debug.service.target.AbstractTarget;
import ghidra.app.services.DebuggerConsoleService;
import ghidra.app.services.DebuggerTraceManagerService;
@@ -176,6 +177,14 @@ public class TraceRecorderTarget extends AbstractTarget {
}
private record MethodWithArgs(TargetMethod method, Map<String, Object> arguments) {
+ public boolean requiresPrompt() {
+ for (ParameterDescription<?> param : method.getParameters().values()) {
+ if (param.required && !arguments.containsKey(param.name)) {
+ return true;
+ }
+ }
+ return false;
+ }
}
private List<MethodWithArgs> findAddressMethods(ProgramLocationActionContext context) {
@@ -215,23 +224,59 @@ public class TraceRecorderTarget extends AbstractTarget {
return method.getName();
}
- private ActionEntry makeEntry(TargetMethod method, Map<String, ?> arguments) {
- return new ActionEntry(method.getDisplay(), null, null, false, () -> true, () -> {
- return method.invoke(arguments).thenAccept(result -> {
- DebuggerConsoleService consoleService =
- tool.getService(DebuggerConsoleService.class);
- if (consoleService != null && method.getReturnType() != Void.class) {
- consoleService.log(null, getDisplay(method) + " returned " + result);
+ private Map<String, ?> promptArgs(TargetMethod method, Map<String, ?> defaults) {
+ DebuggerMethodInvocationDialog dialog = new DebuggerMethodInvocationDialog(tool,
+ method.getDisplay(), method.getDisplay(), null);
+ while (true) {
+ for (ParameterDescription<?> param : method.getParameters().values()) {
+ Object val = defaults.get(param.name);
+ if (val != null) {
+ dialog.setMemorizedArgument(param.name, param.type.asSubclass(Object.class),
+ val);
}
- });
+ }
+ Map<String, ?> args = dialog.promptArguments(method.getParameters());
+ if (args == null) {
+ // Cancelled
+ return null;
+ }
+ if (dialog.isResetRequested()) {
+ continue;
+ }
+ return args;
+ }
+ }
+
+ private CompletableFuture<?> invokeMethod(boolean prompt, TargetMethod method,
+ Map<String, ?> arguments) {
+ Map<String, ?> chosenArgs;
+ if (prompt) {
+ chosenArgs = promptArgs(method, arguments);
+ }
+ else {
+ chosenArgs = arguments;
+ }
+ return method.invoke(chosenArgs).thenAccept(result -> {
+ DebuggerConsoleService consoleService =
+ tool.getService(DebuggerConsoleService.class);
+ if (consoleService != null && method.getReturnType() != Void.class) {
+ consoleService.log(null, getDisplay(method) + " returned " + result);
+ }
});
}
+ private ActionEntry makeEntry(boolean requiresPrompt, TargetMethod method,
+ Map<String, ?> arguments) {
+ return new ActionEntry(method.getDisplay(), null, null, requiresPrompt, () -> true,
+ prompt -> invokeMethod(prompt, method, arguments));
+ }
+
@Override
public Map<String, ActionEntry> collectAddressActions(ProgramLocationActionContext context) {
Map<String, ActionEntry> result = new HashMap<>();
for (MethodWithArgs mwa : findAddressMethods(context)) {
- result.put(mwa.method.getJoinedPath("."), makeEntry(mwa.method, mwa.arguments));
+ result.put(mwa.method.getJoinedPath("."),
+ makeEntry(mwa.requiresPrompt(), mwa.method, mwa.arguments));
}
return result;
}
@@ -244,7 +289,7 @@ public class TraceRecorderTarget extends AbstractTarget {
return Map.of();
}
return Map.of(display, new ActionEntry(display, name, description, false,
- () -> enabled.test(object), () -> action.apply(object)));
+ () -> enabled.test(object), prompt -> action.apply(object)));
}
private TargetExecutionState getStateOf(TargetObject object) {
@@ -541,6 +586,12 @@ public class TraceRecorderTarget extends AbstractTarget {
return spec.toggle(enabled);
}
+ @Override
+ public CompletableFuture<Void> forceTerminateAsync() {
+ recorder.stopRecording();
+ return AsyncUtils.nil();
+ }
+
@Override
public CompletableFuture<Void> disconnectAsync() {
return recorder.getTarget()
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/target/AbstractTarget.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/target/AbstractTarget.java
index cda72ab07c..f19c46b5f1 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/target/AbstractTarget.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/target/AbstractTarget.java
@@ -58,6 +58,10 @@ public abstract class AbstractTarget implements Target {
this.tool = tool;
}
+ public PluginTool getTool() {
+ return tool;
+ }
+
private Address staticToDynamicAddress(ProgramLocation location) {
DebuggerStaticMappingService mappingService =
tool.getService(DebuggerStaticMappingService.class);
@@ -73,10 +77,14 @@ public abstract class AbstractTarget implements Target {
}
protected Address findAddress(Navigatable nav) {
+ ProgramLocation location = nav.getLocation();
+ if (location == null) {
+ return null;
+ }
if (nav.isDynamic()) {
- return nav.getLocation().getAddress();
+ return location.getAddress();
}
- return staticToDynamicAddress(nav.getLocation());
+ return staticToDynamicAddress(location);
}
protected Address findAddress(MarkerLocation location) {
@@ -118,7 +126,7 @@ public abstract class AbstractTarget implements Target {
}
protected AddressRange singleRange(AddressSetView set) {
- if (set.getNumAddressRanges() != 1) {
+ if (set == null || set.getNumAddressRanges() != 1) {
return null;
}
return set.getFirstRange();
@@ -386,6 +394,11 @@ public abstract class AbstractTarget implements Target {
runSync(msg, () -> toggleBreakpointAsync(breakpoint, enabled));
}
+ @Override
+ public void forceTerminate() {
+ runSync("force terminate", () -> forceTerminateAsync());
+ }
+
@Override
public void disconnect() {
runSync("disconnect", this::disconnectAsync);
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/tracemgr/DebuggerTraceManagerServicePlugin.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/tracemgr/DebuggerTraceManagerServicePlugin.java
index c618a4f9b8..9934e98b8c 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/tracemgr/DebuggerTraceManagerServicePlugin.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/tracemgr/DebuggerTraceManagerServicePlugin.java
@@ -463,7 +463,7 @@ public class DebuggerTraceManagerServicePlugin extends Plugin
}
@AutoServiceConsumed
- private void setModelService(DebuggerTargetService targetService) {
+ private void setTargetService(DebuggerTargetService targetService) {
if (this.targetService != null) {
this.targetService.removeTargetPublicationListener(forTargetsListener);
}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/workflow/AbstractMultiToolTraceListener.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/workflow/AbstractMultiToolTraceListener.java
deleted file mode 100644
index c3f68e6b42..0000000000
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/workflow/AbstractMultiToolTraceListener.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/* ###
- * IP: GHIDRA
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.app.plugin.core.debug.service.workflow;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import ghidra.framework.plugintool.PluginTool;
-import ghidra.trace.model.Trace;
-import ghidra.trace.model.TraceDomainObjectListener;
-
-public class AbstractMultiToolTraceListener extends TraceDomainObjectListener {
- protected final Trace trace;
- protected final Set<PluginTool> openIn = new HashSet<>();
-
- public AbstractMultiToolTraceListener(Trace trace) {
- this.trace = trace;
- }
-
- protected void init() {
- trace.addListener(this);
- }
-
- protected void dispose() {
- trace.removeListener(this);
- }
-
- protected void openedBy(PluginTool tool) {
- openIn.add(tool);
- }
-
- protected boolean closedBy(PluginTool tool) {
- openIn.remove(tool);
- return openIn.isEmpty();
- }
-}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/workflow/DebuggerWorkflowServicePlugin.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/workflow/DebuggerWorkflowServicePlugin.java
deleted file mode 100644
index 867a91929d..0000000000
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/workflow/DebuggerWorkflowServicePlugin.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/* ###
- * IP: GHIDRA
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.app.plugin.core.debug.service.workflow;
-
-import java.util.*;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
-import ghidra.app.events.ProgramClosedPluginEvent;
-import ghidra.app.events.ProgramOpenedPluginEvent;
-import ghidra.app.plugin.PluginCategoryNames;
-import ghidra.app.plugin.core.debug.DebuggerPluginPackage;
-import ghidra.app.plugin.core.debug.event.TraceClosedPluginEvent;
-import ghidra.app.plugin.core.debug.event.TraceOpenedPluginEvent;
-import ghidra.app.plugin.core.debug.gui.DebuggerResources;
-import ghidra.app.services.DebuggerWorkflowFrontEndService;
-import ghidra.debug.api.workflow.DebuggerBot;
-import ghidra.framework.main.ApplicationLevelOnlyPlugin;
-import ghidra.framework.main.FrontEndTool;
-import ghidra.framework.options.*;
-import ghidra.framework.plugintool.*;
-import ghidra.framework.plugintool.util.PluginEventListener;
-import ghidra.framework.plugintool.util.PluginStatus;
-import ghidra.util.Msg;
-import ghidra.util.SystemUtilities;
-import ghidra.util.classfinder.ClassSearcher;
-
-@PluginInfo(
- shortDescription = "Debugger workflow service",
- description = "Manage automatic debugging actions and analysis",
- category = PluginCategoryNames.DEBUGGER,
- packageName = DebuggerPluginPackage.NAME,
- status = PluginStatus.RELEASED,
- servicesProvided = {
- DebuggerWorkflowFrontEndService.class,
- })
-public class DebuggerWorkflowServicePlugin extends Plugin
- implements DebuggerWorkflowFrontEndService, ApplicationLevelOnlyPlugin,
- OptionsChangeListener {
-
- protected class ForTrackingOpenStuffPluginEventListener implements PluginEventListener {
- private final PluginTool t;
-
- // TODO: Determine interest dynamically, based on bots' overrides
- private final Set<Class<? extends PluginEvent>> types = Set.of(
- ProgramOpenedPluginEvent.class,
- ProgramClosedPluginEvent.class,
- TraceOpenedPluginEvent.class,
- TraceClosedPluginEvent.class //
- );
-
- public ForTrackingOpenStuffPluginEventListener(PluginTool tool) {
- this.t = tool;
-
- for (Class<? extends PluginEvent> cls : types) {
- tool.addEventListener(cls, this);
- }
- }
-
- private void dispose() {
- for (Class<? extends PluginEvent> cls : types) {
- t.removeEventListener(cls, this);
- }
- }
-
- @Override
- public void eventSent(PluginEvent event) {
- if (event instanceof ProgramOpenedPluginEvent) {
- ProgramOpenedPluginEvent evt = (ProgramOpenedPluginEvent) event;
- dispatch(a -> a.programOpened(t, evt.getProgram()));
- }
- if (event instanceof ProgramClosedPluginEvent) {
- ProgramClosedPluginEvent evt = (ProgramClosedPluginEvent) event;
- dispatch(a -> a.programClosed(t, evt.getProgram()));
- }
- if (event instanceof TraceOpenedPluginEvent) {
- TraceOpenedPluginEvent evt = (TraceOpenedPluginEvent) event;
- dispatch(a -> a.traceOpened(t, evt.getTrace()));
- }
- if (event instanceof TraceClosedPluginEvent) {
- TraceClosedPluginEvent evt = (TraceClosedPluginEvent) event;
- dispatch(a -> a.traceClosed(t, evt.getTrace()));
- }
- }
- }
-
- private final ChangeListener botsChangeListener = this::botsChanged;
- private final Map<PluginTool, ForTrackingOpenStuffPluginEventListener> trackStuffListenersByTool =
- new HashMap<>();
-
- /* testing */ final List<DebuggerBot> allBots = new ArrayList<>();
-
- // Cannot auto-wire, since they're dynamically populated
- private final Options options;
-
- @SuppressWarnings("hiding") // I'm FrontEndOnly
- protected final FrontEndTool tool;
-
- public DebuggerWorkflowServicePlugin(PluginTool tool) {
- super(tool);
- this.tool = (FrontEndTool) tool; // I'm FrontEndOnly
-
- ToolOptions rootOptions = tool.getOptions(DebuggerResources.OPTIONS_CATEGORY_DEBUGGER);
- rootOptions.addOptionsChangeListener(this);
- this.options = rootOptions.getOptions(DebuggerResources.OPTIONS_CATEGORY_WORKFLOW);
- }
-
- @Override
- protected void init() {
- super.init();
-
- ClassSearcher.addChangeListener(botsChangeListener);
- refreshBots();
-
- /**
- * Note instead of trying to use the tool manager to track running tools -- which rests
- * precariously upon the project, anyway -- we will have the proxy plugin notify the
- * front-end plugin of a new tool. This actually works better, since we should affect only
- * those plugin tools which have the proxy plugin enabled.
- */
- }
-
- @Override
- protected void dispose() {
- ClassSearcher.removeChangeListener(botsChangeListener);
-
- // TODO: Is there a good way to clean up the proxies?
- // What if other plugins come to depend on it?
- synchronized (trackStuffListenersByTool) {
- for (ForTrackingOpenStuffPluginEventListener l : trackStuffListenersByTool.values()) {
- l.dispose();
- }
- trackStuffListenersByTool.clear();
- }
- }
-
- private void dispatch(Consumer<DebuggerBot> evt) {
- synchronized (allBots) {
- for (DebuggerBot bot : allBots) {
- if (bot.isEnabled()) {
- evt.accept(bot);
- }
- }
- }
- }
-
- private void botsChanged(ChangeEvent evt) {
- refreshBots();
- }
-
- private void refreshBots() {
- synchronized (allBots) {
- List<DebuggerBot> removed = new ArrayList<>(allBots);
- allBots.clear();
- allBots.addAll(ClassSearcher.getInstances(DebuggerBot.class));
- List<DebuggerBot> added = new ArrayList<>(allBots);
- added.removeAll(removed);
- removed.removeAll(allBots);
-
- for (DebuggerBot bot : removed) {
- options.removeOption(bot.getDescription());
- }
-
- for (DebuggerBot bot : added) {
- options.registerOption(bot.getDescription(), OptionType.BOOLEAN_TYPE,
- bot.isEnabledByDefault(), bot.getHelpLocation(), bot.getDetails());
- }
-
- for (DebuggerBot bot : removed) {
- try {
- if (bot.isEnabled()) {
- bot.disable();
- }
- }
- catch (Throwable t) {
- Msg.error(this, "Failed to disable debugger bot: " + bot, t);
- }
- }
-
- // Require explicit enable via API during testing. These tend to get in the way.
- if (SystemUtilities.isInTestingMode()) {
- return;
- }
- // TODO: Remember bot enablement in tool config
- for (DebuggerBot bot : added) {
- try {
- boolean enabled = options.getBoolean(bot.getDescription(),
- bot.isEnabledByDefault());
- bot.setEnabled(this, enabled);
- }
- catch (Throwable t) {
- Msg.error(this, "Failed to enable debugger bot: " + bot, t);
- }
- }
- }
- }
-
- @Override
- public void optionsChanged(ToolOptions opts, String optionName, Object oldValue,
- Object newValue) {
- assert options == opts;
- // Not the most efficient, but there are few, and this should occur infrequently
-
- // Require explicit enable via API during testing. These tend to get in the way.
- if (SystemUtilities.isInTestingMode()) {
- return;
- }
- synchronized (allBots) {
- for (DebuggerBot bot : allBots) {
- if (!optionName.equals(bot.getDescription())) {
- continue;
- }
- boolean enabled = (Boolean) newValue;
- if (bot.isEnabled() != enabled) {
- bot.setEnabled(this, enabled);
- }
- }
- }
- }
-
- public void pluginToolAdded(PluginTool t) {
- trackToolEvents(t);
- }
-
- public void pluginToolRemoved(PluginTool t) {
- untrackToolEvents(t);
- }
-
- private void trackToolEvents(PluginTool t) {
- synchronized (trackStuffListenersByTool) {
- ForTrackingOpenStuffPluginEventListener old =
- trackStuffListenersByTool.put(t, new ForTrackingOpenStuffPluginEventListener(t));
- if (old != null) {
- old.dispose();
- Msg.warn(this, "Tracking a tool twice: " + tool);
- }
- }
- }
-
- private void untrackToolEvents(PluginTool t) {
- synchronized (trackStuffListenersByTool) {
- ForTrackingOpenStuffPluginEventListener removed = trackStuffListenersByTool.remove(t);
- if (removed != null) {
- removed.dispose();
- }
- else {
- Msg.warn(this, "Never tracked a tool: " + tool);
- }
- }
- }
-
- @Override
- public Collection<PluginTool> getProxyingPluginTools() {
- synchronized (trackStuffListenersByTool) {
- return List.copyOf(trackStuffListenersByTool.keySet());
- }
- }
-
- @Override
- public Set<DebuggerBot> getAllBots() {
- synchronized (allBots) {
- return Set.copyOf(allBots);
- }
- }
-
- @Override
- public Set<DebuggerBot> getEnabledBots() {
- synchronized (allBots) {
- return allBots.stream().filter(a -> a.isEnabled()).collect(Collectors.toSet());
- }
- }
-
- @Override
- public Set<DebuggerBot> getDisabledBots() {
- synchronized (allBots) {
- return allBots.stream().filter(a -> !a.isEnabled()).collect(Collectors.toSet());
- }
- }
-
- @Override
- public void enableBots(Set<DebuggerBot> bots) {
- synchronized (allBots) {
- for (DebuggerBot bot : bots) {
- if (!allBots.contains(bot)) {
- Msg.error(this, "Ignoring request to enable non-discoverable bot " + bot);
- continue;
- }
- if (!bot.isEnabled()) {
- try {
- bot.enable(this);
- }
- catch (Throwable e) {
- Msg.error(this, "Error enabling " + bot, e);
- }
- }
- }
- }
- }
-
- @Override
- public void disableBots(Set<DebuggerBot> bots) {
- synchronized (allBots) {
- for (DebuggerBot bot : bots) {
- if (!allBots.contains(bot)) {
- Msg.error(this, "Ignoring request to disable non-discoverable bot " + bot);
- continue;
- }
- if (bot.isEnabled()) {
- try {
- bot.disable();
- }
- catch (Throwable e) {
- Msg.error(this, "Error disabling " + bot, e);
- }
- }
- }
- }
- }
-}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/workflow/DebuggerWorkflowServiceProxyPlugin.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/workflow/DebuggerWorkflowServiceProxyPlugin.java
deleted file mode 100644
index 55eb491a52..0000000000
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/workflow/DebuggerWorkflowServiceProxyPlugin.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/* ###
- * IP: GHIDRA
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.app.plugin.core.debug.service.workflow;
-
-import java.util.Set;
-
-import ghidra.app.plugin.PluginCategoryNames;
-import ghidra.app.plugin.core.debug.DebuggerPluginPackage;
-import ghidra.app.services.DebuggerWorkflowToolService;
-import ghidra.debug.api.workflow.DebuggerBot;
-import ghidra.framework.main.AppInfo;
-import ghidra.framework.main.FrontEndTool;
-import ghidra.framework.plugintool.*;
-import ghidra.framework.plugintool.util.*;
-
-@PluginInfo(
- shortDescription = "Debugger workflow service (proxy to front-end)",
- description = "Manage automatic debugging actions and analysis",
- category = PluginCategoryNames.DEBUGGER,
- packageName = DebuggerPluginPackage.NAME,
- status = PluginStatus.RELEASED,
- servicesProvided = {
- DebuggerWorkflowToolService.class,
- })
-public class DebuggerWorkflowServiceProxyPlugin extends Plugin
- implements DebuggerWorkflowToolService {
-
- protected static DebuggerWorkflowServicePlugin getOrCreateFrontEndDelegate() {
- FrontEndTool frontEnd = AppInfo.getFrontEndTool();
- for (Plugin plugin : frontEnd.getManagedPlugins()) {
- if (plugin instanceof DebuggerWorkflowServicePlugin) {
- return (DebuggerWorkflowServicePlugin) plugin;
- }
- }
- try {
- DebuggerWorkflowServicePlugin plugin =
- PluginUtils.instantiatePlugin(DebuggerWorkflowServicePlugin.class, frontEnd);
- frontEnd.addPlugin(plugin);
- return plugin;
- }
- catch (PluginException e) {
- throw new AssertionError(e);
- }
- }
-
- protected DebuggerWorkflowServicePlugin delegate;
-
- public DebuggerWorkflowServiceProxyPlugin(PluginTool tool) {
- super(tool);
- }
-
- @Override
- protected void init() {
- super.init();
- delegate = getOrCreateFrontEndDelegate();
- // TODO: Proxy listeners
- delegate.pluginToolAdded(tool);
- }
-
- @Override
- protected void dispose() {
- super.dispose();
- if (delegate != null) {
- // TODO: Proxy listeners
- delegate.pluginToolRemoved(tool);
- }
- }
-
- @Override
- public Set<DebuggerBot> getAllBots() {
- return delegate.getAllBots();
- }
-
- @Override
- public Set<DebuggerBot> getEnabledBots() {
- return delegate.getEnabledBots();
- }
-
- @Override
- public Set<DebuggerBot> getDisabledBots() {
- return delegate.getDisabledBots();
- }
-
- @Override
- public void enableBots(Set<DebuggerBot> actors) {
- delegate.enableBots(actors);
- }
-
- @Override
- public void disableBots(Set<DebuggerBot> actors) {
- delegate.disableBots(actors);
- }
-}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/workflow/MultiToolTraceListenerManager.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/workflow/MultiToolTraceListenerManager.java
deleted file mode 100644
index 0d401725bf..0000000000
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/workflow/MultiToolTraceListenerManager.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/* ###
- * IP: GHIDRA
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.app.plugin.core.debug.service.workflow;
-
-import java.util.*;
-import java.util.function.Function;
-
-import ghidra.app.services.DebuggerTraceManagerService;
-import ghidra.app.services.DebuggerWorkflowFrontEndService;
-import ghidra.framework.plugintool.PluginTool;
-import ghidra.trace.model.Trace;
-
-public class MultiToolTraceListenerManager<L extends AbstractMultiToolTraceListener> {
- private final Function<Trace, L> listenerFactory;
- private final Map<Trace, L> listenersByTrace = new HashMap<>();
-
- public MultiToolTraceListenerManager(Function<Trace, L> listenerFactory) {
- this.listenerFactory = listenerFactory;
- }
-
- public synchronized void enable(DebuggerWorkflowFrontEndService service) {
- for (PluginTool tool : service.getProxyingPluginTools()) {
- DebuggerTraceManagerService traceManager =
- tool.getService(DebuggerTraceManagerService.class);
- if (traceManager == null) {
- continue;
- }
- for (Trace trace : traceManager.getOpenTraces()) {
- L listener = listenersByTrace.computeIfAbsent(trace, t -> {
- L l = listenerFactory.apply(t);
- l.init();
- return l;
- });
- listener.openedBy(tool);
- }
- }
- }
-
- public synchronized void disable() {
- for (Iterator<L> it = listenersByTrace.values().iterator(); it.hasNext();) {
- L listener = it.next();
- listener.dispose();
- it.remove();
- }
- }
-
- public synchronized void traceOpened(PluginTool tool, Trace trace) {
- L listener = listenersByTrace.computeIfAbsent(trace, t -> {
- L l = listenerFactory.apply(t);
- l.init();
- return l;
- });
- listener.openedBy(tool);
- }
-
- public synchronized void traceClosed(PluginTool tool, Trace trace) {
- L listener = listenersByTrace.get(trace);
- // It should never be null, but somehow it happened, so....
- if (listener != null && listener.closedBy(tool)) {
- listenersByTrace.remove(trace).dispose();
- }
- }
-}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/AbstractMapDebuggerBot.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/AbstractMapDebuggerBot.java
deleted file mode 100644
index 8e18d3c2a1..0000000000
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/AbstractMapDebuggerBot.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/* ###
- * IP: GHIDRA
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.app.plugin.core.debug.workflow;
-
-import java.util.*;
-
-import org.apache.commons.lang3.tuple.Pair;
-
-import ghidra.app.plugin.core.debug.service.workflow.*;
-import ghidra.app.services.*;
-import ghidra.async.AsyncDebouncer;
-import ghidra.async.AsyncTimer;
-import ghidra.debug.api.workflow.DebuggerBot;
-import ghidra.framework.cmd.BackgroundCommand;
-import ghidra.framework.model.DomainObject;
-import ghidra.framework.plugintool.PluginTool;
-import ghidra.program.model.listing.Program;
-import ghidra.trace.model.Trace;
-import ghidra.trace.util.TraceChangeType;
-import ghidra.util.exception.CancelledException;
-import ghidra.util.task.TaskMonitor;
-
-public abstract class AbstractMapDebuggerBot implements DebuggerBot {
- protected class ForChangesTraceListener extends AbstractMultiToolTraceListener {
- public ForChangesTraceListener(Trace trace) {
- super(trace);
-
- for (TraceChangeType<?, ?> type : getChangeTypes()) {
- listenFor(type, this::changed);
- }
- }
-
- private void changed() {
- queueTrace(trace);
- }
- }
-
- protected abstract Collection<TraceChangeType<?, ?>> getChangeTypes();
-
- private DebuggerWorkflowFrontEndService service;
-
- private final MultiToolTraceListenerManager<ForChangesTraceListener> listeners =
- new MultiToolTraceListenerManager<>(ForChangesTraceListener::new);
-
- private final Set<Trace> traceQueue = new HashSet<>();
- // Debounce to ensure we don't get too eager if manager is still opening stuff
- private final AsyncDebouncer<Void> debouncer =
- new AsyncDebouncer<>(AsyncTimer.DEFAULT_TIMER, 500);
- {
- debouncer.addListener(this::queueSettled);
- }
-
- @Override
- public void enable(DebuggerWorkflowFrontEndService service) {
- this.service = service;
-
- listeners.enable(service);
- for (PluginTool t : service.getProxyingPluginTools()) {
- DebuggerTraceManagerService traceManager =
- t.getService(DebuggerTraceManagerService.class);
- if (traceManager == null) {
- continue;
- }
- queueTraces(traceManager.getOpenTraces());
- }
- }
-
- @Override
- public void disable() {
- service = null;
-
- listeners.disable();
- }
-
- @Override
- public boolean isEnabled() {
- return service != null;
- }
-
- @Override
- public void traceOpened(PluginTool tool, Trace trace) {
- listeners.traceOpened(tool, trace);
- queueTrace(trace);
- }
-
- @Override
- public void traceClosed(PluginTool tool, Trace trace) {
- listeners.traceClosed(tool, trace);
- }
-
- @Override
- public void programOpened(PluginTool t, Program program) {
- DebuggerTraceManagerService traceManager = t.getService(DebuggerTraceManagerService.class);
- if (traceManager == null) {
- return;
- }
- queueTraces(traceManager.getOpenTraces());
- }
-
- private void queueTrace(Trace trace) {
- synchronized (traceQueue) {
- traceQueue.add(trace);
- }
- debouncer.contact(null);
- }
-
- private void queueTraces(Collection<Trace> traces) {
- synchronized (traceQueue) {
- traceQueue.addAll(traces);
- }
- debouncer.contact(null);
- }
-
- private void queueSettled(Void __) {
- Set<Trace> traces;
- synchronized (traceQueue) {
- traces = Set.copyOf(traceQueue);
- traceQueue.clear();
- }
-
- Map<Trace, Pair<PluginTool, Set<Program>>> toAnalyze = new HashMap<>();
- for (Trace trace : traces) {
- for (PluginTool tool : service.getProxyingPluginTools()) {
- DebuggerTraceManagerService traceManager =
- tool.getService(DebuggerTraceManagerService.class);
- if (traceManager == null) {
- continue;
- }
- ProgramManager programManager = tool.getService(ProgramManager.class);
- if (programManager == null) {
- continue;
- }
- if (!traceManager.getOpenTraces().contains(trace)) {
- continue;
- }
- Pair<PluginTool, Set<Program>> programs =
- toAnalyze.computeIfAbsent(trace, t -> Pair.of(tool, new HashSet<>()));
- programs.getRight().addAll(List.of(programManager.getAllOpenPrograms()));
- }
- }
-
- for (Map.Entry<Trace, Pair<PluginTool, Set<Program>>> ent : toAnalyze.entrySet()) {
- PluginTool tool = ent.getValue().getLeft();
- Trace trace = ent.getKey();
- Set<Program> programs = ent.getValue().getRight();
- analyzeTrace(tool, trace, programs);
- }
- }
-
- private void analyzeTrace(PluginTool tool, Trace trace, Set<Program> programs) {
- BackgroundCommand cmd = new BackgroundCommand(getDescription(), true, true, false) {
- @Override
- public boolean applyTo(DomainObject obj, TaskMonitor monitor) {
- try {
- doAnalysis(tool, trace, programs, monitor);
- return true;
- }
- catch (CancelledException e) {
- return false;
- }
- }
- };
- tool.executeBackgroundCommand(cmd, trace);
- }
-
- protected abstract void doAnalysis(PluginTool tool, Trace trace, Set<Program> programs,
- TaskMonitor monitor) throws CancelledException;
-}
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/DisassembleAtPcDebuggerBot.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/DisassembleAtPcDebuggerBot.java
deleted file mode 100644
index 8dfe25776e..0000000000
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/DisassembleAtPcDebuggerBot.java
+++ /dev/null
@@ -1,421 +0,0 @@
-/* ###
- * IP: GHIDRA
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.app.plugin.core.debug.workflow;
-
-import java.util.*;
-import java.util.Map.Entry;
-
-import javax.swing.event.ChangeListener;
-
-import db.Transaction;
-import docking.DockingWindowManager;
-import docking.Tool;
-import ghidra.app.plugin.core.debug.service.workflow.AbstractMultiToolTraceListener;
-import ghidra.app.plugin.core.debug.service.workflow.MultiToolTraceListenerManager;
-import ghidra.app.services.DebuggerPlatformService;
-import ghidra.app.services.DebuggerWorkflowFrontEndService;
-import ghidra.async.AsyncDebouncer;
-import ghidra.async.AsyncTimer;
-import ghidra.debug.api.platform.DebuggerPlatformMapper;
-import ghidra.debug.api.platform.DisassemblyResult;
-import ghidra.debug.api.workflow.DebuggerBot;
-import ghidra.debug.api.workflow.DebuggerBotInfo;
-import ghidra.framework.cmd.BackgroundCommand;
-import ghidra.framework.model.DomainObject;
-import ghidra.framework.options.annotation.HelpInfo;
-import ghidra.framework.plugintool.PluginTool;
-import ghidra.program.model.address.*;
-import ghidra.program.model.data.PointerTypedef;
-import ghidra.program.model.data.VoidDataType;
-import ghidra.program.model.lang.Register;
-import ghidra.program.model.util.CodeUnitInsertionException;
-import ghidra.trace.model.*;
-import ghidra.trace.model.Trace.TraceMemoryBytesChangeType;
-import ghidra.trace.model.Trace.TraceStackChangeType;
-import ghidra.trace.model.listing.*;
-import ghidra.trace.model.memory.*;
-import ghidra.trace.model.program.TraceProgramView;
-import ghidra.trace.model.stack.*;
-import ghidra.trace.model.target.TraceObject;
-import ghidra.trace.model.thread.TraceObjectThread;
-import ghidra.trace.model.thread.TraceThread;
-import ghidra.trace.util.*;
-import ghidra.util.*;
-import ghidra.util.classfinder.ClassSearcher;
-import ghidra.util.task.TaskMonitor;
-
-@DebuggerBotInfo(
- description = "Disassemble memory at the program counter",
- details = "Listens for changes in memory or pc (stack or registers) and disassembles",
- help = @HelpInfo(anchor = "disassemble_at_pc"),
- enabledByDefault = true)
-public class DisassembleAtPcDebuggerBot implements DebuggerBot {
-
- protected class ForDisassemblyTraceListener extends AbstractMultiToolTraceListener {
- private final TraceStackManager stackManager;
- private final TraceMemoryManager memoryManager;
- private final TraceCodeManager codeManager;
- private final TraceTimeViewport viewport;
-
- private final Register pc;
- private final AddressRange pcRange;
-
- private final Set<DisassemblyInject> injects = new LinkedHashSet<>();
- private final ChangeListener injectsChangeListener = e -> updateInjects();
-
- // Offload disassembly evaluation from swing thread
- private final Deque<Runnable> runQueue = new LinkedList<>();
- private final AsyncDebouncer<Void> runDebouncer =
- new AsyncDebouncer<>(AsyncTimer.DEFAULT_TIMER, 100);
-
- public ForDisassemblyTraceListener(Trace trace) {
- super(trace);
- this.stackManager = trace.getStackManager();
- this.memoryManager = trace.getMemoryManager();
- this.codeManager = trace.getCodeManager();
- this.viewport = trace.getProgramView().getViewport();
-
- this.pc = trace.getBaseLanguage().getProgramCounter();
- this.pcRange = pc == null ? null : TraceRegisterUtils.rangeForRegister(pc);
-
- ClassSearcher.addChangeListener(injectsChangeListener);
- updateInjects();
-
- runDebouncer.addListener(this::processQueue);
-
- listenFor(TraceMemoryBytesChangeType.CHANGED, this::valuesChanged);
- listenFor(TraceStackChangeType.CHANGED, this::stackChanged);
-
- // Do initial analysis?
- }
-
- private void updateInjects() {
- synchronized (injects) {
- injects.clear();
- ClassSearcher.getInstances(DisassemblyInject.class)
- .stream()
- .filter(i -> i.isApplicable(trace))
- .sorted(Comparator.comparing(i -> i.getPriority()))
- .forEach(injects::add);
- }
- }
-
- private void queueRunnable(Runnable r) {
- synchronized (runQueue) {
- runQueue.add(r);
- }
- runDebouncer.contact(null);
- }
-
- private void processQueue(Void __) {
- try {
- List<Runnable> copy;
- synchronized (runQueue) {
- copy = List.copyOf(runQueue);
- runQueue.clear();
- }
- for (Runnable r : copy) {
- r.run();
- }
- }
- catch (Throwable e) {
- Msg.error(this, "Error processing queue", e);
- }
- }
-
- private void valuesChanged(TraceAddressSpace space, TraceAddressSnapRange range,
- byte[] oldValue, byte[] newValue) {
- if (space.getAddressSpace().isRegisterSpace()) {
- registersChanged(space, range);
- }
- else {
- memoryChanged(range);
- }
- }
-
- private void stackChanged(TraceStack stack, long zero, long snap) {
- queueRunnable(() -> {
- disassembleStackPcVals(stack, snap, null);
- });
- }
-
- private long findNonScratchSnap(long snap) {
- if (snap >= 0) {
- return snap;
- }
- TraceViewportSpanIterator spit = new TraceViewportSpanIterator(trace, snap);
- while (spit.hasNext()) {
- Lifespan span = spit.next();
- if (span.lmax() >= 0) {
- return span.lmax();
- }
- }
- return snap;
- }
-
- private void memoryChanged(TraceAddressSnapRange range) {
- if (!viewport.containsAnyUpper(range.getLifespan())) {
- return;
- }
- // This is a wonky case, because we care about where the user is looking.
- long pcSnap = trace.getProgramView().getSnap();
- long memSnap = range.getY1();
- queueRunnable(() -> {
- for (TraceThread thread : trace.getThreadManager()
- .getLiveThreads(findNonScratchSnap(pcSnap))) {
- TraceStack stack = stackManager.getLatestStack(thread, pcSnap);
- if (stack != null) {
- disassembleStackPcVals(stack, memSnap, range.getRange());
- }
- else {
- disassembleRegPcVal(thread, 0, pcSnap, memSnap);
- }
- }
- });
- }
-
- private void registersChanged(TraceAddressSpace space, TraceAddressSnapRange range) {
- queueRunnable(() -> {
- if (space.getFrameLevel() != 0) {
- return;
- }
- if (pcRange == null || !range.getRange().intersects(pcRange)) {
- return;
- }
- TraceThread thread = space.getThread();
- long snap = range.getY1();
- if (stackManager.getLatestStack(thread, snap) != null) {
- return;
- }
- disassembleRegPcVal(thread, space.getFrameLevel(), snap, snap);
- });
- }
-
- protected void disassembleStackPcVals(TraceStack stack, long snap, AddressRange range) {
- TraceStackFrame frame = stack.getFrame(0, false);
- if (frame == null) {
- return;
- }
- Address pcVal = frame.getProgramCounter(snap);
- if (pcVal == null) {
- return;
- }
- if (range != null && !range.contains(pcVal)) {
- return;
- }
- // NOTE: If non-0 frames are ever used, level should be passed in for injects
- disassemble(pcVal, stack.getThread(), snap);
- }
-
- protected void disassembleRegPcVal(TraceThread thread, int frameLevel, long pcSnap,
- long memSnap) {
- if (pc == null) {
- return;
- }
- TraceData pcUnit = null;
- try (Transaction tx =
- trace.openTransaction("Disassemble: PC is code pointer")) {
- TraceCodeSpace regCode = pc.getAddressSpace().isRegisterSpace()
- ? codeManager.getCodeRegisterSpace(thread, frameLevel, true)
- : codeManager.getCodeSpace(pc.getAddressSpace(), true);
- // TODO: Should be same platform as pc, not necessarily base
- AddressSpace space = trace.getBaseAddressFactory().getDefaultAddressSpace();
- PointerTypedef type = new PointerTypedef(null, VoidDataType.dataType,
- pc.getMinimumByteSize(), null, space);
- try {
- pcUnit = regCode.definedData().create(Lifespan.nowOn(pcSnap), pc, type);
- }
- catch (CodeUnitInsertionException e) {
- // I guess something's already there. Leave it, then!
- // Try to get it, in case it's already a pointer type
- pcUnit = regCode.definedData().getForRegister(pcSnap, pc);
- }
- }
- if (pcUnit != null && pcUnit.getValue() instanceof Address pcVal) {
- disassemble(pcVal, thread, memSnap);
- }
- }
-
- protected Long isKnownRWOrEverKnownRO(Address start, long snap) {
- Entry<Long, TraceMemoryState> kent = memoryManager.getViewState(snap, start);
- if (kent != null && kent.getValue() == TraceMemoryState.KNOWN) {
- return kent.getKey();
- }
- Entry<TraceAddressSnapRange, TraceMemoryState> mrent =
- memoryManager.getViewMostRecentStateEntry(snap, start);
- if (mrent == null || mrent.getValue() != TraceMemoryState.KNOWN) {
- // It has never been known up to this snap
- return null;
- }
- TraceMemoryRegion region =
- memoryManager.getRegionContaining(mrent.getKey().getY1(), start);
- if (region == null || region.isWrite()) {
- // It could have changed this snap, so unknown
- return null;
- }
- return mrent.getKey().getY1();
- }
-
- // TODO: TraceManager should instead track focus object, not thread
- protected TraceObject getObject(TraceThread thread) {
- if (!(thread instanceof TraceObjectThread)) {
- return null;
- }
- return ((TraceObjectThread) thread).getObject();
- }
-
- protected void disassemble(Address start, TraceThread thread, long snap) {
- Long knownSnap = isKnownRWOrEverKnownRO(start, snap);
- if (knownSnap == null) {
- return;
- }
- long ks = knownSnap;
- if (codeManager.definedUnits().containsAddress(ks, start)) {
- return;
- }
-
- /**
- * TODO: Is this composition of laziness upon laziness efficient enough?
- *
- * <p>
- * Can experiment with ordering of address-set-view "expression" to optimize early
- * termination.
- *
- * <p>
- * Want addresses satisfying {@code known | (readOnly & everKnown)}
- */
- AddressSetView readOnly =
- memoryManager.getRegionsAddressSetWith(ks, r -> !r.isWrite());
- AddressSetView everKnown = memoryManager.getAddressesWithState(Lifespan.since(ks),
- s -> s == TraceMemoryState.KNOWN);
- AddressSetView roEverKnown = new IntersectionAddressSetView(readOnly, everKnown);
- AddressSetView known =
- memoryManager.getAddressesWithState(ks, s -> s == TraceMemoryState.KNOWN);
- AddressSetView disassemblable =
- new AddressSet(new UnionAddressSetView(known, roEverKnown));
-
- // TODO: Should I just keep a variable-snap view around?
- TraceProgramView view = trace.getFixedProgramView(ks);
-
- BackgroundCommand cmd = new BackgroundCommand("Auto-disassemble", true, true, false) {
- @Override
- public boolean applyTo(DomainObject obj, TaskMonitor monitor) {
- try {
- DebuggerPlatformService platformService =
- findService(DebuggerPlatformService.class);
- if (platformService == null) {
- reportError("Cannot disassemble without the platform service");
- return true;
- }
- TraceObject object = getObject(thread);
- DebuggerPlatformMapper mapper =
- platformService.getMapper(trace, object, snap);
- if (mapper == null) {
- reportError("Cannot disassemble without a platform mapper");
- return true;
- }
- DisassemblyResult result = mapper.disassemble(thread, object, start,
- disassemblable, snap, monitor);
- if (result.isAtLeastOne() || result.isSuccess()) {
- return true;
- }
- reportError("Auto-disassembly error: " + result.getErrorMessage());
- }
- catch (Exception e) {
- reportError("Auto-disassembly error: " + e, e);
- }
- return true; // No pop-up errors
- }
- };
- // TODO: Queue commands so no two for the same trace run concurrently
- service.getTool().executeBackgroundCommand(cmd, view);
- }
- }
-
- private DebuggerWorkflowFrontEndService service;
- private final MultiToolTraceListenerManager<ForDisassemblyTraceListener> listeners =
- new MultiToolTraceListenerManager<>(ForDisassemblyTraceListener::new);
-
- protected void reportError(String error) {
- reportError(error, null);
- }
-
- protected void reportError(String error, Throwable t) {
- for (PluginTool tool : service.getProxyingPluginTools()) {
- Msg.error(this, error, t);
- tool.setStatusInfo(error, true);
- }
- }
-
- /**
- * Find the given service among the open tools
- *
- * <p>
- * NOTE: This will prefer the service from the most-recently active tool first, only considering
- * those with the workflow service proxy enabled. This is important when considering the state
- * of said service.
- *
- * @param <T> the type of the service
- * @param cls the class of the service
- * @return the service, or null
- */
- protected <T> T findService(Class<T> cls) {
- Collection<PluginTool> proxied = service.getProxyingPluginTools();
- List<DockingWindowManager> all = DockingWindowManager.getAllDockingWindowManagers();
- Collections.reverse(all);
- for (DockingWindowManager dwm : all) {
- Tool tool = dwm.getTool();
- if (!proxied.contains(tool)) {
- continue;
- }
- T t = tool.getService(cls);
- if (t == null) {
- continue;
- }
- return t;
- }
- return null;
- }
-
- @Override
- public boolean isEnabled() {
- return service != null;
- }
-
- @Override
- public void enable(DebuggerWorkflowFrontEndService service) {
- this.service = service;
-
- listeners.enable(service);
- }
-
- @Override
- public void disable() {
- this.service = null;
-
- listeners.disable();
- }
-
- @Override
- public void traceOpened(PluginTool tool, Trace trace) {
- listeners.traceOpened(tool, trace);
- }
-
- @Override
- public void traceClosed(PluginTool tool, Trace trace) {
- listeners.traceClosed(tool, trace);
- }
-}
diff --git a/Ghidra/Debug/Debugger/src/screen/java/ghidra/app/plugin/core/debug/gui/console/DebuggerConsolePluginScreenShots.java b/Ghidra/Debug/Debugger/src/screen/java/ghidra/app/plugin/core/debug/gui/console/DebuggerConsolePluginScreenShots.java
index 50c2ad5e9a..d37d28a6e2 100644
--- a/Ghidra/Debug/Debugger/src/screen/java/ghidra/app/plugin/core/debug/gui/console/DebuggerConsolePluginScreenShots.java
+++ b/Ghidra/Debug/Debugger/src/screen/java/ghidra/app/plugin/core/debug/gui/console/DebuggerConsolePluginScreenShots.java
@@ -23,7 +23,7 @@ import org.junit.rules.TestName;
import docking.ActionContext;
import docking.DefaultActionContext;
import docking.action.builder.ActionBuilder;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.DebuggerResources;
import ghidra.util.Msg;
import help.screenshot.GhidraScreenShotGenerator;
@@ -70,7 +70,7 @@ public class DebuggerConsolePluginScreenShots extends GhidraScreenShotGenerator
"<html>You can take <b>action</b> to resolve this message</html>",
new ScreenShotActionContext());
- AbstractGhidraHeadedDebuggerGUITest
+ AbstractGhidraHeadedDebuggerTest
.waitForPass(() -> assertEquals(3, consolePlugin.getRowCount(ActionContext.class)));
captureIsolatedProvider(consoleProvider, 600, 300);
diff --git a/Ghidra/Debug/Debugger/src/screen/java/ghidra/app/plugin/core/debug/gui/copying/DebuggerCopyActionsPluginScreenShots.java b/Ghidra/Debug/Debugger/src/screen/java/ghidra/app/plugin/core/debug/gui/copying/DebuggerCopyActionsPluginScreenShots.java
index 1cc0dcd343..0a45bc9487 100644
--- a/Ghidra/Debug/Debugger/src/screen/java/ghidra/app/plugin/core/debug/gui/copying/DebuggerCopyActionsPluginScreenShots.java
+++ b/Ghidra/Debug/Debugger/src/screen/java/ghidra/app/plugin/core/debug/gui/copying/DebuggerCopyActionsPluginScreenShots.java
@@ -20,7 +20,7 @@ import java.util.Set;
import org.junit.*;
import db.Transaction;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest.TestDebuggerTargetTraceMapper;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest.TestDebuggerTargetTraceMapper;
import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingPlugin;
import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingProvider;
import ghidra.app.plugin.core.debug.service.model.DebuggerModelServicePlugin;
diff --git a/Ghidra/Debug/Debugger/src/screen/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerThreadsPluginScreenShots.java b/Ghidra/Debug/Debugger/src/screen/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerThreadsPluginScreenShots.java
index 457790cb79..e725338c8e 100644
--- a/Ghidra/Debug/Debugger/src/screen/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerThreadsPluginScreenShots.java
+++ b/Ghidra/Debug/Debugger/src/screen/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerThreadsPluginScreenShots.java
@@ -19,8 +19,8 @@ import org.junit.Before;
import org.junit.Test;
import db.Transaction;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest.TestDebuggerTargetTraceMapper;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest.TestDebuggerTargetTraceMapper;
import ghidra.app.plugin.core.debug.service.model.DebuggerModelServiceProxyPlugin;
import ghidra.app.plugin.core.debug.service.tracemgr.DebuggerTraceManagerServicePlugin;
import ghidra.app.services.*;
@@ -72,7 +72,7 @@ public class DebuggerThreadsPluginScreenShots extends GhidraScreenShotGenerator
recorder.forceSnapshot();
TestTargetThread handler2Thread = process.addThread(4);
waitForValue(() -> recorder.getTraceThread(handler2Thread));
- AbstractGhidraHeadedDebuggerGUITest.waitForDomainObject(trace);
+ AbstractGhidraHeadedDebuggerTest.waitForDomainObject(trace);
try (Transaction tx = trace.openTransaction("Comments")) {
recorder.getTraceThread(mainThread).setComment("GUI main loop");
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/disassemble/DebuggerDisassemblyTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/disassemble/DebuggerDisassemblyTest.java
index 1ab3a9a6ff..93b1a38369 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/disassemble/DebuggerDisassemblyTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/disassemble/DebuggerDisassemblyTest.java
@@ -23,7 +23,6 @@ import java.nio.ByteBuffer;
import java.util.Set;
import java.util.function.Predicate;
import java.util.function.Supplier;
-import java.util.stream.Collectors;
import org.junit.*;
@@ -32,19 +31,17 @@ import docking.action.DockingActionIf;
import generic.Unique;
import ghidra.app.context.ListingActionContext;
import ghidra.app.plugin.core.assembler.AssemblerPluginTestHelper;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.listing.*;
import ghidra.app.plugin.core.debug.service.control.DebuggerControlServicePlugin;
import ghidra.app.plugin.core.debug.service.platform.DebuggerPlatformServicePlugin;
-import ghidra.app.plugin.core.debug.service.workflow.DebuggerWorkflowServiceProxyPlugin;
-import ghidra.app.plugin.core.debug.workflow.DisassembleAtPcDebuggerBot;
-import ghidra.app.services.*;
+import ghidra.app.services.DebuggerControlService;
+import ghidra.app.services.DebuggerPlatformService;
import ghidra.dbg.target.TargetEnvironment;
import ghidra.dbg.target.schema.SchemaContext;
import ghidra.dbg.target.schema.TargetObjectSchema.SchemaName;
-import ghidra.debug.api.control.ControlMode;
-import ghidra.debug.api.workflow.DebuggerBot;
import ghidra.dbg.target.schema.XmlSchemaContext;
+import ghidra.debug.api.control.ControlMode;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSet;
import ghidra.program.model.lang.LanguageID;
@@ -70,7 +67,7 @@ import ghidra.trace.model.thread.TraceObjectThread;
import ghidra.trace.model.thread.TraceThread;
import ghidra.util.task.TaskMonitor;
-public class DebuggerDisassemblyTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerDisassemblyTest extends AbstractGhidraHeadedDebuggerTest {
protected DebuggerDisassemblerPlugin disassemblerPlugin;
protected DebuggerPlatformService platformService;
protected DebuggerListingProvider listingProvider;
@@ -128,6 +125,9 @@ public class DebuggerDisassemblyTest extends AbstractGhidraHeadedDebuggerGUITest
platformService = addPlugin(tool, DebuggerPlatformServicePlugin.class);
disassemblerPlugin = addPlugin(tool, DebuggerDisassemblerPlugin.class);
listingProvider = waitForComponentProvider(DebuggerListingProvider.class);
+
+ // TODO: Maybe this shouldn't be the default for these tests?
+ listingProvider.setAutoDisassemble(false);
}
protected void assertX86Nop(Instruction instruction) {
@@ -136,14 +136,7 @@ public class DebuggerDisassemblyTest extends AbstractGhidraHeadedDebuggerGUITest
}
protected void enableAutoDisassembly() throws Throwable {
- DebuggerWorkflowService workflowService =
- addPlugin(tool, DebuggerWorkflowServiceProxyPlugin.class);
- Set<DebuggerBot> disBot = workflowService.getAllBots()
- .stream()
- .filter(b -> b instanceof DisassembleAtPcDebuggerBot)
- .collect(Collectors.toSet());
- assertEquals(1, disBot.size());
- workflowService.enableBots(disBot);
+ listingProvider.setAutoDisassemble(true);
}
protected DebuggerListingActionContext createActionContext(Address start, int len) {
@@ -219,7 +212,8 @@ public class DebuggerDisassemblyTest extends AbstractGhidraHeadedDebuggerGUITest
assertX86Nop(instructions.getAt(0, tb.addr(0x00400000)));
assertX86Nop(instructions.getAt(0, tb.addr(0x00400001)));
assertX86Nop(instructions.getAt(0, tb.addr(0x00400002)));
- assertNull(instructions.getAt(0, tb.addr(0x00400003)));
+ // NB. The auto disassembler will now proceed into "never known" memory.
+ // It's too much trouble to prevent it, and it's different behavior than the D key.
});
}
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/AbstractGhidraHeadedDebuggerGUITest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/AbstractGhidraHeadedDebuggerTest.java
similarity index 95%
rename from Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/AbstractGhidraHeadedDebuggerGUITest.java
rename to Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/AbstractGhidraHeadedDebuggerTest.java
index 5c7452fe21..12020ebefd 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/AbstractGhidraHeadedDebuggerGUITest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/AbstractGhidraHeadedDebuggerTest.java
@@ -32,6 +32,7 @@ import java.util.function.Supplier;
import javax.swing.*;
import javax.swing.tree.TreePath;
+import org.jdom.JDOMException;
import org.junit.*;
import org.junit.rules.TestName;
@@ -58,6 +59,8 @@ import ghidra.app.util.viewer.listingpanel.ListingPanel;
import ghidra.dbg.model.AbstractTestTargetRegisterBank;
import ghidra.dbg.model.TestDebuggerModelBuilder;
import ghidra.dbg.target.*;
+import ghidra.dbg.target.schema.SchemaContext;
+import ghidra.dbg.target.schema.XmlSchemaContext;
import ghidra.dbg.testutil.DebuggerModelTestUtils;
import ghidra.debug.api.action.*;
import ghidra.debug.api.model.*;
@@ -83,13 +86,12 @@ import ghidra.util.datastruct.TestDataStructureErrorHandlerInstaller;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.ConsoleTaskMonitor;
-public abstract class AbstractGhidraHeadedDebuggerGUITest
+public abstract class AbstractGhidraHeadedDebuggerTest
extends AbstractGhidraHeadedIntegrationTest implements DebuggerModelTestUtils {
public static final String LANGID_TOYBE64 = "Toy:BE:64:default";
public static class TestDebuggerTargetTraceMapper extends DefaultDebuggerTargetTraceMapper {
- // TODO: Instantiate this in an opinion / offer
public TestDebuggerTargetTraceMapper(TargetObject target)
throws LanguageNotFoundException, CompilerSpecNotFoundException {
super(target, new LanguageID(LANGID_TOYBE64), new CompilerSpecID("default"), Set.of());
@@ -106,6 +108,15 @@ public abstract class AbstractGhidraHeadedDebuggerGUITest
}
}
+ protected static SchemaContext xmlSchema(String xml) {
+ try {
+ return XmlSchemaContext.deserialize(xml);
+ }
+ catch (JDOMException e) {
+ throw new AssertionError(e);
+ }
+ }
+
protected static void assertNoElement(Supplier<?> supplier) {
// Give the element a chance to appear
try {
@@ -378,6 +389,12 @@ public abstract class AbstractGhidraHeadedDebuggerGUITest
clickMouse(MouseEvent.BUTTON1, m);
}
+ /**
+ * Only use this to escape from pop-up menus. Otherwise, use
+ * {@link #triggerEscapeKey(Component)}.
+ *
+ * @throws AWTException
+ */
protected static void pressEscape() throws AWTException {
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_ESCAPE);
@@ -607,38 +624,41 @@ public abstract class AbstractGhidraHeadedDebuggerGUITest
@After
public void tearDown() {
- waitForTasks();
- runSwing(() -> {
- if (traceManager == null) {
- return;
- }
- traceManager.setSaveTracesByDefault(false);
- });
+ try {
+ waitForTasks();
+ runSwing(() -> {
+ if (traceManager == null) {
+ return;
+ }
+ traceManager.setSaveTracesByDefault(false);
+ });
- if (tb != null) {
- if (traceManager != null && traceManager.getOpenTraces().contains(tb.trace)) {
- traceManager.closeTrace(tb.trace);
+ if (tb != null) {
+ if (traceManager != null && traceManager.getOpenTraces().contains(tb.trace)) {
+ traceManager.closeTrace(tb.trace);
+ }
+ tb.close();
}
- tb.close();
- }
- if (mb != null) {
- if (mb.testModel != null) {
- modelService.removeModel(mb.testModel);
- for (TraceRecorder recorder : modelService.getTraceRecorders()) {
- recorder.stopRecording();
+ if (mb != null) {
+ if (mb.testModel != null) {
+ modelService.removeModel(mb.testModel);
+ for (TraceRecorder recorder : modelService.getTraceRecorders()) {
+ recorder.stopRecording();
+ }
}
}
- }
- if (program != null) {
- programManager.closeAllPrograms(true);
- program.release(this);
- }
-
- waitForTasks();
+ if (program != null) {
+ programManager.closeAllPrograms(true);
+ program.release(this);
+ }
- env.dispose();
+ waitForTasks();
+ }
+ finally {
+ env.dispose();
+ }
}
protected void createTestModel() throws Exception {
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/DebuggerManualTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/DebuggerManualTest.java
index 382b13090e..a7fd6a9be3 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/DebuggerManualTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/DebuggerManualTest.java
@@ -33,7 +33,6 @@ import ghidra.app.plugin.core.debug.gui.register.DebuggerRegistersPlugin;
import ghidra.app.plugin.core.debug.gui.target.DebuggerTargetsPlugin;
import ghidra.app.plugin.core.debug.gui.thread.DebuggerThreadsPlugin;
import ghidra.app.plugin.core.debug.gui.time.DebuggerTimePlugin;
-import ghidra.app.plugin.core.debug.service.workflow.DebuggerWorkflowServiceProxyPlugin;
import ghidra.app.plugin.core.disassembler.DisassemblerPlugin;
import ghidra.app.plugin.core.equate.EquatePlugin;
import ghidra.app.plugin.core.function.FunctionPlugin;
@@ -51,7 +50,7 @@ import ghidra.trace.model.memory.TraceMemoryFlag;
import ghidra.trace.model.memory.TraceOverlappedRegionException;
import ghidra.util.exception.DuplicateNameException;
-public class DebuggerManualTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerManualTest extends AbstractGhidraHeadedDebuggerTest {
protected ToyDBTraceBuilder ub;
@@ -89,7 +88,6 @@ public class DebuggerManualTest extends AbstractGhidraHeadedDebuggerGUITest {
addPlugin(tool, DebuggerTargetsPlugin.class);
addPlugin(tool, DebuggerThreadsPlugin.class);
addPlugin(tool, DebuggerTimePlugin.class);
- addPlugin(tool, DebuggerWorkflowServiceProxyPlugin.class);
//addPlugin(tool, AssemblerPlugin.class);
addPlugin(tool, ByteViewerPlugin.class);
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/console/DebuggerConsoleProviderTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/console/DebuggerConsoleProviderTest.java
index 745003d371..b38f64e376 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/console/DebuggerConsoleProviderTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/console/DebuggerConsoleProviderTest.java
@@ -22,11 +22,11 @@ import org.junit.Test;
import docking.DefaultActionContext;
import docking.action.builder.ActionBuilder;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.DebuggerResources;
import ghidra.util.Msg;
-public class DebuggerConsoleProviderTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerConsoleProviderTest extends AbstractGhidraHeadedDebuggerTest {
DebuggerConsolePlugin consolePlugin;
DebuggerConsoleProvider consoleProvider;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/copying/DebuggerCopyActionsPluginTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/copying/DebuggerCopyActionsPluginTest.java
index 3c9836fb87..83c9b88f29 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/copying/DebuggerCopyActionsPluginTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/copying/DebuggerCopyActionsPluginTest.java
@@ -28,7 +28,7 @@ import db.Transaction;
import docking.action.DockingActionIf;
import generic.Unique;
import generic.test.category.NightlyCategory;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.action.AutoReadMemorySpec;
import ghidra.app.plugin.core.debug.gui.action.NoneAutoReadMemorySpec;
import ghidra.app.plugin.core.debug.gui.copying.DebuggerCopyIntoProgramDialog.RangeEntry;
@@ -49,7 +49,7 @@ import ghidra.trace.model.*;
import ghidra.trace.model.memory.TraceMemoryFlag;
@Category(NightlyCategory.class)
-public class DebuggerCopyActionsPluginTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerCopyActionsPluginTest extends AbstractGhidraHeadedDebuggerTest {
DebuggerCopyActionsPlugin copyActionsPlugin;
DebuggerListingPlugin listingPlugin;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/copying/DebuggerCopyPlanTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/copying/DebuggerCopyPlanTest.java
index 207aad3f49..0154a76193 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/copying/DebuggerCopyPlanTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/copying/DebuggerCopyPlanTest.java
@@ -29,7 +29,7 @@ import db.Transaction;
import generic.theme.GThemeDefaults.Colors.Palette;
import ghidra.app.plugin.assembler.Assembler;
import ghidra.app.plugin.assembler.Assemblers;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.DebuggerResources;
import ghidra.app.plugin.core.debug.gui.copying.DebuggerCopyPlan.AllCopiers;
import ghidra.app.util.viewer.listingpanel.PropertyBasedBackgroundColorModel;
@@ -52,7 +52,7 @@ import ghidra.trace.model.memory.TraceMemoryFlag;
import ghidra.trace.model.memory.TraceMemoryState;
import ghidra.util.task.TaskMonitor;
-public class DebuggerCopyPlanTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerCopyPlanTest extends AbstractGhidraHeadedDebuggerTest {
public static class TestDynamicDataType extends CountedDynamicDataType {
public static final TestDynamicDataType dataType = new TestDynamicDataType();
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/diff/DebuggerTraceViewDiffPluginTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/diff/DebuggerTraceViewDiffPluginTest.java
index e5137a61f4..b0c23916dc 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/diff/DebuggerTraceViewDiffPluginTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/diff/DebuggerTraceViewDiffPluginTest.java
@@ -23,7 +23,7 @@ import org.junit.Before;
import org.junit.Test;
import db.Transaction;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingPlugin;
import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingProvider;
import ghidra.app.plugin.core.debug.gui.time.DebuggerTimeSelectionDialog;
@@ -34,7 +34,7 @@ import ghidra.trace.model.memory.TraceMemoryFlag;
import ghidra.trace.model.time.schedule.TraceSchedule;
import ghidra.util.Swing;
-public class DebuggerTraceViewDiffPluginTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerTraceViewDiffPluginTest extends AbstractGhidraHeadedDebuggerTest {
protected DebuggerTraceViewDiffPlugin traceDiffPlugin;
protected DebuggerListingPlugin listingPlugin;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/interpreters/DebuggerInterpreterPluginTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/interpreters/DebuggerInterpreterPluginTest.java
index d7e7d4ab83..c423efd562 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/interpreters/DebuggerInterpreterPluginTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/interpreters/DebuggerInterpreterPluginTest.java
@@ -27,14 +27,14 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import generic.test.category.NightlyCategory;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.interpreter.InterpreterComponentProvider;
import ghidra.dbg.model.TestTargetInterpreter.ExecuteCall;
import ghidra.dbg.target.TargetConsole.Channel;
import ghidra.debug.api.interpreter.DebuggerInterpreterConnection;
@Category(NightlyCategory.class)
-public class DebuggerInterpreterPluginTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerInterpreterPluginTest extends AbstractGhidraHeadedDebuggerTest {
private DebuggerInterpreterPlugin interpreterPlugin;
@Before
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/listing/DebuggerListingProviderTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/listing/DebuggerListingProviderTest.java
index 0a8c88f2ab..6206e93250 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/listing/DebuggerListingProviderTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/listing/DebuggerListingProviderTest.java
@@ -40,7 +40,7 @@ import ghidra.app.plugin.assembler.*;
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
import ghidra.app.plugin.core.codebrowser.CodeViewerProvider;
import ghidra.app.plugin.core.codebrowser.hover.ReferenceListingHoverPlugin;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.DebuggerResources;
import ghidra.app.plugin.core.debug.gui.DebuggerResources.FollowsCurrentThreadAction;
import ghidra.app.plugin.core.debug.gui.action.*;
@@ -77,7 +77,7 @@ import ghidra.util.exception.VersionException;
import ghidra.util.task.TaskMonitor;
@Category(NightlyCategory.class)
-public class DebuggerListingProviderTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerListingProviderTest extends AbstractGhidraHeadedDebuggerTest {
protected DebuggerListingPlugin listingPlugin;
protected DebuggerListingProvider listingProvider;
@@ -95,6 +95,9 @@ public class DebuggerListingProviderTest extends AbstractGhidraHeadedDebuggerGUI
listingPlugin = addPlugin(tool, DebuggerListingPlugin.class);
listingProvider = waitForComponentProvider(DebuggerListingProvider.class);
+ // TODO: If a task crashes, the test framework hangs.
+ listingProvider.setAutoDisassemble(false);
+
mappingService = tool.getService(DebuggerStaticMappingService.class);
}
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerMemoryBytesProviderTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerMemoryBytesProviderTest.java
index 7fc41d4af2..337157d8c0 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerMemoryBytesProviderTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerMemoryBytesProviderTest.java
@@ -43,7 +43,7 @@ import ghidra.GhidraOptions;
import ghidra.app.plugin.core.byteviewer.ByteViewerComponent;
import ghidra.app.plugin.core.byteviewer.ByteViewerPanel;
import ghidra.app.plugin.core.clipboard.ClipboardPlugin;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.DebuggerResources;
import ghidra.app.plugin.core.debug.gui.DebuggerResources.FollowsCurrentThreadAction;
import ghidra.app.plugin.core.debug.gui.action.*;
@@ -71,7 +71,7 @@ import ghidra.trace.model.thread.TraceThread;
import ghidra.trace.model.time.TraceSnapshot;
@Category(NightlyCategory.class)
-public class DebuggerMemoryBytesProviderTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerMemoryBytesProviderTest extends AbstractGhidraHeadedDebuggerTest {
protected DebuggerMemoryBytesPlugin memBytesPlugin;
protected DebuggerMemoryBytesProvider memBytesProvider;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerRegionsProviderLegacyTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerRegionsProviderLegacyTest.java
index 2814cb6056..296e1150db 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerRegionsProviderLegacyTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerRegionsProviderLegacyTest.java
@@ -27,7 +27,7 @@ import org.junit.experimental.categories.Category;
import db.Transaction;
import generic.Unique;
import generic.test.category.NightlyCategory;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.DebuggerBlockChooserDialog;
import ghidra.app.plugin.core.debug.gui.DebuggerBlockChooserDialog.MemoryBlockRow;
import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingPlugin;
@@ -44,7 +44,7 @@ import ghidra.trace.model.memory.*;
import ghidra.trace.model.modules.TraceStaticMapping;
@Category(NightlyCategory.class)
-public class DebuggerRegionsProviderLegacyTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerRegionsProviderLegacyTest extends AbstractGhidraHeadedDebuggerTest {
DebuggerRegionsProvider provider;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerRegionsProviderTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerRegionsProviderTest.java
index cd817b1071..0045c9843e 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerRegionsProviderTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerRegionsProviderTest.java
@@ -27,7 +27,7 @@ import db.Transaction;
import docking.widgets.table.DynamicTableColumn;
import generic.Unique;
import generic.test.category.NightlyCategory;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.DebuggerBlockChooserDialog;
import ghidra.app.plugin.core.debug.gui.DebuggerBlockChooserDialog.MemoryBlockRow;
import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingPlugin;
@@ -56,7 +56,7 @@ import ghidra.trace.model.target.TraceObject.ConflictResolution;
import ghidra.util.table.GhidraTable;
@Category(NightlyCategory.class)
-public class DebuggerRegionsProviderTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerRegionsProviderTest extends AbstractGhidraHeadedDebuggerTest {
DebuggerRegionsProvider provider;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/model/DebuggerModelProviderTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/model/DebuggerModelProviderTest.java
index fe6e9113ea..c573aad4d8 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/model/DebuggerModelProviderTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/model/DebuggerModelProviderTest.java
@@ -31,7 +31,7 @@ import docking.widgets.tree.GTree;
import docking.widgets.tree.GTreeNode;
import docking.widgets.tree.support.GTreeSelectionEvent.EventOrigin;
import generic.Unique;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.model.ObjectTableModel.PrimitiveRow;
import ghidra.app.plugin.core.debug.gui.model.ObjectTableModel.ValueRow;
import ghidra.app.plugin.core.debug.gui.model.ObjectTreeModel.AbstractNode;
@@ -41,15 +41,15 @@ import ghidra.dbg.target.TargetEventScope;
import ghidra.dbg.target.TargetObject;
import ghidra.dbg.target.schema.SchemaContext;
import ghidra.dbg.target.schema.TargetObjectSchema.SchemaName;
-import ghidra.debug.api.tracemgr.DebuggerCoordinates;
import ghidra.dbg.target.schema.XmlSchemaContext;
+import ghidra.debug.api.tracemgr.DebuggerCoordinates;
import ghidra.trace.model.Lifespan;
import ghidra.trace.model.target.*;
import ghidra.trace.model.target.TraceObject.ConflictResolution;
import ghidra.trace.model.thread.TraceObjectThread;
import ghidra.trace.model.thread.TraceThread;
-public class DebuggerModelProviderTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerModelProviderTest extends AbstractGhidraHeadedDebuggerTest {
protected static final SchemaContext CTX;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/model/ModelQueryTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/model/ModelQueryTest.java
index ac00868261..918df7dcc9 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/model/ModelQueryTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/model/ModelQueryTest.java
@@ -21,7 +21,7 @@ import static org.junit.Assert.*;
import org.junit.Test;
import db.Transaction;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.dbg.target.schema.TargetObjectSchema.SchemaName;
import ghidra.trace.database.target.DBTraceObjectManager;
import ghidra.trace.model.Lifespan;
@@ -29,7 +29,7 @@ import ghidra.trace.model.target.TraceObject.ConflictResolution;
import ghidra.trace.model.target.TraceObjectKeyPath;
import ghidra.trace.model.target.TraceObjectValue;
-public class ModelQueryTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class ModelQueryTest extends AbstractGhidraHeadedDebuggerTest {
@Test
public void testIncludes() throws Throwable {
createTrace();
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProviderLegacyTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProviderLegacyTest.java
index d56bf538b9..c8f07d409e 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProviderLegacyTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProviderLegacyTest.java
@@ -32,6 +32,8 @@ import ghidra.app.plugin.core.debug.gui.*;
import ghidra.app.plugin.core.debug.gui.DebuggerBlockChooserDialog.MemoryBlockRow;
import ghidra.app.plugin.core.debug.gui.DebuggerResources.AbstractImportFromFileSystemAction;
import ghidra.app.plugin.core.debug.gui.DebuggerResources.AbstractSelectAddressesAction;
+import ghidra.app.plugin.core.debug.gui.action.AutoMapSpec;
+import ghidra.app.plugin.core.debug.gui.action.NoneAutoMapSpec;
import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingPlugin;
import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingProvider;
import ghidra.app.plugin.core.debug.gui.modules.DebuggerModuleMapProposalDialog.ModuleMapTableColumns;
@@ -53,7 +55,7 @@ import ghidra.trace.model.modules.*;
import ghidra.util.exception.DuplicateNameException;
@Category(NightlyCategory.class) // this may actually be an @PortSensitive test
-public class DebuggerModulesProviderLegacyTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerModulesProviderLegacyTest extends AbstractGhidraHeadedDebuggerTest {
protected DebuggerModulesPlugin modulesPlugin;
protected DebuggerModulesProvider modulesProvider;
@@ -69,6 +71,9 @@ public class DebuggerModulesProviderLegacyTest extends AbstractGhidraHeadedDebug
public void setUpModulesProviderTest() throws Exception {
modulesPlugin = addPlugin(tool, DebuggerModulesPlugin.class);
modulesProvider = waitForComponentProvider(DebuggerModulesProvider.class);
+
+ // TODO: This seems to hold up the task manager.
+ modulesProvider.setAutoMapSpec(AutoMapSpec.fromConfigName(NoneAutoMapSpec.CONFIG_NAME));
}
protected void addRegionsFromModules()
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProviderTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProviderTest.java
index ec02aa45ba..6884a48537 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProviderTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProviderTest.java
@@ -42,7 +42,6 @@ import ghidra.app.plugin.core.debug.gui.modules.DebuggerModuleMapProposalDialog.
import ghidra.app.plugin.core.debug.gui.modules.DebuggerModulesProvider.MapModulesAction;
import ghidra.app.plugin.core.debug.gui.modules.DebuggerModulesProvider.MapSectionsAction;
import ghidra.app.plugin.core.debug.gui.modules.DebuggerSectionMapProposalDialog.SectionMapTableColumns;
-import ghidra.app.plugin.core.debug.mapping.ObjectBasedDebuggerTargetTraceMapper;
import ghidra.app.services.DebuggerListingService;
import ghidra.dbg.target.*;
import ghidra.dbg.target.schema.SchemaContext;
@@ -50,16 +49,12 @@ import ghidra.dbg.target.schema.TargetObjectSchema.SchemaName;
import ghidra.dbg.target.schema.XmlSchemaContext;
import ghidra.dbg.util.PathPattern;
import ghidra.dbg.util.PathUtils;
-import ghidra.debug.api.model.DebuggerTargetTraceMapper;
-import ghidra.debug.api.model.TraceRecorder;
import ghidra.debug.api.modules.ModuleMapProposal.ModuleMapEntry;
import ghidra.debug.api.modules.SectionMapProposal.SectionMapEntry;
import ghidra.debug.api.tracemgr.DebuggerCoordinates;
import ghidra.framework.main.DataTreeDialog;
import ghidra.plugin.importer.ImporterPlugin;
import ghidra.program.model.address.*;
-import ghidra.program.model.lang.CompilerSpecID;
-import ghidra.program.model.lang.LanguageID;
import ghidra.program.model.mem.MemoryBlock;
import ghidra.trace.database.module.TraceObjectSection;
import ghidra.trace.model.Lifespan;
@@ -71,7 +66,7 @@ import ghidra.trace.model.target.TraceObject.ConflictResolution;
import ghidra.util.table.GhidraTable;
@Category(NightlyCategory.class)
-public class DebuggerModulesProviderTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerModulesProviderTest extends AbstractGhidraHeadedDebuggerTest {
DebuggerModulesProvider provider;
@@ -85,25 +80,6 @@ public class DebuggerModulesProviderTest extends AbstractGhidraHeadedDebuggerGUI
protected SchemaContext ctx;
- @Override
- protected DebuggerTargetTraceMapper createTargetTraceMapper(TargetObject target)
- throws Exception {
- return new ObjectBasedDebuggerTargetTraceMapper(target,
- new LanguageID("DATA:BE:64:default"), new CompilerSpecID("pointer64"), Set.of());
- }
-
- @Override
- protected TraceRecorder recordAndWaitSync() throws Throwable {
- TraceRecorder recorder = super.recordAndWaitSync();
- useTrace(recorder.getTrace());
- return recorder;
- }
-
- @Override
- protected TargetObject chooseTarget() {
- return mb.testModel.session;
- }
-
@Override
protected void createTrace(String langID) throws IOException {
super.createTrace(langID);
@@ -115,21 +91,6 @@ public class DebuggerModulesProviderTest extends AbstractGhidraHeadedDebuggerGUI
}
}
- @Override
- protected void useTrace(Trace trace) {
- super.useTrace(trace);
- if (trace.getObjectManager().getRootObject() != null) {
- // If live, recorder will have created it
- return;
- }
- try {
- activateObjectsMode();
- }
- catch (Exception e) {
- throw new AssertionError(e);
- }
- }
-
public void activateObjectsMode() throws Exception {
// NOTE the use of index='1' allowing object-based managers to ID unique path
ctx = XmlSchemaContext.deserialize("""
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerStaticMappingProviderTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerStaticMappingProviderTest.java
index 1719e41708..43c36f7d94 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerStaticMappingProviderTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerStaticMappingProviderTest.java
@@ -29,7 +29,7 @@ import db.Transaction;
import generic.Unique;
import generic.test.category.NightlyCategory;
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingPlugin;
import ghidra.app.plugin.core.debug.utils.ProgramURLUtils;
import ghidra.framework.plugintool.util.PluginException;
@@ -43,7 +43,7 @@ import ghidra.trace.model.modules.TraceStaticMappingManager;
import ghidra.util.task.TaskMonitor;
@Category(NightlyCategory.class)
-public class DebuggerStaticMappingProviderTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerStaticMappingProviderTest extends AbstractGhidraHeadedDebuggerTest {
protected DebuggerStaticMappingPlugin mappingsPlugin;
protected DebuggerStaticMappingProvider mappingsProvider;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/objects/DebuggerObjectsProviderTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/objects/DebuggerObjectsProviderTest.java
index 23655afc35..9477b21c4a 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/objects/DebuggerObjectsProviderTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/objects/DebuggerObjectsProviderTest.java
@@ -19,11 +19,11 @@ import org.junit.Before;
import org.junit.Test;
import db.Transaction;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.services.CodeViewerService;
import ghidra.app.services.DebuggerStaticMappingService;
-public class DebuggerObjectsProviderTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerObjectsProviderTest extends AbstractGhidraHeadedDebuggerTest {
protected DebuggerObjectsPlugin objectsPlugin;
protected DebuggerObjectsProvider objectsProvider;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/pcode/DebuggerPcodeStepperProviderTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/pcode/DebuggerPcodeStepperProviderTest.java
index 2e0cd0580c..62136ed325 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/pcode/DebuggerPcodeStepperProviderTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/pcode/DebuggerPcodeStepperProviderTest.java
@@ -27,7 +27,7 @@ import db.Transaction;
import generic.Unique;
import ghidra.app.plugin.assembler.Assembler;
import ghidra.app.plugin.assembler.Assemblers;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingPlugin;
import ghidra.app.plugin.core.debug.gui.pcode.DebuggerPcodeStepperProvider.PcodeRowHtmlFormatter;
import ghidra.app.plugin.core.debug.service.emulation.*;
@@ -48,7 +48,7 @@ import ghidra.trace.model.memory.TraceMemoryFlag;
import ghidra.trace.model.thread.TraceThread;
import ghidra.trace.model.time.schedule.TraceSchedule;
-public class DebuggerPcodeStepperProviderTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerPcodeStepperProviderTest extends AbstractGhidraHeadedDebuggerTest {
protected DebuggerTraceManagerService traceManager;
protected DebuggerPcodeStepperPlugin pcodePlugin;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/platform/DebuggerPlatformPluginTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/platform/DebuggerPlatformPluginTest.java
index ca73dd217c..d7c6609c08 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/platform/DebuggerPlatformPluginTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/platform/DebuggerPlatformPluginTest.java
@@ -25,14 +25,14 @@ import org.junit.Before;
import org.junit.Test;
import docking.action.ToggleDockingActionIf;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.mapping.DebuggerPlatformOffer;
import ghidra.app.services.DebuggerPlatformService;
import ghidra.debug.api.platform.DebuggerPlatformMapper;
import ghidra.program.model.lang.LanguageID;
import ghidra.trace.database.ToyDBTraceBuilder;
-public class DebuggerPlatformPluginTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerPlatformPluginTest extends AbstractGhidraHeadedDebuggerTest {
DebuggerPlatformPlugin platformPlugin;
DebuggerPlatformService platformService;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerRegistersProviderGuestTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerRegistersProviderGuestTest.java
deleted file mode 100644
index 391ef41a17..0000000000
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerRegistersProviderGuestTest.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/* ###
- * IP: GHIDRA
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.app.plugin.core.debug.gui.register;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import org.junit.Before;
-import org.junit.experimental.categories.Category;
-
-import db.Transaction;
-import generic.test.category.NightlyCategory;
-import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingPlugin;
-import ghidra.app.plugin.core.debug.mapping.ObjectBasedDebuggerTargetTraceMapper;
-import ghidra.app.plugin.core.debug.service.control.DebuggerControlServicePlugin;
-import ghidra.dbg.target.TargetObject;
-import ghidra.debug.api.model.DebuggerTargetTraceMapper;
-import ghidra.debug.api.model.TraceRecorder;
-import ghidra.framework.plugintool.PluginTool;
-import ghidra.program.model.data.*;
-import ghidra.program.model.lang.*;
-import ghidra.trace.model.Trace;
-import ghidra.trace.model.guest.TraceGuestPlatform;
-import ghidra.trace.model.guest.TracePlatform;
-import ghidra.trace.model.memory.TraceMemorySpace;
-import ghidra.trace.model.thread.TraceThread;
-
-@Category(NightlyCategory.class) // this may actually be an @PortSensitive test
-public class DebuggerRegistersProviderGuestTest extends DebuggerRegistersProviderTest {
-
- protected TraceGuestPlatform toy;
-
- @Override
- protected void createTrace() throws IOException {
- createTrace("DATA:BE:64:default");
- }
-
- public void createToyPlatform() throws Exception {
- try (Transaction tx = tb.startTransaction()) {
- toy = tb.trace.getPlatformManager()
- .addGuestPlatform(getToyBE64Language().getDefaultCompilerSpec());
- toy.addMappedRange(tb.addr(0), tb.addr(toy, 0), -1);
- toy.addMappedRegisterRange();
- }
- }
-
- @Before
- @Override
- public void setUpRegistersProviderTest() throws Exception {
- registersPlugin = addPlugin(tool, DebuggerRegistersPlugin.class);
- registersProvider = waitForComponentProvider(DebuggerRegistersProvider.class);
- listingPlugin = addPlugin(tool, DebuggerListingPlugin.class);
- editingService = addPlugin(tool, DebuggerControlServicePlugin.class);
-
- createTrace();
- createToyPlatform();
-
- r0 = tb.reg(toy, "r0");
- pc = toy.getLanguage().getProgramCounter();
- sp = toy.getCompilerSpec().getStackPointer();
- contextreg = toy.getLanguage().getContextBaseRegister();
-
- pch = tb.reg(toy, "pch");
- pcl = tb.reg(toy, "pcl");
-
- r0h = tb.reg(toy, "r0h");
- r0l = tb.reg(toy, "r0l");
-
- r0Struct = new StructureDataType("r0_struct", 0);
- r0Struct.add(SignedDWordDataType.dataType, "hi", "");
- r0Struct.add(DWordDataType.dataType, "lo", "");
-
- baseRegs = toy.getLanguage()
- .getRegisters()
- .stream()
- .filter(Register::isBaseRegister)
- .collect(Collectors.toSet());
- }
-
- @Override
- protected TargetObject chooseTarget() {
- return mb.testModel.session;
- }
-
- @Override
- protected DebuggerTargetTraceMapper createTargetTraceMapper(TargetObject target)
- throws Exception {
- return new ObjectBasedDebuggerTargetTraceMapper(target,
- new LanguageID("DATA:BE:64:default"), new CompilerSpecID("pointer64"), Set.of()) {
- @Override
- public TraceRecorder startRecording(PluginTool tool, Trace trace) {
- useTrace(trace);
- return super.startRecording(tool, trace);
- }
- };
- }
-
- @Override
- protected TraceRecorder recordAndWaitSync() throws Throwable {
- TraceRecorder recorder = super.recordAndWaitSync();
- createToyPlatform();
- return recorder;
- }
-
- @Override
- protected TracePlatform getPlatform() {
- return toy;
- }
-
- @Override
- protected void activateThread(TraceThread thread) {
- traceManager.activate(traceManager.resolveThread(thread).platform(toy));
- }
-
- @Override
- protected void addRegisterValues(TraceThread thread, Transaction tx) {
- TraceMemorySpace regVals =
- tb.trace.getMemoryManager().getMemoryRegisterSpace(thread, true);
- regVals.putBytes(toy, 0, pc, tb.buf(0, 0, 0, 0, 0, 0x40, 0, 0));
- regVals.putBytes(toy, 0, sp, tb.buf(0x1f, 0, 0, 0, 0, 0, 0, 0));
- regVals.putBytes(toy, 0, r0, tb.buf(1, 2, 3, 4, 5, 6, 7, 8));
- }
-
- @Override
- public void testDefaultSelection() throws Exception {
- traceManager.openTrace(tb.trace);
-
- TraceThread thread = addThread();
- addRegisterValues(thread);
- traceManager.activate(traceManager.resolveThread(thread).platform(toy));
- waitForSwing();
-
- assertEquals(DebuggerRegistersProvider.collectCommonRegisters(toy.getCompilerSpec()),
- registersProvider.getSelectionFor(toy));
- }
-}
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/stack/DebuggerStackProviderLegacyTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/stack/DebuggerStackProviderLegacyTest.java
index 02a36d445a..1f02d1cda5 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/stack/DebuggerStackProviderLegacyTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/stack/DebuggerStackProviderLegacyTest.java
@@ -25,7 +25,7 @@ import org.junit.Test;
import db.Transaction;
import generic.Unique;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.service.modules.DebuggerStaticMappingServicePlugin;
import ghidra.app.plugin.core.debug.service.modules.DebuggerStaticMappingUtils;
import ghidra.app.services.DebuggerStaticMappingService;
@@ -45,7 +45,7 @@ import ghidra.trace.model.thread.TraceThread;
import ghidra.util.exception.DuplicateNameException;
import ghidra.util.task.TaskMonitor;
-public class DebuggerStackProviderLegacyTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerStackProviderLegacyTest extends AbstractGhidraHeadedDebuggerTest {
protected DebuggerStackPlugin stackPlugin;
protected DebuggerStackProvider stackProvider;
protected DebuggerStaticMappingService mappingService;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/stack/DebuggerStackProviderTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/stack/DebuggerStackProviderTest.java
index 8d9fe10a96..87ec82984d 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/stack/DebuggerStackProviderTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/stack/DebuggerStackProviderTest.java
@@ -25,7 +25,7 @@ import org.junit.*;
import db.Transaction;
import docking.widgets.table.DynamicTableColumn;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.model.ObjectTableModel.ValueProperty;
import ghidra.app.plugin.core.debug.gui.model.ObjectTableModel.ValueRow;
import ghidra.app.plugin.core.debug.gui.model.QueryPanelTestHelper;
@@ -58,7 +58,7 @@ import ghidra.util.task.TaskMonitor;
* NOTE: I no longer synthesize a stack frame when the stack is absent. It's a bit of a hack, and I
* don't know if it's really valuable. In fact, in might obscure the fact that the stack is absent.
*/
-public class DebuggerStackProviderTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerStackProviderTest extends AbstractGhidraHeadedDebuggerTest {
protected DebuggerStackPlugin stackPlugin;
protected DebuggerStackProvider stackProvider;
protected DebuggerStaticMappingService mappingService;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/target/DebuggerTargetsProviderTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/target/DebuggerTargetsProviderTest.java
index fc8cfc9d48..0f3685a13e 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/target/DebuggerTargetsProviderTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/target/DebuggerTargetsProviderTest.java
@@ -28,7 +28,7 @@ import org.junit.experimental.categories.Category;
import docking.widgets.tree.GTreeNode;
import generic.test.category.NightlyCategory;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.DebuggerResources.*;
import ghidra.app.plugin.core.debug.service.model.DebuggerConnectDialog;
import ghidra.dbg.model.TestDebuggerObjectModel;
@@ -37,7 +37,7 @@ import ghidra.dbg.model.TestDebuggerObjectModel;
* Tests of the target provider
*/
@Category(NightlyCategory.class) // this may actually be an @PortSensitive test
-public class DebuggerTargetsProviderTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerTargetsProviderTest extends AbstractGhidraHeadedDebuggerTest {
protected DebuggerTargetsPlugin targetsPlugin;
protected DebuggerTargetsProvider targetsProvider;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerThreadsProviderLegacyTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerThreadsProviderLegacyTest.java
index ea0662e01d..c74611ac31 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerThreadsProviderLegacyTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerThreadsProviderLegacyTest.java
@@ -27,7 +27,7 @@ import org.junit.experimental.categories.Category;
import db.Transaction;
import generic.test.category.NightlyCategory;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.thread.DebuggerLegacyThreadsPanel.ThreadTableColumns;
import ghidra.trace.model.Lifespan;
import ghidra.trace.model.Trace;
@@ -36,7 +36,7 @@ import ghidra.trace.model.thread.TraceThreadManager;
import ghidra.trace.model.time.TraceTimeManager;
@Category(NightlyCategory.class) // this may actually be an @PortSensitive test
-public class DebuggerThreadsProviderLegacyTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerThreadsProviderLegacyTest extends AbstractGhidraHeadedDebuggerTest {
protected DebuggerThreadsPlugin threadsPlugin;
protected DebuggerThreadsProvider threadsProvider;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerThreadsProviderTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerThreadsProviderTest.java
index 5e069f397f..71d9a313f6 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerThreadsProviderTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/thread/DebuggerThreadsProviderTest.java
@@ -28,24 +28,18 @@ import org.junit.experimental.categories.Category;
import db.Transaction;
import docking.widgets.table.*;
import generic.test.category.NightlyCategory;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.model.ObjectTableModel;
import ghidra.app.plugin.core.debug.gui.model.ObjectTableModel.*;
import ghidra.app.plugin.core.debug.gui.model.QueryPanelTestHelper;
-import ghidra.app.plugin.core.debug.mapping.ObjectBasedDebuggerTargetTraceMapper;
import ghidra.dbg.target.TargetExecutionStateful;
import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionState;
-import ghidra.dbg.target.TargetObject;
import ghidra.dbg.target.schema.SchemaContext;
import ghidra.dbg.target.schema.TargetObjectSchema.SchemaName;
import ghidra.dbg.target.schema.XmlSchemaContext;
import ghidra.dbg.util.PathPattern;
import ghidra.dbg.util.PathUtils;
-import ghidra.debug.api.model.DebuggerTargetTraceMapper;
-import ghidra.debug.api.model.TraceRecorder;
import ghidra.debug.api.tracemgr.DebuggerCoordinates;
-import ghidra.program.model.lang.CompilerSpecID;
-import ghidra.program.model.lang.LanguageID;
import ghidra.trace.model.Lifespan;
import ghidra.trace.model.Trace;
import ghidra.trace.model.target.TraceObject.ConflictResolution;
@@ -56,7 +50,7 @@ import ghidra.trace.model.time.TraceTimeManager;
import ghidra.util.table.GhidraTable;
@Category(NightlyCategory.class)
-public class DebuggerThreadsProviderTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerThreadsProviderTest extends AbstractGhidraHeadedDebuggerTest {
DebuggerThreadsProvider provider;
@@ -65,25 +59,6 @@ public class DebuggerThreadsProviderTest extends AbstractGhidraHeadedDebuggerGUI
protected SchemaContext ctx;
- @Override
- protected DebuggerTargetTraceMapper createTargetTraceMapper(TargetObject target)
- throws Exception {
- return new ObjectBasedDebuggerTargetTraceMapper(target,
- new LanguageID("DATA:BE:64:default"), new CompilerSpecID("pointer64"), Set.of());
- }
-
- @Override
- protected TraceRecorder recordAndWaitSync() throws Throwable {
- TraceRecorder recorder = super.recordAndWaitSync();
- useTrace(recorder.getTrace());
- return recorder;
- }
-
- @Override
- protected TargetObject chooseTarget() {
- return mb.testModel.session;
- }
-
@Override
protected void createTrace(String langID) throws IOException {
super.createTrace(langID);
@@ -95,21 +70,6 @@ public class DebuggerThreadsProviderTest extends AbstractGhidraHeadedDebuggerGUI
}
}
- @Override
- protected void useTrace(Trace trace) {
- super.useTrace(trace);
- if (trace.getObjectManager().getRootObject() != null) {
- // If live, recorder will have created it
- return;
- }
- try {
- activateObjectsMode();
- }
- catch (Exception e) {
- throw new AssertionError(e);
- }
- }
-
public void activateObjectsMode() throws Exception {
// NOTE the use of index='1' allowing object-based managers to ID unique path
ctx = XmlSchemaContext.deserialize("""
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/time/DebuggerTimeProviderTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/time/DebuggerTimeProviderTest.java
index a0baf2826a..c93a456344 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/time/DebuggerTimeProviderTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/time/DebuggerTimeProviderTest.java
@@ -25,7 +25,7 @@ import org.junit.Test;
import db.Transaction;
import docking.widgets.dialogs.InputDialog;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingPlugin;
import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingProvider;
import ghidra.trace.database.time.DBTraceSnapshot;
@@ -34,7 +34,7 @@ import ghidra.trace.model.thread.TraceThread;
import ghidra.trace.model.time.TraceSnapshot;
import ghidra.trace.model.time.schedule.TraceSchedule;
-public class DebuggerTimeProviderTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerTimeProviderTest extends AbstractGhidraHeadedDebuggerTest {
protected DebuggerTimePlugin timePlugin;
protected DebuggerTimeProvider timeProvider;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/watch/DebuggerWatchesProviderTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/watch/DebuggerWatchesProviderTest.java
index cda384585a..f7432995f6 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/watch/DebuggerWatchesProviderTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/watch/DebuggerWatchesProviderTest.java
@@ -28,7 +28,7 @@ import db.Transaction;
import generic.Unique;
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
import ghidra.app.plugin.core.codebrowser.CodeViewerProvider;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingPlugin;
import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingProvider;
import ghidra.app.plugin.core.debug.gui.register.*;
@@ -59,7 +59,7 @@ import ghidra.trace.util.TraceRegisterUtils;
import ghidra.util.Msg;
import ghidra.util.task.TaskMonitor;
-public class DebuggerWatchesProviderTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerWatchesProviderTest extends AbstractGhidraHeadedDebuggerTest {
protected static void assertNoErr(DefaultWatchRow row) {
Throwable error = row.getError();
@@ -102,6 +102,9 @@ public class DebuggerWatchesProviderTest extends AbstractGhidraHeadedDebuggerGUI
try (Transaction tx = tb.startTransaction()) {
thread = tb.getOrAddThread("Thread1", 0);
}
+
+ // TODO: This seems to hold up the task manager.
+ listingProvider.setAutoDisassemble(false);
}
@After
@@ -652,7 +655,8 @@ public class DebuggerWatchesProviderTest extends AbstractGhidraHeadedDebuggerGUI
performEnabledAction(listingProvider, watchesProvider.actionAddFromLocation, true);
- List<DefaultWatchRow> watches = new ArrayList<>(watchesProvider.watchTableModel.getModelData());
+ List<DefaultWatchRow> watches =
+ new ArrayList<>(watchesProvider.watchTableModel.getModelData());
watches.sort(Comparator.comparing(DefaultWatchRow::getExpression));
assertEquals(2, watches.size());
assertEquals("*:16 0x00600000:8", watches.get(0).getExpression());
@@ -669,7 +673,8 @@ public class DebuggerWatchesProviderTest extends AbstractGhidraHeadedDebuggerGUI
performEnabledAction(codeViewerProvider, watchesProvider.actionAddFromLocation, true);
- List<DefaultWatchRow> watches = new ArrayList<>(watchesProvider.watchTableModel.getModelData());
+ List<DefaultWatchRow> watches =
+ new ArrayList<>(watchesProvider.watchTableModel.getModelData());
watches.sort(Comparator.comparing(DefaultWatchRow::getExpression));
assertEquals(2, watches.size());
assertEquals("*:16 0x55750000:8", watches.get(0).getExpression());
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/mapping/DefaultDebuggerRegisterMapperTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/mapping/DefaultDebuggerRegisterMapperTest.java
index ff1201ea11..5510f27564 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/mapping/DefaultDebuggerRegisterMapperTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/mapping/DefaultDebuggerRegisterMapperTest.java
@@ -24,7 +24,7 @@ import java.util.Set;
import org.junit.Before;
import org.junit.Test;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.dbg.model.TestTargetRegister;
import ghidra.dbg.model.TestTargetRegisterValue;
import ghidra.dbg.target.TargetObject;
@@ -36,7 +36,7 @@ import ghidra.program.model.lang.*;
import ghidra.test.ToyProgramBuilder;
import ghidra.trace.model.thread.TraceThread;
-public class DefaultDebuggerRegisterMapperTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DefaultDebuggerRegisterMapperTest extends AbstractGhidraHeadedDebuggerTest {
static class TestTargetMapper extends DefaultDebuggerTargetTraceMapper {
public TestTargetMapper(TargetObject target)
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/mapping/LargestSubDebuggerRegisterMapperTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/mapping/LargestSubDebuggerRegisterMapperTest.java
index 8f88c74e48..47c6b3e079 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/mapping/LargestSubDebuggerRegisterMapperTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/mapping/LargestSubDebuggerRegisterMapperTest.java
@@ -23,7 +23,7 @@ import java.util.*;
import org.junit.Before;
import org.junit.Test;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.dbg.model.*;
import ghidra.dbg.target.*;
import ghidra.dbg.util.CollectionUtils.Delta;
@@ -33,7 +33,7 @@ import ghidra.program.model.lang.*;
import ghidra.test.ToyProgramBuilder;
import ghidra.trace.model.thread.TraceThread;
-public class LargestSubDebuggerRegisterMapperTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class LargestSubDebuggerRegisterMapperTest extends AbstractGhidraHeadedDebuggerTest {
static class TestTargetMapper extends DefaultDebuggerTargetTraceMapper {
public TestTargetMapper(TargetObject target)
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/control/DebuggerControlServiceTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/control/DebuggerControlServiceTest.java
index 8e252c7d27..2dc97cc893 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/control/DebuggerControlServiceTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/control/DebuggerControlServiceTest.java
@@ -25,7 +25,7 @@ import org.junit.Test;
import db.Transaction;
import ghidra.app.plugin.assembler.*;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.services.*;
import ghidra.app.services.DebuggerControlService.StateEditor;
import ghidra.async.AsyncUtils.TemperamentalRunnable;
@@ -41,7 +41,7 @@ import ghidra.trace.model.memory.TraceMemorySpace;
import ghidra.trace.model.thread.TraceThread;
import ghidra.trace.model.time.schedule.TraceSchedule;
-public class DebuggerControlServiceTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerControlServiceTest extends AbstractGhidraHeadedDebuggerTest {
protected DebuggerControlService editingService;
protected Register r0;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/emulation/DebuggerEmulationServiceTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/emulation/DebuggerEmulationServiceTest.java
index 0e3bd82f5c..8a48851d4c 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/emulation/DebuggerEmulationServiceTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/emulation/DebuggerEmulationServiceTest.java
@@ -31,7 +31,7 @@ import generic.Unique;
import generic.test.category.NightlyCategory;
import ghidra.app.plugin.assembler.*;
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.mapping.DebuggerPlatformOpinion;
import ghidra.app.plugin.core.debug.service.platform.DebuggerPlatformServicePlugin;
import ghidra.app.services.DebuggerEmulationService.EmulationResult;
@@ -62,7 +62,7 @@ import ghidra.trace.model.time.schedule.TraceSchedule;
import ghidra.util.task.TaskMonitor;
@Category(NightlyCategory.class) // this may actually be an @PortSensitive test
-public class DebuggerEmulationServiceTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerEmulationServiceTest extends AbstractGhidraHeadedDebuggerTest {
protected DebuggerEmulationServicePlugin emulationPlugin;
protected CodeBrowserPlugin codeBrowser;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/model/DebuggerModelServiceTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/model/DebuggerModelServiceTest.java
index aa4f51299e..6d7f7bb620 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/model/DebuggerModelServiceTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/model/DebuggerModelServiceTest.java
@@ -30,7 +30,7 @@ import org.junit.experimental.categories.Category;
import generic.Unique;
import generic.test.category.NightlyCategory;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.DebuggerResources.AbstractConnectAction;
import ghidra.app.plugin.core.debug.service.model.DebuggerConnectDialog.FactoryEntry;
import ghidra.app.plugin.core.debug.service.model.TestDebuggerProgramLaunchOpinion.TestDebuggerProgramLaunchOffer;
@@ -55,7 +55,7 @@ import ghidra.util.datastruct.CollectionChangeListener;
* TODO: Cover cases where multiple recorders are present
*/
@Category(NightlyCategory.class)
-public class DebuggerModelServiceTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerModelServiceTest extends AbstractGhidraHeadedDebuggerTest {
protected static final long TIMEOUT_MILLIS =
SystemUtilities.isInTestingBatchMode() ? 5000 : Long.MAX_VALUE;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/model/DefaultTraceRecorderTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/model/DefaultTraceRecorderTest.java
index 36e751b0fb..2a8806b065 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/model/DefaultTraceRecorderTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/model/DefaultTraceRecorderTest.java
@@ -23,7 +23,7 @@ import java.util.Map.Entry;
import org.junit.Test;
import db.Transaction;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.dbg.model.TestTargetMemoryRegion;
import ghidra.dbg.model.TestTargetRegisterBankInThread;
import ghidra.dbg.util.PathUtils;
@@ -38,7 +38,7 @@ import ghidra.trace.model.listing.TraceCodeSpace;
import ghidra.trace.model.memory.*;
import ghidra.trace.model.thread.TraceThread;
-public class DefaultTraceRecorderTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DefaultTraceRecorderTest extends AbstractGhidraHeadedDebuggerTest {
@Test
public void testThreadsRecorded() throws Exception {
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/model/record/ObjectBasedTraceRecorderTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/model/record/ObjectBasedTraceRecorderTest.java
index e367b7f75b..80c1ef1977 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/model/record/ObjectBasedTraceRecorderTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/model/record/ObjectBasedTraceRecorderTest.java
@@ -25,7 +25,7 @@ import java.util.*;
import org.junit.Test;
import generic.Unique;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.mapping.*;
import ghidra.dbg.error.DebuggerMemoryAccessException;
import ghidra.dbg.model.*;
@@ -49,7 +49,7 @@ import ghidra.trace.model.time.TraceSnapshot;
import ghidra.trace.model.time.TraceTimeManager;
import ghidra.util.task.TaskMonitor;
-public class ObjectBasedTraceRecorderTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class ObjectBasedTraceRecorderTest extends AbstractGhidraHeadedDebuggerTest {
DebuggerMappingOpinion opinion = new ObjectBasedDebuggerMappingOpinion();
TraceRecorder recorder;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/modules/DebuggerStaticMappingServiceTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/modules/DebuggerStaticMappingServiceTest.java
index 0665076a31..8bad648977 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/modules/DebuggerStaticMappingServiceTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/modules/DebuggerStaticMappingServiceTest.java
@@ -24,7 +24,7 @@ import org.junit.Before;
import org.junit.Test;
import db.Transaction;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.services.DebuggerStaticMappingService;
import ghidra.app.services.DebuggerStaticMappingService.MappedAddressRange;
import ghidra.framework.model.DomainFile;
@@ -40,7 +40,7 @@ import ghidra.trace.model.modules.*;
import ghidra.util.Msg;
// Not technically a GUI test, but must be carried out in the context of a plugin tool
-public class DebuggerStaticMappingServiceTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerStaticMappingServiceTest extends AbstractGhidraHeadedDebuggerTest {
// TODO: Make change listener more detailed, and test it, too!
protected DebuggerStaticMappingService mappingService;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/tracemgr/DebuggerTraceManagerServiceTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/tracemgr/DebuggerTraceManagerServiceTest.java
index c823cd6b87..5412c5e688 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/tracemgr/DebuggerTraceManagerServiceTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/tracemgr/DebuggerTraceManagerServiceTest.java
@@ -25,7 +25,7 @@ import org.junit.experimental.categories.Category;
import db.Transaction;
import generic.test.category.NightlyCategory;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.service.control.DebuggerControlServicePlugin;
import ghidra.app.services.*;
import ghidra.dbg.model.TestTargetStack;
@@ -48,7 +48,7 @@ import ghidra.trace.model.thread.TraceObjectThread;
import ghidra.trace.model.thread.TraceThread;
@Category(NightlyCategory.class) // this may actually be an @PortSensitive test
-public class DebuggerTraceManagerServiceTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerTraceManagerServiceTest extends AbstractGhidraHeadedDebuggerTest {
protected DebuggerControlService editingService;
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/stack/StackUnwinderTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/stack/StackUnwinderTest.java
index 3da02ed29b..ca28ab6fe9 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/stack/StackUnwinderTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/stack/StackUnwinderTest.java
@@ -36,7 +36,7 @@ import ghidra.app.plugin.assembler.*;
import ghidra.app.plugin.assembler.sleigh.sem.*;
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
import ghidra.app.plugin.core.debug.disassemble.TraceDisassembleCommand;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingPlugin;
import ghidra.app.plugin.core.debug.gui.stack.vars.*;
import ghidra.app.plugin.core.debug.gui.stack.vars.VariableValueRow.*;
@@ -81,7 +81,7 @@ import ghidra.trace.model.time.schedule.Scheduler;
import ghidra.util.Msg;
import ghidra.util.NumericUtilities;
-public class StackUnwinderTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class StackUnwinderTest extends AbstractGhidraHeadedDebuggerTest {
public static final AssemblySelector NO_16BIT_CALLS = new AssemblySelector() {
@Override
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/debug/flatapi/FlatDebuggerAPITest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/debug/flatapi/FlatDebuggerAPITest.java
index 8c14b62b54..937f0f89d1 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/debug/flatapi/FlatDebuggerAPITest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/debug/flatapi/FlatDebuggerAPITest.java
@@ -33,8 +33,9 @@ import db.Transaction;
import generic.Unique;
import ghidra.app.plugin.assembler.Assembler;
import ghidra.app.plugin.assembler.Assemblers;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingPlugin;
+import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingProvider;
import ghidra.app.plugin.core.debug.service.breakpoint.DebuggerLogicalBreakpointServicePlugin;
import ghidra.app.plugin.core.debug.service.control.DebuggerControlServicePlugin;
import ghidra.app.plugin.core.debug.service.emulation.DebuggerEmulationServicePlugin;
@@ -70,7 +71,7 @@ import ghidra.trace.model.stack.TraceStack;
import ghidra.trace.model.thread.TraceThread;
import ghidra.trace.model.time.schedule.TraceSchedule;
-public class FlatDebuggerAPITest extends AbstractGhidraHeadedDebuggerGUITest {
+public class FlatDebuggerAPITest extends AbstractGhidraHeadedDebuggerTest {
protected static class TestFactory implements DebuggerModelFactory {
private final DebuggerObjectModel model;
@@ -143,6 +144,9 @@ public class FlatDebuggerAPITest extends AbstractGhidraHeadedDebuggerGUITest {
listingService = addPlugin(tool, DebuggerListingPlugin.class);
editingService = addPlugin(tool, DebuggerControlServicePlugin.class);
flat = new TestFlatAPI();
+
+ // TODO: This seems to hold up the task manager.
+ waitForComponentProvider(DebuggerListingProvider.class).setAutoDisassemble(false);
}
@Test
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/pcode/exec/TraceRecorderPcodeExecTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/pcode/exec/TraceRecorderPcodeExecTest.java
index cb0c18d236..bbc8274cc8 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/pcode/exec/TraceRecorderPcodeExecTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/pcode/exec/TraceRecorderPcodeExecTest.java
@@ -23,7 +23,7 @@ import java.util.Map;
import org.junit.Test;
import db.Transaction;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.processors.sleigh.SleighLanguage;
import ghidra.dbg.model.TestTargetRegisterBankInThread;
import ghidra.debug.api.action.ActionSource;
@@ -47,7 +47,7 @@ import ghidra.trace.model.time.schedule.TraceSchedule;
* Test the {@link DirectBytesTracePcodeExecutorState} in combination with
* {@link PcodeDebuggerAccess} to ensure it reads and writes the target when appropriate.
*/
-public class TraceRecorderPcodeExecTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class TraceRecorderPcodeExecTest extends AbstractGhidraHeadedDebuggerTest {
@Test
public void testExecutorEval() throws Throwable {
diff --git a/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/target/TargetBreakpointLocation.java b/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/target/TargetBreakpointLocation.java
index c1224ab0b2..000fec54b3 100644
--- a/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/target/TargetBreakpointLocation.java
+++ b/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/target/TargetBreakpointLocation.java
@@ -17,7 +17,6 @@ package ghidra.dbg.target;
import ghidra.dbg.DebuggerTargetObjectIface;
import ghidra.dbg.target.schema.TargetAttributeType;
-import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressRange;
/**
@@ -50,45 +49,6 @@ public interface TargetBreakpointLocation extends TargetObject {
return getTypedAttributeNowByName(RANGE_ATTRIBUTE_NAME, AddressRange.class, null);
}
- /**
- * The minimum address of this location
- *
- * @return the address
- * @deprecated use {@link #getRange()} instead
- */
- @Deprecated(forRemoval = true, since = "10.2")
- public default Address getAddress() {
- return getRange().getMinAddress();
- }
-
- /**
- * If available, get the length in bytes, of the range covered by the breakpoint.
- *
- * <p>
- * In most cases, where the length is not available, a length of 1 should be presumed.
- *
- * @return the length, or {@code null} if not known
- * @deprecated use {@link #getRange()} instead
- */
- @Deprecated(forRemoval = true, since = "10.2")
- public default Integer getLength() {
- AddressRange range = getRange();
- return range == null ? null : (int) range.getLength();
- }
-
- /**
- * Get the length, defaulting to a given fallback, usually 1
- *
- * @param fallback the fallback value
- * @return the length, or the fallback
- * @deprecated use {@link #getRange()} instead
- */
- @Deprecated(forRemoval = true, since = "10.2")
- public default int getLengthOrDefault(int fallback) {
- Integer length = getLength();
- return length == null ? 1 : length;
- }
-
/**
* Get a reference to the specification which generated this breakpoint.
*
diff --git a/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/target/TargetMethod.java b/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/target/TargetMethod.java
index f366636893..d45514f027 100644
--- a/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/target/TargetMethod.java
+++ b/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/target/TargetMethod.java
@@ -639,7 +639,7 @@ public interface TargetMethod extends TargetObject {
* @param permitExtras false to require every named argument has a named parameter
* @return the map of validated arguments
*/
- static Map<String, ?> validateArguments(Map<String, ParameterDescription<?>> parameters,
+ static Map<String, Object> validateArguments(Map<String, ParameterDescription<?>> parameters,
Map<String, ?> arguments, boolean permitExtras) {
if (!permitExtras) {
if (!parameters.keySet().containsAll(arguments.keySet())) {
diff --git a/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/target/TargetObject.java b/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/target/TargetObject.java
index b309c64557..7f5c5fe733 100644
--- a/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/target/TargetObject.java
+++ b/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/target/TargetObject.java
@@ -156,6 +156,13 @@ import ghidra.lifecycle.Internal;
* object or throw an exception. In those cases, unless otherwise noted, this actually means the
* future will complete with that object, or complete exceptionally. Specifying this in every
* instance is just pedantic.
+ *
+ * <p>
+ * Assuming Trace RMI is successful, this interface will face a serious identity crisis. It will no
+ * longer serve its purpose as a proper Java interface, and instead will only serve as a type name
+ * in the object-model schema, which survives in the trace database. For some of the interfaces, we
+ * already have defined equivalent interfaces in the trace object manager. We will probably port
+ * additional interfaces over and eventually remove all of these.
*/
public interface TargetObject extends Comparable<TargetObject> {
diff --git a/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/target/TargetRegister.java b/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/target/TargetRegister.java
index 2dd69e9635..d285cecd28 100644
--- a/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/target/TargetRegister.java
+++ b/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/target/TargetRegister.java
@@ -23,9 +23,31 @@ import ghidra.dbg.util.PathUtils;
* This is a description of a register
*
* <p>
- * This describes a register abstractly. It does not represent the actual value of a register. For
- * values, see {@link TargetRegisterBank}. The description and values are separated, since the
- * descriptions typically apply to the entire platform, and so can be presented just once.
+ * There are two conventions for presenting registers and their values:
+ *
+ * <ol>
+ * <li><b>Descriptions separated from values:</b> In this convention, the target presents one
+ * {@link TargetRegisterContainer}, and in it the various {@link TargetRegister}s, perhaps organized
+ * into groups. Each {@link TargetRegister} is then just an abstract description of the register,
+ * notably its name and size. Values are read and written using the
+ * {@link TargetRegisterBank#readRegister(TargetRegister)} and
+ * {@link TargetRegisterBank#writeRegister(TargetRegister, byte[])} methods, and related convenience
+ * methods. The {@link TargetRegisterBank} is the suitable bank for the desired object, usually a
+ * thread or frame.</li>
+ * <li><b>Descriptions and values together:</b> In this convention, the
+ * {@link TargetRegisterContainer} is the same object as the {@link TargetRegisterBank}, and so its'
+ * replicated for every object that has registers. The registers may be presented in groups under
+ * the container/bank. Each register provides its name (i.e., its index or key), its size, and its
+ * value (in the {@value TargetObject#VALUE_ATTRIBUTE_NAME} attribute).</li>
+ * </ol>
+ *
+ * <p>
+ * Despite the apparent efficiencies of presenting the descriptions only once, we are gravitating
+ * toward the descriptions-and-values together convention. This simplifies the client and
+ * model-inspection code a bit and will make things easier if we ever deal with targets having mixed
+ * architectures. If we settle on this convention, we will probably remove the
+ * {@link TargetRegisterContainer} interface in favor of using {@link TargetRegisterBank}. We may
+ * also formally introduce a {@code TargetRegisterGroup} interface.
*/
@DebuggerTargetObjectIface("Register")
public interface TargetRegister extends TargetObject {
diff --git a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/breakpoint/DBTraceObjectBreakpointLocation.java b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/breakpoint/DBTraceObjectBreakpointLocation.java
index d436ff605f..f96c362127 100644
--- a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/breakpoint/DBTraceObjectBreakpointLocation.java
+++ b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/breakpoint/DBTraceObjectBreakpointLocation.java
@@ -365,6 +365,10 @@ public class DBTraceObjectBreakpointLocation
return object;
}
+ public TraceObjectBreakpointSpec getOrCreateSpecification() {
+ return object.queryOrCreateCanonicalAncestorInterface(TraceObjectBreakpointSpec.class);
+ }
+
@Override
public TraceObjectBreakpointSpec getSpecification() {
try (LockHold hold = object.getTrace().lockRead()) {
diff --git a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/breakpoint/DBTraceObjectBreakpointSpec.java b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/breakpoint/DBTraceObjectBreakpointSpec.java
index a769e9c2d8..bb59a4bd9d 100644
--- a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/breakpoint/DBTraceObjectBreakpointSpec.java
+++ b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/breakpoint/DBTraceObjectBreakpointSpec.java
@@ -46,7 +46,7 @@ public class DBTraceObjectBreakpointSpec
implements TraceObjectBreakpointSpec, DBTraceObjectInterface {
private final DBTraceObject object;
- private TraceBreakpointKindSet kinds;
+ private TraceBreakpointKindSet kinds = TraceBreakpointKindSet.of();
public DBTraceObjectBreakpointSpec(DBTraceObject object) {
this.object = object;
diff --git a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/memory/DBTraceObjectMemoryRegion.java b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/memory/DBTraceObjectMemoryRegion.java
index ebb157a12f..04f8c3e5ad 100644
--- a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/memory/DBTraceObjectMemoryRegion.java
+++ b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/memory/DBTraceObjectMemoryRegion.java
@@ -312,7 +312,8 @@ public class DBTraceObjectMemoryRegion implements TraceObjectMemoryRegion, DBTra
public Set<TraceMemoryFlag> getFlags(long snap) {
EnumSet<TraceMemoryFlag> result = EnumSet.noneOf(TraceMemoryFlag.class);
for (TraceMemoryFlag flag : TraceMemoryFlag.values()) {
- if (object.getValue(snap, keyForFlag(flag)) != null) {
+ TraceObjectValue value = object.getValue(snap, keyForFlag(flag));
+ if (value != null && value.getValue() == Boolean.TRUE) {
result.add(flag);
}
}
diff --git a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/target/DBTraceObject.java b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/target/DBTraceObject.java
index 6858c2a2f3..3062e1f78b 100644
--- a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/target/DBTraceObject.java
+++ b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/target/DBTraceObject.java
@@ -863,6 +863,22 @@ public class DBTraceObject extends DBAnnotatedObject implements TraceObject {
.map(p -> p.getSource(this).queryInterface(ifClass));
}
+ public TraceObject queryOrCreateCanonicalAncestorTargetInterface(
+ Class<? extends TargetObject> targetIf) {
+ PathMatcher matcher = getManager().getRootSchema().searchFor(targetIf, false);
+ return path.streamMatchingAncestry(matcher)
+ .limit(1)
+ .map(kp -> manager.createObject(kp))
+ .findAny()
+ .orElseThrow();
+ }
+
+ public <I extends TraceObjectInterface> I queryOrCreateCanonicalAncestorInterface(
+ Class<I> ifClass) {
+ return queryOrCreateCanonicalAncestorTargetInterface(
+ TraceObjectInterfaceUtils.toTargetIf(ifClass)).queryInterface(ifClass);
+ }
+
@Override
public Stream<? extends TraceObject> queryCanonicalAncestorsTargetInterface(
Class<? extends TargetObject> targetIf) {
diff --git a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/target/DBTraceObjectManager.java b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/target/DBTraceObjectManager.java
index e990bb5c64..49ce50eabb 100644
--- a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/target/DBTraceObjectManager.java
+++ b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/target/DBTraceObjectManager.java
@@ -37,6 +37,7 @@ import ghidra.program.model.address.*;
import ghidra.program.model.lang.Language;
import ghidra.trace.database.DBTrace;
import ghidra.trace.database.DBTraceManager;
+import ghidra.trace.database.breakpoint.DBTraceObjectBreakpointLocation;
import ghidra.trace.database.map.DBTraceAddressSnapRangePropertyMap;
import ghidra.trace.database.map.DBTraceAddressSnapRangePropertyMapTree.TraceAddressSnapRangeQuery;
import ghidra.trace.database.module.TraceObjectSection;
@@ -45,8 +46,7 @@ import ghidra.trace.database.target.visitors.SuccessorsRelativeVisitor;
import ghidra.trace.database.thread.DBTraceObjectThread;
import ghidra.trace.model.*;
import ghidra.trace.model.Trace.TraceObjectChangeType;
-import ghidra.trace.model.breakpoint.TraceBreakpointKind;
-import ghidra.trace.model.breakpoint.TraceObjectBreakpointLocation;
+import ghidra.trace.model.breakpoint.*;
import ghidra.trace.model.memory.*;
import ghidra.trace.model.modules.TraceObjectModule;
import ghidra.trace.model.stack.TraceObjectStack;
@@ -599,14 +599,17 @@ public class DBTraceObjectManager implements TraceObjectManager, DBTraceManager
"breakpoint specification on the given path.");
}
try (LockHold hold = trace.lockWrite()) {
- TraceObjectBreakpointLocation loc =
- doAddWithInterface(path, TraceObjectBreakpointLocation.class);
+ DBTraceObjectBreakpointLocation loc =
+ (DBTraceObjectBreakpointLocation) doAddWithInterface(path,
+ TraceObjectBreakpointLocation.class);
loc.setName(lifespan, path);
loc.setRange(lifespan, range);
- // NB. Ignore threads. I'd like to deprecate that field, anyway.
- loc.setKinds(lifespan, kinds);
loc.setEnabled(lifespan, enabled);
loc.setComment(lifespan, comment);
+
+ TraceObjectBreakpointSpec spec = loc.getOrCreateSpecification();
+ // NB. Ignore threads. I'd like to deprecate that field, anyway.
+ spec.setKinds(lifespan, kinds);
loc.getObject().insert(lifespan, ConflictResolution.DENY);
return loc;
}
diff --git a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/target/visitors/CanonicalSuccessorsRelativeVisitor.java b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/target/visitors/CanonicalSuccessorsRelativeVisitor.java
index beecf8320f..4a3720ab84 100644
--- a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/target/visitors/CanonicalSuccessorsRelativeVisitor.java
+++ b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/target/visitors/CanonicalSuccessorsRelativeVisitor.java
@@ -89,7 +89,8 @@ public class CanonicalSuccessorsRelativeVisitor implements Visitor {
Stream<TraceObjectValue> restStream = nextKeys.stream()
.filter(k -> !"".equals(k) && !"[]".equals(k))
- .map(k -> getCanonicalValue(object, k));
+ .map(k -> getCanonicalValue(object, k))
+ .filter(v -> v != null);
return Stream.concat(Stream.concat(attrStream, elemStream), restStream);
}
diff --git a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/target/visitors/TreeTraversal.java b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/target/visitors/TreeTraversal.java
index fe22c8dcf7..61759e1326 100644
--- a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/target/visitors/TreeTraversal.java
+++ b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/target/visitors/TreeTraversal.java
@@ -15,6 +15,7 @@
*/
package ghidra.trace.database.target.visitors;
+import java.util.Objects;
import java.util.stream.Stream;
import ghidra.trace.model.Lifespan;
@@ -180,6 +181,7 @@ public enum TreeTraversal {
*/
public Stream<? extends TraceObjectValPath> walkValue(Visitor visitor,
TraceObjectValue value, Lifespan span, TraceObjectValPath path) {
+ Objects.requireNonNull(value);
Lifespan compSpan = visitor.composeSpan(span, value);
if (compSpan == null) {
return Stream.empty();
diff --git a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/model/memory/TraceMemoryManager.java b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/model/memory/TraceMemoryManager.java
index d8c80944fe..d27016a2f5 100644
--- a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/model/memory/TraceMemoryManager.java
+++ b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/model/memory/TraceMemoryManager.java
@@ -52,7 +52,7 @@ public interface TraceMemoryManager extends TraceMemoryOperations {
* <p>
* NOTE: We are also moving away from (space, thread, frame) triples to uniquely identify
* register storage. Instead, that will be encoded into the address space itself. Register
- * overlays will overlay register space as be named after the register container object, which
+ * overlays will overlay register space and be named after the register container object, which
* subsumes thread and frame when applicable.
*
* @param name the name of the new address space
diff --git a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/model/target/TraceObject.java b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/model/target/TraceObject.java
index 89f2d54137..98f320159e 100644
--- a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/model/target/TraceObject.java
+++ b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/model/target/TraceObject.java
@@ -26,7 +26,6 @@ import ghidra.dbg.util.PathPattern;
import ghidra.dbg.util.PathPredicates;
import ghidra.trace.model.*;
import ghidra.trace.model.Lifespan.LifeSet;
-import ghidra.trace.model.target.TraceObject.ConflictResolution;
/**
* The trace record of an observed {@link TargetObject}
diff --git a/Ghidra/Debug/Framework-TraceModeling/src/test/java/ghidra/trace/database/ToyDBTraceBuilder.java b/Ghidra/Debug/Framework-TraceModeling/src/test/java/ghidra/trace/database/ToyDBTraceBuilder.java
index e9cc67c8e9..b3524eae0d 100644
--- a/Ghidra/Debug/Framework-TraceModeling/src/test/java/ghidra/trace/database/ToyDBTraceBuilder.java
+++ b/Ghidra/Debug/Framework-TraceModeling/src/test/java/ghidra/trace/database/ToyDBTraceBuilder.java
@@ -32,6 +32,7 @@ import db.DBHandle;
import db.Transaction;
import generic.theme.GThemeDefaults.Colors.Messages;
import ghidra.app.plugin.processors.sleigh.SleighLanguage;
+import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionState;
import ghidra.dbg.util.PathPredicates;
import ghidra.pcode.exec.*;
import ghidra.pcode.exec.trace.TraceSleighUtils;
@@ -49,12 +50,15 @@ import ghidra.trace.database.bookmark.*;
import ghidra.trace.database.listing.*;
import ghidra.trace.database.memory.DBTraceMemoryManager;
import ghidra.trace.database.symbol.DBTraceReference;
+import ghidra.trace.database.target.DBTraceObjectManager;
import ghidra.trace.database.thread.DBTraceThreadManager;
import ghidra.trace.model.*;
import ghidra.trace.model.guest.TraceGuestPlatform;
import ghidra.trace.model.guest.TracePlatform;
import ghidra.trace.model.symbol.TraceReferenceManager;
import ghidra.trace.model.target.*;
+import ghidra.trace.model.target.TraceObject.ConflictResolution;
+import ghidra.trace.model.thread.TraceObjectThread;
import ghidra.trace.model.thread.TraceThread;
import ghidra.util.Msg;
import ghidra.util.database.DBOpenMode;
@@ -754,6 +758,33 @@ public class ToyDBTraceBuilder implements AutoCloseable {
return getLanguage(langID).getCompilerSpecByID(new CompilerSpecID(compID));
}
+ public void createObjectsProcessAndThreads() {
+ DBTraceObjectManager objs = trace.getObjectManager();
+ TraceObjectKeyPath pathProc1 = TraceObjectKeyPath.parse("Processes[1]");
+ TraceObject proc1 = objs.createObject(pathProc1);
+ Lifespan zeroOn = Lifespan.nowOn(0);
+ proc1.insert(zeroOn, ConflictResolution.DENY);
+ TraceObject t1 = objs.createObject(pathProc1.key("Threads").index(1));
+ t1.insert(zeroOn, ConflictResolution.DENY);
+ TraceObject t2 = objs.createObject(pathProc1.key("Threads").index(2));
+ t2.insert(zeroOn, ConflictResolution.DENY);
+
+ proc1.setAttribute(zeroOn, "_state", TargetExecutionState.STOPPED.name());
+ }
+
+ public void createObjectsFramesAndRegs(TraceObjectThread thread, Lifespan lifespan,
+ TracePlatform platform, int n) {
+ DBTraceObjectManager objs = trace.getObjectManager();
+ TraceObjectKeyPath pathThread = thread.getObject().getCanonicalPath();
+ for (int i = 0; i < n; i++) {
+ TraceObjectKeyPath pathContainer = pathThread.key("Stack").index(i).key("Registers");
+ for (Register reg : platform.getLanguage().getRegisters()) {
+ TraceObject regObj = objs.createObject(pathContainer.index(reg.getName()));
+ regObj.insert(lifespan, ConflictResolution.DENY);
+ }
+ }
+ }
+
/**
* Get an object by its canonical path
*
@@ -765,7 +796,6 @@ public class ToyDBTraceBuilder implements AutoCloseable {
.getObjectByCanonicalPath(TraceObjectKeyPath.parse(canonicalPath));
}
-
/**
* Get an object by its path pattern
*
@@ -775,8 +805,10 @@ public class ToyDBTraceBuilder implements AutoCloseable {
public TraceObject objAny(String pat) {
return objAny(pat, Lifespan.at(0));
}
+
public TraceObject objAny(String path, Lifespan span) {
- return trace.getObjectManager().getObjectsByPath(span, TraceObjectKeyPath.parse(path))
+ return trace.getObjectManager()
+ .getObjectsByPath(span, TraceObjectKeyPath.parse(path))
.findFirst()
.orElse(null);
}
@@ -795,7 +827,7 @@ public class ToyDBTraceBuilder implements AutoCloseable {
}
/**
- * List all values matching the given pattern at the given stnap.
+ * List all values matching the given pattern at the given snap.
*
* @param snap the snap
* @param pattern the pattern
diff --git a/Ghidra/Debug/TaintAnalysis/src/test/java/ghidra/pcode/emu/taint/full/TaintDebuggerPcodeEmulatorTest.java b/Ghidra/Debug/TaintAnalysis/src/test/java/ghidra/pcode/emu/taint/full/TaintDebuggerPcodeEmulatorTest.java
index 4f8fcd6ce1..c5bc1ac99f 100644
--- a/Ghidra/Debug/TaintAnalysis/src/test/java/ghidra/pcode/emu/taint/full/TaintDebuggerPcodeEmulatorTest.java
+++ b/Ghidra/Debug/TaintAnalysis/src/test/java/ghidra/pcode/emu/taint/full/TaintDebuggerPcodeEmulatorTest.java
@@ -26,7 +26,7 @@ import org.junit.Test;
import db.Transaction;
import ghidra.app.plugin.assembler.Assembler;
import ghidra.app.plugin.assembler.Assemblers;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.service.emulation.DebuggerEmulationServicePlugin;
import ghidra.app.plugin.core.debug.service.modules.DebuggerStaticMappingServicePlugin;
import ghidra.app.services.DebuggerEmulationService;
@@ -45,7 +45,7 @@ import ghidra.trace.model.thread.TraceThread;
import ghidra.trace.model.time.schedule.*;
import ghidra.util.task.TaskMonitor;
-public class TaintDebuggerPcodeEmulatorTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class TaintDebuggerPcodeEmulatorTest extends AbstractGhidraHeadedDebuggerTest {
private DebuggerStaticMappingService mappingService;
private DebuggerEmulationService emuService;
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/terminal/DefaultTerminal.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/terminal/DefaultTerminal.java
index eebfe0eab5..fff16c1656 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/terminal/DefaultTerminal.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/terminal/DefaultTerminal.java
@@ -45,6 +45,11 @@ public class DefaultTerminal implements Terminal {
provider.terminated();
}
+ @Override
+ public boolean isTerminated() {
+ return provider.isTerminated();
+ }
+
@Override
public void addTerminalListener(TerminalListener listener) {
provider.addTerminalListener(listener);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/terminal/TerminalPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/terminal/TerminalPlugin.java
index 0150af43ac..34fe44f1e9 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/terminal/TerminalPlugin.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/terminal/TerminalPlugin.java
@@ -35,7 +35,7 @@ import ghidra.util.Swing;
* The plugin that provides {@link TerminalService}
*/
@PluginInfo(
- status = PluginStatus.UNSTABLE,
+ status = PluginStatus.STABLE,
category = PluginCategoryNames.COMMON,
packageName = CorePluginPackage.NAME,
description = "Provides VT100 Terminal Emulation",
@@ -74,6 +74,7 @@ public class TerminalPlugin extends Plugin implements TerminalService {
provider.setVisible(true);
providers.add(provider);
provider.setClipboardService(clipboardService);
+ provider.toFront();
return provider;
});
}
@@ -93,7 +94,7 @@ public class TerminalPlugin extends Plugin implements TerminalService {
channel.write(buf);
}
catch (IOException e) {
- Msg.error(this, "Could not write terminal output", e);
+ Msg.error(this, "Could not write terminal output: " + e);
}
}
}), in);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/terminal/TerminalProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/terminal/TerminalProvider.java
index 48ccac54be..e76a82a865 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/terminal/TerminalProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/terminal/TerminalProvider.java
@@ -34,6 +34,7 @@ import docking.action.DockingActionIf;
import docking.action.builder.ActionBuilder;
import docking.widgets.OkDialog;
import docking.widgets.fieldpanel.support.*;
+import generic.theme.GColor;
import generic.theme.GIcon;
import ghidra.app.plugin.core.terminal.TerminalPanel.FindOptions;
import ghidra.app.plugin.core.terminal.vt.VtOutput;
@@ -48,6 +49,8 @@ import ghidra.util.Swing;
* This also provides UI actions for searching the terminal's contents.
*/
public class TerminalProvider extends ComponentProviderAdapter {
+ // TODO: A separate color?
+ private static final Color COLOR_TERMINATED = new GColor("color.border.provider.disconnected");
protected class FindDialog extends DialogComponentProvider {
protected final JTextField txtFind = new JTextField(20);
@@ -173,6 +176,10 @@ public class TerminalProvider extends ComponentProviderAdapter {
});
createActions();
setWindowMenuGroup("Terminals");
+ setDefaultWindowPosition(WindowPosition.BOTTOM);
+
+ // Avoid change in dimension when "terminated" border is applied
+ panel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
}
@Override
@@ -363,6 +370,9 @@ public class TerminalProvider extends ComponentProviderAdapter {
if (!isVisible()) {
removeFromTool();
}
+ else {
+ panel.setBorder(BorderFactory.createLineBorder(COLOR_TERMINATED, 2));
+ }
});
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/services/Terminal.java b/Ghidra/Features/Base/src/main/java/ghidra/app/services/Terminal.java
index 20b422d73d..69b2045bf4 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/services/Terminal.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/services/Terminal.java
@@ -203,4 +203,11 @@ public interface Terminal extends AutoCloseable {
* @param action the action to terminate the session, or null to remove the action
*/
void setTerminateAction(Runnable action);
+
+ /**
+ * Check whether the terminal is terminated or active
+ *
+ * @return true for terminated, false for active
+ */
+ boolean isTerminated();
}
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/test/AbstractDockingTest.java b/Ghidra/Framework/Docking/src/main/java/docking/test/AbstractDockingTest.java
index 224b43826f..63cf3e30f0 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/test/AbstractDockingTest.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/test/AbstractDockingTest.java
@@ -1742,8 +1742,7 @@ public abstract class AbstractDockingTest extends AbstractGuiTest {
Objects.requireNonNull(c);
Objects.requireNonNull(consumer);
- if (c instanceof JTextComponent) {
- JTextComponent tf = (JTextComponent) c;
+ if (c instanceof JTextComponent tf) {
forceTextComponentFocus(tf);
}
diff --git a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/PtySession.java b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/PtySession.java
index 8402856d32..a096c2f79b 100644
--- a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/PtySession.java
+++ b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/PtySession.java
@@ -40,4 +40,11 @@ public interface PtySession {
* whatever local resources are used in maintaining and controlling the remote session.
*/
void destroyForcibly();
+
+ /**
+ * Get a human-readable description of the session
+ *
+ * @return the description
+ */
+ String description();
}
diff --git a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/linux/FdInputStream.java b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/linux/FdInputStream.java
index 0b580ca1f5..9a79cdb8f5 100644
--- a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/linux/FdInputStream.java
+++ b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/linux/FdInputStream.java
@@ -75,7 +75,7 @@ public class FdInputStream extends InputStream {
ret = LIB_POSIX.read(fd, buf, len);
}
catch (LastErrorException e) {
- if (e.getErrorCode() == 5) {
+ if (e.getErrorCode() == 5 || e.getErrorCode() == 9) {
throw new IOException(e);
}
throw e;
diff --git a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/linux/FdOutputStream.java b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/linux/FdOutputStream.java
index e873f4f955..bedcc42aee 100644
--- a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/linux/FdOutputStream.java
+++ b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/linux/FdOutputStream.java
@@ -18,6 +18,7 @@ package ghidra.pty.linux;
import java.io.IOException;
import java.io.OutputStream;
+import com.sun.jna.LastErrorException;
import com.sun.jna.Memory;
/**
@@ -60,12 +61,20 @@ public class FdOutputStream extends OutputStream {
}
Memory buf = new Memory(len);
buf.write(0, b, off, len);
- int total = 0;
- do {
- int ret = LIB_POSIX.write(fd, buf, len - total);
- total += ret;
+ try {
+ int total = 0;
+ do {
+ int ret = LIB_POSIX.write(fd, buf, len - total);
+ total += ret;
+ }
+ while (total < len);
+ }
+ catch (LastErrorException e) {
+ if (e.getErrorCode() == 5 || e.getErrorCode() == 9) {
+ throw new IOException(e);
+ }
+ throw e;
}
- while (total < len);
}
@Override
diff --git a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/linux/LinuxPtyChild.java b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/linux/LinuxPtyChild.java
index 164ddb7f6f..8f0089ec77 100644
--- a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/linux/LinuxPtyChild.java
+++ b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/linux/LinuxPtyChild.java
@@ -15,10 +15,8 @@
*/
package ghidra.pty.linux;
-import java.io.*;
-import java.net.URL;
-import java.net.URLDecoder;
-import java.nio.file.Paths;
+import java.io.File;
+import java.io.IOException;
import java.util.*;
import ghidra.pty.PtyChild;
@@ -85,7 +83,7 @@ public class LinuxPtyChild extends LinuxPtyEndpoint implements PtyChild {
applyMode(mode);
try {
- return new LocalProcessPtySession(builder.start());
+ return new LocalProcessPtySession(builder.start(), name);
}
catch (Exception e) {
Msg.error(this, "Could not start process with args " + Arrays.toString(args), e);
@@ -93,64 +91,6 @@ public class LinuxPtyChild extends LinuxPtyEndpoint implements PtyChild {
}
}
- protected PtySession sessionUsingPythonLeader(String[] args, Map<String, String> env)
- throws IOException {
- final List<String> argsList = new ArrayList<>();
- argsList.add("python");
- argsList.add("-m");
- argsList.add("session");
-
- argsList.add(name);
- argsList.addAll(Arrays.asList(args));
- ProcessBuilder builder = new ProcessBuilder(argsList);
- if (env != null) {
- builder.environment().putAll(env);
- }
- String sourceLoc = getSourceLocationForResource("session.py").getAbsolutePath();
- //System.err.println("PYTHONPATH=" + sourceLoc);
- builder.environment().put("PYTHONPATH", sourceLoc);
- builder.inheritIO();
-
- return new LocalProcessPtySession(builder.start());
- }
-
- public static File getSourceLocationForResource(String name) {
- // TODO: Refactor this with SystemUtilities.getSourceLocationForClass()
- URL url = LinuxPtyChild.class.getClassLoader().getResource(name);
- String urlFile = url.getFile();
- try {
- urlFile = URLDecoder.decode(urlFile, "UTF-8");
- }
- catch (UnsupportedEncodingException e) {
- // can't happen, since we know the encoding is correct
- throw new AssertionError(e);
- }
-
- if ("file".equals(url.getProtocol())) {
- int packageLevel = Paths.get(name).getNameCount();
- File file = new File(urlFile);
- for (int i = 0; i < packageLevel; i++) {
- file = file.getParentFile();
- }
- return file;
- }
-
- if ("jar".equals(url.getProtocol())) {
- // Running from Jar file
- String jarPath = urlFile;
- if (!jarPath.startsWith("file:")) {
- return null;
- }
-
- // strip off the 'file:' prefix and the jar path suffix after the
- // '!'
- jarPath = jarPath.substring(5, jarPath.indexOf('!'));
- return new File(jarPath);
- }
-
- return null;
- }
-
private void applyMode(Collection<TermMode> mode) {
if (mode.contains(Echo.OFF)) {
disableEcho();
diff --git a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/local/LocalProcessPtySession.java b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/local/LocalProcessPtySession.java
index dc7772f5e2..1ae6675088 100644
--- a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/local/LocalProcessPtySession.java
+++ b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/local/LocalProcessPtySession.java
@@ -23,9 +23,11 @@ import ghidra.util.Msg;
*/
public class LocalProcessPtySession implements PtySession {
private final Process process;
+ private final String ptyName;
- public LocalProcessPtySession(Process process) {
+ public LocalProcessPtySession(Process process, String ptyName) {
this.process = process;
+ this.ptyName = ptyName;
Msg.info(this, "local Pty session. PID = " + process.pid());
}
@@ -38,4 +40,9 @@ public class LocalProcessPtySession implements PtySession {
public void destroyForcibly() {
process.destroyForcibly();
}
+
+ @Override
+ public String description() {
+ return "process " + process.pid() + " on " + ptyName;
+ }
}
diff --git a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/local/LocalWindowsNativeProcessPtySession.java b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/local/LocalWindowsNativeProcessPtySession.java
index 2393fe1928..658b3f3923 100644
--- a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/local/LocalWindowsNativeProcessPtySession.java
+++ b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/local/LocalWindowsNativeProcessPtySession.java
@@ -25,17 +25,19 @@ import ghidra.pty.windows.Handle;
import ghidra.util.Msg;
public class LocalWindowsNativeProcessPtySession implements PtySession {
- //private final int pid;
+ private final int pid;
//private final int tid;
private final Handle processHandle;
//private final Handle threadHandle;
+ private final String ptyName;
public LocalWindowsNativeProcessPtySession(int pid, int tid, Handle processHandle,
- Handle threadHandle) {
- //this.pid = pid;
+ Handle threadHandle, String ptyName) {
+ this.pid = pid;
//this.tid = tid;
this.processHandle = processHandle;
//this.threadHandle = threadHandle;
+ this.ptyName = ptyName;
Msg.info(this, "local Windows Pty session. PID = " + pid);
}
@@ -74,4 +76,9 @@ public class LocalWindowsNativeProcessPtySession implements PtySession {
throw new LastErrorException(error);
}
}
+
+ @Override
+ public String description() {
+ return "process " + pid + " on " + ptyName;
+ }
}
diff --git a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/ssh/SshPtySession.java b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/ssh/SshPtySession.java
index 7d40087c33..35650307ef 100644
--- a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/ssh/SshPtySession.java
+++ b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/ssh/SshPtySession.java
@@ -15,7 +15,7 @@
*/
package ghidra.pty.ssh;
-import com.jcraft.jsch.Channel;
+import com.jcraft.jsch.*;
import ghidra.pty.PtySession;
@@ -41,4 +41,16 @@ public class SshPtySession implements PtySession {
public void destroyForcibly() {
channel.disconnect();
}
+
+ @Override
+ public String description() {
+ Session session;
+ try {
+ session = channel.getSession();
+ }
+ catch (JSchException e) {
+ return "ssh";
+ }
+ return "ssh " + session.getUserName() + "@" + session.getHost() + ":" + session.getPort();
+ }
}
diff --git a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/windows/ConPtyChild.java b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/windows/ConPtyChild.java
index 7a0233e822..7f84402b86 100644
--- a/Ghidra/Framework/Pty/src/main/java/ghidra/pty/windows/ConPtyChild.java
+++ b/Ghidra/Framework/Pty/src/main/java/ghidra/pty/windows/ConPtyChild.java
@@ -101,7 +101,7 @@ public class ConPtyChild extends ConPtyEndpoint implements PtyChild {
return new LocalWindowsNativeProcessPtySession(pi.dwProcessId.intValue(),
pi.dwThreadId.intValue(),
- new Handle(pi.hProcess), new Handle(pi.hThread));
+ new Handle(pi.hProcess), new Handle(pi.hThread), "ConPTY");
}
@Override
diff --git a/Ghidra/Framework/Utility/src/main/java/utility/function/ExceptionalCallback.java b/Ghidra/Framework/Utility/src/main/java/utility/function/ExceptionalCallback.java
index 91eeea1ee8..502f3f3077 100644
--- a/Ghidra/Framework/Utility/src/main/java/utility/function/ExceptionalCallback.java
+++ b/Ghidra/Framework/Utility/src/main/java/utility/function/ExceptionalCallback.java
@@ -22,7 +22,7 @@ package utility.function;
* @param <E> the exception of your choice
*/
@FunctionalInterface
-public interface ExceptionalCallback<E extends Exception> {
+public interface ExceptionalCallback<E extends Throwable> {
/**
* The method that will be called
diff --git a/Ghidra/Framework/Utility/src/main/java/utility/function/ExceptionalConsumer.java b/Ghidra/Framework/Utility/src/main/java/utility/function/ExceptionalConsumer.java
index 5c75c3a1ac..a575c6cfd3 100644
--- a/Ghidra/Framework/Utility/src/main/java/utility/function/ExceptionalConsumer.java
+++ b/Ghidra/Framework/Utility/src/main/java/utility/function/ExceptionalConsumer.java
@@ -23,7 +23,7 @@ package utility.function;
* @param <E> the exception of your choice
*/
@FunctionalInterface
-public interface ExceptionalConsumer<T, E extends Exception> {
+public interface ExceptionalConsumer<T, E extends Throwable> {
/**
* The method that will be called
diff --git a/Ghidra/Framework/Utility/src/main/java/utility/function/ExceptionalFunction.java b/Ghidra/Framework/Utility/src/main/java/utility/function/ExceptionalFunction.java
index 2c6545ce99..7ce79f1a26 100644
--- a/Ghidra/Framework/Utility/src/main/java/utility/function/ExceptionalFunction.java
+++ b/Ghidra/Framework/Utility/src/main/java/utility/function/ExceptionalFunction.java
@@ -24,7 +24,7 @@ package utility.function;
* @param <E> the exception of your choice
*/
@FunctionalInterface
-public interface ExceptionalFunction<I, R, E extends Exception> {
+public interface ExceptionalFunction<I, R, E extends Throwable> {
/**
* The method that will be called
diff --git a/Ghidra/Framework/Utility/src/main/java/utility/function/ExceptionalSupplier.java b/Ghidra/Framework/Utility/src/main/java/utility/function/ExceptionalSupplier.java
index 2225d45cda..464dc92cac 100644
--- a/Ghidra/Framework/Utility/src/main/java/utility/function/ExceptionalSupplier.java
+++ b/Ghidra/Framework/Utility/src/main/java/utility/function/ExceptionalSupplier.java
@@ -23,7 +23,7 @@ package utility.function;
* @param <E> the exception of your choice
*/
@FunctionalInterface
-public interface ExceptionalSupplier<T, E extends Exception> {
+public interface ExceptionalSupplier<T, E extends Throwable> {
/**
* The supplier method
diff --git a/Ghidra/Test/DebuggerIntegrationTest/build.gradle b/Ghidra/Test/DebuggerIntegrationTest/build.gradle
new file mode 100644
index 0000000000..4c37269109
--- /dev/null
+++ b/Ghidra/Test/DebuggerIntegrationTest/build.gradle
@@ -0,0 +1,86 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+apply from: "$rootProject.projectDir/gradle/javaProject.gradle"
+apply from: "$rootProject.projectDir/gradle/javaTestProject.gradle"
+apply plugin: 'eclipse'
+eclipse.project.name = '_Debugger Integration Test'
+
+
+/*********************************************************************************
+ * Build dependencies
+ *********************************************************************************/
+
+// There are tests in this module that require resources in Base:test. This
+// is a on-off type of situation so just add to the resources source set here.
+sourceSets {
+ integrationTest {
+ resources {
+ srcDirs += [project(':Base').sourceSets.test.resources]
+ }
+ }
+}
+
+processIntegrationTestResources {
+ duplicatesStrategy = 'exclude'
+}
+
+dependencies {
+ // integrationtest module may depend on other projects in this repo; add them
+ // here
+ def ghidraPath = projectDir.getParentFile().getParentFile().path.replace(File.separator, "/") + "/";
+
+ rootProject.subprojects { p ->
+ p.plugins.withType(JavaPlugin) {
+ def projectPath = p.projectDir.path.replace(File.separator, "/")
+ if (projectPath.startsWith(ghidraPath) && (
+ projectPath.contains("/Framework/") ||
+ projectPath.contains("/Features/") ||
+ projectPath.contains("/Debug/") ||
+ projectPath.contains("/Processors/"))) {
+
+ api p
+ }
+ }
+ }
+
+ // some tests use classes in Base, FunctionGraph and PDB
+ testImplementation project(path: ':Base', configuration: 'testArtifacts')
+ testImplementation project(path: ':Base', configuration: 'integrationTestArtifacts')
+ testImplementation project(path: ':FunctionGraph', configuration: 'testArtifacts')
+ testImplementation project(path: ':PDB', configuration: 'testArtifacts')
+ testImplementation project(path: ':GnuDemangler', configuration: 'testArtifacts')
+
+ testImplementation project(path: ':Framework-TraceModeling', configuration: 'testArtifacts')
+ testImplementation project(path: ':Framework-AsyncComm', configuration: 'testArtifacts')
+ testImplementation project(path: ':Framework-Debugging', configuration: 'testArtifacts')
+ testImplementation project(path: ':Debugger', configuration: 'testArtifacts')
+}
+
+// For Java 9, we must explicitly export references to the internal classes we are using.
+// We export them to all "unnamed" modules, which are modules that don't define themselves
+// as a new Java 9 style module. Ghidra is currently using unnamed modules everywhere.
+ext.addExports([
+ 'java.desktop/sun.awt=ALL-UNNAMED',
+ 'java.desktop/sun.swing=ALL-UNNAMED',
+ 'java.desktop/sun.java2d=ALL-UNNAMED'
+])
+
+integrationTest {
+ dependsOn { project(':Debugger-rmi-trace').assemblePyPackage }
+ dependsOn { project(':Debugger-agent-gdb').assemblePyPackage }
+ dependsOn { project(':Debugger-agent-lldb').assemblePyPackage }
+ dependsOn { project(':Debugger-agent-dbgeng').assemblePyPackage }
+}
diff --git a/Ghidra/Test/DebuggerIntegrationTest/certification.manifest b/Ghidra/Test/DebuggerIntegrationTest/certification.manifest
new file mode 100644
index 0000000000..a59e5aca65
--- /dev/null
+++ b/Ghidra/Test/DebuggerIntegrationTest/certification.manifest
@@ -0,0 +1,2 @@
+##VERSION: 2.0
+src/test.slow/resources/ghidra/pcodeCPort/slgh_compile/pcode1.xml||GHIDRA||||END|
diff --git a/Ghidra/Debug/Debugger/src/screen/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointMarkerPluginScreenShots.java b/Ghidra/Test/DebuggerIntegrationTest/src/screen/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointMarkerPluginScreenShots.java
similarity index 98%
rename from Ghidra/Debug/Debugger/src/screen/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointMarkerPluginScreenShots.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/screen/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointMarkerPluginScreenShots.java
index 776c71b8c9..f26dfd44f8 100644
--- a/Ghidra/Debug/Debugger/src/screen/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointMarkerPluginScreenShots.java
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/screen/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointMarkerPluginScreenShots.java
@@ -24,7 +24,7 @@ import org.junit.Test;
import db.Transaction;
import generic.Unique;
import ghidra.app.plugin.core.codebrowser.CodeViewerProvider;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest.TestDebuggerTargetTraceMapper;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest.TestDebuggerTargetTraceMapper;
import ghidra.app.plugin.core.debug.service.breakpoint.DebuggerLogicalBreakpointServicePlugin;
import ghidra.app.plugin.core.debug.service.model.DebuggerModelServiceProxyPlugin;
import ghidra.app.plugin.core.debug.service.modules.DebuggerStaticMappingServicePlugin;
@@ -126,7 +126,7 @@ public class DebuggerBreakpointMarkerPluginScreenShots extends GhidraScreenShotG
program.save("Placed breakpoints", TaskMonitor.DUMMY);
Msg.debug(this, "Clicking and capturing");
- DebuggerBreakpointMarkerPluginTest.clickListing(panel, addr(program, 0x00401c66),
+ AbstractDebuggerBreakpointMarkerPluginTest.clickListing(panel, addr(program, 0x00401c66),
MouseEvent.BUTTON3);
waitForSwing();
diff --git a/Ghidra/Debug/Debugger/src/screen/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsPluginScreenShots.java b/Ghidra/Test/DebuggerIntegrationTest/src/screen/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsPluginScreenShots.java
similarity index 99%
rename from Ghidra/Debug/Debugger/src/screen/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsPluginScreenShots.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/screen/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsPluginScreenShots.java
index 209ce2e260..0468022155 100644
--- a/Ghidra/Debug/Debugger/src/screen/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsPluginScreenShots.java
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/screen/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsPluginScreenShots.java
@@ -15,7 +15,7 @@
*/
package ghidra.app.plugin.core.debug.gui.breakpoint;
-import static ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest.*;
+import static ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest.*;
import static org.junit.Assert.*;
import java.util.Set;
@@ -24,7 +24,7 @@ import org.junit.*;
import db.Transaction;
import generic.Unique;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest.TestDebuggerTargetTraceMapper;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest.TestDebuggerTargetTraceMapper;
import ghidra.app.plugin.core.debug.service.breakpoint.DebuggerLogicalBreakpointServicePlugin;
import ghidra.app.plugin.core.debug.service.model.DebuggerModelServiceProxyPlugin;
import ghidra.app.plugin.core.debug.service.modules.DebuggerStaticMappingServicePlugin;
diff --git a/Ghidra/Test/IntegrationTest/src/screen/java/ghidraclass/debugger/screenshot/TutorialDebuggerMaintenance.java b/Ghidra/Test/DebuggerIntegrationTest/src/screen/java/ghidraclass/debugger/screenshot/TutorialDebuggerMaintenance.java
similarity index 100%
rename from Ghidra/Test/IntegrationTest/src/screen/java/ghidraclass/debugger/screenshot/TutorialDebuggerMaintenance.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/screen/java/ghidraclass/debugger/screenshot/TutorialDebuggerMaintenance.java
diff --git a/Ghidra/Test/IntegrationTest/src/screen/java/ghidraclass/debugger/screenshot/TutorialDebuggerScreenShots.java b/Ghidra/Test/DebuggerIntegrationTest/src/screen/java/ghidraclass/debugger/screenshot/TutorialDebuggerScreenShots.java
similarity index 97%
rename from Ghidra/Test/IntegrationTest/src/screen/java/ghidraclass/debugger/screenshot/TutorialDebuggerScreenShots.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/screen/java/ghidraclass/debugger/screenshot/TutorialDebuggerScreenShots.java
index bc70ec7bb6..b7e62a3d40 100644
--- a/Ghidra/Test/IntegrationTest/src/screen/java/ghidraclass/debugger/screenshot/TutorialDebuggerScreenShots.java
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/screen/java/ghidraclass/debugger/screenshot/TutorialDebuggerScreenShots.java
@@ -24,7 +24,6 @@ import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.util.*;
import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
import org.junit.Before;
import org.junit.Test;
@@ -67,7 +66,6 @@ import ghidra.app.plugin.core.debug.service.model.DebuggerConnectDialog;
import ghidra.app.plugin.core.debug.stack.StackUnwinderTest;
import ghidra.app.plugin.core.debug.stack.StackUnwinderTest.HoverLocation;
import ghidra.app.plugin.core.debug.stack.UnwindStackCommand;
-import ghidra.app.plugin.core.debug.workflow.*;
import ghidra.app.plugin.core.decompile.DecompilerProvider;
import ghidra.app.script.GhidraState;
import ghidra.app.services.*;
@@ -84,7 +82,6 @@ import ghidra.dbg.util.ConfigurableFactory.Property;
import ghidra.debug.api.model.DebuggerProgramLaunchOffer;
import ghidra.debug.api.model.DebuggerProgramLaunchOffer.*;
import ghidra.debug.api.watch.WatchRow;
-import ghidra.debug.api.workflow.DebuggerBot;
import ghidra.debug.flatapi.FlatDebuggerAPI;
import ghidra.framework.Application;
import ghidra.framework.TestApplicationUtils;
@@ -124,7 +121,6 @@ public class TutorialDebuggerScreenShots extends GhidraScreenShotGenerator
protected ProgramManager programManager;
protected CodeViewerService staticListingService;
- protected DebuggerWorkflowService workflowService;
protected DebuggerModelService modelService;
protected DebuggerModelFactory gdbFactory;
@@ -192,15 +188,6 @@ public class TutorialDebuggerScreenShots extends GhidraScreenShotGenerator
finished(TUTORIAL_DIR, name + ".png");
}
- protected void enableBot(Class<? extends DebuggerBot> botCls) {
- Set<DebuggerBot> bots = workflowService.getAllBots()
- .stream()
- .filter(b -> botCls.isInstance(b))
- .map(b -> botCls.cast(b))
- .collect(Collectors.toSet());
- workflowService.enableBots(bots);
- }
-
protected CodeViewerService getStaticListingService() {
for (CodeViewerService viewer : tool.getServices(CodeViewerService.class)) {
if (viewer instanceof DebuggerListingService) {
@@ -230,11 +217,6 @@ public class TutorialDebuggerScreenShots extends GhidraScreenShotGenerator
programManager = tool.getService(ProgramManager.class);
staticListingService = getStaticListingService();
- // This is a front-end plugin. We have to configure it.
- workflowService = tool.getService(DebuggerWorkflowService.class);
- enableBot(MapModulesDebuggerBot.class);
- enableBot(DisassembleAtPcDebuggerBot.class);
-
modelService = tool.getService(DebuggerModelService.class);
gdbFactory = modelService.getModelFactories()
.stream()
diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/agent/dbgeng/rmi/AbstractDbgEngTraceRmiTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/dbgeng/rmi/AbstractDbgEngTraceRmiTest.java
similarity index 99%
rename from Ghidra/Test/IntegrationTest/src/test.slow/java/agent/dbgeng/rmi/AbstractDbgEngTraceRmiTest.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/dbgeng/rmi/AbstractDbgEngTraceRmiTest.java
index 9279cace90..9a6897f483 100644
--- a/Ghidra/Test/IntegrationTest/src/test.slow/java/agent/dbgeng/rmi/AbstractDbgEngTraceRmiTest.java
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/dbgeng/rmi/AbstractDbgEngTraceRmiTest.java
@@ -28,7 +28,7 @@ import java.util.function.Function;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.junit.Before;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.service.rmi.trace.TraceRmiPlugin;
import ghidra.app.plugin.core.debug.utils.ManagedDomainObject;
import ghidra.app.services.TraceRmiService;
@@ -50,7 +50,7 @@ import ghidra.trace.model.target.TraceObjectValue;
import ghidra.util.Msg;
import ghidra.util.NumericUtilities;
-public abstract class AbstractDbgEngTraceRmiTest extends AbstractGhidraHeadedDebuggerGUITest {
+public abstract class AbstractDbgEngTraceRmiTest extends AbstractGhidraHeadedDebuggerTest {
/**
* Some features have to be disabled to avoid permissions issues in the test container. Namely,
* don't try to disable ASLR.
diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/agent/dbgeng/rmi/DbgEngCommandsTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/dbgeng/rmi/DbgEngCommandsTest.java
similarity index 100%
rename from Ghidra/Test/IntegrationTest/src/test.slow/java/agent/dbgeng/rmi/DbgEngCommandsTest.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/dbgeng/rmi/DbgEngCommandsTest.java
diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/agent/dbgeng/rmi/DbgEngHooksTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/dbgeng/rmi/DbgEngHooksTest.java
similarity index 100%
rename from Ghidra/Test/IntegrationTest/src/test.slow/java/agent/dbgeng/rmi/DbgEngHooksTest.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/dbgeng/rmi/DbgEngHooksTest.java
diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/agent/dbgeng/rmi/DbgEngMethodsTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/dbgeng/rmi/DbgEngMethodsTest.java
similarity index 100%
rename from Ghidra/Test/IntegrationTest/src/test.slow/java/agent/dbgeng/rmi/DbgEngMethodsTest.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/dbgeng/rmi/DbgEngMethodsTest.java
diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/agent/gdb/rmi/AbstractGdbTraceRmiTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/gdb/rmi/AbstractGdbTraceRmiTest.java
similarity index 99%
rename from Ghidra/Test/IntegrationTest/src/test.slow/java/agent/gdb/rmi/AbstractGdbTraceRmiTest.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/gdb/rmi/AbstractGdbTraceRmiTest.java
index fb8654b3c7..5645238e66 100644
--- a/Ghidra/Test/IntegrationTest/src/test.slow/java/agent/gdb/rmi/AbstractGdbTraceRmiTest.java
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/gdb/rmi/AbstractGdbTraceRmiTest.java
@@ -32,7 +32,7 @@ import java.util.stream.Collectors;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.junit.Before;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.service.rmi.trace.TraceRmiPlugin;
import ghidra.app.plugin.core.debug.utils.ManagedDomainObject;
import ghidra.app.services.TraceRmiService;
@@ -53,7 +53,7 @@ import ghidra.trace.model.target.*;
import ghidra.util.Msg;
import ghidra.util.NumericUtilities;
-public abstract class AbstractGdbTraceRmiTest extends AbstractGhidraHeadedDebuggerGUITest {
+public abstract class AbstractGdbTraceRmiTest extends AbstractGhidraHeadedDebuggerTest {
/**
* The tests are touchy about anything being printed on stderr, because that's usually where
* Python stack traces go that otherwise are ignored. Unfortunately, GDB also emits some
@@ -367,13 +367,6 @@ public abstract class AbstractGdbTraceRmiTest extends AbstractGhidraHeadedDebugg
return new MemDump(address, buf.toByteArray());
}
- record RegDump() {
- }
-
- protected RegDump parseRegDump(String dump) {
- return new RegDump();
- }
-
protected ManagedDomainObject openDomainObject(String path) throws Exception {
DomainFile df = env.getProject().getProjectData().getFile(path);
assertNotNull(df);
diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/agent/gdb/rmi/GdbCommandsTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/gdb/rmi/GdbCommandsTest.java
similarity index 100%
rename from Ghidra/Test/IntegrationTest/src/test.slow/java/agent/gdb/rmi/GdbCommandsTest.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/gdb/rmi/GdbCommandsTest.java
diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/agent/gdb/rmi/GdbHooksTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/gdb/rmi/GdbHooksTest.java
similarity index 100%
rename from Ghidra/Test/IntegrationTest/src/test.slow/java/agent/gdb/rmi/GdbHooksTest.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/gdb/rmi/GdbHooksTest.java
diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/agent/gdb/rmi/GdbMethodsTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/gdb/rmi/GdbMethodsTest.java
similarity index 93%
rename from Ghidra/Test/IntegrationTest/src/test.slow/java/agent/gdb/rmi/GdbMethodsTest.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/gdb/rmi/GdbMethodsTest.java
index 19183218db..7081dc2714 100644
--- a/Ghidra/Test/IntegrationTest/src/test.slow/java/agent/gdb/rmi/GdbMethodsTest.java
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/gdb/rmi/GdbMethodsTest.java
@@ -18,6 +18,7 @@ package agent.gdb.rmi;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
+import java.nio.ByteBuffer;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@@ -33,6 +34,7 @@ import ghidra.dbg.testutil.DummyProc;
import ghidra.dbg.util.PathPattern;
import ghidra.dbg.util.PathPredicates;
import ghidra.debug.api.tracermi.RemoteMethod;
+import ghidra.pcode.utils.Utils;
import ghidra.program.model.address.*;
import ghidra.program.model.data.Float10DataType;
import ghidra.program.model.lang.Register;
@@ -357,6 +359,8 @@ public class GdbMethodsTest extends AbstractGdbTraceRmiTest {
}
}
+ // TODO: Test writeReg
+
@Test
public void testRefreshMappings() throws Exception {
try (GdbAndConnection conn = startAndConnectGdb()) {
@@ -1252,4 +1256,96 @@ public class GdbMethodsTest extends AbstractGdbTraceRmiTest {
}
}
}
+
+ @Test
+ public void testReadMem() throws Exception {
+ try (GdbAndConnection conn = startAndConnectGdb()) {
+ conn.execute("""
+ file bash
+ ghidra trace start
+ %s
+ break main
+ run"""
+ .formatted(INSTRUMENT_STOPPED));
+ RemoteMethod readMem = conn.getMethod("read_mem");
+ try (ManagedDomainObject mdo = openDomainObject("/New Traces/gdb/bash")) {
+ tb = new ToyDBTraceBuilder((Trace) mdo.get());
+ waitStopped();
+ long snap = 0;
+ long pcOff =
+ Integer.decode(conn.executeCapture("print/x $pc").split("=")[1].strip());
+ TraceObject inf1 = Objects.requireNonNull(tb.obj("Inferiors[1]"));
+
+ readMem.invoke(Map.ofEntries(
+ Map.entry("inferior", inf1),
+ Map.entry("range", tb.range(pcOff, pcOff + 10))));
+
+ MemDump dump = parseHexDump(conn.executeCapture("x/10bx $pc"));
+ assertEquals(pcOff, dump.address());
+ assertEquals(10, dump.data().length);
+ ByteBuffer buf = ByteBuffer.allocate(dump.data().length);
+ tb.trace.getMemoryManager().getBytes(snap, tb.addr(dump.address()), buf);
+ assertArrayEquals(dump.data(), buf.array());
+ }
+ }
+ }
+
+ @Test
+ public void testWriteMem() throws Exception {
+ try (GdbAndConnection conn = startAndConnectGdb()) {
+ conn.execute("""
+ file bash
+ ghidra trace start
+ %s
+ break main
+ run"""
+ .formatted(INSTRUMENT_STOPPED));
+ RemoteMethod writeMem = conn.getMethod("write_mem");
+ try (ManagedDomainObject mdo = openDomainObject("/New Traces/gdb/bash")) {
+ tb = new ToyDBTraceBuilder((Trace) mdo.get());
+ waitStopped();
+ long pcOff =
+ Integer.decode(conn.executeCapture("print/x $pc").split("=")[1].strip());
+ TraceObject inf1 = Objects.requireNonNull(tb.obj("Inferiors[1]"));
+
+ writeMem.invoke(Map.ofEntries(
+ Map.entry("inferior", inf1),
+ Map.entry("address", tb.addr(pcOff)),
+ Map.entry("data", new byte[] { 1, 2, 3, 4 })));
+
+ MemDump dump = parseHexDump(conn.executeCapture("x/4bx $pc"));
+ assertEquals(pcOff, dump.address());
+ assertArrayEquals(new byte[] { 1, 2, 3, 4 }, dump.data());
+ }
+ }
+ }
+
+ @Test
+ public void testWriteReg() throws Exception {
+ try (GdbAndConnection conn = startAndConnectGdb()) {
+ conn.execute("""
+ file bash
+ ghidra trace start
+ %s
+ break main
+ run"""
+ .formatted(INSTRUMENT_STOPPED));
+ RemoteMethod writeReg = conn.getMethod("write_reg");
+ try (ManagedDomainObject mdo = openDomainObject("/New Traces/gdb/bash")) {
+ tb = new ToyDBTraceBuilder((Trace) mdo.get());
+ waitStopped();
+ conn.execute("ghidra trace tx-open Init 'ghidra trace putreg'");
+ TraceObject frame =
+ Objects.requireNonNull(tb.obj("Inferiors[1].Threads[1].Stack[0]"));
+
+ writeReg.invoke(Map.ofEntries(
+ Map.entry("frame", frame),
+ Map.entry("name", "RCX"),
+ Map.entry("value", Utils.longToBytes(0xdeadbeefL, 8, true))));
+
+ String out = conn.executeCapture("print/x $rcx");
+ assertEquals("$1 = 0xdeadbeef", out.strip());
+ }
+ }
+ }
}
diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/agent/lldb/rmi/AbstractLldbTraceRmiTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/lldb/rmi/AbstractLldbTraceRmiTest.java
similarity index 99%
rename from Ghidra/Test/IntegrationTest/src/test.slow/java/agent/lldb/rmi/AbstractLldbTraceRmiTest.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/lldb/rmi/AbstractLldbTraceRmiTest.java
index b723f1dea0..62e63eba09 100644
--- a/Ghidra/Test/IntegrationTest/src/test.slow/java/agent/lldb/rmi/AbstractLldbTraceRmiTest.java
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/lldb/rmi/AbstractLldbTraceRmiTest.java
@@ -31,7 +31,7 @@ import java.util.stream.Collectors;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.junit.Before;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.service.rmi.trace.TraceRmiPlugin;
import ghidra.app.plugin.core.debug.utils.ManagedDomainObject;
import ghidra.app.services.TraceRmiService;
@@ -53,7 +53,7 @@ import ghidra.trace.model.target.TraceObjectValue;
import ghidra.util.Msg;
import ghidra.util.NumericUtilities;
-public abstract class AbstractLldbTraceRmiTest extends AbstractGhidraHeadedDebuggerGUITest {
+public abstract class AbstractLldbTraceRmiTest extends AbstractGhidraHeadedDebuggerTest {
/**
* Some features have to be disabled to avoid permissions issues in the test container. Namely,
* don't try to disable ASLR.
diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/agent/lldb/rmi/LldbCommandsTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/lldb/rmi/LldbCommandsTest.java
similarity index 100%
rename from Ghidra/Test/IntegrationTest/src/test.slow/java/agent/lldb/rmi/LldbCommandsTest.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/lldb/rmi/LldbCommandsTest.java
diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/agent/lldb/rmi/LldbHooksTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/lldb/rmi/LldbHooksTest.java
similarity index 100%
rename from Ghidra/Test/IntegrationTest/src/test.slow/java/agent/lldb/rmi/LldbHooksTest.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/lldb/rmi/LldbHooksTest.java
diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/agent/lldb/rmi/LldbMethodsTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/lldb/rmi/LldbMethodsTest.java
similarity index 100%
rename from Ghidra/Test/IntegrationTest/src/test.slow/java/agent/lldb/rmi/LldbMethodsTest.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/lldb/rmi/LldbMethodsTest.java
diff --git a/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/AbstractGhidraHeadedDebuggerIntegrationTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/AbstractGhidraHeadedDebuggerIntegrationTest.java
new file mode 100644
index 0000000000..aebd8507b6
--- /dev/null
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/AbstractGhidraHeadedDebuggerIntegrationTest.java
@@ -0,0 +1,314 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui;
+
+import java.util.Set;
+
+import db.Transaction;
+import ghidra.app.plugin.core.debug.service.rmi.trace.TestTraceRmiConnection;
+import ghidra.app.plugin.core.debug.service.rmi.trace.TestTraceRmiConnection.*;
+import ghidra.dbg.target.schema.*;
+import ghidra.dbg.target.schema.TargetObjectSchema.SchemaName;
+import ghidra.debug.api.target.ActionName;
+import ghidra.program.model.address.AddressRange;
+import ghidra.trace.model.Lifespan;
+import ghidra.trace.model.breakpoint.TraceBreakpointKind;
+import ghidra.trace.model.breakpoint.TraceBreakpointKind.TraceBreakpointKindSet;
+import ghidra.trace.model.target.*;
+import ghidra.trace.model.target.TraceObject.ConflictResolution;
+
+public class AbstractGhidraHeadedDebuggerIntegrationTest
+ extends AbstractGhidraHeadedDebuggerTest {
+
+ public static final SchemaContext SCHEMA_CTX = xmlSchema("""
+ <context>
+ <schema name='Session' elementResync='NEVER' attributeResync='ONCE'>
+ <attribute name='Processes' schema='ProcessContainer' />
+ </schema>
+ <schema name='ProcessContainer' canonical='yes' elementResync='NEVER'
+ attributeResync='ONCE'>
+ <element schema='Process' />
+ </schema>
+ <schema name='Process' elementResync='NEVER' attributeResync='ONCE'>
+ <interface name='Aggregate' />
+ <interface name='Process' />
+ <interface name='ExecutionStateful' />
+ <attribute name='Threads' schema='ThreadContainer' />
+ <attribute name='Memory' schema='Memory' />
+ <attribute name='Breakpoints' schema='BreakpointContainer' />
+ <attribute name='_state' schema='EXECUTION_STATE' hidden='yes' />
+ </schema>
+ <schema name='ThreadContainer' canonical='yes' elementResync='NEVER'
+ attributeResync='ONCE'>
+ <element schema='Thread' />
+ </schema>
+ <schema name='Thread' elementResync='NEVER' attributeResync='ONCE'>
+ <interface name='Aggregate' />
+ <interface name='Thread' />
+ <attribute name='Stack' schema='Stack' />
+ </schema>
+ <schema name='Stack' canonical='yes' elementResync='NEVER'
+ attributeResync='ONCE'>
+ <interface name='Stack' />
+ <element schema='Frame' />
+ </schema>
+ <schema name='Frame' elementResync='NEVER' attributeResync='ONCE'>
+ <interface name='Aggregate' />
+ <interface name='StackFrame' />
+ <attribute name='Registers' schema='RegisterContainer' />
+ </schema>
+ <schema name='RegisterContainer' canonical='yes' elementResync='NEVER'
+ attributeResync='ONCE'>
+ <interface name='RegisterBank' />
+ <interface name='RegisterContainer' />
+ <element schema='Register' />
+ </schema>
+ <schema name='Register' elementResync='NEVER' attributeResync='ONCE'>
+ <interface name='Register' />
+ </schema>
+ <schema name='Memory' canonical='yes' elementResync='NEVER'
+ attributeResync='ONCE'>
+ <interface name='Memory' />
+ <element schema='MemoryRegion' />
+ </schema>
+ <schema name='MemoryRegion' elementResync='NEVER' attributeResync='ONCE'>
+ <interface name='MemoryRegion' />
+ <attribute name='_range' schema='RANGE' hidden='yes' />
+ <attribute name='_readable' schema='BOOL' hidden='yes' />
+ <attribute name='_writable' schema='BOOL' hidden='yes' />
+ <attribute name='_executable' schema='BOOL' hidden='yes' />
+ </schema>
+ <schema name='BreakpointContainer' canonical='yes' elementResync='NEVER'
+ attributeResync='ONCE'>
+ <interface name='BreakpointSpecContainer' />
+ <element schema='BreakpointSpec' />
+ </schema>
+ <schema name='BreakpointSpec' canonical='yes' elementResync='NEVER'
+ attributeResync='ONCE'>
+ <interface name='BreakpointSpec' />
+ <interface name='BreakpointLocationContainer' />
+ <interface name='Togglable' />
+ <element schema='BreakpointLoc' />
+ <attribute name='_kinds' schema='SET_BREAKPOINT_KIND' hidden='yes' />
+ <attribute name='_expr' schema='STRING' hidden='yes' />
+ <attribute name='_enabled' schema='BOOL' hidden='yes' />
+ </schema>
+ <schema name='BreakpointLoc' canonical='yes' elementResync='NEVER'
+ attributeResync='ONCE'>
+ <interface name='BreakpointLocation' />
+ <attribute name='_range' schema='RANGE' hidden='yes' />
+ </schema>
+ </context>
+ """);
+ public static final TargetObjectSchema SCHEMA_SESSION =
+ SCHEMA_CTX.getSchema(new SchemaName("Session"));
+
+ protected TestTraceRmiConnection rmiCx;
+
+ protected TestRemoteMethod rmiMethodResume;
+ protected TestRemoteMethod rmiMethodInterrupt;
+ protected TestRemoteMethod rmiMethodKill;
+ protected TestRemoteMethod rmiMethodStepInto;
+ protected TestRemoteMethod rmiMethodStepOver;
+ protected TestRemoteMethod rmiMethodStepOut;
+
+ protected TestRemoteMethod rmiMethodSetHwBreak;
+ protected TestRemoteMethod rmiMethodSetSwBreak;
+ protected TestRemoteMethod rmiMethodSetReadBreak;
+ protected TestRemoteMethod rmiMethodSetWriteBreak;
+ protected TestRemoteMethod rmiMethodSetAccessBreak;
+ protected TestRemoteMethod rmiMethodToggleBreak;
+ protected TestRemoteMethod rmiMethodDeleteBreak;
+
+ protected TestRemoteMethod rmiMethodReadRegs;
+ protected TestRemoteMethod rmiMethodWriteReg;
+
+ protected void createRmiConnection() {
+ rmiCx = new TestTraceRmiConnection();
+ }
+
+ protected void addControlMethods() {
+ rmiMethodResume = new TestRemoteMethod("resume", ActionName.RESUME,
+ "Resume the target", EnumerableTargetObjectSchema.VOID.getName(),
+ new TestRemoteParameter("process", new SchemaName("Process"), true, null, "Process",
+ "The process to resume"));
+
+ rmiMethodInterrupt = new TestRemoteMethod("interrupt", ActionName.INTERRUPT,
+ "Interrupt the target", EnumerableTargetObjectSchema.VOID.getName(),
+ new TestRemoteParameter("process", new SchemaName("Process"), true, null, "Process",
+ "The process to interrupt"));
+
+ rmiMethodKill = new TestRemoteMethod("kill", ActionName.KILL,
+ "Kill the target", EnumerableTargetObjectSchema.VOID.getName(),
+ new TestRemoteParameter("process", new SchemaName("Process"), true, null, "Process",
+ "The process to kill"));
+
+ rmiMethodStepInto = new TestRemoteMethod("step_into", ActionName.STEP_INTO,
+ "Step the thread, descending into subroutines",
+ EnumerableTargetObjectSchema.VOID.getName(),
+ new TestRemoteParameter("thread", new SchemaName("Thread"), true, null, "Thread",
+ "The thread to step"));
+
+ rmiMethodStepOver = new TestRemoteMethod("step_over", ActionName.STEP_OVER,
+ "Step the thread, without descending into subroutines",
+ EnumerableTargetObjectSchema.VOID.getName(),
+ new TestRemoteParameter("thread", new SchemaName("Thread"), true, null, "Thread",
+ "The thread to step"));
+
+ rmiMethodStepOut = new TestRemoteMethod("step_out", ActionName.STEP_OUT,
+ "Allow the thread to finish the current subroutine",
+ EnumerableTargetObjectSchema.VOID.getName(),
+ new TestRemoteParameter("thread", new SchemaName("Thread"), true, null, "Thread",
+ "The thread to step"));
+
+ TestRemoteMethodRegistry reg = rmiCx.getMethods();
+ reg.add(rmiMethodResume);
+ reg.add(rmiMethodInterrupt);
+ reg.add(rmiMethodKill);
+ reg.add(rmiMethodStepInto);
+ reg.add(rmiMethodStepOver);
+ reg.add(rmiMethodStepOut);
+ }
+
+ protected void addBreakpointMethods() {
+ rmiMethodSetHwBreak = new TestRemoteMethod("set_hw_break", ActionName.BREAK_HW_EXECUTE,
+ "Place a hardware execution breakpoint", EnumerableTargetObjectSchema.VOID.getName(),
+ new TestRemoteParameter("process", new SchemaName("Process"), true, null, "Process",
+ "The process in which to place the breakpoint"),
+ new TestRemoteParameter("address", EnumerableTargetObjectSchema.ADDRESS.getName(), true,
+ null, "Address", "The desired address"));
+
+ rmiMethodSetSwBreak = new TestRemoteMethod("set_sw_break", ActionName.BREAK_SW_EXECUTE,
+ "Place a software execution breakpoint", EnumerableTargetObjectSchema.VOID.getName(),
+ new TestRemoteParameter("process", new SchemaName("Process"), true, null, "Process",
+ "The process in which to place the breakpoint"),
+ new TestRemoteParameter("address", EnumerableTargetObjectSchema.ADDRESS.getName(), true,
+ null, "Address", "The desired address"));
+
+ rmiMethodSetReadBreak = new TestRemoteMethod("set_read_break", ActionName.BREAK_READ,
+ "Place a read breakpoint", EnumerableTargetObjectSchema.VOID.getName(),
+ new TestRemoteParameter("process", new SchemaName("Process"), true, null, "Process",
+ "The process in which to place the breakpoint"),
+ new TestRemoteParameter("range", EnumerableTargetObjectSchema.RANGE.getName(), true,
+ null, "Range", "The desired address range"));
+
+ rmiMethodSetWriteBreak = new TestRemoteMethod("set_write_break", ActionName.BREAK_WRITE,
+ "Place a write breakpoint", EnumerableTargetObjectSchema.VOID.getName(),
+ new TestRemoteParameter("process", new SchemaName("Process"), true, null, "Process",
+ "The process in which to place the breakpoint"),
+ new TestRemoteParameter("range", EnumerableTargetObjectSchema.RANGE.getName(), true,
+ null, "Range", "The desired address range"));
+
+ rmiMethodSetAccessBreak = new TestRemoteMethod("set_acc_break", ActionName.BREAK_ACCESS,
+ "Place an access breakpoint", EnumerableTargetObjectSchema.VOID.getName(),
+ new TestRemoteParameter("process", new SchemaName("Process"), true, null, "Process",
+ "The process in which to place the breakpoint"),
+ new TestRemoteParameter("range", EnumerableTargetObjectSchema.RANGE.getName(), true,
+ null, "Range", "The desired address range"));
+
+ rmiMethodToggleBreak = new TestRemoteMethod("toggle_break", ActionName.TOGGLE,
+ "Toggle a breakpoint", EnumerableTargetObjectSchema.VOID.getName(),
+ new TestRemoteParameter("breakpoint", new SchemaName("BreakpointSpec"), true, null,
+ "Breakpoint", "The breakpoint to toggle"),
+ new TestRemoteParameter("enabled", EnumerableTargetObjectSchema.BOOL.getName(), true,
+ null, "Enable", "True to enable. False to disable"));
+
+ rmiMethodDeleteBreak = new TestRemoteMethod("delete_break", ActionName.DELETE,
+ "Delete a breakpoint", EnumerableTargetObjectSchema.VOID.getName(),
+ new TestRemoteParameter("breakpoint", new SchemaName("BreakpointSpec"), true, null,
+ "Breakpoint", "The breakpoint to delete"));
+
+ TestRemoteMethodRegistry reg = rmiCx.getMethods();
+ reg.add(rmiMethodSetHwBreak);
+ reg.add(rmiMethodSetSwBreak);
+ reg.add(rmiMethodSetReadBreak);
+ reg.add(rmiMethodSetWriteBreak);
+ reg.add(rmiMethodSetAccessBreak);
+ reg.add(rmiMethodToggleBreak);
+ reg.add(rmiMethodDeleteBreak);
+ }
+
+ protected void addRegisterMethods() {
+ rmiMethodReadRegs = new TestRemoteMethod("read_regs", ActionName.REFRESH,
+ "Read registers", EnumerableTargetObjectSchema.VOID.getName(),
+ new TestRemoteParameter("container", new SchemaName("RegisterContainer"), true, null,
+ "Registers", "The registers node to read"));
+
+ rmiMethodWriteReg = new TestRemoteMethod("write_reg", ActionName.WRITE_REG,
+ "Write a register", EnumerableTargetObjectSchema.VOID.getName(),
+ new TestRemoteParameter("frame", new SchemaName("Frame"), false, 0, "Frame",
+ "The frame to write to"),
+ new TestRemoteParameter("name", EnumerableTargetObjectSchema.STRING.getName(), true,
+ null, "Register", "The name of the register to write"),
+ new TestRemoteParameter("value", EnumerableTargetObjectSchema.BYTE_ARR.getName(), true,
+ null, "Value", "The desired value"));
+
+ TestRemoteMethodRegistry reg = rmiCx.getMethods();
+ reg.add(rmiMethodReadRegs);
+ reg.add(rmiMethodWriteReg);
+ }
+
+ protected TraceObject addMemoryRegion(TraceObjectManager objs, Lifespan lifespan,
+ AddressRange range, String name, String flags) {
+ String pathStr =
+ "Processes[1].Memory[0x%08x:%s]".formatted(range.getMinAddress().getOffset(), name);
+ TraceObject regionText = objs.createObject(TraceObjectKeyPath.parse(pathStr));
+ regionText.setAttribute(lifespan, "_range", range);
+ regionText.setAttribute(lifespan, "_readable", flags.contains("r"));
+ regionText.setAttribute(lifespan, "_writable", flags.contains("w"));
+ regionText.setAttribute(lifespan, "_executable", flags.contains("x"));
+ regionText.insert(lifespan, ConflictResolution.DENY);
+
+ return regionText;
+ }
+
+ protected TraceObject ensureBreakpointContainer(TraceObjectManager objs) {
+ try (Transaction tx = tb.startTransaction()) {
+ return objs.createObject(TraceObjectKeyPath.parse("Processes[1].Breakpoints"));
+ }
+ }
+
+ protected TraceObject findAndCreateFreeBreakpointSpec(TraceObjectManager objs) {
+ TraceObjectKeyPath brkConPath = TraceObjectKeyPath.parse("Processes[1].Breakpoints");
+ for (int i = 1; i < 10; i++) {
+ TraceObjectKeyPath path = brkConPath.index(i);
+ TraceObject exists = objs.getObjectByCanonicalPath(path);
+ if (exists == null) {
+ return objs.createObject(path);
+ }
+ }
+ throw new AssertionError("More than 10 breakpoints for a test?");
+ }
+
+ protected TraceObject addBreakpointAndLoc(TraceObjectManager objs, Lifespan lifespan,
+ AddressRange range, Set<TraceBreakpointKind> kinds) {
+ try (Transaction tx = objs.getTrace().openTransaction("Add breakpoint")) {
+ TraceObject spec = findAndCreateFreeBreakpointSpec(objs);
+
+ spec.setAttribute(lifespan, "_kinds", TraceBreakpointKindSet.encode(kinds));
+ spec.setAttribute(lifespan, "_expr", "*0x" + range.getMinAddress());
+ spec.setAttribute(lifespan, "_enabled", true);
+ spec.insert(lifespan, ConflictResolution.DENY);
+
+ TraceObjectKeyPath specPath = spec.getCanonicalPath();
+ TraceObject loc = objs.createObject(specPath.index(0));
+ loc.setAttribute(lifespan, "_display", specPath.index());
+ loc.setAttribute(lifespan, "_range", range);
+ loc.insert(lifespan, ConflictResolution.DENY);
+ return spec;
+ }
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointMarkerPluginTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/AbstractDebuggerBreakpointMarkerPluginTest.java
similarity index 86%
rename from Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointMarkerPluginTest.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/AbstractDebuggerBreakpointMarkerPluginTest.java
index 6103287e85..f52ba692c8 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointMarkerPluginTest.java
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/AbstractDebuggerBreakpointMarkerPluginTest.java
@@ -22,7 +22,7 @@ import java.awt.event.MouseEvent;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.*;
+import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -31,18 +31,16 @@ import javax.swing.SwingUtilities;
import org.junit.Before;
import org.junit.Test;
-import org.junit.experimental.categories.Category;
import db.Transaction;
import docking.action.DockingAction;
import docking.widgets.fieldpanel.FieldPanel;
import generic.Unique;
-import generic.test.category.NightlyCategory;
import ghidra.app.context.ProgramLocationActionContext;
import ghidra.app.decompiler.DecompileResults;
import ghidra.app.decompiler.component.DecompileData;
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerIntegrationTest;
import ghidra.app.plugin.core.debug.gui.DebuggerResources.*;
import ghidra.app.plugin.core.debug.gui.breakpoint.DebuggerBreakpointMarkerPlugin.AbstractToggleBreakpointAction;
import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingPlugin;
@@ -51,12 +49,8 @@ import ghidra.app.plugin.core.decompile.DecompilePlugin;
import ghidra.app.plugin.core.decompile.DecompilerProvider;
import ghidra.app.services.*;
import ghidra.app.util.viewer.listingpanel.ListingPanel;
-import ghidra.dbg.target.TargetBreakpointSpec.TargetBreakpointKind;
-import ghidra.debug.api.action.ActionSource;
import ghidra.debug.api.breakpoint.LogicalBreakpoint;
import ghidra.debug.api.breakpoint.LogicalBreakpoint.State;
-import ghidra.debug.api.model.TraceRecorder;
-import ghidra.dbg.target.TargetBreakpointSpecContainer;
import ghidra.framework.store.LockException;
import ghidra.program.disassemble.Disassembler;
import ghidra.program.model.address.*;
@@ -67,21 +61,30 @@ import ghidra.program.model.mem.MemoryConflictException;
import ghidra.program.model.symbol.SourceType;
import ghidra.program.util.ProgramLocation;
import ghidra.trace.model.*;
+import ghidra.trace.model.breakpoint.TraceBreakpoint;
import ghidra.trace.model.breakpoint.TraceBreakpointKind;
+import ghidra.trace.model.breakpoint.TraceBreakpointKind.TraceBreakpointKindSet;
import ghidra.trace.model.program.TraceProgramView;
import ghidra.util.SystemUtilities;
import ghidra.util.exception.CancelledException;
import ghidra.util.exception.DuplicateNameException;
import ghidra.util.task.TaskMonitor;
-@Category(NightlyCategory.class) // this may actually be an @PortSensitive test
-public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebuggerGUITest {
+public abstract class AbstractDebuggerBreakpointMarkerPluginTest<T>
+ extends AbstractGhidraHeadedDebuggerIntegrationTest {
protected static final long TIMEOUT_MILLIS =
SystemUtilities.isInTestingBatchMode() ? 5000 : Long.MAX_VALUE;
protected static final Map<State, Color> COLOR_FOR_STATE =
Stream.of(State.values()).collect(Collectors.toMap(s -> s, s -> new Color(s.ordinal())));
+ protected static final Set<String> POPUP_ACTIONS = Set.of(AbstractSetBreakpointAction.NAME,
+ AbstractToggleBreakpointAction.NAME, AbstractEnableBreakpointAction.NAME,
+ AbstractDisableBreakpointAction.NAME, AbstractClearBreakpointAction.NAME);
+
+ protected static final Set<String> SET_ACTIONS =
+ Set.of("SW_EXECUTE", "HW_EXECUTE", "READ,WRITE", "READ", "WRITE");
+
protected DebuggerBreakpointMarkerPlugin breakpointMarkerPlugin;
protected DebuggerListingPlugin listingPlugin;
protected CodeBrowserPlugin codeBrowserPlugin;
@@ -94,6 +97,66 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
protected Address entry;
protected DecompilerProvider decompilerProvider;
+ protected Color getBackgroundColor(Program p, Address address) {
+ return runSwing(() -> markerService.getBackgroundColor(p, address));
+ }
+
+ /**
+ * HACK: since service doesn't let me get markers for an address, change each that I care about
+ * to have a distinct background color
+ */
+ protected void hackMarkerBackgroundColors(Program p) throws Exception {
+ SwingUtilities.invokeAndWait(() -> {
+ for (State state : State.values()) {
+ if (state == State.NONE) {
+ continue;
+ }
+ MarkerSet ms = markerService.getMarkerSet(state.display, p);
+ ms.setMarkerColor(COLOR_FOR_STATE.get(state));
+ ms.setColoringBackground(true);
+ }
+ });
+ }
+
+ protected static void clickListing(ListingPanel panel, Address address, int button)
+ throws Exception {
+ runSwing(() -> panel.goTo(address));
+ waitForCondition(() -> {
+ Rectangle cursor = panel.getCursorBounds();
+ if (cursor == null) {
+ return false;
+ }
+ Rectangle visible = panel.getVisibleRect();
+ return visible.contains(cursor);
+ });
+ clickListing(panel.getFieldPanel(), button);
+ }
+
+ protected static void clickListing(FieldPanel fp, int button) throws Exception {
+ clickListing(fp, fp.getCursorPoint(), button);
+ }
+
+ protected static void clickListing(FieldPanel fp, Point p, int button) throws Exception {
+ Point fpsl = fp.getLocationOnScreen();
+ Point s = new Point(fpsl.x + p.x, fpsl.y + p.y);
+ clickMouse(button, s);
+ }
+
+ protected abstract T createLive() throws Throwable;
+
+ protected abstract void waitT(T t) throws Throwable;
+
+ protected abstract Trace getTrace(T t);
+
+ protected abstract void handleSetBreakpointInvocation(Set<TraceBreakpointKind> expectedKinds,
+ long dynOffset) throws Throwable;
+
+ protected abstract void handleToggleBreakpointInvocation(TraceBreakpoint expectedBreakpoint,
+ boolean expectedEn) throws Throwable;
+
+ protected abstract void handleDeleteBreakpointInvocation(TraceBreakpoint expectedBreakpoint)
+ throws Throwable;
+
@Before
public void setUpBreakpointMarkerPluginTest() throws Exception {
breakpointMarkerPlugin = addPlugin(tool, DebuggerBreakpointMarkerPlugin.class);
@@ -127,13 +190,7 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
}
}
- protected void addLiveMemoryAndBreakpoint(TraceRecorder recorder)
- throws InterruptedException, ExecutionException, TimeoutException {
- mb.testProcess1.addRegion("bin:.text", mb.rng(0x55550000, 0x55550fff), "rx");
- TargetBreakpointSpecContainer cont = getBreakpointContainer(recorder);
- cont.placeBreakpoint(mb.addr(0x55550123), Set.of(TargetBreakpointKind.SW_EXECUTE))
- .get(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
- }
+ protected abstract void addLiveMemoryAndBreakpoint(T t) throws Throwable;
protected void addStaticMemoryAndBreakpoint() throws LockException, DuplicateNameException,
MemoryConflictException, AddressOverflowException, CancelledException {
@@ -147,7 +204,7 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
}
}
- protected void addMapping(Trace trace) throws Exception {
+ protected void addMapping(Trace trace) throws Throwable {
try (Transaction tx = trace.openTransaction("Add mapping")) {
DebuggerStaticMappingUtils.addMapping(
new DefaultTraceLocation(trace, null, Lifespan.nowOn(0), addr(trace, 0x55550123)),
@@ -155,7 +212,7 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
}
}
- protected void waitForMappedEnabledBreakpoint(Trace trace) throws Exception {
+ protected void waitForMappedEnabledBreakpoint(Trace trace) throws Throwable {
waitForPass(() -> {
LogicalBreakpoint lb = Unique.assertOne(breakpointService.getAllBreakpoints());
assertEquals(program, lb.getProgram());
@@ -164,76 +221,39 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
});
}
- protected TraceRecorder addMappedBreakpointOpenAndWait() throws Throwable {
- createTestModel();
- mb.createTestProcessesAndThreads();
- TraceRecorder recorder = modelService.recordTarget(mb.testProcess1,
- createTargetTraceMapper(mb.testProcess1), ActionSource.AUTOMATIC);
- waitRecorder(recorder);
- Trace trace = recorder.getTrace();
+ protected T addMappedBreakpointOpenAndWait() throws Throwable {
+ T t = createLive();
+ Trace trace = getTrace(t);
createProgramFromTrace(trace);
intoProject(trace);
intoProject(program);
addMapping(trace);
addStaticMemoryAndBreakpoint();
- addLiveMemoryAndBreakpoint(recorder);
+ addLiveMemoryAndBreakpoint(t);
programManager.openProgram(program);
traceManager.openTrace(trace);
+ traceManager.activateTrace(trace);
waitForMappedEnabledBreakpoint(trace);
- return recorder;
- }
-
- protected Color getBackgroundColor(Program p, Address address) {
- return runSwing(() -> markerService.getBackgroundColor(p, address));
- }
-
- /**
- * HACK: since service doesn't let me get markers for an address, change each that I can about
- * to have a distinct background color
- */
- protected void hackMarkerBackgroundColors(Program p) throws Exception {
- SwingUtilities.invokeAndWait(() -> {
- for (State state : State.values()) {
- if (state == State.NONE) {
- continue;
- }
- MarkerSet ms = markerService.getMarkerSet(state.display, p);
- ms.setMarkerColor(COLOR_FOR_STATE.get(state));
- ms.setColoringBackground(true);
- }
- });
- }
-
- protected static void clickListing(ListingPanel panel, Address address, int button)
- throws Exception {
- runSwing(() -> panel.goTo(address));
- waitForCondition(() -> {
- Rectangle cursor = panel.getCursorBounds();
- if (cursor == null) {
- return false;
- }
- Rectangle visible = panel.getVisibleRect();
- return visible.contains(cursor);
- });
- clickListing(panel.getFieldPanel(), button);
+ return t;
}
- protected static void clickListing(FieldPanel fp, int button) throws Exception {
- clickListing(fp, fp.getCursorPoint(), button);
+ protected ProgramLocationActionContext staticCtx(Address address) {
+ return new ProgramLocationActionContext(codeBrowserPlugin.getProvider(), program,
+ new ProgramLocation(program, address), null, null);
}
- protected static void clickListing(FieldPanel fp, Point p, int button) throws Exception {
- Point fpsl = fp.getLocationOnScreen();
- Point s = new Point(fpsl.x + p.x, fpsl.y + p.y);
- clickMouse(button, s);
+ protected ProgramLocationActionContext dynamicCtx(Trace trace, Address address) {
+ TraceProgramView view = trace.getProgramView();
+ return new ProgramLocationActionContext(listingPlugin.getProvider(), view,
+ new ProgramLocation(view, address), null, null);
}
@Test
public void testBreakpointMarked() throws Throwable {
- TraceRecorder recorder = addMappedBreakpointOpenAndWait();
- Trace trace = recorder.getTrace();
+ T t = addMappedBreakpointOpenAndWait();
+ Trace trace = getTrace(t);
traceManager.activateTrace(trace);
LogicalBreakpoint lb = Unique.assertOne(breakpointService.getAllBreakpoints());
Address dAddr = addr(trace, 0x55550123);
@@ -260,8 +280,10 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
waitForPass(() -> assertEquals(COLOR_FOR_STATE.get(State.INCONSISTENT_DISABLED),
getBackgroundColor(program, sAddr)));
- waitOn(lb.disableForTrace(trace));
- waitRecorder(recorder);
+ CompletableFuture<Void> dis = lb.disableForTrace(trace);
+ handleToggleBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(trace)), false);
+ waitOn(dis);
+ waitT(t);
waitForPass(() -> assertEquals(State.DISABLED, lb.computeStateForTrace(trace)));
waitForPass(() -> assertEquals(COLOR_FOR_STATE.get(State.DISABLED),
@@ -283,13 +305,6 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
getBackgroundColor(program, sAddr)));
}
- protected static final Set<String> POPUP_ACTIONS = Set.of(AbstractSetBreakpointAction.NAME,
- AbstractToggleBreakpointAction.NAME, AbstractEnableBreakpointAction.NAME,
- AbstractDisableBreakpointAction.NAME, AbstractClearBreakpointAction.NAME);
-
- protected static final Set<String> SET_ACTIONS =
- Set.of("SW_EXECUTE", "HW_EXECUTE", "READ,WRITE", "READ", "WRITE");
-
@Test
public void testProgramNoBreakPopupMenus() throws Throwable {
// NOTE: Need a target to have any breakpoint actions, even on programs
@@ -308,8 +323,8 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
@Test
public void testTraceNoBreakPopupMenus() throws Throwable {
- TraceRecorder recorder = addMappedBreakpointOpenAndWait();
- Trace trace = recorder.getTrace();
+ T t = addMappedBreakpointOpenAndWait();
+ Trace trace = getTrace(t);
traceManager.activateTrace(trace);
waitForSwing();
@@ -320,13 +335,13 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
MenuElement elem = getSubMenuElementByText(AbstractSetBreakpointAction.NAME);
assertSubMenu(elem, SET_ACTIONS, SET_ACTIONS); // All of them
- // TODO: Margin, too? (Is there one?)
+ // TODO: Margin, too?
}
@Test
public void testProgramBreakpointPopupMenus() throws Throwable {
- TraceRecorder recorder = addMappedBreakpointOpenAndWait();
- Trace trace = recorder.getTrace();
+ T t = addMappedBreakpointOpenAndWait();
+ Trace trace = getTrace(t);
LogicalBreakpoint lb = Unique.assertOne(breakpointService.getAllBreakpoints());
waitForPass(
() -> assertEquals(State.ENABLED, lb.computeStateForProgram(program)));
@@ -351,8 +366,10 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
AbstractClearBreakpointAction.NAME));
pressEscape();
- waitOn(lb.disableForTrace(trace));
- waitRecorder(recorder);
+ CompletableFuture<Void> dis = lb.disableForTrace(trace);
+ handleToggleBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(trace)), false);
+ waitOn(dis);
+ waitT(t);
waitForPass(
() -> assertEquals(State.DISABLED, lb.computeStateForProgram(program)));
@@ -380,8 +397,8 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
@Test
public void testTraceBreakpointPopupMenus() throws Throwable {
- TraceRecorder recorder = addMappedBreakpointOpenAndWait();
- Trace trace = recorder.getTrace();
+ T t = addMappedBreakpointOpenAndWait();
+ Trace trace = getTrace(t);
LogicalBreakpoint lb = Unique.assertOne(breakpointService.getAllBreakpoints());
traceManager.activateTrace(trace);
waitForSwing();
@@ -406,8 +423,10 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
AbstractClearBreakpointAction.NAME));
pressEscape();
- waitOn(lb.disableForTrace(trace));
- waitRecorder(recorder);
+ CompletableFuture<Void> dis = lb.disableForTrace(trace);
+ handleToggleBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(trace)), false);
+ waitOn(dis);
+ waitT(t);
waitForPass(
() -> assertEquals(State.DISABLED, lb.computeStateForTrace(trace)));
@@ -432,23 +451,14 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
// TODO: Margin, too?
}
- protected ProgramLocationActionContext staticCtx(Address address) {
- return new ProgramLocationActionContext(codeBrowserPlugin.getProvider(), program,
- new ProgramLocation(program, address), null, null);
- }
-
- protected ProgramLocationActionContext dynamicCtx(Trace trace, Address address) {
- TraceProgramView view = trace.getProgramView();
- return new ProgramLocationActionContext(listingPlugin.getProvider(), view,
- new ProgramLocation(view, address), null, null);
- }
-
@Test
public void testActionToggleBreakpointProgramWithNoCurrentBreakpointOnInstruction()
throws Throwable {
addMappedBreakpointOpenAndWait(); // wasteful, but whatever
for (LogicalBreakpoint lb : List.copyOf(breakpointService.getAllBreakpoints())) {
+ TraceBreakpoint brk = Unique.assertOne(lb.getTraceBreakpoints(tb.trace));
lb.delete();
+ handleDeleteBreakpointInvocation(brk);
}
waitForPass(() -> assertEquals(0, breakpointService.getAllBreakpoints().size()));
@@ -464,6 +474,7 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
DebuggerPlaceBreakpointDialog dialog =
waitForDialogComponent(DebuggerPlaceBreakpointDialog.class);
runSwing(() -> dialog.okCallback());
+ handleSetBreakpointInvocation(TraceBreakpointKindSet.SW_EXECUTE, 0x55550123);
waitForPass(() -> {
LogicalBreakpoint lb = Unique.assertOne(breakpointService.getAllBreakpoints());
@@ -477,7 +488,9 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
public void testActionToggleBreakpointProgramWithNoCurrentBreakpointOnData() throws Throwable {
addMappedBreakpointOpenAndWait(); // wasteful, but whatever
for (LogicalBreakpoint lb : List.copyOf(breakpointService.getAllBreakpoints())) {
+ TraceBreakpoint brk = Unique.assertOne(lb.getTraceBreakpoints(tb.trace));
lb.delete();
+ handleDeleteBreakpointInvocation(brk);
}
waitForPass(() -> assertEquals(0, breakpointService.getAllBreakpoints().size()));
@@ -492,13 +505,13 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
DebuggerPlaceBreakpointDialog dialog =
waitForDialogComponent(DebuggerPlaceBreakpointDialog.class);
runSwing(() -> dialog.okCallback());
+ handleSetBreakpointInvocation(TraceBreakpointKindSet.ACCESS, 0x55550123);
waitForPass(() -> {
LogicalBreakpoint lb = Unique.assertOne(breakpointService.getAllBreakpoints());
assertEquals(State.ENABLED, lb.computeState());
// TODO: Different cases for different expected default kinds?
- assertEquals(Set.of(TraceBreakpointKind.READ, TraceBreakpointKind.WRITE),
- lb.getKinds());
+ assertEquals(TraceBreakpointKindSet.ACCESS, lb.getKinds());
});
}
@@ -510,19 +523,21 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
ProgramLocationActionContext ctx = staticCtx(addr(program, 0x00400123));
assertTrue(breakpointMarkerPlugin.actionToggleBreakpoint.isAddToPopup(ctx));
performAction(breakpointMarkerPlugin.actionToggleBreakpoint, ctx, false);
+ handleToggleBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(tb.trace)), false);
waitForPass(() -> assertEquals(State.DISABLED, lb.computeState()));
assertTrue(breakpointMarkerPlugin.actionToggleBreakpoint.isAddToPopup(ctx));
performAction(breakpointMarkerPlugin.actionToggleBreakpoint, ctx, false);
+ handleToggleBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(tb.trace)), true);
waitForPass(() -> assertEquals(State.ENABLED, lb.computeState()));
}
@Test
public void testActionToggleBreakpointTrace() throws Throwable {
- TraceRecorder recorder = addMappedBreakpointOpenAndWait();
- Trace trace = recorder.getTrace();
+ T t = addMappedBreakpointOpenAndWait();
+ Trace trace = getTrace(t);
LogicalBreakpoint lb = Unique.assertOne(breakpointService.getAllBreakpoints());
// NB. addMappedBreakpointOpenAndWait already makes this assertion. Just a reminder:
@@ -531,11 +546,13 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
ProgramLocationActionContext ctx = dynamicCtx(trace, addr(trace, 0x55550123));
assertTrue(breakpointMarkerPlugin.actionToggleBreakpoint.isAddToPopup(ctx));
performAction(breakpointMarkerPlugin.actionToggleBreakpoint, ctx, true);
+ handleToggleBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(trace)), false);
waitForPass(() -> assertEquals(State.DISABLED, lb.computeStateForTrace(trace)));
assertTrue(breakpointMarkerPlugin.actionToggleBreakpoint.isAddToPopup(ctx));
performAction(breakpointMarkerPlugin.actionToggleBreakpoint, ctx, true);
+ handleToggleBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(trace)), true);
waitForPass(() -> assertEquals(State.ENABLED, lb.computeStateForTrace(trace)));
@@ -547,8 +564,9 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
assertTrue(breakpointMarkerPlugin.actionToggleBreakpoint.isAddToPopup(ctx));
performAction(breakpointMarkerPlugin.actionToggleBreakpoint, ctx, true);
-
// NB. toggling from dynamic view, this toggles trace bpt, not logical/program bpt
+ handleToggleBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(trace)), false);
+
waitForPass(() -> assertEquals(State.DISABLED, lb.computeStateForTrace(trace)));
lb.enableForProgram();
@@ -557,6 +575,7 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
assertTrue(breakpointMarkerPlugin.actionToggleBreakpoint.isAddToPopup(ctx));
performAction(breakpointMarkerPlugin.actionToggleBreakpoint, ctx, true);
+ handleToggleBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(trace)), true);
waitForPass(() -> assertEquals(State.ENABLED, lb.computeStateForTrace(trace)));
}
@@ -575,6 +594,8 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
dialog.okCallback();
});
+ handleSetBreakpointInvocation(expectedKinds, 0x55550321);
+
waitForPass(() -> {
LogicalBreakpoint lb = Unique.assertOne(
breakpointService.getBreakpointsAt(program, addr(program, 0x00400321)));
@@ -586,8 +607,8 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
protected void testActionSetBreakpointTrace(DockingAction action,
Set<TraceBreakpointKind> expectedKinds) throws Throwable {
- TraceRecorder recorder = addMappedBreakpointOpenAndWait(); // Adds an unneeded breakpoint. Aw well.
- Trace trace = recorder.getTrace();
+ T t = addMappedBreakpointOpenAndWait(); // Adds an unneeded breakpoint. Aw well.
+ Trace trace = getTrace(t);
ProgramLocationActionContext ctx = dynamicCtx(trace, addr(trace, 0x55550321));
assertTrue(action.isAddToPopup(ctx));
@@ -595,6 +616,7 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
DebuggerPlaceBreakpointDialog dialog =
waitForDialogComponent(DebuggerPlaceBreakpointDialog.class);
runSwing(() -> dialog.okCallback());
+ handleSetBreakpointInvocation(expectedKinds, 0x55550321);
waitForPass(() -> {
LogicalBreakpoint lb = Unique
@@ -670,29 +692,36 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
@Test
public void testActionEnableBreakpointProgram() throws Throwable {
- addMappedBreakpointOpenAndWait();
+ T t = addMappedBreakpointOpenAndWait();
+ Trace trace = getTrace(t);
LogicalBreakpoint lb = Unique.assertOne(breakpointService.getAllBreakpoints());
+
lb.disable();
+ handleToggleBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(trace)), false);
waitForPass(() -> assertEquals(State.DISABLED, lb.computeState()));
ProgramLocationActionContext ctx = staticCtx(addr(program, 0x00400123));
assertTrue(breakpointMarkerPlugin.actionEnableBreakpoint.isAddToPopup(ctx));
performAction(breakpointMarkerPlugin.actionEnableBreakpoint, ctx, true);
+ handleToggleBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(trace)), true);
waitForPass(() -> assertEquals(State.ENABLED, lb.computeState()));
}
@Test
public void testActionEnableBreakpointTrace() throws Throwable {
- TraceRecorder recorder = addMappedBreakpointOpenAndWait();
- Trace trace = recorder.getTrace();
+ T t = addMappedBreakpointOpenAndWait();
+ Trace trace = getTrace(t);
LogicalBreakpoint lb = Unique.assertOne(breakpointService.getAllBreakpoints());
+
lb.disable();
+ handleToggleBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(trace)), false);
waitForPass(() -> assertEquals(State.DISABLED, lb.computeState()));
ProgramLocationActionContext ctx = dynamicCtx(trace, addr(trace, 0x55550123));
assertTrue(breakpointMarkerPlugin.actionEnableBreakpoint.isAddToPopup(ctx));
performAction(breakpointMarkerPlugin.actionEnableBreakpoint, ctx, true);
+ handleToggleBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(trace)), true);
waitForPass(() -> assertEquals(State.ENABLED, lb.computeStateForTrace(trace)));
// TODO: Same test but with multiple traces
@@ -700,25 +729,28 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
@Test
public void testActionDisableBreakpointProgram() throws Throwable {
- addMappedBreakpointOpenAndWait();
+ T t = addMappedBreakpointOpenAndWait();
+ Trace trace = getTrace(t);
LogicalBreakpoint lb = Unique.assertOne(breakpointService.getAllBreakpoints());
ProgramLocationActionContext ctx = staticCtx(addr(program, 0x00400123));
assertTrue(breakpointMarkerPlugin.actionDisableBreakpoint.isAddToPopup(ctx));
performAction(breakpointMarkerPlugin.actionDisableBreakpoint, ctx, true);
+ handleToggleBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(trace)), false);
waitForPass(() -> assertEquals(State.DISABLED, lb.computeState()));
}
@Test
public void testActionDisableBreakpointTrace() throws Throwable {
- TraceRecorder recorder = addMappedBreakpointOpenAndWait();
- Trace trace = recorder.getTrace();
+ T t = addMappedBreakpointOpenAndWait();
+ Trace trace = getTrace(t);
LogicalBreakpoint lb = Unique.assertOne(breakpointService.getAllBreakpoints());
ProgramLocationActionContext ctx = dynamicCtx(trace, addr(trace, 0x55550123));
assertTrue(breakpointMarkerPlugin.actionDisableBreakpoint.isAddToPopup(ctx));
performAction(breakpointMarkerPlugin.actionDisableBreakpoint, ctx, true);
+ handleToggleBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(trace)), false);
waitForPass(() -> assertEquals(State.DISABLED, lb.computeStateForTrace(trace)));
// TODO: Same test but with multiple traces
@@ -726,24 +758,30 @@ public class DebuggerBreakpointMarkerPluginTest extends AbstractGhidraHeadedDebu
@Test
public void testActionClearBreakpointProgram() throws Throwable {
- addMappedBreakpointOpenAndWait();
+ T t = addMappedBreakpointOpenAndWait();
+ Trace trace = getTrace(t);
+ LogicalBreakpoint lb = Unique.assertOne(breakpointService.getAllBreakpoints());
ProgramLocationActionContext ctx = staticCtx(addr(program, 0x00400123));
assertTrue(breakpointMarkerPlugin.actionClearBreakpoint.isAddToPopup(ctx));
+ TraceBreakpoint brk = Unique.assertOne(lb.getTraceBreakpoints(trace));
performAction(breakpointMarkerPlugin.actionClearBreakpoint, ctx, true);
+ handleDeleteBreakpointInvocation(brk);
waitForPass(() -> assertTrue(breakpointService.getAllBreakpoints().isEmpty()));
}
@Test
public void testActionClearBreakpointTrace() throws Throwable {
- TraceRecorder recorder = addMappedBreakpointOpenAndWait();
- Trace trace = recorder.getTrace();
+ T t = addMappedBreakpointOpenAndWait();
+ Trace trace = getTrace(t);
LogicalBreakpoint lb = Unique.assertOne(breakpointService.getAllBreakpoints());
ProgramLocationActionContext ctx = dynamicCtx(trace, addr(trace, 0x55550123));
assertTrue(breakpointMarkerPlugin.actionClearBreakpoint.isAddToPopup(ctx));
+ TraceBreakpoint brk = Unique.assertOne(lb.getTraceBreakpoints(trace));
performAction(breakpointMarkerPlugin.actionClearBreakpoint, ctx, true);
+ handleDeleteBreakpointInvocation(brk);
waitForPass(() -> assertEquals(State.NONE, lb.computeStateForTrace(trace)));
// TODO: Same test but with multiple traces
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsProviderTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/AbstractDebuggerBreakpointsProviderTest.java
similarity index 87%
rename from Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsProviderTest.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/AbstractDebuggerBreakpointsProviderTest.java
index 89508ef53f..8db783b869 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsProviderTest.java
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/AbstractDebuggerBreakpointsProviderTest.java
@@ -31,7 +31,7 @@ import db.Transaction;
import docking.widgets.table.RowWrappedEnumeratedColumnTableModel;
import generic.Unique;
import generic.test.category.NightlyCategory;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerIntegrationTest;
import ghidra.app.plugin.core.debug.gui.DebuggerResources.*;
import ghidra.app.plugin.core.debug.gui.breakpoint.DebuggerBreakpointsProvider.LogicalBreakpointTableModel;
import ghidra.app.plugin.core.debug.gui.console.DebuggerConsolePlugin;
@@ -39,14 +39,9 @@ import ghidra.app.plugin.core.debug.service.control.DebuggerControlServicePlugin
import ghidra.app.plugin.core.debug.service.emulation.ProgramEmulationUtils;
import ghidra.app.plugin.core.debug.service.modules.DebuggerStaticMappingUtils;
import ghidra.app.services.*;
-import ghidra.dbg.model.TestTargetProcess;
-import ghidra.dbg.target.TargetBreakpointSpec.TargetBreakpointKind;
-import ghidra.debug.api.action.ActionSource;
import ghidra.debug.api.breakpoint.LogicalBreakpoint;
import ghidra.debug.api.breakpoint.LogicalBreakpoint.State;
import ghidra.debug.api.control.ControlMode;
-import ghidra.debug.api.model.TraceRecorder;
-import ghidra.dbg.target.TargetBreakpointSpecContainer;
import ghidra.framework.store.LockException;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressOverflowException;
@@ -55,6 +50,8 @@ import ghidra.program.model.mem.MemoryConflictException;
import ghidra.program.util.ProgramLocation;
import ghidra.trace.model.*;
import ghidra.trace.model.breakpoint.TraceBreakpoint;
+import ghidra.trace.model.breakpoint.TraceBreakpointKind;
+import ghidra.trace.model.breakpoint.TraceBreakpointKind.TraceBreakpointKindSet;
import ghidra.trace.model.time.TraceSnapshot;
import ghidra.util.SystemUtilities;
import ghidra.util.exception.CancelledException;
@@ -62,7 +59,8 @@ import ghidra.util.exception.DuplicateNameException;
import ghidra.util.task.TaskMonitor;
@Category(NightlyCategory.class) // this may actually be an @PortSensitive test
-public class DebuggerBreakpointsProviderTest extends AbstractGhidraHeadedDebuggerGUITest {
+public abstract class AbstractDebuggerBreakpointsProviderTest<T, P>
+ extends AbstractGhidraHeadedDebuggerIntegrationTest {
protected static final long TIMEOUT_MILLIS =
SystemUtilities.isInTestingBatchMode() ? 5000 : Long.MAX_VALUE;
@@ -71,34 +69,36 @@ public class DebuggerBreakpointsProviderTest extends AbstractGhidraHeadedDebugge
protected DebuggerStaticMappingService mappingService;
protected DebuggerLogicalBreakpointService breakpointService;
- @Before
- public void setUpBreakpointsProviderTest() throws Exception {
- breakpointsPlugin = addPlugin(tool, DebuggerBreakpointsPlugin.class);
- breakpointsProvider = waitForComponentProvider(DebuggerBreakpointsProvider.class);
- mappingService = tool.getService(DebuggerStaticMappingService.class);
- breakpointService = tool.getService(DebuggerLogicalBreakpointService.class);
- }
+ protected abstract T createTarget1() throws Throwable;
- protected void addMapping(Trace trace, Program prog) throws Exception {
- try (Transaction tx = trace.openTransaction("Add mapping")) {
- DebuggerStaticMappingUtils.addMapping(
- new DefaultTraceLocation(trace, null, Lifespan.nowOn(0), addr(trace, 0x55550000)),
- new ProgramLocation(prog, addr(prog, 0x00400000)), 0x1000, false);
- }
- }
+ protected abstract T createTarget3() throws Throwable;
- protected void addLiveMemoryAndBreakpoint(TestTargetProcess process, TraceRecorder recorder)
- throws Exception {
- process.addRegion("bin:.text", mb.rng(0x55550000, 0x55550fff), "rx");
- addLiveBreakpoint(recorder, 0x55550123);
- }
+ protected abstract P getProcess1();
+
+ protected abstract P getProcess3();
+
+ protected abstract Trace getTrace(T t);
+
+ protected abstract void waitTarget(T t) throws Throwable;
+
+ protected abstract void addLiveMemory(P process) throws Throwable;
+
+ protected abstract void addLiveBreakpoint(T target, long offset) throws Throwable;
- protected void addLiveBreakpoint(TraceRecorder recorder, long offset) throws Exception {
- TargetBreakpointSpecContainer cont = getBreakpointContainer(recorder);
- cont.placeBreakpoint(mb.addr(offset), Set.of(TargetBreakpointKind.SW_EXECUTE))
- .get(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
+ protected abstract void assertNotLiveBreakpoint(T target, TraceBreakpoint breakpoint)
+ throws Throwable;
+
+ protected void addLiveMemoryAndBreakpoint(P process, T target) throws Throwable {
+ addLiveMemory(process);
+ addLiveBreakpoint(target, 0x55550123);
}
+ protected abstract void handleSetBreakpointInvocation(Set<TraceBreakpointKind> expectedKinds,
+ long dynOffset) throws Throwable;
+
+ protected abstract void handleToggleBreakpointInvocation(TraceBreakpoint expectedBreakpoint,
+ boolean expectedEnabled) throws Throwable;
+
protected void addStaticMemoryAndBreakpoint() throws LockException, DuplicateNameException,
MemoryConflictException, AddressOverflowException, CancelledException {
try (Transaction tx = program.openTransaction("Add bookmark break")) {
@@ -111,10 +111,26 @@ public class DebuggerBreakpointsProviderTest extends AbstractGhidraHeadedDebugge
}
}
+ protected void addMapping(Trace trace, Program prog) throws Exception {
+ try (Transaction tx = trace.openTransaction("Add mapping")) {
+ DebuggerStaticMappingUtils.addMapping(
+ new DefaultTraceLocation(trace, null, Lifespan.nowOn(0), addr(trace, 0x55550000)),
+ new ProgramLocation(prog, addr(prog, 0x00400000)), 0x1000, false);
+ }
+ }
+
protected void assertProviderEmpty() {
assertTrue(breakpointsProvider.breakpointTableModel.getModelData().isEmpty());
}
+ @Before
+ public void setUpBreakpointsProviderTest() throws Exception {
+ breakpointsPlugin = addPlugin(tool, DebuggerBreakpointsPlugin.class);
+ breakpointsProvider = waitForComponentProvider(DebuggerBreakpointsProvider.class);
+ mappingService = tool.getService(DebuggerStaticMappingService.class);
+ breakpointService = tool.getService(DebuggerLogicalBreakpointService.class);
+ }
+
@Test
public void testEmpty() throws Exception {
waitForSwing();
@@ -123,14 +139,11 @@ public class DebuggerBreakpointsProviderTest extends AbstractGhidraHeadedDebugge
@Test
public void testAddLiveOpenTracePopulatesProvider() throws Throwable {
- createTestModel();
- mb.createTestProcessesAndThreads();
- TraceRecorder recorder = modelService.recordTarget(mb.testProcess1,
- createTargetTraceMapper(mb.testProcess1), ActionSource.AUTOMATIC);
- Trace trace = recorder.getTrace();
+ T target = createTarget1();
+ Trace trace = getTrace(target);
- addLiveMemoryAndBreakpoint(mb.testProcess1, recorder);
- waitRecorder(recorder);
+ addLiveMemoryAndBreakpoint(getProcess1(), target);
+ waitTarget(target);
// NB, optionally open trace. Mapping only works if open...
traceManager.openTrace(trace);
@@ -145,15 +158,12 @@ public class DebuggerBreakpointsProviderTest extends AbstractGhidraHeadedDebugge
}
@Test
- public void testToggleLiveViaTable() throws Exception {
- createTestModel();
- mb.createTestProcessesAndThreads();
- TraceRecorder recorder = modelService.recordTarget(mb.testProcess1,
- createTargetTraceMapper(mb.testProcess1), ActionSource.AUTOMATIC);
- Trace trace = recorder.getTrace();
+ public void testToggleLiveViaTable() throws Throwable {
+ T target = createTarget1();
+ Trace trace = getTrace(target);
- addLiveMemoryAndBreakpoint(mb.testProcess1, recorder);
- waitForDomainObject(trace);
+ addLiveMemoryAndBreakpoint(getProcess1(), target);
+ waitTarget(target);
traceManager.openTrace(trace);
waitForSwing();
@@ -164,10 +174,14 @@ public class DebuggerBreakpointsProviderTest extends AbstractGhidraHeadedDebugge
// NB, the row does not take the value immediately, but via async callbacks
row.setEnabled(false);
+ handleToggleBreakpointInvocation(
+ Unique.assertOne(row.getLogicalBreakpoint().getTraceBreakpoints(trace)), false);
waitForPass(() -> assertEquals(State.INCONSISTENT_DISABLED, row.getState()));
row.setEnabled(true);
+ handleToggleBreakpointInvocation(
+ Unique.assertOne(row.getLogicalBreakpoint().getTraceBreakpoints(trace)), true);
waitForPass(() -> assertEquals(State.INCONSISTENT_ENABLED, row.getState()));
}
@@ -211,17 +225,14 @@ public class DebuggerBreakpointsProviderTest extends AbstractGhidraHeadedDebugge
@Test
public void testEnablementColumnMapped() throws Throwable {
- createTestModel();
- mb.createTestProcessesAndThreads();
- TraceRecorder recorder = modelService.recordTarget(mb.testProcess1,
- createTargetTraceMapper(mb.testProcess1), ActionSource.AUTOMATIC);
- Trace trace = recorder.getTrace();
+ T target = createTarget1();
+ Trace trace = getTrace(target);
createProgramFromTrace(trace);
intoProject(trace);
intoProject(program);
addMapping(trace, program);
- addLiveMemoryAndBreakpoint(mb.testProcess1, recorder);
+ addLiveMemoryAndBreakpoint(getProcess1(), target);
addStaticMemoryAndBreakpoint();
programManager.openProgram(program);
traceManager.openTrace(trace);
@@ -245,8 +256,10 @@ public class DebuggerBreakpointsProviderTest extends AbstractGhidraHeadedDebugge
waitForPass(() -> assertEquals(State.INCONSISTENT_DISABLED, row.getState()));
// NOTE: This acts on the corresponding target, not directly on trace
- waitOn(lb.disableForTrace(trace));
- waitRecorder(recorder);
+ CompletableFuture<Void> disable = lb.disableForTrace(trace);
+ handleToggleBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(trace)), false);
+ waitOn(disable);
+ waitTarget(target);
waitForPass(() -> assertEquals(State.DISABLED, row.getState()));
@@ -256,8 +269,10 @@ public class DebuggerBreakpointsProviderTest extends AbstractGhidraHeadedDebugge
waitForPass(() -> assertEquals(State.INCONSISTENT_ENABLED, row.getState()));
// This duplicates the initial case, but without it, I just feel incomplete
- waitOn(lb.enableForTrace(trace));
- waitRecorder(recorder);
+ CompletableFuture<Void> enable = lb.enableForTrace(trace);
+ handleToggleBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(trace)), true);
+ waitOn(enable);
+ waitTarget(target);
waitForPass(() -> assertEquals(State.ENABLED, row.getState()));
}
@@ -494,14 +509,11 @@ public class DebuggerBreakpointsProviderTest extends AbstractGhidraHeadedDebugge
}
@Test
- public void testActionMakeBreakpointsEffective() throws Exception {
+ public void testActionMakeBreakpointsEffective() throws Throwable {
DebuggerConsolePlugin consolePlugin = addPlugin(tool, DebuggerConsolePlugin.class);
- createTestModel();
- mb.createTestProcessesAndThreads();
- TraceRecorder recorder = modelService.recordTarget(mb.testProcess1,
- createTargetTraceMapper(mb.testProcess1), ActionSource.AUTOMATIC);
- Trace trace = recorder.getTrace();
+ T target = createTarget1();
+ Trace trace = getTrace(target);
createProgramFromTrace(trace);
intoProject(trace);
intoProject(program);
@@ -522,6 +534,7 @@ public class DebuggerBreakpointsProviderTest extends AbstractGhidraHeadedDebugge
});
performAction(breakpointsProvider.actionMakeBreakpointsEffective);
+ handleSetBreakpointInvocation(TraceBreakpointKindSet.SW_EXECUTE, 0x55550123);
waitForPass(() -> {
assertFalse(breakpointsProvider.actionMakeBreakpointsEffective.isEnabled());
@@ -539,16 +552,11 @@ public class DebuggerBreakpointsProviderTest extends AbstractGhidraHeadedDebugge
@Test
public void testActionFilters() throws Throwable {
- createTestModel();
- mb.createTestProcessesAndThreads();
-
- TraceRecorder recorder1 = modelService.recordTarget(mb.testProcess1,
- createTargetTraceMapper(mb.testProcess1), ActionSource.AUTOMATIC);
- Trace trace1 = recorder1.getTrace();
+ T target1 = createTarget1();
+ Trace trace1 = getTrace(target1);
- TraceRecorder recorder3 = modelService.recordTarget(mb.testProcess3,
- createTargetTraceMapper(mb.testProcess3), ActionSource.AUTOMATIC);
- Trace trace3 = recorder3.getTrace();
+ T target3 = createTarget3();
+ Trace trace3 = getTrace(target3);
createProgramFromTrace(trace1);
intoProject(trace1);
@@ -557,12 +565,12 @@ public class DebuggerBreakpointsProviderTest extends AbstractGhidraHeadedDebugge
addMapping(trace1, program);
addMapping(trace3, program);
- addLiveMemoryAndBreakpoint(mb.testProcess1, recorder1);
- addLiveBreakpoint(recorder1, 0x55550321);
- addLiveMemoryAndBreakpoint(mb.testProcess3, recorder3);
- addLiveBreakpoint(recorder3, 0x55550321);
- waitRecorder(recorder1);
- waitRecorder(recorder3);
+ addLiveMemoryAndBreakpoint(getProcess1(), target1);
+ addLiveBreakpoint(target1, 0x55550321);
+ addLiveMemoryAndBreakpoint(getProcess3(), target3);
+ addLiveBreakpoint(target3, 0x55550321);
+ waitTarget(target1);
+ waitTarget(target3);
addStaticMemoryAndBreakpoint();
// Note, no program breakpoint for 0321...
@@ -728,21 +736,18 @@ public class DebuggerBreakpointsProviderTest extends AbstractGhidraHeadedDebugge
}
@Test
- public void testTablesAndStatesWhenhModeChanges() throws Throwable {
+ public void testTablesAndStatesWhenModeChanges() throws Throwable {
DebuggerControlService controlService =
addPlugin(tool, DebuggerControlServicePlugin.class);
- createTestModel();
- mb.createTestProcessesAndThreads();
- TraceRecorder recorder = modelService.recordTarget(mb.testProcess1,
- createTargetTraceMapper(mb.testProcess1), ActionSource.AUTOMATIC);
- Trace trace = recorder.getTrace();
+ T target = createTarget1();
+ Trace trace = getTrace(target);
createProgramFromTrace(trace);
intoProject(trace);
intoProject(program);
- mb.testProcess1.addRegion("bin:.text", mb.rng(0x55550000, 0x55550fff), "rx");
- waitRecorder(recorder);
+ addLiveMemory(getProcess1());
+ waitTarget(target);
addMapping(trace, program);
addStaticMemoryAndBreakpoint();
programManager.openProgram(program);
@@ -764,7 +769,7 @@ public class DebuggerBreakpointsProviderTest extends AbstractGhidraHeadedDebugge
lbRow1.setEnabled(true);
TraceBreakpoint emuBpt = waitForValue(
() -> Unique.assertAtMostOne(trace.getBreakpointManager().getAllBreakpoints()));
- assertNull(recorder.getTargetBreakpoint(emuBpt));
+ assertNotLiveBreakpoint(target, emuBpt);
LogicalBreakpointRow lbRow2 =
Unique.assertOne(breakpointsProvider.breakpointTableModel.getModelData());
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsProviderObjectTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerObjectRecorderBreakpointsProviderTest.java
similarity index 97%
rename from Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsProviderObjectTest.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerObjectRecorderBreakpointsProviderTest.java
index a1b4dfa813..24afab15a7 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerBreakpointsProviderObjectTest.java
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerObjectRecorderBreakpointsProviderTest.java
@@ -28,7 +28,8 @@ import ghidra.trace.model.Trace;
import ghidra.trace.model.target.TraceObjectKeyPath;
@Category(NightlyCategory.class)
-public class DebuggerBreakpointsProviderObjectTest extends DebuggerBreakpointsProviderTest {
+public class DebuggerObjectRecorderBreakpointsProviderTest
+ extends DebuggerRecorderBreakpointsProviderTest {
protected SchemaContext ctx;
diff --git a/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerRecorderBreakpointMarkerPluginTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerRecorderBreakpointMarkerPluginTest.java
new file mode 100644
index 0000000000..5f9a40e524
--- /dev/null
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerRecorderBreakpointMarkerPluginTest.java
@@ -0,0 +1,82 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.breakpoint;
+
+import java.util.Set;
+import java.util.concurrent.*;
+
+import org.junit.experimental.categories.Category;
+
+import generic.test.category.NightlyCategory;
+import ghidra.dbg.target.TargetBreakpointSpec.TargetBreakpointKind;
+import ghidra.dbg.target.TargetBreakpointSpecContainer;
+import ghidra.debug.api.action.ActionSource;
+import ghidra.debug.api.model.TraceRecorder;
+import ghidra.trace.model.Trace;
+import ghidra.trace.model.breakpoint.TraceBreakpoint;
+import ghidra.trace.model.breakpoint.TraceBreakpointKind;
+
+@Category(NightlyCategory.class) // this may actually be an @PortSensitive test
+public class DebuggerRecorderBreakpointMarkerPluginTest
+ extends AbstractDebuggerBreakpointMarkerPluginTest<TraceRecorder> {
+
+ @Override
+ protected TraceRecorder createLive() throws Throwable {
+ createTestModel();
+ mb.createTestProcessesAndThreads();
+ TraceRecorder recorder = modelService.recordTarget(mb.testProcess1,
+ createTargetTraceMapper(mb.testProcess1), ActionSource.AUTOMATIC);
+ waitRecorder(recorder);
+ return recorder;
+ }
+
+ @Override
+ protected Trace getTrace(TraceRecorder recorder) {
+ return recorder.getTrace();
+ }
+
+ @Override
+ protected void waitT(TraceRecorder recorder) throws Throwable {
+ waitRecorder(recorder);
+ }
+
+ @Override
+ protected void addLiveMemoryAndBreakpoint(TraceRecorder recorder)
+ throws InterruptedException, ExecutionException, TimeoutException {
+ mb.testProcess1.addRegion("bin:.text", mb.rng(0x55550000, 0x55550fff), "rx");
+ TargetBreakpointSpecContainer cont = getBreakpointContainer(recorder);
+ cont.placeBreakpoint(mb.addr(0x55550123), Set.of(TargetBreakpointKind.SW_EXECUTE))
+ .get(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
+ }
+
+ @Override
+ protected void handleSetBreakpointInvocation(Set<TraceBreakpointKind> expectedKinds,
+ long dynOffset) {
+ // The logic is already embedded in the Test model
+ }
+
+ @Override
+ protected void handleToggleBreakpointInvocation(TraceBreakpoint expectedBreakpoint,
+ boolean expectedEn) throws Throwable {
+ // The logic is already embedded in the Test model
+ }
+
+ @Override
+ protected void handleDeleteBreakpointInvocation(TraceBreakpoint expectedBreakpoint)
+ throws Throwable {
+ // The logic is already embedded in the Test model
+ }
+}
diff --git a/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerRecorderBreakpointsProviderTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerRecorderBreakpointsProviderTest.java
new file mode 100644
index 0000000000..c427007143
--- /dev/null
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerRecorderBreakpointsProviderTest.java
@@ -0,0 +1,98 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.breakpoint;
+
+import static org.junit.Assert.assertNull;
+
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import ghidra.dbg.model.TestTargetProcess;
+import ghidra.dbg.target.TargetBreakpointSpec.TargetBreakpointKind;
+import ghidra.dbg.target.TargetBreakpointSpecContainer;
+import ghidra.debug.api.action.ActionSource;
+import ghidra.debug.api.model.TraceRecorder;
+import ghidra.trace.model.Trace;
+import ghidra.trace.model.breakpoint.TraceBreakpoint;
+import ghidra.trace.model.breakpoint.TraceBreakpointKind;
+
+public class DebuggerRecorderBreakpointsProviderTest
+ extends AbstractDebuggerBreakpointsProviderTest<TraceRecorder, TestTargetProcess> {
+
+ @Override
+ protected TraceRecorder createTarget1() throws Throwable {
+ createTestModel();
+ mb.createTestProcessesAndThreads();
+ return modelService.recordTarget(mb.testProcess1, createTargetTraceMapper(mb.testProcess1),
+ ActionSource.AUTOMATIC);
+ }
+
+ @Override
+ protected TraceRecorder createTarget3() throws Throwable {
+ return modelService.recordTarget(mb.testProcess3, createTargetTraceMapper(mb.testProcess3),
+ ActionSource.AUTOMATIC);
+ }
+
+ @Override
+ protected TestTargetProcess getProcess1() {
+ return mb.testProcess1;
+ }
+
+ @Override
+ protected TestTargetProcess getProcess3() {
+ return mb.testProcess3;
+ }
+
+ @Override
+ protected Trace getTrace(TraceRecorder recorder) {
+ return recorder.getTrace();
+ }
+
+ @Override
+ protected void waitTarget(TraceRecorder recorder) throws Throwable {
+ waitRecorder(recorder);
+ }
+
+ @Override
+ protected void addLiveMemory(TestTargetProcess process) throws Exception {
+ process.addRegion("bin:.text", mb.rng(0x55550000, 0x55550fff), "rx");
+ }
+
+ @Override
+ protected void addLiveBreakpoint(TraceRecorder recorder, long offset) throws Exception {
+ TargetBreakpointSpecContainer cont = getBreakpointContainer(recorder);
+ cont.placeBreakpoint(mb.addr(offset), Set.of(TargetBreakpointKind.SW_EXECUTE))
+ .get(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
+ }
+
+ @Override
+ protected void handleSetBreakpointInvocation(Set<TraceBreakpointKind> expectedKinds,
+ long dynOffset) throws Throwable {
+ // Logic already in Test model
+ }
+
+ @Override
+ protected void handleToggleBreakpointInvocation(TraceBreakpoint expectedBreakpoint,
+ boolean expectedEnabled) throws Throwable {
+ // Logic already in Test model
+ }
+
+ @Override
+ protected void assertNotLiveBreakpoint(TraceRecorder recorder, TraceBreakpoint breakpoint)
+ throws Throwable {
+ assertNull(recorder.getTargetBreakpoint(breakpoint));
+ }
+}
diff --git a/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerRmiBreakpointMarkerPluginTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerRmiBreakpointMarkerPluginTest.java
new file mode 100644
index 0000000000..9fcf0f7f09
--- /dev/null
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerRmiBreakpointMarkerPluginTest.java
@@ -0,0 +1,167 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.breakpoint;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.junit.experimental.categories.Category;
+
+import db.Transaction;
+import generic.test.category.NightlyCategory;
+import ghidra.app.plugin.core.debug.service.rmi.trace.TraceRmiTarget;
+import ghidra.trace.database.target.DBTraceObjectManager;
+import ghidra.trace.model.Lifespan;
+import ghidra.trace.model.Trace;
+import ghidra.trace.model.breakpoint.*;
+import ghidra.trace.model.breakpoint.TraceBreakpointKind.TraceBreakpointKindSet;
+
+@Category(NightlyCategory.class)
+public class DebuggerRmiBreakpointMarkerPluginTest
+ extends AbstractDebuggerBreakpointMarkerPluginTest<TraceRmiTarget> {
+
+ @Override
+ protected TraceRmiTarget createLive() throws Throwable {
+ createRmiConnection();
+ addBreakpointMethods();
+ createTrace();
+ try (Transaction tx = tb.startTransaction()) {
+ /**
+ * TODO: Various schema scenarios?:
+ * <ul>
+ * <li>per-session BreakpointContainer</li>
+ * <li>per-process BreakpointContainer</li>
+ * <li>spec-is-location</li>
+ * <li>spec-has-locations</li>
+ * <li>togglable locs</li>
+ * <li>non-togglable locs</li>
+ * <ul>
+ */
+ tb.trace.getObjectManager().createRootObject(SCHEMA_SESSION);
+ tb.createObjectsProcessAndThreads();
+ }
+ TraceRmiTarget target = rmiCx.publishTarget(tool, tb.trace);
+ return target;
+ }
+
+ @Override
+ protected Trace getTrace(TraceRmiTarget target) {
+ return target.getTrace();
+ }
+
+ @Override
+ protected void waitT(TraceRmiTarget target) throws Throwable {
+ // No need to wait
+ }
+
+ @Override
+ protected void addLiveMemoryAndBreakpoint(TraceRmiTarget target) throws Throwable {
+ Lifespan zeroOn = Lifespan.nowOn(0);
+ try (Transaction tx = tb.startTransaction()) {
+ DBTraceObjectManager objs = tb.trace.getObjectManager();
+ addMemoryRegion(objs, zeroOn, tb.range(0x55550000, 0x55550fff), "bin:.text", "rx");
+ addBreakpointAndLoc(objs, zeroOn, tb.range(0x55550123),
+ Set.of(TraceBreakpointKind.SW_EXECUTE));
+ }
+ }
+
+ @Override
+ protected void handleSetBreakpointInvocation(Set<TraceBreakpointKind> expectedKinds,
+ long dynOffset) throws Throwable {
+ Lifespan zeroOn = Lifespan.nowOn(0);
+ if (TraceBreakpointKindSet.READ.equals(expectedKinds)) {
+ Map<String, Object> args = rmiMethodSetReadBreak.expect();
+ addBreakpointAndLoc(tb.trace.getObjectManager(), zeroOn, tb.range(dynOffset),
+ TraceBreakpointKindSet.READ);
+ rmiMethodSetReadBreak.result(null);
+ assertEquals(Map.ofEntries(
+ Map.entry("process", tb.obj("Processes[1]")),
+ Map.entry("range", tb.range(dynOffset))), args);
+ }
+ else if (TraceBreakpointKindSet.WRITE.equals(expectedKinds)) {
+ Map<String, Object> args = rmiMethodSetWriteBreak.expect();
+ addBreakpointAndLoc(tb.trace.getObjectManager(), zeroOn, tb.range(dynOffset),
+ TraceBreakpointKindSet.WRITE);
+ rmiMethodSetWriteBreak.result(null);
+ assertEquals(Map.ofEntries(
+ Map.entry("process", tb.obj("Processes[1]")),
+ Map.entry("range", tb.range(dynOffset))), args);
+ }
+ else if (TraceBreakpointKindSet.ACCESS.equals(expectedKinds)) {
+ Map<String, Object> args = rmiMethodSetAccessBreak.expect();
+ addBreakpointAndLoc(tb.trace.getObjectManager(), zeroOn, tb.range(dynOffset),
+ TraceBreakpointKindSet.ACCESS);
+ rmiMethodSetAccessBreak.result(null);
+ assertEquals(Map.ofEntries(
+ Map.entry("process", tb.obj("Processes[1]")),
+ Map.entry("range", tb.range(dynOffset))), args);
+ }
+ else if (TraceBreakpointKindSet.SW_EXECUTE.equals(expectedKinds)) {
+ Map<String, Object> args = rmiMethodSetSwBreak.expect();
+ addBreakpointAndLoc(tb.trace.getObjectManager(), zeroOn, tb.range(dynOffset),
+ TraceBreakpointKindSet.SW_EXECUTE);
+ rmiMethodSetSwBreak.result(null);
+ assertEquals(Map.ofEntries(
+ Map.entry("process", tb.obj("Processes[1]")),
+ Map.entry("address", tb.addr(dynOffset))), args);
+ }
+ else if (TraceBreakpointKindSet.HW_EXECUTE.equals(expectedKinds)) {
+ Map<String, Object> args = rmiMethodSetHwBreak.expect();
+ addBreakpointAndLoc(tb.trace.getObjectManager(), zeroOn, tb.range(dynOffset),
+ TraceBreakpointKindSet.HW_EXECUTE);
+ rmiMethodSetHwBreak.result(null);
+ assertEquals(Map.ofEntries(
+ Map.entry("process", tb.obj("Processes[1]")),
+ Map.entry("address", tb.addr(dynOffset))), args);
+ }
+ else {
+ throw new AssertionError("Unhandled invocation for kinds: " + expectedKinds);
+ }
+ }
+
+ @Override
+ protected void handleToggleBreakpointInvocation(TraceBreakpoint expectedBreakpoint,
+ boolean expectedEn) throws Throwable {
+ if (!(expectedBreakpoint instanceof TraceObjectBreakpointLocation loc)) {
+ throw new AssertionError("Unexpected trace breakpoint type: " + expectedBreakpoint);
+ }
+ Map<String, Object> args = rmiMethodToggleBreak.expect();
+ try (Transaction tx = tb.startTransaction()) {
+ loc.setEnabled(Lifespan.nowOn(0), expectedEn);
+ }
+ rmiMethodToggleBreak.result(null);
+ assertEquals(Map.ofEntries(
+ Map.entry("breakpoint", loc.getSpecification().getObject()),
+ Map.entry("enabled", expectedEn)), args);
+ }
+
+ @Override
+ protected void handleDeleteBreakpointInvocation(TraceBreakpoint expectedBreakpoint)
+ throws Throwable {
+ if (!(expectedBreakpoint instanceof TraceObjectBreakpointLocation loc)) {
+ throw new AssertionError("Unexpected trace breakpoint type: " + expectedBreakpoint);
+ }
+ Map<String, Object> args = rmiMethodDeleteBreak.expect();
+ try (Transaction tx = tb.startTransaction()) {
+ loc.getObject().remove(Lifespan.nowOn(0));
+ }
+ rmiMethodDeleteBreak.result(null);
+ assertEquals(Map.ofEntries(
+ Map.entry("breakpoint", loc.getSpecification().getObject())), args);
+ }
+}
diff --git a/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerRmiBreakpointsProviderTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerRmiBreakpointsProviderTest.java
new file mode 100644
index 0000000000..a7697b0a78
--- /dev/null
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/DebuggerRmiBreakpointsProviderTest.java
@@ -0,0 +1,144 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.breakpoint;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.*;
+
+import org.junit.Before;
+
+import db.Transaction;
+import ghidra.app.plugin.core.debug.service.rmi.trace.TraceRmiTarget;
+import ghidra.trace.database.ToyDBTraceBuilder;
+import ghidra.trace.model.Lifespan;
+import ghidra.trace.model.Trace;
+import ghidra.trace.model.breakpoint.*;
+import ghidra.trace.model.breakpoint.TraceBreakpointKind.TraceBreakpointKindSet;
+import ghidra.trace.model.memory.TraceObjectMemoryRegion;
+
+public class DebuggerRmiBreakpointsProviderTest
+ extends AbstractDebuggerBreakpointsProviderTest<TraceRmiTarget, Trace> {
+
+ ToyDBTraceBuilder tb3;
+
+ @Before
+ public void setUpRmiBreakpointServiceTest() throws Throwable {
+ createRmiConnection();
+ addBreakpointMethods();
+ }
+
+ @Override
+ protected TraceRmiTarget createTarget1() throws Throwable {
+ createTrace();
+ try (Transaction tx = tb.startTransaction()) {
+ tb.trace.getObjectManager().createRootObject(SCHEMA_SESSION);
+ tb.createObjectsProcessAndThreads();
+ ensureBreakpointContainer(tb.trace.getObjectManager());
+ }
+ return rmiCx.publishTarget(tool, tb.trace);
+ }
+
+ @Override
+ protected TraceRmiTarget createTarget3() throws Throwable {
+ tb3 = new ToyDBTraceBuilder("dynamic3-" + name.getMethodName(), LANGID_TOYBE64);
+ try (Transaction tx = tb3.startTransaction()) {
+ tb3.trace.getTimeManager().createSnapshot("Fist snapshot");
+ tb3.trace.getObjectManager().createRootObject(SCHEMA_SESSION);
+ tb3.createObjectsProcessAndThreads();
+ ensureBreakpointContainer(tb3.trace.getObjectManager());
+ }
+ return rmiCx.publishTarget(tool, tb3.trace);
+ }
+
+ @Override
+ protected Trace getProcess1() {
+ return tb.trace;
+ }
+
+ @Override
+ protected Trace getProcess3() {
+ return tb3.trace;
+ }
+
+ @Override
+ protected Trace getTrace(TraceRmiTarget target) {
+ return target.getTrace();
+ }
+
+ @Override
+ protected void waitTarget(TraceRmiTarget target) throws Throwable {
+ waitForDomainObject(target.getTrace());
+ }
+
+ @Override
+ protected void addLiveMemory(Trace trace) throws Throwable {
+ try (Transaction tx = trace.openTransaction("Add .text")) {
+ Objects.requireNonNull(addMemoryRegion(trace.getObjectManager(), Lifespan.nowOn(0),
+ tb.range(0x55550000, 0x55550fff), "bin:.text", "rx")
+ .queryInterface(TraceObjectMemoryRegion.class));
+ }
+ }
+
+ @Override
+ protected void addLiveBreakpoint(TraceRmiTarget target, long offset) throws Throwable {
+ Trace trace = target.getTrace();
+ try (Transaction tx = trace.openTransaction("Add breakpoint")) {
+ addBreakpointAndLoc(trace.getObjectManager(), Lifespan.nowOn(0), tb.range(offset),
+ TraceBreakpointKindSet.SW_EXECUTE);
+ }
+ }
+
+ @Override
+ protected void handleSetBreakpointInvocation(Set<TraceBreakpointKind> expectedKinds,
+ long dynOffset) throws Throwable {
+ Lifespan zeroOn = Lifespan.nowOn(0);
+ if (TraceBreakpointKindSet.SW_EXECUTE.equals(expectedKinds)) {
+ Map<String, Object> args = rmiMethodSetSwBreak.expect();
+ addBreakpointAndLoc(tb.trace.getObjectManager(), zeroOn, tb.range(dynOffset),
+ TraceBreakpointKindSet.SW_EXECUTE);
+ rmiMethodSetSwBreak.result(null);
+ assertEquals(Map.ofEntries(
+ Map.entry("process", tb.obj("Processes[1]")),
+ Map.entry("address", tb.addr(dynOffset))), args);
+ }
+ else {
+ throw new AssertionError("Unhandled invocation for kinds: " + expectedKinds);
+ }
+ }
+
+ @Override
+ protected void handleToggleBreakpointInvocation(TraceBreakpoint expectedBreakpoint,
+ boolean expectedEn) throws Throwable {
+ if (!(expectedBreakpoint instanceof TraceObjectBreakpointLocation loc)) {
+ throw new AssertionError("Unexpected trace breakpoint type: " + expectedBreakpoint);
+ }
+ Map<String, Object> args = rmiMethodToggleBreak.expect();
+ try (Transaction tx = tb.startTransaction()) {
+ loc.setEnabled(Lifespan.nowOn(0), expectedEn);
+ }
+ rmiMethodToggleBreak.result(null);
+ assertEquals(Map.ofEntries(
+ Map.entry("breakpoint", loc.getSpecification().getObject()),
+ Map.entry("enabled", expectedEn)), args);
+ }
+
+ @Override
+ protected void assertNotLiveBreakpoint(TraceRmiTarget target, TraceBreakpoint breakpoint)
+ throws Throwable {
+ // TODO: Not sure there's anything to do here
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/MockDecompileResults.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/MockDecompileResults.java
similarity index 100%
rename from Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/MockDecompileResults.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/breakpoint/MockDecompileResults.java
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/control/DebuggerControlPluginTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/control/DebuggerControlPluginTest.java
similarity index 74%
rename from Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/control/DebuggerControlPluginTest.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/control/DebuggerControlPluginTest.java
index 31089c9b3f..d6f8b59ebd 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/control/DebuggerControlPluginTest.java
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/control/DebuggerControlPluginTest.java
@@ -41,16 +41,18 @@ import ghidra.app.plugin.core.clipboard.ClipboardPlugin;
import ghidra.app.plugin.core.codebrowser.CodeViewerProvider;
import ghidra.app.plugin.core.debug.disassemble.DebuggerDisassemblerPlugin;
import ghidra.app.plugin.core.debug.disassemble.DebuggerDisassemblerPluginTestHelper;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerIntegrationTest;
import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingPlugin;
import ghidra.app.plugin.core.debug.mapping.ObjectBasedDebuggerTargetTraceMapper;
import ghidra.app.plugin.core.debug.service.control.DebuggerControlServicePlugin;
import ghidra.app.plugin.core.debug.service.emulation.DebuggerEmulationServicePlugin;
+import ghidra.app.plugin.core.debug.service.rmi.trace.TestTraceRmiConnection.TestRemoteMethod;
import ghidra.app.services.DebuggerControlService;
import ghidra.app.services.DebuggerEmulationService;
import ghidra.app.services.DebuggerEmulationService.CachedEmulator;
import ghidra.app.services.DebuggerEmulationService.EmulationResult;
import ghidra.dbg.model.*;
+import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionState;
import ghidra.dbg.target.TargetObject;
import ghidra.dbg.target.TargetSteppable.TargetStepKind;
import ghidra.debug.api.control.ControlMode;
@@ -66,6 +68,7 @@ import ghidra.program.util.ProgramLocation;
import ghidra.trace.model.Lifespan;
import ghidra.trace.model.memory.TraceMemoryFlag;
import ghidra.trace.model.program.TraceVariableSnapProgramView;
+import ghidra.trace.model.target.TraceObject;
import ghidra.trace.model.thread.TraceThread;
import ghidra.trace.model.time.schedule.Scheduler;
import ghidra.trace.model.time.schedule.TraceSchedule;
@@ -79,7 +82,7 @@ import ghidra.util.Swing;
* stand-in for any mode. We also use {@link ControlMode#RO_TARGET} just to verify the mode is
* heeded. Other modes may be tested if bugs crop up in various combinations.
*/
-public class DebuggerControlPluginTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerControlPluginTest extends AbstractGhidraHeadedDebuggerIntegrationTest {
DebuggerListingPlugin listingPlugin;
DebuggerControlService controlService;
@@ -169,7 +172,7 @@ public class DebuggerControlPluginTest extends AbstractGhidraHeadedDebuggerGUITe
}
@Test
- public void testTargetResumeAction() throws Throwable {
+ public void testRecorderTargetResumeAction() throws Throwable {
createTestModel();
TraceRecorder recorder = recordAndWaitSync();
traceManager.openTrace(tb.trace);
@@ -179,7 +182,8 @@ public class DebuggerControlPluginTest extends AbstractGhidraHeadedDebuggerGUITe
waitRecorder(recorder);
waitForSwing();
- DockingAction actionTargetResume = controlPlugin.getTargetAction("Resume");
+ DockingAction actionTargetResume = controlPlugin.actionTargetResume;
+ assertInTool(actionTargetResume);
performEnabledAction(null, actionTargetResume, true);
waitForTasks();
waitRecorder(recorder);
@@ -189,7 +193,7 @@ public class DebuggerControlPluginTest extends AbstractGhidraHeadedDebuggerGUITe
}
@Test
- public void testTargetInterruptAction() throws Throwable {
+ public void testRecorderTargetInterruptAction() throws Throwable {
createTestModel();
TraceRecorder recorder = recordAndWaitSync();
traceManager.openTrace(tb.trace);
@@ -199,7 +203,8 @@ public class DebuggerControlPluginTest extends AbstractGhidraHeadedDebuggerGUITe
waitRecorder(recorder);
waitForSwing();
- DockingAction actionTargetInterrupt = controlPlugin.getTargetAction("Interrupt");
+ DockingAction actionTargetInterrupt = controlPlugin.actionTargetInterrupt;
+ assertInTool(actionTargetInterrupt);
assertFalse(actionTargetInterrupt.isEnabled());
waitOn(mb.testThread1.resume());
waitRecorder(recorder);
@@ -215,7 +220,7 @@ public class DebuggerControlPluginTest extends AbstractGhidraHeadedDebuggerGUITe
}
@Test
- public void testTargetKillAction() throws Throwable {
+ public void testRecorderTargetKillAction() throws Throwable {
createTestModel();
TraceRecorder recorder = recordAndWaitSync();
traceManager.openTrace(tb.trace);
@@ -225,7 +230,8 @@ public class DebuggerControlPluginTest extends AbstractGhidraHeadedDebuggerGUITe
waitRecorder(recorder);
waitForSwing();
- DockingAction actionTargetKill = controlPlugin.getTargetAction("Kill");
+ DockingAction actionTargetKill = controlPlugin.actionTargetKill;
+ assertInTool(actionTargetKill);
performEnabledAction(null, actionTargetKill, true);
waitForTasks();
waitRecorder(recorder);
@@ -235,23 +241,25 @@ public class DebuggerControlPluginTest extends AbstractGhidraHeadedDebuggerGUITe
}
@Test
- public void testTargetDisconnectAction() throws Throwable {
+ public void testRecorderTargetDisconnectAction() throws Throwable {
createTestModel();
TraceRecorder recorder = recordAndWaitSync();
traceManager.openTrace(tb.trace);
traceManager.activateTrace(tb.trace);
waitForSwing();
- performEnabledAction(null, controlPlugin.actionTargetDisconnect, true);
+ DockingAction actionTargetDisconnect = controlPlugin.actionTargetDisconnect;
+ assertInTool(actionTargetDisconnect);
+ performEnabledAction(null, actionTargetDisconnect, true);
waitForTasks();
waitRecorder(recorder);
assertEquals(List.of("close"), commands);
waitForSwing();
- waitForPass(() -> assertFalse(controlPlugin.actionTargetDisconnect.isEnabled()));
+ waitForPass(() -> assertFalse(actionTargetDisconnect.isEnabled()));
}
- protected void runTestTargetStepAction(Supplier<DockingAction> action, TargetStepKind expected)
- throws Throwable {
+ protected void runTestRecorderTargetStepAction(Supplier<DockingAction> actionSupplier,
+ TargetStepKind expected) throws Throwable {
createTestModel();
TraceRecorder recorder = recordAndWaitSync();
traceManager.openTrace(tb.trace);
@@ -261,32 +269,192 @@ public class DebuggerControlPluginTest extends AbstractGhidraHeadedDebuggerGUITe
waitRecorder(recorder);
waitForSwing();
- performEnabledAction(null, action.get(), true);
+ DockingAction action = actionSupplier.get();
+ assertInTool(action);
+ performEnabledAction(null, action, true);
waitForTasks();
waitRecorder(recorder);
assertEquals(List.of("step(" + expected + ")"), commands);
waitForSwing();
- assertTrue(action.get().isEnabled());
+ assertTrue(actionSupplier.get().isEnabled());
}
@Test
- public void testTargetStepIntoAction() throws Throwable {
- runTestTargetStepAction(() -> controlPlugin.getTargetAction("Step Into"),
+ public void testRecorderTargetStepIntoAction() throws Throwable {
+ runTestRecorderTargetStepAction(() -> controlPlugin.actionTargetStepInto,
TargetStepKind.INTO);
}
@Test
- public void testTargetStepOverAction() throws Throwable {
- runTestTargetStepAction(() -> controlPlugin.getTargetAction("Step Over"),
+ public void testRecorderTargetStepOverAction() throws Throwable {
+ runTestRecorderTargetStepAction(() -> controlPlugin.actionTargetStepOver,
TargetStepKind.OVER);
}
@Test
- public void testTargetStepOutAction() throws Throwable {
- runTestTargetStepAction(() -> controlPlugin.getTargetAction("Step Out"),
+ public void testRecorderTargetStepOutAction() throws Throwable {
+ runTestRecorderTargetStepAction(() -> controlPlugin.actionTargetStepOut,
TargetStepKind.FINISH);
}
+ protected TraceObject setUpRmiTarget() throws Throwable {
+ createRmiConnection();
+ addControlMethods();
+ createTrace();
+ try (Transaction tx = tb.startTransaction()) {
+ tb.trace.getObjectManager().createRootObject(SCHEMA_SESSION);
+ tb.createObjectsProcessAndThreads();
+ }
+ rmiCx.publishTarget(tool, tb.trace);
+ traceManager.openTrace(tb.trace);
+ traceManager.activateTrace(tb.trace);
+ return Objects.requireNonNull(tb.obj("Processes[1]"));
+ }
+
+ protected void assertInTool(DockingAction action) {
+ assertNotNull(action);
+ assertTrue(tool.getDockingActionsByOwnerName(controlPlugin.getName()).contains(action));
+ }
+
+ @Test
+ public void testRmiTargetResumeAction() throws Throwable {
+ TraceObject proc1 = setUpRmiTarget();
+ traceManager.activateObject(proc1);
+ waitForSwing();
+
+ DockingAction actionTargetResume = controlPlugin.actionTargetResume;
+ assertInTool(actionTargetResume);
+ performEnabledAction(null, actionTargetResume, true);
+
+ Map<String, Object> args = rmiMethodResume.expect();
+ try (Transaction tx = tb.startTransaction()) {
+ proc1.setAttribute(Lifespan.nowOn(0), "_state", TargetExecutionState.RUNNING.name());
+ }
+ rmiMethodResume.result(null);
+ assertEquals(Map.ofEntries(
+ Map.entry("process", proc1)),
+ args);
+ waitForTasks();
+ waitForDomainObject(tb.trace);
+
+ assertFalse(actionTargetResume.isEnabled());
+ }
+
+ @Test
+ public void testRmiTargetInterruptAction() throws Throwable {
+ TraceObject proc1 = setUpRmiTarget();
+ traceManager.activateObject(proc1);
+ waitForSwing();
+
+ DockingAction actionTargetInterrupt = controlPlugin.actionTargetInterrupt;
+ assertInTool(actionTargetInterrupt);
+ assertFalse(actionTargetInterrupt.isEnabled());
+
+ try (Transaction tx = tb.startTransaction()) {
+ proc1.setAttribute(Lifespan.nowOn(0), "_state", TargetExecutionState.RUNNING.name());
+ }
+ waitForDomainObject(tb.trace);
+
+ performEnabledAction(null, actionTargetInterrupt, true);
+
+ Map<String, Object> args = rmiMethodInterrupt.expect();
+ try (Transaction tx = tb.startTransaction()) {
+ proc1.setAttribute(Lifespan.nowOn(0), "_state", TargetExecutionState.STOPPED.name());
+ }
+ rmiMethodInterrupt.result(null);
+ assertEquals(Map.ofEntries(
+ Map.entry("process", proc1)),
+ args);
+ waitForTasks();
+ waitForDomainObject(tb.trace);
+
+ assertFalse(actionTargetInterrupt.isEnabled());
+ }
+
+ @Test
+ public void testRmiTargetKillAction() throws Throwable {
+ TraceObject proc1 = setUpRmiTarget();
+ traceManager.activateObject(proc1);
+ waitForSwing();
+
+ DockingAction actionTargetKill = controlPlugin.actionTargetKill;
+ assertInTool(actionTargetKill);
+ performEnabledAction(null, actionTargetKill, true);
+
+ Map<String, Object> args = rmiMethodKill.expect();
+ try (Transaction tx = tb.startTransaction()) {
+ proc1.setAttribute(Lifespan.nowOn(0), "_state", TargetExecutionState.TERMINATED.name());
+ }
+ rmiMethodKill.result(null);
+ assertEquals(Map.ofEntries(
+ Map.entry("process", proc1)),
+ args);
+ waitForTasks();
+ waitForDomainObject(tb.trace);
+
+ assertFalse(actionTargetKill.isEnabled());
+ }
+
+ @Test
+ public void testRmiTargetDisconnectAction() throws Throwable {
+ TraceObject proc1 = setUpRmiTarget();
+ traceManager.activateObject(proc1);
+ waitForSwing();
+ assertFalse(rmiCx.isClosed());
+
+ DockingAction actionTargetDisconnect = controlPlugin.actionTargetDisconnect;
+ assertInTool(actionTargetDisconnect);
+ performEnabledAction(null, actionTargetDisconnect, true);
+ waitForTasks();
+
+ assertTrue(rmiCx.isClosed());
+
+ waitForPass(() -> assertFalse(actionTargetDisconnect.isEnabled()));
+ }
+
+ protected void runTestRmiTargetStepAction(Supplier<DockingAction> actionSupplier,
+ TargetStepKind expected, Supplier<TestRemoteMethod> methodSupplier) throws Throwable {
+ setUpRmiTarget(); // method is created here, so we accept a supplier
+ TraceObject thread1 = tb.obj("Processes[1].Threads[1]");
+ traceManager.activateObject(thread1);
+ waitForSwing();
+
+ DockingAction action = actionSupplier.get();
+ assertInTool(action);
+ performEnabledAction(null, action, true);
+
+ TestRemoteMethod method = methodSupplier.get();
+ // NB. Provide a result before asserting
+ Map<String, Object> args = method.expect();
+ // No state change, or brief state change
+ method.result(null);
+ assertEquals(Map.ofEntries(
+ Map.entry("thread", thread1)),
+ args);
+ waitForTasks();
+ waitForDomainObject(tb.trace);
+
+ assertTrue(action.isEnabled());
+ }
+
+ @Test
+ public void testRmiTargetStepIntoAction() throws Throwable {
+ runTestRmiTargetStepAction(() -> controlPlugin.actionTargetStepInto,
+ TargetStepKind.INTO, () -> rmiMethodStepInto);
+ }
+
+ @Test
+ public void testRmiTargetStepOverAction() throws Throwable {
+ runTestRmiTargetStepAction(() -> controlPlugin.actionTargetStepOver,
+ TargetStepKind.OVER, () -> rmiMethodStepOver);
+ }
+
+ @Test
+ public void testRmiTargetStepOutAction() throws Throwable {
+ runTestRmiTargetStepAction(() -> controlPlugin.actionTargetStepOut,
+ TargetStepKind.FINISH, () -> rmiMethodStepOut);
+ }
+
TraceThread createToyLoopTrace() throws Throwable {
createAndOpenTrace();
@@ -322,9 +490,9 @@ public class DebuggerControlPluginTest extends AbstractGhidraHeadedDebuggerGUITe
}
/**
- * Tests the UI so it does not error when the user presses resume
- * after already stepped into a pcode instruction.
- */
+ * Tests the UI so it does not error when the user presses resume after already stepped into a
+ * pcode instruction.
+ */
@Test
public void testEmulateResumeActionAfterPcodeStep() throws Throwable {
TraceThread thread = createToyLoopTrace();
@@ -333,7 +501,7 @@ public class DebuggerControlPluginTest extends AbstractGhidraHeadedDebuggerGUITe
traceManager.activateThread(thread);
traceManager.activateTime(TraceSchedule.parse("0:.t0-2"));
waitForSwing();
-
+
performEnabledAction(null, controlPlugin.actionEmulateResume, true);
waitForPass(() -> assertFalse(controlPlugin.actionEmulateResume.isEnabled()));
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/control/DebuggerMethodActionsPluginTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/control/DebuggerMethodActionsPluginTest.java
similarity index 99%
rename from Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/control/DebuggerMethodActionsPluginTest.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/control/DebuggerMethodActionsPluginTest.java
index a53f0270de..e06cd9fdbf 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/control/DebuggerMethodActionsPluginTest.java
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/control/DebuggerMethodActionsPluginTest.java
@@ -30,7 +30,7 @@ import db.Transaction;
import docking.action.DockingActionIf;
import generic.Unique;
import ghidra.app.context.ProgramLocationActionContext;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingPlugin;
import ghidra.app.plugin.core.debug.service.modules.DebuggerStaticMappingServicePlugin;
import ghidra.app.services.DebuggerStaticMappingService;
@@ -47,7 +47,7 @@ import ghidra.program.model.address.Address;
import ghidra.program.util.ProgramLocation;
import ghidra.trace.model.Lifespan;
-public class DebuggerMethodActionsPluginTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class DebuggerMethodActionsPluginTest extends AbstractGhidraHeadedDebuggerTest {
public static final XmlSchemaContext SCHEMA_CTX;
public static final TargetObjectSchema MOD_ROOT_SCHEMA;
diff --git a/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/AbstractDebuggerRegistersProviderTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/AbstractDebuggerRegistersProviderTest.java
new file mode 100644
index 0000000000..16b8e7586c
--- /dev/null
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/AbstractDebuggerRegistersProviderTest.java
@@ -0,0 +1,295 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.register;
+
+import static org.junit.Assert.*;
+
+import java.math.BigInteger;
+import java.nio.ByteBuffer;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.junit.Before;
+import org.junit.experimental.categories.Category;
+
+import db.Transaction;
+import generic.test.category.NightlyCategory;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerIntegrationTest;
+import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingPlugin;
+import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingProvider;
+import ghidra.app.plugin.core.debug.service.control.DebuggerControlServicePlugin;
+import ghidra.app.services.DebuggerControlService;
+import ghidra.program.model.address.AddressSpace;
+import ghidra.program.model.data.*;
+import ghidra.program.model.lang.Register;
+import ghidra.program.model.util.CodeUnitInsertionException;
+import ghidra.trace.model.Lifespan;
+import ghidra.trace.model.guest.TraceGuestPlatform;
+import ghidra.trace.model.guest.TracePlatform;
+import ghidra.trace.model.listing.TraceCodeSpace;
+import ghidra.trace.model.memory.TraceMemorySpace;
+import ghidra.trace.model.thread.TraceThread;
+import ghidra.util.exception.DuplicateNameException;
+
+@Category(NightlyCategory.class) // this may actually be an @PortSensitive test
+public abstract class AbstractDebuggerRegistersProviderTest
+ extends AbstractGhidraHeadedDebuggerIntegrationTest {
+
+ protected TraceGuestPlatform toy;
+
+ protected DebuggerRegistersPlugin registersPlugin;
+ protected DebuggerRegistersProvider registersProvider;
+ protected DebuggerListingPlugin listingPlugin;
+ protected DebuggerControlService controlService;
+
+ protected Register r0;
+ protected Register pc;
+ protected Register sp;
+ protected Register contextreg;
+
+ protected Register r0h;
+ protected Register r0l;
+ protected Register pch;
+ protected Register pcl;
+
+ protected Set<Register> baseRegs;
+
+ protected StructureDataType r0Struct;
+
+ @Before
+ public void setUpRegistersProviderTest() throws Exception {
+ registersPlugin = addPlugin(tool, DebuggerRegistersPlugin.class);
+ registersProvider = waitForComponentProvider(DebuggerRegistersProvider.class);
+ listingPlugin = addPlugin(tool, DebuggerListingPlugin.class);
+ controlService = addPlugin(tool, DebuggerControlServicePlugin.class);
+
+ // TODO: Workaround issue in testing framework.
+ waitForComponentProvider(DebuggerListingProvider.class).setAutoDisassemble(false);
+
+ createTrace();
+ r0 = tb.language.getRegister("r0");
+ pc = tb.language.getProgramCounter();
+ sp = tb.language.getDefaultCompilerSpec().getStackPointer();
+ contextreg = tb.language.getContextBaseRegister();
+
+ pch = tb.language.getRegister("pch");
+ pcl = tb.language.getRegister("pcl");
+
+ r0h = tb.language.getRegister("r0h");
+ r0l = tb.language.getRegister("r0l");
+
+ r0Struct = new StructureDataType("r0_struct", 0);
+ r0Struct.add(SignedDWordDataType.dataType, "hi", "");
+ r0Struct.add(DWordDataType.dataType, "lo", "");
+
+ baseRegs = tb.language.getRegisters()
+ .stream()
+ .filter(Register::isBaseRegister)
+ .collect(Collectors.toSet());
+ }
+
+ protected void setUpGuestRegistersProviderTest() throws Exception {
+ registersPlugin = addPlugin(tool, DebuggerRegistersPlugin.class);
+ registersProvider = waitForComponentProvider(DebuggerRegistersProvider.class);
+ listingPlugin = addPlugin(tool, DebuggerListingPlugin.class);
+ controlService = addPlugin(tool, DebuggerControlServicePlugin.class);
+
+ createTrace();
+ createToyPlatform();
+
+ r0 = tb.reg(toy, "r0");
+ pc = toy.getLanguage().getProgramCounter();
+ sp = toy.getCompilerSpec().getStackPointer();
+ contextreg = toy.getLanguage().getContextBaseRegister();
+
+ pch = tb.reg(toy, "pch");
+ pcl = tb.reg(toy, "pcl");
+
+ r0h = tb.reg(toy, "r0h");
+ r0l = tb.reg(toy, "r0l");
+
+ r0Struct = new StructureDataType("r0_struct", 0);
+ r0Struct.add(SignedDWordDataType.dataType, "hi", "");
+ r0Struct.add(DWordDataType.dataType, "lo", "");
+
+ baseRegs = toy.getLanguage()
+ .getRegisters()
+ .stream()
+ .filter(Register::isBaseRegister)
+ .collect(Collectors.toSet());
+ }
+
+ protected TraceThread addThread() throws DuplicateNameException {
+ return addThread("Thread1");
+ }
+
+ protected TraceThread addThread(String threadName) throws DuplicateNameException {
+ try (Transaction tx = tb.startTransaction()) {
+ return tb.trace.getThreadManager().createThread(threadName, 0);
+ }
+ }
+
+ public void createToyPlatform() throws Exception {
+ try (Transaction tx = tb.startTransaction()) {
+ toy = tb.trace.getPlatformManager()
+ .addGuestPlatform(getToyBE64Language().getDefaultCompilerSpec());
+ toy.addMappedRange(tb.addr(0), tb.addr(toy, 0), -1);
+ toy.addMappedRegisterRange();
+ }
+ }
+
+ protected TracePlatform getPlatform() {
+ return tb.host;
+ }
+
+ protected void activateThread(TraceThread thread) {
+ traceManager.activateThread(thread);
+ }
+
+ protected void addRegisterValues(TraceThread thread) {
+ try (Transaction tx = tb.startTransaction()) {
+ addRegisterValues(thread, tx);
+ }
+ }
+
+ protected void addRegisterValues(TraceThread thread, Transaction tx) {
+ TraceMemorySpace regVals =
+ tb.trace.getMemoryManager().getMemoryRegisterSpace(thread, true);
+ regVals.putBytes(0, pc, tb.buf(0, 0, 0, 0, 0, 0x40, 0, 0));
+ regVals.putBytes(0, sp, tb.buf(0x1f, 0, 0, 0, 0, 0, 0, 0));
+ regVals.putBytes(0, r0, tb.buf(1, 2, 3, 4, 5, 6, 7, 8));
+ }
+
+ protected void addRegisterTypes(TraceThread thread, Transaction tx)
+ throws CodeUnitInsertionException {
+ TraceCodeSpace regCode =
+ tb.trace.getCodeManager().getCodeRegisterSpace(thread, true);
+ DataTypeManager dtm = tb.trace.getDataTypeManager();
+ AddressSpace space = tb.host.getAddressFactory().getDefaultAddressSpace();
+ PointerTypedef ramPtr = new PointerTypedef(null, VoidDataType.dataType, -1, dtm, space);
+ regCode.definedData().create(getPlatform(), Lifespan.nowOn(0), pc, ramPtr);
+ regCode.definedData().create(getPlatform(), Lifespan.nowOn(0), r0, r0Struct);
+ }
+
+ protected void addRegisterTypes(TraceThread thread) throws CodeUnitInsertionException {
+ try (Transaction tx = tb.startTransaction()) {
+ addRegisterTypes(thread, tx);
+ }
+ }
+
+ protected RegisterRow findRegisterRow(Register reg) {
+ RegisterRow row = getRegisterRow(reg);
+ if (row == null) {
+ throw new NoSuchElementException(reg.getName());
+ }
+ return row;
+ }
+
+ protected RegisterRow getRegisterRow(Register reg) {
+ return registersProvider.regMap.get(reg);
+ }
+
+ protected void setRowText(RegisterRow row, String text) {
+ assertTrue(row.isValueEditable());
+ row.setValue(new BigInteger(text, 16));
+ }
+
+ protected void setRowRepr(RegisterRow row, String repr) {
+ assertTrue(row.isRepresentationEditable());
+ row.setRepresentation(repr);
+ }
+
+ protected void assertRowValueEmpty(RegisterRow row) {
+ assertEquals(BigInteger.ZERO, row.getValue());
+ }
+
+ protected void assertRowTypeEmpty(RegisterRow row) {
+ assertNull(row.getDataType());
+ }
+
+ protected void assertPCRowValueEmpty() {
+ assertRowValueEmpty(findRegisterRow(pc));
+ }
+
+ protected void assertPCRowTypeEmpty() {
+ assertRowTypeEmpty(findRegisterRow(pc));
+ }
+
+ protected void assertR0RowValueEmpty() {
+ assertRowValueEmpty(findRegisterRow(r0));
+ }
+
+ protected void assertR0RowTypeEmpty() {
+ assertRowTypeEmpty(findRegisterRow(r0));
+ }
+
+ protected void assertPCRowValuePopulated() {
+ RegisterRow row = findRegisterRow(pc);
+ assertEquals(0x00400000, row.getValue().longValue());
+
+ RegisterRow rowH = findRegisterRow(pch);
+ assertEquals(0x00000000, rowH.getValue().longValue());
+
+ RegisterRow rowL = findRegisterRow(pcl);
+ assertEquals(0x00400000, rowL.getValue().longValue());
+ }
+
+ protected void assertPCRowTypePopulated() {
+ RegisterRow row = findRegisterRow(pc);
+ assertTypeEquals(PointerDataType.dataType, row.getDataType());
+
+ //assertTrue(row.data.getValue() instanceof Address);
+ //Address pcAddr = (Address) row.data.getValue();
+ //assertEquals("ram", pcAddr.getAddressSpace().getName());
+ //assertEquals(0x00400000, pcAddr.getOffset());
+ //assertEquals("<INVALID>", row.reprField.getText()); // No memory layout is provided
+
+ RegisterRow rowH = findRegisterRow(pch);
+ assertNull(rowH.getDataType());
+
+ RegisterRow rowL = findRegisterRow(pcl);
+ assertNull(rowL.getDataType());
+ }
+
+ protected void assertR0RowValuePopulated() {
+ RegisterRow row = findRegisterRow(r0);
+ assertEquals(0x0102030405060708L, row.getValue().longValue());
+
+ RegisterRow rowL = findRegisterRow(r0l);
+ assertEquals(0x05060708, rowL.getValue().longValue());
+
+ RegisterRow rowH = findRegisterRow(r0h);
+ assertEquals(0x01020304, rowH.getValue().longValue());
+ }
+
+ protected void assertR0RowTypePopulated() {
+ RegisterRow row = findRegisterRow(r0);
+ assertTypeEquals(r0Struct, row.getDataType());
+
+ RegisterRow rowL = findRegisterRow(r0l);
+ assertTypeEquals(DWordDataType.dataType, rowL.getDataType());
+
+ RegisterRow rowH = findRegisterRow(r0h);
+ assertTypeEquals(SignedDWordDataType.dataType, rowH.getDataType());
+ }
+
+ long encodeDouble(double value) {
+ ByteBuffer buf = ByteBuffer.allocate(Double.BYTES);
+ buf.putDouble(0, value);
+ return buf.getLong(0);
+ }
+}
diff --git a/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerGuestRecorderRegistersProviderTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerGuestRecorderRegistersProviderTest.java
new file mode 100644
index 0000000000..25c82dcf05
--- /dev/null
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerGuestRecorderRegistersProviderTest.java
@@ -0,0 +1,82 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.register;
+
+import java.io.IOException;
+import java.util.Set;
+
+import org.junit.Before;
+
+import ghidra.app.plugin.core.debug.mapping.ObjectBasedDebuggerTargetTraceMapper;
+import ghidra.dbg.target.TargetObject;
+import ghidra.debug.api.model.DebuggerTargetTraceMapper;
+import ghidra.debug.api.model.TraceRecorder;
+import ghidra.framework.plugintool.PluginTool;
+import ghidra.program.model.lang.CompilerSpecID;
+import ghidra.program.model.lang.LanguageID;
+import ghidra.trace.model.Trace;
+import ghidra.trace.model.guest.TracePlatform;
+import ghidra.trace.model.thread.TraceThread;
+
+public class DebuggerGuestRecorderRegistersProviderTest
+ extends DebuggerRecorderRegistersProviderTest {
+
+ @Override
+ protected void createTrace() throws IOException {
+ createTrace("DATA:BE:64:default");
+ }
+
+ @Before
+ @Override
+ public void setUpRegistersProviderTest() throws Exception {
+ setUpGuestRegistersProviderTest();
+ }
+
+ @Override
+ protected TracePlatform getPlatform() {
+ return toy;
+ }
+
+ @Override
+ protected void activateThread(TraceThread thread) {
+ traceManager.activate(traceManager.resolveThread(thread).platform(toy));
+ }
+
+ @Override
+ protected TargetObject chooseTarget() {
+ return mb.testModel.session;
+ }
+
+ @Override
+ protected DebuggerTargetTraceMapper createTargetTraceMapper(TargetObject target)
+ throws Exception {
+ return new ObjectBasedDebuggerTargetTraceMapper(target,
+ new LanguageID("DATA:BE:64:default"), new CompilerSpecID("pointer64"), Set.of()) {
+ @Override
+ public TraceRecorder startRecording(PluginTool tool, Trace trace) {
+ useTrace(trace);
+ return super.startRecording(tool, trace);
+ }
+ };
+ }
+
+ @Override
+ protected TraceRecorder recordAndWaitSync() throws Throwable {
+ TraceRecorder recorder = super.recordAndWaitSync();
+ createToyPlatform();
+ return recorder;
+ }
+}
diff --git a/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerGuestTraceRegistersProviderTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerGuestTraceRegistersProviderTest.java
new file mode 100644
index 0000000000..98e772070c
--- /dev/null
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerGuestTraceRegistersProviderTest.java
@@ -0,0 +1,76 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.register;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.junit.Before;
+import org.junit.experimental.categories.Category;
+
+import db.Transaction;
+import generic.test.category.NightlyCategory;
+import ghidra.trace.model.guest.TracePlatform;
+import ghidra.trace.model.memory.TraceMemorySpace;
+import ghidra.trace.model.thread.TraceThread;
+
+@Category(NightlyCategory.class)
+public class DebuggerGuestTraceRegistersProviderTest extends DebuggerTraceRegistersProviderTest {
+
+ @Override
+ protected void createTrace() throws IOException {
+ createTrace("DATA:BE:64:default");
+ }
+
+ @Before
+ @Override
+ public void setUpRegistersProviderTest() throws Exception {
+ setUpGuestRegistersProviderTest();
+ }
+
+ @Override
+ protected TracePlatform getPlatform() {
+ return toy;
+ }
+
+ @Override
+ protected void activateThread(TraceThread thread) {
+ traceManager.activate(traceManager.resolveThread(thread).platform(toy));
+ }
+
+ @Override
+ protected void addRegisterValues(TraceThread thread, Transaction tx) {
+ TraceMemorySpace regVals =
+ tb.trace.getMemoryManager().getMemoryRegisterSpace(thread, true);
+ regVals.putBytes(toy, 0, pc, tb.buf(0, 0, 0, 0, 0, 0x40, 0, 0));
+ regVals.putBytes(toy, 0, sp, tb.buf(0x1f, 0, 0, 0, 0, 0, 0, 0));
+ regVals.putBytes(toy, 0, r0, tb.buf(1, 2, 3, 4, 5, 6, 7, 8));
+ }
+
+ @Override
+ public void testDefaultSelection() throws Exception {
+ traceManager.openTrace(tb.trace);
+
+ TraceThread thread = addThread();
+ addRegisterValues(thread);
+ traceManager.activate(traceManager.resolveThread(thread).platform(toy));
+ waitForSwing();
+
+ assertEquals(DebuggerRegistersProvider.collectCommonRegisters(toy.getCompilerSpec()),
+ registersProvider.getSelectionFor(toy));
+ }
+}
diff --git a/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerRecorderRegistersProviderTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerRecorderRegistersProviderTest.java
new file mode 100644
index 0000000000..056d7f1e50
--- /dev/null
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerRecorderRegistersProviderTest.java
@@ -0,0 +1,105 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.register;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import generic.test.category.NightlyCategory;
+import ghidra.debug.api.control.ControlMode;
+import ghidra.debug.api.model.TraceRecorder;
+import ghidra.pcode.utils.Utils;
+import ghidra.program.model.data.DoubleDataType;
+
+@Category(NightlyCategory.class)
+public class DebuggerRecorderRegistersProviderTest extends AbstractDebuggerRegistersProviderTest {
+
+ @Test
+ public void testLiveAddValuesThenActivatePopulatesPanel() throws Throwable {
+ TraceRecorder recorder = recordAndWaitSync();
+ traceManager.openTrace(recorder.getTrace());
+ waitForSwing();
+
+ mb.testBank1.writeRegister("pc", new byte[] { 0x00, 0x40, 0x00, 0x00 });
+ waitForSwing();
+
+ activateThread(recorder.getTraceThread(mb.testThread1));
+ waitForSwing();
+
+ assertPCRowValuePopulated();
+ }
+
+ @Test
+ public void testLiveActivateThenAddValuesPopulatesPanel() throws Throwable {
+ TraceRecorder recorder = recordAndWaitSync();
+ traceManager.openTrace(recorder.getTrace());
+ activateThread(recorder.getTraceThread(mb.testThread1));
+ waitForSwing();
+
+ mb.testBank1.writeRegister("pc", new byte[] { 0x00, 0x40, 0x00, 0x00 });
+ waitRecorder(recorder);
+
+ RegisterRow rowL = findRegisterRow(pc);
+ waitForPass(() -> assertTrue(rowL.isKnown()));
+ assertPCRowValuePopulated();
+ }
+
+ @Test
+ public void testModifyValueLive() throws Throwable {
+ TraceRecorder recorder = recordAndWaitSync();
+ traceManager.openTrace(recorder.getTrace());
+ activateThread(recorder.getTraceThread(mb.testThread1));
+ waitForSwing();
+
+ controlService.setCurrentMode(tb.trace, ControlMode.RW_TARGET);
+
+ assertTrue(registersProvider.actionEnableEdits.isEnabled());
+ performAction(registersProvider.actionEnableEdits);
+
+ RegisterRow row = findRegisterRow(r0);
+
+ setRowText(row, "1234");
+ waitRecorder(recorder);
+ assertArrayEquals(new byte[] { 0, 0, 0, 0, 0, 0, 0x12, 0x34 },
+ mb.testBank1.regVals.get("r0"));
+ }
+
+ @Test
+ public void testModifyRepresentationLive() throws Throwable {
+ TraceRecorder recorder = recordAndWaitSync();
+ traceManager.openTrace(recorder.getTrace());
+ activateThread(recorder.getTraceThread(mb.testThread1));
+ waitForSwing();
+
+ controlService.setCurrentMode(tb.trace, ControlMode.RW_TARGET);
+
+ assertTrue(registersProvider.actionEnableEdits.isEnabled());
+ performAction(registersProvider.actionEnableEdits);
+
+ RegisterRow row = findRegisterRow(r0);
+ assertFalse(row.isRepresentationEditable());
+
+ row.setDataType(DoubleDataType.dataType);
+ waitForDomainObject(tb.trace);
+
+ setRowRepr(row, "1234");
+ waitRecorder(recorder);
+ assertEquals(encodeDouble(1234),
+ Utils.bytesToLong(mb.testBank1.regVals.get("r0"), 8, true));
+ }
+}
diff --git a/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerRmiRegistersProviderTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerRmiRegistersProviderTest.java
new file mode 100644
index 0000000000..68a18f7cf7
--- /dev/null
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerRmiRegistersProviderTest.java
@@ -0,0 +1,117 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.gui.register;
+
+import static org.junit.Assert.*;
+
+import java.util.*;
+
+import org.junit.Test;
+
+import db.Transaction;
+import ghidra.debug.api.control.ControlMode;
+import ghidra.pcode.utils.Utils;
+import ghidra.program.model.data.DoubleDataType;
+import ghidra.trace.model.Lifespan;
+import ghidra.trace.model.stack.TraceObjectStackFrame;
+import ghidra.trace.model.target.TraceObject;
+import ghidra.trace.model.thread.TraceObjectThread;
+
+public class DebuggerRmiRegistersProviderTest extends AbstractDebuggerRegistersProviderTest {
+
+ protected TraceObject setUpRmiTarget() throws Throwable {
+ createRmiConnection();
+ addRegisterMethods();
+ createTrace();
+ try (Transaction tx = tb.startTransaction()) {
+ tb.trace.getObjectManager().createRootObject(SCHEMA_SESSION);
+ tb.createObjectsProcessAndThreads();
+ tb.createObjectsFramesAndRegs(
+ tb.obj("Processes[1].Threads[1]").queryInterface(TraceObjectThread.class),
+ Lifespan.nowOn(0), tb.host, 2);
+ }
+ rmiCx.publishTarget(tool, tb.trace);
+ traceManager.openTrace(tb.trace);
+ traceManager.activateTrace(tb.trace);
+ return Objects.requireNonNull(tb.obj("Processes[1]"));
+ }
+
+ protected void handleReadRegsInvocation(TraceObject container) throws Throwable {
+ Map<String, Object> args = rmiMethodReadRegs.expect();
+ rmiMethodReadRegs.result(null);
+ assertEquals(Map.ofEntries(
+ Map.entry("container", container)),
+ args);
+ }
+
+ protected void handleWriteRegInvocation(TraceObjectStackFrame frame, String name, long value)
+ throws Throwable {
+ Map<String, Object> args = rmiMethodWriteReg.expect();
+ rmiMethodWriteReg.result(null);
+ assertEquals(Set.of("frame", "name", "value"), args.keySet());
+ assertEquals(frame.getObject(), args.get("frame"));
+ assertEquals("r0", args.get("name"));
+ assertEquals(value, Utils.bytesToLong((byte[]) args.get("value"), 8, true));
+ }
+
+ @Test
+ public void testReadLiveValuesOnActivate() throws Throwable {
+ setUpRmiTarget();
+ waitForSwing();
+
+ handleReadRegsInvocation(tb.obj("Processes[1].Threads[1].Stack[0].Registers"));
+ }
+
+ @Test
+ public void testModifyValueLive() throws Throwable {
+ setUpRmiTarget();
+ waitForSwing();
+
+ controlService.setCurrentMode(tb.trace, ControlMode.RW_TARGET);
+
+ assertTrue(registersProvider.actionEnableEdits.isEnabled());
+ performAction(registersProvider.actionEnableEdits);
+
+ RegisterRow row = findRegisterRow(r0);
+
+ setRowText(row, "1234");
+ handleWriteRegInvocation(
+ tb.obj("Processes[1].Threads[1].Stack[0]").queryInterface(TraceObjectStackFrame.class),
+ "r0", 0x1234);
+ }
+
+ @Test
+ public void testModifyRepresentationLive() throws Throwable {
+ setUpRmiTarget();
+ waitForSwing();
+
+ controlService.setCurrentMode(tb.trace, ControlMode.RW_TARGET);
+
+ assertTrue(registersProvider.actionEnableEdits.isEnabled());
+ performAction(registersProvider.actionEnableEdits);
+
+ RegisterRow row = findRegisterRow(r0);
+ assertFalse(row.isRepresentationEditable());
+
+ row.setDataType(DoubleDataType.dataType);
+ waitForDomainObject(tb.trace);
+
+ setRowRepr(row, "1234");
+ handleWriteRegInvocation(
+ tb.obj("Processes[1].Threads[1].Stack[0]").queryInterface(TraceObjectStackFrame.class),
+ "r0", encodeDouble(1234));
+ }
+}
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerRegistersProviderTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerTraceRegistersProviderTest.java
similarity index 72%
rename from Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerRegistersProviderTest.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerTraceRegistersProviderTest.java
index 75c3a0733d..3615d288a4 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerRegistersProviderTest.java
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerTraceRegistersProviderTest.java
@@ -19,30 +19,21 @@ import static ghidra.lifecycle.Unfinished.TODO;
import static org.junit.Assert.*;
import java.math.BigInteger;
-import java.nio.ByteBuffer;
-import java.util.*;
-import java.util.stream.Collectors;
+import java.util.List;
-import org.junit.*;
+import org.junit.Ignore;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import db.Transaction;
import generic.test.category.NightlyCategory;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
import ghidra.app.plugin.core.debug.gui.action.NoneLocationTrackingSpec;
-import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingPlugin;
import ghidra.app.plugin.core.debug.gui.register.DebuggerRegistersProvider.RegisterDataSettingsDialog;
import ghidra.app.plugin.core.debug.gui.register.DebuggerRegistersProvider.RegisterTableColumns;
-import ghidra.app.plugin.core.debug.service.control.DebuggerControlServicePlugin;
-import ghidra.app.services.*;
import ghidra.debug.api.control.ControlMode;
-import ghidra.debug.api.model.TraceRecorder;
import ghidra.docking.settings.FormatSettingsDefinition;
import ghidra.docking.settings.Settings;
-import ghidra.program.model.address.AddressSpace;
import ghidra.program.model.data.*;
-import ghidra.program.model.lang.Register;
-import ghidra.program.model.util.CodeUnitInsertionException;
import ghidra.trace.database.ToyDBTraceBuilder;
import ghidra.trace.database.listing.DBTraceCodeSpace;
import ghidra.trace.model.Lifespan;
@@ -51,203 +42,9 @@ import ghidra.trace.model.listing.*;
import ghidra.trace.model.memory.TraceMemoryFlag;
import ghidra.trace.model.memory.TraceMemorySpace;
import ghidra.trace.model.thread.TraceThread;
-import ghidra.util.exception.DuplicateNameException;
-@Category(NightlyCategory.class) // this may actually be an @PortSensitive test
-public class DebuggerRegistersProviderTest extends AbstractGhidraHeadedDebuggerGUITest {
-
- protected DebuggerRegistersPlugin registersPlugin;
- protected DebuggerRegistersProvider registersProvider;
- protected DebuggerListingPlugin listingPlugin;
- protected DebuggerControlService editingService;
-
- protected Register r0;
- protected Register pc;
- protected Register sp;
- protected Register contextreg;
-
- protected Register r0h;
- protected Register r0l;
- protected Register pch;
- protected Register pcl;
-
- protected Set<Register> baseRegs;
-
- protected StructureDataType r0Struct;
-
- @Before
- public void setUpRegistersProviderTest() throws Exception {
- registersPlugin = addPlugin(tool, DebuggerRegistersPlugin.class);
- registersProvider = waitForComponentProvider(DebuggerRegistersProvider.class);
- listingPlugin = addPlugin(tool, DebuggerListingPlugin.class);
- editingService = addPlugin(tool, DebuggerControlServicePlugin.class);
-
- createTrace();
- r0 = tb.language.getRegister("r0");
- pc = tb.language.getProgramCounter();
- sp = tb.language.getDefaultCompilerSpec().getStackPointer();
- contextreg = tb.language.getContextBaseRegister();
-
- pch = tb.language.getRegister("pch");
- pcl = tb.language.getRegister("pcl");
-
- r0h = tb.language.getRegister("r0h");
- r0l = tb.language.getRegister("r0l");
-
- r0Struct = new StructureDataType("r0_struct", 0);
- r0Struct.add(SignedDWordDataType.dataType, "hi", "");
- r0Struct.add(DWordDataType.dataType, "lo", "");
-
- baseRegs = tb.language.getRegisters()
- .stream()
- .filter(Register::isBaseRegister)
- .collect(Collectors.toSet());
- }
-
- protected TraceThread addThread() throws DuplicateNameException {
- return addThread("Thread1");
- }
-
- protected TraceThread addThread(String threadName) throws DuplicateNameException {
- try (Transaction tx = tb.startTransaction()) {
- return tb.trace.getThreadManager().createThread(threadName, 0);
- }
- }
-
- protected TracePlatform getPlatform() {
- return tb.host;
- }
-
- protected void activateThread(TraceThread thread) {
- traceManager.activateThread(thread);
- }
-
- protected void addRegisterValues(TraceThread thread) {
- try (Transaction tx = tb.startTransaction()) {
- addRegisterValues(thread, tx);
- }
- }
-
- protected void addRegisterValues(TraceThread thread, Transaction tx) {
- TraceMemorySpace regVals =
- tb.trace.getMemoryManager().getMemoryRegisterSpace(thread, true);
- regVals.putBytes(0, pc, tb.buf(0, 0, 0, 0, 0, 0x40, 0, 0));
- regVals.putBytes(0, sp, tb.buf(0x1f, 0, 0, 0, 0, 0, 0, 0));
- regVals.putBytes(0, r0, tb.buf(1, 2, 3, 4, 5, 6, 7, 8));
- }
-
- protected void addRegisterTypes(TraceThread thread, Transaction tx)
- throws CodeUnitInsertionException {
- TraceCodeSpace regCode =
- tb.trace.getCodeManager().getCodeRegisterSpace(thread, true);
- DataTypeManager dtm = tb.trace.getDataTypeManager();
- AddressSpace space = tb.host.getAddressFactory().getDefaultAddressSpace();
- PointerTypedef ramPtr = new PointerTypedef(null, VoidDataType.dataType, -1, dtm, space);
- regCode.definedData().create(getPlatform(), Lifespan.nowOn(0), pc, ramPtr);
- regCode.definedData().create(getPlatform(), Lifespan.nowOn(0), r0, r0Struct);
- }
-
- protected void addRegisterTypes(TraceThread thread) throws CodeUnitInsertionException {
- try (Transaction tx = tb.startTransaction()) {
- addRegisterTypes(thread, tx);
- }
- }
-
- protected RegisterRow findRegisterRow(Register reg) {
- RegisterRow row = getRegisterRow(reg);
- if (row == null) {
- throw new NoSuchElementException(reg.getName());
- }
- return row;
- }
-
- protected RegisterRow getRegisterRow(Register reg) {
- return registersProvider.regMap.get(reg);
- }
-
- protected void setRowText(RegisterRow row, String text) {
- assertTrue(row.isValueEditable());
- row.setValue(new BigInteger(text, 16));
- }
-
- protected void setRowRepr(RegisterRow row, String repr) {
- assertTrue(row.isRepresentationEditable());
- row.setRepresentation(repr);
- }
-
- protected void assertRowValueEmpty(RegisterRow row) {
- assertEquals(BigInteger.ZERO, row.getValue());
- }
-
- protected void assertRowTypeEmpty(RegisterRow row) {
- assertNull(row.getDataType());
- }
-
- protected void assertPCRowValueEmpty() {
- assertRowValueEmpty(findRegisterRow(pc));
- }
-
- protected void assertPCRowTypeEmpty() {
- assertRowTypeEmpty(findRegisterRow(pc));
- }
-
- protected void assertR0RowValueEmpty() {
- assertRowValueEmpty(findRegisterRow(r0));
- }
-
- protected void assertR0RowTypeEmpty() {
- assertRowTypeEmpty(findRegisterRow(r0));
- }
-
- protected void assertPCRowValuePopulated() {
- RegisterRow row = findRegisterRow(pc);
- assertEquals(0x00400000, row.getValue().longValue());
-
- RegisterRow rowH = findRegisterRow(pch);
- assertEquals(0x00000000, rowH.getValue().longValue());
-
- RegisterRow rowL = findRegisterRow(pcl);
- assertEquals(0x00400000, rowL.getValue().longValue());
- }
-
- protected void assertPCRowTypePopulated() {
- RegisterRow row = findRegisterRow(pc);
- assertTypeEquals(PointerDataType.dataType, row.getDataType());
-
- //assertTrue(row.data.getValue() instanceof Address);
- //Address pcAddr = (Address) row.data.getValue();
- //assertEquals("ram", pcAddr.getAddressSpace().getName());
- //assertEquals(0x00400000, pcAddr.getOffset());
- //assertEquals("<INVALID>", row.reprField.getText()); // No memory layout is provided
-
- RegisterRow rowH = findRegisterRow(pch);
- assertNull(rowH.getDataType());
-
- RegisterRow rowL = findRegisterRow(pcl);
- assertNull(rowL.getDataType());
- }
-
- protected void assertR0RowValuePopulated() {
- RegisterRow row = findRegisterRow(r0);
- assertEquals(0x0102030405060708L, row.getValue().longValue());
-
- RegisterRow rowL = findRegisterRow(r0l);
- assertEquals(0x05060708, rowL.getValue().longValue());
-
- RegisterRow rowH = findRegisterRow(r0h);
- assertEquals(0x01020304, rowH.getValue().longValue());
- }
-
- protected void assertR0RowTypePopulated() {
- RegisterRow row = findRegisterRow(r0);
- assertTypeEquals(r0Struct, row.getDataType());
-
- RegisterRow rowL = findRegisterRow(r0l);
- assertTypeEquals(DWordDataType.dataType, rowL.getDataType());
-
- RegisterRow rowH = findRegisterRow(r0h);
- assertTypeEquals(SignedDWordDataType.dataType, rowH.getDataType());
- }
+@Category(NightlyCategory.class)
+public class DebuggerTraceRegistersProviderTest extends AbstractDebuggerRegistersProviderTest {
@Test
public void testEmpty() throws Exception {
@@ -299,36 +96,6 @@ public class DebuggerRegistersProviderTest extends AbstractGhidraHeadedDebuggerG
assertR0RowValuePopulated();
}
- @Test
- public void testLiveAddValuesThenActivatePopulatesPanel() throws Throwable {
- TraceRecorder recorder = recordAndWaitSync();
- traceManager.openTrace(recorder.getTrace());
- waitForSwing();
-
- mb.testBank1.writeRegister("pc", new byte[] { 0x00, 0x40, 0x00, 0x00 });
- waitForSwing();
-
- activateThread(recorder.getTraceThread(mb.testThread1));
- waitForSwing();
-
- assertPCRowValuePopulated();
- }
-
- @Test
- public void testLiveActivateThenAddValuesPopulatesPanel() throws Throwable {
- TraceRecorder recorder = recordAndWaitSync();
- traceManager.openTrace(recorder.getTrace());
- activateThread(recorder.getTraceThread(mb.testThread1));
- waitForSwing();
-
- mb.testBank1.writeRegister("pc", new byte[] { 0x00, 0x40, 0x00, 0x00 });
- waitRecorder(recorder);
-
- RegisterRow rowL = findRegisterRow(pc);
- waitForPass(() -> assertTrue(rowL.isKnown()));
- assertPCRowValuePopulated();
- }
-
@Test
public void testActivateThenAddValuesPopulatesPanel() throws Exception {
traceManager.openTrace(tb.trace);
@@ -384,7 +151,7 @@ public class DebuggerRegistersProviderTest extends AbstractGhidraHeadedDebuggerG
activateThread(thread);
waitForSwing();
- editingService.setCurrentMode(tb.trace, ControlMode.RW_EMULATOR);
+ controlService.setCurrentMode(tb.trace, ControlMode.RW_EMULATOR);
assertTrue(registersProvider.actionEnableEdits.isEnabled());
performAction(registersProvider.actionEnableEdits);
@@ -408,12 +175,6 @@ public class DebuggerRegistersProviderTest extends AbstractGhidraHeadedDebuggerG
});
}
- long encodeDouble(double value) {
- ByteBuffer buf = ByteBuffer.allocate(Double.BYTES);
- buf.putDouble(0, value);
- return buf.getLong(0);
- }
-
@Test
public void testModifyRepresentationEmu() throws Exception {
traceManager.openTrace(tb.trace);
@@ -422,7 +183,7 @@ public class DebuggerRegistersProviderTest extends AbstractGhidraHeadedDebuggerG
activateThread(thread);
waitForSwing();
- editingService.setCurrentMode(tb.trace, ControlMode.RW_EMULATOR);
+ controlService.setCurrentMode(tb.trace, ControlMode.RW_EMULATOR);
assertTrue(registersProvider.actionEnableEdits.isEnabled());
performAction(registersProvider.actionEnableEdits);
@@ -450,8 +211,6 @@ public class DebuggerRegistersProviderTest extends AbstractGhidraHeadedDebuggerG
});
}
- // NOTE: Value modification only allowed on live target
-
@Test
public void testModifyTypeAffectsTrace() throws Exception {
traceManager.openTrace(tb.trace);
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/breakpoint/DebuggerLogicalBreakpointServiceTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/service/breakpoint/AbstractDebuggerLogicalBreakpointServiceTest.java
similarity index 73%
rename from Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/breakpoint/DebuggerLogicalBreakpointServiceTest.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/service/breakpoint/AbstractDebuggerLogicalBreakpointServiceTest.java
index 790ac2d4f8..7fd2058274 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/breakpoint/DebuggerLogicalBreakpointServiceTest.java
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/service/breakpoint/AbstractDebuggerLogicalBreakpointServiceTest.java
@@ -19,27 +19,21 @@ import static org.junit.Assert.*;
import java.util.*;
import java.util.Map.Entry;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.CompletableFuture;
import org.junit.*;
import db.Transaction;
import generic.Unique;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerIntegrationTest;
import ghidra.app.plugin.core.debug.service.control.DebuggerControlServicePlugin;
import ghidra.app.plugin.core.debug.service.modules.DebuggerStaticMappingUtils;
import ghidra.app.services.*;
import ghidra.async.AsyncReference;
-import ghidra.dbg.model.TestTargetMemoryRegion;
-import ghidra.dbg.model.TestTargetProcess;
-import ghidra.dbg.target.*;
-import ghidra.dbg.target.TargetBreakpointSpec.TargetBreakpointKind;
-import ghidra.debug.api.action.ActionSource;
import ghidra.debug.api.breakpoint.LogicalBreakpoint;
import ghidra.debug.api.breakpoint.LogicalBreakpoint.State;
import ghidra.debug.api.breakpoint.LogicalBreakpointsChangeListener;
import ghidra.debug.api.control.ControlMode;
-import ghidra.debug.api.model.TraceRecorder;
import ghidra.debug.api.modules.DebuggerStaticMappingChangeListener;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.Bookmark;
@@ -50,11 +44,13 @@ import ghidra.trace.model.*;
import ghidra.trace.model.breakpoint.*;
import ghidra.trace.model.memory.TraceMemoryFlag;
import ghidra.trace.model.memory.TraceMemoryRegion;
-import ghidra.trace.model.modules.TraceStaticMapping;
import ghidra.util.Msg;
import ghidra.util.SystemUtilities;
+import utility.function.ExceptionalCallback;
+import utility.function.ExceptionalSupplier;
-public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDebuggerGUITest {
+public abstract class AbstractDebuggerLogicalBreakpointServiceTest<T, MR>
+ extends AbstractGhidraHeadedDebuggerIntegrationTest {
protected static final long TIMEOUT_MILLIS =
SystemUtilities.isInTestingBatchMode() ? 5000 : Long.MAX_VALUE;
@@ -66,7 +62,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
* double-removes. 3) No extraneous updates. At the end of each test, the current set of
* breakpoints in this listener should be verified against those reported by the service.
*/
- protected class NoDuplicatesTrackingChangeListener implements LogicalBreakpointsChangeListener {
+ protected class NoDuplicatesBreakpointsChangeListener
+ implements LogicalBreakpointsChangeListener {
private Set<LogicalBreakpoint> current = new HashSet<>();
@Override
@@ -105,26 +102,18 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
}
}
- protected interface ExceptionalSupplier<T, E extends Throwable> {
- T get() throws E;
- }
-
- protected interface ExceptionalRunnable<E extends Throwable> {
- void run() throws E;
- }
-
- protected <T, E extends Throwable> T expectMappingChange(ExceptionalSupplier<T, E> supplier)
+ protected <U, E extends Throwable> U expectMappingChange(ExceptionalSupplier<U, E> supplier)
throws Throwable {
mappingChangeListener.ar.set(false, null);
- T result = supplier.get();
+ U result = supplier.get();
waitOn(mappingChangeListener.ar.waitValue(true));
return result;
}
- protected <E extends Throwable> void expectMappingChange(ExceptionalRunnable<E> runnable)
+ protected <E extends Throwable> void expectMappingChange(ExceptionalCallback<E> runnable)
throws Throwable {
expectMappingChange(() -> {
- runnable.run();
+ runnable.call();
return null;
});
}
@@ -132,8 +121,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
protected DebuggerStaticMappingService mappingService;
protected DebuggerLogicalBreakpointService breakpointService;
- protected TraceRecorder recorder1;
- protected TraceRecorder recorder3;
+ protected T target1;
+ protected T target3;
protected Bookmark enBm;
protected Bookmark disBm;
@@ -143,11 +132,49 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
protected TraceBreakpointManager breakpointManager;
- protected NoDuplicatesTrackingChangeListener changeListener =
- new NoDuplicatesTrackingChangeListener();
+ protected NoDuplicatesBreakpointsChangeListener changeListener =
+ new NoDuplicatesBreakpointsChangeListener();
protected ForTimingMappingChangeListener mappingChangeListener =
new ForTimingMappingChangeListener();
+ protected abstract void createTarget1() throws Throwable;
+
+ protected abstract void createTarget3() throws Throwable;
+
+ protected abstract void simulateTargetStep(T t) throws Throwable;
+
+ protected abstract Trace getTrace(T t);
+
+ protected abstract long getSnap(T t);
+
+ protected abstract boolean isTargetValid(T t);
+
+ protected abstract MR addTargetTextRegion(T t, long offset) throws Throwable;
+
+ protected abstract MR addTargetTextRegion(T t) throws Throwable;
+
+ protected abstract MR addTargetDataRegion(T t) throws Throwable;
+
+ protected abstract void addTextMapping(T t, MR text, Program program) throws Throwable;
+
+ protected abstract void removeTextMapping(T t, Program program) throws Throwable;
+
+ protected abstract void addTargetSoftwareBreakpoint(T t, MR region) throws Throwable;
+
+ protected abstract void removeTargetSoftwareBreakpoint(T t) throws Throwable;
+
+ protected abstract void addTargetAccessBreakpoint(T t, MR region) throws Throwable;
+
+ protected abstract void terminateTarget(T t);
+
+ protected abstract TraceBreakpoint findLoc(Set<TraceBreakpoint> locs, int index);
+
+ protected abstract void handleToggleBreakpointInvocation(TraceBreakpoint expectedBreakpoint,
+ boolean expectedEnabled) throws Throwable;
+
+ protected abstract void handleDeleteBreakpointInvocation(TraceBreakpoint expectedBreakpoint)
+ throws Throwable;
+
@Before
public void setUpBreakpointServiceTest() throws Throwable {
addPlugin(tool, DebuggerLogicalBreakpointServicePlugin.class);
@@ -156,42 +183,23 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
breakpointService.addChangeListener(changeListener);
mappingService.addChangeListener(mappingChangeListener);
-
- // NOTE: Traces derive from recordings, not toy builder
- // NOTE: Program must be saved into project so it has a URL for mappings
- createTestModel();
- mb.createTestProcessesAndThreads();
-
- // Unfinished.ignoreTODO();
- }
-
- public void startRecorder1() throws Throwable {
- recorder1 = modelService.recordTarget(mb.testProcess1,
- createTargetTraceMapper(mb.testProcess1), ActionSource.AUTOMATIC);
- }
-
- public void startRecorder3() throws Throwable {
- recorder3 = modelService.recordTarget(mb.testProcess3,
- createTargetTraceMapper(mb.testProcess3), ActionSource.AUTOMATIC);
}
@After
public void tearDownBreakpointServiceTest() throws Throwable {
Msg.debug(this, "Tearing down");
try {
- waitRecorder(recorder1);
- waitRecorder(recorder3);
waitForProgram(program);
assertServiceAgreesWithOpenProgramsAndTraces();
changeListener.assertAgreesWithService();
- if (recorder1 != null && recorder1.isRecording()) {
- waitForLock(recorder1.getTrace());
- recorder1.stopRecording();
+ if (target1 != null && isTargetValid(target1)) {
+ waitForLock(getTrace(target1));
+ terminateTarget(target1);
}
- if (recorder3 != null && recorder3.isRecording()) {
- waitForLock(recorder3.getTrace());
- recorder3.stopRecording();
+ if (target3 != null && isTargetValid(target3)) {
+ waitForLock(getTrace(target3));
+ terminateTarget(target3);
}
}
catch (Throwable t) {
@@ -263,80 +271,6 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
}
}
- protected TestTargetMemoryRegion addTargetDataRegion(TestTargetProcess p) {
- return p.addRegion("bin:.data", mb.rng(0x56550000, 0x5655ffff), "rw");
- }
-
- protected TestTargetMemoryRegion addTargetTextRegion(TestTargetProcess p) {
- return addTargetTextRegion(p, 0x55550000);
- }
-
- protected TestTargetMemoryRegion addTargetTextRegion(TestTargetProcess p, long offset) {
- return p.addRegion("bin:.text", mb.rng(offset, offset + 0x0fff), "rx");
- }
-
- protected void addTextMapping(TraceRecorder r, TestTargetMemoryRegion region, Program p)
- throws Throwable {
- Trace t = r.getTrace();
- TraceMemoryRegion textRegion =
- waitFor(() -> r.getTraceMemoryRegion(region), "Recorder missed region: " + region);
- try (Transaction tx = t.openTransaction("Add .text mapping")) {
- DebuggerStaticMappingUtils.addMapping(
- new DefaultTraceLocation(t, null, textRegion.getLifespan(),
- textRegion.getMinAddress()),
- new ProgramLocation(p, addr(p, 0x00400000)), 0x1000, false);
- }
- }
-
- protected void removeTextMapping(TraceRecorder r, Program p) throws Throwable {
- Trace t = r.getTrace();
- try (Transaction tx = t.openTransaction("Remove .text mapping")) {
- TraceStaticMapping mapping =
- t.getStaticMappingManager().findContaining(addr(t, 0x55550000), r.getSnap());
- mapping.delete();
- }
- }
-
- protected void addTargetAccessBreakpoint(TraceRecorder r, TestTargetMemoryRegion region)
- throws Throwable {
- TraceMemoryRegion traceRegion =
- waitFor(() -> r.getTraceMemoryRegion(region), "Recorder missed region: " + region);
- long offset = traceRegion.getMinAddress().getOffset() + 0x0123;
- TargetBreakpointSpecContainer cont = getBreakpointContainer(r);
- cont.placeBreakpoint(mb.addr(offset),
- Set.of(TargetBreakpointKind.READ, TargetBreakpointKind.WRITE))
- .get(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
- }
-
- protected void addTargetSoftwareBreakpoint(TraceRecorder r, TestTargetMemoryRegion region)
- throws Throwable {
- TraceMemoryRegion traceRegion =
- waitFor(() -> r.getTraceMemoryRegion(region), "Recorder missed region: " + region);
- long offset = traceRegion.getMinAddress().getOffset() + 0x0123;
- TargetBreakpointSpecContainer cont = getBreakpointContainer(r);
- cont.placeBreakpoint(mb.addr(offset), Set.of(TargetBreakpointKind.SW_EXECUTE))
- .get(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
- }
-
- protected void removeTargetSoftwareBreakpoint(TraceRecorder r) throws Throwable {
- TargetBreakpointSpecContainer cont = getBreakpointContainer(r);
- cont.fetchElements().thenAccept(elements -> {
- for (TargetObject obj : elements.values()) {
- if (!(obj instanceof TargetBreakpointSpec) || !(obj instanceof TargetDeletable)) {
- continue;
- }
- TargetBreakpointSpec spec = (TargetBreakpointSpec) obj;
- if (!spec.getKinds().contains(TargetBreakpointKind.SW_EXECUTE)) {
- continue;
- }
- TargetDeletable del = (TargetDeletable) obj;
- del.delete();
- return;
- }
- fail("No deletable software breakpoint spec found");
- }).get(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
- }
-
protected void addProgramBreakpoints(Program p) throws Throwable {
try (Transaction tx = p.openTransaction("Create bookmarks")) {
enBm = p.getBookmarkManager()
@@ -545,12 +479,12 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testRecordTraceThenOpenTraceThenAddBreakpoint() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
- TestTargetMemoryRegion data = addTargetDataRegion(mb.testProcess1);
- addTargetAccessBreakpoint(recorder1, data);
+ MR data = addTargetDataRegion(target1);
+ addTargetAccessBreakpoint(target1, data);
waitForPass(() -> {
assertLogicalBreakpointForLoneAccessBreakpoint(trace);
@@ -559,12 +493,11 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testRecordTraceThenAddBreakpointThenOpenTrace() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
- TestTargetMemoryRegion data = addTargetDataRegion(mb.testProcess1);
- addTargetAccessBreakpoint(recorder1, data);
- waitForDomainObject(trace);
+ MR data = addTargetDataRegion(target1);
+ addTargetAccessBreakpoint(target1, data);
traceManager.openTrace(trace);
waitForSwing();
@@ -590,8 +523,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testRecordTraceThenOpenEmptyProgram() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
createProgramFromTrace(trace);
@@ -603,8 +536,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testRecordTraceThenOpenProgramThenAddMapping() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
createProgramFromTrace(trace);
@@ -612,8 +545,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
programManager.openProgram(program);
addProgramTextBlock(program);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
- expectMappingChange(() -> addTextMapping(recorder1, text, program));
+ MR text = addTargetTextRegion(target1);
+ expectMappingChange(() -> addTextMapping(target1, text, program));
waitForSwing();
assertTrue(breakpointService.getAllBreakpoints().isEmpty());
@@ -621,8 +554,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testRecordTraceThenOpenProgramThenAddMappingThenAddBookmarks() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
createProgramFromTrace(trace);
@@ -630,8 +563,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
programManager.openProgram(program);
addProgramTextBlock(program);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
- expectMappingChange(() -> addTextMapping(recorder1, text, program));
+ MR text = addTargetTextRegion(target1);
+ expectMappingChange(() -> addTextMapping(target1, text, program));
addProgramBreakpoints(program);
waitForSwing();
@@ -640,8 +573,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testRecordTraceThenOpenProgramThenAddBookmarksThenAddMapping() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
createProgramFromTrace(trace);
@@ -649,13 +582,13 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
programManager.openProgram(program);
addProgramTextBlock(program);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
+ MR text = addTargetTextRegion(target1);
addProgramBreakpoints(program);
waitForSwing();
changeListener.assertAgreesWithService();
- expectMappingChange(() -> addTextMapping(recorder1, text, program));
+ expectMappingChange(() -> addTextMapping(target1, text, program));
waitForSwing();
assertLogicalBreakpointsForMappedBookmarks(trace);
@@ -663,8 +596,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testRecordTraceThenOpenProgramThenAddMappingThenAddBreakpoint() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
createProgramFromTrace(trace);
@@ -672,9 +605,9 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
programManager.openProgram(program);
addProgramTextBlock(program);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
- expectMappingChange(() -> addTextMapping(recorder1, text, program));
- addTargetSoftwareBreakpoint(recorder1, text);
+ MR text = addTargetTextRegion(target1);
+ expectMappingChange(() -> addTextMapping(target1, text, program));
+ addTargetSoftwareBreakpoint(target1, text);
waitForPass(() -> {
assertLogicalBreakpointForMappedSoftwareBreakpoint(trace);
@@ -683,8 +616,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testRecordTraceThenOpenProgramThenAddBreakpointThenAddMapping() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
createProgramFromTrace(trace);
@@ -692,15 +625,15 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
programManager.openProgram(program);
addProgramTextBlock(program);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
- addTargetSoftwareBreakpoint(recorder1, text);
+ MR text = addTargetTextRegion(target1);
+ addTargetSoftwareBreakpoint(target1, text);
waitForPass(() -> {
assertLogicalBreakpointForLoneSoftwareBreakpoint(trace, 1);
});
changeListener.assertAgreesWithService();
- expectMappingChange(() -> addTextMapping(recorder1, text, program));
+ expectMappingChange(() -> addTextMapping(target1, text, program));
waitForSwing();
assertLogicalBreakpointForMappedSoftwareBreakpoint(trace);
@@ -708,8 +641,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testOpenProgramThenAddBookmarksThenRecordTraceThenAddMapping() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
// delay opening
createProgramFromTrace(trace);
@@ -725,9 +658,9 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
traceManager.openTrace(trace);
// NOTE: Extraneous mappings-changed events can cause timing issues here.
- // TODO: Button down testing for static mapping listener events
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
- expectMappingChange(() -> addTextMapping(recorder1, text, program));
+ // TODO: Better testing for static mapping listener events?
+ MR text = addTargetTextRegion(target1);
+ expectMappingChange(() -> addTextMapping(target1, text, program));
waitForSwing();
assertLogicalBreakpointsForMappedBookmarks(trace);
@@ -735,8 +668,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testRecordTraceThenAddMappingThenOpenProgramWithBookmark() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
createProgramFromTrace(trace);
@@ -744,8 +677,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
// delay opening
addProgramTextBlock(program);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
- addTextMapping(recorder1, text, program);
+ MR text = addTargetTextRegion(target1);
+ addTextMapping(target1, text, program);
addProgramBreakpoints(program);
waitForSwing();
@@ -759,8 +692,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testRecordTraceThenAddMappingThenAddBreakpointThenOpenProgram() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
createProgramFromTrace(trace);
@@ -768,9 +701,9 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
// delay opening
addProgramTextBlock(program);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
- addTextMapping(recorder1, text, program);
- addTargetSoftwareBreakpoint(recorder1, text);
+ MR text = addTargetTextRegion(target1);
+ addTextMapping(target1, text, program);
+ addTargetSoftwareBreakpoint(target1, text);
waitForPass(() -> assertLogicalBreakpointForLoneSoftwareBreakpoint(trace, 1));
@@ -782,8 +715,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testRecordTraceThenOpenProgramThenCloseProgram() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
createProgramFromTrace(trace);
@@ -801,8 +734,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testRecordTraceThenOpenProgramThenCloseAndStopTrace() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
createProgramFromTrace(trace);
@@ -813,7 +746,7 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
assertTrue(breakpointService.getAllBreakpoints().isEmpty());
traceManager.closeTrace(trace);
- recorder1.stopRecording();
+ terminateTarget(target1);
waitForSwing();
assertTrue(breakpointService.getAllBreakpoints().isEmpty());
@@ -822,8 +755,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testRecordTraceThenOpenProgramThenAddBookmarksThenAddMappingThenRemoveBookmark()
throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
createProgramFromTrace(trace);
@@ -832,8 +765,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
addProgramTextBlock(program);
addProgramBreakpoints(program);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
- expectMappingChange(() -> addTextMapping(recorder1, text, program));
+ MR text = addTargetTextRegion(target1);
+ expectMappingChange(() -> addTextMapping(target1, text, program));
waitForSwing();
assertLogicalBreakpointsForMappedBookmarks(trace);
@@ -847,8 +780,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testRecordTraceThenOpenProgramThenAddBookmarksThenAddMappingThenRemoveMapping()
throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
createProgramFromTrace(trace);
@@ -857,13 +790,13 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
addProgramTextBlock(program);
addProgramBreakpoints(program);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
- expectMappingChange(() -> addTextMapping(recorder1, text, program));
+ MR text = addTargetTextRegion(target1);
+ expectMappingChange(() -> addTextMapping(target1, text, program));
waitForSwing();
assertLogicalBreakpointsForMappedBookmarks(trace);
- expectMappingChange(() -> removeTextMapping(recorder1, program));
+ expectMappingChange(() -> removeTextMapping(target1, program));
waitForSwing();
assertLogicalBreakpointsForUnmappedBookmarks();
@@ -873,25 +806,25 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testRecordTraceThenAddBreakpointThenOpenProgramThenAddMappingThenRemoveBreakpoint()
throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
- addTargetSoftwareBreakpoint(recorder1, text);
+ MR text = addTargetTextRegion(target1);
+ addTargetSoftwareBreakpoint(target1, text);
createProgramFromTrace(trace);
intoProject(program);
programManager.openProgram(program);
addProgramTextBlock(program);
- expectMappingChange(() -> addTextMapping(recorder1, text, program));
+ expectMappingChange(() -> addTextMapping(target1, text, program));
waitForSwing();
assertLogicalBreakpointForMappedSoftwareBreakpoint(trace);
assertServiceAgreesWithOpenProgramsAndTraces();
- removeTargetSoftwareBreakpoint(recorder1);
+ removeTargetSoftwareBreakpoint(target1);
waitForPass(() -> {
// NB. The bookmark remains
@@ -903,25 +836,25 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testRecordTraceThenAddBreakpointThenOpenProgramThenAddMappingThenRemoveMapping()
throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
- addTargetSoftwareBreakpoint(recorder1, text);
+ MR text = addTargetTextRegion(target1);
+ addTargetSoftwareBreakpoint(target1, text);
createProgramFromTrace(trace);
intoProject(program);
programManager.openProgram(program);
addProgramTextBlock(program);
- expectMappingChange(() -> addTextMapping(recorder1, text, program));
+ expectMappingChange(() -> addTextMapping(target1, text, program));
waitForSwing();
assertLogicalBreakpointForMappedSoftwareBreakpoint(trace);
assertServiceAgreesWithOpenProgramsAndTraces();
- expectMappingChange(() -> removeTextMapping(recorder1, program));
+ expectMappingChange(() -> removeTextMapping(target1, program));
waitForSwing();
// NB. Bookmark remains
@@ -930,12 +863,12 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testFill1Program2Traces() throws Throwable {
- startRecorder1();
- Trace trace1 = recorder1.getTrace();
+ createTarget1();
+ Trace trace1 = getTrace(target1);
traceManager.openTrace(trace1);
- startRecorder3();
- Trace trace3 = recorder3.getTrace();
+ createTarget3();
+ Trace trace3 = getTrace(target3);
traceManager.openTrace(trace3);
createProgramFromTrace(trace1); // Also suitable for trace3
@@ -943,11 +876,11 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
programManager.openProgram(program);
addProgramTextBlock(program);
- TestTargetMemoryRegion text1 = addTargetTextRegion(mb.testProcess1);
- TestTargetMemoryRegion text3 = addTargetTextRegion(mb.testProcess3, 0x55551000);
+ MR text1 = addTargetTextRegion(target1);
+ MR text3 = addTargetTextRegion(target3, 0x55551000);
- addTextMapping(recorder1, text1, program);
- addTextMapping(recorder3, text3, program);
+ addTextMapping(target1, text1, program);
+ addTextMapping(target3, text3, program);
waitForSwing();
waitForPass(() -> {
assertEquals(2,
@@ -959,10 +892,9 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
waitForSwing();
addProgramBreakpoints(program);
- addTargetSoftwareBreakpoint(recorder1, text1);
- addTargetSoftwareBreakpoint(recorder3, text3);
+ addTargetSoftwareBreakpoint(target1, text1);
+ addTargetSoftwareBreakpoint(target3, text3);
- // NB. Model events in own thread, recorder transactions in another
waitForPass(() -> {
assertLogicalBreakpointForMappedBookmarkAnd2TraceBreakpoints(trace1, trace3);
});
@@ -970,12 +902,12 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testFill1Program2TracesThenCloseProgram() throws Throwable {
- startRecorder1();
- Trace trace1 = recorder1.getTrace();
+ createTarget1();
+ Trace trace1 = getTrace(target1);
traceManager.openTrace(trace1);
- startRecorder3();
- Trace trace3 = recorder3.getTrace();
+ createTarget3();
+ Trace trace3 = getTrace(target3);
traceManager.openTrace(trace3);
createProgramFromTrace(trace1); // Also suitable for trace3
@@ -983,11 +915,11 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
programManager.openProgram(program);
addProgramTextBlock(program);
- TestTargetMemoryRegion text1 = addTargetTextRegion(mb.testProcess1);
- TestTargetMemoryRegion text3 = addTargetTextRegion(mb.testProcess3, 0x55551000);
+ MR text1 = addTargetTextRegion(target1);
+ MR text3 = addTargetTextRegion(target3, 0x55551000);
- addTextMapping(recorder1, text1, program);
- addTextMapping(recorder3, text3, program);
+ addTextMapping(target1, text1, program);
+ addTextMapping(target3, text3, program);
waitForSwing();
waitForPass(() -> {
assertEquals(2,
@@ -999,8 +931,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
waitForSwing();
addProgramBreakpoints(program);
- addTargetSoftwareBreakpoint(recorder1, text1);
- addTargetSoftwareBreakpoint(recorder3, text3);
+ addTargetSoftwareBreakpoint(target1, text1);
+ addTargetSoftwareBreakpoint(target3, text3);
waitForPass(() -> {
assertLogicalBreakpointForMappedBookmarkAnd2TraceBreakpoints(trace1, trace3);
@@ -1015,12 +947,12 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testFill1Program2TracesThenCloseProgramThenReopenProgram() throws Throwable {
- startRecorder1();
- Trace trace1 = recorder1.getTrace();
+ createTarget1();
+ Trace trace1 = getTrace(target1);
traceManager.openTrace(trace1);
- startRecorder3();
- Trace trace3 = recorder3.getTrace();
+ createTarget3();
+ Trace trace3 = getTrace(target3);
traceManager.openTrace(trace3);
createProgramFromTrace(trace1); // Also suitable for trace3
@@ -1028,11 +960,11 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
programManager.openProgram(program);
addProgramTextBlock(program);
- TestTargetMemoryRegion text1 = addTargetTextRegion(mb.testProcess1);
- TestTargetMemoryRegion text3 = addTargetTextRegion(mb.testProcess3, 0x55551000);
+ MR text1 = addTargetTextRegion(target1);
+ MR text3 = addTargetTextRegion(target3, 0x55551000);
- addTextMapping(recorder1, text1, program);
- addTextMapping(recorder3, text3, program);
+ addTextMapping(target1, text1, program);
+ addTextMapping(target3, text3, program);
waitForSwing();
waitForPass(() -> {
assertEquals(2,
@@ -1044,8 +976,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
waitForSwing();
addProgramBreakpoints(program);
- addTargetSoftwareBreakpoint(recorder1, text1);
- addTargetSoftwareBreakpoint(recorder3, text3);
+ addTargetSoftwareBreakpoint(target1, text1);
+ addTargetSoftwareBreakpoint(target3, text3);
waitForPass(() -> {
assertLogicalBreakpointForMappedBookmarkAnd2TraceBreakpoints(trace1, trace3);
@@ -1069,12 +1001,12 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testFill1Program2TracesThenStop1Trace() throws Throwable {
- startRecorder1();
- Trace trace1 = recorder1.getTrace();
+ createTarget1();
+ Trace trace1 = getTrace(target1);
traceManager.openTrace(trace1);
- startRecorder3();
- Trace trace3 = recorder3.getTrace();
+ createTarget3();
+ Trace trace3 = getTrace(target3);
traceManager.openTrace(trace3);
createProgramFromTrace(trace1); // Also suitable for trace3
@@ -1082,11 +1014,11 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
programManager.openProgram(program);
addProgramTextBlock(program);
- TestTargetMemoryRegion text1 = addTargetTextRegion(mb.testProcess1);
- TestTargetMemoryRegion text3 = addTargetTextRegion(mb.testProcess3, 0x55551000);
+ MR text1 = addTargetTextRegion(target1);
+ MR text3 = addTargetTextRegion(target3, 0x55551000);
- addTextMapping(recorder1, text1, program);
- addTextMapping(recorder3, text3, program);
+ addTextMapping(target1, text1, program);
+ addTextMapping(target3, text3, program);
waitForSwing();
waitForPass(() -> {
assertEquals(2,
@@ -1098,19 +1030,18 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
waitForSwing();
addProgramBreakpoints(program);
- addTargetSoftwareBreakpoint(recorder1, text1);
- addTargetSoftwareBreakpoint(recorder3, text3);
+ addTargetSoftwareBreakpoint(target1, text1);
+ addTargetSoftwareBreakpoint(target3, text3);
waitForSwing();
waitForPass(() -> {
assertLogicalBreakpointForMappedBookmarkAnd2TraceBreakpoints(trace1, trace3);
});
- waitForLock(recorder3.getTrace());
+ waitForLock(getTrace(target3));
expectMappingChange(() -> {
- // TODO: Change breakpoint manager to require both open and recording...
// If I don't close the trace here, the test will fail.
- recorder3.stopRecording();
+ terminateTarget(target3);
// NB. Auto-close on stop is the default
//traceManager.closeTrace(trace3);
});
@@ -1120,44 +1051,10 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
waitForPass(() -> assertLogicalBreakpointForMappedBookmarkAnd1TraceBreakpoint(trace1));
}
- /**
- * I don't think this test is actually sane. The recorder should never abort a transaction,
- * unless something has already gone wrong. The logical breakpoint service only cares about live
- * breakpoints, so there's no context in which testing this service with aborted transactions on
- * breakpoints is sane.
- */
- //@Test
- public void testAbortAddBreakpoint() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
- traceManager.openTrace(trace);
-
- createProgramFromTrace(trace);
- intoProject(program);
- programManager.openProgram(program);
-
- addProgramTextBlock(program);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
- expectMappingChange(() -> addTextMapping(recorder1, text, program));
- waitForSwing();
-
- try (Transaction tx = trace.openTransaction("Will abort")) {
- addTargetSoftwareBreakpoint(recorder1, text);
- waitForDomainObject(trace);
-
- // Sanity
- assertLogicalBreakpointForMappedSoftwareBreakpoint(trace);
- tx.abort();
- }
- waitForDomainObject(trace);
-
- assertTrue(breakpointService.getAllBreakpoints().isEmpty());
- }
-
@Test
public void testAbortAddMapping() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
createProgramFromTrace(trace);
@@ -1165,22 +1062,22 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
programManager.openProgram(program);
addProgramTextBlock(program);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
- addTargetSoftwareBreakpoint(recorder1, text);
+ MR text = addTargetTextRegion(target1);
+ addTargetSoftwareBreakpoint(target1, text);
waitForPass(() -> {
assertLogicalBreakpointForLoneSoftwareBreakpoint(trace, 1);
});
/**
- * NB. The recorder could still be mid transaction. If we open this transaction too soon,
- * then the breakpoint gets aborted as well.
+ * NB. The target could still be mid transaction. If we open this transaction too soon, then
+ * the breakpoint gets aborted as well.
*/
waitForLock(trace);
waitForDomainObject(trace);
changeListener.assertAgreesWithService();
try (Transaction tx = trace.openTransaction("Will abort")) {
- expectMappingChange(() -> addTextMapping(recorder1, text, program));
+ expectMappingChange(() -> addTextMapping(target1, text, program));
waitForSwing();
// Sanity
@@ -1197,8 +1094,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testAbortAddBreakpointAndMapping() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
createProgramFromTrace(trace);
@@ -1206,12 +1103,12 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
programManager.openProgram(program);
addProgramTextBlock(program);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
+ MR text = addTargetTextRegion(target1);
try (Transaction tx = trace.openTransaction("Will abort")) {
- addTargetSoftwareBreakpoint(recorder1, text);
+ addTargetSoftwareBreakpoint(target1, text);
- expectMappingChange(() -> addTextMapping(recorder1, text, program));
+ expectMappingChange(() -> addTextMapping(target1, text, program));
waitForSwing();
// Sanity
@@ -1229,8 +1126,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testAbortAddBookmarks() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
createProgramFromTrace(trace);
@@ -1238,8 +1135,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
programManager.openProgram(program);
addProgramTextBlock(program);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
- expectMappingChange(() -> addTextMapping(recorder1, text, program));
+ MR text = addTargetTextRegion(target1);
+ expectMappingChange(() -> addTextMapping(target1, text, program));
waitForSwing();
try (Transaction tx = program.openTransaction("Will abort")) {
@@ -1257,8 +1154,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testUndoRedoAddBreakpointAndMapping() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
createProgramFromTrace(trace);
@@ -1266,11 +1163,11 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
programManager.openProgram(program);
addProgramTextBlock(program);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
+ MR text = addTargetTextRegion(target1);
try (Transaction tx = trace.openTransaction("Will undo")) {
- addTargetSoftwareBreakpoint(recorder1, text);
- expectMappingChange(() -> addTextMapping(recorder1, text, program));
+ addTargetSoftwareBreakpoint(target1, text);
+ expectMappingChange(() -> addTextMapping(target1, text, program));
}
waitForDomainObject(trace);
@@ -1297,8 +1194,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testUndoRedoAddBookmarks() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
createProgramFromTrace(trace);
@@ -1306,8 +1203,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
programManager.openProgram(program);
addProgramTextBlock(program);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
- expectMappingChange(() -> addTextMapping(recorder1, text, program));
+ MR text = addTargetTextRegion(target1);
+ expectMappingChange(() -> addTextMapping(target1, text, program));
waitForSwing();
try (Transaction tx = program.openTransaction("Will undo")) {
@@ -1330,34 +1227,37 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testPlaceDisableStepThenEnableTraceOnly() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
+ MR text = addTargetTextRegion(target1);
- addTargetSoftwareBreakpoint(recorder1, text);
+ addTargetSoftwareBreakpoint(target1, text);
waitForPass(() -> {
assertLogicalBreakpointForLoneSoftwareBreakpoint(trace, 1);
});
LogicalBreakpoint lb = Unique.assertOne(breakpointService.getAllBreakpoints());
- waitOn(lb.disable());
+ CompletableFuture<Void> disable = lb.disable();
+ handleToggleBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(trace)), false);
+ waitOn(disable);
waitForPass(() -> {
assertEquals(State.INCONSISTENT_DISABLED, lb.computeState());
});
- // Simulate a step, which should also cause snap advance in recorder
- long oldSnap = recorder1.getSnap();
- mb.testModel.session.simulateStep(mb.testThread1);
- waitOn(mb.testModel.flushEvents());
+ // Simulate a step, which should also cause snap advance in target
+ long oldSnap = getSnap(target1);
+ simulateTargetStep(target1);
waitForPass(() -> {
- assertEquals(oldSnap + 1, recorder1.getSnap());
+ assertEquals(oldSnap + 1, getSnap(target1));
assertEquals(State.INCONSISTENT_DISABLED, lb.computeState());
});
- waitOn(lb.enable());
+ CompletableFuture<Void> enable = lb.enable();
+ handleToggleBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(trace)), true);
+ waitOn(enable);
waitForPass(() -> {
assertEquals(State.INCONSISTENT_ENABLED, lb.computeState());
});
@@ -1365,13 +1265,13 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testDeleteBreakpointTraceOnly() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
+ MR text = addTargetTextRegion(target1);
- addTargetSoftwareBreakpoint(recorder1, text);
+ addTargetSoftwareBreakpoint(target1, text);
waitForPass(() -> {
assertLogicalBreakpointForLoneSoftwareBreakpoint(trace, 1);
@@ -1379,7 +1279,9 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
LogicalBreakpoint lb = Unique.assertOne(breakpointService.getAllBreakpoints());
- waitOn(lb.delete());
+ CompletableFuture<Void> delete = lb.delete();
+ handleDeleteBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(trace)));
+ waitOn(delete);
waitForPass(() -> {
assertTrue(breakpointService.getAllBreakpoints().isEmpty());
@@ -1388,24 +1290,25 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testPlaceStepThenDeleteBreakpointTraceOnly() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
+ MR text = addTargetTextRegion(target1);
- addTargetSoftwareBreakpoint(recorder1, text);
+ addTargetSoftwareBreakpoint(target1, text);
waitForDomainObject(trace);
waitForPass(() -> assertLogicalBreakpointForLoneSoftwareBreakpoint(trace, 1));
LogicalBreakpoint lb = Unique.assertOne(breakpointService.getAllBreakpoints());
- // Simulate a step, which should also cause snap advance in recorder
- mb.testModel.session.simulateStep(mb.testThread1);
- waitRecorder(recorder1);
+ // Simulate a step, which should also cause snap advance in target
+ simulateTargetStep(target1);
- waitOn(lb.delete());
+ CompletableFuture<Void> delete = lb.delete();
+ handleDeleteBreakpointInvocation(Unique.assertOne(lb.getTraceBreakpoints(trace)));
+ waitOn(delete);
waitForPass(() -> {
assertEquals(0, breakpointService.getAllBreakpoints().size());
@@ -1414,13 +1317,13 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testRecordThenCloseTraceOnly() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
+ MR text = addTargetTextRegion(target1);
- addTargetSoftwareBreakpoint(recorder1, text);
+ addTargetSoftwareBreakpoint(target1, text);
waitForPass(() -> {
assertLogicalBreakpointForLoneSoftwareBreakpoint(trace, 1);
@@ -1435,8 +1338,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testRecordThenAddTwoBreakpointsDisable1Mixed() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
createProgramFromTrace(trace);
@@ -1444,14 +1347,14 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
programManager.openProgram(program);
addProgramTextBlock(program);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
+ MR text = addTargetTextRegion(target1);
- addTextMapping(recorder1, text, program);
+ addTextMapping(target1, text, program);
waitForSwing();
addProgramBreakpoints(program);
- addTargetSoftwareBreakpoint(recorder1, text);
- addTargetSoftwareBreakpoint(recorder1, text);
+ addTargetSoftwareBreakpoint(target1, text);
+ addTargetSoftwareBreakpoint(target1, text);
waitForPass(() -> {
assertEquals(2, breakpointService.getAllBreakpoints().size());
@@ -1468,11 +1371,11 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
.assertOne(breakpointService.getBreakpointsAt(program, addr(program, 0x00400123)));
Set<TraceBreakpoint> locs = lb.getTraceBreakpoints();
- TraceBreakpoint bpt0 =
- locs.stream().filter(b -> b.getName().equals("0")).findAny().orElseThrow();
- TraceBreakpoint bpt1 =
- locs.stream().filter(b -> b.getName().equals("1")).findAny().orElseThrow();
- breakpointService.disableLocs(Set.of(bpt0));
+ TraceBreakpoint bpt0 = findLoc(locs, 0);
+ TraceBreakpoint bpt1 = findLoc(locs, 1);
+ CompletableFuture<Void> disable = breakpointService.disableLocs(Set.of(bpt0));
+ handleToggleBreakpointInvocation(bpt0, false);
+ waitOn(disable);
waitForPass(() -> {
assertEquals(State.INCONSISTENT_ENABLED, lb.computeState());
@@ -1484,8 +1387,8 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testRecordThenAddTwoKindsOfBreakpointsDisable1Mixed() throws Throwable {
- startRecorder1();
- Trace trace = recorder1.getTrace();
+ createTarget1();
+ Trace trace = getTrace(target1);
traceManager.openTrace(trace);
createProgramFromTrace(trace);
@@ -1493,14 +1396,14 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
programManager.openProgram(program);
addProgramTextBlock(program);
- TestTargetMemoryRegion text = addTargetTextRegion(mb.testProcess1);
+ MR text = addTargetTextRegion(target1);
- addTextMapping(recorder1, text, program);
+ addTextMapping(target1, text, program);
waitForSwing();
addProgramBreakpoints(program);
- addTargetSoftwareBreakpoint(recorder1, text);
- addTargetAccessBreakpoint(recorder1, text);
+ addTargetSoftwareBreakpoint(target1, text);
+ addTargetAccessBreakpoint(target1, text);
waitForPass(() -> {
assertEquals(3, breakpointService.getAllBreakpoints().size());
@@ -1527,7 +1430,9 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
.filter(l -> l.getKinds().contains(TraceBreakpointKind.READ))
.findAny()
.orElseThrow();
- waitOn(lbEx.disable());
+ CompletableFuture<Void> disable = lbEx.disable();
+ handleToggleBreakpointInvocation(Unique.assertOne(lbEx.getTraceBreakpoints(trace)), false);
+ waitOn(disable);
// TODO: This is more a test for the marker plugin, no?
waitForPass(
@@ -1616,14 +1521,15 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
@Test
public void testAddTraceBreakpointSetSleighThenMapThenSaveToProgramCopiesSleigh()
throws Throwable {
- DebuggerControlService editingService = addPlugin(tool, DebuggerControlServicePlugin.class);
+ DebuggerControlService controlService =
+ addPlugin(tool, DebuggerControlServicePlugin.class);
// TODO: What if already mapped?
// Not sure I care about tb.setEmuSleigh() out of band
createTrace();
traceManager.openTrace(tb.trace);
- editingService.setCurrentMode(tb.trace, ControlMode.RW_EMULATOR);
+ controlService.setCurrentMode(tb.trace, ControlMode.RW_EMULATOR);
createProgramFromTrace();
intoProject(program);
programManager.openProgram(program);
@@ -1653,4 +1559,40 @@ public class DebuggerLogicalBreakpointServiceTest extends AbstractGhidraHeadedDe
assertEquals("{\"sleigh\":\"r0\\u003d0xbeef;\"}", lb.getProgramBookmark().getComment());
}
+
+ /**
+ * With the addition of emulated breakpoints (which are stored in the trace), this test is now
+ * sane.
+ */
+ @Test
+ public void testAbortAddBreakpointSetSleigh() throws Throwable {
+ DebuggerControlService controlService =
+ addPlugin(tool, DebuggerControlServicePlugin.class);
+
+ // TODO: What if already mapped?
+ // Not sure I care about tb.setEmuSleigh() out of band
+
+ createTrace();
+ traceManager.openTrace(tb.trace);
+ controlService.setCurrentMode(tb.trace, ControlMode.RW_EMULATOR);
+ createProgramFromTrace();
+ intoProject(program);
+ programManager.openProgram(program);
+
+ try (Transaction tid = tb.startTransaction()) {
+ TraceBreakpoint bpt = tb.trace.getBreakpointManager()
+ .addBreakpoint("Processes[1].Breakpoints[0]", Lifespan.nowOn(0),
+ tb.addr(0x55550123),
+ Set.of(), Set.of(TraceBreakpointKind.SW_EXECUTE),
+ false /* emuEnabled defaults to true */, "");
+ bpt.setEmuSleigh("r0=0xbeef;");
+ waitForValue(() -> Unique.assertAtMostOne(
+ breakpointService.getBreakpointsAt(tb.trace, tb.addr(0x55550123))));
+
+ tid.abort();
+ }
+ waitForDomainObject(tb.trace);
+
+ assertTrue(breakpointService.getAllBreakpoints().isEmpty());
+ }
}
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/breakpoint/DebuggerLogicalBreakpointServiceObjectTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/service/breakpoint/DebuggerObjectRecorderLogicalBreakpointServiceTest.java
similarity index 97%
rename from Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/breakpoint/DebuggerLogicalBreakpointServiceObjectTest.java
rename to Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/service/breakpoint/DebuggerObjectRecorderLogicalBreakpointServiceTest.java
index 7eb2342b7b..981859ef71 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/breakpoint/DebuggerLogicalBreakpointServiceObjectTest.java
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/service/breakpoint/DebuggerObjectRecorderLogicalBreakpointServiceTest.java
@@ -24,8 +24,8 @@ import ghidra.dbg.target.schema.XmlSchemaContext;
import ghidra.trace.model.Trace;
import ghidra.trace.model.target.TraceObjectKeyPath;
-public class DebuggerLogicalBreakpointServiceObjectTest
- extends DebuggerLogicalBreakpointServiceTest {
+public class DebuggerObjectRecorderLogicalBreakpointServiceTest
+ extends DebuggerRecorderLogicalBreakpointServiceTest {
protected SchemaContext ctx;
diff --git a/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/service/breakpoint/DebuggerRecorderLogicalBreakpointServiceTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/service/breakpoint/DebuggerRecorderLogicalBreakpointServiceTest.java
new file mode 100644
index 0000000000..6685d6efff
--- /dev/null
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/service/breakpoint/DebuggerRecorderLogicalBreakpointServiceTest.java
@@ -0,0 +1,213 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.service.breakpoint;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.Before;
+
+import db.Transaction;
+import ghidra.app.plugin.core.debug.service.modules.DebuggerStaticMappingUtils;
+import ghidra.dbg.model.TestTargetMemoryRegion;
+import ghidra.dbg.model.TestTargetProcess;
+import ghidra.dbg.target.*;
+import ghidra.dbg.target.TargetBreakpointSpec.TargetBreakpointKind;
+import ghidra.debug.api.action.ActionSource;
+import ghidra.debug.api.model.TraceRecorder;
+import ghidra.program.model.listing.Program;
+import ghidra.program.util.ProgramLocation;
+import ghidra.trace.model.DefaultTraceLocation;
+import ghidra.trace.model.Trace;
+import ghidra.trace.model.breakpoint.TraceBreakpoint;
+import ghidra.trace.model.memory.TraceMemoryRegion;
+import ghidra.trace.model.modules.TraceStaticMapping;
+
+public class DebuggerRecorderLogicalBreakpointServiceTest extends
+ AbstractDebuggerLogicalBreakpointServiceTest<TraceRecorder, TestTargetMemoryRegion> {
+
+ @Before
+ public void setUpRecorderBreakpointServiceTest() throws Throwable {
+ // NOTE: Traces derive from recordings, not toy builder
+ // NOTE: Program must be saved into project so it has a URL for mappings
+ createTestModel();
+ mb.createTestProcessesAndThreads();
+ }
+
+ @Override
+ protected void createTarget1() throws Throwable {
+ target1 = modelService.recordTarget(mb.testProcess1,
+ createTargetTraceMapper(mb.testProcess1), ActionSource.AUTOMATIC);
+ }
+
+ @Override
+ protected void createTarget3() throws Throwable {
+ target3 = modelService.recordTarget(mb.testProcess3,
+ createTargetTraceMapper(mb.testProcess3), ActionSource.AUTOMATIC);
+ }
+
+ @Override
+ protected Trace getTrace(TraceRecorder recorder) {
+ return recorder.getTrace();
+ }
+
+ @Override
+ protected void simulateTargetStep(TraceRecorder recorder) throws Throwable {
+ assertEquals(target1, recorder); // In case I ever pass in target3, scream.
+ mb.testModel.session.simulateStep(mb.testThread1);
+ waitRecorder(recorder);
+ }
+
+ @Override
+ protected long getSnap(TraceRecorder recorder) {
+ return recorder.getSnap();
+ }
+
+ @Override
+ protected boolean isTargetValid(TraceRecorder recorder) {
+ return recorder.isRecording();
+ }
+
+ protected TestTargetMemoryRegion addTargetTextRegion(TestTargetProcess p, long offset) {
+ return p.addRegion("bin:.text", mb.rng(offset, offset + 0x0fff), "rx");
+ }
+
+ protected TestTargetMemoryRegion addTargetDataRegion(TestTargetProcess p) {
+ return p.addRegion("bin:.data", mb.rng(0x56550000, 0x5655ffff), "rw");
+ }
+
+ protected TestTargetProcess getProcess(TraceRecorder recorder) {
+ if (recorder == target1) {
+ return mb.testProcess1;
+ }
+ if (recorder == target3) {
+ return mb.testProcess3;
+ }
+ throw new AssertionError();
+ }
+
+ @Override
+ protected TestTargetMemoryRegion addTargetTextRegion(TraceRecorder recorder, long offset) {
+ return addTargetTextRegion(getProcess(recorder), offset);
+ }
+
+ @Override
+ protected TestTargetMemoryRegion addTargetTextRegion(TraceRecorder recorder) {
+ return addTargetTextRegion(getProcess(recorder), 0x55550000);
+ }
+
+ @Override
+ protected TestTargetMemoryRegion addTargetDataRegion(TraceRecorder recorder) throws Throwable {
+ return addTargetDataRegion(getProcess(recorder));
+ }
+
+ @Override
+ protected void addTextMapping(TraceRecorder r, TestTargetMemoryRegion region, Program p)
+ throws Throwable {
+ Trace t = r.getTrace();
+ TraceMemoryRegion textRegion =
+ waitFor(() -> r.getTraceMemoryRegion(region), "Recorder missed region: " + region);
+ try (Transaction tx = t.openTransaction("Add .text mapping")) {
+ DebuggerStaticMappingUtils.addMapping(
+ new DefaultTraceLocation(t, null, textRegion.getLifespan(),
+ textRegion.getMinAddress()),
+ new ProgramLocation(p, addr(p, 0x00400000)), 0x1000,
+ false);
+ }
+ }
+
+ @Override
+ protected void removeTextMapping(TraceRecorder r, Program p) throws Throwable {
+ Trace t = r.getTrace();
+ try (Transaction tx = t.openTransaction("Remove .text mapping")) {
+ TraceStaticMapping mapping =
+ t.getStaticMappingManager().findContaining(addr(t, 0x55550000), r.getSnap());
+ mapping.delete();
+ }
+ }
+
+ @Override
+ protected void addTargetAccessBreakpoint(TraceRecorder r, TestTargetMemoryRegion region)
+ throws Throwable {
+ TraceMemoryRegion traceRegion =
+ waitFor(() -> r.getTraceMemoryRegion(region), "Recorder missed region: " + region);
+ long offset = traceRegion.getMinAddress().getOffset() + 0x0123;
+ TargetBreakpointSpecContainer cont = getBreakpointContainer(r);
+ waitOn(cont.placeBreakpoint(mb.addr(offset),
+ Set.of(TargetBreakpointKind.READ, TargetBreakpointKind.WRITE)));
+ waitRecorder(r);
+ }
+
+ @Override
+ protected void addTargetSoftwareBreakpoint(TraceRecorder r, TestTargetMemoryRegion region)
+ throws Throwable {
+ TraceMemoryRegion traceRegion =
+ waitFor(() -> r.getTraceMemoryRegion(region), "Recorder missed region: " + region);
+ long offset = traceRegion.getMinAddress().getOffset() + 0x0123;
+ TargetBreakpointSpecContainer cont = getBreakpointContainer(r);
+ waitOn(cont.placeBreakpoint(mb.addr(offset), Set.of(TargetBreakpointKind.SW_EXECUTE)));
+ waitRecorder(r);
+ }
+
+ @Override
+ protected void removeTargetSoftwareBreakpoint(TraceRecorder r) throws Throwable {
+ TargetBreakpointSpecContainer cont = getBreakpointContainer(r);
+ cont.fetchElements().thenAccept(elements -> {
+ for (TargetObject obj : elements.values()) {
+ if (!(obj instanceof TargetBreakpointSpec) ||
+ !(obj instanceof TargetDeletable)) {
+ continue;
+ }
+ TargetBreakpointSpec spec = (TargetBreakpointSpec) obj;
+ if (!spec.getKinds().contains(TargetBreakpointKind.SW_EXECUTE)) {
+ continue;
+ }
+ TargetDeletable del = (TargetDeletable) obj;
+ del.delete();
+ return;
+ }
+ fail("No deletable software breakpoint spec found");
+ }).get(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
+ }
+
+ @Override
+ protected void terminateTarget(TraceRecorder recorder) {
+ recorder.stopRecording();
+ }
+
+ @Override
+ protected TraceBreakpoint findLoc(Set<TraceBreakpoint> locs, int index) {
+ return locs.stream()
+ .filter(b -> b.getName().equals(Integer.toString(index)))
+ .findAny()
+ .orElseThrow();
+ }
+
+ @Override
+ protected void handleToggleBreakpointInvocation(TraceBreakpoint expectedBreakpoint,
+ boolean expectedEnabled) throws Throwable {
+ // Logic is in the Test model
+ }
+
+ @Override
+ protected void handleDeleteBreakpointInvocation(TraceBreakpoint expectedBreakpoint)
+ throws Throwable {
+ // Logic is in the Test model
+ }
+}
diff --git a/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/service/breakpoint/DebuggerRmiLogicalBreakpointServiceTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/service/breakpoint/DebuggerRmiLogicalBreakpointServiceTest.java
new file mode 100644
index 0000000000..e4d95f0dee
--- /dev/null
+++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/service/breakpoint/DebuggerRmiLogicalBreakpointServiceTest.java
@@ -0,0 +1,236 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.debug.service.breakpoint;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.*;
+
+import org.junit.Before;
+
+import db.Transaction;
+import ghidra.app.plugin.core.debug.service.modules.DebuggerStaticMappingUtils;
+import ghidra.app.plugin.core.debug.service.rmi.trace.TraceRmiTarget;
+import ghidra.program.model.address.Address;
+import ghidra.program.model.listing.Program;
+import ghidra.program.util.ProgramLocation;
+import ghidra.trace.database.ToyDBTraceBuilder;
+import ghidra.trace.model.*;
+import ghidra.trace.model.breakpoint.*;
+import ghidra.trace.model.breakpoint.TraceBreakpointKind.TraceBreakpointKindSet;
+import ghidra.trace.model.memory.TraceObjectMemoryRegion;
+import ghidra.trace.model.modules.TraceStaticMapping;
+import ghidra.trace.model.time.TraceSnapshot;
+
+public class DebuggerRmiLogicalBreakpointServiceTest extends
+ AbstractDebuggerLogicalBreakpointServiceTest<TraceRmiTarget, TraceObjectMemoryRegion> {
+
+ ToyDBTraceBuilder tb3;
+
+ @Before
+ public void setUpRmiBreakpointServiceTest() throws Throwable {
+ createRmiConnection();
+ addBreakpointMethods();
+ }
+
+ @Override
+ protected void createTarget1() throws Throwable {
+ createTrace();
+ try (Transaction tx = tb.startTransaction()) {
+ tb.trace.getObjectManager().createRootObject(SCHEMA_SESSION);
+ tb.createObjectsProcessAndThreads();
+ }
+ target1 = rmiCx.publishTarget(tool, tb.trace);
+ }
+
+ @Override
+ protected void createTarget3() throws Throwable {
+ tb3 = new ToyDBTraceBuilder("dynamic3-" + name.getMethodName(), LANGID_TOYBE64);
+ try (Transaction tx = tb3.startTransaction()) {
+ tb3.trace.getTimeManager().createSnapshot("Fist snapshot");
+ tb3.trace.getObjectManager().createRootObject(SCHEMA_SESSION);
+ tb3.createObjectsProcessAndThreads();
+ }
+ target3 = rmiCx.publishTarget(tool, tb3.trace);
+ }
+
+ @Override
+ protected Trace getTrace(TraceRmiTarget target) {
+ return target.getTrace();
+ }
+
+ @Override
+ protected void simulateTargetStep(TraceRmiTarget target) throws Throwable {
+ Trace trace = target.getTrace();
+ TraceSnapshot snapshot;
+ try (Transaction tx = trace.openTransaction("Simulate step")) {
+ snapshot = trace.getTimeManager().createSnapshot("Simulated step");
+ }
+ rmiCx.setLastSnapshot(trace, snapshot.getKey());
+ }
+
+ @Override
+ protected long getSnap(TraceRmiTarget target) {
+ return target.getSnap();
+ }
+
+ @Override
+ protected boolean isTargetValid(TraceRmiTarget target) {
+ return target.isValid();
+ }
+
+ @Override
+ protected TraceObjectMemoryRegion addTargetTextRegion(TraceRmiTarget target, long offset)
+ throws Throwable {
+ Trace trace = target.getTrace();
+ try (Transaction tx = trace.openTransaction("Add .text")) {
+ return Objects.requireNonNull(
+ addMemoryRegion(trace.getObjectManager(), Lifespan.nowOn(target.getSnap()),
+ tb.range(offset, offset + 0x0fff), "bin:.text", "rx")
+ .queryInterface(TraceObjectMemoryRegion.class));
+ }
+ }
+
+ @Override
+ protected TraceObjectMemoryRegion addTargetTextRegion(TraceRmiTarget target) throws Throwable {
+ return addTargetTextRegion(target, 0x55550000);
+ }
+
+ @Override
+ protected TraceObjectMemoryRegion addTargetDataRegion(TraceRmiTarget target) throws Throwable {
+ Trace trace = target.getTrace();
+ long offset = 0x56550000;
+ try (Transaction tx = trace.openTransaction("Add .data")) {
+ return Objects.requireNonNull(
+ addMemoryRegion(trace.getObjectManager(), Lifespan.nowOn(target.getSnap()),
+ tb.range(offset, offset + 0x0fff), "bin:.data", "rw")
+ .queryInterface(TraceObjectMemoryRegion.class));
+ }
+ }
+
+ @Override
+ protected void addTextMapping(TraceRmiTarget target, TraceObjectMemoryRegion text,
+ Program program) throws Throwable {
+ Trace trace = target.getTrace();
+ try (Transaction tx = trace.openTransaction("Add .text mapping")) {
+ DebuggerStaticMappingUtils.addMapping(
+ new DefaultTraceLocation(trace, null, text.getLifespan(), text.getMinAddress()),
+ new ProgramLocation(program, addr(program, 0x00400000)), 0x1000,
+ false);
+ }
+ }
+
+ @Override
+ protected void removeTextMapping(TraceRmiTarget target, Program p) throws Throwable {
+ Trace t = target.getTrace();
+ try (Transaction tx = t.openTransaction("Remove .text mapping")) {
+ TraceStaticMapping mapping =
+ t.getStaticMappingManager().findContaining(addr(t, 0x55550000), target.getSnap());
+ mapping.delete();
+ }
+ }
+
+ @Override
+ protected void addTargetAccessBreakpoint(TraceRmiTarget target, TraceObjectMemoryRegion region)
+ throws Throwable {
+ Address min = region.getMinAddress().add(0x0123);
+ Trace trace = target.getTrace();
+ try (Transaction tx = trace.openTransaction("Add access breakpoint")) {
+ addBreakpointAndLoc(trace.getObjectManager(), Lifespan.nowOn(target.getSnap()),
+ tb.range(min, min), TraceBreakpointKindSet.ACCESS);
+ }
+ waitForDomainObject(trace);
+ }
+
+ @Override
+ protected void addTargetSoftwareBreakpoint(TraceRmiTarget target,
+ TraceObjectMemoryRegion region) throws Throwable {
+ Address min = region.getMinAddress().add(0x0123);
+ Trace trace = target.getTrace();
+ try (Transaction tx = trace.openTransaction("Add software breakpoint")) {
+ addBreakpointAndLoc(trace.getObjectManager(), Lifespan.nowOn(target.getSnap()),
+ tb.range(min, min), TraceBreakpointKindSet.SW_EXECUTE);
+ }
+ waitForDomainObject(trace);
+ }
+
+ @Override
+ protected void removeTargetSoftwareBreakpoint(TraceRmiTarget target) throws Throwable {
+ Trace trace = target.getTrace();
+ Lifespan nowOn = Lifespan.nowOn(target.getSnap());
+ List<TraceObjectBreakpointLocation> locsToDel = trace.getBreakpointManager()
+ .getAllBreakpoints()
+ .stream()
+ .filter(bp -> bp.getKinds().equals(TraceBreakpointKindSet.SW_EXECUTE))
+ .filter(bp -> bp instanceof TraceObjectBreakpointLocation)
+ .map(bp -> (TraceObjectBreakpointLocation) bp)
+ .toList();
+ List<TraceObjectBreakpointSpec> specsToDel =
+ locsToDel.stream().map(bp -> bp.getSpecification()).distinct().toList();
+ try (Transaction tx = trace.openTransaction("Delete software breakpoints")) {
+ for (TraceObjectBreakpointLocation loc : locsToDel) {
+ loc.getObject().remove(nowOn);
+ }
+ for (TraceObjectBreakpointSpec spec : specsToDel) {
+ spec.getObject().remove(nowOn);
+ }
+ }
+ }
+
+ @Override
+ protected void terminateTarget(TraceRmiTarget t) {
+ t.forceTerminate();
+ }
+
+ @Override
+ protected TraceBreakpoint findLoc(Set<TraceBreakpoint> locs, int index) {
+ return locs.stream()
+ .filter(b -> b.getName().equals(Integer.toString(index + 1)))
+ .findAny()
+ .orElseThrow();
+ }
+
+ @Override
+ protected void handleToggleBreakpointInvocation(TraceBreakpoint expectedBreakpoint,
+ boolean expectedEn) throws Throwable {
+ if (!(expectedBreakpoint instanceof TraceObjectBreakpointLocation loc)) {
+ throw new AssertionError("Unexpected trace breakpoint type: " + expectedBreakpoint);
+ }
+ Map<String, Object> args = rmiMethodToggleBreak.expect();
+ try (Transaction tx = tb.startTransaction()) {
+ loc.setEnabled(Lifespan.nowOn(0), expectedEn);
+ }
+ rmiMethodToggleBreak.result(null);
+ assertEquals(Map.ofEntries(
+ Map.entry("breakpoint", loc.getSpecification().getObject()),
+ Map.entry("enabled", expectedEn)), args);
+ }
+
+ @Override
+ protected void handleDeleteBreakpointInvocation(TraceBreakpoint expectedBreakpoint)
+ throws Throwable {
+ if (!(expectedBreakpoint instanceof TraceObjectBreakpointLocation loc)) {
+ throw new AssertionError("Unexpected trace breakpoint type: " + expectedBreakpoint);
+ }
+ Map<String, Object> args = rmiMethodDeleteBreak.expect();
+ try (Transaction tx = tb.startTransaction()) {
+ loc.getObject().remove(Lifespan.nowOn(0));
+ }
+ rmiMethodDeleteBreak.result(null);
+ assertEquals(Map.ofEntries(
+ Map.entry("breakpoint", loc.getSpecification().getObject())), args);
+ }
+}
diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/TraceRmiLauncherServicePluginTest.java b/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/TraceRmiLauncherServicePluginTest.java
index aa113545ea..3647b622ba 100644
--- a/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/TraceRmiLauncherServicePluginTest.java
+++ b/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/plugin/core/debug/gui/tracermi/launcher/TraceRmiLauncherServicePluginTest.java
@@ -24,13 +24,13 @@ import org.junit.Before;
import org.junit.Test;
import db.Transaction;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.services.TraceRmiLauncherService;
import ghidra.debug.api.tracermi.TraceRmiLaunchOffer;
import ghidra.debug.api.tracermi.TraceRmiLaunchOffer.*;
import ghidra.util.task.ConsoleTaskMonitor;
-public class TraceRmiLauncherServicePluginTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class TraceRmiLauncherServicePluginTest extends AbstractGhidraHeadedDebuggerTest {
TraceRmiLauncherService launcherService;
@Before
@@ -43,11 +43,6 @@ public class TraceRmiLauncherServicePluginTest extends AbstractGhidraHeadedDebug
return offers.stream().filter(o -> o.getTitle().equals(title)).findFirst().get();
}
- @Test
- public void testGetOpinions() throws Exception {
- assertFalse(launcherService.getOpinions().isEmpty());
- }
-
@Test
public void testGetOffers() throws Exception {
createProgram(getSLEIGH_X86_64_LANGUAGE());
diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/plugin/core/terminal/TerminalProviderTest.java b/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/plugin/core/terminal/TerminalProviderTest.java
index 81a95bad23..a9b3d4f49c 100644
--- a/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/plugin/core/terminal/TerminalProviderTest.java
+++ b/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/plugin/core/terminal/TerminalProviderTest.java
@@ -31,13 +31,13 @@ import org.junit.Test;
import docking.widgets.OkDialog;
import docking.widgets.fieldpanel.support.*;
import ghidra.app.plugin.core.clipboard.ClipboardPlugin;
-import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
+import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerTest;
import ghidra.app.services.*;
import ghidra.framework.OperatingSystem;
import ghidra.pty.*;
import ghidra.util.SystemUtilities;
-public class TerminalProviderTest extends AbstractGhidraHeadedDebuggerGUITest {
+public class TerminalProviderTest extends AbstractGhidraHeadedDebuggerTest {
protected static byte[] ascii(String str) {
try {
return str.getBytes("UTF-8");