-
Notifications
You must be signed in to change notification settings - Fork 16
/
trapmap.go
38 lines (31 loc) · 1.16 KB
/
trapmap.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
// Copyright (c) 2019 Timo Savola. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package debug
import (
"github.com/tsavola/wag/object"
)
// TrapMap implements compile.DebugObjectMapper. It stores function addresses,
// and all call and trap sites. Instruction information is not stored.
type TrapMap struct {
object.CallMap // Function calls and recoverable (portable) traps.
TrapSites []object.CallSite // Unrecoverable (or nonportable) traps.
}
func (m *TrapMap) PutTrapSite(retAddr uint32, stackOffset int32) {
m.TrapSites = append(m.TrapSites, object.CallSite{
RetAddr: retAddr,
StackOffset: stackOffset,
})
}
func (TrapMap) PutInsnAddr(uint32) {}
func (TrapMap) PutDataBlock(uint32, int32) {}
func (m *TrapMap) FindCall(retAddr uint32,
) (init bool, funcIndex, callIndex int, stackOffset int32, retOffset uint32) {
init, funcIndex, callIndex, stackOffset, retOffset = m.CallMap.FindCall(retAddr)
if callIndex < 0 {
if i, found := object.FindCallSite(m.TrapSites, retAddr); found {
stackOffset = m.TrapSites[i].StackOffset
}
}
return
}