mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
Merge remote-tracking branch 'origin/GP-3063_d-millar_more_iphone_mods--SQUASHED'
This commit is contained in:
commit
044ec1ab5d
9 changed files with 60 additions and 32 deletions
|
@ -305,7 +305,11 @@ public interface DebugClient extends DebugClientReentrant {
|
|||
}
|
||||
if (modelObject instanceof SBFrame) {
|
||||
SBFrame frame = (SBFrame) modelObject;
|
||||
return Long.toString(frame.GetFrameID());
|
||||
int frameId = (int)frame.GetFrameID();
|
||||
if (frameId < 0) {
|
||||
frameId = 0;
|
||||
}
|
||||
return Integer.toString(frameId);
|
||||
}
|
||||
if (modelObject instanceof SBValue) {
|
||||
SBValue val = (SBValue) modelObject;
|
||||
|
|
|
@ -116,12 +116,13 @@ public class DebugClientImpl implements DebugClient {
|
|||
public SBProcess connectRemote(DebugServerId si, String key, boolean auto, boolean async, boolean kernel) {
|
||||
SBListener listener = new SBListener();
|
||||
SBError error = new SBError();
|
||||
session = createNullSession();
|
||||
if (!auto) {
|
||||
session = createNullSession();
|
||||
((LldbManagerImpl) manager).addSessionIfAbsent(session);
|
||||
return null;
|
||||
}
|
||||
String plugin = kernel ? "kdb-remote" : "gdb-remote";
|
||||
session = connectSession("");
|
||||
SBProcess process = session.ConnectRemote(listener, key, plugin, error);
|
||||
if (!error.Success()) {
|
||||
Msg.error(this, error.GetType() + " while attaching to " + key);
|
||||
|
|
|
@ -1553,22 +1553,31 @@ public class LldbManagerImpl implements LldbManager {
|
|||
eventThread = SBThread.GetThreadFromEvent(currentEvent);
|
||||
if (eventThread != null && eventThread.IsValid()) {
|
||||
currentThread = eventThread;
|
||||
Msg.warn(this, "defaulting to event thread");
|
||||
return currentThread;
|
||||
}
|
||||
}
|
||||
if (currentProcess == null) {
|
||||
currentProcess = eventProcess = currentSession.GetProcess();
|
||||
}
|
||||
if (currentThread == null || !currentThread.IsValid()) {
|
||||
currentProcess = currentSession.GetProcess();
|
||||
for (int i = 0; i < currentProcess.GetNumThreads(); i++) {
|
||||
SBThread thread = currentProcess.GetThreadAtIndex(i);
|
||||
if (thread.IsValid()) {
|
||||
currentThread = thread;
|
||||
break;
|
||||
}
|
||||
if (currentProcess == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
currentThread = currentProcess.GetSelectedThread();
|
||||
if (currentThread != null && currentThread.IsValid()) {
|
||||
Msg.warn(this, "defaulting to active thread");
|
||||
return currentThread;
|
||||
}
|
||||
|
||||
for (int i = 0; i < currentProcess.GetNumThreads(); i++) {
|
||||
SBThread thread = currentProcess.GetThreadAtIndex(i);
|
||||
if (thread.IsValid()) {
|
||||
Msg.warn(this, "defaulting to thread "+i);
|
||||
currentThread = thread;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return currentThread;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ public class LldbModelTargetBreakpointContainerImpl extends LldbModelTargetObjec
|
|||
LldbModelImpl impl = (LldbModelImpl) model;
|
||||
impl.deleteModelObject(info);
|
||||
changeElements(List.of( //
|
||||
DebugClient.getId(getModelObject()) //
|
||||
DebugClient.getId(info) //
|
||||
), List.of(), Map.of(), "Deleted");
|
||||
}
|
||||
|
||||
|
|
|
@ -216,17 +216,13 @@ public class LldbModelTargetProcessImpl extends LldbModelTargetObjectImpl
|
|||
@Override
|
||||
public CompletableFuture<Void> step(TargetStepKind kind) {
|
||||
LldbManagerImpl manager = getManager();
|
||||
SBProcess currentProcess = manager.getCurrentProcess();
|
||||
SBThread thread = currentProcess == null ? null : currentProcess.GetSelectedThread();
|
||||
return getManager().execute(new LldbStepCommand(manager, thread, kind, null));
|
||||
return getManager().execute(new LldbStepCommand(manager, null, kind, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> step(Map<String, ?> args) {
|
||||
LldbManagerImpl manager = getManager();
|
||||
SBProcess currentProcess = manager.getCurrentProcess();
|
||||
SBThread thread = currentProcess == null ? null : currentProcess.GetSelectedThread();
|
||||
return getManager().execute(new LldbStepCommand(manager, thread, null, args));
|
||||
return getManager().execute(new LldbStepCommand(manager, null, null, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -57,6 +57,14 @@ public class LldbModelTargetSessionAttributesImpl extends LldbModelTargetObjectI
|
|||
|
||||
SBTarget target = (SBTarget) session.getModelObject();
|
||||
String[] triple = target.GetTriple().split("-");
|
||||
String arch = "x86_64";
|
||||
String manufacturer = "unknown";
|
||||
String os = System.getProperty("os.name").toLowerCase();
|
||||
if (triple.length == 3) {
|
||||
arch = triple[0];
|
||||
manufacturer = triple[1];
|
||||
os = triple[2];
|
||||
}
|
||||
ByteOrder order = target.GetByteOrder();
|
||||
String orderStr = "invalid";
|
||||
if (order.equals(ByteOrder.eByteOrderLittle)) {
|
||||
|
@ -73,9 +81,9 @@ public class LldbModelTargetSessionAttributesImpl extends LldbModelTargetObjectI
|
|||
platformAttributes, //
|
||||
environment //
|
||||
), Map.of( //
|
||||
ARCH_ATTRIBUTE_NAME, triple[0], //
|
||||
ARCH_ATTRIBUTE_NAME, arch, //
|
||||
DEBUGGER_ATTRIBUTE_NAME, "lldb", //
|
||||
OS_ATTRIBUTE_NAME, triple[2], //
|
||||
OS_ATTRIBUTE_NAME, os, //
|
||||
ENDIAN_ATTRIBUTE_NAME, orderStr //
|
||||
), "Initialized");
|
||||
|
||||
|
|
|
@ -59,6 +59,14 @@ public class LldbModelTargetSessionAttributesPlatformImpl extends LldbModelTarge
|
|||
|
||||
session = (SBTarget) getModelObject();
|
||||
String[] triple = session.GetTriple().split("-");
|
||||
String arch = "x86_64";
|
||||
String manufacturer = "unknown";
|
||||
String os = System.getProperty("os.name").toLowerCase();
|
||||
if (triple.length == 3) {
|
||||
arch = triple[0];
|
||||
manufacturer = triple[1];
|
||||
os = triple[2];
|
||||
}
|
||||
ByteOrder order = session.GetByteOrder();
|
||||
SBPlatform platform = session.GetPlatform();
|
||||
|
||||
|
@ -78,9 +86,9 @@ public class LldbModelTargetSessionAttributesPlatformImpl extends LldbModelTarge
|
|||
}
|
||||
|
||||
changeAttributes(List.of(), List.of(), Map.of( //
|
||||
ARCH_ATTRIBUTE_NAME, triple[0], //
|
||||
MANUFACTURER_ATTRIBUTE_NAME, triple[1], //
|
||||
OS_ATTRIBUTE_NAME, triple[2], //
|
||||
ARCH_ATTRIBUTE_NAME, arch, //
|
||||
MANUFACTURER_ATTRIBUTE_NAME, manufacturer, //
|
||||
OS_ATTRIBUTE_NAME, os, //
|
||||
OS_DESC_ATTRIBUTE_NAME, desc, //
|
||||
DEBUGGER_ATTRIBUTE_NAME, "lldb", //
|
||||
OS_MM_ATTRIBUTE_NAME, major + ":" + minor, //
|
||||
|
|
|
@ -22,9 +22,7 @@ import java.util.Map;
|
|||
import SWIG.SBStream;
|
||||
import SWIG.SBValue;
|
||||
import agent.lldb.model.iface2.LldbModelTargetStackFrameRegister;
|
||||
import ghidra.dbg.target.schema.TargetAttributeType;
|
||||
import ghidra.dbg.target.schema.TargetElementType;
|
||||
import ghidra.dbg.target.schema.TargetObjectSchemaInfo;
|
||||
import ghidra.dbg.target.schema.*;
|
||||
import ghidra.dbg.util.ConversionUtils;
|
||||
import ghidra.dbg.util.PathUtils;
|
||||
|
||||
|
@ -104,19 +102,23 @@ public class LldbModelTargetStackFrameRegisterImpl
|
|||
String[] split = trim.split(" ");
|
||||
value = split[0].substring(2) + split[1].substring(2);
|
||||
}
|
||||
BigInteger val = new BigInteger(value, 16);
|
||||
byte[] bytes = ConversionUtils.bigIntegerToBytes((int) getRegister().GetByteSize(), val);
|
||||
changeAttributes(List.of(), Map.of( //
|
||||
VALUE_ATTRIBUTE_NAME, value //
|
||||
), "Refreshed");
|
||||
if (val.longValue() != 0) {
|
||||
if (!value.equals("0")) {
|
||||
String newval = getDescription(0);
|
||||
changeAttributes(List.of(), Map.of( //
|
||||
DISPLAY_ATTRIBUTE_NAME, newval //
|
||||
), "Refreshed");
|
||||
setModified(!value.equals(oldValue));
|
||||
}
|
||||
return bytes;
|
||||
try {
|
||||
BigInteger val = new BigInteger(value, 16);
|
||||
byte[] bytes = ConversionUtils.bigIntegerToBytes((int) getRegister().GetByteSize(), val);
|
||||
return bytes;
|
||||
} catch (NumberFormatException nfe) {
|
||||
return new byte[0];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -138,12 +138,12 @@ public class LldbModelTargetThreadImpl extends LldbModelTargetObjectImpl
|
|||
|
||||
@Override
|
||||
public CompletableFuture<Void> step(TargetStepKind kind) {
|
||||
return getModel().gateFuture(getManager().execute(new LldbStepCommand(getManager(), null, kind, null)));
|
||||
return getModel().gateFuture(getManager().execute(new LldbStepCommand(getManager(), getThread(), kind, null)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> step(Map<String, ?> args) {
|
||||
return getModel().gateFuture(getManager().execute(new LldbStepCommand(getManager(), null, null, args)));
|
||||
return getModel().gateFuture(getManager().execute(new LldbStepCommand(getManager(), getThread(), null, args)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue