github.com/Rookout/GoSDK@v0.1.48/pkg/services/instrumentation/module/pcsp_generator.go (about) 1 package module 2 3 import ( 4 "github.com/Rookout/GoSDK/pkg/rookoutErrors" 5 "github.com/Rookout/GoSDK/pkg/services/disassembler" 6 ) 7 8 func pcspFromInstructions(instructions []*disassembler.Instruction, lastOffset uintptr) []PCDataEntry { 9 var pcDataEntries []PCDataEntry 10 stackValue := 0 11 state := newRegState() 12 13 for _, inst := range instructions { 14 state.update(inst) 15 newStackValue := state.getStackSize() 16 if newStackValue == stackValue { 17 continue 18 } 19 20 pcDataEntries = append(pcDataEntries, PCDataEntry{ 21 Offset: inst.Offset + uintptr(inst.Len), 22 Value: int32(stackValue), 23 }) 24 stackValue = newStackValue 25 } 26 27 28 pcDataEntries = append(pcDataEntries, PCDataEntry{ 29 Value: int32(state.getStackSize()), 30 Offset: lastOffset, 31 }) 32 33 return pcDataEntries 34 } 35 36 37 38 func generatePCSP(startPC uintptr, endPC uintptr) ([]PCDataEntry, rookoutErrors.RookoutError) { 39 instructions, err := read(startPC, endPC) 40 if err != nil { 41 return nil, err 42 } 43 44 return pcspFromInstructions(instructions, endPC-startPC), nil 45 }