1

I just want to debug without seeing "no type information available in symbol file." I can not debug an application efficiently if I can not see the types I am working with when I am debugging.

Currently, if I build a new project and try to debug Win32 COM code, I get the annoying "no type information available in symbol file."

I have tried every single answer in the question below and nothing has worked! Why does a newly created project in an ide built for such project have this issue?

Visual Studio No Symbols have been loaded for this document

Here is the code with the error:

#include <InitGuid.h>
#include <Mmdeviceapi.h>
#include <Functiondiscoverykeys_devpkey.h>

#include <iostream>
#include <Windows.h>
#include <Audiopolicy.h>
#include <Audioclient.h>
#include <dshow.h>

#include <functional>
#include <random>

#define EXIT_ON_ERROR(hres)  \
              if (FAILED(hres))  \
{ std::cout << std::hex <<hres << "\n"; goto Exit; }

#define SAFE_RELEASE(punk)  \
              if ((punk) != NULL)  \
                { (punk)->Release(); (punk) = NULL; }

class RandomDouble
{
public:
                RandomDouble(double low, double high)
                                :r(std::bind(std::uniform_real_distribution<>(low, high), std::default_random_engine())) {}

                double operator()() { return r(); }

private:
                std::function<double()> r;
};

HRESULT getAudioEndpointRenderDevices(IMMDeviceCollection** ppMMDeviceCollection) {
                HRESULT hr = S_OK;
                const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
                const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
                IMMDeviceEnumerator* pMMDeviceEnumerator = NULL;
                hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL,
                                CLSCTX_ALL, IID_IMMDeviceEnumerator, (void**)&pMMDeviceEnumerator);
                if (hr != S_OK) {
                                goto EXITGAERD;
                }
                hr = pMMDeviceEnumerator->EnumAudioEndpoints(
                                EDataFlow::eRender, DEVICE_STATE_ACTIVE, ppMMDeviceCollection);
             EXITGAERD:
                SAFE_RELEASE(pMMDeviceEnumerator);
                return hr;
}

HRESULT getAudioEndpointSpeakerIndices(IMMDeviceCollection** ppMMDeviceCollection, 
                std::vector<int> iSpeakers) {
                HRESULT hr;
                UINT nMMDevices;
                IMMDevice* pMMDevice = NULL;
                IPropertyStore* pPropertyStore = NULL;
                PROPVARIANT property;
                // Initialize container for property value.
                PropVariantInit(&property);
                hr = (*ppMMDeviceCollection)->GetCount(&nMMDevices);
                if (hr != S_OK) {
                                goto EXITGAES;
                }
                for (ULONG i = 0; i < nMMDevices; i++) {
                                hr = (*ppMMDeviceCollection)->Item(i, &pMMDevice);
                                if (hr != S_OK) {
                                                goto EXITGAES;
                                }
                                hr = pMMDevice->OpenPropertyStore(STGM_READ, &pPropertyStore);
                                if (hr != S_OK) {
                                                goto EXITGAES;
                                }
                                hr = pPropertyStore->GetValue(PKEY_AudioEndpoint_FormFactor, &property);
                                if (hr != S_OK) {
                                                goto EXITGAES;
                                }
                                if (property.uintVal == Speakers) {
                                                iSpeakers.push_back(i);
                                    }
                }
EXITGAES:
                SAFE_RELEASE(pMMDevice);
                SAFE_RELEASE(pPropertyStore);
                return hr;
}

int main()
{
                IMMDeviceCollection* pMMDeviceCollection = NULL;
                std::vector<int> iSpeakers{};
                IMMDevice* pMMDevice = NULL;
                IPropertyStore* pPropertyStore = NULL;
                IAudioClient* pAudioClient = NULL;
                REFERENCE_TIME bufferTime = 0;
                WAVEFORMATEX* pWaveFormatEx = NULL;
                WAVEFORMATEXTENSIBLE* pWaveFormatExtensible = NULL;
                IAudioRenderClient* pAudioRenderClient = NULL;
                RandomDouble* rd;

                EXIT_ON_ERROR(CoInitialize(nullptr));
                EXIT_ON_ERROR(getAudioEndpointRenderDevices(&pMMDeviceCollection));
                EXIT_ON_ERROR(getAudioEndpointSpeakerIndices(&pMMDeviceCollection, iSpeakers));
                // TODO make user pick device
                EXIT_ON_ERROR(pMMDeviceCollection->Item(0, &pMMDevice));
                EXIT_ON_ERROR(pMMDevice->Activate(__uuidof(IAudioClient), CLSCTX_ALL,
                                NULL, (void**)&pAudioClient));
                EXIT_ON_ERROR(pMMDevice->OpenPropertyStore(STGM_READ, &pPropertyStore));
                PROPVARIANT property;
                // Initialize container for property value.
                PropVariantInit(&property);
                EXIT_ON_ERROR(pPropertyStore->GetValue(PKEY_AudioEngine_DeviceFormat, &property));
                
                WORD formatTag;
                WORD validBitsPerSample;
                WORD samplesPerBlock;
                GUID subFormat;
                WORD nChannels;
                DWORD nSamplesPerSec;
                DWORD nAvgBytesPerSec;
                WORD nBlockAlign;
                WORD bitsPerSample;
                WORD cbSize;
                /*
                pWaveFormatEx = (WAVEFORMATEX*)property.blob.pBlobData;
                formatTag = pWaveFormatEx->wFormatTag;
                bitsPerSample = pWaveFormatEx->wBitsPerSample;
                if (formatTag == 0xFFFE) {
                                pWaveFormatExtensible = (WAVEFORMATEXTENSIBLE*)property.blob.pBlobData;
                                validBitsPerSample = pWaveFormatExtensible->Samples.wValidBitsPerSample;
                                samplesPerBlock = pWaveFormatExtensible->Samples.wSamplesPerBlock;
                                subFormat = pWaveFormatExtensible->SubFormat;               }
                else {
                                validBitsPerSample = bitsPerSample;
                }
                */
                pAudioClient->GetMixFormat(&pWaveFormatEx);
                pWaveFormatExtensible = (WAVEFORMATEXTENSIBLE*)pWaveFormatEx;
                validBitsPerSample = pWaveFormatExtensible->Samples.wValidBitsPerSample;
                samplesPerBlock = pWaveFormatExtensible->Samples.wSamplesPerBlock;
                double amplitude;
                amplitude = std::pow(2.0, validBitsPerSample);
                nChannels = pWaveFormatEx->nChannels;
                nSamplesPerSec = pWaveFormatEx->nSamplesPerSec;
                nAvgBytesPerSec = pWaveFormatEx->nAvgBytesPerSec;
                nBlockAlign = pWaveFormatEx->nBlockAlign;
                bitsPerSample = pWaveFormatEx->wBitsPerSample;

                EXIT_ON_ERROR(pAudioClient->Initialize(AUDCLNT_SHAREMODE_SHARED, 0,
                                bufferTime, 0, pWaveFormatEx, NULL));
                UINT32 bufferSize;
                EXIT_ON_ERROR(pAudioClient->GetBufferSize(&bufferSize));
                EXIT_ON_ERROR(pAudioClient->GetService(__uuidof(IAudioRenderClient), (void**)&pAudioRenderClient));
                EXIT_ON_ERROR(pAudioClient->Start());
                rd = new RandomDouble(0, amplitude);
                UINT32 currentPadding;
                for (int i = 0; i < nSamplesPerSec / bufferSize; i++) {
                                EXIT_ON_ERROR(pAudioClient->GetCurrentPadding(&currentPadding));
                                //currentPadding *= bytesPerSample;
                                if (bufferSize - currentPadding != 0) {
                                                long* pData;
                                                pData = new long[bufferSize - currentPadding];
                                                for (int i = 0; i < bufferSize - currentPadding; i++) {
                                                                pData[i] = (*rd)();
                                                }
                                                BYTE* pBuffer;
                                                EXIT_ON_ERROR(pAudioRenderClient->GetBuffer(bufferSize - currentPadding, &pBuffer));
                                                for (int j = 0; j < (bufferSize - currentPadding) / 8; j += 8) {
                                                                BYTE* bytePointer = reinterpret_cast<byte*>(&pData[j / 8]);
                                                                *((pBuffer)+j) = *bytePointer;
                                                                *((pBuffer)+j + 1) = *(bytePointer + 1);
                                                                *((pBuffer)+j + 2) = *(bytePointer + 2);
                                                                *((pBuffer)+j + 3) = *(bytePointer + 3);
                                                                *((pBuffer)+j + 4) = *bytePointer;
                                                                *((pBuffer)+j + 5) = *(bytePointer + 1);
                                                                *((pBuffer)+j + 6) = *(bytePointer + 2);
                                                                *((pBuffer)+j + 7) = *(bytePointer + 3);
                                                }
                                                EXIT_ON_ERROR(pAudioRenderClient->ReleaseBuffer(bufferSize - currentPadding, 0));
                                }
                                else {
                                                i--;
                                }
                }
                return 0;

Exit:
                printf("Error!\n");
                SAFE_RELEASE(pMMDeviceCollection);
                SAFE_RELEASE(pAudioClient);
                SAFE_RELEASE(pPropertyStore);
                CoUninitialize();
                return 0;
}

pMMDeviceCollection in particular has no type information. Even with this line:

Loaded 'C:\Windows\System32\MMDevAPI.dll'. Symbols loaded.

and this:

SYMSRV:  RESULT: 0x00000000
https://msdl.microsoft.com/download/symbols: Symbols downloaded from symbol server.
C:\Users\me\AppData\Local\Temp\SymbolCache\MMDevAPI.pdb\64A6E5290A7AFAE0E2C07DFC2B0252291\MMDevAPI.pdb: Symbols loaded.```
John Glen
  • 771
  • 7
  • 24
  • The problem is that we do not have access to your system. A project built with debug information is supposed to be debuggable. Check if you are actually running the executable that you've built. – PaulMcKenzie Dec 04 '20 at 01:51
  • How do I check that? The build folder builds the correct file and debugging pauses on the breakpoints in that file. – John Glen Dec 04 '20 at 01:55
  • @JohnGlen, any update about this issue? – Mr Qian Dec 08 '20 at 01:48
  • Updated @PerryQian-MSFT – John Glen Dec 08 '20 at 02:18
  • This is entirely *by design* for COM interface pointers. Thoroughly hiding the implementation so it is usable in any language was the design goal. It is not a problem, a library that is used millions of times per day does not have vexing bugs. Even if you'd find one, there isn't anything you can do to fix it. Focus on debugging your own code. – Hans Passant Dec 08 '20 at 11:18

1 Answers1

0

Try the following suggestions:

1) disable any third party installed extensions under Extensions-->Manage Extensions-->Installed

2) reset all vs settings under Tools-->Import and Export Settings-->Reset all settings

3) try to run devenv /safemode to start a initial VS to test whether the issue happens again.

4) repair VS or update it if it is not the latest version.

Besides, you could share a small sample with us to test whether the project happens in my side.

======================== Update 1

Thanks for sharing your code with us. And I also faced the same issue in our side. While the symbol file MMDevAPI.dll is loaded, we cannot get the type info from it on the Locals. It is quite strange.

enter image description here

Besides, I have reported the issue on our DC Forum. You can vote on it and add any comments if I did not describe the issue in detail. Hope the Team will consider the idea carefully and give us a satisfactory reply.

Mr Qian
  • 21,064
  • 1
  • 31
  • 41
  • Disabling 3rd party plugins didn't work. Safe mode did not work. I am hesitant to reset all settings or repair because I have set up the formatting with a lot of changes. I added code with the issue. – John Glen Dec 08 '20 at 02:08
  • Actually, I faced the same issue in our side. It is quite strange that the symbol file is loaded but we still cannot get the type from pdb file on the Local Window. Since the issue is out of our scope, I have reported it on our DC Fourm, you can check it. And hope the team will give a good feedback. Please check my answer:) – Mr Qian Dec 08 '20 at 08:22
  • Also, I suggest you could `mark this answer` to tell other community members it is a real issue now. – Mr Qian Jan 13 '21 at 02:42