summaryrefslogtreecommitdiff
path: root/sapi/phpdbg/phpdbg_frame.c
diff options
context:
space:
mode:
authorFerenc Kovacs <tyrael@php.net>2014-11-26 18:38:36 +0100
committerFerenc Kovacs <tyrael@php.net>2014-11-26 18:38:36 +0100
commit0afc04b91394a2b8d3d33531810ee0256088408d (patch)
tree6d2200f8d41cfff450df09bdc4b4f2802567b8d7 /sapi/phpdbg/phpdbg_frame.c
parentfa2a2a105900e36f8882093c8c48e0ecfeb4b3ac (diff)
downloadphp-git-0afc04b91394a2b8d3d33531810ee0256088408d.tar.gz
go back with phpdbg to the state of 5.6.3, reverting the controversial commits(remote debugging/xml protocol)
Diffstat (limited to 'sapi/phpdbg/phpdbg_frame.c')
-rw-r--r--sapi/phpdbg/phpdbg_frame.c141
1 files changed, 48 insertions, 93 deletions
diff --git a/sapi/phpdbg/phpdbg_frame.c b/sapi/phpdbg/phpdbg_frame.c
index 0506c305dc..a235fe8cb0 100644
--- a/sapi/phpdbg/phpdbg_frame.c
+++ b/sapi/phpdbg/phpdbg_frame.c
@@ -52,27 +52,22 @@ void phpdbg_switch_frame(int frame TSRMLS_DC) /* {{{ */
int i = 0;
if (PHPDBG_FRAME(num) == frame) {
- phpdbg_notice("frame", "id=\"%d\"", "Already in frame #%d", frame);
+ phpdbg_notice("Already in frame #%d", frame);
return;
}
- phpdbg_try_access {
- while (execute_data) {
- if (i++ == frame) {
- break;
- }
-
- do {
- execute_data = execute_data->prev_execute_data;
- } while (execute_data && execute_data->opline == NULL);
+ while (execute_data) {
+ if (i++ == frame) {
+ break;
}
- } phpdbg_catch_access {
- phpdbg_error("signalsegv", "", "Couldn't switch frames, invalid data source");
- return;
- } phpdbg_end_try_access();
+
+ do {
+ execute_data = execute_data->prev_execute_data;
+ } while (execute_data && execute_data->opline == NULL);
+ }
if (execute_data == NULL) {
- phpdbg_error("frame", "type=\"maxnum\" id=\"%d\"", "No frame #%d", frame);
+ phpdbg_error("No frame #%d", frame);
return;
}
@@ -95,7 +90,7 @@ void phpdbg_switch_frame(int frame TSRMLS_DC) /* {{{ */
EG(called_scope) = PHPDBG_EX(current_called_scope);
}
- phpdbg_notice("frame", "id=\"%d\"", "Switched to frame #%d", frame);
+ phpdbg_notice("Switched to frame #%d", frame);
phpdbg_list_file(
zend_get_executed_filename(TSRMLS_C),
3,
@@ -109,84 +104,61 @@ static void phpdbg_dump_prototype(zval **tmp TSRMLS_DC) /* {{{ */
{
zval **funcname, **class, **type, **args, **argstmp;
char is_class;
- int has_args = FAILURE;
- zend_hash_find(Z_ARRVAL_PP(tmp), "function", sizeof("function"), (void **) &funcname);
+ zend_hash_find(Z_ARRVAL_PP(tmp), "function", sizeof("function"),
+ (void **)&funcname);
- if ((is_class = zend_hash_find(Z_ARRVAL_PP(tmp), "object", sizeof("object"), (void **) &class)) == FAILURE) {
- is_class = zend_hash_find(Z_ARRVAL_PP(tmp), "class", sizeof("class"), (void **)&class);
+ if ((is_class = zend_hash_find(Z_ARRVAL_PP(tmp),
+ "object", sizeof("object"), (void **)&class)) == FAILURE) {
+ is_class = zend_hash_find(Z_ARRVAL_PP(tmp), "class", sizeof("class"),
+ (void **)&class);
} else {
- zend_get_object_classname(*class, (const char **) &Z_STRVAL_PP(class), (zend_uint *) &Z_STRLEN_PP(class) TSRMLS_CC);
+ zend_get_object_classname(*class, (const char **)&Z_STRVAL_PP(class),
+ (zend_uint *)&Z_STRLEN_PP(class) TSRMLS_CC);
}
if (is_class == SUCCESS) {
zend_hash_find(Z_ARRVAL_PP(tmp), "type", sizeof("type"), (void **)&type);
}
- has_args = zend_hash_find(Z_ARRVAL_PP(tmp), "args", sizeof("args"), (void **)&args) == SUCCESS;
-
- phpdbg_xml(" symbol=\"%s%s%s\"",
- is_class == FAILURE?"":Z_STRVAL_PP(class),
- is_class == FAILURE?"":Z_STRVAL_PP(type),
- Z_STRVAL_PP(funcname)
- );
- if (has_args) {
- phpdbg_xml(">");
- } else {
- phpdbg_xml(" />");
- }
-
- phpdbg_out("%s%s%s(",
+ phpdbg_write("%s%s%s(",
is_class == FAILURE?"":Z_STRVAL_PP(class),
is_class == FAILURE?"":Z_STRVAL_PP(type),
Z_STRVAL_PP(funcname)
);
- if (has_args) {
+ if (zend_hash_find(Z_ARRVAL_PP(tmp), "args", sizeof("args"),
+ (void **)&args) == SUCCESS) {
HashPosition iterator;
- const zend_function *func = NULL;
- const zend_arg_info *arginfo = NULL;
- int j = 0, m;
+ const zend_function *func = phpdbg_get_function(
+ Z_STRVAL_PP(funcname), is_class == FAILURE ? NULL : Z_STRVAL_PP(class) TSRMLS_CC);
+ const zend_arg_info *arginfo = func ? func->common.arg_info : NULL;
+ int j = 0, m = func ? func->common.num_args : 0;
zend_bool is_variadic = 0;
- phpdbg_try_access {
- /* assuming no autoloader call is necessary, class should have been loaded if it's in backtrace ... */
- if ((func = phpdbg_get_function(Z_STRVAL_PP(funcname), is_class == FAILURE ? NULL : Z_STRVAL_PP(class) TSRMLS_CC))) {
- arginfo = func->common.arg_info;
- }
- } phpdbg_end_try_access();
-
- m = func ? func->common.num_args : 0;
-
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(args), &iterator);
- while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(args), (void **) &argstmp, &iterator) == SUCCESS) {
+ while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(args),
+ (void **) &argstmp, &iterator) == SUCCESS) {
if (j) {
- phpdbg_out(", ");
+ phpdbg_write(", ");
}
- phpdbg_xml("<arg %r");
if (m && j < m) {
#if PHP_VERSION_ID >= 50600
- is_variadic = arginfo ? arginfo[j].is_variadic : 0;
+ is_variadic = arginfo[j].is_variadic;
#endif
- phpdbg_xml(" variadic=\"%s\" name=\"%s\">", is_variadic ? "variadic" : "", arginfo ? arginfo[j].name : "");
- phpdbg_out("%s=%s", arginfo ? arginfo[j].name : "?", is_variadic ? "[": "");
-
- } else {
- phpdbg_xml(">");
+ phpdbg_write("%s=%s",
+ arginfo[j].name, is_variadic ? "[": "");
}
++j;
zend_print_flat_zval_r(*argstmp TSRMLS_CC);
zend_hash_move_forward_ex(Z_ARRVAL_PP(args), &iterator);
-
- phpdbg_xml("</arg>");
}
if (is_variadic) {
- phpdbg_out("]");
+ phpdbg_write("]");
}
- phpdbg_xml("</frame>");
}
- phpdbg_out(")");
+ phpdbg_write(")");
}
void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */
@@ -198,54 +170,37 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */
int i = 0, limit = num;
int user_defined;
- PHPDBG_OUTPUT_BACKUP();
-
if (limit < 0) {
- phpdbg_error("backtrace", "type=\"minnum\"", "Invalid backtrace size %d", limit);
-
- PHPDBG_OUTPUT_BACKUP_RESTORE();
- return;
+ phpdbg_error("Invalid backtrace size %d", limit);
}
- phpdbg_try_access {
- zend_fetch_debug_backtrace(&zbacktrace, 0, 0, limit TSRMLS_CC);
- } phpdbg_catch_access {
- phpdbg_error("signalsegv", "", "Couldn't fetch backtrace, invalid data source");
- return;
- } phpdbg_end_try_access();
-
- phpdbg_xml("<backtrace %r>");
+ zend_fetch_debug_backtrace(
+ &zbacktrace, 0, 0, limit TSRMLS_CC);
zend_hash_internal_pointer_reset_ex(Z_ARRVAL(zbacktrace), &position);
- zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), (void **) &tmp, &position);
+ zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), (void**)&tmp, &position);
while (1) {
- user_defined = zend_hash_find(Z_ARRVAL_PP(tmp), "file", sizeof("file"), (void **) &file);
- zend_hash_find(Z_ARRVAL_PP(tmp), "line", sizeof("line"), (void **) &line);
+ user_defined = zend_hash_find(Z_ARRVAL_PP(tmp), "file", sizeof("file"), (void **)&file);
+ zend_hash_find(Z_ARRVAL_PP(tmp), "line", sizeof("line"), (void **)&line);
zend_hash_move_forward_ex(Z_ARRVAL(zbacktrace), &position);
- if (zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), (void **) &tmp, &position) == FAILURE) {
- phpdbg_write("frame", "id=\"%d\" symbol=\"{main}\" file=\"%s\" line=\"%d\"", "frame #%d: {main} at %s:%ld", i, Z_STRVAL_PP(file), Z_LVAL_PP(line));
+ if (zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace),
+ (void**)&tmp, &position) == FAILURE) {
+ phpdbg_write("frame #%d: {main} at %s:%ld", i, Z_STRVAL_PP(file), Z_LVAL_PP(line));
break;
}
if (user_defined == SUCCESS) {
- phpdbg_out("frame #%d: ", i);
- phpdbg_xml("<frame %r id=\"%d\" file=\"%s\" line=\"%d\"", i, Z_STRVAL_PP(file), Z_LVAL_PP(line));
+ phpdbg_write("frame #%d: ", i++);
phpdbg_dump_prototype(tmp TSRMLS_CC);
- phpdbg_out(" at %s:%ld\n", Z_STRVAL_PP(file), Z_LVAL_PP(line));
- i++;
+ phpdbg_writeln(" at %s:%ld", Z_STRVAL_PP(file), Z_LVAL_PP(line));
} else {
- phpdbg_out(" => ");
- phpdbg_xml("<frame %r id=\"%d\" internal=\"internal\"", i);
+ phpdbg_write(" => ");
phpdbg_dump_prototype(tmp TSRMLS_CC);
- phpdbg_out(" (internal function)\n");
+ phpdbg_writeln(" (internal function)");
}
}
- phpdbg_out("\n");
- phpdbg_xml("</backtrace>");
-
+ phpdbg_writeln(EMPTY);
zval_dtor(&zbacktrace);
-
- PHPDBG_OUTPUT_BACKUP_RESTORE();
} /* }}} */