【问题标题】:Visual Studio 2019 C++ debugging: "no type information available in symbol file"Visual Studio 2019 C++ 调试:“符号文件中没有可用的类型信息”
【发布时间】:2021-03-16 02:32:35
【问题描述】:

我只想调试而没有看到“符号文件中没有可用的类型信息”。如果在调试时看不到正在使用的类型,我就无法有效地调试应用程序。

目前,如果我构建一个新项目并尝试调试 Win32 COM 代码,我会收到烦人的“符号文件中没有可用的类型信息”。

我已经尝试了以下问题中的每一个答案,但没有任何效果!为什么在为此类项目构建的 ide 中新创建的项目会出现此问题?

Visual Studio No Symbols have been loaded for this document

下面是错误代码:

#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 特别没有类型信息。即使有这一行:

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

还有这个:

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.```

【问题讨论】:

  • 问题是我们无权访问您的系统。使用调试信息构建的项目应该是可调试的。检查你是否真的在运行你构建的可执行文件。
  • 如何检查? build 文件夹构建正确的文件并在该文件的断点处暂停调试。
  • @JohnGlen,有关于这个问题的更新吗?
  • 更新@PerryQian-MSFT
  • 这完全是针对 COM 接口指针的设计。彻底隐藏实现以便它可以在任何语言中使用是设计目标。这不是问题,每天使用数百万次的库没有令人烦恼的错误。即使你能找到一个,也没有任何办法可以修复它。专注于调试自己的代码。

标签: c++ visual-studio debugging visual-studio-debugging debug-symbols


【解决方案1】:

尝试以下建议:

1)扩展程序-->管理扩展程序-->已安装下禁用任何第三方安装的扩展程序

2)重置工具下的所有vs设置-->导入和导出设置-->重置所有设置强>

3)尝试运行devenv /safemode启动初始VS,测试问题是否再次发生。

4) repair VS 或者如果不是最新版本就更新。

另外,你可以和我们分享一个小样本来测试这个项目是否发生在我身边。

========================= 更新 1

感谢您与我们分享您的代码。我在我们这边也面临同样的问题。加载符号文件MMDevAPI.dll 时,我们无法获取类型信息 从它对当地人。这很奇怪。

另外I have reported the issue on our DC Forum。如果我没有详细描述该问题,您可以对其进行投票并添加任何 cmets。希望团队慎重考虑,给我们一个满意的答复。

【讨论】:

  • 禁用第 3 方插件不起作用。安全模式不起作用。我对重置所有设置或修复犹豫不决,因为我已经设置了很多更改的格式。我添加了问题代码。
  • 实际上,我在我们这边也遇到了同样的问题。加载符号文件很奇怪,但我们仍然无法从本地窗口的 pdb 文件中获取类型。由于这个问题超出了我们的范围,我已经在我们的 DC Fourm 上报告了它,您可以查看它。并希望团队给予良好的反馈。请检查我的答案:)
  • 另外,我建议您可以mark this answer 告诉其他社区成员这是一个真正的问题。
猜你喜欢
  • 1970-01-01
  • 2015-06-30
  • 1970-01-01
  • 1970-01-01
  • 2020-07-09
  • 1970-01-01
  • 1970-01-01
  • 2020-06-10
  • 2021-11-06
相关资源
最近更新 更多