mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
GP-822: Fixed issue with GDB when launched process terminates immediately.
This commit is contained in:
parent
fcc0d97ae0
commit
cac43030eb
5 changed files with 34 additions and 12 deletions
|
@ -70,7 +70,8 @@ public class GdbManagerImpl implements GdbManager {
|
|||
CLI, MI2;
|
||||
}
|
||||
|
||||
private static final boolean LOG_IO = true;
|
||||
private static final boolean LOG_IO =
|
||||
Boolean.parseBoolean(System.getProperty("agent.gdb.manager.log"));
|
||||
private static final PrintWriter DBG_LOG;
|
||||
static {
|
||||
if (LOG_IO) {
|
||||
|
@ -838,7 +839,7 @@ public class GdbManagerImpl implements GdbManager {
|
|||
throw new RuntimeException("GDB gave an unrecognized response", e);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
Msg.warn(this, e.getMessage());
|
||||
Msg.warn(this, "Error processing GDB output", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,11 @@ public class GdbGetThreadInfoCommand extends AbstractGdbCommandWithThreadId<GdbT
|
|||
return "-thread-info " + threadId; // Note the trailing space
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer impliesCurrentThreadId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(GdbEvent<?> evt, GdbPendingCommand<?> pending) {
|
||||
if (evt instanceof AbstractGdbCompletedCommandEvent) {
|
||||
|
|
|
@ -222,20 +222,34 @@ public class GdbModelTargetInferior
|
|||
protected CompletableFuture<Void> inferiorStarted(Long pid) {
|
||||
parent.getListeners().fire.event(
|
||||
parent, null, TargetEventType.PROCESS_CREATED, "Inferior " + inferior.getId() +
|
||||
" started " + inferior.getExecutable() + " pid=" + inferior.getPid(),
|
||||
" started " + inferior.getExecutable() + " pid=" + pid,
|
||||
List.of(this));
|
||||
AsyncFence fence = new AsyncFence();
|
||||
fence.include(modules.refreshInternal());
|
||||
//fence.include(registers.refreshInternal());
|
||||
fence.include(environment.refreshInternal());
|
||||
fence.include(impl.gdb.listInferiors()); // HACK to update inferior.getExecutable()
|
||||
// NB. Hack also updates inferior.getPid(), so ignore pid parameter
|
||||
return fence.ready().thenAccept(__ -> {
|
||||
changeAttributes(List.of(),
|
||||
Map.ofEntries(Map.entry(STATE_ATTRIBUTE_NAME, state = realState),
|
||||
Map.entry(PID_ATTRIBUTE_NAME, inferior.getPid()),
|
||||
Map.entry(DISPLAY_ATTRIBUTE_NAME, updateDisplay())),
|
||||
"Refresh on started");
|
||||
// NB. Hack also updates inferior.getPid()
|
||||
Long p = pid;
|
||||
if (p == null) {
|
||||
// Might have become null if it quickly terminates
|
||||
// Also, we should save it before waiting on the refresh
|
||||
p = inferior.getPid();
|
||||
}
|
||||
if (p == null) {
|
||||
changeAttributes(List.of(),
|
||||
Map.ofEntries(Map.entry(STATE_ATTRIBUTE_NAME, state = realState),
|
||||
Map.entry(DISPLAY_ATTRIBUTE_NAME, updateDisplay())),
|
||||
"Refresh on started");
|
||||
}
|
||||
else {
|
||||
changeAttributes(List.of(),
|
||||
Map.ofEntries(Map.entry(STATE_ATTRIBUTE_NAME, state = realState),
|
||||
Map.entry(PID_ATTRIBUTE_NAME, p),
|
||||
Map.entry(DISPLAY_ATTRIBUTE_NAME, updateDisplay())),
|
||||
"Refresh on started");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue