]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - utils/analyzer/ubiviz
Vendor import of clang trunk r338536:
[FreeBSD/FreeBSD.git] / utils / analyzer / ubiviz
1 #!/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
15 import xmlrpclib
16 import sys
17
18
19 def Error(message):
20     print >> sys.stderr, 'ubiviz: ' + message
21     sys.exit(1)
22
23
24 def StreamData(filename):
25     file = open(filename)
26     for ln in file:
27         yield eval(ln)
28     file.close()
29
30
31 def Display(G, data):
32     action = data[0]
33     if action == 'vertex':
34         vertex = data[1]
35         G.new_vertex_w_id(vertex)
36         for attribute in data[2:]:
37             G.set_vertex_attribute(vertex, attribute[0], attribute[1])
38     elif action == 'edge':
39         src = data[1]
40         dst = data[2]
41         edge = G.new_edge(src, dst)
42         for attribute in data[3:]:
43             G.set_edge_attribute(edge, attribute[0], attribute[1])
44     elif action == "vertex_style":
45         style_id = data[1]
46         parent_id = data[2]
47         G.new_vertex_style_w_id(style_id, parent_id)
48         for attribute in data[3:]:
49             G.set_vertex_style_attribute(style_id, attribute[0], attribute[1])
50     elif action == "vertex_style_attribute":
51         style_id = data[1]
52         for attribute in data[2:]:
53             G.set_vertex_style_attribute(style_id, attribute[0], attribute[1])
54     elif action == "change_vertex_style":
55         vertex_id = data[1]
56         style_id = data[2]
57         G.change_vertex_style(vertex_id, style_id)
58
59
60 def main(args):
61     if len(args) == 0:
62         Error('no input files')
63
64     server = xmlrpclib.Server('http://127.0.0.1:20738/RPC2')
65     G = server.ubigraph
66
67     for arg in args:
68         G.clear()
69         for x in StreamData(arg):
70             Display(G, x)
71
72     sys.exit(0)
73
74
75 if __name__ == '__main__':
76     main(sys.argv[1:])