如何解释 Windbg "x /2" 结果中的双重条目?
How to interprete double entries in Windbg "x /2" result?
我正在调试一个转储文件(内存转储,而不是故障转储),它似乎包含两倍于预期对象的数量。在调查相应的符号时,我注意到以下内容:
0:000> x /2 <product_name>!<company>::<main_product>::<chapter>::<subchapter>::<Current_Object>*
012511cc <product_name>!<company>::<main_product>::<chapter>::<subchapter>::<Current_ObjectID>::`vftable'
012511b0 <product_name>!<company>::<main_product>::<chapter>::<subchapter>::<Current_ObjectID>::`vftable'
01251194 <product_name>!<company>::<main_product>::<chapter>::<subchapter>::<Current_Object>::`vftable'
0125115c <product_name>!<company>::<main_product>::<chapter>::<subchapter>::<Current_Object>::`vftable'
供您参考,条目 Current_Object
和 Current_ObjectID
存在于代码中,没有问题。
我不明白的是,似乎每个符号都有两个条目,并且它们的内存地址彼此非常接近。
有人知道我该如何解释吗?
这可能是由于多种原因优化和冗余代码消除在linking 时是一个(pdb 通常是在编译时生成的)see this link by raymond chen 了解概览
引用 link
中的相关段落
And when you step into the call to p->GetValue() you find yourself in Class1::GetQ.
What happened?
What happened is that the Microsoft linker combined functions that are identical
at the code generation level.
?GetQ@Class1@@QAEPAHXZ PROC NEAR ; Class1::GetQ, COMDAT
00000 8b 41 04 mov eax, DWORD PTR [ecx+4]
00003 c3 ret 0
?GetQ@Class1@@QAEPAHXZ ENDP ; Class1::GetQ
?GetValue@Class2@@UAEHXZ PROC NEAR ; Class2::GetValue, COMDAT
00000 8b 41 04 mov eax, DWORD PTR [ecx+4]
00003 c3 ret 0
?GetValue@Class2@@UAEHXZ ENDP ; Class2::GetValue
Observe that at the object code level, the two functions are identical.
(Note that whether two functions are identical at the object code level is
highly dependent on which version of what compiler you're using, and with
which optimization flags. Identical code generation for different functions
occurs with very high frequency when you use templates.) Therefore, the
linker says, "Well, what's the point of having two identical functions? I'll
just keep one copy and use it to stand for both Class1::GetQ and
Class2::GetValue."
我正在调试一个转储文件(内存转储,而不是故障转储),它似乎包含两倍于预期对象的数量。在调查相应的符号时,我注意到以下内容:
0:000> x /2 <product_name>!<company>::<main_product>::<chapter>::<subchapter>::<Current_Object>*
012511cc <product_name>!<company>::<main_product>::<chapter>::<subchapter>::<Current_ObjectID>::`vftable'
012511b0 <product_name>!<company>::<main_product>::<chapter>::<subchapter>::<Current_ObjectID>::`vftable'
01251194 <product_name>!<company>::<main_product>::<chapter>::<subchapter>::<Current_Object>::`vftable'
0125115c <product_name>!<company>::<main_product>::<chapter>::<subchapter>::<Current_Object>::`vftable'
供您参考,条目 Current_Object
和 Current_ObjectID
存在于代码中,没有问题。
我不明白的是,似乎每个符号都有两个条目,并且它们的内存地址彼此非常接近。
有人知道我该如何解释吗?
这可能是由于多种原因优化和冗余代码消除在linking 时是一个(pdb 通常是在编译时生成的)see this link by raymond chen 了解概览
引用 link
中的相关段落 And when you step into the call to p->GetValue() you find yourself in Class1::GetQ.
What happened?
What happened is that the Microsoft linker combined functions that are identical
at the code generation level.
?GetQ@Class1@@QAEPAHXZ PROC NEAR ; Class1::GetQ, COMDAT
00000 8b 41 04 mov eax, DWORD PTR [ecx+4]
00003 c3 ret 0
?GetQ@Class1@@QAEPAHXZ ENDP ; Class1::GetQ
?GetValue@Class2@@UAEHXZ PROC NEAR ; Class2::GetValue, COMDAT
00000 8b 41 04 mov eax, DWORD PTR [ecx+4]
00003 c3 ret 0
?GetValue@Class2@@UAEHXZ ENDP ; Class2::GetValue
Observe that at the object code level, the two functions are identical.
(Note that whether two functions are identical at the object code level is
highly dependent on which version of what compiler you're using, and with
which optimization flags. Identical code generation for different functions
occurs with very high frequency when you use templates.) Therefore, the
linker says, "Well, what's the point of having two identical functions? I'll
just keep one copy and use it to stand for both Class1::GetQ and
Class2::GetValue."