[Lldb-commits] [lldb] r287266 - Make GetRegisterByName() take a StringRef.

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 17 13:54:37 PST 2016


Author: zturner
Date: Thu Nov 17 15:54:37 2016
New Revision: 287266

URL: http://llvm.org/viewvc/llvm-project?rev=287266&view=rev
Log:
Make GetRegisterByName() take a StringRef.

This one is fairly trivial and only really involves changing
function signatures and a few simple call-sites.

Modified:
    lldb/trunk/include/lldb/Host/common/NativeRegisterContext.h
    lldb/trunk/include/lldb/Target/RegisterContext.h
    lldb/trunk/source/Host/common/NativeRegisterContext.cpp
    lldb/trunk/source/Target/RegisterContext.cpp

Modified: lldb/trunk/include/lldb/Host/common/NativeRegisterContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/NativeRegisterContext.h?rev=287266&r1=287265&r2=287266&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/common/NativeRegisterContext.h (original)
+++ lldb/trunk/include/lldb/Host/common/NativeRegisterContext.h Thu Nov 17 15:54:37 2016
@@ -126,7 +126,7 @@ public:
 
   virtual NativeThreadProtocol &GetThread() { return m_thread; }
 
-  const RegisterInfo *GetRegisterInfoByName(const char *reg_name,
+  const RegisterInfo *GetRegisterInfoByName(llvm::StringRef reg_name,
                                             uint32_t start_idx = 0);
 
   const RegisterInfo *GetRegisterInfo(uint32_t reg_kind, uint32_t reg_num);

Modified: lldb/trunk/include/lldb/Target/RegisterContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/RegisterContext.h?rev=287266&r1=287265&r2=287266&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/RegisterContext.h (original)
+++ lldb/trunk/include/lldb/Target/RegisterContext.h Thu Nov 17 15:54:37 2016
@@ -155,7 +155,7 @@ public:
 
   virtual Thread &GetThread() { return m_thread; }
 
-  const RegisterInfo *GetRegisterInfoByName(const char *reg_name,
+  const RegisterInfo *GetRegisterInfoByName(llvm::StringRef reg_name,
                                             uint32_t start_idx = 0);
 
   const RegisterInfo *GetRegisterInfo(lldb::RegisterKind reg_kind,

Modified: lldb/trunk/source/Host/common/NativeRegisterContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/NativeRegisterContext.cpp?rev=287266&r1=287265&r2=287266&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/NativeRegisterContext.cpp (original)
+++ lldb/trunk/source/Host/common/NativeRegisterContext.cpp Thu Nov 17 15:54:37 2016
@@ -56,20 +56,18 @@ NativeRegisterContext::~NativeRegisterCo
 // }
 
 const RegisterInfo *
-NativeRegisterContext::GetRegisterInfoByName(const char *reg_name,
+NativeRegisterContext::GetRegisterInfoByName(llvm::StringRef reg_name,
                                              uint32_t start_idx) {
-  if (reg_name && reg_name[0]) {
-    const uint32_t num_registers = GetRegisterCount();
-    for (uint32_t reg = start_idx; reg < num_registers; ++reg) {
-      const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg);
+  if (reg_name.empty())
+    return nullptr;
 
-      if ((reg_info->name != nullptr &&
-           ::strcasecmp(reg_info->name, reg_name) == 0) ||
-          (reg_info->alt_name != nullptr &&
-           ::strcasecmp(reg_info->alt_name, reg_name) == 0)) {
-        return reg_info;
-      }
-    }
+  const uint32_t num_registers = GetRegisterCount();
+  for (uint32_t reg = start_idx; reg < num_registers; ++reg) {
+    const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg);
+
+    if (reg_name.equals_lower(reg_info->name) ||
+        reg_name.equals_lower(reg_info->alt_name))
+      return reg_info;
   }
   return nullptr;
 }

Modified: lldb/trunk/source/Target/RegisterContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/RegisterContext.cpp?rev=287266&r1=287265&r2=287266&view=diff
==============================================================================
--- lldb/trunk/source/Target/RegisterContext.cpp (original)
+++ lldb/trunk/source/Target/RegisterContext.cpp Thu Nov 17 15:54:37 2016
@@ -53,20 +53,19 @@ void RegisterContext::InvalidateIfNeeded
   }
 }
 
-const RegisterInfo *RegisterContext::GetRegisterInfoByName(const char *reg_name,
-                                                           uint32_t start_idx) {
-  if (reg_name && reg_name[0]) {
-    const uint32_t num_registers = GetRegisterCount();
-    for (uint32_t reg = start_idx; reg < num_registers; ++reg) {
-      const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg);
+const RegisterInfo *
+RegisterContext::GetRegisterInfoByName(llvm::StringRef reg_name,
+                                       uint32_t start_idx) {
+  if (reg_name.empty())
+    return nullptr;
 
-      if ((reg_info->name != nullptr &&
-           ::strcasecmp(reg_info->name, reg_name) == 0) ||
-          (reg_info->alt_name != nullptr &&
-           ::strcasecmp(reg_info->alt_name, reg_name) == 0)) {
-        return reg_info;
-      }
-    }
+  const uint32_t num_registers = GetRegisterCount();
+  for (uint32_t reg = start_idx; reg < num_registers; ++reg) {
+    const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg);
+
+    if (reg_name.equals_lower(reg_info->name) ||
+        reg_name.equals_lower(reg_info->alt_name))
+      return reg_info;
   }
   return nullptr;
 }




More information about the lldb-commits mailing list