瀏覽代碼

Allow comments in mutex profiles

This corresponds to https://golang.org/cl/33454
Raul Silvera 8 年之前
父節點
當前提交
6c04e3db69
共有 1 個檔案被更改,包括 23 行新增25 行删除
  1. 23
    25
      profile/legacy_profile.go

+ 23
- 25
profile/legacy_profile.go 查看文件

@@ -710,15 +710,12 @@ func parseContention(b []byte) (*Profile, error) {
710 710
 	const delimiter = "="
711 711
 	for s.Scan() {
712 712
 		line := s.Text()
713
-
714
-		if line = strings.TrimSpace(line); line == "" {
713
+		if line = strings.TrimSpace(line); isSpaceOrComment(line) {
715 714
 			continue
716 715
 		}
717
-
718 716
 		if strings.HasPrefix(line, "---") {
719 717
 			break
720 718
 		}
721
-
722 719
 		attr := strings.SplitN(line, delimiter, 2)
723 720
 		if len(attr) != 2 {
724 721
 			break
@@ -761,30 +758,31 @@ func parseContention(b []byte) (*Profile, error) {
761 758
 		if strings.HasPrefix(line, "---") {
762 759
 			break
763 760
 		}
764
-		value, addrs, err := parseContentionSample(line, p.Period, cpuHz)
765
-		if err != nil {
766
-			return nil, err
767
-		}
768
-		var sloc []*Location
769
-		for _, addr := range addrs {
770
-			// Addresses from stack traces point to the next instruction after
771
-			// each call. Adjust by -1 to land somewhere on the actual call.
772
-			addr--
773
-			loc := locs[addr]
774
-			if locs[addr] == nil {
775
-				loc = &Location{
776
-					Address: addr,
761
+		if !isSpaceOrComment(line) {
762
+			value, addrs, err := parseContentionSample(line, p.Period, cpuHz)
763
+			if err != nil {
764
+				return nil, err
765
+			}
766
+			var sloc []*Location
767
+			for _, addr := range addrs {
768
+				// Addresses from stack traces point to the next instruction after
769
+				// each call. Adjust by -1 to land somewhere on the actual call.
770
+				addr--
771
+				loc := locs[addr]
772
+				if locs[addr] == nil {
773
+					loc = &Location{
774
+						Address: addr,
775
+					}
776
+					p.Location = append(p.Location, loc)
777
+					locs[addr] = loc
777 778
 				}
778
-				p.Location = append(p.Location, loc)
779
-				locs[addr] = loc
779
+				sloc = append(sloc, loc)
780 780
 			}
781
-			sloc = append(sloc, loc)
781
+			p.Sample = append(p.Sample, &Sample{
782
+				Value:    value,
783
+				Location: sloc,
784
+			})
782 785
 		}
783
-		p.Sample = append(p.Sample, &Sample{
784
-			Value:    value,
785
-			Location: sloc,
786
-		})
787
-
788 786
 		if !s.Scan() {
789 787
 			break
790 788
 		}