Home All Groups Group Topic Archive Search About

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

Author
23 Mar 2007 2:01 PM
shelby.pereira@gmail.com
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");

    }

Author
23 Mar 2007 2:13 PM
Damien
On Mar 23, 2:01 pm, "shelby.pere***@gmail.com"
<shelby.pere***@gmail.com> wrote:
Show quote
> 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
Author
23 Mar 2007 2:56 PM
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.



<shelby.pere***@gmail.com> wrote in message
Show quote
news:1174658485.385300.193930@d57g2000hsg.googlegroups.com...
> 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");
>
>    }
>

AddThis Social Bookmark Button