@@ -111,6 +111,10 @@ static void ddtrace_capture_long_value(zend_long num, struct ddog_CaptureValue *
111111}
112112
113113void ddtrace_create_capture_value (zval * zv , struct ddog_CaptureValue * value , const ddog_CaptureConfiguration * config , int remaining_nesting ) {
114+ if (UNEXPECTED (DDTRACE_G (debugger_capture_timed_out ))) {
115+ value -> not_captured_reason = DDOG_CHARSLICE_C ("timeout" );
116+ return ;
117+ }
114118 ZVAL_DEREF (zv );
115119 switch (Z_TYPE_P (zv )) {
116120 case IS_FALSE :
@@ -158,6 +162,10 @@ void ddtrace_create_capture_value(zval *zv, struct ddog_CaptureValue *value, con
158162 if (zend_array_is_list (Z_ARR_P (zv ))) {
159163 int remaining_fields = config -> max_collection_size ;
160164 ZEND_HASH_FOREACH_VAL (Z_ARR_P (zv ), val ) {
165+ if (UNEXPECTED (DDTRACE_G (debugger_capture_timed_out ))) {
166+ value -> not_captured_reason = DDOG_CHARSLICE_C ("timeout" );
167+ break ;
168+ }
161169 if (remaining_fields -- == 0 ) {
162170 value -> not_captured_reason = DDOG_CHARSLICE_C ("collectionSize" );
163171 break ;
@@ -172,6 +180,10 @@ void ddtrace_create_capture_value(zval *zv, struct ddog_CaptureValue *value, con
172180 zend_string * key ;
173181 int remaining_fields = config -> max_collection_size ;
174182 ZEND_HASH_FOREACH_KEY_VAL (Z_ARR_P (zv ), idx , key , val ) {
183+ if (UNEXPECTED (DDTRACE_G (debugger_capture_timed_out ))) {
184+ value -> not_captured_reason = DDOG_CHARSLICE_C ("timeout" );
185+ break ;
186+ }
175187 if (remaining_fields -- == 0 ) {
176188 value -> not_captured_reason = DDOG_CHARSLICE_C ("collectionSize" );
177189 break ;
@@ -224,6 +236,10 @@ void ddtrace_create_capture_value(zval *zv, struct ddog_CaptureValue *value, con
224236 break ;
225237 }
226238 ZEND_HASH_REVERSE_FOREACH_STR_KEY_VAL (ht , key , val ) {
239+ if (UNEXPECTED (DDTRACE_G (debugger_capture_timed_out ))) {
240+ value -> not_captured_reason = DDOG_CHARSLICE_C ("timeout" );
241+ break ;
242+ }
227243 if (!key ) {
228244 continue ;
229245 }
@@ -401,6 +417,8 @@ static void ddtrace_collect_exception_debug_data(zend_object *exception, zend_ob
401417
402418 memset (& DDTRACE_G (exception_debugger_buffer ), 0 , sizeof (DDTRACE_G (exception_debugger_buffer )));
403419
420+ dd_start_debugger_timeout ();
421+
404422 zval * frame ;
405423 int frame_num = 0 ;
406424 ZEND_HASH_FOREACH_NUM_KEY_VAL (Z_ARR_P (trace ), frame_num , frame ) {
@@ -480,6 +498,8 @@ static void ddtrace_collect_exception_debug_data(zend_object *exception, zend_ob
480498 }
481499 }
482500
501+ dd_stop_debugger_timeout ();
502+
483503 // Note: We MUST immediately send this, and not defer, as stuff may be freed during span processing. Including stuff potentially contained within the exception debugger payload.
484504 ddtrace_sidecar_send_debugger_data (DDTRACE_G (exception_debugger_buffer ));
485505
0 commit comments