Mex files from Matlab debug.
In general: Compile mex files with -g -DDEBUG option.
inside DDD:
Additional useful valgrind option: --leak-check=yes
C++ output in matlab (useful macros):
/* macros for debugging */ #ifdef DEBUG #include "mex.h" #define MPRINT_MSG(_msg) mexPrintf("[%s|%s, %3d]: %s\n", __FILE__, __func__, __LINE__, _msg); #define MPRINT_INT(_val) mexPrintf("[%s|%s, %3d]: %s = %d\n", __FILE__, __func__, __LINE__, #_val, _val); #define MPRINT_DBL(_val) mexPrintf("[%s|%s, %3d]: %s = %f\n", __FILE__, __func__, __LINE__, #_val, _val); #define MPRINT_PTR(_val) mexPrintf("[%s|%s, %3d]: %s = %p\n", __FILE__, __func__, __LINE__, #_val, _val); #else /* #ifdef DEBUG */ /* do not print messages and values */ #define MPRINT_MSG(_msg) #define MPRINT_INT(_val) #define MPRINT_DBL(_val) #define MPRINT_PTR(_val) /* assert needs that when no debugging is desired and therefore, assertion is ignored */ #ifndef NDEBUG #define NDEBUG 1 #endif #endif /* #ifdef DEBUG */