中断Xdebug中的属性更改 [英] Break on property change in Xdebug

查看:67
本文介绍了中断Xdebug中的属性更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出某个对象的某些属性在哪里被修改了.由于PHP具有高度动态性($o->$prop = $val等),因此实际上不可能通过简单的代码分析来完成.有没有一种方法可以启动调试会话并在修改属性的行处中断? (在简单的情况下,通过条件调用xdebug_break()向类添加魔术__set可能会有所帮助,但是如果该类或其祖先之一已经具有魔术设置器,则它会变得非常复杂,因此这不是一个好的解决方案要么.

I'm trying to find out where a certain property of a certain object gets modified. Due to PHP's highly dynamic nature ($o->$prop = $val and such) this is practically impossible to do by simple code analysis. Is there a way to start a debugging session and break at the line where the property gets modified? (Adding a magic __set with a conditional xdebug_break() call to the class might help in simple cases, but if the class or one of its ancestors already has a magic setter, it can get very complicated, so that's not a good solution either.)

推荐答案

根据xdebug文档,看来应该是一种打破变量更改的方法. http://xdebug.org/docs-dbgp.php#breakpoints

According to the xdebug documentation, it seems like there should be a way to break on a variable change. http://xdebug.org/docs-dbgp.php#breakpoints

watch:写入变量或由地址定义的地址时中断 表达式参数

watch: break on write of the variable or address defined by the expression argument

但是源代码表明该文档领先于其实际功能: https://github.com/xdebug/xdebug/blob/master/xdebug_handler_dbgp .c#L875

But the source code indicates that the documentation is ahead of its actual functionality: https://github.com/xdebug/xdebug/blob/master/xdebug_handler_dbgp.c#L875

if (strcmp(CMD_OPTION('t'), "watch") == 0) {
        RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_BREAKPOINT_TYPE_NOT_SUPPORTED);
    }

我实际上无法在回购中的其他任何地方找到字符串"watch",因此我认为目前不支持该字符串.

I wasn't actually able to find the string 'watch' anywhere else in the repo, so my assumption is that it's currently unsupported.

Xdebug的错误跟踪器中似乎存在该错误:

There appears to be the bug in Xdebug's bug tracker:

http://bugs.xdebug.org/view.php?id=514

这篇关于中断Xdebug中的属性更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆