[Lldb-commits] [lldb] f687850 - [lldb] Change return type of UnixSignals::GetShortName

Alex Langford via lldb-commits lldb-commits at lists.llvm.org
Mon Jun 12 16:44:41 PDT 2023


Author: Alex Langford
Date: 2023-06-12T16:44:05-07:00
New Revision: f687850de87759fa4a76a883971c2f909ae4d1b9

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

LOG: [lldb] Change return type of UnixSignals::GetShortName

The short names of each signal name and alias only exist as ConstStrings
in this one scenario. For example, GetShortName("SIGHUP") will just give
you "HUP". There's not a good reason the string "HUP" needs to be in the
ConstString StringPool, and that's true for just about every signal
name.

Differential Revision: https://reviews.llvm.org/D152582

Added: 
    

Modified: 
    lldb/include/lldb/Target/UnixSignals.h
    lldb/source/Target/UnixSignals.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Target/UnixSignals.h b/lldb/include/lldb/Target/UnixSignals.h
index 74eb75fa23aa4..7b6060b9343c8 100644
--- a/lldb/include/lldb/Target/UnixSignals.h
+++ b/lldb/include/lldb/Target/UnixSignals.h
@@ -77,8 +77,6 @@ class UnixSignals {
 
   int32_t GetSignalAtIndex(int32_t index) const;
 
-  ConstString GetShortName(ConstString name) const;
-
   // We assume that the elements of this object are constant once it is
   // constructed, since a process should never need to add or remove symbols as
   // it runs.  So don't call these functions anywhere but the constructor of
@@ -147,6 +145,8 @@ class UnixSignals {
     void Reset(bool reset_stop, bool reset_notify, bool reset_suppress);
   };
 
+  llvm::StringRef GetShortName(llvm::StringRef name) const;
+
   virtual void Reset();
 
   typedef std::map<int32_t, Signal> collection;

diff  --git a/lldb/source/Target/UnixSignals.cpp b/lldb/source/Target/UnixSignals.cpp
index 5d0f687b8ba6f..0e738241b1c56 100644
--- a/lldb/source/Target/UnixSignals.cpp
+++ b/lldb/source/Target/UnixSignals.cpp
@@ -195,10 +195,8 @@ bool UnixSignals::SignalIsValid(int32_t signo) const {
   return m_signals.find(signo) != m_signals.end();
 }
 
-ConstString UnixSignals::GetShortName(ConstString name) const {
-  if (name)
-    return ConstString(name.GetStringRef().substr(3)); // Remove "SIG" from name
-  return name;
+llvm::StringRef UnixSignals::GetShortName(llvm::StringRef name) const {
+  return name.substr(3); // Remove "SIG" from name
 }
 
 int32_t UnixSignals::GetSignalNumberFromName(const char *name) const {


        


More information about the lldb-commits mailing list