Salome HOME
9b7a2e192522082c72d7359b7a2528c569ba52d6
[modules/hexablock.git] / src / HEXABLOCKGUI / HEXABLOCKGUI_Trace.cxx
1 // Copyright (C) 2009-2012  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include <cstdlib>
21 #include <iostream>
22 #include <sstream>
23
24 #include "HEXABLOCKGUI_Trace.hxx"
25
26
27 #ifdef WNT
28 #include <process.h>
29 #define getpid _getpid
30 #else
31 #include <unistd.h>
32 #endif
33
34 namespace HEXABLOCK{
35   namespace GUI{
36     int traceLevel=0;
37   }
38 }
39
40 void AttachDebugger()
41 {
42   if(getenv ("HEXABLOCKDEBUGGER"))
43     {
44       std::stringstream exec;
45       exec << "$HEXABLOCKDEBUGGER " << getpid() << "&";
46       std::cerr << exec.str() << std::endl;
47       system(exec.str().c_str());
48       while(1);
49     }
50 }