GP-0 improved error logging for ApplyDataArchiveAnalyzer

This commit is contained in:
ghidra1 2021-01-14 17:18:05 -05:00
parent b0a2791826
commit b7c7120f0f
2 changed files with 17 additions and 9 deletions

View file

@ -27,7 +27,7 @@ import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.data.DataTypeManager;
import ghidra.program.model.listing.Program;
import ghidra.program.model.symbol.SourceType;
import ghidra.util.Msg;
import ghidra.util.exception.VersionException;
import ghidra.util.task.TaskMonitor;
public class ApplyDataArchiveAnalyzer extends AbstractAnalyzer {
@ -67,7 +67,7 @@ public class ApplyDataArchiveAnalyzer extends AbstractAnalyzer {
try {
dtm = service.openDataTypeArchive(archiveName);
if (dtm == null) {
Msg.showError(this, null, "Failed to Apply Data Types",
log.appendMsg("Apply Data Archives",
"Failed to locate data type archive: " + archiveName);
}
else {
@ -75,8 +75,18 @@ public class ApplyDataArchiveAnalyzer extends AbstractAnalyzer {
}
}
catch (Exception e) {
if (mgr.debugOn) {
Msg.error(this, "Unexpected Exception: " + e.getMessage(), e);
Throwable cause = e.getCause();
if (cause instanceof VersionException) {
log.appendMsg("Apply Data Archives",
"Unable to open archive " + archiveName + ": " + cause.toString());
}
else {
String msg = e.getMessage();
if (msg == null) {
msg = e.toString();
}
log.appendMsg("Apply Data Archives",
"Unexpected Error opening archive " + archiveName + ": " + msg);
}
}
}

View file

@ -438,10 +438,8 @@ public class DataTypeManagerHandler {
addArchive(archive);
}
if (isUserAction && (archive instanceof FileArchive)) {
if (file != null) {
userOpenedFileArchiveNames.add(getSaveableArchive(file.getAbsolutePath()));
}
}
return archive;
}
@ -1251,8 +1249,8 @@ public class DataTypeManagerHandler {
public Set<String> getPossibleEquateNames(long value) {
Set<String> equateNames = new HashSet<>();
for (int i = 0; i < openArchives.size(); i++) {
DataTypeManager dtMgr = openArchives.get(i).getDataTypeManager();
for (Archive element : openArchives) {
DataTypeManager dtMgr = element.getDataTypeManager();
dtMgr.findEnumValueNames(value, equateNames);
}
return equateNames;