CentOS 7
cd $HOME
wget http://ftp.gnu.org/gnu/binutils/binutils-2.29.1.tar.xz | |
wget http://releases.llvm.org/3.9.1/cfe-3.9.1.src.tar.xz | |
wget http://releases.llvm.org/3.9.1/llvm-3.9.1.src.tar.xz | |
wget http://releases.llvm.org/3.9.1/lldb-3.9.1.src.tar.xz | |
wget http://releases.llvm.org/3.9.1/compiler-rt-3.9.1.src.tar.xz | |
tar -xf binutils-2.29.1.tar.xz | |
tar -xf llvm-3.9.1.src.tar.xz | |
mkdir llvm-3.9.1.src/tools/clang | |
mkdir llvm-3.9.1.src/tools/lldb | |
mkdir llvm-3.9.1.src/projects/compiler-rt | |
tar -xf cfe-3.9.1.src.tar.xz --strip 1 -C llvm-3.9.1.src/tools/clang | |
tar -xf lldb-3.9.1.src.tar.xz --strip 1 -C llvm-3.9.1.src/tools/lldb | |
tar -xf compiler-rt-3.9.1.src.tar.xz --strip 1 -C llvm-3.9.1.src/projects/compiler-rt | |
rm binutils-2.29.1.tar.xz | |
rm cfe-3.9.1.src.tar.xz | |
rm lldb-3.9.1.src.tar.xz | |
rm llvm-3.9.1.src.tar.xz | |
rm compiler-rt-3.9.1.src.tar.xz | |
mkdir llvmbuild | |
cd llvmbuild | |
cmake3 -DCMAKE_BUILD_TYPE=Release -DLLVM_LIBDIR_SUFFIX=64 -DLLVM_ENABLE_EH=1 -DLLVM_ENABLE_RTTI=1 -DLLVM_BINUTILS_INCDIR=../binutils-2.29.1/include ../llvm-3.9.1.src | |
make -j $(($(getconf _NPROCESSORS_ONLN)+1)) | |
sudo make install | |
cd .. | |
rm -r llvmbuild | |
rm -r llvm-3.9.1.src | |
rm -r binutils-2.29.1
|
lldb 3.9 will have to be built for this distro.
First the prerequisites:
sudo yum install centos-release-SCL epel-release
sudo yum install cmake cmake3 gcc gcc-c++ git libicu libunwind make python27 tar wget which zip
sudo yum install doxygen libedit-devel libxml2-devel python-argparse python-devel readline-devel swig xz
Now build and install llvm/lldb 3.9 using the script provided here: build-install-lldb.sh.
WARNING: This script installs llvm and lldb as root (via sudo) and may overwrite any previously installed versions.
cd $HOME
git clone https://github.com/dotnet/diagnostics.git
$HOME/diagnostics/documentation/lldb/centos7/build-install-lldb.sh
This will take some time to complete. After the build is finished, run these commands to remove the no longer needed packages:
sudo yum remove doxygen libedit-devel libxml2-devel python-argparse python-devel readline-devel swig xz
sudo yum clean all
To launch lldb:
lldb-3.9.1
https://github.com/dotnet/diagnostics/blob/master/documentation/lldb/linux-instructions.md
https://github.com/dotnet/diagnostics
.NET Core Diagnostics Repo
This repository contains the source code for various .NET Core runtime diagnostic tools. It currently contains SOS, the managed portion of SOS, the lldb SOS plugin and various global diagnostic tools. The goals of this repo is to build SOS and the lldb SOS plugin for the portable (glibc based) Linux platform (Centos 7) and the platforms not supported by the portable (musl based) build (Centos 6, Alpine, and macOS) and to test across various indexes in a very large matrix: OSs/distros (Centos 6/7, Ubuntu, Alpine, Fedora, Debian, RHEL 7.2), architectures (x64, x86, arm, arm64), lldb versions (3.9 to 9.0) and .NET Core versions (2.1, 3.1, 5.0.x).
Another goal to make it easier to obtain a version of lldb (currently 3.9) with scripts and documentation for platforms/distros like Centos, Alpine, Fedora, etc. that by default provide really old versions.
This repo will also allow out of band development of new SOS and lldb plugin features like symbol server support for the .NET Core runtime and solve the source build problem having SOS.NETCore (managed portion of SOS) in the runtime repo.
See the GitHub Release tab for notes on SOS and diagnostic tools releases.
在 linux 上调试 .NET Core 一般使用 lldb (gdb 也可以但是没有 SOS 插件支持),SOS 插件的源代码被搬到了 diagnostics 仓库,所以我们还需要下载编译这个仓库的源代码。
下载编译 diagnostics 仓库 (LLDB SOS 插件)
安装 LLDB 与 LLDB 的开发文件:
apt-get install clang llvm lldb liblldb-3.9-dev
下载编译 diagnostics 仓库:
git clone https://github.com/dotnet/diagnostics
cd diagnostics
./build.sh
编译成功后你可以在 /diagnostics/artifacts/bin/Linux.x64.Debug/libsosplugin.so
找到 SOS 插件的 dll 文件。