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

Add some docs on debugging #66

Open
varungandhi-src opened this issue Mar 18, 2022 · 2 comments
Open

Add some docs on debugging #66

varungandhi-src opened this issue Mar 18, 2022 · 2 comments

Comments

@varungandhi-src
Copy link
Contributor

For example, if you have a compile_commands.json which is generating an empty LSIF dump, here is a useful baseline to check first and start delta debugging.


Configuration: clang-11 and lsif-clang from the sourcegraph/lsif-clang Docker image (e78b83931bd2).

Testing with a basic cpp file.

// tmp.cpp
struct C {
	static int doStuff() { return 1; }
};
int main() {
	return C::doStuff();
}

I generated the compilation database as follows: (inside the Docker container with a shell)

clang++-11 -MJ tmp.cc.json tmp.cpp -c -o tmp.o

This generates a single compilation command database entry, which needs to be massaged into the right format.

sed -e ‘1s/^/[\n/’ -e ‘$s/,$/\n]/’ *.cc.json > compile_commands.json 

Pass this to lsif-clang

lsif-clang compile_commands.json

This generates a dump.lsif file with 53 lines, including lines such as

{“id”:17,“type”:“vertex”,“label”:“hoverResult”,“result”:{“contents”:[{“language”:“cpp”,“value”:“int C::doStuff()“}]}}

@varungandhi-src
Copy link
Contributor Author

Another thing that would be helpful: Add a helper script for bisecting a crash from a compile_commands.json. This came up in a customer conversation where the customer mentioned that you couldn't run lsif-clang on a single file.

@varungandhi-src
Copy link
Contributor Author

^ Script above is added in #75; the PR also includes usage examples.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant