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

Function parseThreadSample

profile/legacy_profile.go:925–955  ·  view source on GitHub ↗

parseThreadSample parses a symbolized or unsymbolized stack trace. Returns the first line after the traceback, the sample (or nil if it hits a 'same-as-previous' marker) and an error.

(s *bufio.Scanner)

Source from the content-addressed store, hash-verified

923// Returns the first line after the traceback, the sample (or nil if
924// it hits a 'same-as-previous' marker) and an error.
925func parseThreadSample(s *bufio.Scanner) (nextl string, addrs []uint64, err error) {
926 var line string
927 sameAsPrevious := false
928 for s.Scan() {
929 line = strings.TrimSpace(s.Text())
930 if line == "" {
931 continue
932 }
933
934 if strings.HasPrefix(line, "---") {
935 break
936 }
937 if strings.Contains(line, "same as previous thread") {
938 sameAsPrevious = true
939 continue
940 }
941
942 curAddrs, err := parseHexAddresses(line)
943 if err != nil {
944 return "", nil, fmt.Errorf("malformed sample: %s: %v", line, err)
945 }
946 addrs = append(addrs, curAddrs...)
947 }
948 if err := s.Err(); err != nil {
949 return "", nil, err
950 }
951 if sameAsPrevious {
952 return line, nil, nil
953 }
954 return line, addrs, nil
955}
956
957// parseAdditionalSections parses any additional sections in the
958// profile, ignoring any unrecognized sections.

Callers 1

parseThreadFunction · 0.85

Calls 1

parseHexAddressesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…