|
10 | 10 | - [UBSan stacktraces](#ubsan-stacktraces)
|
11 | 11 | - [Attaching a debugger](#attaching-a-debugger)
|
12 | 12 | - [Debugging on Linux](#debugging-on-linux)
|
13 |
| - - [Automated test case reduction](#automated-test-case-reduction) |
14 | 13 | - [Inspecting Clang ASTs](#inspecting-clang-asts)
|
| 14 | + - [Automated test case reduction](#automated-test-case-reduction) |
| 15 | + - [Debugging preprocessor issues](#debugging-preprocessor-issues) |
15 | 16 | - [Implementation notes](#implementation-notes)
|
16 | 17 | - [Notes on Clang internals](#notes-on-clang-internals)
|
17 | 18 |
|
@@ -174,6 +175,29 @@ which still reproduces the crash.
|
174 | 175 |
|
175 | 176 | See the script's `--help` text for information about additional flags.
|
176 | 177 |
|
| 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 | + |
177 | 201 | ## Implementation notes
|
178 | 202 |
|
179 | 203 | <!-- NOTE(def: based-on-sorbet) -->
|
|
0 commit comments