diff --git a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/model/target/info/TraceObjectInterfaceUtils.java b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/model/target/info/TraceObjectInterfaceUtils.java index 1ce3ac2a93..dc260c4079 100644 --- a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/model/target/info/TraceObjectInterfaceUtils.java +++ b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/model/target/info/TraceObjectInterfaceUtils.java @@ -53,7 +53,8 @@ public enum TraceObjectInterfaceUtils { List instances = ClassSearcher.getInstances(TraceObjectInterfaceFactory.class); if (instances.isEmpty()) { - Msg.warn(this, "ClassSearcher not active, yet. Falling back to built-ins"); + Msg.warn(this, "ClassSearcher not active, yet. " + + "Falling back to built-in TraceObjectInterfaces."); instances = List.of(new BuiltinTraceObjectInterfaceFactory()); } mapByClass = instances diff --git a/Ghidra/Framework/Emulation/src/test/java/ghidra/app/plugin/processors/sleigh/SleighLanguageHelper.java b/Ghidra/Framework/Emulation/src/test/java/ghidra/app/plugin/processors/sleigh/SleighLanguageHelper.java index 7bc039a498..89432c7316 100644 --- a/Ghidra/Framework/Emulation/src/test/java/ghidra/app/plugin/processors/sleigh/SleighLanguageHelper.java +++ b/Ghidra/Framework/Emulation/src/test/java/ghidra/app/plugin/processors/sleigh/SleighLanguageHelper.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,16 +32,24 @@ import ghidra.util.Msg; import resources.ResourceManager; public class SleighLanguageHelper { + + private static SleighLanguage MOCK_BE_64_LANGUAGE; + private static ResourceFile getResourceFile(String name) { URL url = ResourceManager.getResource(name); if (url == null) { return null; } - return new ResourceFile(url.getPath()); + ResourceFile maybeInJar = new ResourceFile(url.toExternalForm()); + ResourceFile notInJar = new ResourceFile(maybeInJar.getFile(true)); + return notInJar; } - public static SleighLanguage getMockBE64Language() + public synchronized static SleighLanguage getMockBE64Language() throws DecoderException, UnknownInstructionException, SAXException, IOException { + if (MOCK_BE_64_LANGUAGE != null) { + return MOCK_BE_64_LANGUAGE; + } ResourceFile cSpecFile = getResourceFile("mock.cpsec"); CompilerSpecDescription cSpecDesc = @@ -50,6 +58,7 @@ public class SleighLanguageHelper { ResourceFile pSpecFile = getResourceFile("mock.pspec"); ResourceFile slaSpecFile = getResourceFile("mock.slaspec"); ResourceFile slaFile = getResourceFile("mock.sla"); + if (slaFile == null || !slaFile.exists() || (slaSpecFile.lastModified() > slaFile.lastModified())) { assertNotNull("Cannot find mock.slaspec", slaSpecFile); @@ -61,8 +70,8 @@ public class SleighLanguageHelper { catch (IOException | RecognitionException e) { throw new AssertionError(e); } - slaFile = getResourceFile("mock.sla"); - assertNotNull("Cannot find mock.sla (after compilation)"); + slaFile = new ResourceFile(slaSpecFile.getParentFile(), "mock.sla"); + assertTrue("Cannot find mock.sla (after compilation)", slaFile.exists()); } SleighLanguageDescription langDesc = new SleighLanguageDescription( @@ -74,12 +83,14 @@ public class SleighLanguageHelper { 0, // minor version false, // deprecated new HashMap<>(), // truncatedSpaceMap - new ArrayList<>(List.of(cSpecDesc)), new HashMap<>() // externalNames + new ArrayList<>(List.of(cSpecDesc)), // compiler specs + new HashMap<>() // externalNames ); langDesc.setDefsFile(lDefsFile); langDesc.setSpecFile(pSpecFile); langDesc.setSlaFile(slaFile); - return new SleighLanguage(langDesc); + MOCK_BE_64_LANGUAGE = new SleighLanguage(langDesc); + return MOCK_BE_64_LANGUAGE; } } diff --git a/Ghidra/Framework/Utility/src/main/java/generic/jar/ResourceFile.java b/Ghidra/Framework/Utility/src/main/java/generic/jar/ResourceFile.java index 022b16c7a5..5ccf6fc3f2 100644 --- a/Ghidra/Framework/Utility/src/main/java/generic/jar/ResourceFile.java +++ b/Ghidra/Framework/Utility/src/main/java/generic/jar/ResourceFile.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. @@ -30,9 +30,10 @@ import utilities.util.FileUtilities; */ public class ResourceFile implements Comparable { - private static final String JAR_FILE_PREFIX = "jar:file:"; - private Resource resource; - private static Map jarRootsMap = new HashMap<>(); + private static final String FILE_PREFIX = "file:"; + private static final String JAR_FILE_PREFIX = "jar:" + FILE_PREFIX; + private final Resource resource; + private static final Map jarRootsMap = new HashMap<>(); /** * Construct a ResourceFile that represents a normal file in the file system. @@ -93,7 +94,13 @@ public class ResourceFile implements Comparable { throw new IllegalArgumentException("Failed to open jar: " + filePath, e); } } - resource = new FileResource(new File(absolutePath)); + else if (absolutePath.startsWith(FILE_PREFIX)) { + String filePath = absolutePath.substring(FILE_PREFIX.length()); + resource = new FileResource(new File(filePath)); + } + else { + resource = new FileResource(new File(absolutePath)); + } } /** diff --git a/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerTraceRegistersProviderTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerTraceRegistersProviderTest.java index 3615d288a4..1262d695a4 100644 --- a/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerTraceRegistersProviderTest.java +++ b/Ghidra/Test/DebuggerIntegrationTest/src/test/java/ghidra/app/plugin/core/debug/gui/register/DebuggerTraceRegistersProviderTest.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. @@ -563,7 +563,7 @@ public class DebuggerTraceRegistersProviderTest extends AbstractDebuggerRegister waitForDialogComponent(DebuggerAvailableRegistersDialog.class); List modelData = dialog.availableTableModel.getModelData(); - assertEquals(52, modelData.size()); + assertEquals(getPlatform().getLanguage().getRegisters().size(), modelData.size()); AvailableRegisterRow pcAvail = modelData.stream().filter(r -> r.getRegister() == pc).findFirst().orElse(null); assertNotNull(pcAvail);