[lldb/Target] Fix `frame recognizer list` crash when registered with nullptr
authorMed Ismail Bennani <medismail.bennani@gmail.com>
Fri, 7 Feb 2020 15:33:33 +0000 (16:33 +0100)
committerMed Ismail Bennani <medismail.bennani@gmail.com>
Fri, 7 Feb 2020 16:35:29 +0000 (17:35 +0100)
commit047c4b0369f05ba2f96c79151641f07035bec954
tree15103473a0aeffc011ec6ca30c48c140365c00f0
parent380fe91fc6dd58a64fd8945bf509c0433038a723
[lldb/Target] Fix `frame recognizer list` crash when registered with nullptr

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 adds checks for the symbol and module RegularExpressionSP.

Differential Revision: https://reviews.llvm.org/D74212

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
lldb/source/Target/StackFrameRecognizer.cpp
lldb/unittests/Target/CMakeLists.txt
lldb/unittests/Target/StackFrameRecognizerTest.cpp [new file with mode: 0644]