| 95 | } |
| 96 | |
| 97 | func getDwarfLocationAddress(ent *dwarf.Entry) uint32 { |
| 98 | f := ent.AttrField(dwarf.AttrLocation) |
| 99 | if f == nil { |
| 100 | return 0 |
| 101 | } |
| 102 | if f.Class != dwarf.ClassExprLoc { |
| 103 | panic(fmt.Errorf("invalid location class: %s", f.Class)) |
| 104 | } |
| 105 | const DW_OP_addr = 0x3 |
| 106 | loc := f.Val.([]byte) |
| 107 | if len(loc) == 0 || loc[0] != DW_OP_addr { |
| 108 | panic(fmt.Errorf("unexpected address format: %X", loc)) |
| 109 | } |
| 110 | return binary.LittleEndian.Uint32(loc[1:]) |
| 111 | } |
| 112 | |
| 113 | // Padding of fields in various CPython structs. They are calculated |
| 114 | // by writing a function in any CPython module, and executing it with |