{"record":{"id":"afbf6df8acc1dd45","repo":"go-delve/delve","slug":"invalid-typecast-for-dwarf-instructions","errorCode":null,"errorMessage":"invalid typecast for Dwarf instructions","messagePattern":"invalid typecast for Dwarf instructions","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/dwarf/reader/reader.go","lineNumber":190,"sourceCode":"\t\treturn entry, nil\n\t}\n\treturn nil, fmt.Errorf(\"could not find symbol value for %s\", name)\n}\n\nfunc (reader *Reader) InstructionsForEntryNamed(name string, member bool) ([]byte, error) {\n\tentry, err := reader.FindEntryNamed(name, member)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar attr dwarf.Attr\n\tif member {\n\t\tattr = dwarf.AttrDataMemberLoc\n\t} else {\n\t\tattr = dwarf.AttrLocation\n\t}\n\tinstr, ok := entry.Val(attr).([]byte)\n\tif !ok {\n\t\treturn nil, errors.New(\"invalid typecast for Dwarf instructions\")\n\t}\n\treturn instr, nil\n}\n\nfunc (reader *Reader) InstructionsForEntry(entry *dwarf.Entry) ([]byte, error) {\n\tif entry.Tag == dwarf.TagMember {\n\t\tinstructions, ok := entry.Val(dwarf.AttrDataMemberLoc).([]byte)\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"member data has no data member location attribute\")\n\t\t}\n\t\t// clone slice to prevent stomping on the dwarf data\n\t\treturn append([]byte{}, instructions...), nil\n\t}\n\n\t// non-member\n\tinstructions, ok := entry.Val(dwarf.AttrLocation).([]byte)\n\tif !ok {\n\t\treturn nil, errors.New(\"entry has no location attribute\")","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/dwarf/reader/reader.go#L172-L208","documentation":"In Reader.InstructionsForEntryNamed, the located entry's location attribute (AttrLocation or AttrDataMemberLoc depending on tag) must be a []byte DWARF expression. Any other value type yields this error, meaning the entry cannot provide executable location instructions.","triggerScenarios":"InstructionsForEntryNamed on an entry whose AttrLocation/AttrDataMemberLoc is nil or a non-[]byte form (e.g., location list, constant), or on an entry lacking the attribute altogether.","commonSituations":"Querying variables that are in registers via loclists, constant-valued enum members with AttrConstValue instead of member location, or optimized builds where Go emits location lists.","solutions":["Use InstructionsForEntry on an entry known to carry a static expression","Fall back to full variable evaluation through proc when the attribute is a location list","Dump the entry's attributes to confirm the form before extracting instructions"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func hasByteLocation(e *dwarf.Entry) bool {\n    attr := dwarf.AttrLocation\n    if e.Tag == dwarf.TagMember { attr = dwarf.AttrDataMemberLoc }\n    _, ok := e.Val(attr).([]byte)\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Only call InstructionsForEntryNamed on entries with expression-form attributes","Prefer InstructionsForEntry with a validated entry","Handle loclist/constant forms separately"],"tags":["dwarf","type-assertion","location-attribute"],"backgroundTag":"dwarf-attribute-type-mismatch","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}