diff --git a/README.md b/README.md index e7990ee2a7fda8d65a99be2e30f222e90c31c245..bcd7ad3544376f0e17397cf4f5248b473da1b6d3 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,73 @@ # lldb-mi -This is the LLDB's machine interface driver from llvm-8.0.1. -A few patches and OHOS target modifications are applied. +LLDB's machine interface driver. # Build -The build of lldb-mi relies on LLDB, Clang and LLVM. On a system that's already configured with LLDB, CLANG and LLVM, -the lldb-mi can be built with the following commond: +lldb-mi uses CMake to build. The only dependencies needed for lldb-mi are a C++14 compiler and LLDB itself (including its dependencies: Clang and LLVM). These dependencies should be installed in a way that they can be found via CMake's [`find_package`](https://cmake.org/cmake/help/latest/command/find_package.html) functionality. You need both the LLDB/Clang/LLVM headers and their compiled libraries for the build to work, but not the respective source files. +# Building against system LLDB + +If your distribution or operating system already ships a correctly configured LLDB/Clang/LLVM installation, lldb-mi can be build by simply running: + + +```bash +cmake . +cmake --build . +``` + +# Building against custom LLDB + +You can also build lldb-mi against a LLDB that you compiled yourself. For that compile LLDB as described [here](https://lldb.llvm.org/resources/build.html) but set `CMAKE_INSTALL_PREFIX` to a local directory and build the LLVM shared library by passing `-DLLVM_BUILD_LLVM_DYLIB=On` to CMake. Afterwards point towards that prefix directory when building lldb-mi by settings `CMAKE_PREFIX_PATH` (e.g. `cmake -DCMAKE_PREFIX_PATH=/home/yourname/lldb-mi/install`). + +This example script should build LLVM and lldb-mi on an average UNIX system in the ~/buildspace subfolder: +``` +cd +mkdir buildspace + +# Download LLVM/Clang/LLDB and build them. +git clone https://github.com/llvm/llvm-project.git +mkdir llvm-inst +mkdir llvm-build +cd llvm-build + +cmake -DLLVM_ENABLE_PROJECTS="clang;lldb;libcxx;libcxxabi" -DCMAKE_INSTALL_PREFIX=~/buildspace/llvm-inst/ -GNinja ../llvm-project/llvm +ninja +ninja install + +# Download lldb-mi and build it against our custom installation. +cd ~/buildspace +git clone https://github.com/lldb-tools/lldb-mi +cd lldb-mi + +# Create a separate build directory for building lldb-mi. +mkdir build +cd build +cmake -DCMAKE_PREFIX_PATH=~/buildspace/llvm-inst/ -GNinja .. +ninja +``` + +# Building against custom LLDB.framework (Darwin Only) + +You can also build lldb-mi against a LLDB.framework that you compiled yourself. It is the same instructions as above but build the LLVM framework by passing `-DLLDB_BUILD_FRAMEWORK=1` to CMake instead of using the shared library. Then build LLDB-MI with `-DUSE_LLDB_FRAMEWORK=1` + +The snippits below change the cmake calls from the above script. +``` +// Building llvm-project +cmake -DLLVM_ENABLE_PROJECTS="clang;lldb;libcxx;libcxxabi" -DCMAKE_INSTALL_PREFIX=~/buildspace/llvm-inst/ -DLLDB_BUILD_FRAMEWORK=1 -GNinja ../llvm-project/llvm +``` + +``` +// Building lldb-mi +cmake -DCMAKE_PREFIX_PATH=~/buildspace/llvm-inst/ -DUSE_LLDB_FRAMEWORK=1 -GNinja .. + +``` + +# Notes + +On some architectures (e. g. Linux, x86-64), LLDB dinamic library fails to determine its location. That results to inability of locating a gdbserver stub: ```bash -cmake . ; cmake --build . +process launch failed: unable to locate lldb-server ``` + +The workaraund is to set LLDB_DEBUGSERVER_PATH environment variable before running LLDB-MI. diff --git a/README_zh.md b/README_zh.md index e21877b1a095a6b3425d636ef90ae42633d78fa6..66404e2d47188fa7c5bf24550b5c356716a8f198 100644 --- a/README_zh.md +++ b/README_zh.md @@ -1,12 +1,76 @@ # lldb-mi -这是来自 llvm-8.0.1 的 LLDB 的机器接口驱动程序。 应用了一些补丁和 OHOS 目标修改。 +这是来自 llvm-8.0.1 的 LLDB 的机器接口驱动程序。 # Build -lldb-mi的构建依赖于LLDB,Clang和LLVM。在已经配置了 LLDB、CLANG 和 LLVM 的系统上,可以使用以下通用方法构建 lldb-mi: +lldb-mi使用CMake构建。lldb-mi所需的唯一依赖项是C++14编译器和lldb本身(包括其依赖项:Clang和LLVM)。这些依赖项的安装方式应确保可以通过CMake的[find_package](https://cmake.org/cmake/help/latest/command/find_package.html)找到它们的功能。您需要LLDB/Clang/LLVM头及其编译的库才能使构建工作,但不需要相应的源文件。 + +# 基于系统LLDB的构建 + +如果您的发行版或操作系统已经提供了正确配置的LLDB/Clang/LLVM安装,则只需运行以下命令即可构建LLDB-mi: ```sh cmake . ; cmake --build . ``` +# 根据自定义LLDB构建 + +您还可以根据自己编译的lldb构建lldb-mi。为此,请按[此处](https://lldb.llvm.org/resources/build.html)所述编译LLDB。但将`CMAKE_INSTALL_PREFIX`设置为本地目录,并通过将`-DLLVM_BUILD_LLVM_DYLIB=On`传递给CMAKE来构建LLVM共享库。然后,在通过设置`CMAKE_PREFIX_PATH`(例如`cmake -DCMAKE_PREFIX_PATH=/home/yourname/lldb-mi/install`)构建lldb-mi时,指向该前缀目录。 + +此示例脚本应在~/buildspace子文件夹中的普通UNIX系统上构建LLVM和lldb-mi: + +``` +cd +mkdir buildspace + +# Download LLVM/Clang/LLDB and build them. +git clone https://github.com/llvm/llvm-project.git +mkdir llvm-inst +mkdir llvm-build +cd llvm-build + +cmake -DLLVM_ENABLE_PROJECTS="clang;lldb;libcxx;libcxxabi" -DCMAKE_INSTALL_PREFIX=~/buildspace/llvm-inst/ -GNinja ../llvm-project/llvm +ninja +ninja install + +# Download lldb-mi and build it against our custom installation. +cd ~/buildspace +git clone https://github.com/lldb-tools/lldb-mi +cd lldb-mi + +# Create a separate build directory for building lldb-mi. +mkdir build +cd build +cmake -DCMAKE_PREFIX_PATH=~/buildspace/llvm-inst/ -GNinja .. +ninja +``` + +# 根据自定义LLDB构建(仅限达尔文)框架 + +您还可以针对您自己编译的框架构建lldb-mi。指令与上述相同,但通过将`-DLLDB_BUILD_FRAMEWORK=1`传递给CMake而不是使用共享库来构建LLVM框架。然后用`-DUSE_LLDB_FRAMEWORK=1`构建LLDB-MI。 + +下面的代码片段更改了上面脚本中的cmake调用。 + + + +``` +// Building llvm-project +cmake -DLLVM_ENABLE_PROJECTS="clang;lldb;libcxx;libcxxabi" -DCMAKE_INSTALL_PREFIX=~/buildspace/llvm-inst/ -DLLDB_BUILD_FRAMEWORK=1 -GNinja ../llvm-project/llvm +``` + +``` +// Building lldb-mi +cmake -DCMAKE_PREFIX_PATH=~/buildspace/llvm-inst/ -DUSE_LLDB_FRAMEWORK=1 -GNinja .. +``` + +# Notes + +在某些架构上(如Linux, x86-64), LLDB动态库无法确定其位置。这导致无法定位gdbserver存根: + +```bash +process launch failed: unable to locate lldb-server +``` + +解决方法是在运行LLDB-MI之前设置环境变量LLDB_DEBUGSERVER_PATH。 +