Skip to content

Commit dffa9f4

Browse files
committed
Remove old Gen script for running debug tests
1 parent 20c8280 commit dffa9f4

File tree

13 files changed

+47
-321
lines changed

13 files changed

+47
-321
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ testlogs/
6262

6363
# Put local stuff here
6464
local/
65-
compiler/test/debug/Gen.jar
6665

6766
/bin/.cp
6867

compiler/test/debug/Gen

-13
This file was deleted.

compiler/test/debug/Gen.scala

-174
This file was deleted.

compiler/test/debug/test

-21
This file was deleted.

docs/_docs/contributing/debugging/other-debugging.md

-65
Original file line numberDiff line numberDiff line change
@@ -26,71 +26,6 @@ $ jdb -attach 5005 -sourcepath tests/debug/
2626

2727
You 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

tests/debug/for.scala

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
object Test {
22
def main(args: Array[String]): Unit = {
3-
val b = 8 * 9 // [break] [step: f()]
4-
f() // [step: val a]
3+
val b = 8 * 9
4+
f()
55
20 + b
66
println(b)
77
}
88

99
def f(): Unit = {
10-
val a = for (i <- 1 to 5; j <- 10 to 20) // [cont]
11-
yield (i, j) // Error: incorrect reaching this line
10+
val a = for (i <- 1 to 5; j <- 10 to 20)
11+
yield (i, j)
1212

1313
for (i <- 1 to 5; j <- 10 to 20)
14-
println(i + j) // TODO: i is renamed to i$2 --> reduce debuggability
14+
println(i + j)
1515
}
1616
}

tests/debug/function.scala

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
object Test {
22
def main(args: Array[String]): Unit = {
33
val a = 1 + 2
4-
val b = a * 9 // [break] [step: plus] [step: c = plus]
5-
val plus = (x: Int, y: Int) => { // [cont: x * x]
6-
val a = x * x // [break] [step: y * y]
7-
val b = y * y // [step: a + b]
8-
a + b // [next] [next]
4+
val b = a * 9
5+
val plus = (x: Int, y: Int) => {
6+
val a = x * x
7+
val b = y * y
8+
a + b
99
}
10-
val c = plus(a, b) // [next: print]
11-
println(c) // [cont]
10+
val c = plus(a, b)
11+
println(c)
1212
}
1313

1414
}

tests/debug/if.scala

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
object Test {
22

33
def main(args: Array[String]): Unit = {
4-
var a = 1 + 2 // [break] [step: a + 3]
5-
a = a + 3 // [step: 4 + 5]
6-
a = 4 + 5 // [step: if]
4+
var a = 1 + 2
5+
a = a + 3
6+
a = 4 + 5
77

8-
if (a * 8 > 20) // [step: 9 * 9]
9-
a = 9 * 9 // [step: if]
8+
if (a * 8 > 20)
9+
a = 9 * 9
1010
else
1111
a = 34 * 23
1212

13-
if (a * 8 < 20) // [step: 34 * 23]
13+
if (a * 8 < 20)
1414
a = 9 * 9
1515
else
16-
a = 34 * 23 // [step: print]
16+
a = 34 * 23
1717

1818
println(a)
1919
}

tests/debug/method.scala

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
object Test {
22
def main(args: Array[String]): Unit = {
3-
val a = 1 + 2 // [break] [step: a * 9]
4-
val b = a * 9 // [step: plus]
5-
val c = plus(a, b) // [step: x * x]
3+
val a = 1 + 2
4+
val b = a * 9
5+
val c = plus(a, b)
66
println(c)
77
}
88

99
def plus(x: Int, y: Int) = {
10-
val a = x * x // [step: y * y]
11-
val b = y * y // [step: a + b]
12-
a + b // [step: plus] [step: print] [cont]
10+
val a = x * x
11+
val b = y * y
12+
a + b
1313
}
1414
}

0 commit comments

Comments
 (0)