| 1 |
# Test the unwinder and the frame filter. |
| 2 |
# flake8: NOQA: F821 |
| 3 |
import platform |
| 4 |
|
| 5 |
|
| 6 |
def do_unwinder_test(): |
| 7 |
# The unwinder is disabled by default for the moment. Turn it on to check |
| 8 |
# that the unwinder works as expected. |
| 9 |
import gdb |
| 10 |
|
| 11 |
gdb.execute("enable unwinder .* SpiderMonkey") |
| 12 |
|
| 13 |
run_fragment("unwind.simple", "Something") |
| 14 |
|
| 15 |
first = True |
| 16 |
# The unwinder is a bit flaky still but should at least be able to |
| 17 |
# recognize one set of entry and exit frames. This also tests to |
| 18 |
# make sure we didn't end up solely in the interpreter. |
| 19 |
found_entry = False |
| 20 |
found_exit = False |
| 21 |
found_main = False |
| 22 |
found_inner = False |
| 23 |
found_outer = False |
| 24 |
frames = list(gdb.frames.execute_frame_filters(gdb.newest_frame(), 0, -1)) |
| 25 |
for frame in frames: |
| 26 |
print("examining " + frame.function()) |
| 27 |
if first: |
| 28 |
assert_eq(frame.function().startswith("Something"), True) |
| 29 |
first = False |
| 30 |
elif frame.function() == "<<FrameType::Exit>>": |
| 31 |
found_exit = True |
| 32 |
elif frame.function() == "<<FrameType::CppToJSJit>>": |
| 33 |
found_entry = True |
| 34 |
elif frame.function() == "main": |
| 35 |
found_main = True |
| 36 |
elif "unwindFunctionInner" in frame.function(): |
| 37 |
found_inner = True |
| 38 |
elif "unwindFunctionOuter" in frame.function(): |
| 39 |
found_outer = True |
| 40 |
|
| 41 |
# Had to have found a frame. |
| 42 |
assert_eq(first, False) |
| 43 |
# Had to have found main. |
| 44 |
assert_eq(found_main, True) |
| 45 |
# Had to have found the entry and exit frames. |
| 46 |
assert_eq(found_exit, True) |
| 47 |
assert_eq(found_entry, True) |
| 48 |
# Had to have found the names of the two JS functions. |
| 49 |
assert_eq(found_inner, True) |
| 50 |
assert_eq(found_outer, True) |
| 51 |
|
| 52 |
|
| 53 |
# Only on the right platforms. |
| 54 |
if platform.machine() == "x86_64" and platform.system() == "Linux": |
| 55 |
# Only test when gdb has the unwinder feature. |
| 56 |
try: |
| 57 |
import gdb.unwinder # NOQA: F401 |
| 58 |
|
| 59 |
do_unwinder_test() |
| 60 |
except Exception: |
| 61 |
pass |