6
6
//! This module provides C-compatible FFI bindings for registering runtime-specific
7
7
//! crash callbacks that can provide stack traces for dynamic languages.
8
8
use datadog_crashtracker:: {
9
- get_registered_callback_type_ptr, get_registered_runtime_type_ptr,
10
- is_runtime_callback_registered, register_runtime_stack_callback, CallbackError , CallbackType ,
11
- RuntimeStackCallback , RuntimeType ,
9
+ get_registered_callback_type_ptr, is_runtime_callback_registered,
10
+ register_runtime_stack_callback, CallbackError , CallbackType , RuntimeStackCallback ,
12
11
} ;
13
12
14
13
// Re-export the enums for C/C++ consumers
15
14
pub use datadog_crashtracker:: CallbackType as ddog_CallbackType;
16
- pub use datadog_crashtracker:: RuntimeType as ddog_RuntimeType;
17
15
18
16
pub use datadog_crashtracker:: RuntimeStackFrame as ddog_RuntimeStackFrame;
19
17
@@ -75,7 +73,6 @@ impl From<CallbackError> for CallbackResult {
75
73
///
76
74
/// ddog_CallbackResult result = ddog_crasht_register_runtime_stack_callback(
77
75
/// my_runtime_callback,
78
- /// RuntimeType::Ruby,
79
76
/// CallbackType::Frame,
80
77
/// );
81
78
/// ```
@@ -86,7 +83,6 @@ impl From<CallbackError> for CallbackResult {
86
83
///
87
84
/// # Arguments
88
85
/// - `callback`: The callback function to invoke during crashes
89
- /// - `runtime_type`: Runtime type enum (Python, Ruby, Php, Nodejs, Unknown)
90
86
/// - `callback_type`: Callback type enum (Frame, StacktraceString)
91
87
///
92
88
/// # Returns
@@ -99,10 +95,9 @@ impl From<CallbackError> for CallbackResult {
99
95
#[ no_mangle]
100
96
pub unsafe extern "C" fn ddog_crasht_register_runtime_stack_callback (
101
97
callback : RuntimeStackCallback ,
102
- runtime_type : RuntimeType ,
103
98
callback_type : CallbackType ,
104
99
) -> CallbackResult {
105
- match register_runtime_stack_callback ( callback, runtime_type , callback_type) {
100
+ match register_runtime_stack_callback ( callback, callback_type) {
106
101
Ok ( ( ) ) => CallbackResult :: Ok ,
107
102
Err ( e) => e. into ( ) ,
108
103
}
@@ -119,20 +114,6 @@ pub extern "C" fn ddog_crasht_is_runtime_callback_registered() -> bool {
119
114
is_runtime_callback_registered ( )
120
115
}
121
116
122
- /// Get the runtime type from the currently registered callback context
123
- ///
124
- /// Returns the runtime type C string pointer if a callback with valid context is registered,
125
- /// null pointer otherwise
126
- ///
127
- /// # Safety
128
- /// - The returned pointer is valid only while the callback remains registered
129
- /// - The caller should not free the returned pointer
130
- /// - The returned string should be copied if it needs to persist beyond callback lifetime
131
- #[ no_mangle]
132
- pub unsafe extern "C" fn ddog_crasht_get_registered_runtime_type ( ) -> * const std:: ffi:: c_char {
133
- get_registered_runtime_type_ptr ( )
134
- }
135
-
136
117
/// Get the callback type from the currently registered callback context
137
118
///
138
119
/// Returns the callback type C string pointer if a callback with valid context is registered,
@@ -191,12 +172,10 @@ mod tests {
191
172
192
173
// Test that no callback is initially registered
193
174
assert ! ( !ddog_crasht_is_runtime_callback_registered( ) ) ;
194
- assert_eq ! ( ddog_crasht_get_registered_runtime_type( ) , ptr:: null( ) ) ;
195
175
196
176
// Test successful registration using type-safe enums
197
177
let result = ddog_crasht_register_runtime_stack_callback (
198
178
test_runtime_callback,
199
- RuntimeType :: Ruby ,
200
179
CallbackType :: Frame ,
201
180
) ;
202
181
@@ -205,16 +184,9 @@ mod tests {
205
184
// Verify callback is now registered
206
185
assert ! ( ddog_crasht_is_runtime_callback_registered( ) ) ;
207
186
208
- // Verify we can retrieve the runtime type
209
- let runtime_type_ptr = ddog_crasht_get_registered_runtime_type ( ) ;
210
- assert ! ( !runtime_type_ptr. is_null( ) ) ;
211
- let runtime_type_str = std:: ffi:: CStr :: from_ptr ( runtime_type_ptr) . to_str ( ) . unwrap ( ) ;
212
- assert_eq ! ( runtime_type_str, "ruby" ) ;
213
-
214
187
// Test duplicate registration fails
215
188
let result = ddog_crasht_register_runtime_stack_callback (
216
189
test_runtime_callback,
217
- RuntimeType :: Ruby ,
218
190
CallbackType :: Frame ,
219
191
) ;
220
192
assert_eq ! ( result, CallbackResult :: Ok ) ;
@@ -239,19 +211,12 @@ mod tests {
239
211
// Test registration with enum values - Python + StacktraceString
240
212
let result = ddog_crasht_register_runtime_stack_callback (
241
213
test_runtime_callback,
242
- RuntimeType :: Python ,
243
214
CallbackType :: StacktraceString ,
244
215
) ;
245
216
246
217
assert_eq ! ( result, CallbackResult :: Ok ) ;
247
218
assert ! ( ddog_crasht_is_runtime_callback_registered( ) ) ;
248
219
249
- // Verify runtime type
250
- let runtime_type_ptr = ddog_crasht_get_registered_runtime_type ( ) ;
251
- assert ! ( !runtime_type_ptr. is_null( ) ) ;
252
- let runtime_type_str = std:: ffi:: CStr :: from_ptr ( runtime_type_ptr) . to_str ( ) . unwrap ( ) ;
253
- assert_eq ! ( runtime_type_str, "python" ) ;
254
-
255
220
// Verify callback type
256
221
let callback_type_ptr = ddog_crasht_get_registered_callback_type ( ) ;
257
222
assert ! ( !callback_type_ptr. is_null( ) ) ;
@@ -263,17 +228,11 @@ mod tests {
263
228
// Test re-registration with different values - Ruby + Frame
264
229
let result = ddog_crasht_register_runtime_stack_callback (
265
230
test_runtime_callback,
266
- RuntimeType :: Ruby ,
267
231
CallbackType :: Frame ,
268
232
) ;
269
233
270
234
assert_eq ! ( result, CallbackResult :: Ok ) ;
271
235
272
- // Verify new values
273
- let runtime_type_ptr = ddog_crasht_get_registered_runtime_type ( ) ;
274
- let runtime_type_str = std:: ffi:: CStr :: from_ptr ( runtime_type_ptr) . to_str ( ) . unwrap ( ) ;
275
- assert_eq ! ( runtime_type_str, "ruby" ) ;
276
-
277
236
let callback_type_ptr = ddog_crasht_get_registered_callback_type ( ) ;
278
237
let callback_type_str = std:: ffi:: CStr :: from_ptr ( callback_type_ptr)
279
238
. to_str ( )
0 commit comments