|
@@ -286,20 +286,16 @@ func printTopProto(w io.Writer, rpt *Report) error {
|
286
|
286
|
PeriodType: p.PeriodType,
|
287
|
287
|
Period: p.Period,
|
288
|
288
|
}
|
289
|
|
- var flatSum int64
|
|
289
|
+ functionMap := make(functionMap)
|
290
|
290
|
for i, n := range g.Nodes {
|
291
|
|
- name, flat, cum := n.Info.PrintableName(), n.FlatValue(), n.CumValue()
|
292
|
|
-
|
293
|
|
- flatSum += flat
|
294
|
|
- f := &profile.Function{
|
295
|
|
- ID: uint64(i + 1),
|
296
|
|
- Name: name,
|
297
|
|
- SystemName: name,
|
298
|
|
- }
|
|
291
|
+ f := functionMap.FindOrAdd(n.Info)
|
|
292
|
+ flat, cum := n.FlatValue(), n.CumValue()
|
299
|
293
|
l := &profile.Location{
|
300
|
|
- ID: uint64(i + 1),
|
|
294
|
+ ID: uint64(i + 1),
|
|
295
|
+ Address: n.Info.Address,
|
301
|
296
|
Line: []profile.Line{
|
302
|
297
|
{
|
|
298
|
+ Line: int64(n.Info.Lineno),
|
303
|
299
|
Function: f,
|
304
|
300
|
},
|
305
|
301
|
},
|
|
@@ -319,6 +315,26 @@ func printTopProto(w io.Writer, rpt *Report) error {
|
319
|
315
|
return out.Write(w)
|
320
|
316
|
}
|
321
|
317
|
|
|
318
|
+type functionMap map[string]*profile.Function
|
|
319
|
+
|
|
320
|
+func (fm functionMap) FindOrAdd(ni graph.NodeInfo) *profile.Function {
|
|
321
|
+ fName := fmt.Sprintf("%q%q%q%d", ni.Name, ni.OrigName, ni.File, ni.StartLine)
|
|
322
|
+
|
|
323
|
+ if f := fm[fName]; f != nil {
|
|
324
|
+ return f
|
|
325
|
+ }
|
|
326
|
+
|
|
327
|
+ f := &profile.Function{
|
|
328
|
+ ID: uint64(len(fm) + 1),
|
|
329
|
+ Name: ni.Name,
|
|
330
|
+ SystemName: ni.OrigName,
|
|
331
|
+ Filename: ni.File,
|
|
332
|
+ StartLine: int64(ni.StartLine),
|
|
333
|
+ }
|
|
334
|
+ fm[fName] = f
|
|
335
|
+ return f
|
|
336
|
+}
|
|
337
|
+
|
322
|
338
|
// printAssembly prints an annotated assembly listing.
|
323
|
339
|
func printAssembly(w io.Writer, rpt *Report, obj plugin.ObjTool) error {
|
324
|
340
|
o := rpt.options
|