I have a dump file of a Metro application created by AdPlus.
I have both the pdb files and the source code.
When I open dmp file in Visual Studio I can see only Disassembled code (asm).
Is there any way to debug source code? How do I add pdbs and debug using source code?
if the file is a dll you just need to put the pdb in the same directory where the dll resides, and in the visual studio debugger you need to point to this file
Related
I have an external dll and a pdb file from C# code. I have the source code downloaded on my computer. In Visual Studio, under modules, Symbol status is: Symbol loaded for that specific dll. But User code is: N/A.
And I can't step into the functions in that dll. How do I know where to put the source code so the pdb finds it? Is the pdb looking the C# source file in a specific directory and is there a way to find out where?
There is a tool called SrcTool.exe that is installed with the WinSDK. Srctool.exe utility lists all files indexed within the .pdb file.
SrcTool.exe -r filename.pdb will print the source file paths.
I have a web project that posts from client-side code to a method in external dll, which I have source code file and pdb file of this external dll. What I would like to do is to debug external dll using source code file and pdb. Visual studio does not stop to say no symbols are loaded for the module since.
To debug a a symbol file with the same version is always needed. When you are debugging your own applications you usually don't have to care about this.
But there are things happening in the background. Visual Studio always puts the symbol files in the debug folder when you build your application and also loads them as described under Loading the symbols automatic.
(When you distribute your application you usually do not want to distribute those symbols and therefore they won't be copied to the release directory you change your build configuration to release.)
Loading the symbols manually
If you want to load the symbols manually you can load them with the Modules dialog.
"Debug" -> "Windows" -> "Modules".
You can right click a row and there is the option "Load Symbols" which lets you specify a PDB file to load.
Loading the symbols automatically
Visual studio also loads the symbols automatically when they can be found in one of the the places listed in the Specify Symbol (.pdb) and Source Files in the Visual Studio Debugger documentation:
The location that is specified inside the DLL or the executable file.
(By default, if you have built a DLL or an executable file on your computer, the linker places the full path and file name of the associated .pdb file inside the DLL or the executable file. The debugger first checks to see if the symbol file exists in the location that is specified inside the DLL or the executable file. This is helpful, because you always have symbols available for code that you have compiled on your computer.)
.pdb files that could be present in the same folder as the DLL or executable file.
Any local symbol cache folders.
Any network, internet, or local symbol servers and locations that are specified on, such as the Microsoft symbol server if enabled.
If you want to read more about how the symbols are used with visual studio you can read this article about Understanding symbol files and Visual Studio’s symbol settings.
When doing a "Debug" Build in Visual Studio it outputs a pdb file so that you get detailed information when an exception occurs.
Is the information in the pdb files actually loaded when the executable is run or later at the moment when the exception occurs?
Decompilers such as IDA load symbol files when it analyses your executable, or when you tell it to load specific symbols with your executable, as long as it matches the executable currently being debugged.
Debuggers such as the Visual Studio debugger load PDB files and symbols as soon as it starts debugging, not when an exception occurs.
The MSDN page on PDB files further underlines this:
The Visual Studio debugger uses the project.PDB file created by the
linker directly and embeds the absolute path to the PDB in the EXE or
DLL file. If the debugger cannot find the PDB file at that location or
if the path is invalid (for example, if the project was moved to
another computer), the debugger searches the path containing the EXE,
the Symbol Path specified in the solution's Property Pages (Common
Properties folder, Debug Symbol Files page). The debugger will not
load a PDB that does not match the binary being debugged.
Of course, is a program is compiled without /debug, the path to the PDB file won't be included in the resulting exe or DLL.
Yes, they are loaded outside of VS. If your code crashes while loaded with the PDB's you'll see source code location and line numbers.
I have compiled a Debug-Version of my application in one folder. There are now all dll's, pdb's and the exe with the pdb.
I have now created a MiniDump of my running application started out of this path with Taskmanager. Now, I can open this dmp-File in Visual Studio 2010. But when I try to debug, there will be a message, that the symbols could not be found. I have added the path to my symbols (pdb) to the symbol-paths in visual studio - but with no success. I have also try to load the symbols over the ContextMenu of the modules. It is searching there for MyApp.pdb and I have selected the correct pdb. But I get the message A matching symbol file was not found in this folder.
What can I do to make post mortem debug of my MiniDump with Visual Studio 2010 (so it will find my symbols)?
Do your pdb's and dll's have the same timestamp? Are they both recreated when you rebuild?
Try using chkmatch to ensure your dll and pdb match.
Use chkmatch this way:
chkmatch -c MyApp.exe MyApp.dll
The output should look something like this
Debug information file:
Format: PDB 7.00
Signature: {ef4bc52f-0161-4e0a-8654-cc1368d7a8a6} Age: 1
Result: Matched
You shouldnt need to set the symbol path if your pdb's are in the same location as the exe you are dumping.
Are you on .NET 4?
What is a PDB file and how can I exclude it from the release folder when I rebuild my solution?
A PDB file contains information for the debugger to work with. There's less information in a Release build than in a Debug build anyway. But if you want it to not be generated at all, go to your project's Build properties, select the Release configuration, click on "Advanced..." and under "Debug Info" pick "None".
I had originally asked myself the question "Do I need a PDB file deployed to my customer's machine?", and after reading this post, decided to exclude the file.
Everything worked fine, until today, when I was trying to figure out why a message box containing an Exception.StackTrace was missing the file and line number information - necessary for troubleshooting the exception. I re-read this post and found the key nugget of information: that although the PDB is not necessary for the app to run, it is necessary for the file and line numbers to be present in the StackTrace string. I included the PDB file in the executable folder and now all is fine.
PDB is an abbreviation for Program-Debug Data Base. As the name suggests, it is a repository (persistent storage such as databases) to maintain information required to run your program in debug mode. It contains several vital information required for code debugging e.g. at what points you have put break points where you expect the debugger to break in Visual Studio (VS).
This is the reason why Visual Studio fails to hit the break points if you remove PDB files from the debug directory. Visual Studio debugger is capable of telling you the exact line number of code file at which any exception occurred along with its stacktrace. It is able to do so with the help of PDB files only. Thus PDB files are very helpful for debugging purposes.
In general, it is not recommended to exclude the generation of PDB files during build process. From production release stand-point, what you should be doing is create the PDB files but don't ship them to customer site in product installer. Preserve all the generated PDB files on a symbol server from where it can be used/referenced in future if required.
It is specially important in scenario where you debug process crash issues. While analysing the crash dump files, Visual Studio will not be able to make out the exact line of code where program is crashing if the original PDB files created during the build process were not preserved.
If you still want to disable generation of PDB files then follow below steps:
Go to properties window of the project. To open properties window, select the project file in solution explorer and press Alt + Enter.
Go to Build tab
Click Advanced
Choose none from Debug Info drop-down box
Press OK as shown in the snapshot below:
Note: This setting will have to be done separately for Debug and Release build configurations.
A PDB file contains information used by the debugger. It is not required to run your application and it does not need to be included in your released version.
You can disable pdb files from being created in Visual Studio. If you are building from the command line or a script then omit the /Debug switch.
Program Debug Database file (pdb) is a file format by Microsoft for storing debugging information.
When you build a project using Visual Studio or command prompt the compiler creates these symbol files.
Check Microsoft Docs