@@ -26,71 +26,6 @@ $ jdb -attach 5005 -sourcepath tests/debug/
2626
2727You can run ` help ` for commands that supported by JDB.
2828
29- ## Debug Automatically with Expect
30-
31- ### 1. Annotate the source code with debug information.
32-
33- Following file (` tests/debug/while.scala ` ) is an example of annotated source code:
34-
35- ``` scala
36- object Test {
37-
38- def main (args : Array [String ]): Unit = {
39- var a = 1 + 2
40- a = a + 3
41- a = 4 + 5 // [break] [step: while]
42-
43- while (a * 8 < 100 ) { // [step: a += 1]
44- a += 1 // [step: while] [cont: print]
45- }
46-
47- print(a) // [break] [cont]
48- }
49- }
50- ```
51-
52- The debugging information is annotated as comments to the code in brackets:
53-
54- ``` scala
55- val x = f(3 ) // [break] [next: line=5]
56- val y = 5
57- ```
58-
59- 1 . A JDB command must be wrapped in brackets, like ` [step] ` . All JDB commands can be used.
60- 2 . To check output of JDB for a command, use ` [cmd: expect] ` .
61- 3 . If ` expect ` is wrapped in double quotes, regex is supported.
62- 4 . Break commands are collected and set globally.
63- 5 . Other commands will be send to jdb in the order they appear in the source file
64-
65- Note that JDB uses line number starts from 1.
66-
67- ### 2. Generate Expect File
68-
69- Now we can run the following command to generate an expect file:
70-
71- ``` shell
72- compiler/test/debug/Gen tests/debug/while.scala > robot
73- ```
74-
75- ### 3. Run the Test
76-
77- First, compile the file ` tests/debug/while.scala ` :
78-
79- ``` shell
80- $ scalac tests/debug/while.scala
81- ```
82-
83- Second, run the compiled class with debugging enabled:
84-
85- ``` shell
86- $ scala -d Test
87- ```
88-
89- Finally, run the expect script:
90-
91- ``` shell
92- expect robot
93- ```
9429## Other tips
9530### Show for human readable output
9631
0 commit comments