Discussion:
How to use valgrind and gdb
(too old to reply)
cs240
2011-07-18 15:05:21 UTC
Permalink
gdb is a c++ debugger, to use it compile your code using g++ with the -g
flag, then call gdb on the compiled object

EG:
g++ -g *.cpp
gdb a.out

http://www.student.cs.uwaterloo.ca/~cs343/documents/C++GDBTutorial.pdf


valgrind is a programming tool for memory debugging, memory leak
detection, and profiling.

If you have a segmentation fault, run valgrind on your program to check
for any uninitialized values.

EG:
valgrind a.out
--
Patrick Lee
CS240 Tutor
Daniel S. Roche
2011-07-18 15:23:30 UTC
Permalink
Post by cs240
valgrind is a programming tool for memory debugging, memory leak
detection, and profiling.
If you have a segmentation fault, run valgrind on your program to check
for any uninitialized values.
valgrind a.out
Yes, valgrind is a wonderful (and free!) tool. I recommend the "quick
start guide" here: http://valgrind.org/docs/manual/quick-start.html

Tips:
-Compile with -g for gdb AND for valgrind
-Run valgrind with --leak-check=yes since memory leaks are probably what
you're after.
-All the sizes are in terms of bytes. For reference, a char is typically
1 byte, an int is typically 4, and a double is always 8 bytes.
-valgrind is really slow. Don't use big data on it! Start with very
small examples and build up slowly until you get some errors.

-Dan Roche
CS 240 Instructor, Section 003

Loading...