dow98764 2016-10-28 05:52
浏览 107
已采纳

qcachegrind错误:未知的文件格式。 从php xdebug生成的文件

I am attempting to use xdebug to profile an application written in php7.

I've written a script that sets the follow ini settings:

ini_set('xdebug.trace_format',1); // Note: I tried 0 and 2 here as well
ini_set('xdebug.profiler_enable',1);
xdebug_start_trace('/tmp/cachegrind.out');
// RUN CODE HERE
xdebug_stop_trace();

Running the script created the cachegrind files as I would expect:

root@host:/# ls /tmp | grep cachegrind
cachegrind.out.0028fd.xt
cachegrind.out.0072ab.xt
cachegrind.out.009b09.xt
cachegrind.out.025ac3.xt

Here is the first few lines of a cachegrind file so that the format is visible:

Version: 2.4.1
File format: 4
TRACE START [2016-10-28 05:26:57]
2   3784    1   0.242945    2692856
2   3785    0   0.242955    2692800 DI\Container->set   1       /path/public/api/index.php   100
2   3785    1   0.242966    2692800
2   3786    0   0.242973    2692800 spl_autoload_call   0       /path/public/api/index.php   103
3   3787    0   0.242982    2692896 Fuel\Core\Autoloader::load  1       /path/public/api/index.php   103
4   3788    0   0.242990    2692896 strpos  0       /path/fuel/core/classes/autoloader.php   219

However, when I try to open this file in qcachegrind, it fails to open:

enter image description here

The error message reads: "Error loading /path/to/cachegrind/file: Unknown file format

Anyone know what's going on here? I'd like to be able to use a tool like this to profile my application.

I also shelled out $30 to try opening the file in MCG but that app crashes immediately upon opening any of these files.

As a side note, the file is fairly large, but not so large that I'd expect apps to be freaking out:

❯ ls -al /Users/johnpc/repos/cachegrind.out.094ffa.xt
-rw-r--r--  1 johnpc  staff  62744095 Oct 28 02:13 /Users/johnpc/repos/cachegrind.out.094ffa.xt
  • 写回答

1条回答 默认 最新

  • douqu2712 2016-10-28 07:59
    关注

    that file is a trace file not a callgrind file.

    i seems you set trace_output_name and profiler_output_name in the ini to the same string or trying to open the wrong file. you need to set the profiling_* variables in the ini. see: "Profiling PHP Scripts" in the xdebug docs

    a sample profiling output looks like this:

        version: 1
        creator: xdebug 2.1.1rc1
        cmd: /Users/foo/bar/test1.php
        part: 1
        positions: line
    
        events: Time
    
        fl=php:internal
        fn=php::microtime
    

    when you get problems because of the file size, you could also try the app from profilingviewer.com

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 STM32 INMP441无法读取数据
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。
  • ¥15 各位 帮我看看如何写代码,打出来的图形要和如下图呈现的一样,急
  • ¥30 c#打开word开启修订并实时显示批注
  • ¥15 如何解决ldsc的这条报错/index error
  • ¥15 VS2022+WDK驱动开发环境