52

I am having some trouble debugging a visual studio 2008 C++ project. When I start running it in debug, the breakpoints are disabled with the message

The Breakpoint will not be hit. No Symbols have been loaded for this document.

I have tried cleaning and rebuilding, but this doesn't make a difference.

I also tried looking in Debug->Windows->Modules. If I right click on the module I am trying to debug and press Symbol load information it brings up a list of places it has tried to load the symbols from. The first in the list is correct and the file exists, but next to it is this error

C:\path\to\my\symbol\Debug\MyProject.pdb: Unknown symbol handler for error

Does anyone know what causes this or how to fix it?

Jim Jeffries
  • 9,841
  • 15
  • 62
  • 103
  • 2
    Have you tried Build>Clean Solution? This will remove temporary files, which might have been corrupted. – MSalters Dec 01 '11 at 13:37
  • I have, as mentioned just below the first quote ;) – Jim Jeffries Dec 01 '11 at 13:42
  • Are you trying to debug code in the executable project which you are running? Or code in a static lib which you have linked against? – bunkerdive Sep 10 '15 at 23:00
  • Also, make sure the output (pdb) file name is set to `$(OutDir)$(TargetName)` . You should be able to find it under project properties -> config properties -> C/C++ -> Output Files -> Program Database File Name. – bunkerdive Sep 10 '15 at 23:07
  • 1
    For C++/CLI projects you may need to go into the project's properties -> Debugging, and set Debuger Type to "Mixed", for me in VS 2015 it defaulted to "Auto" which won't work very well. – jrh Jun 19 '18 at 20:07
  • AHHHHHHHHHHH, half an hour wasted on all these solutions and none of them worked!!!!!!!!!!!!!!!!!!!!!!! – John Glen Dec 04 '20 at 01:35

21 Answers21

45

First of all, it is possible that some of your modules won't show in the module window, because some of them may be loaded dynamically (only as needed).

You might want to check in your project properties under Linker > Debugging > Generate Program Database File and Generate Debug Info. Be sure these two are set properly.

Also, check if C/C++ > General > Debug Information Format is set to Program Database for Edit And Continue (/ZI) or something similar.

I know you mentioned that your symbol file exists, but checking what I just mentioned will ensure you have the right version of your symbol in the right place.

Finally, check if all your project and files in your solution are set to compile as Debug and not Release or something else, because no symbols will be generated (hence none will be loaded) for this project / file.

Hope this helps a bit.

Joseph
  • 380
  • 3
  • 16
TurnsCoffeeIntoScripts
  • 3,868
  • 8
  • 41
  • 46
  • 1
    Thanks, but these settings are all set correctly. Also I checked time the .pdb file was created and it matches the time I did my build. – Jim Jeffries Dec 01 '11 at 13:09
  • 2
    When using default Release builds, debug information is still generated. However, due to optimizations, debugger doesn't work quite as well (lots of variables disappear, for example). – Bartek Banachewicz Dec 01 '11 at 13:11
  • Do you have multiple project in your solution ? – TurnsCoffeeIntoScripts Dec 01 '11 at 13:12
  • No, just a single project in my solution – Jim Jeffries Dec 01 '11 at 13:23
  • Does all your files (if you right-click on them and go to properties) are set to be C/C++ Header (for .h) and C/C++ Compiler (.cpp / .cc / .c) ? – TurnsCoffeeIntoScripts Dec 01 '11 at 13:48
  • 5
    I had the same problem in VS2015. It was quite interesting. I had upgraded from a VS2013 project, which worked fine in both win32 and x64 versions, but when I upgraded to VS2015 I found that breakpoints were hit in the win32 build, but not in the x64 build. I discovered eventually that the x64 build had /Zi (program database), while win32 had /ZI (program database for edit and continue). I changed the x64 build to /ZI and that solved the problem. Why you now can't debug with /Zi, I don't know. – Graham Asher Dec 08 '15 at 11:01
8

In case anyone has this problem when using 'Attach to process', the answer to this question solved it for me:

Visual Studio is not loading modules when attaching to process

Specifically, switching to 'Native code' in the 'Attach to' options instead of 'Auto'.

Community
  • 1
  • 1
James Jenkinson
  • 1,563
  • 2
  • 16
  • 33
7

In my case, the problem was solved by checking "Use Managed Compatibility Mode" in Tools / Options / Debugging / General.

Razvan Socol
  • 5,426
  • 2
  • 20
  • 32
4

Go to the "Properties" for the website that would use that dll for debugging and then select "Native Code" in the "Debuggers" section below:

enter image description here

Vijay Bansal
  • 737
  • 7
  • 10
4

I have managed to solve this by copying my source sideways and checking out a completely clean copy. I assume it was some setting stored in the projects .suo file.

Jim Jeffries
  • 9,841
  • 15
  • 62
  • 103
3

There could be a problem with the mspdbsrv.exe process. Try killing it and start debugger again.

David
  • 31
  • 1
3

For me the fix was in restarting the Visual Studio :) As simple as that. Nothing else helped - tried to Clean (even deleted all files in the Debug folder), checked settings, even killed the mspdbsrv.exe process, but only VS restart did the trick.

Volodymyr Frytskyy
  • 1,233
  • 11
  • 15
2

In the Modules window you can right click and add your Debug output folder to folders where your system looks for symbol files. Also, the thing that worked for me was deleting all the output files manually, Clean won't do it every time and that's why even though the .pdb file is generated, it doesn't correspond to your output files, thus not loading symbols from it.

GreatDane
  • 683
  • 1
  • 9
  • 31
2

Delete all files in the bin and obj folders. Then build the solution again. If your problem was like mine, it seemed like VS was loading an older version of a specific unknown file that rebuilding the solution/project would not replace. Make sure to make a copy of your solution/project before trying this. Good Luck!

1

Make a copy of your "Debug" folder within your project's folder, then delete every file in the original "Debug" folder. As additional measure if you had your visual studio already running with your project loaded, close it after deleting Debug's contain and reopen it before re-build the whole project, theoretically this action will create new copy of symbol files and the rest needed to debug your code. I found out this problem occurred to me when I moved my files to other computer and try to compile and debug my code from there, although all folder and drive names were the same, some how the IDE was unable to use the previously created symbol files. Hope this work around works for some one else !.

Diego
  • 21
  • 1
1

VS2015 C++

I ran into the same problem after cancelling the loading of symbols whilst attempting to debug my application in VS2015. After this, VS2015 refused to load the symbols for the project I was interested in (multiple sub projects in a solution with C# calling C++ DLLs). Solutions above did not work for me, but this did.

For Visual Studio 2015 (C++):

  1. Right click on your project that your break point is in and select
    properties Expand C/C++
  2. Select General under C/C++
  3. Change the Debug Information Format to any other option
  4. Click Apply
  5. Change the Debug Information Format back to its default "Program Database for Edit And Continue (/ZI) (or whatever you prefer)
  6. Click Apply
  7. Now rebuild your project

Hope this helps. Alan M

Alan M
  • 11
  • 1
0

1) Right click on the project you want to debug.

2) Select [Properties]

3) Select the [Build] tab

4) Make sure [Define DEBUG constant] and [Define TRACE constant] are checked

5) Click the [Advanced] button at the bottom of the Build tabpage Make sure that [Debug Info:] is set to [full]

6) Click [OK]

7) Rebuild the project

semicolon
  • 43
  • 5
0

In my case, "use library dependency inputs" in "linker->general"should be set to yes, then the problem is solved.

0

None of the above helped me...

At the end I changed from Debug\X64 to Debug\win32, this helped, probably it's some configuration which isn't the same in both. Maybe this will help as a workaround for someone...

Hope that could help anyone.

ephraim
  • 379
  • 1
  • 3
  • 15
0

I'm debugging a WIA driver, and came across this similar problem. I noticed this log :

DLL named C:\Windows\System32\WIA\wiadriverex.dll cannot be loaded (LoadLibraryEx returned 0x0000007E). Make sure the driver is installed correctly

Then I realized that it is due to DLL dependency. Then I copied required DLLs to System32, the problem is gone. Pay attention, copy to System32, or it won't work for me.

Sanbrother
  • 601
  • 5
  • 12
0

It helped in my case:

  1. Debug -> Attach to process

  2. Scroll down to w3wp.exe enter image description here

  3. Check "Show processes from all users enter image description here

  4. After refresh scroll again to w3wp.exe enter image description here

  5. Select new one with type x64, Managed (Native compilation)

darson1991
  • 406
  • 6
  • 18
0

Try disabling /GL option if it has been enabled in C/C++ / General / Optimization / Whole program optimization.

Initially, I had no issue with debugging my program but after tweaking here and there the issue that OP says began to arise.

The module and its symbols were loaded and nothing in this guide seemed to correspond to my problem. Turning /Zi to /Zl also didn't help.

I'm not sure why, but, it's sort of a compiler behavior I haven't been experienced before. FYI, /GL option is not a default in the C++ projects in VS2017.

David Jung
  • 376
  • 5
  • 8
0

In my case, the error was due to the fact that part of the code was connected as an external library. In order for debug process to work also when going into the code of the external library, it was necessary to add not only its headers, but also the implementation files - folder Source Files of Solution Explorer.

ant0nk
  • 134
  • 1
  • 7
0

It's because /Zi is not the only option to setup, there is also the linker "Generate Debug Info" option that is the second mandatory thing to activate to unlock symbols loading.

From here:
enter image description here

Chose one of:
enter image description here

v.oddou
  • 6,476
  • 3
  • 32
  • 63
0

In my case it was the remote debugging option that caused this problem. I accidentally forgot that it was still turned on in my project while the connection to the remote machine was established. Because the version of the assembly on the remote machine did not match my local version, no symbols were loaded. When I did a reboot, I received a timeout message telling me that no connection to the remote machine is currently established. At that moment I realized that this was the reason for the error. After I turned off the remote debugging option, the breakpoint was hit again.

Pete Hilde
  • 659
  • 1
  • 10
  • 24
-1

In my case it was debugger type.

I used remote windows debugger, changing it to local solved an issue.

Debugger options:

enter image description here

Tomislav Stankovic
  • 3,080
  • 17
  • 35
  • 42
Kuerty
  • 21
  • 2