[Lldb-commits] [PATCH] D61240: Implement GetSystemIncludeDirectories for macOS
teemperor created this revision. teemperor added a reviewer: aprantl. Herald added subscribers: lldb-commits, abidh. Herald added a project: LLDB. `GetSystemIncludeDirectories` is currently only implemented for Linux where it returns `/usr/include` with a potential sysroot as a prefix. This patch implements the equivalent functionality on macOS. Repository: rLLDB LLDB https://reviews.llvm.org/D61240 Files: lldb/include/lldb/Target/Platform.h lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp lldb/source/Plugins/Platform/Linux/PlatformLinux.h lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h Index: lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h === --- lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h +++ lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h @@ -69,6 +69,10 @@ lldb_private::ConstString GetSDKDirectory(lldb_private::Target &target) override; + std::vector + GetSystemIncludeDirectories(lldb::LanguageType lang, + lldb_private::Target &target) override; + void AddClangModuleCompilationOptions(lldb_private::Target *target, std::vector &options) override { Index: lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp === --- lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp +++ lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp @@ -226,6 +226,27 @@ return ConstString(); } +std::vector +PlatformMacOSX::GetSystemIncludeDirectories(LanguageType lang, +lldb_private::Target &target) { + std::string sys_root = GetSDKDirectory(target).AsCString(""); + switch (lang) { + case lldb::eLanguageTypeC: + case lldb::eLanguageTypeC89: + case lldb::eLanguageTypeC99: + case lldb::eLanguageTypeC11: + case lldb::eLanguageTypeC_plus_plus: + case lldb::eLanguageTypeC_plus_plus_03: + case lldb::eLanguageTypeC_plus_plus_11: + case lldb::eLanguageTypeC_plus_plus_14: + case lldb::eLanguageTypeObjC: + case lldb::eLanguageTypeObjC_plus_plus: +return {sys_root + "/usr/include/"}; + default: +return {}; + } +} + Status PlatformMacOSX::GetSymbolFile(const FileSpec &platform_file, const UUID *uuid_ptr, FileSpec &local_file) { Index: lldb/source/Plugins/Platform/Linux/PlatformLinux.h === --- lldb/source/Plugins/Platform/Linux/PlatformLinux.h +++ lldb/source/Plugins/Platform/Linux/PlatformLinux.h @@ -49,7 +49,8 @@ bool CanDebugProcess() override; std::vector - GetSystemIncludeDirectories(lldb::LanguageType lang) override; + GetSystemIncludeDirectories(lldb::LanguageType lang, + lldb_private::Target &target) override; lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, Target *target, Index: lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp === --- lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -261,7 +261,8 @@ } std::vector -PlatformLinux::GetSystemIncludeDirectories(lldb::LanguageType lang) { +PlatformLinux::GetSystemIncludeDirectories(lldb::LanguageType lang, + lldb_private::Target &target) { std::string sys_root = GetSDKRootDirectory().AsCString(""); switch (lang) { case lldb::eLanguageTypeC: Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp === --- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -217,10 +217,9 @@ std::shared_ptr m_passthrough; }; -static void -SetupModuleHeaderPaths(CompilerInstance *compiler, - std::vector include_directories, - lldb::TargetSP target_sp) { +static void SetupModuleHeaderPaths(CompilerInstance *compiler, + std::vector include_directories, + lldb_private::Target &target) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); HeaderSearchOptions &search_opts = compiler->getHeaderSearchOpts(); @@ -249,8 +248,8 @@ search_opts.ImplicitModuleMaps = true; std::vector system_include_directories = - target_sp->GetPlatform()->GetSystemIncludeDirectories( - lldb::eLanguageTypeC_plus_plus); + target.GetPlatform()->GetSystemIncludeDirectories( + lldb::eLanguageTypeC_plus_plus,
[Lldb-commits] [PATCH] D61235: Add more information to the log timer dump
teemperor added a comment. Could you provide a test? There are some existing tests for Timer in `lldb/unittests/Utility/TimerTest.cpp` which you can extend. You can run/compile these tests via `LIT_FILTER="TimerTest" make check-lldb`. (I also believe this patch breaks `TimerTest` as it checks the output of `DumpCategoryTimes`) Comment at: lldb/source/Utility/Timer.cpp:111 -typedef std::pair TimerEntry; +struct Stats { + uint64_t nanos; Can you move struct this into an anonymous namespace? Repository: rLLDB LLDB CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61235/new/ https://reviews.llvm.org/D61235 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D61231: Add 'oneOf' utility function for comparing a ConstString against a set of strings
JDevlieghere added a comment. I'm on the fence on this one. I think the `==` pattern attracts more attention to the fact that we are comparing strings. However, I also see the benefit, like in the example, where even a temporary variable wouldn't help much. Regarding the name, how would you feel about `anyOf` instead? Although not relevant here, it has a nice duality with `allOf`. I think this is what the AST matchers use. Repository: rLLDB LLDB CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61231/new/ https://reviews.llvm.org/D61231 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D61231: Add 'oneOf' utility function for comparing a ConstString against a set of strings
teemperor added a comment. Yeah, I'm also just like 60% confident that this more readable/expressive. `anyOf` sounds good to me. Will update the patch in case this gets community approval. Repository: rLLDB LLDB CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61231/new/ https://reviews.llvm.org/D61231 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D61244: Re-enable gmodules tests on Linux
teemperor created this revision. teemperor added a reviewer: labath. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. teemperor edited the summary of this revision. These tests are not failing for me on (Arch) Linux, so I would suggest that we re-enable them. See also http://llvm.org/pr36107 which is the reason we disabled them. Repository: rLLDB LLDB https://reviews.llvm.org/D61244 Files: lldb/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/TestGModules.py lldb/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py Index: lldb/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py === --- lldb/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py +++ lldb/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py @@ -9,7 +9,6 @@ mydir = TestBase.compute_mydir(__file__) -@skipIf(bugnumber="llvm.org/pr36146", oslist=["linux"], archs=["i386"]) @add_test_categories(["gmodules"]) def test_specialized_typedef_from_pch(self): self.build() Index: lldb/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/TestGModules.py === --- lldb/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/TestGModules.py +++ lldb/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/TestGModules.py @@ -1,6 +1,3 @@ import lldbsuite.test.lldbinline as lldbinline -from lldbsuite.test.decorators import * -lldbinline.MakeInlineTest(__file__, globals(), [ -expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr36107", -debug_info="gmodules")]) +lldbinline.MakeInlineTest(__file__, globals()) Index: lldb/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py === --- lldb/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py +++ lldb/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py @@ -9,7 +9,6 @@ mydir = TestBase.compute_mydir(__file__) -@skipIf(bugnumber="llvm.org/pr36146", oslist=["linux"], archs=["i386"]) @add_test_categories(["gmodules"]) def test_specialized_typedef_from_pch(self): self.build() Index: lldb/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/TestGModules.py === --- lldb/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/TestGModules.py +++ lldb/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/TestGModules.py @@ -1,6 +1,3 @@ import lldbsuite.test.lldbinline as lldbinline -from lldbsuite.test.decorators import * -lldbinline.MakeInlineTest(__file__, globals(), [ -expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr36107", -debug_info="gmodules")]) +lldbinline.MakeInlineTest(__file__, globals()) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D61244: Re-enable gmodules tests on Linux
davide accepted this revision. davide added a comment. This revision is now accepted and ready to land. LGTM Repository: rLLDB LLDB CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61244/new/ https://reviews.llvm.org/D61244 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D61247: Add more information to the log timer dump
aadsm created this revision. Herald added subscribers: lldb-commits, jfb, erik.pilkington, aprantl. Herald added a project: LLDB. aadsm abandoned this revision. The `log timer dump` is showing the time of the function itself minus any function that is called from this one that also happens to be timed. However, this is really not obvious and it also makes it hard to understand the time spent in total and also which children are actually taking the time. To get a better reading of the timer dump I added the total, children (which I abbreviated to child) and also the hit count. I used these timers to figure out a performance issue and only after adding this things were more clear to me. It looks like this: (lldb) log timer dump 35.447713617 sec (total: 35.449s; child: 0.001s; count: 1374) for void SymbolFileDWARF::Index() 29.717921481 sec (total: 29.718s; child: 0.000s; count: 8230500) for const lldb_private::ConstString &lldb_private::Mangled::GetDemangledName(lldb::LanguageType) const 21.049508865 sec (total: 24.683s; child: 3.633s; count: 1399) for void lldb_private::Symtab::InitNameIndexes() ... Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D61247 Files: lldb/include/lldb/Utility/Timer.h lldb/source/Utility/Timer.cpp lldb/unittests/Utility/TimerTest.cpp Index: lldb/unittests/Utility/TimerTest.cpp === --- lldb/unittests/Utility/TimerTest.cpp +++ lldb/unittests/Utility/TimerTest.cpp @@ -61,7 +61,9 @@ StreamString ss; Timer::DumpCategoryTimes(&ss); double seconds1, seconds2; - ASSERT_EQ(2, sscanf(ss.GetData(), "%lf sec for CAT1%*[\n ]%lf sec for CAT2", + ASSERT_EQ(2, sscanf(ss.GetData(), + "%lf sec (total: %*lfs; child: %*lfs; count: %*d) for " + "CAT1%*[\n ]%lf sec for CAT2", &seconds1, &seconds2)) << "String: " << ss.GetData(); EXPECT_LT(0.01, seconds1); @@ -69,3 +71,36 @@ EXPECT_LT(0.001, seconds2); EXPECT_GT(0.1, seconds2); } + +TEST(TimerTest, CategoryTimesStats) { + Timer::ResetCategoryTimes(); + { +static Timer::Category tcat1("CAT1"); +Timer t1(tcat1, "."); +std::this_thread::sleep_for(std::chrono::milliseconds(100)); +static Timer::Category tcat2("CAT2"); +Timer t2(tcat2, "."); +std::this_thread::sleep_for(std::chrono::milliseconds(10)); +Timer t3(tcat2, "."); +std::this_thread::sleep_for(std::chrono::milliseconds(10)); + } + // Example output: + // 0.102982273 sec (total: 0.126s; child: 0.023s; count: 1) for CAT1 + // 0.023058228 sec (total: 0.036s; child: 0.012s; count: 2) for CAT2 + StreamString ss; + Timer::DumpCategoryTimes(&ss); + double seconds1, total1, child1, seconds2; + int count1, count2; + ASSERT_EQ( + 6, sscanf(ss.GetData(), +"%lf sec (total: %lfs; child: %lfs; count: %d) for CAT1%*[\n " +"]%lf sec (total: %*lfs; child: %*lfs; count: %d) for CAT2", +&seconds1, &total1, &child1, &count1, &seconds2, &count2)) + << "String: " << ss.GetData(); + EXPECT_GT(total1 - child1, seconds1 - 0.001); + EXPECT_LT(total1 - child1, seconds1 + 0.001); + EXPECT_EQ(1, count1); + EXPECT_GT(child1, seconds2 - 0.001); + EXPECT_LT(child1, seconds2 + 0.001); + EXPECT_EQ(2, count2); +} Index: lldb/source/Utility/Timer.cpp === --- lldb/source/Utility/Timer.cpp +++ lldb/source/Utility/Timer.cpp @@ -41,6 +41,9 @@ Timer::Category::Category(const char *cat) : m_name(cat) { m_nanos.store(0, std::memory_order_release); + m_nanos_total.store(0, std::memory_order_release); + m_nanos_child.store(0, std::memory_order_release); + m_count.store(0, std::memory_order_release); Category *expected = g_categories; do { m_next = expected; @@ -93,6 +96,10 @@ // Keep total results for each category so we can dump results. m_category.m_nanos += std::chrono::nanoseconds(timer_dur).count(); + m_category.m_nanos_total += std::chrono::nanoseconds(total_dur).count(); + m_category.m_nanos_child += + std::chrono::nanoseconds(m_child_duration).count(); + m_category.m_count++; } void Timer::SetDisplayDepth(uint32_t depth) { g_display_depth = depth; } @@ -101,24 +108,38 @@ * - returns whether a person is less than another person */ -typedef std::pair TimerEntry; +struct Stats { + uint64_t nanos; + uint64_t nanos_total; + uint64_t nanos_child; + uint64_t count; +}; +typedef std::pair TimerEntry; static bool CategoryMapIteratorSortCriterion(const TimerEntry &lhs, const TimerEntry &rhs) { - return lhs.second > rhs.second; + return lhs.second.nanos > rhs.second.nanos; } void Timer::ResetCategoryTimes() { - for (Category *i = g_categories; i; i = i->m_next) + for (Category *i = g_categories; i; i = i->m_next) { i->m_nanos.store(0, std::memory_order_release); +i-
[Lldb-commits] [PATCH] D61235: Add more information to the log timer dump
aadsm updated this revision to Diff 197048. aadsm added a comment. Fix and add unit test Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61235/new/ https://reviews.llvm.org/D61235 Files: lldb/include/lldb/Utility/Timer.h lldb/source/Utility/Timer.cpp lldb/unittests/Utility/TimerTest.cpp Index: lldb/unittests/Utility/TimerTest.cpp === --- lldb/unittests/Utility/TimerTest.cpp +++ lldb/unittests/Utility/TimerTest.cpp @@ -61,7 +61,9 @@ StreamString ss; Timer::DumpCategoryTimes(&ss); double seconds1, seconds2; - ASSERT_EQ(2, sscanf(ss.GetData(), "%lf sec for CAT1%*[\n ]%lf sec for CAT2", + ASSERT_EQ(2, sscanf(ss.GetData(), + "%lf sec (total: %*lfs; child: %*lfs; count: %*d) for " + "CAT1%*[\n ]%lf sec for CAT2", &seconds1, &seconds2)) << "String: " << ss.GetData(); EXPECT_LT(0.01, seconds1); @@ -69,3 +71,36 @@ EXPECT_LT(0.001, seconds2); EXPECT_GT(0.1, seconds2); } + +TEST(TimerTest, CategoryTimesStats) { + Timer::ResetCategoryTimes(); + { +static Timer::Category tcat1("CAT1"); +Timer t1(tcat1, "."); +std::this_thread::sleep_for(std::chrono::milliseconds(100)); +static Timer::Category tcat2("CAT2"); +Timer t2(tcat2, "."); +std::this_thread::sleep_for(std::chrono::milliseconds(10)); +Timer t3(tcat2, "."); +std::this_thread::sleep_for(std::chrono::milliseconds(10)); + } + // Example output: + // 0.102982273 sec (total: 0.126s; child: 0.023s; count: 1) for CAT1 + // 0.023058228 sec (total: 0.036s; child: 0.012s; count: 2) for CAT2 + StreamString ss; + Timer::DumpCategoryTimes(&ss); + double seconds1, total1, child1, seconds2; + int count1, count2; + ASSERT_EQ( + 6, sscanf(ss.GetData(), +"%lf sec (total: %lfs; child: %lfs; count: %d) for CAT1%*[\n " +"]%lf sec (total: %*lfs; child: %*lfs; count: %d) for CAT2", +&seconds1, &total1, &child1, &count1, &seconds2, &count2)) + << "String: " << ss.GetData(); + EXPECT_GT(total1 - child1, seconds1 - 0.001); + EXPECT_LT(total1 - child1, seconds1 + 0.001); + EXPECT_EQ(1, count1); + EXPECT_GT(child1, seconds2 - 0.001); + EXPECT_LT(child1, seconds2 + 0.001); + EXPECT_EQ(2, count2); +} Index: lldb/source/Utility/Timer.cpp === --- lldb/source/Utility/Timer.cpp +++ lldb/source/Utility/Timer.cpp @@ -41,6 +41,9 @@ Timer::Category::Category(const char *cat) : m_name(cat) { m_nanos.store(0, std::memory_order_release); + m_nanos_total.store(0, std::memory_order_release); + m_nanos_child.store(0, std::memory_order_release); + m_count.store(0, std::memory_order_release); Category *expected = g_categories; do { m_next = expected; @@ -93,6 +96,10 @@ // Keep total results for each category so we can dump results. m_category.m_nanos += std::chrono::nanoseconds(timer_dur).count(); + m_category.m_nanos_total += std::chrono::nanoseconds(total_dur).count(); + m_category.m_nanos_child += + std::chrono::nanoseconds(m_child_duration).count(); + m_category.m_count++; } void Timer::SetDisplayDepth(uint32_t depth) { g_display_depth = depth; } @@ -101,24 +108,38 @@ * - returns whether a person is less than another person */ -typedef std::pair TimerEntry; +struct Stats { + uint64_t nanos; + uint64_t nanos_total; + uint64_t nanos_child; + uint64_t count; +}; +typedef std::pair TimerEntry; static bool CategoryMapIteratorSortCriterion(const TimerEntry &lhs, const TimerEntry &rhs) { - return lhs.second > rhs.second; + return lhs.second.nanos > rhs.second.nanos; } void Timer::ResetCategoryTimes() { - for (Category *i = g_categories; i; i = i->m_next) + for (Category *i = g_categories; i; i = i->m_next) { i->m_nanos.store(0, std::memory_order_release); +i->m_nanos_total.store(0, std::memory_order_release); +i->m_nanos_child.store(0, std::memory_order_release); +i->m_count.store(0, std::memory_order_release); + } } void Timer::DumpCategoryTimes(Stream *s) { std::vector sorted; for (Category *i = g_categories; i; i = i->m_next) { uint64_t nanos = i->m_nanos.load(std::memory_order_acquire); +uint64_t nanos_total = i->m_nanos_total.load(std::memory_order_acquire); +uint64_t nanos_child = i->m_nanos_child.load(std::memory_order_acquire); +uint64_t count = i->m_count.load(std::memory_order_acquire); +Stats stats{nanos, nanos_total, nanos_child, count}; if (nanos) - sorted.push_back(std::make_pair(i->m_name, nanos)); + sorted.push_back(std::make_pair(i->m_name, stats)); } if (sorted.empty()) return; // Later code will break without any elements. @@ -127,5 +148,9 @@ llvm::sort(sorted.begin(), sorted.end(), CategoryMapIteratorSortCriterion); for (const a
[Lldb-commits] [PATCH] D61235: Add more information to the log timer dump
aadsm updated this revision to Diff 197049. aadsm added a comment. Move struct to anonymous namespace Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61235/new/ https://reviews.llvm.org/D61235 Files: lldb/include/lldb/Utility/Timer.h lldb/source/Utility/Timer.cpp lldb/unittests/Utility/TimerTest.cpp Index: lldb/unittests/Utility/TimerTest.cpp === --- lldb/unittests/Utility/TimerTest.cpp +++ lldb/unittests/Utility/TimerTest.cpp @@ -61,7 +61,9 @@ StreamString ss; Timer::DumpCategoryTimes(&ss); double seconds1, seconds2; - ASSERT_EQ(2, sscanf(ss.GetData(), "%lf sec for CAT1%*[\n ]%lf sec for CAT2", + ASSERT_EQ(2, sscanf(ss.GetData(), + "%lf sec (total: %*lfs; child: %*lfs; count: %*d) for " + "CAT1%*[\n ]%lf sec for CAT2", &seconds1, &seconds2)) << "String: " << ss.GetData(); EXPECT_LT(0.01, seconds1); @@ -69,3 +71,36 @@ EXPECT_LT(0.001, seconds2); EXPECT_GT(0.1, seconds2); } + +TEST(TimerTest, CategoryTimesStats) { + Timer::ResetCategoryTimes(); + { +static Timer::Category tcat1("CAT1"); +Timer t1(tcat1, "."); +std::this_thread::sleep_for(std::chrono::milliseconds(100)); +static Timer::Category tcat2("CAT2"); +Timer t2(tcat2, "."); +std::this_thread::sleep_for(std::chrono::milliseconds(10)); +Timer t3(tcat2, "."); +std::this_thread::sleep_for(std::chrono::milliseconds(10)); + } + // Example output: + // 0.102982273 sec (total: 0.126s; child: 0.023s; count: 1) for CAT1 + // 0.023058228 sec (total: 0.036s; child: 0.012s; count: 2) for CAT2 + StreamString ss; + Timer::DumpCategoryTimes(&ss); + double seconds1, total1, child1, seconds2; + int count1, count2; + ASSERT_EQ( + 6, sscanf(ss.GetData(), +"%lf sec (total: %lfs; child: %lfs; count: %d) for CAT1%*[\n " +"]%lf sec (total: %*lfs; child: %*lfs; count: %d) for CAT2", +&seconds1, &total1, &child1, &count1, &seconds2, &count2)) + << "String: " << ss.GetData(); + EXPECT_GT(total1 - child1, seconds1 - 0.001); + EXPECT_LT(total1 - child1, seconds1 + 0.001); + EXPECT_EQ(1, count1); + EXPECT_GT(child1, seconds2 - 0.001); + EXPECT_LT(child1, seconds2 + 0.001); + EXPECT_EQ(2, count2); +} Index: lldb/source/Utility/Timer.cpp === --- lldb/source/Utility/Timer.cpp +++ lldb/source/Utility/Timer.cpp @@ -41,6 +41,9 @@ Timer::Category::Category(const char *cat) : m_name(cat) { m_nanos.store(0, std::memory_order_release); + m_nanos_total.store(0, std::memory_order_release); + m_nanos_child.store(0, std::memory_order_release); + m_count.store(0, std::memory_order_release); Category *expected = g_categories; do { m_next = expected; @@ -93,6 +96,10 @@ // Keep total results for each category so we can dump results. m_category.m_nanos += std::chrono::nanoseconds(timer_dur).count(); + m_category.m_nanos_total += std::chrono::nanoseconds(total_dur).count(); + m_category.m_nanos_child += + std::chrono::nanoseconds(m_child_duration).count(); + m_category.m_count++; } void Timer::SetDisplayDepth(uint32_t depth) { g_display_depth = depth; } @@ -100,25 +107,40 @@ /* binary function predicate: * - returns whether a person is less than another person */ - -typedef std::pair TimerEntry; +namespace { +struct Stats { + uint64_t nanos; + uint64_t nanos_total; + uint64_t nanos_child; + uint64_t count; +}; +} // namespace +typedef std::pair TimerEntry; static bool CategoryMapIteratorSortCriterion(const TimerEntry &lhs, const TimerEntry &rhs) { - return lhs.second > rhs.second; + return lhs.second.nanos > rhs.second.nanos; } void Timer::ResetCategoryTimes() { - for (Category *i = g_categories; i; i = i->m_next) + for (Category *i = g_categories; i; i = i->m_next) { i->m_nanos.store(0, std::memory_order_release); +i->m_nanos_total.store(0, std::memory_order_release); +i->m_nanos_child.store(0, std::memory_order_release); +i->m_count.store(0, std::memory_order_release); + } } void Timer::DumpCategoryTimes(Stream *s) { std::vector sorted; for (Category *i = g_categories; i; i = i->m_next) { uint64_t nanos = i->m_nanos.load(std::memory_order_acquire); +uint64_t nanos_total = i->m_nanos_total.load(std::memory_order_acquire); +uint64_t nanos_child = i->m_nanos_child.load(std::memory_order_acquire); +uint64_t count = i->m_count.load(std::memory_order_acquire); +Stats stats{nanos, nanos_total, nanos_child, count}; if (nanos) - sorted.push_back(std::make_pair(i->m_name, nanos)); + sorted.push_back(std::make_pair(i->m_name, stats)); } if (sorted.empty()) return; // Later code will break without any elements. @@ -127,5 +149,9 @@ llvm::sort(sorted.be
[Lldb-commits] [PATCH] D61235: Add more information to the log timer dump
davide added inline comments. Comment at: lldb/unittests/Utility/TimerTest.cpp:100-101 + << "String: " << ss.GetData(); + EXPECT_GT(total1 - child1, seconds1 - 0.001); + EXPECT_LT(total1 - child1, seconds1 + 0.001); + EXPECT_EQ(1, count1); this seems ... very fragile. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61235/new/ https://reviews.llvm.org/D61235 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D61235: Add more information to the log timer dump
aadsm marked an inline comment as done. aadsm added inline comments. Comment at: lldb/unittests/Utility/TimerTest.cpp:100-101 + << "String: " << ss.GetData(); + EXPECT_GT(total1 - child1, seconds1 - 0.001); + EXPECT_LT(total1 - child1, seconds1 + 0.001); + EXPECT_EQ(1, count1); davide wrote: > this seems ... very fragile. that's a good point. I'm not that familiar with the ieee754 to know what's a safe interval here, do you know? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61235/new/ https://reviews.llvm.org/D61235 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D56229: [PECOFF] Implementation of ObjectFilePECOFF:: GetUUID()
labath accepted this revision. labath added inline comments. This revision is now accepted and ready to land. Comment at: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp:81 +info.Age = read32be(&pdb_info->PDB70.Age); +return UUID::fromOptionalData((uint8_t *)&info, sizeof(info)); + } this cast is unneeded as the function takes a `void*` Comment at: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp:176-177 + auto COFFObj = + llvm::dyn_cast(binary->getBinary()); + assert(COFFObj); + If you change the `dyn_cast` into a plain `cast` then you can drop the assert (as it will do the asserting for you). CHANGES SINCE LAST ACTION https://reviews.llvm.org/D56229/new/ https://reviews.llvm.org/D56229 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits