Skip to content

Commit

Permalink
Merge branch 'xdebug_3_1'
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed Oct 7, 2021
2 parents f754ce9 + ec4e5c3 commit 624ede5
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 66 deletions.
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Thu, Apr 08, 2021 - Xdebug 3.0.4
<dir name="base">
<file name="base.c" role="src" />
<file name="base.h" role="src" />
<file name="base_globals.h" role="src" />
<file name="base_private.h" role="src" />
<file name="filter.c" role="src" />
<file name="filter.h" role="src" />
Expand Down
45 changes: 5 additions & 40 deletions php_xdebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
# include "config.h"
#endif

#include "base/base_globals.h"
#include "coverage/branch_info.h"
#include "coverage/code_coverage.h"
#include "debugger/debugger.h"
Expand Down Expand Up @@ -75,46 +76,9 @@ ZEND_MODULE_POST_ZEND_DEACTIVATE_D(xdebug);

int xdebug_is_output_tty();

struct xdebug_base_info {
xdebug_vector *stack;
#if PHP_VERSION_ID >= 80100
xdebug_hash *fiber_stacks;
#endif
xdebug_nanotime_context nanotime_context;
uint64_t start_nanotime;
unsigned int prev_memory;
zif_handler orig_set_time_limit_func;
zif_handler orig_error_reporting_func;
zif_handler orig_pcntl_exec_func;
zif_handler orig_pcntl_fork_func;
int output_is_tty;
zend_bool in_debug_info;
zend_long error_reporting_override;
zend_bool error_reporting_overridden;
unsigned int function_count;
zend_string *last_eval_statement;
char *last_exception_trace;

/* in-execution checking */
zend_bool in_execution;
zend_bool in_var_serialisation;

/* filters */
zend_long filter_type_code_coverage;
zend_long filter_type_stack;
zend_long filter_type_tracing;
xdebug_llist *filters_code_coverage;
xdebug_llist *filters_stack;
xdebug_llist *filters_tracing;

struct {
zend_long max_nesting_level;
} settings;
};

ZEND_BEGIN_MODULE_GLOBALS(xdebug)
struct xdebug_base_info base;
struct {
xdebug_base_globals_t base;
xdebug_coverage_globals_t coverage;
xdebug_debugger_globals_t debugger;
xdebug_develop_globals_t develop;
Expand All @@ -124,6 +88,7 @@ ZEND_BEGIN_MODULE_GLOBALS(xdebug)
xdebug_tracing_globals_t tracing;
} globals;
struct {
xdebug_base_settings_t base;
xdebug_coverage_settings_t coverage;
xdebug_debugger_settings_t debugger;
xdebug_develop_settings_t develop;
Expand All @@ -140,7 +105,7 @@ ZEND_END_MODULE_GLOBALS(xdebug)
#define XG(v) (xdebug_globals.v)
#endif

#define XG_BASE(v) (XG(base.v))
#define XINI_BASE(v) (XG(base.settings.v))
#define XG_BASE(v) (XG(globals.base.v))
#define XINI_BASE(v) (XG(settings.base.v))

#endif
2 changes: 0 additions & 2 deletions src/base/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -1106,8 +1106,6 @@ void xdebug_base_minit(INIT_FUNC_ARGS)
XG_BASE(error_reporting_overridden) = 0;
XG_BASE(output_is_tty) = OUTPUT_NOT_CHECKED;

xdebug_nanotime_init();

#if PHP_VERSION_ID >= 80100
zend_observer_fiber_switch_register(xdebug_fiber_switch_observer);
#endif
Expand Down
81 changes: 81 additions & 0 deletions src/base/base_globals.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
+----------------------------------------------------------------------+
| Xdebug |
+----------------------------------------------------------------------+
| Copyright (c) 2002-2021 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 |
| available at through the world-wide-web at |
| https://xdebug.org/license.php |
| If you did not receive a copy of the Xdebug license and are unable |
| to obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/

#ifndef __XDEBUG_BASE_GLOBALS_H__
#define __XDEBUG_BASE_GLOBALS_H__

#include "lib/hash.h"
#include "lib/llist.h"
#include "lib/vector.h"


#if PHP_WIN32
typedef void (WINAPI *WIN_PRECISE_TIME_FUNC)(LPFILETIME);
#endif

typedef struct _xdebug_nanotime_context {
uint64_t start_abs;
uint64_t last_abs;
#if PHP_WIN32 | HAVE_XDEBUG_CLOCK_GETTIME | HAVE_XDEBUG_CLOCK_GETTIME_NSEC_NP
uint64_t start_rel;
uint64_t last_rel;
int use_rel_time;
#endif
#if PHP_WIN32
WIN_PRECISE_TIME_FUNC win_precise_time_func;
uint64_t win_freq;
#endif
} xdebug_nanotime_context;


typedef struct _xdebug_base_globals_t {
xdebug_vector *stack;
#if PHP_VERSION_ID >= 80100
xdebug_hash *fiber_stacks;
#endif
xdebug_nanotime_context nanotime_context;
uint64_t start_nanotime;
unsigned int prev_memory;
zif_handler orig_set_time_limit_func;
zif_handler orig_error_reporting_func;
zif_handler orig_pcntl_exec_func;
zif_handler orig_pcntl_fork_func;
int output_is_tty;
zend_bool in_debug_info;
zend_long error_reporting_override;
zend_bool error_reporting_overridden;
unsigned int function_count;
zend_string *last_eval_statement;
char *last_exception_trace;

/* in-execution checking */
zend_bool in_execution;
zend_bool in_var_serialisation;

/* filters */
zend_long filter_type_code_coverage;
zend_long filter_type_stack;
zend_long filter_type_tracing;
xdebug_llist *filters_code_coverage;
xdebug_llist *filters_stack;
xdebug_llist *filters_tracing;
} xdebug_base_globals_t;

typedef struct _xdebug_base_settings_t {
zend_long max_nesting_level;
} xdebug_base_settings_t;

#endif // __XDEBUG_BASE_GLOBALS_H__
5 changes: 3 additions & 2 deletions src/lib/timing.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include "php_xdebug.h"

#if PHP_WIN32
# include "win32/time.h"
# include <versionhelpers.h>
Expand Down Expand Up @@ -125,7 +126,7 @@ static uint64_t xdebug_get_nanotime_rel(xdebug_nanotime_context *nanotime_contex
}
#endif

void xdebug_nanotime_init(void)
void xdebug_nanotime_init(xdebug_base_globals_t *base)
{
xdebug_nanotime_context context = {0};

Expand Down Expand Up @@ -155,7 +156,7 @@ void xdebug_nanotime_init(void)
context.last_rel = 0;
#endif

XG_BASE(nanotime_context) = context;
base->nanotime_context = context;
}

uint64_t xdebug_get_nanotime(void)
Expand Down
20 changes: 1 addition & 19 deletions src/lib/timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,7 @@
#define NANOS_IN_MILLISEC 1000000
#define NANOS_IN_SEC 1000000000

#if PHP_WIN32
typedef void (WINAPI *WIN_PRECISE_TIME_FUNC)(LPFILETIME);
#endif

typedef struct _xdebug_nanotime_context {
uint64_t start_abs;
uint64_t last_abs;
#if PHP_WIN32 | HAVE_XDEBUG_CLOCK_GETTIME | HAVE_XDEBUG_CLOCK_GETTIME_NSEC_NP
uint64_t start_rel;
uint64_t last_rel;
int use_rel_time;
#endif
#if PHP_WIN32
WIN_PRECISE_TIME_FUNC win_precise_time_func;
uint64_t win_freq;
#endif
} xdebug_nanotime_context;

void xdebug_nanotime_init(void);
void xdebug_nanotime_init(xdebug_base_globals_t *xg);

uint64_t xdebug_get_nanotime(void);

Expand Down
1 change: 1 addition & 0 deletions src/lib/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define __XDEBUG_VECTOR_H__

#include <stddef.h>
#include "mm.h"

typedef void (*xdebug_vector_dtor)(void *);

Expand Down
8 changes: 5 additions & 3 deletions xdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("xdebug.var_display_max_depth", "3", PHP_INI_ALL, OnUpdateLong, settings.library.display_max_depth, zend_xdebug_globals, xdebug_globals)

/* Base settings */
STD_PHP_INI_ENTRY("xdebug.max_nesting_level", "256", PHP_INI_ALL, OnUpdateLong, base.settings.max_nesting_level, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.max_nesting_level", "256", PHP_INI_ALL, OnUpdateLong, settings.base.max_nesting_level, zend_xdebug_globals, xdebug_globals)

/* Develop settings */
STD_PHP_INI_ENTRY("xdebug.cli_color", "0", PHP_INI_ALL, OnUpdateLong, settings.develop.cli_color, zend_xdebug_globals, xdebug_globals)
Expand Down Expand Up @@ -384,7 +384,7 @@ PHP_INI_BEGIN()
XDEBUG_CHANGED_INI_ENTRY(xdebug.trace_enable_trigger_value)
PHP_INI_END()

static void xdebug_init_base_globals(struct xdebug_base_info *xg)
static void xdebug_init_base_globals(xdebug_base_globals_t *xg)
{
xg->stack = NULL;
xg->in_debug_info = 0;
Expand All @@ -400,14 +400,16 @@ static void xdebug_init_base_globals(struct xdebug_base_info *xg)
xg->filters_code_coverage = NULL;
xg->filters_stack = NULL;
xg->filters_tracing = NULL;

xdebug_nanotime_init(xg);
}

static void php_xdebug_init_globals(zend_xdebug_globals *xg)
{
memset(&xg->globals, 0, sizeof(xg->globals));

xdebug_init_library_globals(&xg->globals.library);
xdebug_init_base_globals(&xg->base);
xdebug_init_base_globals(&xg->globals.base);

if (XDEBUG_MODE_IS(XDEBUG_MODE_COVERAGE)) {
xdebug_init_coverage_globals(&xg->globals.coverage);
Expand Down

0 comments on commit 624ede5

Please sign in to comment.