//------------------------------------------------------------------
RegularExpression ();
- //------------------------------------------------------------------
- /// Constructor that takes a regular expression with flags.
- ///
- /// Constructor that compiles \a re using \a flags and stores the
- /// resulting compiled regular expression into this object.
- ///
- /// @param[in] re
- /// A c string that represents the regular expression to
- /// compile.
- ///
- /// @param[in] flags
- /// Flags that are passed to the \c regcomp() function.
- //------------------------------------------------------------------
- explicit
- RegularExpression (const char* re, int flags);
-
- // This one uses flags = REG_EXTENDED.
explicit
RegularExpression (const char* re);
/// Compile a regular expression.
///
/// Compile a regular expression using the supplied regular
- /// expression text and flags. The compiled regular expression lives
+ /// expression text. The compiled regular expression lives
/// in this object so that it can be readily used for regular
/// expression matches. Execute() can be called after the regular
/// expression is compiled. Any previously compiled regular
/// A NULL terminated C string that represents the regular
/// expression to compile.
///
- /// @param[in] flags
- /// Flags that are passed to the \c regcomp() function.
- ///
/// @return
/// \b true if the regular expression compiles successfully,
/// \b false otherwise.
bool
Compile (const char* re);
- bool
- Compile (const char* re, int flags);
-
//------------------------------------------------------------------
/// Executes a regular expression.
///
/// expression that is already in this object against the match
/// string \a s. If any parens are used for regular expression
/// matches \a match_count should indicate the number of regmatch_t
- /// values that are present in \a match_ptr. The regular expression
- /// will be executed using the \a execute_flags
+ /// values that are present in \a match_ptr.
///
/// @param[in] string
/// The string to match against the compile regular expression.
/// properly initialized with the desired number of maximum
/// matches, or NULL if no parenthesized matching is needed.
///
- /// @param[in] execute_flags
- /// Flags to pass to the \c regexec() function.
- ///
/// @return
/// \b true if \a string matches the compiled regular
/// expression, \b false otherwise.
//------------------------------------------------------------------
bool
- Execute (const char* string, Match *match = NULL, int execute_flags = 0) const;
+ Execute (const char* string, Match *match = NULL) const;
size_t
GetErrorAsCString (char *err_str, size_t err_str_max_len) const;
const char*
GetText () const;
- int
- GetCompileFlags () const
- {
- return m_compile_flags;
- }
-
//------------------------------------------------------------------
/// Test if valid.
///
{
Free();
m_re.clear();
- m_compile_flags = 0;
m_comp_err = 1;
}
std::string m_re; ///< A copy of the original regular expression text
int m_comp_err; ///< Error code for the regular expression compilation
regex_t m_preg; ///< The compiled regular expression
- int m_compile_flags; ///< Stores the flags from the last compile.
};
} // namespace lldb_private
class OptionValueRegex : public OptionValue
{
public:
- OptionValueRegex (const char *value = NULL, uint32_t regex_flags = 0) :
+ OptionValueRegex (const char *value = NULL) :
OptionValue(),
- m_regex (value, regex_flags)
+ m_regex (value)
{
}
}
void
- SetCurrentValue (const char *value, uint32_t regex_flags)
+ SetCurrentValue (const char *value)
{
if (value && value[0])
- m_regex.Compile (value, regex_flags);
+ m_regex.Compile (value);
else
m_regex.Clear();
}
//
//===----------------------------------------------------------------------===//
+#include <string.h>
#include "lldb/Core/RegularExpression.h"
#include "llvm/ADT/StringRef.h"
-#include <string.h>
+#include "lldb/Core/Error.h"
-using namespace lldb_private;
//----------------------------------------------------------------------
-// Default constructor
+// Enable enhanced mode if it is available. This allows for things like
+// \d for digit, \s for space, and many more, but it isn't available
+// everywhere.
//----------------------------------------------------------------------
-RegularExpression::RegularExpression() :
- m_re(),
- m_comp_err (1),
- m_preg(),
- m_compile_flags(REG_EXTENDED)
-{
- memset(&m_preg,0,sizeof(m_preg));
-}
+#if defined(REG_ENHANCED)
+#define DEFAULT_COMPILE_FLAGS (REG_ENHANCED|REG_EXTENDED)
+#else
+#define DEFAULT_COMPILE_FLAGS (REG_EXTENDED)
+#endif
+
+using namespace lldb_private;
//----------------------------------------------------------------------
-// Constructor that compiles "re" using "flags" and stores the
-// resulting compiled regular expression into this object.
+// Default constructor
//----------------------------------------------------------------------
-RegularExpression::RegularExpression(const char* re, int flags) :
+RegularExpression::RegularExpression() :
m_re(),
m_comp_err (1),
- m_preg(),
- m_compile_flags(flags)
+ m_preg()
{
memset(&m_preg,0,sizeof(m_preg));
- Compile(re);
}
//----------------------------------------------------------------------
RegularExpression::RegularExpression(const char* re) :
m_re(),
m_comp_err (1),
- m_preg(),
- m_compile_flags(REG_EXTENDED)
+ m_preg()
{
memset(&m_preg,0,sizeof(m_preg));
Compile(re);
RegularExpression::RegularExpression(const RegularExpression &rhs)
{
memset(&m_preg,0,sizeof(m_preg));
- Compile(rhs.GetText(), rhs.GetCompileFlags());
+ Compile(rhs.GetText());
}
const RegularExpression &
RegularExpression::operator= (const RegularExpression &rhs)
{
if (&rhs != this)
- {
- Compile (rhs.GetText(), rhs.GetCompileFlags());
- }
+ Compile (rhs.GetText());
return *this;
}
//----------------------------------------------------------------------
bool
RegularExpression::Compile(const char* re)
{
- return Compile (re, m_compile_flags);
-}
-
-bool
-RegularExpression::Compile(const char* re, int flags)
-{
Free();
- m_compile_flags = flags;
if (re && re[0])
{
m_re = re;
- m_comp_err = ::regcomp (&m_preg, re, flags);
+ m_comp_err = ::regcomp (&m_preg, re, DEFAULT_COMPILE_FLAGS);
}
else
{
// will be executed using the "execute_flags".
//---------------------------------------------------------------------
bool
-RegularExpression::Execute(const char* s, Match *match, int execute_flags) const
+RegularExpression::Execute (const char* s, Match *match) const
{
int err = 1;
if (s != NULL && m_comp_err == 0)
s,
match->GetSize(),
match->GetData(),
- execute_flags);
+ 0);
}
else
{
s,
0,
NULL,
- execute_flags);
+ 0);
}
}
ConstString extension (GetFileNameExtension());
if (extension)
{
- static RegularExpression g_source_file_regex ("^(c|m|mm|cpp|c\\+\\+|cxx|cc|cp|s|asm|f|f77|f90|f95|f03|for|ftn|fpp|ada|adb|ads)$",
- REG_EXTENDED | REG_ICASE);
+ static RegularExpression g_source_file_regex ("^([cC]|[mM]|[mM][mM]|[cC][pP][pP]|[cC]\\+\\+|[cC][xX][xX]|[cC][cC]|[cC][pP]|[sS]|[aA][sS][mM]|[fF]|[fF]77|[fF]90|[fF]95|[fF]03|[fF][oO][rR]|[fF][tT][nN]|[fF][pP][pP]|[aA][dD][aA]|[aA][dD][bB]|[aA][dD][sS])$");
return g_source_file_regex.Execute (extension.GetCString());
}
return false;
{
m_entries.resize(m_entries.size() + 1);
// Only add the regular expression if it compiles
- if (m_entries.back().regex.Compile (re_cstr, REG_EXTENDED))
+ if (m_entries.back().regex.Compile (re_cstr))
{
m_entries.back().command.assign (command_cstr);
return true;
case eVarSetOperationReplace:
case eVarSetOperationAssign:
- if (m_regex.Compile (value_cstr, m_regex.GetCompileFlags()))
+ if (m_regex.Compile (value_cstr))
{
m_value_was_set = true;
NotifyValueChanged();
lldb::OptionValueSP
OptionValueRegex::DeepCopy () const
{
- return OptionValueSP(new OptionValueRegex(m_regex.GetText(), m_regex.GetCompileFlags()));
+ return OptionValueSP(new OptionValueRegex(m_regex.GetText()));
}
// "definition.default_uint_value" is used to the regular expression flags
// "definition.default_cstr_value" the default regular expression value
// value.
- m_value_sp.reset (new OptionValueRegex(definition.default_cstr_value, definition.default_uint_value));
+ m_value_sp.reset (new OptionValueRegex(definition.default_cstr_value));
break;
case OptionValue::eTypeSInt64:
}
}
- static RegularExpression s_regex("[ \t]*([^ ^\t]+)[ \t]*([^ ^\t].*)?", REG_EXTENDED);
+ static RegularExpression s_regex("[ \t]*([^ ^\t]+)[ \t]*([^ ^\t].*)?");
RegularExpression::Match matches(3);
{ "step-in-avoid-nodebug", OptionValue::eTypeBoolean, true, true, NULL, NULL, "If true, step-in will not stop in functions with no debug information." },
{ "step-out-avoid-nodebug", OptionValue::eTypeBoolean, true, false, NULL, NULL, "If true, when step-in/step-out/step-over leave the current frame, they will continue to step out till they come to a function with "
"debug information. Passing a frame argument to step-out will override this option." },
- { "step-avoid-regexp", OptionValue::eTypeRegex , true , REG_EXTENDED, "^std::", NULL, "A regular expression defining functions step-in won't stop in." },
- { "step-avoid-libraries", OptionValue::eTypeFileSpecList , true , REG_EXTENDED, NULL, NULL, "A list of libraries that source stepping won't stop in." },
+ { "step-avoid-regexp", OptionValue::eTypeRegex , true , 0, "^std::", NULL, "A regular expression defining functions step-in won't stop in." },
+ { "step-avoid-libraries", OptionValue::eTypeFileSpecList , true , 0, NULL, NULL, "A list of libraries that source stepping won't stop in." },
{ "trace-thread", OptionValue::eTypeBoolean, false, false, NULL, NULL, "If true, this thread will single-step and log execution." },
{ NULL , OptionValue::eTypeInvalid, false, 0 , NULL, NULL, NULL }
};