Skip to content

Commit 2949827

Browse files
quark-zjumeta-codesync[bot]
authored andcommitted
test-hybrid-backtrace: add a test about python+rust frame resolution
Summary: `backtrace-python` uses raw offsets to extract Python frame info. It can be fragile if the Rust compiler generates different assembly. Add a test to discover incompatibilities. Reviewed By: muirdm Differential Revision: D91793098 fbshipit-source-id: a55cc158dd5b8523713bab31c0ac0aded5ef3070
1 parent 8134c2c commit 2949827

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#require no-eden
2+
3+
Test `bindings.backtrace.backtrace()` includes both resolved Python and Rust frames on supported platforms.
4+
5+
Can only test if supported:
6+
7+
import bindings
8+
SUPPORTED_INFO = bindings.backtrace.SUPPORTED_INFO
9+
if not SUPPORTED_INFO.os_arch or not SUPPORTED_INFO.c_evalframe:
10+
$ exit 80
11+
12+
Test getting backtrace:
13+
14+
$ cat > print_backtrace.py << 'EOF'
15+
> import bindings, re
16+
> def my_unique_function_name_for_test():
17+
> for frame in bindings.backtrace.backtrace():
18+
> # remove Rust function hashes
19+
> # e.g. commands[ec2db546b32b7e26]::run::run_command (-C symbol-mangling-version=v0)
20+
> frame = re.sub(r'\[[0-9a-f]+\]', '', frame) # remove Rust function hashes (e.g.
21+
> # e.g. commands::run::dispatch_command::hac40196f059e3564 (-C symbol-mangling-version=legacy)
22+
> frame = re.sub(r'::h[0-9a-f]{16}$', '', frame)
23+
> print(frame)
24+
> my_unique_function_name_for_test()
25+
> 'EOF'
26+
27+
The backtrace should include the `my_unique_function_name_for_test` Python function and the `run_command` Rust function:
28+
29+
$ sl debugshell print_backtrace.py
30+
...
31+
my_unique_function_name_for_test at print_backtrace.py:3
32+
...
33+
commands::run::run_command
34+
...

0 commit comments

Comments
 (0)