diff --git a/.gitignore b/.gitignore index 09479aee72..33b563f521 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,7 @@ valgrind* .cache bin build -cmake-build-debug* \ No newline at end of file +cmake-build-debug* +.clangd +compile_commands.json +dump.lsif diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..4225bd1d50 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/indexer/backward-cpp"] + path = src/indexer/backward-cpp + url = git@github.com:bombela/backward-cpp.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 069a0aee90..407381f9ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.16) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_BUILD_TYPE RelWithDebInfo) +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -DNDEBUG -g") include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) diff --git a/README.md b/README.md index 5a49a71160..686dbe3c02 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # lsif-clang indexer ![Status: Development](https://img.shields.io/badge/status-beta-yellow?style=flat) -![GIF displaying usage on the linux kernel.](docs/gifs/torvalds-linux.gif) +![GIF displaying usage on the linux kernel.](docs/images/torvalds-linux.gif) This project is a fork of [clangd](https://clangd.llvm.org/) with patches to add support for outputting [LSIF indexes](https://microsoft.github.io/language-server-protocol/specifications/lsif/0.5.0/specification/). Specifically, a fork of the `clang-tools-extra/clangd` subdirectory of the [llvm-project repo](https://github.com/llvm/llvm-project/). diff --git a/docs/examples.md b/docs/examples.md index 6f30b04da3..e39f507b56 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -4,7 +4,7 @@ This page provides examples of generating compile_commands.json files for differ ## [github.com/torvalds/linux](https://github.com/torvalds/linux) -![GIF displaying usage on the linux kernel.](gifs/torvalds-linux.gif) +![GIF displaying usage on the linux kernel.](images/torvalds-linux.gif) Once you've installed the kernel dependencies (you can use the table in `Documentation/process/changes.rst`), run the following commands from the repository root: ```sh diff --git a/docs/images/stacktrace.png b/docs/images/stacktrace.png new file mode 100644 index 0000000000..ac4c056d3e Binary files /dev/null and b/docs/images/stacktrace.png differ diff --git a/docs/gifs/torvalds-linux.gif b/docs/images/torvalds-linux.gif similarity index 100% rename from docs/gifs/torvalds-linux.gif rename to docs/images/torvalds-linux.gif diff --git a/docs/install.md b/docs/install.md index b3069196f6..b95c0f8a4e 100644 --- a/docs/install.md +++ b/docs/install.md @@ -5,7 +5,7 @@ This project depends on LLVM and Clang. lsif-clang itself should be built agains ### Ubuntu (20.04) ```sh -apt install llvm-10 clang clang-10 libclang-10-dev cmake +apt install llvm-10 clang clang-10 libclang-10-dev cmake binutils-dev ``` #### Older versions of Ubuntu @@ -19,13 +19,15 @@ don't exist in the `apt` package repository. ### MacOS ```sh -brew install cmake sourcegraph/brew/llvm@10 +brew install cmake sourcegraph/brew/llvm@10 binutils ``` > Note: lsif-clang must currently be built using LLVM 10 # Installation +Make sure to checkout any submodules, either with `git clone --recurse-submodules ...` or `git submodule update --init --recursive` + ### Ubuntu ```sh diff --git a/src/indexer/CMakeLists.txt b/src/indexer/CMakeLists.txt index 6daba144c4..3798f1583f 100644 --- a/src/indexer/CMakeLists.txt +++ b/src/indexer/CMakeLists.txt @@ -1,8 +1,13 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backward-cpp) + add_executable(lsif-clang - IndexerMain.cpp - ) + IndexerMain.cpp + ${BACKWARD_ENABLE} +) + +add_backward(lsif-clang) install(TARGETS lsif-clang) diff --git a/src/indexer/IndexerMain.cpp b/src/indexer/IndexerMain.cpp index 0c89341dc9..c5d10b3783 100644 --- a/src/indexer/IndexerMain.cpp +++ b/src/indexer/IndexerMain.cpp @@ -32,6 +32,8 @@ #include "llvm/Support/raw_ostream.h" #include +#define BACKWARD_HAS_DWARF 1 + using namespace clang::tooling; using namespace llvm; @@ -119,7 +121,7 @@ class IndexActionFactory : public FrontendActionFactory { }; int main(int argc, const char **argv) { - sys::PrintStackTraceOnErrorSignal(argv[0]); + //sys::PrintStackTraceOnErrorSignal(argv[0]); CommonOptionsParser OptionsParser(argc, argv, LSIFClangCategory, cl::OneOrMore); diff --git a/src/indexer/backward-cpp b/src/indexer/backward-cpp new file mode 160000 index 0000000000..27a89004a8 --- /dev/null +++ b/src/indexer/backward-cpp @@ -0,0 +1 @@ +Subproject commit 27a89004a86fe2a665f041c198c7fbab7489e278