summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py7
-rw-r--r--lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp4
-rw-r--r--lldb/source/Target/Thread.cpp32
3 files changed, 27 insertions, 16 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py b/lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
index cc68e3677ec..1d4ee9aa579 100644
--- a/lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
+++ b/lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
@@ -196,11 +196,12 @@ class ObjCExceptionsTestCase(TestBase):
self.expect("thread list",
substrs=['stopped', 'stop reason = signal SIGABRT'])
- self.expect('thread exception', substrs=[])
+ self.expect('thread exception', substrs=['exception ='])
process = self.dbg.GetSelectedTarget().process
thread = process.GetSelectedThread()
- # C++ exceptions are not exposed in the API (yet).
- self.assertFalse(thread.GetCurrentException().IsValid())
+ self.assertTrue(thread.GetCurrentException().IsValid())
+
+ # C++ exception backtraces are not exposed in the API (yet).
self.assertFalse(thread.GetCurrentExceptionBacktrace().IsValid())
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
index 66278cacc44..ca2847f6a8c 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
@@ -594,6 +594,10 @@ ValueObjectSP ItaniumABILanguageRuntime::GetExceptionObjectForThread(
addr_t exception_addr =
m_process->ReadPointerFromMemory(result_ptr - ptr_size, error);
+ if (!error.Success()) {
+ return ValueObjectSP();
+ }
+
lldb_private::formatters::InferiorSizedWord exception_isw(exception_addr,
*m_process);
ValueObjectSP exception = ValueObject::CreateValueObjectFromData(
diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index 78176412b3a..a8b57c86f59 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -2209,25 +2209,31 @@ ValueObjectSP Thread::GetCurrentException() {
if (auto e = recognized_frame->GetExceptionObject())
return e;
- // FIXME: For now, only ObjC exceptions are supported. This should really
- // iterate over all language runtimes and ask them all to give us the current
- // exception.
- if (auto runtime = GetProcess()->GetObjCLanguageRuntime())
- if (auto e = runtime->GetExceptionObjectForThread(shared_from_this()))
- return e;
+ // NOTE: Even though this behavior is generalized, only ObjC is actually
+ // supported at the moment.
+ for (unsigned lang = eLanguageTypeUnknown; lang < eNumLanguageTypes; lang++) {
+ if (auto runtime = GetProcess()->GetLanguageRuntime(
+ static_cast<lldb::LanguageType>(lang)))
+ if (auto e = runtime->GetExceptionObjectForThread(shared_from_this()))
+ return e;
+ }
return ValueObjectSP();
}
ThreadSP Thread::GetCurrentExceptionBacktrace() {
ValueObjectSP exception = GetCurrentException();
- if (!exception) return ThreadSP();
+ if (!exception)
+ return ThreadSP();
- // FIXME: For now, only ObjC exceptions are supported. This should really
- // iterate over all language runtimes and ask them all to give us the current
- // exception.
- auto runtime = GetProcess()->GetObjCLanguageRuntime();
- if (!runtime) return ThreadSP();
+ // NOTE: Even though this behavior is generalized, only ObjC is actually
+ // supported at the moment.
+ for (unsigned lang = eLanguageTypeUnknown; lang < eNumLanguageTypes; lang++) {
+ if (auto runtime = GetProcess()->GetLanguageRuntime(
+ static_cast<lldb::LanguageType>(lang)))
+ if (auto bt = runtime->GetBacktraceThreadFromException(exception))
+ return bt;
+ }
- return runtime->GetBacktraceThreadFromException(exception);
+ return ThreadSP();
}
OpenPOWER on IntegriCloud