aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/API
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/API')
-rw-r--r--lldb/source/API/SBThread.cpp35
1 files changed, 29 insertions, 6 deletions
diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp
index 4e4aa48..f58a1b5 100644
--- a/lldb/source/API/SBThread.cpp
+++ b/lldb/source/API/SBThread.cpp
@@ -239,11 +239,34 @@ SBThread::GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type) {
return threads;
}
-size_t SBThread::GetStopDescription(char *dst, size_t dst_len) {
- LLDB_INSTRUMENT_VA(this, dst, dst_len);
+bool SBThread::GetStopDescription(lldb::SBStream &stream) const {
+ LLDB_INSTRUMENT_VA(this, stream);
+
+ if (!m_opaque_sp)
+ return false;
+
+ llvm::Expected<StoppedExecutionContext> exe_ctx =
+ GetStoppedExecutionContext(m_opaque_sp);
+ if (!exe_ctx) {
+ LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
+ return false;
+ }
+
+ if (!exe_ctx->HasThreadScope())
+ return false;
+
+ Stream &strm = stream.ref();
+ const std::string stop_desc = exe_ctx->GetThreadPtr()->GetStopDescription();
+ strm.PutCString(stop_desc);
+
+ return true;
+}
+
+size_t SBThread::GetStopDescription(char *dst_or_null, size_t dst_len) {
+ LLDB_INSTRUMENT_VA(this, dst_or_null, dst_len);
- if (dst)
- *dst = 0;
+ if (dst_or_null)
+ *dst_or_null = 0;
llvm::Expected<StoppedExecutionContext> exe_ctx =
GetStoppedExecutionContext(m_opaque_sp);
@@ -259,8 +282,8 @@ size_t SBThread::GetStopDescription(char *dst, size_t dst_len) {
if (thread_stop_desc.empty())
return 0;
- if (dst)
- return ::snprintf(dst, dst_len, "%s", thread_stop_desc.c_str()) + 1;
+ if (dst_or_null)
+ return ::snprintf(dst_or_null, dst_len, "%s", thread_stop_desc.c_str()) + 1;
// NULL dst passed in, return the length needed to contain the
// description.