19 Mar 2002 01:27:14 +0100
Hi Miguel and all,
I started writing an implementation of the System.Diagnostics.SymbolStore.ISymbolWriter
interface yesterday which we can use in MCS to provide line numbers and other debugging
My implementation writes an assembler file containing DWARF code. This file still needs
to be processed by the JIT, but this can now be done by a very simple algorithm. Basically
all the JIT needs to do is mapping IL offsets to machine addresses. To do this, the
MonoSymbolWriter creates a special ELF section containing a table of file offsets containing
all places where there's an IL offset in the file.
However, I discovered several problems with the ISymbolWriter interface - one of them is
that it's using this proprietary, undocumented DLL to write the PDB files and that there
is no documentation about how to write and use another symbol writer with that interface.
All that I could gather from the docs is that you get an instance of a class implementing
the ISymbolWriter interface "by some kind of magic" and then use it.
Since the actual symbol writer seems to be dynamically loaded I thought it'd be best to
put my implementation into an assembly of its own - Mono.CSharp.Debugger.
To use this interface in MCS we need to figure out how to do the following:
a) System.Reflection.Emit.LocalBuilder has a SetSymNameInfo() method and according to the
MSDN docs it uses the symbol writer.
So the LocalBuilder's constructor must get an instance of the ISymbolWriter interface
and then call DefineLocalVariable () on it.
MCS can just call LocalBuilder.SetSymNameInfo, it should do nothing if there is no
symbol writer (compiling without debugging support).
b) System.Reflection.Emit.AssemblyBuilder has a version of DefineDynamicModule which takes
a `bool emitSymbolInfo' argument.
When this argument is true, it must create a new ISymbolWriter instance and pass it to
c) System.Reflection.Emit.ModuleBuilder has a GetSymWriter() method which needs to return
an instance of the ISymbolWriter.
The documentation is unclear about how and where to create the symbol writer - is it done
in the AssemblyBuilder's constructor and then passed to the ModuleBuilder's constructor
as argument or does GetSymWriter () create a new symbol writer each time it is called ?
d) Some of System.Reflection.Emit.ILGenerator's methods seem to talk to the symbol writer
as well - but how does the ILGenerator get an instance of the symbol writer ?
e) ISymbolWriter.OpenMethod () takes a Token argument, but currently there is no way to get
the MethodInfo back from the token - how is this supposed to be done ?
f) If MCS is using the ISymbolWriter interface, can it also be used to write PDF files on
Windows ? The answer should be yet, but .....
There's some more docu in mcs/class/Mono.CSharp.Debugger/README about this.
Miguel, maybe you can address some of these issues at the ECMA meeting ?