[Mono-devel-list] Is native codes for C# methods and CLI internal calls different?

Vivek, Bharath Varma (IE10) Vivek.Varma at honeywell.com
Wed Mar 2 09:08:41 EST 2005


> If you have the filter in Console.WriteLine() and you call it from Main,
why
> do you expect a huge stack walk? It looks correct that it just shows
> WriteLine, Main and the invoke wrapper used to go from unmanaged
> to managed code.

I verified this against the output using the --trace and yes it is CORRECT
that the stack walk shows only these 3 methods. Sorry about the hasty email!

I ran into another issue regarding stack walk, here's a short description,
I put the following lines of code into the "DoAssemblyResolve" method of 
AppDomain.cs in corlib
//Code starts here
System.Diagnostics.StackTrace st = new
System.Diagnostics.StackTrace(13,false);
for(int i =0; i< st.FrameCount; i++ )
{
// High up the call stack, there is only one stack frame
System.Diagnostics.StackFrame sf = st.GetFrame(i);
sf.GetMethod();
}
//Code Ends here

I observed the stack walk in ves_icall_get_frame_info in mini-exceptions.c. 
The stackwalk showed me the following <namespace.classname.methodname>
combination.

//Start stack walk info
System.Diagnostics.Stackframe.get_frame_info
....
......
.....
HelloWorld.Class1.Main
HelloWorld.Class1.Main
System.Object.runtime_invoke_void

//End stack walk info

The problem: HelloWorld.Class1.Main appears twice in the stack walk,
although it is expected to appear only once. 
The other method in this stack walk that appear twice is
System.Appdomain.LoadAssembly, a managed-to-native wrapper BOTH the times.
Any idea why this would be happening?


A look at the code in mono_arch_find_jit_info showed me that 
We are doing a mono_jit_info_table_find with the (*lmf)->eip and then again
setting the new_ctx->SC_EIP = (*lmf)->eip. 
This seemed to be the reason why we see some methods appearing twice in the
stack walk. 

Is this possibly a bug?
However I'm not sure what the solution to avoid this is.

Any ideas please?


Thanks in anticipation!




More information about the Mono-devel-list mailing list