I added check for SymTagFriend inside loop for UDT children but it's never executed. Can someone tell me how I can get friend classes and functions?
bool PDB::readFromFile(const QString& filePath)
{
HRESULT hr = CoInitialize(nullptr);
hr = CoCreateInstance(__uuidof(DiaSource),
nullptr,
CLSCTX_INPROC_SERVER,
__uuidof(IDiaDataSource),
(void**)(&diaDataSource));
if (FAILED(hr))
{
emit sendStatusMessage("Can't load msdia library!");
return false;
}
QByteArray buffer2;
buffer2.resize((filePath.length() + 1) * 2);
buffer2.fill(0);
wchar_t* filePath2 = (wchar_t*)buffer2.data();
filePath.toWCharArray(filePath2);
hr = diaDataSource->loadDataFromPdb(filePath2);
if (FAILED(hr))
{
emit sendStatusMessage("Can't load data from PDB!");
return false;
}
hr = diaDataSource->openSession(&diaSession);
if (FAILED(hr))
{
emit sendStatusMessage("Can't open session!");
return false;
}
hr = diaSession->get_globalScope(&global);
if (FAILED(hr))
{
emit sendStatusMessage("Can't get global scope!");
return false;
}
return true;
}
void PDB::loadPDBData()
{
IDiaSymbol* symbol;
if (getSymbolByTypeName(SymTagUDT, "A", &symbol)
{
IDiaEnumSymbols* enumSymbols;
if (symbol->findChildren(SymTagNull, nullptr, nsNone, &enumSymbols) == S_OK)
{
LONG count;
if (enumSymbols->get_Count(&count) == S_OK)
{
if (count)
{
IDiaSymbol* symbol2;
ULONG celt = 0;
while (SUCCEEDED(enumSymbols->Next(1, &symbol2, &celt)) && (celt == 1))
{
DWORD symTag;
symbol2->get_symTag(&symTag);
if (symTag == SymTagFriend)
{
Friend friend1 = getFriend(symbol2);
}
symbol2->Release();
}
}
}
enumSymbols->Release();
}
}
}
bool PDB::getSymbolByTypeName(enum SymTagEnum symTag, QString typeName, IDiaSymbol** symbol)
{
IDiaEnumSymbols* enumSymbols;
if (global->findChildren(symTag, typeName.toStdWString().c_str(), nsNone, &enumSymbols) == S_OK)
{
if (enumSymbols->Item(0, symbol) != S_OK)
{
return false;
}
enumSymbols->Release();
return true;
}
return false;
}
Here is also example for which I am trying to get friend class
class A
{
private:
int a;
public:
A() { a = 0; }
friend class B;
};
class B
{
private:
int b;
public:
void showA(A& x)
{
std::cout << "A::a=" << x.a;
}
};
Even the VS2019 DIA2Dump sample fails to produce any information regarding friend classes and SymTagFriend symbols.
The only place in the sample that referenced SymTagFriend was the PrintTypeInDetail function on line 1845 of PrintSymbol.cpp. I set a breakpoint in the function and then ran the sample with the -all parameter so that all debug information would be printed. The breakpoint was never hit.
Hello @Pavle Stojanovic , have you also checked the @RLWA32 ’s reply? Please feel free to contact us.
Can you please check also my other two questions about DIA SDK?
https://learn.microsoft.com/en-us/answers/questions/486175/is-additional-function-parameter-that-is-generated.html
https://learn.microsoft.com/en-us/answers/questions/353265/can-i-get-alignment-value-for-class-using-dia-sdk.html
Sign in to comment