. .


ST 4U 81: Using Breakpoints in VA

May 11, 2011 7:30:49.617

Today's Smalltalk 4 You takes an overview look at the debugger in VA Smalltalk. If you prefer a written walkthrough to video, then skip down to it. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

VA Debugger

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Today we'll take a little deeper look at the VA Smalltalk debugger. This tool has a lot of functionality, so it'll take more than this tutorial to cover the entire tool. To start with, we've created a simple Counter class. This gives us a jumping off place beyond the workspace to work with the debugger. The class is pretty simple - it has one instance variable, and two api methods to either increment or decrement the counter:

Counter Class

Next we'll script some simple interactions with the object in a workspace. To simulate a more complex bug, we've implemented a simple bug in the subtraction method:

Execute the Code

Having discovered that the decrement functionality doesn't work right, we'll go to the browser and put a breakpoint in. Again, this example is very simple; the idea is to show you how to use breakpoints. Put the cursor down in the method where you want the breakpoint, right click, and select Break:

Insert a Breakpoint

It turns out that you can configure your breakpoint -

Configure a Breakpoint

  • Select a specific process for which this breakpoint applies (ignoring it in all others)
  • If this code is in a loop, break on a specific iteration
  • Specify a boolean condition for which the break applies

If you let all of those default, then the breakpoint will halt your code anytime it is reached - yielding a debugger. Once you have inserted the breakpoint, you'll see a little red indicator appear in the browser:

Breakpoint Added

Now let's return to the workspace, and exercise the code that should hit the breakpoint:

Execute the Code

Now we've landed in the debugger. The top pane contains the context stack - all of the methods that were in the process of executing when we hit the break. To the right you'll see an inspector for all variables - temps, instance, and method arguments. At the bottom, you have the code pane. Since this is Smalltalk, you can change the code. Note that recompiling the code will remove the breakpoint.

In the Debugger

Now, if you hit the Break option in the debugger or browser while you have the cursor at the right place (where you inserted it), the options differ a bit:

Break Options

If you deactivate the break, the marker will change to yellow:

Break Deactivated

Finally, if you select Clear, the breakpoint will be removed.

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Technorati Tags: , , , ,

[st4u81-iPhone.m4v ( Size: 8781165 )]

posted by James Robertson

 Share Tweet This