obtaining full stack trace in release mode from a thrown exception?

S

shelby.pereira

Hello,

If I have the following code excerpt where I call m1() in release
mode. my stack trace output shows only m1 and m4 and not the
intermediate method calls.

I obtain the full information in Debug mode. However this information
is critical even in Release mode, is there away to obtain it?

cheers,
shelby pereira


public void m1(){
try
{
m2();
}
catch (Exception e)
{
Console.WriteLine(e.StackTrace);
}
}
void m2(){
m3();
}
void m3(){
m4();
}
void m4()
{
throw new Exception("exc in m4");

}
 
D

Damien

Hello,

If I have the following code excerpt where I call m1() in release
mode. my stack trace output shows only m1 and m4 and not the
intermediate method calls.

I obtain the full information in Debug mode. However this information
is critical even in Release mode, is there away to obtain it?

cheers,
shelby pereira

public void m1(){
try
{
m2();
}
catch (Exception e)
{
Console.WriteLine(e.StackTrace);
}
}
void m2(){
m3();
}
void m3(){
m4();
}
void m4()
{
throw new Exception("exc in m4");

}

Running that in a release version of a 1.1 program, I get:
at MyBag.m4()
at MyBag.m3()
at MyBag.m2()
at MyBag.m1()

(where MyBag is the name of my class), so I'm seeing the full stack
trace. Can you post a working repro of the problem?

Damien
 
N

Nicole Calinoiu

It's possible that this may be due to inlining. If this is the case, and
you wish to prevent inlining, you can do so by adding a MethodImplAttribute
to any methods that should not be inlined. e.g.:

[MethodImpl(MethodImplOptions.NoInlining]
void m2()
{
...
}

However, before you decide to prevent inlining, you may wish to consider
some of the consequences. See, for example,
http://blogs.msdn.com/ricom/archive/2004/01/14/58703.aspx.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top