Docker Community Forums

Share and learn in the Docker community.

How can I debug docker via gdb?


(Bachue Zhou) #1

Hi,

I hope to use gdb to debug docker to learn the source code, but I found when I run gdb docker (the docker was compiled from source code on Ubuntu Wily), and tried to list the source code, it got the error message:

/tmp/go-build630010359/github.com/docker/docker/pkg/term/_obj/_cgo_export.c: No such file or directory.

If I edit the hack/make/binary and append -gcflags '-N -l' to the go build command, then the compiling was failed:

++ go build -o bundles/1.10.0-dev/binary/docker-1.10.0-dev -a -tags 'autogen netgo static_build sqlite_omit_load_extension apparmor seccomp selinux daemon journald btrfs_noversion libdm_no_deferred_remove' -installsuffix netgo -gcflags '-N -l' -ldflags '
		-w


	-extldflags "-static"

	' ./docker
# github.com/docker/docker/docker
runtime.cgocallbackg: nosplit stack overflow
	504	assumed on entry to runtime.cgocallbackg (nosplit)
	416	after runtime.cgocallbackg (nosplit) uses 88
	408	on entry to runtime.exitsyscall (nosplit)
	288	after runtime.exitsyscall (nosplit) uses 120
	280	on entry to runtime.exitsyscallfast (nosplit)
	120	after runtime.exitsyscallfast (nosplit) uses 160
	112	on entry to runtime.writebarrierptr (nosplit)
	64	after runtime.writebarrierptr (nosplit) uses 48
	56	on entry to runtime.writebarrierptr_nostore1 (nosplit)
	0	after runtime.writebarrierptr_nostore1 (nosplit) uses 56
	-8	on entry to runtime.acquirem (nosplit)
reflect.typelinks: nosplit stack overflow
	504	assumed on entry to reflect.typelinks (nosplit)
	352	after reflect.typelinks (nosplit) uses 152
	344	on entry to runtime.typedmemmove (nosplit)
	320	after runtime.typedmemmove (nosplit) uses 24
	312	on entry to runtime.heapBitsBulkBarrier (nosplit)
	192	after runtime.heapBitsBulkBarrier (nosplit) uses 120
	184	on entry to runtime.throw (nosplit)
	160	after runtime.throw (nosplit) uses 24
	152	on entry to runtime.dopanic (nosplit)
	72	after runtime.dopanic (nosplit) uses 80
	64	on entry to runtime.getcallerpc (nosplit)
	56	after runtime.getcallerpc (nosplit) uses 8
	48	on entry to runtime.nextBarrierPC (nosplit)
	8	after runtime.nextBarrierPC (nosplit) uses 40
	0	on entry to runtime.panicindex
	-8	on entry to runtime.morestack (nosplit)
runtime.cgocallback_gofunc: nosplit stack overflow
	504	assumed on entry to runtime.cgocallback_gofunc (nosplit)
	496	after runtime.cgocallback_gofunc (nosplit) uses 8
	488	on entry to runtime.cgocallbackg (nosplit)
	400	after runtime.cgocallbackg (nosplit) uses 88
	392	on entry to runtime.exitsyscall (nosplit)
	272	after runtime.exitsyscall (nosplit) uses 120
	264	on entry to runtime.exitsyscallfast (nosplit)
	104	after runtime.exitsyscallfast (nosplit) uses 160
	96	on entry to runtime.writebarrierptr (nosplit)
	48	after runtime.writebarrierptr (nosplit) uses 48
	40	on entry to runtime.writebarrierptr_nostore1 (nosplit)
	-16	after runtime.writebarrierptr_nostore1 (nosplit) uses 56
Makefile:68: recipe for target 'binary' failed
make: *** [binary] Error 1

What looks like it cannot fully support golang program.

My gdb version is 7.10, and the docker version I tried was 1.8, 1.9, 1.10-dev, all of them have the same issue.

Can anyone help on that? Thanks!


(Kimh) #2

I had the same issue. It might be related to this issue. If I remove -N then the build succeeds and I can run docker with gdb.

However, most of docker commands (ex docker run) ends up with Program received signal SIGSEGV, Segmentation fault. error, so it seems not possible to debug docker with gdb at this moment.