Class: RubyDebugView

Inherits:
Object
  • Object
show all
Includes:
TkUtil
Defined in:
ext/ae-ruby-debug/ae-ruby-debug.rb

Constant Summary collapse

B_STATE_ON =
'+'
B_STATE_OFF =
'-'
B_STATE_FREEZE =
'='

Instance Method Summary collapse

Constructor Details

#initialize(_controller) ⇒ RubyDebugView

Returns a new instance of RubyDebugView.



13
14
15
16
17
18
19
20
21
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 13

def initialize(_controller)
  @frame = _controller.frame.hinner_frame
  @frame_server = _controller.frame(1).hinner_frame
  @controller = _controller
  self.build_ui
  @controller.rdc.add_listener(self)
  @nodes_to_open = Array.new
  #@break_hash = Hash.new
end

Instance Method Details

#bnext_state(_state) ⇒ Object



183
184
185
186
187
188
189
190
191
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 183

def bnext_state(_state)
  if _state == B_STATE_ON
    return B_STATE_FREEZE
  elsif _state == B_STATE_FREEZE
    return B_STATE_OFF
  elsif _state == B_STATE_OFF
    return B_STATE_ON
  end   
end

#build_buttons_setObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 23

def build_buttons_set
  _relief = 'groove'
#    @debug_button_box.add(Arcadia.style('toolbarbutton').update({
#      'name'=>'debug_over',
#      'anchor' => 'nw',
#      'command'=>proc{self.debug_send(:step_over)},
#      'helptext'=>'step over',
#      'image'=> TkPhotoImage.new('dat' => D_NEXT_GIF)})
#    )
  @debug_button_box.add(
    'name'=>'debug_over',
    'background' => 'white',
    'anchor' => 'nw',
    'command'=>proc{self.debug_send(:step_over)},
    'helptext'=>'step over',
    'image'=> TkPhotoImage.new('dat' => D_NEXT_GIF),
    'relief'=> _relief
  )
  @debug_button_box.add(
    'name'=>'debug_into',
    'background' => 'white',
    'anchor' => 'nw',
    'command'=>proc{self.debug_send(:step_into)},
    'helptext'=>'step into',
    'image'=> TkPhotoImage.new('dat' => D_STEP_INTO_GIF),
    'relief'=>_relief
  )
  @debug_button_box.add(
    'name'=>'debug_out',
    'background' => 'white',
    'anchor' => 'nw',
    'helptext'=>'step out',
    'command'=>proc{self.debug_send(:step_out)},
    'image'=> TkPhotoImage.new('dat' => D_STEP_OUT_GIF),
    'relief'=>_relief
  )
  @debug_button_box.add(
    'name'=>'debug_resume',
    'background' => 'white',
    'anchor' => 'nw',
    'helptext'=>'resume',
    'image'=> TkPhotoImage.new('dat' => D_RESUME_GIF),
    'command'=>proc{self.debug_send(:resume)},
    'relief'=>_relief
  )

  @debug_button_box.add(
    'name'=>'debug_quit',
    'background' => 'white',
    'anchor' => 'nw',
    'helptext'=>'quit',
    'image'=> TkPhotoImage.new('dat' => D_QUIT_GIF),
    'command'=>proc{self.debug_send(:quit)},
    'relief'=>_relief
  )
  
#    @debug_button_box.bind_append("KeyPress"){|e|
#       case e.keysym
#         when 'F5'
#           self.debug_send(:step_over)  
#       end
#
#    }
end

#build_process_panel(_frame) ⇒ Object



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 141

def build_process_panel(_frame)
  @tree_process = Tk::BWidget::Tree.new(_frame, Arcadia.style('treepanel')){
    showlines false
    deltay 15
    place('relwidth' => 1,'relheight' => '1')
  }
  @tree_process.textbind("Double-ButtonPress-1", proc{
    _selected = @tree_process.selection_get[0]
    if @tree_process.parent(_selected)=='client'
      _text = @tree_process.itemcget(_selected, 'text')
      pos = match_position_from_stack(_text)
      if pos.length >0 
  	     Arcadia.process_event(OpenBufferEvent.new(self,'file'=>pos[0], 'row'=>pos[1]))
        #EditorContract.instance.open_file(self, 'file'=>pos[0], 'line'=>pos[1])
      end
    end
  })

end

#build_uiObject



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 88

def build_ui
  _y = 22
  @debug_button_box = Tk::BWidget::ButtonBox.new(@frame){
    homogeneous true
    state 'disabled'
    background Arcadia.conf('panel.background')
  }.place('height'=> _y)
  
  @debug_frame = TkFrame.new(@frame, Arcadia.style('panel')){ 
      border  2
      place(
        'y'=>_y,
        'height'=> -_y,
        'relheight'=> 1,
        'relwidth'=> 1
      )
  }
  
  self.build_buttons_set
  
#    sf = AGTkOSplittedFrames.new(@debug_frame,@debug_frame,70)

  #-------------------------------------------------
  build_process_panel(@frame_server)
#    build_process_panel(sf.top_frame)
  #-------------------------------------------------

  @enb = Tk::BWidget::NoteBook.new(@debug_frame, Arcadia.style('tabpanel')){
    tabbevelsize 0
    internalborderwidth 2
    place('relwidth' => 1,'relheight' => '1')
  }
  _tab_var = @enb.insert('end', 'vars' ,
    'text'=> 'Variables',
    'raisecmd'=>proc{}
  )
#    _tab_breakpoint = @enb.insert('end', 'Breakpoint' ,
#      'text'=> 'Breakpoints',
#      'raisecmd'=>proc{}
#    )

#    _tab_catchpoint = @enb.insert('end', 'catchpoint' ,
#      'text'=> 'catchpoint',
#      'raisecmd'=>proc{}
#    )
  
  build_var_panel(_tab_var)
  #build_break_panel(_tab_breakpoint)
  @stack_nodes = Array.new
  @enb.raise('vars')

end

#build_var_panel(_frame) ⇒ Object



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 193

def build_var_panel(_frame)
  _open_proc = proc do |_arg|
      inspect_node(_arg) if @nodes_to_open.include?(_arg)
  end
      
  @tree_var = Tk::BWidget::Tree.new(_frame, Arcadia.style('treepanel')){
    showlines true
    deltay 15
    opencmd _open_proc
  }.place('relwidth' => 1,'relheight' => '1','bordermode' => 'inside')

  _scrollcommand = proc{|*args| @tree_var.yview(*args)}
  _scrollbar = TkScrollbar.new(_frame, Arcadia.style('scrollbar')){|s|
    width 8
    command _scrollcommand
  }.pack('side'=>'right', 'fill'=>'y')
  @tree_var.yscrollcommand proc{|first,last| _scrollbar.set(first,last)}

  @tree_var.textbind("Double-ButtonPress-1", proc{
    _selected = @tree_var.selection_get[0]
    _msg = @tree_var.itemcget(_selected, 'text')
    Arcadia.dialog(self, 'type'=>'ok','title' => 'Value', 'msg' => _msg, 'level'=>'info')
  })

  
  @local_state = B_STATE_ON
  @instance_state = B_STATE_ON
  @class_state = B_STATE_ON
  @global_state = B_STATE_OFF
  
  _i_on = TkPhotoImage.new('dat' => ON_GIF)
  _i_off = TkPhotoImage.new('dat' => OFF_GIF)
  _i_freeze = TkPhotoImage.new('dat' => FREEZE_GIF)

  _b_relief = 'groove'
  #------------------ loacal variables -------------------
  _loc_var_text = "Local variables"
  @b_local_onoff = TkButton.new(@tree_var, Arcadia.style('button')){
      image  _i_on
      state 'disabled'
      anchor 'nw'
  }.bind("1",proc{
    @local_state = bnext_state(@local_state)
    if @local_state == B_STATE_ON
      @tree_var.itemconfigure('local_var',
        'text'=>"#{_loc_var_text}",
        'helptext'=>""
      )
      @b_local_onoff.image(_i_on)
      command_enabled(false)
      Thread.new{
        update_variables('local_var', @controller.rdc.variables('local_variables')) #if @tree_var.open?('local_var')
        command_enabled(true)
      }
    elsif @local_state == B_STATE_FREEZE
      @b_local_onoff.image(_i_freeze)
      @tree_var.itemconfigure('local_var',
        'text'=>"#{_loc_var_text} freeze at #{@last_position_string}",
        'helptext'=>"#{_loc_var_text} freeze at #{@last_position_string}"
      )
    elsif @local_state == B_STATE_OFF
      @b_local_onoff.image(_i_off)
      @tree_var.delete(@tree_var.nodes('local_var'))
      @tree_var.itemconfigure('local_var',
        'text'=>"#{_loc_var_text}",
        'helptext'=>""
      )
    end
  })

  @tree_var.insert('end', 'root' ,'local_var', Arcadia.style('treeitem').update({
    'fill'=>Arcadia.conf('hightlight.8.foreground'),
    'open'=>true,
    'anchor'=>'w',
    'text' =>  _loc_var_text,
    'window' => @b_local_onoff
  }))

  #------------------ instance variables -------------------
  _instance_var_text="Instance variables"
  @b_instance_onoff = TkButton.new(@tree_var, Arcadia.style('button')){
      image  _i_on
      #relief _b_relief
      state 'disabled'
      anchor 'nw'
  }.bind("1",proc{
    @instance_state = bnext_state(@instance_state)
    if @instance_state == B_STATE_ON
      @tree_var.itemconfigure('instance_var',
        'text'=>"#{_instance_var_text}",
        'helptext'=>""
      )
      @b_instance_onoff.image(_i_on)
      command_enabled(false)
      Thread.new{
        update_variables('instance_var', @controller.rdc.variables('instance_variables')) #if @tree_var.open?('local_var')
        command_enabled(true)
      }
    elsif @instance_state == B_STATE_FREEZE
      @b_instance_onoff.image(_i_freeze)
      @tree_var.itemconfigure('instance_var',
        'text'=>"#{_instance_var_text} freeze at #{@last_position_string}",
        'helptext'=>"#{_instance_var_text} freeze at #{@last_position_string}"
      )
    elsif @instance_state == B_STATE_OFF
      @b_instance_onoff.image(_i_off)
      @tree_var.delete(@tree_var.nodes('instance_var'))
      @tree_var.itemconfigure('instance_var',
        'text'=>"#{_instance_var_text}",
        'helptext'=>""
      )
    end
  })
  @tree_var.insert('end', 'root' ,'instance_var', Arcadia.style('treeitem').update({
    'fill'=>Arcadia.conf('hightlight.9.foreground'),
    'open'=>true,
    'anchor'=>'w',
    'text' =>  _instance_var_text,
    'window' => @b_instance_onoff
  }))

  #------------------ class variables -------------------
  _class_var_text="Class variables"
  @b_class_onoff = TkButton.new(@tree_var, Arcadia.style('button')){
      image  _i_on
      #relief _b_relief
      state 'disabled'
      anchor 'nw'
  }.bind("1",proc{
    @class_state = bnext_state(@class_state)
    if @class_state == B_STATE_ON
      @tree_var.itemconfigure('class_var',
        'text'=>"#{_class_var_text}",
        'helptext'=>""
      )
      @b_class_onoff.image(_i_on)
      command_enabled(false)
      Thread.new{
        update_variables('class_var', @controller.rdc.variables('self.class.class_variables')) #if @tree_var.open?('local_var')
        command_enabled(true)
      }
    elsif @class_state == B_STATE_FREEZE
      @b_class_onoff.image(_i_freeze)
      @tree_var.itemconfigure('class_var',
        'text'=>"#{_class_var_text} freeze at #{@last_position_string}",
        'helptext'=>"#{_class_var_text} freeze at #{@last_position_string}"
      )
    elsif @class_state == B_STATE_OFF
      @b_class_onoff.image(_i_off)
      @tree_var.delete(@tree_var.nodes('class_var'))
      @tree_var.itemconfigure('class_var',
        'text'=>"#{_class_var_text}",
        'helptext'=>""
      )
    end
  })
  @tree_var.insert('end', 'root' ,'class_var', Arcadia.style('treeitem').update({
    'fill'=>Arcadia.conf('hightlight.10.foreground'),
    'open'=>true,
    'anchor'=>'w',
    'text' =>  _class_var_text,
    'window' => @b_class_onoff
  }))


  #------------------ global variables -------------------
  _global_var_text="Global variables"
  @b_global_onoff = TkButton.new(@tree_var, Arcadia.style('button')){
      image  _i_off
      #relief _b_relief
      state 'disabled'
      anchor 'nw'
  }.bind("1",proc{
    @global_state = bnext_state(@global_state)
    if @global_state == B_STATE_ON
      @tree_var.itemconfigure('global_var',
        'text'=>"#{_global_var_text}",
        'helptext'=>""
      )
      @b_global_onoff.image(_i_on)
      command_enabled(false)
      Thread.new{
        update_variables('global_var', @controller.rdc.variables('global_variables')) #if @tree_var.open?('local_var')
        command_enabled(true)
      }
    elsif @global_state == B_STATE_FREEZE
      @b_global_onoff.image(_i_freeze)
      @tree_var.itemconfigure('global_var',
        'text'=>"#{_global_var_text} freeze at #{@last_position_string}",
        'helptext'=>"#{_global_var_text} freeze at #{@last_position_string}"
      )
    elsif @global_state == B_STATE_OFF
      @b_global_onoff.image(_i_off)
      @tree_var.delete(@tree_var.nodes('global_var'))
      @tree_var.itemconfigure('global_var',
        'text'=>"#{_global_var_text}",
        'helptext'=>""
      )
    end
  })
  @tree_var.insert('end', 'root' ,'global_var', Arcadia.style('treeitem').update({
    'fill'=>Arcadia.conf('hightlight.11.foreground'),
    'open'=>true,
    'anchor'=>'w',
    'text' =>  _global_var_text,
    'window' => @b_global_onoff
  }))
end

#clearObject

def break_list_free

  @tree_break.delete(@tree_break.nodes('root'))
end


465
466
467
468
469
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 465

def clear
  tree_var_free
  tree_process_free
  #break_list_free
end

#command_enabled(_value) ⇒ Object



677
678
679
680
681
682
683
684
685
686
687
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 677

def command_enabled(_value)
  #Arcadia.new_debug_msg(self,"command_enabled= #{_value.to_s}")
  @c_on = _value
  _value ? _state = 'normal':_state = 'disabled'
  @debug_button_box.configure(:state=>_state) 
  @b_local_onoff.configure(:state=>_state) 
  @b_instance_onoff.configure(:state=>_state) 
  @b_class_onoff.configure(:state=>_state) 
  @b_global_onoff.configure(:state=>_state) 
  Tk.update
end

#debug_send(_command) ⇒ Object



737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 737

def debug_send(_command)
  if @controller.rdc
    begin
      command_enabled(false)
      #@debug_button_box.configure(:state=>'disabled')
      Thread.new do
        Arcadia.process_event(StepDebugEvent.new(self, 'command'=>_command))
        #@controller.rdc.send(_command)
      end
      #@controller.rdc.send(_command)
    rescue Exception => e
      Arcadia.console(self, 'msg'=>"---> "+e.to_s + ' ' + e.backtrace[0], 'level'=>'debug')
      #Arcadia.new_debug_msg(self,"---> "+e.to_s)
    end
  end
end

#file2node_name(_file) ⇒ Object

def build_break_panel(_tab_breakpoint)

  @tree_break = Tk::BWidget::Tree.new(_tab_breakpoint, Arcadia.style('treepanel')){
    showlines true
    deltay 15
  }.place('relwidth' => 1,'relheight' => '1')
end


409
410
411
412
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 409

def file2node_name(_file)
  _s = ""
  _file.gsub("/",_s).gsub(".",_s).gsub(":",_s).gsub("\\",_s).gsub("-",_s)
end

#inspect_node(_node) ⇒ Object



578
579
580
581
582
583
584
585
586
587
588
589
590
591
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 578

def inspect_node(_node)
  command_enabled(false)
  begin
    _var = var_name(_node)
    _o = @controller.rdc.debug_dump(_var)
    if _o.class == Hash
      var_deep(_node, _o)
    else 
      var_deep_string(_node, _o)
    end
  ensure
    command_enabled(true)
  end
end

#is_simple_class?(_var) ⇒ Boolean

Returns:

  • (Boolean)


562
563
564
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 562

def is_simple_class?(_var)
  ['Numeric','Fixnum','String','FalseClass','TrueClass','NilClass','Float','BigDecimal','Bignum','Symbol'].include?(_var.value_class) && !_var.value.to_s.strip.include?("\n")
end

#line2node_name(_parent, _line) ⇒ Object



414
415
416
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 414

def line2node_name(_parent, _line)
  "#{_parent}_#{_line.to_s}"
end

#match_position_from_stack(_line) ⇒ Object



511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 511

def match_position_from_stack(_line)
  #Arcadia.new_error_msg(self, "match on #{_line}")
  ret = Array.new
  matchline = _line.match(/#*([0-9]*)[\s\w\W]*\s(.*):([0-9]*)(.*)/)
  if !matchline.nil? && matchline.length==5
    #Arcadia.new_error_msg(self, "matchline[2]=#{matchline[2]}")
    #Arcadia.new_error_msg(self, "matchline[3]=#{matchline[3]}")
    filename = matchline[2].to_s.strip
    line_no = matchline[3].to_i 
    if filename && line_no
      ret << filename << line_no
    end
  end
  ret
end

#node_name(_node, _parent) ⇒ Object



667
668
669
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 667

def node_name(_node, _parent)
  return "#{_parent}@@@#{_node.to_s.gsub('$','__S__').gsub('&','__E__').gsub(':','__D__').gsub('!','__A__')}" 
end

#rdebug_client_update(_command, _result) ⇒ Object



472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 472

def rdebug_client_update(_command, _result)
  #Arcadia.console(self,'msg'=>"on command #{_command} => #{_result}", 'level'=>'debug')
  return if @controller.rdc.nil? || !@controller.rdc.is_debugging_ready? || !@controller.rds.is_alive?
  begin
    if _command == 'quit'
      msg = "Really quit debug ? (y/n)"
      ans = 'yes'#Tk.messageBox('icon' => 'question', 'type' => 'yesno',
#        'title' => '(Arcadia) Debug', 'message' => msg)
      if  ans == 'yes'
        debug_send(:quit_yes)
        clear
      else
        debug_send(:quit_no)
      end
    elsif _command == 'quit_yes'
        clear
    elsif  _command == 'quit_no'
      command_enabled(true)
    elsif _command == 'cont' && !_result.downcase.include?('breakpoint')
      @controller.rdc.kill
      clear
    elsif _command != 'where' && _command != 'quit_yes'  
      begin
        update_position
        update_variables('local_var', @controller.rdc.variables('local_variables')) if @local_state == B_STATE_ON
        update_variables('instance_var', @controller.rdc.variables('instance_variables')) if @instance_state == B_STATE_ON
        update_variables('class_var', @controller.rdc.variables('self.class.class_variables')) if @class_state == B_STATE_ON
        #Arcadia.new_debug_msg(self,"on command #{_command}:global_variables")
        update_variables('global_var', @controller.rdc.variables('global_variables')) if @global_state == B_STATE_ON
      ensure
        command_enabled(true) if !@controller.rdc.nil? && @controller.rdc.is_debugging_ready? && (!_command.include?('quit') || _command.include?('quit_no')) 
      end
    end
  rescue Exception => e
    Arcadia.console(self, 'msg'=>"on command #{_command}:#{e.inspect}", 'level'=>'debug')
    #Arcadia.new_debug_msg(self,"on command #{_command}:#{e.inspect}")
  end
end

#show_expression(_exp, _hash) ⇒ Object



566
567
568
569
570
571
572
573
574
575
576
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 566

def show_expression(_exp, _hash)
  if !@tree_var.exist?('eval')
    @tree_var.insert('end', 'root' ,'eval', Arcadia.style('treeitem').update({
      'fill'=>Arcadia.conf('hightlight.13.foreground'),
      'open'=>true,
      'anchor'=>'w',
      'text' =>  "Eval selection"
    }))
  end
  update_variables('eval', _hash)
end

#start_process(_filename) ⇒ Object



161
162
163
164
165
166
167
168
169
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 161

def start_process(_filename)
  @tree_process.insert('end', 'root' ,'server', {
    'text' =>  "Server => #{File.basename(_filename)} at #{@controller.conf('server.host')}:#{@controller.conf('server.port')}"
  }.update(Arcadia.style('treeitem')))
  @tree_process.insert('end', 'server' ,'client', {
    'text' =>  "Client"
  }.update(Arcadia.style('treeitem')))
  @tree_process.open_tree('server',true)
end

#tree_process_freeObject



179
180
181
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 179

def tree_process_free
  @tree_process.delete(@tree_process.nodes('root'))
end

#tree_var_freeObject



171
172
173
174
175
176
177
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 171

def tree_var_free
  @tree_var.delete(@tree_var.nodes('local_var'))
  @tree_var.delete(@tree_var.nodes('instance_var'))
  @tree_var.delete(@tree_var.nodes('global_var'))
  @tree_var.delete(@tree_var.nodes('class_var'))
  @tree_var.delete(@tree_var.nodes('eval')) if @tree_var.exist?('eval')
end

#update_positionObject



527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 527

def update_position
  stack = @controller.rdc.where
  #Arcadia.new_debug_msg(self,stack)
  if !stack.nil?
    stack = stack.split(/\n/)
    line_no = -1
    if stack.length > 1 && stack[1].strip[0..0]!='#'
      pos = match_position_from_stack(stack[1].strip)
    elsif !stack[0].nil?
      pos = match_position_from_stack(stack[0])
    end
    if pos.length > 0
      _file = pos[0]
      #p "_file=#{_file}"
      _file = File.expand_path(pos[0]) if !File.exist?(_file)
      Arcadia.broadcast_event(DebugStepInfoEvent.new(self,'file'=> _file, 'row'=>pos[1]))
      #DebugContract.instance.debug_step(self, 'file'=> _file, 'line'=>pos[1])
      #break_list_select(_file, pos[1].to_s)
      @last_position_string = "#{pos[0]}:#{pos[1]}"
    end
    i = 0
    @tree_process.delete(@stack_nodes)
    stack.each do |line| 
      _node = "c#{i.to_s}"
      @tree_process.insert('end', 'client' ,_node, {
        'text' =>  line,
        'helptext' => line
      }.update(Arcadia.style('treeitem')))
      #Arcadia.console(self, 'msg'=>"inserted line #{line}")
      @stack_nodes << _node
      i = i+1
    end
  end
end

#update_variables(_parent_node, _var) ⇒ Object



689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 689

def update_variables(_parent_node, _var)
  #Arcadia.console(self, 'msg'=>"---update_variables =>#{_var} figlio di #{_parent_node}")
  if _var.keys.sort == @tree_var.nodes(_parent_node).collect! {|x| var_name(x).to_s}.sort
    _var.each{|k,v|
      #Arcadia.console(self, 'msg'=>"node_name of #{k}")
      _n = node_name(k, _parent_node)
      if is_simple_class?(v)
        _text = var_format(k,v.value_class,v.value)
        _drawcross = 'auto'
      else
        _text = var_format(k,v.value_class)
        _drawcross = 'always'
        @nodes_to_open << _n if !@nodes_to_open.include?(_n)
        inspect_node(_n) if bool(@tree_var.itemcget(@tree_var.tagid(_n), 'open'))
      end
      #Arcadia.console(self, 'msg'=>"_n=#{_n} text=#{_text}")
      _node = @tree_var.itemconfigure(_n, 
        'text' =>  _text, 
        'helptext' => v.value,
        'drawcross' => _drawcross
      )
    }          
  else 
    @nodes_to_open.clear
    @tree_var.delete(@tree_var.nodes(_parent_node))
    #@nodes[_parent_node].clear
    _var.keys.sort.each{|k|
        v = _var[k]
        _n = node_name(k, _parent_node)
        if is_simple_class?(v)
          _text = var_format(k,v.value_class,v.value)
          _drawcross = 'auto'
        else
          _text = var_format(k,v.value_class)
          _drawcross = 'always'
          @nodes_to_open << _n
        end
        @tree_var.insert('end', _parent_node ,_n, Arcadia.style('treeitem').update({
          'text' =>  _text,
          'helptext' => v.value,
          'drawcross' => _drawcross,
          'anchor'=>'w'
        }))
    }
  end
  Tk.update
end

#var_deep(_var, _hash) ⇒ Object



593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 593

def var_deep(_var, _hash)
#    _var_cla = _hash['__CLASS__']
#    _var_len = _hash['__LENGTH__']
#    @tree_var.itemconfigure(_var, 'text' =>  "#{_var_cla}:#{_var_len}")
  return nil if _hash.nil? 
  return _hash.to_s if _hash.class != Hash
  if _hash['__CLASS__']=='Array'
   _sorted_keys = _hash.keys.collect!{|x| x.to_i}.sort.collect!{|x| x.to_s}
  else
   _sorted_keys = _hash.keys.sort
  end
  _sorted_keys.each{|k|
  #_hash.keys.sort.each{|k|
    v = _hash[k]
    next if k=='__CLASS__'
    _complex = v.class == Hash
    if _complex
      _text = var_format(k,v['__CLASS__'])
    elsif (k=='__LENGTH__') && v=='0'
      _text = '{}'
    elsif (k=='__LENGTH__') && v!='0'
      next
    elsif _hash['__CLASS__']=='Array'
      _text = var_format(k.rjust(_hash['__LENGTH__'].length),nil,v,false)
    else
      _text = var_format(k,nil,v)
    end
    _node = node_name(k, _var)
    if @tree_var.exist?(_node)
      @tree_var.itemconfigure(_node, 'text' =>  _text)
    else
      @tree_var.insert('end', _var ,_node, Arcadia.style('treeitem').update({
        'text' =>  _text,
        'helptext' => v,
        'anchor'=>'w'
      }))
    end
    var_deep(_node,v) if _complex
  }
end

#var_deep_string(_var, _str) ⇒ Object



634
635
636
637
638
639
640
641
642
643
644
645
646
647
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 634

def var_deep_string(_var, _str)
  @tree_var.delete(@tree_var.nodes(_var))
  return nil if _str.nil? 
  _str = _str.to_s if !_str.kind_of?(String)
  a_str = _str.split("\n")
  a_str.each_with_index{|v,i|
    _node = node_name(i.to_s, _var)
    @tree_var.insert('end', _var ,_node, Arcadia.style('treeitem').update({
      'text' =>  v,
      'fill' => Arcadia.conf('hightlight.12.foreground'),
      'anchor'=>'w'
    }))
  }
end

#var_format(_name, _class, _value = nil, _strip_name = true) ⇒ Object



650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 650

def var_format(_name, _class, _value=nil, _strip_name=true)
  if _strip_name
    _name = _name.to_s.strip
  else
    _name = _name.to_s
  end
  if !_value.nil? && !_class.nil?
    return "#{_name} => #{_value.to_s.strip} [#{_class.to_s.strip}]"
  elsif _value.nil? && !_class.nil?
    return "#{_name} [#{_class.to_s.strip}]"
  elsif !_value.nil? && _class.nil?
    return "#{_name} => #{_value.to_s.strip}"
  elsif _value.nil? && _class.nil?
    return "#{_name} => {}"
  end
end

#var_name(_node) ⇒ Object



671
672
673
674
675
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 671

def var_name(_node)
  #_parent = @tree_var.parent(_node)
  #return _node.sub("#{_parent}_", '') 
  return _node.split('@@@')[-1].gsub('__S__','$').gsub('__E__','&').gsub('__D__',':').gsub('__A__','!')
end