summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-10-27 08:43:52 +0000
committerChris Lattner <sabre@nondot.org>2001-10-27 08:43:52 +0000
commit009f8108bcde4d81602fe9556947ff0486983682 (patch)
tree66813e43b1b3ece0a48c2ccecf8ae243f1b852a6 /llvm/lib/ExecutionEngine
parent0b00b31c78d4131d3cbcb98066375f7901602b2a (diff)
downloadbcm5719-llvm-009f8108bcde4d81602fe9556947ff0486983682.tar.gz
bcm5719-llvm-009f8108bcde4d81602fe9556947ff0486983682.zip
Implement a -trace command line option and a trace option in the interpreter.
llvm-svn: 989
Diffstat (limited to 'llvm/lib/ExecutionEngine')
-rw-r--r--llvm/lib/ExecutionEngine/Interpreter/Execution.cpp3
-rw-r--r--llvm/lib/ExecutionEngine/Interpreter/Interpreter.h2
-rw-r--r--llvm/lib/ExecutionEngine/Interpreter/UserInput.cpp16
3 files changed, 20 insertions, 1 deletions
diff --git a/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp b/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
index a7ded5b705b..1d7ec7aa8ee 100644
--- a/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
+++ b/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
@@ -834,6 +834,9 @@ bool Interpreter::executeInstruction() {
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 {
diff --git a/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h b/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h
index 16cc569ad0f..2d262aedc5d 100644
--- a/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h
+++ b/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h
@@ -56,6 +56,7 @@ class Interpreter {
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
@@ -72,6 +73,7 @@ public:
// enableProfiling() - Turn profiling on, clear stats?
void enableProfiling() { Profile = true; }
+ void enableTracing() { Trace = true; }
void initializeExecutionEngine();
void handleUserInput();
diff --git a/llvm/lib/ExecutionEngine/Interpreter/UserInput.cpp b/llvm/lib/ExecutionEngine/Interpreter/UserInput.cpp
index a24b3117506..97bba9cf7dc 100644
--- a/llvm/lib/ExecutionEngine/Interpreter/UserInput.cpp
+++ b/llvm/lib/ExecutionEngine/Interpreter/UserInput.cpp
@@ -16,7 +16,8 @@ enum CommandID {
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...
@@ -52,6 +53,9 @@ static struct CommandTableElement {
{ "load" , Load },
{ "flush" , Flush },
+
+ { "trace" , TraceOpt },
+ { "profile" , ProfileOpt },
};
static CommandTableElement *CommandTableEnd =
CommandTable+sizeof(CommandTable)/sizeof(CommandTable[0]);
@@ -118,6 +122,16 @@ void Interpreter::handleUserInput() {
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;
OpenPOWER on IntegriCloud