File tree 2 files changed +43
-0
lines changed
2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 9
9
- [ Membership] ( ./membership.md )
10
10
- [ Reviewing] ( ./reviewing.md )
11
11
12
+ ---
13
+
14
+ - [ Building and debugging libraries] ( ./development/building-and-debugging.md )
15
+
16
+
12
17
---
13
18
14
19
- [ The feature lifecycle] ( ./feature-lifecycle/summary.md )
Original file line number Diff line number Diff line change
1
+
2
+ # Building and Debugging the library crates
3
+
4
+ Most of the [ instructions from the rustc-dev-guide] [ rustc-guide ] also apply to the standard library since
5
+ it is built with the same build system, so it is recommended to read it first.
6
+
7
+ [ rustc-guide ] : https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html
8
+
9
+ # Println-debugging alloc and core
10
+
11
+ Since logging and IO APIs are not available in ` alloc ` and ` core ` advice meant for the rest of the compiler
12
+ is not applicable here.
13
+
14
+ Instead one can either extract the code that should be tested to a normal crate and add debugging statements there or
15
+ on POSIX systems one can use the following hack:
16
+
17
+ ``` rust
18
+ extern " C" {
19
+ fn dprintf (fd : i32 , s : * const u8 , ... );
20
+ }
21
+
22
+ macro_rules! dbg_printf {
23
+ ($ s : expr ) => {
24
+ unsafe { dprintf (2 , " %s\ 0" . as_ptr (), $ s as * const u8 ); }
25
+ }
26
+ }
27
+
28
+ fn function_to_debug () {
29
+ let dbg_str = format! (" debug: {}\ n\ 0" , " hello world" );
30
+ dbg_printf! (dbg_str . as_bytes (). as_ptr ());
31
+ }
32
+ ```
33
+
34
+ Then one can run a test which exercises the code to debug and show the error output via
35
+
36
+ ``` shell,ignore
37
+ ./x.py test library/alloc --test-args <test_name> --test-args --no-capture
38
+ ```
You can’t perform that action at this time.
0 commit comments