On Fri, Mar 8, 2019 at 4:23 PM Mohit Verma <vmohit...@gmail.com> wrote:
>
> I was looking to see how the golang compiler works, and wanted to step in to 
> the compilation process to see what happens. I am looking at the standard Go 
> compiler in src/cmd/compile from https://github.com/golang/go.
>
> When I try to run the compilation process with gdb, I see I can put 
> breakpoints for the code when the "go tool" is triggered (code in 
> src/cmd/go), but not in the code inside cmd/compile/internal.
> I can also put breakpoints for the code in runtime package, and I see runtime 
> package has a special "runtime-gdb.py" file.
>
> Can anyone point me to what is going on here? And how can I step-in to the 
> compiler code?

The go tool invokes cmd/compile as a subprocess.  To see exactly what
the go tool does, run

go tool -x -work

That will show you an invocation of cmd/compile that you can run under
the debugger.  Using -work ensures that the temporary files passed to
the compiler will be available; you will have to replace $WORK in the
-x output with the temporary directory printed in the first line of
the cmd/go output.

Note that in general compilation are cached, so to get a useful
cmd/compile execution you may have to first run "go clean -cache".

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to