From 41d0bbdc166b8ade1b91f5493e4ad7cb901020de Mon Sep 17 00:00:00 2001 From: David Chase Date: Mon, 8 May 2017 14:37:02 -0400 Subject: [PATCH] cmd/link: include DW_AT_producer in .debug_info This can make life easier for Delve (and other debuggers), and can help them with bug reports. Sample producer field (from objdump): <48> DW_AT_producer : Go cmd/compile devel +8a59dbf41a Mon May 8 16:02:44 2017 -0400 Change-Id: I0605843c959b53a60a25a3b870aa8755bf5d5b13 Reviewed-on: https://go-review.googlesource.com/33588 Run-TryBot: David Chase TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/cmd/internal/dwarf/dwarf.go | 1 + src/cmd/link/internal/ld/dwarf.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/cmd/internal/dwarf/dwarf.go b/src/cmd/internal/dwarf/dwarf.go index 827b146584..042a79b5a6 100644 --- a/src/cmd/internal/dwarf/dwarf.go +++ b/src/cmd/internal/dwarf/dwarf.go @@ -197,6 +197,7 @@ var abbrevs = [DW_NABRV]dwAbbrev{ {DW_AT_high_pc, DW_FORM_addr}, {DW_AT_stmt_list, DW_FORM_data4}, {DW_AT_comp_dir, DW_FORM_string}, + {DW_AT_producer, DW_FORM_string}, }, }, diff --git a/src/cmd/link/internal/ld/dwarf.go b/src/cmd/link/internal/ld/dwarf.go index c190e537fe..35c450904a 100644 --- a/src/cmd/link/internal/ld/dwarf.go +++ b/src/cmd/link/internal/ld/dwarf.go @@ -1024,6 +1024,8 @@ func writelines(ctxt *Link, syms []*Symbol) ([]*Symbol, []*Symbol) { // OS X linker requires compilation dir or absolute path in comp unit name to output debug info. compDir := getCompilationDir() newattr(dwinfo, dwarf.DW_AT_comp_dir, dwarf.DW_CLS_STRING, int64(len(compDir)), compDir) + producer := "Go cmd/compile " + objabi.Version + newattr(dwinfo, dwarf.DW_AT_producer, dwarf.DW_CLS_STRING, int64(len(producer)), producer) // Write .debug_line Line Number Program Header (sec 6.2.4) // Fields marked with (*) must be changed for 64-bit dwarf