Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func printContext(lines []string, line, contextCount int) {
}
if i >= 0 && i < len(lines) {
line := strings.TrimRightFunc(prefix+lines[i], unicode.IsSpace)
fmt.Println(line)
fmt.Printf("%d: %s\n", i, line)
}
}
fmt.Println()
Expand Down
52 changes: 26 additions & 26 deletions testdata/single-file-tests/example-session-list-2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,44 @@
-> x = mul(x, x)
(godebug) list


func main() {
x := mul(1, 2)
_ = "breakpoint"
--> x = mul(x, x)
if x == 4 {
fmt.Println("It works! x == 4.")
} else if n := 2; n == 3 {
fmt.Println("Math is broken. Ah!")
3:
4: func main() {
5: x := mul(1, 2)
6: _ = "breakpoint"
7: --> x = mul(x, x)
8: if x == 4 {
9: fmt.Println("It works! x == 4.")
10: } else if n := 2; n == 3 {
11: fmt.Println("Math is broken. Ah!")

(godebug) step
-> var x int
(godebug) list

return n + m
}

func mul(n, m int) int {
--> var x int
for i := 0; i < m; i++ {
x = add(x, m)
}
return x
24: return n + m
25: }
26:
27: func mul(n, m int) int {
28: --> var x int
29: for i := 0; i < m; i++ {
30: x = add(x, m)
31: }
32: return x

(godebug) n
-> for i := 0; i < m; i++ {
(godebug) n
-> x = add(x, m)
(godebug) l


func mul(n, m int) int {
var x int
for i := 0; i < m; i++ {
--> x = add(x, m)
}
return x
}
26:
27: func mul(n, m int) int {
28: var x int
29: for i := 0; i < m; i++ {
30: --> x = add(x, m)
31: }
32: return x
33: }

(godebug) continue
What's going on? x == 16
90 changes: 45 additions & 45 deletions testdata/single-file-tests/example-session-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,71 +3,71 @@
-> x = mul(x, x)
(godebug) list


func main() {
x := mul(1, 2)
_ = "breakpoint"
--> x = mul(x, x)
if x == 4 {
fmt.Println("It works! x == 4.")
} else if n := 2; n == 3 {
fmt.Println("Math is broken. Ah!")
3:
4: func main() {
5: x := mul(1, 2)
6: _ = "breakpoint"
7: --> x = mul(x, x)
8: if x == 4 {
9: fmt.Println("It works! x == 4.")
10: } else if n := 2; n == 3 {
11: fmt.Println("Math is broken. Ah!")

(godebug) n
-> if x == 4 {
(godebug) list

func main() {
x := mul(1, 2)
_ = "breakpoint"
x = mul(x, x)
--> if x == 4 {
fmt.Println("It works! x == 4.")
} else if n := 2; n == 3 {
fmt.Println("Math is broken. Ah!")
} else {
4: func main() {
5: x := mul(1, 2)
6: _ = "breakpoint"
7: x = mul(x, x)
8: --> if x == 4 {
9: fmt.Println("It works! x == 4.")
10: } else if n := 2; n == 3 {
11: fmt.Println("Math is broken. Ah!")
12: } else {

(godebug) n
-> } else if n := 2; n == 3 {
(godebug) l

_ = "breakpoint"
x = mul(x, x)
if x == 4 {
fmt.Println("It works! x == 4.")
--> } else if n := 2; n == 3 {
fmt.Println("Math is broken. Ah!")
} else {
fmt.Println("What's going on? x ==", x)
}
6: _ = "breakpoint"
7: x = mul(x, x)
8: if x == 4 {
9: fmt.Println("It works! x == 4.")
10: --> } else if n := 2; n == 3 {
11: fmt.Println("Math is broken. Ah!")
12: } else {
13: fmt.Println("What's going on? x ==", x)
14: }

(godebug) n
-> } else {
(godebug) l

if x == 4 {
fmt.Println("It works! x == 4.")
} else if n := 2; n == 3 {
fmt.Println("Math is broken. Ah!")
--> } else {
fmt.Println("What's going on? x ==", x)
}
}

8: if x == 4 {
9: fmt.Println("It works! x == 4.")
10: } else if n := 2; n == 3 {
11: fmt.Println("Math is broken. Ah!")
12: --> } else {
13: fmt.Println("What's going on? x ==", x)
14: }
15: }
16:

(godebug) n
-> fmt.Println("What's going on? x ==", x)
(godebug) l

fmt.Println("It works! x == 4.")
} else if n := 2; n == 3 {
fmt.Println("Math is broken. Ah!")
} else {
--> fmt.Println("What's going on? x ==", x)
}
}

func add(n, m int) int {
9: fmt.Println("It works! x == 4.")
10: } else if n := 2; n == 3 {
11: fmt.Println("Math is broken. Ah!")
12: } else {
13: --> fmt.Println("What's going on? x ==", x)
14: }
15: }
16:
17: func add(n, m int) int {

(godebug) next
What's going on? x == 16
54 changes: 27 additions & 27 deletions testdata/single-file-tests/select-session.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
-> go func() {
(godebug) list


// -------------------
// Check simple cases.

--> go func() {
select {}
}()

select {
24:
25: // -------------------
26: // Check simple cases.
27:
28: --> go func() {
29: select {}
30: }()
31:
32: select {

(godebug) step
-> select {
Expand Down Expand Up @@ -133,15 +133,15 @@ hello
-> case r1 = <-foo():
(godebug) list

_, _ = r2, ok

case <-foo():
case _ = <-foo():
--> case r1 = <-foo():
case r2 := <-foo():
_ = r2

case _, _ = <-foo():
96: _, _ = r2, ok
97:
98: case <-foo():
99: case _ = <-foo():
100: --> case r1 = <-foo():
101: case r2 := <-foo():
102: _ = r2
103:
104: case _, _ = <-foo():

(godebug) n
-> case r2 := <-foo():
Expand All @@ -164,15 +164,15 @@ hello
-> case r2, ok := <-c[9]: // This is the case that will proceed.
(godebug) list

case _, ok = <-c[6]:
case _, ok1 := <-c[7]:
_ = ok1
case r1, ok = <-c[8]:
--> case r2, ok := <-c[9]: // This is the case that will proceed.
_, _ = r2, ok

case <-foo():
case _ = <-foo():
91: case _, ok = <-c[6]:
92: case _, ok1 := <-c[7]:
93: _ = ok1
94: case r1, ok = <-c[8]:
95: --> case r2, ok := <-c[9]: // This is the case that will proceed.
96: _, _ = r2, ok
97:
98: case <-foo():
99: case _ = <-foo():

(godebug) n
-> _, _ = r2, ok
Expand Down