How the Golang process prints Goroutine stack information

Source: Internet
Author: User

Unfortunately, there are no tools like pstack/jstack available at this time.

There are some ways to add code to the source program, such as Debug. Printstack (), and then outside the trigger signal to print the stack content, but in reality the program does not have the code specifically set for debugging.
such as the normal operation of the program, the online program, suddenly deadlock, how to see what each goroutine are doing?

The only way I know now is to send a sigquit signal to the process:
kill -SIGQUIT <pid>

After the go process receives the sigquit signal, it prints out all goroutine stack information to the standard error (STDERR).

Unfortunately, the go process is now out.
If you want to print out all the gorouotine stack, and not kill the process itself, there seems to be no way alas.

In addition Pstack for go process at all, Pstack can print out the operating system level of thread information, but Goroutine does not have the corresponding relationship with thread, especially Gomaxprocs=1, Pstack only prints the stack information for one thread, without any goroutine stack information.

Related Article

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.