Browse Source

Merge pull request #7 from rauls5382/master

Apply leaf cleanup to threadz samples
Hyoun Kyu Cho 9 years ago
parent
commit
df108c626c
1 changed files with 10 additions and 5 deletions
  1. 10
    5
      profile/legacy_profile.go

+ 10
- 5
profile/legacy_profile.go View File

373
 		}
373
 		}
374
 	}
374
 	}
375
 
375
 
376
+	if err := p.ParseMemoryMap(bytes.NewBuffer(b)); err != nil {
377
+		return nil, err
378
+	}
379
+
380
+	cleanupDuplicateLocations(p)
381
+	return p, nil
382
+}
383
+
384
+func cleanupDuplicateLocations(p *Profile) {
376
 	// The profile handler may duplicate the leaf frame, because it gets
385
 	// The profile handler may duplicate the leaf frame, because it gets
377
 	// its address both from stack unwinding and from the signal
386
 	// its address both from stack unwinding and from the signal
378
 	// context. Detect this and delete the duplicate, which has been
387
 	// context. Detect this and delete the duplicate, which has been
383
 			s.Location = append(s.Location[:1], s.Location[2:]...)
392
 			s.Location = append(s.Location[:1], s.Location[2:]...)
384
 		}
393
 		}
385
 	}
394
 	}
386
-
387
-	if err := p.ParseMemoryMap(bytes.NewBuffer(b)); err != nil {
388
-		return nil, err
389
-	}
390
-	return p, nil
391
 }
395
 }
392
 
396
 
393
 // parseCPUSamples parses a collection of profilez samples from a
397
 // parseCPUSamples parses a collection of profilez samples from a
936
 		return nil, err
940
 		return nil, err
937
 	}
941
 	}
938
 
942
 
943
+	cleanupDuplicateLocations(p)
939
 	return p, nil
944
 	return p, nil
940
 }
945
 }
941
 
946