mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
Merge remote-tracking branch 'origin/GP-2781_d-millar_lldb_fixes--SQUASHED'
This commit is contained in:
commit
da9e178765
9 changed files with 42 additions and 16 deletions
|
@ -385,7 +385,7 @@ public interface DebugClient extends DebugClientReentrant {
|
||||||
|
|
||||||
SBProcess attachProcess(DebugServerId si, int keyType, String key, boolean wait, boolean async);
|
SBProcess attachProcess(DebugServerId si, int keyType, String key, boolean wait, boolean async);
|
||||||
|
|
||||||
SBProcess connectRemote(DebugServerId localServer, String key, boolean async);
|
SBProcess connectRemote(DebugServerId localServer, String key, boolean auto, boolean async);
|
||||||
|
|
||||||
SBProcess createProcess(DebugServerId si, String fileName);
|
SBProcess createProcess(DebugServerId si, String fileName);
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import SWIG.*;
|
||||||
import agent.lldb.manager.LldbEvent;
|
import agent.lldb.manager.LldbEvent;
|
||||||
import agent.lldb.manager.LldbManager;
|
import agent.lldb.manager.LldbManager;
|
||||||
import agent.lldb.manager.evt.*;
|
import agent.lldb.manager.evt.*;
|
||||||
|
import agent.lldb.manager.impl.LldbManagerImpl;
|
||||||
import ghidra.util.Msg;
|
import ghidra.util.Msg;
|
||||||
|
|
||||||
public class DebugClientImpl implements DebugClient {
|
public class DebugClientImpl implements DebugClient {
|
||||||
|
@ -112,10 +113,14 @@ public class DebugClientImpl implements DebugClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SBProcess connectRemote(DebugServerId si, String key, boolean async) {
|
public SBProcess connectRemote(DebugServerId si, String key, boolean auto, boolean async) {
|
||||||
SBListener listener = new SBListener();
|
SBListener listener = new SBListener();
|
||||||
SBError error = new SBError();
|
SBError error = new SBError();
|
||||||
session = createNullSession();
|
session = createNullSession();
|
||||||
|
if (!auto) {
|
||||||
|
((LldbManagerImpl) manager).addSessionIfAbsent(session);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
SBProcess process = session.ConnectRemote(listener, key, null, error);
|
SBProcess process = session.ConnectRemote(listener, key, null, error);
|
||||||
if (!error.Success()) {
|
if (!error.Success()) {
|
||||||
Msg.error(this, error.GetType() + " while attaching to " + key);
|
Msg.error(this, error.GetType() + " while attaching to " + key);
|
||||||
|
|
|
@ -404,7 +404,7 @@ public interface LldbManager extends AutoCloseable, LldbBreakpointInsertions {
|
||||||
|
|
||||||
CompletableFuture<?> attach(String url, boolean wait, boolean async);
|
CompletableFuture<?> attach(String url, boolean wait, boolean async);
|
||||||
|
|
||||||
CompletableFuture<?> connect(String url, boolean async);
|
CompletableFuture<?> connect(String url, boolean auto, boolean async);
|
||||||
|
|
||||||
CompletableFuture<?> launch(String fileName, List<String> args);
|
CompletableFuture<?> launch(String fileName, List<String> args);
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,9 @@ public class LldbListAvailableProcessesCommand
|
||||||
for (int i = 3; i < lines.length; i++) {
|
for (int i = 3; i < lines.length; i++) {
|
||||||
String[] fields = lines[i].split("\\s+");
|
String[] fields = lines[i].split("\\s+");
|
||||||
try {
|
try {
|
||||||
result.add(new ImmutablePair<String,String>(fields[0], fields[fields.length-1]));
|
if (fields[0].matches("[0-9]+") && fields[1].matches("[0-9]+")) {
|
||||||
|
result.add(new ImmutablePair<String,String>(fields[0], fields[fields.length-1]));
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Msg.error(this, e.getMessage());
|
Msg.error(this, e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,15 +33,19 @@ public class LldbRemoteConnectionCommand extends AbstractLldbCommand<Set<SBThrea
|
||||||
private LldbProcessCreatedEvent created = null;
|
private LldbProcessCreatedEvent created = null;
|
||||||
private boolean completed = false;
|
private boolean completed = false;
|
||||||
private String key;
|
private String key;
|
||||||
|
private boolean auto = true;
|
||||||
private boolean async = false;
|
private boolean async = false;
|
||||||
|
|
||||||
public LldbRemoteConnectionCommand(LldbManagerImpl manager, String key) {
|
public LldbRemoteConnectionCommand(LldbManagerImpl manager, String key) {
|
||||||
this(manager, key, false);
|
this(manager, key, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LldbRemoteConnectionCommand(LldbManagerImpl manager, String key, boolean async) {
|
public LldbRemoteConnectionCommand(LldbManagerImpl manager, String key, boolean auto,
|
||||||
|
boolean async) {
|
||||||
super(manager);
|
super(manager);
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
this.auto = auto;
|
||||||
|
this.async = async;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -74,6 +78,6 @@ public class LldbRemoteConnectionCommand extends AbstractLldbCommand<Set<SBThrea
|
||||||
@Override
|
@Override
|
||||||
public void invoke() {
|
public void invoke() {
|
||||||
DebugClient client = manager.getClient();
|
DebugClient client = manager.getClient();
|
||||||
client.connectRemote(client.getLocalServer(), key, async);
|
client.connectRemote(client.getLocalServer(), key, auto, async);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,12 +228,15 @@ public class LldbManagerImpl implements LldbManager {
|
||||||
if (process.IsValid()) {
|
if (process.IsValid()) {
|
||||||
DebugProcessInfo info = new DebugProcessInfo(process);
|
DebugProcessInfo info = new DebugProcessInfo(process);
|
||||||
if (!map.containsKey(id)) {
|
if (!map.containsKey(id)) {
|
||||||
getClient().processEvent(new LldbProcessCreatedEvent(info));
|
if (!info.state.equals(StateType.eStateUnloaded)) {
|
||||||
|
getClient().processEvent(new LldbProcessCreatedEvent(info));
|
||||||
|
map.put(id, process);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
getClient().processEvent(new LldbProcessReplacedEvent(info));
|
getClient().processEvent(new LldbProcessReplacedEvent(info));
|
||||||
|
map.put(id, process);
|
||||||
}
|
}
|
||||||
map.put(id, process);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -268,6 +271,7 @@ public class LldbManagerImpl implements LldbManager {
|
||||||
|
|
||||||
public void addSessionIfAbsent(SBTarget session) {
|
public void addSessionIfAbsent(SBTarget session) {
|
||||||
synchronized (sessions) {
|
synchronized (sessions) {
|
||||||
|
this.currentSession = eventSession = session;
|
||||||
String id = DebugClient.getId(session);
|
String id = DebugClient.getId(session);
|
||||||
SBTarget pred = sessions.get(id);
|
SBTarget pred = sessions.get(id);
|
||||||
if (!sessions.containsKey(id) || !session.equals(pred)) {
|
if (!sessions.containsKey(id) || !session.equals(pred)) {
|
||||||
|
@ -1078,7 +1082,9 @@ public class LldbManagerImpl implements LldbManager {
|
||||||
}
|
}
|
||||||
if (status.equals(DebugStatus.GO)) {
|
if (status.equals(DebugStatus.GO)) {
|
||||||
waiting = true;
|
waiting = true;
|
||||||
processEvent(new LldbRunningEvent(DebugClient.getId(eventThread)));
|
if (eventThread != null) {
|
||||||
|
processEvent(new LldbRunningEvent(DebugClient.getId(eventThread)));
|
||||||
|
}
|
||||||
return DebugStatus.GO;
|
return DebugStatus.GO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1471,8 +1477,8 @@ public class LldbManagerImpl implements LldbManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<?> connect(String url, boolean async) {
|
public CompletableFuture<?> connect(String url, boolean auto, boolean async) {
|
||||||
return execute(new LldbRemoteConnectionCommand(this, url, async));
|
return execute(new LldbRemoteConnectionCommand(this, url, auto, async));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -91,7 +91,9 @@ public class LldbModelTargetModuleSectionContainerImpl extends LldbModelTargetOb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.setRange(new AddressRangeImpl(min, max));
|
if (min != null && max != null) {
|
||||||
|
module.setRange(new AddressRangeImpl(min, max));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SBModule getModule() {
|
public SBModule getModule() {
|
||||||
|
|
|
@ -70,8 +70,11 @@ public class LldbModelTargetProcessRemoteConnectorImpl extends LldbModelTargetOb
|
||||||
String.class, "Port", true, "12345", "Port", "port for connection");
|
String.class, "Port", true, "12345", "Port", "port for connection");
|
||||||
map.put("Port", p1);
|
map.put("Port", p1);
|
||||||
ParameterDescription<Boolean> p2 = ParameterDescription.create(
|
ParameterDescription<Boolean> p2 = ParameterDescription.create(
|
||||||
|
Boolean.class, "Auto", false, true, "Auto", "connect automatically");
|
||||||
|
map.put("Auto", p2);
|
||||||
|
ParameterDescription<Boolean> p3 = ParameterDescription.create(
|
||||||
Boolean.class, "Async", false, true, "Async", "connect asynchronously");
|
Boolean.class, "Async", false, true, "Async", "connect asynchronously");
|
||||||
map.put("Async", p2);
|
map.put("Async", p3);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,10 +87,11 @@ public class LldbModelTargetProcessRemoteConnectorImpl extends LldbModelTargetOb
|
||||||
public CompletableFuture<Void> launch(Map<String, ?> args) {
|
public CompletableFuture<Void> launch(Map<String, ?> args) {
|
||||||
String host = (String) args.get("Host");
|
String host = (String) args.get("Host");
|
||||||
String port = (String) args.get("Port");
|
String port = (String) args.get("Port");
|
||||||
String url = "connect://"+host+":"+port;
|
String url = "connect://" + host + ":" + port;
|
||||||
|
Boolean auto = (Boolean) args.get("Auto");
|
||||||
Boolean async = (Boolean) args.get("Async");
|
Boolean async = (Boolean) args.get("Async");
|
||||||
return AsyncUtils.sequence(TypeSpec.VOID).then(seq -> {
|
return AsyncUtils.sequence(TypeSpec.VOID).then(seq -> {
|
||||||
getManager().connect(url, async).handle(seq::nextIgnore);
|
getManager().connect(url, auto, async).handle(seq::nextIgnore);
|
||||||
}).finish().exceptionally((exc) -> {
|
}).finish().exceptionally((exc) -> {
|
||||||
throw new DebuggerUserException("Launch failed for " + args);
|
throw new DebuggerUserException("Launch failed for " + args);
|
||||||
});
|
});
|
||||||
|
|
|
@ -73,6 +73,9 @@ public class LldbModelTargetSessionAttributesPlatformImpl extends LldbModelTarge
|
||||||
desc = "unknown";
|
desc = "unknown";
|
||||||
}
|
}
|
||||||
String wdir = platform.GetWorkingDirectory();
|
String wdir = platform.GetWorkingDirectory();
|
||||||
|
if (wdir == null) {
|
||||||
|
wdir = "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
changeAttributes(List.of(), List.of(), Map.of( //
|
changeAttributes(List.of(), List.of(), Map.of( //
|
||||||
ARCH_ATTRIBUTE_NAME, triple[0], //
|
ARCH_ATTRIBUTE_NAME, triple[0], //
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue