File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 3
3
#include < algorithm>
4
4
#include < cassert>
5
5
#include < cstdlib>
6
+ #include < execinfo.h>
6
7
#include < functional>
8
+ #include < iostream>
7
9
#include < map>
8
10
#include < memory>
9
11
#include < optional>
20
22
#include " file.hpp"
21
23
22
24
25
+
23
26
namespace ioh ::problem
24
27
{
25
28
// ! Defintion interface of problems that are defined in static files
@@ -57,6 +60,21 @@ namespace ioh::problem
57
60
58
61
namespace ioh ::common
59
62
{
63
+
64
+ void printStackTrace () {
65
+ const int MAX_CALLSTACK_SIZE = 128 ;
66
+ void *callstack[MAX_CALLSTACK_SIZE];
67
+ int stackSize = backtrace (callstack, MAX_CALLSTACK_SIZE);
68
+ char **symbols = backtrace_symbols (callstack, stackSize);
69
+
70
+ std::cerr << " Call Stack:" << std::endl;
71
+ for (int i = 0 ; i < stackSize; i++) {
72
+ std::cerr << symbols[i] << std::endl;
73
+ }
74
+
75
+ free (symbols);
76
+ }
77
+
60
78
// ! Function to get the next non zero value in an array of integers
61
79
inline int get_next_id (const std::vector<int > &ids)
62
80
{
@@ -135,7 +153,9 @@ namespace ioh::common
135
153
std::cerr << error_message << std::endl;
136
154
std::cout << error_message << std::endl;
137
155
138
- assert (false );
156
+ printStackTrace ();
157
+
158
+ assert (!already_defined && name.c_str ());
139
159
}
140
160
141
161
name_map[name] = std::move (creator);
You can’t perform that action at this time.
0 commit comments