proc/tests: testing apparatus for complex location expressions

This commit is contained in:
aarzilli
2017-08-22 16:40:01 +02:00
committed by Derek Parker
parent 25b19c77c2
commit f098915192
12 changed files with 863 additions and 11 deletions

View File

@ -0,0 +1,34 @@
package dwarfbuilder
import (
"bytes"
"github.com/derekparker/delve/pkg/dwarf/op"
"github.com/derekparker/delve/pkg/dwarf/util"
)
// LocEntry represents one entry of debug_loc.
type LocEntry struct {
Lowpc uint64
Highpc uint64
Loc []byte
}
// LocationBlock returns a DWARF expression corresponding to the list of
// arguments.
func LocationBlock(args ...interface{}) []byte {
var buf bytes.Buffer
for _, arg := range args {
switch x := arg.(type) {
case op.Opcode:
buf.WriteByte(byte(x))
case int:
util.EncodeSLEB128(&buf, int64(x))
case uint:
util.EncodeULEB128(&buf, uint64(x))
default:
panic("unsupported value type")
}
}
return buf.Bytes()
}