CSE 303 Concepts and Tools for Software Development

Slides:



Advertisements
Similar presentations
Debugging What can debuggers do? Run programs Make the program stops on specified places or on specified conditions Give information about current variables’
Advertisements

Gdb: GNU Debugger Lecturer: Prof. Andrzej (AJ) Bieszczad Phone: “UNIX for Programmers and Users” Third Edition, Prentice-Hall,
CSE 303 Lecture 13a Debugging C programs
Homework Reading –Finish K&R Chapter 1 (if not done yet) –Start K&R Chapter 2 for next time. Programming Assignments –DON’T USE and string library functions,
Debugger Presented by 李明璋 2012/05/08. The Definition of Bug –Part of the code which would result in an error, fault or malfunctioning of the program.
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.
P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Compilers, Interpreters and Debuggers Ruibin Bai (Room AB326) Division of Computer Science.
Debugging Cluster Programs using symbolic debuggers.
Memory & Storage Architecture Seoul National University GDB commands Hyeon-gyu School of Computer Science and Engineering.
1 ENERGY 211 / CME 211 Lecture 13 October 20, 2008.
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 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 12/6/2006 Lecture 24 – Profilers.
Debugging and Profiling With some help from Software Carpentry resources.
A Tutorial on Introduction to gdb By Sasanka Madiraju Graduate Assistant Center for Computation and Technology.
CSE 332: C++ debugging Why Debug a Program? When your program crashes –Finding out where it crashed –Examining program memory at that point When a bug.
Debugging Xin Tong. GDB GNU Project debugger Allows you to see what is going on `inside' another program while it executes or crashed. (Faster than printing.
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)
C++ crash course Class 9 flight times program, using gdb.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 11 – gdb and Debugging.
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.
COP 3530 Spring2012 Data Structures & Algorithms Discussion Session Week 2.
Dale Roberts Debugger Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and Information Science, School.
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?
CSc 352 Debugging Tools Saumya Debray Dept. of Computer Science The University of Arizona, Tucson
CSE 332: C++ expressions Expressions: Operators and Operands Operators obey arity, associativity, and precedence int result = 2 * 3 + 5; // assigns 11.
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 10/11/2006 Lecture 7 – Introduction to C.
HP-SEE Debugging with GDB Vladimir Slavnic Research Assistant SCL, Institute of Physics Belgrade The HP-SEE initiative.
 Wind River Systems, Inc Chapter - 4 CrossWind.
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.
DEBUG.
Computer System Laboratory
Gnu Debugger (gdb) Debuggers are used to: Find semantic errors
Winter 2009 Tutorial #6 Arrays Part 2, Structures, Debugger
14 Compilers, Interpreters and Debuggers
Dynamic Analysis ddaa.
CSE 374 Programming Concepts & Tools
CS1101X Programming Methodology
CSE 303 Concepts and Tools for Software Development
Testing and Debugging.
Debugging with gdb gdb is the GNU debugger on our CS machines.
CSE 303 Concepts and Tools for Software Development
CSE 303 Concepts and Tools for Software Development
gdb gdb is the GNU debugger on our CS machines.
Lab: ssh, scp, gdb, valgrind
COMP 2710 Software Construction Introduction to GDB
Debuggers.
Common C Programming Errors, GDB Debugging
DEBUGGING JAVA PROGRAMS USING ECLIPSE DEBUGGER
CSE 303 Concepts and Tools for Software Development
Tonga Institute of Higher Education
Getting Started: Developing Code with Cloud9
Using a Debugger 1-Jan-19.
CSc 352 Debugging Tools Saumya Debray Dept. of Computer Science
GNU DEBUGGER TOOL. What is the GDB ? GNU Debugger It Works for several languages – including C/C++ [Assembly, Fortran,Go,Objective-C,Pascal]
When your program crashes
CSE 303 Concepts and Tools for Software Development
Testing, debugging, and using support libraries
Debuggers and Debugging
Chapter 15 Debugging.
Debugging.
Makefiles, GDB, Valgrind
CSE 303 Concepts and Tools for Software Development
CSE 303 Concepts and Tools for Software Development
Chapter 15 Debugging.
Presentation transcript:

CSE 303 Concepts and Tools for Software Development CSE 303 Lecture 20 11/22/2006 CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 11/22/2006 Lecture 20 – Debuggers

Administravia HW6 Due 30 Minutes Ago! Societal Implications 4 next Wednesday We'll resume discussion of DRM No new reading Short Paper Instructions are posted Due last day of class This is 2 days after HW7 HW7 Posted by Monday 11/22/2006 CSE 303 Lecture 20

Where We Are Tools for working on larger projects Specification/Testing Version Control Systems Build Scripting 11/22/2006 CSE 303 Lecture 20

Today Debuggers GDB Role How they work The art of debugging 11/22/2006 CSE 303 Lecture 20

Role of a Debugger Helps you see what's going on in program More accurate name: "Execution Monitor" Debugger Capabilities Start program with arguments Suspend execution At predefined "breakpoints" Possible to break on some condition Examine suspended state of program Change the values of variables (sometimes) 11/22/2006 CSE 303 Lecture 20

How Debuggers Work Program has special links to source code These make programs much larger Most projects have "Debug" and "Release" builds External libraries may also have debug versions gcc & g++ add debug info with -g flag OS hooks for examining program state 11/22/2006 CSE 303 Lecture 20

The Art of Debugging A debugger won't solve all your problems Stopping program too late to find problem Trying to "debug" the wrong algorithm "Debugging" vs. "Understanding the program" Debugging C/C++ vs. Java No crashes != Correct program Java easier to debug: No crashes or memory errors But programming Java is "easier" for same reason 11/22/2006 CSE 303 Lecture 20

Debugging with GDB Running gdb Note: There are many other debuggers Command Line: gdb programname Source files should be in same directory Emacs: M-x gdb Current file must be in directory of program/source Note: There are many other debuggers dbx, jdb (for Java) Debuggers integrated into IDEs But concepts are the same 11/22/2006 CSE 303 Lecture 20

Example: Locating a Crash Approach 1: Execute program in gdb -bash-3.1$ gdb bug4 … (gdb) run Program received signal SIGABRT, Aborted. 0xffffe410 in __kernel_vsyscall () (gdb) where 11/22/2006 CSE 303 Lecture 20

Example: Locating a Crash (gdb) where #0 0xffffe410 in __kernel_vsyscall () #1 0x4320bee9 in raise () from /lib/libc.so.6 #2 0x4320d4f1 in abort () from /lib/libc.so.6 #3 0x4324053b in __libc_message () from /lib/libc.so.6 #4 0x43247a68 in _int_free () from /lib/libc.so.6 #5 0x4324af6f in free () from /lib/libc.so.6 #6 0x43dc96c1 in operator delete () from /usr/lib/libstdc++.so.6 #7 0x080485d7 in ~A (this=0xbfbdb744) at bug4.cpp:5 #8 0x08048567 in main () at bug4.cpp:19 (gdb) up (gdb) <pressing return repeats previous command> 11/22/2006 CSE 303 Lecture 20

Example: Locating a Crash Approach 2: Examine a core file Need to set max size allowed for core files ulimit -c 16000 Run program as usual Aborted (core dumped) Examine core file with gdb dgb bug4 core.10050 (gdb) where Same output as Approach 1 11/22/2006 CSE 303 Lecture 20

Example: Suspending a Program Approach 1: Send interrupt gdb heaptest run 10 Note here that you can supply arguments (user presses Ctrl-c, or Ctrl-c Ctrl-c if in Emacs) Program received signal SIGINT, Interrupt. 0xffffe410 in __kernel_vsyscall () (gdb) 11/22/2006 CSE 303 Lecture 20

Example: Suspending a Program Approach 2: Place a breakpoint gdb heaptest break heaptest.c:26 run 10 Program received signal SIGINT, Interrupt. 0xffffe410 in __kernel_vsyscall () (gdb) 11/22/2006 CSE 303 Lecture 20

Working with Breakpoints Function Names break main Within files break heap.c:HeapInit Within methods break Point::GetX Delete all breakpoints delete Clear one breakpoint clear heap.c:HeapInit Conditional breakpoint break Point::SetX if newX==1 11/22/2006 CSE 303 Lecture 20

Inspecting the Program Inspecting arguments and local variables (gdb) info args Show arguments (gdb) info locals Show local variables (gdb) info variables Show locals and globals (gdb) p variable_name Print a variable 11/22/2006 CSE 303 Lecture 20

Inspecting the Program Where are we? (gdb) where Show call stack (gdb) frame Show current activation record (gdb) up Move "up" the call stack (gdb) down  Move "down" the call stack (gdb) l Print 10 lines of context Names of variables depend on current stack frame 11/22/2006 CSE 303 Lecture 20

Other Commands Executing Step-by-step Quitting (gdb) n Execute one statement and stop at next (gdb) s Step inside function (gdb) c Continue until next breakpoint Quitting (gdb) quit 11/22/2006 CSE 303 Lecture 20

Summary Debuggers important for fast development Understand what the tool provides you Use it to accomplish specific tasks "I want to know the call stack when I get the NULL-Pointer dereference" Avoid command line Use Emacs Use an IDE 11/22/2006 CSE 303 Lecture 20

Reading Programming in C Chapter 18: Debugging Programs 11/22/2006 CSE 303 Lecture 20

Next Time Profilers 11/22/2006 CSE 303 Lecture 20