[Mono-dev] Mono Debugger and Mono 2.4

Martin Baulig martin at ximian.com
Tue May 26 20:26:51 EDT 2009


On Fri, 2009-05-08 at 12:09 +0200, jonas echterhoff wrote:
> Following up on my own post here, I have managed to make mdb work with  
> Unity (to some degree). It was mostly as easy as Miguel said, just  
> instruct Unity to use mono the same was as if "mono --inside_mdb" had  
> been called.
> 
> Reading the MONO_DEBUGGER__debugger_info struct still is a problem,  
> though. I was wrong in my last post that mdb won't try to read it for  
> native applications. Rather, the problem is, that since we are linking  
> against mono dynamically, the debugger will first interrupt when  
> loading Unity, before the linker has resolved the external dynamic  
> symbols, thus it won't get the correct address for the struct.
> 
> I have worked around this for now, by making the debugger ignore the  
> first stop, which works, but breaks compatibility with everything but  
> Unity - so I really need some better fix. Does anybody know the OS X  
> linker very well? I tried setting the DYLD_BIND_AT_LAUNCH environment  
> variable, but that still seems to link the symbol too late. If nobody  
> knows a more elegant solution, I'd need to change the debugger to try  
> again and read the symbol table again, if the symbol is unresolved the  
> first time, but if it can be fixed by some different link settings,  
> i'd prefer that.

Hi,

I have a look at this problem today and fixed this for Linux - and while
doing that, I realized that the old code was really very broken, it only
worked by accident because the 'mono' binary is statically linked.

My new code now correctly handles dynamic linking and embedding - I
tested this with moonlight in firefox.

We're basically getting the same problem on Linux, when the debugger
stops the first time, the dynamic info structure hasn't been initialized
yet.

To fix this, I read the entry point address (on Linux, this is '_start',
not 'main') from the ELF header and stop there to initialize the shared
libraries.  After that, I look for the '.mdb_debug_info' section in each
shared library we load.

I need to make a few minor cleanups to the patch, especially handle
unloading of the mono runtime - and then I'll commit it to SVN.

Martin





More information about the Mono-devel-list mailing list