summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
diff options
context:
space:
mode:
authorKuba Mracek <mracek@apple.com>2018-10-31 00:36:20 +0000
committerKuba Mracek <mracek@apple.com>2018-10-31 00:36:20 +0000
commit8fddd9818599663cee75b834c19df9bfd41a64f2 (patch)
treed76b43ccc16f9e14fec315222030f6051f010e8c /lldb/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
parent3e27306565554fbf8f1c93a55f278856fe02c22e (diff)
downloadbcm5719-llvm-8fddd9818599663cee75b834c19df9bfd41a64f2.tar.gz
bcm5719-llvm-8fddd9818599663cee75b834c19df9bfd41a64f2.zip
[lldb] Introduce StackFrameRecognizer [take 2]
This patch introduces a concept of "frame recognizer" and "recognized frame". This should be an extensible mechanism that retrieves information about special frames based on ABI, arguments or other special properties of that frame, even without source code. A few examples where that could be useful could be 1) objc_exception_throw, where we'd like to get the current exception, 2) terminate_with_reason and extracting the current terminate string, 3) recognizing Objective-C frames and automatically extracting the receiver+selector, or perhaps all arguments (based on selector). Differential Revision: https://reviews.llvm.org/D44603 llvm-svn: 345686
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py102
1 files changed, 102 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py b/lldb/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
index e69de29bb2d..abd4ae8b382 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
@@ -0,0 +1,102 @@
+# encoding: utf-8
+"""
+Test lldb's frame recognizers.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+import recognizer
+
+class FrameRecognizerTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
+
+ @skipUnlessDarwin
+ def test_frame_recognizer_1(self):
+ self.build()
+
+ target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+ self.assertTrue(target, VALID_TARGET)
+
+ self.runCmd("command script import " + os.path.join(self.getSourceDir(), "recognizer.py"))
+
+ self.expect("frame recognizer list",
+ substrs=['no matching results found.'])
+
+ self.runCmd("frame recognizer add -l recognizer.MyFrameRecognizer -s a.out -n foo")
+
+ self.expect("frame recognizer list",
+ substrs=['0: recognizer.MyFrameRecognizer, module a.out, function foo'])
+
+ self.runCmd("frame recognizer add -l recognizer.MyOtherFrameRecognizer -s a.out -n bar -x")
+
+ self.expect("frame recognizer list",
+ substrs=['0: recognizer.MyFrameRecognizer, module a.out, function foo',
+ '1: recognizer.MyOtherFrameRecognizer, module a.out, function bar (regexp)'
+ ])
+
+ self.runCmd("frame recognizer delete 0")
+
+ self.expect("frame recognizer list",
+ substrs=['1: recognizer.MyOtherFrameRecognizer, module a.out, function bar (regexp)'])
+
+ self.runCmd("frame recognizer clear")
+
+ self.expect("frame recognizer list",
+ substrs=['no matching results found.'])
+
+ self.runCmd("frame recognizer add -l recognizer.MyFrameRecognizer -s a.out -n foo")
+
+ lldbutil.run_break_set_by_symbol(self, "foo")
+ self.runCmd("r")
+
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped', 'stop reason = breakpoint'])
+
+ process = target.GetProcess()
+ thread = process.GetSelectedThread()
+ frame = thread.GetSelectedFrame()
+
+ self.assertEqual(frame.GetSymbol().GetName(), "foo")
+ self.assertFalse(frame.GetLineEntry().IsValid())
+
+ self.expect("frame variable",
+ substrs=['(int) a = 42', '(int) b = 56'])
+
+ opts = lldb.SBVariablesOptions();
+ opts.SetIncludeRecognizedArguments(True);
+ variables = frame.GetVariables(opts);
+
+ self.assertEqual(variables.GetSize(), 2)
+ self.assertEqual(variables.GetValueAtIndex(0).name, "a")
+ self.assertEqual(variables.GetValueAtIndex(0).signed, 42)
+ self.assertEqual(variables.GetValueAtIndex(1).name, "b")
+ self.assertEqual(variables.GetValueAtIndex(1).signed, 56)
+
+ self.expect("frame recognizer info 0",
+ substrs=['frame 0 is recognized by recognizer.MyFrameRecognizer'])
+
+ self.expect("frame recognizer info 999", error=True,
+ substrs=['no frame with index 999'])
+
+ self.expect("frame recognizer info 1",
+ substrs=['frame 1 not recognized by any recognizer'])
+
+ # FIXME: The following doesn't work yet, but should be fixed.
+ """
+ lldbutil.run_break_set_by_symbol(self, "bar")
+ self.runCmd("c")
+
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped', 'stop reason = breakpoint'])
+
+ self.expect("frame variable -t",
+ substrs=['(int *) a = '])
+
+ self.expect("frame variable -t *a",
+ substrs=['*a = 78'])
+ """
OpenPOWER on IntegriCloud