Core: debug helper for DOH constructor

This is disabled by default - but when compiled in it makes it a lot
easier to pinpoint why we are creating so many DiveObjectHelpers.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2019-10-19 17:54:56 -04:00
parent 769403a4b2
commit 5a10cd42f7

View file

@ -10,6 +10,14 @@
#include "core/subsurface-string.h"
#include "qt-models/tankinfomodel.h"
#if defined(DEBUG_DOH)
#include <execinfo.h>
#include <stdio.h>
#include <unistd.h>
static int callCounter = 0;
#endif /* defined(DEBUG_DOH) */
enum returnPressureSelector {START_PRESSURE, END_PRESSURE};
static QString getFormattedWeight(const struct dive *dive, unsigned int idx)
@ -169,7 +177,7 @@ static QVector<CylinderObjectHelper> makeCylinderObjects(const dive *d)
static QStringList formatGetCylinder(const dive *d)
{
QStringList getCylinder;
QStringList getCylinder;
for (int i = 0; i < MAX_CYLINDERS; i++) {
if (is_cylinder_used(d, i))
getCylinder << d->cylinder[i].type.description;
@ -246,6 +254,17 @@ DiveObjectHelper::DiveObjectHelper(const struct dive *d) :
endPressure(getEndPressure(d)),
firstGas(getFirstGas(d))
{
#if defined(DEBUG_DOH)
void *array[4];
size_t size;
// get void*'s for all entries on the stack
size = backtrace(array, 4);
// print out all the frames to stderr
fprintf(stderr, "\n\nCalling DiveObjectHelper constructor for dive %d - call #%d\n", d->number, ++callCounter);
backtrace_symbols_fd(array, size, STDERR_FILENO);
#endif /* defined(DEBUG_DOH) */
}
DiveObjectHelperGrantlee::DiveObjectHelperGrantlee()