1 // Created on: 1995-02-23
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
19 #include <Draw_Appli.hxx>
20 #include <Draw_Chronometer.hxx>
21 #include <Draw_Drawable3D.hxx>
22 #include <Draw_Printer.hxx>
23 #include <Draw_ProgressIndicator.hxx>
24 #include <Message.hxx>
25 #include <Message_Messenger.hxx>
27 #include <OSD_Chronometer.hxx>
28 #include <OSD_Environment.hxx>
29 #include <OSD_Exception_CTRL_BREAK.hxx>
30 #include <OSD_MAllocHook.hxx>
31 #include <OSD_MemInfo.hxx>
32 #include <Standard_Macro.hxx>
33 #include <Standard_SStream.hxx>
34 #include <Standard_Stream.hxx>
35 #include <Standard_Version.hxx>
36 #include <TCollection_AsciiString.hxx>
38 #include <OSD_PerfMeter.h>
49 #define RLIM_INFINITY 0x7fffffff
51 static clock_t CPU_CURRENT; // cpu time already used at last
52 // cpulimit call. (sec.)
55 #include <sys/resource.h>
59 #if defined (__hpux) || defined ( HPUX )
60 #define RLIM_INFINITY 0x7fffffff
66 extern Standard_Boolean Draw_Batch;
68 static clock_t CPU_LIMIT; // Cpu_limit in Sec.
69 static OSD_Timer aTimer;
71 //=======================================================================
73 //=======================================================================
75 extern Standard_Boolean Draw_Chrono;
77 static Standard_Integer chronom(Draw_Interpretor& di,
78 Standard_Integer n,const char** a)
80 if ((n == 1) || (*a[1] == '0') || (*a[1] == '1')) {
82 Draw_Chrono = !Draw_Chrono;
84 Draw_Chrono = (*a[1] == '1');
86 if (Draw_Chrono) di << "Chronometers activated.\n";
87 else di << "Chronometers desactivated.\n";
90 Handle(Draw_Drawable3D) D = Draw::Get(a[1]);
91 Handle(Draw_Chronometer) C;
93 C = Handle(Draw_Chronometer)::DownCast(D);
96 C = new Draw_Chronometer();
97 Draw::Set(a[1],C,Standard_False);
103 for (Standard_Integer anIter = 2; anIter < n; ++anIter)
105 TCollection_AsciiString anArg (a[anIter]);
108 if (anArg == "reset")
112 else if (anArg == "restart")
114 C->Timer().Restart();
116 else if (anArg == "start")
120 else if (anArg == "stop")
124 else if (anArg == "show")
128 else if (anArg == "counter")
130 Standard_Real aSeconds,aCPUtime;
131 Standard_Integer aMinutes, aHours;
132 C->Timer().Show(aSeconds,aMinutes,aHours,aCPUtime);
133 std::cout << "COUNTER " << a[++anIter] << ": " << aCPUtime << "\n";
137 std::cerr << "Unknown argument '" << a[anIter] << "'!\n";
145 static Standard_Integer dchronom(Draw_Interpretor& theDI,
146 Standard_Integer n,const char** a)
148 if ((n == 1) || (*a[1] == '0') || (*a[1] == '1')) {
150 Draw_Chrono = !Draw_Chrono;
152 Draw_Chrono = (*a[1] == '1');
154 if (Draw_Chrono) theDI << "Chronometers activated.\n";
155 else theDI << "Chronometers desactivated.\n";
158 Handle(Draw_Drawable3D) D = Draw::Get(a[1]);
159 Handle(Draw_Chronometer) C;
161 C = Handle(Draw_Chronometer)::DownCast(D);
164 C = new Draw_Chronometer();
165 Draw::Set(a[1],C,Standard_False);
171 for (Standard_Integer anIter = 2; anIter < n; ++anIter)
173 TCollection_AsciiString anArg (a[anIter]);
176 if (anArg == "reset")
180 else if (anArg == "restart")
182 C->Timer().Restart();
184 else if (anArg == "start")
188 else if (anArg == "stop")
192 else if (anArg == "show")
198 else if (anArg == "counter")
200 Standard_Real aSeconds,aCPUtime;
201 Standard_Integer aMinutes, aHours;
202 C->Timer().Show(aSeconds,aMinutes,aHours,aCPUtime);
203 theDI << "COUNTER " << a[++anIter] << ": " << aCPUtime << "\n";
207 theDI << "Unknown argument '" << a[anIter] << "'!\n";
217 //=======================================================================
220 //=======================================================================
222 static Standard_Integer ifbatch(Draw_Interpretor& DI, Standard_Integer , const char** )
232 //=======================================================================
235 //=======================================================================
237 extern Standard_Boolean Draw_Spying;
238 extern filebuf Draw_Spyfile;
240 static Standard_Integer spy(Draw_Interpretor& di, Standard_Integer n, const char** a)
243 Draw_Spyfile.close();
244 Draw_Spying = Standard_False;
246 if (!Draw_Spyfile.open(a[1],ios::out)) {
247 di << "Cannot open "<<a[1]<<" for writing\n";
250 Draw_Spying = Standard_True;
255 static Standard_Integer dlog(Draw_Interpretor& di, Standard_Integer n, const char** a)
257 if (n != 2 && n != 3)
259 cout << "Enable or disable logging: " << a[0] << " {on|off}" << endl;
260 cout << "Reset log: " << a[0] << " reset" << endl;
261 cout << "Get log content: " << a[0] << " get" << endl;
265 if (! strcmp (a[1], "on") && n == 2)
267 di.SetDoLog (Standard_True);
268 // di.Log() << "dlog on" << endl; // for symmetry
270 else if (! strcmp (a[1], "off") && n == 2)
272 di.SetDoLog (Standard_False);
274 else if (! strcmp (a[1], "reset") && n == 2)
278 else if (! strcmp (a[1], "get") && n == 2)
282 else if (! strcmp (a[1], "add") && n == 3)
287 else if (! strcmp (a[1], "status") && n == 2)
289 di << (di.GetDoLog() ? "on" : "off");
292 cout << "Unrecognized option(s): " << a[1] << endl;
298 static Standard_Integer decho(Draw_Interpretor& di, Standard_Integer n, const char** a)
302 cout << "Enable or disable echoing: " << a[0] << " {on|off}" << endl;
306 if (! strcmp (a[1], "on"))
308 di.SetDoEcho (Standard_True);
310 else if (! strcmp (a[1], "off"))
312 di.SetDoEcho (Standard_False);
315 cout << "Unrecognized option: " << a[1] << endl;
321 static Standard_Integer dbreak(Draw_Interpretor& di, Standard_Integer, const char**)
326 catch (OSD_Exception_CTRL_BREAK) {
327 di << "User pressed Control-Break";
328 return 1; // Tcl exception
334 static Standard_Integer dversion(Draw_Interpretor& di, Standard_Integer, const char**)
336 // print OCCT version and OCCTY-specific macros used
337 di << "Open CASCADE Technology " << OCC_VERSION_STRING_EXT << "\n";
339 di << "Extended debug mode\n";
340 #elif defined(_DEBUG)
341 di << "Debug mode\n";
344 di << "TBB enabled (HAVE_TBB)\n";
346 di << "TBB disabled\n";
348 #ifdef HAVE_FREEIMAGE
349 di << "FreeImage enabled (HAVE_FREEIMAGE)\n";
351 di << "FreeImage disabled\n";
354 di << "FFmpeg enabled (HAVE_FFMPEG)\n";
356 di << "FFmpeg disabled\n";
359 di << "OpenGL: ES2\n";
361 di << "OpenGL: desktop\n";
364 di << "VTK enabled (HAVE_VTK)\n";
366 di << "VTK disabled\n";
369 di << "Exceptions disabled (No_Exception)\n";
371 di << "Exceptions enabled\n";
374 // check compiler, OS, etc. using pre-processor macros provided by compiler
375 // see "Pre-defined C/C++ Compiler Macros" http://sourceforge.net/p/predef/wiki/
376 // note that only modern compilers that are known to be used for OCCT are recognized
378 // compiler; note that GCC and MSVC are last as other compilers (e.g. Intel) can also define __GNUC__ and _MSC_VER
379 #if defined(__INTEL_COMPILER)
380 di << "Compiler: Intel " << __INTEL_COMPILER << "\n";
381 #elif defined(__BORLANDC__)
382 di << "Compiler: Borland C++ (__BORLANDC__ = " << __BORLANDC__ << ")\n";
383 #elif defined(__clang__)
384 di << "Compiler: Clang " << __clang_major__ << "." << __clang_minor__ << "." << __clang_patchlevel__ << "\n";
385 #elif defined(__SUNPRO_C)
386 di << "Compiler: Sun Studio (__SUNPRO_C = " << __SUNPROC_C << ")\n";
387 #elif defined(_MSC_VER)
389 di << "Compiler: MS Visual C++ " << (int)(_MSC_VER/100-6) << "." << (int)((_MSC_VER/10)-60-10*(int)(_MSC_VER/100-6)) << " (_MSC_FULL_VER = " << _MSC_FULL_VER << ")\n";
391 di << "Compiler: MS Visual C++ " << (int)(_MSC_VER/100-5) << "." << (int)((_MSC_VER/10)-50-10*(int)(_MSC_VER/100-5)) << " (_MSC_FULL_VER = " << _MSC_FULL_VER << ")\n";
393 #elif defined(__GNUC__)
394 di << "Compiler: GCC " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__ << "\n";
396 di << "Compiler: unrecognized\n";
399 // Cygwin and MinGW specifics
400 #if defined(__CYGWIN__)
403 #if defined(__MINGW64__)
404 di << "MinGW 64 " << __MINGW64_VERSION_MAJOR << "." << __MINGW64_VERSION_MINOR << "\n";
405 #elif defined(__MINGW32__)
406 di << "MinGW 32 " << __MINGW32_MAJOR_VERSION << "." << __MINGW32_MINOR_VERSION << "\n";
410 #if defined(__amd64) || defined(__x86_64) || defined(_M_AMD64)
411 di << "Architecture: AMD64\n";
412 #elif defined(__i386) || defined(_M_IX86) || defined(__X86__)|| defined(_X86_)
413 di << "Architecture: Intel x86\n";
414 #elif defined(_M_IA64) || defined(__ia64__)
415 di << "Architecture: Intel Itanium (IA 64)\n";
416 #elif defined(__sparc__) || defined(__sparc)
417 di << "Architecture: SPARC\n";
419 di << "Architecture: unrecognized\n";
423 #if defined(_WIN32) || defined(__WINDOWS__) || defined(__WIN32__)
424 di << "OS: Windows\n";
425 #elif defined(__APPLE__) || defined(__MACH__)
426 di << "OS: Mac OS X\n";
428 di << "OS: SUN Solaris\n";
429 #elif defined(__ANDROID__) /* must be before Linux */
430 #include <android/api-level.h>
431 di << "OS: Android (__ANDROID_API__ = " << __ANDROID_API__ << ")\n";
432 #elif defined(__QNXNTO__)
433 di << "OS: QNX Neutrino\n";
434 #elif defined(__QNX__)
436 #elif defined(__linux__)
438 #elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
439 #include <sys/param.h>
440 di << "OS: BSD (BSD = " << BSD << ")\n";
442 di << "OS: unrecognized\n";
448 //=======================================================================
451 //=======================================================================
453 static Standard_Integer Draw_wait(Draw_Interpretor& , Standard_Integer n, const char** a)
455 Standard_Integer w = 10;
457 w = Draw::Atoi(a[1]);
458 time_t ct = time(NULL) + w;
459 while (time(NULL) < ct) {};
463 //=======================================================================
464 //function : cpulimit
466 //=======================================================================
468 static unsigned int __stdcall CpuFunc (void * /*param*/)
470 clock_t anElapCurrent;
476 Standard_Real anUserSeconds, aSystemSeconds;
477 OSD_Chronometer::GetProcessCPU (anUserSeconds, aSystemSeconds);
478 aCurrent = clock_t(anUserSeconds + aSystemSeconds);
479 anElapCurrent = clock_t(aTimer.ElapsedTime());
481 if (CPU_LIMIT > 0 && (aCurrent - CPU_CURRENT) >= CPU_LIMIT)
483 cout << "Process killed by CPU limit (" << CPU_LIMIT << " sec)" << endl;
487 if (CPU_LIMIT > 0 && anElapCurrent >= CPU_LIMIT)
489 cout << "Process killed by elapsed limit (" << CPU_LIMIT << " sec)" << endl;
496 static void cpulimitSignalHandler (int)
498 cout << "Process killed by CPU limit (" << CPU_LIMIT << " sec)" << endl;
501 static void *CpuFunc(void* /*threadarg*/)
503 clock_t anElapCurrent;
507 anElapCurrent = clock_t(aTimer.ElapsedTime());
508 if (CPU_LIMIT >0 && (anElapCurrent) >= CPU_LIMIT) {
509 cout << "Process killed by elapsed limit (" << CPU_LIMIT << " sec)" << endl;
518 static Standard_Integer cpulimit(Draw_Interpretor&, Standard_Integer n, const char** a)
521 static Standard_Integer cpulimit(Draw_Interpretor& di, Standard_Integer n, const char** a)
524 static int aFirst = 1;
526 // Windows specific code
527 unsigned int __stdcall CpuFunc (void *);
531 CPU_LIMIT = RLIM_INFINITY;
533 CPU_LIMIT = Draw::Atoi (a[1]);
534 Standard_Real anUserSeconds, aSystemSeconds;
535 OSD_Chronometer::GetProcessCPU (anUserSeconds, aSystemSeconds);
536 CPU_CURRENT = clock_t(anUserSeconds + aSystemSeconds);
539 if (aFirst) // Launch the thread only at the 1st call.
542 _beginthreadex (NULL, 0, CpuFunc, NULL, 0, &aThreadID);
549 rlp.rlim_max = RLIM_INFINITY;
551 rlp.rlim_cur = RLIM_INFINITY;
553 rlp.rlim_cur = Draw::Atoi(a[1]);
554 CPU_LIMIT = rlp.rlim_cur;
557 status=setrlimit(RLIMIT_CPU,&rlp);
559 di << "status cpulimit setrlimit : " << status << "\n";
561 // set signal handler to print a message before death
562 struct sigaction act, oact;
563 memset (&act, 0, sizeof(act));
564 act.sa_handler = cpulimitSignalHandler;
565 sigaction (SIGXCPU, &act, &oact);
567 // cpulimit for elapsed time
570 pthread_t cpulimitThread;
571 if (aFirst) // Launch the thread only at the 1st call.
574 pthread_create(&cpulimitThread, NULL, CpuFunc, NULL);
581 //=======================================================================
582 //function : mallochook
584 //=======================================================================
586 static Standard_Integer mallochook(Draw_Interpretor& di, Standard_Integer n,
592 usage: mallochook cmd\n\
593 where cmd is one of:\n\
594 set [<op>] - set callback to malloc/free; op is one of the following:\n\
595 0 - set callback to NULL,\n\
596 1 - set callback OSD_MAllocHook::CollectBySize (default)\n\
597 2 - set callback OSD_MAllocHook::LogFileHandler\n\
598 reset - reset the CollectBySize handler\n\
599 report1 [<outfile>]\n\
600 - write report from CollectBySize handler in <outfile>\n\
602 - open file for writing the log with LogFileHandler\n\
603 close - close the log file with LogFileHandler\n\
604 report2 [<flag>] [<logfile>] [<outfile>]\n\
605 - scan <logfile> written with LogFileHandler\n\
606 and make synthesized report in <outfile>; <flag> can be:\n\
607 0 - simple stats by sizes (default),\n\
608 1 - with alive allocation numbers\n\
609 By default <logfile> is \"mem-log.txt\", <outfile> is \"mem-stat.txt\""
613 if (strcmp(a[1], "set") == 0)
615 int aType = (n > 2 ? Draw::Atoi(a[2]) : 1);
616 if (aType < 0 || aType > 2)
618 di << "unknown op of the command set\n";
623 OSD_MAllocHook::SetCallback(NULL);
624 di << "callback is unset\n";
628 OSD_MAllocHook::SetCallback(OSD_MAllocHook::GetCollectBySize());
629 di << "callback is set to CollectBySize\n";
631 else //if (aType == 2)
633 OSD_MAllocHook::SetCallback(OSD_MAllocHook::GetLogFileHandler());
634 di << "callback is set to LogFileHandler\n";
637 else if (strcmp(a[1], "reset") == 0)
639 OSD_MAllocHook::GetCollectBySize()->Reset();
640 di << "CollectBySize handler is reset\n";
642 else if (strcmp(a[1], "open") == 0)
644 const char* aFileName = (n > 2 ? a[2] : "mem-log.txt");
645 if (!OSD_MAllocHook::GetLogFileHandler()->Open(aFileName))
647 di << "cannot create file " << aFileName << " for writing\n";
650 di << "log file " << aFileName << " is opened for writing\n";
652 else if (strcmp(a[1], "close") == 0)
654 OSD_MAllocHook::GetLogFileHandler()->Close();
655 di << "log file is closed\n";
657 else if (strcmp(a[1], "report1") == 0)
659 const char* aOutFile = "mem-stat.txt";
662 if (OSD_MAllocHook::GetCollectBySize()->MakeReport(aOutFile))
664 di << "report " << aOutFile << " has been created\n";
668 di << "cannot create report " << aOutFile << "\n";
672 else if (strcmp(a[1], "report2") == 0)
674 Standard_Boolean includeAlive = Standard_False;
675 const char* aLogFile = "mem-log.txt";
676 const char* aOutFile = "mem-stat.txt";
679 includeAlive = (Draw::Atoi(a[2]) != 0);
687 if (OSD_MAllocHook::LogFileHandler::MakeReport(aLogFile, aOutFile, includeAlive))
689 di << "report " << aOutFile << " has been created\n";
693 di << "cannot create report " << aOutFile << " from the log file "
700 di << "unrecognized command " << a[1] << "\n";
706 //==============================================================================
709 //==============================================================================
711 static int dlocale (Draw_Interpretor& di, Standard_Integer n, const char** argv)
713 int category = LC_ALL;
716 const char *cat = argv[1];
717 if ( ! strcmp (cat, "LC_ALL") ) category = LC_ALL;
718 else if ( ! strcmp (cat, "LC_COLLATE") ) category = LC_COLLATE;
719 else if ( ! strcmp (cat, "LC_CTYPE") ) category = LC_CTYPE;
720 else if ( ! strcmp (cat, "LC_MONETARY") ) category = LC_MONETARY;
721 else if ( ! strcmp (cat, "LC_NUMERIC") ) category = LC_NUMERIC;
722 else if ( ! strcmp (cat, "LC_TIME") ) category = LC_TIME;
725 cout << "Error: cannot recognize argument " << cat << " as one of LC_ macros" << endl;
729 const char* locale = (n > 2 ? argv[2] : NULL);
730 const char* result = setlocale (category, locale);
734 cout << "Error: unsupported locale specification: " << locale << endl;
738 //==============================================================================
739 //function : dmeminfo
741 //==============================================================================
743 static int dmeminfo (Draw_Interpretor& theDI,
744 Standard_Integer theArgNb,
745 const char** theArgVec)
747 OSD_MemInfo aMemInfo;
750 theDI << aMemInfo.ToString();
754 for (Standard_Integer anIter = 1; anIter < theArgNb; ++anIter)
756 TCollection_AsciiString anArg (theArgVec[anIter]);
758 if (anArg == "virt" || anArg == "v")
760 theDI << Standard_Real (aMemInfo.Value (OSD_MemInfo::MemVirtual)) << " ";
762 else if (anArg == "heap" || anArg == "h")
764 theDI << Standard_Real (aMemInfo.Value (OSD_MemInfo::MemHeapUsage)) << " ";
766 else if (anArg == "wset" || anArg == "w")
768 theDI << Standard_Real (aMemInfo.Value (OSD_MemInfo::MemWorkingSet)) << " ";
770 else if (anArg == "wsetpeak")
772 theDI << Standard_Real (aMemInfo.Value (OSD_MemInfo::MemWorkingSetPeak)) << " ";
774 else if (anArg == "swap")
776 theDI << Standard_Real (aMemInfo.Value (OSD_MemInfo::MemSwapUsage)) << " ";
778 else if (anArg == "swappeak")
780 theDI << Standard_Real (aMemInfo.Value (OSD_MemInfo::MemSwapUsagePeak)) << " ";
782 else if (anArg == "private")
784 theDI << Standard_Real (aMemInfo.Value (OSD_MemInfo::MemPrivate)) << " ";
788 std::cerr << "Unknown argument '" << theArgVec[anIter] << "'!\n";
795 //==============================================================================
798 //==============================================================================
800 static int dperf (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
802 // reset if argument is provided and it is not '0'
803 int reset = (theArgNb > 1 ? theArgVec[1][0] != '0' && theArgVec[1][0] != '\0' : 0);
805 perf_sprint_all_meters (buffer, 25600 - 1, reset);
810 //==============================================================================
811 //function : dsetsignal
813 //==============================================================================
815 static int dsetsignal (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
817 // arm FPE handler if argument is provided and its first symbol is not '0'
818 // or if environment variable CSF_FPE is set and its first symbol is not '0'
822 setFPE = (theArgVec[1][0] == '1' || theArgVec[1][0] == 't');
826 OSD_Environment aEnv ("CSF_FPE");
827 TCollection_AsciiString aEnvStr = aEnv.Value();
828 setFPE = (! aEnvStr.IsEmpty() && aEnvStr.Value(1) != '0');
830 OSD::SetSignal (setFPE);
831 theDI << "Signal handlers are set, with FPE " << (setFPE ? "armed" : "disarmed");
835 //==============================================================================
836 //function : dtracelevel
838 //==============================================================================
840 static int dtracelevel (Draw_Interpretor& theDI,
841 Standard_Integer theArgNb,
842 const char** theArgVec)
844 Message_Gravity aLevel = Message_Info;
845 if (theArgNb < 1 || theArgNb > 2)
847 std::cout << "Error: wrong number of arguments! See usage:\n";
848 theDI.PrintHelp (theArgVec[0]);
851 else if (theArgNb == 2)
853 TCollection_AsciiString aVal (theArgVec[1]);
857 aLevel = Message_Trace;
859 else if (aVal == "info")
861 aLevel = Message_Info;
863 else if (aVal == "warn"
864 || aVal == "warning")
866 aLevel = Message_Warning;
868 else if (aVal == "alarm")
870 aLevel = Message_Alarm;
872 else if (aVal == "fail")
874 aLevel = Message_Fail;
878 std::cout << "Error: unknown gravity '" << theArgVec[1] << "'!\n";
883 Handle(Message_Messenger) aMessenger = Message::DefaultMessenger();
884 if (aMessenger.IsNull())
886 std::cout << "Error: default messenger is unavailable!\n";
890 Message_SequenceOfPrinters& aPrinters = aMessenger->ChangePrinters();
891 if (aPrinters.Length() < 1)
893 std::cout << "Error: no printers registered in default Messenger!\n";
897 for (Standard_Integer aPrinterIter = 1; aPrinterIter <= aPrinters.Length(); ++aPrinterIter)
899 Handle(Message_Printer)& aPrinter = aPrinters.ChangeValue (aPrinterIter);
902 if (aPrinterIter == 1)
904 aLevel = aPrinter->GetTraceLevel();
906 else if (aLevel == aPrinter->GetTraceLevel())
911 switch (aPrinter->GetTraceLevel())
913 case Message_Trace: theDI << "trace"; break;
914 case Message_Info: theDI << "info"; break;
915 case Message_Warning: theDI << "warn"; break;
916 case Message_Alarm: theDI << "alarm"; break;
917 case Message_Fail: theDI << "fail"; break;
922 aPrinter->SetTraceLevel (aLevel);
928 void Draw::BasicCommands(Draw_Interpretor& theCommands)
930 static Standard_Boolean Done = Standard_False;
932 Done = Standard_True;
934 ios::sync_with_stdio();
936 const char* g = "DRAW General Commands";
938 theCommands.Add("batch", "returns 1 in batch mode",
940 theCommands.Add("spy","spy [file], Save commands in file. no file close",
942 theCommands.Add("wait","wait [time(10)], wait time seconds",
943 __FILE__,Draw_wait,g);
944 theCommands.Add("cpulimit","cpulimit [nbseconds], no args remove limits",
945 __FILE__,cpulimit,g);
946 theCommands.Add("chrono","chrono [name action [action...]] \n Operates named timer.\n"
947 " Supported actions: reset, start, stop, restart, show, counter [text].\n"
948 " Without arguments enables / disables global timer for all DRAW commands.",
950 theCommands.Add("dchrono","see help of chrono command",
951 __FILE__,dchronom,g);
952 theCommands.Add("mallochook",
953 "debug memory allocation/deallocation, w/o args for help",
954 __FILE__, mallochook, g);
955 theCommands.Add ("meminfo",
956 "meminfo [virt|v] [heap|h] [wset|w] [wsetpeak] [swap] [swappeak] [private]"
957 " : memory counters for this process",
958 __FILE__, dmeminfo, g);
959 theCommands.Add("dperf","dperf [reset] -- show performance counters, reset if argument is provided",
961 theCommands.Add("dsetsignal","dsetsignal [fpe=0] -- set OSD signal handler, with FPE option if argument is given",
962 __FILE__,dsetsignal,g);
964 // Logging commands; note that their names are hard-coded in the code
965 // of Draw_Interpretor, thus should not be changed without update of that code!
966 theCommands.Add("dlog", "manage logging of commands and output; run without args to get help",
968 theCommands.Add("decho", "switch on / off echo of commands to cout; run without args to get help",
970 theCommands.Add("dtracelevel", "dtracelevel [trace|info|warn|alarm|fail]",
971 __FILE__, dtracelevel, g);
973 theCommands.Add("dbreak", "raises Tcl exception if user has pressed Control-Break key",
975 theCommands.Add("dversion", "provides information on OCCT build configuration (version, compiler, OS, C library, etc.)",
976 __FILE__,dversion,g);
977 theCommands.Add("dlocale", "set and / or query locate of C subsystem (function setlocale())",