[Lldb-commits] [lldb] r177376 - More cleanup on the lldb-perf code:
Greg Clayton
gclayton at apple.com
Mon Mar 18 21:41:23 PDT 2013
Author: gclayton
Date: Mon Mar 18 23:41:22 2013
New Revision: 177376
URL: http://llvm.org/viewvc/llvm-project?rev=177376&view=rev
Log:
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)
Modified:
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj
lldb/trunk/tools/lldb-perf/README
lldb/trunk/tools/lldb-perf/darwin/formatters/main.cpp
lldb/trunk/tools/lldb-perf/darwin/sketch/main.cpp
lldb/trunk/tools/lldb-perf/lib/TestCase.cpp
lldb/trunk/tools/lldb-perf/lib/TestCase.h
lldb/trunk/tools/lldb-perf/lib/Xcode.cpp
lldb/trunk/tools/lldb-perf/lldbperf.xcodeproj/project.pbxproj
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=177376&r1=177375&r2=177376&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Mar 18 23:41:22 2013
@@ -4476,7 +4476,6 @@
"-flimit-debug-info",
"-Wparentheses",
);
- SDKROOT = macosx;
STRIP_INSTALLED_PRODUCT = NO;
STRIP_STYLE = debugging;
WARNING_CFLAGS = "-Wreorder";
@@ -4539,7 +4538,6 @@
"-flimit-debug-info",
"-Wparentheses",
);
- SDKROOT = macosx;
STRIP_INSTALLED_PRODUCT = NO;
STRIP_STYLE = debugging;
WARNING_CFLAGS = "-Wreorder";
@@ -4907,7 +4905,6 @@
"-flimit-debug-info",
"-Wparentheses",
);
- SDKROOT = "";
STRIP_INSTALLED_PRODUCT = NO;
STRIP_STYLE = debugging;
WARNING_CFLAGS = "-Wreorder";
@@ -5395,7 +5392,6 @@
"-flimit-debug-info",
"-Wparentheses",
);
- SDKROOT = macosx;
STRIP_INSTALLED_PRODUCT = NO;
STRIP_STYLE = debugging;
WARNING_CFLAGS = "-Wreorder";
Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=177376&r1=177375&r2=177376&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Mon Mar 18 23:41:22 2013
@@ -497,7 +497,6 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
- SDKROOT = "";
STRIP_INSTALLED_PRODUCT = NO;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_BUILDER = "$(USER)";
@@ -524,7 +523,6 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
- SDKROOT = "";
STRIPFLAGS = "-x";
STRIP_STYLE = debugging;
VERSIONING_SYSTEM = "apple-generic";
@@ -554,7 +552,6 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- SDKROOT = "";
STRIPFLAGS = "-x";
STRIP_STYLE = debugging;
VERSIONING_SYSTEM = "apple-generic";
@@ -572,11 +569,11 @@
CURRENT_PROJECT_VERSION = 300.99.0;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks;
- "FRAMEWORK_SEARCH_PATHS[arch=*][sdk=iphoneos*]" = (
+ "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = (
"$(SDKROOT)/System/Library/PrivateFrameworks",
"$(SDKROOT)/Developer/Library/PrivateFrameworks",
);
- "FRAMEWORK_SEARCH_PATHS[arch=*][sdk=macosx*]" = "$(SDKROOT)/System/Library/PrivateFrameworks";
+ "FRAMEWORK_SEARCH_PATHS[sdk=macosx*][arch=*]" = "$(SDKROOT)/System/Library/PrivateFrameworks";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_PREPROCESSOR_DEFINITIONS = LLDB_DEBUGSERVER_BUILDANDINTEGRATION;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
@@ -585,20 +582,20 @@
"INSTALL_PATH[sdk=iphoneos*]" = /Developer/usr/bin/;
LLDB_DEBUGSERVER = 1;
OTHER_CFLAGS = "-Wparentheses";
- "OTHER_CFLAGS[arch=*][sdk=iphoneos*]" = (
+ "OTHER_CFLAGS[sdk=iphoneos*][arch=*]" = (
"-Wparentheses",
"-DWITH_LOCKDOWN",
"-DWITH_SPRINGBOARD",
"-DOS_OBJECT_USE_OBJC=0",
);
- "OTHER_CPLUSPLUSFLAGS[arch=*][sdk=iphoneos*]" = "$(OTHER_CFLAGS)";
+ "OTHER_CPLUSPLUSFLAGS[sdk=iphoneos*][arch=*]" = "$(OTHER_CFLAGS)";
OTHER_LDFLAGS = (
"-sectcreate",
__TEXT,
__info_plist,
"$(PROJECT_DIR)/resources/lldb-debugserver-Info.plist",
);
- "OTHER_LDFLAGS[arch=*][sdk=iphoneos*]" = (
+ "OTHER_LDFLAGS[sdk=iphoneos*][arch=*]" = (
"-framework",
SpringBoardServices,
"-llockdown",
@@ -624,11 +621,11 @@
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 300.99.0;
FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks;
- "FRAMEWORK_SEARCH_PATHS[arch=*][sdk=iphoneos*]" = (
+ "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = (
"$(SDKROOT)/System/Library/PrivateFrameworks",
"$(SDKROOT)/Developer/Library/PrivateFrameworks",
);
- "FRAMEWORK_SEARCH_PATHS[arch=*][sdk=macosx*]" = "$(SDKROOT)/System/Library/PrivateFrameworks";
+ "FRAMEWORK_SEARCH_PATHS[sdk=macosx*][arch=*]" = "$(SDKROOT)/System/Library/PrivateFrameworks";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
@@ -637,20 +634,20 @@
INSTALL_PATH = /usr/bin;
LLDB_DEBUGSERVER = 1;
OTHER_CFLAGS = "-Wparentheses";
- "OTHER_CFLAGS[arch=*][sdk=iphoneos*]" = (
+ "OTHER_CFLAGS[sdk=iphoneos*][arch=*]" = (
"-Wparentheses",
"-DWITH_LOCKDOWN",
"-DWITH_SPRINGBOARD",
"-DOS_OBJECT_USE_OBJC=0",
);
- "OTHER_CPLUSPLUSFLAGS[arch=*][sdk=iphoneos*]" = "$(OTHER_CFLAGS)";
+ "OTHER_CPLUSPLUSFLAGS[sdk=iphoneos*][arch=*]" = "$(OTHER_CFLAGS)";
OTHER_LDFLAGS = (
"-sectcreate",
__TEXT,
__info_plist,
"$(PROJECT_DIR)/resources/lldb-debugserver-Info.plist",
);
- "OTHER_LDFLAGS[arch=*][sdk=iphoneos*]" = (
+ "OTHER_LDFLAGS[sdk=iphoneos*][arch=*]" = (
"-framework",
SpringBoardServices,
"-llockdown",
@@ -677,11 +674,11 @@
CURRENT_PROJECT_VERSION = 300.99.0;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks;
- "FRAMEWORK_SEARCH_PATHS[arch=*][sdk=iphoneos*]" = (
+ "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = (
"$(SDKROOT)/System/Library/PrivateFrameworks",
"$(SDKROOT)/Developer/Library/PrivateFrameworks",
);
- "FRAMEWORK_SEARCH_PATHS[arch=*][sdk=macosx*]" = "$(SDKROOT)/System/Library/PrivateFrameworks";
+ "FRAMEWORK_SEARCH_PATHS[sdk=macosx*][arch=*]" = "$(SDKROOT)/System/Library/PrivateFrameworks";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_PREPROCESSOR_DEFINITIONS = LLDB_DEBUGSERVER_RELEASE;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
@@ -689,20 +686,20 @@
INSTALL_PATH = /usr/bin;
LLDB_DEBUGSERVER = 1;
OTHER_CFLAGS = "-Wparentheses";
- "OTHER_CFLAGS[arch=*][sdk=iphoneos*]" = (
+ "OTHER_CFLAGS[sdk=iphoneos*][arch=*]" = (
"-Wparentheses",
"-DWITH_LOCKDOWN",
"-DWITH_SPRINGBOARD",
"-DOS_OBJECT_USE_OBJC=0",
);
- "OTHER_CPLUSPLUSFLAGS[arch=*][sdk=iphoneos*]" = "$(OTHER_CFLAGS)";
+ "OTHER_CPLUSPLUSFLAGS[sdk=iphoneos*][arch=*]" = "$(OTHER_CFLAGS)";
OTHER_LDFLAGS = (
"-sectcreate",
__TEXT,
__info_plist,
"$(PROJECT_DIR)/resources/lldb-debugserver-Info.plist",
);
- "OTHER_LDFLAGS[arch=*][sdk=iphoneos*]" = (
+ "OTHER_LDFLAGS[sdk=iphoneos*][arch=*]" = (
"-framework",
SpringBoardServices,
"-llockdown",
@@ -740,7 +737,6 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
- SDKROOT = "";
STRIP_INSTALLED_PRODUCT = NO;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_BUILDER = "$(USER)";
@@ -758,11 +754,11 @@
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 300.99.0;
FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks;
- "FRAMEWORK_SEARCH_PATHS[arch=*][sdk=iphoneos*]" = (
+ "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = (
"$(SDKROOT)/System/Library/PrivateFrameworks",
"$(SDKROOT)/Developer/Library/PrivateFrameworks",
);
- "FRAMEWORK_SEARCH_PATHS[arch=*][sdk=macosx*]" = "$(SDKROOT)/System/Library/PrivateFrameworks";
+ "FRAMEWORK_SEARCH_PATHS[sdk=macosx*][arch=*]" = "$(SDKROOT)/System/Library/PrivateFrameworks";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
@@ -771,20 +767,20 @@
INSTALL_PATH = /usr/bin;
LLDB_DEBUGSERVER = 1;
OTHER_CFLAGS = "-Wparentheses";
- "OTHER_CFLAGS[arch=*][sdk=iphoneos*]" = (
+ "OTHER_CFLAGS[sdk=iphoneos*][arch=*]" = (
"-Wparentheses",
"-DWITH_LOCKDOWN",
"-DWITH_SPRINGBOARD",
"-DOS_OBJECT_USE_OBJC=0",
);
- "OTHER_CPLUSPLUSFLAGS[arch=*][sdk=iphoneos*]" = "$(OTHER_CFLAGS)";
+ "OTHER_CPLUSPLUSFLAGS[sdk=iphoneos*][arch=*]" = "$(OTHER_CFLAGS)";
OTHER_LDFLAGS = (
"-sectcreate",
__TEXT,
__info_plist,
"$(PROJECT_DIR)/resources/lldb-debugserver-Info.plist",
);
- "OTHER_LDFLAGS[arch=*][sdk=iphoneos*]" = (
+ "OTHER_LDFLAGS[sdk=iphoneos*][arch=*]" = (
"-framework",
SpringBoardServices,
"-llockdown",
Modified: lldb/trunk/tools/lldb-perf/README
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-perf/README?rev=177376&r1=177375&r2=177376&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-perf/README (original)
+++ lldb/trunk/tools/lldb-perf/README Mon Mar 18 23:41:22 2013
@@ -1,17 +1,24 @@
The lldb-perf infrastructure for LLDB performance testing
===========================================================
-lldb-perf is an infrastructure meant to simplify the creation of performance tests for the LLDB debugger
-It is contained in liblldbperf.a which is part of the standard opensource checkout of LLDB
-Its main concepts are:
-- Gauges: a gauge is a thing that takes a sample (e.g. it samples the time elapsed, the memory used, the energy consumed)
-- Metrics: a metric is a collection of samples that knows how to do statistics (for now, sum() and average() but can be extended as need be)
-- Measurements: a measurement is the thing that stores an action, a gauge and a metric. essentially, you define measurements as in âtake the time to run this functionâ, âtake the memory to run this block of codeâ, and then after you invoke it, your stats will be automagically there
-- Tests: a test is a sequence of steps and measurements
-
-Tests cases should be added as targets to the lldbperf.xcodeproj project. It is probably easiest to duplicate one of the existing targets.
+lldb-perf is an infrastructure meant to simplify the creation of performance
+tests for the LLDB debugger. It is contained in liblldbperf.a which is part of
+the standard opensource checkout of LLDB
-In order to write a test based on lldb-perf, you need to subclass lldb_perf::TestCase, as in:
+Its main concepts are:
+- Gauges: a gauge is a thing that takes a sample. Samples include elapsed time,
+ memory used, and energy consumed.
+- Metrics: a metric is a collection of samples that knows how to do statistics
+ like sum() and average(). Metrics can be extended as needed.
+- Measurements: a measurement is the thing that stores an action, a gauge and
+ a metric. You define measurements as in âtake the time to run this functionâ,
+ âtake the memory to run this block of codeâ, and then after you invoke it,
+ your stats will automagically be there.
+- Tests: a test is a sequence of steps and measurements.
+
+Tests cases should be added as targets to the lldbperf.xcodeproj project. It
+is probably easiest to duplicate one of the existing targets. In order to
+write a test based on lldb-perf, you need to subclass lldb_perf::TestCase:
using namespace lldb_perf;
@@ -19,6 +26,7 @@ class FormattersTest : public TestCase
{
Usually, you will define measurements as variables of your test case class:
+
private:
// C++ formatters
TimeMeasurement<std::function<void(SBValue)>> m_dump_std_vector_measurement;
@@ -34,107 +42,126 @@ private:
TimeMeasurement<std::function<void(SBValue)>> m_dump_nsbundle_measurement;
TimeMeasurement<std::function<void(SBValue)>> m_dump_nsdate_measurement;
-A TimeMeasurement is, obviously, a class that measures âhow much time to run this block of codeâ. the block of code is passed as an std::function (you can construct with a lambda!) - you need however to give the prototype of your block of code. in this example, we run blocks of code that take an SBValue and return nothing. other things are possible.
+A TimeMeasurement is, obviously, a class that measures âhow much time to run
+this block of codeâ. The block of code is passed as an std::function which you
+can construct with a lambda! You need to give the prototype of your block of
+code. In this example, we run blocks of code that take an SBValue and return
+nothing.
+
These blocks look like:
- m_dump_std_vector_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
- lldb_perf::Xcode::FetchVariable (value,1,false);
- }, "std-vector", "time to dump an std::vector");
-Here we are saying: make me a measurement named âstd-vectorâ, whose description is âtime to dump an std::vectorâ and that takes the time required to call lldb_perf::Xcode::FetchVariable(value,1,false)
-The Xcode class is a collection of utility functions that replicate common Xcode patterns (FetchVariable unsurprisingly calls API functions that Xcode could use when populating a variables view entry - the 1 means âexpand 1 level of depthâ and the
-false means âdo not dump the data to stdoutâ)
+ m_dump_std_vector_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
+ lldb_perf::Xcode::FetchVariable (value,1,false);
+ }, "std-vector", "time to dump an std::vector");
+
+Here we are saying: make me a measurement named âstd-vectorâ, whose
+description is âtime to dump an std::vectorâ and that takes the time required
+to call lldb_perf::Xcode::FetchVariable(value,1,false).
+
+The Xcode class is a collection of utility functions that replicate common
+Xcode patterns (FetchVariable unsurprisingly calls API functions that Xcode
+could use when populating a variables view entry - the 1 means âexpand 1 level
+of depthâ and the false means âdo not dump the data to stdoutâ)
A full constructor for a TestCase looks like:
- FormattersTest () : TestCase()
- {
- m_dump_std_vector_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
- lldb_perf::Xcode::FetchVariable (value,1,false);
- }, "std-vector", "time to dump an std::vector");
- m_dump_std_list_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
- lldb_perf::Xcode::FetchVariable (value,1,false);
- }, "std-list", "time to dump an std::list");
- m_dump_std_map_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
- lldb_perf::Xcode::FetchVariable (value,1,false);
- }, "std-map", "time to dump an std::map");
- m_dump_std_string_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
- lldb_perf::Xcode::FetchVariable (value,1,false);
- }, "std-string", "time to dump an std::string");
-
- m_dump_nsstring_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
- lldb_perf::Xcode::FetchVariable (value,0,false);
- }, "ns-string", "time to dump an NSString");
-
- m_dump_nsarray_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
- lldb_perf::Xcode::FetchVariable (value,1,false);
- }, "ns-array", "time to dump an NSArray");
-
- m_dump_nsdictionary_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
- lldb_perf::Xcode::FetchVariable (value,1,false);
- }, "ns-dictionary", "time to dump an NSDictionary");
-
- m_dump_nsset_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
- lldb_perf::Xcode::FetchVariable (value,1,false);
- }, "ns-set", "time to dump an NSSet");
-
- m_dump_nsbundle_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
- lldb_perf::Xcode::FetchVariable (value,1,false);
- }, "ns-bundle", "time to dump an NSBundle");
-
- m_dump_nsdate_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
- lldb_perf::Xcode::FetchVariable (value,0,false);
- }, "ns-date", "time to dump an NSDate");
- }
+
+FormattersTest () : TestCase()
+{
+ m_dump_std_vector_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
+ lldb_perf::Xcode::FetchVariable (value,1,false);
+ }, "std-vector", "time to dump an std::vector");
+ m_dump_std_list_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
+ lldb_perf::Xcode::FetchVariable (value,1,false);
+ }, "std-list", "time to dump an std::list");
+ m_dump_std_map_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
+ lldb_perf::Xcode::FetchVariable (value,1,false);
+ }, "std-map", "time to dump an std::map");
+ m_dump_std_string_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
+ lldb_perf::Xcode::FetchVariable (value,1,false);
+ }, "std-string", "time to dump an std::string");
+
+ m_dump_nsstring_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
+ lldb_perf::Xcode::FetchVariable (value,0,false);
+ }, "ns-string", "time to dump an NSString");
+
+ m_dump_nsarray_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
+ lldb_perf::Xcode::FetchVariable (value,1,false);
+ }, "ns-array", "time to dump an NSArray");
+
+ m_dump_nsdictionary_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
+ lldb_perf::Xcode::FetchVariable (value,1,false);
+ }, "ns-dictionary", "time to dump an NSDictionary");
+
+ m_dump_nsset_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
+ lldb_perf::Xcode::FetchVariable (value,1,false);
+ }, "ns-set", "time to dump an NSSet");
+
+ m_dump_nsbundle_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
+ lldb_perf::Xcode::FetchVariable (value,1,false);
+ }, "ns-bundle", "time to dump an NSBundle");
+
+ m_dump_nsdate_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
+ lldb_perf::Xcode::FetchVariable (value,0,false);
+ }, "ns-date", "time to dump an NSDate");
+}
Once your test case is constructed, Setup() is called on it:
- virtual void
+
+ virtual bool
Setup (int argc, const char** argv)
{
m_app_path.assign(argv[1]);
m_out_path.assign(argv[2]);
m_target = m_debugger.CreateTarget(m_app_path.c_str());
m_target.BreakpointCreateByName("main");
-
- Launch (NULL,".");
+ SBLaunchInfo launch_info (argv);
+ return Launch (launch_info);
}
-(I am considering moving Setup to the constructor, to be honest, but have not done so yet because it might also make sense to have Setup() return a bool or an Error object. stay tuned for more here!)
-In Setup() you process command-line arguments and create a target to run
+
+Setup() returns a boolean value that indicates if setup was successful.
+In Setup() you fill out a SBLaunchInfo with any needed settings for launching
+your process like arguments, environment variables, working directory, and
+much more.
+
The last thing you want to do in setup is call Launch():
+
bool
- Launch (const char** args, const char* cwd);
-This ensures your target is now alive. Make sure to have a breakpoint created :)
-Once you launched, the event loop is entered. The event loop waits for stops, and when it gets one, it calls your test caseâs
+ Launch (coSBLaunchInfo &launch_info);
+
+This ensures your target is now alive. Make sure to have a breakpoint created.
+
+Once you launched, the event loop is entered. The event loop waits for stops,
+and when it gets one, it calls your test caseâs TestStep() function:
+
virtual void
TestStep (int counter, ActionWanted &next_action)
-the counter is the step id (a monotonically increasing counter). In TestStep() you will essentially run your measurements and then return what you want the driver to do.
+the counter is the step id (a monotonically increasing counter). In TestStep()
+you will essentially run your measurements and then return what you want the
+driver to do by filling in the ActionWanted object named "next_action".
+
Possible options are:
-- continue process ActionWanted::Continue()
-- kill process ActionWanted::Kill()
-- finish on a thread ActionWanted::Finish(SBThread)
-- step-over on a thread. ActionWanted::Next(SBThread)
-
-If you use ActionWanted::Next() or ActionWanted::Finish(), define a SelectMyThread() that gives you an SBThread. I usually use a filename as key:
- SBThread
- SelectMyThread (const char* file_name)
- {
- auto threads_count = m_process.GetNumThreads();
- for (auto thread_num = 0; thread_num < threads_count; thread_num++)
- {
- SBThread thread(m_process.GetThreadAtIndex(thread_num));
- auto local_file_name = thread.GetFrameAtIndex(0).GetCompileUnit().GetFileSpec().GetFilename();
- if (!local_file_name)
- continue;
- if (strcmp(local_file_name,file_name))
- continue;
- return thread;
- }
- Xcode::RunCommand(m_debugger,"bt all",true);
- assert(false);
- }
-you might want to use some other logic in your selection.
-For your convenience TestCase has m_debugger, m_target and m_process as member variables. There is also an m_thread, but that is for you to set if you need/want to use it!
+- continue process next_action.Continue();
+- kill process next_action.Kill();
+- Step-out on a thread next_action.StepOut(SBThread)
+- step-over on a thread. next_action.StepOver(SBThread)
+
+If you use ActionWanted::Next() or ActionWanted::Finish() you need to specify
+a thread to use. By default the TestCase class will select the first thread
+that had a stop reason other than eStopReasonNone and place it into the
+m_thread member variable of TestCase. This means if your test case hits a
+breakpoint or steps, the thread that hit the breakpoint or finished the step
+will automatically be selected in the process (m_process) and m_thread will
+be set to this thread. If you have one or more threads that will stop with a
+reason simultaneously, you will need to find those threads manually by
+iterating through the process list and determine what to do next.
+
+For your convenience TestCase has m_debugger, m_target and m_process as member
+variables. As state above m_thread will be filled in with the first thread
+that has a stop reason.
An example:
+
virtual void
TestStep (int counter, ActionWanted &next_action)
{
@@ -148,14 +175,14 @@ An example:
break;
case 2:
DoTest ();
- next_action.Continue();
+ next_action.StepOver(m_thread);
break;
DoTest() is a function I define in my own class that calls the measurements:
void
DoTest ()
{
- SBThread thread_main(SelectMyThread("fmts_tester.mm"));
+ SBThread thread_main(m_thread);
SBFrame frame_zero(thread_main.GetFrameAtIndex(0));
m_dump_nsarray_measurement(frame_zero.FindVariable("nsarray", lldb::eDynamicCanRunTarget));
@@ -193,8 +220,11 @@ DoTest() is a function I define in my ow
m_dump_std_string_measurement(frame_zero.FindVariable("sstr4", lldb::eDynamicCanRunTarget));
}
-Essentially, you call your measurements as if they were functions, passing them arguments and all, and they will do the right thing with gathering stats.
+Essentially, you call your measurements as if they were functions, passing
+them arguments and all, and they will do the right thing with gathering stats.
+
The last step is usually to KILL the inferior and bail out:
+
virtual ActionWanted
TestStep (int counter)
{
@@ -214,6 +244,7 @@ The last step is usually to KILL the inf
At the end, you define a Results() function:
+
void
Results ()
{
@@ -230,24 +261,35 @@ At the end, you define a Results() funct
m_dump_nsbundle_measurement.Write(array);
m_dump_nsdate_measurement.Write(array);
- CFDataRef xmlData = CFPropertyListCreateData(kCFAllocatorDefault, array.get(), kCFPropertyListXMLFormat_v1_0, 0, NULL);
-
- CFURLRef file = CFURLCreateFromFileSystemRepresentation(NULL, (const UInt8*)m_out_path.c_str(), m_out_path.size(), FALSE);
+ CFDataRef xmlData = CFPropertyListCreateData (kCFAllocatorDefault,
+ array.get(),
+ kCFPropertyListXMLFormat_v1_0,
+ 0,
+ NULL);
+
+ CFURLRef file = CFURLCreateFromFileSystemRepresentation (NULL,
+ (const UInt8*)m_out_path.c_str(),
+ m_out_path.size(),
+ FALSE);
CFURLWriteDataAndPropertiesToResource(file,xmlData,NULL,NULL);
}
-For now, pretty much copy this and just call Write() on all your measurements. I plan to move this higher in the hierarchy (e.g. make a TestCase::Write(filename) fairly soon).
+For now, pretty much copy this and just call Write() on all your measurements.
+I plan to move this higher in the hierarchy (e.g. make a
+TestCase::Write(filename) fairly soon).
Your main() will look like:
+
int main(int argc, const char * argv[])
{
MyTest test;
- TestCase::Run(test,argc,argv);
+ TestCase::Run (test, argc, argv);
return 0;
}
If you are debugging your test, before Run() call
+
test.SetVerbose(true);
Feel free to send any questions and ideas for improvements.
Modified: lldb/trunk/tools/lldb-perf/darwin/formatters/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-perf/darwin/formatters/main.cpp?rev=177376&r1=177375&r2=177376&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-perf/darwin/formatters/main.cpp (original)
+++ lldb/trunk/tools/lldb-perf/darwin/formatters/main.cpp Mon Mar 18 23:41:22 2013
@@ -68,40 +68,21 @@ public:
{
}
- virtual void
+ virtual bool
Setup (int argc, const char** argv)
{
m_app_path.assign(argv[1]);
m_out_path.assign(argv[2]);
m_target = m_debugger.CreateTarget(m_app_path.c_str());
m_target.BreakpointCreateByName("main");
-
- Launch (NULL,".");
+ SBLaunchInfo launch_info(argv);
+ return Launch (launch_info);
}
- SBThread
- SelectMyThread (const char* file_name)
- {
- auto threads_count = m_process.GetNumThreads();
- for (auto thread_num = 0; thread_num < threads_count; thread_num++)
- {
- SBThread thread(m_process.GetThreadAtIndex(thread_num));
- auto local_file_name = thread.GetFrameAtIndex(0).GetCompileUnit().GetFileSpec().GetFilename();
- if (!local_file_name)
- continue;
- if (strcmp(local_file_name,file_name))
- continue;
- return thread;
- }
- Xcode::RunCommand(m_debugger,"bt all",true);
- assert(false);
- }
-
void
DoTest ()
{
- SBThread thread_main(SelectMyThread("fmts_tester.mm"));
- SBFrame frame_zero(thread_main.GetFrameAtIndex(0));
+ SBFrame frame_zero(m_thread.GetFrameAtIndex(0));
m_dump_nsarray_measurement(frame_zero.FindVariable("nsarray", lldb::eDynamicCanRunTarget));
m_dump_nsarray_measurement(frame_zero.FindVariable("nsmutablearray", lldb::eDynamicCanRunTarget));
Modified: lldb/trunk/tools/lldb-perf/darwin/sketch/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-perf/darwin/sketch/main.cpp?rev=177376&r1=177375&r2=177376&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-perf/darwin/sketch/main.cpp (original)
+++ lldb/trunk/tools/lldb-perf/darwin/sketch/main.cpp Mon Mar 18 23:41:22 2013
@@ -54,9 +54,10 @@ public:
{
}
- virtual void
+ virtual bool
Setup (int argc, const char** argv)
{
+ SetVerbose(true);
m_app_path.assign(argv[1]);
m_doc_path.assign(argv[2]);
m_out_path.assign(argv[3]);
@@ -67,11 +68,11 @@ public:
const char* persist_skip = "YES";
const char* empty = nullptr;
const char* args[] = {file_arg,persist_arg,persist_skip,empty};
+ SBLaunchInfo launch_info (args);
m_file_line_bp_measurement(m_target, "SKTDocument.m",245);
m_file_line_bp_measurement(m_target, "SKTDocument.m",283);
m_file_line_bp_measurement(m_target, "SKTText.m",326);
-
- Launch (args,".");
+ return Launch (launch_info);
}
void
@@ -98,12 +99,11 @@ public:
case 1:
{
DoTest ();
- SBThread thread(SelectMyThread("SKTDocument.m"));
- m_run_expr_measurement(thread.GetFrameAtIndex(0),"properties");
- m_run_expr_measurement(thread.GetFrameAtIndex(0),"[properties description]");
- m_run_expr_measurement(thread.GetFrameAtIndex(0),"typeName");
- m_run_expr_measurement(thread.GetFrameAtIndex(0),"data");
- m_run_expr_measurement(thread.GetFrameAtIndex(0),"[data description]");
+ m_run_expr_measurement(m_thread.GetFrameAtIndex(0),"properties");
+ m_run_expr_measurement(m_thread.GetFrameAtIndex(0),"[properties description]");
+ m_run_expr_measurement(m_thread.GetFrameAtIndex(0),"typeName");
+ m_run_expr_measurement(m_thread.GetFrameAtIndex(0),"data");
+ m_run_expr_measurement(m_thread.GetFrameAtIndex(0),"[data description]");
next_action.Continue();
}
break;
@@ -118,52 +118,49 @@ public:
case 3:
{
DoTest ();
- next_action.Next(SelectMyThread ("SKTText.m"));
+ next_action.StepOver(m_thread);
}
break;
case 4:
{
DoTest ();
- SBThread thread(SelectMyThread("SKTText.m"));
- m_run_expr_measurement(thread.GetFrameAtIndex(0),"layoutManager");
- m_run_expr_measurement(thread.GetFrameAtIndex(0),"contents");
- next_action.Next(thread);
+ m_run_expr_measurement(m_thread.GetFrameAtIndex(0),"layoutManager");
+ m_run_expr_measurement(m_thread.GetFrameAtIndex(0),"contents");
+ next_action.StepOver(m_thread);
}
break;
case 5:
{
DoTest ();
- next_action.Next(SelectMyThread ("SKTText.m"));
+ next_action.StepOver(m_thread);
}
break;
case 6:
{
DoTest ();
- next_action.Next(SelectMyThread ("SKTText.m"));
+ next_action.StepOver(m_thread);
}
break;
case 7:
{
DoTest ();
- SBThread thread(SelectMyThread("SKTText.m"));
- m_run_expr_measurement(thread.GetFrameAtIndex(0),"@\"an NSString\"");
- m_run_expr_measurement(thread.GetFrameAtIndex(0),"[(id)@\"an NSString\" description]");
- m_run_expr_measurement(thread.GetFrameAtIndex(0),"@[@1, at 2, at 3]");
- next_action.Finish(thread);
+ m_run_expr_measurement(m_thread.GetFrameAtIndex(0),"@\"an NSString\"");
+ m_run_expr_measurement(m_thread.GetFrameAtIndex(0),"[(id)@\"an NSString\" description]");
+ m_run_expr_measurement(m_thread.GetFrameAtIndex(0),"@[@1, at 2, at 3]");
+ next_action.StepOut(m_thread);
}
break;
case 8:
{
DoTest ();
- SBThread thread(SelectMyThread("SKTGraphicView.m"));
- m_run_expr_measurement(thread.GetFrameAtIndex(0),"[graphics description]");
- m_run_expr_measurement(thread.GetFrameAtIndex(0),"[selectionIndexes description]");
- m_run_expr_measurement(thread.GetFrameAtIndex(0),"(BOOL)NSIntersectsRect(rect, graphicDrawingBounds)");
+ m_run_expr_measurement(m_thread.GetFrameAtIndex(0),"[graphics description]");
+ m_run_expr_measurement(m_thread.GetFrameAtIndex(0),"[selectionIndexes description]");
+ m_run_expr_measurement(m_thread.GetFrameAtIndex(0),"(BOOL)NSIntersectsRect(rect, graphicDrawingBounds)");
next_action.Kill();
}
break;
@@ -200,23 +197,6 @@ private:
Measurement<lldb_perf::TimeGauge, std::function<void(SBProcess,int)>> m_fetch_vars_measurement;
Measurement<lldb_perf::TimeGauge, std::function<void(SBFrame,const char*)>> m_run_expr_measurement;
- SBThread
- SelectMyThread (const char* file_name)
- {
- auto threads_count = m_process.GetNumThreads();
- for (auto thread_num = 0; thread_num < threads_count; thread_num++)
- {
- SBThread thread(m_process.GetThreadAtIndex(thread_num));
- auto local_file_name = thread.GetFrameAtIndex(0).GetCompileUnit().GetFileSpec().GetFilename();
- if (!local_file_name)
- continue;
- if (strcmp(local_file_name,file_name))
- continue;
- return thread;
- }
- Xcode::RunCommand(m_debugger,"bt all",true);
- assert(false);
- }
std::string m_app_path;
std::string m_doc_path;
std::string m_out_path;
Modified: lldb/trunk/tools/lldb-perf/lib/TestCase.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-perf/lib/TestCase.cpp?rev=177376&r1=177375&r2=177376&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-perf/lib/TestCase.cpp (original)
+++ lldb/trunk/tools/lldb-perf/lib/TestCase.cpp Mon Mar 18 23:41:22 2013
@@ -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();
+ }
}
Modified: lldb/trunk/tools/lldb-perf/lib/TestCase.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-perf/lib/TestCase.h?rev=177376&r1=177375&r2=177376&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-perf/lib/TestCase.h (original)
+++ lldb/trunk/tools/lldb-perf/lib/TestCase.h Mon Mar 18 23:41:22 2013
@@ -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();
Modified: lldb/trunk/tools/lldb-perf/lib/Xcode.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-perf/lib/Xcode.cpp?rev=177376&r1=177375&r2=177376&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-perf/lib/Xcode.cpp (original)
+++ lldb/trunk/tools/lldb-perf/lib/Xcode.cpp Mon Mar 18 23:41:22 2013
@@ -26,7 +26,7 @@ Xcode::FetchVariable (SBValue value, uin
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();
Modified: lldb/trunk/tools/lldb-perf/lldbperf.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-perf/lldbperf.xcodeproj/project.pbxproj?rev=177376&r1=177375&r2=177376&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-perf/lldbperf.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/tools/lldb-perf/lldbperf.xcodeproj/project.pbxproj Mon Mar 18 23:41:22 2013
@@ -631,9 +631,8 @@
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.9;
+ MACOSX_DEPLOYMENT_TARGET = 10.7;
ONLY_ACTIVE_ARCH = YES;
- SDKROOT = macosx;
};
name = Debug;
};
@@ -660,8 +659,7 @@
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.9;
- SDKROOT = macosx;
+ MACOSX_DEPLOYMENT_TARGET = 10.7;
};
name = Release;
};
More information about the lldb-commits
mailing list