While trying to debug a panic in kubelet
, I have been trying unsuccessfully to attach delve
to kubelet
executable:
me@mycomputer:~$ sudo dlv attach 23796
could not attach to pid 23796: could not open debug info
file
and objdump --syms
reveal no debug info is included in kubelet
:
me@mycomputer:~$ file _output/bin/kubelet
_output/bin/kubelet: ELF 64-bit LSB executable, x86-64, version 1
(SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2,
BuildID[sha1]=c7a1645940f91048eea9086bd0500deb7ec75b38, for
GNU/Linux 3.2.0, stripped
me@mycomputer:~$ objdump --syms _output/bin/kubelet
_output/bin/kubelet: file format elf64-x86-64
SYMBOL TABLE:
no symbols
I have tried different options while building kubelet
:
make WHAT=cmd/kubelet GOGCFLAGS=-dwarf
or:
make WHAT=cmd/kubelet GOFLAGS=-dwarf
but still no debug info is included in the executable. It seems to me that -w
option is included by default in go tool link
, which strips the DWARF symbol table to save on final executable size (see here). But I was not able to reverse that.
Any thoughts on how I should build kubelet
to include debug info?