diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index 6913a9c3ee699..330862e5d2a52 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -620,7 +620,7 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { RegularExpression regexp(m_options.m_func_regexp); if (llvm::Error err = regexp.GetError()) { result.AppendErrorWithFormat( - "Function name regular expression could not be compiled: \"%s\"", + "Function name regular expression could not be compiled: %s", llvm::toString(std::move(err)).c_str()); result.SetStatus(eReturnStatusFailed); return false; diff --git a/lldb/source/Utility/RegularExpression.cpp b/lldb/source/Utility/RegularExpression.cpp index fd9d963f7294c..b58ce76ff24f4 100644 --- a/lldb/source/Utility/RegularExpression.cpp +++ b/lldb/source/Utility/RegularExpression.cpp @@ -35,7 +35,7 @@ llvm::StringRef RegularExpression::GetText() const { return m_regex_text; } llvm::Error RegularExpression::GetError() const { std::string error; if (!m_regex.isValid(error)) - return llvm::make_error<llvm::StringError>(llvm::inconvertibleErrorCode(), - error); + return llvm::make_error<llvm::StringError>(error, + llvm::inconvertibleErrorCode()); return llvm::Error::success(); } diff --git a/lldb/test/API/commands/breakpoint/set/func-regex/TestBreakpointRegexError.py b/lldb/test/API/commands/breakpoint/set/func-regex/TestBreakpointRegexError.py new file mode 100644 index 0000000000000..a8cfcf2d1d87a --- /dev/null +++ b/lldb/test/API/commands/breakpoint/set/func-regex/TestBreakpointRegexError.py @@ -0,0 +1,14 @@ +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @no_debug_info_test + def test_error(self): + self.expect("breakpoint set --func-regex (", error=True, + substrs=["error: Function name regular expression could " + + "not be compiled: parentheses not balanced"])