diff options
author | Dave Lee <davelee.com@gmail.com> | 2022-01-06 19:38:31 -0800 |
---|---|---|
committer | Dave Lee <davelee.com@gmail.com> | 2022-01-15 14:20:12 -0800 |
commit | 696f9706f34d76bca8f8d496eabe1a67b60e8a54 (patch) | |
tree | 5d219c4ecc937b98353f8d14c7d09a475e128edc /lldb/source/Commands/CommandObjectFrame.cpp | |
parent | c63a3175c2947e8c1a2d3bbe16a8586600705c54 (diff) | |
download | llvm-696f9706f34d76bca8f8d496eabe1a67b60e8a54.zip llvm-696f9706f34d76bca8f8d496eabe1a67b60e8a54.tar.gz llvm-696f9706f34d76bca8f8d496eabe1a67b60e8a54.tar.bz2 |
[lldb] Set result error state in 'frame variable'
Ensure that errors in `frame variable` are reflected in result object.
The statistics for `frame variable` show invocations as being successful, even
when executing one of the error paths.
This change replaces `result.GetErrorStream()` with `result.AppendError()`,
which also sets the status to `eReturnStatusFailed`.
Differential Revision: https://reviews.llvm.org/D116788
Recommitting after D116901 and D116863.
(cherry picked from commit 2c7d10c41278181e3e45c68f28b501cd95193a8a)
Diffstat (limited to 'lldb/source/Commands/CommandObjectFrame.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectFrame.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index 9cfe997..8dd1a79 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -558,18 +558,16 @@ protected: } } } else if (num_matches == 0) { - result.GetErrorStream().Printf("error: no variables matched " - "the regular expression '%s'.\n", - entry.c_str()); + result.AppendErrorWithFormat( + "no variables matched the regular expression '%s'.", + entry.c_str()); } } else { if (llvm::Error err = regex.GetError()) - result.GetErrorStream().Printf( - "error: %s\n", llvm::toString(std::move(err)).c_str()); + result.AppendError(llvm::toString(std::move(err))); else - result.GetErrorStream().Printf( - "error: unknown regex error when compiling '%s'\n", - entry.c_str()); + result.AppendErrorWithFormat( + "unknown regex error when compiling '%s'", entry.c_str()); } } else // No regex, either exact variable names or variable // expressions. @@ -605,14 +603,13 @@ protected: valobj_sp->GetParent() ? entry.c_str() : nullptr); valobj_sp->Dump(output_stream, options); } else { - const char *error_cstr = error.AsCString(nullptr); - if (error_cstr) - result.GetErrorStream().Printf("error: %s\n", error_cstr); + if (auto error_cstr = error.AsCString(nullptr)) + result.AppendError(error_cstr); else - result.GetErrorStream().Printf("error: unable to find any " - "variable expression path that " - "matches '%s'.\n", - entry.c_str()); + result.AppendErrorWithFormat( + "unable to find any variable expression path that matches " + "'%s'.", + entry.c_str()); } } } @@ -680,7 +677,8 @@ protected: } } } - result.SetStatus(eReturnStatusSuccessFinishResult); + if (result.GetStatus() != eReturnStatusFailed) + result.SetStatus(eReturnStatusSuccessFinishResult); } if (m_option_variable.show_recognized_args) { |