summaryrefslogtreecommitdiffstats
path: root/core/subsurface-qt/DiveObjectHelper.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2019-10-19 17:54:56 -0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-10-20 16:08:55 -0400
commit5a10cd42f7f0d5eef6a220046c4ed2671baea6c4 (patch)
tree6eb16e53757f5649e5758574323ec2daed7cc030 /core/subsurface-qt/DiveObjectHelper.cpp
parent769403a4b2c3dd8e8cc94d7f1b5dad6b66d10caf (diff)
downloadsubsurface-5a10cd42f7f0d5eef6a220046c4ed2671baea6c4.tar.gz
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>
Diffstat (limited to 'core/subsurface-qt/DiveObjectHelper.cpp')
-rw-r--r--core/subsurface-qt/DiveObjectHelper.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/core/subsurface-qt/DiveObjectHelper.cpp b/core/subsurface-qt/DiveObjectHelper.cpp
index 9e4ff47bb..85138c0c0 100644
--- a/core/subsurface-qt/DiveObjectHelper.cpp
+++ b/core/subsurface-qt/DiveObjectHelper.cpp
@@ -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()