499 Commits

Author SHA1 Message Date
Chelsea Cassanova
76a841a5e6
Revert "Reland "[lldb][RPC] Upstream lldb-rpc-gen tool" (#146969)" (#147779)
Reverts llvm/llvm-project#147417. Failing an assert:
`lldb-rpc-gen:
../llvm-project/lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerSourceEmitter.cpp:361:
void lldb_rpc_gen::RPCServerSourceEmitter::EmitMethodCallAndEncode(const
Method &): Assertion `Pos != MethodsWithPointerReturnTypes.end() &&
"Unable to determine the size of the return buffer"' failed.`
2025-07-09 09:39:30 -07:00
Chelsea Cassanova
afc82ce3aa
Reland "[lldb][RPC] Upstream lldb-rpc-gen tool" (#146969) (#147417)
Relands the commit to upstream the lldb-rpc-gen tool in order to fix a
build failure on the linux remote bots. The reland adds the Clang
resource dir unconditionally to the invocation for the tool instead of
only adding it in the event that we're using a standalone build.

Original PR description:

This commit upstreams the lldb-rpc-gen tool, a ClangTool that generates
the LLDB RPC client and server interfaces. This tool, as well as LLDB
RPC itself is built by default. If it needs to be disabled, put
-DLLDB_BUILD_LLDBRPC=OFF in your CMake invocation.

https://discourse.llvm.org/t/rfc-upstreaming-lldb-rpc/85804

Original PR Link:

https://github.com/llvm/llvm-project/pull/138031
2025-07-09 09:19:42 -07:00
Chelsea Cassanova
7e04bfbf18
Revert "[lldb][RPC] Upstream lldb-rpc-gen tool" (#146969)
Reverts llvm/llvm-project#138031. This is failing during the build phase
on the Ubuntu buildbot:
```
Error while processing /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/include/lldb/API/SBWatchpoint.h.
[78/78] Processing file /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/include/lldb/API/SBWatchpointOptions.h.
warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-class-memaccess'; did you mean '-Wno-class-varargs'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-stringop-truncation'; did you mean '-Wno-format-truncation'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-class-memaccess'; did you mean '-Wno-class-varargs'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-stringop-truncation'; did you mean '-Wno-format-truncation'? [-Wunknown-warning-option]
In file included from /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/include/lldb/API/SBWatchpointOptions.h:12:
In file included from /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/include/lldb/API/SBDefines.h:12:
In file included from /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/include/lldb/lldb-defines.h:12:
In file included from /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/include/lldb/lldb-types.h:12:
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/include/lldb/lldb-enumerations.h:12:10: fatal error: 'cstdint' file not found
   12 | #include <cstdint>
      |          ^~~~~~~~~
```
2025-07-03 15:53:40 -07:00
Chelsea Cassanova
9bfb347ea0
[lldb][RPC] Upstream lldb-rpc-gen tool (#138031)
This commit upstreams the `lldb-rpc-gen` tool, a ClangTool that
generates the LLDB RPC client and server interfaces. This tool, as well
as LLDB RPC itself is built by default. If it needs to be disabled, put
-DLLDB_BUILD_LLDBRPC=OFF in your CMake invocation.

https://discourse.llvm.org/t/rfc-upstreaming-lldb-rpc/85804
2025-07-03 15:31:17 -07:00
Chelsea Cassanova
45083dc4d2
[lldb][framework] Correctly place framework files in framework with script (#146425)
There's 2 bugs that this commit fixes:
1. Calculate the correct file path for the output file by appending the
basename of the input header instead of appending the entire input
header's path to the framework path.
2. In the script, create the framework's header directory if it does not
exist.
2025-07-03 15:09:15 -07:00
Pavel Labath
46e1e9f104
Reapply "[lldb/cmake] Plugin layering enforcement mechanism (#144543)" (#145305)
The only difference from the original PR are the added BRIEF and
FULL_DOCS arguments to define_property, which are required for
cmake<3.23.
2025-06-24 11:10:35 +02:00
Pavel Labath
18f667d804 Revert "[lldb/cmake] Plugin layering enforcement mechanism (#144543)"
Causes failures on several bots.

This reverts commits 714b2fdf3a385e5b9a95c435f56b1696ec3ec9e8 and
e7c1da7c8ef31c258619c1668062985e7ae83b70.
2025-06-23 12:07:10 +02:00
Pavel Labath
714b2fdf3a [lldb] Add BRIEF_DOCS for cmake properties defined in #144543
It seems some cmake versions require it.
2025-06-23 11:39:20 +02:00
Pavel Labath
e7c1da7c8e
[lldb/cmake] Plugin layering enforcement mechanism (#144543)
Some inter-plugin dependencies are okay, others are not. Yet others not,
but we're sort of stuck with them. The idea is to be able to prevent
backsliding while making sure that acceptable dependencies are..
accepted. For context, see
https://github.com/llvm/llvm-project/pull/139170 and the attached
changes to the documentation.
2025-06-23 11:31:26 +02:00
Jonas Devlieghere
9524bfb270
[lldb] Add Model Context Protocol (MCP) support to LLDB (#143628)
This PR adds an MCP (Model Context Protocol ) server to LLDB. For
motivation and background, please refer to the corresponding RFC:
https://discourse.llvm.org/t/rfc-adding-mcp-support-to-lldb/86798

I implemented this as a new kind of plugin. The idea is that we could
support multiple protocol servers (e.g. if we want to support DAP from
within LLDB). This also introduces a corresponding top-level command
(`protocol-server`) with two subcommands to `start` and `stop` the
server.

```
(lldb) protocol-server start MCP tcp://localhost:1234
MCP server started with connection listeners: connection://[::1]:1234, connection://[127.0.0.1]:1234
```

The MCP sever supports one tool (`lldb_command`) which executes a
command, but can easily be extended with more commands.
2025-06-20 10:48:04 -05:00
Charles Zablit
556e69b7f4
[lldb] make lit use the same Python executable for building and testing (#143756)
When testing LLDB, we want to make sure to use the same Python as the
one we used to build it.

This patch uses the CMake variable `Python3_ROOT_DIR` to add the correct
Python to the `PATH` in LLDB lit tests, in order to ensure of this.

Please see https://github.com/swiftlang/swift/pull/82063 for the
original issue.

This is a continuation of https://github.com/swiftlang/swift/pull/82063.
2025-06-17 11:52:03 -05:00
Chelsea Cassanova
8a8ea8fec0
Reland "[lldb][headers] Create Python script to fix up framework head… (#143945)
…ers" (#143941)

Reland the script that converts lldb headers to RPC headers. The RPC
test was failing due to the incorrect input filepath being used.

Original commit message:
This commit replaces the shell script that fixes up includes for the
LLDB framework with a Python script. This script will also be used when
fixing up includes for the LLDBRPC.framework.
2025-06-12 13:55:44 -07:00
Chelsea Cassanova
06dad352db
Revert "[lldb][headers] Create Python script to fix up framework headers" (#143941)
Reverts llvm/llvm-project#142051
2025-06-12 10:39:53 -07:00
Chelsea Cassanova
1a4cf1d3ed
[lldb][headers] Create Python script to fix up framework headers (#142051)
This commit replaces the shell script that fixes up includes for the
LLDB framework with a Python script. This script will also be used when
fixing up includes for the LLDBRPC.framework.
2025-06-12 10:07:45 -07:00
Pavel Labath
622df892b8
[lldb/cmake] Remove EXTRA_CXXFLAGS arg (#143731)
We have one library using this and three libraries directly calling
`target_compile_options`. Might as well standardize on the latter.
2025-06-12 15:27:27 +02:00
Chelsea Cassanova
eb76d8332e
Reland "[lldb][headers] Create script to fix up versioning" (#142864)" (#142871)
This relands the original commit for the versioning script in LLDB. This
commit uses '>' for output from `unifdef` for platforms that have that
executable but do not have the `-o` option. It also fixes the Xcode
build by adding a dependency between the liblldb-header-staging target
in the source/API/CMakeLists.txt the `liblldb-resource-headers` target
in LLDBFramework.cmake.

Original patch: https://github.com/llvm/llvm-project/pull/141116
2025-06-10 09:47:11 -07:00
Pavel Labath
7e471c1fd0
[lldb/cmake] Use ADDITIONAL_HEADER(_DIR)?S (#142587)
Replace (questionable) header globs with an explicit argument supported
by llvm_add_library.
2025-06-10 11:58:39 +02:00
Pavel Labath
2c4f67794b
[lldb/cmake] Implicitly pass arguments to llvm_add_library (#142583)
If we're not touching them, we don't need to do anything special to pass
them along -- with one important caveat: due to how cmake arguments
work, the implicitly passed arguments need to be specified before
arguments that we handle.

This isn't particularly nice, but the alternative is enumerating all
arguments that can be used by llvm_add_library and the macros it calls
(it also relies on implicit passing of some arguments to
llvm_process_sources).
2025-06-04 11:33:37 +02:00
Fabrice de Gans
a080c741bc
[lldb] Add build option to specify the libxml 2 version (#142183)
The Swift Windows toolchain uses its own static build of libxml 2, which
is more recent than 2.8, resulting in the provided libxml 2 to be
rejected. This change allows to specify a custom version for libxml 2,
while defaulting to 2.8.
2025-05-30 16:21:13 -07:00
Pavel Labath
e3e5bd1cb1
[lldb/cmake] Don't call llvm_process_sources (#141217)
It's already called in llvm_add_library.
2025-05-27 14:32:16 +02:00
Pavel Labath
a4380fe5f9
[lldb/cmake] Remove special handling of OBJECT libraries (#141066)
Nothing in lldb sets this. And even if they did, llvm_add_library should
know how to handle that.
2025-05-23 10:22:59 +02:00
Pavel Labath
f1cf168a6f
[lldb/cmake] Remove a no-op statement (#141063)
Like the comment says, this really is a no-op and has no effect on the
generated build commands.
2025-05-23 09:23:53 +02:00
jeremyd2019
ba4bd3f46e
[CMake] respect LLVMConfig.cmake's LLVM_DEFINITIONS in standalone builds (#138587)
In #138329, _GNU_SOURCE was added for Cygwin, but when building Clang
standalone against an installed LLVM this definition was not picked up,
resulting in undefined strnlen. Follow the documentation in
https://llvm.org/docs/CMake.html#embedding-llvm-in-your-project and add
the LLVM_DEFINITIONS in standalone projects' cmakes.
2025-05-22 08:14:13 +03:00
Chelsea Cassanova
ff8fc5bc45
[lldb][cmake] Add clang resource dir to LLDB shell tests config (#136761)
We want to be able to access the Clang resources directory in LLDB shell
tests, this commit adds the ability to do this by populating the
`CLANG_RESOURCE_DIR` variable in LLDBConfig.cmake.
2025-04-30 10:10:05 -07:00
Dhruv Srivastava
ec95ce358c
[lldb][AIX] Added base files for NativeProcess Support for AIX (#118160)
This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:

1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640
2. https://github.com/llvm/llvm-project/issues/101657
The complete changes for porting are present in this draft PR:
https://github.com/llvm/llvm-project/pull/102601

Added base files for NativeProcess Support for AIX. 
Will be adding further support in consequent incremental PR.
2025-03-14 16:52:41 +05:30
Jordan R AW
bb6a273d9a
[lldb] Fix manual CURSES_LIBRARIES tinfo finding (#128245) 2025-02-22 11:13:46 -06:00
Jordan R AW
8fff0c181f
[lldb] Add terminfo dependency for ncurses support (#126810)
For some operating systems (e.g. chromiumos), terminfo is a separate
package and library from ncurses. Both are still requirements for curses
support in lldb, individually.
    
This is a rework of this original spack commit:

9ea2612650

Instead though, this PR uses CMake to detect whether the symbol is
present and defined in the curses library, and only falls back to a separate
tinfo if not found.
    
Without this fix, LLDB cannot be built on these systems.
    
Fixes #101368
2025-02-14 21:37:39 -08:00
Brad Smith
ff17a4136d
[lldb] Remove support and workarounds for Android 4 and older (#124047) 2025-01-23 12:54:35 -05:00
Brad Smith
1b476ecdcf
[lldb] A few more pieces towards OpenBSD support (#121051) 2024-12-26 08:04:44 -05:00
Saleem Abdulrasool
24593f1814
[lldb] build: cleanup extraneous include paths (#117615)
Clean up some unnecessary include paths. The use of `LibXml2::LibXml2`
with `target_link_libraries` on `libLLDBHost` ensures that the header
search path is properly propagated.
2024-11-27 08:39:15 -08:00
David Spickett
3ce0dbb718
[lldb] Recommend Python 3.8 as the minimum Python version for LLDB (#114807)
See
https://discourse.llvm.org/t/rfc-lets-document-and-enforce-a-minimum-python-version-for-lldb/82731
for discussions.

This matches LLVM's requirement to run tests. For LLDB 20 there will be
a CMake warning telling builders that from LLDB 21 this will be a hard
requirement. From LLDB 21, it will be an error to try to build with
anything <= 3.8.

So there are no code changes in this commit. Once the llvm 20 branch is
created we can remove some < 3.8 support code.

As always, if you disable Python support you will not get any new
warnings or errors from this change.
2024-11-12 10:49:16 +00:00
Jonas Devlieghere
e19d740169
[lldb] Support both Lua 5.3 and Lua 5.4 (#115500)
Lua 5.3 and Lua 5.4 are similar enough that we can easily support both
in LLDB. This patch adds support for building LLDB with both and updates
the documentation accordingly.
2024-11-11 08:11:03 -08:00
Jonas Devlieghere
4897fc44a9
[lldb] Narrow scope of -Wno-deprecated-declarations (NFC) (#112276)
Currently all of LLDB is being compiled with
-Wno-deprecated-declarations. That's not desirable, especially as part
of the LLVM monorepo, as we miss deprecation warnings from LLVM and
clang.

According to the git history, this was first introduced to suppress
warnings related to auto_ptr. Since then, other things have been
deprecated and gone unnoticed. This patch limits the flag to Host.mm
which uses a handful of LSApplication headers that have no replacement.

rdar://112040718
2024-10-17 08:22:56 -07:00
Jon Roelofs
a982cabea3
[cmake][llvm] Limit the number of Xcode schemes created by default (#101243)
CMake -GXcode would otherwise offer to create one scheme for each
target, which ends up being a lot. For now, limit the default to the
`check-*` LIT targets, plus `ALL_BUILD` and `install`.

For targets that aren't in the default list, we now have a configuration
variable to promote an extra list of targets into schemes, for example
`-DLLVM_XCODE_EXTRA_TARGET_SCHEMES="TargetParserTests;SupportTests"` to
add schemes for `TargetParserTests` and `SupportTests` respectively.
2024-07-30 17:17:04 -07:00
Vlad Serebrennikov
cd676e5b27 [lldb] Guard some GCC-style flags from MSVC
A follow up to #92953. Suggested in https://github.com/llvm/llvm-project/pull/92953#issuecomment-2143274065
2024-06-01 12:48:12 +03:00
Michael Kruse
c3efb57655
[lldb] Revise IDE folder structure (#89748)
Update the folder titles for targets in the monorepository that have not
seen taken care of for some time. These are the folders that targets are
organized in Visual Studio and XCode
(`set_property(TARGET <target> PROPERTY FOLDER "<title>")`)
when using the respective CMake's IDE generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically
deduce the folder. This reduces the number of
`set_property`/`set_target_property`, but are still necessary when
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's
root CMakeLists.txt.
2024-05-25 17:29:18 +02:00
Vlad Serebrennikov
4feae05c6a
Remove some try_compile CMake checks for compiler flags (#92953)
This patch remove 36 checks for compiler flags that are done via
invoking the compiler across LLVM, Clang, and LLDB. It's was made
possible by raising the bar for supported compilers that has been
happening over the years since the checks were added.

This is going to improve CMake configuration times. This topic was
highlighted in
https://discourse.llvm.org/t/cmake-compiler-flag-checks-are-really-slow-ideas-to-speed-them-up/78882.
2024-05-23 17:05:41 +04:00
Adrian Prantl
fcfc15b705
Add a dependency from lldb-sbapi-dwarf-enums as a dependency of libll… (#91511)
…db-resource-headers

The Xcode build otherwise fails with
```
CMake Error in source/API/CMakeLists.txt:
  The custom command generating

    /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-standalone/lldb-xcode-build/include/lldb/API/SBLanguages.h

  is attached to multiple targets:

    lldb-sbapi-dwarf-enums
    liblldb-resource-headers

  but none of these is a common dependency of the other(s).  This is not
  allowed by the Xcode "new build system".

CMake Generate step failed.  Build files cannot be regenerated correctly.
```
2024-05-08 10:38:09 -07:00
Adrian Prantl
b88d21127f
Install generated API headers into LLDB.framework (#90666) 2024-05-01 12:47:43 -07:00
Jordan Rupprecht
0e5c28d193
[lldb][test] Remove LLDB_TEST_USE_VENDOR_PACKAGES (#89260)
The `LLDB_TEST_USE_VENDOR_PACKAGES` has defaulted to `Off` for a while.
Either installing `pexpect` or skipping those tests with
`-DLLDB_TEST_USER_ARGS=--skip-category=pexpect` seems to be enough that
we can fully remove this option.

This patch removes the `LLDB_TEST_USE_VENDOR_PACKAGES` cmake
configuration as well as the associated code to add
`third_party/Python/module` to the python path. I'll do the actual
deletion of `third_party/Python/module` in a followup PR in the
(unlikely, I hope) event this commit needs to be reverted.
2024-04-18 13:17:39 -05:00
Jonas Devlieghere
a855eea7fe
[lldb] Fix the standalone Xcode build after #88317
In #88317, the clang resource headers was converted to an interface
library. Update LLDB and fix the Xcode standalone build. Thanks Evan for
the help!
2024-04-15 14:08:56 -07:00
Adam Fowler
2c2377d3a9
Add lldb-dap to Swift distributions (#88482)
This includes the lldb-dap executable in the MacOS and Linux
distributions of Swift. Currently there is a commit in the Apple repo to
do this for just MacOS https://github.com/apple/llvm-project/pull/8176.
This PR extends this to both Linux and MacOS and brings the change
upstream.

@JDevlieghere @adrian-prantl
2024-04-12 07:39:22 -07:00
Cyndy Ishida
e0219f2d53 [lldb] Overwrite existing LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES
on apple-linux
2024-04-09 19:35:55 -07:00
Cyndy Ishida
a3bb9c2b06
[cmake] Prevent implicitly passing -no_exported_symbols (#87846)
* It is possible to setup llvm-project builds without going through
`llvm/CMakeList.txt` so the fatal error handling should be smarter.
* Disable option on Apple style lldb-linux builds.
2024-04-07 10:22:34 -07:00
Cyndy Ishida
25cf27910c
[cmake] Build executables with -no_exported_symbols when building Apple toolchain (#87684)
Building the Apple way turns off plugin support, meaning we don't need
to export unloadable symbols from all executables. While deadstripping
effects aren't expected to change, enabling this across all tools
prevents the creation of export tries. This saves us ~3.5 MB in just the
universal build of `clang`.
2024-04-05 14:41:20 -07:00
Alastair Houghton
a75d0a3dba
[LLDB] Add lldb-python-scripts to the things installed on Linux. (#85080) 2024-03-14 08:22:29 -07:00
Jordan Rupprecht
3239b4dcfe
[lldb][test] Enforce pexpect system availability by default (#84270)
This switches the default of `LLDB_TEST_USE_VENDOR_PACKAGES` from `ON`
to `OFF` in preparation for eventually deleting it. All known LLDB
buildbots have this package installed, so flipping the default will
uncover any other users.

If this breaks anything, the preferred fix is to install `pexpect` on
the host system. The second fix is to build with cmake option
`-DLLDB_TEST_USE_VENDOR_PACKAGES=ON` as a temporary measure until
`pexpect` can be installed. If neither of those work, reverting this
patch is OK.
2024-03-07 08:53:18 -06:00
Jonas Devlieghere
a6d9b7ba27
[lldb] Don't cache lldb_find_python_module result
Don't cache lldb_find_python_module result as that requires you to do a
clean build after installing the dependency.
2024-02-29 09:12:20 -08:00
Jordan Rupprecht
249cf356ef
[lldb][test][NFC] Add option to exclude third_party packages (#83191)
The goal here is to remove the third_party/Python/module tree, which
LLDB tests only use to `import pexpect`. This package is available on
`pip`, and I believe should not be hard to obtain.

However, in case it isn't easily available, deleting the tree right now
could cause disruption. This introduces a
`LLDB_TEST_USE_VENDOR_PACKAGES` cmake param that can be enabled, and the
tests will continue loading that tree. By default, it is enabled,
meaning there's really no change here. A followup change will disable it
by default once all known build bots are updated to include this
package. When disabled, an eager cmake check runs that makes sure
`pexpect` is available before waiting for the test to fail in an obscure
way.

Later, this option will go away, and when it does, we can delete the
tree too. Ideally this is not disruptive, and we can remove it in a week
or two.
2024-02-28 15:00:41 -06:00
Alexandre Ganea
ded8aa6184 [lldb] Silence warning with latest MSVC
Fixes several of these:
```
[3370/3822] Building CXX object tools\lldb\source\Plugins\Process\U...lldbPluginProcessUtility.dir\NativeRegisterContextDBReg_x86.cpp.ob
C:\git\llvm-project\lldb\source\Plugins\Process\Utility\NativeRegisterContextDBReg_x86.h(23): warning C4589: Constructor of abstract class 'lldb_private::NativeRegisterContextDBReg_x86' ignores initializer for virtual base class 'lldb_private::NativeRegisterContextRegisterInfo'
C:\git\llvm-project\lldb\source\Plugins\Process\Utility\NativeRegisterContextDBReg_x86.h(23): note: virtual base classes are only initialized by the most-derived type
```
2024-01-18 13:06:12 -05:00