aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/Core/ExecutionState.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Core/ExecutionState.cpp')
-rw-r--r--lib/Core/ExecutionState.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/Core/ExecutionState.cpp b/lib/Core/ExecutionState.cpp
index 57f9bca9..4362b78f 100644
--- a/lib/Core/ExecutionState.cpp
+++ b/lib/Core/ExecutionState.cpp
@@ -22,6 +22,7 @@
#include "llvm/Support/CommandLine.h"
#include <iostream>
+#include <iomanip>
#include <cassert>
#include <map>
#include <set>
@@ -302,3 +303,35 @@ bool ExecutionState::merge(const ExecutionState &b) {
return true;
}
+
+void ExecutionState::dumpStack(std::ostream &out) const {
+ unsigned idx = 0;
+ const KInstruction *target = prevPC;
+ for (ExecutionState::stack_ty::const_reverse_iterator
+ it = stack.rbegin(), ie = stack.rend();
+ it != ie; ++it) {
+ const StackFrame &sf = *it;
+ Function *f = sf.kf->function;
+ const InstructionInfo &ii = *target->info;
+ out << "\t#" << idx++
+ << " " << std::setw(8) << std::setfill('0') << ii.assemblyLine
+ << " in " << f->getNameStr() << " (";
+ // Yawn, we could go up and print varargs if we wanted to.
+ unsigned index = 0;
+ for (Function::arg_iterator ai = f->arg_begin(), ae = f->arg_end();
+ ai != ae; ++ai) {
+ if (ai!=f->arg_begin()) out << ", ";
+
+ out << ai->getNameStr();
+ // XXX should go through function
+ ref<Expr> value = sf.locals[sf.kf->getArgRegister(index++)].value;
+ if (isa<ConstantExpr>(value))
+ out << "=" << value;
+ }
+ out << ")";
+ if (ii.file != "")
+ out << " at " << ii.file << ":" << ii.line;
+ out << "\n";
+ target = sf.caller;
+ }
+}