1414#include "util_memory.h"
1515#include "util_strings.h"
1616#include "util_syscalls.h"
17+ #include <pthread.h>
1718
1819/*
1920 * The mechanism of zend_try .. zend_catch .. zend_end_try
@@ -209,13 +210,58 @@ static nr_php_wraprec_hashmap_t* user_function_wrappers;
209210
210211static inline void nr_php_wraprec_lookup_set (nruserfn_t * wr ,
211212 zend_function * zf ) {
213+ /* Debug logging for WordPress functions */
214+ if (nrl_should_print (NRL_VERBOSEDEBUG , NRL_FRAMEWORK )) {
215+ char * func_name = nr_php_function_debug_name (zf );
216+ if (func_name && (nr_strstr (func_name , "bbp_" ) || nr_strstr (func_name , "pre_post_update" ))) {
217+ nrl_verbosedebug (
218+ NRL_FRAMEWORK ,
219+ "[NR WP SET] Storing %s on thread %p: wraprec=%p in hashmap=%p (elements before=%zu)" ,
220+ func_name ? func_name : "<NULL>" ,
221+ (void * )pthread_self (),
222+ (void * )wr ,
223+ (void * )user_function_wrappers ,
224+ user_function_wrappers ? user_function_wrappers -> elements : 0 );
225+ }
226+ nr_free (func_name );
227+ }
228+
212229 nr_php_wraprec_hashmap_update (user_function_wrappers , zf , wr );
230+
231+ /* Debug logging after update */
232+ if (nrl_should_print (NRL_VERBOSEDEBUG , NRL_FRAMEWORK )) {
233+ char * func_name = nr_php_function_debug_name (zf );
234+ if (func_name && (nr_strstr (func_name , "bbp_" ) || nr_strstr (func_name , "pre_post_update" ))) {
235+ nrl_verbosedebug (
236+ NRL_FRAMEWORK ,
237+ "[NR WP SET] Stored %s: hashmap now has %zu elements" ,
238+ func_name ? func_name : "<NULL>" ,
239+ user_function_wrappers ? user_function_wrappers -> elements : 0 );
240+ }
241+ nr_free (func_name );
242+ }
213243}
214244static inline nruserfn_t * nr_php_wraprec_lookup_get (zend_function * zf ) {
215245 nruserfn_t * wraprec = NULL ;
216246
217247 nr_php_wraprec_hashmap_get_into (user_function_wrappers , zf , & wraprec );
218248
249+ /* Debug logging for WordPress functions */
250+ if (nrl_should_print (NRL_VERBOSEDEBUG , NRL_FRAMEWORK )) {
251+ char * func_name = nr_php_function_debug_name (zf );
252+ if (func_name && (nr_strstr (func_name , "bbp_" ) || nr_strstr (func_name , "pre_post_update" ))) {
253+ nrl_verbosedebug (
254+ NRL_FRAMEWORK ,
255+ "[NR WP LOOKUP] Function %s on thread %p: wraprec %s (hashmap=%p, elements=%zu)" ,
256+ func_name ? func_name : "<NULL>" ,
257+ (void * )pthread_self (),
258+ wraprec ? "FOUND" : "NOT FOUND" ,
259+ (void * )user_function_wrappers ,
260+ user_function_wrappers ? user_function_wrappers -> elements : 0 );
261+ }
262+ nr_free (func_name );
263+ }
264+
219265 return wraprec ;
220266}
221267
@@ -235,6 +281,11 @@ void nr_php_init_user_instrumentation(void) {
235281 }
236282 user_function_wrappers
237283 = nr_php_wraprec_hashmap_create_buckets (1024 , reset_wraprec );
284+ nrl_verbosedebug (
285+ NRL_INSTRUMENT ,
286+ "[NR HASHMAP] Initialized wraprec hashmap=%p on thread %p" ,
287+ (void * )user_function_wrappers ,
288+ (void * )pthread_self ());
238289}
239290
240291/*
0 commit comments