mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
GP-589 - Updated Function.getCalledFunctions() and
Function.getCallingFunctions() to support a null task monitor Closes #589
This commit is contained in:
parent
89a6574f6e
commit
8e4f0c5f16
2 changed files with 25 additions and 8 deletions
|
@ -283,7 +283,8 @@ public class FunctionDB extends DatabaseObject implements Function {
|
||||||
manager.lock.acquire();
|
manager.lock.acquire();
|
||||||
try {
|
try {
|
||||||
checkIsValid();
|
checkIsValid();
|
||||||
return manager.getCodeManager().getComment(CodeUnit.REPEATABLE_COMMENT,
|
return manager.getCodeManager()
|
||||||
|
.getComment(CodeUnit.REPEATABLE_COMMENT,
|
||||||
getEntryPoint());
|
getEntryPoint());
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
@ -301,7 +302,8 @@ public class FunctionDB extends DatabaseObject implements Function {
|
||||||
manager.lock.acquire();
|
manager.lock.acquire();
|
||||||
try {
|
try {
|
||||||
checkDeleted();
|
checkDeleted();
|
||||||
manager.getCodeManager().setComment(getEntryPoint(), CodeUnit.REPEATABLE_COMMENT,
|
manager.getCodeManager()
|
||||||
|
.setComment(getEntryPoint(), CodeUnit.REPEATABLE_COMMENT,
|
||||||
comment);
|
comment);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
@ -885,7 +887,8 @@ public class FunctionDB extends DatabaseObject implements Function {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
program.getBookmarkManager().setBookmark(getEntryPoint(), BookmarkType.ERROR,
|
program.getBookmarkManager()
|
||||||
|
.setBookmark(getEntryPoint(), BookmarkType.ERROR,
|
||||||
"Bad Variables Removed", "Removed " + badSymbols.size() + " bad variables");
|
"Bad Variables Removed", "Removed " + badSymbols.size() + " bad variables");
|
||||||
for (Symbol s : badSymbols) {
|
for (Symbol s : badSymbols) {
|
||||||
s.delete();
|
s.delete();
|
||||||
|
@ -2703,7 +2706,9 @@ public class FunctionDB extends DatabaseObject implements Function {
|
||||||
callFixupMap.remove(entryPoint);
|
callFixupMap.remove(entryPoint);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (program.getCompilerSpec().getPcodeInjectLibrary().getPayload(
|
if (program.getCompilerSpec()
|
||||||
|
.getPcodeInjectLibrary()
|
||||||
|
.getPayload(
|
||||||
InjectPayload.CALLFIXUP_TYPE, name, null, null) == null) {
|
InjectPayload.CALLFIXUP_TYPE, name, null, null) == null) {
|
||||||
Msg.warn(this, "Undefined CallFixup set at " + entryPoint + ": " + name);
|
Msg.warn(this, "Undefined CallFixup set at " + entryPoint + ": " + name);
|
||||||
}
|
}
|
||||||
|
@ -2719,6 +2724,7 @@ public class FunctionDB extends DatabaseObject implements Function {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Function> getCallingFunctions(TaskMonitor monitor) {
|
public Set<Function> getCallingFunctions(TaskMonitor monitor) {
|
||||||
|
monitor = TaskMonitor.dummyIfNull(monitor);
|
||||||
Set<Function> set = new HashSet<>();
|
Set<Function> set = new HashSet<>();
|
||||||
ReferenceIterator iter = program.getReferenceManager().getReferencesTo(getEntryPoint());
|
ReferenceIterator iter = program.getReferenceManager().getReferencesTo(getEntryPoint());
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
|
@ -2737,6 +2743,7 @@ public class FunctionDB extends DatabaseObject implements Function {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Function> getCalledFunctions(TaskMonitor monitor) {
|
public Set<Function> getCalledFunctions(TaskMonitor monitor) {
|
||||||
|
monitor = TaskMonitor.dummyIfNull(monitor);
|
||||||
Set<Function> set = new HashSet<>();
|
Set<Function> set = new HashSet<>();
|
||||||
Set<Reference> references = getReferencesFromBody(monitor);
|
Set<Reference> references = getReferencesFromBody(monitor);
|
||||||
for (Reference reference : references) {
|
for (Reference reference : references) {
|
||||||
|
|
|
@ -32,6 +32,16 @@ public interface TaskMonitor {
|
||||||
|
|
||||||
public static final TaskMonitor DUMMY = new StubTaskMonitor();
|
public static final TaskMonitor DUMMY = new StubTaskMonitor();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the given task monitor if it is not {@code null}. Otherwise, a {@link #DUMMY}
|
||||||
|
* monitor is returned.
|
||||||
|
* @param tm the monitor to check for {@code null}
|
||||||
|
* @return a non-null task monitor
|
||||||
|
*/
|
||||||
|
public static TaskMonitor dummyIfNull(TaskMonitor tm) {
|
||||||
|
return tm == null ? DUMMY : tm;
|
||||||
|
}
|
||||||
|
|
||||||
/** A value to indicate that this monitor has no progress value set */
|
/** A value to indicate that this monitor has no progress value set */
|
||||||
public static final int NO_PROGRESS_VALUE = -1;
|
public static final int NO_PROGRESS_VALUE = -1;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue