@@ -18,10 +18,12 @@ use gdbstub::{
1818} ;
1919use nix:: sys:: pthread:: { Pthread , pthread_self} ;
2020
21+ #[ cfg_attr( target_os = "macos" , allow( unused_imports) ) ]
22+ use crate :: HypervisorResult ;
23+ #[ cfg_attr( target_os = "macos" , allow( unused_imports) ) ]
24+ use crate :: os:: Breakpoints ;
2125use crate :: {
22- HypervisorResult ,
2326 gdb:: resume:: { ResumeMarker , ResumeMode } ,
24- os:: Breakpoints ,
2527 vcpu:: { VcpuStopReason , VirtualCPU } ,
2628 vm:: {
2729 KernelInfo , VirtualizationBackend , VmPeripherals , internal:: VirtualizationBackendInternal ,
@@ -45,11 +47,13 @@ pub(crate) struct PthreadWrapper(pub Pthread);
4547unsafe impl Send for PthreadWrapper { }
4648unsafe impl Sync for PthreadWrapper { }
4749
50+ #[ cfg_attr( target_os = "macos" , allow( unused) ) ]
4851pub ( crate ) struct VcpuWrapperShared < VCpu > {
4952 pub ( crate ) vcpu : RwLock < VCpu > ,
5053 pub ( crate ) resume : ResumeMarker ,
5154}
5255
56+ #[ cfg_attr( target_os = "macos" , allow( unused) ) ]
5357pub ( crate ) struct VcpuWrapper < VCpu > {
5458 pub ( crate ) shared : Arc < VcpuWrapperShared < VCpu > > ,
5559
@@ -60,7 +64,9 @@ pub(crate) struct VcpuWrapper<VCpu> {
6064 pub ( crate ) planned_resume_mode : Option < ResumeMode > ,
6165}
6266
67+ #[ cfg_attr( target_os = "macos" , allow( unused) ) ]
6368pub ( crate ) struct GdbVcpuManager < Vm : VirtualizationBackend > {
69+ #[ cfg( not( target_os = "macos" ) ) ]
6470 pub ( crate ) breakpoints : Arc < RwLock < Breakpoints > > ,
6571
6672 pub ( crate ) peripherals : Arc < VmPeripherals > ,
@@ -85,6 +91,7 @@ fn derive_tid(pthread: libc::pthread_t) -> NonZero<u32> {
8591}
8692
8793impl < Vm : VirtualizationBackend > crate :: vm:: UhyveVm < Vm > {
94+ #[ cfg_attr( target_os = "macos" , allow( dead_code) ) ]
8895 pub ( crate ) fn spawn_cpu_manager_for_gdb (
8996 self ,
9097 cpu_affinity : Option < Vec < CoreId > > ,
@@ -97,6 +104,7 @@ impl<Vm: VirtualizationBackend> crate::vm::UhyveVm<Vm> {
97104 let ( stops_s, stops_r) = async_channel:: unbounded ( ) ;
98105 let peripherals = Arc :: clone ( & self . peripherals ) ;
99106 let kernel_info = Arc :: clone ( & self . kernel_info ) ;
107+ #[ cfg( not( target_os = "macos" ) ) ]
100108 let breakpoints = Arc :: new ( RwLock :: new ( Breakpoints :: default ( ) ) ) ;
101109 let cpu_affinity: Option < Arc < [ _ ] > > = cpu_affinity. map ( Arc :: from) ;
102110
@@ -107,6 +115,7 @@ impl<Vm: VirtualizationBackend> crate::vm::UhyveVm<Vm> {
107115 let vcpu_id = vcpu. get_vcpu_id ( ) ;
108116 let vcpu = RwLock :: new ( vcpu) ;
109117 let stops_s = stops_s. clone ( ) ;
118+ #[ cfg( not( target_os = "macos" ) ) ]
110119 let breakpoints = Arc :: clone ( & breakpoints) ;
111120 let shared = Arc :: new ( VcpuWrapperShared {
112121 resume : ResumeMarker {
@@ -154,6 +163,7 @@ impl<Vm: VirtualizationBackend> crate::vm::UhyveVm<Vm> {
154163
155164 listener. wait ( ) ;
156165 }
166+ #[ cfg( not( target_os = "macos" ) ) ]
157167 shared
158168 . apply_current_guest_debug ( & ( * breakpoints) . read ( ) . unwrap ( ) )
159169 . expect ( "GDB target error" ) ;
@@ -164,6 +174,9 @@ impl<Vm: VirtualizationBackend> crate::vm::UhyveVm<Vm> {
164174 . r#continue ( )
165175 . expect ( "GDB target error" )
166176 {
177+ #[ cfg( target_os = "macos" ) ]
178+ VcpuStopReason :: Debug ( _debug) => todo ! ( ) ,
179+ #[ cfg( not( target_os = "macos" ) ) ]
167180 VcpuStopReason :: Debug ( debug) => crate :: os:: debug_info_to_stop_reason (
168181 debug,
169182 tid. try_into ( ) . unwrap ( ) ,
@@ -207,6 +220,7 @@ impl<Vm: VirtualizationBackend> crate::vm::UhyveVm<Vm> {
207220 trace ! ( "tid2vcpu = {tid_to_vcpu:?}" ) ;
208221
209222 GdbVcpuManager {
223+ #[ cfg( not( target_os = "macos" ) ) ]
210224 breakpoints,
211225 peripherals,
212226 kernel_info,
@@ -222,6 +236,7 @@ impl<Vm: VirtualizationBackend> crate::vm::UhyveVm<Vm> {
222236
223237impl < Vm : VirtualizationBackend > GdbVcpuManager < Vm > {
224238 /// Resolves a [`Tid`] from GDB to the associated [`VcpuWrapper`].
239+ #[ cfg_attr( target_os = "macos" , allow( dead_code) ) ]
225240 pub ( crate ) fn get_vcpu_wrapper (
226241 & self ,
227242 tid : Tid ,
@@ -244,6 +259,7 @@ impl<Vm: VirtualizationBackend> GdbVcpuManager<Vm> {
244259 }
245260
246261 /// Resolves a [`Tid`] from GDB to the lock around the associated [`KvmCpu`].
262+ #[ cfg_attr( target_os = "macos" , allow( dead_code) ) ]
247263 pub ( crate ) fn get_vm_cpu (
248264 & self ,
249265 tid : Tid ,
@@ -257,6 +273,7 @@ impl<VCpu: VirtualCPU> VcpuWrapperShared<VCpu> {
257273 /// `ResumeMode`, and `breakpoints`.
258274 ///
259275 /// This handles e.g. single-stepping of the vCPU.
276+ #[ cfg( not( target_os = "macos" ) ) ]
260277 pub fn apply_current_guest_debug ( & self , breakpoints : & Breakpoints ) -> HypervisorResult < ( ) > {
261278 // SAFETY: we trust the value of `self.resume.mode`.
262279 let mode: ResumeMode =
0 commit comments