4
4
use :: function_name:: named;
5
5
use datadog_crashtracker:: { BuildIdType , FileType , StackFrame } ;
6
6
use ddcommon_ffi:: {
7
- slice:: AsBytes , wrap_with_void_ffi_result, CharSlice , Handle , Result , ToInner , VoidResult ,
7
+ slice:: AsBytes , utils:: ToHexStr , wrap_with_void_ffi_result, CharSlice , Error , Handle , ToInner ,
8
+ VoidResult ,
8
9
} ;
9
10
10
11
////////////////////////////////////////////////////////////////////////////////////////////////////
11
12
// FFI API //
12
13
////////////////////////////////////////////////////////////////////////////////////////////////////
13
14
15
+ #[ allow( dead_code) ]
16
+ #[ repr( C ) ]
17
+ pub enum StackFrameNewResult {
18
+ Ok ( Handle < StackFrame > ) ,
19
+ Err ( Error ) ,
20
+ }
21
+
14
22
/// Create a new StackFrame, and returns an opaque reference to it.
15
23
/// # Safety
16
24
/// No safety issues.
17
25
#[ no_mangle]
18
26
#[ must_use]
19
- pub unsafe extern "C" fn ddog_crasht_StackFrame_new ( ) -> Result < Handle < StackFrame > > {
20
- ddcommon_ffi :: Result :: Ok ( StackFrame :: new ( ) . into ( ) )
27
+ pub unsafe extern "C" fn ddog_crasht_StackFrame_new ( ) -> StackFrameNewResult {
28
+ StackFrameNewResult :: Ok ( StackFrame :: new ( ) . into ( ) )
21
29
}
22
30
23
31
/// # Safety
@@ -41,10 +49,10 @@ pub unsafe extern "C" fn ddog_crasht_StackFrame_drop(frame: *mut Handle<StackFra
41
49
#[ named]
42
50
pub unsafe extern "C" fn ddog_crasht_StackFrame_with_ip (
43
51
mut frame : * mut Handle < StackFrame > ,
44
- ip : CharSlice ,
52
+ ip : usize ,
45
53
) -> VoidResult {
46
54
wrap_with_void_ffi_result ! ( {
47
- frame. to_inner_mut( ) ?. ip = ip. try_to_string_option ( ) ? ;
55
+ frame. to_inner_mut( ) ?. ip = Some ( ip. to_hex_str ( ) ) ;
48
56
} )
49
57
}
50
58
@@ -57,10 +65,10 @@ pub unsafe extern "C" fn ddog_crasht_StackFrame_with_ip(
57
65
#[ named]
58
66
pub unsafe extern "C" fn ddog_crasht_StackFrame_with_module_base_address (
59
67
mut frame : * mut Handle < StackFrame > ,
60
- module_base_address : CharSlice ,
68
+ module_base_address : usize ,
61
69
) -> VoidResult {
62
70
wrap_with_void_ffi_result ! ( {
63
- frame. to_inner_mut( ) ?. module_base_address = module_base_address. try_to_string_option ( ) ? ;
71
+ frame. to_inner_mut( ) ?. module_base_address = Some ( module_base_address. to_hex_str ( ) ) ;
64
72
} )
65
73
}
66
74
@@ -73,10 +81,10 @@ pub unsafe extern "C" fn ddog_crasht_StackFrame_with_module_base_address(
73
81
#[ named]
74
82
pub unsafe extern "C" fn ddog_crasht_StackFrame_with_sp (
75
83
mut frame : * mut Handle < StackFrame > ,
76
- sp : CharSlice ,
84
+ sp : usize ,
77
85
) -> VoidResult {
78
86
wrap_with_void_ffi_result ! ( {
79
- frame. to_inner_mut( ) ?. sp = sp. try_to_string_option ( ) ? ;
87
+ frame. to_inner_mut( ) ?. sp = Some ( sp. to_hex_str ( ) ) ;
80
88
} )
81
89
}
82
90
@@ -89,10 +97,10 @@ pub unsafe extern "C" fn ddog_crasht_StackFrame_with_sp(
89
97
#[ named]
90
98
pub unsafe extern "C" fn ddog_crasht_StackFrame_with_symbol_address (
91
99
mut frame : * mut Handle < StackFrame > ,
92
- symbol_address : CharSlice ,
100
+ symbol_address : usize ,
93
101
) -> VoidResult {
94
102
wrap_with_void_ffi_result ! ( {
95
- frame. to_inner_mut( ) ?. symbol_address = symbol_address. try_to_string_option ( ) ? ;
103
+ frame. to_inner_mut( ) ?. symbol_address = Some ( symbol_address. to_hex_str ( ) ) ;
96
104
} )
97
105
}
98
106
@@ -169,10 +177,10 @@ pub unsafe extern "C" fn ddog_crasht_StackFrame_with_path(
169
177
#[ named]
170
178
pub unsafe extern "C" fn ddog_crasht_StackFrame_with_relative_address (
171
179
mut frame : * mut Handle < StackFrame > ,
172
- relative_address : CharSlice ,
180
+ relative_address : usize ,
173
181
) -> VoidResult {
174
182
wrap_with_void_ffi_result ! ( {
175
- frame. to_inner_mut( ) ?. relative_address = relative_address. try_to_string_option ( ) ? ;
183
+ frame. to_inner_mut( ) ?. relative_address = Some ( relative_address. to_hex_str ( ) ) ;
176
184
} )
177
185
}
178
186
0 commit comments