diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/address/StraightLineCorrelation.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/address/StraightLineCorrelation.java index bf690421be..eeb8fa9059 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/address/StraightLineCorrelation.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/address/StraightLineCorrelation.java @@ -57,6 +57,9 @@ public class StraightLineCorrelation implements AddressCorrelation { TaskMonitor monitor) throws CancelledException { initialize(monitor); AddressRange range = cachedForwardAddressMap.get(sourceAddress); + if (range == null) { + return null; + } return new AddressCorrelationRange(range, getName()); } diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/plugin/AddressCorrelatorManager.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/plugin/AddressCorrelatorManager.java index f066bd7c9c..78cb7b2a48 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/plugin/AddressCorrelatorManager.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/plugin/AddressCorrelatorManager.java @@ -21,8 +21,7 @@ import org.jdom.Element; import generic.cache.FixedSizeMRUCachingFactory; import generic.stl.Pair; -import ghidra.feature.vt.api.correlator.address.ExactMatchAddressCorrelator; -import ghidra.feature.vt.api.correlator.address.VTHashedFunctionAddressCorrelator; +import ghidra.feature.vt.api.correlator.address.*; import ghidra.features.codecompare.correlator.CodeCompareAddressCorrelator; import ghidra.framework.options.*; import ghidra.program.model.listing.Data; @@ -74,10 +73,11 @@ public class AddressCorrelatorManager { correlatorList.add(new CodeCompareAddressCorrelator()); // Note: at the time of writing this comment, the linear address correlator will not be - // executed. The VTHashedFunctionAddressCorrelator handles correlation between programs - // with the same architecture and the CodeCompareAddressCorrelator handles correlation - // between programs with different architectures. - // correlatorList.add(new LinearAddressCorrelator()); + // executed for functions. The VTHashedFunctionAddressCorrelator handles function + // correlation between programs with the same architecture and the + // CodeCompareAddressCorrelator handles function correlation between programs with different + // architectures. This will still get called for data correlation. + correlatorList.add(new LinearAddressCorrelator()); correlatorList.addAll(initializeAddressCorrelators()); diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/task/VtTask.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/task/VtTask.java index 640765f552..ed1875947e 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/task/VtTask.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/task/VtTask.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,7 +32,7 @@ public abstract class VtTask extends Task { private boolean success = false; private boolean cancelled = false; - private List errors = new ArrayList<>(); + private List errors = new ArrayList<>(); protected VtTask(String title, VTSession session) { super(title, true, true, true, true); @@ -124,31 +124,21 @@ public abstract class VtTask extends Task { if (errors.isEmpty()) { return; } + String title = getErrorDialogTitle(); String message = getErrorDetails(); - Msg.showError(this, null, title, message); + if (errors.size() == 1) { + Msg.showError(this, null, title, message, errors.get(0)); + return; + } + Msg.showError(this, null, title, message); } protected String getErrorHeader() { return "Errors encountered for task \"" + getTaskTitle() + "\":"; } - /** - * Writes any error messages from the task to the log. - */ - public void logErrors() { - if (errors.isEmpty()) { - return; - } - StringBuilder buf = new StringBuilder(getErrorHeader()); - buf.append("\n"); - for (String error : errors) { - buf.append("\t").append(error).append("\n"); - } - Msg.error(this, buf.toString()); - } - private String getErrorDialogTitle() { if (success) { return "Task \"" + getTaskTitle() + "\" Partially Completed"; @@ -164,8 +154,14 @@ public abstract class VtTask extends Task { StringBuilder buf = new StringBuilder("" + getErrorHeader()); int errorCount = 0; buf.append("

"); - for (String error : errors) { - buf.append(error).append("
"); + for (Throwable t : errors) { + + String message = t.getMessage(); + if (message == null) { + message = "Unexpected Exception: " + t.toString(); + } + + buf.append(message).append("
"); if (++errorCount > MAX_ERRORS) { buf.append("...and " + (errors.size() - errorCount) + " more!"); break; @@ -180,15 +176,7 @@ public abstract class VtTask extends Task { if (cause != null) { t = cause; } - String message = t.getMessage(); - if (message == null) { - message = "Unexpected Exception: " + e.toString(); - } - errors.add(message); - } - - protected void reportError(String message) { - errors.add(message); + errors.add(t); } protected void addErrors(VtTask task) { diff --git a/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/api/markupitem/FunctionSignatureMarkupOptionsTest.java b/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/api/markupitem/FunctionSignatureMarkupOptionsTest.java index 0e21395729..c1aac22d7d 100644 --- a/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/api/markupitem/FunctionSignatureMarkupOptionsTest.java +++ b/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/api/markupitem/FunctionSignatureMarkupOptionsTest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -73,8 +73,8 @@ public class FunctionSignatureMarkupOptionsTest extends AbstractFunctionSignatur super(); } -@Test - public void testExcludeCallingConvention() throws Exception { + @Test + public void testExcludeCallingConvention() throws Exception { useMatch("0x00411860", "0x00411830"); setCallingConvention(sourceFunction, "__cdecl"); // unknown, default, __stdcall, __cdecl, __fastcall, __thiscall @@ -118,8 +118,8 @@ public class FunctionSignatureMarkupOptionsTest extends AbstractFunctionSignatur checkMarkupStatus(functionSignatureMarkupItems, VTMarkupItemStatus.UNAPPLIED); } -@Test - public void testNameMatchReplaceCallingConventionBothSpecified() throws Exception { + @Test + public void testNameMatchReplaceCallingConventionBothSpecified() throws Exception { setLanguage(destinationProgram, "Toy:LE:32:default", "default"); useMatch("0x00411860", "0x00411830"); @@ -165,8 +165,8 @@ public class FunctionSignatureMarkupOptionsTest extends AbstractFunctionSignatur checkMarkupStatus(functionSignatureMarkupItems, VTMarkupItemStatus.UNAPPLIED); } -@Test - public void testNameMatchNotFoundCallingConventionBothSpecified() throws Exception { + @Test + public void testNameMatchNotFoundCallingConventionBothSpecified() throws Exception { setLanguage(destinationProgram, "Toy:LE:32:default", "default"); useMatch("0x00411860", "0x00411830"); @@ -212,8 +212,8 @@ public class FunctionSignatureMarkupOptionsTest extends AbstractFunctionSignatur checkMarkupStatus(functionSignatureMarkupItems, VTMarkupItemStatus.UNAPPLIED); } -@Test - public void testReplaceSrcCallFixupNoDestCallFixup() { + @Test + public void testReplaceSrcCallFixupNoDestCallFixup() { useMatch("0x00411860", "0x00411830"); setCallFixup(sourceFunction, "SEH_prolog4"); @@ -256,8 +256,8 @@ public class FunctionSignatureMarkupOptionsTest extends AbstractFunctionSignatur checkMarkupStatus(functionSignatureMarkupItems, VTMarkupItemStatus.UNAPPLIED); } -@Test - public void testReplaceNoSrcCallFixupDestCallFixup() { + @Test + public void testReplaceNoSrcCallFixupDestCallFixup() { useMatch("0x00411860", "0x00411830"); setCallFixup(destinationFunction, "SEH_prolog4"); @@ -300,8 +300,8 @@ public class FunctionSignatureMarkupOptionsTest extends AbstractFunctionSignatur checkMarkupStatus(functionSignatureMarkupItems, VTMarkupItemStatus.UNAPPLIED); } -@Test - public void testReplaceSrcCallFixupSameDestCallFixup() { + @Test + public void testReplaceSrcCallFixupSameDestCallFixup() { useMatch("0x00411860", "0x00411830"); setCallFixup(sourceFunction, "SEH_prolog4"); @@ -345,8 +345,8 @@ public class FunctionSignatureMarkupOptionsTest extends AbstractFunctionSignatur checkMarkupStatus(functionSignatureMarkupItems, VTMarkupItemStatus.UNAPPLIED); } -@Test - public void testReplaceSrcCallFixupDifferentDestCallFixup() { + @Test + public void testReplaceSrcCallFixupDifferentDestCallFixup() { useMatch("0x00411860", "0x00411830"); setCallFixup(sourceFunction, "SEH_prolog4"); @@ -390,8 +390,8 @@ public class FunctionSignatureMarkupOptionsTest extends AbstractFunctionSignatur checkMarkupStatus(functionSignatureMarkupItems, VTMarkupItemStatus.UNAPPLIED); } -@Test - public void testExcludeSrcCallFixupDifferentDestCallFixup() { + @Test + public void testExcludeSrcCallFixupDifferentDestCallFixup() { useMatch("0x00411860", "0x00411830"); setCallFixup(sourceFunction, "SEH_prolog4"); @@ -435,8 +435,8 @@ public class FunctionSignatureMarkupOptionsTest extends AbstractFunctionSignatur checkMarkupStatus(functionSignatureMarkupItems, VTMarkupItemStatus.UNAPPLIED); } -@Test - public void testReplaceNoSrcCallFixupNoDestCallFixup() { + @Test + public void testReplaceNoSrcCallFixupNoDestCallFixup() { useMatch("0x00411860", "0x00411830"); checkSignatures("void addPerson(Person * * list, char * name)", @@ -477,8 +477,8 @@ public class FunctionSignatureMarkupOptionsTest extends AbstractFunctionSignatur checkMarkupStatus(functionSignatureMarkupItems, VTMarkupItemStatus.UNAPPLIED); } -@Test - public void testExcludeReturnType() throws Exception { + @Test + public void testExcludeReturnType() throws Exception { useMatch("0x00411860", "0x00411830"); setReturnType(sourceFunction, new FloatDataType(), SourceType.USER_DEFINED); @@ -518,8 +518,8 @@ public class FunctionSignatureMarkupOptionsTest extends AbstractFunctionSignatur checkMarkupStatus(functionSignatureMarkupItems, VTMarkupItemStatus.UNAPPLIED); } -@Test - public void testReplaceDefinedReturnTypeWithDefined() throws Exception { + @Test + public void testReplaceDefinedReturnTypeWithDefined() throws Exception { useMatch("0x00411860", "0x00411830"); setReturnType(sourceFunction, new FloatDataType(), SourceType.USER_DEFINED); @@ -560,8 +560,8 @@ public class FunctionSignatureMarkupOptionsTest extends AbstractFunctionSignatur checkMarkupStatus(functionSignatureMarkupItems, VTMarkupItemStatus.UNAPPLIED); } -@Test - public void testReplaceUndefinedReturnTypeWithDefinedForReplace() throws Exception { + @Test + public void testReplaceUndefinedReturnTypeWithDefinedForReplace() throws Exception { useMatch("0x00411860", "0x00411830"); setReturnType(sourceFunction, new FloatDataType(), SourceType.USER_DEFINED); @@ -601,8 +601,8 @@ public class FunctionSignatureMarkupOptionsTest extends AbstractFunctionSignatur checkMarkupStatus(functionSignatureMarkupItems, VTMarkupItemStatus.UNAPPLIED); } -@Test - public void testDontReplaceDefinedReturnTypeWithDefinedForUndefinedOnly() throws Exception { + @Test + public void testDontReplaceDefinedReturnTypeWithDefinedForUndefinedOnly() throws Exception { useMatch("0x00411860", "0x00411830"); setReturnType(sourceFunction, new FloatDataType(), SourceType.USER_DEFINED); @@ -644,8 +644,8 @@ public class FunctionSignatureMarkupOptionsTest extends AbstractFunctionSignatur checkMarkupStatus(functionSignatureMarkupItems, VTMarkupItemStatus.UNAPPLIED); } -@Test - public void testReplaceUndefinedReturnTypeWithDefinedForUndefinedOnly() throws Exception { + @Test + public void testReplaceUndefinedReturnTypeWithDefinedForUndefinedOnly() throws Exception { useMatch("0x00411860", "0x00411830"); setReturnType(sourceFunction, new FloatDataType(), SourceType.USER_DEFINED); @@ -687,8 +687,8 @@ public class FunctionSignatureMarkupOptionsTest extends AbstractFunctionSignatur checkMarkupStatus(functionSignatureMarkupItems, VTMarkupItemStatus.UNAPPLIED); } -@Test - public void testReplaceDefaultReturnTypeWithUndefined() throws Exception { + @Test + public void testReplaceDefaultReturnTypeWithUndefined() throws Exception { useMatch("0x00411860", "0x00411830"); setReturnType(sourceFunction, new Undefined4DataType(), SourceType.USER_DEFINED); @@ -728,8 +728,8 @@ public class FunctionSignatureMarkupOptionsTest extends AbstractFunctionSignatur checkMarkupStatus(functionSignatureMarkupItems, VTMarkupItemStatus.UNAPPLIED); } -@Test - public void testDontReplaceDefinedReturnTypeWithUndefined() throws Exception { + @Test + public void testDontReplaceDefinedReturnTypeWithUndefined() throws Exception { useMatch("0x00411860", "0x00411830"); setReturnType(sourceFunction, new Undefined4DataType(), SourceType.USER_DEFINED); @@ -770,15 +770,13 @@ public class FunctionSignatureMarkupOptionsTest extends AbstractFunctionSignatur checkMarkupStatus(functionSignatureMarkupItems, VTMarkupItemStatus.UNAPPLIED); } - - // TODO // TODO // TODO this address needs to be updated: I think it is 00411da0/00411d80 // TODO // TODO -private void setLanguage(Program program, String languageID, String compilerSpecName) + private void setLanguage(Program program, String languageID, String compilerSpecName) throws IllegalStateException, LockException, IncompatibleLanguageException, LanguageNotFoundException { int transaction = -1; diff --git a/Ghidra/Framework/Generic/src/main/resources/generic.log4jdev.xml b/Ghidra/Framework/Generic/src/main/resources/generic.log4jdev.xml index 469b78c63a..1c2799cb13 100644 --- a/Ghidra/Framework/Generic/src/main/resources/generic.log4jdev.xml +++ b/Ghidra/Framework/Generic/src/main/resources/generic.log4jdev.xml @@ -73,7 +73,8 @@ - + + diff --git a/Ghidra/Framework/Generic/src/main/resources/generic.log4jtest.xml b/Ghidra/Framework/Generic/src/main/resources/generic.log4jtest.xml index d0332a6f37..7ee2c56c5c 100644 --- a/Ghidra/Framework/Generic/src/main/resources/generic.log4jtest.xml +++ b/Ghidra/Framework/Generic/src/main/resources/generic.log4jtest.xml @@ -72,6 +72,7 @@ +