Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Debugging Code Generation in Go
Search
JBD
February 02, 2020
Programming
1.7k
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Debugging Code Generation in Go
JBD
February 02, 2020
More Decks by JBD
See All by JBD
eBPF in Microservices Observability at eBPF Day
rakyll
1
2.2k
eBPF in Microservices Observability
rakyll
1
1.8k
OpenTelemetry at AWS
rakyll
1
1.9k
Are you ready for production?
rakyll
8
3k
Servers are doomed to fail
rakyll
3
1.6k
Serverless Containers
rakyll
1
300
Critical Path Analysis
rakyll
0
710
Monitoring and Debugging Containers
rakyll
2
1.2k
CPDD
rakyll
0
4.3k
Other Decks in Programming
See All in Programming
20260722_microCMSで考える、AI時代のコンテンツ運用設計
yosh1
0
400
Google Apps Script で Ruby を動かす
kawahara
0
220
What's New in Android 2026
veronikapj
0
260
楽しそうなつよつよエンジニアと目が死んでる僕/A brilliant engineer having a blast, and dead-eyed me.
3l4l5
2
180
これって Effect でできたのでは? / TSKaigi Mashup Kansai #2
susisu
0
240
今さら聞けない .NET CLI
htkym
0
190
Flow は今どうなっているか
mizdra
PRO
0
510
リアルな遅延を測る仕様
kota_yata
1
100
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
570
Built Our Own Background Agent at LayerX
layerx
PRO
10
5.4k
AI時代のPHPer生存戦略 ~「言語、もうなんでもよくない?」に本気で向き合う~
vivion
0
410
komatsuna「分散システムにおけるバグ分析手法」
komatsunaqa
0
260
Featured
See All Featured
Fireside Chat
paigeccino
42
4k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
3
430
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.3k
Raft: Consensus for Rubyists
vanstee
141
7.6k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
410
Navigating Team Friction
lara
192
16k
Thoughts on Productivity
jonyablonski
76
5.3k
Mind Mapping
helmedeiros
PRO
1
310
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4.3k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
470
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
210
Context Engineering - Making Every Token Count
addyosmani
9
1.1k
Transcript
Debugging Code Generation in Go Jaana B. Dogan, Google
[email protected]
None
None
@rakyll Who needs this talk? • Developers who want to
debug the compilation. • Reverse engineers, security practitioners, ... • Current or prospective Go contributors. • Anyone who wants to study compilers.
Lexing and parsing Transformations on AST SSA optimizations
main program package main import "fmt" func main() { sum
:= 1 + 1 fmt.Printf("sum: %v\n", sum) }
main program $ go build -x WORK=/var/folders/zq/wgh6df4s6fz2wjwdp5dvzlww005d 21/T/go-build399551378 mkdir -p
$WORK/b001/ cat >$WORK/b001/importcfg.link << 'EOF' # internal packagefile github.com/rakyll/codegen=/Users/jbd/Library/Cach es/go-build/00/00ed60989b390a64bad3cb01d4ec61aae6 d0ea61e3e38fc35052d1ab5b0efe66-d packagefile ...
main program $ go build -n # run dry WORK=/var/folders/zq/wgh6df4s6fz2wjwdp5dvzlww005d
21/T/go-build399551378 mkdir -p $WORK/b001/ cat >$WORK/b001/importcfg.link << 'EOF' # internal packagefile github.com/rakyll/codegen=/Users/jbd/Library/Cach es/go-build/00/00ed60989b390a64bad3cb01d4ec61aae6 d0ea61e3e38fc35052d1ab5b0efe66-d packagefile ...
main program $ go build -a # build without the
cache
main program $ go build -work # don’t delete work
directory WORK=/var/folders/zq/wgh6df4s6fz2wjwdp5dvzlww005d 21/T/go-build444532126
main program $ go list -f {{.GoFiles}} # investigate files
[main.go] $ GOOS=windows go list -f {{.GoFiles}} [main.go main_windows.go] See https://golang.org/pkg/cmd/go/internal/list/ for more.
main program $ go build -gcflags="-S" # print Go assembly
# github.com/rakyll/codegen os.(*File).close STEXT dupok nosplit size=26 args=0x18 locals=0x0 0x0000 00000 (<autogenerated>:1) TEXT os.(*File).close(SB), DUPOK|NOSPLIT|ABIInternal, $0-24 0x0000 00000 (<autogenerated>:1) FUNCDATA$0, gclocals·e6397a44f8e1b6e77d0f200b4fba5269(SB) 0x0000 00000 (<autogenerated>:1) FUNCDATA...
main program $ go tool objdump -s main.main <binary> TEXT
main.main(SB) /Users/jbd/go/src/github.com/rakyll/codegen/main. go main.go:5 0x109adc0 65488b0c2530000000 MOVQ GS:0x30, CX main.go:5 0x109adc9 483b6110 CMPQ 0x10(CX), SP main.go:5 0x109adcd 0f8690000000 JBE 0x109ae63 main.go:5 0x109add3 4883ec68 SUBQ ...
main program $ go tool nm <binary> | grep runtime.walltime
1044b20 T runtime.walltime 1054c50 T runtime.walltime_trampoline
main program $ go build -gcflags="-N" # disable optimizations $
go build -gcflags="-l" # disable inlining $ go build -gcflags="-N -l" # disable both
main program $ GOSSAFUNC=main go build && open ssa.html
main program $ go build -gcflags="-m" # escape analysis $
go build -gcflags="-m=2" # more info
main program $ go build -gcflags="-live" # debug liveness $
go build -gcflags="-live=2" # more info
main program $ go build -gcflags="-bench=bench.out" $ go build -gcflags="-race"
# race detector $ go build -gcflags="-memprofile=profile.out" $ go build -gcflags="-traceprofile=trace.out" # ...
Thanks. Jaana B. Dogan, Google
[email protected]