Skip to content

Commit

Permalink
Fixed issue #2077: Added xdebug.collect_params setting (back)
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed Sep 18, 2023
1 parent e016b35 commit 8863a40
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/lib/lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Xdebug |
+----------------------------------------------------------------------+
| Copyright (c) 2002-2021 Derick Rethans |
| Copyright (c) 2002-2023 Derick Rethans |
+----------------------------------------------------------------------+
| This source file is subject to version 1.01 of the Xdebug license, |
| that is bundled with this package in the file LICENSE, and is |
Expand Down Expand Up @@ -67,10 +67,10 @@ typedef struct xdebug_var_name {

#define XDEBUG_MAX_FUNCTION_LEN 1024

#define XDEBUG_TRACE_OPTION_APPEND 1
#define XDEBUG_TRACE_OPTION_COMPUTERIZED 2
#define XDEBUG_TRACE_OPTION_HTML 4
#define XDEBUG_TRACE_OPTION_NAKED_FILENAME 8
#define XDEBUG_TRACE_OPTION_APPEND 0x01
#define XDEBUG_TRACE_OPTION_COMPUTERIZED 0x02
#define XDEBUG_TRACE_OPTION_HTML 0x04
#define XDEBUG_TRACE_OPTION_NAKED_FILENAME 0x08

#define XDEBUG_CC_OPTION_UNUSED 1
#define XDEBUG_CC_OPTION_DEAD_CODE 2
Expand Down
6 changes: 4 additions & 2 deletions src/tracing/trace_computerized.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Xdebug |
+----------------------------------------------------------------------+
| Copyright (c) 2002-2022 Derick Rethans |
| Copyright (c) 2002-2023 Derick Rethans |
+----------------------------------------------------------------------+
| This source file is subject to version 1.01 of the Xdebug license, |
| that is bundled with this package in the file LICENSE, and is |
Expand Down Expand Up @@ -170,7 +170,9 @@ void xdebug_trace_computerized_function_entry(void *ctxt, function_stack_entry *
/* Filename and Lineno (9, 10) */
xdebug_str_add_fmt(&str, "\t%s\t%d", ZSTR_VAL(fse->filename), fse->lineno);

add_arguments(&str, fse);
if (XINI_TRACE(collect_params)) {
add_arguments(&str, fse);
}

/* Trailing \n */
xdebug_str_addc(&str, '\n');
Expand Down
6 changes: 4 additions & 2 deletions src/tracing/trace_textual.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Xdebug |
+----------------------------------------------------------------------+
| Copyright (c) 2002-2022 Derick Rethans |
| Copyright (c) 2002-2023 Derick Rethans |
+----------------------------------------------------------------------+
| This source file is subject to version 1.01 of the Xdebug license, |
| that is bundled with this package in the file LICENSE, and is |
Expand Down Expand Up @@ -182,7 +182,9 @@ void xdebug_trace_textual_function_entry(void *ctxt, function_stack_entry *fse,

xdfree(tmp_name);

add_arguments(&str, fse);
if (XINI_TRACE(collect_params)) {
add_arguments(&str, fse);
}

if (fse->include_filename) {
if (fse->function.type == XFUNC_EVAL) {
Expand Down
3 changes: 2 additions & 1 deletion src/tracing/tracing.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Xdebug |
+----------------------------------------------------------------------+
| Copyright (c) 2002-2022 Derick Rethans |
| Copyright (c) 2002-2023 Derick Rethans |
+----------------------------------------------------------------------+
| This source file is subject to version 1.01 of the Xdebug license, |
| that is bundled with this package in the file LICENSE, and is |
Expand Down Expand Up @@ -42,6 +42,7 @@ static xdebug_trace_handler_t *xdebug_select_trace_handler(int options)
tmp = &xdebug_trace_handler_textual; break;
}

/* Override handler based on options */
if (options & XDEBUG_TRACE_OPTION_COMPUTERIZED) {
tmp = &xdebug_trace_handler_computerized;
}
Expand Down
3 changes: 2 additions & 1 deletion src/tracing/tracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Xdebug |
+----------------------------------------------------------------------+
| Copyright (c) 2002-2022 Derick Rethans |
| Copyright (c) 2002-2023 Derick Rethans |
+----------------------------------------------------------------------+
| This source file is subject to version 1.01 of the Xdebug license, |
| that is bundled with this package in the file LICENSE, and is |
Expand Down Expand Up @@ -48,6 +48,7 @@ typedef struct _xdebug_tracing_settings_t {
zend_long trace_format;

zend_bool collect_assignments;
zend_bool collect_params;
zend_bool collect_return;
} xdebug_tracing_settings_t;

Expand Down
35 changes: 35 additions & 0 deletions tests/tracing/comp-without-params.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
--TEST--
Test for trace with xdebug.collect_params turned off (comp)
--INI--
xdebug.mode=trace
xdebug.start_with_request=no
xdebug.collect_assignments=0
xdebug.collect_params=0
xdebug.collect_return=0
xdebug.trace_format=1
--FILE--
<?php
require_once 'capture-trace.inc';

function a ($a, $b, $h, &$i) {
echo $a;
return $a + $b;
}

$a = array (1, 2,3,4,5);
$b = array ("h" => 9.12, $a, $a, $a, "p" => 9 - 0.12);
echo a (5, 9.12, FALSE, $b), "\n";

xdebug_stop_trace();
?>
--EXPECTF--
514.12
Version: %s
File format: %d
TRACE START [%d-%d-%d %d:%d:%d.%d]
2 1 1 %f %d
2 7 0 %f %d a 1 %scomp-without-params.php 11
2 7 1 %f %d
2 8 0 %f %d xdebug_stop_trace 0 %scomp-without-params.php 13
%f %d
TRACE END [%d-%d-%d %d:%d:%d.%d]
31 changes: 31 additions & 0 deletions tests/tracing/text-without-params.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--TEST--
Test for trace with xdebug.collect_params turned off (text)
--INI--
xdebug.mode=trace
xdebug.start_with_request=no
xdebug.collect_assignments=0
xdebug.collect_params=0
xdebug.collect_return=0
xdebug.trace_format=0
--FILE--
<?php
require_once 'capture-trace.inc';

function a ($a, $b, $h, &$i) {
echo $a;
return $a + $b;
}

$a = array (1, 2,3,4,5);
$b = array ("h" => 9.12, $a, $a, $a, "p" => 9 - 0.12);
echo a (5, 9.12, FALSE, $b), "\n";

xdebug_stop_trace();
?>
--EXPECTF--
514.12
TRACE START [%d-%d-%d %d:%d:%d.%d]
%w%f %w%d -> a() %stext-without-params.php:11
%w%f %w%d -> xdebug_stop_trace() %stext-without-params.php:13
%w%f %w%d
TRACE END [%d-%d-%d %d:%d:%d.%d]
2 changes: 1 addition & 1 deletion xdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,12 @@ PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("xdebug.trace_format", "0", PHP_INI_ALL, OnUpdateLong, settings.tracing.trace_format, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.trace_options", "0", PHP_INI_ALL, OnUpdateLong, settings.tracing.trace_options, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_BOOLEAN("xdebug.collect_assignments", "0", PHP_INI_ALL, OnUpdateBool, settings.tracing.collect_assignments, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_BOOLEAN("xdebug.collect_params", "1", PHP_INI_ALL, OnUpdateBool, settings.tracing.collect_params, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_BOOLEAN("xdebug.collect_return", "0", PHP_INI_ALL, OnUpdateBool, settings.tracing.collect_return, zend_xdebug_globals, xdebug_globals)

/* Removed/Changed settings */
XDEBUG_CHANGED_INI_ENTRY(xdebug.auto_trace)
XDEBUG_REMOVED_INI_ENTRY(xdebug.collect_includes)
XDEBUG_REMOVED_INI_ENTRY(xdebug.collect_params)
XDEBUG_REMOVED_INI_ENTRY(xdebug.collect_vars)
XDEBUG_CHANGED_INI_ENTRY(xdebug.coverage_enable)
XDEBUG_CHANGED_INI_ENTRY(xdebug.default_enable)
Expand Down

0 comments on commit 8863a40

Please sign in to comment.