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[]) {
113 if (getenv(
"ISISROOT") == NULL || QString(getenv(
"ISISROOT")) ==
"") {
114 std::cerr <<
"Please set ISISROOT before running any Isis applications" << std::endl;
119 startMonitoringMemory();
120 signal(SIGSEGV, SegmentationFault);
121 signal(SIGABRT, Abort);
122 signal(SIGINT, InterruptSignal);
125 Isis::Application::p_applicationForceGuiApp =
false;
128 Isis::Application::p_applicationForceGuiApp =
true;
133 int status = app->
Run(APPLICATION);
135 delete QCoreApplication::instance();
140 void startMonitoringMemory() {
142 MyMutex *mutex =
new MyMutex();
143 std::fstream *alloc_output =
new std::fstream(
"/dev/null");
144 Debug(make_all_allocations_invisible_except(NULL));
145 ForAllDebugChannels(
if(debugChannel.is_on()) debugChannel.off());
146 Debug(dc::malloc.on());
147 Debug(libcw_do.on());
148 Debug(libcw_do.set_ostream(alloc_output));
149 Debug(libcw_do.set_ostream(alloc_output, mutex));
150 atexit(stopMonitoringMemory);
155 void stopMonitoringMemory() {
158 alloc_filter_ct alloc_filter;
159 std::vector<std::string> objmasks;
160 objmasks.push_back(
"libc.so*");
161 objmasks.push_back(
"libstdc++*");
162 std::vector<std::string> srcmasks;
163 srcmasks.push_back(
"*new_allocator.h*");
164 srcmasks.push_back(
"*set_ostream.inl*");
165 alloc_filter.hide_objectfiles_matching(objmasks);
166 alloc_filter.hide_sourcefiles_matching(srcmasks);
167 alloc_filter.hide_unknown_locations();
168 delete libcw_do.get_ostream();
169 libcw_do.set_ostream(&std::cout);
170 list_allocations_on(libcw_do, alloc_filter);
178 void SegmentationFault(
int) {
179 std::vector<std::string> currentStack;
180 StackTrace::GetStackTrace(¤tStack);
182 std::cerr <<
"Segmentation Fault" << std::endl;
183 for(
unsigned int i = 1; i < currentStack.size(); i++) {
184 std::cerr << currentStack[i] << std::endl;
191 std::vector<std::string> currentStack;
192 StackTrace::GetStackTrace(¤tStack);
194 std::cerr <<
"Abort" << std::endl;
195 for(
unsigned int i = 1; i < currentStack.size(); i++) {
196 std::cerr << currentStack[i] << std::endl;
203 void InterruptSignal(
int) {
std::map< QString, void * > GuiHelpers()
Base include file for all Isis applications.
int main(int argc, char *argv[])
The programmer supplied main function.
int Run(void(*funct)())
Runs the program defined in the function funct.
void RegisterGuiHelpers(std::map< QString, void *> helpers)