Index: lldb/trunk/lldb.xcworkspace/contents.xcworkspacedata
===================================================================
--- lldb/trunk/lldb.xcworkspace/contents.xcworkspacedata
+++ lldb/trunk/lldb.xcworkspace/contents.xcworkspacedata
@@ -7,7 +7,4 @@
-
-
Index: lldb/trunk/tools/lldb-perf/README
===================================================================
--- lldb/trunk/tools/lldb-perf/README
+++ lldb/trunk/tools/lldb-perf/README
@@ -1,295 +0,0 @@
- 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. 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;
-
-class FormattersTest : public TestCase
-{
-
-Usually, you will define measurements as variables of your test case class:
-
-private:
- // C++ formatters
- TimeMeasurement> m_dump_std_vector_measurement;
- TimeMeasurement> m_dump_std_list_measurement;
- TimeMeasurement> m_dump_std_map_measurement;
- TimeMeasurement> m_dump_std_string_measurement;
-
- // Cocoa formatters
- TimeMeasurement> m_dump_nsstring_measurement;
- TimeMeasurement> m_dump_nsarray_measurement;
- TimeMeasurement> m_dump_nsdictionary_measurement;
- TimeMeasurement> m_dump_nsset_measurement;
- TimeMeasurement> m_dump_nsbundle_measurement;
- TimeMeasurement> 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 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”)
-
-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");
-}
-
-Once your test case is constructed, Setup() is called on it:
-
- 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");
- SBLaunchInfo launch_info (argv);
- return Launch (launch_info);
- }
-
-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 (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 by filling in the ActionWanted object named "next_action".
-
-Possible options are:
-- 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)
- {
- case 0:
- m_target.BreakpointCreateByLocation("fmts_tester.mm", 68);
- next_action.Continue();
- break;
- case 1:
- DoTest ();
- next_action.Continue();
- break;
- case 2:
- DoTest ();
- 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(m_thread);
- SBFrame frame_zero(thread_main.GetFrameAtIndex(0));
-
- m_dump_nsarray_measurement(frame_zero.FindVariable("nsarray", lldb::eDynamicCanRunTarget));
- m_dump_nsarray_measurement(frame_zero.FindVariable("nsmutablearray", lldb::eDynamicCanRunTarget));
-
- m_dump_nsdictionary_measurement(frame_zero.FindVariable("nsdictionary", lldb::eDynamicCanRunTarget));
- m_dump_nsdictionary_measurement(frame_zero.FindVariable("nsmutabledictionary", lldb::eDynamicCanRunTarget));
-
- m_dump_nsstring_measurement(frame_zero.FindVariable("str0", lldb::eDynamicCanRunTarget));
- m_dump_nsstring_measurement(frame_zero.FindVariable("str1", lldb::eDynamicCanRunTarget));
- m_dump_nsstring_measurement(frame_zero.FindVariable("str2", lldb::eDynamicCanRunTarget));
- m_dump_nsstring_measurement(frame_zero.FindVariable("str3", lldb::eDynamicCanRunTarget));
- m_dump_nsstring_measurement(frame_zero.FindVariable("str4", lldb::eDynamicCanRunTarget));
-
- m_dump_nsdate_measurement(frame_zero.FindVariable("me", lldb::eDynamicCanRunTarget));
- m_dump_nsdate_measurement(frame_zero.FindVariable("cutie", lldb::eDynamicCanRunTarget));
- m_dump_nsdate_measurement(frame_zero.FindVariable("mom", lldb::eDynamicCanRunTarget));
- m_dump_nsdate_measurement(frame_zero.FindVariable("dad", lldb::eDynamicCanRunTarget));
- m_dump_nsdate_measurement(frame_zero.FindVariable("today", lldb::eDynamicCanRunTarget));
-
- m_dump_nsbundle_measurement(frame_zero.FindVariable("bundles", lldb::eDynamicCanRunTarget));
- m_dump_nsbundle_measurement(frame_zero.FindVariable("frameworks", lldb::eDynamicCanRunTarget));
-
- m_dump_nsset_measurement(frame_zero.FindVariable("nsset", lldb::eDynamicCanRunTarget));
- m_dump_nsset_measurement(frame_zero.FindVariable("nsmutableset", lldb::eDynamicCanRunTarget));
-
- m_dump_std_vector_measurement(frame_zero.FindVariable("vector", lldb::eDynamicCanRunTarget));
- m_dump_std_list_measurement(frame_zero.FindVariable("list", lldb::eDynamicCanRunTarget));
- m_dump_std_map_measurement(frame_zero.FindVariable("map", lldb::eDynamicCanRunTarget));
-
- m_dump_std_string_measurement(frame_zero.FindVariable("sstr0", lldb::eDynamicCanRunTarget));
- m_dump_std_string_measurement(frame_zero.FindVariable("sstr1", lldb::eDynamicCanRunTarget));
- m_dump_std_string_measurement(frame_zero.FindVariable("sstr2", lldb::eDynamicCanRunTarget));
- m_dump_std_string_measurement(frame_zero.FindVariable("sstr3", lldb::eDynamicCanRunTarget));
- 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.
-
-The last step is usually to KILL the inferior and bail out:
-
- virtual ActionWanted
- TestStep (int counter)
- {
-...
- case 9:
- DoTest ();
- next_action.Continue();
- break;
- case 10:
- DoTest ();
- next_action.Continue();
- break;
- default:
- next_action.Kill();
- break;
- }
-
-
-At the end, you define a Results() function:
-
- void
- Results ()
- {
- CFCMutableArray array;
- m_dump_std_vector_measurement.Write(array);
- m_dump_std_list_measurement.Write(array);
- m_dump_std_map_measurement.Write(array);
- m_dump_std_string_measurement.Write(array);
-
- m_dump_nsstring_measurement.Write(array);
- m_dump_nsarray_measurement.Write(array);
- m_dump_nsdictionary_measurement.Write(array);
- m_dump_nsset_measurement.Write(array);
- 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);
-
- 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).
-
-Your main() will look like:
-
-int main(int argc, const char * argv[])
-{
- MyTest test;
- 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.
Index: lldb/trunk/tools/lldb-perf/common/clang/build-clang.sh
===================================================================
--- lldb/trunk/tools/lldb-perf/common/clang/build-clang.sh
+++ lldb/trunk/tools/lldb-perf/common/clang/build-clang.sh
@@ -1,33 +0,0 @@
-#!/bin/bash
-
-if [ -d "llvm-build" ]; then
- echo "Using existing 'llvm-build' directory..."
-else
- mkdir llvm-build
-fi
-
-cd llvm-build
-
-if [ -d "llvm" ]; then
- echo "Using existing 'llvm' directory..."
-else
- svn co --revision 176809 http://llvm.org/svn/llvm-project/llvm/trunk llvm
- ( cd llvm/tools ; svn co --revision 176809 http://llvm.org/svn/llvm-project/cfe/trunk clang )
-fi
-
-if [ ! -d "build" ]; then
- mkdir build
- cd build
- ../llvm/configure --enable-targets=x86_64,arm --build=x86_64-apple-darwin10 --disable-optimized --disable-assertions --enable-libcpp
- make -j8 clang-only DEBUG_SYMBOLS=1
- rm -rf lib projects runtime unittests utils config.*
- ( cd ./Debug/bin ; rm -rf ll* clang-check clang-tblgen count diagtool fpcmp macho-dump not opt yaml2obj FileCheck FileUpdate arcmt-test c-arcmt-test c-index-test bugpoint )
- ( cd ./tools ; rm -rf ll* clang-check clang-tblgen count diagtool fpcmp lto macho-dump not opt yaml2obj FileCheck FileUpdate arcmt-test c-arcmt-test c-index-test bugpoint )
- ( cd ./tools/clang ; rm -rf lib unittests utils )
- ( cd ./tools/clang/tools ; rm -rf arcmt-test c-arcmt-test c-index-test clang-check diagtool libclang )
- ( cd ../llvm ; rm -rf cmake configure docs examples projects *.txt *.TXT autoconf bindings test unittests utils ; find . -type d -name .svn -print0 | xargs -0 rm -rf )
- ( cd ../llvm/tools ; rm -rf *.txt bugpoint bugpoint-passes ll* lto macho-dump opt gold )
-fi
-
-
-
Index: lldb/trunk/tools/lldb-perf/common/clang/lldb_perf_clang.cpp
===================================================================
--- lldb/trunk/tools/lldb-perf/common/clang/lldb_perf_clang.cpp
+++ lldb/trunk/tools/lldb-perf/common/clang/lldb_perf_clang.cpp
@@ -1,441 +0,0 @@
-//===-- lldb_perf_clang.cpp -------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb-perf/lib/Measurement.h"
-#include "lldb-perf/lib/Metric.h"
-#include "lldb-perf/lib/Results.h"
-#include "lldb-perf/lib/TestCase.h"
-#include "lldb-perf/lib/Timer.h"
-#include "lldb-perf/lib/Xcode.h"
-#include "llvm/ADT/STLExtras.h"
-#include
-#include
-#include
-#include
-
-using namespace lldb_perf;
-
-#define NUM_EXPR_ITERATIONS 3
-class ClangTest : public TestCase {
-public:
- ClangTest()
- : TestCase(),
- m_time_create_target(
- [this]() -> void {
- m_memory_change_create_target.Start();
- m_target = m_debugger.CreateTarget(m_exe_path.c_str());
- m_memory_change_create_target.Stop();
- },
- "time-create-target", "The time it takes to create a target."),
- m_time_set_bp_main(
- [this]() -> void {
- m_memory_change_break_main.Start();
- m_target.BreakpointCreateByName("main");
- m_memory_change_break_main.Stop();
- },
- "time-set-break-main",
- "Elapsed time it takes to set a breakpoint at 'main' by name."),
- m_memory_change_create_target(), m_memory_change_break_main(),
- m_memory_total(), m_time_launch_stop_main(), m_time_total(),
- m_expr_first_evaluate(
- [this](SBFrame frame) -> void {
- frame.EvaluateExpression("Diags.DiagArgumentsStr[0].size()")
- .GetError();
- },
- "time-expr", "Elapsed time it takes to evaluate an expression for "
- "the first time."),
- m_expr_frame_zero(
- [this](SBFrame frame) -> void {
- frame.EvaluateExpression("Diags.DiagArgumentsStr[0].size()")
- .GetError();
- },
- "time-expr-frame-zero", "Elapsed time it takes to evaluate an "
- "expression 3 times at frame zero."),
- m_expr_frame_non_zero(
- [this](SBFrame frame) -> void {
- frame.EvaluateExpression("Diags.DiagArgumentsStr[0].size()")
- .GetError();
- },
- "time-expr-frame-non-zero", "Elapsed time it takes to evaluate an "
- "expression 3 times at a non-zero "
- "frame."),
- m_exe_path(), m_out_path(), m_launch_info(NULL), m_use_dsym(false) {}
-
- virtual ~ClangTest() {}
-
- virtual bool Setup(int &argc, const char **&argv) {
- if (m_exe_path.empty())
- return false;
- m_launch_info.SetArguments(argv, false);
- return true;
- }
-
- void DoTest() {}
-
- virtual void TestStep(int counter, ActionWanted &next_action) {
- char temp_source_path[PATH_MAX] = "/tmp/main.XXXXXX.cpp";
-
- switch (counter) {
- case 0: {
- // Xcode::RunCommand(m_debugger,"log enable -f /tmp/packets.txt gdb-remote
- // packets",true);
-
- m_memory_total.Start();
- m_time_total.Start();
-
- // Time creating the target
- m_time_create_target();
-
- m_time_set_bp_main();
-
- int fd = mkstemps(temp_source_path, 4);
-
- if (fd >= 0) {
- const char *source_content = R"(
-#include
-#include
-#include
-
-namespace {
- struct Foo
- {
- int i; int j;
- };
- void doit (const Foo &foo)
- {
- printf ("doit(%i)\n", foo.i);
- }
-}
-
-int main (int argc, char const *argv[], char const *envp[])
-{
- std::vector ints;
- for (int i=0;i<10;++i)
- ints.push_back(i);
- printf ("hello world\n");
- Foo foo = { 12, 13 };
- doit (foo);
- return 0;
-}
-)";
- write(fd, source_content, strlen(source_content));
- close(fd);
- } else {
- const char *error_cstr = strerror(errno);
- fprintf(stderr,
- "error: failed to created temporary source file: '%s' (%s)",
- temp_source_path, error_cstr);
- exit(2);
- }
-
- m_time_launch_stop_main.Start();
- const char *clang_argv[] = {"-cc1",
- "-triple",
- "x86_64-apple-macosx10.8.0",
- "-emit-obj",
- "-mrelax-all",
- "-disable-free",
- "-disable-llvm-verifier",
- "-main-file-name",
- "main.cpp",
- "-mrelocation-model",
- "pic",
- "-pic-level",
- "2",
- "-mdisable-fp-elim",
- "-masm-verbose",
- "-munwind-tables",
- "-target-cpu",
- "core2",
- "-target-linker-version",
- "132.10.1",
- "-v",
- "-g",
- "-O0",
- "-fdeprecated-macro",
- "-ferror-limit",
- "19",
- "-fmessage-length",
- "298",
- "-stack-protector",
- "1",
- "-mstackrealign",
- "-fblocks",
- "-fobjc-runtime=macosx-10.8.0",
- "-fobjc-dispatch-method=mixed",
- "-fencode-extended-block-signature",
- "-fcxx-exceptions",
- "-fexceptions",
- "-fdiagnostics-show-option",
- "-fcolor-diagnostics",
- "-backend-option",
- "-vectorize-loops",
- "-o",
- "/tmp/main.o",
- "-x",
- "c++",
- NULL,
- NULL};
- clang_argv[llvm::array_lengthof(clang_argv) - 2] = temp_source_path;
- SBLaunchInfo launch_info(clang_argv);
- Launch(launch_info);
- next_action
- .None(); // Don't continue or do anything, just wait for next event...
- } break;
- case 1: {
- m_time_launch_stop_main.Stop();
- m_time_total.Stop();
- SBFrame frame(m_thread.GetFrameAtIndex(0));
-
- // Time the first expression evaluation
- m_expr_first_evaluate(frame);
-
- SBValue result;
- for (size_t i = 0; i < NUM_EXPR_ITERATIONS; ++i) {
- m_expr_frame_zero(frame);
- }
- m_target.BreakpointCreateByName("DeclContext::lookup");
- next_action.Continue();
- } break;
- case 2: {
- SBFrame frame(m_thread.GetFrameAtIndex(21));
- SBValue result;
- for (size_t i = 0; i < NUM_EXPR_ITERATIONS; ++i) {
- m_expr_frame_non_zero(frame);
- }
- next_action.Continue();
- } break;
- default:
- m_memory_total.Stop();
- next_action.Kill();
- break;
- }
- }
-
- void WriteResults(Results &results) {
- Results::Dictionary &results_dict = results.GetDictionary();
-
- m_time_set_bp_main.WriteAverageAndStandardDeviation(results);
- results_dict.Add(
- "memory-change-create-target",
- "Memory increase that occurs due to creating the target.",
- m_memory_change_create_target.GetDeltaValue().GetResult(NULL, NULL));
-
- results_dict.Add(
- "memory-change-break-main", "Memory increase that occurs due to "
- "setting a breakpoint at main by name.",
- m_memory_change_break_main.GetDeltaValue().GetResult(NULL, NULL));
-
- m_time_create_target.WriteAverageAndStandardDeviation(results);
- m_expr_first_evaluate.WriteAverageAndStandardDeviation(results);
- m_expr_frame_zero.WriteAverageAndStandardDeviation(results);
- m_expr_frame_non_zero.WriteAverageAndStandardDeviation(results);
- results_dict.Add("memory-total-break-main",
- "The total memory that the current process is using after "
- "setting the first breakpoint.",
- m_memory_total.GetStopValue().GetResult(NULL, NULL));
-
- results_dict.AddDouble(
- "time-launch-stop-main",
- "The time it takes to launch the process and stop at main.",
- m_time_launch_stop_main.GetDeltaValue());
-
- results_dict.AddDouble(
- "time-total", "The time it takes to create the target, set breakpoint "
- "at main, launch clang and hit the breakpoint at main.",
- m_time_total.GetDeltaValue());
- results.Write(GetResultFilePath());
- }
-
- const char *GetExecutablePath() const {
- if (m_exe_path.empty())
- return NULL;
- return m_exe_path.c_str();
- }
-
- const char *GetResultFilePath() const {
- if (m_out_path.empty())
- return NULL;
- return m_out_path.c_str();
- }
-
- void SetExecutablePath(const char *path) {
- if (path && path[0])
- m_exe_path = path;
- else
- m_exe_path.clear();
- }
-
- void SetResultFilePath(const char *path) {
- if (path && path[0])
- m_out_path = path;
- else
- m_out_path.clear();
- }
-
- void SetUseDSYM(bool b) { m_use_dsym = b; }
-
-private:
- // C++ formatters
- TimeMeasurement> m_time_create_target;
- TimeMeasurement> m_time_set_bp_main;
- MemoryGauge m_memory_change_create_target;
- MemoryGauge m_memory_change_break_main;
- MemoryGauge m_memory_total;
- TimeGauge m_time_launch_stop_main;
- TimeGauge m_time_total;
- TimeMeasurement> m_expr_first_evaluate;
- TimeMeasurement> m_expr_frame_zero;
- TimeMeasurement> m_expr_frame_non_zero;
- std::string m_exe_path;
- std::string m_out_path;
- SBLaunchInfo m_launch_info;
- bool m_use_dsym;
-};
-
-struct Options {
- std::string clang_path;
- std::string out_file;
- bool verbose;
- bool use_dsym;
- bool error;
- bool print_help;
-
- Options() : verbose(false), error(false), print_help(false) {}
-};
-
-static struct option g_long_options[] = {
- {"verbose", no_argument, NULL, 'v'},
- {"clang", required_argument, NULL, 'c'},
- {"out-file", required_argument, NULL, 'o'},
- {"dsym", no_argument, NULL, 'd'},
- {NULL, 0, NULL, 0}};
-
-std::string GetShortOptionString(struct option *long_options) {
- std::string option_string;
- for (int i = 0; long_options[i].name != NULL; ++i) {
- if (long_options[i].flag == NULL) {
- option_string.push_back((char)long_options[i].val);
- switch (long_options[i].has_arg) {
- default:
- case no_argument:
- break;
- case required_argument:
- option_string.push_back(':');
- break;
- case optional_argument:
- option_string.append(2, ':');
- break;
- }
- }
- }
- return option_string;
-}
-
-int main(int argc, const char *argv[]) {
-
- // Prepare for & make calls to getopt_long_only.
-
- std::string short_option_string(GetShortOptionString(g_long_options));
-
- ClangTest test;
-
- Options option_data;
- bool done = false;
-
-#if __GLIBC__
- optind = 0;
-#else
- optreset = 1;
- optind = 1;
-#endif
- while (!done) {
- int long_options_index = -1;
- const int short_option = ::getopt_long_only(
- argc, const_cast(argv), short_option_string.c_str(),
- g_long_options, &long_options_index);
-
- switch (short_option) {
- case 0:
- // Already handled
- break;
-
- case -1:
- done = true;
- break;
-
- case '?':
- option_data.print_help = true;
- break;
-
- case 'h':
- option_data.print_help = true;
- break;
-
- case 'v':
- option_data.verbose = true;
- break;
-
- case 'c': {
- SBFileSpec file(optarg);
- if (file.Exists())
- test.SetExecutablePath(optarg);
- else
- fprintf(stderr, "error: file specified in --clang (-c) option doesn't "
- "exist: '%s'\n",
- optarg);
- } break;
-
- case 'o':
- test.SetResultFilePath(optarg);
- break;
-
- case 'd':
- test.SetUseDSYM(true);
- break;
-
- default:
- option_data.error = true;
- option_data.print_help = true;
- fprintf(stderr, "error: unrecognized option %c\n", short_option);
- break;
- }
- }
-
- if (test.GetExecutablePath() == NULL) {
- // --clang is mandatory
- option_data.print_help = true;
- option_data.error = true;
- fprintf(stderr, "error: the '--clang=PATH' option is mandatory\n");
- }
-
- if (option_data.print_help) {
- puts(R"(
-NAME
- lldb_perf_clang -- a tool that measures LLDB peformance while debugging clang.
-
-SYNOPSIS
- lldb_perf_clang --clang=PATH [--out-file=PATH --verbose --dsym] -- [clang options]
-
-DESCRIPTION
- Runs a set of static timing and memory tasks against clang and outputs results
- to a plist file.
-)");
- }
- if (option_data.error) {
- exit(1);
- }
-
- // Update argc and argv after parsing options
- argc -= optind;
- argv += optind;
-
- test.SetVerbose(true);
- TestCase::Run(test, argc, argv);
- return 0;
-}
Index: lldb/trunk/tools/lldb-perf/common/clang/main.cpp
===================================================================
--- lldb/trunk/tools/lldb-perf/common/clang/main.cpp
+++ lldb/trunk/tools/lldb-perf/common/clang/main.cpp
@@ -1,20 +0,0 @@
-#include
-#include
-#include
-
-namespace {
-struct Foo {
- int i;
- int j;
-};
-void doit(const Foo &foo) { printf("doit(%i)\n", foo.i); }
-}
-int main(int argc, char const *argv[], char const *envp[]) {
- std::vector ints;
- for (int i = 0; i < 10; ++i)
- ints.push_back(i);
- printf("hello world\n");
- Foo foo = {12, 13};
- doit(foo);
- return 0;
-}
Index: lldb/trunk/tools/lldb-perf/common/stepping/lldb-perf-stepping.cpp
===================================================================
--- lldb/trunk/tools/lldb-perf/common/stepping/lldb-perf-stepping.cpp
+++ lldb/trunk/tools/lldb-perf/common/stepping/lldb-perf-stepping.cpp
@@ -1,287 +0,0 @@
-#include
-
-#include "lldb-perf/lib/Measurement.h"
-#include "lldb-perf/lib/Metric.h"
-#include "lldb-perf/lib/TestCase.h"
-#include "lldb-perf/lib/Timer.h"
-#include "lldb-perf/lib/Xcode.h"
-
-#include
-#include
-#include
-
-using namespace lldb_perf;
-
-class StepTest : public TestCase {
- typedef void (*no_function)(void);
-
-public:
- StepTest(bool use_single_stepping = false)
- : m_main_source("stepping-testcase.cpp"),
- m_use_single_stepping(use_single_stepping),
- m_time_measurements(nullptr) {}
-
- virtual ~StepTest() {}
-
- virtual bool Setup(int &argc, const char **&argv) {
- TestCase::Setup(argc, argv);
-
- // Toggle the fast stepping command on or off as required.
- const char *single_step_cmd = "settings set target.use-fast-stepping false";
- const char *fast_step_cmd = "settings set target.use-fast-stepping true";
- const char *cmd_to_use;
-
- if (m_use_single_stepping)
- cmd_to_use = single_step_cmd;
- else
- cmd_to_use = fast_step_cmd;
-
- SBCommandReturnObject return_object;
- m_debugger.GetCommandInterpreter().HandleCommand(cmd_to_use, return_object);
- if (!return_object.Succeeded()) {
- if (return_object.GetError() != NULL)
- printf("Got an error running settings set: %s.\n",
- return_object.GetError());
- else
- printf("Failed running settings set, no error.\n");
- }
-
- m_target = m_debugger.CreateTarget(m_app_path.c_str());
- m_first_bp = m_target.BreakpointCreateBySourceRegex(
- "Here is some code to stop at originally.", m_main_source);
-
- const char *file_arg = m_app_path.c_str();
- const char *empty = nullptr;
- const char *args[] = {file_arg, empty};
- SBLaunchInfo launch_info(args);
-
- return Launch(launch_info);
- }
-
- void WriteResults(Results &results) {
- // Gotta turn off the last timer now.
- m_individual_step_times.push_back(m_time_measurements.Stop());
-
- size_t num_time_measurements = m_individual_step_times.size();
-
- Results::Dictionary &results_dict = results.GetDictionary();
- const char *short_format_string = "step-time-%0.2d";
- const size_t short_size = strlen(short_format_string) + 5;
- char short_buffer[short_size];
- const char *long_format_string =
- "The time it takes for step %d in the step sequence.";
- const size_t long_size = strlen(long_format_string) + 5;
- char long_buffer[long_size];
-
- for (size_t i = 0; i < num_time_measurements; i++) {
- snprintf(short_buffer, short_size, short_format_string, i);
- snprintf(long_buffer, long_size, long_format_string, i);
-
- results_dict.AddDouble(short_buffer, long_buffer,
- m_individual_step_times[i]);
- }
- results_dict.AddDouble("total-time", "Total time spent stepping.",
- m_time_measurements.GetMetric().GetSum());
- results_dict.AddDouble(
- "stddev-time", "StdDev of time spent stepping.",
- m_time_measurements.GetMetric().GetStandardDeviation());
-
- results.Write(m_out_path.c_str());
- }
-
- const char *GetExecutablePath() const {
- if (m_app_path.empty())
- return NULL;
- return m_app_path.c_str();
- }
-
- const char *GetResultFilePath() const {
- if (m_out_path.empty())
- return NULL;
- return m_out_path.c_str();
- }
-
- void SetExecutablePath(const char *path) {
- if (path && path[0])
- m_app_path = path;
- else
- m_app_path.clear();
- }
-
- void SetResultFilePath(const char *path) {
- if (path && path[0])
- m_out_path = path;
- else
- m_out_path.clear();
- }
-
- void SetUseSingleStep(bool use_it) { m_use_single_stepping = use_it; }
-
-private:
- virtual void TestStep(int counter, ActionWanted &next_action) {
- if (counter > 0) {
- m_individual_step_times.push_back(m_time_measurements.Stop());
- }
-
- // Disable the breakpoint, just in case it gets multiple locations we don't
- // want that confusing the stepping.
- if (counter == 0)
- m_first_bp.SetEnabled(false);
-
- next_action.StepOver(m_process.GetThreadAtIndex(0));
- m_time_measurements.Start();
- }
-
- SBBreakpoint m_first_bp;
- SBFileSpec m_main_source;
- TimeMeasurement m_time_measurements;
- std::vector m_individual_step_times;
- bool m_use_single_stepping;
- std::string m_app_path;
- std::string m_out_path;
-};
-
-struct Options {
- std::string test_file_path;
- std::string out_file;
- bool verbose;
- bool fast_step;
- bool error;
- bool print_help;
-
- Options()
- : verbose(false), fast_step(true), error(false), print_help(false) {}
-};
-
-static struct option g_long_options[] = {
- {"verbose", no_argument, NULL, 'v'},
- {"single-step", no_argument, NULL, 's'},
- {"test-file", required_argument, NULL, 't'},
- {"out-file", required_argument, NULL, 'o'},
- {NULL, 0, NULL, 0}};
-
-std::string GetShortOptionString(struct option *long_options) {
- std::string option_string;
- for (int i = 0; long_options[i].name != NULL; ++i) {
- if (long_options[i].flag == NULL) {
- option_string.push_back((char)long_options[i].val);
- switch (long_options[i].has_arg) {
- default:
- case no_argument:
- break;
- case required_argument:
- option_string.push_back(':');
- break;
- case optional_argument:
- option_string.append(2, ':');
- break;
- }
- }
- }
- return option_string;
-}
-
-int main(int argc, const char *argv[]) {
-
- // Prepare for & make calls to getopt_long_only.
-
- std::string short_option_string(GetShortOptionString(g_long_options));
-
- StepTest test;
-
- Options option_data;
- bool done = false;
-
-#if __GLIBC__
- optind = 0;
-#else
- optreset = 1;
- optind = 1;
-#endif
- while (!done) {
- int long_options_index = -1;
- const int short_option = ::getopt_long_only(
- argc, const_cast(argv), short_option_string.c_str(),
- g_long_options, &long_options_index);
-
- switch (short_option) {
- case 0:
- // Already handled
- break;
-
- case -1:
- done = true;
- break;
-
- case '?':
- option_data.print_help = true;
- break;
-
- case 'h':
- option_data.print_help = true;
- break;
-
- case 'v':
- option_data.verbose = true;
- break;
-
- case 's':
- option_data.fast_step = false;
- test.SetUseSingleStep(true);
- break;
-
- case 't': {
- SBFileSpec file(optarg);
- if (file.Exists())
- test.SetExecutablePath(optarg);
- else
- fprintf(stderr, "error: file specified in --test-file (-t) option "
- "doesn't exist: '%s'\n",
- optarg);
- } break;
-
- case 'o':
- test.SetResultFilePath(optarg);
- break;
-
- default:
- option_data.error = true;
- option_data.print_help = true;
- fprintf(stderr, "error: unrecognized option %c\n", short_option);
- break;
- }
- }
-
- if (option_data.print_help) {
- puts(R"(
-NAME
- lldb-perf-stepping -- a tool that measures LLDB peformance of simple stepping operations.
-
-SYNOPSIS
- lldb-perf-stepping --test-file=FILE [--out-file=PATH --verbose --fast-step]
-
-DESCRIPTION
- Runs a set of stepping operations, timing each step and outputs results
- to a plist file.
-)");
- exit(0);
- }
- if (option_data.error) {
- exit(1);
- }
-
- if (test.GetExecutablePath() == NULL) {
- // --clang is mandatory
- option_data.print_help = true;
- option_data.error = true;
- fprintf(stderr, "error: the '--test-file=PATH' option is mandatory\n");
- }
-
- // Update argc and argv after parsing options
- argc -= optind;
- argv += optind;
-
- test.SetVerbose(true);
- TestCase::Run(test, argc, argv);
- return 0;
-}
Index: lldb/trunk/tools/lldb-perf/common/stepping/stepping-testcase.cpp
===================================================================
--- lldb/trunk/tools/lldb-perf/common/stepping/stepping-testcase.cpp
+++ lldb/trunk/tools/lldb-perf/common/stepping/stepping-testcase.cpp
@@ -1,35 +0,0 @@
-#include
-#include
-#include
-
-struct struct_for_copying {
- struct_for_copying(int in_int, double in_double, const char *in_string)
- : int_value(in_int), double_value(in_double), string_value(in_string) {}
- struct_for_copying() { struct_for_copying(0, 0, ""); }
-
- int int_value;
- double double_value;
- std::string string_value;
-};
-
-int main(int argc, char **argv) {
- struct_for_copying input_struct(150 * argc, 10.0 * argc, argv[0]);
- struct_for_copying output_struct;
- int some_int = 44;
- double some_double = 34.5;
- double other_double;
- size_t vector_size;
- std::vector my_vector;
-
- printf("Here is some code to stop at originally. Got: %d, %p.\n", argc,
- argv);
- output_struct = input_struct;
- other_double = (some_double * some_int) / ((double)argc);
- other_double = other_double > 0
- ? some_double / other_double
- : some_double > 0 ? other_double / some_double : 10.0;
- my_vector.push_back(input_struct);
- vector_size = my_vector.size();
-
- return vector_size == 0 ? 0 : 1;
-}
Index: lldb/trunk/tools/lldb-perf/darwin/formatters/fmts_tester.mm
===================================================================
--- lldb/trunk/tools/lldb-perf/darwin/formatters/fmts_tester.mm
+++ lldb/trunk/tools/lldb-perf/darwin/formatters/fmts_tester.mm
@@ -1,81 +0,0 @@
-//===-- fmts_tester.cpp -----------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#import
-#include
-#include