3

.Net assemblies have pdb files for debugging. The PDB file points to the exact source location among other details. This is good if I am building the assembly and debugging it locally. The problem starts when you need to deploy your assemblies on other computers. Debugging in such scenarios can be accomplished in a couple of ways; 1. You could put the source in a shared location and point to the location when VS asks for it 2. You could use Source server and point to the source control and configure VS to use that

Java has source jars that could be just deployed on alongside the actual jar itself and use it for debugging. This seems a simpler and neater solution. Can we do this with .Net (I know sourcepack provides a similar functionality)? Or are there better/simpler solution options for this?

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
praskris
  • 479
  • 5
  • 15
  • Usually you have a version control system and this makes your code accessible from anywhere. – Ignacio Soler Garcia Jun 12 '12 at 12:18
  • are you debugging mainly or entirely on your LAN ? – wal Jun 12 '12 at 12:43
  • @SoMoS - I do have a source control system and I do realize that I can source index the PDB and that will link up to the SCM system. I was actually trying to look at a scenario where i didnt have to host a symbol server etc. I have the PDB right next to my assembly, how can i provide access to the source for it easily. Hope this makes sense – praskris Jun 14 '12 at 18:50
  • @wal - Not sure I understand your question correctly. I am talking about debugging any assembly. Are you suggesting that I put the code in a shared public drive and build the assembly from that location? That way the source could be picked up? We do have this system, but it's not very flexible and building from a shared drive is slower. – praskris Jun 14 '12 at 18:53
  • @praskris you don't need to build it from that location. you can build it from any location. i'm suggesting putting the source code and pdb's in a central location (if you arent deploying the pdbs with your dlls) and then when you need to debug you can instruct VS to load the pdbs from the shared location and point VS to the source code (VS will prompt you if it cant find the source at the place specified embedded in the pdb file) – wal Jun 14 '12 at 22:49
  • @wal - yes, I could do that. It might be annoying for users using the libraries to point to the source path for every assembly they reference while debugging. We do have a distributed file system and have the code shared in that location. My question is, if the source jar kind of option a bad idea? i felt it is simpler. wanted to get an opinion of how people handle this. – praskris Jun 15 '12 at 14:53

1 Answers1

1

PDB are actually not need for .NET Assemblies! PDB files do NOT point to the exact source location, it only contains the GUID of the associated source file!

See more details about how PDB and sources files are linked

See John Robbins for more information....

A .NET PDB only contains two pieces of information, the source file names and their lines and the local variable names. All the other information is already in the .NET metadata so there is no need to duplicate the same information in a PDB file.

Community
  • 1
  • 1
mox
  • 6,084
  • 2
  • 23
  • 35
  • The key part though is 'local variable names (and info)' it contains. – leppie Jun 12 '12 at 12:23
  • @mox are you implying you do not need pdb's to debug effectively? – wal Jun 12 '12 at 12:27
  • @wal - I don't imply anything. For .Net assemblies, PDB are used as described by John Robbins. – mox Jun 12 '12 at 12:30
  • @wal - I wrote the article mentioned above how PDB and sources files are linked. – mox Jun 12 '12 at 12:37
  • Thanks, I read through the article by John Robbins. It was insightful, bu tit does mention that the path for the source file is stored if you don't source index it. I can't think of any other way for the debugger to get the location of the source file if it is not stored in the PDB file. My knowledge is limited here, please correct me if I am wrong. _`...if you use a source file MYCODE.CPP in C:\FOO, what's embedded in the PDB file is C:\FOO\MYCODE.CPP. This is probably what you already suspected, but I just wanted to make it clear.`_ – praskris Jun 14 '12 at 18:41
  • This is the article I referred to:[article link](http://www.wintellect.com/cs/blogs/jrobbins/archive/2009/05/11/pdb-files-what-every-developer-must-know.aspx) – praskris Jun 14 '12 at 18:48