Debugging Flashcards
Bug
- is not any error
- failure, fault, error
- infinite loop(failure)
- deadlock (failure)
- incorrect output (failure)
- memory leaks (failure)
- runtime exception
Segmentation Fault
-program try’s to access memory that is not available (outside accessible range)
Bus fault
-program tried to access misaligned data item
Illegal instruction
-try to execute an unassigned or privileged opcode
Bug classification
- A : algorithm ~ code follows the infect of the programmer but intent was wrong
- D : data ~ code reads/writes incorrect data or accessed a wrong storage location
- F : Forgotten ~ a missing action/statement or maybe put in wrong place
- B : Blunder ~ algorithm was correct but it was implemented wrong
Blunder
- variable (wrong var name)
- expression (incorrect written expression)
- language (mistake encouraged by language syntax)
Whose bug
Goes away when try to observe it
Bug detection
1: study the failure systems, add exception handler
2: read and re-read in error location, have someone else read code, or someone who will listen
3: experiment to find the simplest way to identify
4: try inserting, verifying of the code is working as it should
Crash dumps
Debugger helps discover where program crashed and why, inspect call stack, and values of vars
Static tools
Crash dump inspection
Dynamic tools
Debugger
Debugger monitoring facilities
- breakpoint: break main
- single step execution: step over line you don’t want to go through
- inspect vars: use where or print vars
- display source code: list main
- fault detection: throws exception
- watchpoints: watch when var changes
- multithread/ multiprocess support: monitor execution of threads
Failure
Something visible to the programs user
Fault
The state of the program which leads to a failure
Error
The incorrect code fragment which leads to the fault and thus to the failure