OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [debug/] [dwarf/] [unit.go] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2009 The Go Authors.  All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
 
5
package dwarf
6
 
7
import "strconv"
8
 
9
// DWARF debug info is split into a sequence of compilation units.
10
// Each unit has its own abbreviation table and address size.
11
 
12
type unit struct {
13
        base     Offset // byte offset of header within the aggregate info
14
        off      Offset // byte offset of data within the aggregate info
15
        data     []byte
16
        atable   abbrevTable
17
        addrsize int
18
}
19
 
20
func (d *Data) parseUnits() ([]unit, error) {
21
        // Count units.
22
        nunit := 0
23
        b := makeBuf(d, "info", 0, d.info, 0)
24
        for len(b.data) > 0 {
25
                b.skip(int(b.uint32()))
26
                nunit++
27
        }
28
        if b.err != nil {
29
                return nil, b.err
30
        }
31
 
32
        // Again, this time writing them down.
33
        b = makeBuf(d, "info", 0, d.info, 0)
34
        units := make([]unit, nunit)
35
        for i := range units {
36
                u := &units[i]
37
                u.base = b.off
38
                n := b.uint32()
39
                if vers := b.uint16(); vers != 2 {
40
                        b.error("unsupported DWARF version " + strconv.Itoa(int(vers)))
41
                        break
42
                }
43
                atable, err := d.parseAbbrev(b.uint32())
44
                if err != nil {
45
                        if b.err == nil {
46
                                b.err = err
47
                        }
48
                        break
49
                }
50
                u.atable = atable
51
                u.addrsize = int(b.uint8())
52
                u.off = b.off
53
                u.data = b.bytes(int(n - (2 + 4 + 1)))
54
        }
55
        if b.err != nil {
56
                return nil, b.err
57
        }
58
        return units, nil
59
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.