// ConvertThread converts a proc.Thread into an // api thread. func ConvertThread(th *proc.Thread) *Thread { var ( function *Function file string line int pc uint64 gid int ) loc, err := th.Location() if err == nil { pc = loc.PC file = loc.File line = loc.Line function = ConvertFunction(loc.Fn) } var bp *Breakpoint if th.CurrentBreakpoint != nil && th.BreakpointConditionMet { bp = ConvertBreakpoint(th.CurrentBreakpoint) } if g, _ := th.GetG(); g != nil { gid = g.ID } return &Thread{ ID: th.ID, PC: pc, File: file, Line: line, Function: function, GoroutineID: gid, Breakpoint: bp, } }
// convertThread converts an internal thread to an API Thread. func ConvertThread(th *proc.Thread) *Thread { var ( function *Function file string line int pc uint64 ) loc, err := th.Location() if err == nil { pc = loc.PC file = loc.File line = loc.Line function = ConvertFunction(loc.Fn) } return &Thread{ ID: th.Id, PC: pc, File: shortenFilePath(file), Line: line, Function: function, } }