gc vs. gccgo

There are two compilers: gc and gccgo

Packages like Docker require the most recent version of Go - 1.4.2, for gccgo available only since gcc-5.0 (Fedora 22).

Current Python pretty printers + helper commands /usr/lib/golang/src/runtime/runtime-gdb.py work only partially now:

Go Delve Debugger

Delve is written in Go based on DWARF information. Therefore it suffers the same debug info problems like GDB. It cannot walk the stack frames.

break|b - Set break point at the entry point of a function,
continue|c - Run until breakpoint or program termination.
step|si - Single step through program.
next|n - Step over to next source line.
threads - Print out info for every traced thread.
clear - Deletes breakpoint.
goroutines - Print out info for every goroutine.
print|p - Evaluate a variable.
info - Provides info about source, locals, args, or funcs.

-O0 -g

Pretty Printing


(gdb) p *state
$5 = {__descriptor = 0x496480 <__go_map_MN3_int__N3_int>,
      __element_count = 4, __bucket_count = 5,
      __buckets = 0xc2080141e0}
(gdb) ptype state.__buckets
type = void **

(gdb) p state
$2 = map[int]int = {[0]= 85, [2]= 10}


Maybe provide an xmethod to access channel’s goroutine?

(gdb) p reads
$1 = (__go_channel **) 0xc208006060
(gdb) p **reads
$2 = {<No data fields>}
  DW_AT_byte_size: 0

(gdb) p ’&reads’
$1 = (chan *main.readOp *) 0xc208048018
(gdb) ptype ’&reads’
type = struct hchan<*main.readOp> {
(gdb) p *((*’&reads’).sendq.first[0]).elem
$6 = {key = 833357914640, resp = 0xc20803e120}
(gdb) x/gx ((*’&reads’).sendq.first[0]).elem.key
0xc20800a210: 0x0000000000000002
(gdb) p **(struct ’hchan<*main.readOp>’ **)’&reads’
$13 = struct hchan<*main.readOp>

gc Missing CFI

(gdb) bt
#0 runtime.rt0_go () at /usr/lib/golang/src/runtime/asm_am
#1 0x3424e1ffe0 in __libc_start_main (main=0x4489c0 <main>
fini=<optimized out>, rtld_fini=<optimized out>, stack_
#2 0x403659 in _start ()
(gdb) bt
#0 runtime.epollwait () at /usr/lib/golang/src/runtime/sys
#1 0x41c353 in runtime.netpoll (block=true, gp=0x0) at /us
#7 0x43bdf4 in runtime.mstart () at /usr/lib/golang/src/ru
#8 0x445e4c in runtime.rt0_go () at /usr/lib/golang/src/ru
#9 0x3 in ?? ()

(gdb) bt
#0 crosscall_amd64 () at /builddir/build/BUILD/go/src/runt
#1 0x404513 in threadentry (v=<optimized out>) at /builddi
#2 0x342560752a in start_thread (arg=0x7ffff7e2f700) at pt
#3 0x3424f0079d in clone () at ../sysdeps/unix/sysv/linux/
(gdb) bt
#0 runtime.futex () at /usr/lib/golang/src/runtime/sys_lin
#6 0x43bdf4 in runtime.mstart () at /usr/lib/golang/src/ru
#7 0x404753 in crosscall_amd64 () at /builddir/build/BUILD
#8 0x7ffff7e2f9c0 in ?? ()
#13 0x43bd50 in runtime.starttheworld () at /usr/lib/golang
#14 0x7ffff7e2f700 in ?? ()

gc Wrong DW_TAG_variable

func NewDaemonFromDirectory(config *Config, eng *engine.E
config.Root = realRoot

(gdb) p config.Root
$1 = 0xc208001170 "/var/lib/docker"

(gdb) p '&config'.Root
$2 = 0xc208159b10 "/var/lib/docker"
    DW_AT_name: &config

Missing Modules/Namespaces

No DW_TAG_imported_* anywhere:

var (
DefaultDriver string
import (
graphdriver.DefaultDriver = config.GraphDriver

(gdb) p 'github_com_docker_docker_daemon_graphdriver.DefaultDriver'
$4 = 0xc9d1a4 ""
    DW_AT_name: graphdriver.DefaultDriver
    DW_AT_linkage_name: github_com_docker_docker_daemon_graphdriver.Defaul

(gdb) p 'github.com/docker.docker.daemon/graphdriver.DefaultDriver'
$6 = 0x0 ""
    DW_AT_name: github.com/docker.docker.daemon/graphdriver.DefaultDriver

Fedora Packaging

# *** ERROR: No build ID note found in /.../BUILDROOT/etcd-2.0.0-1.rc1.fc22.x86_64/usr/bin/etcd
# build-id gets later regenerated by debugedit.
function gobuild { go build -a -ldflags "-B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n')" -v -x "$@"; }

gccgo Bug

gccgo overrides gc by default, see: alternatives --display go

Use: alternatives --set go /usr/lib/golang/bin/linux_amd64/go

Fedora Bug 1192716

gc runtime-gdb.py Bug

info goroutines, goroutine commands and Maps pretty printer fix:

Fedora Bug 1192721

gc variable references Bug

Fix #gc Wrong DW_TAG_variable; not completely clean fix:

Fedora Bug 1192742

gc Gerrit 7150

gc downloaded testsuite Bug

gc fails to rebuild outside of mock.

Fedora Bug 1191944

dockerinit Bug

Docker is not packageable as it contains embedded checksum of /usr/libexec/docker/dockerinit binary. This prevents debuginfo splitting and also prelink.


Fedora Bug 995136

DWZ will crash on gc-produced binaries. This does not prevent the packages to be built, just the DWZ optimization is not applied.

dwz: dwz.c:1984: checksum_die: Assertion `((!(multifile_mode & MULTIFILE_MODE_OP) && !(multifile_mode & MULTIFILE_MODE_RD) && !(multifile_mode & MULTIFILE_MODE_FI)) || cu != die_cu (ref)) && (!(multifile_mode & MULTIFILE_MODE_OP) || cu->cu_chunk == die_cu (ref)->cu_chunk)' failed.

At least a reduced level of DWZ optimization can be achieved by:

# https://bugzilla.redhat.com/show_bug.cgi?id=995136#c12
%global _dwz_low_mem_die_limit 0

debugedit Bug

Fedora Bug 1184221

Filenames of source files are invalid in *-debuginfo.rpm, they are not rewritten into /usr/src/debug/** subdirectory.

TODO list for gc in Fedora

Critical path:

Optional TODOs:

None: GoDebugging (last edited 2015-12-10 19:30:03 by JanKratochvil)

All content (C) 2008 Free Software Foundation. For terms of use, redistribution, and modification, please see the WikiLicense page.