Data Display Debugger (DDD)

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

Makefiles. makefiles Problem: You are working on one part of a large programming project (e. g., MS Word).  It consists of hundreds of individual.c files.
Utilizing the GDB debugger to analyze programs Background and application.
Debugging What can debuggers do? Run programs Make the program stops on specified places or on specified conditions Give information about current variables’
Binghamton University CS-220 Spring 2015 Binghamton University CS-220 Spring 2015 The CS-220 Development Environment.
MT311 Tutorial Li Tak Sing( 李德成 ). Uploading your work You need to upload your work for tutorials and assignments at the following site:
Understanding Makefiles COMP 2400, Fall 2008 Prof. Chris GauthierDickey.
Compilation & linkage.h read.h.c read.c.c main.c.c list.c.h list.h prog1 Linkage: g++ read.o main.o list.o –o prog1.o main.o.o list.o.o read.o Compilation:
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
Software Engineering Recitation 7 Suhit Gupta. Review Anything from last time???
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
Fall 2007CS 2251 Programming Tools Eclipse JUnit Testing make and ant.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
Introduction to Make Updated by Prasad Spring 2000.
CS 225 Lab #2 - Pointers, Copy Constructors, Destructors, and DDD.
Guide To UNIX Using Linux Third Edition
Gdb is the GNU debugger on our CS machines. gdb is most effective when it is debugging a program that has debugging symbols linked in to it. With gcc and.
Chapter 2 Build Your First Project A Step-by-Step Approach 2 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
1 Integrated Development Environment Building Your First Project (A Step-By-Step Approach)
Compiling & Debugging Quick tutorial. What is gcc? Gcc is the GNU Project C compiler A command-line program Gcc takes C source files as input Outputs.
CSE 332: C++ debugging in Eclipse C++ Debugging in Eclipse We’ve now covered several key program features –Variable declarations, expressions and statements.
Linux Operations and Administration
Chapter Ten g++ and make1 System Programming Software Development: g++ and make.
Presented by IBM developer Works ibm.com/developerworks/ 2006 January – April © 2006 IBM Corporation. Making the most of The Eclipse debugger.
CSE 232: C++ Programming in Visual Studio Graphical Development Environments for C++ Eclipse –Widely available open-source debugging environment Available.
EIE375 BlueJ: Getting Started Dr Lawrence Cheung.
Makefiles. Multiple Source Files (1) u Obviously, large programs are not going to be contained within single files. u C provides several techniques to.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
Program Development Tools GNU make (much of this material is adapted from “GNU Make” by Richard Stallman) The make utility automatically determines which.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 4 Slide 1 Slide 1 What we'll cover here l Using the debugger: Starting the debugger Setting.
COP 3530 Spring2012 Data Structures & Algorithms Discussion Session Week 2.
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015 Makefile Tutorial CIS5027.
CSI605 Introduction to ddd. ddd ddd stands for the Data Display Debugger ddd is a graphical environment that resides on top of gdb We recall that gdb.
COP 3530 Spring 12 Discussion Session 1. Agenda 1.Introduction 2.Remote programming 3.Separate code 4.Compile -- g++,makefile 5.Debug -- gdb 6.Questions?
CSE 332: C++ debugging in Eclipse C++ Debugging in Eclipse We’ve looked at programs from a text-based mode –Shell commands and command lines –Text editors,
Lab 9 Department of Computer Science and Information Engineering National Taiwan University Lab9 - Debugging I 2014/11/4/ 28 1.
Brandon Packard. Why make? So far, you have probably worked on relatively small projects Coding projects can become huge My research consists of 1600.
GNU Make Computer Organization II 1 © McQuain What is make ? make is a system utility for managing the build process (compilation/linking/etc).
HP-SEE Debugging with GDB Vladimir Slavnic Research Assistant SCL, Institute of Physics Belgrade The HP-SEE initiative.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
 Wind River Systems, Inc Chapter - 4 CrossWind.
Chapter 2 Build Your First Project A Step-by-Step Approach 2 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
Makefiles Manolis Koubarakis Data Structures and Programming Techniques 1.
Lecture 6 UNIX Development Tools. Software Development Tools.
CSE 332: Scientific debugging in C++ Scientific Debugging in C++ (with Eclipse & gdb) By now we’ve covered several key C++ features –Variable declarations.
Multiple file project management & Makefile
DEBUG.
Eclipse.
Development Environment
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha Fall 2015
Debugging with gdb gdb is the GNU debugger on our CS machines.
CS 153: Concepts of Compiler Design November 30 Class Meeting
gdb gdb is the GNU debugger on our CS machines.
Important terms Black-box testing White-box testing Regression testing
Makefile Tutorial CIS5027 Prof: Dr. Shu-Ching Chen
Prof: Dr. Shu-Ching Chen TA: Yimin Yang
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Hector Cen Fall 2017
Important terms Black-box testing White-box testing Regression testing
Debugging with Eclipse
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
Data Structures and Programming Techniques
PPT1: How failures come to be
GNU DEBUGGER TOOL. What is the GDB ? GNU Debugger It Works for several languages – including C/C++ [Assembly, Fortran,Go,Objective-C,Pascal]
Appendix F C Programming Environment on UNIX Systems
Lab 4: Introduction to Scripting
GNU Make.
Compiler vs linker The compiler translates one .c file into a .o file
Makefiles, GDB, Valgrind
Debugging with Eclipse
Presentation transcript:

Data Display Debugger (DDD) Debugging Data Display Debugger (DDD)

References Project Homepage Manual URL http://www.gnu.org/software/ddd/ Manual URL http://www.gnu.org/manual/ddd/

Debugger Computer program Capabilities Difficulty Run a program step by step Stopping at some kind of event Tracking the values of some variables Modify the state of the program while it’s running. Difficulty Track down runtime problems in complex multi-threaded or distributed systems. Changes the internal timing of a software program.

Data Display Debugger (DDD) A graphical user interface (GUI) for command-line debuggers. Under the GUI, you can use following debuggers GDB, DBX, Ladebug, or XDB: debug executable binaries JDB: debug Java byte code programs PYDB: debug Python programs Perl debugger: debug Perl programs BASHDB: debug Bash programs

A sample DDD session static void shell_sort(int a[], int size) { int i, j; int h = 1; do { h = h * 3 + 1; } while (h <= size); h /= 3; for (i = h; i < size; i++) int v = a[i]; for (j = i; j >= h && a[j - h] > v; j -= h) a[j] = a[j - h]; if (i != j) a[j] = v; } } while (h != 1); int main(int argc, char *argv[]) int *a; int i; a = (int *)malloc((argc - 1) * sizeof(int)); for (i = 0; i < argc - 1; i++) a[i] = atoi(argv[i + 1]); shell_sort(a, argc-1); printf("%d ", a[i]); printf("\n"); free(a); return 0;

A sample DDD session $ gcc -o sample sample.c $ ./sample 8 7 5 4 1 3 1 3 4 5 7 8 $ ./sample 8000000000 7000000000 5000000000 1000000000 4000000000 1000000000 1913000000 4000000000 5000000000 7000000000

Compiling for debugging Need to generate debugging information when compile a program. Stored in the object file Debugging information Describes the data type of each variable or function and the correspondence between source line numbers and addresses in the executable code. Specify ‘-g’ option when compiling For our case: gcc -g -o sample sample.c

Launching: ddd sample

Breakpoint Makes your program stop whenever a certain point in the program is reached. Typically, breakpoints are set before running the program. Put the cursor on the left of the source line, and click on the ‘Break’ button.

Run the program Select menu ‘Program->Run’. In ‘Run with Arguments’ dialog, enter arguments for the program to be executed.

Command Tools ‘Run’: Run the program without argument / Run the program again with the same arguments. ‘Interrupt’: Interrupt the running program. ‘Step’: Step into a subroutine/sub-function which has debugging information. ‘Stepi’: Similar with ‘Step’, but it executes one machine instruction. ‘Next’: Execute a source line without stepping into the subroutine. ‘Nexti’: Similar with ‘Next’, also executes one machine instruction.

Command Tools ‘Until’: Continue until a greater line in the current function is reached This is useful to avoid single stepping through a loop more than once. ‘Finish’: Continue running until the current function returns. ‘Continue’: Resume execution. ‘Kill’: Kill the process of the debugged program.

Command Tools ‘Up’: Select the function stack frame that called this one. ‘Down’: Select the function stack frame that was called by this one. ‘Undo’: Undo the most recent action. ‘Redo’: Redo the most recently undone. ‘Edit’: Edit the source code by a test editor, by default it is VIM. ‘Make’: Recompile the source code. Needs ‘Makefile’

‘Makefile’ for sample.c sample: sample.o gcc -o sample sample.o sample.o: sample.c gcc -g -c sample.c clean: rm sample sample.o

Examine data To examine a simple variable To examine an entire array Move the mouse pointer on its name. Enter variable name to argument field, and click on the ‘Print’ button. Show once Enter variable name to argument field, and click on the ‘Display’ button. The value will be shown in the Data Window To examine an entire array Enter ‘a[0]@(argc - 1)’ to argument field, and print or display

Assignment to variables Change the values of arbitrary variables during program execution. Select the variable in the source window, and click on the ‘Set’ button. Enter the variable name in the argument field, and click on the ‘Set’ button. If the variable is on the Data window, just select the variable, and click on the ‘Set’ button, or right click on the variable and select ‘Set Value…’.

Makefile

Reference Project Homepage Manual URL http://www.gnu.org/software/make/ Manual URL http://www.gnu.org/software/make/manual/make.html

Why we need a makefile Make enables the end user to build and install/deinstall your package without knowing the details of how that is done. Make figures out automatically which files it needs to update, based on which source files have changed. Make is not limited to any particular language. Make can do anything else you want to do often enough to make it worth while writing down how to do it. Makefile tells make what to do. Tells make how to compile and link a program.

How to use ‘Makefile’ $ make ‘make’ is system program ‘make’ will automatically search ‘Makefile’ or ‘makefile’ in the current directory ‘make’ will interpret it and execute it.

Simple Makefile A simple makefile consists of "rules" with the following shape: targets : prerequisites commands target: usually the name of a file that is generated by a program. the name of an action to carry out, such as `clean‘. prerequisite: a file that is used as input to create the target. commands: an action that make carries out.

Simplest Makefile for sample sample: sample.c gcc -g -o sample.c clean: rm sample Rule Rule

How ‘make’ Processes a Makefile By default, ‘make’ starts with the first target. ‘sample’ Before processing the rule ‘sample’, ‘make’ will process on the prerequisites first. ‘make’ will recompile ‘edit’ if one or more its prerequisites are newer than ‘sample’. no ‘sample’ file exists. If you want to process a specific rule, such as ‘clean’ ‘make clean’

Makefile for sample #Simplest Makefile for sample. #sample.o is intermediate file. sample: sample.o gcc -o sample.o sample.o: sample.c gcc -g -c sample.c Why we need the intermediate file, which is ‘sample.o’?

Simple Makefile edit: main.c kbd.c command.c display.c gcc -o main.c kbd.c command.c display.c clean: rm edit

Simple Makefile edit : main.o kbd.o command.o display.o gcc -o edit main.o kbd.o command.o display.o main.o : main.c defs.h gcc -c main.c kbd.o : kbd.c defs.h command.h gcc -c kbd.c command.o : command.c defs.h command.h gcc -c command.c display.o : display.c defs.h buffer.h gcc -c display.c clean : rm edit main.o kbd.o command.o display.o

Variable edit : main.o kbd.o command.o display.o cc -o edit main.o kbd.o command.o display.o A name defined in a makefile to represent a string of text, called the variable's value. Use ‘=’ to assign a value to a variable. objects = main.o kbd.o command.o display.o\ insert.o search.o files.o utils.o Usage: $(var_name) $(objects)

Simple Makefile objects = main.o kbd.o command.o display.o edit : $(objects) gcc -o edit $(objects) main.o : main.c defs.h gcc -c main.c kbd.o : kbd.c defs.h command.h gcc -c kbd.c command.o : command.c defs.h command.h gcc -c command.c display.o : display.c defs.h buffer.h gcc -c display.c clean : rm edit $(objects)

Implicit Rule If you either write a rule with no command lines, or don't write a rule at all ‘make’ will figure out which implicit rule to use based on which kind of source file exists or can be made. For example foo: foo.o gcc -o foo foo.o foo.o: foo.h ‘name.o’ is made automatically from ‘name.c’ with a command of the form ‘$(CC) -c $(CPPFLAGS) $(CFLAGS)’ in C programs In our case, we should set ‘CFLAGS = -g’, such that can be used for debugging.

Implicit Rule (Example) sample: sample.o gcc -o sample.o sample.o: sample.c gcc -g -c sample.c CC = gcc CFLAGS = -g sample: sample.o gcc -o sample.o

Simple Makefile objects = main.o kbd.o command.o display.o CFLAGS = -g CC = gcc edit : $(objects) $(CC) -o edit $(objects) main.o : defs.h kbd.o : defs.h command.h command.o : defs.h command.h display.o : defs.h buffer.h clean : rm edit $(objects)

Simple Makefile objects = main.o kbd.o command.o display.o CFLAGS = -g CC = gcc edit : $(objects) $(CC) -o edit $(objects) $(objects) : defs.h kbd.o command.o files.o : command.h display.o insert.o search.o files.o : buffer.h

Lab Exercise Debug the quick sorting program. Extract the file using ‘tar -xvf sorting.tar’. Make a ‘Makefile’ to compile the source files. The algorithm is some kind of quick sort algorithm, but it does not work correctly. Find the bug!