Skip to content

Commit

Permalink
Fix some issues in the handler dependency tracker.
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSpencer committed Jun 24, 2014
1 parent fe0c620 commit bc68293
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
25 changes: 20 additions & 5 deletions artemis-code/src/concolic/handlerdependencytracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ namespace artemis
{

HandlerDependencyTracker::HandlerDependencyTracker(bool enabled) :
mEnabled(enabled),
mCurrentEvent("[none]")
{}
mEnabled(enabled)
{
mCurrentEvent = mNoEventLabel;
}

void HandlerDependencyTracker::writeGraph()
{
Expand All @@ -50,14 +51,28 @@ void HandlerDependencyTracker::writeGraph()
idx++;
}
// Check for any which were not listed in the event sequence...
QSet<QString> extras;
foreach(EdgeDescriptor edge, mEdgeCounts.keys()) {
assert(mEvents.contains(edge.first.first) || edge.first.first == "[none]");
assert(mEvents.contains(edge.first.first) || edge.first.first == mNoEventLabel);
if(!mEvents.contains(edge.first.second)) {
names.insert(edge.first.second, QString("unknown_%1").arg(idx));
graph += QString(" %1 [label = \"%2\", fillcolor = \"lightpink\"];\n").arg(names[edge.first.second], edge.first.second);
idx++;
extras.insert(edge.first.second);
}
}
// Sanity check for any variable reads not coming from a known handler.
QSet<QString> observed;
foreach(EdgeDescriptor edge, mEdgeCounts.keys()) {
observed.insert(edge.first.first);
}
if(observed.contains(mNoEventLabel)) {
names.insert(mNoEventLabel, QString("no_source"));
graph += QString(" no_source [label = \"%1\", fillcolor = \"lightpink\"];\n").arg(mNoEventLabel);
mEvents.prepend(mNoEventLabel);
}
observed.subtract(extras);
assert(mEvents.toSet().contains(observed));

graph += "\n";

Expand Down Expand Up @@ -101,7 +116,7 @@ void HandlerDependencyTracker::newIteration()
// Reset mEvents, so we only keep the version from the latest run.
// In fact it should be the same on every iteration (except the initial load...).
mEvents.clear();
mCurrentEvent = "[none]";
mCurrentEvent = mNoEventLabel;
}

void HandlerDependencyTracker::slJavascriptSymbolicFieldRead(QString variable, bool isSymbolic)
Expand Down
2 changes: 2 additions & 0 deletions artemis-code/src/concolic/handlerdependencytracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public slots:
QString mCurrentEvent;
QList<QString> mEvents;

const QString mNoEventLabel = "[none]";

typedef QPair<QPair<QString, QString>, bool> EdgeDescriptor;
QMap<EdgeDescriptor, uint> mEdgeCounts;
};
Expand Down

0 comments on commit bc68293

Please sign in to comment.