[Lldb-commits] [lldb] b4583a5 - Revert "Allow signposts to take advantage of deferred string substitution"

2021-06-12 Thread Florian Hahn via lldb-commits

Author: Florian Hahn
Date: 2021-06-12T12:08:25+01:00
New Revision: b4583a5ad73b633c3eac5ffbad93f2405e1418ab

URL: 
https://github.com/llvm/llvm-project/commit/b4583a5ad73b633c3eac5ffbad93f2405e1418ab
DIFF: 
https://github.com/llvm/llvm-project/commit/b4583a5ad73b633c3eac5ffbad93f2405e1418ab.diff

LOG: Revert "Allow signposts to take advantage of deferred string substitution"

This reverts commit 4fc93a3a1f95ef5a0a57750fc621f2411ea445a8 because it
breaks LLDB builds on certain macOS platform & SDK combinations, e.g.
http://green.lab.llvm.org/green/job/lldb-cmake-standalone/3288/consoleFull#-195476041949ba4694-19c4-4d7e-bec5-911270d8a58c

Added: 


Modified: 
lldb/include/lldb/Utility/Timer.h
lldb/source/Utility/Timer.cpp
llvm/include/llvm/Support/Signposts.h
llvm/lib/Support/Signposts.cpp
llvm/lib/Support/Timer.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Timer.h 
b/lldb/include/lldb/Utility/Timer.h
index 1e47ac7afc82b..2b39881de89ec 100644
--- a/lldb/include/lldb/Utility/Timer.h
+++ b/lldb/include/lldb/Utility/Timer.h
@@ -10,16 +10,10 @@
 #define LLDB_UTILITY_TIMER_H
 
 #include "lldb/lldb-defines.h"
-#include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/Chrono.h"
-#include "llvm/Support/Signposts.h"
 #include 
 #include 
 
-namespace llvm {
-  class SignpostEmitter;
-}
-
 namespace lldb_private {
 class Stream;
 
@@ -78,28 +72,15 @@ class Timer {
   const Timer &operator=(const Timer &) = delete;
 };
 
-llvm::SignpostEmitter &GetSignposts();
-
 } // namespace lldb_private
 
 // Use a format string because LLVM_PRETTY_FUNCTION might not be a string
 // literal.
 #define LLDB_SCOPED_TIMER()
\
   static ::lldb_private::Timer::Category _cat(LLVM_PRETTY_FUNCTION);   
\
-  ::lldb_private::Timer _scoped_timer(_cat, "%s", LLVM_PRETTY_FUNCTION);   
\
-  SIGNPOST_EMITTER_START_INTERVAL(::lldb_private::GetSignposts(),  
\
-  &_scoped_timer, "%s", LLVM_PRETTY_FUNCTION); 
\
-  auto _scoped_signpost = llvm::make_scope_exit([&_scoped_timer]() {   
\
-::lldb_private::GetSignposts().endInterval(&_scoped_timer);
\
-  })
-
-#define LLDB_SCOPED_TIMERF(FMT, ...)   
\
+  ::lldb_private::Timer _scoped_timer(_cat, "%s", LLVM_PRETTY_FUNCTION)
+#define LLDB_SCOPED_TIMERF(...)
\
   static ::lldb_private::Timer::Category _cat(LLVM_PRETTY_FUNCTION);   
\
-  ::lldb_private::Timer _scoped_timer(_cat, FMT, __VA_ARGS__); 
\
-  SIGNPOST_EMITTER_START_INTERVAL(::lldb_private::GetSignposts(),  
\
-  &_scoped_timer, FMT, __VA_ARGS__);   
\
-  auto _scoped_signpost = llvm::make_scope_exit([&_scoped_timer]() {   
\
-::lldb_private::GetSignposts().endInterval(&_scoped_timer);
\
-  })
+  ::lldb_private::Timer _scoped_timer(_cat, __VA_ARGS__)
 
 #endif // LLDB_UTILITY_TIMER_H

diff  --git a/lldb/source/Utility/Timer.cpp b/lldb/source/Utility/Timer.cpp
index b59ce3b9f5563..2f3afe4c87037 100644
--- a/lldb/source/Utility/Timer.cpp
+++ b/lldb/source/Utility/Timer.cpp
@@ -33,8 +33,6 @@ static std::atomic g_categories;
 /// Allows llvm::Timer to emit signposts when supported.
 static llvm::ManagedStatic Signposts;
 
-llvm::SignpostEmitter &lldb_private::GetSignposts() { return *Signposts; }
-
 std::atomic Timer::g_quiet(true);
 std::atomic Timer::g_display_depth(0);
 static std::mutex &GetFileMutex() {
@@ -61,6 +59,7 @@ void Timer::SetQuiet(bool value) { g_quiet = value; }
 
 Timer::Timer(Timer::Category &category, const char *format, ...)
 : m_category(category), m_total_start(std::chrono::steady_clock::now()) {
+  Signposts->startInterval(this, m_category.GetName());
   TimerStack &stack = GetTimerStackForCurrentThread();
 
   stack.push_back(this);
@@ -87,6 +86,8 @@ Timer::~Timer() {
   auto total_dur = stop_time - m_total_start;
   auto timer_dur = total_dur - m_child_duration;
 
+  Signposts->endInterval(this, m_category.GetName());
+
   TimerStack &stack = GetTimerStackForCurrentThread();
   if (g_quiet && stack.size() <= g_display_depth) {
 std::lock_guard lock(GetFileMutex());

diff  --git a/llvm/include/llvm/Support/Signposts.h 
b/llvm/include/llvm/Support/Signposts.h
index be01eb7854e5a..d31f3c1e6eb55 100644
--- a/llvm/include/llvm/Support/Signposts.h
+++ b/llvm/include/llvm/Support/Signposts.h
@@ -18,17 +18,8 @@
 #define LLVM_SUPPORT_SIGNPOSTS_H
 
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Config/config.h"
 #include 
 
-#if LLVM_SUPPORT_XCODE_SIGNPOSTS
-#include 
-#include 
-#endif
-
-#define SIGNPOSTS_AVAILABLE()  
\
-  __builtin_available(macos 10.14, iOS 12, tvOS 12, watchOS 5, *)
-
 namespace llvm {
 class SignpostEmitterImpl;
 
@@ 

[Lldb-commits] [PATCH] D103575: Allow signposts to take advantage of deferred string substitution

2021-06-12 Thread Florian Hahn via Phabricator via lldb-commits
fhahn added a comment.

It looks like this is causing build failures on certain macOS / SDK 
combinations, e.g. 
http://green.lab.llvm.org/green/job/lldb-cmake-standalone/3288/consoleFull#-195476041949ba4694-19c4-4d7e-bec5-911270d8a58c

I reverted the change for now in b4583a5ad73b 


  
/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/host-compiler/bin/clang++
  -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -D_DEBUG -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Isource/Plugins/ObjectFile/Mach-O 
-I/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/llvm-project/lldb/source/Plugins/ObjectFile/Mach-O
 -Isource 
-I/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/llvm-project/lldb/include
 -Iinclude 
-I/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/llvm-project/llvm/include
 
-I/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/clang-build/include 
-I/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/llvm-project/clang/include
 
-I/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/clang-build/tools/clang/include
 
-I/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/include/python3.7m
 
-I/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/llvm-project/lldb/tools/clang/include
 -I../clang/include -I/usr/local/include 
-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/libxml2
 
-I/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/llvm-project/lldb/source/.
 -fPIC -fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -fdiagnostics-color -Wno-deprecated-declarations 
-Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register 
-Wno-vla-extension -O3 -DNDEBUG -isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
-fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT 
source/Plugins/ObjectFile/Mach-O/CMakeFiles/lldbPluginObjectFileMachO.dir/ObjectFileMachO.cpp.o
 -MF 
source/Plugins/ObjectFile/Mach-O/CMakeFiles/lldbPluginObjectFileMachO.dir/ObjectFileMachO.cpp.o.d
 -o 
source/Plugins/ObjectFile/Mach-O/CMakeFiles/lldbPluginObjectFileMachO.dir/ObjectFileMachO.cpp.o
 -c 
/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/llvm-project/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  In file included from 
/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/llvm-project/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp:45:
  In file included from 
/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/llvm-project/lldb/include/lldb/Host/SafeMachO.h:159:
  
  
/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/llvm-project/llvm/include/llvm/BinaryFormat/MachO.h:30:3:
 error: expected identifier
MH_MAGIC = 0xFEEDFACEu,
^
  
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/mach-o/loader.h:65:18:
 note: expanded from macro 'MH_MAGIC'
  #define MH_MAGIC0xfeedface  /* the mach magic number */
  ^
  In file included from 
/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/llvm-project/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp:45:
  In file included from 
/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/llvm-project/lldb/include/lldb/Host/SafeMachO.h:159:
  
/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/llvm-project/llvm/include/llvm/BinaryFormat/MachO.h:31:3:
 error: expected identifier
MH_CIGAM = 0xCEFAEDFEu,
^
  
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/mach-o/loader.h:66:18:
 note: expanded from macro 'MH_CIGAM'
  #define MH_CIGAM0xcefaedfe  /* NXSwapInt(MH_MAGIC) */
  ^
  In file included from 
/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/llvm-project/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp:45:
  In file included from 
/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/llvm-project/lldb/include/lldb/Host/SafeMachO.h:159:
  
/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/llvm-project/llvm/include/llvm/BinaryFormat/MachO.h:32:3:
 error: expected identifier
MH_MAGIC_64 = 0xFEEDFACFu,
^
  
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/mach-o/loader.h:84:21:
 note: expanded from macro 'MH_MAGIC_64'
  #define MH_MAGIC_64 0xfeedfacf /* the 64-bit mach magic number */
  ^
  In file included from 

[Lldb-commits] [PATCH] D104067: [lldb] Decouple ObjCLanguage from Symtab

2021-06-12 Thread Alex Langford via Phabricator via lldb-commits
bulbazord updated this revision to Diff 351696.
bulbazord added a comment.

Addressing comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104067/new/

https://reviews.llvm.org/D104067

Files:
  lldb/include/lldb/Target/Language.h
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
  lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
  lldb/source/Symbol/CMakeLists.txt
  lldb/source/Symbol/Symtab.cpp

Index: lldb/source/Symbol/Symtab.cpp
===
--- lldb/source/Symbol/Symtab.cpp
+++ lldb/source/Symbol/Symtab.cpp
@@ -9,8 +9,6 @@
 #include 
 #include 
 
-#include "Plugins/Language/ObjC/ObjCLanguage.h"
-
 #include "lldb/Core/Module.h"
 #include "lldb/Core/RichManglingContext.h"
 #include "lldb/Core/Section.h"
@@ -18,6 +16,7 @@
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Symbol/Symtab.h"
+#include "lldb/Target/Language.h"
 #include "lldb/Utility/RegularExpression.h"
 #include "lldb/Utility/Stream.h"
 #include "lldb/Utility/Timer.h"
@@ -330,14 +329,21 @@
 
 // If the demangled name turns out to be an ObjC name, and is a category
 // name, add the version without categories to the index too.
-ObjCLanguage::MethodName objc_method(name.GetStringRef(), true);
-if (objc_method.IsValid(true)) {
-  selector_to_index.Append(objc_method.GetSelector(), value);
+auto map_variant_names = [&](Language *lang) {
+  for (auto variant : lang->GetMethodNameVariants(name)) {
+if (variant.GetType() & lldb::eFunctionNameTypeSelector)
+  selector_to_index.Append(variant.GetName(), value);
+else if (variant.GetType() & lldb::eFunctionNameTypeFull)
+  name_to_index.Append(variant.GetName(), value);
+else if (variant.GetType() & lldb::eFunctionNameTypeMethod)
+  method_to_index.Append(variant.GetName(), value);
+else if (variant.GetType() & lldb::eFunctionNameTypeBase)
+  basename_to_index.Append(variant.GetName(), value);
+  }
+  return true;
+};
 
-  if (ConstString objc_method_no_category =
-  objc_method.GetFullNameWithoutCategory(true))
-name_to_index.Append(objc_method_no_category, value);
-}
+Language::ForEach(map_variant_names);
   }
 }
 
Index: lldb/source/Symbol/CMakeLists.txt
===
--- lldb/source/Symbol/CMakeLists.txt
+++ lldb/source/Symbol/CMakeLists.txt
@@ -44,7 +44,6 @@
 lldbHost
 lldbTarget
 lldbUtility
-lldbPluginObjCLanguage
 
   LINK_COMPONENTS
 Support
Index: lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
===
--- lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
+++ lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
@@ -100,7 +100,8 @@
   //  variant_names[1] => "-[NSString(my_additions) myStringWithCString:]"
   //  variant_names[2] => "+[NSString myStringWithCString:]"
   //  variant_names[3] => "-[NSString myStringWithCString:]"
-  std::vector
+  // We also return the FunctionNameType of each possible name.
+  std::vector
   GetMethodNameVariants(ConstString method_name) const override;
 
   bool SymbolNameFitsToLanguage(Mangled mangled) const override;
Index: lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
===
--- lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -225,14 +225,17 @@
   return ConstString();
 }
 
-std::vector
+std::vector
 ObjCLanguage::GetMethodNameVariants(ConstString method_name) const {
-  std::vector variant_names;
+  std::vector variant_names;
   ObjCLanguage::MethodName objc_method(method_name.GetCString(), false);
   if (!objc_method.IsValid(false)) {
 return variant_names;
   }
 
+  variant_names.emplace_back(objc_method.GetSelector(),
+ lldb::eFunctionNameTypeSelector);
+
   const bool is_class_method =
   objc_method.GetType() == MethodName::eTypeClassMethod;
   const bool is_instance_method =
@@ -242,25 +245,30 @@
 
   if (is_class_method || is_instance_method) {
 if (name_sans_category)
-  variant_names.emplace_back(name_sans_category);
+  variant_names.emplace_back(name_sans_category,
+ lldb::eFunctionNameTypeFull);
   } else {
 StreamString strm;
 
 strm.Printf("+%s", objc_method.GetFullName().GetCString());
-variant_names.emplace_back(strm.GetString());
+variant_names.emplace_back(ConstString(strm.GetString()),
+   lldb::eFunctionNameTypeFull);
 strm.Clear();
 
 strm.Printf("-%s", objc_method.GetFullName().GetCString());
-variant_names.emplace_bac