[Lldb-commits] [PATCH] D39436: Add regex support to file (-f) and module (-s) breakpoints.
Don Hinton via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Oct 30 14:56:26 PDT 2017
hintonda created this revision.
Add regex support to file and module names when setting breakpoints.
This solution is enabled via a "regex:" prefix, and doesn't require any other
api changes.
In this example, setting breakpoints for a particular function was twice as
fast using "regex:.*/clang/.*":
br s -n "DiagnosticsEngine::Report" -f "regex:.*/clang/.*"
https://reviews.llvm.org/D39436
Files:
include/lldb/Utility/FileSpec.h
source/Utility/FileSpec.cpp
Index: source/Utility/FileSpec.cpp
===================================================================
--- source/Utility/FileSpec.cpp
+++ source/Utility/FileSpec.cpp
@@ -185,7 +185,8 @@
//------------------------------------------------------------------
FileSpec::FileSpec(const FileSpec &rhs)
: m_directory(rhs.m_directory), m_filename(rhs.m_filename),
- m_is_resolved(rhs.m_is_resolved), m_syntax(rhs.m_syntax) {}
+ m_is_resolved(rhs.m_is_resolved), m_syntax(rhs.m_syntax),
+ m_regex(rhs.m_regex) {}
//------------------------------------------------------------------
// Copy constructor
@@ -209,6 +210,7 @@
m_filename = rhs.m_filename;
m_is_resolved = rhs.m_is_resolved;
m_syntax = rhs.m_syntax;
+ m_regex = rhs.m_regex;
}
return *this;
}
@@ -232,6 +234,12 @@
if (pathname.empty())
return;
+ if(pathname.startswith("regex:")) {
+ m_filename.SetString(pathname);
+ m_regex.Compile(pathname.substr(6));
+ return;
+ }
+
llvm::SmallString<64> resolved(pathname);
if (resolve) {
@@ -301,6 +309,9 @@
// Equal to operator
//------------------------------------------------------------------
bool FileSpec::operator==(const FileSpec &rhs) const {
+ if (m_regex.IsValid())
+ return m_regex.Execute(rhs.GetPath());
+
if (!FileEquals(rhs))
return false;
if (DirectoryEquals(rhs))
@@ -411,6 +422,9 @@
bool FileSpec::Equal(const FileSpec &a, const FileSpec &b, bool full,
bool remove_backups) {
+ if (a.m_regex.IsValid())
+ return a.m_regex.Execute(b.GetPath());
+
static ConstString g_dot_string(".");
static ConstString g_dot_dot_string("..");
Index: include/lldb/Utility/FileSpec.h
===================================================================
--- include/lldb/Utility/FileSpec.h
+++ include/lldb/Utility/FileSpec.h
@@ -18,6 +18,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/RegularExpression.h"
#include "llvm/ADT/StringRef.h" // for StringRef
#include "llvm/Support/FileSystem.h"
@@ -583,6 +584,7 @@
mutable bool m_is_resolved = false; ///< True if this path has been resolved.
PathSyntax
m_syntax; ///< The syntax that this path uses (e.g. Windows / Posix)
+ RegularExpression m_regex; ///< Regular expression in "regex:" prefix passed.
};
//----------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39436.120895.patch
Type: text/x-patch
Size: 2470 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20171030/fb75b351/attachment-0001.bin>
More information about the lldb-commits
mailing list