Debugging in Small Basic is the process of analysing a program to detect and fix errors or improve functionality in some way.

Similar documents
Introduction to IntelliJ

Supplement: Visual C++ Debugging

Chapter 12 Visual Program Debugger

Lab 8 - Vectors, and Debugging. Directions

Programming Logic - Beginning

Under the Debug menu, there are two menu items for executing your code: the Start (F5) option and the

The NetBeans IDE is a big file --- a minimum of around 30 MB. After you have downloaded the file, simply execute the file to install the software.

The NetBeans Debugger: A Brief Tutorial

GDB Tutorial. A Walkthrough with Examples. CMSC Spring Last modified March 22, GDB Tutorial

GETTING STARTED WITH ECLIPSE Caitrin Armstrong

NetBeans Tutorial. For Introduction to Java Programming By Y. Daniel Liang. This tutorial applies to NetBeans 6, 7, or a higher version.

Debugging Code in Access 2002

Code::Blocks Student Manual

Code::Blocks Student Manual

Laboratory Assignment #4 Debugging in Eclipse CDT 1

BasicScript 2.25 User s Guide. May 29, 1996

Parallel Debugging. ª Objective. ª Contents. ª Learn the basics of debugging parallel programs

Introduction. Key features and lab exercises to familiarize new users to the Visual environment

HOW TO USE CODE::BLOCKS IDE FOR COMPUTER PROGRAMMING LABORATORY SESSIONS

7 The Integrated Debugger

JCreator. Starting JCreator

We are built to make mistakes, coded for error. Lewis Thomas

Your code must have been compiled with the -g compiler option. Example:

1 Introduction to MARS

First, let s just try to run the program. When we click the button we get the error message shown below:

BASICS OF THE RENESAS SYNERGY PLATFORM

Setting up a Project and Debugging with Visual Studio

11Debugging and Handling. C# Programming: From Problem Analysis to Program Design 2nd Edition. David McDonald, Ph.D. Director of Emerging Technologies

SQL Server Whitepaper DEMYSTIFYING DEBUGGING TECHNIQUES WITH SQL SERVER BY PINAL DAVE

Visual Studio.NET. Although it is possible to program.net using only the command OVERVIEW OF VISUAL STUDIO.NET

SECTION 2: HW3 Setup.

Chapter 4 Working with Arena

Debugging and testing

VB Net Debugging (Console)

CHAPTER 1. Interface Overview 3 CHAPTER 2. Menus 17 CHAPTER 3. Toolbars and Tools 33 CHAPTER 4. Timelines and Screens 61 CHAPTER 5.

Outline. Debugging. In Class Exercise Solution. Review If Else If. Immediate Program Errors. Function Test Example

After completing this appendix, you will be able to:

Flow of Control: Loops

Creating Breakout - Part 2

Starting Embedded C Programming CM0506 Small Embedded Systems

Enterprise Architect. User Guide Series. Profiling

Enterprise Architect. User Guide Series. Profiling. Author: Sparx Systems. Date: 10/05/2018. Version: 1.0 CREATED WITH

Mastering the Visual LISP Integrated Development Environment

Debugging with GDB and DDT

Debugging INTRODUCTION DEBUGGER WHAT IS VBA'S DEBUGGING ENVIRONMENT?

IDE: Integrated Development Environment

1.00 Lecture 2. What s an IDE?

COPYRIGHTED MATERIAL. Part I: Getting Started. Chapter 1: IDE. Chapter 2: Controls in General. Chapter 3: Program and Module Structure

Step through Your DATA Step: Introducing the DATA Step Debugger in SAS Enterprise Guide

ATMS ACTION TRACKING MANAGEMENT SYSTEM. Quick Start Guide. The ATMS dev team

An Introduction to Komodo

Your code must have been compiled with the -g compiler option. Example:

Prerequisites for Eclipse

Visual Studio.NET. Rex Jaeschke

Supplement H.1: JBuilder X Tutorial. For Introduction to Java Programming, 5E By Y. Daniel Liang

Debugging and Handling Exceptions

Supplement II.B(1): JBuilder X Tutorial. For Introduction to Java Programming By Y. Daniel Liang

the NXT-G programming environment

HPCC - Hrothgar. Getting Started User Guide TotalView. High Performance Computing Center Texas Tech University

Section 2: Developer tools and you. Alex Mariakakis (staff-wide)

Enterprise Architect. User Guide Series. Portals. Author: Sparx Systems. Date: 19/03/2018. Version: 1.0 CREATED WITH

Intro to MS Visual C++ Debugging

Enterprise Architect. User Guide Series. Portals

Chapter 24 Control User Interface

Enterprise Architect. User Guide Series. Portals

Introduction to Computation and Problem Solving

Product Updates TPFUG 2019, Denver

2 Getting Started. Getting Started (v1.8.6) 3/5/2007

We first learn one useful option of gcc. Copy the following C source file to your

Integrated Software Environment. Part 2

CS520 Setting Up the Programming Environment for Windows Suresh Kalathur. For Windows users, download the Java8 SDK as shown below.

Using a debugger. Segmentation fault? GDB to the rescue!

2. Click on the "FREE JAVA DOWNLOAD" button. Note: It will check their PC first and tell them if they have the latest version of Java.

Remodeling Your Office A New Look for the SAS Add-In for Microsoft Office

SECTION 2: Loop Reasoning & HW3 Setup

A Tour of the Scripting System. Contents

Lesson Seven: Holding Gestures

Software Engineering

Using the Xcode Debugger

Excel Intermediate

1 Preface About this Manual Intended Audience Revision History Document Conventions Version...

Keil uvision development story (Adapted from (Valvano, 2014a))

Changing the Embedded World TM. Module 3: Getting Started Debugging

Software Setup and Introductory Assembly programs for the MSP430 *

At the shell prompt, enter idlde

NetBeans IDE Field Guide

MIDI Player Pro v1.3.0 basic users guide By Hans Petter Selasky, November 2015

NEW CEIBO DEBUGGER. Menus and Commands

Tutorial 1 Exploring ArcGIS

SDKs - Eclipse. SENG 403, Tutorial 2

hw6, BFS, debugging CSE 331 Section 5 10/25/12 Slides by Kellen Donohue

1LIVE CHESS BOOK User Manual

Ms. Payne, WCSS. This is very much like asking a question, and having a yes/no answer (also known a true/false). The general structure for this is:

1. Allowed you to see the value of one or more variables, or 2. Indicated where you were in the execution of a program

Software Engineering Testing and Debugging Debugging

Eclipse Tutorial. For Introduction to Java Programming By Y. Daniel Liang

Today s Topic. Software Engineering Testing and Debugging Debugging. Today s Topic. The Main Steps in Systematic Debugging

Flow of Control: Loops. Chapter 4

Teach Yourself Microsoft Word Topic 12 - Multipage Document Features Part 1

6L00IA - Introduction to Synergy Software Package Short Version (SSP v1.2.0) Renesas Synergy Family - S7 Series

Transcription:

How to Debug Introduction Debugging in Small Basic is the process of analysing a program to detect and fix errors or improve functionality in some way. In order to debug a program it must first compile and run with no syntax errors in the source code, so fix these first. Using standard Small Basic the techniques to debug a program mainly rely on adding TextWindow.WriteLine commands or some other way to see the value of variables at key points in the program. Other commands that can be useful are GraphicsWindow.Title (write simple data to the GraphicsWindow title bar), Program.Delay (to slow a dynamic program to see what is happening on the screen) or Sound.PlayClickAndWait (to give an audible indication that some piece of code was executed). This document is about extended debugging using SB-Prime. Overview Debugging runs the program as normal, except that the program can be paused at specific lines of your code. When the program is paused, the current line is highlighted with a yellow background colour. Also, when paused, the values of variables can be checked or even changed. When paused, the program can also be advanced line-by-line so you can see the path taken, for example which branch of an If statement is taken. As well as advancing line by line you can step over or out of subroutines. This means it can be easier to get to a point in your code where something doesn t seem to work as expected. Another way to get the program to pause at a point you want is by setting breakpoints. These can be set at any line in the code and the program will pause when a break-point line is reached. Finally, it is possible to pause the program when the value of a variable changes, or becomes greater than, less than or equal to a certain value. So for example, you want the program to pause when a game score is at a value that is causing problems. So, in summary debugging allows you to trace the route through a program, checking variables as it proceeds, ensuring it is behaving as you want.

Debug Ribbon Bar To debug your program, first make sure it complies and runs. This example shows the PaintProgram.sb sample that comes with Small Basic. Next select the Debug ribbon bar. When the debug ribbon bar is selected, the Debug tab at the bottom of the IDE is also selected. Errors and warnings will continue to be sent to the Output tab, so this can also be checked if any errors occur. For example, you can only debug one program at a time. Occasionally if a program crashes you may have to manually kill the program process, however usually pressing Stop will reset everything to start a new debugging run. Various commands have function key shortcuts, such as F6 to start debugging or F9 to toggle break-points. The function keys are shown in the tooltip for buttons where they are available. Run and Step Commands Start or resume running the program. You can interact normally with the program only while it is running. The program will continue running until it is paused.

Stop and close the current program, if it is running or paused. Pause a running program at its current location. Step to the next statement, this will step into a subroutine if the next statement calls a subroutine. You can also use this to start and pause at the first statement in a program. Step over the next statement. This is the same as the step unless the statement is a subroutine, in which case the entire subroutine is run and the program is paused when the subroutine has completed. Step out will complete the current subroutine and pause when the subroutine is exited. Therefore this method only really applies when you are currently paused within a subroutine. Break Points Toggle setting a break-point on the current line. The program will break and pause when a break-point line is reached. Break-points are shown as red circles on the left of the code window. Break-points can also be set or unset by clicking to the left of the line numbers. A red circle appears in the first column of the left margin when a break-point is set. Remove all break-points. Toggle to temporarily disable all break-points. Book Marks Bookmarks do not interact with the debugger, but can be useful in a long program to quickly move between different sections of the program. Watch Variables Variables may be added to the watch list in the Debug tab at the bottom of the IDE. The variable name may be entered directly. Alternatively a variable may be selected in the program code and added with Ctrl+W or using right click context menu.

Whenever the program is paused the current value of the watch variables will be shown. Various options for the watch variable may be used to change the current value of a variable, or pause the program when the value of the variable changes or becomes greater than or less than or equal to a set value. You can also use the [] notation to watch array elements, e.g. data[5] or data[i]. Variables and Call Stack Use this option to create a window that displays all of the program variable values and subroutine call stack every time the program is paused. Example Using the PainProgram.sb example we are going to set a break-point inside the OnMouseDown event subroutine and set a watch parameter to pause the program when the variable x is greater than 200. Doing this should leave your program looking like this: Now we can either run the program or step into the first line we do the second by pressing Step.

The program is now paused at the first line, the variable x has not been set yet so no value is shown. Note that default values for unset variables in Small Basic is zero, so this could be confusing if you set conditional watch break-points that trigger for a value of zero (e.g. x < 200). Now we can continue by pressing Start/Resume. The program is now running and the GraphicsWindow with a black background appears. We can move our windows or select the GraphicsWindow to interact with it. Draw a line in the left part of the window, x < 200. Hint, make sure you enter the GraphicsWindow from the left, otherwise x may be > 200. As soon as you press the mouse down the program pauses at the break point.

Note that the variable x now has a value. The current value of any variable can also be view when paused by hovering the mouse over a variable name in the program. You can also use the Variables and Call Stack button shows the values of all variables. Advance one step window. to bring up a window that to update the data in this

Now remove the break point in the subroutine OnMouseDown, simply by clicking the red circle in the left margin on line 20. Press to continue the program, and draw a line, this time that has x > 200. At any point when x become greater than 200 the program will pause.

You can experiment changing the conditions for watch variables to pause the code. You can also change the value of a variable by typing a new value in the Value column of the watch list and pressing the Set button. This example is useful to show how to debug, but there is an issue with some aspects of this program under some circumstances. The problem is that the main UI thread actually ends and all the action occurs inside event subroutines. For programs of this type it is sometimes useful to add a dummy Game Loop to keep the main UI thread running, perhaps like this: