Skip to content

Commit

Permalink
Merge branch 'xdebug_3_2'
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed Mar 21, 2023
2 parents 803f551 + b134291 commit 0f3ef12
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gdbinit
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ define pxdset
end
printf "\n"
end

set $xg = ((zend_xdebug_globals*) (*((void ***) tsrm_get_ls_cache()))[xdebug_globals_id-1])
17 changes: 8 additions & 9 deletions src/lib/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ extern ZEND_DECLARE_MODULE_GLOBALS(xdebug);
void xdebug_init_library_globals(xdebug_library_globals_t *xg)
{
xg->headers = NULL;
xg->mode = 0xFFFFFFFF;
xg->mode_from_environment = 0;

xg->log_file = 0;
Expand Down Expand Up @@ -123,31 +122,31 @@ void xdebug_disable_opcache_optimizer(void)
static int xdebug_lib_set_mode_item(const char *mode, int len)
{
if (strncmp(mode, "off", len) == 0) {
XG_LIB(mode) |= XDEBUG_MODE_OFF;
xdebug_global_mode |= XDEBUG_MODE_OFF;
return 1;
}
if (strncmp(mode, "develop", len) == 0) {
XG_LIB(mode) |= XDEBUG_MODE_DEVELOP;
xdebug_global_mode |= XDEBUG_MODE_DEVELOP;
return 1;
}
if (strncmp(mode, "coverage", len) == 0) {
XG_LIB(mode) |= XDEBUG_MODE_COVERAGE;
xdebug_global_mode |= XDEBUG_MODE_COVERAGE;
return 1;
}
if (strncmp(mode, "debug", len) == 0) {
XG_LIB(mode) |= XDEBUG_MODE_STEP_DEBUG;
xdebug_global_mode |= XDEBUG_MODE_STEP_DEBUG;
return 1;
}
if (strncmp(mode, "gcstats", len) == 0) {
XG_LIB(mode) |= XDEBUG_MODE_GCSTATS;
xdebug_global_mode |= XDEBUG_MODE_GCSTATS;
return 1;
}
if (strncmp(mode, "profile", len) == 0) {
XG_LIB(mode) |= XDEBUG_MODE_PROFILING;
xdebug_global_mode |= XDEBUG_MODE_PROFILING;
return 1;
}
if (strncmp(mode, "trace", len) == 0) {
XG_LIB(mode) |= XDEBUG_MODE_TRACING;
xdebug_global_mode |= XDEBUG_MODE_TRACING;
return 1;
}

Expand All @@ -160,7 +159,7 @@ static int xdebug_lib_set_mode_from_setting(const char *mode)
char *comma = NULL;
int errors = 0;

XG_LIB(mode) = 0;
xdebug_global_mode = 0;

comma = strchr(mode_ptr, ',');
while (comma) {
Expand Down
7 changes: 4 additions & 3 deletions src/lib/lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include "zend_API.h"
#include "compat.h"

extern int xdebug_global_mode;

typedef struct xdebug_var_name {
zend_string *name;
zval data;
Expand Down Expand Up @@ -194,7 +196,6 @@ struct _xdebug_multi_opcode_handler_t
};

typedef struct _xdebug_library_globals_t {
int mode;
int start_with_request; /* One of the XDEBUG_START_WITH_REQUEST_* constants */
int start_upon_error; /* One of the XDEBUG_START_UPON_ERROR_* constants */
int mode_from_environment; /* Keeps track whether the mode was set with XDEBUG_MODE for diagnostics purposes */
Expand Down Expand Up @@ -265,8 +266,8 @@ void xdebug_disable_opcache_optimizer(void);
#define XDEBUG_MODE_TRACING 1<<5
int xdebug_lib_set_mode(const char *mode);

#define XDEBUG_MODE_IS_OFF() ((XG(globals.library.mode) == XDEBUG_MODE_OFF))
#define XDEBUG_MODE_IS(v) ((XG(globals.library.mode) & (v)) ? 1 : 0)
#define XDEBUG_MODE_IS_OFF() ((xdebug_global_mode == XDEBUG_MODE_OFF))
#define XDEBUG_MODE_IS(v) ((xdebug_global_mode & (v)) ? 1 : 0)
#define RETURN_IF_MODE_IS_NOT(m) if (!XDEBUG_MODE_IS((m))) { return; }
#define RETURN_FALSE_IF_MODE_IS_NOT(m) if (!XDEBUG_MODE_IS((m))) { RETURN_FALSE; }
#define WARN_AND_RETURN_IF_MODE_IS_NOT(m) if (!XDEBUG_MODE_IS((m))) { php_error(E_NOTICE, "Functionality is not enabled"); return; }
Expand Down
2 changes: 2 additions & 0 deletions xdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ static zend_result xdebug_post_startup(void);

int xdebug_include_or_eval_handler(zend_execute_data *execute_data);

/* True globals */
int zend_xdebug_initialised = 0;
int xdebug_global_mode = 0;

zend_module_entry xdebug_module_entry = {
STANDARD_MODULE_HEADER,
Expand Down

0 comments on commit 0f3ef12

Please sign in to comment.