GP-4389: Fixes for Trace RMI lldb on macOS

Create local-lldh.sh launch script
Upgrade to JNA-5.14
Fix pty IOCTL numbers for macOS
Fix compile-spec mapping
Improv error report / clean-up after launch failure.
Write ERROR state on memory read failures
Convert Python exceptions to LLDB command errors
This commit is contained in:
Dan
2024-03-04 16:45:41 -05:00
parent bb8ec1cbe6
commit 973b9a8d4c
50 changed files with 1247 additions and 723 deletions

View File

@@ -25,7 +25,7 @@ import agent.gdb.manager.breakpoint.GdbBreakpointInfo;
import agent.gdb.manager.breakpoint.GdbBreakpointInsertions;
import agent.gdb.manager.impl.GdbManagerImpl;
import ghidra.pty.PtyFactory;
import ghidra.pty.linux.LinuxPty;
import ghidra.pty.unix.UnixPty;
/**
* The controlling side of a GDB session, using GDB/MI, usually via a pseudo-terminal
@@ -232,7 +232,7 @@ public interface GdbManager extends AutoCloseable, GdbConsoleOperations, GdbBrea
* Note: depending on the target, its output may not be communicated via this listener. Local
* targets, e.g., tend to just print output to GDB's controlling TTY. See
* {@link GdbInferior#setTty(String)} for a means to more reliably interact with a target's
* input and output. See also {@link LinuxPty} for a means to easily acquire a new TTY from
* input and output. See also {@link UnixPty} for a means to easily acquire a new TTY from
* Java.
*
* @param listener the listener to add

View File

@@ -551,7 +551,7 @@ def putmem_state(address, length, state, pages=True):
inf = gdb.selected_inferior()
base, addr = STATE.trace.memory_mapper.map(inf, start)
if base != addr.space:
trace.create_overlay_space(base, addr.space)
STATE.trace.create_overlay_space(base, addr.space)
STATE.trace.set_memory_state(addr.extend(end - start), state)

View File

@@ -17,11 +17,10 @@ from concurrent.futures import Future, Executor
from contextlib import contextmanager
import re
import gdb
from ghidratrace import sch
from ghidratrace.client import MethodRegistry, ParamDesc, Address, AddressRange
import gdb
from . import commands, hooks, util
@@ -690,8 +689,8 @@ def read_mem(inferior: sch.Schema('Inferior'), range: AddressRange):
gdb.execute(
f'ghidra trace putmem 0x{offset_start:x} {range.length()}')
except:
commands.putmem_state(
offset_start, offset_start+range.length() - 1, 'error')
gdb.execute(
f'ghidra trace putmem-state 0x{offset_start:x} {range.length()} error')
@REGISTRY.method

View File

@@ -23,7 +23,8 @@ import org.junit.Ignore;
import agent.gdb.manager.GdbManager;
import ghidra.pty.PtySession;
import ghidra.pty.linux.LinuxPty;
import ghidra.pty.linux.LinuxIoctls;
import ghidra.pty.unix.UnixPty;
import ghidra.util.Msg;
@Ignore("Need compatible GDB version for CI")
@@ -45,13 +46,13 @@ public class JoinedGdbManagerTest extends AbstractGdbManagerTest {
}
}
protected LinuxPty ptyUserGdb;
protected UnixPty ptyUserGdb;
protected PtySession gdb;
@Override
protected CompletableFuture<Void> startManager(GdbManager manager) {
try {
ptyUserGdb = LinuxPty.openpty();
ptyUserGdb = UnixPty.openpty(LinuxIoctls.INSTANCE);
manager.start(null);
Msg.debug(this, "Starting GDB and invoking new-ui mi2 " + manager.getMi2PtyName());