1
proc checkscilabbusy {{mb "message"}} {
3
if [ expr [string compare $sciprompt -1] == 0 ] {
4
if {$mb != "nomessage"} {
6
set mes "Scilab is working, wait for the prompt to issue a\
8
set tit "Scilab working"
10
set mes "Scilab est occup�, attendez le prompt pour\
11
effectuer des commandes de d�bug."
12
set tit "Scilab occup�"
14
tk_messageBox -message $mes -title $tit -type ok -icon info
23
global funnameargs funsinbuffer
24
if {[checkscilabbusy] == "OK"} {
25
set removecomm [removescilab_bp "no_output"]
26
set textareacur [gettextareacur]
27
set tagranges [$textareacur tag ranges breakpoint]
32
foreach {tstart tstop} $tagranges {
33
set infun [whichfun [$textareacur index $tstart]]
35
set funname [lindex $infun 0]
36
set lineinfun [expr [lindex $infun 1] - 1]
37
set setbpcomm [concat $setbpcomm "setbpt(\"$funname\",$lineinfun);"]
38
if {$firstbp == "true"} {
40
$textareacur tag remove activebreakpoint 1.0 end
41
$textareacur tag add activebreakpoint "$tstart linestart" "$tstart lineend"
42
$textareacur mark set insert "$tstart linestart"
43
$textareacur see "$tstart linestart"
46
# <TODO> .sce case: I thought about:
47
# - inserting pause before each bp, or
48
# - inserting mode(6) plus mode(0) before each bp
49
# but none is satisfactory. Using mode() will fail in loops,
50
# and pause is very limited (no way to add a new bp during debug,
51
# or to remove all bp to finish execution ignoring them)
54
# $textareacur insert "$tstart +$nlins l linestart" "pause\n"
55
# $textareacur insert "$tstart +$nlins l linestart" "mode(6)\nmode(0)\n"
58
if {$funnameargs != ""} {
60
# Leading spaces here to avoid possible loss of first characters
61
# However this does not work for long lines created by execfile (i.e.
62
# lines that take a long time to display or execute in Scilab window)
63
if {$setbpcomm != ""} {
64
set commnvars [createsetinscishellcomm]
65
set watchsetcomm [lindex $commnvars 0]
66
if {$watchsetcomm != ""} {
67
ScilabEval " $watchsetcomm"
69
while {[checkscilabbusy "nomessage"] == "busy"} {}
70
ScilabEval " $setbpcomm; $funnameargs,$removecomm"
71
set filename [creategetfromshellcomm]
72
ScilabEval " exec(\"$filename\");"
74
ScilabEval " $funnameargs"
83
proc removescilab_bp {outp} {
85
if {[checkscilabbusy] == "OK"} {
86
set textareacur [gettextareacur]
87
set tagranges [$textareacur tag ranges breakpoint]
89
if {$funnames != ""} {
90
foreach fun $funnames {
91
set setbpcomm [concat $setbpcomm "delbpt(\"$fun\");"]
93
if {$outp != "no_output"} {
94
ScilabEval " $setbpcomm"
103
proc stepbystep_bp {} {
105
# I have no satisfactory solution for the time being.
106
# The heart of the matter with step by step execution is that
107
# once the execution is stopped there is no way of knowing what is the next
108
# line of code to execute. Of course, it is usually the next code line in the
109
# sci file, but this is not necessarily true in for, while, if, and case
110
# structures. I do not foresee any other remedy than a complete code analysis
111
# performed in tcl (!), but this is a huge task I'm not prepared to go into.
112
# Moreover, all this analysis is already (and surely better) done by the
113
# Scilab interpreter, therefore the best way would probably be to add a new
114
# Scilab function that would return the line number of the next instruction to
115
# be executed. This should no be such a tricky thing to do drawing inspiration
116
# e.g. from setbpt. Then I would have to hack a way of returning a result to
117
# tcl from a ScilabEval.
118
# Note: There is a similar issue with active bp tag in conditional structures.
119
# Currently the "next active bp" is the next one in the file
120
# but this becomes wrong if the bp is in a for, while, if or case
121
tk_messageBox -message "Sorry, step execution not yet implemented!"
125
# <TODO> correct wrong active bp tag when bp is in conditional structure
126
# Solution to this is similar to what is explained in proc stepbystep_bp
128
if {[checkscilabbusy] == "OK"} {
129
set textareacur [gettextareacur]
130
set actbprange [$textareacur tag ranges activebreakpoint]
131
if {$actbprange != {} } {
132
set actstart [lindex $actbprange 0]
133
set actstop [lindex $actbprange 1]
134
$textareacur tag remove activebreakpoint $actstart $actstop
135
set nextbprange [$textareacur tag nextrange breakpoint $actstop]
136
if {$nextbprange != {} } {
137
set newipos [lindex $nextbprange 0]
138
$textareacur tag add activebreakpoint $newipos [lindex $nextbprange 1]
139
$textareacur mark set insert $newipos
140
$textareacur see $newipos
143
if {$funnameargs != ""} {
144
set commnvars [createsetinscishellcomm]
145
set watchsetcomm [lindex $commnvars 0]
146
if {$watchsetcomm != ""} {
147
ScilabEval " $watchsetcomm"
148
set returnwithvars [lindex $commnvars 1]
149
while {[checkscilabbusy "nomessage"] == "busy"} {}
150
# <TODO> : [..]=resume(..) is bugged! -> replaced by a simple resume with no argument
151
# but then the changes in the watch window are obviously not reflected in the calling
152
# workspace in Scilab
153
# ScilabEval " $returnwithvars"
156
while {[checkscilabbusy "nomessage"] == "busy"} {}
159
set filename [creategetfromshellcomm]
160
ScilabEval " exec(\"$filename\");"
163
# Sending \n is if mode(6) mode(0) is used. If pause, there is no
164
# need to distinguish between .sci and .sce (resume is sent for both)
172
if {[checkscilabbusy] == "OK"} {
173
if {$funnameargs != ""} {
174
[gettextareacur] tag remove activebreakpoint 1.0 end
175
removescilab_bp "with_output"
177
set filename [creategetfromshellcomm]
178
ScilabEval " exec(\"$filename\");"
183
proc dispcallstack_bp {} {
184
if {[checkscilabbusy] == "OK"} {
185
ScilabEval " whereami()"
189
proc canceldebug_bp {} {
191
if {[checkscilabbusy] == "OK"} {
192
if {$funnameargs != ""} {
193
[gettextareacur] tag remove activebreakpoint 1.0 end
194
removescilab_bp "with_output"
196
set filename [creategetfromshellcomm]
197
ScilabEval " exec(\"$filename\");"