Difference between revisions of "Correctness checking"
(Created page with "This is a short overview over the basic concepts of Correctness Checking (debugging). __TOC__ == General == The common approach of try and error is usually not very efficien...") |
(→) |
||
Line 4: | Line 4: | ||
== General == | == General == | ||
− | The common approach of | + | The common approach of trial and error is usually not very efficient with large programs. It is easy to lose track of what has been tested and adjusted and it small changes are easily forgotten when trying to recover an earlier state. It is therefore advisable to tackle errors and warnings systematically. A good first approach is always to keep a logbook (which can be a simple textfile) and write down exactly what error message came up, if and how it was reproducable and actions taken to understand what happened (e.g. core file). Bug tacking systems (e.g. Bugzilla, trac) can also be helpful. |
While debugging it is also recommended to simplify the program, i.g. reducing the input size, reducing the number of pprocesses etc. and also reducing the number of compiler warnings. These test cases can be reused when making changes later on so you might want to keep them. Please not that when using [[Parallel_Programming]] it is important to keep a high enough number of processors, as issues like data races will not occur otherwise. | While debugging it is also recommended to simplify the program, i.g. reducing the input size, reducing the number of pprocesses etc. and also reducing the number of compiler warnings. These test cases can be reused when making changes later on so you might want to keep them. Please not that when using [[Parallel_Programming]] it is important to keep a high enough number of processors, as issues like data races will not occur otherwise. | ||
− | It is also advisable to use a source control manager (e.g. git, svn) to be able to recover an earlier state of the program. | + | It is also advisable to use a source control manager (e.g. git, svn) to be able to recover an earlier state of the program. |
== Common issues == | == Common issues == |
Revision as of 16:15, 8 January 2019
This is a short overview over the basic concepts of Correctness Checking (debugging).
General
The common approach of trial and error is usually not very efficient with large programs. It is easy to lose track of what has been tested and adjusted and it small changes are easily forgotten when trying to recover an earlier state. It is therefore advisable to tackle errors and warnings systematically. A good first approach is always to keep a logbook (which can be a simple textfile) and write down exactly what error message came up, if and how it was reproducable and actions taken to understand what happened (e.g. core file). Bug tacking systems (e.g. Bugzilla, trac) can also be helpful.
While debugging it is also recommended to simplify the program, i.g. reducing the input size, reducing the number of pprocesses etc. and also reducing the number of compiler warnings. These test cases can be reused when making changes later on so you might want to keep them. Please not that when using Parallel_Programming it is important to keep a high enough number of processors, as issues like data races will not occur otherwise.
It is also advisable to use a source control manager (e.g. git, svn) to be able to recover an earlier state of the program.
Common issues
Small mistakes can create very interesting error messages that are often also completely unrelated to the point where they actually happened. A list of things you may want to look out for:
- Are all variables initialized?
- Are there unused variables? (written but never read)
- Is there a part in the code that is never reached? (e.g. broken if-statement)
- Beware of pointers
- what are the defaults on the system you are using (e.g. stack size too small)
Debugging Tools
There are usually various debugging Tools available on a cluster, which can mostly be divided into two types, interpretive and direct execution. The former more or less works on the source code and machine code level and simulates parts of the program while the latter is attached to the program and monitors the internal state of it during runtime. The most common strategies are line by line execution or the use of breakpoints to skip the monitoring of longer and irrelevant parts.