php - 有没有办法增加 xdebug 配置文件调用树深度?

标签 php xdebug

我正在尝试使用 xdebug 来确定导致页面加载缓慢的原因,并且探查器快照在调用树选项卡中没有显示足够的深度(我正在使用 PhpStorm)。

调用树选项卡如下所示:

index.php
  ..
  ..
  my_file.php
    function1
    function2
    ...

它显示 my_file.php 占用了超过 90% 的时间,但它在调用树中的深入程度不够,我无法看到哪些函数占用了时间。我主要可以从执行统计选项卡中弄清楚这一点,该选项卡显示每个单独的函数,但如果调用树选项卡能更深入,那就太好了。

是否有允许这样做的设置?

这是我的 xdebug 设置:

[xdebug]
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_name = "callgrind.out.%t-%s"
xdebug.profiler_output_dir = "E:\wamp\www\xdebug_profiler"
xdebug.max_nesting_level = 500
xdebug.var_display_max_depth = 100
xdebug.var_display_max_data = 1024

最佳答案

编辑

我刚刚收到 xdebug 的作者 Derick Rethans 的规范答案,看来我的答案确实是正确的!来自 xdebug-general 邮件列表上的信件:

Hi folks,

Is there a limit to the depth of the call stack in the profiling feature of xdebug?

不,没有。

Using PHP Storm as a front end, I can see my_file.php taking over 90% of the time, but the graph doesn't go deep enough in the call tree to see what functions are taking up the time.

我知道 kcachegrind 不会显示占用少于以下内容的内容 默认为 5%。也许 phpstorm 也这样做?

I'm able to see what functions are taking up the most time in the execution statistic tab, however it would be nice to see how the code is arriving at the rogue function call.

对我来说很难看到,没有配置文件,也没有指针作为什么 你会期望...

原始答案

这是一个有趣的问题,很好奇在哪里可能会施加限制。原因是 PHP 内置 debug_backtrace 默认情况下打印整个堆栈跟踪。 $limit参数仅在 5.4 中添加...

此外,浏览 xdebug 源代码时,我没有看到任何会限制调用堆栈集合的值或代码。也就是说,我没有看到任何配置选项可以影响探查器捕获的函数调用数量...

所以简短的回答是

一些想法和建议

  1. 使用执行统计选项卡查找恶意函数。调用die(print_debug_backtrace())来自该函数。这应该会给你一个到所述流氓函数的堆栈跟踪。
  2. 再次使用执行统计选项卡查找流氓函数,使用 xdebug 的 function trace feature从那里获取它(不如我知道的cachegrind UI,但代替它......)
  3. 清除 xdebug.profiler_output_dir在收集配置文件时加载页面之前。如果有多个输出文件,请确保在 Cachegrind UI 中检查所有文件。沿着这些思路考虑添加一个随机值 xdebug.profiler_output_name = "callgrind.out.%t-%s-%r"只是为了排除文件相互覆盖的情况(这种情况发生在我身上,一旦您意识到问题所在,就会非常感到沮丧)。
  4. 尝试另一个cachegrind可视化工具。虽然我怀疑这就是问题所在,但谁知道呢,作为最后的手段,我认为值得一试。
  5. 最后,对于规范的答案,您可以在 xdebug 邮件列表上发布 [email protected] ,或者问作者本人。他们建议首先询问 SO,您已经这样做了,因此列表和作者可能会接受询问。详细信息xdebug support page .

关于php - 有没有办法增加 xdebug 配置文件调用树深度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25961502/

相关文章:

php - 如何在用户使用 Jquery 输入期间的明显暂停处启动 AJAX 请求?

php - 关于 preFlush 的循环引用

php - 如何隐藏MySQL查询的行?

来自另一个文件的 PHP 调用函数不起作用

php - 如何在Ubuntu上安装Xdebug?

php - Visual Studio 代码 (VSCode) - 错误 : Debug Adapter Process Has Terminated Unexpectedly

php - 禁用 Xdebug 转储捕获的异常

php - 是什么导致消息 "Failed loading/usr/lib/php/modules/xdebug.so"("No such file or directory")?

xdebug - 无法使用 PhpStorm + Vagrant + XDebug 进行调试

php - 即使我自己创建了用户帐户 PHPMyAdmin,用户的访问仍被拒绝