Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix wrapper tracking
  • Loading branch information
ZNeumann authored and lavarou committed Nov 6, 2024
commit 7ad1ab234727bdd5f531a7cd639822c5dd002f6d
8 changes: 1 addition & 7 deletions agent/php_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -2130,9 +2130,6 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO, bool create_metric, boo
nr_status_t status = nr_php_error_record_exception_segment(
NRPRG(txn), &exception,
&NRPRG(exception_filters));
if (execute_data->func && execute_data->func->common.function_name) {
nrl_verbosedebug(NRL_AGENT, "END %s", ZSTR_VAL(execute_data->func->common.function_name));
}

if (NR_FAILURE == status) {
nrl_verbosedebug(NRL_AGENT, "%s: unable to record exception on segment",
Expand Down Expand Up @@ -2217,9 +2214,6 @@ void nr_php_observer_fcall_begin(zend_execute_data* execute_data) {
//if (execute_data->func && execute_data->func->common.function_name) {
// printf("BEGIN %s\n", ZSTR_VAL(execute_data->func->common.function_name));
//}
if (execute_data->func && execute_data->func->common.function_name) {
nrl_verbosedebug(NRL_AGENT, "BEGIN %s", ZSTR_VAL(execute_data->func->common.function_name));
}
if (nrunlikely(NULL == execute_data)) {
return;
}
Expand Down Expand Up @@ -2262,7 +2256,7 @@ void nr_php_observer_fcall_begin_instrumented(zend_execute_data* execute_data) {
*/
zval* func_return_value = NULL;
//if (execute_data->func && execute_data->func->common.function_name) {
// nrl_verbosedebug(NRL_AGENT, "BEGIN %s", ZSTR_VAL(execute_data->func->common.function_name));
// printf("BEGIN %s", ZSTR_VAL(execute_data->func->common.function_name));
//}
if (nrunlikely(NULL == execute_data)) {
return;
Expand Down
5 changes: 0 additions & 5 deletions agent/php_newrelic.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,6 @@ int symfony1_in_dispatch; /* Whether we are currently within a
int symfony1_in_error404; /* Whether we are currently within a
sfError404Exception::printStackTrace() frame */

#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO \
&& !defined OVERWRITE_ZEND_EXECUTE_DATA
bool in_wrapper;
#endif

#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \
&& !defined OVERWRITE_ZEND_EXECUTE_DATA
bool check_cufa;
Expand Down
5 changes: 1 addition & 4 deletions agent/php_rinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,9 @@ PHP_RINIT_FUNCTION(newrelic) {
nr_stack_init(&NRPRG(drupal_invoke_all_hooks), NR_STACK_DEFAULT_CAPACITY);
nr_stack_init(&NRPRG(drupal_invoke_all_states), NR_STACK_DEFAULT_CAPACITY);
NRPRG(predis_ctxs).dtor = str_stack_dtor;
NRPRG(wordpress_tags).dtor = str_stack_dtor;
NRPRG(drupal_invoke_all_hooks).dtor = zval_stack_dtor;
#endif
#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO \
&& !defined OVERWRITE_ZEND_EXECUTE_DATA
NRPRG(in_wrapper) = false;
#endif

NRPRG(mysql_last_conn) = NULL;
NRPRG(pgsql_last_conn) = NULL;
Expand Down
3 changes: 3 additions & 0 deletions agent/php_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ nruserfn_t* nr_php_wrap_callable_before_after(
// begin_handler will be NULL if the observer hasn't been installed yet.
// *begin_Handler will be NULL if the function has not yet been called.
if (begin_handler && *begin_handler) {
name = nr_php_function_debug_name(callable);
php_printf("AHHHHHHH %s\n", name);
nr_free(name);
// It is okay to attempt to remove a handler that doesn't exist
// TODO this could remove nr_php_observer_fcall_begin/end and then re-add it :)
if (zend_observer_remove_begin_handler(callable, NRINI(tt_detail) ?
Expand Down
22 changes: 8 additions & 14 deletions agent/php_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,27 +276,22 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D);
#define NR_PHP_WRAPPER_START(name) \
NR_PHP_WRAPPER_PROTOTYPE(name) { \
int was_executed = 0; \
bool in_begin = true;\
int zcaught = 0; \
bool is_begin = false; \
nruserfn_t* wraprec = NULL; \
zval* func_return_value = NULL; \
const nrtxn_t* txn = NRPRG(txn); \
const nrtime_t txn_start_time = nr_txn_start_time(txn); \
if (NRPRG(in_wrapper)) { \
printf("AAHHHHHHHHHHH %s\n", #name); \
} \
NRPRG(in_wrapper) = true; \
\
nr_segment_t* auto_segment = nr_txn_get_current_segment(NRPRG(txn), NULL); \
if (!auto_segment || auto_segment->execute_data != execute_data || \
auto_segment == NRPRG(txn)->segment_root) { \
if (!auto_segment || auto_segment->execute_data != execute_data) { \
nr_php_observer_fcall_begin(execute_data); \
auto_segment = nr_txn_get_current_segment(NRPRG(txn), NULL); \
is_begin = true; \
} else { \
va_list ptr; \
va_start(ptr, execute_data); \
func_return_value = va_arg(ptr, zval*); \
va_list args; \
va_start(args, execute_data); \
func_return_value = va_arg(args, zval*); \
va_end(args); \
in_begin = false; \
nr_php_observer_fcall_end_keep_segment(execute_data, \
func_return_value); \
}
Expand Down Expand Up @@ -327,12 +322,11 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D);
if (!was_executed) { \
NR_PHP_WRAPPER_CALL \
} \
if (is_begin) { \
if (in_begin) { \
nr_php_observer_fcall_begin_late(execute_data, txn_start_time);\
} else { \
nr_php_observer_fcall_end_late(execute_data, false, txn_start_time); \
} \
NRPRG(in_wrapper) = false; \
if (zcaught) { \
zend_bailout(); \
} \
Expand Down