【问题标题】:Trying to understand GCC-XML OutPut Variables Meaning试图理解 GCC-XML 输出变量的含义
【发布时间】:2012-07-03 17:24:00
【问题描述】:

当我在 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) 代表什么?我没有找到任何有用的文档或输出解释,因此非常感谢任何提示。

【问题讨论】:

  • 这是GCCXML的完整输出吗?
  • 不,这只是试图解释我的问题的一部分

标签: c++ python xml gcc wrapper


【解决方案1】:

这些数字是文件中其他内容的标识符。为了了解_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函数的attributes元素:

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

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

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

那意思应该很明显了:_5int的类型:所以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 &amp;

我希望现在更有意义。

【讨论】:

  • 您的猜测肯定是正确的,这 _255 可能代表(int 或 float ..etc),但是您找到一个 id="_253" 的 XML 元素是什么意思,您能解释一下吗?我需要能够说好的 _255 例如是 int 而 _256 是 float。
  • 我需要一个恒定的解码规则来遵循
  • @MicHans:请参阅添加到我的答案中的完整示例。
  • 非常感谢。明天我会检查它,因为我现在无法访问该文件,我会告诉你。但是非常感谢这个例子,事情开始变得有意义我非常感谢你的帮助。
猜你喜欢
  • 1970-01-01
  • 2016-08-25
  • 1970-01-01
  • 2019-12-23
  • 1970-01-01
  • 2018-11-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多