Add two utility functions:
o get_parent_frame(frame)
o get_args_as_string(frame)
to lldbutil.py and create TestFrameUtils.py to exercise the utils.
Plus re-arrange the test/python_api/lldbutil to have three directories
for testing iteration, process stack traces, and the just added frame utils.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@131213 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/lldbutil.py b/test/lldbutil.py
index da5ecc3..04f98be 100644
--- a/test/lldbutil.py
+++ b/test/lldbutil.py
@@ -409,6 +409,37 @@
# Utility functions related to Frames
# ===================================
+def get_parent_frame(frame):
+ """
+ Returns the parent frame of the input frame object; None if not available.
+ """
+ thread = frame.GetThread()
+ parent_found = False
+ for f in thread:
+ if parent_found:
+ return f
+ if f.GetFrameID() == frame.GetFrameID():
+ parent_found = True
+
+ # If we reach here, no parent has been found, return None.
+ return None
+
+def get_args_as_string(frame):
+ """
+ Returns the args of the input frame object as a string.
+ """
+ # arguments => True
+ # locals => False
+ # statics => False
+ # in_scope_only => True
+ vars = frame.GetVariables(True, False, False, True) # type of SBValueList
+ args = [] # list of strings
+ for var in vars:
+ args.append("(%s)%s=%s" % (var.GetTypeName(),
+ var.GetName(),
+ var.GetValue(frame)))
+ return "%s(%s)" % (frame.GetFunction().GetName(), ", ".join(args))
+
def print_registers(frame, string_buffer = False):
"""Prints all the register sets of the frame."""