Debugging in AnyLogic. Nathaniel Osgood CMPT

Similar documents
NetBeans IDE Field Guide

ICOM 4015 Advanced Programming Laboratory. Chapter 1 Introduction to Eclipse, Java and JUnit

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

Noopur Gupta Eclipse JDT/UI Committer IBM India

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

Debugging in AVR32 Studio

GETTING STARTED WITH ECLIPSE Caitrin Armstrong

The Road to CCSv4. Status Update

NSIGHT ECLIPSE EDITION

IBM VisualAge for Java,Version3.5. Distributed Debugger for Workstations

Laboratory Assignment #4 Debugging in Eclipse CDT 1

Debugging and Profiling

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

Benefits of object-orientationorientation

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Program Correctness and Efficiency. Chapter 2

Application Note: AN00193 Getting Started with Debugging in xtimecomposer

News in RSA-RTE 10.2 updated for sprint Mattias Mohlin, May 2018

CS 201 Software Development Methods Spring Tutorial #1. Eclipse

What s NetBeans? Like Eclipse:

NSIGHT ECLIPSE EDITION

NSIGHT ECLIPSE EDITION

Java Program Structure and Eclipse. Overview. Eclipse Projects and Project Structure. COMP 210: Object-Oriented Programming Lecture Notes 1

A Tutorial for ECE 175

GRLIDE. LEON IDE plugin for Eclipse User's Manual. The most important thing we build is trust GR-LIDE-UM. August 2016, Version 1.

Supplement: Visual C++ Debugging

Le L c e t c ur u e e 5 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Exception Handling

ADT: Eclipse development tools for ATL

ActiveBPEL Fundamentals

Object Oriented Programming

Lab Exercise 1 Using EGit and JUnit

Software Engineering

CS2: Debugging in Java

Basics of Java: Expressions & Statements. Nathaniel Osgood CMPT 858 February 15, 2011

After you create a new project you should be able to access the below windows:

News in RSA-RTE 10.1 updated for sprint Mattias Mohlin, January 2018

Collecting, Outputting & Inputting Data in AnyLogic

Instructions PLEASE READ (notice bold and underlined phrases)

Chapter 1 Getting Started

POOSL IDE Installation Manual

Comp Assignment 2: Object-Oriented Scanning for Numbers, Words, and Quoted Strings

Enterprise Architect. User Guide Series. Profiling

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

Object Oriented Programming Exception Handling

Unit 20: Extensions in ActiveBPEL

Software Project Seminar VII: Tools of the Craft. 23 march 2006 Jevgeni Kabanov

Intro to MS Visual C++ Debugging

Software Engineering Testing and Debugging Debugging

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

News in RSA-RTE 10.1 updated for sprint Mattias Mohlin, November 2017

News in RSA-RTE 10.1 updated for sprint Mattias Mohlin, July 2017

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

IT 540 Operating Systems ECE519 Advanced Operating Systems

ECE 122. Engineering Problem Solving with Java

Simulator. Chapter 4 Tutorial: The SDL

JDB - QUICK GUIDE JDB - INTRODUCTION

CS1004: Intro to CS in Java, Spring 2005

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

Hands-On with STM32 MCU Francesco Conti

BEAJRockit Mission Control. Method Profiling

JBoss IDE Quick Start Guide

Wentworth Institute of Technology. Engineering & Technology WIT COMP1000. Testing and Debugging

Infor LN Studio Application Development Guide

Exceptions in Java

Developing with VMware vcenter Orchestrator. vrealize Orchestrator 5.5.1

CSE 374 Programming Concepts & Tools. Brandon Myers Winter 2015 Lecture 11 gdb and Debugging (Thanks to Hal Perkins)

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

ewon Flexy JAVA J2SE Toolkit User Guide

STARCOUNTER. Technical Overview

EiffelStudio the Eiffel IDE

CHAPTER 1INTRODUCTION... 3 CHAPTER 2INSTALLING ECLIPSE...

CSE 351. GDB Introduction

CSE 374 Programming Concepts & Tools

Eclipse Quick Reference Windows Hosted

Programming II (CS300)

Day 8. COMP1006/1406 Summer M. Jason Hinek Carleton University

DATA STRUCTURE AND ALGORITHM USING PYTHON

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

Error Handling in C++

Application Note: AN00198 Getting Started with Simulator Tracing in xtimecomposer Studio

Lab 0 Introduction to the MSP430F5529 Launchpad-based Lab Board and Code Composer Studio

Android Debug Framework

Getting Started (1.8.7) 9/2/2009

1.00 Lecture 2. What s an IDE?

Laboratory 1: Eclipse and Karel the Robot

Chapter 12 Visual Program Debugger

BASICS OF THE RENESAS SYNERGY PLATFORM

Checked and Unchecked Exceptions in Java

The Perl Debugger. Avoiding Bugs with Warnings and Strict. Daniel Allen. Abstract

Exception Handling Introduction. Error-Prevention Tip 13.1 OBJECTIVES

TogoDocClient Plug-ins development manual. TogoDocClient plug-ins development manual

Before you start with this tutorial, you need to know basic Java programming.

Mastering the Visual LISP Integrated Development Environment

7 The Integrated Debugger

Debugging Java in Agents, Script Libraries, and XPages

Flint - Eclipse Based IDE User Manual

Steps for project success. git status. Milestones. Deliverables. Homework 1 submitted Homework 2 will be posted October 26.

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

Module Road Map. 7. Version Control with Subversion Introduction Terminology

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

Transcription:

Debugging in AnyLogic Nathaniel Osgood CMPT 858 4-5-2011

Avoiding Debugging Defensive Programming Offensive Programming

Offensive Programming: Try to Get Broken Program to Fail Early, Hard Asserts: Actually quit the program Fill memory allocated with illegal values Fill object w/illegal data just before deletion Set buffers at end of heap, so that overwrites likely trigger page fault Setting default values to be illegal in enums We will talk about Assertions & Error Handling later this week

Assertion Goal: Fail Early! Alert programmer to misplaced assumptions as early as possible Benefits Documents assumptions Reduces likelihood that error will slip through Helps discourage lazy handling of only common case Forces developer to deal explicitly with bug before continuing Reduces debugging time Helps improve thoroughness of tests

Avoid Side Effects in Assertions Because assertions may be completely removed from the program, it is unsafe to rely on side effects occuring in them Arnold et al. The Java Programming Language, Fourth Edition. 2006.

Enabling Assertions in AnyLogic

Arnold et al. The Java Programming Language, Fourth Edition. 2006. Enabling Assertions in Java 2 ways Usual: Via java runtime command line e.g. Less common: via reflection (ClassLoader)

Debugging AnyLogic Debugging is the process of locating the faults behind observed failures AnyLogic s education now contains a debugger You can attach to AnyLogic from debuggers such as eclipse The key thing is to set anylogic to use a port

Debugging Options Using output for manual tracing & reporting Using AspectJ & tracing Using an external debugger (e.g. via eclipse) Using AnyLogic Professional/Research debugger

Using output for manual tracing & reporting Pros Minimal learning curve Flexible Easily targeted Cons Requires time-consuming manual markup de-markup Can require many build/simulation iterations to localize problem Limited capacity of console

Output to the Console: How To System.err.println(String) System.err.println("Sent cure message to person [" + associatedperson + "]"); traceln(string) System.out.println(String)

Use in AnyLogic

AspectJ and Eclipse AspectJ is a language that allows for succinctly describing cross cutting functionality in programs such as tracing or logging requests AspectJ can automatically insert tracing instrumentation into our code This gives us many of the benefits of manual tracing program execution without the need for the markup & mark-down work

AnyLogic Built-in Debugger

Running the Debugger

Running the Models

Setting a Breakpoint

When we Hit the Breakpoint

Components to Direct Execution

Visible ( In-Scope ) Variables

Exploring Composite Variable Values in the Debugger

Inspecting Composite Variables

Changing Variable Values During Debugging

Stepping into Auto-Generated Code

Seeing Result of Expression Evaluation Note that this doesn t update immediate may need to switch stack frames in the Debug method To see the update

External Debugging in Eclipse The Eclipse editor is one of the most popular extant software development tools Eclipse offers plug-ins of many sorts Debuggers Profilers Visualization tools Version control of models Eclipse can be used to debug AnyLogic models at the Java source-code level

Steps Required for Eclipse Debugging One time set-up for a particular model Set up AnyLogic to allow debugging connections Set up Eclipse to know How to connect to AnyLogic Where to look for source code files Every time want to debug Go to Eclipse Tell debugger to connect to AnyLogic process Interrupt process Set breakpoints, etc.

Setup In AnyLogic -Xdebug -Xnoagent -Djava.compiler=NONE - Xrunjdwp:transport=dt_socket,server=y,suspe nd=n,address=8321 These go under the "Advanced" tab of the simulation run to use

Set up: Creating a Debugging Configuration in Eclipse

Setting Up Source Code Folders

Add Source Folder

Once Set up, Can Set breakpoints See the variables, with symbolic information Suggestions Set a breakpoint on a thrown runtime exception (regardless of whether caught) Throw a caught runtime exception from model startup code When catch this in Eclipse, can then use to set breakpoints (including in other files)

Example Setup: Set up Function to Trigger the Debugger

In Startup Code for Model, Call Function

In Eclipse, Open Debug Perspective

Request Creation of Exception Breakpoint

Request as Breakpoint Regardless of Handling

Should Now be in List of Enabled Breakpoints

Start AnyLogic Model (Experiment with Extra Debugging JVM Arguments)

Leave on Opening Screen for Now (So We can Set up Eclipse)

Go To Eclipse & Request AnyLogic Debugging Debug Configuration (previously set up)

Should Immediately See Something Like This

Return to AnyLogic & Start Simulation via Button Push

Back in Eclipse, the Debugger Should have been Triggered & at Exception Handler (If not, close Main.java and double-click on topmost stack frame (Where Exception is triggered

Now Can Set Breakpoints in Main.java or Elsewhere (Here: Person.java)

Warning: Breakpoints are Not Shown in Source Window Just in Breakpoints area

Press Resume to Continue Awaiting a Breakpoint

Example Breakpoint in Main

Example Breakpoint in Person

Once at Breakpoint, Can Look at Variables, Single Step, etc.

Variables Displayed

Terminating Execution from AnyLogic Console

Eclipse is Now Detached

Remembering Breakpoints Note Eclipse does remember breakpoints from session to session So breakpoints that set earlier in an anylogic session will work again even after close eclipse and restart it again Suggestions Consider creating a common breakpoints (e.g. at Main.start) Disable and enable breakpoints rather than deleting them

Example of Debugging Session