blob: 1582797c63f9c31be129bbbcbed889003069fce3 [file] [log] [blame]
Ted Kremenekf8ce6992008-08-27 22:31:43 +00001#!/usr/bin/env python
2#
3# The LLVM Compiler Infrastructure
4#
5# This file is distributed under the University of Illinois Open Source
6# License. See LICENSE.TXT for details.
7#
8##===----------------------------------------------------------------------===##
9#
10# This script reads visualization data emitted by the static analyzer for
11# display in Ubigraph.
12#
13##===----------------------------------------------------------------------===##
14
15import xmlrpclib
16import sys
17
18def Error(message):
19 print >> sys.stderr, 'ubiviz: ' + message
20 sys.exit(1)
21
22def StreamData(filename):
23 file = open(filename)
24 for ln in file:
25 yield eval(ln)
26 file.close()
27
28def Display(G, data):
29 action = data[0]
30 if action == 'vertex':
31 vertex = data[1]
32 G.new_vertex_w_id(vertex)
33 for attribute in data[2:]:
34 G.set_vertex_attribute(vertex, attribute[0], attribute[1])
35 elif action == 'edge':
36 src = data[1]
37 dst = data[2]
38 edge = G.new_edge(src,dst)
39 for attribute in data[3:]:
40 G.set_edge_attribute(edge, attribute[0], attribute[1])
Ted Kremenekf1f17002008-08-28 05:01:37 +000041 elif action == "vertex_style":
42 style_id = data[1]
43 parent_id = data[2]
44 G.new_vertex_style_w_id(style_id, parent_id)
45 for attribute in data[3:]:
46 G.set_vertex_style_attribute(style_id, attribute[0], attribute[1])
47 elif action == "vertex_style_attribute":
48 style_id = data[1]
49 for attribute in data[2:]:
50 G.set_vertex_style_attribute(style_id, attribute[0], attribute[1])
51 elif action == "change_vertex_style":
52 vertex_id = data[1]
53 style_id = data[2]
54 G.change_vertex_style(vertex_id,style_id)
Ted Kremenekf8ce6992008-08-27 22:31:43 +000055
56def main(args):
57 if len(args) == 0:
58 Error('no input files')
59
60 server = xmlrpclib.Server('http://127.0.0.1:20738/RPC2')
61 G = server.ubigraph
62
63 for arg in args:
64 G.clear()
65 for x in StreamData(arg):
66 Display(G,x)
Ted Kremenek710ad932008-08-28 03:54:51 +000067
68 sys.exit(0)
69
Ted Kremenekf8ce6992008-08-27 22:31:43 +000070
71if __name__ == '__main__':
72 main(sys.argv[1:])
73
74