[Lldb-commits] [PATCH] D126014: Show error message for optimized variables

Jorge Gorbe Moya via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 26 17:04:49 PDT 2022


jgorbe added a comment.

Hi! I've just debugged an issue that brought me to this commit. I'll start preparing a patch tomorrow (not sure how to test it yet) but since it's a recent-ish change I figured I'd ping the commit thread to give you a heads up.

`v.GetSummary()` returns a char* that is backed by a member `std::string m_summary_str` in SBValue, and we put the result in a StringRef that just points there. I've found that in some cases the call to `v.GetError()` invalidates the cached summary and causes the `m_summary_str` member to be cleared.

So, if we have a summary provider that returns "Summary string", it ends up being displayed as "<NUL byte>ummary string", because clearing `m_summary_str` sets the first byte to 0 but we are still holding on to a StringRef with the old length.

Calling `v.GetError()` first seems to avoid the issue. Another option to fix it would be to keep the summary in a local `std::string` instead. Any preference?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126014/new/

https://reviews.llvm.org/D126014



More information about the lldb-commits mailing list