MCPcopy Create free account
hub / github.com/google/pprof / ParseData

Function ParseData

profile/profile.go:182–206  ·  view source on GitHub ↗

ParseData parses a profile from a buffer and checks for its validity.

(data []byte)

Source from the content-addressed store, hash-verified

180// ParseData parses a profile from a buffer and checks for its
181// validity.
182func ParseData(data []byte) (*Profile, error) {
183 var p *Profile
184 var err error
185 if len(data) >= 2 && data[0] == 0x1f && data[1] == 0x8b {
186 gz, err := gzip.NewReader(bytes.NewBuffer(data))
187 if err == nil {
188 data, err = io.ReadAll(gz)
189 }
190 if err != nil {
191 return nil, fmt.Errorf("decompressing profile: %v", err)
192 }
193 }
194 if p, err = ParseUncompressed(data); err != nil && err != errNoData && err != errConcatProfile {
195 p, err = parseLegacy(data)
196 }
197
198 if err != nil {
199 return nil, fmt.Errorf("parsing profile: %v", err)
200 }
201
202 if err := p.CheckValid(); err != nil {
203 return nil, fmt.Errorf("malformed profile: %v", err)
204 }
205 return p, nil
206}
207
208var errUnrecognized = fmt.Errorf("unrecognized profile format")
209var errMalformed = fmt.Errorf("malformed profile format")

Callers 3

TestParseDataFunction · 0.92
FuzzFunction · 0.92
ParseFunction · 0.85

Calls 3

CheckValidMethod · 0.95
ParseUncompressedFunction · 0.85
parseLegacyFunction · 0.85

Tested by 1

TestParseDataFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…