mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
GP-1808: Added 'Run to Address'-type actions to right-click menu for some connectors.
This commit is contained in:
parent
44d7c4f031
commit
bde529b4d5
39 changed files with 1663 additions and 136 deletions
|
@ -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 agent.lldb.manager.cmd;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
import SWIG.*;
|
||||
import agent.lldb.manager.LldbEvent;
|
||||
import agent.lldb.manager.evt.*;
|
||||
import agent.lldb.manager.impl.LldbManagerImpl;
|
||||
import ghidra.util.Msg;
|
||||
|
||||
public class LldbRunToAddressCommand extends AbstractLldbCommand<Void> {
|
||||
|
||||
private SBThread thread;
|
||||
private final BigInteger addr;
|
||||
|
||||
public LldbRunToAddressCommand(LldbManagerImpl manager, SBThread thread, BigInteger addr) {
|
||||
super(manager);
|
||||
this.thread = thread;
|
||||
this.addr = addr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(LldbEvent<?> evt, LldbPendingCommand<?> pending) {
|
||||
if (evt instanceof AbstractLldbCompletedCommandEvent && pending.getCommand().equals(this)) {
|
||||
return evt instanceof LldbCommandErrorEvent ||
|
||||
!pending.findAllOf(LldbRunningEvent.class).isEmpty();
|
||||
}
|
||||
else if (evt instanceof LldbRunningEvent) {
|
||||
// Event happens no matter which interpreter received the command
|
||||
pending.claim(evt);
|
||||
return !pending.findAllOf(AbstractLldbCompletedCommandEvent.class).isEmpty();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke() {
|
||||
if (thread == null || !thread.IsValid()) {
|
||||
thread = manager.getCurrentThread();
|
||||
}
|
||||
SBError error = new SBError();
|
||||
thread.RunToAddress(addr, error);
|
||||
if (!error.Success()) {
|
||||
SBStream stream = new SBStream();
|
||||
error.GetDescription(stream);
|
||||
Msg.error(this, error.GetType() + " while running to address: " + stream.GetData());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -86,11 +86,6 @@ public class LldbStepCommand extends AbstractLldbCommand<Void> {
|
|||
case FINISH:
|
||||
thread.StepOutOfFrame(thread.GetSelectedFrame(), error);
|
||||
break;
|
||||
case ADVANCE:
|
||||
SBFileSpec file = (SBFileSpec) args.get("File");
|
||||
long line = (long) args.get("Line");
|
||||
error = thread.StepOverUntil(thread.GetSelectedFrame(), file, line);
|
||||
break;
|
||||
case EXTENDED:
|
||||
manager.execute(new LldbEvaluateCommand(manager, lastCommand));
|
||||
break;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package agent.lldb.model.impl;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
@ -24,13 +25,16 @@ import agent.lldb.lldb.DebugClient;
|
|||
import agent.lldb.manager.LldbCause;
|
||||
import agent.lldb.manager.LldbReason;
|
||||
import agent.lldb.manager.LldbReason.Reasons;
|
||||
import agent.lldb.manager.cmd.LldbRunToAddressCommand;
|
||||
import agent.lldb.manager.cmd.LldbStepCommand;
|
||||
import agent.lldb.model.iface1.LldbModelTargetFocusScope;
|
||||
import agent.lldb.model.iface2.*;
|
||||
import ghidra.dbg.target.*;
|
||||
import ghidra.dbg.target.TargetMethod.AnnotatedTargetMethod;
|
||||
import ghidra.dbg.target.schema.*;
|
||||
import ghidra.dbg.target.schema.TargetObjectSchema.ResyncMode;
|
||||
import ghidra.dbg.util.PathUtils;
|
||||
import ghidra.program.model.address.Address;
|
||||
|
||||
@TargetObjectSchemaInfo(
|
||||
name = "Thread",
|
||||
|
@ -49,7 +53,6 @@ public class LldbModelTargetThreadImpl extends LldbModelTargetObjectImpl
|
|||
implements LldbModelTargetThread {
|
||||
|
||||
public static final TargetStepKindSet SUPPORTED_KINDS = TargetStepKindSet.of( //
|
||||
TargetStepKind.ADVANCE, //
|
||||
TargetStepKind.FINISH, //
|
||||
TargetStepKind.LINE, //
|
||||
TargetStepKind.OVER, //
|
||||
|
@ -82,6 +85,9 @@ public class LldbModelTargetThreadImpl extends LldbModelTargetObjectImpl
|
|||
|
||||
this.stack = new LldbModelTargetStackImpl(this, process);
|
||||
|
||||
changeAttributes(List.of(), List.of(),
|
||||
AnnotatedTargetMethod.collectExports(MethodHandles.lookup(), threads.getModel(), this),
|
||||
"Methods");
|
||||
changeAttributes(List.of(), List.of( //
|
||||
stack //
|
||||
), Map.of( //
|
||||
|
@ -102,6 +108,7 @@ public class LldbModelTargetThreadImpl extends LldbModelTargetObjectImpl
|
|||
getModel().addModelObject(modelObject, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription(int level) {
|
||||
SBStream stream = new SBStream();
|
||||
SBThread thread = (SBThread) getModelObject();
|
||||
|
@ -114,8 +121,9 @@ public class LldbModelTargetThreadImpl extends LldbModelTargetObjectImpl
|
|||
String tidstr = DebugClient.getId(getThread());
|
||||
if (base == 16) {
|
||||
tidstr = "0x" + tidstr;
|
||||
} else {
|
||||
tidstr = Long.toString(Long.parseLong(tidstr,16));
|
||||
}
|
||||
else {
|
||||
tidstr = Long.toString(Long.parseLong(tidstr, 16));
|
||||
}
|
||||
return "[" + tidstr + "]";
|
||||
}
|
||||
|
@ -138,12 +146,25 @@ public class LldbModelTargetThreadImpl extends LldbModelTargetObjectImpl
|
|||
|
||||
@Override
|
||||
public CompletableFuture<Void> step(TargetStepKind kind) {
|
||||
return getModel().gateFuture(getManager().execute(new LldbStepCommand(getManager(), getThread(), 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(), getThread(), null, args)));
|
||||
return getModel().gateFuture(
|
||||
getManager().execute(new LldbStepCommand(getManager(), getThread(), null, args)));
|
||||
}
|
||||
|
||||
@TargetMethod.Export("Run to Address")
|
||||
public CompletableFuture<Void> runToAddress(
|
||||
@TargetMethod.Param(
|
||||
description = "The target address",
|
||||
display = "Address",
|
||||
name = "address") Address address) {
|
||||
return getModel().gateFuture(
|
||||
getManager().execute(new LldbRunToAddressCommand(getManager(), getThread(),
|
||||
address.getOffsetAsBigInteger())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue