Permalink
Browse files

- Use PG(html_errors) instead of checking for CLI.

- Cleaned up compilation warnings.
- Fixed a bug in get_zval_synopsis() which was still using xdebug_var_export().

SVN Rev: 2072
  • Loading branch information...
1 parent c641c94 commit 170b02f6c88bfa4d7540b575ce58c0aadb9932f7 @derickr committed Oct 7, 2006
Showing with 66 additions and 69 deletions.
  1. +1 −1 tests/local_vars_in_error.phpt
  2. +4 −4 tests/test6.phpt
  3. +2 −1 usefulstuff.c
  4. +36 −27 xdebug.c
  5. +2 −6 xdebug_code_coverage.c
  6. +6 −6 xdebug_handler_dbgp.c
  7. +1 −1 xdebug_profiler.c
  8. +8 −8 xdebug_set.c
  9. +2 −1 xdebug_set.h
  10. +0 −8 xdebug_superglobals.c
  11. +1 −5 xdebug_var.c
  12. +3 −1 xdebug_xml.c
@@ -26,7 +26,7 @@ Fatal error: Call to undefined function do_f() in /%s/local_vars_in_error.php on
Call Stack:
%w%f %w%d 1. {main}() /%s/local_vars_in_error.php:0
-%w%f %w%d 2. a(5, 6) /%s/local_vars_in_error.php:8
+%w%f %w%d 2. a(long, long) /%s/local_vars_in_error.php:8
Variables in local scope (#2):
View
@@ -23,8 +23,8 @@ xdebug.var_display_max_depth=3
Warning: Missing argument 3 for foo2()%sin /%s/test6.php on line 2
Call Stack:
- %f %d 1. {main}() /%s/test6.php:0
- %f %d 2. foo2(4, array (0 => array (0 => 'blaat', 1 => 5, 2 => FALSE))) /%s/test6.php:7
+%w%f %w%d 1. {main}() /%s/test6.php:0
+%w%f %w%d 2. foo2(long, array (1)) /%s/test6.php:7
Variables in local scope:
@@ -35,8 +35,8 @@ Variables in local scope:
Fatal error: Call to undefined function%sfoo() in /%s/test6.php on line 4
Call Stack:
- %f %d 1. {main}() /%s/test6.php:0
- %f %d 2. foo2(4, array (0 => array (0 => 'blaat', 1 => 5, 2 => FALSE))) /%s/test6.php:7
+%w%f %w%d 1. {main}() /%s/test6.php:0
+%w%f %w%d 2. foo2(long, array(1)) /%s/test6.php:7
Variables in local scope:
View
@@ -36,6 +36,7 @@
#include "xdebug_mm.h"
#include "xdebug_str.h"
#include "usefulstuff.h"
+#include "ext/standard/php_lcg.h"
#define READ_BUFFER_SIZE 128
@@ -394,7 +395,7 @@ static FILE *xdebug_open_file(char *fname, char *mode, char *extension, char **n
FILE *xdebug_fopen(char *fname, char *mode, char *extension, char **new_fname)
{
- int fd, r;
+ int r;
FILE *fh;
struct stat buf;
char *tmp_fname;
View
@@ -1292,11 +1292,13 @@ void xdebug_execute(zend_op_array *op_array TSRMLS_DC)
/* Remove session cookie if requested */
if (
(
- PG(http_globals)[TRACK_VARS_GET] &&
- zend_hash_find(PG(http_globals)[TRACK_VARS_GET]->value.ht, "XDEBUG_SESSION_STOP", sizeof("XDEBUG_SESSION_STOP"), (void **) &dummy) == SUCCESS
- ) || (
- PG(http_globals)[TRACK_VARS_POST] &&
- zend_hash_find(PG(http_globals)[TRACK_VARS_POST]->value.ht, "XDEBUG_SESSION_STOP", sizeof("XDEBUG_SESSION_STOP"), (void **) &dummy) == SUCCESS
+ (
+ PG(http_globals)[TRACK_VARS_GET] &&
+ zend_hash_find(PG(http_globals)[TRACK_VARS_GET]->value.ht, "XDEBUG_SESSION_STOP", sizeof("XDEBUG_SESSION_STOP"), (void **) &dummy) == SUCCESS
+ ) || (
+ PG(http_globals)[TRACK_VARS_POST] &&
+ zend_hash_find(PG(http_globals)[TRACK_VARS_POST]->value.ht, "XDEBUG_SESSION_STOP", sizeof("XDEBUG_SESSION_STOP"), (void **) &dummy) == SUCCESS
+ )
)
&& !SG(headers_sent)
) {
@@ -1337,13 +1339,15 @@ void xdebug_execute(zend_op_array *op_array TSRMLS_DC)
XG(profiler_enable)
||
(
- XG(profiler_enable_trigger) &&
+ XG(profiler_enable_trigger) &&
(
- PG(http_globals)[TRACK_VARS_GET] &&
- zend_hash_find(PG(http_globals)[TRACK_VARS_GET]->value.ht, "XDEBUG_PROFILE", sizeof("XDEBUG_PROFILE"), (void **) &dummy) == SUCCESS
- ) || (
- PG(http_globals)[TRACK_VARS_POST] &&
- zend_hash_find(PG(http_globals)[TRACK_VARS_POST]->value.ht, "XDEBUG_PROFILE", sizeof("XDEBUG_PROFILE"), (void **) &dummy) == SUCCESS
+ (
+ PG(http_globals)[TRACK_VARS_GET] &&
+ zend_hash_find(PG(http_globals)[TRACK_VARS_GET]->value.ht, "XDEBUG_PROFILE", sizeof("XDEBUG_PROFILE"), (void **) &dummy) == SUCCESS
+ ) || (
+ PG(http_globals)[TRACK_VARS_POST] &&
+ zend_hash_find(PG(http_globals)[TRACK_VARS_POST]->value.ht, "XDEBUG_PROFILE", sizeof("XDEBUG_PROFILE"), (void **) &dummy) == SUCCESS
+ )
)
)
)
@@ -1608,7 +1612,7 @@ static void log_stack(const char *error_type_str, char *buffer, const char *erro
/* Printing vars */
for (j = 0; j < i->varc; j++) {
- char *tmp_varname, *tmp_value, *tmp_fancy_value;
+ char *tmp_varname, *tmp_value;
if (c) {
xdebug_str_addl(&log_buffer, ", ", 2, 0);
@@ -1630,21 +1634,16 @@ static void log_stack(const char *error_type_str, char *buffer, const char *erro
}
}
-static char* get_printable_stack(int html, const char *error_type_str, char *buffer, const char *error_filename, const int error_lineno, int log_only TSRMLS_DC)
+static char* get_printable_stack(int html, const char *error_type_str, char *buffer, const char *error_filename, const int error_lineno TSRMLS_DC)
{
- char *error_format, *error_string;
xdebug_llist_element *le;
function_stack_entry *i;
- int len, dummy;
+ int len;
char **formats;
xdebug_str str = {0, 0, NULL};
log_stack(error_type_str, buffer, error_filename, error_lineno TSRMLS_CC);
- if (log_only) {
- return;
- }
-
if (html) {
formats = html_formats;
} else {
@@ -1712,8 +1711,13 @@ static char* get_printable_stack(int html, const char *error_type_str, char *buf
xdebug_str_add(&str, xdebug_sprintf(formats[5], i->filename, i->lineno), 1);
}
- if (XG(dump_globals)) {
- xdebug_str_add(&str, xdebug_get_printable_superglobals(html TSRMLS_CC), 1);
+ if (XG(dump_globals) && !(XG(dump_once) && XG(dumped))) {
+ char *tmp = xdebug_get_printable_superglobals(html TSRMLS_CC);
+
+ if (tmp) {
+ xdebug_str_add(&str, tmp, 1);
+ }
+ XG(dumped) = 1;
}
if (XG(show_local_vars) && XG(stack) && XDEBUG_LLIST_TAIL(XG(stack))) {
@@ -1735,11 +1739,11 @@ static char* get_printable_stack(int html, const char *error_type_str, char *buf
return str.d;
}
-static void print_stack(int html, const char *error_type_str, char *buffer, const char *error_filename, const int error_lineno, int log_only TSRMLS_DC)
+static void print_stack(int html, const char *error_type_str, char *buffer, const char *error_filename, const int error_lineno TSRMLS_DC)
{
char *printable_stack;
- printable_stack = get_printable_stack(html, error_type_str, buffer, error_filename, error_lineno, log_only TSRMLS_CC);
+ printable_stack = get_printable_stack(html, error_type_str, buffer, error_filename, error_lineno TSRMLS_CC);
php_printf("%s", printable_stack);
xdfree(printable_stack);
}
@@ -1925,7 +1929,6 @@ void xdebug_throw_exception_hook(zval *exception TSRMLS_DC)
zval *message, *file, *line;
zend_class_entry *default_ce, *exception_ce;
xdebug_brk_info *extra_brk_info;
- int do_exception = 0;
if (!exception) {
return;
@@ -1943,7 +1946,10 @@ void xdebug_throw_exception_hook(zval *exception TSRMLS_DC)
line = zend_read_property(default_ce, exception, "line", sizeof("line")-1, 0 TSRMLS_CC);
if (XG(show_ex_trace)) {
- print_stack(!(strcmp("cli", sapi_module.name) == 0), exception_ce->name, Z_STRVAL_P(message), Z_STRVAL_P(file), Z_LVAL_P(line), !PG(display_errors) TSRMLS_CC);
+ log_stack(exception_ce->name, Z_STRVAL_P(message), Z_STRVAL_P(file), Z_LVAL_P(line) TSRMLS_CC);
+ if (PG(display_errors)) {
+ print_stack(PG(html_errors), exception_ce->name, Z_STRVAL_P(message), Z_STRVAL_P(file), Z_LVAL_P(line) TSRMLS_CC);
+ }
}
/* Start JIT if requested and not yet enabled */
@@ -2052,7 +2058,10 @@ void xdebug_error_cb(int type, const char *error_filename, const uint error_line
}
if ((EG(error_reporting) & type)) { /* Otherwise print the default stack trace */
- print_stack(!(strcmp("cli", sapi_module.name) == 0), error_type_str, buffer, error_filename, error_lineno, !PG(display_errors) TSRMLS_CC);
+ log_stack(error_type_str, buffer, error_filename, error_lineno TSRMLS_CC);
+ if (PG(display_errors)) {
+ print_stack(PG(html_errors), error_type_str, buffer, error_filename, error_lineno TSRMLS_CC);
+ }
}
/* Check for the pseudo exceptions to allow breakpoints on PHP error statusses */
@@ -2197,7 +2206,7 @@ PHP_FUNCTION(xdebug_print_function_stack)
function_stack_entry *i;
i = xdebug_get_stack_frame(0 TSRMLS_CC);
- print_stack(!(strcmp("cli", sapi_module.name) == 0), "Xdebug", "user triggered", i->filename, i->lineno, 0 TSRMLS_CC);
+ print_stack(PG(html_errors), "Xdebug", "user triggered", i->filename, i->lineno TSRMLS_CC);
}
/* }}} */
@@ -112,7 +112,7 @@ static zend_brk_cont_element* xdebug_find_brk_cont(zval *nest_levels_zval, int a
return jmp_to;
}
-static int xdebug_find_jump(zend_op_array *opa, unsigned int position, unsigned int *jmp1, unsigned int *jmp2)
+static int xdebug_find_jump(zend_op_array *opa, unsigned int position, int *jmp1, int *jmp2)
{
zend_uint base_address = (zend_uint) &(opa->opcodes[0]);
@@ -151,7 +151,6 @@ static int xdebug_find_jump(zend_op_array *opa, unsigned int position, unsigned
static void xdebug_analyse_branch(zend_op_array *opa, unsigned int position, xdebug_set *set)
{
- unsigned int jump_found = 0;
int jump_pos1 = -1;
int jump_pos2 = -1;
@@ -205,7 +204,6 @@ static void xdebug_analyse_branch(zend_op_array *opa, unsigned int position, xde
static void prefil_from_oparray(function_stack_entry *fse, char *fn, zend_op_array *opa TSRMLS_DC)
{
unsigned int i;
- zend_uint base_address = (zend_uint) &(opa->opcodes[0]);
xdebug_set *set = NULL;
#ifdef ZEND_ENGINE_2
@@ -237,7 +235,6 @@ static void prefil_from_oparray(function_stack_entry *fse, char *fn, zend_op_arr
static int prefil_from_function_table(zend_op_array *opa, int num_args, va_list args, zend_hash_key *hash_key)
{
char *new_filename;
- unsigned int i;
TSRMLS_FETCH();
new_filename = va_arg(args, char*);
@@ -275,12 +272,11 @@ static int prefil_from_class_table(zend_class_entry *class_entry, int num_args,
void xdebug_prefil_code_coverage(function_stack_entry *fse, zend_op_array *op_array TSRMLS_DC)
{
- unsigned int i;
char cache_key[64];
int cache_key_len;
void *dummy;
- cache_key_len = snprintf(&cache_key, 63, "%X", op_array);
+ cache_key_len = snprintf(cache_key, sizeof(cache_key) - 1, "%p", op_array);
if (xdebug_hash_find(XG(code_coverage_op_array_cache), cache_key, cache_key_len, (void*) &dummy)) {
return;
}
View
@@ -1071,7 +1071,7 @@ DBGP_FUNC(breakpoint_set)
/* Perhaps we have a break condition */
if (CMD_OPTION('-')) {
- brk_info->condition = xdebug_base64_decode(CMD_OPTION('-'), strlen(CMD_OPTION('-')), &new_length);
+ brk_info->condition = (char*) xdebug_base64_decode((unsigned char*) CMD_OPTION('-'), strlen(CMD_OPTION('-')), &new_length);
}
tmp_name = xdebug_sprintf("%s$%lu", brk_info->file, brk_info->lineno);
@@ -1139,7 +1139,7 @@ DBGP_FUNC(breakpoint_set)
xdebug_xml_add_attribute_ex(*retval, "id", xdebug_sprintf("%d", brk_id), 0, 1);
}
-static int _xdebug_do_eval(unsigned char *eval_string, zval *ret_zval TSRMLS_DC)
+static int _xdebug_do_eval(char *eval_string, zval *ret_zval TSRMLS_DC)
{
int old_error_reporting;
int res;
@@ -1161,7 +1161,7 @@ static int _xdebug_do_eval(unsigned char *eval_string, zval *ret_zval TSRMLS_DC)
DBGP_FUNC(eval)
{
- unsigned char *eval_string;
+ char *eval_string;
xdebug_xml_node *ret_xml;
zval ret_zval;
int new_length;
@@ -1175,7 +1175,7 @@ DBGP_FUNC(eval)
options = (xdebug_var_export_options*) context->options;
/* base64 decode eval string */
- eval_string = xdebug_base64_decode(CMD_OPTION('-'), strlen(CMD_OPTION('-')), &new_length);
+ eval_string = (char*) xdebug_base64_decode((unsigned char*) CMD_OPTION('-'), strlen(CMD_OPTION('-')), &new_length);
res = _xdebug_do_eval(eval_string, &ret_zval TSRMLS_CC);
@@ -1624,7 +1624,7 @@ DBGP_FUNC(property_set)
}
/* base64 decode eval string */
- new_value = xdebug_base64_decode(data, strlen(data), &new_length);
+ new_value = (char*) xdebug_base64_decode((unsigned char*) data, strlen(data), &new_length);
eval_string = xdebug_sprintf("%s = %s", name, new_value);
res = _xdebug_do_eval(eval_string, &ret_zval TSRMLS_CC);
@@ -2061,7 +2061,7 @@ int xdebug_dbgp_parse_option(xdebug_con *context, char* line, int flags, xdebug_
char *xdebug_dbgp_get_revision(void)
{
- return "$Revision: 1.98 $";
+ return "$Revision: 1.99 $";
}
int xdebug_dbgp_cmdloop(xdebug_con *context TSRMLS_DC)
View
@@ -283,7 +283,7 @@ static int xdebug_print_aggr_entry(void *pDest, void *argument TSRMLS_DC)
#endif
if (strcmp(xae->function, "{main}") == 0) {
#if HAVE_PHP_MEMORY_USAGE
- fprintf(fp, "\nsummary: %lu %u\n\n", (unsigned long) (xae->time_inclusive * 10000000), (xae->mem_used));
+ fprintf(fp, "\nsummary: %lu %lu\n\n", (unsigned long) (xae->time_inclusive * 10000000), (xae->mem_used));
#else
fprintf(fp, "\nsummary: %lu\n\n", (unsigned long) (xae->time_inclusive * 10000000), (xae->mem_used));
#endif
View
@@ -15,7 +15,7 @@
| Authors: Derick Rethans <derick@xdebug.org> |
+----------------------------------------------------------------------+
*/
-/* $Id: xdebug_set.c,v 1.1 2006-09-25 20:20:01 derick Exp $ */
+/* $Id: xdebug_set.c,v 1.2 2006-10-07 23:10:32 derick Exp $ */
#include <stdlib.h>
#include <math.h>
@@ -41,9 +41,9 @@ void xdebug_set_free(xdebug_set *set)
void xdebug_set_add(xdebug_set *set, unsigned int position)
{
- char *byte;
- unsigned int bit;
-
+ unsigned char *byte;
+ unsigned int bit;
+
byte = &(set->setinfo[position / 8]);
bit = position % 8;
@@ -52,8 +52,8 @@ void xdebug_set_add(xdebug_set *set, unsigned int position)
void xdebug_set_remove(xdebug_set *set, unsigned int position)
{
- char *byte;
- unsigned int bit;
+ unsigned char *byte;
+ unsigned int bit;
byte = &(set->setinfo[position / 8]);
bit = position % 8;
@@ -63,8 +63,8 @@ void xdebug_set_remove(xdebug_set *set, unsigned int position)
int xdebug_set_in_ex(xdebug_set *set, unsigned int position, int noisy)
{
- char *byte;
- unsigned int bit;
+ unsigned char *byte;
+ unsigned int bit;
byte = &(set->setinfo[position / 8]);
bit = position % 8;
View
@@ -15,7 +15,7 @@
| Authors: Derick Rethans <derick@xdebug.org> |
+----------------------------------------------------------------------+
*/
-/* $Id: xdebug_set.h,v 1.1 2006-09-25 20:20:01 derick Exp $ */
+/* $Id: xdebug_set.h,v 1.2 2006-10-07 23:10:32 derick Exp $ */
#ifndef __XDEBUG_SET_H__
#define __XDEBUG_SET_H__
@@ -31,5 +31,6 @@ void xdebug_set_remove(xdebug_set *set, unsigned int position);
#define xdebug_set_in(x,y) xdebug_set_in_ex(x,y,1)
int xdebug_set_in_ex(xdebug_set *set, unsigned int position, int noisy);
void xdebug_set_dump(xdebug_set *set);
+void xdebug_set_free(xdebug_set *set);
#endif
@@ -31,7 +31,6 @@ void xdebug_superglobals_dump_dtor(void *user, void *ptr)
static void dump_hash_elem(zval *z, char *name, long index, char *elem, int html, xdebug_str *str TSRMLS_DC)
{
- char buffer[1024];
int len;
if (html) {
@@ -155,12 +154,6 @@ char* xdebug_get_printable_superglobals(int html TSRMLS_DC)
{
xdebug_str str = {0, 0, NULL};
- if (XG(dump_once) && XG(dumped)) {
- return;
- }
-
- XG(dumped) = 1;
-
dump_hash(&XG(server), "_SERVER", 8, html, &str TSRMLS_CC);
dump_hash(&XG(get), "_GET", 5, html, &str TSRMLS_CC);
dump_hash(&XG(post), "_POST", 6, html, &str TSRMLS_CC);
@@ -200,7 +193,6 @@ void xdebug_superglobals_dump_tok(xdebug_llist *l, char *str)
PHP_FUNCTION(xdebug_dump_superglobals)
{
- int is_cli = (strcmp("cli", sapi_module.name) == 0);
int html = PG(html_errors);
if (html) {
Oops, something went wrong.

0 comments on commit 170b02f

Please sign in to comment.