Supplement: Visual C++ Debugging

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

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

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

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

Intro to MS Visual C++ Debugging

The NetBeans Debugger: A Brief Tutorial

Introduction to IntelliJ

Lab 8 - Vectors, and Debugging. Directions

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

A Tutorial for ECE 175

7 The Integrated Debugger

SQL Server. Management Studio. Chapter 3. In This Chapter. Management Studio. c Introduction to SQL Server

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

1 Introduction to MARS

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

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

Debugging INTRODUCTION DEBUGGER WHAT IS VBA'S DEBUGGING ENVIRONMENT?

Using the Xcode Debugger

Chapter 12 Visual Program Debugger

NEW CEIBO DEBUGGER. Menus and Commands

Code::Blocks Student Manual

BasicScript 2.25 User s Guide. May 29, 1996

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

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

Code::Blocks Student Manual

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

BASICS OF THE RENESAS SYNERGY PLATFORM

Programming Logic - Beginning

CPE 323: Laboratory Assignment #1 Getting Started with the MSP430 IAR Embedded Workbench

1.2 - Introduction to the IAR Workbench IDE *

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

Using Visual Studio.NET: IntelliSense and Debugging

Flow of Control: Loops

JCreator. Starting JCreator

IBM i Debugger. Overview Service Entry Points Debugger Functions Attach to an IBM i Job Launch Configurations and Settings

After completing this appendix, you will be able to:

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

Laboratory Assignment #4 Debugging in Eclipse CDT 1

A Quick Introduction to MPLAB SIM

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

Debugging with PyCharm ~0~ What does it mean to debug a program?

Project Debugging with MDK-ARM

1. Move your mouse to the location you wish text to appear in the document. 2. Click the mouse. The insertion point appears.

Cloverleaf Education Webinar Debugging your translations with the Cloverleaf Translate Debugger

Use the Template Editor function to create and maintain templates used in the e-note module. Click anywhere to continue

An Introduction to Komodo

II. Compiling and launching from Command-Line, IDE A simple JAVA program

Assembly Programming in Atmel Studio 7 Step by Step Tutorial

5/19/2015. Objectives. JavaScript, Sixth Edition. Understanding Syntax Errors. Introduction to Debugging. Handling Run-Time Errors

EiffelStudio the Eiffel IDE

Zend Studio 3.0. Quick Start Guide

Click the buttons in the interactive below to learn how to navigate the Access window.

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

When the AT breakpoint is reached, the AT Display screen shows your sourceless program in dump format.

Introduction to C/C++ Programming

VB Net Debugging (Console)

Starting Embedded C Programming CM0506 Small Embedded Systems

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

GETTING STARTED WITH ECLIPSE Caitrin Armstrong

Computer Science II Lab 3 Testing and Debugging

Enterprise Architect. User Guide Series. Portals

Enterprise Architect. User Guide Series. Portals

Enterprise Architect. User Guide Series. Profiling

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

3 TUTORIAL. In This Chapter. Figure 1-0. Table 1-0. Listing 1-0.

Getting Started (1.8.7) 9/2/2009

QTP interview questions

MODEL-BASED DEVELOPMENT -TUTORIAL

International Journal of Current Research and Modern Education (IJCRME) ISSN (Online): ( Volume I, Issue II, 2016

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.

Chapter 15 Debugging

Working with Macros. Creating a Macro

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

If this is the first time you have run SSMS, I recommend setting up the startup options so that the environment is set up the way you want it.

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

Lab 3-2: Exploring the Heap

Indium Documentation. Release Nicolas Petton

Telerik Corp. Test Studio Standalone & Visual Studio Plug-In Quick-Start Guide

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

Start Active-HDL. Create a new workspace TUTORIAL #1 CREATING AND SIMULATING SIMPLE SCHEMATICS

Introduction. This tutorial introduces the following SingleStep features:

Software Development With Emacs: The Edit-Compile-Debug Cycle

MPLAB SIM. MPLAB IDE Software Simulation Engine Microchip Technology Incorporated MPLAB SIM Software Simulation Engine

Flow of Control: Loops. Chapter 4

Creating Relationships in Primavera P Powered by POeT Solvers Limited

C Programming in Atmel Studio 7 Step by Step Tutorial

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

Integration for CodeBlocks

EXECUTION OF METHODS

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

Debugging in AVR32 Studio

H8 C-SPY. User Guide WINDOWS WORKBENCH VERSION

The Debug Perspective in Eclipse for Python A Reference and Tutorial

1. Open the folder called TI APPS and Emulators. 2. Open the folder called 83plus emulator

Training Simulator and Demo Software

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

Setting up a Project and Debugging with Visual Studio

Resource 2 Embedded computer and development environment

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

Visual Studio.NET. Rex Jaeschke

Transcription:

Supplement: Visual C++ Debugging For Introduction to C++ Programming By Y. Daniel Liang Note: The screen shots are taken from VC++ 2010. It is the same for the later version. 1 Introduction The debugger utility is integrated in VC++. You can pinpoint bugs in your program with the help of the VC++ debugger without leaving the IDE. The VC++ debugger enables you to set breakpoints and execute programs line by line. As your program executes, you can watch the values stored in variables, observe which functions are being called, and know what events have occurred in the program. Let us use Listing 2.11, ShowCurrentTime.cpp, to demonstrate debugging. Create a new program named ShowCurrentTime.cpp. The source code for ShowCurrentTime.cpp can be obtained from the book. 2 Setting Breakpoints You can execute a program line by line to trace it, but this is time-consuming if you are debugging a large program. Often, you know that some parts of the program work fine. It makes no sense to trace these parts when you only need to trace the lines of code that are likely to have bugs. In cases of this kind, you can use breakpoints. A breakpoint is a stop sign placed on a line of source code that tells the debugger to pause when this line is encountered. The debugger executes every line until it encounters a breakpoint, so you can trace the part of the program at the breakpoint. Using the breakpoint, you can quickly move over the sections you know work correctly and concentrate on the sections causing problems. There are several ways to set a breakpoint on a line. One quick way is to click the cutter of the line on which you want to put a breakpoint. You will see the line highlighted, as shown in Figure 1. You also can set breakpoints by choosing Run, Add Breakpoint. To remove a breakpoint, simply click the cutter of the line. As you debug your program, you can set as many breakpoints as you want, and can remove breakpoints at any time during debugging. The project retains the breakpoints you have set when you exit the project. The breakpoints are restored when you reopen it. 1

Figure 1 A breakpoint is set in ShowCurrentTime.cpp. 3 Starting the Debugger To start debugging, set a break point at the first line in the main function and choose Debug, Start (or F5). If the program compiles without problems, debugging starts. You will see two debugging windows (Autos and Call Stack) appearing at the bottom, as shown in Figure 2. If these windows do not appear, choose Debug, Windows to open these windows. 2

Figure 2 The debugging windows appear in the IDE. The Autos window displays variables and expressions from the current line of code, and the preceding line of code. See Figure 3. This window has tabs Locals, Thread, Module, and Watch at the bottom. The Locals tab (see Figure 4) displays all local variables in the current block of code. If you are inside of a function, the locals tab will display the function parameters and locally defined variables. The Watch tab (see Figure 5) display a variable state until you explicitly remove it from the window. You can add a variable to the watch window by right clicking a variable and selecting Add Watch. 3

Figure 3 The Autos window displays the variable in the current line. 4

Figure 4 The Locals window displays all variables in the block. 5

Figure 5 The Watchs window displays the variables you want to watch for. 4 Controlling Program Execution The program pauses at a line called the current execution point. This line is highlighted and has a yellow arrow to the left. The execution point marks the next line of source code to be executed by the debugger. When the program pauses at the execution point, you can issue debugging commands to control the execution of the program. You also can inspect or modify the values of variables in the program. When VC++ is in the debugging mode, the Debug menu contains the debugging commands (see Figure 6). Most of the commands also appear in the toolbar under the message pane. The toolbar contains additional commands that are not in the Run menu. Here are the commands for controlling program execution: Step Over executes a single statement. If the statement contains a call to a function, the entire function is executed without stepping through it. 6

Step Into executes a single statement or steps into a function. Step Out executes all the statements in the current function and returns to its caller. Figure 6 The debugging commands appear under the Degub menu. NOTE: The debugger is an indispensable, powerful tool that boosts your programming productivity. It may take you some time to become familiar with it, but your investment will pay off in the long run. 7