浏览代码

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
 	const delimiter = "="
710
 	const delimiter = "="
711
 	for s.Scan() {
711
 	for s.Scan() {
712
 		line := s.Text()
712
 		line := s.Text()
713
-
714
-		if line = strings.TrimSpace(line); line == "" {
713
+		if line = strings.TrimSpace(line); isSpaceOrComment(line) {
715
 			continue
714
 			continue
716
 		}
715
 		}
717
-
718
 		if strings.HasPrefix(line, "---") {
716
 		if strings.HasPrefix(line, "---") {
719
 			break
717
 			break
720
 		}
718
 		}
721
-
722
 		attr := strings.SplitN(line, delimiter, 2)
719
 		attr := strings.SplitN(line, delimiter, 2)
723
 		if len(attr) != 2 {
720
 		if len(attr) != 2 {
724
 			break
721
 			break
761
 		if strings.HasPrefix(line, "---") {
758
 		if strings.HasPrefix(line, "---") {
762
 			break
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
 		if !s.Scan() {
786
 		if !s.Scan() {
789
 			break
787
 			break
790
 		}
788
 		}