Skip to content

Commit

Permalink
Add basic valgrind support
Browse files Browse the repository at this point in the history
But something is wrong because I always get a warning about converting to unsigned int, so disable.
  • Loading branch information
jedbrown committed Mar 12, 2011
1 parent 8ba134d commit c4a6f1c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ list (APPEND CMAKE_MODULE_PATH "${Dohp_SOURCE_DIR}/CMake")
# Normally PETSc is built with MPI, if not, use CC=mpicc, etc
find_package (PETSc REQUIRED)
find_package (ITAPS COMPONENTS MESH GEOM REL)
find_path (MEMCHECK_HEADER valgrind/memcheck.h)
if (MEMCHECK_HEADER)
set (dUSE_VALGRIND TRUE)
endif ()

#find_package (Doxygen)

Expand Down
1 change: 1 addition & 0 deletions dohpconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@

#cmakedefine dUSE_DEBUG
#cmakedefine dUSE_PARALLEL_HDF5
#cmakedefine dUSE_VALGRIND

#endif
11 changes: 11 additions & 0 deletions include/dohp.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
#include <stdint.h>
#include <petscsys.h>

#if defined dUSE_VALGRIND && 0
# include <valgrind/memcheck.h>
# define dMakeMemUndefined(mem,bytes) do { \
if (VALGRIND_MAKE_MEM_UNDEFINED((mem),(bytes))) dERROR(PETSC_COMM_SELF,PETSC_ERR_LIB,"Valgrind returned an error"); \
} while (0)
#else
# define dMakeMemUndefined(mem,bytes) do { \
if (dMemzero((mem),(bytes))) dERROR(PETSC_COMM_SELF,PETSC_ERR_MEMC,"Memory " #mem " is corrupt"); \
} while (0)
#endif

#define dSTATUS_UNOWNED (dEntStatus)0x1
#define dSTATUS_SHARED (dEntStatus)0x2
#define dSTATUS_INTERFACE (dEntStatus)0x4
Expand Down
10 changes: 4 additions & 6 deletions src/fs/interface/fsrulesetit.c
Original file line number Diff line number Diff line change
Expand Up @@ -738,12 +738,10 @@ static dErr ValueCacheReset(struct ValueCache *vc,dBool self)
vc->v = NULL;
vc->dv = NULL;
}
#if defined dUSE_DEBUG
err = dMemzero(vc->u_alloc,nbs*sizeof(dScalar));dCHK(err);
err = dMemzero(vc->du_alloc,3*nbs*sizeof(dScalar));dCHK(err);
err = dMemzero(vc->v_alloc,nbs*sizeof(dScalar));dCHK(err);
err = dMemzero(vc->dv_alloc,3*nbs*sizeof(dScalar));dCHK(err);
#endif
dMakeMemUndefined(vc->u_alloc,nbs*sizeof(dScalar));
dMakeMemUndefined(vc->du_alloc,3*nbs*sizeof(dScalar));
dMakeMemUndefined(vc->v_alloc,nbs*sizeof(dScalar));
dMakeMemUndefined(vc->dv_alloc,3*nbs*sizeof(dScalar));
dFunctionReturn(0);
}

Expand Down

0 comments on commit c4a6f1c

Please sign in to comment.