Skip to content

Commit

Permalink
Plot
Browse files Browse the repository at this point in the history
  • Loading branch information
SoveraNia committed Jan 11, 2020
1 parent 647b671 commit fa43967
Show file tree
Hide file tree
Showing 23 changed files with 70 additions and 10 deletions.
Binary file removed analyze/__pycache__/analyze_corpus.cpython-35.pyc
Binary file not shown.
Binary file removed analyze/__pycache__/analyze_coverage.cpython-35.pyc
Binary file not shown.
Binary file removed analyze/__pycache__/analyze_debug.cpython-35.pyc
Binary file not shown.
Binary file removed analyze/__pycache__/analyze_mab.cpython-35.pyc
Binary file not shown.
Binary file not shown.
Binary file removed analyze/__pycache__/analyze_programs.cpython-35.pyc
Binary file not shown.
Binary file removed analyze/__pycache__/analyze_seeds.cpython-35.pyc
Binary file not shown.
Binary file removed analyze/__pycache__/analyze_signal.cpython-35.pyc
Binary file not shown.
Binary file removed analyze/__pycache__/analyze_triage.cpython-35.pyc
Binary file not shown.
Binary file removed analyze/__pycache__/analyze_work.cpython-35.pyc
Binary file not shown.
Binary file removed analyze/__pycache__/plot.cpython-35.pyc
Binary file not shown.
Binary file removed analyze/__pycache__/prog.cpython-35.pyc
Binary file not shown.
Binary file removed analyze/__pycache__/syscalls.cpython-35.pyc
Binary file not shown.
Binary file removed analyze/__pycache__/utils.cpython-35.pyc
Binary file not shown.
5 changes: 5 additions & 0 deletions analyze/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from analyze_mab import plotMAB
from analyze_seeds import plotSeeds
from analyze_mutationtree import plotMutationTree
from analyze_crashes import plotCrashes
from plot import plot

if __name__ == "__main__":
Expand All @@ -45,6 +46,8 @@
help="Analyze Mutation Tree", default=False)
parser.add_option("-s", "--seed", dest="analyze_seed", action="store_true",
help="Analyze Seed", default=False)
parser.add_option("-C", "--crash", dest="analyze_crashes", action="store_true",
help="Analyze Crashes", default=False)

(options, args) = parser.parse_args()
blacklist = options.blacklist.split(',') if len(options.blacklist) > 0 else []
Expand All @@ -70,6 +73,8 @@
plotPrograms(tests)
if options.analyze_seed or options.analyze_all:
plotSeeds(tests)
if options.analyze_crashes or options.analyze_all:
plotCrashes(tests)
if options.analyze_mutationtree or options.analyze_all:
plotMutationTree(tests)
#plotSignal(tests)
Expand Down
54 changes: 54 additions & 0 deletions analyze/analyze_crashes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import sys
import os
import copy
import glob
import traceback
import simplejson as json
import matplotlib.pyplot as plt
from matplotlib.collections import PatchCollection
from matplotlib.patches import Rectangle
import numpy as np
import pygraphviz as PG

from plot import plot, plotBar, plotCDF, plotBar1
from utils import loadDataCached, getTestParams

def __processCrashLog(fn):
ret = {
"prog": None,
"description": "",
"ts": 0
}
f = open(fn)
for line in f:
line = line.strip('\n').strip();
f.close();

def __processTest(test):
ret = []
workdir = 'workdir_' + test
if not os.path.isdir(workdir):
return None
flist = glob.glob()
for line in f:
line = line.strip('\n').strip();
f.close();
return p_all, p_generated, p_corpus, p_triage, ret;

def plotCrashes(tests=["KCOV", "RAMINDEX"]):
datas = {}
for test in tests:
name, module, run = getTestParams(test)
name = name + '_' + module

for test in tests:
name, module, run = getTestParams(test)
name = name + '_' + module
print("Plotting crashes for %s" % test)
try:
# p_all, p_generated, p_corpus, p_triage, __data = __processTest(test);
__data = loadDataCached('crashes_%s.cache', test, __processTest);
except:
traceback.print_exc()
continue;

17 changes: 8 additions & 9 deletions analyze/analyze_programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
from utils import loadDataCached, getTestParams

class Program:
def __init__(self, sig, data):
def __init__(self, sig):
self.id = 0;
self.ts = 0;
self.executed = True;
self.inCorpus = False;
self.corpusSource = None;
self.sig = sig
self.data = data;
self.size = len(data.strip().split('\n'))
self.size = 0
self.coverage = []
self.coverageCorpus = []
self.minimize = None
Expand All @@ -37,7 +36,7 @@ def _asdict(self):
return self.__dict__
@staticmethod
def FromDict(d):
ret = Program('','')
ret = Program('')
for k in d:
ret.__setattr__(k, d[k])
return ret
Expand Down Expand Up @@ -141,7 +140,7 @@ def __processTest(test):
elif (line == '<' or line == '<<<') and status_program == True:
status_program = False
if status != "MINIMIZE_FROM" and status != "MUTATE_FROM":
p_current = Program(sig=sig_current, data=data_current)
p_current = Program(sig=sig_current)
p_current.ts = (ts_cur - ts_bgn) / 1000000000
p_current.id = len(p_all)
p_all.append(p_current)
Expand All @@ -156,7 +155,7 @@ def __processTest(test):
elif status == "MINIMIZE_FROM":
sig_from = sig_current
if not sig_from in p_triage:
p_current = Program(sig=sig_current, data=data_current)
p_current = Program(sig=sig_current)
p_current.executed = False
p_current.ts = (ts_cur - ts_bgn) / 1000000000
p_current.id = len(p_all)
Expand Down Expand Up @@ -189,7 +188,7 @@ def __processTest(test):
if not sig_from in p_corpus:
print("This should not happen!!!!")
print(sig_from)
p_current = Program(sig=sig_current, data=data_current)
p_current = Program(sig=sig_current)
p_current.executed = False
p_current.ts = (ts_cur - ts_bgn) / 1000000000
p_current.id = len(p_all)
Expand Down Expand Up @@ -538,10 +537,10 @@ def plotPrograms(tests=["KCOV", "RAMINDEX"]):
tmp = {}
for name in datas_seedpower:
plotCDF(datas_mutls[name], xlabel="# Mutations", ylabel="CDF", title="", outfile="mutations_lifespan_%s.png" % name, xrange=(-25, 425));
plotCDF(datas_seedpower[name], xlabel="Coverage", ylabel="CDF", title="", outfile="seed_power_%s.png" % name, xrange=(-0.5, 10005), xlogscale=True);
plotCDF(datas_seedpower[name], xlabel="Coverage", ylabel="CDF", title="", outfile="seed_power_%s.png" % name, xrange=(-0.5, 1005), xlogscale=True);
plotCDF(datas_seedpower_avg[name], xlabel="Coverage", ylabel="CDF", title="", outfile="seed_power_avg_%s.png" % name, xrange=(-0.5,10), xlogscale=False);
tmp[name] = datas_seedpower[name]["All"]
plotCDF(tmp, xlabel="Coverage", ylabel="CDF", title="", outfile="seed_power_all.png", xrange=(-0.5, 10005), xlogscale=True);
plotCDF(tmp, xlabel="Coverage", ylabel="CDF", title="", outfile="seed_power_all.png", xrange=(-0.5, 1005), xlogscale=True);
# Seed power sum
#for name in datas_seedpower_sum:
# for job in datas_seedpower_sum[name]:
Expand Down
4 changes: 3 additions & 1 deletion analyze/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

linecolors = ["r", "g", "b", "black"]
markers = ['s', 'o', '^', 'v', '+', 'x', 'd']
fillcolors = ["tab:red", "tab:olive", "tab:blue", "tab:cyan"]
patterns = ['--', 'xx', '++', '\\\\', '**', '..']
linestyles = ["-",
(0, (1, 3)),
(0, (5, 5)),
Expand Down Expand Up @@ -120,7 +122,7 @@ def plotBar1(data, width=1, xlabel="", ylabel="", title="", outfile="out.png",
y_mean.append(np.mean(data[test][key]))
y_std.append(np.std(data[test][key]))
tlabel = test.replace("KCOV", "").replace('_', ' ').strip()
ax.bar(x,y_mean, yerr=y_std, width=bar_width, label=tlabel, color=linecolors[idx%len(linecolors)], edgecolor=linecolors[idx%len(linecolors)]);
ax.bar(x,y_mean, yerr=y_std, width=bar_width, label=tlabel, color=fillcolors[idx%len(fillcolors)], edgecolor='black', hatch=patterns[idx % len(patterns)]);
idx += 1;
ax.grid();
ax.set_xticks([(width * i + len(data.keys()) * bar_width / 2) for i in range(len(labels))])
Expand Down
Binary file removed python/__pycache__/__init__.cpython-35.pyc
Binary file not shown.
Binary file removed python/__pycache__/adb.cpython-35.pyc
Binary file not shown.
Binary file removed python/__pycache__/modules.cpython-35.pyc
Binary file not shown.
Binary file removed python/__pycache__/qemu.cpython-35.pyc
Binary file not shown.
Binary file removed python/__pycache__/utils.cpython-35.pyc
Binary file not shown.

0 comments on commit fa43967

Please sign in to comment.