@@ -49,9 +49,11 @@ def parse_trace(src, program):
49
49
for label , obs_str in zip (trace_lines [1 ::2 ], trace_lines [2 ::2 ]):
50
50
label = int (label )
51
51
obs = [o .strip () for o in obs_str .split ('\n ' )]
52
- obs = list (filter (None , obs )) # drop empty obs
52
+ obs = list (filter (None , obs )) # drop empty obs
53
53
if len (combined_trace_lines ) > 0 and combined_trace_lines [- 1 ][0 ] == label :
54
- combined_trace_lines [- 1 ] = (label , combined_trace_lines [- 1 ][1 ] + obs ) # append obs to last line
54
+ # append obs to last line
55
+ combined_trace_lines [- 1 ] = (label ,
56
+ combined_trace_lines [- 1 ][1 ] + obs )
55
57
else :
56
58
combined_trace_lines .append ((label , obs ))
57
59
@@ -62,8 +64,10 @@ def parse_trace(src, program):
62
64
for label , obs in combined_trace_lines :
63
65
def filter_obs (obs , matcher ):
64
66
return [ob for ob in obs if matcher .match (ob )]
67
+
65
68
def extract_obs_info (obs , matcher , group ):
66
- res = [int (matcher .match (ob ).group (group )) for ob in filter_obs (obs , matcher )]
69
+ res = [int (matcher .match (ob ).group (group ))
70
+ for ob in filter_obs (obs , matcher )]
67
71
return list_without_duplicates (res )
68
72
69
73
targets = program [label ]['targets' ]
@@ -72,7 +76,7 @@ def extract_obs_info(obs, matcher, group):
72
76
if pc_targets :
73
77
assert (len (pc_targets ) == 1 )
74
78
to = pc_targets [0 ]
75
- elif len (targets ) == 0 : # end
79
+ elif len (targets ) == 0 : # end
76
80
to = label
77
81
else :
78
82
assert (len (targets ) == 1 )
@@ -177,7 +181,8 @@ def main(inputfile, outputfile, show_inital_final_config):
177
181
sys .exit (- 3 )
178
182
179
183
graph = Digraph (format = 'svg' )
180
- graph .node_attr .update (style = 'filled' , fontcolor = '#4a4a4a' , fillcolor = '#e6e6e6' , color = '#4a4a4a' )
184
+ graph .node_attr .update (style = 'filled' , fontcolor = '#4a4a4a' ,
185
+ fillcolor = '#e6e6e6' , color = '#4a4a4a' )
181
186
182
187
# cfg
183
188
program = spectector_out ['program' ]
@@ -186,7 +191,8 @@ def main(inputfile, outputfile, show_inital_final_config):
186
191
graph .node (str (label ), label = '{}: {}' .format (label , instr ['text' ]),
187
192
shape = 'doubleoctagon' if is_end else 'rect' )
188
193
for target in instr ['targets' ]:
189
- graph .edge (str (label ), str (target ), color = '#a2a2a2' , penwidth = '1.5' )
194
+ graph .edge (str (label ), str (target ),
195
+ color = '#a2a2a2' , penwidth = '1.5' )
190
196
191
197
# trace
192
198
trace = spectector_out ['trace' ]
@@ -195,7 +201,8 @@ def main(inputfile, outputfile, show_inital_final_config):
195
201
label = '@{}\n {}' .format (entry ['t' ], '\n ' .join (entry ['obs' ])))
196
202
197
203
# transactions
198
- transaction_colors = ['#00934a' , '#4363d8' , '#F96714' , '#2A4B7C' , '#CE5B78' , '#800000' , '#797B3A' ]
204
+ transaction_colors = ['#00934a' , '#4363d8' , '#F96714' ,
205
+ '#2A4B7C' , '#CE5B78' , '#800000' , '#797B3A' ]
199
206
for entry in trace :
200
207
for tid in entry ['running_transactions' ]:
201
208
color = transaction_colors [tid % len (transaction_colors )]
@@ -209,7 +216,8 @@ def annotate_node_with_config(node_id, conf, draw_on_top=False):
209
216
label = 'mem: {}\n reg: {}' .format (str (conf ['m' ]), str (conf ['a' ])))
210
217
f = conf_node_id if draw_on_top else node_id
211
218
t = node_id if draw_on_top else conf_node_id
212
- graph .edge (f , t , color = 'grey' , penwidth = '2.0' , style = 'dotted' , arrowhead = 'none' )
219
+ graph .edge (f , t , color = 'grey' , penwidth = '2.0' ,
220
+ style = 'dotted' , arrowhead = 'none' )
213
221
214
222
if show_inital_final_config :
215
223
annotate_node_with_config (
@@ -223,7 +231,8 @@ def annotate_node_with_config(node_id, conf, draw_on_top=False):
223
231
if __name__ == '__main__' :
224
232
def print_help_and_exit ():
225
233
print ('Tool for visualizing Spectector traces.' )
226
- print ('\n USAGE:\n {} [-i <inputfile>] -o <outputfile>' .format (sys .argv [0 ]))
234
+ print (
235
+ '\n USAGE:\n {} [-i <inputfile>] -o <outputfile>' .format (sys .argv [0 ]))
227
236
options = [
228
237
'-i, --in\t Input text-file containing the output of Spectector (will read from stdin if not set)' ,
229
238
'-o, --out\t Output file containing the graph (will create SVG- and DOT-files)' ,
0 commit comments