[lldb/API] NFC: Reformat and simplify SBThread::GetStopDescription()

Summary:
This gets rid of some nesting and of the raw char* variable that caused
the memory management bug we hit recently.

This commit also removes the fallback code which should trigger when
the StopInfo provides no stop description. All currently implemented
StopInfos have a `GetDescription()` method that shouldn't return an
empty description.

Reviewers: JDevlieghere, labath, mib

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74157
This commit is contained in:
Fred Riss
2020-02-05 21:47:33 -08:00
parent c0a2da9460
commit 20ce8affce
2 changed files with 23 additions and 91 deletions

View File

@@ -596,8 +596,12 @@ std::string Thread::GetStopDescription() {
std::string Thread::GetStopDescriptionRaw() {
StopInfoSP stop_info_sp = GetStopInfo();
std::string raw_stop_description;
if (stop_info_sp && stop_info_sp->IsValid())
if (stop_info_sp && stop_info_sp->IsValid()) {
raw_stop_description = stop_info_sp->GetDescription();
assert((!raw_stop_description.empty() ||
stop_info_sp->GetStopReason() == eStopReasonNone) &&
"StopInfo returned an empty description.");
}
return raw_stop_description;
}