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

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

Using the Debugger. Michael Jantz Dr. Prasad Kulkarni

Programming Logic - Beginning

You can also start with both an executable program and a core file specified:

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

Using gdb to find the point of failure

CSE 351. GDB Introduction

The NetBeans Debugger: A Brief Tutorial

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

Code::Blocks Student Manual

Supplement: Visual C++ Debugging

Intro to MS Visual C++ Debugging

Princeton University COS 217: Introduction to Programming Systems GDB Tutorial and Reference for x86-64 Assembly Language

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

Code::Blocks Student Manual

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

Laboratory Assignment #4 Debugging in Eclipse CDT 1

Debugging Techniques. CEFET Engineering Week

Exercise Session 6 Computer Architecture and Systems Programming

Basic functions of a debugger

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

Princeton University COS 217: Introduction to Programming Systems GDB Tutorial and Reference

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.

Starting Embedded C Programming CM0506 Small Embedded Systems

Eclipse CDT Tutorial. Eclipse CDT Homepage: Tutorial written by: James D Aniello

Libgdb. Version 0.3 Oct Thomas Lord

Debugging and Debugger. Terminology. GNU gcc and gdb. Debugging C programs in Unix and Windows Environments - Part One

Programming Tips for CS758/858

Source level debugging. October 18, 2016

SGI Altix Getting Correct Code Reiner Vogelsang SGI GmbH

Laboratory 1 Semester 1 11/12

CSE 374 Programming Concepts & Tools

Introduction to IntelliJ

Hands-on Workshop on How To Debug Codes at the Institute

Problem Set 1: Unix Commands 1

GDB QUICK REFERENCE GDB Version 4

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

1.00 Lecture 2. What s an IDE?

Lab 8 - Vectors, and Debugging. Directions

Debugging (Part 1) The material for this lecture is drawn, in part, from The Practice of Programming (Kernighan & Pike) Chapter 5

File Access. FILE * fopen(const char *name, const char * mode);

1 A Brief Introduction To GDB

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

CS 11 C track: lecture 6

CS 270 Systems Programming. Debugging Tools. CS 270: Systems Programming. Instructor: Raphael Finkel

UPDATING YOUR POS SOLUTIONS NEWSAGENCY SYSTEM

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information

Codewarrior for ColdFire (Eclipse) 10.0 Setup

Section 1: Tools. Kaifei Chen, Luca Zuccarini. January 23, Make Motivation How... 2

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

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger.

Lab6 GDB debugging. Conventions. Department of Computer Science and Information Engineering National Taiwan University

Simulator. Chapter 4 Tutorial: The SDL

1 Basic functions of a debugger

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

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

GDB Tutorial. University of Waterloo

Here's how you declare a function that returns a pointer to a character:

Programming Studio #9 ECE 190

12. Debugging. Overview. COMP1917: Computing 1. Developing Programs. The Programming Cycle. Programming cycle. Do-it-yourself debugging

TotalView Debugger New Features Guide. version 8.4.0

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

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

ALD Assembly Language Debugger Copyright (C) Patrick Alken

Should you know scanf and printf?

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

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

Coordinator of Education and Training Programs

Lab 4. Out: Friday, February 25th, 2005

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

Development Environment of Embedded System

18-600: Recitation #3

Navigating in SPSS. C h a p t e r 2 OBJECTIVES

EL2310 Scientific Programming

Introduction. Inserting and Modifying Tables. Word 2010 Working with Tables. To Insert a Blank Table: Page 1

VISION BASICS. Introduction (note materials updated for Vision 6.8.0)

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

COBISS3 Basic Guidelines. You can find an object in three different ways: in the search window through a query by object key

Unix and C Program Development SEEM

Intro to Segmentation Fault Handling in Linux. By Khanh Ngo-Duy

Debugging with GDB and DDT

Scintillating! A Modernized Text Editor for VA Smalltalk

Debugging and Handling Exceptions

Introduction. This tutorial introduces the following SingleStep features:

Debug for GDB Users. Action Description Debug GDB $debug <program> <args> >create <program> <args>

Jackson State University Department of Computer Science CSC / Advanced Information Security Spring 2013 Lab Project # 5

Integration with IDE tools

C Program Development and Debugging under Unix SEEM 3460

Examplify v12 Exam Instructions

Using the GNU Debugger

CSE 390a Lecture 2. Exploring Shell Commands, Streams, and Redirection

CSE 390a Lecture 2. Exploring Shell Commands, Streams, Redirection, and Processes

GETTING STARTED WITH ECLIPSE Caitrin Armstrong

Firewalls can prevent access to the Unix Servers. Please make sure any firewall software or hardware allows access through Port 22.

Creating a Histogram Creating a Histogram

Debugging! The material for this lecture is drawn, in part, from! The Practice of Programming (Kernighan & Pike) Chapter 5!

Using the GNU Debugger

Using the Xcode Debugger

Centricity Cardio Workflow (CCW)

CSci 4061 Introduction to Operating Systems. Programs in C/Unix

Transcription:

ddd Tips This provides some helpful information about the Unix ddd debugger. with more detailed information: There are other resources available gnu ddd manual matloff ddd information Contents Prerequisites... 1 Launching ddd... 1 Overview of ddd... 1 How can I tell ddd to show line numbers?... 3 Running Your Program... 4 What happens after run begins?... 6 How can I set breakpoints?... 6 How can I remove a breakpoint?... 7 How can I look at the value of a variable?... 7 How can I look at an array or complex structure?... 7 How can I remove something from the Display Area?... 9 How can I tell ddd to interrupt execution when a variable's value changes?... 9 Prerequisites Your code must have been compiled with the -g compiler option. Example: gcc -g -o executablename programname.c ddd uses an x-window display. If you are using it remotely, you must have ubuntu (or a unixemulation product such as cygwin) and started an x-window terminal window. Launching ddd ddd./executablename Overview of ddd When ddd starts (it takes a while), it shows a Tip of the Day. These will be helpful for most students. It shows the initial DDD window (see Figure 1: Initial Display) which consists of the following areas: Menu Bar This is at the menu at the top of the window and includes File, Edit, View, etc.

Tool Bar Data Area Source File Area Command Tool Area Console Area This is immediately below the menu bar and contains some important tools like Find and Break. At the beginning, this shows an empty grid area. It is used to show values of variables which you wish to closely examine. This displays your source code. This appears on the right side of the Source File Area and includes buttons: Run Step Next Cont Finish Kill run the program. This is at the bottom of the screen: execute the current step. It will step into a called function. execute the current step, but do not step into a called function. Continue execution until the next break or stdin. continue execution until the finish of the current function. Kill the execution of your program. debugger commands are shown/entered standard input is entered (depending on preferences) standard output is shown (depending on preferences)

Menu Bar Tool Bar Display Area Source File Area Command Tool Area Console Area Figure 1: Initial Display How can I tell ddd to show line numbers? This is done via the Source menu item. Source > Display Line Numbers

Figure 2: Showing Line Numbers Running Your Program Although there are multiple mechanisms provided to run your code within ddd, it is easiest to specify program arguments and how to handle stdin by using the Program menu item. If you are using stdin, it is easier to first tell ddd to use an Execution Window: Program > Run in Execution Window (you only have to do this one time) Figure 3: Running in an Execution Window

And then to tell ddd to run it: Program > Run Figure 4: Run If you need to enter command line arguments for your program, use Program > Run ddd will show a window which allows you to either select previously entered arguments or enter new ones If you want to redirect stdin to come from a file, use Program > Run ddd will show a window which allows you to either select previously entered arguments or enter new ones. You can specify command line arguments, stdin redirection or both: args <inputfilename args <inputfilename

Figure 5: Redirecting stdin What happens after run begins? After run, your code will execute until whichever it first encounters program exit or program return a request for stdin from the keyboard a Breakpoint (which you must manually set) a Watch Point variable's value changes How can I set breakpoints? Click on a line number. Your right mouse button will give you a popup menu where you can set a breakpoint. When you set it, a stop sign will appear. Figure 6: Setting a Break Point

When you run your code, if the breakpoint is encountered, execution will stop at it. The current point of execution is shown with a large arrow. Figure 7: Program Breaking at a Breakpoint How can I remove a breakpoint? Click on the line number containing the breakpoint. Your right mouse button will give you a popup menu allowing you to delete the breakpoint. How can I look at the value of a variable? For a simple variable, you can hover the mouse over the variable and its value will show during execution. For an array reference (e.g., studentm[i].szstudentfullnm), highlight the entire reference and then hover over that selected text. You can also display a variable in the Display Area. Right click on a variable and it will be shown in the Display Area. This is useful to see how the variable changes as the code executes. How can I look at an array or complex structure? Arrays and complex structures are usually shown in the Display Area. Right click on the array and select Display. If your variable is a pointer, you might prefer to display what it references by selecting Display*. The example in Figure 8 shows what is displayed for the following array: typedef struct { double dexam1; double dexam2; double dfinalexam; char szstudentidnr[7]; char szstudentfullnm[21]; } Student; Student studentm[10]; // exam #1 score // exam #2 score // final exam score // Student Identification Nr // Student full Nm

Figure 8: Display of studentm To examine the contents of an element of that array, click on the element and then you can do any of the following on that element: right click menu and select show all. Figure 9 shows what would then be displayed for that element. right click menu, select New Display, select Other, and a New Dependent Display window appears. It should show you which element you selected. Press the Display button in that dialogue window. Figure 10 shows the display. Figure 9: Showing the contents of studentm[0] using show all Figure 10: Showing the contents of studentm[1] using a New Display.

You can also display slices of an array. In the Display Area, right click and select New Display. In the Display Expression,specify a slice of an array as shown below: When the array display appears, it may appear across the page. If your right click and select Rotate, it will display vertically. How can I remove something from the Display Area? Right click on it and select Undisplay. Figure 11: Removing a Display How can I tell ddd to interrupt execution when a variable's value changes? This is done by setting a watch point. While running, select what you want to watch using the mouse and press the Watch button (it looks like two eyeballs) in the Tool Bar. When you continue executing your code, it will interrupt execution at the point in the code where the value of that variable changes.