SlideShare a Scribd company logo
1 of 23
DEFINITION 
Debugging is a methodical process 
of finding and reducing the number 
of bugs, or defects, in a 
computer program or a 
piece of electronic 
hardware, thus 
making it behave as 
expected.
BUG 
A software bug is an error, flaw, 
failure, or fault in a computer 
program or system that causes it 
to produce an incorrect or 
unexpected result, or to behave 
in unintended ways.
REASONS FOR A BUG 
• Syntactic Errors 
Input code is not legal. Caught by compiler 
(or other translation mechanism) 
• Semantic Errors 
Legal code, but not what programmer 
intended. Not caught by compiler, because 
syntax is correct 
• Algorithmic Errors 
Problem with the logic of the program. 
Program does what programmer intended, 
but it doesn't solve the right problem.
SYNTATIC ERRORS 
Common Errors: 
• missing semicolon or brace 
• miss-spelled type in declaration 
One mistake can cause an avalanche of errors 
because compiler can't recover and gets confused 
main () { 
int i 
int j; 
for (i = 0; i <= 10; i++) { 
j = i * 7; 
printf("%d x 7 = %dn", i, j); 
} 
} 
MISSING SEMI-COLON
SEMANTIC ERRORS 
Common Errors: 
• Missing braces to group statements together 
• Confusing assignment with equality 
• Wrong assumptions about operator precedence, 
associativity 
• Wrong limits on for-loop counter 
• Uninitialized variables 
main () { 
int i 
int j; 
for (i = 0; i <= 10; i++) 
j = i * 7; 
printf("%d x 7 = %dn", i, j); 
} 
MISSING BRACE, 
So printf() is mot a part of 
for
Algorithmic Errors 
Design is wrong, so program does not 
solve the correct problem 
Difficult to find 
• Program does what we intended 
• Problem might not show up until many 
runs of program 
• Maybe difficult to fix 
• Have to redesign, may have large impact 
on program code
DEBUGGING PROCESS 
• Testing 
To determine if a code contains errors. 
• Debugging 
To locate the error and fix it. 
• Documentation 
To improve maintainability of the code. 
Include sensible comments, good coding 
style and clear logic 
Testing 
Error? 
Yes 
Debug
• Unit testing 
Test of individual parts of an application – a 
single method, a single class, a group of classes, 
etc. 
• Positive versus negative testing 
Positive testing – testing of functionality that we 
expect to work. 
Negative testing – testing cases we expect to fail, 
and handle these cases in some controlled way 
(example: catch handler for exception). 
• Test automation 
Regression testing – re-running tests that have 
previously been passed whenever a change is 
made to the code. 
Write a test rig or a test harness.
• Modularization and interfaces 
Problem is broken into sub-problems and each sub-problem 
is tackled separately – divide-and-conquer. 
Such a process is called modularization. 
The modules are possibly implemented by different 
programmers, hence the need for well-defined 
interfaces. 
The signature of a method (its return type, name and 
parameter list) constitutes the interface. The body of 
the method (implementation) is hidden – abstraction. 
Good documentation (example: comment to describe 
what the method does) aids in understanding.
• Manual walkthroughs 
Pencil-and-paper. 
Tracing the flow of control between classes 
and objects. 
Verbal walkthroughs 
• Print statements 
Easy to add 
Provide information: Which methods have 
been called 
The value of parameters 
The order in which methods have been called 
The values of local variables and fields at 
strategic points
• Tips and techniques 
Start off with a working algorithm 
Incremental coding/test early 
Simplify the problem 
Explain the bug to someone else 
Fix bugs as you find them 
Recognize common bugs (such as using 
‘=’ instead of ‘==’, using ‘==’ instead of 
equals( ), dereferencing null, etc.) 
Recompile everything 
Test boundaries 
Test exceptional conditions 
Take a break
DEBUGGER 
A debugger or debugging tool is a 
computer program that is used to 
test and debug other programs (the 
"target" program). 
Typically, debuggers offer a query 
processor, symbol resolver, 
expression interpreter, and debug 
support interface at its top level.
DEBUGGING TECHNIQUES 
• Execution tracing 
-running the program 
-print 
-trace utilities 
-single stepping in debugger 
-hand simulation
• Interface checking 
-check procedure parameter 
number/type (if not enforced by 
compiler) and value 
-defensive programming: check 
inputs/results from other modules 
-documents assumptions about 
caller/callee relationships in modules, 
communication protocols, etc.
• Assertions: include range 
constraints or other information 
with data. 
• Skipping code: comment out 
suspect code, then check if error 
remains.
• Other Techniques:- 
-Disassembly (in context and 
with live data!) 
-Execution Tracing/Stack tracing 
-Symbol watches
DISASSEMBLY 
• Most basic form of debugging 
• Translating machine code into 
assembly instructions that are more 
easily understood by the user. 
• Typically implementable as a simple 
lookup table 
• No higher-level information (variable 
names, etc.) 
• Relatively easy to implement.
EXECUTION TRACING 
• Follows the program through the 
execution. Users can step through 
line-by-line, or use breakpoints. 
• Typically allows for “watches” on – 
registers, memory locations, symbols 
• Allows for tracing up the stack of 
runtime errors (back traces) 
• Allows user to trace the causes of 
unexpected behavior and fix them
LIST OF DEBUGGERS 
Some widely used debuggers are 
• GNU Debugger (GDB) 
• Intel Debugger (IDB) 
• LLDB 
• Microsoft Visual Studio Debugger 
• Valgrind 
• WinDbg
. 
.
. 
.
. 
.

More Related Content

What's hot

Black box testing or behavioral testing
Black box testing or behavioral testingBlack box testing or behavioral testing
Black box testing or behavioral testingSlideshare
 
Software Testing Foundations Part 4 - Black Box Testing
Software Testing Foundations Part 4 - Black Box TestingSoftware Testing Foundations Part 4 - Black Box Testing
Software Testing Foundations Part 4 - Black Box TestingNikita Knysh
 
Equivalence class testing
Equivalence  class testingEquivalence  class testing
Equivalence class testingMani Kanth
 
Control Flow Testing
Control Flow TestingControl Flow Testing
Control Flow TestingHirra Sultan
 
Boundary value analysis and equivalence partitioning
Boundary value analysis and equivalence partitioningBoundary value analysis and equivalence partitioning
Boundary value analysis and equivalence partitioningSneha Singh
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving TechniquesAshesh R
 
Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)Adam Mukharil Bachtiar
 
Slice Based testing and Object Oriented Testing
Slice Based testing and Object Oriented TestingSlice Based testing and Object Oriented Testing
Slice Based testing and Object Oriented Testingvarsha sharma
 
Unit 3 Control Flow Testing
Unit 3   Control Flow TestingUnit 3   Control Flow Testing
Unit 3 Control Flow Testingravikhimani
 
Equivalence partinioning and boundary value analysis
Equivalence partinioning and boundary value analysisEquivalence partinioning and boundary value analysis
Equivalence partinioning and boundary value analysisniharika5412
 
Fundamentals of programming)
Fundamentals of programming)Fundamentals of programming)
Fundamentals of programming)jakejakejake2
 
Slicing and testing
Slicing and testingSlicing and testing
Slicing and testingTaegeonLee1
 
Test case techniques
Test case techniquesTest case techniques
Test case techniquesPina Parmar
 

What's hot (20)

UNIT testing
UNIT testingUNIT testing
UNIT testing
 
Testing techniques
Testing techniquesTesting techniques
Testing techniques
 
Black box testing or behavioral testing
Black box testing or behavioral testingBlack box testing or behavioral testing
Black box testing or behavioral testing
 
Software Testing Foundations Part 4 - Black Box Testing
Software Testing Foundations Part 4 - Black Box TestingSoftware Testing Foundations Part 4 - Black Box Testing
Software Testing Foundations Part 4 - Black Box Testing
 
Equivalence class testing
Equivalence  class testingEquivalence  class testing
Equivalence class testing
 
White box testing
White box testingWhite box testing
White box testing
 
Lesson 2....PPT 1
Lesson 2....PPT 1Lesson 2....PPT 1
Lesson 2....PPT 1
 
Control Flow Testing
Control Flow TestingControl Flow Testing
Control Flow Testing
 
Boundary value analysis and equivalence partitioning
Boundary value analysis and equivalence partitioningBoundary value analysis and equivalence partitioning
Boundary value analysis and equivalence partitioning
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniques
 
Introduction to problem solving in C
Introduction to problem solving in CIntroduction to problem solving in C
Introduction to problem solving in C
 
Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)
 
Black box testing
Black box testingBlack box testing
Black box testing
 
Slice Based testing and Object Oriented Testing
Slice Based testing and Object Oriented TestingSlice Based testing and Object Oriented Testing
Slice Based testing and Object Oriented Testing
 
Unit 3 Control Flow Testing
Unit 3   Control Flow TestingUnit 3   Control Flow Testing
Unit 3 Control Flow Testing
 
Equivalence partinioning and boundary value analysis
Equivalence partinioning and boundary value analysisEquivalence partinioning and boundary value analysis
Equivalence partinioning and boundary value analysis
 
Fundamentals of programming)
Fundamentals of programming)Fundamentals of programming)
Fundamentals of programming)
 
Black Box Testing
Black Box TestingBlack Box Testing
Black Box Testing
 
Slicing and testing
Slicing and testingSlicing and testing
Slicing and testing
 
Test case techniques
Test case techniquesTest case techniques
Test case techniques
 

Similar to Debbuging

debugging (1).ppt
debugging (1).pptdebugging (1).ppt
debugging (1).pptjerlinS1
 
An important characteristic of a test suite that is computed by a dynamic ana...
An important characteristic of a test suite that is computed by a dynamic ana...An important characteristic of a test suite that is computed by a dynamic ana...
An important characteristic of a test suite that is computed by a dynamic ana...jeyasrig
 
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
Parasoft .TEST, Write better C# Code Using  Data Flow Analysis Parasoft .TEST, Write better C# Code Using  Data Flow Analysis
Parasoft .TEST, Write better C# Code Using Data Flow Analysis Engineering Software Lab
 
C programming for Computing Techniques
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing TechniquesAppili Vamsi Krishna
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)praveena p
 
Algorithmic problem sloving
Algorithmic problem slovingAlgorithmic problem sloving
Algorithmic problem slovingMani Kandan
 
Unit 1 program development cycle
Unit 1 program development cycleUnit 1 program development cycle
Unit 1 program development cycleDhana malar
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptxTadiwaMawere
 
Chelberg ptcuser 2010
Chelberg ptcuser 2010Chelberg ptcuser 2010
Chelberg ptcuser 2010Clay Helberg
 
FPL -Part 2 ( Sem - I 2013)
FPL -Part 2 ( Sem - I 2013)FPL -Part 2 ( Sem - I 2013)
FPL -Part 2 ( Sem - I 2013)Yogesh Deshpande
 
The pragmatic programmer
The pragmatic programmerThe pragmatic programmer
The pragmatic programmerLeylimYaln
 
Ch1 principles of software development
Ch1 principles of software developmentCh1 principles of software development
Ch1 principles of software developmentHattori Sidek
 
Software Testing overview jay prakash maurya.pptx
Software Testing overview jay prakash maurya.pptxSoftware Testing overview jay prakash maurya.pptx
Software Testing overview jay prakash maurya.pptxJayPrakash779563
 
PCCF UNIT 1.pptx
PCCF UNIT 1.pptxPCCF UNIT 1.pptx
PCCF UNIT 1.pptxDivyaKS12
 

Similar to Debbuging (20)

debugging (1).ppt
debugging (1).pptdebugging (1).ppt
debugging (1).ppt
 
An important characteristic of a test suite that is computed by a dynamic ana...
An important characteristic of a test suite that is computed by a dynamic ana...An important characteristic of a test suite that is computed by a dynamic ana...
An important characteristic of a test suite that is computed by a dynamic ana...
 
testing
testingtesting
testing
 
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
Parasoft .TEST, Write better C# Code Using  Data Flow Analysis Parasoft .TEST, Write better C# Code Using  Data Flow Analysis
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
 
C programming for Computing Techniques
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing Techniques
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)
 
Algorithmic problem sloving
Algorithmic problem slovingAlgorithmic problem sloving
Algorithmic problem sloving
 
Unit 1 program development cycle
Unit 1 program development cycleUnit 1 program development cycle
Unit 1 program development cycle
 
Ss debuggers
Ss debuggersSs debuggers
Ss debuggers
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptx
 
Chelberg ptcuser 2010
Chelberg ptcuser 2010Chelberg ptcuser 2010
Chelberg ptcuser 2010
 
FPL -Part 2 ( Sem - I 2013)
FPL -Part 2 ( Sem - I 2013)FPL -Part 2 ( Sem - I 2013)
FPL -Part 2 ( Sem - I 2013)
 
The pragmatic programmer
The pragmatic programmerThe pragmatic programmer
The pragmatic programmer
 
L software testing
L   software testingL   software testing
L software testing
 
Ch1 principles of software development
Ch1 principles of software developmentCh1 principles of software development
Ch1 principles of software development
 
H testing and debugging
H testing and debuggingH testing and debugging
H testing and debugging
 
PHP - Introduction to PHP Bugs - Debugging
PHP -  Introduction to  PHP Bugs - DebuggingPHP -  Introduction to  PHP Bugs - Debugging
PHP - Introduction to PHP Bugs - Debugging
 
Lecture 21
Lecture 21Lecture 21
Lecture 21
 
Software Testing overview jay prakash maurya.pptx
Software Testing overview jay prakash maurya.pptxSoftware Testing overview jay prakash maurya.pptx
Software Testing overview jay prakash maurya.pptx
 
PCCF UNIT 1.pptx
PCCF UNIT 1.pptxPCCF UNIT 1.pptx
PCCF UNIT 1.pptx
 

Debbuging

  • 1.
  • 2. DEFINITION Debugging is a methodical process of finding and reducing the number of bugs, or defects, in a computer program or a piece of electronic hardware, thus making it behave as expected.
  • 3. BUG A software bug is an error, flaw, failure, or fault in a computer program or system that causes it to produce an incorrect or unexpected result, or to behave in unintended ways.
  • 4. REASONS FOR A BUG • Syntactic Errors Input code is not legal. Caught by compiler (or other translation mechanism) • Semantic Errors Legal code, but not what programmer intended. Not caught by compiler, because syntax is correct • Algorithmic Errors Problem with the logic of the program. Program does what programmer intended, but it doesn't solve the right problem.
  • 5. SYNTATIC ERRORS Common Errors: • missing semicolon or brace • miss-spelled type in declaration One mistake can cause an avalanche of errors because compiler can't recover and gets confused main () { int i int j; for (i = 0; i <= 10; i++) { j = i * 7; printf("%d x 7 = %dn", i, j); } } MISSING SEMI-COLON
  • 6. SEMANTIC ERRORS Common Errors: • Missing braces to group statements together • Confusing assignment with equality • Wrong assumptions about operator precedence, associativity • Wrong limits on for-loop counter • Uninitialized variables main () { int i int j; for (i = 0; i <= 10; i++) j = i * 7; printf("%d x 7 = %dn", i, j); } MISSING BRACE, So printf() is mot a part of for
  • 7. Algorithmic Errors Design is wrong, so program does not solve the correct problem Difficult to find • Program does what we intended • Problem might not show up until many runs of program • Maybe difficult to fix • Have to redesign, may have large impact on program code
  • 8. DEBUGGING PROCESS • Testing To determine if a code contains errors. • Debugging To locate the error and fix it. • Documentation To improve maintainability of the code. Include sensible comments, good coding style and clear logic Testing Error? Yes Debug
  • 9. • Unit testing Test of individual parts of an application – a single method, a single class, a group of classes, etc. • Positive versus negative testing Positive testing – testing of functionality that we expect to work. Negative testing – testing cases we expect to fail, and handle these cases in some controlled way (example: catch handler for exception). • Test automation Regression testing – re-running tests that have previously been passed whenever a change is made to the code. Write a test rig or a test harness.
  • 10. • Modularization and interfaces Problem is broken into sub-problems and each sub-problem is tackled separately – divide-and-conquer. Such a process is called modularization. The modules are possibly implemented by different programmers, hence the need for well-defined interfaces. The signature of a method (its return type, name and parameter list) constitutes the interface. The body of the method (implementation) is hidden – abstraction. Good documentation (example: comment to describe what the method does) aids in understanding.
  • 11. • Manual walkthroughs Pencil-and-paper. Tracing the flow of control between classes and objects. Verbal walkthroughs • Print statements Easy to add Provide information: Which methods have been called The value of parameters The order in which methods have been called The values of local variables and fields at strategic points
  • 12. • Tips and techniques Start off with a working algorithm Incremental coding/test early Simplify the problem Explain the bug to someone else Fix bugs as you find them Recognize common bugs (such as using ‘=’ instead of ‘==’, using ‘==’ instead of equals( ), dereferencing null, etc.) Recompile everything Test boundaries Test exceptional conditions Take a break
  • 13. DEBUGGER A debugger or debugging tool is a computer program that is used to test and debug other programs (the "target" program). Typically, debuggers offer a query processor, symbol resolver, expression interpreter, and debug support interface at its top level.
  • 14. DEBUGGING TECHNIQUES • Execution tracing -running the program -print -trace utilities -single stepping in debugger -hand simulation
  • 15. • Interface checking -check procedure parameter number/type (if not enforced by compiler) and value -defensive programming: check inputs/results from other modules -documents assumptions about caller/callee relationships in modules, communication protocols, etc.
  • 16. • Assertions: include range constraints or other information with data. • Skipping code: comment out suspect code, then check if error remains.
  • 17. • Other Techniques:- -Disassembly (in context and with live data!) -Execution Tracing/Stack tracing -Symbol watches
  • 18. DISASSEMBLY • Most basic form of debugging • Translating machine code into assembly instructions that are more easily understood by the user. • Typically implementable as a simple lookup table • No higher-level information (variable names, etc.) • Relatively easy to implement.
  • 19. EXECUTION TRACING • Follows the program through the execution. Users can step through line-by-line, or use breakpoints. • Typically allows for “watches” on – registers, memory locations, symbols • Allows for tracing up the stack of runtime errors (back traces) • Allows user to trace the causes of unexpected behavior and fix them
  • 20. LIST OF DEBUGGERS Some widely used debuggers are • GNU Debugger (GDB) • Intel Debugger (IDB) • LLDB • Microsoft Visual Studio Debugger • Valgrind • WinDbg
  • 21. . .
  • 22. . .
  • 23. . .