mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
Merge remote-tracking branch
'origin/GP-2099_Dan_disassembleAsActions--SQUASHED' Conflicts: Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/AbstractGhidraHeadedDebuggerGUITest.java
This commit is contained in:
commit
5098c04745
66 changed files with 2213 additions and 774 deletions
|
@ -42,7 +42,8 @@ import ghidra.util.exception.VersionException;
|
|||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
@DBAnnotatedObjectInfo(version = 0)
|
||||
public class DBTraceGuestPlatform extends DBAnnotatedObject implements TraceGuestPlatform {
|
||||
public class DBTraceGuestPlatform extends DBAnnotatedObject
|
||||
implements TraceGuestPlatform, InternalTracePlatform {
|
||||
public static final String TABLE_NAME = "Platforms";
|
||||
|
||||
@DBAnnotatedObjectInfo(version = 0)
|
||||
|
@ -160,6 +161,16 @@ public class DBTraceGuestPlatform extends DBAnnotatedObject implements TraceGues
|
|||
return manager.trace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntKey() {
|
||||
return (int) key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGuest() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void deleteMappedRange(DBTraceGuestPlatformMappedRange range, TaskMonitor monitor)
|
||||
throws CancelledException {
|
||||
try (LockHold hold = LockHold.lock(manager.lock.writeLock())) {
|
||||
|
@ -175,6 +186,7 @@ public class DBTraceGuestPlatform extends DBAnnotatedObject implements TraceGues
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Internal
|
||||
public DBTraceGuestLanguage getLanguageEntry() {
|
||||
return languageEntry;
|
||||
|
|
|
@ -68,7 +68,7 @@ public class DBTraceGuestPlatformMappedRange extends DBAnnotatedObject
|
|||
private DBTracePlatformManager manager;
|
||||
|
||||
private AddressRangeImpl hostRange;
|
||||
private DBTraceGuestPlatform guestPlatform;
|
||||
private DBTraceGuestPlatform platform;
|
||||
private AddressRangeImpl guestRange;
|
||||
|
||||
public DBTraceGuestPlatformMappedRange(DBTracePlatformManager manager, DBCachedObjectStore<?> s,
|
||||
|
@ -83,28 +83,27 @@ public class DBTraceGuestPlatformMappedRange extends DBAnnotatedObject
|
|||
if (created) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Address hostStart =
|
||||
manager.getBaseLanguage().getAddressFactory().getAddress(hostSpace, hostOffset);
|
||||
Address hostEnd = hostStart.addNoWrap(length - 1);
|
||||
this.hostRange = new AddressRangeImpl(hostStart, hostEnd);
|
||||
Address hostStart =
|
||||
manager.trace.getBaseLanguage()
|
||||
.getAddressFactory()
|
||||
.getAddress(hostSpace, hostOffset);
|
||||
Address hostEnd = hostStart.addWrap(length - 1);
|
||||
this.hostRange = new AddressRangeImpl(hostStart, hostEnd);
|
||||
|
||||
this.guestPlatform = manager.getPlatformByKey(guestPlatformKey);
|
||||
Address guestStart =
|
||||
guestPlatform.getAddressFactory().getAddress(guestSpace, guestOffset);
|
||||
Address guestEnd = guestStart.addNoWrap(length - 1);
|
||||
this.guestRange = new AddressRangeImpl(guestStart, guestEnd);
|
||||
}
|
||||
catch (AddressOverflowException e) {
|
||||
throw new RuntimeException("Database is corrupt or languages changed", e);
|
||||
InternalTracePlatform platform = manager.getPlatformByKey(guestPlatformKey);
|
||||
if (platform.isHost()) {
|
||||
throw new IOException("Table is corrupt. Got host platform in guest mapping.");
|
||||
}
|
||||
this.platform = (DBTraceGuestPlatform) platform;
|
||||
Address guestStart = platform.getAddressFactory().getAddress(guestSpace, guestOffset);
|
||||
Address guestEnd = guestStart.addWrap(length - 1);
|
||||
this.guestRange = new AddressRangeImpl(guestStart, guestEnd);
|
||||
}
|
||||
|
||||
void set(Address hostStart, DBTraceGuestPlatform guestPlatform, Address guestStart,
|
||||
long length) {
|
||||
void set(Address hostStart, DBTraceGuestPlatform platform, Address guestStart, long length) {
|
||||
this.hostSpace = hostStart.getAddressSpace().getSpaceID();
|
||||
this.hostOffset = hostStart.getOffset();
|
||||
this.guestPlatformKey = (int) guestPlatform.getKey();
|
||||
this.guestPlatformKey = (int) platform.getKey();
|
||||
this.guestSpace = guestStart.getAddressSpace().getSpaceID();
|
||||
this.guestOffset = guestStart.getOffset();
|
||||
this.length = length;
|
||||
|
@ -112,19 +111,19 @@ public class DBTraceGuestPlatformMappedRange extends DBAnnotatedObject
|
|||
GUEST_OFFSET_COLUMN, LENGTH_COLUMN);
|
||||
|
||||
this.hostRange = new AddressRangeImpl(hostStart, hostStart.addWrap(length - 1));
|
||||
this.guestPlatform = guestPlatform;
|
||||
this.platform = platform;
|
||||
this.guestRange = new AddressRangeImpl(guestStart, guestStart.addWrap(length - 1));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Language getHostLanguage() {
|
||||
return manager.getBaseLanguage();
|
||||
return manager.trace.getBaseLanguage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompilerSpec getHostCompilerSpec() {
|
||||
return manager.getBaseCompilerSpec();
|
||||
return manager.trace.getBaseCompilerSpec();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -134,7 +133,7 @@ public class DBTraceGuestPlatformMappedRange extends DBAnnotatedObject
|
|||
|
||||
@Override
|
||||
public DBTraceGuestPlatform getGuestPlatform() {
|
||||
return guestPlatform;
|
||||
return platform;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,14 +21,15 @@ import java.util.concurrent.locks.ReadWriteLock;
|
|||
|
||||
import db.DBHandle;
|
||||
import ghidra.lifecycle.Internal;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.lang.*;
|
||||
import ghidra.program.model.listing.Instruction;
|
||||
import ghidra.program.model.mem.MemBuffer;
|
||||
import ghidra.trace.database.DBTrace;
|
||||
import ghidra.trace.database.DBTraceManager;
|
||||
import ghidra.trace.database.guest.DBTraceGuestPlatform.DBTraceGuestLanguage;
|
||||
import ghidra.trace.model.guest.TraceGuestPlatform;
|
||||
import ghidra.trace.model.guest.TracePlatformManager;
|
||||
import ghidra.trace.model.listing.TraceInstruction;
|
||||
import ghidra.trace.model.Trace;
|
||||
import ghidra.trace.model.guest.*;
|
||||
import ghidra.util.LockHold;
|
||||
import ghidra.util.database.*;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
|
@ -57,6 +58,68 @@ public class DBTracePlatformManager implements DBTraceManager, TracePlatformMana
|
|||
|
||||
protected final DBCachedObjectStore<DBTraceGuestPlatformMappedRange> rangeMappingStore;
|
||||
|
||||
protected final InternalTracePlatform hostPlatform = new InternalTracePlatform() {
|
||||
@Override
|
||||
public Trace getTrace() {
|
||||
return trace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DBTraceGuestLanguage getLanguageEntry() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntKey() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGuest() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Language getLanguage() {
|
||||
return trace.getBaseLanguage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompilerSpec getCompilerSpec() {
|
||||
return trace.getBaseCompilerSpec();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddressSetView getHostAddressSet() {
|
||||
return trace.getBaseAddressFactory().getAddressSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddressSetView getGuestAddressSet() {
|
||||
return trace.getBaseAddressFactory().getAddressSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Address mapHostToGuest(Address hostAddress) {
|
||||
return hostAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Address mapGuestToHost(Address guestAddress) {
|
||||
return guestAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MemBuffer getMappedMemBuffer(long snap, Address guestAddress) {
|
||||
return trace.getMemoryManager().getBufferAt(snap, guestAddress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstructionSet mapGuestInstructionAddressesToHost(InstructionSet set) {
|
||||
return set;
|
||||
}
|
||||
};
|
||||
|
||||
public DBTracePlatformManager(DBHandle dbh, DBOpenMode openMode, ReadWriteLock lock,
|
||||
TaskMonitor monitor, CompilerSpec baseCompilerSpec, DBTrace trace)
|
||||
throws VersionException, IOException {
|
||||
|
@ -129,9 +192,9 @@ public class DBTracePlatformManager implements DBTraceManager, TracePlatformMana
|
|||
}
|
||||
|
||||
@Internal
|
||||
public DBTraceGuestPlatform getPlatformByKey(int key) {
|
||||
public InternalTracePlatform getPlatformByKey(int key) {
|
||||
if (key == -1) {
|
||||
return null;
|
||||
return hostPlatform;
|
||||
}
|
||||
return platformStore.getObjectAt(key);
|
||||
}
|
||||
|
@ -201,13 +264,8 @@ public class DBTracePlatformManager implements DBTraceManager, TracePlatformMana
|
|||
}
|
||||
|
||||
@Override
|
||||
public Language getBaseLanguage() {
|
||||
return trace.getBaseLanguage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompilerSpec getBaseCompilerSpec() {
|
||||
return trace.getBaseCompilerSpec();
|
||||
public InternalTracePlatform getHostPlatform() {
|
||||
return hostPlatform;
|
||||
}
|
||||
|
||||
protected DBTraceGuestPlatform doAddGuestPlatform(CompilerSpec compilerSpec) {
|
||||
|
@ -219,9 +277,9 @@ public class DBTracePlatformManager implements DBTraceManager, TracePlatformMana
|
|||
|
||||
@Override
|
||||
public DBTraceGuestPlatform addGuestPlatform(CompilerSpec compilerSpec) {
|
||||
if (compilerSpec.getCompilerSpecID()
|
||||
.equals(trace.getBaseCompilerSpec().getCompilerSpecID())) {
|
||||
throw new IllegalArgumentException("Base language cannot be a guest language");
|
||||
if (trace.getBaseCompilerSpec() == compilerSpec) {
|
||||
throw new IllegalArgumentException(
|
||||
"Base compiler spec cannot be a guest compiler spec");
|
||||
}
|
||||
try (LockHold hold = LockHold.lock(lock.writeLock())) {
|
||||
return doAddGuestPlatform(compilerSpec);
|
||||
|
@ -229,8 +287,11 @@ public class DBTracePlatformManager implements DBTraceManager, TracePlatformMana
|
|||
}
|
||||
|
||||
@Override
|
||||
public DBTraceGuestPlatform getGuestPlatform(CompilerSpec compilerSpec) {
|
||||
public InternalTracePlatform getPlatform(CompilerSpec compilerSpec) {
|
||||
try (LockHold hold = LockHold.lock(lock.readLock())) {
|
||||
if (trace.getBaseCompilerSpec() == compilerSpec) {
|
||||
return hostPlatform;
|
||||
}
|
||||
return platformsByCompiler.get(compilerSpec);
|
||||
}
|
||||
}
|
||||
|
@ -255,33 +316,10 @@ public class DBTracePlatformManager implements DBTraceManager, TracePlatformMana
|
|||
return platformView;
|
||||
}
|
||||
|
||||
protected TraceGuestPlatform getPlatformOf(InstructionSet instructionSet) {
|
||||
for (InstructionBlock block : instructionSet) {
|
||||
for (Instruction instruction : block) {
|
||||
if (!(instruction instanceof TraceInstruction)) {
|
||||
continue;
|
||||
}
|
||||
TraceInstruction traceInstruction = (TraceInstruction) instruction;
|
||||
return traceInstruction.getGuestPlatform();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public InstructionSet mapGuestInstructionAddressesToHost(TraceGuestPlatform platform,
|
||||
InstructionSet instructionSet) {
|
||||
try (LockHold hold = LockHold.lock(lock.readLock())) {
|
||||
if (platform == null) { // Instructions belong to the host platform
|
||||
return instructionSet;
|
||||
}
|
||||
return platform.mapGuestInstructionAddressesToHost(instructionSet);
|
||||
}
|
||||
}
|
||||
|
||||
@Internal
|
||||
public DBTraceGuestPlatform assertMine(TraceGuestPlatform platform) {
|
||||
if (platform == null) {
|
||||
return null;
|
||||
public InternalTracePlatform assertMine(TracePlatform platform) {
|
||||
if (platform == hostPlatform) {
|
||||
return hostPlatform;
|
||||
}
|
||||
if (!(platform instanceof DBTraceGuestPlatform)) {
|
||||
throw new IllegalArgumentException("Given platform does not belong to this trace");
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/* ###
|
||||
* 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 ghidra.trace.database.guest;
|
||||
|
||||
import ghidra.trace.database.guest.DBTraceGuestPlatform.DBTraceGuestLanguage;
|
||||
import ghidra.trace.model.guest.TracePlatform;
|
||||
|
||||
public interface InternalTracePlatform extends TracePlatform {
|
||||
/**
|
||||
* Get the entry's key in the table as an integer
|
||||
*
|
||||
* @return the key
|
||||
*/
|
||||
int getIntKey();
|
||||
|
||||
DBTraceGuestLanguage getLanguageEntry();
|
||||
}
|
|
@ -26,6 +26,7 @@ import generic.NestedIterator;
|
|||
import ghidra.program.model.address.*;
|
||||
import ghidra.trace.database.DBTraceUtils;
|
||||
import ghidra.trace.database.space.DBTraceDelegatingManager;
|
||||
import ghidra.trace.model.Trace;
|
||||
import ghidra.trace.model.TraceAddressSnapRange;
|
||||
import ghidra.util.LockHold;
|
||||
|
||||
|
@ -40,6 +41,10 @@ public abstract class AbstractBaseDBTraceCodeUnitsMemoryView<T extends DBTraceCo
|
|||
Collections2.transform(manager.getActiveMemorySpaces(), this::getView);
|
||||
}
|
||||
|
||||
public Trace getTrace() {
|
||||
return manager.getTrace();
|
||||
}
|
||||
|
||||
protected abstract M getView(DBTraceCodeSpace space);
|
||||
|
||||
protected T nullOrUndefined(long snap, Address address) {
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.google.common.collect.Range;
|
|||
|
||||
import generic.NestedIterator;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.trace.model.Trace;
|
||||
import ghidra.trace.model.TraceAddressSnapRange;
|
||||
|
||||
public abstract class AbstractBaseDBTraceCodeUnitsView<T extends DBTraceCodeUnitAdapter> {
|
||||
|
@ -29,6 +30,10 @@ public abstract class AbstractBaseDBTraceCodeUnitsView<T extends DBTraceCodeUnit
|
|||
this.space = space;
|
||||
}
|
||||
|
||||
public Trace getTrace() {
|
||||
return space.manager.getTrace();
|
||||
}
|
||||
|
||||
public abstract int size();
|
||||
|
||||
public T getBefore(long snap, Address address) {
|
||||
|
|
|
@ -25,7 +25,7 @@ import ghidra.program.model.data.DataType;
|
|||
import ghidra.program.model.lang.Language;
|
||||
import ghidra.trace.database.DBTrace;
|
||||
import ghidra.trace.database.data.DBTraceDataSettingsAdapter.DBTraceDataSettingsSpace;
|
||||
import ghidra.trace.model.guest.TraceGuestPlatform;
|
||||
import ghidra.trace.model.guest.TracePlatform;
|
||||
import ghidra.trace.model.thread.TraceThread;
|
||||
import ghidra.util.LockHold;
|
||||
|
||||
|
@ -84,8 +84,8 @@ public abstract class AbstractDBTraceDataComponent implements DBTraceDefinedData
|
|||
}
|
||||
|
||||
@Override
|
||||
public TraceGuestPlatform getGuestPlatform() {
|
||||
return root.getGuestPlatform();
|
||||
public TracePlatform getPlatform() {
|
||||
return root.getPlatform();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -142,7 +142,7 @@ public class DBTraceCodeSpace implements TraceCodeSpace, DBTraceSpaceBased {
|
|||
TraceAddressSnapRangeQuery.intersecting(range, span)).values()) {
|
||||
monitor.checkCanceled();
|
||||
monitor.incrementProgress(1);
|
||||
if (instruction.guest != guest) {
|
||||
if (instruction.platform != guest) {
|
||||
continue;
|
||||
}
|
||||
instructionMapSpace.deleteData(instruction);
|
||||
|
@ -154,7 +154,7 @@ public class DBTraceCodeSpace implements TraceCodeSpace, DBTraceSpaceBased {
|
|||
TraceAddressSnapRangeQuery.intersecting(range, span)).values()) {
|
||||
monitor.checkCanceled();
|
||||
monitor.incrementProgress(1);
|
||||
if (dataUnit.guest != guest) {
|
||||
if (dataUnit.platform != guest) {
|
||||
continue;
|
||||
}
|
||||
// TODO: I don't yet have guest-language data units.
|
||||
|
|
|
@ -26,9 +26,9 @@ import ghidra.program.model.data.*;
|
|||
import ghidra.program.model.lang.Language;
|
||||
import ghidra.trace.database.DBTraceUtils;
|
||||
import ghidra.trace.database.data.DBTraceDataSettingsAdapter.DBTraceDataSettingsSpace;
|
||||
import ghidra.trace.database.guest.DBTraceGuestPlatform;
|
||||
import ghidra.trace.database.guest.InternalTracePlatform;
|
||||
import ghidra.trace.database.map.DBTraceAddressSnapRangePropertyMapTree;
|
||||
import ghidra.trace.model.guest.TraceGuestPlatform;
|
||||
import ghidra.trace.model.guest.TracePlatform;
|
||||
import ghidra.util.LockHold;
|
||||
import ghidra.util.database.DBCachedObjectStore;
|
||||
import ghidra.util.database.DBObjectColumn;
|
||||
|
@ -56,7 +56,7 @@ public class DBTraceData extends AbstractDBTraceCodeUnit<DBTraceData>
|
|||
@DBAnnotatedField(column = DATATYPE_COLUMN_NAME)
|
||||
private long dataTypeID;
|
||||
|
||||
protected DBTraceGuestPlatform guest;
|
||||
protected InternalTracePlatform platform;
|
||||
protected DataType dataType;
|
||||
protected DataType baseDataType;
|
||||
protected Settings defaultSettings;
|
||||
|
@ -75,8 +75,8 @@ public class DBTraceData extends AbstractDBTraceCodeUnit<DBTraceData>
|
|||
if (created) {
|
||||
return;
|
||||
}
|
||||
guest = space.manager.platformManager.getPlatformByKey(platformKey);
|
||||
if (guest == null && platformKey != -1) {
|
||||
platform = space.manager.platformManager.getPlatformByKey(platformKey);
|
||||
if (platform == null) {
|
||||
throw new IOException("Data table is corrupt. Missing platform: " + platformKey);
|
||||
}
|
||||
dataType = space.dataTypeManager.getDataType(dataTypeID);
|
||||
|
@ -102,12 +102,12 @@ public class DBTraceData extends AbstractDBTraceCodeUnit<DBTraceData>
|
|||
return this;
|
||||
}
|
||||
|
||||
protected void set(DBTraceGuestPlatform platform, DataType dataType) {
|
||||
this.platformKey = (int) (platform == null ? -1 : platform.getKey());
|
||||
protected void set(InternalTracePlatform platform, DataType dataType) {
|
||||
this.platformKey = platform.getIntKey();
|
||||
this.dataTypeID = space.dataTypeManager.getResolvedID(dataType);
|
||||
update(PLATFORM_COLUMN, DATATYPE_COLUMN);
|
||||
|
||||
this.guest = platform;
|
||||
this.platform = platform;
|
||||
// Use the stored dataType, not the given one, in case it's different
|
||||
this.dataType = space.dataTypeManager.getDataType(dataTypeID);
|
||||
assert this.dataType != null;
|
||||
|
@ -133,8 +133,8 @@ public class DBTraceData extends AbstractDBTraceCodeUnit<DBTraceData>
|
|||
}
|
||||
|
||||
@Override
|
||||
public TraceGuestPlatform getGuestPlatform() {
|
||||
return guest;
|
||||
public TracePlatform getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -157,7 +157,7 @@ public class DBTraceData extends AbstractDBTraceCodeUnit<DBTraceData>
|
|||
|
||||
@Override
|
||||
public Language getLanguage() {
|
||||
return guest == null ? space.baseLanguage : guest.getLanguage();
|
||||
return platform.getLanguage();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -146,7 +146,7 @@ public class DBTraceDefinedDataView extends AbstractBaseDBTraceDefinedUnitsView<
|
|||
|
||||
DBTraceData created = space.dataMapSpace.put(tasr, null);
|
||||
// TODO: data units with a guest platform
|
||||
created.set(null, dataType);
|
||||
created.set(space.trace.getPlatformManager().getHostPlatform(), dataType);
|
||||
// TODO: Explicitly remove undefined from cache, or let weak refs take care of it?
|
||||
|
||||
cacheForContaining.notifyNewEntry(lifespan, createdRange, created);
|
||||
|
|
|
@ -32,13 +32,13 @@ import ghidra.program.model.symbol.*;
|
|||
import ghidra.trace.database.DBTraceUtils;
|
||||
import ghidra.trace.database.context.DBTraceRegisterContextManager;
|
||||
import ghidra.trace.database.context.DBTraceRegisterContextSpace;
|
||||
import ghidra.trace.database.guest.DBTraceGuestPlatform;
|
||||
import ghidra.trace.database.guest.DBTraceGuestPlatform.DBTraceGuestLanguage;
|
||||
import ghidra.trace.database.guest.InternalTracePlatform;
|
||||
import ghidra.trace.database.map.DBTraceAddressSnapRangePropertyMapTree;
|
||||
import ghidra.trace.database.symbol.DBTraceReference;
|
||||
import ghidra.trace.database.symbol.DBTraceReferenceSpace;
|
||||
import ghidra.trace.model.Trace.TraceInstructionChangeType;
|
||||
import ghidra.trace.model.guest.TraceGuestPlatform;
|
||||
import ghidra.trace.model.guest.TracePlatform;
|
||||
import ghidra.trace.model.listing.TraceInstruction;
|
||||
import ghidra.trace.model.symbol.TraceReference;
|
||||
import ghidra.trace.util.*;
|
||||
|
@ -79,7 +79,7 @@ public class DBTraceInstruction extends AbstractDBTraceCodeUnit<DBTraceInstructi
|
|||
protected class GuestInstructionContext implements InstructionContext {
|
||||
@Override
|
||||
public Address getAddress() {
|
||||
return guest.mapHostToGuest(getX1());
|
||||
return platform.mapHostToGuest(getX1());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,7 +118,7 @@ public class DBTraceInstruction extends AbstractDBTraceCodeUnit<DBTraceInstructi
|
|||
protected FlowOverride flowOverride;
|
||||
|
||||
protected ParserContext parserContext;
|
||||
protected DBTraceGuestPlatform guest;
|
||||
protected InternalTracePlatform platform;
|
||||
protected InstructionContext instructionContext;
|
||||
|
||||
public DBTraceInstruction(DBTraceCodeSpace space,
|
||||
|
@ -127,9 +127,9 @@ public class DBTraceInstruction extends AbstractDBTraceCodeUnit<DBTraceInstructi
|
|||
super(space, tree, store, record);
|
||||
}
|
||||
|
||||
protected void doSetGuestMapping(final DBTraceGuestPlatform guest) {
|
||||
this.guest = guest;
|
||||
if (guest == null) {
|
||||
protected void doSetPlatformMapping(final InternalTracePlatform platform) {
|
||||
this.platform = platform;
|
||||
if (platform.isHost()) {
|
||||
instructionContext = this;
|
||||
}
|
||||
else {
|
||||
|
@ -137,11 +137,11 @@ public class DBTraceInstruction extends AbstractDBTraceCodeUnit<DBTraceInstructi
|
|||
}
|
||||
}
|
||||
|
||||
protected void set(DBTraceGuestPlatform guest, InstructionPrototype prototype,
|
||||
protected void set(InternalTracePlatform platform, InstructionPrototype prototype,
|
||||
ProcessorContextView context) {
|
||||
this.platformKey = (int) (guest == null ? -1 : guest.getKey());
|
||||
this.platformKey = platform.getIntKey();
|
||||
// NOTE: Using "this" for the MemBuffer seems a bit precarious.
|
||||
DBTraceGuestLanguage languageEntry = guest == null ? null : guest.getLanguageEntry();
|
||||
DBTraceGuestLanguage languageEntry = platform == null ? null : platform.getLanguageEntry();
|
||||
this.prototypeKey = (int) space.manager
|
||||
.findOrRecordPrototype(prototype, languageEntry, this, context)
|
||||
.getKey();
|
||||
|
@ -149,7 +149,7 @@ public class DBTraceInstruction extends AbstractDBTraceCodeUnit<DBTraceInstructi
|
|||
update(PLATFORM_COLUMN, PROTOTYPE_COLUMN, FLAGS_COLUMN);
|
||||
|
||||
// TODO: Can there be more in this context than the context register???
|
||||
doSetGuestMapping(guest);
|
||||
doSetPlatformMapping(platform);
|
||||
this.prototype = prototype;
|
||||
}
|
||||
|
||||
|
@ -160,8 +160,8 @@ public class DBTraceInstruction extends AbstractDBTraceCodeUnit<DBTraceInstructi
|
|||
// Wait for something to set prototype
|
||||
return;
|
||||
}
|
||||
guest = space.manager.platformManager.getPlatformByKey(platformKey);
|
||||
if (guest == null && platformKey != -1) {
|
||||
platform = space.manager.platformManager.getPlatformByKey(platformKey);
|
||||
if (platform == null) {
|
||||
throw new IOException("Instruction table is corrupt. Missing platform: " + platformKey);
|
||||
}
|
||||
prototype = space.manager.getPrototypeByKey(prototypeKey);
|
||||
|
@ -173,7 +173,7 @@ public class DBTraceInstruction extends AbstractDBTraceCodeUnit<DBTraceInstructi
|
|||
}
|
||||
flowOverride = FlowOverride.values()[(flags & FLOWOVERRIDE_SET_MASK) >> FLOWOVERRIDE_SHIFT];
|
||||
|
||||
doSetGuestMapping(guest);
|
||||
doSetPlatformMapping(platform);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -206,8 +206,8 @@ public class DBTraceInstruction extends AbstractDBTraceCodeUnit<DBTraceInstructi
|
|||
}
|
||||
|
||||
@Override
|
||||
public TraceGuestPlatform getGuestPlatform() {
|
||||
return guest;
|
||||
public TracePlatform getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -273,8 +273,7 @@ public class DBTraceInstruction extends AbstractDBTraceCodeUnit<DBTraceInstructi
|
|||
public Address getDefaultFallThrough() {
|
||||
try (LockHold hold = LockHold.lock(space.lock.readLock())) {
|
||||
Address fallThrough = getGuestDefaultFallThrough();
|
||||
return guest == null || fallThrough == null ? fallThrough
|
||||
: guest.mapGuestToHost(fallThrough);
|
||||
return platform.mapGuestToHost(fallThrough);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -392,12 +391,12 @@ public class DBTraceInstruction extends AbstractDBTraceCodeUnit<DBTraceInstructi
|
|||
public Address[] getDefaultFlows() {
|
||||
try (LockHold hold = LockHold.lock(space.lock.readLock())) {
|
||||
Address[] guestFlows = getGuestDefaultFlows();
|
||||
if (guest == null || guestFlows == null) {
|
||||
if (platform.isHost() || guestFlows == null) {
|
||||
return guestFlows;
|
||||
}
|
||||
List<Address> hostFlows = new ArrayList<>();
|
||||
for (Address g : guestFlows) {
|
||||
Address h = guest.mapGuestToHost(g);
|
||||
Address h = platform.mapGuestToHost(g);
|
||||
if (h != null) {
|
||||
hostFlows.add(h);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import com.google.common.collect.Range;
|
|||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.*;
|
||||
import ghidra.program.model.util.CodeUnitInsertionException;
|
||||
import ghidra.trace.model.guest.TraceGuestPlatform;
|
||||
import ghidra.trace.model.guest.TracePlatform;
|
||||
import ghidra.trace.model.listing.TraceInstructionsView;
|
||||
import ghidra.util.LockHold;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
|
@ -50,17 +50,16 @@ public class DBTraceInstructionsMemoryView
|
|||
|
||||
@Override
|
||||
public DBTraceInstruction create(Range<Long> lifespan, Address address,
|
||||
TraceGuestPlatform platform, InstructionPrototype prototype,
|
||||
TracePlatform platform, InstructionPrototype prototype,
|
||||
ProcessorContextView context) throws CodeUnitInsertionException {
|
||||
return delegateWrite(address.getAddressSpace(),
|
||||
m -> m.create(lifespan, address, platform, prototype, context));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddressSetView addInstructionSet(Range<Long> lifespan, TraceGuestPlatform platform,
|
||||
public AddressSetView addInstructionSet(Range<Long> lifespan, TracePlatform platform,
|
||||
InstructionSet instructionSet, boolean overwrite) {
|
||||
InstructionSet mappedSet = manager.platformManager
|
||||
.mapGuestInstructionAddressesToHost(platform, instructionSet);
|
||||
InstructionSet mappedSet = platform.mapGuestInstructionAddressesToHost(instructionSet);
|
||||
|
||||
Map<AddressSpace, InstructionSet> breakDown = new HashMap<>();
|
||||
// TODO: I'm not sure the consequences of breaking an instruction set down.
|
||||
|
|
|
@ -29,12 +29,12 @@ import ghidra.program.model.util.CodeUnitInsertionException;
|
|||
import ghidra.trace.database.DBTraceUtils;
|
||||
import ghidra.trace.database.context.DBTraceRegisterContextManager;
|
||||
import ghidra.trace.database.context.DBTraceRegisterContextSpace;
|
||||
import ghidra.trace.database.guest.DBTraceGuestPlatform;
|
||||
import ghidra.trace.database.guest.InternalTracePlatform;
|
||||
import ghidra.trace.database.memory.DBTraceMemorySpace;
|
||||
import ghidra.trace.model.ImmutableTraceAddressSnapRange;
|
||||
import ghidra.trace.model.Trace.TraceCodeChangeType;
|
||||
import ghidra.trace.model.guest.TraceGuestPlatform;
|
||||
import ghidra.trace.model.TraceAddressSnapRange;
|
||||
import ghidra.trace.model.guest.TracePlatform;
|
||||
import ghidra.trace.model.listing.TraceInstruction;
|
||||
import ghidra.trace.model.listing.TraceInstructionsView;
|
||||
import ghidra.trace.util.OverlappingObjectIterator;
|
||||
|
@ -53,7 +53,7 @@ public class DBTraceInstructionsView extends AbstractBaseDBTraceDefinedUnitsView
|
|||
protected class InstructionBlockAdder {
|
||||
private final Set<Address> skipDelaySlots;
|
||||
private final Range<Long> lifespan;
|
||||
private final DBTraceGuestPlatform platform;
|
||||
private final InternalTracePlatform platform;
|
||||
private final InstructionBlock block;
|
||||
private final Address errorAddress;
|
||||
private final InstructionError conflict;
|
||||
|
@ -62,7 +62,7 @@ public class DBTraceInstructionsView extends AbstractBaseDBTraceDefinedUnitsView
|
|||
protected int count = 0;
|
||||
|
||||
private InstructionBlockAdder(Set<Address> skipDelaySlots, Range<Long> lifespan,
|
||||
DBTraceGuestPlatform platform, InstructionBlock block, Address errorAddress,
|
||||
InternalTracePlatform platform, InstructionBlock block, Address errorAddress,
|
||||
InstructionError conflict, CodeUnit conflictCodeUnit) {
|
||||
this.skipDelaySlots = skipDelaySlots;
|
||||
this.lifespan = lifespan;
|
||||
|
@ -185,19 +185,11 @@ public class DBTraceInstructionsView extends AbstractBaseDBTraceDefinedUnitsView
|
|||
ctxSpace.setValue(language, newValue, tasr.getLifespan(), tasr.getRange());
|
||||
}
|
||||
|
||||
protected boolean languagesAgree(DBTraceGuestPlatform platform,
|
||||
InstructionPrototype prototype) {
|
||||
if (platform == null) {
|
||||
return prototype.getLanguage() == space.baseLanguage;
|
||||
}
|
||||
return prototype.getLanguage() == platform.getLanguage();
|
||||
}
|
||||
|
||||
protected DBTraceInstruction doCreate(Range<Long> lifespan, Address address,
|
||||
DBTraceGuestPlatform platform, InstructionPrototype prototype,
|
||||
InternalTracePlatform platform, InstructionPrototype prototype,
|
||||
ProcessorContextView context)
|
||||
throws CodeUnitInsertionException, AddressOverflowException {
|
||||
if (!languagesAgree(platform, prototype)) {
|
||||
if (platform.getLanguage() != prototype.getLanguage()) {
|
||||
throw new IllegalArgumentException("Platform and prototype disagree in language");
|
||||
}
|
||||
|
||||
|
@ -245,11 +237,10 @@ public class DBTraceInstructionsView extends AbstractBaseDBTraceDefinedUnitsView
|
|||
}
|
||||
|
||||
@Override
|
||||
public DBTraceInstruction create(Range<Long> lifespan, Address address,
|
||||
TraceGuestPlatform platform, InstructionPrototype prototype,
|
||||
ProcessorContextView context)
|
||||
public DBTraceInstruction create(Range<Long> lifespan, Address address, TracePlatform platform,
|
||||
InstructionPrototype prototype, ProcessorContextView context)
|
||||
throws CodeUnitInsertionException {
|
||||
DBTraceGuestPlatform dbPlatform = space.manager.platformManager.assertMine(platform);
|
||||
InternalTracePlatform dbPlatform = space.manager.platformManager.assertMine(platform);
|
||||
try (LockHold hold = LockHold.lock(space.lock.writeLock())) {
|
||||
DBTraceInstruction created =
|
||||
doCreate(lifespan, address, dbPlatform, prototype, context);
|
||||
|
@ -277,7 +268,7 @@ public class DBTraceInstructionsView extends AbstractBaseDBTraceDefinedUnitsView
|
|||
}
|
||||
|
||||
protected InstructionBlockAdder startAddingBlock(Range<Long> lifespan,
|
||||
Set<Address> skipDelaySlots, DBTraceGuestPlatform platform, InstructionBlock block) {
|
||||
Set<Address> skipDelaySlots, InternalTracePlatform platform, InstructionBlock block) {
|
||||
InstructionError conflict = block.getInstructionConflict();
|
||||
if (conflict == null) {
|
||||
return new InstructionBlockAdder(skipDelaySlots, lifespan, platform, block, null, null,
|
||||
|
@ -384,9 +375,9 @@ public class DBTraceInstructionsView extends AbstractBaseDBTraceDefinedUnitsView
|
|||
}
|
||||
|
||||
@Override
|
||||
public AddressSetView addInstructionSet(Range<Long> lifespan, TraceGuestPlatform platform,
|
||||
public AddressSetView addInstructionSet(Range<Long> lifespan, TracePlatform platform,
|
||||
InstructionSet instructionSet, boolean overwrite) {
|
||||
DBTraceGuestPlatform dbPlatform = space.manager.platformManager.assertMine(platform);
|
||||
InternalTracePlatform dbPlatform = space.manager.platformManager.assertMine(platform);
|
||||
// NOTE: Partly derived from CodeManager#addInstructions()
|
||||
// Attempted to factor more fluently
|
||||
AddressSet result = new AddressSet();
|
||||
|
|
|
@ -33,7 +33,7 @@ import ghidra.trace.database.memory.DBTraceMemorySpace;
|
|||
import ghidra.trace.database.space.DBTraceSpaceKey;
|
||||
import ghidra.trace.model.ImmutableTraceAddressSnapRange;
|
||||
import ghidra.trace.model.TraceAddressSnapRange;
|
||||
import ghidra.trace.model.guest.TraceGuestPlatform;
|
||||
import ghidra.trace.model.guest.TracePlatform;
|
||||
import ghidra.trace.model.listing.TraceData;
|
||||
import ghidra.trace.model.thread.TraceThread;
|
||||
import ghidra.trace.util.TraceAddressSpace;
|
||||
|
@ -82,8 +82,8 @@ public class UndefinedDBTraceData implements DBTraceDataAdapter, DBTraceSpaceKey
|
|||
}
|
||||
|
||||
@Override
|
||||
public TraceGuestPlatform getGuestPlatform() {
|
||||
return null;
|
||||
public TracePlatform getPlatform() {
|
||||
return trace.getPlatformManager().getHostPlatform();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -37,6 +37,7 @@ import ghidra.program.model.symbol.SourceType;
|
|||
import ghidra.program.model.util.CodeUnitInsertionException;
|
||||
import ghidra.program.model.util.PropertyMap;
|
||||
import ghidra.trace.database.DBTrace;
|
||||
import ghidra.trace.database.guest.InternalTracePlatform;
|
||||
import ghidra.trace.database.listing.UndefinedDBTraceData;
|
||||
import ghidra.trace.database.memory.DBTraceMemorySpace;
|
||||
import ghidra.trace.database.symbol.DBTraceFunctionSymbol;
|
||||
|
@ -77,6 +78,7 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
|
|||
|
||||
protected final DBTraceProgramView program;
|
||||
protected final TraceCodeOperations codeOperations;
|
||||
protected final InternalTracePlatform platform;
|
||||
|
||||
protected final DBTraceProgramViewRootModule rootModule;
|
||||
protected final Map<TraceMemoryRegion, DBTraceProgramViewFragment> fragmentsByRegion =
|
||||
|
@ -94,6 +96,8 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
|
|||
TraceCodeOperations codeOperations) {
|
||||
this.program = program;
|
||||
this.codeOperations = codeOperations;
|
||||
// TODO: Guest platform views?
|
||||
this.platform = program.trace.getPlatformManager().getHostPlatform();
|
||||
|
||||
this.rootModule = new DBTraceProgramViewRootModule(this);
|
||||
}
|
||||
|
@ -725,17 +729,15 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
|
|||
public Instruction createInstruction(Address addr, InstructionPrototype prototype,
|
||||
MemBuffer memBuf, ProcessorContextView context) throws CodeUnitInsertionException {
|
||||
// TODO: Why memBuf? Can it vary from program memory?
|
||||
// TODO: Per-platform views?
|
||||
return codeOperations.instructions()
|
||||
.create(Range.atLeast(program.snap), addr, null, prototype, context);
|
||||
.create(Range.atLeast(program.snap), addr, platform, prototype, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddressSetView addInstructions(InstructionSet instructionSet, boolean overwrite)
|
||||
throws CodeUnitInsertionException {
|
||||
// TODO: Per-platform views?
|
||||
return codeOperations.instructions()
|
||||
.addInstructionSet(Range.atLeast(program.snap), null, instructionSet,
|
||||
.addInstructionSet(Range.atLeast(program.snap), platform, instructionSet,
|
||||
overwrite);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.google.common.collect.Range;
|
|||
|
||||
import db.DBHandle;
|
||||
import ghidra.trace.database.*;
|
||||
import ghidra.trace.database.target.DBTraceObject;
|
||||
import ghidra.trace.database.target.DBTraceObjectManager;
|
||||
import ghidra.trace.model.Trace.TraceThreadChangeType;
|
||||
import ghidra.trace.model.thread.*;
|
||||
|
@ -158,9 +159,8 @@ public class DBTraceThreadManager implements TraceThreadManager, DBTraceManager
|
|||
@Override
|
||||
public TraceThread getThread(long key) {
|
||||
if (objectManager.hasSchema()) {
|
||||
return objectManager
|
||||
.getObjectById(key)
|
||||
.queryInterface(TraceObjectThread.class);
|
||||
DBTraceObject object = objectManager.getObjectById(key);
|
||||
return object == null ? null : object.queryInterface(TraceObjectThread.class);
|
||||
}
|
||||
return threadStore.getObjectAt(key);
|
||||
}
|
||||
|
|
|
@ -15,46 +15,15 @@
|
|||
*/
|
||||
package ghidra.trace.model.guest;
|
||||
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.*;
|
||||
import ghidra.program.model.mem.MemBuffer;
|
||||
import ghidra.trace.model.Trace;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressOverflowException;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
public interface TraceGuestPlatform {
|
||||
/**
|
||||
* Get the trace
|
||||
*
|
||||
* @return the trace
|
||||
*/
|
||||
Trace getTrace();
|
||||
public interface TraceGuestPlatform extends TracePlatform {
|
||||
|
||||
/**
|
||||
* Get the language of the guest platform
|
||||
*
|
||||
* @return the language
|
||||
*/
|
||||
Language getLanguage();
|
||||
|
||||
/**
|
||||
* Get the address factory of the guest platform
|
||||
*
|
||||
* @return the factory
|
||||
*/
|
||||
default AddressFactory getAddressFactory() {
|
||||
return getLanguage().getAddressFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the compiler of the guest platform
|
||||
*
|
||||
* @return the compiler spec
|
||||
*/
|
||||
CompilerSpec getCompilerSpec();
|
||||
|
||||
/**
|
||||
* Add an adress mapping from host to guest
|
||||
* Add an address mapping from host to guest
|
||||
*
|
||||
* @param hostStart the starting host address (mapped to guestStart)
|
||||
* @param guestStart the starting guest address (mapped to hostStart)
|
||||
|
@ -65,66 +34,6 @@ public interface TraceGuestPlatform {
|
|||
TraceGuestPlatformMappedRange addMappedRange(Address hostStart, Address guestStart, long length)
|
||||
throws AddressOverflowException;
|
||||
|
||||
/**
|
||||
* Get the addresses in the host which are mapped to somewhere in the guest
|
||||
*
|
||||
* @return the address set
|
||||
*/
|
||||
AddressSetView getHostAddressSet();
|
||||
|
||||
/**
|
||||
* Get the addresses in the guest which are mapped to somehere in the host
|
||||
*
|
||||
* @return the address set
|
||||
*/
|
||||
AddressSetView getGuestAddressSet();
|
||||
|
||||
/**
|
||||
* Map an address from host to guest
|
||||
*
|
||||
* @param hostAddress the host address
|
||||
* @return the guest address
|
||||
*/
|
||||
Address mapHostToGuest(Address hostAddress);
|
||||
|
||||
/**
|
||||
* Map an address from guest to host
|
||||
*
|
||||
* @param guestAddress the guest address
|
||||
* @return the host address
|
||||
*/
|
||||
Address mapGuestToHost(Address guestAddress);
|
||||
|
||||
/**
|
||||
* Get a memory buffer, which presents the host bytes in the guest address space
|
||||
*
|
||||
* <p>
|
||||
* This, with pseudo-disassembly, is the primary mechanism for adding instructions in the guest
|
||||
* language.
|
||||
*
|
||||
* @param snap the snap, up to which the most recent memory changes are presented
|
||||
* @param guestAddress the starting address in the guest space
|
||||
* @return the mapped memory buffer
|
||||
*/
|
||||
MemBuffer getMappedMemBuffer(long snap, Address guestAddress);
|
||||
|
||||
/**
|
||||
* Copy the given instruction set, but with addresses mapped from the guest space to the host
|
||||
* space
|
||||
*
|
||||
* <p>
|
||||
* Instructions which do not map are silently ignored. If concerned, the caller ought to examine
|
||||
* the resulting instruction set and/or the resulting address set after it is added to the
|
||||
* trace. A single instruction cannot span two mapped ranges, even if the comprised bytes are
|
||||
* consecutive in the guest space. Mapping such an instruction back into the host space would
|
||||
* cause the instruction to be split in the middle, which is not possible. Thus, such
|
||||
* instructions are silently ignored.
|
||||
*
|
||||
* @param set the instruction set in the guest space
|
||||
* @return the instruction set in the host space
|
||||
*/
|
||||
InstructionSet mapGuestInstructionAddressesToHost(InstructionSet set);
|
||||
|
||||
/**
|
||||
* Remove the mapped language, including all code units of the language
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
/* ###
|
||||
* 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 ghidra.trace.model.guest;
|
||||
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.*;
|
||||
import ghidra.program.model.mem.MemBuffer;
|
||||
import ghidra.trace.model.Trace;
|
||||
|
||||
public interface TracePlatform {
|
||||
/**
|
||||
* Get the trace
|
||||
*
|
||||
* @return the trace
|
||||
*/
|
||||
Trace getTrace();
|
||||
|
||||
/**
|
||||
* Check if this is a guest platform
|
||||
*
|
||||
* @return true for guest, false for host
|
||||
*/
|
||||
boolean isGuest();
|
||||
|
||||
/**
|
||||
* Check if this is the host platform
|
||||
*
|
||||
* @return true for host, false for guest
|
||||
*/
|
||||
default boolean isHost() {
|
||||
return !isGuest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the language of the guest platform
|
||||
*
|
||||
* @return the language
|
||||
*/
|
||||
Language getLanguage();
|
||||
|
||||
/**
|
||||
* Get the address factory of the guest platform
|
||||
*
|
||||
* @return the factory
|
||||
*/
|
||||
default AddressFactory getAddressFactory() {
|
||||
return getLanguage().getAddressFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the compiler of the guest platform
|
||||
*
|
||||
* @return the compiler spec
|
||||
*/
|
||||
CompilerSpec getCompilerSpec();
|
||||
|
||||
/**
|
||||
* Get the addresses in the host which are mapped to somewhere in the guest
|
||||
*
|
||||
* @return the address set
|
||||
*/
|
||||
AddressSetView getHostAddressSet();
|
||||
|
||||
/**
|
||||
* Get the addresses in the guest which are mapped to somehere in the host
|
||||
*
|
||||
* @return the address set
|
||||
*/
|
||||
AddressSetView getGuestAddressSet();
|
||||
|
||||
/**
|
||||
* Map an address from host to guest
|
||||
*
|
||||
* @param hostAddress the host address
|
||||
* @return the guest address
|
||||
*/
|
||||
Address mapHostToGuest(Address hostAddress);
|
||||
|
||||
/**
|
||||
* Map an address from guest to host
|
||||
*
|
||||
* @param guestAddress the guest address
|
||||
* @return the host address
|
||||
*/
|
||||
Address mapGuestToHost(Address guestAddress);
|
||||
|
||||
/**
|
||||
* Get a memory buffer, which presents the host bytes in the guest address space
|
||||
*
|
||||
* <p>
|
||||
* This, with pseudo-disassembly, is the primary mechanism for adding instructions in the guest
|
||||
* language.
|
||||
*
|
||||
* @param snap the snap, up to which the most recent memory changes are presented
|
||||
* @param guestAddress the starting address in the guest space
|
||||
* @return the mapped memory buffer
|
||||
*/
|
||||
MemBuffer getMappedMemBuffer(long snap, Address guestAddress);
|
||||
|
||||
/**
|
||||
* Copy the given instruction set, but with addresses mapped from the guest space to the host
|
||||
* space
|
||||
*
|
||||
* <p>
|
||||
* Instructions which do not map are silently ignored. If concerned, the caller ought to examine
|
||||
* the resulting instruction set and/or the resulting address set after it is added to the
|
||||
* trace. A single instruction cannot span two mapped ranges, even if the comprised bytes are
|
||||
* consecutive in the guest space. Mapping such an instruction back into the host space would
|
||||
* cause the instruction to be split in the middle, which is not possible. Thus, such
|
||||
* instructions are silently ignored.
|
||||
*
|
||||
* @param set the instruction set in the guest space
|
||||
* @return the instruction set in the host space
|
||||
*/
|
||||
InstructionSet mapGuestInstructionAddressesToHost(InstructionSet set);
|
||||
}
|
|
@ -18,7 +18,6 @@ package ghidra.trace.model.guest;
|
|||
import java.util.Collection;
|
||||
|
||||
import ghidra.program.model.lang.CompilerSpec;
|
||||
import ghidra.program.model.lang.Language;
|
||||
|
||||
/**
|
||||
* Allows the addition of "guest platforms" for disassembling in multiple languages.
|
||||
|
@ -28,18 +27,11 @@ import ghidra.program.model.lang.Language;
|
|||
*/
|
||||
public interface TracePlatformManager {
|
||||
/**
|
||||
* Get the base language of the trace
|
||||
* Get a platform representing the trace's base language and compiler spec
|
||||
*
|
||||
* @return the language
|
||||
* @return the host platform
|
||||
*/
|
||||
Language getBaseLanguage();
|
||||
|
||||
/**
|
||||
* Get the base compiler spec of the trace
|
||||
*
|
||||
* @return the compiler spec
|
||||
*/
|
||||
CompilerSpec getBaseCompilerSpec();
|
||||
TracePlatform getHostPlatform();
|
||||
|
||||
/**
|
||||
* Add a guest platform
|
||||
|
@ -50,12 +42,12 @@ public interface TracePlatformManager {
|
|||
TraceGuestPlatform addGuestPlatform(CompilerSpec compilerSpec);
|
||||
|
||||
/**
|
||||
* Get the guest platform for the given compiler spec
|
||||
* Get the platform for the given compiler spec
|
||||
*
|
||||
* @param compilerSpec the compiler spec. For the base compiler spec, this will return null.
|
||||
* @param compilerSpec the compiler spec
|
||||
* @return the platform, if found, or null
|
||||
*/
|
||||
TraceGuestPlatform getGuestPlatform(CompilerSpec compilerSpec);
|
||||
TracePlatform getPlatform(CompilerSpec compilerSpec);
|
||||
|
||||
/**
|
||||
* Get or add a platform for the given compiler spec
|
||||
|
|
|
@ -18,6 +18,7 @@ package ghidra.trace.model.listing;
|
|||
import com.google.common.collect.Range;
|
||||
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.trace.model.Trace;
|
||||
import ghidra.trace.model.TraceAddressSnapRange;
|
||||
import ghidra.util.IntersectionAddressSetView;
|
||||
import ghidra.util.UnionAddressSetView;
|
||||
|
@ -30,6 +31,13 @@ import ghidra.util.UnionAddressSetView;
|
|||
*/
|
||||
public interface TraceBaseCodeUnitsView<T extends TraceCodeUnit> {
|
||||
|
||||
/**
|
||||
* Get the trace for this view
|
||||
*
|
||||
* @return the trace
|
||||
*/
|
||||
Trace getTrace();
|
||||
|
||||
/**
|
||||
* Get the total number of <em>defined</em> units in this view
|
||||
*
|
||||
|
|
|
@ -25,7 +25,7 @@ import ghidra.program.model.listing.CodeUnit;
|
|||
import ghidra.program.model.util.TypeMismatchException;
|
||||
import ghidra.trace.model.Trace;
|
||||
import ghidra.trace.model.TraceAddressSnapRange;
|
||||
import ghidra.trace.model.guest.TraceGuestPlatform;
|
||||
import ghidra.trace.model.guest.TracePlatform;
|
||||
import ghidra.trace.model.program.TraceProgramView;
|
||||
import ghidra.trace.model.symbol.TraceReference;
|
||||
import ghidra.trace.model.thread.TraceThread;
|
||||
|
@ -44,11 +44,11 @@ public interface TraceCodeUnit extends CodeUnit {
|
|||
Trace getTrace();
|
||||
|
||||
/**
|
||||
* If the unit is for a guest platform, get it
|
||||
* Get the platform for this unit
|
||||
*
|
||||
* @return the guest platform, or null if it's for the host platform
|
||||
* @return the platform
|
||||
*/
|
||||
TraceGuestPlatform getGuestPlatform();
|
||||
TracePlatform getPlatform();
|
||||
|
||||
@Override
|
||||
TraceProgramView getProgram();
|
||||
|
|
|
@ -21,7 +21,7 @@ import ghidra.program.model.address.Address;
|
|||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.lang.*;
|
||||
import ghidra.program.model.util.CodeUnitInsertionException;
|
||||
import ghidra.trace.model.guest.TraceGuestPlatform;
|
||||
import ghidra.trace.model.guest.TracePlatform;
|
||||
|
||||
public interface TraceInstructionsView extends TraceBaseDefinedUnitsView<TraceInstruction> {
|
||||
/**
|
||||
|
@ -29,16 +29,28 @@ public interface TraceInstructionsView extends TraceBaseDefinedUnitsView<TraceIn
|
|||
*
|
||||
* @param lifespan the lifespan for the instruction unit
|
||||
* @param address the starting address of the instruction
|
||||
* @param platform the optional guest platform, null for the host
|
||||
* @param platform the platform
|
||||
* @param prototype the instruction prototype
|
||||
* @param context the input disassembly context for the instruction
|
||||
* @return the new instruction
|
||||
* @throws CodeUnitInsertionException if the instruction cannot be created
|
||||
*/
|
||||
TraceInstruction create(Range<Long> lifespan, Address address, TraceGuestPlatform platform,
|
||||
TraceInstruction create(Range<Long> lifespan, Address address, TracePlatform platform,
|
||||
InstructionPrototype prototype, ProcessorContextView context)
|
||||
throws CodeUnitInsertionException;
|
||||
|
||||
/**
|
||||
* Create an instruction for the host platform
|
||||
*
|
||||
* @see #create(Range, Address, TracePlatform, InstructionPrototype, ProcessorContextView)
|
||||
*/
|
||||
default TraceInstruction create(Range<Long> lifespan, Address address,
|
||||
InstructionPrototype prototype, ProcessorContextView context)
|
||||
throws CodeUnitInsertionException {
|
||||
return create(lifespan, address, getTrace().getPlatformManager().getHostPlatform(),
|
||||
prototype, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create several instructions
|
||||
*
|
||||
|
@ -52,6 +64,17 @@ public interface TraceInstructionsView extends TraceBaseDefinedUnitsView<TraceIn
|
|||
* @param overwrite true to replace conflicting instructions
|
||||
* @return the (host) address set of instructions actually added
|
||||
*/
|
||||
AddressSetView addInstructionSet(Range<Long> lifespan, TraceGuestPlatform platform,
|
||||
AddressSetView addInstructionSet(Range<Long> lifespan, TracePlatform platform,
|
||||
InstructionSet instructionSet, boolean overwrite);
|
||||
|
||||
/**
|
||||
* Create several instructions for the host platform
|
||||
*
|
||||
* @see #addInstructionSet(Range, TracePlatform, InstructionSet, boolean)
|
||||
*/
|
||||
default AddressSetView addInstructionSet(Range<Long> lifespan, InstructionSet instructionSet,
|
||||
boolean overwrite) {
|
||||
return addInstructionSet(lifespan, getTrace().getPlatformManager().getHostPlatform(),
|
||||
instructionSet, overwrite);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ import ghidra.trace.database.symbol.DBTraceReference;
|
|||
import ghidra.trace.database.thread.DBTraceThreadManager;
|
||||
import ghidra.trace.model.*;
|
||||
import ghidra.trace.model.guest.TraceGuestPlatform;
|
||||
import ghidra.trace.model.guest.TracePlatform;
|
||||
import ghidra.trace.model.thread.TraceThread;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.database.DBOpenMode;
|
||||
|
@ -62,6 +63,7 @@ import ghidra.util.task.ConsoleTaskMonitor;
|
|||
public class ToyDBTraceBuilder implements AutoCloseable {
|
||||
public final Language language;
|
||||
public final DBTrace trace;
|
||||
public final TracePlatform host;
|
||||
public final LanguageService languageService = DefaultLanguageService.getLanguageService();
|
||||
|
||||
public ToyDBTraceBuilder(File file)
|
||||
|
@ -69,17 +71,20 @@ public class ToyDBTraceBuilder implements AutoCloseable {
|
|||
DBHandle handle = new DBHandle(file);
|
||||
this.trace = new DBTrace(handle, DBOpenMode.UPDATE, new ConsoleTaskMonitor(), this);
|
||||
this.language = trace.getBaseLanguage();
|
||||
this.host = trace.getPlatformManager().getHostPlatform();
|
||||
}
|
||||
|
||||
// TODO: A constructor for specifying compiler, too
|
||||
public ToyDBTraceBuilder(String name, String langID) throws IOException {
|
||||
this.language = languageService.getLanguage(new LanguageID(langID));
|
||||
this.trace = new DBTrace(name, language.getDefaultCompilerSpec(), this);
|
||||
this.host = trace.getPlatformManager().getHostPlatform();
|
||||
}
|
||||
|
||||
public ToyDBTraceBuilder(Trace trace) {
|
||||
this.language = trace.getBaseLanguage();
|
||||
this.trace = (DBTrace) trace;
|
||||
this.host = trace.getPlatformManager().getHostPlatform();
|
||||
trace.addConsumer(this);
|
||||
}
|
||||
|
||||
|
@ -102,7 +107,7 @@ public class ToyDBTraceBuilder implements AutoCloseable {
|
|||
return addr(language, offset);
|
||||
}
|
||||
|
||||
public Address addr(TraceGuestPlatform lang, long offset) {
|
||||
public Address addr(TracePlatform lang, long offset) {
|
||||
return lang.getLanguage().getDefaultSpace().getAddress(offset);
|
||||
}
|
||||
|
||||
|
@ -246,36 +251,28 @@ public class ToyDBTraceBuilder implements AutoCloseable {
|
|||
}
|
||||
|
||||
public DBTraceInstruction addInstruction(long snap, Address start,
|
||||
TraceGuestPlatform guest) throws CodeUnitInsertionException {
|
||||
DBTraceMemoryManager memory = trace.getMemoryManager();
|
||||
TracePlatform platform) throws CodeUnitInsertionException {
|
||||
DBTraceCodeManager code = trace.getCodeManager();
|
||||
Language language = guest == null ? this.language : guest.getLanguage();
|
||||
Language language = platform.getLanguage();
|
||||
Disassembler dis = Disassembler.getDisassembler(language, language.getAddressFactory(),
|
||||
new ConsoleTaskMonitor(), msg -> Msg.info(this, "Listener: " + msg));
|
||||
RegisterValue defaultContextValue = trace.getRegisterContextManager()
|
||||
.getDefaultContext(language)
|
||||
.getDefaultDisassemblyContext();
|
||||
|
||||
MemBuffer memBuf;
|
||||
if (guest == null) {
|
||||
memBuf = memory.getBufferAt(snap, start);
|
||||
}
|
||||
else {
|
||||
memBuf = guest.getMappedMemBuffer(snap, guest.mapHostToGuest(start));
|
||||
}
|
||||
MemBuffer memBuf = platform.getMappedMemBuffer(snap, platform.mapHostToGuest(start));
|
||||
InstructionBlock block = dis.pseudoDisassembleBlock(memBuf, defaultContextValue, 1);
|
||||
Instruction pseudoIns = block.iterator().next();
|
||||
return code.instructions()
|
||||
.create(Range.atLeast(snap), start, guest, pseudoIns.getPrototype(), pseudoIns);
|
||||
.create(Range.atLeast(snap), start, platform, pseudoIns.getPrototype(), pseudoIns);
|
||||
}
|
||||
|
||||
public DBTraceInstruction addInstruction(long snap, Address start,
|
||||
TraceGuestPlatform guest, ByteBuffer buf)
|
||||
throws CodeUnitInsertionException {
|
||||
public DBTraceInstruction addInstruction(long snap, Address start, TracePlatform platform,
|
||||
ByteBuffer buf) throws CodeUnitInsertionException {
|
||||
int length = buf.remaining();
|
||||
DBTraceMemoryManager memory = trace.getMemoryManager();
|
||||
memory.putBytes(snap, start, buf);
|
||||
DBTraceInstruction instruction = addInstruction(snap, start, guest);
|
||||
DBTraceInstruction instruction = addInstruction(snap, start, platform);
|
||||
assertEquals(length, instruction.getLength());
|
||||
return instruction;
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ import org.junit.*;
|
|||
|
||||
import ghidra.test.AbstractGhidraHeadlessIntegrationTest;
|
||||
import ghidra.trace.database.ToyDBTraceBuilder;
|
||||
import ghidra.trace.database.guest.*;
|
||||
import ghidra.trace.model.guest.TraceGuestPlatform;
|
||||
import ghidra.trace.model.guest.TracePlatform;
|
||||
import ghidra.util.database.UndoableTransaction;
|
||||
import ghidra.util.task.ConsoleTaskMonitor;
|
||||
|
||||
|
@ -46,14 +46,10 @@ public class DBTracePlatformManagerTest extends AbstractGhidraHeadlessIntegratio
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testGetBaseLanguage() {
|
||||
assertEquals("Toy:BE:64:default",
|
||||
manager.getBaseLanguage().getLanguageID().getIdAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBaseCompilerSpec() {
|
||||
assertEquals("default", manager.getBaseCompilerSpec().getCompilerSpecID().getIdAsString());
|
||||
public void testGetHostPlatform() throws Throwable {
|
||||
TracePlatform host = b.trace.getPlatformManager().getHostPlatform();
|
||||
assertEquals("Toy:BE:64:default", host.getLanguage().getLanguageID().getIdAsString());
|
||||
assertEquals("default", host.getCompilerSpec().getCompilerSpecID().getIdAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -324,7 +320,8 @@ public class DBTracePlatformManagerTest extends AbstractGhidraHeadlessIntegratio
|
|||
|
||||
b.trace.undo();
|
||||
|
||||
guest = manager.getGuestPlatform(b.getCompiler("x86:LE:32:default", "gcc"));
|
||||
guest =
|
||||
(DBTraceGuestPlatform) manager.getPlatform(b.getCompiler("x86:LE:32:default", "gcc"));
|
||||
assertNotNull(guest.mapHostToGuest(b.addr(0x01000800)));
|
||||
assertNotNull(guest.mapGuestToHost(b.addr(guest, 0x02000800)));
|
||||
}
|
||||
|
@ -359,7 +356,8 @@ public class DBTracePlatformManagerTest extends AbstractGhidraHeadlessIntegratio
|
|||
|
||||
b.trace.undo();
|
||||
|
||||
guest = manager.getGuestPlatform(b.getCompiler("x86:LE:32:default", "gcc"));
|
||||
guest =
|
||||
(DBTraceGuestPlatform) manager.getPlatform(b.getCompiler("x86:LE:32:default", "gcc"));
|
||||
assertEquals(b.addr(guest, 0x02000800), guest.mapHostToGuest(b.addr(0x01000800)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
@Test
|
||||
public void testAddInstruction() throws CodeUnitInsertionException {
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
b.addInstruction(0, b.addr(0x4004), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
b.trace.getMemoryManager().putBytes(10, b.addr(0x4001), b.buf(0xaa));
|
||||
TraceInstruction i4000 =
|
||||
b.addInstruction(0, b.addr(0x4000), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(0, b.addr(0x4000), b.host, b.buf(0xf4, 0));
|
||||
assertEquals(Range.closed(0L, 9L), i4000.getLifespan());
|
||||
}
|
||||
}
|
||||
|
@ -206,15 +206,15 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
b.trace.getMemoryManager().putBytes(-5L, b.addr(0x4001), b.buf(0xaa));
|
||||
TraceInstruction i4000 =
|
||||
b.addInstruction(-10, b.addr(0x4000), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(-10, b.addr(0x4000), b.host, b.buf(0xf4, 0));
|
||||
assertEquals(Range.closed(-10L, -6L), i4000.getLifespan());
|
||||
|
||||
TraceInstruction i4004 =
|
||||
b.addInstruction(-1, b.addr(0x4004), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(-1, b.addr(0x4004), b.host, b.buf(0xf4, 0));
|
||||
assertEquals(Range.closed(-1L, -1L), i4004.getLifespan());
|
||||
|
||||
TraceInstruction i4008 =
|
||||
b.addInstruction(-10, b.addr(0x4008), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(-10, b.addr(0x4008), b.host, b.buf(0xf4, 0));
|
||||
assertEquals(Range.closed(-10L, -1L), i4008.getLifespan());
|
||||
}
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
public void testPutBytesTruncatesInstruction() throws CodeUnitInsertionException {
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
TraceInstruction i4000 =
|
||||
b.addInstruction(0, b.addr(0x4000), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(0, b.addr(0x4000), b.host, b.buf(0xf4, 0));
|
||||
assertEquals(b.addr(0x4001), i4000.getMaxAddress());
|
||||
assertEquals(Range.atLeast(0L), i4000.getLifespan());
|
||||
b.trace.getMemoryManager().putBytes(10, b.addr(0x4001), b.buf(1));
|
||||
|
@ -236,7 +236,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
public void testPutBytesDeletesInstruction() throws CodeUnitInsertionException {
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
TraceInstruction i4000 =
|
||||
b.addInstruction(0, b.addr(0x4000), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(0, b.addr(0x4000), b.host, b.buf(0xf4, 0));
|
||||
assertEquals(b.addr(0x4001), i4000.getMaxAddress());
|
||||
assertEquals(Range.atLeast(0L), i4000.getLifespan());
|
||||
b.trace.getMemoryManager().putBytes(0, b.addr(0x4001), b.buf(1));
|
||||
|
@ -267,14 +267,14 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
}
|
||||
|
||||
try {
|
||||
b.addInstruction(1, b.addr(0x4001), null);
|
||||
b.addInstruction(1, b.addr(0x4001), b.host);
|
||||
fail();
|
||||
}
|
||||
catch (CodeUnitInsertionException e) {
|
||||
// pass
|
||||
}
|
||||
|
||||
b.addInstruction(0, b.addr(0x4004), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xf4, 0));
|
||||
|
||||
try {
|
||||
b.addData(1, b.addr(0x4005), ByteDataType.dataType, 1);
|
||||
|
@ -285,7 +285,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
}
|
||||
|
||||
try {
|
||||
b.addInstruction(1, b.addr(0x4005), null);
|
||||
b.addInstruction(1, b.addr(0x4005), b.host);
|
||||
}
|
||||
catch (CodeUnitInsertionException e) {
|
||||
// pass
|
||||
|
@ -350,7 +350,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
assertAllNullFunc(v -> v.getAt(9, b.addr(0x4003)));
|
||||
assertUndefinedFunc(v -> v.getAt(9, b.addr(0x4004)));
|
||||
|
||||
TraceInstruction i4005 = b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
TraceInstruction i4005 = b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
i4005.setEndSnap(5);
|
||||
assertUndefinedFunc(v -> v.getAt(0, b.addr(0x4004)));
|
||||
assertInstructionFunc(i4005, v -> v.getAt(0, b.addr(0x4005)));
|
||||
|
@ -383,7 +383,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
assertDataFunc(d4000, v -> v.getContaining(9, b.addr(0x4003)));
|
||||
assertUndefinedFunc(v -> v.getContaining(9, b.addr(0x4004)));
|
||||
|
||||
TraceInstruction i4005 = b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
TraceInstruction i4005 = b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
i4005.setEndSnap(5);
|
||||
assertUndefinedFunc(v -> v.getContaining(0, b.addr(0x4004)));
|
||||
|
||||
|
@ -449,7 +449,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
d4000.setEndSnap(9);
|
||||
d4004 = b.addData(0, b.addr(0x4004), IntegerDataType.dataType, b.buf(5, 6, 7, 8));
|
||||
d4004.setEndSnap(5);
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), null, b.buf(0xf4, 0));
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), b.host, b.buf(0xf4, 0));
|
||||
i4008.setEndSnap(9);
|
||||
}
|
||||
|
||||
|
@ -591,7 +591,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
d4000.setEndSnap(9);
|
||||
d4004 = b.addData(0, b.addr(0x4004), IntegerDataType.dataType, b.buf(5, 6, 7, 8));
|
||||
d4004.setEndSnap(5);
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), null, b.buf(0xf4, 0));
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), b.host, b.buf(0xf4, 0));
|
||||
i4008.setEndSnap(9);
|
||||
}
|
||||
|
||||
|
@ -730,7 +730,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
d4000.setEndSnap(9);
|
||||
d4004 = b.addData(0, b.addr(0x4004), IntegerDataType.dataType, b.buf(5, 6, 7, 8));
|
||||
d4004.setEndSnap(5);
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), null, b.buf(0xf4, 0));
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), b.host, b.buf(0xf4, 0));
|
||||
i4008.setEndSnap(9);
|
||||
}
|
||||
|
||||
|
@ -870,7 +870,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
d4000.setEndSnap(9);
|
||||
d4004 = b.addData(0, b.addr(0x4004), IntegerDataType.dataType, b.buf(5, 6, 7, 8));
|
||||
d4004.setEndSnap(5);
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), null, b.buf(0xf4, 0));
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), b.host, b.buf(0xf4, 0));
|
||||
i4008.setEndSnap(9);
|
||||
}
|
||||
|
||||
|
@ -1084,7 +1084,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
d4000.setEndSnap(9);
|
||||
d4004 = b.addData(0, b.addr(0x4004), IntegerDataType.dataType, b.buf(5, 6, 7, 8));
|
||||
d4004.setEndSnap(5);
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), null, b.buf(0xf4, 0));
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), b.host, b.buf(0xf4, 0));
|
||||
i4008.setEndSnap(9);
|
||||
}
|
||||
TraceData u3fff = manager.undefinedData().getAt(0, b.addr(0x3fff));
|
||||
|
@ -1137,7 +1137,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
|
||||
TraceInstruction iCodeMax;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
iCodeMax = b.addInstruction(0, b.addr(-0x0002), null, b.buf(0xf4, 0));
|
||||
iCodeMax = b.addInstruction(0, b.addr(-0x0002), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
|
||||
assertEquals(iCodeMax, manager.codeUnits().getBefore(0, b.data(0x0000)));
|
||||
|
@ -1170,7 +1170,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
manager.undefinedData().getFloor(0, b.data(0x0003)));
|
||||
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
iCodeMax = b.addInstruction(0, b.addr(-0x0002), null, b.buf(0xf4, 0));
|
||||
iCodeMax = b.addInstruction(0, b.addr(-0x0002), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
TraceData uCodePre = manager.undefinedData().getAt(0, b.addr(-0x0003));
|
||||
assertUndefinedWithAddr(b.addr(-0x0003), uCodePre);
|
||||
|
@ -1209,7 +1209,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
d4000 = b.addData(0, b.addr(0x4000), IntegerDataType.dataType, b.buf(1, 2, 3, 4));
|
||||
d4000.setEndSnap(9);
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), null, b.buf(0xf4, 0));
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), b.host, b.buf(0xf4, 0));
|
||||
i4008.setEndSnap(9);
|
||||
}
|
||||
|
||||
|
@ -1344,7 +1344,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
d4000.setEndSnap(9);
|
||||
d4004 = b.addData(0, b.addr(0x4004), IntegerDataType.dataType, b.buf(5, 6, 7, 8));
|
||||
d4004.setEndSnap(5);
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), null, b.buf(0xf4, 0));
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), b.host, b.buf(0xf4, 0));
|
||||
i4008.setEndSnap(9);
|
||||
}
|
||||
|
||||
|
@ -1414,7 +1414,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
d4000.setEndSnap(9);
|
||||
d4004 = b.addData(0, b.addr(0x4004), IntegerDataType.dataType, b.buf(5, 6, 7, 8));
|
||||
d4004.setEndSnap(5);
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), null, b.buf(0xf4, 0));
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), b.host, b.buf(0xf4, 0));
|
||||
i4008.setEndSnap(9);
|
||||
}
|
||||
|
||||
|
@ -1489,7 +1489,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
d4000.setEndSnap(9);
|
||||
d4004 = b.addData(0, b.addr(0x4004), IntegerDataType.dataType, b.buf(5, 6, 7, 8));
|
||||
d4004.setEndSnap(5);
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), null, b.buf(0xf4, 0));
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), b.host, b.buf(0xf4, 0));
|
||||
i4008.setEndSnap(9);
|
||||
}
|
||||
|
||||
|
@ -1573,7 +1573,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
d4000.setEndSnap(9);
|
||||
d4004 = b.addData(0, b.addr(0x4004), IntegerDataType.dataType, b.buf(5, 6, 7, 8));
|
||||
d4004.setEndSnap(5);
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), null, b.buf(0xf4, 0));
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), b.host, b.buf(0xf4, 0));
|
||||
i4008.setEndSnap(9);
|
||||
}
|
||||
|
||||
|
@ -1672,7 +1672,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
d4000.setEndSnap(9);
|
||||
d4004 = b.addData(0, b.addr(0x4004), IntegerDataType.dataType, b.buf(5, 6, 7, 8));
|
||||
d4004.setEndSnap(5);
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), null, b.buf(0xf4, 0));
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), b.host, b.buf(0xf4, 0));
|
||||
i4008.setEndSnap(9);
|
||||
|
||||
// Clear one of the data before a context space is created
|
||||
|
@ -1720,7 +1720,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
guest = langMan.addGuestPlatform(x86.getDefaultCompilerSpec());
|
||||
mappedRange = guest.addMappedRange(b.addr(0x0000), b.addr(guest, 0x0000), 1L << 32);
|
||||
g4000 = b.addInstruction(0, b.addr(0x4000), guest, b.buf(0x90));
|
||||
i4001 = b.addInstruction(0, b.addr(0x4001), null, b.buf(0xf4, 0));
|
||||
i4001 = b.addInstruction(0, b.addr(0x4001), b.host, b.buf(0xf4, 0));
|
||||
d4003 = b.addData(0, b.addr(0x4003), LongDataType.dataType, b.buf(1, 2, 3, 4));
|
||||
}
|
||||
|
||||
|
@ -1738,7 +1738,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
// TODO: Related to GP-479?
|
||||
g4000 = manager.instructions().getAt(0, b.addr(0x4000));
|
||||
assertNotNull(g4000);
|
||||
assertEquals(guest, g4000.getGuestPlatform());
|
||||
assertEquals(guest, g4000.getPlatform());
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
guest.delete(new ConsoleTaskMonitor());
|
||||
}
|
||||
|
@ -1753,7 +1753,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
@Test
|
||||
public void testSaveAndLoad() throws Exception {
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
b.addInstruction(0, b.addr(0x4004), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xf4, 0));
|
||||
|
||||
TraceThread thread = b.getOrAddThread("Thread 1", 0);
|
||||
DBTraceCodeRegisterSpace regCode = manager.getCodeRegisterSpace(thread, true);
|
||||
|
@ -1801,7 +1801,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
@Test
|
||||
public void testUndoThenRedo() throws Exception {
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
b.addInstruction(0, b.addr(0x4004), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xf4, 0));
|
||||
|
||||
TraceThread thread = b.getOrAddThread("Thread 1", 0);
|
||||
DBTraceCodeRegisterSpace regCode = manager.getCodeRegisterSpace(thread, true);
|
||||
|
@ -1854,7 +1854,7 @@ public class DBTraceCodeManagerTest extends AbstractGhidraHeadlessIntegrationTes
|
|||
b.trace.getBaseAddressFactory().getDefaultAddressSpace());
|
||||
DBTraceCodeSpace space = manager.getCodeSpace(os, true);
|
||||
|
||||
b.addInstruction(0, os.getAddress(0x4004), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(0, os.getAddress(0x4004), b.host, b.buf(0xf4, 0));
|
||||
|
||||
List<CodeUnit> all = new ArrayList<>();
|
||||
space.definedUnits().get(0, true).forEach(all::add);
|
||||
|
|
|
@ -242,7 +242,7 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
|
|||
TraceOverlappedRegionException, DuplicateNameException {
|
||||
TraceInstruction ins;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
ins = b.addInstruction(0, b.addr(0x4004), null, b.buf(0xf4, 0));
|
||||
ins = b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
TraceData und = manager.undefinedData().getAt(0, b.addr(0x4006));
|
||||
|
||||
|
@ -281,7 +281,7 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
|
|||
public void testGetProgram() throws CodeUnitInsertionException {
|
||||
TraceInstruction i4004;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), null, b.buf(0xf4, 0));
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
|
||||
assertEquals(0, i4004.getProgram().getSnap());
|
||||
|
@ -291,7 +291,7 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
|
|||
public void testGetMemory() throws CodeUnitInsertionException {
|
||||
TraceInstruction i4004;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), null, b.buf(0xf4, 0));
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
|
||||
assertEquals(i4004.getProgram().getMemory(), i4004.getMemory());
|
||||
|
@ -304,7 +304,7 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
|
|||
TraceInstruction i4004;
|
||||
TraceInstruction g4006;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), null, b.buf(0xf4, 0));
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xf4, 0));
|
||||
guest = b.trace.getPlatformManager().addGuestPlatform(x86.getDefaultCompilerSpec());
|
||||
guest.addMappedRange(b.addr(0x0000), b.addr(guest, 0x0000), 1L << 32);
|
||||
g4006 = b.addInstruction(0, b.addr(0x4006), guest, b.buf(0x90));
|
||||
|
@ -319,8 +319,8 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
|
|||
TraceInstruction i4004;
|
||||
TraceInstruction i4006;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), null, b.buf(0xf4, 0));
|
||||
i4006 = b.addInstruction(0, b.addr(0x4006), null, b.buf(0xf4, 0));
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xf4, 0));
|
||||
i4006 = b.addInstruction(0, b.addr(0x4006), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
assertFalse(i4004.hasProperty("myVoid"));
|
||||
|
||||
|
@ -455,8 +455,8 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
|
|||
TraceInstruction i4004;
|
||||
TraceInstruction i4006;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), null, b.buf(0xf4, 0));
|
||||
i4006 = b.addInstruction(0, b.addr(0x4006), null, b.buf(0xf4, 0));
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xf4, 0));
|
||||
i4006 = b.addInstruction(0, b.addr(0x4006), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
|
@ -510,7 +510,7 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
|
|||
// TODO: Decide whether or not to shrink the comment lifespan with the unit lifespan
|
||||
assertEquals(Range.atLeast(0L), c4004.getLifespan());
|
||||
|
||||
i4004_10 = b.addInstruction(10, b.addr(0x4004), null);
|
||||
i4004_10 = b.addInstruction(10, b.addr(0x4004), b.host);
|
||||
i4004_10.setComment(CodeUnit.PRE_COMMENT, "Get this back in the mix");
|
||||
i4004_10.setComment(CodeUnit.EOL_COMMENT, "A different comment");
|
||||
}
|
||||
|
@ -538,8 +538,8 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
|
|||
TraceInstruction i4006;
|
||||
TraceData d4008;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), null, b.buf(0xf4, 0));
|
||||
i4006 = b.addInstruction(0, b.addr(0x4006), null, b.buf(0xf4, 0));
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xf4, 0));
|
||||
i4006 = b.addInstruction(0, b.addr(0x4006), b.host, b.buf(0xf4, 0));
|
||||
d4008 = b.addData(0, b.addr(0x4008), LongDataType.dataType, b.buf(1, 2, 3, 4));
|
||||
}
|
||||
|
||||
|
@ -564,8 +564,8 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
|
|||
TraceInstruction i4006;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
d4000 = b.addData(0, b.addr(0x4000), LongDataType.dataType, b.buf(1, 2, 3, 4));
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), null, b.buf(0xf4, 0));
|
||||
i4006 = b.addInstruction(0, b.addr(0x4006), null, b.buf(0xf4, 0));
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xf4, 0));
|
||||
i4006 = b.addInstruction(0, b.addr(0x4006), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
Set<TraceReference> refs;
|
||||
|
||||
|
@ -708,7 +708,7 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
|
|||
TraceData undefined;
|
||||
TraceData undReg;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
instruction = b.addInstruction(0, b.addr(0x4004), null, b.buf(0xf4, 0));
|
||||
instruction = b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xf4, 0));
|
||||
undefined = manager.undefinedData().getAt(0, b.addr(0x4006));
|
||||
|
||||
thread = b.getOrAddThread("Thread 1", 0);
|
||||
|
@ -739,7 +739,7 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
|
|||
TraceInstruction i4004;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
d4000 = b.addData(0, b.addr(0x4000), LongDataType.dataType, b.buf(1, 2, 3, 4));
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), null, b.buf(0xf4, 0));
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xf4, 0));
|
||||
|
||||
d4000.setEndSnap(9);
|
||||
assertEquals(Range.closed(0L, 9L), d4000.getLifespan());
|
||||
|
@ -1039,13 +1039,13 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
|
|||
.addRegion("myRegion", Range.atLeast(0L),
|
||||
b.range(0x4000, 0x4fff), TraceMemoryFlag.READ);
|
||||
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), null, b.buf(0xc8, 0x47));
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xc8, 0x47));
|
||||
assertEquals("add r4,#0x7", i4004.toString());
|
||||
i4006 = b.addInstruction(0, b.addr(0x4006), null, b.buf(0xf4, 0));
|
||||
i4006 = b.addInstruction(0, b.addr(0x4006), b.host, b.buf(0xf4, 0));
|
||||
assertEquals("ret", i4006.toString());
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), null, b.buf(0xff, 0xfc));
|
||||
i4008 = b.addInstruction(0, b.addr(0x4008), b.host, b.buf(0xff, 0xfc));
|
||||
assertEquals("call 0x00004004", i4008.toString());
|
||||
i400a = b.addInstruction(0, b.addr(0x400a), null, b.buf(0xf6, 0x40));
|
||||
i400a = b.addInstruction(0, b.addr(0x400a), b.host, b.buf(0xf6, 0x40));
|
||||
assertEquals("call r4", i400a.toString());
|
||||
}
|
||||
|
||||
|
@ -1191,7 +1191,7 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
|
|||
|
||||
TraceInstruction i4004;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), null, b.buf(0xf4, 0));
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
|
||||
// TODO: Test with non-default context
|
||||
|
@ -1240,7 +1240,7 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
|
|||
TraceData d4006;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
d4000 = b.addData(0, b.addr(0x4000), LongDataType.dataType, b.buf(1, 2, 3, 4));
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), null, b.buf(0xf4, 0));
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xf4, 0));
|
||||
d4006 = b.addData(0, b.addr(0x4006), PointerDataType.dataType,
|
||||
b.buf(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00));
|
||||
}
|
||||
|
@ -1260,7 +1260,7 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
|
|||
TraceData d4006;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
d4000 = b.addData(0, b.addr(0x4000), LongDataType.dataType, b.buf(1, 2, 3, 4));
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), null, b.buf(0xf4, 0));
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xf4, 0));
|
||||
d4006 = b.addData(0, b.addr(0x4006), PointerDataType.dataType,
|
||||
b.buf(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00));
|
||||
}
|
||||
|
@ -1289,7 +1289,7 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
|
|||
TraceInstruction i4004;
|
||||
TraceInstruction g4006;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), null, b.buf(0xf4, 0));
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xf4, 0));
|
||||
guest = b.trace.getPlatformManager().addGuestPlatform(x86.getDefaultCompilerSpec());
|
||||
guest.addMappedRange(b.addr(0x0000), b.addr(guest, 0x0000), 1L << 32);
|
||||
g4006 = b.addInstruction(0, b.addr(0x4006), guest, b.buf(0x90));
|
||||
|
@ -1320,9 +1320,9 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
|
|||
guest.addMappedRange(b.addr(0x0000), b.addr(guest, 0x0000), 1L << 32);
|
||||
|
||||
d4000 = b.addData(0, b.addr(0x4000), LongDataType.dataType, b.buf(1, 2, 3, 4));
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), null, b.buf(0xc8, 0x47));
|
||||
i4004 = b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xc8, 0x47));
|
||||
g4006 = b.addInstruction(0, b.addr(0x4006), guest, b.buf(0x90));
|
||||
i4007 = b.addInstruction(0, b.addr(0x4007), null, b.buf(0xff, 0xfd));
|
||||
i4007 = b.addInstruction(0, b.addr(0x4007), b.host, b.buf(0xff, 0xfd));
|
||||
}
|
||||
TraceData u4009 = manager.undefinedData().getAt(0, b.addr(0x4009));
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
CodeUnitInsertionException {
|
||||
Instruction ins;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
ins = b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
ins = b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
assertEquals("ret", ins.toString());
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
|
||||
Instruction i4005;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
assertEquals(i4005, listing.getCodeUnitAt(b.addr(0x4005)));
|
||||
assertNull(listing.getCodeUnitAt(b.addr(0x4006)));
|
||||
|
@ -163,7 +163,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
assertUndefined(listing.getCodeUnitContaining(b.addr(0x4005)));
|
||||
Instruction i4005;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
assertEquals(i4005, listing.getCodeUnitContaining(b.addr(0x4005)));
|
||||
assertEquals(i4005, listing.getCodeUnitContaining(b.addr(0x4006)));
|
||||
|
@ -189,7 +189,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
assertEquals(b.addr(0x4005), cu.getAddress());
|
||||
Instruction i4005;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
assertEquals(i4005, listing.getCodeUnitAfter(b.addr(0x4004)));
|
||||
assertUndefined(cu = listing.getCodeUnitAfter(b.addr(0x4005)));
|
||||
|
@ -215,7 +215,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
assertEquals(b.addr(0x4005), cu.getAddress());
|
||||
Instruction i4005;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
assertEquals(i4005, listing.getCodeUnitBefore(b.addr(0x4006)));
|
||||
assertUndefined(cu = listing.getCodeUnitBefore(b.addr(0x4005)));
|
||||
|
@ -291,7 +291,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
Instruction i4005;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
d4000 = b.addData(0, b.addr(0x4000), Undefined4DataType.dataType, b.buf(1, 2, 3, 4));
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
|
||||
sample = takeN(10, listing.getCodeUnits(true));
|
||||
|
@ -355,7 +355,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
assertNull(listing.getInstructionAt(b.addr(0x4005)));
|
||||
Instruction i4005;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
assertEquals(i4005, listing.getInstructionAt(b.addr(0x4005)));
|
||||
assertNull(listing.getInstructionAt(b.addr(0x4006)));
|
||||
|
@ -368,7 +368,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
assertNull(listing.getInstructionContaining(b.addr(0x4005)));
|
||||
Instruction i4005;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
assertEquals(i4005, listing.getInstructionContaining(b.addr(0x4005)));
|
||||
assertEquals(i4005, listing.getInstructionContaining(b.addr(0x4006)));
|
||||
|
@ -381,7 +381,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
assertNull(listing.getInstructionAfter(b.addr(0x4004)));
|
||||
Instruction i4005;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
assertEquals(i4005, listing.getInstructionAfter(b.addr(0x4004)));
|
||||
assertNull(listing.getInstructionAfter(b.addr(0x4005)));
|
||||
|
@ -393,7 +393,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
assertNull(listing.getInstructionBefore(b.addr(0x4006)));
|
||||
Instruction i4005;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
assertEquals(i4005, listing.getInstructionBefore(b.addr(0x4006)));
|
||||
assertNull(listing.getInstructionBefore(b.addr(0x4005)));
|
||||
|
@ -421,9 +421,9 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
Instruction i4007;
|
||||
Instruction i400a;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
i4007 = b.addInstruction(0, b.addr(0x4007), null, b.buf(0xf4, 0));
|
||||
i400a = b.addInstruction(0, b.addr(0x400a), null, b.buf(0xf4, 0));
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
i4007 = b.addInstruction(0, b.addr(0x4007), b.host, b.buf(0xf4, 0));
|
||||
i400a = b.addInstruction(0, b.addr(0x400a), b.host, b.buf(0xf4, 0));
|
||||
b.addData(0, b.addr(0x400c), Undefined4DataType.dataType, b.buf(1, 2, 3, 4));
|
||||
}
|
||||
|
||||
|
@ -454,7 +454,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
|
||||
assertUndefined(listing.getDataAt(b.addr(0x4005)));
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
assertNull(listing.getDataAt(b.addr(0x4005)));
|
||||
assertNull(listing.getDataAt(b.addr(0x4006)));
|
||||
|
@ -477,7 +477,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
|
||||
assertUndefined(listing.getDataContaining(b.addr(0x4005)));
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
assertNull(listing.getDataContaining(b.addr(0x4005)));
|
||||
assertNull(listing.getDataContaining(b.addr(0x4006)));
|
||||
|
@ -502,7 +502,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
assertUndefined(cu = listing.getDataAfter(b.addr(0x4004)));
|
||||
assertEquals(b.addr(0x4005), cu.getAddress());
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
assertUndefined(cu = listing.getDataAfter(b.addr(0x4004)));
|
||||
assertEquals(b.addr(0x4007), cu.getAddress());
|
||||
|
@ -526,7 +526,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
assertUndefined(cu = listing.getDataBefore(b.addr(0x4006)));
|
||||
assertEquals(b.addr(0x4005), cu.getAddress());
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
assertUndefined(cu = listing.getDataBefore(b.addr(0x4007)));
|
||||
assertEquals(b.addr(0x4004), cu.getAddress());
|
||||
|
@ -600,7 +600,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
Data d4000;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
d4000 = b.addData(0, b.addr(0x4000), Undefined4DataType.dataType, b.buf(1, 2, 3, 4));
|
||||
b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
|
||||
sample = takeN(10, listing.getData(true));
|
||||
|
@ -731,7 +731,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
d4004 = b.addData(0, b.addr(0x4004), Undefined4DataType.dataType, b.buf(5, 6, 7, 8));
|
||||
d400a =
|
||||
b.addData(0, b.addr(0x400a), Undefined4DataType.dataType, b.buf(10, 11, 12, 13));
|
||||
b.addInstruction(0, b.addr(0x400e), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(0, b.addr(0x400e), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
|
||||
assertEquals(List.of(d4000, d4004, d400a), takeN(10, listing.getDefinedData(true)));
|
||||
|
@ -760,7 +760,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
|
||||
assertUndefined(listing.getUndefinedDataAt(b.addr(0x4005)));
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
assertNull(listing.getUndefinedDataAt(b.addr(0x4005)));
|
||||
assertNull(listing.getUndefinedDataAt(b.addr(0x4006)));
|
||||
|
@ -783,7 +783,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
assertUndefined(cu = listing.getUndefinedDataAfter(b.addr(0x4004), TaskMonitor.DUMMY));
|
||||
assertEquals(b.addr(0x4005), cu.getAddress());
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
assertUndefined(cu = listing.getUndefinedDataAfter(b.addr(0x4004), TaskMonitor.DUMMY));
|
||||
assertEquals(b.addr(0x4007), cu.getAddress());
|
||||
|
@ -805,7 +805,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
assertUndefined(cu = listing.getUndefinedDataBefore(b.addr(0x4006), TaskMonitor.DUMMY));
|
||||
assertEquals(b.addr(0x4005), cu.getAddress());
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
assertUndefined(cu = listing.getUndefinedDataBefore(b.addr(0x4007), TaskMonitor.DUMMY));
|
||||
assertEquals(b.addr(0x4004), cu.getAddress());
|
||||
|
@ -816,7 +816,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
UnknownInstructionException, CodeUnitInsertionException {
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
b.addData(0, b.addr(0x4000), Undefined4DataType.dataType, b.buf(1, 2, 3, 4));
|
||||
b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
Data cu;
|
||||
|
||||
|
@ -834,7 +834,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
UnknownInstructionException, CodeUnitInsertionException, CancelledException {
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
b.addData(0, b.addr(0x4000), Undefined4DataType.dataType, b.buf(1, 2, 3, 4));
|
||||
b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
|
||||
TODO(); // Should I expect OTHER ranges in the undefined set?
|
||||
|
@ -849,7 +849,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
assertNull(listing.getDefinedCodeUnitAfter(b.addr(0x3fff)));
|
||||
Instruction i4005;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
assertEquals(i4005, listing.getDefinedCodeUnitAfter(b.addr(0x3fff)));
|
||||
assertNull(listing.getDefinedCodeUnitAfter(b.addr(0x4005)));
|
||||
|
@ -873,7 +873,7 @@ public class DBTraceProgramViewListingTest extends AbstractGhidraHeadlessIntegra
|
|||
assertNull(listing.getDefinedCodeUnitBefore(b.addr(0x4000)));
|
||||
Instruction i4005;
|
||||
try (UndoableTransaction tid = b.startTransaction()) {
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), null, b.buf(0xf4, 0));
|
||||
i4005 = b.addInstruction(0, b.addr(0x4005), b.host, b.buf(0xf4, 0));
|
||||
}
|
||||
assertEquals(i4005, listing.getDefinedCodeUnitBefore(b.addr(0x4006)));
|
||||
assertEquals(d4000, listing.getDefinedCodeUnitBefore(b.addr(0x4005)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue