mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 12:00:04 +02:00
GP-1346 corrected SymbolManager.getClassNamespaces()
This commit is contained in:
parent
5b07797cb8
commit
f1ee39fd3c
2 changed files with 25 additions and 13 deletions
|
@ -1988,29 +1988,40 @@ public class SymbolManager implements SymbolTable, ManagerDB {
|
|||
|
||||
private class ClassNamespaceIterator implements Iterator<GhidraClass> {
|
||||
|
||||
private Iterator<Symbol> symbols;
|
||||
private QueryRecordIterator iter;
|
||||
|
||||
ClassNamespaceIterator() {
|
||||
ArrayList<Symbol> list = new ArrayList<>();
|
||||
SymbolIterator iter = getSymbols(namespaceMgr.getGlobalNamespace());
|
||||
while (iter.hasNext()) {
|
||||
Symbol s = iter.next();
|
||||
if (s.getSymbolType() == SymbolType.CLASS) {
|
||||
list.add(s);
|
||||
}
|
||||
try {
|
||||
byte classTypeId = SymbolType.CLASS.getID();
|
||||
iter = new QueryRecordIterator(adapter.getSymbols(),
|
||||
rec -> classTypeId == rec.getByteValue(SymbolDatabaseAdapter.SYMBOL_TYPE_COL));
|
||||
}
|
||||
catch (IOException e) {
|
||||
dbError(e);
|
||||
}
|
||||
symbols = list.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return symbols.hasNext();
|
||||
try {
|
||||
return iter.hasNext();
|
||||
}
|
||||
catch (IOException e) {
|
||||
dbError(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GhidraClass next() {
|
||||
if (symbols.hasNext()) {
|
||||
return (GhidraClass) symbols.next().getObject();
|
||||
try {
|
||||
if (iter.hasNext()) {
|
||||
Symbol s = getSymbol(iter.next());
|
||||
return (GhidraClass) s.getObject();
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
dbError(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -560,7 +560,8 @@ public interface SymbolTable {
|
|||
public Namespace getNamespace(Address addr);
|
||||
|
||||
/**
|
||||
* Returns all Class Namespaces defined within the program.
|
||||
* Returns all Class Namespaces defined within the program in an
|
||||
* arbitrary ordering.
|
||||
* @return iterator of {@link GhidraClass}
|
||||
*/
|
||||
public Iterator<GhidraClass> getClassNamespaces();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue