@@ -57,17 +57,20 @@ use hyperlight_common::flatbuffer_wrappers::guest_error::ErrorCode;
5757use hyperlight_common:: flatbuffer_wrappers:: util:: get_flatbuffer_result;
5858use hyperlight_guest:: error:: { HyperlightGuestError , Result } ;
5959use spin:: Mutex ;
60+ use tracing:: instrument;
6061use wasmtime:: { AsContextMut , Extern , Val } ;
6162
6263// Global tracking for return value allocations that need to be freed on next VM entry
6364static RETURN_VALUE_ALLOCATIONS : Mutex < Vec < i32 > > = Mutex :: new ( Vec :: new ( ) ) ;
6465
6566/// Track a return value allocation that should be freed on the next VM entry
67+ #[ instrument( skip_all, level = "Trace" ) ]
6668fn track_return_value_allocation ( addr : i32 ) {
6769 RETURN_VALUE_ALLOCATIONS . lock ( ) . push ( addr) ;
6870}
6971
7072/// Free all tracked return value allocations from previous VM calls
73+ #[ instrument( skip_all, level = "Trace" ) ]
7174pub fn free_return_value_allocations < C : AsContextMut > (
7275 ctx : & mut C ,
7376 get_export : & impl Fn ( & mut C , & str ) -> Option < Extern > ,
@@ -79,6 +82,7 @@ pub fn free_return_value_allocations<C: AsContextMut>(
7982 Ok ( ( ) )
8083}
8184
85+ #[ instrument( skip_all, level = "Trace" ) ]
8286fn malloc < C : AsContextMut > (
8387 ctx : & mut C ,
8488 get_export : & impl Fn ( & mut C , & str ) -> Option < Extern > ,
@@ -96,6 +100,7 @@ fn malloc<C: AsContextMut>(
96100 Ok ( addr)
97101}
98102
103+ #[ instrument( skip_all, level = "Trace" ) ]
99104fn free < C : AsContextMut > (
100105 ctx : & mut C ,
101106 get_export : & impl Fn ( & mut C , & str ) -> Option < Extern > ,
@@ -111,6 +116,7 @@ fn free<C: AsContextMut>(
111116 Ok ( ( ) )
112117}
113118
119+ #[ instrument( skip_all, level = "Trace" ) ]
114120fn write < C : AsContextMut > (
115121 ctx : & mut C ,
116122 get_export : & impl Fn ( & mut C , & str ) -> Option < Extern > ,
@@ -132,6 +138,7 @@ fn write<C: AsContextMut>(
132138 Ok ( ( ) )
133139}
134140
141+ #[ instrument( skip_all, level = "Trace" ) ]
135142fn read < C : AsContextMut > (
136143 ctx : & mut C ,
137144 get_export : & impl Fn ( & mut C , & str ) -> Option < Extern > ,
@@ -153,6 +160,7 @@ fn read<C: AsContextMut>(
153160 Ok ( ( ) )
154161}
155162
163+ #[ instrument( skip_all, level = "Trace" ) ]
156164fn read_cstr < C : AsContextMut > (
157165 ctx : & mut C ,
158166 get_export : & impl Fn ( & mut C , & str ) -> Option < Extern > ,
@@ -196,6 +204,7 @@ fn read_cstr<C: AsContextMut>(
196204/// For String and VecBytes parameter types, this allocates memory in the guest's memory space
197205/// and returns a pointer. The guest function is responsible for freeing this memory when it is no
198206/// longer needed using the `free` function exported from the guest module.
207+ #[ instrument( skip_all, level = "Trace" ) ]
199208pub fn hl_param_to_val < C : AsContextMut > (
200209 mut ctx : C ,
201210 get_export : impl Fn ( & mut C , & str ) -> Option < Extern > ,
@@ -230,6 +239,7 @@ pub fn hl_param_to_val<C: AsContextMut>(
230239/// For String and VecBytes return types, the guest has allocated memory in its own memory space
231240/// and returned pointers. The host takes ownership of these allocations and tracks them for
232241/// automatic cleanup on the next VM entry to prevent memory leaks.
242+ #[ instrument( skip_all, level = "Trace" ) ]
233243pub fn val_to_hl_result < C : AsContextMut > (
234244 mut ctx : C ,
235245 get_export : impl Fn ( & mut C , & str ) -> Option < Extern > ,
@@ -284,6 +294,7 @@ pub fn val_to_hl_result<C: AsContextMut>(
284294/// For String and VecBytes parameter types, the guest passes pointers to data in its own
285295/// memory space. The guest retains ownership of these allocations and remains responsible
286296/// for freeing them. This function only reads the data without taking ownership.
297+ #[ instrument( skip_all, level = "Trace" ) ]
287298pub fn val_to_hl_param < ' a , C : AsContextMut > (
288299 ctx : & mut C ,
289300 get_export : impl Fn ( & mut C , & str ) -> Option < Extern > ,
@@ -339,6 +350,7 @@ pub fn val_to_hl_param<'a, C: AsContextMut>(
339350/// For String and VecBytes return types, this allocates memory in the guest's memory space
340351/// and returns a pointer. The guest owns these allocations and must free them when no longer needed
341352/// using the `free` function exported from the guest module.
353+ #[ instrument( skip_all, level = "Trace" ) ]
342354pub fn hl_return_to_val < C : AsContextMut > (
343355 ctx : & mut C ,
344356 get_export : impl Fn ( & mut C , & str ) -> Option < Extern > ,
0 commit comments