Java Code Examples for ghidra.util.task.TaskMonitor#checkCanceled()

The following examples show how to use ghidra.util.task.TaskMonitor#checkCanceled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskSimulator.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void run(UndoableDomainObject domainObject, TaskMonitor monitor)
		throws CancelledException {

	monitor.initialize(count);

	for (int i = 0; i < count; i++) {
		monitor.checkCanceled();
		try {
			Thread.sleep(1000);
		}
		catch (InterruptedException e) {
			e.printStackTrace();
		}
		monitor.setMessage("Completed " + (i + 1) + " of " + count);
		monitor.incrementProgress(1);
		if (yielding) {
			taskMgr.waitForHigherPriorityTasks();
		}
	}

}
 
Example 2
Source File: MemorySectionResolver.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Perform final resolve of all defined memory "sections" to establish final memory mappings.
 * This method will resolve all conflicts and create memory blocks within the associated program.
 * @param monitor
 * @throws CancelledException
 */
public void resolve(TaskMonitor monitor) throws CancelledException {

	if (sectionMemoryMap != null) {
		throw new IllegalStateException("already resolved");
	}

	if (!program.getMemory().isEmpty()) {
		throw new IllegalStateException("program memory blocks already exist - unsupported");
	}

	// Maintain file allocation map for resolving file section overlap (i.e., shared bytes)
	// AddressRange -> section loaded from file
	AddressRangeObjectMap<AllocatedFileSectionRange> fileAllocationMap =
		new AddressRangeObjectMap<>();

	// build-up mapping of sections to a sequence of memory ranges
	sectionMemoryMap = new HashMap<>();

	// process sections in reverse order - last-in takes precedence
	int sectionCount = sections.size();
	for (int index = sectionCount - 1; index >= 0; --index) {
		monitor.checkCanceled();
		resolveSectionMemory(sections.get(index), fileAllocationMap, monitor);
	}
}
 
Example 3
Source File: ProgramMerge.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * <CODE>mergeEquates</CODE> merges the equate differences in the specified
 * address set.
 *
 * @param originAddressSet the addresses to be merged.
 * The addresses in this set should be derived from the origin program.
 * @param monitor the task monitor for notifying the user of this merge's
 * progress.
 *
 * @throws CancelledException if user cancels via the monitor.
 * @throws UnsupportedOperationException if the ProgramMerge translators are not
 * "one for one translators".
 */
public void mergeEquates(AddressSetView originAddressSet, TaskMonitor monitor)
		throws CancelledException, UnsupportedOperationException {

	if (!originToResultTranslator.isOneForOneTranslator()) {
		String message = originToResultTranslator.getClass().getName() +
			" is not a one for one translator and can't merge equates.";
		throw new UnsupportedOperationException(message);
	}
	monitor.setMessage("Applying Equates...");
	if (originAddressSet.isEmpty()) {
		return;
	}

	AddressIterator addresses = originAddressSet.getAddresses(true);
	// Get each equate out of the equate address iterator and set it in the merged program.
	for (long count = 0; addresses.hasNext() && !monitor.isCancelled(); count++) {
		monitor.checkCanceled();
		Address address = addresses.next();
		if (count == PROGRESS_COUNTER_GRANULARITY) {
			monitor.setMessage("Applying Equates...   " + address.toString(true, false));
			count = 0;
		}
		mergeEquates(address);
	}
}
 
Example 4
Source File: FunctionMerger.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void handleOverlappingFunctionsConflict(ListingMergePanel listingPanel, Address addr,
		int currentConflictOption, TaskMonitor monitor) throws CancelledException {
	currentConflictType = FunctionConflictType.FUNCTION_OVERLAP_CONFLICT;
	boolean askUser =
		(overlapChoice == ASK_USER) && currentConflictOption == ListingMergeConstants.ASK_USER;
	if (askUser && mergeManager != null) {
		VariousChoicesPanel choicesPanel = createOverlapConflictPanel(addr, monitor);

		boolean useForAll = (overlapChoice != ASK_USER);
		choicesPanel.setUseForAll(useForAll);
		choicesPanel.setConflictType("Function Overlap");

		setupAddressSetConflictPanel(listingPanel, choicesPanel, addr,
			overlapConflicts.get(addr), monitor);
		monitor.checkCanceled();
	}
	else {
		// If we have a function overlap choice then a "Use For All" has already occurred.
		int optionToUse = (overlapChoice == ASK_USER) ? currentConflictOption : overlapChoice;
		mergeOverlap(addr, optionToUse, monitor);
	}
}
 
Example 5
Source File: DyldCacheLocalSymbolsInfo.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void parseLocalSymbols(MessageLog log, TaskMonitor monitor) throws CancelledException {
	monitor.setMessage("Parsing DYLD local symbol entries...");
	monitor.initialize(entriesCount);
	reader.setPointerIndex(startIndex + entriesOffset);
	try {
		for (int i = 0; i < entriesCount; ++i) {
			localSymbolsEntryList.add(new DyldCacheLocalSymbolsEntry(reader));
			monitor.checkCanceled();
			monitor.incrementProgress(1);
		}
	}
	catch (IOException e) {
		log.appendMsg(DyldCacheAccelerateInfo.class.getSimpleName(),
			"Failed to parse dyld_cache_local_symbols_entry.");
	}
}
 
Example 6
Source File: FunctionMerger.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void handleFunctionBodyConflict(ListingMergePanel listingPanel, Address addr,
		int currentConflictOption, TaskMonitor monitor) throws CancelledException {
	currentConflictType = FunctionConflictType.FUNCTION_BODY_CONFLICT;
	boolean askUser =
		(bodyChoice == ASK_USER) && currentConflictOption == ListingMergeConstants.ASK_USER;
	if (askUser && mergeManager != null) {
		VerticalChoicesPanel choicesPanel = createBodyConflictPanel(addr, monitor);

		boolean useForAll = (bodyChoice != ASK_USER);
		choicesPanel.setUseForAll(useForAll);
		choicesPanel.setConflictType("Function Body");

		setupAddressSetConflictPanel(listingPanel, choicesPanel, addr, getBodySet(addr),
			monitor);
		monitor.checkCanceled();
	}
	else {
		// If we have a function body choice then a "Use For All" has already occurred.
		int optionToUse = (bodyChoice == ASK_USER) ? currentConflictOption : bodyChoice;
		merge(addr, optionToUse, monitor);
	}
}
 
Example 7
Source File: AutoVersionTrackingCommand.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private int getNumberOfDataMatches(TaskMonitor monitor) throws CancelledException {

		int numDataMatches = 0;
		List<VTMatchSet> matchSets = session.getMatchSets();
		for (VTMatchSet matchSet : matchSets) {
			monitor.checkCanceled();
			Collection<VTMatch> matches = matchSet.getMatches();
			for (VTMatch match : matches) {
				monitor.checkCanceled();
				if (match.getAssociation().getStatus() == VTAssociationStatus.ACCEPTED &&
					match.getAssociation().getType() == VTAssociationType.DATA) {
					numDataMatches++;
				}
			}
		}
		return numDataMatches;
	}
 
Example 8
Source File: SetMarkupItemDestinationAddressTask.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean doWork(TaskMonitor monitor) throws Exception {
	monitor.initialize(markupItems.size());

	for (VTMarkupItem markupItem : markupItems) {
		monitor.checkCanceled();
		markupItem.setDestinationAddress(destinationAddress);
		monitor.incrementProgress(1);
	}
	return true;
}
 
Example 9
Source File: GTreeSelectNodeByNameTask.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private GTreeNode findNodeByName(GTreeNode node, String name, TaskMonitor monitor)
		throws CancelledException {
	for (GTreeNode child : node.getChildren()) {
		monitor.checkCanceled();
		if (child.getName().equals(name)) {
			return child;
		}
	}
	return null;
}
 
Example 10
Source File: EquateMerger.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public void mergeConflicts(ListingMergePanel listingPanel, Address addr,
		int chosenConflictOption, TaskMonitor monitor) throws CancelledException,
		MemoryAccessException {
	if (!hasConflict(addr)) {
		return;
	}
	monitor.setMessage("Resolving Equate conflicts.");
	boolean askUser = chosenConflictOption == ASK_USER;

	// At address get the equate conflict ArrayList.
	ArrayList<EquateConflict> list = conflicts.get(addr);
	if (list != null) {
		int len = list.size();
		// merge each conflict at this address.
		for (int i = 0; i < len; i++) {
			EquateConflict equateConflict = list.get(i);
			// If we have a equate choice then a "Use For All" has already occurred.
			if (equateChoice != ASK_USER) {
				merge(equateConflict.address, equateConflict.opIndex, equateConflict.scalar,
					equateChoice);
			}
			else {
				if (askUser && mergeManager != null) {
					setupConflictPanel(listingPanel, equateConflict);
					monitor.checkCanceled();
				}
				else {
					merge(equateConflict.address, equateConflict.opIndex,
						equateConflict.scalar, chosenConflictOption);
				}
			}
		}
	}
}
 
Example 11
Source File: ElfProgramBuilder.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void processSymbolTables(TaskMonitor monitor) throws CancelledException {

		monitor.setMessage("Processing symbol tables...");

		// Mapped data/object symbol addresses with specific sizes
		HashMap<Address, Integer> dataAllocationMap = new HashMap<>();

		ElfSymbolTable[] symbolTables = elf.getSymbolTables();

		for (ElfSymbolTable elfSymbolTable : symbolTables) {
			monitor.checkCanceled();

			Address symbolTableAddr = null;

			ElfSectionHeader symbolTableSection = elfSymbolTable.getTableSectionHeader();
			if (symbolTableSection != null) {
				symbolTableAddr = findLoadAddress(symbolTableSection, 0);
			}
			else {
				symbolTableAddr =
					findLoadAddress(elfSymbolTable.getFileOffset(), elfSymbolTable.getLength());
			}

			ElfSymbol[] symbols = elfSymbolTable.getSymbols();

			if (symbolTableAddr != null) {
				markupSymbolTable(symbolTableAddr, elfSymbolTable, monitor);
			}

			processSymbols(symbols, dataAllocationMap, monitor);
		}

		//create an artificial block for the external symbols
		createExternalBlock();

		// create undefined data code units for symbols
		allocateUndefinedSymbolData(dataAllocationMap);
	}
 
Example 12
Source File: Ext4FileSystem.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private Ext4Inode[] getInodes(BinaryReader reader, Ext4SuperBlock superBlock,
		Ext4GroupDescriptor[] groupDescriptors, boolean is64Bit, TaskMonitor monitor)
		throws IOException, CancelledException {

	int inodeCount = superBlock.getS_inodes_count();
	Ext4Inode[] inodes = new Ext4Inode[inodeCount + 1];
	int inodeIndex = 1;

	for (int i = 0; i < groupDescriptors.length; i++) {
		monitor.checkCanceled();
		long inodeTableBlockOffset = groupDescriptors[i].getBg_inode_table_lo() & 0xffffffffL;
		if (is64Bit) {
			inodeTableBlockOffset =
				(groupDescriptors[i].getBg_inode_table_hi() << 32) | inodeTableBlockOffset;
		}
		long offset = inodeTableBlockOffset * blockSize;
		reader.setPointerIndex(offset);
		int inodesPerGroup = superBlock.getS_inodes_per_group();
		monitor.setMessage(
			"Reading inode table " + i + " of " + (groupDescriptors.length - 1) + "...");
		monitor.setMaximum(inodesPerGroup);
		monitor.setProgress(0);
		for (int j = 0; j < inodesPerGroup; j++) {
			monitor.checkCanceled();
			monitor.incrementProgress(1);

			Ext4Inode inode = new Ext4Inode(reader);
			offset = offset + superBlock.getS_inode_size();
			reader.setPointerIndex(offset);

			inodes[inodeIndex++] = inode; //inodes[ inodesPerGroup * i + j ] = inode;
		}
	}
	return inodes;
}
 
Example 13
Source File: DexMarkupDataAnalyzer.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public boolean analyze( Program program, AddressSetView set, TaskMonitor monitor, MessageLog log ) throws Exception {
	monitor.setMaximum( set == null ? program.getMemory( ).getSize( ) : set.getNumAddresses( ) );
	monitor.setProgress( 0 );

	DexAnalysisState analysisState = DexAnalysisState.getState(program);
	DexHeader header = analysisState.getHeader();

	int headerLength = header.toDataType( ).getLength( );

	Listing listing = program.getListing( );

	DataIterator dataIterator = listing.getDefinedData( set, true );
	while ( dataIterator.hasNext( ) ) {
		monitor.checkCanceled( );
		monitor.incrementProgress( 1 );

		Data data = dataIterator.next( );

		if ( data.getMinAddress( ).getOffset( ) == 0x0 ) {
			continue;// skip the main dex header..
		}

		monitor.setMessage( "DEX: Data markup ... " + data.getMinAddress( ) );

		if ( data.isStructure( ) ) {
			processData( data, headerLength, monitor );
		}
	}

	return true;
}
 
Example 14
Source File: GTaskTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public void run(UndoableDomainObject obj, TaskMonitor monitor) throws CancelledException {
	try {
		if (!latch.await(2, TimeUnit.SECONDS)) {
			Assert.fail("Latch await expired!");
		}
	}
	catch (InterruptedException e) {
		Assert.fail("Did not expect Interrupted Exception");
	}
	monitor.checkCanceled();
	super.run(obj, monitor);
}
 
Example 15
Source File: BookmarkMerger.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public void mergeConflicts(ListingMergePanel listingPanel, Address addr,
		int chosenConflictOption, TaskMonitor monitor) throws CancelledException,
		MemoryAccessException {
	monitor.setMessage("Resolving Bookmark conflicts.");
	if (!hasConflict(addr)) {
		return;
	}
	// At address get the BookmarkUid ArrayList for each conflict.
	boolean askUser = chosenConflictOption == ASK_USER;
	ArrayList<BookmarkUid> list = conflicts.get(addr);
	int size = list.size();
	for (int i = 0; i < size; i++) {
		BookmarkUid bmuid = list.get(i);
		// If we have a bookmark choice then a "Use For All" has already occurred.
		if ((bookmarkChoice == ASK_USER) && askUser && mergeManager != null) {
			showMergePanel(listingPanel, bmuid.address, bmuid.bookmarkType,
				bmuid.bookmarkCategory, monitor);
			monitor.checkCanceled();
		}
		else {
			int optionToUse =
				(bookmarkChoice == ASK_USER) ? chosenConflictOption : bookmarkChoice;
			merge(bmuid.address, bmuid.bookmarkType, bmuid.bookmarkCategory, optionToUse,
				monitor);
		}
	}
	resolvedSet.addRange(addr, addr);
}
 
Example 16
Source File: ApplyTypeDefs.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Perform parsing and caching of typedefs 
 * @param monitor task monitor
 * @throws CancelledException if task cancelled
 */
void buildTypeDefs(TaskMonitor monitor) throws CancelledException {
	monitor.setMessage("Applying typedefs...");
	// NOTE: PDB does not appear to contain typedefs of typedefs.  Such definitions do not convey
	// so we are saved from having dependency ordering issues for typedef elements.
	for (XmlElement elem : todo) {
		monitor.checkCanceled();

		String datatypeName =
			SymbolUtilities.replaceInvalidChars(elem.getAttribute("name"), false);
		String baseDatatypeName =
			SymbolUtilities.replaceInvalidChars(elem.getAttribute("basetype"), false);

		if (datatypeName.equals(baseDatatypeName)) {
			continue;
		}
		if ("Function".equals(baseDatatypeName)) {
			continue;//TODO is this actually a global function
		}

		WrappedDataType baseDataType = pdbParser.findDataType(baseDatatypeName);
		if (baseDataType == null) {
			log.appendMsg("PDB",
				"Failed to resolve typedef: " + datatypeName + " -> " + baseDatatypeName);
			continue;
		}
		if (baseDataType.isZeroLengthArray()) {
			log.appendMsg("PDB",
				"Zero length array not supported for typedef: " + datatypeName);
			continue;
		}

		TypedefDataType typedef =
			pdbParser.createTypeDef(datatypeName, baseDataType.getDataType());
		pdbParser.cacheDataType(datatypeName, typedef); // cache with namespace-based name
	}
}
 
Example 17
Source File: SetMarkupItemConsideredTask.java    From ghidra with Apache License 2.0 5 votes vote down vote up
protected void doWork(TaskMonitor monitor) throws Exception, CancelledException {
	monitor.initialize(markupItems.size());
	for (VTMarkupItem markupItem : markupItems) {
		monitor.checkCanceled();
		markupItem.setConsidered(status);
		monitor.incrementProgress(1);
	}
}
 
Example 18
Source File: FunctionMerger.java    From ghidra with Apache License 2.0 4 votes vote down vote up
public void mergeThunks(ListingMergePanel listingPanel, int currentConflictOption,
			TaskMonitor monitor) throws CancelledException {

		currentConflictType = FunctionConflictType.THUNK_CONFLICT;
		boolean askUser = currentConflictOption == ListingMergeConstants.ASK_USER;
		this.currentMonitor = monitor;

		mergeEntireFunctions(thunkAutoMergeSet, KEEP_MY, monitor);

		AddressIterator conflictIter = thunkConflictSet.getAddresses(true);
		while (conflictIter.hasNext()) {
			Address thunkConflictAddress = conflictIter.next();
			this.currentAddress = thunkConflictAddress;
			Function latestFunction = functionManagers[LATEST].getFunctionAt(thunkConflictAddress);
			Function myFunction = functionManagers[MY].getFunctionAt(thunkConflictAddress);
			boolean latestIsInvalidThunk = (latestFunction != null) && latestFunction.isThunk() &&
				(latestFunction.getThunkedFunction(false) == null);
			boolean myIsInvalidThunk = (myFunction != null) && myFunction.isThunk() &&
				(myFunction.getThunkedFunction(false) == null);
			if (latestIsInvalidThunk && myIsInvalidThunk) {
				continue;
			}
			else if (myIsInvalidThunk) {
				// The my thunked function is no longer there so can't pick the thunk. Instead keep LATEST function.
				// We already have the LATEST so do nothing.
				continue;
			}
			else if (latestIsInvalidThunk) {
				// The latest thunked function is no longer there so can't pick the thunk. Instead keep MY function.
				ProgramMerge programListingMerge = getProgramListingMerge(KEEP_MY);
				programListingMerge.mergeFunction(thunkConflictAddress, monitor);
				continue;
			}
			// If we have a thunk function choice then a "Use For All" has already occurred.
			if (thunkChoice != ASK_USER) {
				merge(thunkConflictAddress, thunkChoice, monitor);
			}
			// Handle thunk function conflict.
			else if (askUser && mergeManager != null) {
				VerticalChoicesPanel choicesPanel =
					createThunkConflictPanel(thunkConflictAddress, monitor);

				boolean useForAll = (thunkChoice != ASK_USER);
				choicesPanel.setUseForAll(useForAll);
				choicesPanel.setConflictType("Thunk Function");

				setupConflictPanel(listingPanel, choicesPanel, thunkConflictAddress, monitor);
				monitor.checkCanceled();
			}
			else {
				merge(thunkConflictAddress, currentConflictOption, monitor);
			}
			monitor.checkCanceled();
		}

		showResolveErrors(ERROR_TITLE);
		showResolveInfo(INFO_TITLE);
//		clearResolveErrors();
//		clearResolveInfo();
	}
 
Example 19
Source File: AbstractFunctionMerger.java    From ghidra with Apache License 2.0 4 votes vote down vote up
/**
	 * Compares the functions (Latest, Original, My) to determine where conflicting changes
	 * have been made to Latest and My. It then saves the conflict info within the merger for 
	 * later resolution and processing.
	 * @param functions the matching set of functions from Result, Latest, My, and Original.
	 * (Use MergeConstants.RESULT, LATEST, MY, ORIGINAL to reference these.)
	 * @param ignoreNames true indicates that function name differences should not be detected.
	 * @param monitor the merge status monitor
	 * @throws CancelledException if merge has been cancelled.
	 */
	void determineFunctionConflicts(Function[] functions, boolean ignoreNames, TaskMonitor monitor)
			throws CancelledException {
		monitor.checkCanceled();
		boolean isExternalFunction = (functions[LATEST] != null) ? functions[LATEST].isExternal()
				: ((functions[MY] != null) ? functions[MY].isExternal()
						: functions[ORIGINAL].isExternal());

		int functionConflictFlags = 0;

		int latestMyChanges = getFunctionDiffs(functions[LATEST], functions[MY]);
		if (latestMyChanges != 0) {

			int originalLatestChanges = getFunctionDiffs(functions[ORIGINAL], functions[LATEST]);
			int originalMyChanges = getFunctionDiffs(functions[ORIGINAL], functions[MY]);

//					functionConflictFlags |=
//						determineFunctionConflict(functions, FUNC_RETURN_TYPE, latestMyChanges,
//							originalLatestChanges, originalMyChanges, monitor);
			functionConflictFlags |=
				determineFunctionConflict(functions, FUNC_RETURN_ADDRESS_OFFSET, latestMyChanges,
					originalLatestChanges, originalMyChanges, monitor);

			// For now, we are not allowing you to set the parameter offset or local size outright.
			//		functionConflictFlags |=
			//			determineFunctionConflict(entry, FUNC_PARAMETER_OFFSET, latestMyChanges,
			//				originalLatestChanges, originalMyChanges, monitor);
			//		functionConflictFlags |=
			//			determineFunctionConflict(entry, FUNC_LOCAL_SIZE, latestMyChanges,
			//				originalLatestChanges, originalMyChanges, monitor);
			functionConflictFlags |= determineFunctionConflict(functions, FUNC_STACK_PURGE_SIZE,
				latestMyChanges, originalLatestChanges, originalMyChanges, monitor);
			if (!ignoreNames) {
				functionConflictFlags |= determineFunctionConflict(functions, FUNC_NAME,
					latestMyChanges, originalLatestChanges, originalMyChanges, monitor);
			}
			functionConflictFlags |= determineFunctionConflict(functions, FUNC_INLINE,
				latestMyChanges, originalLatestChanges, originalMyChanges, monitor);
			functionConflictFlags |= determineFunctionConflict(functions, FUNC_NO_RETURN,
				latestMyChanges, originalLatestChanges, originalMyChanges, monitor);

			// If FUNC_CALLING_CONVENTION conflict we must delay checking any storage related conflicts
			functionConflictFlags |= determineFunctionConflict(functions, FUNC_CALLING_CONVENTION,
				latestMyChanges, originalLatestChanges, originalMyChanges, monitor);
			functionConflictFlags |= determineFunctionConflict(functions, FUNC_SIGNATURE_SOURCE,
				latestMyChanges, originalLatestChanges, originalMyChanges, monitor);
		}

		// If the calling-convention is in conflict we must defer any specific storage and variable checking
		if ((functionConflictFlags & (FUNC_CALLING_CONVENTION)) == 0) {

			FunctionVariableStorageConflicts variableStorageConflicts = null;
			boolean skipParamChecks = false;
			if (!isExternalFunction) {
				variableStorageConflicts = determineStorageConflict(functions, monitor);
				skipParamChecks = variableStorageConflicts != null &&
					variableStorageConflicts.hasParameterConflict();
			}

			if (!skipParamChecks && determineSignatureConflicts(functions, monitor)) {
				determineParameterInfoConflicts(functions, true, monitor);
			}

			determineReturnConflict(functions, true, monitor);

			if (!isExternalFunction) {
				determineLocalVariableInfoConflicts(functions, true, variableStorageConflicts,
					monitor);
			}
		}

		if (functionConflictFlags != 0) {
			saveFunctionDetailConflict(functions, functionConflictFlags);
		}
	}
 
Example 20
Source File: SymbolMerger.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
public void autoMerge(int progressMinimum, int progressMaximum, TaskMonitor monitor)
		throws ProgramConflictException, MemoryAccessException, CancelledException {

	initializeAutoMerge("Auto-merging Symbols and determining conflicts.", progressMinimum,
		progressMaximum, monitor);

	// The ExternalFunctionMerger has external symbols that have been mapped so add them
	// to what the SymbolMerger already may have from calls to its resolve methods.
	if (mergeManager != null) {
		// Get the symbols that have already been resolved by the ExternalFunctionMerger.
		loadSymbolMapInfo(MergeConstants.RESOLVED_LATEST_SYMBOLS, latestHash);
		loadSymbolMapInfo(MergeConstants.RESOLVED_MY_SYMBOLS, myHash);
		loadSymbolMapInfo(MergeConstants.RESOLVED_ORIGINAL_SYMBOLS, originalHash);
	}

	if (currentMonitor != monitor) {
		currentMonitor = monitor;
	}
	monitor.checkCanceled();

	setupSymbolChanges(monitor); // Creates ID arrays used by processing methods.

	totalChanges =
		myRemoveIDs.length + myModifiedIDs.length + myAddIDs.length + myAnchorChangeIDs.length +
			mySetPrimary.getNumAddresses() + removeEntryPts.getNumAddresses() +
			addEntryPts.getNumAddresses() + deferredRemoveIDs.size();

	getEntryPtChanges(monitor);
	processRemoves(monitor);
	processModifies(monitor);
	processAdds(monitor);
	processAnchorChanges(monitor);
	processPrimaryChanges(monitor);
	updateEntryPtChanges(monitor);
	processDeferredRemoves(monitor);

	updateProgress(100, "Done auto-merging Symbols and determining conflicts.");
	cleanupIdArrays(); // Removes ID arrays used by processing methods.

	monitor.setMessage("Auto-merging Symbols completed.");
	monitor.setProgress(0);
}