Merge remote-tracking branch 'origin/GT-3586_ghidra1_ClearBookmarks'

This commit is contained in:
ghidra1 2020-07-13 14:35:13 -04:00
commit 813a24d6d2
4 changed files with 32 additions and 16 deletions

View file

@ -44,7 +44,6 @@ import ghidra.program.database.register.ProgramRegisterContextDB;
import ghidra.program.database.reloc.RelocationManager;
import ghidra.program.database.symbol.*;
import ghidra.program.database.util.AddressSetPropertyMapDB;
import ghidra.program.disassemble.Disassembler;
import ghidra.program.model.address.*;
import ghidra.program.model.lang.*;
import ghidra.program.model.listing.*;
@ -488,7 +487,6 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
return ve;
}
@Override
protected void setDomainFile(DomainFile df) {
super.setDomainFile(df);
@ -2210,21 +2208,16 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
monitor.setProgress(0);
ProgramRegisterContextDB contextMgr =
(ProgramRegisterContextDB) getProgramContext();
if (redisassemblyRequired) {
contextMgr.setLanguage(translator, compilerSpec, memoryManager, monitor);
repairContext(oldLanguageVersion, oldLanguageMinorVersion, translator, monitor);
getCodeManager().reDisassembleAllInstructions(monitor);
}
else {
contextMgr.initializeDefaultValues(language, compilerSpec);
}
if (redisassemblyRequired) {
Disassembler.clearUnimplementedPcodeWarnings(this, null, monitor);
repairContext(oldLanguageVersion, oldLanguageMinorVersion, translator, monitor);
monitor.setMessage("Updating instructions...");
monitor.setProgress(0);
getCodeManager().reDisassembleAllInstructions(500, monitor);
}
// Force function manager to reconcile calling conventions
managers[FUNCTION_MGR].setProgram(this);
managers[FUNCTION_MGR].programReady(UPDATE, getStoredVersion(), monitor);

View file

@ -3525,13 +3525,13 @@ public class CodeManager implements ErrorHandler, ManagerDB {
* be discarded and all instructions redisassembled following flow and adjusting context as needed.
* Instructions which fail to redisassemble will be marked - since only one byte will be skipped, such bad
* instruction disassembly may cause subsequent errors due to possible instruction shift.
* This method is only intended for use by the ProgramDB setLanguage method.
* @param bookmarkLimit maximum number of errors to bookmark
* This method is only intended for use by the ProgramDB setLanguage method which must ensure that
* the context has been properly initialized.
* @param monitor task monitor
* @throws IOException
* @throws IOException if IO error occurs
* @throws CancelledException if the operation is canceled.
*/
public void reDisassembleAllInstructions(int bookmarkLimit, TaskMonitor monitor)
public void reDisassembleAllInstructions(TaskMonitor monitor)
throws IOException, CancelledException {
redisassemblyMode = true;
@ -3539,6 +3539,10 @@ public class CodeManager implements ErrorHandler, ManagerDB {
if (lock.getOwner() != Thread.currentThread()) {
throw new IllegalStateException("Must be invoked by lock owner");
}
Disassembler.clearUnimplementedPcodeWarnings(program, null, monitor);
Disassembler.clearBadInstructionErrors(program, null, monitor);
int maxCount = instAdapter.getRecordCount();
monitor.initialize(maxCount);
monitor.setMessage("Preparing for Re-Disassembly...");

View file

@ -1471,6 +1471,24 @@ public class Disassembler implements DisassemblerConflictHandler {
}
}
/**
* Clear all bookmarks which indicate Bad Instruction within the specified address set.
* @param program program to clear bookmarks
* @param addressSet restricted address set or null for entire program
* @param monitor allow canceling
* @throws CancelledException if monitor canceled
*/
public static void clearBadInstructionErrors(Program program, AddressSetView addressSet,
TaskMonitor monitor) throws CancelledException {
BookmarkManager bmMgr = program.getBookmarkManager();
if (addressSet == null) {
bmMgr.removeBookmarks(BookmarkType.ERROR, ERROR_BOOKMARK_CATEGORY, monitor);
}
else {
bmMgr.removeBookmarks(addressSet, BookmarkType.ERROR, ERROR_BOOKMARK_CATEGORY, monitor);
}
}
private void reportMessage(final String msg) {
if (listener != null) {
listener.disassembleMessageReported(msg);