From f566a6136bbd4fd4f3afeaeccb666bd7806562b8 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Tue, 12 Nov 2013 06:43:23 +0000 Subject: [PATCH] additional list option, class methods --- phpdbg_help.c | 4 +++- phpdbg_prompt.c | 26 ++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/phpdbg_help.c b/phpdbg_help.c index d942ebeb61..b887380d07 100644 --- a/phpdbg_help.c +++ b/phpdbg_help.c @@ -141,7 +141,9 @@ PHPDBG_HELP(list) /* {{{ */ printf("\tphpdbg> list 2\n"); printf("Will print next 2 lines from the current file\n"); printf("\tphpdbg> list func\n"); - printf("Will print func source code\n"); + printf("Will print the source of the global function \"func\"\n"); + printf("\tphpdbg> list .mine\n"); + printf("Will print the source of the class method \"mine\"\n"); printf("Note: before listing functions you must have a populated function table, try compile !!\n"); return SUCCESS; } /* }}} */ diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 72d9023912..d42e638b51 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -547,22 +547,40 @@ static PHPDBG_COMMAND(list) /* {{{ */ phpdbg_list_file(filename, count, offset TSRMLS_CC); } else { + HashTable *func_table = EG(function_table); zend_function* fbc; + const char *func_name = expr; + size_t func_name_len = expr_len; - if (!EG(function_table)) { + /* search active scope if begins with period */ + if (func_name[0] == '.') { + if (EG(scope)) { + func_name++; + func_name_len--; + + func_table = &EG(scope)->function_table; + } else { + printf( + "%sNo active class%s\n", + PHPDBG_RED_LINE(TSRMLS_C), PHPDBG_END_LINE(TSRMLS_C)); + return FAILURE; + } + } else if (!EG(function_table)) { printf( "%sNo function table loaded%s\n", PHPDBG_RED_LINE(TSRMLS_C), PHPDBG_END_LINE(TSRMLS_C)); return SUCCESS; + } else { + func_table = EG(function_table); } - - if (zend_hash_find(EG(function_table), expr, expr_len, + + if (zend_hash_find(func_table, func_name, func_name_len, (void**)&fbc) == SUCCESS) { phpdbg_list_function(fbc TSRMLS_CC); } else { printf( "%sFunction %s not found%s\n", - PHPDBG_RED_LINE(TSRMLS_C), expr, PHPDBG_END_LINE(TSRMLS_C)); + PHPDBG_RED_LINE(TSRMLS_C), func_name, PHPDBG_END_LINE(TSRMLS_C)); } } -- 2.50.1