@@ -9,9 +9,11 @@ import (
9
9
"fmt"
10
10
"io"
11
11
12
- "github.com/go-delve/delve/pkg /dwarf/util"
12
+ "github.com/parca-dev/parca-agent/internal /dwarf/util"
13
13
)
14
14
15
+ // TODO(kakkoyun): Can we speed parsin using or look up using .eh_frame_hdr?
16
+
15
17
type parsefunc func (* parseContext ) parsefunc
16
18
17
19
type parseContext struct {
@@ -22,18 +24,18 @@ type parseContext struct {
22
24
entries FrameDescriptionEntries
23
25
ciemap map [int ]* CommonInformationEntry
24
26
common * CommonInformationEntry
25
- frame * FrameDescriptionEntry
27
+ frame * DescriptionEntry
26
28
length uint32
27
29
ptrSize int
28
30
ehFrameAddr uint64
29
31
err error
30
32
}
31
33
32
34
// Parse takes in data (a byte slice) and returns FrameDescriptionEntries,
33
- // which is a slice of FrameDescriptionEntry . Each FrameDescriptionEntry
35
+ // which is a slice of DescriptionEntry . Each DescriptionEntry
34
36
// has a pointer to CommonInformationEntry.
35
37
// If ehFrameAddr is not zero the .eh_frame format will be used, a minor variant of DWARF described at https://www.airs.com/blog/archives/460.
36
- // The value of ehFrameAddr will be used as the address at which eh_frame will be mapped into memory
38
+ // The value of ehFrameAddr will be used as the address at which eh_frame will be mapped into memory.
37
39
func Parse (data []byte , order binary.ByteOrder , staticBase uint64 , ptrSize int , ehFrameAddr uint64 ) (FrameDescriptionEntries , error ) {
38
40
var (
39
41
buf = bytes .NewBuffer (data )
@@ -71,15 +73,15 @@ func (ctx *parseContext) offset() int {
71
73
72
74
func parselength (ctx * parseContext ) parsefunc {
73
75
start := ctx .offset ()
74
- binary .Read (ctx .buf , binary .LittleEndian , & ctx .length ) // TODO(aarzilli): this does not support 64bit DWARF
76
+ _ = binary .Read (ctx .buf , binary .LittleEndian , & ctx .length ) // TODO(aarzilli): this does not support 64bit DWARF
75
77
76
78
if ctx .length == 0 {
77
79
// ZERO terminator
78
80
return parselength
79
81
}
80
82
81
83
var cieid uint32
82
- binary .Read (ctx .buf , binary .LittleEndian , & cieid )
84
+ _ = binary .Read (ctx .buf , binary .LittleEndian , & cieid )
83
85
84
86
ctx .length -= 4 // take off the length of the CIE id / CIE pointer.
85
87
@@ -99,7 +101,7 @@ func parselength(ctx *parseContext) parsefunc {
99
101
ctx .err = fmt .Errorf ("unknown CIE_id %#x at %#x" , cieid , start )
100
102
}
101
103
102
- ctx .frame = & FrameDescriptionEntry {Length : ctx .length , CIE : common }
104
+ ctx .frame = & DescriptionEntry {Length : ctx .length , CIE : common }
103
105
return parseFDE
104
106
}
105
107
@@ -127,7 +129,7 @@ func parseFDE(ctx *parseContext) parsefunc {
127
129
// need to read the augmentation data, which are encoded as a ULEB128
128
130
// size followed by 'size' bytes.
129
131
n , _ := util .DecodeULEB128 (reader )
130
- reader .Seek (int64 (n ), io .SeekCurrent )
132
+ _ , _ = reader .Seek (int64 (n ), io .SeekCurrent )
131
133
}
132
134
133
135
// The rest of this entry consists of the instructions
@@ -238,6 +240,7 @@ func (ctx *parseContext) readEncodedPtr(addr uint64, buf util.ByteReaderWithLen,
238
240
239
241
var ptr uint64
240
242
243
+ //nolint:exhaustive
241
244
switch ptrEnc & 0xf {
242
245
case ptrEncAbs , ptrEncSigned :
243
246
ptr , _ = util .ReadUintRaw (buf , binary .LittleEndian , ctx .ptrSize )
@@ -268,7 +271,7 @@ func (ctx *parseContext) readEncodedPtr(addr uint64, buf util.ByteReaderWithLen,
268
271
}
269
272
270
273
// DwarfEndian determines the endianness of the DWARF by using the version number field in the debug_info section
271
- // Trick borrowed from "debug/dwarf".New()
274
+ // Trick borrowed from "debug/dwarf".New().
272
275
func DwarfEndian (infoSec []byte ) binary.ByteOrder {
273
276
if len (infoSec ) < 6 {
274
277
return binary .BigEndian
0 commit comments