forked from RustPython/RustPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfaulthandler.rs
More file actions
65 lines (57 loc) · 1.49 KB
/
faulthandler.rs
File metadata and controls
65 lines (57 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
pub(crate) use decl::make_module;
#[pymodule(name = "faulthandler")]
mod decl {
use crate::vm::{
frame::FrameRef, function::OptionalArg, stdlib::sys::PyStderr, VirtualMachine,
};
fn dump_frame(frame: &FrameRef, vm: &VirtualMachine) {
let stderr = PyStderr(vm);
writeln!(
stderr,
" File \"{}\", line {} in {}",
frame.code.source_path,
frame.current_location().row(),
frame.code.obj_name
)
}
#[pyfunction]
fn dump_traceback(
_file: OptionalArg<i64>,
_all_threads: OptionalArg<bool>,
vm: &VirtualMachine,
) {
let stderr = PyStderr(vm);
writeln!(stderr, "Stack (most recent call first):");
for frame in vm.frames.borrow().iter() {
dump_frame(frame, vm);
}
}
#[derive(FromArgs)]
#[allow(unused)]
struct EnableArgs {
#[pyarg(any, default)]
file: Option<i64>,
#[pyarg(any, default = "true")]
all_threads: bool,
}
#[pyfunction]
fn enable(_args: EnableArgs) {
// TODO
}
#[derive(FromArgs)]
#[allow(unused)]
struct RegisterArgs {
#[pyarg(positional)]
signum: i64,
#[pyarg(any, default)]
file: Option<i64>,
#[pyarg(any, default = "true")]
all_threads: bool,
#[pyarg(any, default = "false")]
chain: bool,
}
#[pyfunction]
fn register(_args: RegisterArgs) {
// TODO
}
}