Skip to content

Commit 4546ed6

Browse files
author
git apple-llvm automerger
committed
Merge commit '34e235a02604' from apple/stable/20200108 into swift/release/5.3
2 parents 0e3f0ff + 34e235a commit 4546ed6

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -491,19 +491,32 @@ ValueObjectSP AppleObjCRuntime::GetExceptionObjectForThread(
491491
return ValueObjectSP();
492492
}
493493

494+
/// Utility method for error handling in GetBacktraceThreadFromException.
495+
/// \param msg The message to add to the log.
496+
/// \return An invalid ThreadSP to be returned from
497+
/// GetBacktraceThreadFromException.
498+
LLVM_NODISCARD
499+
static ThreadSP FailExceptionParsing(llvm::StringRef msg) {
500+
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
501+
LLDB_LOG(log, "Failed getting backtrace from exception: {0}", msg);
502+
return ThreadSP();
503+
}
504+
494505
ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException(
495506
lldb::ValueObjectSP exception_sp) {
496507
ValueObjectSP reserved_dict =
497508
exception_sp->GetChildMemberWithName(ConstString("reserved"), true);
498-
if (!reserved_dict) return ThreadSP();
509+
if (!reserved_dict)
510+
return FailExceptionParsing("Failed to get 'reserved' member.");
499511

500512
reserved_dict = reserved_dict->GetSyntheticValue();
501-
if (!reserved_dict) return ThreadSP();
513+
if (!reserved_dict)
514+
return FailExceptionParsing("Failed to get synthetic value.");
502515

503516
TypeSystemClang *clang_ast_context =
504517
TypeSystemClang::GetScratch(*exception_sp->GetTargetSP());
505518
if (!clang_ast_context)
506-
return ThreadSP();
519+
return FailExceptionParsing("Failed to get scratch AST.");
507520
CompilerType objc_id =
508521
clang_ast_context->GetBasicType(lldb::eBasicTypeObjCID);
509522
ValueObjectSP return_addresses;
@@ -544,15 +557,22 @@ ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException(
544557
}
545558
}
546559

547-
if (!return_addresses) return ThreadSP();
560+
if (!return_addresses)
561+
return FailExceptionParsing("Failed to get return addresses.");
548562
auto frames_value =
549563
return_addresses->GetChildMemberWithName(ConstString("_frames"), true);
564+
if (!frames_value)
565+
return FailExceptionParsing("Failed to get frames_value.");
550566
addr_t frames_addr = frames_value->GetValueAsUnsigned(0);
551567
auto count_value =
552568
return_addresses->GetChildMemberWithName(ConstString("_cnt"), true);
569+
if (!count_value)
570+
return FailExceptionParsing("Failed to get count_value.");
553571
size_t count = count_value->GetValueAsUnsigned(0);
554572
auto ignore_value =
555573
return_addresses->GetChildMemberWithName(ConstString("_ignore"), true);
574+
if (!ignore_value)
575+
return FailExceptionParsing("Failed to get ignore_value.");
556576
size_t ignore = ignore_value->GetValueAsUnsigned(0);
557577

558578
size_t ptr_size = m_process->GetAddressByteSize();
@@ -564,7 +584,8 @@ ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException(
564584
pcs.push_back(pc);
565585
}
566586

567-
if (pcs.empty()) return ThreadSP();
587+
if (pcs.empty())
588+
return FailExceptionParsing("Failed to get PC list.");
568589

569590
ThreadSP new_thread_sp(new HistoryThread(*m_process, 0, pcs));
570591
m_process->GetExtendedThreadList().AddThread(new_thread_sp);

0 commit comments

Comments
 (0)