How to get information about location of some methods from the PDB file?

Topics: PDB Reader
Jan 11, 2011 at 8:07 AM

How to get information about location of some methods from the PDB file?

string pdbFile = @"c:\Nemerle-2\Compiler\Core\bin\Debug\Core.pdb";
string asmFile = @"c:\Nemerle-2\Compiler\Core\bin\Debug\Core.dll";

using (var host = new PeReader.DefaultHost()) 
{
  var asm = host.LoadUnitFrom(asmFile) as IAssembly;
  var nTable = host.NameTable;

  PdbReader pdbReader = null;
  if (File.Exists(pdbFile))
  {
    Stream pdbStream = File.OpenRead(pdbFile);
    pdbReader = new PdbReader(pdbStream, host);
    var slp = (ISourceLocationProvider)pdbReader;

    var ty = UnitHelper.FindType(nTable, asm, "Nemerle2.Compiler.IVariantOptionTypeInfo");

    foreach (var m in ty.Methods)
    {
      // ||||||||||||||||||||||||||||||||||||||||
      // What I should do here to get the source file location information (from PDB) for method "m"?
    }
  }


Coordinator
Jan 11, 2011 at 2:59 PM

The PeToText sample illustrates how one can use the PDB information.

Jan 11, 2011 at 3:25 PM

I can't find this sample. Where it is?

Coordinator
Jan 11, 2011 at 3:49 PM

Oops, yes. The sample lives in cciast. I'll port it over to ccimetadata in due course, but meanwhile you can have a look in cciast.

Jan 11, 2011 at 8:09 PM

I loock on this sample, but unfortunatly I not find unswer on my question.

:(

Coordinator
Jan 11, 2011 at 8:13 PM

It seems that you want to find PDB information using the method as a key. Unfortunately this is not possible. PDB files generated by the CLR only record the names of locals, scoping information and a mapping from IL instruction locations to source locations.