mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
GP-4788: Correct use of trace base address factory.
This commit is contained in:
parent
82b3831529
commit
20f4bee746
8 changed files with 88 additions and 42 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue