Other Debugging Tools Flashcards
Log Files
- files containing text and values written out by programs as they execute
- can be gathered over a long period of time
- can gather information in a production system.
- good for working with distributed programs
Log4c
- our own logging system
- Has 3 levels of logging severity
error: very important, major problems
warning: must read, something is wrong
info: informational message - 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
Assertions
- access assertions: #include <assert.h></assert.h>
- Added to production systems to stop program when something goes very
wrong - Tells the programmer the impossible happened and needs to be fixed
- assert(logical condition)
-If the condition is triggered, the assert fires.
Lint
- check source code for many possible errors
- can give clues about the source of a bug
- Available for many languages
- more sensitive than a compiler & points out potential source errors compiler might miss
- might yield higher quality source code
Core Dumps
- older debugging technique
- makes copy of all of the memory allocated for program and writes it to a file
- information is in binary, very laborous
- can use automatic dump readers which can allow you to explore these files in a more human readable way
Conditional Compilation
define DEBUG
- can turn debugging on and off by simply changing the value of the DEBUG macro
…
#ifdef DEBUG
printf(“%s(%d):z$d\n”,FILE,LINE,z);
#endif
- uses preprocessor directives to include or exclude code from the build based on the value of a macro
Debug and Release Builds
Debug builds
- do more checking of error conditions
- in debug mode, code is compile such that:
- it does not optimize the code to make it as fast as possible
- it might include additional runtime checks
Release Builds
- faster but dont do checking
Compiled vs Interpreted
Compiled
- 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 Typed 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
- Type mismatches may not be detected until runtime.
- Errors in infrequently executed lines may remain undetected for a long timer.