forked from grafana/pyroscope
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable.go
51 lines (40 loc) · 745 Bytes
/
table.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package symtab
import (
"sort"
)
type SymbolTab struct {
symbols []Symbol
base uint64
}
func (t *SymbolTab) DebugString() string {
return "SymbolTab{TODO}"
}
type Symbol struct {
Start uint64
Name string
Module string
}
func NewSymbolTab(symbols []Symbol) *SymbolTab {
return &SymbolTab{symbols: symbols}
}
func (t *SymbolTab) Refresh() {
}
func (t *SymbolTab) Cleanup() {
}
func (t *SymbolTab) Rebase(base uint64) {
t.base = base
}
func (t *SymbolTab) Resolve(addr uint64) Symbol {
if len(t.symbols) == 0 {
return Symbol{}
}
addr -= t.base
if addr < t.symbols[0].Start {
return Symbol{}
}
i := sort.Search(len(t.symbols), func(i int) bool {
return addr < t.symbols[i].Start
})
i--
return t.symbols[i]
}