[Lldb-commits] [PATCH] D74212: [lldb/Target] Fix `recognizer list` crash when registered with nullptre

Med Ismail Bennani via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Feb 7 03:49:51 PST 2020


mib created this revision.
mib added reviewers: teemperor, friss.
mib added a project: LLDB.
Herald added a subscriber: lldb-commits.

One way to register a recognizer is to use RegularExpressionSP for the
module and symbol.

In order to match a symbol regardless of the module, the recognizer can
be registered with a nullptr for the module. However, this cause the
`frame recognizer list` command to crash because it calls
RegularExpression::GetText without checking if the shared pointer is valid.

This patch add checks for the symbol and module RegularExpressionSP.

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74212

Files:
  lldb/source/Target/StackFrameRecognizer.cpp


Index: lldb/source/Target/StackFrameRecognizer.cpp
===================================================================
--- lldb/source/Target/StackFrameRecognizer.cpp
+++ lldb/source/Target/StackFrameRecognizer.cpp
@@ -70,9 +70,17 @@
                          std::string symbol, bool regexp)> const &callback) {
     for (auto entry : m_recognizers) {
       if (entry.is_regexp) {
-        callback(entry.recognizer_id, entry.recognizer->GetName(),
-                 std::string(entry.module_regexp->GetText()),
-                 std::string(entry.symbol_regexp->GetText()), true);
+        std::string module_name;
+        std::string symbol_name;
+
+        if (entry.module_regexp)
+          module_name = entry.module_regexp->GetText().str();
+        if (entry.symbol_regexp)
+          symbol_name = entry.symbol_regexp->GetText().str();
+
+        callback(entry.recognizer_id, entry.recognizer->GetName(), module_name,
+                 symbol_name, true);
+
       } else {
         callback(entry.recognizer_id, entry.recognizer->GetName(), entry.module.GetCString(),
                  entry.symbol.GetCString(), false);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74212.243128.patch
Type: text/x-patch
Size: 1135 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200207/eed43075/attachment.bin>


More information about the lldb-commits mailing list