Skip to content

Commit 0803c9f

Browse files
docs: Document how to debug preprocessing issues (#161)
1 parent 1b80f86 commit 0803c9f

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

docs/Development.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
- [UBSan stacktraces](#ubsan-stacktraces)
1111
- [Attaching a debugger](#attaching-a-debugger)
1212
- [Debugging on Linux](#debugging-on-linux)
13-
- [Automated test case reduction](#automated-test-case-reduction)
1413
- [Inspecting Clang ASTs](#inspecting-clang-asts)
14+
- [Automated test case reduction](#automated-test-case-reduction)
15+
- [Debugging preprocessor issues](#debugging-preprocessor-issues)
1516
- [Implementation notes](#implementation-notes)
1617
- [Notes on Clang internals](#notes-on-clang-internals)
1718

@@ -174,6 +175,29 @@ which still reproduces the crash.
174175

175176
See the script's `--help` text for information about additional flags.
176177

178+
### Debugging preprocessor issues
179+
180+
The LLVM monorepo contains a tool
181+
[pp-trace](https://clang.llvm.org/extra/pp-trace.html)
182+
which can be used to understand
183+
the preprocessor callbacks being invoked
184+
without having to resort to
185+
print debugging inside scip-clang itself.
186+
187+
First, build `pp-trace` from source in your LLVM checkout,
188+
making sure to include `clang-tools-extra` in `LLVM_ENABLE_PROJECTS`.
189+
After that, it can be invoked like so:
190+
191+
```
192+
/path/to/llvm-project/build/bin/pp-trace mytestfile.cpp --extra-arg="-isysroot" --extra-arg="$(xcrun --show-sdk-path)"
193+
```
194+
195+
The `isysroot` argument is particularly important,
196+
as `pp-trace` will not find standard library headers without it.
197+
198+
See the [pp-trace](https://clang.llvm.org/extra/pp-trace.html) docs
199+
or the `--help` text for information about other supported flags.
200+
177201
## Implementation notes
178202

179203
<!-- NOTE(def: based-on-sorbet) -->

0 commit comments

Comments
 (0)