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?

Slides:



Advertisements
Similar presentations
Introduction to the Omega Server CSE Overview Intro to Omega Basic Unix Command Files Directories Printing C and C++ compilers GNU Debugger.
Advertisements

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’
Lecture Roger Sutton CO331 Visual programming 15: Debugging 1.
Environment & tools Assistant Anssi Jääskeläinen Visiting hours: Tuesdays Room: 6606
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
CSE 303 Lecture 13a Debugging C programs
Unix Programming Tools Operating Systems. man- on-line unix manual vi - a command line text editor make- runs make files gcc- compiler gdb- debugger Operating.
Guide To UNIX Using Linux Third Edition
Introduction to C. A Brief History Created by Dennis Ritchie at AT&T Labs in 1972 Originally created to design and support the Unix operating system.
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.
Debugging Cluster Programs using symbolic debuggers.
Memory & Storage Architecture Seoul National University GDB commands Hyeon-gyu School of Computer Science and Engineering.
1 Chapter 9 Writing, Testing, and Debugging Access Applications.
Programming Tools gcc make utility Open Source code Static and Shared Libraries gdb Memory debugging tools.
Introduction make is a UNIX utility for building projects that are comprised of multiple source filesmake is a UNIX utility for building projects that.
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.
TAMU CSCE 313 (the basics). Basic Unix/Linux programming Accessing CS systems  PuTTY (putty.exe) – a Telnet and SSH client  Common hosts: unix.cs.tamu.edu.
C Tutorial Session #2 Type conversions More on looping Common errors Control statements Pointers and Arrays C Pre-processor Makefile Debugging.
Active-HDL Interfaces Debugging C Code Course 10.
CSE 232: C++ debugging in Visual Studio and emacs C++ Debugging (in Visual Studio and emacs) We’ve looked at programs from a text-based mode –Shell commands.
A Tutorial on Introduction to gdb By Sasanka Madiraju Graduate Assistant Center for Computation and Technology.
L function n predefined, programmer-defined l arguments, (formal) parameters l return value l function call, function invocation l function definition.
Chapter 7 Debugging Techniques Xiaogang Su Department of Statistics University of Central Florida.
Makefiles. Multiple Source Files (1) u Obviously, large programs are not going to be contained within single files. u C provides several techniques to.
1 SEEM3460 Tutorial Compiling and Debugging C programs.
CSE 351 GDB Introduction. Lab 1 Status? How is Lab 1 going? I’ll be available at the end of class to answer questions There are office hours later today.
Data Display Debugger (DDD)
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 11 – gdb and Debugging.
Chapter Six Introduction to Shell Script Programming.
Debugging 1/6/2016. Debugging 1/6/2016 Debugging  Debugging is a methodical process of finding and reducing the number of bugs, or defects, in a program.
CPS120: Introduction to Computer Science Compiling a C++ Program From The Command Line.
COP 3530 Spring2012 Data Structures & Algorithms Discussion Session Week 2.
Discussion Week 1 TA: Kyle Dewey. Project 0 Walkthrough.
Dale Roberts Debugger Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and Information Science, School.
Unit - V. Debugging GNU Debugger helps you in getting information about the following: 1.If a core dump happened, then what statement or expression did.
Program in Multiple Files. l all C++ statements are divided into executable and non-executable l executable - some corresponding machine code is generated.
Emacs, Compilation, and Makefile C151 Multi-User Operating Systems.
Chapter – 8 Software Tools.
C P ROGRAMMING T OOLS. C OMPILING AND R UNNING S INGLE M ODULE P ROGRAM.
Advanced UNIX progamming Fall 2002 Instructor: Ashok Srinivasan Lecture 2 Class web site:
Object Oriented Programming COP3330 / CGS5409.  Compiling with g++  Using Makefiles  Debugging.
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.
Object Oriented Programming COP3330 / CGS5409.  Assignment Submission Overview  Compiling with g++  Using Makefiles  Misc. Review.
 Wind River Systems, Inc Chapter - 4 CrossWind.
GDB Introduction And Lab 2
Dale Roberts Debugger Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and Information Science, School.
Using the GNU Debugger (GDB)‏ Techzemplary Pvt.Ltd February 24 th 2008 Pranav Peshwe.
Institute of Radio Physics and Electronics ILug-Cal Introduction to GDB Institute of Radio Physics and Electronics and Indian GNU/Linux Users Group Kolkata.
Gnu Debugger (gdb) Debuggers are used to: Find semantic errors Locate seg faults and bus errors Prepared by Dr. Spiegel.
CSCI 4061 Recitation 2 1.
DEBUG.
Gnu Debugger (gdb) Debuggers are used to: Find semantic errors
What Is? function predefined, programmer-defined
CS1101X Programming Methodology
Compilation and Debugging
Compilation and Debugging
Debugging with gdb gdb is the GNU debugger on our CS machines.
Editor, Compiler, Linker, Debugger, Makefiles
gdb gdb is the GNU debugger on our CS machines.
Debuggers.
GNU DEBUGGER TOOL. What is the GDB ? GNU Debugger It Works for several languages – including C/C++ [Assembly, Fortran,Go,Objective-C,Pascal]
Debuggers and Debugging
Appendix F C Programming Environment on UNIX Systems
What Is? function predefined, programmer-defined
CSE 303 Concepts and Tools for Software Development
Debugging.
SPL – PS1 Introduction to C++.
Presentation transcript:

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?

Introduction Ravi Jampani Ph.D. student Office hour for this week: Thursday 9 th period Location: E309

Remote Programming: Remote programming 1) putty/terminal Editing files: pico, emacs, vim, kate 2) winscp, filrezilla, cyberduckwinscpfilrezillacyberduck Transfer files to E114. remote machines list: link, any machine starts with "lin"link host: lin cise.ufl.edu Tutorial: Off-campus: Submitting a hw in sakai:sakai To create a tar file: tar cvf (tar file name) (file 1) (file 2) (file 3)... tar cvf myhwassignment.tar readme makefile *.cpp *.h

Separate code header file #ifndef ADD_H #define ADD_H int add(int x, int y); // function prototype for add.h #endif Header guards Because header files can include other header files, it is possible to end up in the situation where a header file gets included multiple times. For example, consider the following program:.cpp int add(int x, int y) { return x + y; } Example: Stack.cpp into main.cpp, Stack.h, Stack.cppStack.cppmain.cppStack.hStack.cpp

Compilation 1.Compiling, in which C++ code is translated into assembly; 2.Assembling, in which assembly is translated into machine language; and 3.Linking, in which calls to functions outside the main file are linked to their definitions. //////////////////////////////////////////////// g++ -c stack.cppstack.cpp g++ -c main.cpp g++ -o stack main.o stack.o or //////////////////////////////////////////////// g++ -o stack main.cpp stack.cpp -o program_name // compiling and linking to generate program_name, default "a.out" -c // compiling but no linking -g // for debugging, but runs slow

make and makefile make is a system designed to create programs from large source code trees and to maximize the efficiency of doing so. To that effect, make uses a file in each directory called a Makefile. This file contains instructions for make on how to build your program and when. target: dependencies instructions example Note: Build several independent targets in order, below is sample makefile ========================================================== all: target1 target2 target3 target1: dependencies instructions target2:...

Run./program_name For ex:./stack

GNU debugger -- gdb A symbolic debugger is a program that aids programmers in finding logical errors, by allowing them to execute their program in a controlled manner. 1.Enable symbol table 2.Debug the program g++ -g -o stack stack.cpp gdb stack

Use gdb Quitting gdb (gdb) quit (or q or Ctrl-D) Starting Execution of Program (gdb) run (or r) Resuming Execution at a Breakpoint Once you have suspended execution at a particular statement, you can resume execution in several ways: continue (or c) Resumes execution and continues until the next breakpoint or until execution is completed. next (or n) next will execute a function in the current statement in its entirety. step (or s) step command will execute the next statement, but will step into function calls.

Setting Breakpoints Setting a breakpoint permits you to mark a particular line in your program (called a breakpoint) so that when execution reaches that line, program execution will be suspended, allowing you to enter a gdb command. break function : Set a breakpoint at entry to function function. break filename:linenum :Set a breakpoint at line linenum in source file filename.

Removing Breakpoints and backtrace clear function clear filename:function Delete any breakpoints set at entry to the function function. clear filename:linenum ---- Delete any breakpoints set at or within the code of the specified line. bt OR backtrace ---- Shows the functions in the execution path

Displaying Values print expression (or p expression)Displays the value of the expression (usually a variable) once → at the current point of execution. display expression Displays the value of the expression (usually a variable) each time execution is suspended info display Displays a numbered list of all expressions currently being displayed. undisplay num Stop displaying expression number num.