summaryrefslogtreecommitdiff
path: root/Zend/zend_builtin_functions.c
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/zend_builtin_functions.c')
-rw-r--r--Zend/zend_builtin_functions.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 0f30efb30e..fc5bd14584 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -1188,23 +1188,33 @@ ZEND_FUNCTION(debug_backtrace)
{
zend_execute_data *ptr;
int lineno;
-
+ char *function_name;
+ char *filename;
ptr = EG(current_execute_data);
lineno = ptr->opline->lineno;
-
- ptr = ptr->prev_execute_data;
-
+
while (ptr) {
if (ptr->object) {
printf("%s::", Z_OBJCE(*ptr->object)->name);
}
- printf("%s() [%s:%d]\n", ptr->function_state.function->common.function_name, ptr->function_state.function->op_array.filename, lineno);
- lineno = ptr->opline->lineno;
+ function_name = ptr->function_state.function->common.function_name;
+ if (!function_name) {
+ function_name = "main";
+ }
+
ptr = ptr->prev_execute_data;
+ if (!ptr) {
+ break;
+ }
+
+ filename = ptr->function_state.function->op_array.filename;
+
+ printf("%s() [%s:%d]\n", function_name, filename, lineno);
+ if (ptr->opline) {
+ lineno = ptr->opline->lineno;
+ }
}
-
- printf("main() [...:%d]\n", lineno);
RETURN_TRUE;
}