ExecutionContext &SF = ECStack.back(); // Current stack frame
Instruction *I = *SF.CurInst++; // Increment before execute
+ if (Trace)
+ cout << "Run:" << I;
+
if (I->isBinaryOp()) {
executeBinaryInst((BinaryOperator*)I, SF);
} else {
Module *CurMod; // The current Module being executed (0 if none)
int ExitCode; // The exit code to be returned by the lli util
bool Profile; // Profiling enabled?
+ bool Trace; // Tracing enabled?
int CurFrame; // The current stack frame being inspected
// The runtime stack of executing code. The top of the stack is the current
// enableProfiling() - Turn profiling on, clear stats?
void enableProfiling() { Profile = true; }
+ void enableTracing() { Trace = true; }
void initializeExecutionEngine();
void handleUserInput();
Print, Info, List, StackTrace, Up, Down, // Inspection
Next, Step, Run, Finish, Call, // Control flow changes
Break, Watch, // Debugging
- Load, Flush
+ Load, Flush,
+ TraceOpt, ProfileOpt // Toggle features
};
// CommandTable - Build a lookup table for the commands available to the user...
{ "load" , Load },
{ "flush" , Flush },
+
+ { "trace" , TraceOpt },
+ { "profile" , ProfileOpt },
};
static CommandTableElement *CommandTableEnd =
CommandTable+sizeof(CommandTable)/sizeof(CommandTable[0]);
finish(); // Run until it's complete
break;
+ case TraceOpt:
+ Trace = !Trace;
+ cout << "Tracing " << (Trace ? "enabled\n" : "disabled\n");
+ break;
+
+ case ProfileOpt:
+ Profile = !Profile;
+ cout << "Profiling " << (Trace ? "enabled\n" : "disabled\n");
+ break;
+
default:
cout << "Command '" << Command << "' unimplemented!\n";
break;
cl::String MainFunction ("f" , "Function to execute", cl::NoFlags, "main");
cl::Flag DebugMode ("debug" , "Start program in debugger");
cl::Alias DebugModeA ("d" , "Alias for -debug", cl::NoFlags, DebugMode);
+cl::Flag TraceMode ("trace" , "Enable Tracing");
cl::Flag ProfileMode ("profile", "Enable Profiling [unimp]");
+
//===----------------------------------------------------------------------===//
// Interpreter ctor - Initialize stuff
//
-Interpreter::Interpreter() : ExitCode(0), Profile(ProfileMode), CurFrame(-1) {
+Interpreter::Interpreter() : ExitCode(0), Profile(ProfileMode),
+ Trace(TraceMode), CurFrame(-1) {
CurMod = 0;
loadModule(InputArgv.size() ? InputArgv[0] : "");
// If running with the profiler, enable it now...
if (ProfileMode) I.enableProfiling();
+ if (TraceMode) I.enableTracing();
// Start interpreter into the main function...
//