mirror of
https://github.com/php/php-src.git
synced 2025-08-18 23:18:56 +02:00
Merge branch 'master' of https://github.com/krakjoe/phpdbg
This commit is contained in:
commit
beea71bd25
3 changed files with 20 additions and 16 deletions
|
@ -6,6 +6,7 @@ Version 0.2.0 2013-00-00
|
||||||
|
|
||||||
1. Added "break delete <id>" command
|
1. Added "break delete <id>" command
|
||||||
2. Added "break opcode <opcode>" command
|
2. Added "break opcode <opcode>" command
|
||||||
|
3. Added "set" command
|
||||||
|
|
||||||
Version 0.1.0 2013-11-23
|
Version 0.1.0 2013-11-23
|
||||||
------------------------
|
------------------------
|
||||||
|
|
|
@ -35,7 +35,7 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
|
||||||
/* {{{ color structures */
|
/* {{{ color structures */
|
||||||
const static phpdbg_color_t colors[] = {
|
const static phpdbg_color_t colors[] = {
|
||||||
PHPDBG_COLOR_D("none", "0;0"),
|
PHPDBG_COLOR_D("none", "0;0"),
|
||||||
|
|
||||||
PHPDBG_COLOR_D("white", "0;64"),
|
PHPDBG_COLOR_D("white", "0;64"),
|
||||||
PHPDBG_COLOR_D("white-bold", "1;64"),
|
PHPDBG_COLOR_D("white-bold", "1;64"),
|
||||||
PHPDBG_COLOR_D("red", "0;31"),
|
PHPDBG_COLOR_D("red", "0;31"),
|
||||||
|
@ -48,6 +48,8 @@ const static phpdbg_color_t colors[] = {
|
||||||
PHPDBG_COLOR_D("purple-bold", "1;35"),
|
PHPDBG_COLOR_D("purple-bold", "1;35"),
|
||||||
PHPDBG_COLOR_D("cyan", "0;36"),
|
PHPDBG_COLOR_D("cyan", "0;36"),
|
||||||
PHPDBG_COLOR_D("cyan-bold", "1;36"),
|
PHPDBG_COLOR_D("cyan-bold", "1;36"),
|
||||||
|
PHPDBG_COLOR_D("yellow", "0;33"),
|
||||||
|
PHPDBG_COLOR_D("yellow-bold", "1;33"),
|
||||||
PHPDBG_COLOR_END
|
PHPDBG_COLOR_END
|
||||||
}; /* }}} */
|
}; /* }}} */
|
||||||
|
|
||||||
|
@ -179,8 +181,8 @@ PHPDBG_API int phpdbg_print(int type TSRMLS_DC, FILE *fp, const char *format, ..
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case P_ERROR:
|
case P_ERROR:
|
||||||
if (PHPDBG_G(flags) & PHPDBG_IS_COLOURED) {
|
if (PHPDBG_G(flags) & PHPDBG_IS_COLOURED) {
|
||||||
rc = fprintf(fp,
|
rc = fprintf(fp,
|
||||||
"\033[%sm[%s]\033[0m\n",
|
"\033[%sm[%s]\033[0m\n",
|
||||||
PHPDBG_G(colors)[PHPDBG_COLOR_ERROR]->code, buffer);
|
PHPDBG_G(colors)[PHPDBG_COLOR_ERROR]->code, buffer);
|
||||||
} else {
|
} else {
|
||||||
rc = fprintf(fp, "[%s]\n", buffer);
|
rc = fprintf(fp, "[%s]\n", buffer);
|
||||||
|
@ -189,8 +191,8 @@ PHPDBG_API int phpdbg_print(int type TSRMLS_DC, FILE *fp, const char *format, ..
|
||||||
|
|
||||||
case P_NOTICE:
|
case P_NOTICE:
|
||||||
if (PHPDBG_G(flags) & PHPDBG_IS_COLOURED) {
|
if (PHPDBG_G(flags) & PHPDBG_IS_COLOURED) {
|
||||||
rc = fprintf(fp,
|
rc = fprintf(fp,
|
||||||
"\033[%sm[%s]\033[0m\n",
|
"\033[%sm[%s]\033[0m\n",
|
||||||
PHPDBG_G(colors)[PHPDBG_COLOR_NOTICE]->code, buffer);
|
PHPDBG_G(colors)[PHPDBG_COLOR_NOTICE]->code, buffer);
|
||||||
} else {
|
} else {
|
||||||
rc = fprintf(fp, "[%s]\n", buffer);
|
rc = fprintf(fp, "[%s]\n", buffer);
|
||||||
|
@ -226,10 +228,10 @@ PHPDBG_API int phpdbg_print(int type TSRMLS_DC, FILE *fp, const char *format, ..
|
||||||
return rc;
|
return rc;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
PHPDBG_API const phpdbg_color_t* phpdbg_get_color(const char *name, size_t name_length TSRMLS_DC) /* {{{ */
|
PHPDBG_API const phpdbg_color_t *phpdbg_get_color(const char *name, size_t name_length TSRMLS_DC) /* {{{ */
|
||||||
{
|
{
|
||||||
const phpdbg_color_t *color = colors;
|
const phpdbg_color_t *color = colors;
|
||||||
|
|
||||||
while (color && color->name) {
|
while (color && color->name) {
|
||||||
if (name_length == color->name_length &&
|
if (name_length == color->name_length &&
|
||||||
memcmp(name, color->name, name_length) == SUCCESS) {
|
memcmp(name, color->name, name_length) == SUCCESS) {
|
||||||
|
@ -239,10 +241,10 @@ PHPDBG_API const phpdbg_color_t* phpdbg_get_color(const char *name, size_t name_
|
||||||
}
|
}
|
||||||
++color;
|
++color;
|
||||||
}
|
}
|
||||||
|
|
||||||
phpdbg_debug(
|
phpdbg_debug(
|
||||||
"phpdbg_get_color(%s, %lu): failed", name, name_length);
|
"phpdbg_get_color(%s, %lu): failed", name, name_length);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
@ -254,6 +256,7 @@ PHPDBG_API void phpdbg_set_color(int element, const phpdbg_color_t *color TSRMLS
|
||||||
PHPDBG_API void phpdbg_set_color_ex(int element, const char *name, size_t name_length TSRMLS_DC) /* {{{ */
|
PHPDBG_API void phpdbg_set_color_ex(int element, const char *name, size_t name_length TSRMLS_DC) /* {{{ */
|
||||||
{
|
{
|
||||||
const phpdbg_color_t *color = phpdbg_get_color(name, name_length TSRMLS_CC);
|
const phpdbg_color_t *color = phpdbg_get_color(name, name_length TSRMLS_CC);
|
||||||
|
|
||||||
if (color) {
|
if (color) {
|
||||||
phpdbg_set_color(element, color TSRMLS_CC);
|
phpdbg_set_color(element, color TSRMLS_CC);
|
||||||
} else PHPDBG_G(colors)[element] = colors;
|
} else PHPDBG_G(colors)[element] = colors;
|
||||||
|
@ -276,7 +279,7 @@ PHPDBG_API void phpdbg_set_prompt(const char *prompt TSRMLS_DC) /* {{{ */
|
||||||
free(PHPDBG_G(prompt)[0]);
|
free(PHPDBG_G(prompt)[0]);
|
||||||
PHPDBG_G(prompt)[0] = NULL;
|
PHPDBG_G(prompt)[0] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy new prompt */
|
/* copy new prompt */
|
||||||
PHPDBG_G(prompt)[0] = strdup(prompt);
|
PHPDBG_G(prompt)[0] = strdup(prompt);
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
@ -287,18 +290,18 @@ PHPDBG_API const char *phpdbg_get_prompt(TSRMLS_D) /* {{{ */
|
||||||
if (PHPDBG_G(prompt)[1]) {
|
if (PHPDBG_G(prompt)[1]) {
|
||||||
return PHPDBG_G(prompt)[1];
|
return PHPDBG_G(prompt)[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create cached prompt */
|
/* create cached prompt */
|
||||||
if ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED)) {
|
if ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED)) {
|
||||||
asprintf(
|
asprintf(
|
||||||
&PHPDBG_G(prompt)[1], "\033[%sm%s\033[0m ",
|
&PHPDBG_G(prompt)[1], "\033[%sm%s\033[0m ",
|
||||||
PHPDBG_G(colors)[PHPDBG_COLOR_PROMPT]->code,
|
PHPDBG_G(colors)[PHPDBG_COLOR_PROMPT]->code,
|
||||||
PHPDBG_G(prompt)[0]);
|
PHPDBG_G(prompt)[0]);
|
||||||
} else {
|
} else {
|
||||||
asprintf(
|
asprintf(
|
||||||
&PHPDBG_G(prompt)[1], "%s ",
|
&PHPDBG_G(prompt)[1], "%s ",
|
||||||
PHPDBG_G(prompt)[0]);
|
PHPDBG_G(prompt)[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return PHPDBG_G(prompt)[1];
|
return PHPDBG_G(prompt)[1];
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
|
@ -81,7 +81,7 @@ PHPDBG_API int phpdbg_print(int TSRMLS_DC, FILE*, const char*, ...) PHP_ATTRIBUT
|
||||||
{color, sizeof(color)-1, code}
|
{color, sizeof(color)-1, code}
|
||||||
#define PHPDBG_COLOR_END \
|
#define PHPDBG_COLOR_END \
|
||||||
{NULL, 0L, {0}}
|
{NULL, 0L, {0}}
|
||||||
|
|
||||||
#define PHPDBG_COLOR_INVALID -1
|
#define PHPDBG_COLOR_INVALID -1
|
||||||
#define PHPDBG_COLOR_PROMPT 0
|
#define PHPDBG_COLOR_PROMPT 0
|
||||||
#define PHPDBG_COLOR_ERROR 1
|
#define PHPDBG_COLOR_ERROR 1
|
||||||
|
@ -94,7 +94,7 @@ typedef struct _phpdbg_color_t {
|
||||||
const char code[PHPDBG_COLOR_LEN];
|
const char code[PHPDBG_COLOR_LEN];
|
||||||
} phpdbg_color_t;
|
} phpdbg_color_t;
|
||||||
|
|
||||||
PHPDBG_API const phpdbg_color_t* phpdbg_get_color(const char *name, size_t name_length TSRMLS_DC);
|
PHPDBG_API const phpdbg_color_t *phpdbg_get_color(const char *name, size_t name_length TSRMLS_DC);
|
||||||
PHPDBG_API void phpdbg_set_color(int element, const phpdbg_color_t *color TSRMLS_DC);
|
PHPDBG_API void phpdbg_set_color(int element, const phpdbg_color_t *color TSRMLS_DC);
|
||||||
PHPDBG_API void phpdbg_set_color_ex(int element, const char *name, size_t name_length TSRMLS_DC);
|
PHPDBG_API void phpdbg_set_color_ex(int element, const char *name, size_t name_length TSRMLS_DC);
|
||||||
PHPDBG_API const phpdbg_color_t* phpdbg_get_colors(TSRMLS_D); /* }}} */
|
PHPDBG_API const phpdbg_color_t* phpdbg_get_colors(TSRMLS_D); /* }}} */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue