{"record":{"id":"abefa58fec551772","repo":"golang/go","slug":"no-dwarf-data-in-go-object-file","errorCode":null,"errorMessage":"no DWARF data in go object file","messagePattern":"no DWARF data in go object file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/internal/objfile/goobj.go","lineNumber":341,"sourceCode":"}\n\n// We treat the whole object file as the text section.\nfunc (f *goobjFile) text() (textStart uint64, text []byte, err error) {\n\ttext = make([]byte, f.goobj.Size)\n\t_, err = f.f.ReadAt(text, f.goobj.Offset)\n\treturn\n}\n\nfunc (f *goobjFile) goarch() string {\n\treturn f.goobj.Arch\n}\n\nfunc (f *goobjFile) loadAddress() (uint64, error) {\n\treturn 0, fmt.Errorf(\"unknown load address\")\n}\n\nfunc (f *goobjFile) dwarf() (*dwarf.Data, error) {\n\treturn nil, errors.New(\"no DWARF data in go object file\")\n}\n","sourceCodeStart":323,"sourceCodeEnd":343,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/internal/objfile/goobj.go#L323-L343","documentation":"Returned unconditionally by goobjFile.dwarf() in cmd/internal/objfile. gc object files do not embed DWARF debug info inside the goobj container the way some other formats do, so the objfile abstraction (used by cmd/pprof to locate cgo functions) reports that DWARF is simply not available for this file type. It is a permanent, by-design 'not supported' for the gc-object branch of the objfile backend.","triggerScenarios":"Calling (*objfile.Entry).DWARF() (objfile.go:178) on an Entry whose raw file is a gc goobj file. The dispatch reaches goobjFile.dwarf() which always returns this error. pprof or any DWARF-consuming tool hitting a '.o' produced by gc will trigger it.","commonSituations":"A pprof / symbol-resolution workflow pointed at an intermediate gc object file rather than the final linked executable (which does carry DWARF). Mistaking the gc object for an ELF/Mach-O binary that pprof can read.","solutions":["Point DWARF-consuming tooling at the linked executable or test binary, not the intermediate '.o' object file.","Build with DWARF enabled (-ldflags='-w' strips it; remove that flag) so the final binary carries debug info.","Treat this error as informational: detect it and fall back to gosym table-based symbolization instead of DWARF.","If you need DWARF from objects, switch to a backend (ELF/Mach-O/PE) via objfile's other file types."],"exampleFix":"// before\nentry, _ := objfile.Open(objPath)\ndata, err := entry.DWARF() // err == \"no DWARF data in go object file\"\n\n// after: operate on the final binary\nentry, _ := objfile.Open(binPath) // linked executable\ndata, err := entry.DWARF()","handlingStrategy":"type-guard","validationCode":"// Skip DWARF() for goobj-backed entries; it never succeeds.\nfunc supportsDWARF(e *objfile.Entry) bool {\n    // heuristic: gc objects never carry DWARF via this API\n    return false // for goobj-backed entries\n}","typeGuard":"func isNoDWARF(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"no DWARF data\")\n}","tryCatchPattern":"data, err := entry.DWARF()\nif err != nil {\n    if strings.Contains(err.Error(), \"no DWARF data\") {\n        // fall back to gosym table; not fatal\n        return symTableOnly(entry)\n    }\n    return err\n}","preventionTips":["Point DWARF tooling at the final linked executable, not intermediate '.o' files.","Branch on file type before calling DWARF() so you can degrade gracefully.","Build final binaries with DWARF retained (avoid -ldflags='-w')."],"tags":["dwarf","goobj","debugging","pprof","go-toolchain"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}