mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-06-01 13:24:41 +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) {
|
private void rowActivated(StackFrameRow row) {
|
||||||
|
if (row == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
TraceStackFrame frame = row.frame;
|
TraceStackFrame frame = row.frame;
|
||||||
|
if (frame == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
TraceThread thread = frame.getStack().getThread();
|
TraceThread thread = frame.getStack().getThread();
|
||||||
Trace trace = thread.getTrace();
|
Trace trace = thread.getTrace();
|
||||||
TraceRecorder recorder = modelService.getRecorder(trace);
|
TraceRecorder recorder = modelService.getRecorder(trace);
|
||||||
if (recorder != null) {
|
if (recorder == null) {
|
||||||
TargetStackFrame targetFrame = recorder.getTargetStackFrame(thread, frame.getLevel());
|
return;
|
||||||
if (targetFrame != null && targetFrame.isValid()) {
|
|
||||||
DebugModelConventions.requestActivation(targetFrame);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
TargetStackFrame targetFrame = recorder.getTargetStackFrame(thread, frame.getLevel());
|
||||||
|
if (targetFrame == null || !targetFrame.isValid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DebugModelConventions.requestActivation(targetFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createActions() {
|
protected void createActions() {
|
||||||
|
|||||||
+10
-5
@@ -521,15 +521,20 @@ public class DebuggerThreadsProvider extends ComponentProviderAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void rowActivated(ThreadRow row) {
|
private void rowActivated(ThreadRow row) {
|
||||||
|
if (row == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
TraceThread thread = row.getThread();
|
TraceThread thread = row.getThread();
|
||||||
Trace trace = thread.getTrace();
|
Trace trace = thread.getTrace();
|
||||||
TraceRecorder recorder = modelService.getRecorder(trace);
|
TraceRecorder recorder = modelService.getRecorder(trace);
|
||||||
if (recorder != null) {
|
if (recorder == null) {
|
||||||
TargetThread targetThread = recorder.getTargetThread(thread);
|
return;
|
||||||
if (targetThread != null && targetThread.isValid()) {
|
|
||||||
DebugModelConventions.requestActivation(targetThread);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
TargetThread targetThread = recorder.getTargetThread(thread);
|
||||||
|
if (targetThread == null || !targetThread.isValid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DebugModelConventions.requestActivation(targetThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void buildMainPanel() {
|
protected void buildMainPanel() {
|
||||||
|
|||||||
+3
-3
@@ -152,10 +152,10 @@ public enum ProgramEmulationUtils {
|
|||||||
String modName = getModuleName(program);
|
String modName = getModuleName(program);
|
||||||
|
|
||||||
// TODO: Do I populate modules, since the mapping will already be done?
|
// TODO: Do I populate modules, since the mapping will already be done?
|
||||||
|
String path = "Modules[" + modName + "].Sections[" + block.getName() + "-" +
|
||||||
|
block.getStart() + "]";
|
||||||
trace.getMemoryManager()
|
trace.getMemoryManager()
|
||||||
.createRegion(
|
.createRegion(path, snapshot.getKey(), range, getRegionFlags(block));
|
||||||
"Modules[" + modName + "].Sections[" + block.getName() + "]",
|
|
||||||
snapshot.getKey(), range, getRegionFlags(block));
|
|
||||||
}
|
}
|
||||||
DebuggerStaticMappingUtils.addMapping(
|
DebuggerStaticMappingUtils.addMapping(
|
||||||
new DefaultTraceLocation(trace, null, Range.atLeast(snapshot.getKey()), min),
|
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);
|
new AsyncWrappedPcodeArithmetic<>(BytesPcodeArithmetic.BIG_ENDIAN);
|
||||||
public static final AsyncWrappedPcodeArithmetic<byte[]> BYTES_LE =
|
public static final AsyncWrappedPcodeArithmetic<byte[]> BYTES_LE =
|
||||||
new AsyncWrappedPcodeArithmetic<>(BytesPcodeArithmetic.LITTLE_ENDIAN);
|
new AsyncWrappedPcodeArithmetic<>(BytesPcodeArithmetic.LITTLE_ENDIAN);
|
||||||
|
@Deprecated(forRemoval = true) // TODO: Not getting used
|
||||||
public static final AsyncWrappedPcodeArithmetic<BigInteger> BIGINT =
|
public static final AsyncWrappedPcodeArithmetic<BigInteger> BIGINT =
|
||||||
new AsyncWrappedPcodeArithmetic<>(BigIntegerPcodeArithmetic.INSTANCE);
|
new AsyncWrappedPcodeArithmetic<>(BigIntegerPcodeArithmetic.INSTANCE);
|
||||||
|
|
||||||
@@ -63,8 +64,8 @@ public class AsyncWrappedPcodeArithmetic<T> implements PcodeArithmetic<Completab
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<T> fromConst(BigInteger value, int size) {
|
public CompletableFuture<T> fromConst(BigInteger value, int size, boolean isContextreg) {
|
||||||
return CompletableFuture.completedFuture(arithmetic.fromConst(value, size));
|
return CompletableFuture.completedFuture(arithmetic.fromConst(value, size, isContextreg));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -76,10 +77,10 @@ public class AsyncWrappedPcodeArithmetic<T> implements PcodeArithmetic<Completab
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigInteger toConcrete(CompletableFuture<T> cond) {
|
public BigInteger toConcrete(CompletableFuture<T> cond, boolean isContextreg) {
|
||||||
if (!cond.isDone()) {
|
if (!cond.isDone()) {
|
||||||
throw new AssertionError("You need a better 8-ball");
|
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
|
@Override
|
||||||
public TraceMemoryState fromConst(BigInteger value, int size) {
|
public TraceMemoryState fromConst(BigInteger value, int size, boolean isContextreg) {
|
||||||
return TraceMemoryState.KNOWN;
|
return TraceMemoryState.KNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ public enum TraceMemoryStatePcodeArithmetic implements PcodeArithmetic<TraceMemo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigInteger toConcrete(TraceMemoryState value) {
|
public BigInteger toConcrete(TraceMemoryState value, boolean isContextreg) {
|
||||||
throw new AssertionError("Cannot make TraceMemoryState a 'concrete value'");
|
throw new AssertionError("Cannot make TraceMemoryState a 'concrete value'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -272,7 +272,7 @@ public class TracePcodeEmulatorTest extends AbstractGhidraHeadlessIntegrationTes
|
|||||||
emuThread.getState().getVar(pc));
|
emuThread.getState().getVar(pc));
|
||||||
assertEquals(new RegisterValue(ctxreg, BigInteger.valueOf(0x8000_0000_0000_0000L)),
|
assertEquals(new RegisterValue(ctxreg, BigInteger.valueOf(0x8000_0000_0000_0000L)),
|
||||||
emuThread.getContext());
|
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.getState().getVar(ctxreg));
|
||||||
|
|
||||||
emuThread.stepInstruction();
|
emuThread.stepInstruction();
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ public class DefaultPcodeThread<T> implements PcodeThread<T> {
|
|||||||
assignContext(context);
|
assignContext(context);
|
||||||
state.setVar(contextreg, arithmetic.fromConst(
|
state.setVar(contextreg, arithmetic.fromConst(
|
||||||
this.context.getUnsignedValueIgnoreMask(),
|
this.context.getUnsignedValueIgnoreMask(),
|
||||||
contextreg.getMinimumByteSize()));
|
contextreg.getMinimumByteSize(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -215,7 +215,7 @@ public class DefaultPcodeThread<T> implements PcodeThread<T> {
|
|||||||
|
|
||||||
if (contextreg != Register.NO_CONTEXT) {
|
if (contextreg != Register.NO_CONTEXT) {
|
||||||
try {
|
try {
|
||||||
BigInteger ctx = arithmetic.toConcrete(state.getVar(contextreg));
|
BigInteger ctx = arithmetic.toConcrete(state.getVar(contextreg), true);
|
||||||
assignContext(new RegisterValue(contextreg, ctx));
|
assignContext(new RegisterValue(contextreg, ctx));
|
||||||
}
|
}
|
||||||
catch (AccessPcodeExecutionException e) {
|
catch (AccessPcodeExecutionException e) {
|
||||||
|
|||||||
+2
-2
@@ -42,7 +42,7 @@ public enum AddressOfPcodeArithmetic implements PcodeArithmetic<Address> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Address fromConst(BigInteger value, int size) {
|
public Address fromConst(BigInteger value, int size, boolean isContextreg) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ public enum AddressOfPcodeArithmetic implements PcodeArithmetic<Address> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigInteger toConcrete(Address value) {
|
public BigInteger toConcrete(Address value, boolean isContextreg) {
|
||||||
throw new AssertionError("Should not attempt to concretize 'address of'");
|
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.BinaryOpBehavior;
|
||||||
import ghidra.pcode.opbehavior.UnaryOpBehavior;
|
import ghidra.pcode.opbehavior.UnaryOpBehavior;
|
||||||
|
|
||||||
|
@Deprecated(forRemoval = true) // TODO: Not getting used
|
||||||
public enum BigIntegerPcodeArithmetic implements PcodeArithmetic<BigInteger> {
|
public enum BigIntegerPcodeArithmetic implements PcodeArithmetic<BigInteger> {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ public enum BigIntegerPcodeArithmetic implements PcodeArithmetic<BigInteger> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigInteger fromConst(BigInteger value, int size) {
|
public BigInteger fromConst(BigInteger value, int size, boolean isContextreg) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ public enum BigIntegerPcodeArithmetic implements PcodeArithmetic<BigInteger> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigInteger toConcrete(BigInteger value) {
|
public BigInteger toConcrete(BigInteger value, boolean isContextreg) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -76,8 +76,8 @@ public enum BytesPcodeArithmetic implements PcodeArithmetic<byte[]> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] fromConst(BigInteger value, int size) {
|
public byte[] fromConst(BigInteger value, int size, boolean isContextreg) {
|
||||||
return Utils.bigIntegerToBytes(value, size, isBigEndian);
|
return Utils.bigIntegerToBytes(value, size, isBigEndian || isContextreg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -91,7 +91,7 @@ public enum BytesPcodeArithmetic implements PcodeArithmetic<byte[]> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigInteger toConcrete(byte[] value) {
|
public BigInteger toConcrete(byte[] value, boolean isContextreg) {
|
||||||
return Utils.bytesToBigInteger(value, value.length, isBigEndian, false);
|
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
|
@Override
|
||||||
public Pair<L, R> fromConst(BigInteger value, int size) {
|
public Pair<L, R> fromConst(BigInteger value, int size, boolean isContextreg) {
|
||||||
return new ImmutablePair<>(leftArith.fromConst(value, size),
|
return new ImmutablePair<>(leftArith.fromConst(value, size, isContextreg),
|
||||||
rightArith.fromConst(value, size));
|
rightArith.fromConst(value, size, isContextreg));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -77,8 +77,8 @@ public class PairedPcodeArithmetic<L, R> implements PcodeArithmetic<Pair<L, R>>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigInteger toConcrete(Pair<L, R> value) {
|
public BigInteger toConcrete(Pair<L, R> value, boolean isContextreg) {
|
||||||
return leftArith.toConcrete(value.getLeft());
|
return leftArith.toConcrete(value.getLeft(), isContextreg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PcodeArithmetic<L> getLeft() {
|
public PcodeArithmetic<L> getLeft() {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import ghidra.pcode.opbehavior.UnaryOpBehavior;
|
|||||||
public interface PcodeArithmetic<T> {
|
public interface PcodeArithmetic<T> {
|
||||||
PcodeArithmetic<byte[]> BYTES_BE = BytesPcodeArithmetic.BIG_ENDIAN;
|
PcodeArithmetic<byte[]> BYTES_BE = BytesPcodeArithmetic.BIG_ENDIAN;
|
||||||
PcodeArithmetic<byte[]> BYTES_LE = BytesPcodeArithmetic.LITTLE_ENDIAN;
|
PcodeArithmetic<byte[]> BYTES_LE = BytesPcodeArithmetic.LITTLE_ENDIAN;
|
||||||
|
@Deprecated(forRemoval = true) // TODO: Not getting used
|
||||||
PcodeArithmetic<BigInteger> BIGINT = BigIntegerPcodeArithmetic.INSTANCE;
|
PcodeArithmetic<BigInteger> BIGINT = BigIntegerPcodeArithmetic.INSTANCE;
|
||||||
|
|
||||||
T unaryOp(UnaryOpBehavior op, int sizeout, int sizein1, T in1);
|
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(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
|
* 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.
|
* exception to throw and/or establish a hierarchy of checked exceptions.
|
||||||
*
|
*
|
||||||
* @param value the abstract value
|
* @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
|
* @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