Software Testing Debugging Tools PDF

Summary

This presentation covers various debugging tools and techniques used in software testing. It includes a discussion about log files, assertions, and other methods to identify and resolve software issues, as well as methods for compiler use. Topics also include conditional compilation, and strongly vs weakly typed programming languages.

Full Transcript

Software Testing Other Debugging Tools Instructor: Kaveh Eshraghian Overview Log Files Assertions Lint Core Dumps Conditional Compilation Debug and Release Build Other Languages Log Files Definition:  Log files are simply files containing text and values written out b...

Software Testing Other Debugging Tools Instructor: Kaveh Eshraghian Overview Log Files Assertions Lint Core Dumps Conditional Compilation Debug and Release Build Other Languages Log Files Definition:  Log files are simply files containing text and values written out by programs as they execute. Application:  Debug distributed programs working on many computers making function calls from one to another.  Mostly used to gather information on production systems Benefits:  Information gathered continuously.  Information stored for a long period of time  Gather output under certain circumstances. Log File Information The name of the computer producing the output. The name of the program producing the output. The ID of the thread producing the output. The timestamp of the output to the millisecond. The name of the function producing the output. Including the name of the file producing the output and the line number. An informational message that might show the values of variables. Log4c 3 levels of logging severity  Error – very important  Warning – you should read this  Info – information you might want to see (most debugging info) Can be  Filtered to write only messages of higher than a given severity  Can be enabled and disabled  Can auto flush to make sure output or not to increase efficiency Log4c Functions Function Description l4cOpen Open a log file for overwriting or appending l4cClose Close an open log file l4cError Write a message to the log with a specific severity l4cWarning level. l4cInfo l4cPrintf Write a formatted message to the log file. l4cEnable Enable or disable log file. l4cDisable l4cIsEnabled l4cFilter Set filter level or get filter level. l4cGetFilter l4cEnableAutoFlush Turn AutoFlush on or off. l4cDisableAutoFlush Assertions Application:  Added to production systems to stop program when something goes very wrong  Tells the programmer the impossible happened and needs to be fixed How to use:  #include  assert(logical condition)  If the condition is triggered, the assert fires.  E.g. assert(length > 0); Lint A program which checks code for many possible errors Can give clues about the source of a bug Available for many languages CPPcheck for windows  https://github.com/danmar/cppcheck/releases/tag/2.8 CPPcheck Core Dumps A much older debugging technique which are rarely used nowadays. A copy of the memory allocated for program written it to a file. In binary and is very laborious to go through by hand. Automatic dumped readers which can allow you to explore these files in a more human readable way. Debug and Release Builds Debug Mode:  It links to a set of libraries which have been compiled in debug mode.  It includes debugging information in an associated program database file.  It does not optimize the code to make it as fast as possible.  It might include additional runtime checks to pick up errors.  Slower compared to release mode. Release Mode:  No longer includes all the debugging information.  Runs the optimizer to produce the fastest running code possible. Conditional Compilation We can turn debugging on an off with #define DEBUG 1... if(DEBUG) printf("%s (%d): z=%d\n", __FILE__, __LINE__, z); This does a check of the condition during runtime, slowing program Conditional compilation is more efficient #define DEBUG... #ifdef DEBUG printf("%s (%d): z=%d\n", __FILE__, __LINE__, z); #endif Compiled vs. Interpreted Compiled  A compiler goes through the whole program at once before it runs  Detects problems before the program ever runs Interpreted  Program is run line by line  Program is parsed only just before line is executed  Problems are not detected until line is executed  Rarely executed lines can make it to production with bugs in them because they were never executed Strongly vs. Weakly Typed Strongly typed  All assignments and function calls are check to make sure the right types are used  Errors detected at compilation time Weakly typed  Variables and parameters can accept any type  Sending the wrong variable by mistake is not detected until the line is executed  Rarely executed lines can have errors in them that are not detected until months later.

Use Quizgecko on...
Browser
Browser