MCPcopy Index your code
hub / github.com/maruel/panicparse / ScanSnapshot

Function ScanSnapshot

stack/context.go:160–208  ·  view source on GitHub ↗

ScanSnapshot scans the Reader for the output from runtime.Stack() in br. Returns nil *Snapshot if no stack trace was detected. If a Snapshot is returned, you can call the function again to find another trace, or do io.Copy(br, out) to flush the rest of the stream. ParseSnapshot processes the outp

(in io.Reader, prefix io.Writer, opts *Opts)

Source from the content-addressed store, hash-verified

158// assumes there is junk before the actual stack trace. The junk is streamed to
159// out.
160func ScanSnapshot(in io.Reader, prefix io.Writer, opts *Opts) (*Snapshot, []byte, error) {
161 if opts == nil || !opts.isValid() {
162 return nil, nil, errors.New("invalid Opts")
163 }
164 // TODO(maruel): Validate opts.
165 s := scanningState{
166 Snapshot: &Snapshot{
167 LocalGOROOT: opts.LocalGOROOT,
168 LocalGOPATHs: opts.LocalGOPATHs,
169 },
170 state: looking,
171 }
172 r := reader{rd: in}
173 var err error
174 var suffix []byte
175 for err == nil && s.state != done {
176 var d []byte
177 if d, err = r.readLine(); len(d) != 0 {
178 l, err1 := s.scan(d)
179 if err1 != nil && (err == nil || err == io.EOF) {
180 err = err1
181 }
182 if !l {
183 if s.state != looking {
184 suffix = append([]byte{}, d...)
185 suffix = append(suffix, r.buffered()...)
186 break
187 }
188 if _, err1 = prefix.Write(d); err1 != nil && (err == nil || err == io.EOF) {
189 err = err1
190 break
191 }
192 }
193 }
194 }
195 if s.Goroutines != nil {
196 if opts.NameArguments {
197 nameArguments(s.Goroutines)
198 }
199 if opts.GuessPaths {
200 _ = s.guessPaths()
201 }
202 if opts.AnalyzeSources {
203 _ = s.augment()
204 }
205 return s.Snapshot, suffix, err
206 }
207 return nil, suffix, err
208}
209
210// IsRace returns true if a race detector stack trace was found.
211//

Callers 15

Example_textFunction · 0.92
Example_streamFunction · 0.92
Example_hTMLFunction · 0.92
Example_simpleFunction · 0.92
recoverPanicFunction · 0.92
snapshotFunction · 0.92
processFunction · 0.92
TestScanSnapshotErrFunction · 0.85
TestGomoduleComplexFunction · 0.85
TestGoRunFunction · 0.85

Calls 8

readLineMethod · 0.95
scanMethod · 0.95
bufferedMethod · 0.95
nameArgumentsFunction · 0.85
isValidMethod · 0.80
WriteMethod · 0.80
guessPathsMethod · 0.80
augmentMethod · 0.80

Tested by 15

Example_textFunction · 0.74
Example_streamFunction · 0.74
Example_hTMLFunction · 0.74
Example_simpleFunction · 0.74
recoverPanicFunction · 0.74
TestScanSnapshotErrFunction · 0.68
TestGomoduleComplexFunction · 0.68
TestGoRunFunction · 0.68
TestPanicFunction · 0.68
TestPanicwebFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…