OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [gdbtk/] [library/] [tracedlg.tcl] - Blame information for rev 1767

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Trace configuration dialog for GDBtk.
2
# Copyright 1997, 1998, 1999 Cygnus Solutions
3
#
4
# This program is free software; you can redistribute it and/or modify it
5
# under the terms of the GNU General Public License (GPL) as published by
6
# the Free Software Foundation; either version 2 of the License, or (at
7
# your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
 
14
 
15
# -----------------------------------------------------------------
16
# Implements the Tracepoint configuration dialog box. This (modal)
17
# dialog will be called upon to interact with gdb's tracepoint routines
18
# allowing the user to add/edit tracepoints. Specifically, user can
19
# specify:
20
#
21
#    - What data to collect: locals, registers, "all registers", "all locals",
22
#                            user-defined (globals)
23
#    - Number of passes which we should collect the data
24
#    - An ignore count after which data will start being collected
25
# This method will destroy itself when the dialog is released. It returns
26
# either one if a tracepoint was set/edited successfully or zero if 
27
# the user bails out (cancel or destroy buttons).
28
 
29
itcl_class TraceDlg {
30
  # ------------------------------------------------------------------
31
  # CONSTRUCTOR: create new trace dialog
32
  # ------------------------------------------------------------------
33
  constructor {config} {
34
    #
35
    #  Create a window with the same name as this object
36
    #
37
    set class [$this info class]
38
    set hull [namespace tail $this]
39
    set old_name $this
40
    ::rename $this $this-tmp-
41
    ::frame $hull -class $class
42
    ::rename $hull $old_name-win-
43
    ::rename $this $old_name
44
 
45
    set top [winfo toplevel [namespace tail $this]]
46
    wm withdraw $top
47
    build_win $this
48
    after idle [list wm deiconify $top]
49
    after idle [list $this title]
50
#    after idle grab $this
51
  }
52
 
53
  # ------------------------------------------------------------------
54
  #  DESTRUCTOR - destroy window containing widget
55
  # ------------------------------------------------------------------
56
  destructor {
57
 
58
    # Remove this window and all hooks
59
#    grab release $this
60
    if {$ActionsDlg != ""} {
61
      catch {manage delete $ActionsDlg}
62
    }
63
    set top [winfo toplevel [namespace tail $this]]
64
    destroy $top
65
    destroy $this
66
  }
67
 
68
  # ------------------------------------------------------------------
69
  # METHOD: build_win - build the Trace dialog box (cache this?)
70
  # ------------------------------------------------------------------
71
  method build_win {f} {
72
    global _TPassCount
73
 
74
 
75
    # Need to set the title to either "Add Tracepoint" or "Edit Tracepoint",
76
    # depending on the location of the given tracepoint.
77
    # !! Why can I not do this?
78
 
79
    # If we have multiple lines, we "add" if we have any new ones ONLY..
80
    set nums      {}
81
    set lown     -1
82
    set highn    -1
83
    set lowl     -1
84
    set highl     0
85
    set functions {}
86
    set last_function {}
87
    set display_lines {}
88
    set display_number {}
89
 
90
    # Look at all lines
91
    foreach line $Lines {
92
      set num [gdb_tracepoint_exists "$File:$line"]
93
      if {$num == -1} {
94
        set New 1
95
      } else {
96
        set Exists 1
97
      }
98
 
99
      set function [gdb_get_function "$File:$line"]
100
      if {"$last_function" != "$function"} {
101
        lappend functions $function
102
        set last_function $function
103
      }
104
 
105
      if {$lown == -1 && $num != -1} {
106
        set lown $num
107
      }
108
      if {$lowl == -1} {
109
        set lowl $line
110
      }
111
 
112
      lappend Number $num
113
      if {$num > $highn} {
114
        set highn $num
115
      }
116
      if {$num != -1 && $num < $lown} {
117
        set lown $num
118
      }
119
      if {$line > $highl} {
120
        set highl $line
121
      }
122
      if {$line < $lowl} {
123
        set lowl $line
124
      }
125
    }
126
 
127
    # Look at all addresses
128
    foreach addr $Addresses {
129
      set num [gdb_tracepoint_exists "*$addr"]
130
      if {$num == -1} {
131
        set New 1
132
      } else {
133
        set Exists 1
134
      }
135
 
136
      set function [gdb_get_function "*$addr"]
137
      if {"$last_function" != "$function"} {
138
        lappend functions $function
139
        set last_function $function
140
      }
141
 
142
      if {$lown == -1 && $num != -1} {
143
        set lown $num
144
      }
145
      if {$lowl == -1} {
146
        set lowl $addr
147
      }
148
 
149
      lappend Number $num
150
      if {$num > $highn} {
151
        set highn $num
152
      }
153
      if {$num != -1 && $num < $lown} {
154
        set lown $num
155
      }
156
      if {$addr > $highl} {
157
        set highl $addr
158
      }
159
      if {$addr < $lowl} {
160
        set lowl $addr
161
      }
162
    }
163
 
164
    if {$Lines != {}} {
165
      if {[llength $Lines] == 1} {
166
        set Number $lown
167
        set display_number [concat $Number]
168
        set display_lines  [concat $Lines]
169
        set multiline 0
170
      } else {
171
        # range of numbers
172
        set display_number "$lown-$highn"
173
        set display_lines  "$lowl-$highl"
174
        set multiline 1
175
      }
176
    } elseif {$Addresses != {}} {
177
      if {[llength $Addresses] == 1} {
178
        set Number $lown
179
        set display_number [concat $Number]
180
        set display_lines  [concat $Addresses]
181
        set multiline 0
182
      } else {
183
        # range of numbers
184
        set display_number "$lown-$highn"
185
        set display_lines  "$lowl-$highl"
186
        set multiline 1
187
      }
188
    } elseif {$Number != {}} {
189
      set New 0
190
      set multiline 0
191
      set display_number $Number
192
    }
193
 
194
    # The three frames of this dialog
195
    set bbox [frame $f.bbox];                # for holding OK,CANCEL DELETE buttons
196
    tixLabelFrame $f.exp -label "Experiment"
197
    set exp [$f.exp subwidget frame];        # the "Experiment" frame
198
    tixLabelFrame $f.act -label "Actions"
199
    set act [$f.act subwidget frame];        # the "Actions" frame
200
 
201
    # Setup the button box
202
    button $bbox.ok     -text OK -command "$this ok" -width 6
203
    button $bbox.cancel -text CANCEL -command "$this cancel"
204
    set Delete [button $bbox.delete -text DELETE -command "$this delete_tp"]
205
    pack $bbox.ok $bbox.cancel -side left -padx 10 -expand yes
206
    pack $bbox.delete -side right -padx 10 -expand yes
207
 
208
    # Setup the "Experiment" frame
209
    if {$New} {
210
      set hit_count   "N/A"
211
      set thread      "N/A"
212
      set _TPassCount 0
213
      if {!$Exists} {
214
        $Delete configure -state disabled
215
      }
216
    } else {
217
      if {!$multiline} {
218
        set stuff [gdb_get_tracepoint_info $Number]
219
        # 0=file 1=func 2=line 3=addr 4=disposition 5=passCount 6=stepCount
220
        # 7=thread 8=hitCount 9=actions
221
        set enabled [lindex $stuff 4]
222
        set _TPassCount [lindex $stuff 5]
223
        set thread      [lindex $stuff 7]
224
        set hit_count   [lindex $stuff 8]
225
        set actions     [lindex $stuff 9]
226
        if {$File == {}} {
227
          set File [lindex $stuff 0]
228
        }
229
        if {$Lines == {} && $Addresses == {}} {
230
          set Addresses [lindex $stuff 3]
231
          set display_lines $Addresses
232
        }
233
        if {$functions == {}} {
234
          set functions [lindex $stuff 1]
235
        }
236
      } else {
237
        # ummm...
238
        set hit_count "N/A"
239
        set thread    "N/A"
240
 
241
        # !! Assumptions...
242
        set stuff [gdb_get_tracepoint_info [lindex $Number 0]]
243
        set _TPassCount [lindex $stuff 5]
244
        set actions     [lindex $stuff 9]
245
      }
246
    }
247
 
248
    # Number
249
    label $exp.numlbl -text {Number:}
250
    label $exp.number -text $display_number
251
 
252
    # File
253
    label $exp.fillbl -text {File:}
254
    label $exp.file   -text $File
255
    # Line
256
    if {$Lines != {}} {
257
      label $exp.linlbl -text {Line(s):}
258
    } else {
259
      label $exp.linlbl -text {Address(es):}
260
    }
261
    label $exp.line   -text $display_lines
262
 
263
    # Function
264
    if {[llength $functions] > 1} {
265
      # Do not allow this until we clean up the action dialog...
266
      tk_messageBox -type ok -icon error \
267
        -message "Cannot set tracepoint ranges across functions!"
268
      after idle manage delete $this
269
    }
270
    #set functions [join $functions ,]
271
    label $exp.funlbl -text {Function:}
272
    label $exp.funct  -text [concat $functions]
273
 
274
    # Hit count
275
    label $exp.hitlbl -text {Hit Count:}
276
    label $exp.hit    -text $hit_count
277
 
278
    # Thread
279
    label $exp.thrlbl -text {Thread:}
280
    label $exp.thread -text $thread
281
 
282
    # Place these onto the screen
283
    grid $exp.numlbl -row 0 -column 0 -sticky w -padx 10 -pady 1
284
    grid $exp.number -row 0 -column 1 -sticky w -padx 10 -pady 1
285
    grid $exp.funlbl -row 0 -column 2 -sticky w -padx 10 -pady 1
286
    grid $exp.funct  -row 0 -column 3 -sticky w -padx 10 -pady 1
287
    grid $exp.hitlbl -row 1 -column 0 -sticky w -padx 10 -pady 1
288
    grid $exp.hit    -row 1 -column 1 -sticky w -padx 10 -pady 1
289
    grid $exp.fillbl -row 1 -column 2 -sticky w -padx 10 -pady 1
290
    grid $exp.file   -row 1 -column 3 -sticky w -padx 10 -pady 1
291
    grid $exp.thrlbl -row 2 -column 0 -sticky w -padx 10 -pady 1
292
    grid $exp.thread -row 2 -column 1 -sticky w -padx 10 -pady 1
293
    grid $exp.linlbl -row 2 -column 2 -sticky w -padx 10 -pady 1
294
    grid $exp.line   -row 2 -column 3 -sticky w -padx 10 -pady 1
295
 
296
    # Configure columns
297
    grid columnconfigure $exp 0 -weight 1
298
    grid columnconfigure $exp 1 -weight 1
299
    grid columnconfigure $exp 2 -weight 1
300
    grid columnconfigure $exp 3 -weight 1
301
 
302
    # The "Actions" Frame
303
    set pass_frame [frame $act.pass]
304
    set act_frame  [frame $act.actions]
305
    set new_frame  [frame $act.new]
306
 
307
    # Pack these frames
308
    pack $pass_frame -fill x
309
    pack $act_frame -fill both -expand 1
310
    pack $new_frame -side top -fill x
311
 
312
    # Passes
313
    label $pass_frame.lbl -text {Number of Passes:}
314
    entry $pass_frame.ent -textvariable _TPassCount -width 5
315
    pack $pass_frame.lbl -side left -padx 10 -pady 5
316
    pack $pass_frame.ent -side right -padx 10 -pady 5
317
 
318
    # Actions
319
    tixScrolledListBox $act_frame.lb -scrollbar auto
320
    set ActionLB [$act_frame.lb subwidget listbox]
321
    $ActionLB configure -selectmode multiple -exportselection 0
322
    label $act_frame.lbl -text {Actions}
323
    pack $act_frame.lbl -side top
324
    pack $act_frame.lb -side bottom -fill both -expand 1 -padx 5 -pady 5
325
    $act_frame.lb configure -command "$this edit" \
326
      -browsecmd "$this set_delete_action_state $ActionLB $new_frame.del_but"
327
 
328
    # New actions
329
    combobox::combobox $new_frame.combo -maxheight 15 -editable 0 -font src-font \
330
      -command [code $this set_action_type]
331
    $new_frame.combo list insert end collect while-stepping
332
    $new_frame.combo entryset collect
333
 
334
    button $new_frame.add_but -text {Add} -command "$this add_action"
335
    pack $new_frame.combo $new_frame.add_but -side left -fill x \
336
      -padx 5 -pady 5
337
 
338
    button $new_frame.del_but -text {Delete} -state disabled \
339
      -command "$this delete_action"
340
    pack $new_frame.del_but -side right -fill x \
341
      -padx 5 -pady 5
342
 
343
    # Pack the main frames
344
    pack $bbox -side bottom -padx 5 -pady 8 -fill x
345
    pack $f.exp -side top -padx 5 -pady 2 -fill x
346
    pack $f.act -side top -padx 5 -pady 2 -expand yes -fill both
347
 
348
    # If we are not new, add all actions
349
    if {!$New} {
350
      add_all_actions $actions
351
    }
352
 
353
    # !! FOR SOME REASON, THE *_FRAMES DO NOT GET MAPPED WHENEVER THE USER
354
    # WAITS A FEW SECONDS TO PLACE THIS DIALOG ON THE SCREEN. This is here
355
    # as a workaround so that the action-related widgets don't disappear...
356
    #update idletasks
357
  }
358
 
359
  method set_action_type {widget action} {
360
    set ActionType $action
361
  }
362
 
363
  method add_action {} {
364
 
365
    if {"$ActionType" == "while-stepping"} {
366
      if {$WhileStepping} {
367
        # We are only allowed on of these...
368
        tk_messageBox -icon error -type ok \
369
          -message "A tracepoint may only have one while-stepping action."
370
        return
371
      }
372
      set whilestepping 1
373
      set step_args "-Steps 1"
374
    } else {
375
      set whilestepping 0
376
      set step_args {}
377
    }
378
 
379
    #debug "ADDING ACTION FOR $File:[lindex $Lines 0]"
380
    if {$Lines != {}} {
381
      set ActionsDlg [eval manage create actiondlg -File $File \
382
                        -Line [lindex $Lines 0] \
383
                        -WhileStepping $whilestepping -Number [lindex $Number 0]\
384
                        -Callback \"$this done\" $step_args]
385
    } else {
386
      set ActionsDlg [eval manage create actiondlg -File $File \
387
                        -Address [lindex $Addresses 0] \
388
                        -WhileStepping $whilestepping -Number [lindex $Number 0]\
389
                        -Callback \"$this done\" $step_args]
390
    }
391
  }
392
 
393
  method delete_action {} {
394
    # If we just delete these from the action list, they will get deleted
395
    # when the user presses OK.
396
 
397
    set selected_elem [lsort -integer -decreasing [$ActionLB curselection]]
398
    foreach elem $selected_elem {
399
      $ActionLB delete $elem
400
    }
401
  }
402
 
403
  method set_delete_action_state {list but} {
404
    if {[$list curselection] == ""} {
405
      $but configure -state disabled
406
    } else {
407
      $but configure -state normal
408
    }
409
  }
410
 
411
  method done {status {steps 0} {data {}}} {
412
 
413
    # We have just returned from the ActionDlg: must reinstall our grab
414
#    after idle grab $this
415
 
416
    switch $status {
417
      cancel {
418
        # Don't do anything
419
        set ActionsDlg {}
420
        return
421
      }
422
      add {
423
        add_action_to_list $steps $data
424
        set ActionsDlg {}
425
      }
426
      delete {
427
        # do something
428
        set ActionsDlg {}
429
      }
430
      modify {
431
        # Delete the current selection and insert the new one in its place
432
        $ActionLB delete $Selection
433
        add_action_to_list $steps $data $Selection
434
        set ActionsDlg {}
435
      }
436
      default {
437
        debug "Unknown status from ActionDlg : \"$status\""
438
      }
439
    }
440
  }
441
 
442
  method add_action_to_list {steps data {index {}}} {
443
 
444
    set data [join $data ,]
445
 
446
    if {$steps > 0} {
447
      if {"$index" == ""} {
448
        set index "end"
449
      }
450
      $ActionLB insert $index "while-stepping ($steps): $data"
451
      set WhileStepping 1
452
    } else {
453
      if {"$index" == ""} {
454
        set index 0
455
      }
456
      $ActionLB insert $index "collect: $data"
457
    }
458
  }
459
 
460
  # ------------------------------------------------------------------
461
  # METHOD: cancel - cancel the dialog and do not set the trace
462
  # ------------------------------------------------------------------
463
  method cancel {} {
464
    manage delete $this
465
  }
466
 
467
  # ------------------------------------------------------------------
468
  # METHOD: ok - validate the tracepoint and install it
469
  # ------------------------------------------------------------------
470
  method ok {} {
471
 
472
    # We "dismiss" the dialog here...
473
    wm withdraw [winfo toplevel [namespace tail $this]]
474
 
475
    set actions [get_actions]
476
    # Check that we are collecting data
477
 
478
    # This is silly, but, hey, it works.
479
    # Lines is the line number where the tp is 
480
    # in case of a tp-range it is the set of lines for that range
481
    if {$Lines != {}} {
482
      for {set i 0} {$i < [llength $Number]} {incr i} {
483
        set number [lindex $Number $i]
484
        set line   [lindex $Lines $i]
485
 
486
        if {$number == -1} {
487
          #debug "Adding new tracepoint at $File:$line $_TPassCount $actions"
488
          set err [catch {gdb_add_tracepoint $File:$line $_TPassCount $actions} errTxt]
489
        } else {
490
          if {$New && $Exists} {
491
            set result [tk_messageBox -icon error -type yesno \
492
                          -message "Overwrite actions for tracepoint \#$number at $File:$line?" \
493
                          -title "Query"]
494
            if {"$result" == "no"} {
495
              continue
496
            }
497
          }
498
        if {$New == 0 && $Exists == 1} {
499
          set tpnum [gdb_tracepoint_exists "$File:$line"]
500
          if {$tpnum == -1} {
501
             tk_messageBox -type ok -icon error -message "Tracepoint was deleted"
502
             manage delete $this
503
             return
504
           }
505
        }
506
 
507
          #debug "Editing tracepoint \#$Number: $_TPassCount $actions"
508
          set err [catch {gdb_edit_tracepoint $number $_TPassCount $actions} errTxt]
509
        }
510
 
511
        if {$err} {
512
          if {$number == -1} {
513
            set str "adding new tracepoint at $File:$line"
514
          } else {
515
            set str "editing tracepoint $number at $File:$line"
516
          }
517
          tk_messageBox -type ok -icon error -message "Error $str: $errTxt"
518
        }
519
      }
520
    } else {
521
      # Async
522
      for {set i 0} {$i < [llength $Number]} {incr i} {
523
        set number [lindex $Number $i]
524
        set addr   [lindex $Addresses $i]
525
        if {$number == -1} {
526
          #debug "Adding new tracepoint at $addr in $File; $_TPassCount $actions"
527
          set err [catch {gdb_add_tracepoint {} $_TPassCount $actions $addr} errTxt]
528
        } else {
529
          if {$New && $Exists} {
530
            set result [tk_messageBox -icon error -type yesno \
531
                          -message "Overwrite actions for tracepoint \#$number at $File:$line?" \
532
                          -title "Query"]
533
            if {"$result" == "no"} {
534
              continue
535
            }
536
          }
537
        if {$New == 0 && $Exists == 1} {
538
          set num [gdb_tracepoint_exists "$File:$Line"]
539
          if {$num == -1} {
540
             tk_messageBox -type ok -icon error -message "Tracepoint was deleted"
541
             manage delete $this
542
             return
543
          }
544
       }
545
          #debug "Editing tracepoint \#$Number: $_TPassCount $actions"
546
          set err [catch {gdb_edit_tracepoint $number $_TPassCount $actions} errTxt]
547
        }
548
 
549
        if {$err} {
550
          if {$number == -1} {
551
            set str "adding new tracepoint at $addr in $File"
552
          } else {
553
            set str "editing tracepoint $number at $addr in $File"
554
          }
555
          tk_messageBox -type ok -icon error -message "Error $str: $errTxt"
556
        }
557
      }
558
    }
559
 
560
    manage delete $this
561
  }
562
 
563
  method cmd {line} {
564
    $line
565
  }
566
 
567
  method delete_tp {} {
568
    debug "deleting tracepoint $Number"
569
    set err [catch {gdb_cmd "delete tracepoints $Number"} errTxt]
570
    debug "done deleting tracepoint $Number"
571
    manage delete $this
572
  }
573
 
574
  method get_data {action} {
575
 
576
    set data {}
577
    foreach a $action {
578
      set datum [string trim $a \ \r\n\t,]
579
      if {"$datum" == "collect" || "$datum" == ""} {
580
        continue
581
      }
582
 
583
      lappend data $datum
584
    }
585
 
586
    return $data
587
  }
588
 
589
  method add_all_actions {actions} {
590
 
591
    set length [llength $actions]
592
    for {set i 0} {$i < $length} {incr i} {
593
      set action [lindex $actions $i]
594
 
595
      if {[regexp "collect" $action]} {
596
        set steps 0
597
        set data [get_data $action]
598
      } elseif {[regexp "while-stepping" $action]} {
599
        scan $action "while-stepping %d" steps
600
        incr i
601
        set action [lindex $actions $i]
602
        set data [get_data $action]
603
      } elseif {[regexp "end" $action]} {
604
        continue
605
      }
606
 
607
      # Now have an action: data and steps
608
      add_action_to_list $steps $data
609
    }
610
  }
611
 
612
  method get_actions {} {
613
 
614
    set actions {}
615
    set list [$ActionLB get 0 end]
616
    foreach action $list {
617
      if {[regexp "collect" $action]} {
618
        scan $action "collect: %s" data
619
        set steps 0
620
        set whilestepping 0
621
      } elseif {[regexp "while-stepping" $action]} {
622
        scan $action "while-stepping (%d): %s" steps data
623
        set whilestepping 1
624
      } else {
625
        debug "unknown action: $action"
626
        continue
627
      }
628
 
629
      lappend actions [list $steps $data]
630
    }
631
 
632
    return $actions
633
  }
634
 
635
  method edit {} {
636
 
637
    set Selection [$ActionLB curselection]
638
    set action [$ActionLB get $Selection]
639
    if [regexp "collect" $action] {
640
      scan $action "collect: %s" data
641
      set steps 0
642
      set whilestepping 0
643
    } elseif [regexp "while-stepping" $action] {
644
      scan $action "while-stepping (%d): %s" steps data
645
      set whilestepping 1
646
    } else {
647
      debug "unknown action: $action"
648
      return
649
    }
650
 
651
    set data [split $data ,]
652
    set len [llength $data]
653
    set real_data {}
654
    set special 0
655
    for {set i 0} {$i < $len} {incr i} {
656
      set a [lindex $data $i]
657
      if {[string range $a 0 1] == "\$("} {
658
        set special 1
659
        set b $a
660
      } elseif {$special} {
661
        lappend b $a
662
        if {[string index $a [expr {[string length $a]-1}]] == ")"} {
663
          lappend real_data [join $b ,]
664
          set special 0
665
        }
666
      } else {
667
        lappend real_data $a
668
      }
669
    }
670
 
671
    # !! lindex $Lines 0 -- better way?
672
    if {$Lines != {}} {
673
      manage create actiondlg -File $File -Line [lindex $Lines 0] \
674
        -WhileStepping $whilestepping -Number [lindex $Number 0] \
675
        -Callback "$this done" -Data $real_data -Steps $steps
676
    } else {
677
      manage create actiondlg -File $File -Address [lindex $Addresses 0] \
678
        -WhileStepping $whilestepping -Number [lindex $Number 0] \
679
        -Callback "$this done" -Data $real_data -Steps $steps
680
    }
681
  }
682
 
683
  method get_selection {} {
684
 
685
    set action [$ActionLB curselection]
686
    return [$ActionLB get $action]
687
  }
688
 
689
  # ------------------------------------------------------------------
690
  #   METHOD:  title - Title the trace dialog.
691
  #
692
  #        This is needed to title the window after the dialog has
693
  #        been created. The window manager actually sets our title
694
  #        after we've been created, so we need to do this in an
695
  #        "after idle".
696
  # ------------------------------------------------------------------
697
  method title {} {
698
    if {$New} {
699
      set display_number "N/A"
700
      wm title [winfo toplevel [namespace tail $this]] "Add Tracepoint"
701
    } else {
702
      wm title [winfo toplevel [namespace tail $this]] "Edit Tracepoint"
703
    }
704
  }
705
 
706
  # PUBLIC DATA
707
  public File {}
708
  public Lines {}
709
  public Addresses {}
710
  public Number {}
711
 
712
  # PROTECTED DATA
713
  protected Delete
714
  protected _TPassCount
715
  protected ActionType {}
716
  protected ActionLB
717
  protected Actions
718
  protected WhileStepping 0
719
  protected Selection {}
720
  protected New 0;                       # set whenever there is a new tp to add
721
  protected Exists 0;                    # set whenever a tracepoint in the range exists
722
  protected Dismissed 0;         # has this dialog been dismissed already?
723
  protected ActionsDlg {}
724
}
725
 
726
proc gdb_add_tracepoint {where passes actions {addr {}}} {
727
  #debug "gdb_add_tracepoint $where $passes $actions $addr"
728
 
729
  # Install the tracepoint
730
  if {$where == "" && $addr != ""} {
731
    set where "*$addr"
732
  }
733
 
734
  #debug "trace $where"
735
  set err [catch {gdb_cmd "trace $where"} errTxt]
736
 
737
  if {$err} {
738
    tk_messageBox -type ok -icon error -message $errTxt
739
    return
740
  }
741
 
742
  # Get the number for this tracepoint
743
  set number [gdb_tracepoint_exists $where]
744
 
745
  # If there is a pass count, add that, too
746
  set err [catch {gdb_cmd "passcount $passes $number"} errTxt]
747
 
748
  if {$err} {
749
    tk_messageBox -type ok -icon error -message $errTxt
750
    return
751
  }
752
 
753
  set real_actions {}
754
  foreach action $actions {
755
    set steps [lindex $action 0]
756
    set data  [lindex $action 1]
757
 
758
    if {$steps} {
759
      lappend real_actions "while-stepping $steps"
760
      lappend real_actions "collect $data"
761
      lappend real_actions "end"
762
    } else {
763
      lappend real_actions "collect $data"
764
    }
765
  }
766
 
767
  if {[llength $real_actions] > 0} {
768
    lappend real_actions "end"
769
  }
770
 
771
  set err [catch {gdb_actions $number $real_actions} errTxt]
772
   if $err {
773
    set errTxt "$errTxt Tracepoint will be installed with no actions"
774
    tk_messageBox -type ok -icon error -message $errTxt
775
    return
776
   }
777
}
778
 
779
proc gdb_edit_tracepoint {number passes actions} {
780
  #debug "gdb_edit_tracepoint $number $passes $actions"
781
 
782
  # If there is a pass count, add that, too
783
  set err [catch {gdb_cmd "passcount $passes $number"} errTxt]
784
 
785
  if $err {
786
    tk_messageBox -type ok -icon error -message $errTxt
787
    return
788
  }
789
 
790
  set real_actions {}
791
  foreach action $actions {
792
    set steps [lindex $action 0]
793
    set data  [lindex $action 1]
794
 
795
    if $steps {
796
      lappend real_actions "while-stepping $steps"
797
      lappend real_actions "collect $data"
798
      lappend real_actions "end"
799
    } else {
800
      lappend real_actions "collect $data"
801
    }
802
  }
803
 
804
  if {[llength $real_actions] > 0} {
805
    lappend real_actions "end"
806
  }
807
 
808
  gdb_actions $number $real_actions
809
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.