Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 Debugging 1/6/2016

2 Debugging 1/6/2016 Debugging  Debugging is a methodical process of finding and reducing the number of bugs, or defects, in a program or a piece of electronic hardware.  It is the most important activity in the software and program development.  It is used in order to remove or identify logical errors in the program. Debugging is not testing but testing can be a part of debugging. Testing finds errors; debugging localizes and repairs them. Debugging is a black art. 2

3 Debugging 1/6/2016 What is a Debugger? “A software tool that is used to detect the source of program or script errors, by performing step-by- step execution of application code and viewing the content of code variables.” 3

4 Debugging 1/6/2016 Why Debug?  When your program crashes  Finding out where it crashed  Examining program memory at that point  When a bug occurs in your program  Watching program variables  Identifying where the problem occurs (and why)  Tracing through a program  Learning what a program does  Good basic testing approach 4

5 Debugging 1/6/2016 Steps in Debugging Process 1. Compile your program(s) enabling the same for Debugging. i.e. gcc –g –o p prg.c 2. Execute the debugger 3. Run the program as you normally would. When the error occurs, Debugger will provide information regarding the location of the error, and possible reasons for its occurrence. (It also provides more detail about the error than the initial error messages you may have received without using the debugger) 5

6 Debugging 1/6/2016 Debuggers  Command-line debuggers :  gdb (C, C++), jdb (java), “perl –d”  DDD – Data Display Debugger – Linux Debugger 6

7 Debugging 1/6/2016 GDB  Compile with the "-g" option (for most GNU and Intel compilers) which generates added information in the object code so the debugger can match a line of source code with the step of execution. gcc -g eg.c -o eg  Running gdb gdb name-of-executable (gbd./eg) 7

8 Debugging 1/6/2016 When gdb is started, it should look somewhat like this: GNU gdb 2002-08-18-cvs Copyright 2002 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "powerpc-linux". (gdb) (gdb) quit (gdb) list (gdb) run (gdb) print x 8

9 Debugging 1/6/2016 Breakpoints gdb returns control back to you when it reaches that exact point. Breakpoints are created using the break command. For instance, this is telling gdb to pass back control on line 19 and 21: RUNNING NAVIGATION (gdb) next (gdb) step (gdb) continue 9

10 Debugging 1/6/2016 GDB Breakpoints Useful breakpoint commands: b[reak] [ ]sets breakpoints. can be a number of things, including a hex address, a function name, a line number, or a relative line offset [r]watch sets a watchpoint, which will break when is written to [or read] info break[points]prints out a listing of all breakpoints clear [ ]clears a breakpoint at d[elete] [ ]deletes breakpoints by number DDD: Best Visual Debugger 10

11 Debugging 1/6/2016 Starting DDD  Open your executable program in DDD  ddd./eg OR ddd./a.out (sudo apt-get install ddd) 11

12 Debugging 1/6/2016 Debugger Console and Data Window 12

13 Set Breakpoints 13


Download ppt "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."

Similar presentations


Ads by Google