Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/com_ws/output_ws.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com_ws

import (
"fmt"
"io"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -75,6 +76,7 @@ func (d *outputWs) sendUserMessage(augID types.AugID, messageID string, argument
return nil
}

fmt.Printf("Sending augID: %d, messageID: %d\n", augID, messageID)
msg := &pb.AugReportMessage{
AgentId: d.agentID,
AugID: augID,
Expand Down
6 changes: 4 additions & 2 deletions pkg/processor/namespaces/frame_namespace.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package namespaces

import (
"fmt"
"strconv"
"strings"

Expand Down Expand Up @@ -100,7 +101,7 @@ func (f *FrameNamespace) GetDump(args string) (*ContainerNamespace, rookoutError
}

func (f *FrameNamespace) ReadAttribute(name string) (Namespace, rookoutErrors.RookoutError) {

if local, ok := f.locals[name]; ok {
if local.ObjectDumpConf.IsTailored {
return local, nil
Expand All @@ -110,7 +111,6 @@ func (f *FrameNamespace) ReadAttribute(name string) (Namespace, rookoutErrors.Ro
dumpConfig := config.GetDefaultDumpConfig()
dumpConfig.ShouldTailor = true


v, err := f.collectionService.GetVariable(name, dumpConfig)
if err != nil {
return nil, rookoutErrors.NewRookAttributeNotFoundException(name)
Expand All @@ -134,5 +134,7 @@ func (f *FrameNamespace) GetObject() interface{} {

func (f *FrameNamespace) Serialize(serializer Serializer) {
dump, _ := f.GetDump("")
fmt.Println("Serializing frame")
dump.Serialize(serializer)
fmt.Println("Done serializing frame")
}
7 changes: 5 additions & 2 deletions pkg/services/collection/collection_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type Stackframe struct {
}

type CollectionService struct {

variables []*variable.Variable
StackTraceElements []Stackframe
variableLocators []*variable.VariableLocator
Expand All @@ -27,7 +26,7 @@ type CollectionService struct {
dictAddr uint64
regs registers.Registers
pointerSize int
goid int
goid int
}

const goDictionaryName = ".dict"
Expand Down Expand Up @@ -69,6 +68,7 @@ func (c *CollectionService) loadDictVariable(config config.ObjectDumpConfig) {
}

func (c *CollectionService) GetVariables(config config.ObjectDumpConfig) []*variable.Variable {
fmt.Printf("Getting %d variables\n", len(c.variableLocators))
c.loadDictVariable(config)

var variables []*variable.Variable
Expand All @@ -91,6 +91,7 @@ func (c *CollectionService) GetVariable(name string, config config.ObjectDumpCon
}

func (c *CollectionService) locateAndLoadVariable(varLocator *variable.VariableLocator, config config.ObjectDumpConfig) (v *variable.Variable) {
fmt.Printf("Locating %s\n", varLocator.VariableName)
v = varLocator.Locate(c.regs, c.dictAddr, c.variablesCache, config)
if name := v.Name; len(name) > 1 && name[0] == '&' {
v = v.MaybeDereference()
Expand All @@ -104,8 +105,10 @@ func (c *CollectionService) locateAndLoadVariable(varLocator *variable.VariableL
v.ObjectDumpConfig.Tailor(v.Kind, int(v.Len))
}

fmt.Printf("Loading %s\n", varLocator.VariableName)
v.LoadValue()
c.variables = append(c.variables, v)
fmt.Printf("Added %s\n", varLocator.VariableName)
return v
}

Expand Down
20 changes: 8 additions & 12 deletions pkg/services/instrumentation/callback/callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/Rookout/GoSDK/pkg/utils"
)


func getContext() uintptr

var BinaryInfo *binary_info.BinaryInfo
Expand All @@ -45,11 +44,11 @@ type BreakpointInfo struct {

func collectStacktrace(regs *registers.OnStackRegisters, g go_runtime.GPtr, maxStacktrace int) []collection.Stackframe {
if maxStacktrace == 0 {
maxStacktrace = 1
maxStacktrace = 1
}

pcs := make([]uintptr, maxStacktrace)

frameCount := go_runtime.Callers(uintptr(regs.PC()), uintptr(regs.SP()), g, pcs)
pcs = pcs[:frameCount]
stacktrace := make([]collection.Stackframe, 0, frameCount)
Expand All @@ -59,17 +58,13 @@ func collectStacktrace(regs *registers.OnStackRegisters, g go_runtime.GPtr, maxS
frame := runtime.Frame{}
for i := 0; i < frameCount; i++ {
if !more {

logger.Logger().Warningf("Expected more frames but more is false: %d/%d\n", i, frameCount)
break
}

frame, more = frames.Next()






stacktrace = append(stacktrace,
collection.Stackframe{
File: frame.File,
Expand Down Expand Up @@ -131,7 +126,6 @@ func goCollect(context uintptr, g go_runtime.GPtr) {
systemstack(func() {
waitChan = make(chan struct{})


go func() {
defer func() {
waitChan <- struct{}{}
Expand Down Expand Up @@ -169,7 +163,7 @@ func collectBreakpoint(context uintptr, g go_runtime.GPtr) {

goid := go_id.GetGoID(g)
stacktrace := collectStacktrace(regs, g, bpInstance.Breakpoint.Stacktrace)

stacktrace[0].Line = bpInstance.Breakpoint.Line

bpInfo := &BreakpointInfo{
Expand All @@ -187,12 +181,14 @@ func reportBreakpoint(bpInstance *augs.BreakpointInstance, bpInfo *BreakpointInf
return
}

logger.Logger().Debugf("Triggered breakpoint %s:%d (0x%x)", bp.File, bp.Line, bpInstance.Addr)
wg := sync.WaitGroup{}
wg.Add(len(locations))
for i := range locations {
utils.CreateGoroutine(func(i int) func() {
return func() {
return func() {
defer func() {
logger.Logger().Debugf("Finished collecting breakpoint %s:%d (0x%x), audID: %d", bp.File, bp.Line, bpInstance.Addr, locations[i].GetAugID())
if r := recover(); r != nil {
locations[i].SetError(rookoutErrors.NewUnknownError(r))
}
Expand Down