Generators should show original name in backtrace

Use the original name instead of the outer name for generator
functions in backtraces
Esse commit está contido em:
seanc
2013-03-29 15:19:41 -07:00
commit de Sara Golemon
commit 4a6ae52f5d
4 arquivos alterados com 76 adições e 4 exclusões
+11 -4
Ver Arquivo
@@ -2390,7 +2390,14 @@ Array VMExecutionContext::debugBacktrace(bool skip /* = false */,
prevFp->m_func->unit()->getLineNumber(pc), true);
}
// check for include
StringData *funcname = const_cast<StringData*>(fp->m_func->name());
String funcname = const_cast<StringData*>(fp->m_func->name());
if (fp->m_func->isGenerator()) {
// retrieve the original function name from the inner continuation
TypedValue* tv = frame_local(fp, 0);
assert(tv->m_type == HPHP::KindOfObject);
funcname = static_cast<c_Continuation*>(
tv->m_data.pobj)->t_getorigfuncname();
}
if (fp->m_func->isClosureBody()) {
static StringData* s_closure_label =
StringData::GetStaticString("{closure}");
@@ -2401,8 +2408,8 @@ Array VMExecutionContext::debugBacktrace(bool skip /* = false */,
if (!prevFp) continue;
funcname = s_include;
}
frame.set(String(s_function), String(funcname), true);
if (funcname != s_include) {
frame.set(String(s_function), funcname, true);
if (!funcname.same(s_include)) {
// Closures have an m_this but they aren't in object context
Class* ctx = arGetContextClass(fp);
if (ctx != nullptr && !fp->m_func->isClosureBody()) {
@@ -2418,7 +2425,7 @@ Array VMExecutionContext::debugBacktrace(bool skip /* = false */,
}
}
Array args = Array::Create();
if (funcname == s_include) {
if (funcname.same(s_include)) {
if (depth) {
args.append(String(const_cast<StringData*>(
fp->m_func->unit()->filepath())));
@@ -0,0 +1,13 @@
<?php
function my_generator() {
$value = yield null;
var_dump(debug_backtrace());
}
function my_wrapper() {
$gen = my_generator();
$gen->next();
$gen->send(null);
}
my_wrapper();
@@ -0,0 +1,50 @@
array(3) {
[0]=>
array(4) {
["file"]=>
string(0) ""
["line"]=>
int(-1)
["function"]=>
string(12) "my_generator"
["args"]=>
array(1) {
[0]=>
object(Continuation)#1 (0) {
}
}
}
[1]=>
array(7) {
["file"]=>
string() "hphp/test/vm/debug_backtrace_continuation.php"
["line"]=>
int(10)
["function"]=>
string(4) "send"
["class"]=>
string(12) "Continuation"
["object"]=>
object(Continuation)#1 (0) {
}
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
NULL
}
}
[2]=>
array(4) {
["file"]=>
string() "hphp/test/vm/debug_backtrace_continuation.php"
["line"]=>
int(13)
["function"]=>
string(10) "my_wrapper"
["args"]=>
array(0) {
}
}
}
+2
Ver Arquivo
@@ -0,0 +1,2 @@
#!/bin/bash
sed -e 's/string(.*) ".*\/hphp/string() "hphp/g'