试图理解GCC-XML输出变量的含义

Trying to understand GCC-XML OutPut Variables Meaning

本文关键字:变量 输出 GCC-XML      更新时间:2023-10-16

当我在GCC_XML上运行头文件时,我会得到以下输出:

<GCC_XML cvs_revision="1.135"><Namespace id="_1" name="::" members="_3 _4 _5 _6 _7 _8 _9 _10 _11 _12 _13 _14 _16 _17 _18 _19 _20 _21 _22 _23 _24 _25 _26 _27 _29 _31 _32 _33 _35 _36 _37 _38 _39 _40 _41 _42 _43 _44 _46 _47 _48 _49 _50 _52 _53 _54 _55 _56 _57 _58 _59 _60 _61 _62 _63 _64 _66 _67 _68 _69 _70 _71 _72 _73 _74 _75 _76 _77 _78 _79 _80 _81 _82 _83 _84 _85 _86 _87 _88 _89 _90 _91 _93 _94 _95 _96 _97 _98 _99 _100 _101 _103 _104 _105 _106 _107 _108 _109 _110 _111 _112 _113 _114 _115 _116 _117 _118 _119 _120 _121 _122 _123 _124 _125 _126 _127 _128 _129 _130 _131 _132 _133 _134 _135 _136 _137 _138 _139 _140 _141 _142 _143 _144 _145 _146 _147 _148 _149 _150 _151 _152 _153 _154 _155 _156 _157 _2 _158 _159 _160 _161 _162 _163 _164 _165 _166 _167 _168 _169 _170 _171 _173 _174 _175 _176 _177 _178 _179 _181 _182 _183 _184 _185 _186 _187 _188 _189 _190 _191 _192 _193 _194 _195 _196 _197 _198 _200 _201 _202 _203 _204 _205 _206 _207 _208 _209 _210 _211 _212 _213 _214 _216 _217 _218 _219 _220 _221 _222 _223 _224 _225 _226 _227 _228 _229 _230 _231 _232 _233 _234 _235 _236 _237 _238 _239 _240 _241 _242 _243 _244 _245 _246 _247 _248 _249 _250 _252 " mangled="_Z2::" demangled="::"/>
<Namespace id="_2" name="std" context="_1" members="" mangled="_Z3std" demangled="std"/>
<Function id="_3" name="__builtin_nans" returns="_253" context="_1" location="f0:21" file="f0" line="21" extern="1" attributes="nothrow const nonnull">
<Argument name="str" type="_254" location="f0:21" file="f0" line="21"/>
</Function><Function id="_4" name="__builtin_acosf" returns="_255" context="_1" mangled="acosf" location="f0:25" file="f0" line="25" extern="1" attributes="nothrow"><Argument type="_255" location="f0:25" file="f0" line="25"/></Function>
<Function id="_5" name="__builtin_acosl" returns="_256" context="_1" mangled="acosl" location="f0:26" file="f0" line="26" extern="1" attributes="nothrow"><Argument type="_256" location="f0:26" file="f0" line="26"/></Function><Function id="_6" name="__builtin_va_arg_pack" returns="_257" context="_1" location="f0:147" file="f0" line="147" extern="1"><Ellipsis/></Function>
<Function id="_7" name="__builtin_log10" returns="_253" context="_1" mangled="log10" location="f0:63" file="f0" line="63" extern="1" attributes="nothrow">
<Argument type="_253" location="f0:63" file="f0" line="63"/>

现在我的主要问题是这些值代表什么,例如,我得到Argument type="_253"(_253(代表什么?我找不到任何有用的文档或对输出的解释,所以任何提示都将不胜感激。

这些数字是文件中其他内容的标识符。为了了解_253,您必须找到一个具有id="_253"的XML元素。它很可能是一个类型定义或内置类型。

示例

此CXX:

struct EmptyClass {};
int a_function(float f, EmptyClass e)
{
}
int main(void)
{
  return 0;
}

编译成以下XML:

<?xml version="1.0"?>
<GCC_XML>
  <Namespace id="_1" name="::" members="_2 _3 _4 "/>
  <Function id="_2" name="main" returns="_5" context="_1" location="f0:8"/>
  <Function id="_3" name="a_function" returns="_5" context="_1" location="f0:4">
    <Argument name="f" type="_6"/>
    <Argument name="e" type="_4"/>
  </Function>
  <Struct id="_4" name="EmptyClass" context="_1" location="f0:1" members="_7 _8 " bases=""/>
  <FundamentalType id="_5" name="int"/>
  <FundamentalType id="_6" name="float"/>
  <Constructor id="_7" name="EmptyClass" context="_4" location="f0:1">
    <Argument name="_ctor_arg" type="_9"/>
  </Constructor>
  <Constructor id="_8" name="EmptyClass" context="_4" location="f0:1"/>
  <ReferenceType id="_9" type="_4c"/>
  <File id="f0" name="example1.cxx"/>
</GCC_XML>

如果您查看函数main:的属性元素

  <Function id="_2" name="main" returns="_5" context="_1" location="f0:8"/>

它的返回类型是returns="_5",所以您必须在XML中找到一个具有id="_5"的元素。请注意,它可能在之前的,也可能在您当前查看的之后的.还请注意,编译器的不同运行可能会为相同类型产生不同的标识符。在这种情况下:

<FundamentalType id="_5" name="int"/>

其含义应该是显而易见的:_5是类型int:所以main返回int

一种不同的类型来自:

<ReferenceType id="_9" type="_4c"/>

这是对类型id="_4c"的引用,但没有这样的类型。id="_4"类型的const版本(即c(很简单:

<Struct id="_4" name="EmptyClass" context="_1" location="f0:1" members="_7 _8 " bases=""/>

因此类型id="_9"是对名为"EmptyClass"的常量结构的引用,即const EmptyClass &

我希望这现在更有意义。