Version: 9.16.0
debugger.cxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
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, or (at your option) any later version.
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 "RuntimeSALOME.hxx"
21#include "Proc.hxx"
22#include "Exception.hxx"
23#include "Executor.hxx"
24#include "parsers.hxx"
25#include "Thread.hxx"
26
27#include <iostream>
28#include <fstream>
29
34using YACS::BASES::Thread;
35using namespace std;
36
37//#define _DEVDEBUG_
38#include "YacsTrace.hxx"
39
40void *executorFunc(void *arg)
41{
42 void **argT=(void **)arg;
43 Executor *myExec = (Executor *)argT[0];
44 Proc *myProc = (Proc *)argT[1];
45 myExec->RunB(myProc, 2);
46 return 0;
47}
48
49int
50main (int argc, char* argv[])
51{
52 if (argc != 2)
53 {
54 cerr << "usage: " << argv[0] << " schema.xml" << endl;
55 return 1;
56 }
57
58 RuntimeSALOME::setRuntime();
59
61 Executor *executor = new Executor();
62
63 try
64 {
65 Proc* p=loader.load(argv[1]);
66 std::ofstream f("toto");
67 p->writeDot(f);
68 f.close();
69
71 void **args=new void *[2];
72 args[0]=(void *)executor;
73 args[1]=(void *)p;
74 Thread* execThread = new Thread(executorFunc,args);
75 char com;
76 cerr << "enter a char to start" << endl;
77 cin >> com;
78 //executor->wakeUp();
79 while (executor->isNotFinished())
80 {
81 YACS::ExecutorState executorState = executor->getExecutorState();
82 cerr << "executorState: " << executorState << endl;
83 cerr << "command display=d step=s : ";
84 cin >> com;
85 switch (com)
86 {
87 case 's':
88 {
90 bool res = executor->resumeCurrentBreakPoint();
91 cerr << "resumeCurrentBreakPoint(): " << res << endl;
92 break;
93 }
94 case 'd':
95 {
96 executor->displayDot(p);
97 break;
98 }
99 default:
100 {
101 cerr << "commande inconnue" << endl;
102 }
103 }
104 }
105 execThread->join();
106 std::ofstream g("titi");
107 p->writeDot(g);
108 g.close();
109 delete executor;
110 return 0;
111 }
112 catch (YACS::Exception& e)
113 {
114 DEBTRACE("exception YACS levee " << e.what());
115 return 1;
116 }
117 catch (const std::ios_base::failure&)
118 {
119 DEBTRACE("io failure");
120 return 1;
121 }
122 catch(CORBA::SystemException& ex)
123 {
124 DEBTRACE("...");
125 CORBA::Any tmp;
126 tmp <<= ex;
127 CORBA::TypeCode_var tc = tmp.type();
128 const char *p = tc->name();
129 if ( *p != '\0' )
130 {
131 DEBTRACE("Caught a CORBA::SystemException. " <<p);
132 }
133 else
134 {
135 DEBTRACE("Caught a CORBA::SystemException. " << tc->id());
136 }
137 return 1;
138 }
139 catch(omniORB::fatalException& fe)
140 {
141 DEBTRACE("Caught omniORB::fatalException: file: "<<fe.file()<<" line: "<<fe.line()<<" msg: "<<fe.errmsg());
142 return 1;
143 }
144 catch(...)
145 {
146 DEBTRACE("Caught unknown exception.");
147 return 1;
148 }
149}
150
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
Threaded Executor.
Definition: Executor.hxx:63
void displayDot(Scheduler *graph)
Display the graph state as a dot display, public method.
Definition: Executor.cxx:718
void setExecMode(YACS::ExecutionMode mode)
Dynamically set the current mode of execution.
Definition: Executor.cxx:430
bool resumeCurrentBreakPoint()
wake up executor when in pause
Definition: Executor.cxx:448
void RunB(Scheduler *graph, int debug=0, bool fromScratch=true)
Execute a graph with breakpoints or step by step.
Definition: Executor.cxx:235
YACS::ExecutorState getExecutorState()
Definition: Executor.cxx:380
Base class for all schema objects.
Definition: Proc.hxx:44
virtual void writeDot(std::ostream &os) const
Dump to the input stream a dot representation of the node.
Definition: Proc.cxx:86
const char * what(void) const noexcept
Definition: Exception.cxx:50
int main(int argc, char *argv[])
Definition: debugger.cxx:50
void * executorFunc(void *arg)
Definition: debugger.cxx:40
Proc * p
Definition: driver.cxx:216
@ STEPBYSTEP
Definition: define.hxx:77
ExecutorState
Definition: define.hxx:64
YACS::YACSLoader::YACSLoader * loader
Definition: yacs_clt.cxx:31