owned this note changed 5 years ago
Linked with GitHub

Debug golang program with delve - Peter Lai

tags: COSCUP2020 入門 TR214

歡迎來到 https://hackmd.io/@coscup/2020 共筆

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

點擊本頁上方的 開始用 Markdown 一起寫筆記!
手機版請點選上方 按鈕展開議程列表。

請從這裡開始

How delve works

UI layer cli tool
Service layer 透過 DAP protocol 實作前後端分離
Symbolic layer line num, types, variable name
Target layer control target process

target layer

gdbserial

symbolic layer

format of debug symbol DWARFv4

service layer

DAP = Debug Adapter Protocol

Debug with delve

$ dlv *.go -- ${parameters}
$ go build -gcflags="all=-N -l" *.go
$ dlv exec ${filename} -- ${parameters}
$ dlv attach ${pid}

Debug with GDB

  • build -gcflags=all=-N -l
  • build -ldflags=compressdwarf=false
  • Load go runtime-gdb.py (src/runtime/runtime-gdb.py)
    • 使 GDB 可以用一些 cmd 去 inspect golang debug info

工商

pi Givaway

Select a repo