@@ -34,6 +34,8 @@ use super::vm::{Vm, VmExit};
3434#[ cfg( not( gdb) ) ]
3535use super :: vm:: { Vm , VmExit } ;
3636use super :: wrappers:: HandleWrapper ;
37+ #[ cfg( gdb) ]
38+ use crate :: hypervisor:: gdb:: DebuggableVm ;
3739use crate :: hypervisor:: regs:: { CommonFpu , CommonRegisters , CommonSpecialRegisters } ;
3840use crate :: mem:: memory_region:: { MemoryRegion , MemoryRegionFlags } ;
3941use crate :: { Result , log_then_return, new_error} ;
@@ -471,7 +473,14 @@ impl Vm for WhpVm {
471473 Ok ( result)
472474 }
473475
474- #[ cfg( gdb) ]
476+ /// Mark that initial memory setup is complete. After this, map_memory will fail.
477+ fn complete_initial_memory_setup ( & mut self ) {
478+ self . initial_memory_setup_done = true ;
479+ }
480+ }
481+
482+ #[ cfg( gdb) ]
483+ impl DebuggableVm for WhpVm {
475484 fn translate_gva ( & self , gva : u64 ) -> Result < u64 > {
476485 let mut gpa = 0 ;
477486 let mut result = WHV_TRANSLATE_GVA_RESULT :: default ( ) ;
@@ -494,7 +503,6 @@ impl Vm for WhpVm {
494503 Ok ( gpa)
495504 }
496505
497- #[ cfg( gdb) ]
498506 fn set_debug ( & mut self , enable : bool ) -> Result < ( ) > {
499507 if enable {
500508 // Set the extended VM exits property to enable extended VM exits
@@ -527,7 +535,6 @@ impl Vm for WhpVm {
527535 Ok ( ( ) )
528536 }
529537
530- #[ cfg( gdb) ]
531538 fn set_single_step ( & mut self , enable : bool ) -> Result < ( ) > {
532539 let mut regs = self . regs ( ) ?;
533540 if enable {
@@ -539,7 +546,6 @@ impl Vm for WhpVm {
539546 Ok ( ( ) )
540547 }
541548
542- #[ cfg( gdb) ]
543549 fn add_hw_breakpoint ( & mut self , addr : u64 ) -> Result < ( ) > {
544550 use crate :: hypervisor:: gdb:: arch:: MAX_NO_OF_HW_BP ;
545551
@@ -599,7 +605,6 @@ impl Vm for WhpVm {
599605 Ok ( ( ) )
600606 }
601607
602- #[ cfg( gdb) ]
603608 fn remove_hw_breakpoint ( & mut self , addr : u64 ) -> Result < ( ) > {
604609 // Get current debug registers
605610 const LEN : usize = 6 ;
@@ -651,11 +656,6 @@ impl Vm for WhpVm {
651656 Err ( new_error ! ( "Tried to remove non-existing hw-breakpoint" ) )
652657 }
653658 }
654-
655- /// Mark that initial memory setup is complete. After this, map_memory will fail.
656- fn complete_initial_memory_setup ( & mut self ) {
657- self . initial_memory_setup_done = true ;
658- }
659659}
660660
661661impl Drop for WhpVm {
0 commit comments