.NET equilavent to C's backtrace(), or How do I find a calling function?

.NET equilavent to C's backtrace(), or How do I find a calling function?

Post by cmn_ » Sat, 06 May 2006 01:13:42


My problem is this:

I am programming an application in C#.NET / WinForms. It contains a
MonthCalendar, and whenever the DateChanged event is fired, and *only*
when changing the month, the application goes into an infinite loop.
The event procedure is in a seperate thread, although I'd rather not
post it here until asked (there's a *lot* of code there).

On top of this, the event procedure is called from several places in
the code. How would I find which function called the event procedure in
code? If there is no way to find the caller of the function, is there
something like the Backtrace() function in the Standard C Library?
(btw, yes I am a C rather than C# coder...)
 
 
 

.NET equilavent to C's backtrace(), or How do I find a calling function?

Post by Ben Voig » Sat, 06 May 2006 01:18:58


Exception.StackTrace or Environment.StackTrace

Or count the number of times through the loop and add a condition (if
hitCount > 15 {}) where you can put a de *** breakpoint inside and inspect
callstack and variables using the de *** .

 
 
 

.NET equilavent to C's backtrace(), or How do I find a calling function?

Post by cmn_ » Sat, 06 May 2006 01:29:42

Thanks! Exactly what I was looking for, both points.

Cheers

Chris
 
 
 

.NET equilavent to C's backtrace(), or How do I find a calling function?

Post by Carl Danie » Sat, 06 May 2006 08:59:49


FWIW, there's no such function in the standard C library as backtrace -
that's strictly a GNU libc extension.

As Ben already replied, you can get the precise stack trace from
Environment.StackTrace.

-cd