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 33#include < algorithm>
44#include < cassert>
55#include < cstdlib>
6+ #include < execinfo.h>
67#include < functional>
8+ #include < iostream>
79#include < map>
810#include < memory>
911#include < optional>
2022#include " file.hpp"
2123
2224
25+
2326namespace ioh ::problem
2427{
2528 // ! Defintion interface of problems that are defined in static files
@@ -57,6 +60,21 @@ namespace ioh::problem
5760
5861namespace ioh ::common
5962{
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+
6078 // ! Function to get the next non zero value in an array of integers
6179 inline int get_next_id (const std::vector<int > &ids)
6280 {
@@ -135,7 +153,9 @@ namespace ioh::common
135153 std::cerr << error_message << std::endl;
136154 std::cout << error_message << std::endl;
137155
138- assert (false );
156+ printStackTrace ();
157+
158+ assert (!already_defined && name.c_str ());
139159 }
140160
141161 name_map[name] = std::move (creator);
You can’t perform that action at this time.
0 commit comments