Difference between revisions of "CodeDebugging"

From Mu2eWiki
Jump to navigation Jump to search
(Created page with "==Introduction== ==gdb== ==DDT== ==valgrind==")
 
Line 6: Line 6:
  
 
==valgrind==
 
==valgrind==
 +
 +
[http://valgrind.org valgrind] is a memory debugger which largely works by inserting itself into all heap access and flagging memory as requiring a callback before use.  It can detect:
 +
* use of unintialized variables
 +
* using a pointer to access memory not allocated to that pointer
 +
* double deletion
 +
* memory leaks
 +
It is installed on all interactive machines, or you can UPS setup a particular version.
 +
 +
Here is a typical command
 +
valgrind --leak-check=yes --error-limit=no -v  \
 +
        --demangle=yes --show-reachable=yes  --num-callers=20
 +
 +
The additional memory checking causes the exe to run much slower.
 +
 +
You may find that packages like root libraries may have so many (probably not consequential) errors detected that it drowns out the useful messages.  You can create a file of error types, or source code to suppress, please see the [http://valgrind.org documentation].

Revision as of 20:07, 23 July 2018

Introduction

gdb

DDT

valgrind

valgrind is a memory debugger which largely works by inserting itself into all heap access and flagging memory as requiring a callback before use. It can detect:

  • use of unintialized variables
  • using a pointer to access memory not allocated to that pointer
  • double deletion
  • memory leaks

It is installed on all interactive machines, or you can UPS setup a particular version.

Here is a typical command

valgrind --leak-check=yes --error-limit=no -v  \
        --demangle=yes --show-reachable=yes  --num-callers=20 

The additional memory checking causes the exe to run much slower.

You may find that packages like root libraries may have so many (probably not consequential) errors detected that it drowns out the useful messages. You can create a file of error types, or source code to suppress, please see the documentation.