jankratochvil updated this revision to Diff 355327.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105133/new/

https://reviews.llvm.org/D105133

Files:
  lldb/source/Target/AssertFrameRecognizer.cpp


Index: lldb/source/Target/AssertFrameRecognizer.cpp
===================================================================
--- lldb/source/Target/AssertFrameRecognizer.cpp
+++ lldb/source/Target/AssertFrameRecognizer.cpp
@@ -22,6 +22,10 @@
 struct SymbolLocation {
   FileSpec module_spec;
   std::vector<ConstString> symbols;
+
+  // Both module_spec and symbols are regular expressions. In such case all
+  // symbols are matched with their trailing @VER symbol version stripped.
+  bool is_regex = false;
 };
 
 /// Fetches the abort frame location depending on the current platform.
@@ -45,6 +49,8 @@
     location.symbols.push_back(ConstString("raise"));
     location.symbols.push_back(ConstString("__GI_raise"));
     location.symbols.push_back(ConstString("gsignal"));
+    location.symbols.push_back(ConstString("pthread_kill"));
+    location.is_regex = true;
     break;
   default:
     Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND));
@@ -93,9 +99,27 @@
   if (!GetAbortLocation(os, location))
     return;
 
+  if (!location.is_regex) {
+    target.GetFrameRecognizerManager().AddRecognizer(
+        std::make_shared<AssertFrameRecognizer>(),
+        location.module_spec.GetFilename(), location.symbols,
+        /*first_instruction_only*/ false);
+    return;
+  }
+  std::string regex = "^(";
+  for (auto it = location.symbols.cbegin(); it != location.symbols.cend();
+       ++it) {
+    if (it != location.symbols.cbegin())
+      regex += '|';
+    regex += it->GetStringRef();
+  }
+  // Strip the trailing @VER symbol version.
+  regex += ")(@.*)?$";
   target.GetFrameRecognizerManager().AddRecognizer(
-      StackFrameRecognizerSP(new AssertFrameRecognizer()),
-      location.module_spec.GetFilename(), location.symbols,
+      std::make_shared<AssertFrameRecognizer>(),
+      std::make_shared<RegularExpression>(
+          location.module_spec.GetFilename().GetStringRef()),
+      std::make_shared<RegularExpression>(std::move(regex)),
       /*first_instruction_only*/ false);
 }
 
@@ -112,7 +136,7 @@
   if (!GetAssertLocation(os, location))
     return RecognizedStackFrameSP();
 
-  const uint32_t frames_to_fetch = 5;
+  const uint32_t frames_to_fetch = 6;
   const uint32_t last_frame_index = frames_to_fetch - 1;
   StackFrameSP prev_frame_sp = nullptr;
 


Index: lldb/source/Target/AssertFrameRecognizer.cpp
===================================================================
--- lldb/source/Target/AssertFrameRecognizer.cpp
+++ lldb/source/Target/AssertFrameRecognizer.cpp
@@ -22,6 +22,10 @@
 struct SymbolLocation {
   FileSpec module_spec;
   std::vector<ConstString> symbols;
+
+  // Both module_spec and symbols are regular expressions. In such case all
+  // symbols are matched with their trailing @VER symbol version stripped.
+  bool is_regex = false;
 };
 
 /// Fetches the abort frame location depending on the current platform.
@@ -45,6 +49,8 @@
     location.symbols.push_back(ConstString("raise"));
     location.symbols.push_back(ConstString("__GI_raise"));
     location.symbols.push_back(ConstString("gsignal"));
+    location.symbols.push_back(ConstString("pthread_kill"));
+    location.is_regex = true;
     break;
   default:
     Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND));
@@ -93,9 +99,27 @@
   if (!GetAbortLocation(os, location))
     return;
 
+  if (!location.is_regex) {
+    target.GetFrameRecognizerManager().AddRecognizer(
+        std::make_shared<AssertFrameRecognizer>(),
+        location.module_spec.GetFilename(), location.symbols,
+        /*first_instruction_only*/ false);
+    return;
+  }
+  std::string regex = "^(";
+  for (auto it = location.symbols.cbegin(); it != location.symbols.cend();
+       ++it) {
+    if (it != location.symbols.cbegin())
+      regex += '|';
+    regex += it->GetStringRef();
+  }
+  // Strip the trailing @VER symbol version.
+  regex += ")(@.*)?$";
   target.GetFrameRecognizerManager().AddRecognizer(
-      StackFrameRecognizerSP(new AssertFrameRecognizer()),
-      location.module_spec.GetFilename(), location.symbols,
+      std::make_shared<AssertFrameRecognizer>(),
+      std::make_shared<RegularExpression>(
+          location.module_spec.GetFilename().GetStringRef()),
+      std::make_shared<RegularExpression>(std::move(regex)),
       /*first_instruction_only*/ false);
 }
 
@@ -112,7 +136,7 @@
   if (!GetAssertLocation(os, location))
     return RecognizedStackFrameSP();
 
-  const uint32_t frames_to_fetch = 5;
+  const uint32_t frames_to_fetch = 6;
   const uint32_t last_frame_index = frames_to_fetch - 1;
   StackFrameSP prev_frame_sp = nullptr;
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to