Use the GDB breakpoint Go program in Ubuntu

Source: Internet
Author: User
Hello everyone, we are bringing you to debug the Go program using GDB breakpoint in Ubuntu. Since I have never been familiar with GDB debugging before, and the Go language itself has no built-in debugging tools, unlike Eralng, which can be used by Debugger, I searched the internet, there is no relevant Chinese tutorial, so I have studied it here and I will bring you an article on GDB simple debugging of the Go program. (There are a lot of articles about GDB) First, write the test code as follows: packagemainimpo

Hello everyone, we are bringing you to debug the Go program using GDB breakpoint in Ubuntu. Since I have never been familiar with GDB debugging before, and the Go language itself has no built-in debugging tools, unlike Eralng, which can be used by Debugger, I searched the internet, there is no relevant Chinese tutorial, so I have studied it here and I will bring you an article on GDB simple debugging of the Go program. (There are still a lot of articles about GDB)

First, write the test code as follows:

Package main

Import (
"Fmt"
)

Func main (){
Fmt. Printf ("% s \ n", "hello, world ")

PrintNumber ()
}

Func printNumber (){
Var count int;
Count = 10

Sum: = 0

For I: = 0; I <count; I ++ {
Sum = sum + I
Fmt. Printf ("I = % d, sum = % d \ n", I, sum)
}
}

Compile and run the program (Sublime Text 2 In Ubuntu. If you want to use this tool, refer to my order article: use Sublime Text 2 in Ubuntu to build the Go development environment see http://www.linuxidc.com/Linux/2012-06/62942.htm ):

Go build main. go

./Main

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.