.NET Framework Bookmark and Share   
 index > Building Development and Diagnostic Tools for .Net > What info can be added to debug symbols in addition to local variables and source lines?
 

What info can be added to debug symbols in addition to local variables and source lines?

I am Dylan Borg from the tiny European island of Malta. I am building a compiler for the Dylan.NET language currently in v. 7.3. I have read your blog and managed to make pdb files associated with the assemblies. I also managed to use DbgClr.exe from the .NET 2.0 SDK to debug, step into and set breakpoints with dy;an.NET source files and binaries after the compiler made the binaries and program debug files. I wanted to know how to write symbol info for elements other than local variables and source code lines. Is there a way to write info for fields, method parameters etc. The current dylan.NET sources and binaries(before the debug support) with documentation can be found at http://dylandotnet.codeplex.com/ and http://borgdylan.web.officelive.com/dylandotnet.aspx .
Borgdylan

What sort of info do you want to write for fields, method parameters, etc?
Field names, method names, parameter names are all stored in the metadata in the executable file. You can validate this by viewing them with ILDasm even when the PDB is not available.
The general invariant here is:
- Metadata contains most of the "public" information that another assembly would need to know to use your assembly. Since fields and methods are ultimately bound by name, the metadata must contain the names.
- PDBs just contain the information that the debuggers want which is not already in the metadata doesn't.


http://blogs.msdn.com/jmstall
  • Marked As Answer byBorgdylan Monday, September 14, 2009 4:00 PM
  •  
  • Monday, September 14, 2009 6:11 AMRick ByersMSFT, OwnerUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    That description of public vs. private symbols in MSDN is strictly about native PDBs. For mangaed code there isn't really any such thing as "public symbols" (or you could say that the "public symbols" are what's in the metadata alone without any PDB info). As Mike said, everything that is considered "public symbols" in the native world (and much of what is considered private too) is in the metadata of managed DLLs. So to a rough approximation managed PDBs are really just about source-line mapping and local variables (since that's all that's missing from the metadata).

    That said, you can actually store whatever additional detail you want in PDBs using the symbol custom attribute mechanism. But probably what you care about is what information can you store which an existing debugger would know how to read and interpret (I'm assuming you'd like to avoid writing your own debugger / debug engine for Dylan.NET). Really the definition of the ISymUnmanagedWriter API is the specification for what the Visual Studio Debugger (and so also DbgClr which is a subset of the VS code) can read. Eg., in addition to locals/source there's also using info (so expressions in the immediate/watch window can take into account the 'usings' that are active in C#). There's also a few extra things that C# 2.0 stores as a symbol custom attribute specific to some of the transforms it does (iterator methods, display clases, etc.) but I don't think these are documented or particularily useful for any other language to leverage (although I could probably get you details if you're interested).

    I hope this helps.
    Rick

    • Marked As Answer byBorgdylan Monday, September 14, 2009 4:00 PM
    •  
  • All Replies

    • Saturday, September 12, 2009 4:32 PMMike Stall - MSFTMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
       Answer

      What sort of info do you want to write for fields, method parameters, etc?
      Field names, method names, parameter names are all stored in the metadata in the executable file. You can validate this by viewing them with ILDasm even when the PDB is not available.
      The general invariant here is:
      - Metadata contains most of the "public" information that another assembly would need to know to use your assembly. Since fields and methods are ultimately bound by name, the metadata must contain the names.
      - PDBs just contain the information that the debuggers want which is not already in the metadata doesn't.


      http://blogs.msdn.com/jmstall
      • Marked As Answer byBorgdylan Monday, September 14, 2009 4:00 PM
      •  
    • Sunday, September 13, 2009 12:22 PMBorgdylan Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
       
      Thanks for the info Mike, but what I want in addition to the public symbols(in pdb) and metadata (in assembly) is to also add private symbol data like the one specified here in this article: http://msdn.microsoft.com/en-us/library/cc501184.aspx. Can this be done inside symbol files? and if it can how?
    Mike Stall - MSFT

    That description of public vs. private symbols in MSDN is strictly about native PDBs. For mangaed code there isn't really any such thing as "public symbols" (or you could say that the "public symbols" are what's in the metadata alone without any PDB info). As Mike said, everything that is considered "public symbols" in the native world (and much of what is considered private too) is in the metadata of managed DLLs. So to a rough approximation managed PDBs are really just about source-line mapping and local variables (since that's all that's missing from the metadata).

    That said, you can actually store whatever additional detail you want in PDBs using the symbol custom attribute mechanism. But probably what you care about is what information can you store which an existing debugger would know how to read and interpret (I'm assuming you'd like to avoid writing your own debugger / debug engine for Dylan.NET). Really the definition of the ISymUnmanagedWriter API is the specification for what the Visual Studio Debugger (and so also DbgClr which is a subset of the VS code) can read. Eg., in addition to locals/source there's also using info (so expressions in the immediate/watch window can take into account the 'usings' that are active in C#). There's also a few extra things that C# 2.0 stores as a symbol custom attribute specific to some of the transforms it does (iterator methods, display clases, etc.) but I don't think these are documented or particularily useful for any other language to leverage (although I could probably get you details if you're interested).

    I hope this helps.
    Rick

    • Marked As Answer byBorgdylan Monday, September 14, 2009 4:00 PM
    •  
  • Monday, September 14, 2009 4:01 PMBorgdylan Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks for your help, now I understand.
  • Rick Byers

    You can use google to search for other answers

    Custom Search

    More Threads

    • .NET profiler
    • Debugging Custom Attributes
    • CLRProfiler - Relocated Bytes not updated on induced collections?
    • Obtaining the call stack when debugging a native application
    • Reflection.Emit More Dynamic?
    • mdbg ? help does not work, potential workaround
    • Field signatures in StandaloneSig table
    • Check the assembly files in dos command
    • reflector tool in .Net
    • converting .net files to xml