9 #error *****Isis.h MUST be included before any other files!*****
12 #include "IsisDebug.h"
16 #include <QCoreApplication>
18 #include "Application.h"
19 #include "UserInterface.h"
22 #define APPLICATION IsisMain
72 std::map<QString, void *> empty;
79 void startMonitoringMemory();
80 void stopMonitoringMemory();
81 void SegmentationFault(
int);
83 void InterruptSignal(
int);
93 int main(
int argc,
char *argv[]) {
97 if (getenv(
"ISISROOT") == NULL || QString(getenv(
"ISISROOT")) ==
"") {
98 std::cerr <<
"Please set ISISROOT before running any Isis applications" << std::endl;
103 startMonitoringMemory();
104 signal(SIGSEGV, SegmentationFault);
105 signal(SIGABRT, Abort);
106 signal(SIGINT, InterruptSignal);
109 Isis::Application::p_applicationForceGuiApp =
false;
112 Isis::Application::p_applicationForceGuiApp =
true;
117 int status = app->
Run(APPLICATION);
119 delete QCoreApplication::instance();
124 void startMonitoringMemory() {
126 MyMutex *mutex =
new MyMutex();
127 std::fstream *alloc_output =
new std::fstream(
"/dev/null");
128 Debug(make_all_allocations_invisible_except(NULL));
129 ForAllDebugChannels(
if(debugChannel.is_on()) debugChannel.off());
130 Debug(dc::malloc.on());
131 Debug(libcw_do.on());
132 Debug(libcw_do.set_ostream(alloc_output));
133 Debug(libcw_do.set_ostream(alloc_output, mutex));
134 atexit(stopMonitoringMemory);
139 void stopMonitoringMemory() {
142 alloc_filter_ct alloc_filter;
143 std::vector<std::string> objmasks;
144 objmasks.push_back(
"libc.so*");
145 objmasks.push_back(
"libstdc++*");
146 std::vector<std::string> srcmasks;
147 srcmasks.push_back(
"*new_allocator.h*");
148 srcmasks.push_back(
"*set_ostream.inl*");
149 alloc_filter.hide_objectfiles_matching(objmasks);
150 alloc_filter.hide_sourcefiles_matching(srcmasks);
151 alloc_filter.hide_unknown_locations();
152 delete libcw_do.get_ostream();
153 libcw_do.set_ostream(&std::cout);
154 list_allocations_on(libcw_do, alloc_filter);
162 void SegmentationFault(
int) {
163 std::vector<std::string> currentStack;
164 StackTrace::GetStackTrace(¤tStack);
166 std::cerr <<
"Segmentation Fault" << std::endl;
167 for(
unsigned int i = 1; i < currentStack.size(); i++) {
168 std::cerr << currentStack[i] << std::endl;
175 std::vector<std::string> currentStack;
176 StackTrace::GetStackTrace(¤tStack);
178 std::cerr <<
"Abort" << std::endl;
179 for(
unsigned int i = 1; i < currentStack.size(); i++) {
180 std::cerr << currentStack[i] << std::endl;
187 void InterruptSignal(
int) {