Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
introduces backward-cpp based backtraces on segfaults
Browse files Browse the repository at this point in the history
  • Loading branch information
Strum355 committed Feb 4, 2021
1 parent 55bf7ff commit 75e801d
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ valgrind*
.cache
bin
build
cmake-build-debug*
cmake-build-debug*
.clangd
compile_commands.json
dump.lsif
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "src/indexer/backward-cpp"]
path = src/indexer/backward-cpp
url = [email protected]:bombela/backward-cpp.git
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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/).

Expand Down
2 changes: 1 addition & 1 deletion docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added docs/images/stacktrace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
6 changes: 4 additions & 2 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 7 additions & 2 deletions src/indexer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
4 changes: 3 additions & 1 deletion src/indexer/IndexerMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include "llvm/Support/raw_ostream.h"
#include <system_error>

#define BACKWARD_HAS_DWARF 1

using namespace clang::tooling;
using namespace llvm;

Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/indexer/backward-cpp
Submodule backward-cpp added at 27a890

0 comments on commit 75e801d

Please sign in to comment.