~ubuntu-branches/ubuntu/utopic/golang/utopic

« back to all changes in this revision

Viewing changes to src/pkg/debug/dwarf/buf.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 
14
14
// Data buffer being decoded.
15
15
type buf struct {
16
 
        dwarf    *Data
17
 
        order    binary.ByteOrder
18
 
        name     string
19
 
        off      Offset
20
 
        data     []byte
21
 
        addrsize int
22
 
        err      error
23
 
}
24
 
 
25
 
func makeBuf(d *Data, name string, off Offset, data []byte, addrsize int) buf {
26
 
        return buf{d, d.order, name, off, data, addrsize, nil}
 
16
        dwarf  *Data
 
17
        order  binary.ByteOrder
 
18
        format dataFormat
 
19
        name   string
 
20
        off    Offset
 
21
        data   []byte
 
22
        err    error
 
23
}
 
24
 
 
25
// Data format, other than byte order.  This affects the handling of
 
26
// certain field formats.
 
27
type dataFormat interface {
 
28
        // DWARF version number.  Zero means unknown.
 
29
        version() int
 
30
 
 
31
        // 64-bit DWARF format?
 
32
        dwarf64() (dwarf64 bool, isKnown bool)
 
33
 
 
34
        // Size of an address, in bytes.  Zero means unknown.
 
35
        addrsize() int
 
36
}
 
37
 
 
38
// Some parts of DWARF have no data format, e.g., abbrevs.
 
39
type unknownFormat struct{}
 
40
 
 
41
func (u unknownFormat) version() int {
 
42
        return 0
 
43
}
 
44
 
 
45
func (u unknownFormat) dwarf64() (bool, bool) {
 
46
        return false, false
 
47
}
 
48
 
 
49
func (u unknownFormat) addrsize() int {
 
50
        return 0
 
51
}
 
52
 
 
53
func makeBuf(d *Data, format dataFormat, name string, off Offset, data []byte) buf {
 
54
        return buf{d, d.order, format, name, off, data, nil}
27
55
}
28
56
 
29
57
func (b *buf) uint8() uint8 {
121
149
 
122
150
// Address-sized uint.
123
151
func (b *buf) addr() uint64 {
124
 
        switch b.addrsize {
 
152
        switch b.format.addrsize() {
125
153
        case 1:
126
154
                return uint64(b.uint8())
127
155
        case 2: