Skip to content

Reland "[lldb][RPC] Upstream lldb-rpc-gen tool" (#146969)" Attempt 2 #148996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lldb/cmake/modules/LLDBConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,23 @@ else()
set(LLDB_CAN_USE_DEBUGSERVER OFF)
endif()

# In a cross-compile build, we need to skip building the generated
# lldb-rpc sources in the first phase of host build so that they can
# get built using the just-built Clang toolchain in the second phase.
if (NOT DEFINED LLDB_CAN_USE_LLDB_RPC_SERVER)
if ((CMAKE_CROSSCOMPILING OR LLVM_HOST_TRIPLE MATCHES "${LLVM_DEFAULT_TARGET_TRIPLE}") AND
CMAKE_SYSTEM_NAME MATCHES "AIX|Android|Darwin|FreeBSD|Linux|NetBSD|OpenBSD|Windows")
set(LLDB_CAN_USE_LLDB_RPC_SERVER ON)
else()
set(LLDB_CAN_USE_LLDB_RPC_SERVER OFF)
endif()
endif()

if (CMAKE_CROSSCOMPILING)
set(LLDB_BUILD_LLDBRPC OFF CACHE BOOL "")
get_host_tool_path(lldb-rpc-gen LLDB_RPC_GEN_EXE lldb_rpc_gen_exe lldb_rpc_gen_target)
else()
set(LLDB_BUILD_LLDBRPC ON CACHE BOOL "")
endif()

include(LLDBGenerateConfig)
7 changes: 6 additions & 1 deletion lldb/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ if(TARGET lldb-framework)
add_lldb_test_dependency(lldb-framework)
endif()

if (LLDB_CAN_USE_LLDB_RPC_SERVER)
add_lldb_test_dependency(lldb-rpc-generate-sources)
endif()

# Add dependencies that are not exported targets when building standalone.
if(NOT LLDB_BUILT_STANDALONE)
add_lldb_test_dependency(
Expand Down Expand Up @@ -249,7 +253,8 @@ llvm_canonicalize_cmake_booleans(
LLDB_TEST_SHELL_DISABLE_REMOTE
LLDB_TOOL_LLDB_SERVER_BUILD
LLDB_USE_SYSTEM_DEBUGSERVER
LLDB_IS_64_BITS)
LLDB_IS_64_BITS
LLDB_BUILD_LLDBRPC)

# Configure the individual test suites.
add_subdirectory(API)
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
RUN: %lldb-rpc-gen --output-dir=%t %S/../Inputs/SBDummy.h

RUN: ls %t | FileCheck %s

# We're just making sure that the tool emits the class names,
# methods and skipped methods file in the output directory.
CHECK: SBAPI.def
CHECK: SBClasses.def
CHECK: SkippedMethods.txt
3 changes: 3 additions & 0 deletions lldb/test/Shell/RPC/Generator/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# All tests for the tool need lldb-rpc-gen to be built.
if not config.lldb_has_lldbrpc:
config.unsupported = True
10 changes: 10 additions & 0 deletions lldb/test/Shell/helper/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ def use_lldb_substitutions(config):
extra_args=["platform"],
unresolved="ignore",
),
ToolSubst(
"%lldb-rpc-gen",
command=FindTool("lldb-rpc-gen"),
# We need the LLDB build directory root to pass into the tool, not the test build root.
extra_args=[
"-p " + config.lldb_build_directory + "/..",
'--extra-arg="-resource-dir=' + config.clang_resource_dir + '"',
],
unresolved="ignore",
),
"lldb-test",
"lldb-dap",
ToolSubst(
Expand Down
1 change: 1 addition & 0 deletions lldb/test/Shell/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
config.have_lldb_server = @LLDB_TOOL_LLDB_SERVER_BUILD@
config.lldb_system_debugserver = @LLDB_USE_SYSTEM_DEBUGSERVER@
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
config.lldb_has_lldbrpc = @LLDB_BUILD_LLDBRPC@
# The shell tests use their own module caches.
config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-shell")
config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-shell")
Expand Down
6 changes: 6 additions & 0 deletions lldb/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ add_subdirectory(lldb-fuzzer EXCLUDE_FROM_ALL)

add_lldb_tool_subdirectory(lldb-instr)
add_lldb_tool_subdirectory(lldb-dap)
if (LLDB_BUILD_LLDBRPC)
add_lldb_tool_subdirectory(lldb-rpc-gen)
endif()
if (LLDB_CAN_USE_LLDB_RPC_SERVER)
add_subdirectory(lldb-rpc)
endif()

if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_lldb_tool_subdirectory(darwin-debug)
Expand Down
23 changes: 23 additions & 0 deletions lldb/tools/lldb-rpc-gen/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
add_lldb_tool(lldb-rpc-gen
RPCCommon.cpp
server/RPCServerHeaderEmitter.cpp
server/RPCServerSourceEmitter.cpp
lldb-rpc-gen.cpp

CLANG_LIBS
clangAST
clangBasic
clangCodeGen
clangFrontend
clangLex
clangRewrite
clangSerialization
clangTooling

LINK_COMPONENTS
Support
)

if (NOT DEFINED LLDB_RPC_GEN_EXE)
set(LLDB_RPC_GEN_EXE $<TARGET_FILE:lldb-rpc-gen> CACHE STRING "Executable that generates lldb-rpc-server")
endif()
Loading
Loading