mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
Merge remote-tracking branch 'origin/GP-2653_Dan_debuggerPtrTypedef--SQUASHED'
This commit is contained in:
commit
757a1ea66a
9 changed files with 95 additions and 85 deletions
|
@ -120,9 +120,9 @@ public class DBTraceData extends AbstractDBTraceCodeUnit<DBTraceData>
|
|||
* @param platform the platform
|
||||
* @param dataType the data type
|
||||
*/
|
||||
protected void set(InternalTracePlatform platform, DataType dataType) {
|
||||
protected void set(InternalTracePlatform platform, long dataTypeID) {
|
||||
this.platformKey = platform.getIntKey();
|
||||
this.dataTypeID = space.dataTypeManager.getResolvedID(dataType);
|
||||
this.dataTypeID = dataTypeID;
|
||||
update(PLATFORM_COLUMN, DATATYPE_COLUMN);
|
||||
|
||||
this.platform = platform;
|
||||
|
@ -139,12 +139,6 @@ public class DBTraceData extends AbstractDBTraceCodeUnit<DBTraceData>
|
|||
* @return the length, or -1
|
||||
*/
|
||||
protected int getDataTypeLength() {
|
||||
if (baseDataType instanceof Pointer) {
|
||||
// TODO: Also need to know where this address maps into the other language's spaces....
|
||||
// NOTE: Using default data space for now
|
||||
// TODO: I may not need this Pointer check, as clone(dtm) should adjust already
|
||||
return getLanguage().getDefaultDataSpace().getPointerSize();
|
||||
}
|
||||
return dataType.getLength(); // -1 is checked elsewhere
|
||||
}
|
||||
|
||||
|
|
|
@ -157,9 +157,10 @@ public class DBTraceDefinedDataView extends AbstractBaseDBTraceDefinedUnitsView<
|
|||
return space.undefinedData.getAt(startSnap, address);
|
||||
}
|
||||
|
||||
long dataTypeID = space.dataTypeManager.getResolvedID(dataType);
|
||||
DBTraceData created = space.dataMapSpace.put(tasr, null);
|
||||
// TODO: data units with a guest platform
|
||||
created.set(space.trace.getPlatformManager().getHostPlatform(), dataType);
|
||||
created.set(space.trace.getPlatformManager().getHostPlatform(), dataTypeID);
|
||||
// TODO: Explicitly remove undefined from cache, or let weak refs take care of it?
|
||||
|
||||
cacheForContaining.notifyNewEntry(lifespan, createdRange, created);
|
||||
|
|
|
@ -18,7 +18,6 @@ package ghidra.trace.util;
|
|||
import java.math.BigInteger;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
|
@ -124,28 +123,6 @@ public enum TraceRegisterUtils {
|
|||
return seekComponent(data, rangeForRegister(reg));
|
||||
}
|
||||
|
||||
public static Object getValueHackPointer(TraceData data) {
|
||||
if (data.getValueClass() != Address.class) {
|
||||
return data.getValue();
|
||||
}
|
||||
if (!data.getAddress().getAddressSpace().isRegisterSpace()) {
|
||||
return data.getValue();
|
||||
}
|
||||
return PointerDataType.getAddressValue(data, data.getLength(),
|
||||
data.getTrace().getBaseAddressFactory().getDefaultAddressSpace());
|
||||
}
|
||||
|
||||
public static String getValueRepresentationHackPointer(TraceData data) {
|
||||
if (data.getValueClass() != Address.class) {
|
||||
return data.getDefaultValueRepresentation();
|
||||
}
|
||||
Address addr = (Address) getValueHackPointer(data);
|
||||
if (addr == null) {
|
||||
return "NaP";
|
||||
}
|
||||
return addr.toString();
|
||||
}
|
||||
|
||||
public static RegisterValue encodeValueRepresentationHackPointer(Register register,
|
||||
TraceData data, String representation) throws DataTypeEncodeException {
|
||||
DataType dataType = data.getBaseDataType();
|
||||
|
@ -209,30 +186,6 @@ public enum TraceRegisterUtils {
|
|||
return new RegisterValue(register, arr);
|
||||
}
|
||||
|
||||
public static RegisterValue getRegisterValue(Register reg,
|
||||
BiConsumer<Address, ByteBuffer> readAction) {
|
||||
/*
|
||||
* The byte array for reg values spans the whole base register, but we'd like to avoid
|
||||
* over-reading, so we'll zero in on the bytes actually included in the mask. We'll then
|
||||
* have to handle endianness and such. The regval instance should then apply the actual mask
|
||||
* for the sub-register, if applicable.
|
||||
*/
|
||||
int byteLength = reg.getNumBytes();
|
||||
byte[] mask = reg.getBaseMask();
|
||||
ByteBuffer buf = ByteBuffer.allocate(mask.length * 2);
|
||||
buf.put(mask);
|
||||
int maskOffset = TraceRegisterUtils.computeMaskOffset(reg);
|
||||
int startVal = buf.position() + maskOffset;
|
||||
buf.position(startVal);
|
||||
buf.limit(buf.position() + byteLength);
|
||||
readAction.accept(reg.getAddress(), buf);
|
||||
byte[] arr = buf.array();
|
||||
if (!reg.isBigEndian() && !reg.isProcessorContext()) {
|
||||
ArrayUtils.reverse(arr, mask.length, buf.capacity());
|
||||
}
|
||||
return new RegisterValue(reg, arr);
|
||||
}
|
||||
|
||||
public static boolean isByteBound(Register register) {
|
||||
return register.getLeastSignificantBit() % 8 == 0 && register.getBitLength() % 8 == 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue