summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/RegularExpression.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2013-01-30 00:18:29 +0000
committerGreg Clayton <gclayton@apple.com>2013-01-30 00:18:29 +0000
commit1b3815cbf483fa1cc5c5b6d7b567722b3c802bf6 (patch)
tree2be6a86d11bf5507a38fa2a457351df356ff982b /lldb/source/Core/RegularExpression.cpp
parenta4db5d08393c16cb0de83f96c49fc5911fd5f5ed (diff)
downloadbcm5719-llvm-1b3815cbf483fa1cc5c5b6d7b567722b3c802bf6.tar.gz
bcm5719-llvm-1b3815cbf483fa1cc5c5b6d7b567722b3c802bf6.zip
<rdar://problem/9141269>
Cleaned up the objective C name parsing code to use a class. Now breakpoints that are set by name that are objective C methods without the leading '+' or '-' will resolve. We do this by expanding all the objective C names for a given string. For example: (lldb) b [MyString cStringUsingEncoding:] Will set a breakpoint with multiple possible names: -[MyString cStringUsingEncoding:] +[MyString cStringUsingEncoding:] Also if you have a category, it will strip the category and set a breakpoint in all variants: (lldb) [MyString(my_category) cStringUsingEncoding:] Will resolve to the following names: -[MyString(my_category) cStringUsingEncoding:] +[MyString(my_category) cStringUsingEncoding:] -[MyString cStringUsingEncoding:] +[MyString cStringUsingEncoding:] Likewise when we have: (lldb) b -[MyString(my_category) cStringUsingEncoding:] It will resolve to two names: -[MyString(my_category) cStringUsingEncoding:] -[MyString cStringUsingEncoding:] llvm-svn: 173858
Diffstat (limited to 'lldb/source/Core/RegularExpression.cpp')
-rw-r--r--lldb/source/Core/RegularExpression.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/lldb/source/Core/RegularExpression.cpp b/lldb/source/Core/RegularExpression.cpp
index d98bf484abf..1f99bc745f8 100644
--- a/lldb/source/Core/RegularExpression.cpp
+++ b/lldb/source/Core/RegularExpression.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/Core/RegularExpression.h"
+#include "llvm/ADT/StringRef.h"
#include <string.h>
using namespace lldb_private;
@@ -146,6 +147,34 @@ RegularExpression::Execute(const char* s, size_t num_matches, int execute_flags)
}
bool
+RegularExpression::ExecuteThreadSafe (const char* s, llvm::StringRef *match_srefs, size_t count, int execute_flags) const
+{
+ bool success = false;
+ if (m_comp_err == 0)
+ {
+ std::vector<regmatch_t> matches;
+
+ if (match_srefs && count > 0)
+ matches.resize(count + 1);
+
+ success = ::regexec (&m_preg,
+ s,
+ matches.size(),
+ matches.data(),
+ execute_flags) == 0;
+ for (size_t i=0; i<count; ++i)
+ {
+ size_t match_idx = i+1;
+ if (success && matches[match_idx].rm_so < matches[match_idx].rm_eo)
+ match_srefs[i] = llvm::StringRef(s + matches[match_idx].rm_so, matches[match_idx].rm_eo - matches[match_idx].rm_so);
+ else
+ match_srefs[i] = llvm::StringRef();
+ }
+ }
+ return success;
+}
+
+bool
RegularExpression::GetMatchAtIndex (const char* s, uint32_t idx, std::string& match_str) const
{
if (idx <= m_preg.re_nsub && idx < m_matches.size())
@@ -166,6 +195,46 @@ RegularExpression::GetMatchAtIndex (const char* s, uint32_t idx, std::string& ma
return false;
}
+bool
+RegularExpression::GetMatchAtIndex (const char* s, uint32_t idx, llvm::StringRef& match_str) const
+{
+ if (idx <= m_preg.re_nsub && idx < m_matches.size())
+ {
+ if (m_matches[idx].rm_eo == m_matches[idx].rm_so)
+ {
+ // Matched the empty string...
+ match_str = llvm::StringRef();
+ return true;
+ }
+ else if (m_matches[idx].rm_eo > m_matches[idx].rm_so)
+ {
+ match_str = llvm::StringRef (s + m_matches[idx].rm_so, m_matches[idx].rm_eo - m_matches[idx].rm_so);
+ return true;
+ }
+ }
+ return false;
+}
+
+bool
+RegularExpression::GetMatchSpanningIndices (const char* s, uint32_t idx1, uint32_t idx2, llvm::StringRef& match_str) const
+{
+ if (idx1 <= m_preg.re_nsub && idx1 < m_matches.size() && idx2 <= m_preg.re_nsub && idx2 < m_matches.size())
+ {
+ if (m_matches[idx1].rm_so == m_matches[idx2].rm_eo)
+ {
+ // Matched the empty string...
+ match_str = llvm::StringRef();
+ return true;
+ }
+ else if (m_matches[idx1].rm_so < m_matches[idx2].rm_eo)
+ {
+ match_str = llvm::StringRef (s + m_matches[idx1].rm_so, m_matches[idx2].rm_eo - m_matches[idx1].rm_so);
+ return true;
+ }
+ }
+ return false;
+}
+
//----------------------------------------------------------------------
// Returns true if the regular expression compiled and is ready
OpenPOWER on IntegriCloud