package dwarf
import (
+ "encoding/binary"
"errors"
"strconv"
)
return r.d.unit[r.unit].asize
}
+// ByteOrder returns the byte order in the current compilation unit.
+func (r *Reader) ByteOrder() binary.ByteOrder {
+ return r.b.order
+}
+
// Seek positions the Reader at offset off in the encoded entry stream.
// Offset 0 can be used to denote the first entry.
func (r *Reader) Seek(off Offset) {
import (
. "debug/dwarf"
+ "encoding/binary"
"reflect"
"testing"
)
// compilation unit except by using XCOFF, so this is
// hand-written.
tests := []struct {
- name string
- info []byte
+ name string
+ info []byte
+ addrSize int
+ byteOrder binary.ByteOrder
}{
{
"32-bit little",
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
},
+ 8, binary.LittleEndian,
},
{
"64-bit little",
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
},
+ 8, binary.LittleEndian,
},
{
"64-bit big",
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
},
+ 8, binary.BigEndian,
},
}
for _, test := range tests {
- _, err := New(nil, nil, nil, test.info, nil, nil, nil, nil)
+ data, err := New(nil, nil, nil, test.info, nil, nil, nil, nil)
if err != nil {
t.Errorf("%s: %v", test.name, err)
}
+
+ r := data.Reader()
+ if r.AddressSize() != test.addrSize {
+ t.Errorf("%s: got address size %d, want %d", test.name, r.AddressSize(), test.addrSize)
+ }
+ if r.ByteOrder() != test.byteOrder {
+ t.Errorf("%s: got byte order %s, want %s", test.name, r.ByteOrder(), test.byteOrder)
+ }
}
}