Browse files

add vmfPrintTrace method for dumping traces to a specific stream

  • Loading branch information...
1 parent 83670d1 commit dca75df926e48f2a6f3b5ab2c3077d7c21696054 @dicej dicej committed Apr 9, 2013
Showing with 19 additions and 9 deletions.
  1. +3 −0 src/avian/machine.h
  2. +16 −9 src/machine.cpp
View
3 src/avian/machine.h
@@ -2699,6 +2699,9 @@ popResources(Thread* t);
JNIEXPORT void
vmPrintTrace(vm::Thread* t);
+JNIEXPORT void
+vmfPrintTrace(vm::Thread* t, FILE* out);
+
namespace vm {
void
View
25 src/machine.cpp
@@ -5171,11 +5171,11 @@ noop()
// for debugging
JNIEXPORT void
-vmPrintTrace(Thread* t)
+vmfPrintTrace(Thread* t, FILE* out)
{
class Visitor: public Processor::StackVisitor {
public:
- Visitor(Thread* t): t(t) { }
+ Visitor(Thread* t, FILE* out): t(t), out(out) { }
virtual bool visit(Processor::StackWalker* walker) {
const int8_t* class_ = &byteArrayBody
@@ -5185,30 +5185,37 @@ vmPrintTrace(Thread* t)
int line = t->m->processor->lineNumber
(t, walker->method(), walker->ip());
- fprintf(stderr, " at %s.%s ", class_, method);
+ fprintf(out, " at %s.%s ", class_, method);
switch (line) {
case NativeLine:
- fprintf(stderr, "(native)\n");
+ fprintf(out, "(native)\n");
break;
case UnknownLine:
- fprintf(stderr, "(unknown line)\n");
+ fprintf(out, "(unknown line)\n");
break;
default:
- fprintf(stderr, "(line %d)\n", line);
+ fprintf(out, "(line %d)\n", line);
}
return true;
}
Thread* t;
- } v(t);
+ FILE* out;
+ } v(t, out);
- fprintf(stderr, "debug trace for thread %p\n", t);
+ fprintf(out, "debug trace for thread %p\n", t);
t->m->processor->walkStack(t, &v);
- fflush(stderr);
+ fflush(out);
+}
+
+JNIEXPORT void
+vmPrintTrace(Thread* t)
+{
+ vmfPrintTrace(t, stderr);
}
// also for debugging

0 comments on commit dca75df

Please sign in to comment.