mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
GP-0: Post-merge refactoring.
This commit is contained in:
parent
230a24e12c
commit
b779f318d6
6 changed files with 62 additions and 23 deletions
|
@ -29,8 +29,7 @@ import ghidra.trace.database.DBTraceUtils;
|
|||
import ghidra.trace.database.symbol.*;
|
||||
import ghidra.trace.model.symbol.*;
|
||||
import ghidra.util.*;
|
||||
import ghidra.util.exception.DuplicateNameException;
|
||||
import ghidra.util.exception.InvalidInputException;
|
||||
import ghidra.util.exception.*;
|
||||
|
||||
public class DBTraceProgramViewSymbolTable implements SymbolTable {
|
||||
|
||||
|
@ -571,6 +570,47 @@ public class DBTraceProgramViewSymbolTable implements SymbolTable {
|
|||
return symbolManager.namespaces().add(name, assertTraceNamespace(parent), source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Namespace getOrCreateNameSpace(Namespace parent, String name, SourceType source)
|
||||
throws DuplicateNameException, InvalidInputException {
|
||||
try (LockHold hold = program.trace.lockWrite()) {
|
||||
Collection<? extends DBTraceNamespaceSymbol> exist =
|
||||
symbolManager.namespaces().getNamed(name);
|
||||
if (!exist.isEmpty()) {
|
||||
return exist.iterator().next();
|
||||
}
|
||||
return createNameSpace(parent, name, source);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GhidraClass convertNamespaceToClass(Namespace namespace) {
|
||||
if (namespace instanceof GhidraClass) {
|
||||
return (GhidraClass) namespace;
|
||||
}
|
||||
try (LockHold hold = program.trace.lockWrite()) {
|
||||
DBTraceNamespaceSymbol dbNamespace = symbolManager.assertIsMine(namespace);
|
||||
|
||||
String origName = dbNamespace.getName();
|
||||
SourceType origSource = dbNamespace.getSource();
|
||||
|
||||
String tempName = origName + System.nanoTime();
|
||||
DBTraceClassSymbol dbClass =
|
||||
symbolManager.classes().add(tempName, dbNamespace.getParentNamespace(), origSource);
|
||||
for (AbstractDBTraceSymbol child : dbNamespace.getChildren()) {
|
||||
child.setNamespace(dbClass);
|
||||
}
|
||||
|
||||
dbNamespace.delete();
|
||||
dbClass.setName(origName, origSource);
|
||||
return dbClass;
|
||||
}
|
||||
catch (DuplicateNameException | InvalidInputException | IllegalArgumentException
|
||||
| CircularDependencyException e) {
|
||||
throw new AssertException("Unexpected exception creating class from namespace", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Symbol createSymbolPlaceholder(Address address, long id) {
|
||||
return new DBTracePlaceholderSymbol(symbolManager, id);
|
||||
|
|
|
@ -42,7 +42,7 @@ public class DBTraceFunctionStackFrame implements StackFrame, Unfinished {
|
|||
}
|
||||
|
||||
protected synchronized boolean checkIsValid() {
|
||||
if (function.checkIsValid()) {
|
||||
if (!function.isDeleted()) {
|
||||
if (!valid) {
|
||||
growsNegative = function.getTrace().getBaseCompilerSpec().stackGrowsNegative();
|
||||
variables = function.getVariables(VariableFilter.COMPOUND_STACK_VARIABLE_FILTER);
|
||||
|
|
|
@ -326,7 +326,10 @@ public class DBTraceSymbolManager implements TraceSymbolManager, DBTraceManager
|
|||
@DBAnnotatedColumn(STORAGE_COLUMN_NAME)
|
||||
static DBObjectColumn STORAGE_COLUMN;
|
||||
|
||||
@DBAnnotatedField(column = STORAGE_COLUMN_NAME, indexed = true, codec = VariableStorageDBFieldCodec.class)
|
||||
@DBAnnotatedField(
|
||||
column = STORAGE_COLUMN_NAME,
|
||||
indexed = true,
|
||||
codec = VariableStorageDBFieldCodec.class)
|
||||
private VariableStorage storage;
|
||||
|
||||
protected final DBTraceSymbolManager manager;
|
||||
|
@ -642,7 +645,7 @@ public class DBTraceSymbolManager implements TraceSymbolManager, DBTraceManager
|
|||
view.invalidateCache();
|
||||
}
|
||||
|
||||
if (!globalNamespace.checkIsValid()) {
|
||||
if (globalNamespace.isDeleted()) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
@ -766,7 +769,7 @@ public class DBTraceSymbolManager implements TraceSymbolManager, DBTraceManager
|
|||
if (dbns.manager != this) {
|
||||
return null;
|
||||
}
|
||||
if (!dbns.checkIsValid()) {
|
||||
if (dbns.isDeleted()) {
|
||||
return null;
|
||||
}
|
||||
if (namespaceStore.contains(dbns)) {
|
||||
|
@ -794,7 +797,7 @@ public class DBTraceSymbolManager implements TraceSymbolManager, DBTraceManager
|
|||
if (dbSym.manager != this) {
|
||||
return null;
|
||||
}
|
||||
if (!dbSym.checkIsValid()) {
|
||||
if (dbSym.isDeleted()) {
|
||||
return null;
|
||||
}
|
||||
long symbolID = dbSym.getID();
|
||||
|
@ -818,7 +821,7 @@ public class DBTraceSymbolManager implements TraceSymbolManager, DBTraceManager
|
|||
if (dbFunc.manager != this) {
|
||||
return null;
|
||||
}
|
||||
if (!dbFunc.checkIsValid()) {
|
||||
if (dbFunc.isDeleted()) {
|
||||
return null;
|
||||
}
|
||||
if (functionStore.contains(dbFunc)) {
|
||||
|
|
|
@ -246,7 +246,7 @@ public class DBTraceAddressSnapRangePropertyMapSpaceTest
|
|||
obj.space1.deleteValue(entry1);
|
||||
assertEquals(0, obj.space1.size());
|
||||
assertTrue(obj.space1.isEmpty());
|
||||
assertFalse(entry1.checkIsValid());
|
||||
assertTrue(entry1.isDeleted());
|
||||
|
||||
try {
|
||||
obj.space1.deleteValue(entry2);
|
||||
|
@ -281,7 +281,7 @@ public class DBTraceAddressSnapRangePropertyMapSpaceTest
|
|||
|
||||
assertTrue(obj.space1.remove(entry1));
|
||||
assertTrue(obj.space1.isEmpty());
|
||||
assertFalse(entry1.getValue().checkIsValid());
|
||||
assertTrue(entry1.getValue().isDeleted());
|
||||
assertTrue(obj.space2.remove(entry1)); // TODO: Should match by shape?
|
||||
TODO();
|
||||
assertTrue(obj.space2.isEmpty());
|
||||
|
@ -358,10 +358,10 @@ public class DBTraceAddressSnapRangePropertyMapSpaceTest
|
|||
MyEntry entry1 =
|
||||
obj.space1.put(new ImmutableTraceAddressSnapRange(addr(0x1000), 5), null);
|
||||
assertEquals(1, obj.space1.size());
|
||||
assertFalse(entry1.isInvalid());
|
||||
assertFalse(entry1.isDeleted());
|
||||
|
||||
obj.space1.clear();
|
||||
assertTrue(entry1.isInvalid());
|
||||
assertTrue(entry1.isDeleted());
|
||||
assertTrue(obj.space1.isEmpty());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue