Skip to content

Commit

Permalink
GP-1005: Added new agent for lldb on macOS and Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
d-millar authored and ryanmkurtz committed Sep 30, 2021
1 parent a79d257 commit 51cd51d
Show file tree
Hide file tree
Showing 469 changed files with 87,645 additions and 8 deletions.
Empty file.
114 changes: 114 additions & 0 deletions Ghidra/Debug/Debugger-agent-lldb/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/* ###
* 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 plugin: 'eclipse'
eclipse.project.name = 'Debug Debugger-agent-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')
}

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
}

jar {
manifest {
attributes['Main-Class'] = 'agent.lldb.gadp.LldbGadpServer'
}
}

task configureNodepJar {
doLast {
configurations.default.files.forEach {
if (filterJar(it)) {
nodepJar.from(zipTree(it))
}
}
}
}

task nodepJar(type: Jar) {
inputs.file(file(jar.archivePath))
dependsOn(configureNodepJar)
dependsOn(jar)

appendix = 'nodep'
manifest {
attributes['Main-Class'] = 'agent.lldb.gadp.LldbGadpServer'
}

from(zipTree(jar.archivePath))
}

// Include llvm patch and SWIG files
rootProject.assembleDistribution {
from (this.project.projectDir.toString()) {
include "src/llvm/**"
into {getZipPath(this.project) + "/data/"}
}
}

task executableJar {
ext.execsh = file("src/main/sh/execjar.sh")
ext.jarfile = file(nodepJar.archivePath)
ext.outjar = file("${buildDir}/bin/gadp-agent-lldb")
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)
}
}
}

test {
if ("linux_x86_64".equals(getCurrentPlatformName())) {
dependsOn(":Framework-Debugging:testSpecimenLinux_x86_64")
}
if ("mac_x86_64".equals(getCurrentPlatformName())) {
dependsOn(":Framework-Debugging:testSpecimenMac_x86_64")
}
}
21 changes: 21 additions & 0 deletions Ghidra/Debug/Debugger-agent-lldb/certification.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
##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|
Module.manifest||GHIDRA||||END|
build.gradle||GHIDRA||||END|
src/llvm/lldb/CMakeLists.txt||Apache License 2.0 with LLVM Exceptions||||END|
src/llvm/lldb/bindings/CMakeLists.txt||Apache License 2.0 with LLVM Exceptions||||END|
src/llvm/lldb/bindings/java/CMakeLists.txt||Apache License 2.0 with LLVM Exceptions||||END|
src/llvm/lldb/bindings/java/java-typemaps.swig||Apache License 2.0 with LLVM Exceptions||||END|
src/llvm/lldb/bindings/java/java.swig||Apache License 2.0 with LLVM Exceptions||||END|
src/llvm/lldb/cmake/modules/FindJavaAndSwig.cmake||Apache License 2.0 with LLVM Exceptions||||END|
src/llvm/lldb/cmake/modules/LLDBConfig.cmake||Apache License 2.0 with LLVM Exceptions||||END|
src/llvm/lldb/include/lldb/Host/Config.h.cmake||Apache License 2.0 with LLVM Exceptions||||END|
src/llvm/lldb/source/API/CMakeLists.txt||Apache License 2.0 with LLVM Exceptions||||END|
src/llvm/lldb/source/API/liblldb-private.exports||Apache License 2.0 with LLVM Exceptions||||END|
src/llvm/lldb/source/API/liblldb.exports||Apache License 2.0 with LLVM Exceptions||||END|
src/llvm/lldb/source/Plugins/ScriptInterpreter/CMakeLists.txt||Apache License 2.0 with LLVM Exceptions||||END|
src/llvm/lldb/source/Plugins/ScriptInterpreter/Java/CMakeLists.txt||Apache License 2.0 with LLVM Exceptions||||END|
src/llvm/lldb/tools/debugserver/source/CMakeLists.txt||Apache License 2.0 with LLVM Exceptions||||END|
109 changes: 109 additions & 0 deletions Ghidra/Debug/Debugger-agent-lldb/src/llvm/lldb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/* ###
* IP: Apache License 2.0 with LLVM Exceptions
*/
cmake_minimum_required(VERSION 3.13.4)

# Add path for custom modules.
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
)

# If we are not building as part of LLVM, build LLDB as a standalone project,
# using LLVM as an external library.
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
project(lldb)
include(LLDBStandalone)

set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)
endif()

include(LLDBConfig)
include(AddLLDB)

# Define the LLDB_CONFIGURATION_xxx matching the build type.
if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
add_definitions(-DLLDB_CONFIGURATION_DEBUG)
endif()

if (WIN32)
add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE)
endif()

if (LLDB_ENABLE_PYTHON)
if (NOT CMAKE_CROSSCOMPILING)
execute_process(
COMMAND ${Python3_EXECUTABLE}
-c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(True, False, ''))"
OUTPUT_VARIABLE LLDB_PYTHON_DEFAULT_RELATIVE_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE)

file(TO_CMAKE_PATH ${LLDB_PYTHON_DEFAULT_RELATIVE_PATH} LLDB_PYTHON_DEFAULT_RELATIVE_PATH)
else ()
if ("${LLDB_PYTHON_RELATIVE_PATH}" STREQUAL "")
message(FATAL_ERROR
"Crosscompiling LLDB with Python requires manually setting
LLDB_PYTHON_RELATIVE_PATH.")
endif ()
endif ()

set(LLDB_PYTHON_RELATIVE_PATH ${LLDB_PYTHON_DEFAULT_RELATIVE_PATH}
CACHE STRING "Path where Python modules are installed, relative to install prefix")
endif ()

if (LLDB_ENABLE_PYTHON OR LLDB_ENABLE_LUA OR LLDB_ENABLE_JAVA)
add_subdirectory(bindings)
endif ()

# We need the headers generated by instrinsics_gen before we can compile
# any source file in LLDB as the imported Clang modules might include
# some of these generated headers. This approach is copied from Clang's main
# CMakeLists.txt, so it should kept in sync the code in Clang which was added
# in llvm-svn 308844.
if(LLVM_ENABLE_MODULES)
list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
endif()

if(CMAKE_CROSSCOMPILING AND LLDB_BUILT_STANDALONE)
set(LLVM_USE_HOST_TOOLS ON)
include(CrossCompile)
if (NOT NATIVE_LLVM_DIR OR NOT NATIVE_Clang_DIR)
message(FATAL_ERROR
"Crosscompiling standalone requires the variables NATIVE_{CLANG,LLVM}_DIR
for building the native lldb-tblgen used during the build process.")
endif()
llvm_create_cross_target(lldb NATIVE "" Release
-DLLVM_DIR=${NATIVE_LLVM_DIR}
-DClang_DIR=${NATIVE_Clang_DIR})
endif()

# TableGen
add_subdirectory(utils/TableGen)

add_subdirectory(source)
add_subdirectory(tools)
add_subdirectory(docs)

if (LLDB_ENABLE_PYTHON)
if(LLDB_BUILD_FRAMEWORK)
set(lldb_python_target_dir "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python/lldb")
else()
set(lldb_python_target_dir "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
endif()
get_target_property(lldb_python_bindings_dir swig_wrapper_python BINARY_DIR)
finish_swig_python("lldb-python" "${lldb_python_bindings_dir}" "${lldb_python_target_dir}")
endif()

option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests." ${LLVM_INCLUDE_TESTS})
if(LLDB_INCLUDE_TESTS)
add_subdirectory(test)
add_subdirectory(unittests)
add_subdirectory(utils)
endif()

if(LLDB_BUILT_STANDALONE AND NOT LLVM_ENABLE_IDE)
llvm_distribution_add_targets()
endif()
Loading

0 comments on commit 51cd51d

Please sign in to comment.