Visual Studio CPU profiler can't load symbols when copied to a different machine - visual-studio

So I made a profiling using Visual Studio 2022 CPU profiler on one machine. Then I copied the resulting .diagsession file to the local copy of the same project on another machine. But when I try to look at the methods it says Symbols failed to load for <myproject_name>.dll. Failed to find symbol file <myproject_name>.pdb.
I tried to include the bin folder (where both the .dll and .pdb files are located) of this project in the Options > Debugging > Symbols settings, but it does not work. Apparently, VS tries to load the symbols from the Microsoft symbol server and does not look in this folder.
What can I do to make the Profiler load the correct symbols for my project? Maybe I can see more detailed description of the proccess of loading the symbols somewhere (e.g. exact name of the folders that the Profiler is looking into) because information in the Output is not very elaborate?
P.S. Symbol loading on the first machine, where the profiling was initially made, is working fine.

Related

How to find the pdb or dll location for symbols you have already loaded?

If I am debugging something in Visual Studio, and I am looking through the call stack, and some code in the stack is external code, and I click to Load Symbols for that code, and the symbols load, and I can now browse through the source code... where on my file system is the pdb that those symbols were loaded from?
Regardless of which symbol server those symbols are loaded from, as far as I am aware, there has to be a file somewhere on my file system that is storing a pdb or dll or similar that allowed Visual Studio to decompile the source code.
Where can I find this?
You can actually also find the loaded symbol files/pdb under the External Sources folder in Solution Explorer. This is available for Visual Studio 22.
read here : https://devblogs.microsoft.com/visualstudio/debugging-external-sources-with-visual-studio/

Prevent Visual Studio from using cached .pdbs

I did the following experiment: I created a statically linked C++ library solution MyLibrary (I took the code from the MSDN example: https://msdn.microsoft.com/en-us/library/ms235627.aspx.) and built it. Then I created another C++ solution MyConsoleApp, using the console application template in Visual Studio (2017). I copied the MyLibrary.lib file to the root of MyConsoleApp project and added MyLibrary.lib to Linker -> Input -> Additional Dependencies (also had to copy over the headers too of course). What I didn't do was to copy over the MyLibrary.pdb file.
I would've expected to get a linker warning about the missing .pdb file but this was not the case. Then I moved only MyConsoleApp to another machine and tried to build it again, this time getting a missing .pdb linker warning. It seems that Visual Studio is storing the .pdb files when building a solution somewhere on the machine and is able to use those .pdb files when linking other solutions on the same machine.
I would like to be able to disable this behaviour or to be able to remove the cached .pdbs so that I could be sure that when sharing work with other developers they won't get warnings that I'm not getting on my own machine.
Visual Studio doesn't cache the .pdb file. What happens here is that the absolute path to the original .pdb file is stored in the build outputs (.exe, .dll or .obj files) and Visual Studio is able to took it up based on that.
Check this answer for a way to prevent that: Remove PDB references from released file.

VS2010 Debug attach to process / cannot find or open the PDB file

I'm trying to debug some of the examples provided in the Maya API SDK.
Building the DLL with Visual Studio 2010 in debug mode worked fine, and the plugin, once loaded into Maya, worked fine.
However after attaching, Visual Studio complains about cannot find or open the PDB file.
I ignored those warning and set some break points, but clearly VS does not break.
Regarding building plugins and debugging by attaching them to Maya, I've read:
https://alliance.seas.upenn.edu/~cis660/wiki/index.php?title=Debug_CPP_Plugin
http://devmaster.net/forums/topic/6965-how-to-debug-a-plugin/
http://www.creativecrash.com/forums/api/topics/help-33-how-do-i-debug-my-plugin
On SE, I have read the following suggestions:
Why is Visual Studio 2010 not able to find/open PDB files?
PDB does not match image Error
Visual Studio 2010 "Cannot find or open the PDB file"
In particular, I tried:
making sure that the plugin that I am loading into Maya is the one that I just built;
verifying that the PDB has the same name, is in the same folder, has been created at
the same time than the DLL;
loading manually the PDB ("A matching symbol was not found");
activating the Symbol Server in VS (fine, but I got only the Microsoft ones obviously)
Usually, putting the pdb in the same folder will always work - however, the times where this doesn't is usually because your dll is being loaded from elsewhere in the path and its not actually running the dll you think it is (at least, that's what happens to me).
Once your app is running, try and delete the dll - if you can, its not loaded. Or you can look at the path in the modules window in VS. That will also give a clue to why its not loaded and give you the option to manually load symbols from anywhere on disk.

VS2010: "No matching binary found" when trying to load symbols for crashdump

For test purposes, I am debugging a minidump(created with .dump /ma) in Visual Studio 2010.
I have symbols available for that dump, but do not have the current binary (it is an executable).
The Module window in VS2010 shows 'No matching binary found' which seems right, since it cannot be found on the path where it was on the target machine.
I still would like to load the symbols, so I right-click the module, select "Load symbols from symbolpath" (which contains a path to the correct pdb), but a dialog pops up which asks me to select the binary file. I am unable to load the symbols for my module.
Why does VS need the image file? WinDbg is able to load the symbol file and show me the faulting stack without a problem.
I think it is by design. Visual Studio is designed and developed by a team while WinDbg is by another,
http://msdn.microsoft.com/en-us/library/htzy3t6f.aspx
If you load a minidump file that was saved with a heap, Visual Studiocan load the symbols even if the application binary is not found. Minidump files without heaps need the binaries to load symbols.
If you want Visual Studio to be the same as WinDbg, you should go to Microsoft Connect and create a feature request,
http://connect.microsoft.com/intro/

Windows Debugging Symbols - Not Loading

I am having Windows 7 x64 SP1. I have downloaded symbols from:
http://msdn.microsoft.com/en-us/windows/hardware/gg463028
I have downloaded and installed x64 RTM and x64 SP1 symbols for Windows 7 x64 SP1. Installed on T:\Symbols folder.
But When I debug a 64-bit native C++ application, the symbols would not load at all. For ntdll.dll, for instance, the PDBs are located in:
T:\Symbols\ntdll.pdb\6192BFDB9F04442995FFCB0BE95172E12
T:\Symbols\ntdll.pdb\CFF40300FD804691B73E12CF2A150EE02
But Visual Studio (2008/2010) will not load symbols. While debugging, from Modules View, I select ntdll.dll and say Load Symbols From -> Symbol Path, the specify the ntdll.pdb. For both of mentioned paths, it will always say:
A matching symbol file was not found in this folder.
I have also added this folder (T:\Symbols) in Debugging -> Options, but it will still not load the symbols. While debugging, Load All Symbols button would be enabled, and clicking would not load the symbol either!
For 32-bit the PDB filename would be wntdll.pdb for ntdll.dll and would be stored in GUID-named folders in fashion mentioned above. But VS will not load symbols for 32-bit debugging either.
Quite interestingly (and frustratingly), when I select Load Symbols From -> Microsoft Symbols Server, it will download and load the symbols perfectly. It will download the symbols at following location (full path for ntdll):
\Users\...\AppData\Local\Temp\SymbolCache\ntdll.pdb\6192BFDB9F04442995FFCB0BE95172E12
Here you can see the GUID is matching with the GUID-named folder in T:\Symbols path, but for manually installed symbols VS is rigid not to load it!
For NTDLL.PDB, despite the respective folder being same, and the size of PDB also being same, the timestamp might be different.
Sometimes VS would also place symbols in:
C:\...\AppData\Local\Temp\SymbolCache\MicrosoftPublicSymbols
If VS would download correct symbols ONLY from Microsoft Symbols Server, then what the use of locally downloaded symbols?
My question is basically how to load locally downloaded and installed symbols?
The download links for the RTM or SP1 symbols are pretty much useless. After each patch day you will get a changed ntdll.dll or other central OS libraries. This will render your "old" pdbs useless. You need to download them therefore from the symbol servers to be sure that you are up to date.
But since not all dlls are changed you should set your Symbol server download cache to the same location where you have unpackaged your downloaded symbols.
Go to:
Tools - Options - Debugging - Symbols
and set the path for Cache symbols in this directory.
Load all symbols means that you do load all symbols for all modules that are loaded in your current process. But it will not dowload all symbols for all dlls that are used by Windows. If you do download Windbg you get a tool called symchk.exe which allows you to download the symbols for all binaries recursively.

Resources