From 258878ce4bd2ce73ea1eb5f499ca908b868094c8 Mon Sep 17 00:00:00 2001 From: Dan <46821332+nsadeveloper789@users.noreply.github.com> Date: Thu, 30 Jan 2025 13:31:36 +0000 Subject: [PATCH 1/2] GP-5241: Remove `apply from`s from debug agent projects. Delete unneeded gradle scripts. --- .../Debug/Debugger-agent-dbgeng/build.gradle | 5 -- Ghidra/Debug/Debugger-agent-gdb/build.gradle | 5 -- Ghidra/Debug/Debugger-agent-lldb/build.gradle | 5 -- gradle/debugger/hasExecutableJar.gradle | 41 ------------- gradle/debugger/hasNodepJar.gradle | 61 ------------------- 5 files changed, 117 deletions(-) delete mode 100644 gradle/debugger/hasExecutableJar.gradle delete mode 100644 gradle/debugger/hasNodepJar.gradle diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/build.gradle b/Ghidra/Debug/Debugger-agent-dbgeng/build.gradle index dc540b1026..ffb7aff757 100644 --- a/Ghidra/Debug/Debugger-agent-dbgeng/build.gradle +++ b/Ghidra/Debug/Debugger-agent-dbgeng/build.gradle @@ -13,13 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -apply from: "$rootProject.projectDir/gradle/javaProject.gradle" -apply from: "$rootProject.projectDir/gradle/jacocoProject.gradle" -apply from: "$rootProject.projectDir/gradle/javaTestProject.gradle" -apply from: "$rootProject.projectDir/gradle/nativeProject.gradle" apply from: "$rootProject.projectDir/gradle/distributableGhidraModule.gradle" apply from: "$rootProject.projectDir/gradle/hasPythonPackage.gradle" -apply from: "$rootProject.projectDir/gradle/debugger/hasNodepJar.gradle" apply plugin: 'eclipse' eclipse.project.name = 'Debug Debugger-agent-dbgeng' diff --git a/Ghidra/Debug/Debugger-agent-gdb/build.gradle b/Ghidra/Debug/Debugger-agent-gdb/build.gradle index 79d29ae2ef..7a16fd84d4 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/build.gradle +++ b/Ghidra/Debug/Debugger-agent-gdb/build.gradle @@ -13,13 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -apply from: "$rootProject.projectDir/gradle/javaProject.gradle" -apply from: "$rootProject.projectDir/gradle/jacocoProject.gradle" -apply from: "$rootProject.projectDir/gradle/javaTestProject.gradle" -apply from: "$rootProject.projectDir/gradle/nativeProject.gradle" apply from: "$rootProject.projectDir/gradle/distributableGhidraModule.gradle" apply from: "$rootProject.projectDir/gradle/hasPythonPackage.gradle" -apply from: "$rootProject.projectDir/gradle/debugger/hasExecutableJar.gradle" apply plugin: 'eclipse' eclipse.project.name = 'Debug Debugger-agent-gdb' diff --git a/Ghidra/Debug/Debugger-agent-lldb/build.gradle b/Ghidra/Debug/Debugger-agent-lldb/build.gradle index e8884c1a7d..788c285364 100644 --- a/Ghidra/Debug/Debugger-agent-lldb/build.gradle +++ b/Ghidra/Debug/Debugger-agent-lldb/build.gradle @@ -13,13 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -apply from: "$rootProject.projectDir/gradle/javaProject.gradle" -apply from: "$rootProject.projectDir/gradle/jacocoProject.gradle" -apply from: "$rootProject.projectDir/gradle/javaTestProject.gradle" -apply from: "$rootProject.projectDir/gradle/nativeProject.gradle" apply from: "$rootProject.projectDir/gradle/distributableGhidraModule.gradle" apply from: "$rootProject.projectDir/gradle/hasPythonPackage.gradle" -apply from: "$rootProject.projectDir/gradle/debugger/hasExecutableJar.gradle" apply plugin: 'eclipse' eclipse.project.name = 'Debug Debugger-agent-lldb' diff --git a/gradle/debugger/hasExecutableJar.gradle b/gradle/debugger/hasExecutableJar.gradle deleted file mode 100644 index 6252610960..0000000000 --- a/gradle/debugger/hasExecutableJar.gradle +++ /dev/null @@ -1,41 +0,0 @@ -/* ### - * IP: GHIDRA - * - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -apply from: "$rootProject.projectDir/gradle/debugger/hasNodepJar.gradle" - - -task executableJar { - ext.execsh = file("src/main/sh/execjar.sh") - ext.jarfile = nodepJar.archiveFile - ext.outjar = file("${buildDir}/bin/run") - dependsOn(nodepJar) - inputs.file { execsh } - inputs.file { jarfile } - outputs.file { outjar } - doLast { - outjar.parentFile.mkdirs() - outjar.withOutputStream { output -> - execsh.withInputStream { input -> - output << input - } - jarfile.withInputStream { input -> - output << input - } - } - exec { - commandLine("chmod", "+x", outjar) - } - } -} diff --git a/gradle/debugger/hasNodepJar.gradle b/gradle/debugger/hasNodepJar.gradle deleted file mode 100644 index 4824f2f189..0000000000 --- a/gradle/debugger/hasNodepJar.gradle +++ /dev/null @@ -1,61 +0,0 @@ -/* ### - * IP: GHIDRA - * - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -def boolean filterJar(File jarfile) { - if (jarfile.name.contains("gradle-api")) { - return false - } else if (jarfile.name.contains("groovy-all")) { - return false - } else if (jarfile.name.contains("gradle-installation-beacon")) { - return false - } - return true -} - -task configureNodepJar { - dependsOn(configurations.runtimeClasspath) - doLast { - configurations.runtimeClasspath.files.forEach { jar -> - if (filterJar(jar)) { - nodepJar.from(zipTree(jar)) { - // The real solution here is probably to sort out the dependency graph - // Still, I imagine some of the excludes will be necessary - exclude "help/**" - exclude "images/**" - exclude "OSGI-OPT/**" - exclude "org/osgi/**" - exclude "aQute/**" - // Duplicate. And signature breaks nodep jar - exclude "META-INF/*.SF" - exclude "META-INF/*.DSA" - exclude "META-INF/*.RSA" - // Ensure all LICENSES are included, by renaming to avoid collisions - rename("((LICENSE)|(AL2\\.0)|(LGPL2\\.1)|(NOTICE)|(NOTICE.txt)|(DEPENDENCIES))", "${jar.name}-\$1") - } - } - } - } -} - -task nodepJar(type: Jar) { - inputs.file(jar.archiveFile) - dependsOn(configureNodepJar) - dependsOn(jar) - - archiveAppendix = 'nodep' - - from(zipTree(jar.archiveFile)) - duplicatesStrategy = 'exclude' -} From def22c5e199d7e35215e39d13bf74facdfd2df8f Mon Sep 17 00:00:00 2001 From: ghidragon <106987263+ghidragon@users.noreply.github.com> Date: Thu, 30 Jan 2025 17:13:06 -0500 Subject: [PATCH 2/2] GP-5329 fixed bug in LocalBsimQueryScript --- .../BSim/ghidra_scripts/LocalBSimQueryScript.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Ghidra/Features/BSim/ghidra_scripts/LocalBSimQueryScript.java b/Ghidra/Features/BSim/ghidra_scripts/LocalBSimQueryScript.java index 87bd14ed72..7b0e9d60bf 100644 --- a/Ghidra/Features/BSim/ghidra_scripts/LocalBSimQueryScript.java +++ b/Ghidra/Features/BSim/ghidra_scripts/LocalBSimQueryScript.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. @@ -57,6 +57,10 @@ public class LocalBSimQueryScript extends GhidraScript { popup("This script cannot be run headlessly."); return; } + if (currentProgram == null) { + popup("This script requires a program to be open in the tool"); + return; + } Set sourceFuncs = new HashSet<>(); if (currentSelection == null) { @@ -341,7 +345,6 @@ public class LocalBSimQueryScript extends GhidraScript { class CompareMatchesExecutor implements TableChooserExecutor { private FunctionComparisonService compareService; - private MatchedFunctionComparisonModel model; public CompareMatchesExecutor() { compareService = state.getTool().getService(FunctionComparisonService.class); @@ -355,11 +358,7 @@ public class LocalBSimQueryScript extends GhidraScript { @Override public boolean execute(AddressableRowObject rowObject) { LocalBSimMatch match = (LocalBSimMatch) rowObject; - if (model == null) { - model = new MatchedFunctionComparisonModel(); - compareService.createCustomComparison(model, null); - } - model.addMatch(match.getSourceFunc(), match.getTargetFunc()); + compareService.createComparison(match.getSourceFunc(), match.getTargetFunc()); return false; } }