[Lldb-commits] [lldb] a394231 - [lldb] Remove ConstString from SymbolVendor, Trace, TraceExporter, UnwindAssembly, MemoryHistory and InstrumentationRuntime plugin names

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 29 03:09:27 PDT 2021


Author: Pavel Labath
Date: 2021-10-29T12:08:57+02:00
New Revision: a3942318198937a163deeb10f2e3378f3bc69844

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

LOG: [lldb] Remove ConstString from SymbolVendor, Trace, TraceExporter, UnwindAssembly, MemoryHistory and InstrumentationRuntime plugin names

Added: 
    

Modified: 
    lldb/include/lldb/Core/PluginManager.h
    lldb/source/Commands/CommandObjectThread.cpp
    lldb/source/Core/PluginManager.cpp
    lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
    lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.h
    lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
    lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h
    lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
    lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.h
    lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
    lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.h
    lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
    lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h
    lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
    lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h
    lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
    lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h
    lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.cpp
    lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.h
    lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
    lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
    lldb/source/Plugins/TraceExporter/ctf/TraceExporterCTF.cpp
    lldb/source/Plugins/TraceExporter/ctf/TraceExporterCTF.h
    lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
    lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
    lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
    lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h
    lldb/source/Target/Trace.cpp
    lldb/source/Target/TraceExporter.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Core/PluginManager.h b/lldb/include/lldb/Core/PluginManager.h
index dffceb93ebc63..cd720d5a9d0fc 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -324,7 +324,7 @@ class PluginManager {
   GetSymbolFileCreateCallbackAtIndex(uint32_t idx);
 
   // SymbolVendor
-  static bool RegisterPlugin(ConstString name, const char *description,
+  static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
                              SymbolVendorCreateInstance create_callback);
 
   static bool UnregisterPlugin(SymbolVendorCreateInstance create_callback);
@@ -334,7 +334,7 @@ class PluginManager {
 
   // Trace
   static bool RegisterPlugin(
-      ConstString name, const char *description,
+      llvm::StringRef name, llvm::StringRef description,
       TraceCreateInstanceForSessionFile create_callback_for_session_file,
       TraceCreateInstanceForLiveProcess create_callback_for_live_process,
       llvm::StringRef schema);
@@ -343,10 +343,10 @@ class PluginManager {
   UnregisterPlugin(TraceCreateInstanceForSessionFile create_callback);
 
   static TraceCreateInstanceForSessionFile
-  GetTraceCreateCallback(ConstString plugin_name);
+  GetTraceCreateCallback(llvm::StringRef plugin_name);
 
   static TraceCreateInstanceForLiveProcess
-  GetTraceCreateCallbackForLiveProcess(ConstString plugin_name);
+  GetTraceCreateCallbackForLiveProcess(llvm::StringRef plugin_name);
 
   /// Get the JSON schema for a trace session file corresponding to the given
   /// plugin.
@@ -357,7 +357,7 @@ class PluginManager {
   /// \return
   ///     An empty \a StringRef if no plugin was found with that plugin name,
   ///     otherwise the actual schema is returned.
-  static llvm::StringRef GetTraceSchema(ConstString plugin_name);
+  static llvm::StringRef GetTraceSchema(llvm::StringRef plugin_name);
 
   /// Get the JSON schema for a trace session file corresponding to the plugin
   /// given by its index.
@@ -376,16 +376,16 @@ class PluginManager {
   ///     This callback is used to create a CommandObject that will be listed
   ///     under "thread trace export". Can be \b null.
   static bool RegisterPlugin(
-      ConstString name, const char *description,
+      llvm::StringRef name, llvm::StringRef description,
       TraceExporterCreateInstance create_callback,
       ThreadTraceExportCommandCreator create_thread_trace_export_command);
 
   static TraceExporterCreateInstance
-  GetTraceExporterCreateCallback(ConstString plugin_name);
+  GetTraceExporterCreateCallback(llvm::StringRef plugin_name);
 
   static bool UnregisterPlugin(TraceExporterCreateInstance create_callback);
 
-  static const char *GetTraceExporterPluginNameAtIndex(uint32_t index);
+  static llvm::StringRef GetTraceExporterPluginNameAtIndex(uint32_t index);
 
   /// Return the callback used to create the CommandObject that will be listed
   /// under "thread trace export". Can be \b null.
@@ -393,7 +393,7 @@ class PluginManager {
   GetThreadTraceExportCommandCreatorAtIndex(uint32_t index);
 
   // UnwindAssembly
-  static bool RegisterPlugin(ConstString name, const char *description,
+  static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
                              UnwindAssemblyCreateInstance create_callback);
 
   static bool UnregisterPlugin(UnwindAssemblyCreateInstance create_callback);
@@ -402,7 +402,7 @@ class PluginManager {
   GetUnwindAssemblyCreateCallbackAtIndex(uint32_t idx);
 
   // MemoryHistory
-  static bool RegisterPlugin(ConstString name, const char *description,
+  static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
                              MemoryHistoryCreateInstance create_callback);
 
   static bool UnregisterPlugin(MemoryHistoryCreateInstance create_callback);
@@ -412,7 +412,7 @@ class PluginManager {
 
   // InstrumentationRuntime
   static bool
-  RegisterPlugin(ConstString name, const char *description,
+  RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
                  InstrumentationRuntimeCreateInstance create_callback,
                  InstrumentationRuntimeGetType get_type_callback);
 

diff  --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index 7a4760225a580..e9396dc47043c 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -1929,15 +1929,14 @@ class CommandObjectTraceExport : public CommandObjectMultiword {
             "process to 
diff erent formats.",
             "thread trace export <export-plugin> [<subcommand objects>]") {
 
-    for (uint32_t i = 0; true; i++) {
-      if (const char *plugin_name =
-              PluginManager::GetTraceExporterPluginNameAtIndex(i)) {
-        if (ThreadTraceExportCommandCreator command_creator =
-                PluginManager::GetThreadTraceExportCommandCreatorAtIndex(i)) {
-          LoadSubCommand(plugin_name, command_creator(interpreter));
-        }
-      } else {
-        break;
+    unsigned i = 0;
+    for (llvm::StringRef plugin_name =
+             PluginManager::GetTraceExporterPluginNameAtIndex(i++);
+         !plugin_name.empty();
+         plugin_name = PluginManager::GetTraceExporterPluginNameAtIndex(i++)) {
+      if (ThreadTraceExportCommandCreator command_creator =
+              PluginManager::GetThreadTraceExportCommandCreatorAtIndex(i)) {
+        LoadSubCommand(plugin_name, command_creator(interpreter));
       }
     }
   }

diff  --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp
index 7dfa565009f6f..5ba427a24ed45 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -1021,10 +1021,11 @@ static SymbolVendorInstances &GetSymbolVendorInstances() {
   return g_instances;
 }
 
-bool PluginManager::RegisterPlugin(ConstString name, const char *description,
+bool PluginManager::RegisterPlugin(llvm::StringRef name,
+                                   llvm::StringRef description,
                                    SymbolVendorCreateInstance create_callback) {
-  return GetSymbolVendorInstances().RegisterPlugin(name, description,
-                                                   create_callback);
+  return GetSymbolVendorInstances().RegisterPlugin(
+      ConstString(name), description.str().c_str(), create_callback);
 }
 
 bool PluginManager::UnregisterPlugin(
@@ -1063,13 +1064,14 @@ static TraceInstances &GetTracePluginInstances() {
 }
 
 bool PluginManager::RegisterPlugin(
-    ConstString name, const char *description,
+    llvm::StringRef name, llvm::StringRef description,
     TraceCreateInstanceForSessionFile create_callback_for_session_file,
     TraceCreateInstanceForLiveProcess create_callback_for_live_process,
     llvm::StringRef schema) {
   return GetTracePluginInstances().RegisterPlugin(
-      name, description, create_callback_for_session_file,
-      create_callback_for_live_process, schema);
+      ConstString(name), description.str().c_str(),
+      create_callback_for_session_file, create_callback_for_live_process,
+      schema);
 }
 
 bool PluginManager::UnregisterPlugin(
@@ -1079,21 +1081,21 @@ bool PluginManager::UnregisterPlugin(
 }
 
 TraceCreateInstanceForSessionFile
-PluginManager::GetTraceCreateCallback(ConstString plugin_name) {
-  return GetTracePluginInstances().GetCallbackForName(plugin_name);
+PluginManager::GetTraceCreateCallback(llvm::StringRef plugin_name) {
+  return GetTracePluginInstances().GetCallbackForName(ConstString(plugin_name));
 }
 
 TraceCreateInstanceForLiveProcess
-PluginManager::GetTraceCreateCallbackForLiveProcess(ConstString plugin_name) {
+PluginManager::GetTraceCreateCallbackForLiveProcess(llvm::StringRef plugin_name) {
   for (const TraceInstance &instance : GetTracePluginInstances().GetInstances())
-    if (instance.name == plugin_name)
+    if (instance.name.GetStringRef() == plugin_name)
       return instance.create_callback_for_live_process;
   return nullptr;
 }
 
-llvm::StringRef PluginManager::GetTraceSchema(ConstString plugin_name) {
+llvm::StringRef PluginManager::GetTraceSchema(llvm::StringRef plugin_name) {
   for (const TraceInstance &instance : GetTracePluginInstances().GetInstances())
-    if (instance.name == plugin_name)
+    if (instance.name.GetStringRef() == plugin_name)
       return instance.schema;
   return llvm::StringRef();
 }
@@ -1129,16 +1131,18 @@ static TraceExporterInstances &GetTraceExporterInstances() {
 }
 
 bool PluginManager::RegisterPlugin(
-    ConstString name, const char *description,
+    llvm::StringRef name, llvm::StringRef description,
     TraceExporterCreateInstance create_callback,
     ThreadTraceExportCommandCreator create_thread_trace_export_command) {
   return GetTraceExporterInstances().RegisterPlugin(
-      name, description, create_callback, create_thread_trace_export_command);
+      ConstString(name), description.str().c_str(), create_callback,
+      create_thread_trace_export_command);
 }
 
 TraceExporterCreateInstance
-PluginManager::GetTraceExporterCreateCallback(ConstString plugin_name) {
-  return GetTraceExporterInstances().GetCallbackForName(plugin_name);
+PluginManager::GetTraceExporterCreateCallback(llvm::StringRef plugin_name) {
+  return GetTraceExporterInstances().GetCallbackForName(
+      ConstString(plugin_name));
 }
 
 bool PluginManager::UnregisterPlugin(
@@ -1154,7 +1158,8 @@ PluginManager::GetThreadTraceExportCommandCreatorAtIndex(uint32_t index) {
   return nullptr;
 }
 
-const char *PluginManager::GetTraceExporterPluginNameAtIndex(uint32_t index) {
+llvm::StringRef
+PluginManager::GetTraceExporterPluginNameAtIndex(uint32_t index) {
   return GetTraceExporterInstances().GetNameAtIndex(index);
 }
 
@@ -1169,10 +1174,10 @@ static UnwindAssemblyInstances &GetUnwindAssemblyInstances() {
 }
 
 bool PluginManager::RegisterPlugin(
-    ConstString name, const char *description,
+    llvm::StringRef name, llvm::StringRef description,
     UnwindAssemblyCreateInstance create_callback) {
-  return GetUnwindAssemblyInstances().RegisterPlugin(name, description,
-                                                     create_callback);
+  return GetUnwindAssemblyInstances().RegisterPlugin(
+      ConstString(name), description.str().c_str(), create_callback);
 }
 
 bool PluginManager::UnregisterPlugin(
@@ -1196,10 +1201,10 @@ static MemoryHistoryInstances &GetMemoryHistoryInstances() {
 }
 
 bool PluginManager::RegisterPlugin(
-    ConstString name, const char *description,
+    llvm::StringRef name, llvm::StringRef description,
     MemoryHistoryCreateInstance create_callback) {
-  return GetMemoryHistoryInstances().RegisterPlugin(name, description,
-                                                    create_callback);
+  return GetMemoryHistoryInstances().RegisterPlugin(
+      ConstString(name), description.str().c_str(), create_callback);
 }
 
 bool PluginManager::UnregisterPlugin(
@@ -1235,11 +1240,12 @@ static InstrumentationRuntimeInstances &GetInstrumentationRuntimeInstances() {
 }
 
 bool PluginManager::RegisterPlugin(
-    ConstString name, const char *description,
+    llvm::StringRef name, llvm::StringRef description,
     InstrumentationRuntimeCreateInstance create_callback,
     InstrumentationRuntimeGetType get_type_callback) {
   return GetInstrumentationRuntimeInstances().RegisterPlugin(
-      name, description, create_callback, get_type_callback);
+      ConstString(name), description.str().c_str(), create_callback,
+      get_type_callback);
 }
 
 bool PluginManager::UnregisterPlugin(

diff  --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
index e78ea3a684836..8d8b5c68e41b3 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
+++ b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
@@ -47,10 +47,6 @@ void InstrumentationRuntimeASan::Terminate() {
   PluginManager::UnregisterPlugin(CreateInstance);
 }
 
-lldb_private::ConstString InstrumentationRuntimeASan::GetPluginNameStatic() {
-  return ConstString("AddressSanitizer");
-}
-
 lldb::InstrumentationRuntimeType InstrumentationRuntimeASan::GetTypeStatic() {
   return eInstrumentationRuntimeTypeAddressSanitizer;
 }

diff  --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.h b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.h
index 53d13b5e5b8cf..83a88cf7f89fa 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.h
+++ b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.h
@@ -27,13 +27,11 @@ class InstrumentationRuntimeASan : public lldb_private::InstrumentationRuntime {
 
   static void Terminate();
 
-  static lldb_private::ConstString GetPluginNameStatic();
+  static llvm::StringRef GetPluginNameStatic() { return "AddressSanitizer"; }
 
   static lldb::InstrumentationRuntimeType GetTypeStatic();
 
-  llvm::StringRef GetPluginName() override {
-    return GetPluginNameStatic().GetStringRef();
-  }
+  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
 
   virtual lldb::InstrumentationRuntimeType GetType() { return GetTypeStatic(); }
 

diff  --git a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
index 9a88b343878cc..dc8c7c96aa111 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
+++ b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
@@ -54,11 +54,6 @@ void InstrumentationRuntimeMainThreadChecker::Terminate() {
   PluginManager::UnregisterPlugin(CreateInstance);
 }
 
-lldb_private::ConstString
-InstrumentationRuntimeMainThreadChecker::GetPluginNameStatic() {
-  return ConstString("MainThreadChecker");
-}
-
 lldb::InstrumentationRuntimeType
 InstrumentationRuntimeMainThreadChecker::GetTypeStatic() {
   return eInstrumentationRuntimeTypeMainThreadChecker;

diff  --git a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h
index 011ca9dfeec40..3bbbf13b7798e 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h
+++ b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h
@@ -28,13 +28,11 @@ class InstrumentationRuntimeMainThreadChecker
 
   static void Terminate();
 
-  static lldb_private::ConstString GetPluginNameStatic();
+  static llvm::StringRef GetPluginNameStatic() { return "MainThreadChecker"; }
 
   static lldb::InstrumentationRuntimeType GetTypeStatic();
 
-  llvm::StringRef GetPluginName() override {
-    return GetPluginNameStatic().GetStringRef();
-  }
+  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
 
   virtual lldb::InstrumentationRuntimeType GetType() { return GetTypeStatic(); }
 

diff  --git a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
index a2954f556b103..aef10bb2a778b 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
+++ b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
@@ -52,10 +52,6 @@ void InstrumentationRuntimeTSan::Terminate() {
   PluginManager::UnregisterPlugin(CreateInstance);
 }
 
-lldb_private::ConstString InstrumentationRuntimeTSan::GetPluginNameStatic() {
-  return ConstString("ThreadSanitizer");
-}
-
 lldb::InstrumentationRuntimeType InstrumentationRuntimeTSan::GetTypeStatic() {
   return eInstrumentationRuntimeTypeThreadSanitizer;
 }

diff  --git a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.h b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.h
index 97e174e3c6529..db4466a131930 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.h
+++ b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.h
@@ -27,13 +27,11 @@ class InstrumentationRuntimeTSan : public lldb_private::InstrumentationRuntime {
 
   static void Terminate();
 
-  static lldb_private::ConstString GetPluginNameStatic();
+  static llvm::StringRef GetPluginNameStatic() { return "ThreadSanitizer"; }
 
   static lldb::InstrumentationRuntimeType GetTypeStatic();
 
-  llvm::StringRef GetPluginName() override {
-    return GetPluginNameStatic().GetStringRef();
-  }
+  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
 
   virtual lldb::InstrumentationRuntimeType GetType() { return GetTypeStatic(); }
 

diff  --git a/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp b/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
index 58bc38a551f0a..8e7799dc07617 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
+++ b/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
@@ -56,10 +56,6 @@ void InstrumentationRuntimeUBSan::Terminate() {
   PluginManager::UnregisterPlugin(CreateInstance);
 }
 
-lldb_private::ConstString InstrumentationRuntimeUBSan::GetPluginNameStatic() {
-  return ConstString("UndefinedBehaviorSanitizer");
-}
-
 lldb::InstrumentationRuntimeType InstrumentationRuntimeUBSan::GetTypeStatic() {
   return eInstrumentationRuntimeTypeUndefinedBehaviorSanitizer;
 }

diff  --git a/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.h b/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.h
index 6c9f47ecd7ff0..e0de158473de6 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.h
+++ b/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.h
@@ -28,13 +28,13 @@ class InstrumentationRuntimeUBSan
 
   static void Terminate();
 
-  static lldb_private::ConstString GetPluginNameStatic();
+  static llvm::StringRef GetPluginNameStatic() {
+    return "UndefinedBehaviorSanitizer";
+  }
 
   static lldb::InstrumentationRuntimeType GetTypeStatic();
 
-  llvm::StringRef GetPluginName() override {
-    return GetPluginNameStatic().GetStringRef();
-  }
+  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
 
   virtual lldb::InstrumentationRuntimeType GetType() { return GetTypeStatic(); }
 

diff  --git a/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp b/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
index 7d99762851922..14d9c4024689f 100644
--- a/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
+++ b/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
@@ -56,11 +56,6 @@ void MemoryHistoryASan::Terminate() {
   PluginManager::UnregisterPlugin(CreateInstance);
 }
 
-ConstString MemoryHistoryASan::GetPluginNameStatic() {
-  static ConstString g_name("asan");
-  return g_name;
-}
-
 MemoryHistoryASan::MemoryHistoryASan(const ProcessSP &process_sp) {
   if (process_sp)
     m_process_wp = process_sp;

diff  --git a/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h b/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h
index cdeba885084e2..6563c3cd94a7f 100644
--- a/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h
+++ b/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h
@@ -27,11 +27,9 @@ class MemoryHistoryASan : public lldb_private::MemoryHistory {
 
   static void Terminate();
 
-  static lldb_private::ConstString GetPluginNameStatic();
+  static llvm::StringRef GetPluginNameStatic() { return "asan"; }
 
-  llvm::StringRef GetPluginName() override {
-    return GetPluginNameStatic().GetStringRef();
-  }
+  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
 
   lldb_private::HistoryThreads GetHistoryThreads(lldb::addr_t address) override;
 

diff  --git a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
index a598bb0c6ccfe..0a98f5032b770 100644
--- a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
+++ b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
@@ -40,12 +40,7 @@ void SymbolVendorELF::Terminate() {
   PluginManager::UnregisterPlugin(CreateInstance);
 }
 
-lldb_private::ConstString SymbolVendorELF::GetPluginNameStatic() {
-  static ConstString g_name("ELF");
-  return g_name;
-}
-
-const char *SymbolVendorELF::GetPluginDescriptionStatic() {
+llvm::StringRef SymbolVendorELF::GetPluginDescriptionStatic() {
   return "Symbol vendor for ELF that looks for dSYM files that match "
          "executables.";
 }

diff  --git a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h
index 60b520322bd8b..13a1071e38ab0 100644
--- a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h
+++ b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h
@@ -22,18 +22,16 @@ class SymbolVendorELF : public lldb_private::SymbolVendor {
 
   static void Terminate();
 
-  static lldb_private::ConstString GetPluginNameStatic();
+  static llvm::StringRef GetPluginNameStatic() { return "ELF"; }
 
-  static const char *GetPluginDescriptionStatic();
+  static llvm::StringRef GetPluginDescriptionStatic();
 
   static lldb_private::SymbolVendor *
   CreateInstance(const lldb::ModuleSP &module_sp,
                  lldb_private::Stream *feedback_strm);
 
   // PluginInterface protocol
-  llvm::StringRef GetPluginName() override {
-    return GetPluginNameStatic().GetStringRef();
-  }
+  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
 };
 
 #endif // LLDB_SOURCE_PLUGINS_SYMBOLVENDOR_ELF_SYMBOLVENDORELF_H

diff  --git a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
index c3fe34a63647d..6e97f3d440f3f 100644
--- a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
+++ b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
@@ -77,12 +77,7 @@ void SymbolVendorMacOSX::Terminate() {
   PluginManager::UnregisterPlugin(CreateInstance);
 }
 
-lldb_private::ConstString SymbolVendorMacOSX::GetPluginNameStatic() {
-  static ConstString g_name("macosx");
-  return g_name;
-}
-
-const char *SymbolVendorMacOSX::GetPluginDescriptionStatic() {
+llvm::StringRef SymbolVendorMacOSX::GetPluginDescriptionStatic() {
   return "Symbol vendor for MacOSX that looks for dSYM files that match "
          "executables.";
 }

diff  --git a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h
index 11312a8d0b593..5b53bd78cf2a2 100644
--- a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h
+++ b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h
@@ -19,9 +19,9 @@ class SymbolVendorMacOSX : public lldb_private::SymbolVendor {
 
   static void Terminate();
 
-  static lldb_private::ConstString GetPluginNameStatic();
+  static llvm::StringRef GetPluginNameStatic() { return "macosx"; }
 
-  static const char *GetPluginDescriptionStatic();
+  static llvm::StringRef GetPluginDescriptionStatic();
 
   static lldb_private::SymbolVendor *
   CreateInstance(const lldb::ModuleSP &module_sp,
@@ -31,9 +31,7 @@ class SymbolVendorMacOSX : public lldb_private::SymbolVendor {
   SymbolVendorMacOSX(const lldb::ModuleSP &module_sp);
 
   // PluginInterface protocol
-  llvm::StringRef GetPluginName() override {
-    return GetPluginNameStatic().GetStringRef();
-  }
+  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
 };
 
 #endif // LLDB_SOURCE_PLUGINS_SYMBOLVENDOR_MACOSX_SYMBOLVENDORMACOSX_H

diff  --git a/lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.cpp b/lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.cpp
index 6be717b6a65a9..9da5b0133d37a 100644
--- a/lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.cpp
+++ b/lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.cpp
@@ -41,12 +41,7 @@ void SymbolVendorWasm::Terminate() {
   PluginManager::UnregisterPlugin(CreateInstance);
 }
 
-lldb_private::ConstString SymbolVendorWasm::GetPluginNameStatic() {
-  static ConstString g_name("WASM");
-  return g_name;
-}
-
-const char *SymbolVendorWasm::GetPluginDescriptionStatic() {
+llvm::StringRef SymbolVendorWasm::GetPluginDescriptionStatic() {
   return "Symbol vendor for WASM that looks for dwo files that match "
          "executables.";
 }

diff  --git a/lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.h b/lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.h
index 403bdb9d7feac..af692c6e9e002 100644
--- a/lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.h
+++ b/lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.h
@@ -21,8 +21,8 @@ class SymbolVendorWasm : public lldb_private::SymbolVendor {
 
   static void Initialize();
   static void Terminate();
-  static lldb_private::ConstString GetPluginNameStatic();
-  static const char *GetPluginDescriptionStatic();
+  static llvm::StringRef GetPluginNameStatic() { return "WASM"; }
+  static llvm::StringRef GetPluginDescriptionStatic();
 
   static lldb_private::SymbolVendor *
   CreateInstance(const lldb::ModuleSP &module_sp,
@@ -30,9 +30,7 @@ class SymbolVendorWasm : public lldb_private::SymbolVendor {
 
   /// PluginInterface protocol.
   /// \{
-  llvm::StringRef GetPluginName() override {
-    return GetPluginNameStatic().GetStringRef();
-  }
+  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
   /// \}
 };
 

diff  --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
index 1b2a5b27905f4..6ec957771e47d 100644
--- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
@@ -49,11 +49,6 @@ void TraceIntelPT::Terminate() {
   PluginManager::UnregisterPlugin(CreateInstanceForSessionFile);
 }
 
-ConstString TraceIntelPT::GetPluginNameStatic() {
-  static ConstString g_name("intel-pt");
-  return g_name;
-}
-
 StringRef TraceIntelPT::GetSchema() {
   return TraceIntelPTSessionFileParser::GetSchema();
 }

diff  --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
index 29629060e1c80..a6ecf6f906b2c 100644
--- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
+++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
@@ -28,9 +28,7 @@ class TraceIntelPT : public Trace {
 
   /// PluginInterface protocol
   /// \{
-  llvm::StringRef GetPluginName() override {
-    return GetPluginNameStatic().GetStringRef();
-  }
+  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
 
   static void Initialize();
 
@@ -59,7 +57,7 @@ class TraceIntelPT : public Trace {
   static llvm::Expected<lldb::TraceSP>
   CreateInstanceForLiveProcess(Process &process);
 
-  static ConstString GetPluginNameStatic();
+  static llvm::StringRef GetPluginNameStatic() { return "intel-pt"; }
   /// \}
 
   lldb::CommandObjectSP

diff  --git a/lldb/source/Plugins/TraceExporter/ctf/TraceExporterCTF.cpp b/lldb/source/Plugins/TraceExporter/ctf/TraceExporterCTF.cpp
index 893a285284bb0..e98e2c83e6498 100644
--- a/lldb/source/Plugins/TraceExporter/ctf/TraceExporterCTF.cpp
+++ b/lldb/source/Plugins/TraceExporter/ctf/TraceExporterCTF.cpp
@@ -39,11 +39,6 @@ void TraceExporterCTF::Terminate() {
   PluginManager::UnregisterPlugin(CreateInstance);
 }
 
-ConstString TraceExporterCTF::GetPluginNameStatic() {
-  static ConstString g_name("ctf");
-  return g_name;
-}
-
 Expected<TraceExporterUP> TraceExporterCTF::CreateInstance() {
   return std::make_unique<TraceExporterCTF>();
 }

diff  --git a/lldb/source/Plugins/TraceExporter/ctf/TraceExporterCTF.h b/lldb/source/Plugins/TraceExporter/ctf/TraceExporterCTF.h
index 7ead18b0a9dee..74f14fc354d1d 100644
--- a/lldb/source/Plugins/TraceExporter/ctf/TraceExporterCTF.h
+++ b/lldb/source/Plugins/TraceExporter/ctf/TraceExporterCTF.h
@@ -10,7 +10,6 @@
 #define LLDB_SOURCE_PLUGINS_TRACE_EXPORTER_CTF_H
 
 #include "lldb/Target/TraceExporter.h"
-#include "lldb/Utility/ConstString.h"
 
 namespace lldb_private {
 namespace ctf {
@@ -26,14 +25,14 @@ class TraceExporterCTF : public TraceExporter {
   static llvm::Expected<lldb::TraceExporterUP> CreateInstance();
 
   llvm::StringRef GetPluginName() override {
-    return GetPluginNameStatic().GetStringRef();
+    return GetPluginNameStatic();
   }
 
   static void Initialize();
 
   static void Terminate();
 
-  static ConstString GetPluginNameStatic();
+  static llvm::StringRef GetPluginNameStatic() { return "ctf"; }
   /// \}
 };
 

diff  --git a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
index f489dd2370e0e..ccaac687ed7af 100644
--- a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
+++ b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
@@ -342,12 +342,7 @@ void UnwindAssemblyInstEmulation::Terminate() {
   PluginManager::UnregisterPlugin(CreateInstance);
 }
 
-ConstString UnwindAssemblyInstEmulation::GetPluginNameStatic() {
-  static ConstString g_name("inst-emulation");
-  return g_name;
-}
-
-const char *UnwindAssemblyInstEmulation::GetPluginDescriptionStatic() {
+llvm::StringRef UnwindAssemblyInstEmulation::GetPluginDescriptionStatic() {
   return "Instruction emulation based unwind information.";
 }
 

diff  --git a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
index 670be1b5e64e0..97cb04e51408e 100644
--- a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
+++ b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
@@ -52,13 +52,11 @@ class UnwindAssemblyInstEmulation : public lldb_private::UnwindAssembly {
 
   static void Terminate();
 
-  static lldb_private::ConstString GetPluginNameStatic();
+  static llvm::StringRef GetPluginNameStatic() { return "inst-emulation"; }
 
-  static const char *GetPluginDescriptionStatic();
+  static llvm::StringRef GetPluginDescriptionStatic();
 
-  llvm::StringRef GetPluginName() override {
-    return GetPluginNameStatic().GetStringRef();
-  }
+  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
 
 private:
   // Call CreateInstance to get an instance of this class

diff  --git a/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp b/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
index f070008867d47..eca78a9b3a04b 100644
--- a/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
+++ b/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
@@ -248,11 +248,6 @@ void UnwindAssembly_x86::Terminate() {
   PluginManager::UnregisterPlugin(CreateInstance);
 }
 
-lldb_private::ConstString UnwindAssembly_x86::GetPluginNameStatic() {
-  static ConstString g_name("x86");
-  return g_name;
-}
-
-const char *UnwindAssembly_x86::GetPluginDescriptionStatic() {
+llvm::StringRef UnwindAssembly_x86::GetPluginDescriptionStatic() {
   return "i386 and x86_64 assembly language profiler plugin.";
 }

diff  --git a/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h b/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h
index 16c7cf76e9c29..3857c8776b02d 100644
--- a/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h
+++ b/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h
@@ -46,13 +46,11 @@ class UnwindAssembly_x86 : public lldb_private::UnwindAssembly {
 
   static void Terminate();
 
-  static lldb_private::ConstString GetPluginNameStatic();
+  static llvm::StringRef GetPluginNameStatic() { return "x86"; }
 
-  static const char *GetPluginDescriptionStatic();
+  static llvm::StringRef GetPluginDescriptionStatic();
 
-  llvm::StringRef GetPluginName() override {
-    return GetPluginNameStatic().GetStringRef();
-  }
+  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
 
 private:
   UnwindAssembly_x86(const lldb_private::ArchSpec &arch);

diff  --git a/lldb/source/Target/Trace.cpp b/lldb/source/Target/Trace.cpp
index 06dc05af9d459..38b3a7cb006df 100644
--- a/lldb/source/Target/Trace.cpp
+++ b/lldb/source/Target/Trace.cpp
@@ -67,30 +67,28 @@ Trace::FindPluginForPostMortemProcess(Debugger &debugger,
   if (!json::fromJSON(trace_session_file, json_session, root))
     return root.getError();
 
-  ConstString plugin_name(json_session.trace.type);
-  if (auto create_callback = PluginManager::GetTraceCreateCallback(plugin_name))
+  if (auto create_callback =
+          PluginManager::GetTraceCreateCallback(json_session.trace.type))
     return create_callback(trace_session_file, session_file_dir, debugger);
 
   return createInvalidPlugInError(json_session.trace.type);
 }
 
-Expected<lldb::TraceSP>
-Trace::FindPluginForLiveProcess(llvm::StringRef plugin_name, Process &process) {
+Expected<lldb::TraceSP> Trace::FindPluginForLiveProcess(llvm::StringRef name,
+                                                        Process &process) {
   if (!process.IsLiveDebugSession())
     return createStringError(inconvertibleErrorCode(),
                              "Can't trace non-live processes");
 
-  ConstString name(plugin_name);
   if (auto create_callback =
           PluginManager::GetTraceCreateCallbackForLiveProcess(name))
     return create_callback(process);
 
-  return createInvalidPlugInError(plugin_name);
+  return createInvalidPlugInError(name);
 }
 
 Expected<StringRef> Trace::FindPluginSchema(StringRef name) {
-  ConstString plugin_name(name);
-  StringRef schema = PluginManager::GetTraceSchema(plugin_name);
+  StringRef schema = PluginManager::GetTraceSchema(name);
   if (!schema.empty())
     return schema;
 

diff  --git a/lldb/source/Target/TraceExporter.cpp b/lldb/source/Target/TraceExporter.cpp
index 1a6571dba4a0f..8c925aa495b05 100644
--- a/lldb/source/Target/TraceExporter.cpp
+++ b/lldb/source/Target/TraceExporter.cpp
@@ -22,11 +22,10 @@ static Error createInvalidPlugInError(StringRef plugin_name) {
 }
 
 Expected<lldb::TraceExporterUP>
-TraceExporter::FindPlugin(llvm::StringRef plugin_name) {
-  ConstString name(plugin_name);
+TraceExporter::FindPlugin(llvm::StringRef name) {
   if (auto create_callback =
           PluginManager::GetTraceExporterCreateCallback(name))
     return create_callback();
 
-  return createInvalidPlugInError(plugin_name);
+  return createInvalidPlugInError(name);
 }


        


More information about the lldb-commits mailing list