views:

576

answers:

4

I want to debug an application in Visual Studio but I ONLY have the source code for 1 class. I only need to step through a single function in that file, but I don't understand what I need to do it. I think the steps are normally something like this:

  1. Open a file in VS
  2. Load in the "symbols" (.PDB file)
  3. Attach to the running process

I know how to do #1 and #3, but I don't how to do #2 without the .PDB file. Is it possible to generate the .PDB file for this to make it work? Thanks!

+1  A: 

You need the symbol file (.PDB) file that belongs to the application you are trying to debug.

MSDN: PDB Files

The Visual Studio debugger uses the path to the PDB in the EXE or DLL file to find the project.pdb 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 followed by the symbol paths specified in the Options dialog box. This path is generally the Debugging folder in the Symbols node. The debugger will not load a PDB that does not match the binary being debugged.

spoon16
+7  A: 

You need *.pdb files (step 2 from your post) These files contain mapping between source code and compiled assembly. So your step are correct. If your source file has differences with original file, set check mark "Allow the source code to be different from the original version" in BP's properties dialog.

Breakpoints and Tracepoints in Visual Studio

If you don't have PDB files you can try to decompile your project using Reflector.FileDisassembler or FileGenerator For Reflector. They you can recompile these files to get PDBs

Also take a look at Deblector - debugging addin for Reflector.

aku
A: 

The symbol file is the .pdb file. If you place that next to the exectuable, that will load the symbols, and point to the source file.

TraumaPony
A: 

In your case 'Symbols' means a pdb file for the assembly you want to debug. The debugger doesn't require that you have all the source, just that you have the matching pdb. The pdb is generated during the build of the assembly, and no you unfortunately cannot create one after the fact. If you don't have the pdb you will need to debug at a lower level then the source code.

If you built the assembly on your machine then the symbols will be found when you attach. In that case just set a breakpoint on the source and do whatever is necessary to make that code run, and you'll hit the breakpoint.

If you did not build it you need to find the pdb for the assembly. The modules window found under Debug/Windows/Modules can often help by telling you the assemblies loaded in the process along with version info, and timestamps.

You'll need that information in cases where there might be multiple versions of an assembly (such as keep many nightly builds, or the last 20 or so versions from continuous integration builds).

hope that helps.

Steve Steiner