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)
| 923 | // Returns the first line after the traceback, the sample (or nil if |
| 924 | // it hits a 'same-as-previous' marker) and an error. |
| 925 | func 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. |
no test coverage detected
searching dependent graphs…