Software Testing - Debugging Techniques
21 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is a common reason for a program to stop unexpectedly during execution?

  • Handling an exception without appropriate actions (correct)
  • Low battery on the device running the program
  • Exceeding the maximum number of function calls allowed
  • Using dynamic memory allocation correctly
  • What is a likely cause of running out of stack space in a program?

  • Allocating large global variables
  • A shallow recursion with limited variables
  • Circular dependencies in memory allocation
  • Storing a large number of local variables inside functions (correct)
  • Which of the following numeric issues can cause a program to produce an incorrect result?

  • Using float data type for calculations
  • Overflow due to using a small integer type (correct)
  • Using a long integer type for all calculations
  • Assigning a float to an integer without explicit conversion
  • What does a non-zero return code typically indicate in a program?

    <p>A failure case in the operation</p> Signup and view all the answers

    What might result in a NaN value during numeric calculations?

    <p>Dividing by zero</p> Signup and view all the answers

    What is the primary goal of debugging in software development?

    <p>To identify and remove errors from software</p> Signup and view all the answers

    Which of the following is a step in the debugging process?

    <p>Gather Evidence</p> Signup and view all the answers

    Which type of error is detected at compile time?

    <p>Syntactic Errors</p> Signup and view all the answers

    What defines a linker error?

    <p>A mismatch between compiled symbols and libraries</p> Signup and view all the answers

    What is an example of a debugging technique?

    <p>Using interactive debuggers</p> Signup and view all the answers

    What should programmers strive for regarding warnings in their code?

    <p>To develop programs with no warnings</p> Signup and view all the answers

    Which of the following best describes a semantic error?

    <p>Difficult to find and fix in a running program</p> Signup and view all the answers

    What does a declaration typically include?

    <p>The name of the function and the types of its parameters</p> Signup and view all the answers

    What does an external declaration using 'extern' achieve in a program?

    <p>Indicates the variable was declared elsewhere</p> Signup and view all the answers

    Which of the following is NOT a common reason for segmentation faults?

    <p>Using a pointer with a valid address</p> Signup and view all the answers

    What is usually the outcome of encountering a bus error?

    <p>Program terminates</p> Signup and view all the answers

    What common issue can cause a program to exhibit random behavior upon every execution?

    <p>Uninitialized variables</p> Signup and view all the answers

    What might cause a variable to change its value unexpectedly during program execution?

    <p>Using a bad pointer</p> Signup and view all the answers

    Which statement best describes the issue of 'working on some compilers'?

    <p>Different compilers can produce varying outputs for the same code</p> Signup and view all the answers

    In the context of debugging, what is a primary clue for identifying the location of a bug?

    <p>Where the program was executing when the bug occurred</p> Signup and view all the answers

    What may indicate that a program is executing wrong code?

    <p>The stack trace is incomplete</p> 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.

    Quiz Team

    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.

    More Like This

    Junior Software Development Essentials Quiz
    10 questions
    Software Testing Fundamentals
    16 questions

    Software Testing Fundamentals

    DetachableSanctuary378 avatar
    DetachableSanctuary378
    Use Quizgecko on...
    Browser
    Browser