hintonda updated this revision to Diff 120933.
hintonda added a comment.

- Remove prefix and add options.


https://reviews.llvm.org/D39436

Files:
  include/lldb/Utility/FileSpec.h
  source/Commands/CommandObjectBreakpoint.cpp
  source/Utility/FileSpec.cpp

Index: source/Utility/FileSpec.cpp
===================================================================
--- source/Utility/FileSpec.cpp
+++ source/Utility/FileSpec.cpp
@@ -180,12 +180,19 @@
     : FileSpec{path, resolve_path,
                Triple.isOSWindows() ? ePathSyntaxWindows : ePathSyntaxPosix} {}
 
+FileSpec::FileSpec(llvm::StringRef regex) {
+  m_syntax = ePathSyntaxHostNative;
+  m_filename.SetString(regex);
+  m_regex.Compile(regex);
+}
+
 //------------------------------------------------------------------
 // Copy constructor
 //------------------------------------------------------------------
 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 +216,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;
 }
@@ -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: source/Commands/CommandObjectBreakpoint.cpp
===================================================================
--- source/Commands/CommandObjectBreakpoint.cpp
+++ source/Commands/CommandObjectBreakpoint.cpp
@@ -256,6 +256,8 @@
   { LLDB_OPT_NOT_10,               false, "shlib",                  's', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eModuleCompletion,     eArgTypeShlibName,           "Set the breakpoint only in this shared library.  Can repeat this option "
   "multiple times to specify multiple shared libraries." },
   { LLDB_OPT_SET_ALL,              false, "hardware",               'H', OptionParser::eNoArgument,       nullptr, nullptr, 0,                                         eArgTypeNone,                "Require the breakpoint to use hardware breakpoints." },
+  { LLDB_OPT_FILE,                 false, "source-file-regex",      'z', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eSourceFileCompletion, eArgTypeRegularExpression,   "Only files matching pattern." },
+  { LLDB_OPT_FILE,                 false, "module-regex",           'Z', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eSourceFileCompletion, eArgTypeRegularExpression,   "Only modules matching pattern." },
   { LLDB_OPT_FILE,                 false, "file",                   'f', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,            "Specifies the source file in which to set this breakpoint.  Note, by default "
   "lldb only looks for files that are #included if they use the standard include "
   "file extensions.  To set breakpoints on .c/.cpp/.m/.mm files that are "
@@ -560,6 +562,14 @@
         m_source_regex_func_names.insert(option_arg);
         break;
 
+      case 'z':
+        m_filenames.AppendIfUnique(FileSpec(option_arg));
+        break;
+
+      case 'Z':
+        m_modules.AppendIfUnique(FileSpec(option_arg));
+        break;
+
       default:
         error.SetErrorStringWithFormat("unrecognized option '%c'",
                                        short_option);
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"
@@ -92,6 +93,8 @@
   explicit FileSpec(llvm::StringRef path, bool resolve_path,
                     const llvm::Triple &Triple);
 
+  explicit FileSpec(llvm::StringRef regex);
+
   //------------------------------------------------------------------
   /// Copy constructor
   ///
@@ -583,6 +586,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.
 };
 
 //----------------------------------------------------------------------
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to