summaryrefslogtreecommitdiffstats
path: root/lldb/tools/lldb-perf/lib
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2013-03-19 04:41:22 +0000
committerGreg Clayton <gclayton@apple.com>2013-03-19 04:41:22 +0000
commite0b924e3bf83de1f51e1af967916d8612036dbdc (patch)
treeac0c4fb498463a29782cfb517b677d87d087a0c8 /lldb/tools/lldb-perf/lib
parentde78866594d7f38cdf4418552b4034cc81d4a803 (diff)
downloadbcm5719-llvm-e0b924e3bf83de1f51e1af967916d8612036dbdc.tar.gz
bcm5719-llvm-e0b924e3bf83de1f51e1af967916d8612036dbdc.zip
More cleanup on the lldb-perf code:
- TestCase.m_thread is now filled in with the first thread that has a valid stop reason. This eliminates the need for the SelectMyThread() functions. - The first thread that stops for a reason is also set as the selected thread in the process in case any command line commands are run. - Changed launch over to take a SBLaunchInfo parameter so that the launch function doesn't keep getting new arguments as they are needed. - TestCase::Setup() and TestCase::Launch(SBLaunchInfo) now return bool to indicate success of setup and launch. - ActionWanted::Next(SBThread) was renamed to ActionWanted::StepOver(SBThread) - ActionWanted::Finish(SBThread) was renamed to ActionWanted::StepOut(SBThread) llvm-svn: 177376
Diffstat (limited to 'lldb/tools/lldb-perf/lib')
-rw-r--r--lldb/tools/lldb-perf/lib/TestCase.cpp63
-rw-r--r--lldb/tools/lldb-perf/lib/TestCase.h12
-rw-r--r--lldb/tools/lldb-perf/lib/Xcode.cpp2
3 files changed, 51 insertions, 26 deletions
diff --git a/lldb/tools/lldb-perf/lib/TestCase.cpp b/lldb/tools/lldb-perf/lib/TestCase.cpp
index ca825d99ce4..ac8a4c47b95 100644
--- a/lldb/tools/lldb-perf/lib/TestCase.cpp
+++ b/lldb/tools/lldb-perf/lib/TestCase.cpp
@@ -12,12 +12,12 @@
using namespace lldb_perf;
TestCase::TestCase () :
-m_debugger(),
-m_target(),
-m_process(),
-m_thread(),
-m_listener(),
-m_verbose(false)
+ m_debugger(),
+ m_target(),
+ m_process(),
+ m_thread(),
+ m_listener(),
+ m_verbose(false)
{
SBDebugger::Initialize();
SBHostOS::ThreadCreated ("<lldb-tester.app.main>");
@@ -25,16 +25,25 @@ m_verbose(false)
m_listener = m_debugger.GetListener();
}
-void
+bool
TestCase::Setup (int argc, const char** argv)
-{}
+{
+ return false;
+}
bool
-TestCase::Launch (const char** args, const char* cwd)
+TestCase::Launch (lldb::SBLaunchInfo &launch_info)
{
- m_process = m_target.LaunchSimple(args,NULL,cwd);
- m_process.GetBroadcaster().AddListener(m_listener, SBProcess::eBroadcastBitStateChanged | SBProcess::eBroadcastBitInterrupt);
- return m_process.IsValid ();
+ lldb::SBError error;
+ m_process = m_target.Launch (launch_info, error);
+ if (!error.Success())
+ fprintf (stderr, "error: %s\n", error.GetCString());
+ if (m_process.IsValid())
+ {
+ m_process.GetBroadcaster().AddListener(m_listener, SBProcess::eBroadcastBitStateChanged | SBProcess::eBroadcastBitInterrupt);
+ return true;
+ }
+ return false;
}
void
@@ -81,10 +90,12 @@ TestCase::Loop ()
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)
@@ -94,10 +105,12 @@ TestCase::Loop ()
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:
@@ -110,19 +123,28 @@ TestCase::Loop ()
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)
+ {
+ m_thread = thread;
+ selected_thread = m_process.SetSelectedThread(thread);
+ }
}
if (fatal)
{
@@ -134,12 +156,13 @@ TestCase::Loop ()
ActionWanted action;
TestStep(step, action);
step++;
+ SBError err;
switch (action.type)
{
case ActionWanted::Type::eContinue:
- m_debugger.HandleCommand("continue");
+ err = m_process.Continue();
break;
- case ActionWanted::Type::eFinish:
+ case ActionWanted::Type::eStepOut:
if (action.thread.IsValid() == false)
{
if (m_verbose) Xcode::RunCommand(m_debugger,"bt all",true);
@@ -147,7 +170,7 @@ TestCase::Loop ()
exit(501);
}
m_process.SetSelectedThread(action.thread);
- m_debugger.HandleCommand("finish");
+ action.thread.StepOut();
break;
case ActionWanted::Type::eNext:
if (action.thread.IsValid() == false)
@@ -157,7 +180,7 @@ TestCase::Loop ()
exit(500);
}
m_process.SetSelectedThread(action.thread);
- m_debugger.HandleCommand("next");
+ action.thread.StepOver();
break;
case ActionWanted::Type::eKill:
if (m_verbose) printf("I want to die\n");
@@ -173,7 +196,9 @@ TestCase::Loop ()
void
TestCase::Run (TestCase& test, int argc, const char** argv)
{
- test.Setup(argc, argv);
- test.Loop();
- test.Results();
+ if (test.Setup(argc, argv))
+ {
+ test.Loop();
+ test.Results();
+ }
}
diff --git a/lldb/tools/lldb-perf/lib/TestCase.h b/lldb/tools/lldb-perf/lib/TestCase.h
index a46dc5af24b..69d8002f014 100644
--- a/lldb/tools/lldb-perf/lib/TestCase.h
+++ b/lldb/tools/lldb-perf/lib/TestCase.h
@@ -25,7 +25,7 @@ public:
{
eNext,
eContinue,
- eFinish,
+ eStepOut,
eKill
} type;
lldb::SBThread thread;
@@ -44,16 +44,16 @@ public:
}
void
- Next (lldb::SBThread t)
+ StepOver (lldb::SBThread t)
{
type = Type::eNext;
thread = t;
}
void
- Finish (lldb::SBThread t)
+ StepOut (lldb::SBThread t)
{
- type = Type::eFinish;
+ type = Type::eStepOut;
thread = t;
}
@@ -69,14 +69,14 @@ public:
~TestCase ()
{}
- virtual void
+ virtual bool
Setup (int argc, const char** argv);
virtual void
TestStep (int counter, ActionWanted &next_action) = 0;
bool
- Launch (const char** args, const char* cwd);
+ Launch (lldb::SBLaunchInfo &launch_info);
void
Loop();
diff --git a/lldb/tools/lldb-perf/lib/Xcode.cpp b/lldb/tools/lldb-perf/lib/Xcode.cpp
index e0b2a798699..6d42118384f 100644
--- a/lldb/tools/lldb-perf/lib/Xcode.cpp
+++ b/lldb/tools/lldb-perf/lib/Xcode.cpp
@@ -26,7 +26,7 @@ Xcode::FetchVariable (SBValue value, uint32_t expand, bool verbose)
auto type_3 = value.GetType();
auto type_name_2 = value.GetTypeName();
if (verbose)
- printf("%s %s = %llu %s\n",value.GetTypeName(),value.GetName(),num_value,summary);
+ printf("%s %s = 0x%llx (%llu) %s\n",value.GetTypeName(),value.GetName(),num_value, num_value,summary);
if (expand > 0)
{
auto count = value.GetNumChildren();
OpenPOWER on IntegriCloud