From 9c23850bba9778a05bcb30efb10523a6194e2025 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 15 Apr 2019 22:10:37 -0700 Subject: [PATCH] python: Generalize the dot_writer to handle non Master/Slave roles. Change-Id: I6d93c28e754c0cacacdd5e8885c45bc861135e94 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18169 Maintainer: Gabe Black Maintainer: Andreas Sandberg Reviewed-by: Andreas Sandberg Tested-by: kokoro --- src/python/m5/util/dot_writer.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/python/m5/util/dot_writer.py b/src/python/m5/util/dot_writer.py index 730f0ede1..3cec38f85 100644 --- a/src/python/m5/util/dot_writer.py +++ b/src/python/m5/util/dot_writer.py @@ -126,11 +126,23 @@ def dot_create_edges(simNode, callgraph): for child in simnode_children(simNode): dot_create_edges(child, callgraph) -def dot_add_edge(simNode, callgraph, full_port_name, peerPort): - if peerPort.role == "MASTER": - peer_port_name = re.sub('\.', '_', peerPort.peer.simobj.path() \ - + "." + peerPort.peer.name) - callgraph.add_edge(pydot.Edge(full_port_name, peer_port_name)) +def dot_add_edge(simNode, callgraph, full_port_name, port): + peer = port.peer + full_peer_path = re.sub('\.', '_', peer.simobj.path()) + full_peer_port_name = full_peer_path + "_" + peer.name + + # Each edge is encountered twice, once for each peer. We only want one + # edge, so we'll arbitrarily chose which peer "wins" based on their names. + if full_peer_port_name < full_port_name: + dir_type = { + (False, False) : 'both', + (True, False) : 'forward', + (False, True) : 'back', + (True, True) : 'none' + }[ (port.is_source, + peer.is_source) ] + edge = pydot.Edge(full_port_name, full_peer_port_name, dir=dir_type) + callgraph.add_edge(edge) def dot_create_cluster(simNode, full_path, label): # get the parameter values of the node and use them as a tooltip -- 2.30.2