Skip to content

Commit 2be5a1e

Browse files
committed
Enable backwards reading in list command
1 parent 6932eb7 commit 2be5a1e

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

phpdbg_list.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ PHPDBG_LIST(lines) /* {{{ */
4242
case NUMERIC_PARAM:
4343
case EMPTY_PARAM:
4444
phpdbg_list_file(phpdbg_current_file(TSRMLS_C),
45-
param->type == EMPTY_PARAM ? 0 : param->num,
46-
zend_get_executed_lineno(TSRMLS_C), 0 TSRMLS_CC);
45+
param->type == EMPTY_PARAM ? 0 : (param->num < 0 ? 1 - param->num : param->num),
46+
(param->type != EMPTY_PARAM && param->num < 0 ? param->num : 0) + zend_get_executed_lineno(TSRMLS_C),
47+
0 TSRMLS_CC);
4748
break;
4849
case FILE_PARAM:
4950
phpdbg_list_file(param->file.name, param->file.line, 0, 0 TSRMLS_CC);

phpdbg_prompt.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,10 @@ PHPDBG_COMMAND(back) /* {{{ */
668668
zval **file, **line, **funcname, **class, **type, **args;
669669
char is_class;
670670

671+
if (limit < 0) {
672+
phpdbg_error("Invalid backtrace size %d", limit);
673+
}
674+
671675
zend_fetch_debug_backtrace(
672676
&zbacktrace, 0, 0, limit TSRMLS_CC);
673677

phpdbg_utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ PHPDBG_API int phpdbg_is_numeric(const char *str) /* {{{ */
6969
return 0;
7070

7171
for (; *str; str++) {
72-
if (isspace(*str)) {
72+
if (isspace(*str) || *str == '-') {
7373
continue;
7474
}
7575
return isdigit(*str);

0 commit comments

Comments
 (0)