[Lldb-commits] [PATCH] D136890: [lldb-vscode] Don't call SBValue.GetError after generating a summary.
Jorge Gorbe Moya via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 27 14:54:52 PDT 2022
jgorbe created this revision.
jgorbe added reviewers: yinghuitan, clayborg.
jgorbe added a project: LLDB.
Herald added a subscriber: JDevlieghere.
Herald added a project: All.
jgorbe requested review of this revision.
In some occasions, SBValue::GetError can invalidate its cached
`m_summary_str` member. This in turn invalidates any StringRef variables
pointing to it.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D136890
Files:
lldb/tools/lldb-vscode/JSONUtils.cpp
Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===================================================================
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -132,27 +132,28 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136890.471298.patch
Type: text/x-patch
Size: 1689 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20221027/ac24f2da/attachment.bin>
More information about the lldb-commits
mailing list