Reconstructing a Managed C++ vtbl using IDiaSymbol: problems
- From: Tom Harwood <TomHarwood@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 28 Feb 2008 14:48:02 -0800
We are reconstructing the virtual function table (vtbl) of a managed C++
class. We use IDiaSymbol::get_token() to get the token associated with a
virtual function, and IDiaSymbol::get_virtualBaseOffset() to retrieve the
offset in the virtual function table.
Both these methods have been observed to return incorrect data. get_token()
sometimes returns S_OK and outputs the method's MSIL token, and sometimes
returns S_FALSE. get_virtualBaseOffset() has been observed to output the
same offset for several overloads of a method, with S_OK return code; it has
also been observed to return very large values (e.g., 650), but we have not
developed a reproducible test case for this latter behavior. We do have a
test case that outputs the same virtualBaseOffset value for distinct
overloads of a method, and returns S_FALSE for some SymTagFunction symbols'
get_token().
Our desired result is a std::map<size_t, mdToken> which maps method tokens
by their offset within the vtbl. If get_token() always returned the method's
token, and get_virtualBaseOffset() returned "the offset in the virtual
function table of a virtual function", to quote its documentation, then we
could develop our desired table.
Our questions, then, are:
1. Are we using the correct routines to extract information from DIA?
2. If so, are there bugfixes to cause DIA to consistently return MSIL
tokens, and to return correct vtbl offsets?
3. If not, is there an alternative way to extract this information? We
also have the PE file open and can use IMetadataImport APIs, or query the PE
metadata directly.
REPRODUCIBLE TEST CASE:
Our test case consists of a modification to the Microsoft sample "dia2dump"
application, and a sample Managed C++ project whose PDB data exhibits the
problem. The changes to dia2dump attempt to extract the token and
virtualBaseOffset properties from a SymTagFunction IDiaSymbol.
.
- Prev by Date: RE: More debug information on cilents computers
- Next by Date: Debug .NET 2.0 VS2008 "Class Library" accessed by COM
- Previous by thread: RE: More debug information on cilents computers
- Next by thread: Debug .NET 2.0 VS2008 "Class Library" accessed by COM
- Index(es):
Relevant Pages
|
Loading