Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'gprof/org.eclipse.linuxtools.gprof/src/org/eclipse/linuxtools/internal/gprof/parser/CallGraphDecoder.java')
-rw-r--r--gprof/org.eclipse.linuxtools.gprof/src/org/eclipse/linuxtools/internal/gprof/parser/CallGraphDecoder.java134
1 files changed, 67 insertions, 67 deletions
diff --git a/gprof/org.eclipse.linuxtools.gprof/src/org/eclipse/linuxtools/internal/gprof/parser/CallGraphDecoder.java b/gprof/org.eclipse.linuxtools.gprof/src/org/eclipse/linuxtools/internal/gprof/parser/CallGraphDecoder.java
index 01b2605178..b32a8051dc 100644
--- a/gprof/org.eclipse.linuxtools.gprof/src/org/eclipse/linuxtools/internal/gprof/parser/CallGraphDecoder.java
+++ b/gprof/org.eclipse.linuxtools.gprof/src/org/eclipse/linuxtools/internal/gprof/parser/CallGraphDecoder.java
@@ -31,73 +31,73 @@ import org.eclipse.linuxtools.internal.gprof.view.histogram.HistRoot;
*/
public class CallGraphDecoder {
- protected final GmonDecoder decoder;
-
-
- private final Map<ISymbol, CallGraphNode> nodes = new HashMap<>();
-
- /**
- * Constructor
- * @param decoder the Gmon decoder
- */
- public CallGraphDecoder(GmonDecoder decoder) {
- this.decoder = decoder;
- }
-
- /**
- * Decode call-graph record from gmon file.
- * @param stream
- * @throws IOException
- */
- public void decodeCallGraphRecord(DataInput stream, boolean BSDFormat) throws IOException {
- long from_pc = readAddress(stream);
- long self_pc = readAddress(stream);
- int count = BSDFormat?(int)readAddress(stream):stream.readInt();
- IBinaryObject program = decoder.getProgram();
- IAddressFactory addressFactory = program.getAddressFactory();
- IAddress parentAddress = addressFactory.createAddress(Long.toString(from_pc));
- ISymbol parentSymbol = program.getSymbol(parentAddress);
- IAddress childAddress = addressFactory.createAddress(Long.toString(self_pc));
- ISymbol childSymbol = program.getSymbol(childAddress);
- if (childSymbol == null || parentSymbol == null) {
- return;
- }
- addCallArc(parentSymbol, parentAddress, childSymbol, count);
- }
-
-
- protected long readAddress(DataInput stream) throws IOException {
- long ret = stream.readInt() & 0xFFFFFFFFL;
- return ret;
- }
-
-
- private void addCallArc(ISymbol parent, IAddress parentAddress, ISymbol child, int count) {
- CallGraphNode parentNode = nodes.get(parent);
- CallGraphNode childNode = nodes.get(child);
- if (parentNode == null) {
- parentNode = new CallGraphNode(parent);
- nodes.put(parent, parentNode);
- }
- if (childNode == null) {
- childNode = new CallGraphNode(child);
- nodes.put(child, childNode);
- }
- CallGraphArc arc = parentNode.getOutputArc(childNode);
- if (arc == null) {
- arc = new CallGraphArc(parentNode, parentAddress, childNode, count, decoder.getProgram(), decoder.getProject());
- parentNode.getChildren().add(arc);
- childNode.getParents().add(arc);
- } else {
- arc.setCount(arc.getCount() + count);
- }
- }
-
- void populate(HistRoot rootNode) {
- for (CallGraphNode callGraphNode : nodes.values()) {
- rootNode.addCallGraphNode(callGraphNode);
- }
- }
+ protected final GmonDecoder decoder;
+
+
+ private final Map<ISymbol, CallGraphNode> nodes = new HashMap<>();
+
+ /**
+ * Constructor
+ * @param decoder the Gmon decoder
+ */
+ public CallGraphDecoder(GmonDecoder decoder) {
+ this.decoder = decoder;
+ }
+
+ /**
+ * Decode call-graph record from gmon file.
+ * @param stream
+ * @throws IOException
+ */
+ public void decodeCallGraphRecord(DataInput stream, boolean BSDFormat) throws IOException {
+ long from_pc = readAddress(stream);
+ long self_pc = readAddress(stream);
+ int count = BSDFormat?(int)readAddress(stream):stream.readInt();
+ IBinaryObject program = decoder.getProgram();
+ IAddressFactory addressFactory = program.getAddressFactory();
+ IAddress parentAddress = addressFactory.createAddress(Long.toString(from_pc));
+ ISymbol parentSymbol = program.getSymbol(parentAddress);
+ IAddress childAddress = addressFactory.createAddress(Long.toString(self_pc));
+ ISymbol childSymbol = program.getSymbol(childAddress);
+ if (childSymbol == null || parentSymbol == null) {
+ return;
+ }
+ addCallArc(parentSymbol, parentAddress, childSymbol, count);
+ }
+
+
+ protected long readAddress(DataInput stream) throws IOException {
+ long ret = stream.readInt() & 0xFFFFFFFFL;
+ return ret;
+ }
+
+
+ private void addCallArc(ISymbol parent, IAddress parentAddress, ISymbol child, int count) {
+ CallGraphNode parentNode = nodes.get(parent);
+ CallGraphNode childNode = nodes.get(child);
+ if (parentNode == null) {
+ parentNode = new CallGraphNode(parent);
+ nodes.put(parent, parentNode);
+ }
+ if (childNode == null) {
+ childNode = new CallGraphNode(child);
+ nodes.put(child, childNode);
+ }
+ CallGraphArc arc = parentNode.getOutputArc(childNode);
+ if (arc == null) {
+ arc = new CallGraphArc(parentNode, parentAddress, childNode, count, decoder.getProgram(), decoder.getProject());
+ parentNode.getChildren().add(arc);
+ childNode.getParents().add(arc);
+ } else {
+ arc.setCount(arc.getCount() + count);
+ }
+ }
+
+ void populate(HistRoot rootNode) {
+ for (CallGraphNode callGraphNode : nodes.values()) {
+ rootNode.addCallGraphNode(callGraphNode);
+ }
+ }
}

Back to the top