浏览代码

Apply -1 adjustment to leaf frames for some legacy profiles

Legacy profiles that are not based on interrupt-based sampling
only include addresses that are call stack return addresses. For
them, all callstack addresses should be adjusted by -1 to land
on top of the call instruction and permit accurate symbolization.
Raul Silvera 9 年前
父节点
当前提交
d89f0ee907

+ 8
- 17
profile/legacy_profile.go 查看文件

114
 			if err != nil {
114
 			if err != nil {
115
 				return nil, errMalformed
115
 				return nil, errMalformed
116
 			}
116
 			}
117
-			// Adjust all frames by -1 (except the leaf) to land on top of
118
-			// the call instruction.
119
-			if len(locs) > 0 {
120
-				addr--
121
-			}
117
+			// Adjust all frames by -1 to land on top of the call instruction.
118
+			addr--
122
 			loc := locations[addr]
119
 			loc := locations[addr]
123
 			if loc == nil {
120
 			if loc == nil {
124
 				loc = &Location{
121
 				loc = &Location{
527
 		}
524
 		}
528
 
525
 
529
 		var sloc []*Location
526
 		var sloc []*Location
530
-		for i, addr := range addrs {
527
+		for _, addr := range addrs {
531
 			// Addresses from stack traces point to the next instruction after
528
 			// Addresses from stack traces point to the next instruction after
532
-			// each call.  Adjust by -1 to land somewhere on the actual call
533
-			// (except for the leaf, which is not a call).
534
-			if i > 0 {
535
-				addr--
536
-			}
529
+			// each call.  Adjust by -1 to land somewhere on the actual call.
530
+			addr--
537
 			loc := locs[addr]
531
 			loc := locs[addr]
538
 			if locs[addr] == nil {
532
 			if locs[addr] == nil {
539
 				loc = &Location{
533
 				loc = &Location{
769
 			return nil, err
763
 			return nil, err
770
 		}
764
 		}
771
 		var sloc []*Location
765
 		var sloc []*Location
772
-		for i, addr := range addrs {
766
+		for _, addr := range addrs {
773
 			// Addresses from stack traces point to the next instruction after
767
 			// Addresses from stack traces point to the next instruction after
774
-			// each call.  Adjust by -1 to land somewhere on the actual call
775
-			// (except for the leaf, which is not a call).
776
-			if i > 0 {
777
-				addr--
778
-			}
768
+			// each call.  Adjust by -1 to land somewhere on the actual call.
769
+			addr--
779
 			loc := locs[addr]
770
 			loc := locs[addr]
780
 			if locs[addr] == nil {
771
 			if locs[addr] == nil {
781
 				loc = &Location{
772
 				loc = &Location{

+ 1
- 1
profile/testdata/cppbench.contention.string 查看文件

10
         100      75976: 1 15 16 17 18 25 26 27 28 29 30 31 32 33 34 9 
10
         100      75976: 1 15 16 17 18 25 26 27 28 29 30 31 32 33 34 9 
11
         300   63568134: 1 35 36 37 38 39 40 6 7 8 9 10 11 12 13 
11
         300   63568134: 1 35 36 37 38 39 40 6 7 8 9 10 11 12 13 
12
 Locations
12
 Locations
13
-     1: 0xbccc97 M=1 
13
+     1: 0xbccc96 M=1
14
      2: 0xc61201 M=1 
14
      2: 0xc61201 M=1 
15
      3: 0x42ed5e M=1 
15
      3: 0x42ed5e M=1 
16
      4: 0x42edc0 M=1 
16
      4: 0x42edc0 M=1 

+ 2
- 2
profile/testdata/cppbench.growth.string 查看文件

173
           1    2097152: 1 2 3 58 59 60 
173
           1    2097152: 1 2 3 58 59 60 
174
                 bytes:[2097152] 
174
                 bytes:[2097152] 
175
 Locations
175
 Locations
176
-     1: 0xb83003 M=1 
176
+     1: 0xb83002 M=1
177
      2: 0xb87d4f M=1 
177
      2: 0xb87d4f M=1 
178
      3: 0xc635ef M=1 
178
      3: 0xc635ef M=1 
179
      4: 0x42ecc2 M=1 
179
      4: 0x42ecc2 M=1 
186
     11: 0x7a296c M=1 
186
     11: 0x7a296c M=1 
187
     12: 0xa456e3 M=1 
187
     12: 0xa456e3 M=1 
188
     13: 0x7fcdc2ff214d M=7 
188
     13: 0x7fcdc2ff214d M=7 
189
-    14: 0xc635c8 M=1 
189
+    14: 0xc635c7 M=1
190
     15: 0xafc0ea M=1 
190
     15: 0xafc0ea M=1 
191
     16: 0xb087b0 M=1 
191
     16: 0xb087b0 M=1 
192
     17: 0xb0aa7c M=1 
192
     17: 0xb0aa7c M=1 

+ 2
- 2
profile/testdata/cppbench.heap.string 查看文件

65
         379   12439381: 1 2 3 4 5 6 7 8 9 10 11 
65
         379   12439381: 1 2 3 4 5 6 7 8 9 10 11 
66
                 bytes:[32768] 
66
                 bytes:[32768] 
67
 Locations
67
 Locations
68
-     1: 0xc635c8 M=1 
68
+     1: 0xc635c7 M=1
69
      2: 0x42ecc2 M=1 
69
      2: 0x42ecc2 M=1 
70
      3: 0x42e14b M=1 
70
      3: 0x42e14b M=1 
71
      4: 0x5261ae M=1 
71
      4: 0x5261ae M=1 
119
     52: 0x41c710 M=1 
119
     52: 0x41c710 M=1 
120
     53: 0xc25cc5 M=1 
120
     53: 0xc25cc5 M=1 
121
     54: 0x40651a M=1 
121
     54: 0x40651a M=1 
122
-    55: 0xc63568 M=1 
122
+    55: 0xc63567 M=1
123
     56: 0xbc462d M=1 
123
     56: 0xbc462d M=1 
124
     57: 0xbc4bb4 M=1 
124
     57: 0xbc4bb4 M=1 
125
     58: 0xbc4ed9 M=1 
125
     58: 0xbc4ed9 M=1 

+ 4
- 4
profile/testdata/go.godoc.thread.string 查看文件

10
           1: 1 19 20 21 
10
           1: 1 19 20 21 
11
           1: 22 23 
11
           1: 22 23 
12
 Locations
12
 Locations
13
-     1: 0x44cb3 M=1 
13
+     1: 0x44cb2 M=1
14
      2: 0x45044 M=1 
14
      2: 0x45044 M=1 
15
      3: 0x45322 M=1 
15
      3: 0x45322 M=1 
16
      4: 0x45533 M=1 
16
      4: 0x45533 M=1 
23
     11: 0x51583 M=1 
23
     11: 0x51583 M=1 
24
     12: 0x461df M=1 
24
     12: 0x461df M=1 
25
     13: 0x45546 M=1 
25
     13: 0x45546 M=1 
26
-    14: 0x40962 M=1 
26
+    14: 0x40962 M=1
27
     15: 0x4562d M=1 
27
     15: 0x4562d M=1 
28
     16: 0x460ec M=1 
28
     16: 0x460ec M=1 
29
     17: 0x51a58 M=1 
29
     17: 0x51a58 M=1 
30
     18: 0x441ad M=1 
30
     18: 0x441ad M=1 
31
-    19: 0x44e03 M=1 
31
+    19: 0x44e03 M=1
32
     20: 0x44b7f M=1 
32
     20: 0x44b7f M=1 
33
     21: 0x5192c M=1 
33
     21: 0x5192c M=1 
34
-    22: 0x440e2 M=1 
34
+    22: 0x440e1 M=1
35
     23: 0x51919 M=1 
35
     23: 0x51919 M=1 
36
 Mappings
36
 Mappings
37
 1: 0x0/0xffffffffffffffff/0x0   
37
 1: 0x0/0xffffffffffffffff/0x0   

+ 1
- 1
profile/testdata/gobench.heap.string 查看文件

33
       32768     524296          0          0: 1 88 89 90 91 92 93 94 95 96 97 98 99 100 10 
33
       32768     524296          0          0: 1 88 89 90 91 92 93 94 95 96 97 98 99 100 10 
34
                 bytes:[16] 
34
                 bytes:[16] 
35
 Locations
35
 Locations
36
-     1: 0x420cef M=1 
36
+     1: 0x420cee M=1
37
      2: 0x422150 M=1 
37
      2: 0x422150 M=1 
38
      3: 0x4221d9 M=1 
38
      3: 0x4221d9 M=1 
39
      4: 0x41dc0c M=1 
39
      4: 0x41dc0c M=1