mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-06-01 06:16:45 +08:00
Merge remote-tracking branch 'origin/Ghidra_10.1'
This commit is contained in:
+13
-5
@@ -343,16 +343,24 @@ public class DebuggerStackProvider extends ComponentProviderAdapter {
|
||||
}
|
||||
|
||||
private void rowActivated(StackFrameRow row) {
|
||||
if (row == null) {
|
||||
return;
|
||||
}
|
||||
TraceStackFrame frame = row.frame;
|
||||
if (frame == null) {
|
||||
return;
|
||||
}
|
||||
TraceThread thread = frame.getStack().getThread();
|
||||
Trace trace = thread.getTrace();
|
||||
TraceRecorder recorder = modelService.getRecorder(trace);
|
||||
if (recorder != null) {
|
||||
TargetStackFrame targetFrame = recorder.getTargetStackFrame(thread, frame.getLevel());
|
||||
if (targetFrame != null && targetFrame.isValid()) {
|
||||
DebugModelConventions.requestActivation(targetFrame);
|
||||
}
|
||||
if (recorder == null) {
|
||||
return;
|
||||
}
|
||||
TargetStackFrame targetFrame = recorder.getTargetStackFrame(thread, frame.getLevel());
|
||||
if (targetFrame == null || !targetFrame.isValid()) {
|
||||
return;
|
||||
}
|
||||
DebugModelConventions.requestActivation(targetFrame);
|
||||
}
|
||||
|
||||
protected void createActions() {
|
||||
|
||||
+10
-5
@@ -521,15 +521,20 @@ public class DebuggerThreadsProvider extends ComponentProviderAdapter {
|
||||
}
|
||||
|
||||
private void rowActivated(ThreadRow row) {
|
||||
if (row == null) {
|
||||
return;
|
||||
}
|
||||
TraceThread thread = row.getThread();
|
||||
Trace trace = thread.getTrace();
|
||||
TraceRecorder recorder = modelService.getRecorder(trace);
|
||||
if (recorder != null) {
|
||||
TargetThread targetThread = recorder.getTargetThread(thread);
|
||||
if (targetThread != null && targetThread.isValid()) {
|
||||
DebugModelConventions.requestActivation(targetThread);
|
||||
}
|
||||
if (recorder == null) {
|
||||
return;
|
||||
}
|
||||
TargetThread targetThread = recorder.getTargetThread(thread);
|
||||
if (targetThread == null || !targetThread.isValid()) {
|
||||
return;
|
||||
}
|
||||
DebugModelConventions.requestActivation(targetThread);
|
||||
}
|
||||
|
||||
protected void buildMainPanel() {
|
||||
|
||||
+3
-3
@@ -152,10 +152,10 @@ public enum ProgramEmulationUtils {
|
||||
String modName = getModuleName(program);
|
||||
|
||||
// TODO: Do I populate modules, since the mapping will already be done?
|
||||
String path = "Modules[" + modName + "].Sections[" + block.getName() + "-" +
|
||||
block.getStart() + "]";
|
||||
trace.getMemoryManager()
|
||||
.createRegion(
|
||||
"Modules[" + modName + "].Sections[" + block.getName() + "]",
|
||||
snapshot.getKey(), range, getRegionFlags(block));
|
||||
.createRegion(path, snapshot.getKey(), range, getRegionFlags(block));
|
||||
}
|
||||
DebuggerStaticMappingUtils.addMapping(
|
||||
new DefaultTraceLocation(trace, null, Range.atLeast(snapshot.getKey()), min),
|
||||
|
||||
+5
-4
@@ -27,6 +27,7 @@ public class AsyncWrappedPcodeArithmetic<T> implements PcodeArithmetic<Completab
|
||||
new AsyncWrappedPcodeArithmetic<>(BytesPcodeArithmetic.BIG_ENDIAN);
|
||||
public static final AsyncWrappedPcodeArithmetic<byte[]> BYTES_LE =
|
||||
new AsyncWrappedPcodeArithmetic<>(BytesPcodeArithmetic.LITTLE_ENDIAN);
|
||||
@Deprecated(forRemoval = true) // TODO: Not getting used
|
||||
public static final AsyncWrappedPcodeArithmetic<BigInteger> BIGINT =
|
||||
new AsyncWrappedPcodeArithmetic<>(BigIntegerPcodeArithmetic.INSTANCE);
|
||||
|
||||
@@ -63,8 +64,8 @@ public class AsyncWrappedPcodeArithmetic<T> implements PcodeArithmetic<Completab
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<T> fromConst(BigInteger value, int size) {
|
||||
return CompletableFuture.completedFuture(arithmetic.fromConst(value, size));
|
||||
public CompletableFuture<T> fromConst(BigInteger value, int size, boolean isContextreg) {
|
||||
return CompletableFuture.completedFuture(arithmetic.fromConst(value, size, isContextreg));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,10 +77,10 @@ public class AsyncWrappedPcodeArithmetic<T> implements PcodeArithmetic<Completab
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger toConcrete(CompletableFuture<T> cond) {
|
||||
public BigInteger toConcrete(CompletableFuture<T> cond, boolean isContextreg) {
|
||||
if (!cond.isDone()) {
|
||||
throw new AssertionError("You need a better 8-ball");
|
||||
}
|
||||
return arithmetic.toConcrete(cond.getNow(null));
|
||||
return arithmetic.toConcrete(cond.getNow(null), isContextreg);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -46,7 +46,7 @@ public enum TraceMemoryStatePcodeArithmetic implements PcodeArithmetic<TraceMemo
|
||||
}
|
||||
|
||||
@Override
|
||||
public TraceMemoryState fromConst(BigInteger value, int size) {
|
||||
public TraceMemoryState fromConst(BigInteger value, int size, boolean isContextreg) {
|
||||
return TraceMemoryState.KNOWN;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public enum TraceMemoryStatePcodeArithmetic implements PcodeArithmetic<TraceMemo
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger toConcrete(TraceMemoryState value) {
|
||||
public BigInteger toConcrete(TraceMemoryState value, boolean isContextreg) {
|
||||
throw new AssertionError("Cannot make TraceMemoryState a 'concrete value'");
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -272,7 +272,7 @@ public class TracePcodeEmulatorTest extends AbstractGhidraHeadlessIntegrationTes
|
||||
emuThread.getState().getVar(pc));
|
||||
assertEquals(new RegisterValue(ctxreg, BigInteger.valueOf(0x8000_0000_0000_0000L)),
|
||||
emuThread.getContext());
|
||||
assertArrayEquals(tb.arr(0, 0, 0, 0, 0, 0, 0, 0x80),
|
||||
assertArrayEquals(tb.arr(0x80, 0, 0, 0, 0, 0, 0, 0),
|
||||
emuThread.getState().getVar(ctxreg));
|
||||
|
||||
emuThread.stepInstruction();
|
||||
|
||||
@@ -192,7 +192,7 @@ public class DefaultPcodeThread<T> implements PcodeThread<T> {
|
||||
assignContext(context);
|
||||
state.setVar(contextreg, arithmetic.fromConst(
|
||||
this.context.getUnsignedValueIgnoreMask(),
|
||||
contextreg.getMinimumByteSize()));
|
||||
contextreg.getMinimumByteSize(), true));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -215,7 +215,7 @@ public class DefaultPcodeThread<T> implements PcodeThread<T> {
|
||||
|
||||
if (contextreg != Register.NO_CONTEXT) {
|
||||
try {
|
||||
BigInteger ctx = arithmetic.toConcrete(state.getVar(contextreg));
|
||||
BigInteger ctx = arithmetic.toConcrete(state.getVar(contextreg), true);
|
||||
assignContext(new RegisterValue(contextreg, ctx));
|
||||
}
|
||||
catch (AccessPcodeExecutionException e) {
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ public enum AddressOfPcodeArithmetic implements PcodeArithmetic<Address> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Address fromConst(BigInteger value, int size) {
|
||||
public Address fromConst(BigInteger value, int size, boolean isContextreg) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public enum AddressOfPcodeArithmetic implements PcodeArithmetic<Address> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger toConcrete(Address value) {
|
||||
public BigInteger toConcrete(Address value, boolean isContextreg) {
|
||||
throw new AssertionError("Should not attempt to concretize 'address of'");
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -20,6 +20,7 @@ import java.math.BigInteger;
|
||||
import ghidra.pcode.opbehavior.BinaryOpBehavior;
|
||||
import ghidra.pcode.opbehavior.UnaryOpBehavior;
|
||||
|
||||
@Deprecated(forRemoval = true) // TODO: Not getting used
|
||||
public enum BigIntegerPcodeArithmetic implements PcodeArithmetic<BigInteger> {
|
||||
INSTANCE;
|
||||
|
||||
@@ -40,7 +41,7 @@ public enum BigIntegerPcodeArithmetic implements PcodeArithmetic<BigInteger> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger fromConst(BigInteger value, int size) {
|
||||
public BigInteger fromConst(BigInteger value, int size, boolean isContextreg) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -50,7 +51,7 @@ public enum BigIntegerPcodeArithmetic implements PcodeArithmetic<BigInteger> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger toConcrete(BigInteger value) {
|
||||
public BigInteger toConcrete(BigInteger value, boolean isContextreg) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -76,8 +76,8 @@ public enum BytesPcodeArithmetic implements PcodeArithmetic<byte[]> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] fromConst(BigInteger value, int size) {
|
||||
return Utils.bigIntegerToBytes(value, size, isBigEndian);
|
||||
public byte[] fromConst(BigInteger value, int size, boolean isContextreg) {
|
||||
return Utils.bigIntegerToBytes(value, size, isBigEndian || isContextreg);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,7 +91,7 @@ public enum BytesPcodeArithmetic implements PcodeArithmetic<byte[]> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger toConcrete(byte[] value) {
|
||||
return Utils.bytesToBigInteger(value, value.length, isBigEndian, false);
|
||||
public BigInteger toConcrete(byte[] value, boolean isContextreg) {
|
||||
return Utils.bytesToBigInteger(value, value.length, isBigEndian || isContextreg, false);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -66,9 +66,9 @@ public class PairedPcodeArithmetic<L, R> implements PcodeArithmetic<Pair<L, R>>
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<L, R> fromConst(BigInteger value, int size) {
|
||||
return new ImmutablePair<>(leftArith.fromConst(value, size),
|
||||
rightArith.fromConst(value, size));
|
||||
public Pair<L, R> fromConst(BigInteger value, int size, boolean isContextreg) {
|
||||
return new ImmutablePair<>(leftArith.fromConst(value, size, isContextreg),
|
||||
rightArith.fromConst(value, size, isContextreg));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,8 +77,8 @@ public class PairedPcodeArithmetic<L, R> implements PcodeArithmetic<Pair<L, R>>
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger toConcrete(Pair<L, R> value) {
|
||||
return leftArith.toConcrete(value.getLeft());
|
||||
public BigInteger toConcrete(Pair<L, R> value, boolean isContextreg) {
|
||||
return leftArith.toConcrete(value.getLeft(), isContextreg);
|
||||
}
|
||||
|
||||
public PcodeArithmetic<L> getLeft() {
|
||||
|
||||
@@ -23,6 +23,7 @@ import ghidra.pcode.opbehavior.UnaryOpBehavior;
|
||||
public interface PcodeArithmetic<T> {
|
||||
PcodeArithmetic<byte[]> BYTES_BE = BytesPcodeArithmetic.BIG_ENDIAN;
|
||||
PcodeArithmetic<byte[]> BYTES_LE = BytesPcodeArithmetic.LITTLE_ENDIAN;
|
||||
@Deprecated(forRemoval = true) // TODO: Not getting used
|
||||
PcodeArithmetic<BigInteger> BIGINT = BigIntegerPcodeArithmetic.INSTANCE;
|
||||
|
||||
T unaryOp(UnaryOpBehavior op, int sizeout, int sizein1, T in1);
|
||||
@@ -31,7 +32,11 @@ public interface PcodeArithmetic<T> {
|
||||
|
||||
T fromConst(long value, int size);
|
||||
|
||||
T fromConst(BigInteger value, int size);
|
||||
T fromConst(BigInteger value, int size, boolean isContextreg);
|
||||
|
||||
default T fromConst(BigInteger value, int size) {
|
||||
return fromConst(value, size, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make concrete, if possible, the given abstract condition to a boolean value
|
||||
@@ -49,7 +54,24 @@ public interface PcodeArithmetic<T> {
|
||||
* exception to throw and/or establish a hierarchy of checked exceptions.
|
||||
*
|
||||
* @param value the abstract value
|
||||
* @param isContextreg true to indicate the value is from the disassembly context register. If
|
||||
* {@code T} represents bytes, and the value is the contextreg, then the bytes are in
|
||||
* big endian, no matter the machine language's endianness.
|
||||
* @return the concrete value
|
||||
*/
|
||||
BigInteger toConcrete(T value);
|
||||
BigInteger toConcrete(T value, boolean isContextreg);
|
||||
|
||||
/**
|
||||
* Make concrete, if possible, the given abstract value
|
||||
*
|
||||
* <p>
|
||||
* If the conversion is not possible, throw an exception. TODO: Decide on conventions of which
|
||||
* exception to throw and/or establish a hierarchy of checked exceptions.
|
||||
*
|
||||
* @param value the abstract value
|
||||
* @return the concrete value
|
||||
*/
|
||||
default BigInteger toConcrete(T value) {
|
||||
return toConcrete(value, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user