[Lldb-commits] [lldb] 7d4d25c - [lldb-vscode] Don't call SBValue.GetError after generating a summary.
Jorge Gorbe Moya via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 27 15:05:50 PDT 2022
Author: Jorge Gorbe Moya
Date: 2022-10-27T15:05:27-07:00
New Revision: 7d4d25c42a682ec5abcc008225268a6ce82673f3
URL: https://github.com/llvm/llvm-project/commit/7d4d25c42a682ec5abcc008225268a6ce82673f3
DIFF: https://github.com/llvm/llvm-project/commit/7d4d25c42a682ec5abcc008225268a6ce82673f3.diff
LOG: [lldb-vscode] Don't call SBValue.GetError after generating a summary.
In some occasions, SBValue::GetError can invalidate its cached
`m_summary_str` member. This in turn invalidates any StringRef variables
pointing to it.
Differential Revision: https://reviews.llvm.org/D136890
Added:
Modified:
lldb/tools/lldb-vscode/JSONUtils.cpp
Removed:
################################################################################
diff --git a/lldb/tools/lldb-vscode/JSONUtils.cpp b/lldb/tools/lldb-vscode/JSONUtils.cpp
index baeed2a81105c..39c24f8b23e39 100644
--- a/lldb/tools/lldb-vscode/JSONUtils.cpp
+++ b/lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -132,27 +132,28 @@ std::vector<std::string> GetStrings(const llvm::json::Object *obj,
void SetValueForKey(lldb::SBValue &v, llvm::json::Object &object,
llvm::StringRef key) {
-
- llvm::StringRef value = v.GetValue();
- llvm::StringRef summary = v.GetSummary();
- llvm::StringRef type_name = v.GetType().GetDisplayTypeName();
- lldb::SBError error = v.GetError();
-
std::string result;
llvm::raw_string_ostream strm(result);
+
+ lldb::SBError error = v.GetError();
if (!error.Success()) {
strm << "<error: " << error.GetCString() << ">";
- } else if (!value.empty()) {
- strm << value;
- if (!summary.empty())
+ } else {
+ llvm::StringRef value = v.GetValue();
+ llvm::StringRef summary = v.GetSummary();
+ llvm::StringRef type_name = v.GetType().GetDisplayTypeName();
+ if (!value.empty()) {
+ strm << value;
+ if (!summary.empty())
+ strm << ' ' << summary;
+ } else if (!summary.empty()) {
strm << ' ' << summary;
- } else if (!summary.empty()) {
- strm << ' ' << summary;
- } else if (!type_name.empty()) {
- strm << type_name;
- lldb::addr_t address = v.GetLoadAddress();
- if (address != LLDB_INVALID_ADDRESS)
- strm << " @ " << llvm::format_hex(address, 0);
+ } else if (!type_name.empty()) {
+ strm << type_name;
+ lldb::addr_t address = v.GetLoadAddress();
+ if (address != LLDB_INVALID_ADDRESS)
+ strm << " @ " << llvm::format_hex(address, 0);
+ }
}
strm.flush();
EmplaceSafeString(object, key, result);
More information about the lldb-commits
mailing list