25 #error *****Isis.h MUST be included before any other files!*****
28 #include "IsisDebug.h"
32 #include <QCoreApplication>
38 #define APPLICATION IsisMain
88 std::map<QString, void *> empty;
95 void startMonitoringMemory();
96 void stopMonitoringMemory();
97 void SegmentationFault(
int);
99 void InterruptSignal(
int);
109 int main(
int argc,
char *argv[]) {
111 startMonitoringMemory();
112 signal(SIGSEGV, SegmentationFault);
113 signal(SIGABRT, Abort);
114 signal(SIGINT, InterruptSignal);
117 Isis::Application::p_applicationForceGuiApp =
false;
120 Isis::Application::p_applicationForceGuiApp =
true;
125 int status = app->
Run(APPLICATION);
127 delete QCoreApplication::instance();
132 void startMonitoringMemory() {
134 MyMutex *mutex =
new MyMutex();
135 std::fstream *alloc_output =
new std::fstream(
"/dev/null");
136 Debug(make_all_allocations_invisible_except(NULL));
137 ForAllDebugChannels(
if(debugChannel.is_on()) debugChannel.off());
138 Debug(dc::malloc.on());
139 Debug(libcw_do.on());
140 Debug(libcw_do.set_ostream(alloc_output));
141 Debug(libcw_do.set_ostream(alloc_output, mutex));
142 atexit(stopMonitoringMemory);
147 void stopMonitoringMemory() {
150 alloc_filter_ct alloc_filter;
151 std::vector<std::string> objmasks;
152 objmasks.push_back(
"libc.so*");
153 objmasks.push_back(
"libstdc++*");
154 std::vector<std::string> srcmasks;
155 srcmasks.push_back(
"*new_allocator.h*");
156 srcmasks.push_back(
"*set_ostream.inl*");
157 alloc_filter.hide_objectfiles_matching(objmasks);
158 alloc_filter.hide_sourcefiles_matching(srcmasks);
159 alloc_filter.hide_unknown_locations();
160 delete libcw_do.get_ostream();
161 libcw_do.set_ostream(&std::cout);
162 list_allocations_on(libcw_do, alloc_filter);
170 void SegmentationFault(
int) {
171 std::vector<std::string> currentStack;
172 StackTrace::GetStackTrace(¤tStack);
174 std::cerr <<
"Segmentation Fault" << std::endl;
175 for(
unsigned int i = 1; i < currentStack.size(); i++) {
176 std::cerr << currentStack[i] << std::endl;
183 std::vector<std::string> currentStack;
184 StackTrace::GetStackTrace(¤tStack);
186 std::cerr <<
"Abort" << std::endl;
187 for(
unsigned int i = 1; i < currentStack.size(); i++) {
188 std::cerr << currentStack[i] << std::endl;
195 void InterruptSignal(
int) {