@@ -16,6 +16,49 @@ pub static IRQ: [fn(usize) -> bool];
1616#[ def_trap_handler]
1717pub static PAGE_FAULT : [ fn ( VirtAddr , PageFaultFlags ) -> bool ] ;
1818
19+ /// A slice of breakpoint handler functions.
20+ ///
21+ /// Each handler is invoked with a mutable reference to the trapped [`TrapFrame`]
22+ /// and must return a boolean indicating whether it has fully handled the trap:
23+ ///
24+ /// - `true` means the breakpoint has been handled and control should resume
25+ /// according to the state encoded in the trap frame.
26+ /// - `false` means the breakpoint was not handled and default processing
27+ /// (such as falling back to another mechanism or terminating) should occur.
28+ ///
29+ /// When returning `true`, the handler is responsible for updating the saved
30+ /// program counter (or equivalent PC field) in the trap frame as required by
31+ /// the target architecture. In particular, the handler must ensure that,
32+ /// upon resuming from the trap, execution does not immediately re-trigger the
33+ /// same breakpoint instruction or condition, which could otherwise lead to an
34+ /// infinite trap loop. The exact way to advance or modify the PC is
35+ /// architecture-specific and depends on how [`TrapFrame`] encodes the saved
36+ /// context.
37+ #[ def_trap_handler]
38+ pub static BREAK_HANDLER : [ fn ( & mut TrapFrame ) -> bool ] ;
39+
40+ /// A slice of debug handler functions.
41+ ///
42+ /// On `x86_64`, these handlers are invoked for debug-related traps (for
43+ /// example, hardware breakpoints, single-step traps, or other debug
44+ /// exceptions). The handler receives a mutable reference to the trapped
45+ /// [`TrapFrame`] and returns a boolean with the following meaning:
46+ ///
47+ /// - `true` means the debug trap has been fully handled and execution should
48+ /// resume from the state stored in the trap frame.
49+ /// - `false` means the debug trap was not handled and default/secondary
50+ /// processing should take place.
51+ ///
52+ /// As with [`BREAK_HANDLER`], when returning `true`, the handler must adjust
53+ /// the saved program counter (or equivalent) in the trap frame if required by
54+ /// the architecture so that resuming execution does not immediately cause the
55+ /// same debug condition to fire again. Callers must take the architecture-
56+ /// specific PC semantics into account when deciding how to advance or modify
57+ /// the PC.
58+ #[ cfg( target_arch = "x86_64" ) ]
59+ #[ def_trap_handler]
60+ pub static DEBUG_HANDLER : [ fn ( & mut TrapFrame ) -> bool ] ;
61+
1962#[ allow( unused_macros) ]
2063macro_rules! handle_trap {
2164 ( $trap: ident, $( $args: tt) * ) => { {
0 commit comments