Isis 3.0 Programmer Reference
Back | Home
Isis.h
Go to the documentation of this file.
1 
24 #ifdef __GTHREADS
25 #error *****Isis.h MUST be included before any other files!*****
26 #endif
27 
28 #include "IsisDebug.h"
29 
30 #include <signal.h>
31 
32 #include <QCoreApplication>
33 
34 #include "Application.h"
35 #include "UserInterface.h" // this is an unnecessary include
36 
37 #ifndef APPLICATION
38 #define APPLICATION IsisMain
39 #endif
40 
85 std::map<QString, void *> GuiHelpers();
86 #ifndef GUIHELPERS
87 std::map<QString, void *> GuiHelpers() {
88  std::map<QString, void *> empty;
89  return empty;
90 }
91 #endif
92 
93 void APPLICATION();
94 
95 void startMonitoringMemory();
96 void stopMonitoringMemory();
97 void SegmentationFault(int);
98 void Abort(int);
99 void InterruptSignal(int);
100 
109 int main(int argc, char *argv[]) {
110 #ifdef CWDEBUG
111  startMonitoringMemory();
112  signal(SIGSEGV, SegmentationFault);
113  signal(SIGABRT, Abort);
114  signal(SIGINT, InterruptSignal);
115 #endif
116 
117  Isis::Application::p_applicationForceGuiApp = false;
118 
119 #ifdef USE_GUI_QAPP
120  Isis::Application::p_applicationForceGuiApp = true;
121 #endif
122 
123  // Add the plugin directory so QT looks at the Isis plugin dir
124  Isis::FileName qtpluginpath("$ISISROOT/3rdParty/plugins");
125  QCoreApplication::addLibraryPath(qtpluginpath.expanded());
126 
127  Isis::Application *app = new Isis::Application(argc, argv);
128  app->RegisterGuiHelpers(GuiHelpers());
129  int status = app->Run(APPLICATION);
130  delete app;
131  delete QCoreApplication::instance();
132  return status;
133 }
134 
135 #ifdef CWDEBUG
136 void startMonitoringMemory() {
137 #ifndef NOMEMCHECK
138  MyMutex *mutex = new MyMutex();
139  std::fstream *alloc_output = new std::fstream("/dev/null");
140  Debug(make_all_allocations_invisible_except(NULL));
141  ForAllDebugChannels(if(debugChannel.is_on()) debugChannel.off());
142  Debug(dc::malloc.on());
143  Debug(libcw_do.on());
144  Debug(libcw_do.set_ostream(alloc_output));
145  Debug(libcw_do.set_ostream(alloc_output, mutex));
146  atexit(stopMonitoringMemory);
147 #endif
148 }
149 
150 
151 void stopMonitoringMemory() {
152 #ifndef NOMEMCHECK
153  Debug(
154  alloc_filter_ct alloc_filter;
155  std::vector<std::string> objmasks;
156  objmasks.push_back("libc.so*");
157  objmasks.push_back("libstdc++*");
158  std::vector<std::string> srcmasks;
159  srcmasks.push_back("*new_allocator.h*");
160  srcmasks.push_back("*set_ostream.inl*");
161  alloc_filter.hide_objectfiles_matching(objmasks);
162  alloc_filter.hide_sourcefiles_matching(srcmasks);
163  alloc_filter.hide_unknown_locations();
164  delete libcw_do.get_ostream();
165  libcw_do.set_ostream(&std::cout);
166  list_allocations_on(libcw_do, alloc_filter);
167  dc::malloc.off();
168  libcw_do.off()
169  );
170 #endif
171 }
172 
173 
174 void SegmentationFault(int) {
175  std::vector<std::string> currentStack;
176  StackTrace::GetStackTrace(&currentStack);
177 
178  std::cerr << "Segmentation Fault" << std::endl;
179  for(unsigned int i = 1; i < currentStack.size(); i++) {
180  std::cerr << currentStack[i] << std::endl;
181  }
182 
183  exit(1);
184 }
185 
186 void Abort(int) {
187  std::vector<std::string> currentStack;
188  StackTrace::GetStackTrace(&currentStack);
189 
190  std::cerr << "Abort" << std::endl;
191  for(unsigned int i = 1; i < currentStack.size(); i++) {
192  std::cerr << currentStack[i] << std::endl;
193  }
194 
195  exit(1);
196 }
197 
198 
199 void InterruptSignal(int) {
200  exit(1);
201 }
202 
203 #endif
File name manipulation and expansion.
Definition: FileName.h:111
std::map< QString, void * > GuiHelpers()
Base include file for all Isis applications.
Definition: Isis.h:87
int main(int argc, char *argv[])
The programmer supplied main function.
Definition: Isis.h:109

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:20:46