Home >Backend Development >Golang >How to Debug Go Programs with GoClipse: Assembly Code vs. Go Code?
Debugging Go Programs with GoClipse: Assembly Code vs. Go Code
When debugging Go programs using GoClipse, you may encounter a situation where the debugger steps through assembly code instead of Go code, even after setting breakpoints. This is generally caused by an inappropriate setting in the launch configuration options.
Understanding the Debug View
When your Go program stops during debugging, the Debug view in Eclipse displays a stack trace. If it resembles the following:
<code class="text">Thread [1] 0 (Suspended : Breakpoint) main() at rt0_windows_amd64.s:15 0x42a400 KERNEL32!BaseThreadInitThunk() at 0x773259ed 0x0 </code>
This indicates that the program has automatically stopped at the "main" function upon startup. However, this is not the Go "main" function but rather an internal runtime "main" function written in C.
Resolving the Issue
To resolve this issue, check the launch configuration options and find the first option. It may say "Default main() (runtime/rt0_*)" or "main.main() (source code entry point)" or something similar.
If it's set to "Default main() (runtime/rt0_*)", change it to "main.main() (source code entry point)". Alternatively, you can simply uncheck the option.
Once you make the necessary changes, click "Run / Resume" (F8) to continue debugging. The debugger will now step through your Go code rather than the assembly code.
The above is the detailed content of How to Debug Go Programs with GoClipse: Assembly Code vs. Go Code?. For more information, please follow other related articles on the PHP Chinese website!