dwarf を使用して 2 つの C++ ファイルを比較しようとしていますが、非メンバー関数のローカル変数に到達すると問題が発生します。次のコードを検討してください -
int f(){
[static] int j=0;
return j;
}
修飾子なしでコンパイルするとstatic
、次のドワーフ情報が得られます-
<1><eb>: Abbrev Number: 13 (DW_TAG_subprogram)
<ec> DW_AT_external : 1
<ed> DW_AT_name : f
<ef> DW_AT_decl_file : 1
<f0> DW_AT_decl_line : 15
<f1> DW_AT_MIPS_linkage_name: (indirect string, offset: 0x22): _Z1fv
<f5> DW_AT_type : <0xa8>
<f9> DW_AT_low_pc : 0x0
<101> DW_AT_high_pc : 0x10
<109> DW_AT_frame_base : 0x0 (location list)
<10d> DW_AT_sibling : <0x130>
<2><111>: Abbrev Number: 14 (DW_TAG_lexical_block)
<112> DW_AT_low_pc : 0x4
<11a> DW_AT_high_pc : 0xe
<3><122>: Abbrev Number: 15 (DW_TAG_variable)
<123> DW_AT_name : j
<125> DW_AT_decl_file : 1
<126> DW_AT_decl_line : 16
<127> DW_AT_type : <0xa8>
<12b> DW_AT_location : 2 byte block: 91 6c (DW_OP_fbreg: -20)
しかし、修飾子を付けてコンパイルすると、次のようになります-static
<1><eb>: Abbrev Number: 13 (DW_TAG_subprogram)
<ec> DW_AT_external : 1
<ed> DW_AT_name : f
<ef> DW_AT_decl_file : 1
<f0> DW_AT_decl_line : 22
<f1> DW_AT_MIPS_linkage_name: (indirect string, offset: 0x24): _Z1fv
<f5> DW_AT_type : <0xa8>
<f9> DW_AT_low_pc : 0x0
<101> DW_AT_high_pc : 0xc
<109> DW_AT_frame_base : 0x0 (location list)
<10d> DW_AT_sibling : <0x137>
<2><111>: Abbrev Number: 14 (DW_TAG_lexical_block)
<112> DW_AT_low_pc : 0x4
<11a> DW_AT_high_pc : 0xa
<3><122>: Abbrev Number: 15 (DW_TAG_variable)
<123> DW_AT_name : j
<125> DW_AT_decl_file : 1
<126> DW_AT_decl_line : 23
<127> DW_AT_type : <0xa8>
<12b> DW_AT_location : 9 byte block: 3 20 0 0 0 0 0 0 0 (DW_OP_addr: 20)
現在、私が知る限り、これらのファイルには 1 つの違いしかありませんDW_AT_location
。変数 j の属性のバイト ブロック サイズが異なります (DW_AT_sibling
関数 f のタグの属性が異なるのはこのためです。 )。これはどういうわけか静的を意味すると思いますが、その方法はわかりません。