[Lldb-commits] [PATCH] D61776: [Target] Generalize some behavior in Thread

Alex Langford via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu May 9 19:58:32 PDT 2019


xiaobai created this revision.
xiaobai added reviewers: davide, JDevlieghere, jingham, kubamracek, clayborg.

I don't think there's a good reason for this behavior to be considered
ObjC-specific. We can generalize this.


https://reviews.llvm.org/D61776

Files:
  source/Target/Thread.cpp


Index: source/Target/Thread.cpp
===================================================================
--- source/Target/Thread.cpp
+++ source/Target/Thread.cpp
@@ -2209,25 +2209,27 @@
       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;
+  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();
+  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();
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61776.198976.patch
Type: text/x-patch
Size: 1759 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190510/f6c00537/attachment.bin>


More information about the lldb-commits mailing list