Ghidra is a software reverse engineering (SRE) framework
Merge remote-tracking branch 'origin/GP-1477_d-millar_lldbJNI_fix' into Ghidra_10.1
ghidra147bed389c709
diff --cc Ghidra/Debug/Debugger-swig-lldb/InstructionsForBuildingLLDBInterface.txtindex 0000000000,a25871579a..a25871579amode 000000,100644..100644--- a/Ghidra/Debug/Debugger-swig-lldb/InstructionsForBuildingLLDBInterface.txt+++ b/Ghidra/Debug/Debugger-swig-lldb/InstructionsForBuildingLLDBInterface.txtdiff --cc Ghidra/Debug/Debugger-swig-lldb/build.gradleindex 0000000000,83b7b5882c..6d796089e0mode 000000,100644..100644--- a/Ghidra/Debug/Debugger-swig-lldb/build.gradle+++ b/Ghidra/Debug/Debugger-swig-lldb/build.gradle@@@ -1,0 -1,50 +1,51 @@@+ /* ###+ * 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/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: "buildNatives.gradle"++ apply plugin: 'eclipse'+ eclipse.project.name = 'Debug Debugger-swig-lldb'++ dependencies {+ api project(':Framework-AsyncComm')+ api project(':Framework-Debugging')+ api project(':Debugger-gadp')++ testImplementation project(path: ':Framework-AsyncComm', configuration: 'testArtifacts')+ testImplementation project(path: ':Framework-Debugging', configuration: 'testArtifacts')+ testImplementation project(path: ':Debugger-gadp', configuration: 'testArtifacts')+ }++ sourceSets {+ main {+ java {+ srcDir tasks.generateSwig.outdir_java+ }+ }+ }++ // Include buildable native source in distribution+ rootProject.assembleDistribution {+ from (this.project.projectDir.toString()) {- include "src/**"- into { getZipPath(this.project) }++ include "src/**"++ include "*.txt"++ into { getZipPath(this.project) }+ }+ }diff --cc Ghidra/Debug/Debugger-swig-lldb/buildNatives.gradleindex 0000000000,326f7efc5c..5f9a7d12c9mode 000000,100644..100644--- a/Ghidra/Debug/Debugger-swig-lldb/buildNatives.gradle+++ b/Ghidra/Debug/Debugger-swig-lldb/buildNatives.gradle@@@ -1,0 -1,124 +1,144 @@@+ /* ###+ * 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 llvmRequired = false; // tasks will be skipped if LLVM_HOME not defined in env+++ // Native build files are already applied in development mode (indicated by presence of the+ // Generic project). Only need to apply them if we are in a distribution.+ if (findProject(':Generic') == null) {++ // running from within Ghidra install+ apply from: "../../../GPL/utils.gradle"+ apply from: "../../../GPL/nativePlatforms.gradle"+ apply from: "../../../GPL/nativeBuildProperties.gradle"++ llvmRequired = true;+ }++ task generateSwig {+ ext.srcdir = file("src/llvm-project/lldb/bindings/java")+ ext.outdir_java = file("build/generated/src/main/java")+ ext.outdir_cpp = file("build/generated/src/main/cpp")+ ext.llvm_dir = System.env.LLVM_HOME;+ outputs.dir(outdir_java)+ outputs.dir(outdir_cpp)+ doLast {+ if (System.env.LLVM_HOME) {+ new File(ext.outdir_java, "/SWIG").mkdirs()+ def exe = "swig"+ exec {+ commandLine exe, "-c++", "-features", "autodoc", "-D__STDC_LIMIT_MACROS", "-D__STDC_CONSTANT_MACROS",+ "-I$llvm_dir/lldb/include", "-I$llvm_dir/lldb/bindings", "-java", "-package", "SWIG", "-c++",+ "-outdir", "$outdir_java/SWIG", "-o", "$outdir_cpp/LLDBWrapJava.cpp"+ args "$srcdir/java.swig"+ }++ } else if (llvmRequired) {++ throw new GradleException("Debugger-swig-lldb:generateSwig requires LLVM_HOME to be defined")+ } else {- println "Debugger-swig-lldb:generateSwig skipped - no LLVM_HOME defined"++ println "Debugger-swig-lldb:generateSwig skipped - LLVM_HOME not defined"+ }+ }+ }++ /**+ * Define the "native build model" for building the SWIG executables.+ */+ if (System.env.LLVM_HOME) {+ model {+ components {+ main(NativeLibrarySpec) {+ baseName "lldb-java"+ targetPlatform "win_x86_64"+ targetPlatform "linux_x86_64"+ targetPlatform "linux_arm_64"+ targetPlatform "mac_x86_64"+ targetPlatform "mac_arm_64"+ }+ }++ binaries {+ ext.llvm_dir = System.env.LLVM_HOME;+ ext.llvm_build_dir = System.env.LLVM_BUILD;+ if (System.env.JAVA_HOME) {+ // Allow Gradle's default JAVA_HOME to be overridden by an environment variable we set+ project.ext.JAVA_HOME = System.env.JAVA_HOME;+ }+ else {+ project.ext.JAVA_HOME = "${System.properties.'java.home'}"+ }+ all{ b ->+ if (b.targetPlatform.operatingSystem.linux) {+ b.cppCompiler.args "-I${JAVA_HOME}/include/linux"+ } else if (b.targetPlatform.operatingSystem.windows) {+ b.cppCompiler.args "-I${JAVA_HOME}/include/win32"+ } else {+ b.cppCompiler.args "-I${JAVA_HOME}/include/darwin"+ }+ if (b.toolChain in Gcc) {+ b.cppCompiler.args "-I$llvm_dir/lldb/include"+ b.cppCompiler.args "-I${JAVA_HOME}/include"+ b.linker.args "-L$llvm_build_dir/lib"+ b.linker.args "-llldb"+ b.cppCompiler.args "-std=c++14"+ b.cppCompiler.args "-O3"+ // b.cppCompiler.args "-g" // for DEBUG, uncomment this line+ }+ else if (b.toolChain in Clang) {+ b.cppCompiler.args "-I$llvm_dir/lldb/include"+ b.cppCompiler.args "-I${JAVA_HOME}/include"+ b.linker.args "-L$llvm_build_dir/lib"+ b.linker.args "-llldb"+ b.cppCompiler.args "-std=c++14"+ b.cppCompiler.args "-O3"+ // b.cppCompiler.args "-g" // for DEBUG, uncomment this line+ }+ else if (b.toolChain in VisualCpp) {+ b.cppCompiler.args "/I$llvm_dir/lldb/include"+ b.cppCompiler.args "-I${JAVA_HOME}/include"+ b.linker.args "/LIBPATH:$llvm_build_dir/lib"+ b.linker.args "liblldb.lib"+ // b.cppCompiler.args "/Zi" // for DEBUG, uncomment this line+ // b.cppCompiler.args "/FS" // for DEBUG, uncomment this line+ // b.linker.args "/DEBUG" // for DEBUG, uncomment this line+ if (b.targetPlatform.operatingSystem.windows) {+ b.cppCompiler.define "WINDOWS"+ b.cppCompiler.define "_WINDOWS"+ b.cppCompiler.define "WIN32"+ b.cppCompiler.define "_WIN32"+ if (b.targetPlatform.name == "win_x86_64") {+ b.cppCompiler.define "WIN64"+ b.cppCompiler.define "_WIN64"+ }+ }+ }+ }+ }+ }+ } else {- println "Debugger-swig-lldb:buildNatives skipped - no LLVM_HOME defined"++ println "Debugger-swig-lldb:buildNatives skipped - LLVM_HOME not defined"+ }++++task checkLLVM {++ doFirst {++ if (System.env.LLVM_HOME) {++ println "Debugger-swig-lldb: using LLVM_HOME=" + System.env.LLVM_HOME++ }++ else if (llvmRequired) {++ throw new GradleException("Debugger-swig-lldb:build requires LLVM_HOME to be defined")++ }++ }++}++++// Module build within Ghidra install requires LLVM_HOME++tasks.build.dependsOn checkLLVMdiff --cc Ghidra/Debug/Debugger-swig-lldb/certification.manifestindex 0000000000,203c4c7446..780959035emode 000000,100644..100644--- a/Ghidra/Debug/Debugger-swig-lldb/certification.manifest+++ b/Ghidra/Debug/Debugger-swig-lldb/certification.manifest@@@ -1,0 -1,10 +1,10 @@@+ ##VERSION: 2.0+ ##MODULE IP: Apache License 2.0+ ##MODULE IP: Apache License 2.0 with LLVM Exceptions+ .classpath||NONE||reviewed||END|+ .project||NONE||reviewed||END|++InstructionsForBuildingLLDBInterface.txt||GHIDRA||||END|+ Module.manifest||GHIDRA||||END|+ build.gradle||GHIDRA||||END|-data/InstructionsForBuildingLLDBInterface.txt||GHIDRA||||END|+ src/llvm-project/lldb/bindings/java/java-typemaps.swig||Apache License 2.0 with LLVM Exceptions||||END|+ src/llvm-project/lldb/bindings/java/java.swig||Apache License 2.0 with LLVM Exceptions||||END|