blob: 33dae2aa6abb788f3ab38ab0b8b19a96186b307e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/*******************************************************************************
* Copyright (c) 2009 STMicroelectronics.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
*******************************************************************************/
package org.eclipse.linuxtools.internal.gprof.view.histogram;
import java.util.LinkedList;
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
import org.eclipse.cdt.core.IBinaryParser.ISymbol;
import org.eclipse.core.resources.IProject;
import org.eclipse.linuxtools.internal.gprof.parser.GmonDecoder;
import org.eclipse.linuxtools.internal.gprof.symbolManager.Bucket;
import org.eclipse.linuxtools.internal.gprof.symbolManager.CallGraphNode;
/**
* Root node of histogram
*
* @author Xavier Raynaud <xavier.raynaud@st.com>
*/
public class HistRoot extends AbstractTreeElement {
private final LinkedList<HistFile> children = new LinkedList<HistFile>();
/** The decoded gmon to display */
public final GmonDecoder decoder;
/**
* Constructor
* @param decoder
*/
public HistRoot(GmonDecoder decoder) {
super(null);
this.decoder = decoder;
}
private HistFile getChild(String p) {
for (HistFile f : this.children) {
if (p != null) {
if (p.equals(f.sourcePath)) return f;
} else if (f.sourcePath == null) return f;
}
HistFile f = new HistFile(this, p);
this.children.add(f);
return f;
}
/**
* Add a bucket to the tree representation of the gmon file
* @param b a bucket
* @param s a symbol (the bucket belong to this symbol)
* @param program the program
*/
public void addBucket(Bucket b, ISymbol s, IBinaryObject program) {
String path = decoder.getFileName(s);
HistFile hf = getChild(path);
hf.addBucket(b, s, program);
}
/**
* Add a callgraph node to the tree representation of the gmon file
* @param node
*/
public void addCallGraphNode(CallGraphNode node) {
ISymbol s = node.getSymbol();
String path = decoder.getFileName(s);
HistFile hf = getChild(path);
hf.addCallGraphNode(node);
}
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.internal.gprof.view.histogram.TreeElement#getChildren()
*/
public LinkedList<? extends TreeElement> getChildren() {
return this.children;
}
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.internal.gprof.view.histogram.TreeElement#getName()
*/
public String getName() {
return "Summary";
}
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.internal.gprof.view.histogram.AbstractTreeElement#getCalls()
*/
public int getCalls() {
return -1;
}
public IProject getProject() {
return decoder.getProject();
}
}
|