diff options
author | Greg Clayton <gclayton@apple.com> | 2013-03-22 02:31:35 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2013-03-22 02:31:35 +0000 |
commit | 880afc5728954e36d00e42d7961897814e7ae028 (patch) | |
tree | 6f81faa725d1f4e99229d4ba8a64f8d73f0c0d6a /lldb/tools/lldb-perf/lib/TestCase.cpp | |
parent | 0a9875abfe7c7b0eefe8da92766066043c2fa05a (diff) | |
download | bcm5719-llvm-880afc5728954e36d00e42d7961897814e7ae028.tar.gz bcm5719-llvm-880afc5728954e36d00e42d7961897814e7ae028.zip |
Much more cleanup on the performance testing infrastructure:
- Added new abtract Results class to keep CoreFoundation out of the tests. There are many subclasses for different settings:
Results::Result::Dictionary
Results::Result::Array
Results::Result::Unsigned
Results::Result::Double
Results::Result::String
- Gauge<T> can now write themselves out via a templatized write to results function:
template <class T>
Results::ResultSP GetResult (const char *description, T value);
- There are four specializations of this so far:
template <>
Results::ResultSP GetResult (const char *description, double value);
template <>
Results::ResultSP GetResult (const char *description, uint64_t value);
template <>
Results::ResultSP GetResult (const char *description, std::string value);
template <>
Results::ResultSP GetResult (const char *description, MemoryStats value);
- Don't emit the virtual memory reading from the task info call as it really doesn't mean much as it includes way too much (shared cache + other stuff we don't have control over)
- Fixed other test cases to build correctly and use the new classes
llvm-svn: 177696
Diffstat (limited to 'lldb/tools/lldb-perf/lib/TestCase.cpp')
-rw-r--r-- | lldb/tools/lldb-perf/lib/TestCase.cpp | 274 |
1 files changed, 155 insertions, 119 deletions
diff --git a/lldb/tools/lldb-perf/lib/TestCase.cpp b/lldb/tools/lldb-perf/lib/TestCase.cpp index 4f5c00c6204..7a7c48ad637 100644 --- a/lldb/tools/lldb-perf/lib/TestCase.cpp +++ b/lldb/tools/lldb-perf/lib/TestCase.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "TestCase.h" +#include "Results.h" #include "Xcode.h" using namespace lldb_perf; @@ -63,134 +64,167 @@ TestCase::GetVerbose () void TestCase::Loop () { - SBEvent evt; while (true) { - m_listener.WaitForEvent (UINT32_MAX,evt); - StateType state = SBProcess::GetStateFromEvent (evt); - if (m_verbose) - printf("event = %s\n",SBDebugger::StateAsCString(state)); - if (SBProcess::GetRestartedFromEvent(evt)) - continue; - switch (state) - { - case eStateInvalid: - case eStateDetached: - case eStateCrashed: - case eStateUnloaded: - break; - case eStateExited: - return; - case eStateConnected: - case eStateAttaching: - case eStateLaunching: - case eStateRunning: - case eStateStepping: - continue; - case eStateStopped: - case eStateSuspended: - { - bool fatal = false; - bool selected_thread = false; - for (auto thread_index = 0; thread_index < m_process.GetNumThreads(); thread_index++) - { - SBThread thread(m_process.GetThreadAtIndex(thread_index)); - SBFrame frame(thread.GetFrameAtIndex(0)); - bool select_thread = false; - StopReason stop_reason = thread.GetStopReason(); - if (m_verbose) printf("tid = 0x%llx pc = 0x%llx ",thread.GetThreadID(),frame.GetPC()); - switch (stop_reason) - { - case eStopReasonNone: - if (m_verbose) printf("none\n"); - break; - - case eStopReasonTrace: - select_thread = true; - if (m_verbose) printf("trace\n"); - break; - - case eStopReasonPlanComplete: - select_thread = true; - if (m_verbose) printf("plan complete\n"); - break; - case eStopReasonThreadExiting: - if (m_verbose) printf("thread exiting\n"); - break; - case eStopReasonExec: - if (m_verbose) printf("exec\n"); - break; - case eStopReasonInvalid: - if (m_verbose) printf("invalid\n"); - break; - case eStopReasonException: - select_thread = true; - if (m_verbose) printf("exception\n"); - fatal = true; - break; - case eStopReasonBreakpoint: - select_thread = true; - if (m_verbose) printf("breakpoint id = %lld.%lld\n",thread.GetStopReasonDataAtIndex(0),thread.GetStopReasonDataAtIndex(1)); - break; - case eStopReasonWatchpoint: - select_thread = true; - if (m_verbose) printf("watchpoint id = %lld\n",thread.GetStopReasonDataAtIndex(0)); - break; - case eStopReasonSignal: - select_thread = true; - if (m_verbose) printf("signal %d\n",(int)thread.GetStopReasonDataAtIndex(0)); - break; - } - if (select_thread && !selected_thread) + bool call_test_step = false; + if (m_process.IsValid()) + { + SBEvent evt; + m_listener.WaitForEvent (UINT32_MAX, evt); + StateType state = SBProcess::GetStateFromEvent (evt); + if (m_verbose) + printf("event = %s\n",SBDebugger::StateAsCString(state)); + if (SBProcess::GetRestartedFromEvent(evt)) + continue; + switch (state) + { + case eStateInvalid: + case eStateDetached: + case eStateCrashed: + case eStateUnloaded: + break; + case eStateExited: + return; + case eStateConnected: + case eStateAttaching: + case eStateLaunching: + case eStateRunning: + case eStateStepping: + continue; + case eStateStopped: + case eStateSuspended: + { + call_test_step = true; + bool fatal = false; + bool selected_thread = false; + for (auto thread_index = 0; thread_index < m_process.GetNumThreads(); thread_index++) { - m_thread = thread; - selected_thread = m_process.SetSelectedThread(thread); - } - } - if (fatal) - { - if (m_verbose) Xcode::RunCommand(m_debugger,"bt all",true); - exit(1); - } - if (m_verbose) - printf("RUNNING STEP %d\n",m_step); - ActionWanted action; - TestStep(m_step, action); - m_step++; - SBError err; - switch (action.type) - { - case ActionWanted::Type::eContinue: - err = m_process.Continue(); - break; - case ActionWanted::Type::eStepOut: - if (action.thread.IsValid() == false) + SBThread thread(m_process.GetThreadAtIndex(thread_index)); + SBFrame frame(thread.GetFrameAtIndex(0)); + bool select_thread = false; + StopReason stop_reason = thread.GetStopReason(); + if (m_verbose) printf("tid = 0x%llx pc = 0x%llx ",thread.GetThreadID(),frame.GetPC()); + switch (stop_reason) { - if (m_verbose) Xcode::RunCommand(m_debugger,"bt all",true); - if (m_verbose) printf("[finish invalid] I am gonna die at step %d\n",m_step); - exit(501); + case eStopReasonNone: + if (m_verbose) + printf("none\n"); + break; + + case eStopReasonTrace: + select_thread = true; + if (m_verbose) + printf("trace\n"); + break; + + case eStopReasonPlanComplete: + select_thread = true; + if (m_verbose) + printf("plan complete\n"); + break; + case eStopReasonThreadExiting: + if (m_verbose) + printf("thread exiting\n"); + break; + case eStopReasonExec: + if (m_verbose) + printf("exec\n"); + break; + case eStopReasonInvalid: + if (m_verbose) + printf("invalid\n"); + break; + case eStopReasonException: + select_thread = true; + if (m_verbose) + printf("exception\n"); + fatal = true; + break; + case eStopReasonBreakpoint: + select_thread = true; + if (m_verbose) + printf("breakpoint id = %lld.%lld\n",thread.GetStopReasonDataAtIndex(0),thread.GetStopReasonDataAtIndex(1)); + break; + case eStopReasonWatchpoint: + select_thread = true; + if (m_verbose) + printf("watchpoint id = %lld\n",thread.GetStopReasonDataAtIndex(0)); + break; + case eStopReasonSignal: + select_thread = true; + if (m_verbose) + printf("signal %d\n",(int)thread.GetStopReasonDataAtIndex(0)); + break; } - m_process.SetSelectedThread(action.thread); - action.thread.StepOut(); - break; - case ActionWanted::Type::eNext: - if (action.thread.IsValid() == false) + if (select_thread && !selected_thread) { - if (m_verbose) Xcode::RunCommand(m_debugger,"bt all",true); - if (m_verbose) printf("[next invalid] I am gonna die at step %d\n",m_step); - exit(500); + m_thread = thread; + selected_thread = m_process.SetSelectedThread(thread); } - m_process.SetSelectedThread(action.thread); - action.thread.StepOver(); - break; - case ActionWanted::Type::eKill: - if (m_verbose) printf("I want to die\n"); - m_process.Kill(); - return; - } + } + if (fatal) + { + if (m_verbose) Xcode::RunCommand(m_debugger,"bt all",true); + exit(1); + } + } + break; } } + else + { + call_test_step = true; + } + + if (call_test_step) + { + if (m_verbose) + printf("RUNNING STEP %d\n",m_step); + ActionWanted action; + TestStep(m_step, action); + m_step++; + SBError err; + switch (action.type) + { + case ActionWanted::Type::eContinue: + err = m_process.Continue(); + break; + case ActionWanted::Type::eStepOut: + if (action.thread.IsValid() == false) + { + if (m_verbose) + { + Xcode::RunCommand(m_debugger,"bt all",true); + printf("error: invalid thread for step out on step %d\n", m_step); + } + exit(501); + } + m_process.SetSelectedThread(action.thread); + action.thread.StepOut(); + break; + case ActionWanted::Type::eStepOver: + if (action.thread.IsValid() == false) + { + if (m_verbose) + { + Xcode::RunCommand(m_debugger,"bt all",true); + printf("error: invalid thread for step over %d\n",m_step); + } + exit(500); + } + m_process.SetSelectedThread(action.thread); + action.thread.StepOver(); + break; + case ActionWanted::Type::eKill: + if (m_verbose) + printf("kill\n"); + m_process.Kill(); + return; + } + } + } + if (GetVerbose()) printf("I am gonna die at step %d\n",m_step); } @@ -200,6 +234,8 @@ TestCase::Run (TestCase& test, int argc, const char** argv) if (test.Setup(argc, argv)) { test.Loop(); - test.Results(); + Results results; + test.WriteResults(results); } } + |