Skip to content

Commit 8e02b37

Browse files
cg-cnumark-i-m
authored andcommitted
refactor: Fixed all the lines exceeding more than 80 characters
1 parent 5653c13 commit 8e02b37

File tree

1 file changed

+41
-17
lines changed

1 file changed

+41
-17
lines changed

src/compiler-debugging.md

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ normal Rust programs. IIRC backtraces **don't work** on Mac and on MinGW,
1717
sorry. If you have trouble or the backtraces are full of `unknown`,
1818
you might want to find some way to use Linux or MSVC on Windows.
1919

20-
In the default configuration, you don't have line numbers enabled, so the backtrace looks like this:
20+
In the default configuration, you don't have line numbers enabled, so the
21+
backtrace looks like this:
22+
2123
```
2224
stack backtrace:
2325
0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
@@ -26,7 +28,8 @@ stack backtrace:
2628
3: std::panicking::default_hook
2729
4: std::panicking::rust_panic_with_hook
2830
5: std::panicking::begin_panic
29-
6: rustc_typeck::check::cast::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::pointer_kind
31+
6: rustc_typeck::check::cast::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, \
32+
'tcx>>::pointer_kind
3033
(~~~~ LINES REMOVED BY ME FOR BREVITY ~~~~)
3134
32: rustc_typeck::check_crate
3235
33: <std::thread::local::LocalKey<T>>::with
@@ -36,11 +39,15 @@ stack backtrace:
3639
37: rustc_driver::run_compiler
3740
```
3841

39-
If you want line numbers for the stack trace, you can enable `debuginfo-lines=true` or `debuginfo=true` in your config.toml and rebuild the compiler. Then the backtrace will look like this:
42+
If you want line numbers for the stack trace, you can enable
43+
`debuginfo-lines=true` or `debuginfo=true` in your config.toml and rebuild the
44+
compiler. Then the backtrace will look like this:
45+
4046
```
4147
stack backtrace:
4248
(~~~~ LINES REMOVED BY ME FOR BREVITY ~~~~)
43-
6: rustc_typeck::check::cast::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::pointer_kind
49+
6: rustc_typeck::check::cast::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, \
50+
'tcx>>::pointer_kind
4451
at /home/user/rust/src/librustc_typeck/check/cast.rs:110
4552
7: rustc_typeck::check::cast::CastCheck::check
4653
at /home/user/rust/src/librustc_typeck/check/cast.rs:572
@@ -104,13 +111,17 @@ note: rustc 1.24.0-dev running on x86_64-unknown-linux-gnu
104111
105112
note: run with `RUST_BACKTRACE=1` for a backtrace
106113
107-
thread 'rustc' panicked at 'encountered error with `-Z treat_err_as_bug', /home/user/rust/src/librustc_errors/lib.rs:411:12
108-
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
114+
thread 'rustc' panicked at 'encountered error with `-Z treat_err_as_bug',
115+
/home/user/rust/src/librustc_errors/lib.rs:411:12
116+
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose
117+
backtrace.
109118
stack backtrace:
110119
(~~~ IRRELEVANT PART OF BACKTRACE REMOVED BY ME ~~~)
111-
7: rustc::traits::error_reporting::<impl rustc::infer::InferCtxt<'a, 'gcx, 'tcx>>::report_selection_error
120+
7: rustc::traits::error_reporting::<impl rustc::infer::InferCtxt<'a, 'gcx,
121+
'tcx>>::report_selection_error
112122
at /home/user/rust/src/librustc/traits/error_reporting.rs:823
113-
8: rustc::traits::error_reporting::<impl rustc::infer::InferCtxt<'a, 'gcx, 'tcx>>::report_fulfillment_errors
123+
8: rustc::traits::error_reporting::<impl rustc::infer::InferCtxt<'a, 'gcx,
124+
'tcx>>::report_fulfillment_errors
114125
at /home/user/rust/src/librustc/traits/error_reporting.rs:160
115126
at /home/user/rust/src/librustc/traits/error_reporting.rs:112
116127
9: rustc_typeck::check::FnCtxt::select_obligations_where_possible
@@ -190,18 +201,28 @@ However, there are still a few concerns that you might care about:
190201
### Expensive operations in logs
191202

192203
A note of caution: the expressions *within* the `debug!` call are run
193-
whenever RUST_LOG is set, even if the filter would exclude the log. This means that if in the module `rustc::foo` you have a statement
204+
whenever RUST_LOG is set, even if the filter would exclude the log. This means
205+
that if in the module `rustc::foo` you have a statement
194206

195207
```Rust
196208
debug!("{:?}", random_operation(tcx));
197209
```
198210

199-
Then if someone runs a debug `rustc` with `RUST_LOG=rustc::bar`, then `random_operation()` will still run - even while it's output will never be needed!
211+
Then if someone runs a debug `rustc` with `RUST_LOG=rustc::bar`, then
212+
`random_operation()` will still run - even while it's output will never be
213+
needed!
200214

201215
This means that you should not put anything too expensive or likely
202-
to crash there - that would annoy anyone who wants to use logging for their own module. Note that if `RUST_LOG` is unset (the default), then the code will not run - this means that if your logging code panics, then no-one will know it until someone tries to use logging to find *another* bug.
216+
to crash there - that would annoy anyone who wants to use logging for their own
217+
module. Note that if `RUST_LOG` is unset (the default), then the code will not
218+
run - this means that if your logging code panics, then no-one will know it
219+
until someone tries to use logging to find *another* bug.
203220

204-
If you *need* to do an expensive operation in a log, be aware that while log expressions are *evaluated* even if logging is not enabled in your module, they are not *formatted* unless it *is*. This means you can put your expensive/crashy operations inside an `fmt::Debug` impl, and they will not be run unless your log is enabled:
221+
If you *need* to do an expensive operation in a log, be aware that while log
222+
expressions are *evaluated* even if logging is not enabled in your module,
223+
they are not *formatted* unless it *is*. This means you can put your
224+
expensive/crashy operations inside an `fmt::Debug` impl, and they will not be
225+
run unless your log is enabled:
205226

206227
```Rust
207228
use std::fmt;
@@ -225,8 +246,8 @@ debug!("{:?}", ExpensiveOperationContainer { tcx });
225246
## Formatting Graphviz output (.dot files)
226247
[formatting-graphviz-output]: #formatting-graphviz-output
227248

228-
Some compiler options for debugging specific features yield graphviz graphs - e.g.
229-
the `#[rustc_mir(borrowck_graphviz_postflow="suffix.dot")]` attribute
249+
Some compiler options for debugging specific features yield graphviz graphs -
250+
e.g. the `#[rustc_mir(borrowck_graphviz_postflow="suffix.dot")]` attribute
230251
dumps various borrow-checker dataflow graphs.
231252

232253
These all produce `.dot` files. To view these files, install graphviz (e.g.
@@ -252,7 +273,8 @@ assertions enabled - either an "alt" nightly or a compiler you build yourself
252273
by setting `[llvm] assertions=true` in your config.toml - and
253274
see whether anything turns up.
254275

255-
The rustc build process builds the LLVM tools into `./build/<host-triple>/llvm/bin`. They can be called directly.
276+
The rustc build process builds the LLVM tools into
277+
`./build/<host-triple>/llvm/bin`. They can be called directly.
256278

257279
The default rustc compilation pipeline has multiple codegen units, which is hard
258280
to replicate manually and means that LLVM is called multiple times in parallel.
@@ -262,7 +284,8 @@ passing `-C codegen-units=1` to rustc will make debugging easier.
262284
If you want to play with the optimization pipeline, you can use the `opt` from
263285
there on the IR rustc emits with `--emit=llvm-ir`. Note
264286
that rustc emits different IR depending on whether `-O` is enabled, even without
265-
LLVM's optimizations, so if you want to play with the IR rustc emits, you should:
287+
LLVM's optimizations, so if you want to play with the IR rustc emits,
288+
you should:
266289
```
267290
$ rustc +local my-file.rs --emit=llvm-ir -O -C no-prepopulate-passes \
268291
-C codegen-units=1
@@ -275,7 +298,8 @@ IR causes an optimization-time assertion to fail, or to see when
275298
LLVM performs a particular optimization, you can pass the rustc flag
276299
`-C llvm-args=-print-after-all`, and possibly add
277300
`-C llvm-args='-filter-print-funcs=EXACT_FUNCTION_NAME` (e.g.
278-
`-C llvm-args='-filter-print-funcs=_ZN11collections3str21_$LT$impl$u20$str$GT$7replace17hbe10ea2e7c809b0bE'`).
301+
`-C llvm-args='-filter-print-funcs=_ZN11collections3str21_$LT$impl$u20$str$GT$\
302+
7replace17hbe10ea2e7c809b0bE'`).
279303

280304
That produces a lot of output into standard error, so you'll want to pipe
281305
that to some file. Also, if you are using neither `-filter-print-funcs` nor

0 commit comments

Comments
 (0)