Allen
Allen

Reputation: 927

When Debugging in Visual Studio, how do I view the function call hierarchy/stack in the IDE?

In VB.net, I am aware that you can use a stack trace to get the function call hierarchy that lead to an exception.

However, I also know that if you are debugging and an exception is generated, you can view this information right in the IDE... (if you have the right version or settings?)

Allow me to explain:

Say I write a subroutine as follows:

Public Shared Sub DoSomethingFoolish()
    Dim x As integer = 0
    Dim y As integer = 1 / i 'can't do this
End Sub

If I run this in debug mode, the when the bad line is executed, I will get an error, and the debugging will stop. The bad line will be highlighted, and I can view what the error was (divide by zero, in this case)

This line would be highlighted:

Dim y As integer = 1 / i 'can't do this

(this is what I have currently)


However, lets say I have 5 locations in my program where I make a call to DoSomethingFoolish().

I know that there is a way that you can traverse your way up the call heirarchy.

Ex, the call might have been made from here:

Public Shared Sub MaybeDoSomethingFoolish()
    If DareIActAFool = True Then
            DoSomethingFoolish()
    End If
End Sub

And by traversing the heirarchy, I could what line in this subroutine caused the error, and it would be highlighted as well:

DoSomethingFoolish()

(I am not getting this information now, but I did on a previous install)


From there, I could look at where MaybeDoSomethingFoolish() was called from, etc. until I reached a 'starting point' of sorts, ie a button click event or a form load event. (I am only looking for the call heirarchy / stack trace from the code I wrote.)


I know there was a way to view this in the IDE, because I was able to do it a few weeks ago. I was recently upgraded to Windows 7 at my work machine. I am wondering why I lost this ability.

Is it a setting that I can change somewhere?

Was I given an inferior version of Visual Studio? (I have VS 2010 Professional now)


I apologise if this is a stupid question, but when I tried searching the internet for an answer, all I found was a bunch of people talking about this thing:

Dim ST As New StackTrace()
msgbox(ST.ToString())

which is not what I am looking for. I am probably using the wrong keywords.

The debugging mode I am referring to allowed you to view basically the same information, but right in the IDE and it didn't require inserting any code, nor did it require me to read through the text in the stack trace information and navigate there manually in the source. It was point and click.

Upvotes: 1

Views: 1772

Answers (1)

RBarryYoung
RBarryYoung

Reputation: 56725

To view the current Call Stack while paused try

Debug> Windows> Call Stack

Or

Ctrl+Alt+C

Upvotes: 4

Related Questions