mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-09-20 09:31:47 +00:00
Merge remote-tracking branch
'origin/GP-4788_Dan_fixTraceOverlayAddressComparison--SQUASHED' (#6735)
This commit is contained in:
commit
21d0c5438a
|
@ -4,9 +4,9 @@
|
|||
* 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.
|
||||
|
@ -1146,8 +1146,7 @@ public class DebuggerRegistersProvider extends ComponentProviderAdapter
|
|||
if (mem == null) {
|
||||
return result;
|
||||
}
|
||||
AddressSpace regSpace =
|
||||
thread.getTrace().getBaseLanguage().getAddressFactory().getRegisterSpace();
|
||||
AddressSpace regSpace = thread.getTrace().getBaseAddressFactory().getRegisterSpace();
|
||||
AddressSet everKnown = new AddressSet();
|
||||
for (Entry<TraceAddressSnapRange, TraceMemoryState> entry : mem.getMostRecentStates(
|
||||
thread.getTrace().getTimeManager().getMaxSnap(),
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* 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.
|
||||
|
@ -184,7 +184,7 @@ public class TraceEventListener extends AnnotatedDebuggerAttributeListener {
|
|||
long snap = recorder.getSnap();
|
||||
String path = object.getJoinedPath(".");
|
||||
recorder.parTx.execute("Memory invalidated: " + path, () -> {
|
||||
AddressSet set = trace.getBaseLanguage().getAddressFactory().getAddressSet();
|
||||
AddressSet set = trace.getBaseAddressFactory().getAddressSet();
|
||||
memoryManager.setState(snap, set, TraceMemoryState.UNKNOWN);
|
||||
}, path);
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* 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.
|
||||
|
@ -1803,4 +1803,31 @@ public class DebuggerListingProviderTest extends AbstractGhidraHeadedDebuggerTes
|
|||
waitForSwing();
|
||||
assertFalse(listingPanel.isHoverShowing());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithOverlaySpaces() throws Throwable {
|
||||
createAndOpenTrace("DATA:BE:64:default");
|
||||
AddressSpace ram = tb.trace.getBaseAddressFactory().getDefaultAddressSpace();
|
||||
|
||||
AddressSpace ram0;
|
||||
AddressSpace ram1;
|
||||
try (Transaction tx = tb.startTransaction()) {
|
||||
DBTraceMemoryManager mm = tb.trace.getMemoryManager();
|
||||
ram0 = mm.createOverlayAddressSpace("ram0", ram);
|
||||
ram1 = mm.createOverlayAddressSpace("ram1", ram);
|
||||
|
||||
mm.createRegion("Memory[0]", 0, tb.range(ram1, 0, 0x1000),
|
||||
Set.of(TraceMemoryFlag.READ, TraceMemoryFlag.EXECUTE));
|
||||
mm.createRegion("Memory[1]", 0, tb.range(ram0, 0x1000, 0x2000),
|
||||
Set.of(TraceMemoryFlag.READ, TraceMemoryFlag.WRITE));
|
||||
}
|
||||
waitForDomainObject(tb.trace);
|
||||
|
||||
traceManager.activateTrace(tb.trace);
|
||||
waitForSwing();
|
||||
|
||||
assertEquals(ram0.getAddress(0x1002), listingProvider.getListingPanel()
|
||||
.getListingModel()
|
||||
.getAddressAfter(ram0.getAddress(0x1001)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* 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.
|
||||
|
@ -16,6 +16,7 @@
|
|||
package ghidra.trace.database.listing;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
import generic.NestedIterator;
|
||||
|
@ -258,8 +259,11 @@ public abstract class AbstractBaseDBTraceCodeUnitsMemoryView<T extends DBTraceCo
|
|||
*/
|
||||
public T getFloor(long snap, Address address) {
|
||||
try (LockHold hold = LockHold.lock(readLock())) {
|
||||
for (AddressRange range : DBTraceUtils.getAddressSet(
|
||||
manager.getBaseLanguage().getAddressFactory(), address, false)) {
|
||||
Iterator<AddressRange> it = DBTraceUtils
|
||||
.getAddressSet(manager.getTrace().getBaseAddressFactory(), address, false)
|
||||
.iterator(false);
|
||||
while (it.hasNext()) {
|
||||
AddressRange range = it.next();
|
||||
M m = getForSpace(range.getAddressSpace(), false);
|
||||
T candidate = m == null ? nullOrUndefined(snap, range.getMaxAddress())
|
||||
: m.getFloor(snap, range.getMaxAddress());
|
||||
|
@ -303,7 +307,7 @@ public abstract class AbstractBaseDBTraceCodeUnitsMemoryView<T extends DBTraceCo
|
|||
public T getCeiling(long snap, Address address) {
|
||||
try (LockHold hold = LockHold.lock(readLock())) {
|
||||
for (AddressRange range : DBTraceUtils.getAddressSet(
|
||||
manager.getBaseLanguage().getAddressFactory(), address, true)) {
|
||||
manager.getTrace().getBaseAddressFactory(), address, true)) {
|
||||
M m = getForSpace(range.getAddressSpace(), false);
|
||||
T candidate = m == null ? nullOrUndefined(snap, range.getMinAddress())
|
||||
: m.getCeiling(snap, range.getMinAddress());
|
||||
|
@ -333,7 +337,7 @@ public abstract class AbstractBaseDBTraceCodeUnitsMemoryView<T extends DBTraceCo
|
|||
if (min.hasSameAddressSpace(max)) {
|
||||
return get(snap, new AddressRangeImpl(min, max), forward);
|
||||
}
|
||||
return get(snap, manager.getBaseLanguage().getAddressFactory().getAddressSet(min, max),
|
||||
return get(snap, manager.getTrace().getBaseAddressFactory().getAddressSet(min, max),
|
||||
forward);
|
||||
}
|
||||
|
||||
|
@ -360,7 +364,7 @@ public abstract class AbstractBaseDBTraceCodeUnitsMemoryView<T extends DBTraceCo
|
|||
* @see TraceBaseCodeUnitsView#get(long, Address, boolean)
|
||||
*/
|
||||
public Iterable<? extends T> get(long snap, Address start, boolean forward) {
|
||||
AddressFactory factory = manager.getBaseLanguage().getAddressFactory();
|
||||
AddressFactory factory = manager.getTrace().getBaseAddressFactory();
|
||||
return get(snap, DBTraceUtils.getAddressSet(factory, start, forward), forward);
|
||||
}
|
||||
|
||||
|
@ -368,7 +372,7 @@ public abstract class AbstractBaseDBTraceCodeUnitsMemoryView<T extends DBTraceCo
|
|||
* @see TraceBaseCodeUnitsView#get(long, boolean)
|
||||
*/
|
||||
public Iterable<? extends T> get(long snap, boolean forward) {
|
||||
return get(snap, manager.getBaseLanguage().getAddressFactory().getAddressSet(), forward);
|
||||
return get(snap, manager.getTrace().getBaseAddressFactory().getAddressSet(), forward);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -398,7 +402,7 @@ public abstract class AbstractBaseDBTraceCodeUnitsMemoryView<T extends DBTraceCo
|
|||
*/
|
||||
public AddressSetView getAddressSetView(long snap) {
|
||||
AddressSet result = new AddressSet();
|
||||
for (AddressRange range : manager.getBaseLanguage().getAddressFactory().getAddressSet()) {
|
||||
for (AddressRange range : manager.getTrace().getBaseAddressFactory().getAddressSet()) {
|
||||
M m = getForSpace(range.getAddressSpace(), false);
|
||||
if (m == null) {
|
||||
result.add(emptyOrFullAddressSetUndefined(range));
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* 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.
|
||||
|
@ -75,7 +75,7 @@ public class DBTraceInstructionsMemoryView
|
|||
for (InstructionBlock block : mappedSet) {
|
||||
InstructionSet setPerSpace =
|
||||
breakDown.computeIfAbsent(block.getStartAddress().getAddressSpace(),
|
||||
s -> new InstructionSet(manager.getBaseLanguage().getAddressFactory()));
|
||||
s -> new InstructionSet(manager.getTrace().getBaseAddressFactory()));
|
||||
setPerSpace.addBlock(block);
|
||||
}
|
||||
AddressSet result = new AddressSet();
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* 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.
|
||||
|
@ -159,7 +159,7 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
|
|||
|
||||
protected AddressSet getAddressSet(Address start, boolean forward) {
|
||||
AddressFactory factory = program.getAddressFactory();
|
||||
AddressSet all = program.allAddresses;
|
||||
AddressSetView all = program.getAllAddresses();
|
||||
return forward
|
||||
? factory.getAddressSet(start, all.getMaxAddress())
|
||||
: factory.getAddressSet(all.getMinAddress(), start);
|
||||
|
@ -281,7 +281,7 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
|
|||
}
|
||||
|
||||
protected Iterator<TraceCodeUnit> getCodeUnitIterator(boolean forward) {
|
||||
AddressSetView set = program.allAddresses;
|
||||
AddressSetView set = program.getAllAddresses();
|
||||
return getCodeUnitIterator(forward ? set.getMinAddress() : set.getMaxAddress(), forward);
|
||||
}
|
||||
|
||||
|
@ -300,7 +300,7 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
|
|||
}
|
||||
|
||||
protected Iterator<TraceData> getDataIterator(boolean forward) {
|
||||
AddressSetView set = program.allAddresses;
|
||||
AddressSetView set = program.getAllAddresses();
|
||||
return getDataIterator(forward ? set.getMinAddress() : set.getMaxAddress(), forward);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* 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.
|
||||
|
@ -708,7 +708,8 @@ public class DBTraceProgramView implements TraceProgramView {
|
|||
|
||||
protected final DomainObjectEventQueues eventQueues;
|
||||
protected EventTranslator eventTranslator;
|
||||
protected final AddressSet allAddresses = new AddressSet();
|
||||
private volatile boolean allAddressesValid;
|
||||
private volatile AddressSetView allAddresses;;
|
||||
|
||||
protected final DBTraceProgramViewBookmarkManager bookmarkManager;
|
||||
protected final DBTraceProgramViewEquateTable equateTable;
|
||||
|
@ -733,18 +734,14 @@ public class DBTraceProgramView implements TraceProgramView {
|
|||
Long versionTag = 0L;
|
||||
|
||||
public DBTraceProgramView(DBTrace trace, long snap, CompilerSpec compilerSpec) {
|
||||
for (AddressSpace space : trace.getBaseAddressFactory().getPhysicalSpaces()) {
|
||||
if (space.getType() == AddressSpace.TYPE_OTHER) {
|
||||
continue;
|
||||
}
|
||||
allAddresses.add(space.getMinAddress(), space.getMaxAddress());
|
||||
}
|
||||
this.trace = trace;
|
||||
this.snap = snap;
|
||||
this.languageID = compilerSpec.getLanguage().getLanguageID();
|
||||
this.language = compilerSpec.getLanguage();
|
||||
this.compilerSpec = compilerSpec;
|
||||
|
||||
checkRefreshAllAddresses();
|
||||
|
||||
this.viewport = trace.createTimeViewport();
|
||||
this.viewport.setSnap(snap);
|
||||
|
||||
|
@ -766,6 +763,25 @@ public class DBTraceProgramView implements TraceProgramView {
|
|||
|
||||
}
|
||||
|
||||
protected void checkRefreshAllAddresses() {
|
||||
if (this.allAddressesValid) {
|
||||
return;
|
||||
}
|
||||
AddressSet allAddresses = new AddressSet();
|
||||
for (AddressSpace space : trace.getBaseAddressFactory().getPhysicalSpaces()) {
|
||||
if (space.getType() != AddressSpace.TYPE_OTHER) {
|
||||
allAddresses.add(space.getMinAddress(), space.getMaxAddress());
|
||||
}
|
||||
}
|
||||
this.allAddresses = allAddresses;
|
||||
this.allAddressesValid = true;
|
||||
}
|
||||
|
||||
protected AddressSetView getAllAddresses() {
|
||||
checkRefreshAllAddresses();
|
||||
return allAddresses;
|
||||
}
|
||||
|
||||
protected void viewportChanged() {
|
||||
eventQueues.fireEvent(new DomainObjectChangeRecord(DomainObjectEvent.RESTORED));
|
||||
}
|
||||
|
@ -1500,11 +1516,13 @@ public class DBTraceProgramView implements TraceProgramView {
|
|||
public void updateMemoryAddSpaceBlock(AddressSpace space) {
|
||||
// Spaces not not time-bound. No visibility check.
|
||||
memory.updateAddSpaceBlock(space);
|
||||
allAddressesValid = false;
|
||||
}
|
||||
|
||||
public void updateMemoryDeleteSpaceBlock(AddressSpace space) {
|
||||
// Spaces not not time-bound. No visibility check.
|
||||
memory.updateDeleteSpaceBlock(space);
|
||||
allAddressesValid = false;
|
||||
}
|
||||
|
||||
public void updateMemoryRefreshBlocks() {
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* 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.
|
||||
|
@ -15,18 +15,16 @@
|
|||
*/
|
||||
package ghidra.trace.database.program;
|
||||
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressRange;
|
||||
import ghidra.trace.model.Lifespan;
|
||||
import ghidra.util.LockHold;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
public class DBTraceProgramViewListing extends AbstractDBTraceProgramViewListing {
|
||||
protected final AddressSet allMemory;
|
||||
|
||||
public DBTraceProgramViewListing(DBTraceProgramView program) {
|
||||
super(program, program.trace.getCodeManager());
|
||||
this.allMemory = program.getAddressFactory().getAddressSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,7 +59,7 @@ public class DBTraceProgramViewListing extends AbstractDBTraceProgramViewListing
|
|||
// TODO: Delete this when the interface removes it
|
||||
public void clearAll(boolean clearContext, TaskMonitor monitor) {
|
||||
try (LockHold hold = program.trace.lockRead()) {
|
||||
for (AddressRange range : allMemory) {
|
||||
for (AddressRange range : program.getAddressFactory().getAddressSet()) {
|
||||
codeOperations.definedUnits()
|
||||
.clear(Lifespan.at(program.snap), range, clearContext, monitor);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user