aboutsummaryrefslogtreecommitdiffhomepage
path: root/utils/hacks/TreeGraphs/DumpTreeStream.py
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-05-02 17:59:13 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-05-02 17:59:13 +0000
commitf4cdc443fb86f715ab93f3528aff23452a5bb3a3 (patch)
treeffab5077611d32a8b95c9d9b4f96b47703190e82 /utils/hacks/TreeGraphs/DumpTreeStream.py
parentbae2fa50234b0a575a18a119019e5d96f7ff7ecf (diff)
downloadklee-f4cdc443fb86f715ab93f3528aff23452a5bb3a3.tar.gz
Add a little hack for visualizing KLEE branching.
- This consumes the treestream files produced with --write-paths or --write-sym-paths, and renders out the tree in a very ad-hoc funky way. Your mileage may vary! :) Example image: http://klee.llvm.org/data/treegraph_example.jpg Example movie: http://klee.llvm.org/data/treegraph_example.avi git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@102869 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/hacks/TreeGraphs/DumpTreeStream.py')
-rw-r--r--utils/hacks/TreeGraphs/DumpTreeStream.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/utils/hacks/TreeGraphs/DumpTreeStream.py b/utils/hacks/TreeGraphs/DumpTreeStream.py
new file mode 100644
index 00000000..b3614c7c
--- /dev/null
+++ b/utils/hacks/TreeGraphs/DumpTreeStream.py
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+
+from __future__ import division
+
+import sys, os, struct
+
+def getTreeStream(path):
+ data = open(path,'rb').read()
+ paths = { 0 : ''}
+ pos = 0
+ while pos<len(data):
+ id,tag = struct.unpack('II', data[pos:pos+8])
+ pos += 8
+ if tag&(1<<31):
+ child = tag ^ (1<<31)
+ paths[child] = paths[id]
+ else:
+ size = tag
+ paths[id] += data[pos:pos+size]
+ pos += size
+ if pos!=len(data):
+ raise IOError,'bad position'
+ return paths
+
+def writeTreeStream(path, output):
+ paths = getTreeSTream(path)
+ print 'Writing %d paths'%len(paths)
+ for i,data in paths.items():
+ if i!=0:
+ f = open('%s%04d'%(output,i), 'wb')
+ f.write(data)
+ f.close()
+
+def main(args):
+ from optparse import OptionParser
+ op = OptionParser("usage: %prog input outputPrefix")
+ opts,args = op.parse_args()
+
+ input,outputPrefix = args
+
+ f = open(input,'rb')
+ data = f.read()
+ f.close()
+ writeTreeStream(data, outputPrefix)
+
+if __name__=='__main__':
+ main(sys.argv)
+