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

Function parseJavaProfile

profile/legacy_java_profile.go:68–107  ·  view source on GitHub ↗

parseJavaProfile returns a new profile from heapz or contentionz data. b is the profile bytes after the header.

(b []byte)

Source from the content-addressed store, hash-verified

66// parseJavaProfile returns a new profile from heapz or contentionz
67// data. b is the profile bytes after the header.
68func parseJavaProfile(b []byte) (*Profile, error) {
69 h := bytes.SplitAfterN(b, []byte("\n"), 2)
70 if len(h) < 2 {
71 return nil, errUnrecognized
72 }
73
74 p := &Profile{
75 PeriodType: &ValueType{},
76 }
77 header := string(bytes.TrimSpace(h[0]))
78
79 var err error
80 var pType string
81 switch header {
82 case "--- heapz 1 ---":
83 pType = "heap"
84 case "--- contentionz 1 ---":
85 pType = "contention"
86 default:
87 return nil, errUnrecognized
88 }
89
90 if b, err = parseJavaHeader(pType, h[1], p); err != nil {
91 return nil, err
92 }
93 var locs map[uint64]*Location
94 if b, locs, err = parseJavaSamples(pType, b, p); err != nil {
95 return nil, err
96 }
97 if err = parseJavaLocations(b, locs, p); err != nil {
98 return nil, err
99 }
100
101 // Strip out addresses for better merge.
102 if err = p.Aggregate(true, true, true, true, false, false); err != nil {
103 return nil, err
104 }
105
106 return p, nil
107}
108
109// parseJavaHeader parses the attribute section on a java profile and
110// populates a profile. Returns the remainder of the buffer after all

Callers

nothing calls this directly

Calls 4

AggregateMethod · 0.95
parseJavaHeaderFunction · 0.85
parseJavaSamplesFunction · 0.85
parseJavaLocationsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…