03.12.2012 Views

C++ for Scientists - Technische Universität Dresden

C++ for Scientists - Technische Universität Dresden

C++ for Scientists - Technische Universität Dresden

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

10.3. VALGRIND 239<br />

Stepi and Nexti This are the equivalents on instruction level. This is<br />

only needed <strong>for</strong> debugging assembler code and not subject in this<br />

book.<br />

Until Position your cursor in your source and run the program until you<br />

reach this line. If your program flow do not pass this line the execution<br />

will continued till the end, the next break point or bug.<br />

Finish Execute the remainder of the current function and stop in the first<br />

line outside this function, i.e. the line after the function call.<br />

Cont Continue your execution till the next event (break point, bug, or<br />

end).<br />

Kill the program.<br />

Up Show the line of the current function’s call, i.e. go up one level in the<br />

call stack.<br />

Down Go back to the called function, i.e. go down one level in the call<br />

stack.<br />

Undo Revert last action (works rarely or never).<br />

Redo Repeat the last command.<br />

Edit Call an editor with the source file currently shown.<br />

Make Call ‘make’ (which must know what to compile).<br />

10.3 Valgrind<br />

The valgrind distribution offers several tools that you can use to analyze your software. We will<br />

only use one of these tools called memcheck. For more in<strong>for</strong>mation on the others we refer you<br />

to http://valgrind.org Memcheck detects memory-management problems like memory leaks.<br />

Memcheck also reports if your program accesses memory it should not or if it uses uninitialized<br />

values. All these errors are reported as soon as they occur along with the corresponding source<br />

line number at which they occurred and also a stack trace of the functions called to reach<br />

that line. You should also take into account that Memcheck runs programs about 10 to 30<br />

times slower than normal. Use the following command to check the memory management of a<br />

program:<br />

valgrind −−tool=memcheck program name<br />

10.4 Gnuplot<br />

A useful tool <strong>for</strong> making plots is Gnuplot. It is a public domain program.<br />

Invoke gnuplot to start the program. Suppose we have the file results with the following<br />

content:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!