Kuba Mracek 41ae8e7445 [lldb] Introduce StackFrameRecognizer [take 3]
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: 345693
2018-10-31 04:00:22 +00:00

22 lines
770 B
Python

# encoding: utf-8
import lldb
class MyFrameRecognizer(object):
def get_recognized_arguments(self, frame):
if frame.name == "foo":
arg1 = frame.EvaluateExpression("$arg1").signed
arg2 = frame.EvaluateExpression("$arg2").signed
val1 = lldb.target.CreateValueFromExpression("a", "%d" % arg1)
val2 = lldb.target.CreateValueFromExpression("b", "%d" % arg2)
return [val1, val2]
elif frame.name == "bar":
arg1 = frame.EvaluateExpression("$arg1").signed
val1 = lldb.target.CreateValueFromExpression("a", "(int *)%d" % arg1)
return [val1]
return []
class MyOtherFrameRecognizer(object):
def get_recognized_arguments(self, frame):
return []