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

  • Thread starter Thread starter shelby.pereira
  • Start date Start date
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");

}
 
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
 
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.
 
Back
Top