Re: Determening where a function was called from

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Christopher Kimbell (a_at_b.c)
Date: 06/24/04


Date: Thu, 24 Jun 2004 23:08:55 +0200

Thanks a bunch.

Chris

"Sunny" <sunnyask@icebergwireless.com> wrote in message
news:OZ6eMEiWEHA.3420@TK2MSFTNGP12.phx.gbl...
> Hi Chris,
>
>
> In article <40db2339@news.broadpark.no>, a@b.c says...
> > The Trace class in the .NET framework provides basic tracing
capabilities. I
> > would like to create my own tracer that includes the date and time the
trace
> > occured and what function and class the trace was called from.
> >
> > The date and time is no problem, the tricky bit is to determine where
the
> > function was called from, I only want to go one level up, not the whole
call
> > stack. Is there any way to use reflection to determine the calling
function?
> > I had a look at the MethodBase class but I can't find any promising
> > properties or methods. Since the call stack is used when getting the
stack
> > trace from an exception and for security checks, I was hoping it would
be
> > possible to get hold of something I could use.
> >
> > Chris
> >
>
> I'm using this:
>
> private static string GetCallerInfo()
> {
> StackTrace st = new StackTrace(3);
> return st.GetFrame(0).GetMethod().DeclaringType.FullName +
> "." + st.GetFrame(0).GetMethod().Name;
> }
>
> Sunny



Relevant Pages

  • Re: Determening where a function was called from
    ... > The Trace class in the .NET framework provides basic tracing capabilities. ... > would like to create my own tracer that includes the date and time the trace ... > I had a look at the MethodBase class but I can't find any promising ... Since the call stack is used when getting the stack ...
    (microsoft.public.dotnet.framework)
  • Re: Calling Invoke on a Form results in NullReference
    ... If you're running in debug mode, when you get an exception, the stack ... trace should tell you exactly where the error is. ... Chris ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Determening where a function was called from
    ... The Trace class in the .NET framework provides basic tracing capabilities. ... would like to create my own tracer that includes the date and time the trace ... I had a look at the MethodBase class but I can't find any promising ... Since the call stack is used when getting the stack ...
    (microsoft.public.dotnet.framework)
  • [crash] Re: [PATCH 1/3] tracing/function-graph-tracer: introduce __notrace_funcgraph to filt
    ... Thread overran stack, or stack corrupted ... Not yet verified on this CPU type. ... The following trace is a kernel self test and not a bug! ... # CAN Device Drivers ...
    (Linux-Kernel)
  • Re: [PATCH] ftrace: Documentation
    ... This is one of the options that change the trace itself. ... the fact that there is no comma before the `that' implies that the rest ... The irqsoff tracer tracks the time interrupts are disabled to the time ... +is with the interrupts stack which has that to be false. ...
    (Linux-Kernel)