File tree Expand file tree Collapse file tree 1 file changed +26
-27
lines changed Expand file tree Collapse file tree 1 file changed +26
-27
lines changed Original file line number Diff line number Diff line change @@ -92,33 +92,32 @@ GDB的一些常用命令如下所示
9292
9393该命令用来改变运行过程中的变量值,格式如:`set variable <var>=<value>`
9494## 调试过程
95- 我们通过下面这个代码来演示如何通过GDB来调试Go程序,下面是将要演示的代码:
96-
97- //文件名gdbfile.go
98- package main
99-
100- import (
101- "fmt"
102- "time"
103- )
104-
105- func counting(c chan<- int) {
106- for i := 0; i < 10; i++ {
107- time.Sleep(2 * time.Second)
108- c <- i
109- }
110- close(c)
111- }
112-
113- func main() {
114- msg := "Starting main"
115- fmt.Println(msg)
116- bus := make(chan int)
117- msg = "starting a gofunc"
118- go counting(bus)
119- for count := range bus {
120- fmt.Println("count:", count)
121- }
95+ 我们通过下面这个代码来演示如何通过GDB来调试Go程序,下面是将要演示的代码:
96+
97+ package main
98+
99+ import (
100+ "fmt"
101+ "time"
102+ )
103+
104+ func counting(c chan<- int) {
105+ for i := 0; i < 10; i++ {
106+ time.Sleep(2 * time.Second)
107+ c <- i
108+ }
109+ close(c)
110+ }
111+
112+ func main() {
113+ msg := "Starting main"
114+ fmt.Println(msg)
115+ bus := make(chan int)
116+ msg = "starting a gofunc"
117+ go counting(bus)
118+ for count := range bus {
119+ fmt.Println("count:", count)
120+ }
122121}
123122
124123编译文件,生成可执行文件gdbfile:
You can’t perform that action at this time.
0 commit comments