... | ... | @@ -210,30 +210,30 @@ Let us have a closer look at the stack: |
|
|
from the DWARF information and complains with the "corrupt stack?"
|
|
|
error message.
|
|
|
|
|
|
## Debugging while GHC bootstrap
|
|
|
## Debugging while bootstrapping GHC
|
|
|
|
|
|
|
|
|
Imagine you have a crashing GHC \*stage2\* compiler, but \*stage1\* works.
|
|
|
Imagine you have a crashing GHC *stage2* compiler, but *stage1* works.
|
|
|
It is a rather frustrating experience to identify where the crash is coming
|
|
|
from. With DWARF backtraces the situation improves a bit, as you get
|
|
|
source locations for the backtrace, which can give valuable input.
|
|
|
|
|
|
|
|
|
To do this you can compile the second stage with `-g`, like
|
|
|
To do this, you can compile the second stage with `-g`, like
|
|
|
|
|
|
```wiki
|
|
|
make V=1 GhcStage2HcOpts="-O1 -g"
|
|
|
```
|
|
|
make V=1GhcStage2HcOpts="-O1 -g"
|
|
|
```
|
|
|
|
|
|
|
|
|
(or equivalent).
|
|
|
(or equivalent), assuming the miscompilation is triggered by an optimisation.
|
|
|
|
|
|
|
|
|
Then modify the ghc wrapper `inplace/bin/ghc-stage2` to end with:
|
|
|
Then modify the GHC wrapper `inplace/bin/ghc-stage2` to end with:
|
|
|
|
|
|
```wiki
|
|
|
```
|
|
|
rm -f /tmp/${USER}-gdb
|
|
|
echo run -B"$topdir" ${1+"$@"} > /tmp/${USER}-gdb
|
|
|
echo run -B"$topdir"${1+"$@"} > /tmp/${USER}-gdb
|
|
|
exec gdbtui "$executablename" -x /tmp/${USER}-gdb
|
|
|
```
|
|
|
|
... | ... | |