File failed to load: https://isis.astrogeology.usgs.gov/7.1.0/Object/assets/jax/output/NativeMML/config.js
Isis Developer Reference
IsisDebug.h
Go to the documentation of this file.
1#ifndef IsisDebug_h
2#define IsisDebug_h
8/* SPDX-License-Identifier: CC0-1.0 */
9
10#ifdef __GTHREADS
11#error *****IsisDebug.h MUST be included before any system header files!*****
12#endif
13
17void Abort(int);
19
20#ifdef CWDEBUG
25#include <libcwd/sys.h>
26#include <libcwd/debug.h>
27#include <execinfo.h>
28#include <dlfcn.h>
29
30#include <fstream>
31#include <QMutex>
32
39#include "QString.h"
40#include "Constants.h"
41
45#define ASSERT_PTR(x) \
46 if (libcwd::test_delete(x)) \
47 { \
48 std::cerr << ">> " << __FILE__ << ":" << __LINE__ << \
49 " error: ASSERT POINTER " << #x << " FAILED\n"; \
50 }
51
52class MyMutex : public QMutex {
53 public:
54 bool trylock() {
55 return tryLock();
56 }
57};
58
64class StackTrace {
65 public:
76 static void GetStackTrace(std::vector<std::string> *stackTraceResult) {
77 stackTraceResult->clear();
78 const int MAX_STACK_DEPTH = 1024;
79
80 void *stackTrace[MAX_STACK_DEPTH];
81 int stackSize = backtrace(stackTrace, MAX_STACK_DEPTH);
82
83 for(int stackEl = 2; stackEl < stackSize; stackEl ++) {
84 std::string currElement;
85 void *addr = stackTrace[stackEl];
86
87 libcwd::location_ct addrInfo(addr);
88 std::string demangled_name;
89 libcwd::demangle_symbol(addrInfo.mangled_function_name(), demangled_name);
90
91 currElement = ">> ";
92
93 if(addrInfo.is_known()) {
94 currElement +=
95 std::string(addrInfo.file()) +
96 std::string(":") +
97 QString((Isis::BigInt)addrInfo.line()) +
98 std::string(" --- ") +
99 demangled_name;
100 }
101 else {
102 currElement += "?????:0 --- " + demangled_name;
103 }
104
105 stackTraceResult->push_back(currElement);
106 }
107 }
108};
109
110#else
111#define ASSERT_PTR(x)
112
113
120 public:
121 static void GetStackTrace(const void *) {}
122};
123#endif
124
125#ifdef DEBUG
126#include <iostream>
127#define ASSERT(x) \
128 if (!(x)) \
129 { \
130 std::cerr << ">> " << __FILE__ << ":" << __LINE__ << \
131 " error: ASSERT " << #x << " FAILED\n"; \
132 }
133#else
134#define ASSERT(x)
135#endif
136
137#endif
void Abort(int)
void SegmentationFault(int)
void startMonitoringMemory()
This is free and unencumbered software released into the public domain.
void stopMonitoringMemory()
void InterruptSignal(int)
Definition: IsisDebug.h:119
static void GetStackTrace(const void *)
Definition: IsisDebug.h:121
long long int BigInt
Big int.
Definition: Constants.h:49

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 02/21/2025 21:56:32