{"record":{"id":"04959eff1044c6a7","repo":"go-delve/delve","slug":"unsupported-piece-kind","errorCode":null,"errorMessage":"unsupported piece kind","messagePattern":"unsupported piece kind","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/mem.go","lineNumber":167,"sourceCode":"\t\tcase op.AddrPiece:\n\t\t\tbuf := make([]byte, piece.Size)\n\t\t\tif _, err := mem.ReadMemory(buf, piece.Val); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"could not read %d bytes from address %#x: %v\", piece.Size, piece.Val, err)\n\t\t\t}\n\t\t\tcmem.data = append(cmem.data, buf...)\n\t\tcase op.ImmPiece:\n\t\t\tbuf := piece.Bytes\n\t\t\tif buf == nil {\n\t\t\t\tsz := max(piece.Size, 8)\n\t\t\t\tif piece.Size == 0 && i == len(pieces)-1 {\n\t\t\t\t\tpiece.Size = arch.PtrSize() // DWARF doesn't say what this should be\n\t\t\t\t}\n\t\t\t\tbuf = make([]byte, sz)\n\t\t\t\tbinary.LittleEndian.PutUint64(buf, piece.Val)\n\t\t\t}\n\t\t\tcmem.data = append(cmem.data, buf[:piece.Size]...)\n\t\tdefault:\n\t\t\tpanic(\"unsupported piece kind\")\n\t\t}\n\t}\n\tpaddingBytes := int(size) - len(cmem.data)\n\tif paddingBytes > 0 && paddingBytes < arch.ptrSize {\n\t\tpadding := make([]byte, paddingBytes)\n\t\tcmem.data = append(cmem.data, padding...)\n\t}\n\treturn cmem, nil\n}\n\nfunc (mem *compositeMemory) ReadMemory(data []byte, addr uint64) (int, error) {\n\taddr -= mem.base\n\tif addr >= uint64(len(mem.data)) || addr+uint64(len(data)) > uint64(len(mem.data)) {\n\t\treturn 0, errors.New(\"read out of bounds\")\n\t}\n\tcopy(data, mem.data[addr:addr+uint64(len(data))])\n\treturn len(data), nil\n}","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/mem.go#L149-L185","documentation":"CreateCompositeMemory builds a composite MemoryReaderOverOperation from DWARF location pieces (RegisterPiece/ImmediatePiece). The switch over piece kinds has no handling for other op.DWARFPiece kinds, so encountering one panics — it means the location expression produced a piece type the composite-memory constructor cannot materialize.","triggerScenarios":"Evaluating a variable whose DWARF location list yields a piece kind other than op.RegisterPiece or op.ImmPiece (e.g. certain stack/FB-register or implicit-location pieces) when creating composite memory for a register-based variable.","commonSituations":"Inspecting variables with unusual optimized-away or multi-piece locations; compiler-generated DWARF (newer gc or gcc/clang output) using piece kinds delve's constructor doesn't handle.","solutions":["Reproduce with a minimal program and report to go-delve/delve (this is an unhandled DWARF piece kind)","Rebuild the binary with optimizations disabled (-gcflags=\"-N -l\") to get simpler location expressions","Try a newer delve version — piece-kind coverage improves over time","Inspect the variable's pieces to confirm the unsupported kind via 'print -v'"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// inspect variable location first\nv, err := evalVariable(name)\nif err != nil || len(v.LocationExpr) > 1 { /* multi-piece location: printing may panic */ }","typeGuard":null,"tryCatchPattern":"func() {\n    defer func() {\n        if r := recover(); r != nil {\n            val = nil\n            err = fmt.Errorf(\"cannot evaluate composite variable: %v\", r)\n        }\n    }()\n    val, err = evalVariable(name)\n}()","preventionTips":["Compile with -gcflags=\"-N -l\" to get simple DWARF locations","Keep delve up to date for broader DWARF piece support","Minimize repro and file an upstream issue for unsupported pieces"],"tags":["dwarf","variables","panic","piece-kinds"],"backgroundTag":"unsupported-dwarf-location-piece","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}