【问题标题】:Graphviz doesn't understand GCC outputGraphviz 不理解 GCC 输出
【发布时间】:2021-04-27 16:29:32
【问题描述】:

跑步

gcc -fdump-tree-all-graph main.cpp -o main

应该产生可读的点文件。但是,运行

dot .\main.cpp.027t.einline -Tpng -o "main.png"

在任何生成的点文件上都会导致错误

Error: .\main.cpp.013t.cfg.dot: syntax error in line 1 near 'subgraph'

GCC 版本:10.2.0 Graphviz 版本:2.47.0

对于所有 C/C++ 文件,此问题仍然存在。我做错了什么?

编辑:通用 C++ 程序

int main() {}

创建 15 个点文件,所有这些文件看起来都类似于:

subgraph "cluster_main" {
    style="dashed";
    color="black";
    label="main ()";
    fn_0_basic_block_0 [shape=Mdiamond,style=filled,fillcolor=white,label="ENTRY"];

    fn_0_basic_block_1 [shape=Mdiamond,style=filled,fillcolor=white,label="EXIT"];

    fn_0_basic_block_2 [shape=record,style=filled,fillcolor=lightgrey,label="{\<bb\ 2\>:\l\
|D.2331\ =\ 0;\l\
}"];

    fn_0_basic_block_3 [shape=record,style=filled,fillcolor=lightgrey,label="{\<bb\ 3\>:\l\
|\<L0\>:\l\
|return\ D.2331;\l\
}"];

    fn_0_basic_block_0:s -> fn_0_basic_block_2:n [style="solid,bold",color=blue,weight=100,constraint=true];
    fn_0_basic_block_2:s -> fn_0_basic_block_3:n [style="solid,bold",color=blue,weight=100,constraint=true];
    fn_0_basic_block_3:s -> fn_0_basic_block_1:n [style="solid,bold",color=black,weight=10,constraint=true];
    fn_0_basic_block_0:s -> fn_0_basic_block_1:n [style="invis",constraint=true];
}
}

【问题讨论】:

  • syntax error in line 1 near 'subgraph' 显示head main.cpp.013t.cfg.dot。或者整个文件,如果它很短
  • 使用 Graphviz 2.43.0 为我工作。
  • 哪个平台,看起来像windows?发布版本还是调试?自编译或打包(从哪里)?对我来说适用于 dot 版本 2.47.0 的小程序。就像 KamilCuk 说的,请显示点文件并输入 cpp 文件。
  • Head of the dot-File 哪个点文件?应该有14个。 looks like this: 奇怪,点文件无效.. :/ 。它应该以digraph "main.c.013..." { 开头。然后重新创建会产生相同的点文件吗?您能否显示整个文件 - 也许下面有一个 digraph 关键字?你能像把它移到一个不同的文件系统然后试试吗? main.cpp 的内容是否重要,比如int main() {} 文件也有问题?

标签: gcc graphviz dot


【解决方案1】:

不是答案,但评论有点长

使用程序时:

int main() {}

命令:

gcc -fdump-tree-all-graph main.cpp -o main

我得到一个文件:main.cpp.027t.einline.dotwith content:

digraph "main.cpp.027t.einline" {
overlap=false;
subgraph "cluster_main" {
        style="dashed";
        color="black";
        label="main ()";
        fn_0_basic_block_0 [shape=Mdiamond,style=filled,fillcolor=white,label="ENTRY"];

        fn_0_basic_block_1 [shape=Mdiamond,style=filled,fillcolor=white,label="EXIT"];

        fn_0_basic_block_2 [shape=record,style=filled,fillcolor=lightgrey,label="{\<bb\ 2\>:\l\
|_1\ =\ 0;\l\
}"];

        fn_0_basic_block_3 [shape=record,style=filled,fillcolor=lightgrey,label="{\<bb\ 3\>:\l\
|\<L0\>:\l\
|return\ _1;\l\
}"];

        fn_0_basic_block_0:s -> fn_0_basic_block_2:n [style="solid,bold",color=blue,weight=100,constraint=true];
        fn_0_basic_block_2:s -> fn_0_basic_block_3:n [style="solid,bold",color=blue,weight=100,constraint=true];
        fn_0_basic_block_3:s -> fn_0_basic_block_1:n [style="solid,bold",color=black,weight=10,constraint=true];
        fn_0_basic_block_0:s -> fn_0_basic_block_1:n [style="invis",constraint=true];
}
}

在 Cygwin 上使用:

gcc (GCC) 10.2.0

所以这对我来说一切正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-02-23
    • 2011-01-06
    • 1970-01-01
    • 1970-01-01
    • 2018-06-13
    • 2011-03-13
    • 2021-03-19
    相关资源
    最近更新 更多