GDB (API)
/home/stan/gdb/src/gdb/gdbtk/library/tracedlg.tcl
Go to the documentation of this file.
00001 # Trace configuration dialog for Insight
00002 # Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003 Red Hat, Inc.
00003 #
00004 # This program is free software; you can redistribute it and/or modify it
00005 # under the terms of the GNU General Public License (GPL) as published by
00006 # the Free Software Foundation; either version 2 of the License, or (at
00007 # your option) any later version.
00008 #
00009 # This program is distributed in the hope that it will be useful,
00010 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 # GNU General Public License for more details.
00013 
00014 
00015 # -----------------------------------------------------------------
00016 # Implements the Tracepoint configuration dialog box. This (modal)
00017 # dialog will be called upon to interact with gdb's tracepoint routines
00018 # allowing the user to add/edit tracepoints. Specifically, user can
00019 # specify:
00020 #
00021 #    - What data to collect: locals, registers, "all registers", "all locals",
00022 #                            user-defined (globals)
00023 #    - Number of passes which we should collect the data
00024 #    - An ignore count after which data will start being collected
00025 # This method will destroy itself when the dialog is released. It returns
00026 # either one if a tracepoint was set/edited successfully or zero if 
00027 # the user bails out (cancel or destroy buttons).
00028 
00029 itcl::class TraceDlg {
00030   inherit ManagedWin
00031 
00032   # ------------------------------------------------------------------
00033   # CONSTRUCTOR: create new trace dialog
00034   # ------------------------------------------------------------------
00035   constructor {args} {
00036 
00037     eval itk_initialize $args
00038     build_win
00039     title
00040   }
00041 
00042   # ------------------------------------------------------------------
00043   #  DESTRUCTOR - destroy window containing widget
00044   # ------------------------------------------------------------------
00045   destructor {
00046 
00047     # Remove this window and all hooks
00048     if {$ActionsDlg != ""} {
00049       catch {delete object $ActionsDlg}
00050     }
00051   }
00052 
00053   # ------------------------------------------------------------------
00054   # METHOD: build_win - build the Trace dialog box (cache this?)
00055   # ------------------------------------------------------------------
00056   method build_win {} {
00057 
00058     set f $itk_interior
00059 
00060     # Need to set the title to either "Add Tracepoint" or "Edit Tracepoint",
00061     # depending on the location of the given tracepoint.
00062     # !! Why can I not do this?
00063 
00064     # If we have multiple lines, we "add" if we have any new ones ONLY..
00065     set nums      {}
00066     set lown     -1
00067     set highn    -1
00068     set lowl     -1
00069     set highl     0
00070     set functions {}
00071     set last_function {}
00072     set display_lines {}
00073     set display_number {}
00074 
00075     # Look at all lines
00076     foreach line $Lines {
00077       set num [gdb_tracepoint_exists "$File:$line"]
00078       if {$num == -1} {
00079   set New 1
00080       } else {
00081   set Exists 1
00082       }
00083       
00084       set function [gdb_get_function "$File:$line"]
00085       if {"$last_function" != "$function"} {
00086   lappend functions $function
00087   set last_function $function
00088       }
00089 
00090       if {$lown == -1 && $num != -1} {
00091   set lown $num
00092       }
00093       if {$lowl == -1} {
00094   set lowl $line
00095       }
00096 
00097       lappend Number $num
00098       if {$num > $highn} {
00099   set highn $num
00100       }
00101       if {$num != -1 && $num < $lown} {
00102   set lown $num
00103       }
00104       if {$line > $highl} {
00105   set highl $line
00106       }
00107       if {$line < $lowl} {
00108   set lowl $line
00109       } 
00110     }
00111     
00112     # Look at all addresses
00113     foreach addr $Addresses {
00114       set num [gdb_tracepoint_exists "*$addr"]
00115       if {$num == -1} {
00116   set New 1
00117       } else {
00118   set Exists 1
00119       }
00120       
00121       set function [gdb_get_function "*$addr"]
00122       if {"$last_function" != "$function"} {
00123   lappend functions $function
00124   set last_function $function
00125       }
00126 
00127       if {$lown == -1 && $num != -1} {
00128   set lown $num
00129       }
00130       if {$lowl == -1} {
00131   set lowl $addr
00132       }
00133 
00134       lappend Number $num
00135       if {$num > $highn} {
00136   set highn $num
00137       }
00138       if {$num != -1 && $num < $lown} {
00139   set lown $num
00140       }
00141       if {$addr > $highl} {
00142   set highl $addr
00143       }
00144       if {$addr < $lowl} {
00145   set lowl $addr
00146       } 
00147     }
00148 
00149     if {$Lines != {}} {
00150       if {[llength $Lines] == 1} {
00151   set Number $lown
00152   set display_number [concat $Number]
00153   set display_lines  [concat $Lines]
00154   set multiline 0
00155       } else {
00156   # range of numbers
00157   set display_number "$lown-$highn"
00158   set display_lines  "$lowl-$highl"
00159   set multiline 1
00160       }
00161     } elseif {$Addresses != {}} {
00162       if {[llength $Addresses] == 1} {
00163   set Number $lown
00164   set display_number [concat $Number]
00165   set display_lines  [concat $Addresses]
00166   set multiline 0
00167       } else {
00168   # range of numbers
00169   set display_number "$lown-$highn"
00170   set display_lines  "$lowl-$highl"
00171   set multiline 1
00172       }
00173     } elseif {$Number != {}} {
00174       set New 0
00175       set multiline 0
00176       set display_number $Number
00177     }
00178 
00179     # The three frames of this dialog
00180     set bbox [frame $f.bbox];                  # for holding OK,CANCEL DELETE buttons
00181     Labelledframe $f.exp -text "Experiment"
00182     set exp [$f.exp get_frame];        # the "Experiment" frame
00183     Labelledframe $f.act -text "Actions"
00184     set act [$f.act get_frame];        # the "Actions" frame
00185 
00186     # Setup the button box
00187     button $bbox.ok     -text OK -command "$this ok" -width 6
00188     button $bbox.cancel -text CANCEL -command "$this cancel"
00189     set Delete [button $bbox.delete -text DELETE -command "$this delete_tp"]
00190     pack $bbox.ok $bbox.cancel -side left -padx 10 -expand yes
00191     pack $bbox.delete -side right -padx 10 -expand yes
00192 
00193     # Setup the "Experiment" frame
00194     if {$New} {
00195       set hit_count   "N/A"
00196       set thread      "N/A"
00197       set _TPassCount 0
00198       if {!$Exists} {
00199   $Delete configure -state disabled
00200       }
00201     } else {
00202       if {!$multiline} {
00203   set stuff [gdb_get_tracepoint_info $Number]
00204   # 0=file 1=func 2=line 3=addr 4=disposition 5=passCount 6=stepCount
00205   # 7=thread 8=hitCount 9=actions
00206   set enabled [lindex $stuff 4]
00207   set _TPassCount [lindex $stuff 5]
00208   set thread      [lindex $stuff 7]
00209   set hit_count   [lindex $stuff 8]
00210   set actions     [lindex $stuff 9]
00211   if {$File == {}} {
00212     set File [lindex $stuff 0]
00213   }
00214   if {$Lines == {} && $Addresses == {}} {
00215     set Addresses [lindex $stuff 3]
00216     set display_lines $Addresses
00217   }
00218   if {$functions == {}} {
00219     set functions [lindex $stuff 1]
00220   }
00221       } else {
00222   # ummm...
00223   set hit_count "N/A"
00224   set thread    "N/A"
00225 
00226   # !! Assumptions...
00227   set stuff [gdb_get_tracepoint_info [lindex $Number 0]]
00228   set _TPassCount [lindex $stuff 5]
00229   set actions     [lindex $stuff 9]
00230       }
00231     }
00232 
00233     # Number
00234     label $exp.numlbl -text {Number:}
00235     label $exp.number -text $display_number
00236 
00237     # File
00238     label $exp.fillbl -text {File:}
00239     label $exp.file   -text $File
00240     # Line
00241     if {$Lines != {}} {
00242       label $exp.linlbl -text {Line(s):}
00243     } else {
00244       label $exp.linlbl -text {Address(es):}
00245     }
00246     label $exp.line   -text $display_lines
00247 
00248     # Function
00249     if {[llength $functions] > 1} {
00250       # Do not allow this until we clean up the action dialog...
00251       tk_messageBox -type ok -icon error \
00252   -message "Cannot set tracepoint ranges across functions!"
00253       after idle [code delete object $this]
00254     }
00255     #set functions [join $functions ,]
00256     label $exp.funlbl -text {Function:}
00257     label $exp.funct  -text [concat $functions]
00258 
00259     # Hit count
00260     label $exp.hitlbl -text {Hit Count:}
00261     label $exp.hit    -text $hit_count
00262 
00263     # Thread
00264     label $exp.thrlbl -text {Thread:}
00265     label $exp.thread -text $thread
00266 
00267     # Place these onto the screen
00268     grid $exp.numlbl -row 0 -column 0 -sticky w -padx 10 -pady 1
00269     grid $exp.number -row 0 -column 1 -sticky w -padx 10 -pady 1
00270     grid $exp.funlbl -row 0 -column 2 -sticky w -padx 10 -pady 1
00271     grid $exp.funct  -row 0 -column 3 -sticky w -padx 10 -pady 1
00272     grid $exp.hitlbl -row 1 -column 0 -sticky w -padx 10 -pady 1
00273     grid $exp.hit    -row 1 -column 1 -sticky w -padx 10 -pady 1
00274     grid $exp.fillbl -row 1 -column 2 -sticky w -padx 10 -pady 1
00275     grid $exp.file   -row 1 -column 3 -sticky w -padx 10 -pady 1
00276     grid $exp.thrlbl -row 2 -column 0 -sticky w -padx 10 -pady 1
00277     grid $exp.thread -row 2 -column 1 -sticky w -padx 10 -pady 1
00278     grid $exp.linlbl -row 2 -column 2 -sticky w -padx 10 -pady 1
00279     grid $exp.line   -row 2 -column 3 -sticky w -padx 10 -pady 1
00280 
00281     # Configure columns
00282     grid columnconfigure $exp 0 -weight 1
00283     grid columnconfigure $exp 1 -weight 1
00284     grid columnconfigure $exp 2 -weight 1
00285     grid columnconfigure $exp 3 -weight 1    
00286 
00287     # The "Actions" Frame
00288     set pass_frame [frame $act.pass]
00289     set act_frame  [frame $act.actions]
00290     set new_frame  [frame $act.new]
00291 
00292     # Pack these frames
00293     pack $pass_frame -fill x 
00294     pack $act_frame -fill both -expand 1
00295     pack $new_frame -side top -fill x
00296 
00297     # Passes
00298     label $pass_frame.lbl -text {Number of Passes:}
00299     entry $pass_frame.ent -textvariable _TPassCount -width 5
00300     pack $pass_frame.lbl -side left -padx 10 -pady 5
00301     pack $pass_frame.ent -side right -padx 10 -pady 5
00302 
00303     # Actions
00304     set ActionLB $act_frame.lb
00305     iwidgets::scrolledlistbox $act_frame.lb -hscrollmode dynamic \
00306       -vscrollmode dynamic -selectmode multiple -exportselection 0 \
00307       -dblclickcommand [code $this edit] \
00308       -selectioncommand [code $this set_delete_action_state $ActionLB $new_frame.del_but] \
00309       -background $::Colors(bg)
00310     [$ActionLB component listbox] configure -background $::Colors(bg)
00311     label $act_frame.lbl -text {Actions}
00312     pack $act_frame.lbl -side top
00313     pack $act_frame.lb -side bottom -fill both -expand 1 -padx 5 -pady 5
00314 
00315     # New actions
00316     combobox::combobox $new_frame.combo -maxheight 15 -editable 0 \
00317       -font global/fixed -command [code $this set_action_type] \
00318       -bg $::Colors(textbg)
00319     $new_frame.combo list insert end collect while-stepping
00320     $new_frame.combo entryset collect
00321 
00322     button $new_frame.add_but -text {Add} -command "$this add_action"
00323     pack $new_frame.combo $new_frame.add_but -side left -fill x \
00324       -padx 5 -pady 5    
00325 
00326     button $new_frame.del_but -text {Delete} -state disabled \
00327       -command "$this delete_action"
00328     pack $new_frame.del_but -side right -fill x \
00329       -padx 5 -pady 5    
00330 
00331     # Pack the main frames
00332     pack $bbox -side bottom -padx 5 -pady 8 -fill x
00333     pack $f.exp -side top -padx 5 -pady 2 -fill x
00334     pack $f.act -side top -padx 5 -pady 2 -expand yes -fill both
00335 
00336     # If we are not new, add all actions
00337     if {!$New} {
00338       add_all_actions $actions
00339     }
00340     
00341     # !! FOR SOME REASON, THE *_FRAMES DO NOT GET MAPPED WHENEVER THE USER
00342     # WAITS A FEW SECONDS TO PLACE THIS DIALOG ON THE SCREEN. This is here
00343     # as a workaround so that the action-related widgets don't disappear...
00344     #update idletasks
00345   }
00346 
00347   method set_action_type {widget action} {
00348     set ActionType $action
00349   }
00350 
00351   method add_action {} {
00352 
00353     if {"$ActionType" == "while-stepping"} {
00354       if {$WhileStepping} {
00355   # We are only allowed on of these...
00356   tk_messageBox -icon error -type ok \
00357     -message "A tracepoint may only have one while-stepping action."
00358   return
00359       }
00360       set whilestepping 1
00361       set step_args "-Steps 1"
00362     } else {
00363       set whilestepping 0
00364       set step_args {}
00365     }
00366 
00367     #debug "ADDING ACTION FOR $File:[lindex $Lines 0]"
00368     if {$Lines != {}} {
00369       set ActionsDlg [eval ManagedWin::open ActionDlg -File $File \
00370                   -Line [lindex $Lines 0] \
00371                   -WhileStepping $whilestepping -Number [lindex $Number 0]\
00372                   -Callback "\\\{$this done\\\}" $step_args]
00373     } else {
00374       set ActionsDlg [eval ManagedWin::open ActionDlg -File $File \
00375                   -Address [lindex $Addresses 0] \
00376                   -WhileStepping $whilestepping -Number [lindex $Number 0]\
00377                   -Callback "\\\{$this done\\\}" $step_args]
00378     }
00379   }
00380 
00381   method delete_action {} {
00382     # If we just delete these from the action list, they will get deleted
00383     # when the user presses OK.
00384 
00385     set selected_elem [lsort -integer -decreasing [$ActionLB curselection]]
00386     foreach elem $selected_elem {
00387       $ActionLB delete $elem
00388     }
00389   }
00390 
00391   method set_delete_action_state {list but} {
00392     if {[$list curselection] == ""} {
00393       $but configure -state disabled
00394     } else {
00395       $but configure -state normal
00396     }
00397   }
00398 
00399   method done {status {steps 0} {data {}}} {
00400     
00401     # We have just returned from the ActionDlg: must reinstall our grab
00402 #    after idle grab $this
00403 
00404     switch $status {
00405       cancel {
00406   # Don't do anything
00407   set ActionsDlg {}
00408   return
00409       }
00410       add {
00411   add_action_to_list $steps $data
00412   set ActionsDlg {}
00413       }
00414       delete {
00415   # do something
00416   set ActionsDlg {}
00417       }
00418       modify {
00419   # Delete the current selection and insert the new one in its place
00420   $ActionLB delete $Selection
00421   add_action_to_list $steps $data $Selection
00422   set ActionsDlg {}
00423       }
00424       default {
00425   debug "Unknown status from ActionDlg : \"$status\""
00426       }
00427     }
00428   }
00429 
00430   method add_action_to_list {steps data {index {}}} {
00431 
00432     set data [join $data ,]
00433 
00434     if {$steps > 0} {
00435       if {"$index" == ""} {
00436   set index "end"
00437       }
00438       $ActionLB insert $index "while-stepping ($steps): $data"
00439       set WhileStepping 1
00440     } else {
00441       if {"$index" == ""} {
00442   set index 0
00443       }
00444       $ActionLB insert $index "collect: $data"
00445     }
00446   }
00447   
00448   # ------------------------------------------------------------------
00449   # METHOD: cancel - cancel the dialog and do not set the trace
00450   # ------------------------------------------------------------------
00451   method cancel {} {
00452     ::delete object $this
00453   }
00454 
00455   # ------------------------------------------------------------------
00456   # METHOD: ok - validate the tracepoint and install it
00457   # ------------------------------------------------------------------
00458   method ok {} {
00459     
00460     # We "dismiss" the dialog here...
00461     wm withdraw [winfo toplevel [namespace tail $this]]
00462 
00463     set actions [get_actions]
00464     # Check that we are collecting data
00465 
00466     # This is silly, but, hey, it works.
00467     # Lines is the line number where the tp is 
00468     # in case of a tp-range it is the set of lines for that range
00469     if {$Lines != {}} {
00470       for {set i 0} {$i < [llength $Number]} {incr i} {
00471   set number [lindex $Number $i]
00472   set line   [lindex $Lines $i]
00473 
00474   if {$number == -1} {
00475     #debug "Adding new tracepoint at $File:$line $_TPassCount $actions"
00476     set err [catch {gdb_add_tracepoint $File:$line $_TPassCount $actions} errTxt]
00477   } else {
00478     if {$New && $Exists} {
00479       set result [tk_messageBox -icon error -type yesno \
00480                     -message "Overwrite actions for tracepoint \#$number at $File:$line?" \
00481                     -title "Query"]
00482       if {"$result" == "no"} {
00483         continue
00484       }
00485     }
00486         if {$New == 0 && $Exists == 1} {
00487           set tpnum [gdb_tracepoint_exists "$File:$line"]
00488           if {$tpnum == -1} {
00489              tk_messageBox -type ok -icon error -message "Tracepoint was deleted"
00490              ::delete object $this
00491              return
00492            }
00493         }
00494 
00495     #debug "Editing tracepoint \#$Number: $_TPassCount $actions"
00496     set err [catch {gdb_edit_tracepoint $number $_TPassCount $actions} errTxt]
00497   }
00498 
00499   if {$err} {
00500     if {$number == -1} {
00501       set str "adding new tracepoint at $File:$line"
00502     } else {
00503       set str "editing tracepoint $number at $File:$line"
00504     }
00505     tk_messageBox -type ok -icon error -message "Error $str: $errTxt"
00506   }
00507       }
00508     } else {
00509       # Async
00510       for {set i 0} {$i < [llength $Number]} {incr i} {
00511   set number [lindex $Number $i]
00512   set addr   [lindex $Addresses $i]
00513   if {$number == -1} {
00514     #debug "Adding new tracepoint at $addr in $File; $_TPassCount $actions"
00515     set err [catch {gdb_add_tracepoint {} $_TPassCount $actions $addr} errTxt]
00516   } else {
00517     if {$New && $Exists} {
00518       set result [tk_messageBox -icon error -type yesno \
00519                     -message "Overwrite actions for tracepoint \#$number at $File:$line?" \
00520                     -title "Query"]
00521       if {"$result" == "no"} {
00522         continue
00523       }
00524     }
00525     if {$New == 0 && $Exists == 1} {
00526       set num [gdb_tracepoint_exists "$File:$Line"]
00527       if {$num == -1} {
00528         tk_messageBox -type ok -icon error -message "Tracepoint was deleted"
00529         ::delete object $this
00530         return
00531       }
00532     }
00533 
00534     #debug "Editing tracepoint \#$Number: $_TPassCount $actions"
00535     set err [catch {gdb_edit_tracepoint $number $_TPassCount $actions} errTxt]
00536   }
00537 
00538   if {$err} {
00539     if {$number == -1} {
00540       set str "adding new tracepoint at $addr in $File"
00541     } else {
00542       set str "editing tracepoint $number at $addr in $File"
00543     }
00544     tk_messageBox -type ok -icon error -message "Error $str: $errTxt"
00545   }
00546       }
00547     }
00548     
00549     ::delete object $this
00550   }
00551 
00552   method cmd {line} {
00553     $line
00554   }
00555 
00556   method delete_tp {} {
00557     debug "deleting tracepoint $Number"
00558     set err [catch {gdb_cmd "delete tracepoints $Number"} errTxt]
00559     debug "done deleting tracepoint $Number"
00560     ::delete object $this
00561   }
00562 
00563   method get_data {action} {
00564 
00565     set data {}
00566     foreach a $action {
00567       set datum [string trim $a \ \r\n\t,]
00568       if {"$datum" == "collect" || "$datum" == ""} {
00569   continue
00570       }
00571 
00572       lappend data $datum
00573     }
00574       
00575     return $data
00576   }
00577   
00578   method add_all_actions {actions} {
00579     
00580     set length [llength $actions]
00581     for {set i 0} {$i < $length} {incr i} {
00582       set action [lindex $actions $i]
00583 
00584       if {[regexp "collect" $action]} {
00585   set steps 0
00586   set data [get_data $action]
00587       } elseif {[regexp "while-stepping" $action]} {
00588   scan $action "while-stepping %d" steps
00589   incr i
00590   set action [lindex $actions $i]
00591   set data [get_data $action]
00592       } elseif {[regexp "end" $action]} {
00593   continue
00594       }
00595 
00596       # Now have an action: data and steps
00597       add_action_to_list $steps $data
00598     }
00599   }
00600 
00601   method get_actions {} {
00602     
00603     set actions {}
00604     set list [$ActionLB get 0 end]
00605     foreach action $list {
00606       if {[regexp "collect" $action]} {
00607   scan $action "collect: %s" data
00608   set steps 0
00609   set whilestepping 0
00610       } elseif {[regexp "while-stepping" $action]} {
00611   scan $action "while-stepping (%d): %s" steps data
00612   set whilestepping 1
00613       } else {
00614   debug "unknown action: $action"
00615   continue
00616       }
00617 
00618       lappend actions [list $steps $data]
00619     }
00620 
00621     return $actions
00622   }
00623 
00624   method edit {} {
00625     
00626     set Selection [$ActionLB curselection]
00627     if {$Selection != ""} {
00628       set action [$ActionLB get $Selection]
00629       if [regexp "collect" $action] {
00630   scan $action "collect: %s" data
00631   set steps 0
00632   set whilestepping 0
00633       } elseif [regexp "while-stepping" $action] {
00634   scan $action "while-stepping (%d): %s" steps data
00635   set whilestepping 1
00636       } else {
00637   debug "unknown action: $action"
00638   return
00639       }
00640     
00641       set data [split $data ,] 
00642       set len [llength $data]
00643       set real_data {}
00644       set special 0
00645       for {set i 0} {$i < $len} {incr i} {
00646   set a [lindex $data $i]
00647   if {[string range $a 0 1] == "\$("} {
00648     set special 1
00649     set b $a
00650   } elseif {$special} {
00651     lappend b $a
00652     if {[string index $a [expr {[string length $a]-1}]] == ")"} {
00653       lappend real_data [join $b ,]
00654       set special 0
00655     }
00656   } else {
00657     lappend real_data $a
00658   }
00659       }
00660 
00661       # !! lindex $Lines 0 -- better way?
00662       if {$Lines != {}} {
00663   ManagedWin::open ActionDlg -File $File -Line [lindex $Lines 0] \
00664     -WhileStepping $whilestepping -Number [lindex $Number 0] \
00665     -Callback [list [code $this done]] -Data $real_data -Steps $steps
00666       } else {
00667   ManagedWin::open ActionDlg -File $File -Address [lindex $Addresses 0] \
00668     -WhileStepping $whilestepping -Number [lindex $Number 0] \
00669     -Callback [list [code $this done]] -Data $real_data -Steps $steps
00670       }
00671     }
00672   }
00673 
00674   method get_selection {} {
00675     
00676     set action [$ActionLB curselection]
00677     return [$ActionLB get $action]
00678   }
00679 
00680   # ------------------------------------------------------------------
00681   #   METHOD:  title - Title the trace dialog.
00682   #
00683   #        This is needed to title the window after the dialog has
00684   #        been created. The window manager actually sets our title
00685   #        after we've been created, so we need to do this in an
00686   #        "after idle".
00687   # ------------------------------------------------------------------
00688   method title {} {
00689     if {$New} {
00690       set display_number "N/A"
00691       wm title [winfo toplevel [namespace tail $this]] "Add Tracepoint"
00692     } else {
00693       wm title [winfo toplevel [namespace tail $this]] "Edit Tracepoint"
00694     }
00695   }
00696 
00697   # PUBLIC DATA
00698   public variable File {}
00699   public variable Lines {}
00700   public variable Addresses {}
00701   public variable Number {}
00702 
00703   # PROTECTED DATA
00704   protected variable Delete
00705   protected variable _TPassCount
00706   protected variable ActionType {}
00707   protected variable ActionLB
00708   protected variable Actions
00709   protected variable WhileStepping 0
00710   protected variable Selection {}
00711   protected variable New 0;               # set whenever there is a new tp to add
00712   protected variable Exists 0;            # set whenever a tracepoint in the range exists
00713   protected variable Dismissed 0; # has this dialog been dismissed already?
00714   protected variable ActionsDlg {}
00715 }
00716 
00717 proc gdb_add_tracepoint {where passes actions {addr {}}} {
00718   #debug "gdb_add_tracepoint $where $passes $actions $addr"
00719   
00720   # Install the tracepoint
00721   if {$where == "" && $addr != ""} {
00722     set where "*$addr"
00723   }
00724 
00725   #debug "trace $where"
00726   set err [catch {gdb_cmd "trace $where"} errTxt]
00727 
00728   if {$err} {
00729     tk_messageBox -type ok -icon error -message $errTxt
00730     return
00731   }
00732 
00733   # Get the number for this tracepoint
00734   set number [gdb_tracepoint_exists $where]
00735 
00736   # If there is a pass count, add that, too
00737   set err [catch {gdb_cmd "passcount $passes $number"} errTxt]
00738 
00739   if {$err} {
00740     tk_messageBox -type ok -icon error -message $errTxt
00741     return
00742   }
00743 
00744   set real_actions {}
00745   foreach action $actions {
00746     set steps [lindex $action 0]
00747     set data  [lindex $action 1]
00748 
00749     if {$steps} {
00750       lappend real_actions "while-stepping $steps"
00751       lappend real_actions "collect $data"
00752       lappend real_actions "end"
00753     } else {
00754       lappend real_actions "collect $data"
00755     }
00756   }
00757 
00758   if {[llength $real_actions] > 0} {
00759     lappend real_actions "end"
00760   }
00761 
00762   set err [catch {gdb_actions $number $real_actions} errTxt]
00763    if $err {
00764     set errTxt "$errTxt Tracepoint will be installed with no actions"
00765     tk_messageBox -type ok -icon error -message $errTxt
00766     return
00767    }
00768 }
00769 
00770 proc gdb_edit_tracepoint {number passes actions} {
00771   #debug "gdb_edit_tracepoint $number $passes $actions"
00772 
00773   # If there is a pass count, add that, too
00774   set err [catch {gdb_cmd "passcount $passes $number"} errTxt]
00775     
00776   if $err {
00777     tk_messageBox -type ok -icon error -message $errTxt
00778     return
00779   }
00780   
00781   set real_actions {}
00782   foreach action $actions {
00783     set steps [lindex $action 0]
00784     set data  [lindex $action 1]
00785 
00786     if $steps {
00787       lappend real_actions "while-stepping $steps"
00788       lappend real_actions "collect $data"
00789       lappend real_actions "end"
00790     } else {
00791       lappend real_actions "collect $data"
00792     }
00793   }
00794   
00795   if {[llength $real_actions] > 0} {
00796     lappend real_actions "end"
00797   }
00798   
00799   gdb_actions $number $real_actions
00800 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines