@@ -11,7 +11,7 @@ use gdbstub::target::ext::base::singlethread::{
1111} ;
1212use gdbstub:: target:: ext:: base:: BaseOps ;
1313use gdbstub:: target:: ext:: breakpoints:: {
14- Breakpoints , BreakpointsOps , HwBreakpoint , HwBreakpointOps ,
14+ Breakpoints , BreakpointsOps , HwBreakpoint , HwBreakpointOps , SwBreakpoint , SwBreakpointOps ,
1515} ;
1616use gdbstub:: target:: ext:: section_offsets:: { Offsets , SectionOffsets } ;
1717use gdbstub:: target:: { Target , TargetError , TargetResult } ;
@@ -158,6 +158,10 @@ impl HyperlightKvmSandboxTarget {
158158 }
159159
160160 let ip = self . get_instruction_pointer ( ) ?;
161+ let gpa = self . translate_gva ( ip) ?;
162+ if self . hw_breakpoints . contains ( & gpa) {
163+ return Ok ( Some ( SingleThreadStopReason :: SwBreak ( ( ) ) ) ) ;
164+ }
161165
162166 if self . hw_breakpoints . contains ( & ip) {
163167 return Ok ( Some ( SingleThreadStopReason :: HwBreak ( ( ) ) ) ) ;
@@ -469,6 +473,9 @@ impl Breakpoints for HyperlightKvmSandboxTarget {
469473 fn support_hw_breakpoint ( & mut self ) -> Option < HwBreakpointOps < Self > > {
470474 Some ( self )
471475 }
476+ fn support_sw_breakpoint ( & mut self ) -> Option < SwBreakpointOps < ' _ , Self > > {
477+ Some ( self )
478+ }
472479}
473480
474481impl HwBreakpoint for HyperlightKvmSandboxTarget {
@@ -489,6 +496,24 @@ impl HwBreakpoint for HyperlightKvmSandboxTarget {
489496 }
490497}
491498
499+ impl SwBreakpoint for HyperlightKvmSandboxTarget {
500+ fn add_sw_breakpoint (
501+ & mut self ,
502+ addr : <Self :: Arch as Arch >:: Usize ,
503+ _kind : <Self :: Arch as Arch >:: BreakpointKind ,
504+ ) -> TargetResult < bool , Self > {
505+ self . add_breakpoint ( addr) . map_err ( TargetError :: Fatal )
506+ }
507+
508+ fn remove_sw_breakpoint (
509+ & mut self ,
510+ addr : <Self :: Arch as Arch >:: Usize ,
511+ _kind : <Self :: Arch as Arch >:: BreakpointKind ,
512+ ) -> TargetResult < bool , Self > {
513+ self . remove_breakpoint ( addr) . map_err ( TargetError :: Fatal )
514+ }
515+ }
516+
492517impl SingleThreadResume for HyperlightKvmSandboxTarget {
493518 fn resume ( & mut self , _signal : Option < Signal > ) -> Result < ( ) , Self :: Error > {
494519 log:: debug!( "Resume" ) ;
0 commit comments