From b8602f2475c8310b09ef2a003f91313bde094324 Mon Sep 17 00:00:00 2001 From: "beard%netscape.com" Date: Fri, 28 Apr 2000 05:44:38 +0000 Subject: [PATCH] tracing now prints instruction operands. git-svn-id: svn://10.0.0.236/trunk@67479 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/js2/js2.cpp | 15 +++++++++++++-- mozilla/js2/tests/cpp/js2_shell.cpp | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/mozilla/js/js2/js2.cpp b/mozilla/js/js2/js2.cpp index daae0d84b8c..feaa23967d8 100644 --- a/mozilla/js/js2/js2.cpp +++ b/mozilla/js/js2/js2.cpp @@ -298,14 +298,25 @@ static float64 testFunctionCall(World &world, float64 n) return result.f64; } +/** + * Poor man's instruction tracing facility. + */ class Tracer : public Context::Listener { typedef InstructionStream::difference_type InstructionOffset; void listen(Context* /*context*/, InstructionIterator pc, - JSValues* /*registers*/, ICodeModule* iCode) + JSValues* registers, ICodeModule* iCode) { InstructionOffset offset = (pc - iCode->its_iCode->begin()); printFormat(stdOut, "%04X: ", offset); - stdOut << **pc << '\n'; + Instruction* i = *pc; + stdOut << *i; + if (i->count() > 0) { + stdOut << " ["; + i->printOperands(stdOut, *registers); + stdOut << "]\n"; + } else { + stdOut << '\n'; + } } }; diff --git a/mozilla/js2/tests/cpp/js2_shell.cpp b/mozilla/js2/tests/cpp/js2_shell.cpp index daae0d84b8c..feaa23967d8 100644 --- a/mozilla/js2/tests/cpp/js2_shell.cpp +++ b/mozilla/js2/tests/cpp/js2_shell.cpp @@ -298,14 +298,25 @@ static float64 testFunctionCall(World &world, float64 n) return result.f64; } +/** + * Poor man's instruction tracing facility. + */ class Tracer : public Context::Listener { typedef InstructionStream::difference_type InstructionOffset; void listen(Context* /*context*/, InstructionIterator pc, - JSValues* /*registers*/, ICodeModule* iCode) + JSValues* registers, ICodeModule* iCode) { InstructionOffset offset = (pc - iCode->its_iCode->begin()); printFormat(stdOut, "%04X: ", offset); - stdOut << **pc << '\n'; + Instruction* i = *pc; + stdOut << *i; + if (i->count() > 0) { + stdOut << " ["; + i->printOperands(stdOut, *registers); + stdOut << "]\n"; + } else { + stdOut << '\n'; + } } };