Skip to content

Commit 86a3ae8

Browse files
committed
Merged pull request xdebug#1053
* pr/1053: Reimplement PR xdebug#1052 with normal style Add missing section comment
2 parents be2680f + fb64fab commit 86a3ae8

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

src/base/base.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,12 @@ void xdebug_base_rinit()
13841384
XG_BASE(last_eval_statement) = NULL;
13851385
XG_BASE(last_exception_trace) = NULL;
13861386

1387+
/* Enable statement handler only when needed */
1388+
XG_BASE(statement_handler_enabled) = false;
1389+
if (XDEBUG_MODE_IS(XDEBUG_MODE_COVERAGE) || XDEBUG_MODE_IS(XDEBUG_MODE_STEP_DEBUG)) {
1390+
XG_BASE(statement_handler_enabled) = true;
1391+
}
1392+
13871393
/* Initialize start time */
13881394
XG_BASE(start_nanotime) = xdebug_get_nanotime();
13891395

@@ -1425,6 +1431,7 @@ void xdebug_base_rinit()
14251431
XG_BASE(filters_stack) = xdebug_llist_alloc(xdebug_llist_string_dtor);
14261432
XG_BASE(filters_tracing) = xdebug_llist_alloc(xdebug_llist_string_dtor);
14271433

1434+
/* Warn about Private Temp Directory */
14281435
if (XG_BASE(private_tmp)) {
14291436
xdebug_log_ex(XLOG_CHAN_CONFIG, XLOG_INFO, "PRIVTMP", "Systemd Private Temp Directory is enabled (%s)", XG_BASE(private_tmp));
14301437
}

src/base/base_globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ typedef struct _xdebug_base_globals_t {
5656
unsigned int function_count;
5757
zend_string *last_eval_statement;
5858
char *last_exception_trace;
59+
zend_bool statement_handler_enabled;
5960

6061
/* in-execution checking */
6162
zend_bool in_execution;

xdebug.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ static void xdebug_init_base_globals(xdebug_base_globals_t *xg)
417417
xg->in_var_serialisation = 0;
418418
xg->error_reporting_override = 0;
419419
xg->error_reporting_overridden = 0;
420+
xg->statement_handler_enabled = false;
420421

421422
xg->filter_type_code_coverage = XDEBUG_FILTER_NONE;
422423
xg->filter_type_stack = XDEBUG_FILTER_NONE;
@@ -760,8 +761,8 @@ PHP_MINFO_FUNCTION(xdebug)
760761

761762
ZEND_DLEXPORT void xdebug_statement_call(zend_execute_data *frame)
762763
{
763-
zend_op_array *op_array = &frame->func->op_array;
764-
int lineno;
764+
zend_op_array *op_array;
765+
int lineno;
765766

766767
if (XDEBUG_MODE_IS_OFF()) {
767768
return;
@@ -771,6 +772,15 @@ ZEND_DLEXPORT void xdebug_statement_call(zend_execute_data *frame)
771772
return;
772773
}
773774

775+
#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT
776+
xdebug_control_socket_dispatch();
777+
#endif
778+
779+
if (!XG_BASE(statement_handler_enabled)) {
780+
return;
781+
}
782+
783+
op_array = &frame->func->op_array;
774784
lineno = EG(current_execute_data)->opline->lineno;
775785

776786
if (XDEBUG_MODE_IS(XDEBUG_MODE_COVERAGE)) {
@@ -780,10 +790,6 @@ ZEND_DLEXPORT void xdebug_statement_call(zend_execute_data *frame)
780790
if (XDEBUG_MODE_IS(XDEBUG_MODE_STEP_DEBUG)) {
781791
xdebug_debugger_statement_call(op_array->filename, lineno);
782792
}
783-
784-
#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT
785-
xdebug_control_socket_dispatch();
786-
#endif
787793
}
788794

789795
ZEND_DLEXPORT int xdebug_zend_startup(zend_extension *extension)

0 commit comments

Comments
 (0)