Podcast
Questions and Answers
What is a common reason for a program to stop unexpectedly during execution?
What is a common reason for a program to stop unexpectedly during execution?
What is a likely cause of running out of stack space in a program?
What is a likely cause of running out of stack space in a program?
Which of the following numeric issues can cause a program to produce an incorrect result?
Which of the following numeric issues can cause a program to produce an incorrect result?
What does a non-zero return code typically indicate in a program?
What does a non-zero return code typically indicate in a program?
Signup and view all the answers
What might result in a NaN value during numeric calculations?
What might result in a NaN value during numeric calculations?
Signup and view all the answers
What is the primary goal of debugging in software development?
What is the primary goal of debugging in software development?
Signup and view all the answers
Which of the following is a step in the debugging process?
Which of the following is a step in the debugging process?
Signup and view all the answers
Which type of error is detected at compile time?
Which type of error is detected at compile time?
Signup and view all the answers
What defines a linker error?
What defines a linker error?
Signup and view all the answers
What is an example of a debugging technique?
What is an example of a debugging technique?
Signup and view all the answers
What should programmers strive for regarding warnings in their code?
What should programmers strive for regarding warnings in their code?
Signup and view all the answers
Which of the following best describes a semantic error?
Which of the following best describes a semantic error?
Signup and view all the answers
What does a declaration typically include?
What does a declaration typically include?
Signup and view all the answers
What does an external declaration using 'extern' achieve in a program?
What does an external declaration using 'extern' achieve in a program?
Signup and view all the answers
Which of the following is NOT a common reason for segmentation faults?
Which of the following is NOT a common reason for segmentation faults?
Signup and view all the answers
What is usually the outcome of encountering a bus error?
What is usually the outcome of encountering a bus error?
Signup and view all the answers
What common issue can cause a program to exhibit random behavior upon every execution?
What common issue can cause a program to exhibit random behavior upon every execution?
Signup and view all the answers
What might cause a variable to change its value unexpectedly during program execution?
What might cause a variable to change its value unexpectedly during program execution?
Signup and view all the answers
Which statement best describes the issue of 'working on some compilers'?
Which statement best describes the issue of 'working on some compilers'?
Signup and view all the answers
In the context of debugging, what is a primary clue for identifying the location of a bug?
In the context of debugging, what is a primary clue for identifying the location of a bug?
Signup and view all the answers
What may indicate that a program is executing wrong code?
What may indicate that a program is executing wrong code?
Signup and view all the answers
Study Notes
Software Testing - Debugging
- Debugging is the process of identifying and removing errors (bugs) from computer software or hardware.
Debugging Techniques
- Using print statements
- Creating and reviewing log files
- Using an interactive debugger
Debugging Process
- Start
- Gather Evidence
- Test Code
- Fix Bug
- Interpret Evidence
- Passed
- Done
- Failed
Types of Errors
- Syntactic errors: Code doesn't follow the language rules, detected at compile time, easy to fix.
- Semantic errors: Logic errors in the running program, harder to find, usually require debugging techniques.
- Requirements errors: Building the wrong program, clarifying requirements needed.
Syntactic Errors
- Errors: Severe, stop compilation, need correction before continuing
- Warnings: Do not stop compilation, indicate unusual situations, often point to a possible semantic error, shouldn't be ignored, strive for a program with no warnings.
Linker Errors
- Definition: Mismatches between compiled symbols and the libraries using them. (Diagram shows compilation, object files, and linking process)
Declaration vs Definition
- Declaration: Function name, parameters, return type. (Example code shows syntax for declaration).
- Definition: Function's code, what the linker is looking for. (Example code shows syntax for definition).
Extern Declarations
-
Declaration: Declares a variable type (Example code demonstrates declaration syntax, including
#ifndef
and#endif
preprocessor directives). -
Definition: Allocates memory to the variable. (Example code demonstrates definition syntax,
#ifndef
and#endif
).
Debugging Techniques
- Debugging needs understanding the process, execution moment, termination point and issues in the results.
- Knowing where the bug occurred, whether the program terminated at the bug location.
- Knowing where a program has incorrect results, how the code line executes and variable values during execution.
Debugging Clues
- Segmentation Faults: Program trying to access unallocated memory, resulting in program termination. Common causes: Subscripts, invalid/null pointers, uninitialized variables, deallocated memory.
- Bus Error: Program attempting to access illegal/non-existent memory, same result as Segmentation Fault.
- Random Behavior: Program behaves differently each time, unpredictable launch behavior, common cause: uninitialized variables.
- Executing Wrong Code: Program executes unexpected code, stack trace is incomplete. Common cause: bad pointers.
- Variable Changing Value: Variable value unexpectedly changes, common causes: running off array bounds/indexes, bad pointers.
- Working on Some Compilers: Program behaves differently across different compilers or operating systems. Windows zeros memory, but Unix doesn't, different memory allocation and layouts.
- Program Stopping Unexpectedly: Program terminates unexpectedly, might have exceptions or signals. Try-catch block needed. No action in try, catch block.
- Memory Layout: Application memory is divided into segments: Constants, Code (executable code), Stack (local data in active functions), and Heap (dynamically allocated memory).
- Memory Layout Issues: Out of stack space (large variables, infinite recursion), out of heap memory (allocation too much, memory leaks).
- Numeric Problems: Incorrect results due to integer arithmetic (fractional part loss), results starting correctly but changing sign, numbers getting very big or too small. Infinity, NaN results and strange values, division by zero and other arithmetic issues.
- Non-Zero Return Code: Used for a failed execution, could result from "out of memory," or "divide by zero"
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Explore the essential methods and processes involved in debugging software. This quiz covers various debugging techniques, types of errors, and the overall debugging process. Test your understanding of how to identify and fix issues in programming effectively.