Copy as Markdown
# Test the unwinder and the frame filter.
# flake8: NOQA: F821
# The unwinder is disabled by default for the moment. Turn it on to check
# that the unwinder works as expected.
gdb.execute("enable unwinder .* SpiderMonkey")
first = True
# The unwinder is a bit flaky still but should at least be able to
# recognize one set of entry and exit frames. This also tests to
# make sure we didn't end up solely in the interpreter.
found_entry = False
found_exit = False
found_main = False
found_inner = False
found_outer = False
frames = list(gdb.frames.execute_frame_filters(gdb.newest_frame(), 0, -1))
for frame in frames:
print("examining " + frame.function())
first = False
elif frame.function() == "<<FrameType::Exit>>":
found_exit = True
elif frame.function() == "<<FrameType::CppToJSJit>>":
found_entry = True
elif frame.function() == "main":
found_main = True
elif "unwindFunctionInner" in frame.function():
found_inner = True
elif "unwindFunctionOuter" in frame.function():
found_outer = True
# Had to have found a frame.
# Had to have found main.
# Had to have found the entry and exit frames.
# Had to have found the names of the two JS functions.
# Only on the right platforms.
if platform.machine() == "x86_64" and platform.system() == "Linux":
# Only test when gdb has the unwinder feature.
import gdb.unwinder # NOQA: F401