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

Similar documents
Prerequisites for Eclipse

Laboratory Assignment #4 Debugging in Eclipse CDT 1

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

At the shell prompt, enter idlde

GETTING STARTED WITH ECLIPSE Caitrin Armstrong

SDKs - Eclipse. SENG 403, Tutorial 2

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

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

JCreator. Starting JCreator

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

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

7 The Integrated Debugger

Part I. Integrated Development Environment. Chapter 2: The Solution Explorer, Toolbox, and Properties. Chapter 3: Options and Customizations

ECE QNX Real-time Lab

The Road to CCSv4. Status Update

Resource 2 Embedded computer and development environment

Migration from HEW to e 2 studio Development Tools > IDEs

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

Debugging INTRODUCTION DEBUGGER WHAT IS VBA'S DEBUGGING ENVIRONMENT?

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

Enterprise Architect. User Guide Series. Profiling

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

BasicScript 2.25 User s Guide. May 29, 1996

Eclipse Quick Reference Windows Hosted

3 Getting Started with Objects

2 The Stata user interface

Noopur Gupta Eclipse JDT/UI Committer IBM India

QNX Software Development Platform 6.6. Quickstart Guide

Figure 1. Simplicity Studio

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

AURIX family and AUDO Future, AUDO MAX

COBOL-IT Developer Studio Getting Started The Debugger Perspective Version 2.0

A Quick Tour GETTING STARTED WHAT S IN THIS CHAPTER?

Infor LN Studio Application Development Guide

ActiveBPEL Fundamentals

TriCore Free Entry Tool Chain. AURIX family and AUDO Future, AUDO MAX

BASICS OF THE RENESAS SYNERGY PLATFORM

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

NonStop Development Environment for Eclipse 4.0 Debugging Supplement

Express Yourself. What is Eclipse?

ARM DS-5. Using the Debugger. Copyright 2010 ARM. All rights reserved. ARM DUI 0446A (ID070310)

DS-5 ARM. Using Eclipse. Version Copyright ARM. All rights reserved. ARM DUI 0480L (ID100912)

Getting Started (1.8.7) 9/2/2009

BASICS OF THE RENESAS SYNERGY PLATFORM

Table of Contents. 1 Introduction Downloads Eclipse SDK Installation Eclipse Workspace Eclipse Preferences...

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

Table of Contents HOL-SDC-1422

Debugging in AVR32 Studio

Mehran Sahami Handout #5 CS 106A September 26, 2018 Downloading Eclipse

A quick guide to installing the SpesCoin Wallet for Windows and MacOS users SPESCOIN WALLET. Installation Guide

Assignment 1. Application Development

Code::Blocks Student Manual

The NetBeans Debugger: A Brief Tutorial

Maintain an ILE RPG application using Remote System Explorer

An Introduction to Eclipse: Quick Guide. Part 1: Getting Started with Eclipse Part 2: Working with Eclipse Useful Online Guides

Module 3: Working with C/C++

IBM ILOG OPL IDE Reference

DOMAIN TECHNOLOGIES. Getting Started Guide Version 1.1. BoxView IDE. Integrated Development Environment

Test/Debug Guide. Reference Pages. Test/Debug Guide. Site Map Index

WPS Workbench. user guide. "To help guide you through using the WPS user interface (Workbench) to create, edit and run programs"

NEW CEIBO DEBUGGER. Menus and Commands

Supplement: Visual C++ Debugging

Mehran Sahami Handout #5 CS 106A September 27, 2017 Downloading Eclipse

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

Code::Blocks Student Manual

Eclipse Environment Setup

Enterprise Architect. User Guide Series. Portals

CSCI0330 Intro Computer Systems Doeppner. Lab 02 - Tools Lab. Due: Sunday, September 23, 2018 at 6:00 PM. 1 Introduction 0.

INF 111 / CSE 121. Homework 3: Code Reading

Introduction to Eclipse

egui Eclipse User Guide

BASICS OF THE RENESAS SYNERGY TM

Section 1 AVR Studio User Guide

CSCI 201 Lab 1 Environment Setup

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.

i2b2 Workbench Developer s Guide: Eclipse Neon & i2b2 Source Code

After completing this appendix, you will be able to:

POOSL IDE Installation Manual

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

Using SQL Developer. Oracle University and Egabi Solutions use only

Starting the KVM Console

Optional Eclipse Workspace Configurations

Drools Tools Reference Guide. Version: CR1

Introduction to Eclipse Rich Client Platform Support in IBM Rational HATS. For IBM System i (5250)

Function names can be specified with winidea syntax for qualified names, if multiple download files and file static functions are tested.

Debugging. CSE 2231 Supplement A Annatala Wolf

COMP 110/401 APPENDIX: INSTALLING AND USING ECLIPSE. Instructor: Prasun Dewan (FB 150,

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

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

Introduction to Eclipse Rich Client Platform Support in IBM Rational HATS For IBM System i (5250)

Lab 3a: Scheduling Tasks with uvision and RTX

Quick-Start Guide. BNS Solutions. QSK62P Plus

Your password is: firstpw

Freescale Semiconductor Inc. Vybrid DS-5 Getting Started Guide Rev 1.0

Oracle Enterprise Manager Oracle Database and Application Testing. Application Testing Suite Lab. Session S318966

Eclipse Debug Find Current Instruction Pointer

Eclipse Setup. Opening Eclipse. Setting Up Eclipse for CS15

CS 201 Software Development Methods Spring Tutorial #1. Eclipse

Rapid SQL Developer Debugger 2.1 User Guide

Transcription:

Debugging in Eclipse Debugging 1 We are built to make mistakes, coded for error. Lewis Thomas It is one thing to show a man that he is in error, and another to put him in possession of the truth. John Locke

Prerequisites for Eclipse Debugging 2 To use Eclipse you must have an installed version of the Java Runtime Environment (JRE). The latest version is available from java.com. Since Eclipse includes its own Java compiler, it is not strictly necessary to have a version of the Java Development Kit (JDK) installed on your computer. However, I recommend installing one anyway so that you can test your code against the "real" Java compiler. The latest version is available from: www.oracle.com/technetwork/java/ If you install the JDK, I recommend putting it in a root-level directory, and making sure there are no spaces in the pathname for the directory.

Eclipse Workbench Debugging 3 The initial Eclipse Workbench (my configuration): Minimize View Maximize View Restore View Restore View Hover for info

Eclipse Java Perspective Toolbar Debugging 4 Choose a Perspective New Project / Save / Save All / Print Build Project Start Debugging + configurations Run Project + configurations Run Last Tool + configurations

Eclipse Java Perspective Toolbar Debugging 5 New Java Project / Package / Class Open Type / Open Task / Search + options Go to last edit location Back/Next + more navigation options

Creating a New Java Project Debugging 6 In the Workbench, select File/New/Java Project:

Creating a New Java Project Debugging 7 In the resulting dialog box: Enter a name for the Project. For now, just take the defaults for the remaining options. Click Next and then Finish in the next dialog.

Adding Source for the DList Example Debugging 8 Download the file DListExample.zip from the course website Resources page, and place the contents into the src directory for the Eclipse project you just created:

Performing a Build Debugging 9 Back in Eclipse, right-click on the project icon for DList and select Refresh Use the Project menu or click on the Build All button ( ) to compile the code.

Running the Program Debugging 10 To execute the program, click on the Run button ( ). As indicated by the source code, the test driver writes its output to a file named Log.txt: display of initial list display of list after deleting 5 Unfortunately, there appears to be an error; the value 5 should have been added to the list and appear in the final listing of the contents it's not there. display of list after reinserting 5

Controlling Execution Debugging 11 Now, we have some clues about the error: The list appears to be OK after the first for loop completes; that doesn't indicate any problems with the add() method called there. The list appears to be OK after the call to the removefirstoccurrenceof() method; that doesn't indicate any problems there. The list is missing an element after the call to the second add() method; that seems to indicate the problem lies there It would be useful to be able to run the program to a certain point, check the state of the list (and perhaps other variables), and then step carefully through the subsequent execution, watching just how things change. Fortunately, Eclipse provides considerable support for doing just that.

Kinds of Breakpoints Debugging 12 A breakpoint marks a location or condition under which we want the program's execution to be suspended. Eclipse supports setting four kinds of breakpoints: line breakpoint method breakpoint expression breakpoint exception breakpoint halt when execution reaches a specific statement halt when execution enters/exits a specific method halt when a user-defined condition becomes true, or changes value halt when a particular Java exception occurs (caught or not)

Setting a Line Breakpoint Debugging 13 line breakpoint halt when execution reaches a specific statement To set one, just double-click in the editor margin next to the selected line of code:

Running to a Breakpoint Debugging 14 Go to the Run menu and select Debug (or use the keyboard shortcut F11):

Debug Perspective Debugging 15 This opens the Debug Perspective: Source Variables Execution stack You may see a different window layout; feel free to close other Views, like Outline if they are visible.

Using the Variables View Debugging 16 At this point, the list constructor has run let's examine the structure: Objects are assigned unique IDs as they are created; these allow us to infer the physical structure

Using the Variables View Examine the values of the fields of front and rear: Debugging 17 26: list 28: list.front 30: list.rear 28 front.elem front.next front.prev 30 rear.elem OK, that looks just fine two guard nodes pointing at each other, neither holding a data value. rear.next rear.prev

The Debug Toolbar Debugging 18 1 2 3 4 5 6 7 8 9 10 1. Resume Continues execution until breakpoint or thread ends 2. Suspend Interrupts a running thread 3. Terminate Ends the execution of the selected thread 4. Disconnect Disconnect from a remote debugging session 5. Remove terminated launches Closes all terminated debug sessions 6. Step Into Steps into a method and executes its first line of code 7. Step Over Executes the next line of code in the current method 8. Step Return Continues execution until the end of the current method (until a return) 9. Drop to Frame Returns to a previous stack frame 10.Step with Filters Continues execution until the next line of code which is not filtered out

Step-by-step Execution Debugging 19 For illustration, we'll examine the insertion of the first data node, step by step: Note the appearance of the variable i and its value.

Step-by-step Execution Debugging 20 Click the step-into button again; now we'll enter the call to add(): Now, I don't really want to trace the constructor, much less the call to new, so this time I'll click the step-over button

Step-over versus Step-into Debugging 21 The difference is that if you are executing a method call (or invoking new, for example) in the current statement: step-into step-over takes you into the implementation of that method calls the method, but does not step you through its execution Both are useful step-into is frustrating when system code is involved.

Step-by-step Execution Debugging 22 So, we see that the needed node has been properly initialized:

Step-by-step Execution Debugging 23 Three clicks on step-over (or step-into) bring us to this point:

Checking the List Structure Debugging 24 26: list 28: list.front 30: list.rear 31 0 28 front.elem front.next front.prev 36: toadd toadd.elem toadd.prev toadd.next 30 Well, that looks OK. rear.elem rear.next rear.prev

Resetting Breakpoints and Resuming Debugging 25 OK, we've confirmed that the first data node is inserted properly; now we can remove the breakpoint at the for loop, and set one at the call to the removefirstoccurrenceof() method, and then click Resume to continue execution:

After Resuming the List is Constructed Debugging 26 Execution proceeds to the new breakpoint:

Complete List Structure Debugging 27 26: list 28 36 0 37 1 43 4 45 5 47 6 30 53 9

Step Into removefirstoccurrenceof() Debugging 28 Use step-into and proceed to the while loop that will walk to the first occurrence of the target value:

In removefirstoccurrenceof() Debugging 29 Continue stepping until current reaches the node holding the target value:

At End of removefirstoccurrenceof() Debugging 30 Continue stepping through the if statement and examine the list structure right before the return is executed:

List Details Debugging 31 Does the list structure seem to be OK? 26: list 28 36 0 37 1 43 4 47 6 30 53 9

Buggered List Structure (more detail) Debugging 32 A careful examination indicates that something odd has happened: OK?? 45 5 43 4 Apparently the removal method did not correctly reset the prev pointer in the node after the node that was removed from the list. We should check that 47 6

Another Error Debugging 33 A careful examination also reveals another bug

A Look at the Code Debugging 34 It should be obvious that two statements are missing from the given code

Testing Again Debugging 35 Let's execute the modified program: display of initial list display of list after deleting 5 Now, the list contents seem to be correct so, more testing is in order display of list after reinserting 5

Method Breakpoints Debugging 36 method breakpoint halt when execution enters and/or exits a selected method To set one, just double-click in the editor margin next to the method header: By default, this causes a break when execution enters the method

Breakpoint View Debugging 37 Go to Window/Show View and open the Breakpoint View. You can right-click on a selected breakpoint to alter its properties:

Breakpoint View Toolbar Debugging 38 1 2 3 4 5 6 7 8 9 1 remove selected breakpoints 2 remove all breakpoints 3 show breakpoints 4 go to file for breakpoint 5 skip all breakpoints 6 expand all (details) 7 collapse all (details) 8 link with the Debug View 9 set a Java exception breakpoint

Exception Breakpoints Debugging 39