@@ -319,6 +319,13 @@ void SBThread::SetThread(const ThreadSP &lldb_object_sp) {
319319lldb::tid_t SBThread::GetThreadID () const {
320320 LLDB_INSTRUMENT_VA (this );
321321
322+ llvm::Expected<StoppedExecutionContext> exe_ctx =
323+ GetStoppedExecutionContext (m_opaque_sp);
324+ if (!exe_ctx) {
325+ LLDB_LOG_ERROR (GetLog (LLDBLog::API), exe_ctx.takeError (), " {0}" );
326+ return LLDB_INVALID_THREAD_ID;
327+ }
328+
322329 ThreadSP thread_sp (m_opaque_sp->GetThreadSP ());
323330 if (thread_sp)
324331 return thread_sp->GetID ();
@@ -328,6 +335,13 @@ lldb::tid_t SBThread::GetThreadID() const {
328335uint32_t SBThread::GetIndexID () const {
329336 LLDB_INSTRUMENT_VA (this );
330337
338+ llvm::Expected<StoppedExecutionContext> exe_ctx =
339+ GetStoppedExecutionContext (m_opaque_sp);
340+ if (!exe_ctx) {
341+ LLDB_LOG_ERROR (GetLog (LLDBLog::API), exe_ctx.takeError (), " {0}" );
342+ return LLDB_INVALID_INDEX32;
343+ }
344+
331345 ThreadSP thread_sp (m_opaque_sp->GetThreadSP ());
332346 if (thread_sp)
333347 return thread_sp->GetIndexID ();
@@ -1315,6 +1329,13 @@ SBThread SBThread::GetExtendedBacktraceThread(const char *type) {
13151329uint32_t SBThread::GetExtendedBacktraceOriginatingIndexID () {
13161330 LLDB_INSTRUMENT_VA (this );
13171331
1332+ llvm::Expected<StoppedExecutionContext> exe_ctx =
1333+ GetStoppedExecutionContext (m_opaque_sp);
1334+ if (!exe_ctx) {
1335+ LLDB_LOG_ERROR (GetLog (LLDBLog::API), exe_ctx.takeError (), " {0}" );
1336+ return LLDB_INVALID_INDEX32;
1337+ }
1338+
13181339 ThreadSP thread_sp (m_opaque_sp->GetThreadSP ());
13191340 if (thread_sp)
13201341 return thread_sp->GetExtendedBacktraceOriginatingIndexID ();
@@ -1324,6 +1345,13 @@ uint32_t SBThread::GetExtendedBacktraceOriginatingIndexID() {
13241345SBValue SBThread::GetCurrentException () {
13251346 LLDB_INSTRUMENT_VA (this );
13261347
1348+ llvm::Expected<StoppedExecutionContext> exe_ctx =
1349+ GetStoppedExecutionContext (m_opaque_sp);
1350+ if (!exe_ctx) {
1351+ LLDB_LOG_ERROR (GetLog (LLDBLog::API), exe_ctx.takeError (), " {0}" );
1352+ return SBValue ();
1353+ }
1354+
13271355 ThreadSP thread_sp (m_opaque_sp->GetThreadSP ());
13281356 if (!thread_sp)
13291357 return SBValue ();
@@ -1334,6 +1362,13 @@ SBValue SBThread::GetCurrentException() {
13341362SBThread SBThread::GetCurrentExceptionBacktrace () {
13351363 LLDB_INSTRUMENT_VA (this );
13361364
1365+ llvm::Expected<StoppedExecutionContext> exe_ctx =
1366+ GetStoppedExecutionContext (m_opaque_sp);
1367+ if (!exe_ctx) {
1368+ LLDB_LOG_ERROR (GetLog (LLDBLog::API), exe_ctx.takeError (), " {0}" );
1369+ return SBThread ();
1370+ }
1371+
13371372 ThreadSP thread_sp (m_opaque_sp->GetThreadSP ());
13381373 if (!thread_sp)
13391374 return SBThread ();
@@ -1344,6 +1379,13 @@ SBThread SBThread::GetCurrentExceptionBacktrace() {
13441379bool SBThread::SafeToCallFunctions () {
13451380 LLDB_INSTRUMENT_VA (this );
13461381
1382+ llvm::Expected<StoppedExecutionContext> exe_ctx =
1383+ GetStoppedExecutionContext (m_opaque_sp);
1384+ if (!exe_ctx) {
1385+ LLDB_LOG_ERROR (GetLog (LLDBLog::API), exe_ctx.takeError (), " {0}" );
1386+ return false ;
1387+ }
1388+
13471389 ThreadSP thread_sp (m_opaque_sp->GetThreadSP ());
13481390 if (thread_sp)
13491391 return thread_sp->SafeToCallFunctions ();
@@ -1363,6 +1405,13 @@ lldb_private::Thread *SBThread::get() {
13631405SBValue SBThread::GetSiginfo () {
13641406 LLDB_INSTRUMENT_VA (this );
13651407
1408+ llvm::Expected<StoppedExecutionContext> exe_ctx =
1409+ GetStoppedExecutionContext (m_opaque_sp);
1410+ if (!exe_ctx) {
1411+ LLDB_LOG_ERROR (GetLog (LLDBLog::API), exe_ctx.takeError (), " {0}" );
1412+ return SBValue ();
1413+ }
1414+
13661415 ThreadSP thread_sp = m_opaque_sp->GetThreadSP ();
13671416 if (!thread_sp)
13681417 return SBValue ();
0 commit comments