diff options
author | Fernando Nasser <fnasser@redhat.com> | 2001-01-03 05:34:04 +0000 |
---|---|---|
committer | Fernando Nasser <fnasser@redhat.com> | 2001-01-03 05:34:04 +0000 |
commit | e9b50e271757a3f2d9b3749e511f743ab5315cc7 (patch) | |
tree | c7580205e2172c06503cf2cc068522638d5f351c /gdb/gdbtk | |
parent | 90f12c1c3a28940ac468cc9f135c7651cb4c63f9 (diff) | |
download | gdb-e9b50e271757a3f2d9b3749e511f743ab5315cc7.tar.gz |
2001-01-02 Fernando Nasser <fnasser@totem.toronto.redhat.com>
* library/gdbmenubar.itcl: New file. Define the GDBMenuBar class,
a generic menubar building facility for Insight windows (WIP).
* library/gdbtoolbar.itcl: New file. Define the GDBToolBar class,
a generic toolbar building facility for Insight windows (WIP).
* library/srcmenubar.itcl: New file. Define the SrcMenuBar class,
which implements the Source Window menubar (inherits GDBMenuBar).
* library/srctoolbar.itcl: New file. Define the SrcToolBar class,
which implements the Source Window toolbar (inherits GDBToolBar).
* library/srcwin.itb (_build_win): Use SrcMenuBar and SrcToolBar
instead of the obsolete GDBSrcBar.
* library/srcbar.tcl: Mark as OBSOLETE.
* library/toolbar.tcl: Mark as OBSOLETE. Rename class GDBToolBar
to avoid conflict with new class with the same name.
* library/Makefile (TCL): Include .itcl files.
* library/tclIndex: Regenerate.
Diffstat (limited to 'gdb/gdbtk')
-rw-r--r-- | gdb/gdbtk/ChangeLog | 18 | ||||
-rw-r--r-- | gdb/gdbtk/library/Makefile | 2 | ||||
-rw-r--r-- | gdb/gdbtk/library/gdbmenubar.itcl | 234 | ||||
-rw-r--r-- | gdb/gdbtk/library/gdbtoolbar.itcl | 345 | ||||
-rw-r--r-- | gdb/gdbtk/library/srcbar.tcl | 2 | ||||
-rw-r--r-- | gdb/gdbtk/library/srcmenubar.itcl | 695 | ||||
-rw-r--r-- | gdb/gdbtk/library/srctoolbar.itcl | 645 | ||||
-rw-r--r-- | gdb/gdbtk/library/srcwin.itb | 5 | ||||
-rw-r--r-- | gdb/gdbtk/library/tclIndex | 6 | ||||
-rw-r--r-- | gdb/gdbtk/library/toolbar.tcl | 4 |
10 files changed, 1952 insertions, 4 deletions
diff --git a/gdb/gdbtk/ChangeLog b/gdb/gdbtk/ChangeLog index ede499c2d02..357ab12f7aa 100644 --- a/gdb/gdbtk/ChangeLog +++ b/gdb/gdbtk/ChangeLog @@ -1,5 +1,23 @@ 2001-01-02 Fernando Nasser <fnasser@totem.toronto.redhat.com> + * library/gdbmenubar.itcl: New file. Define the GDBMenuBar class, + a generic menubar building facility for Insight windows (WIP). + * library/gdbtoolbar.itcl: New file. Define the GDBToolBar class, + a generic toolbar building facility for Insight windows (WIP). + * library/srcmenubar.itcl: New file. Define the SrcMenuBar class, + which implements the Source Window menubar (inherits GDBMenuBar). + * library/srctoolbar.itcl: New file. Define the SrcToolBar class, + which implements the Source Window toolbar (inherits GDBToolBar). + * library/srcwin.itb (_build_win): Use SrcMenuBar and SrcToolBar + instead of the obsolete GDBSrcBar. + * library/srcbar.tcl: Mark as OBSOLETE. + * library/toolbar.tcl: Mark as OBSOLETE. Rename class GDBToolBar + to avoid conflict with new class with the same name. + * library/Makefile (TCL): Include .itcl files. + * library/tclIndex: Regenerate. + +2001-01-02 Fernando Nasser <fnasser@totem.toronto.redhat.com> + * library/srcwin.itb (_build_win): If gdb is running a program, load the window with source for that location (if available). (download_progress): Calls to "update" must refer to the global diff --git a/gdb/gdbtk/library/Makefile b/gdb/gdbtk/library/Makefile index 53953ad9e0c..029dffe9186 100644 --- a/gdb/gdbtk/library/Makefile +++ b/gdb/gdbtk/library/Makefile @@ -1,5 +1,5 @@ -TCL := $(wildcard *.tcl *.ith *.itb) +TCL := $(wildcard *.tcl *.itcl *.ith *.itb) ITCL_SH = itclsh3.0 diff --git a/gdb/gdbtk/library/gdbmenubar.itcl b/gdb/gdbtk/library/gdbmenubar.itcl new file mode 100644 index 00000000000..fc6b69ce86e --- /dev/null +++ b/gdb/gdbtk/library/gdbmenubar.itcl @@ -0,0 +1,234 @@ +# GDBMenuBar +# Copyright 2000 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License (GPL) as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# ---------------------------------------------------------------------- +# Implements a GDB menubar. +# +# PUBLIC ATTRIBUTES: +# +# +# METHODS: +# +# configure ....... used to change public attributes +# +# PRIVATE METHODS +# +# X11 OPTION DATABASE ATTRIBUTES +# +# +# ---------------------------------------------------------------------- + +class GDBMenuBar { + inherit itk::Widget + + # ------------------------------------------------------------------ + # CONSTRUCTOR - create widget + # ------------------------------------------------------------------ + constructor {args} { + + set OtherMenus {} + set ControlMenus {} + + set Menu [menu $itk_interior.m -tearoff 0] + + eval itk_initialize $args + } + + # ------------------------------------------------------------------ + # DESTRUCTOR - destroy window containing widget + # ------------------------------------------------------------------ + destructor { + + #destroy $this + } + + #################################################################### + # Methods that deal with menus. + # + # The next set of methods control the menubar associated with the + # toolbar. Currently, only sequential addition of submenu's and menu + # entries is allowed. Here's what you do. First, create a submenu + # with the "new_menu" command. This submenu is the targeted menu. + # Subsequent calls to add_menu_separator, and add_menu_command add + # separators and commands to the end of this submenu. + # If you need to edit a submenu, call clear_menu and then add all the + # items again. + # + # Each menu command also has a class list. Transitions between states + # of gdb will enable and disable different classes of menus. + # + # FIXME - support insert_command, and also cascade menus, whenever + # we need it... + #################################################################### + + # ------------------------------------------------------------------ + # METHOD: menubar_new_menu - Add a new cascade menu to the main menu. + # Also target this menu for subsequent + # menubar_add_menu_command calls. + # + # name - the token for the new menu + # label - The label used for the label + # underline - the index of the underlined character for this menu item. + # + # RETURNS: the cascade menu widget path. + # ------------------------------------------------------------------ + method menubar_new_menu {name label underline} { + set current_menu $Menu.$name + set menu_list($name) [$Menu add cascade -menu $current_menu \ + -label $label -underline $underline] + menu $current_menu -tearoff 0 + + set item_number -1 + return $current_menu + } + + # ------------------------------------------------------------------ + # METHOD: menubar_menu_exists - Report whether a menu keyed by + # NAME exists. + # + # name - the token for the menu sought + # + # RETURNS: 1 if the menu exists, 0 otherwise. + # ------------------------------------------------------------------ + method menubar_menu_exists {name} { + return [info exists menu_list($name)] + + } + + # ------------------------------------------------------------------ + # METHOD: menubar_menu_class_find - Find a menu class and returns + # its members. + # + # type - the token for the menu class sought + # + # RETURNS: class members (list) if the class exists, {} otherwise. + # ------------------------------------------------------------------ + method menubar_menu_class_find {type} { + if {[info exists menu_classes($type)]} { + return $menu_classes($type) + } else { + return {} + } + } + + # ------------------------------------------------------------------ + # METHOD: menubar_clear_menu - Deletes the items from one of the + # main menu cascade menus. Also makes this menu + # the target menu. + # + # name - the token for the new menu + # + # RETURNS: then item number of the menu, or "" if the menu is not found. + # + # FIXME: Does not remove the deleted menus from their class lists. + # ------------------------------------------------------------------ + method menubar_clear_menu {name} { + if {[info exists menu_list($name)]} { + set current_menu [$Menu entrycget $menu_list($name) -menu] + $current_menu delete 0 end + set item_number -1 + return $current_menu + } else { + return "" + } + } + + # ------------------------------------------------------------------ + # METHOD: menubar_add_menu_separator - Adds a menu separator to + # the currently targeted submenu of the main menu. + # + # ------------------------------------------------------------------ + method menubar_add_menu_separator {} { + incr item_number + $current_menu add separator + } + + # ------------------------------------------------------------------ + # METHOD: menubar_add_menu_command - Adds a menu command item to + # the currently targeted submenu of the main menu. + # + # class - The class of the command, used for disabling entries. + # label - The text for the command. + # command - The command for the menu entry + # args - Passed to the menu entry creation command (eval'ed) + # ------------------------------------------------------------------ + method menubar_add_menu_command {class label command args} { + + eval $current_menu add command -label \$label -command \$command \ + $args + + incr item_number + + switch $class { + None {} + default { + foreach elem $class { + lappend menu_classes($elem) [list $current_menu $item_number] + } + } + } + } + + # ------------------------------------------------------------------ + # METHOD: menubar_change_menu_state - Does the actual job of + # enabling menus... + # + # INPUT: Pass normal or disabled for the state. + # ------------------------------------------------------------------ + method menubar_change_menu_state {state menuList} { + + foreach elem $menuList { + [lindex $elem 0] entryconfigure [lindex $elem 1] -state $state + } + } + + # ------------------------------------------------------------------ + # METHOD: menubar_set_current_menu - Change the current_menu pointer. + # Returns the current value so it can be restored. + # ------------------------------------------------------------------ + method menubar_set_current_menu {menup} { + set saved_menu $current_menu + set current_menu $menup + return $saved_menu + } + + #################################################################### + # + # PRIVATE DATA + # + #################################################################### + + # This array holds the menu classes. The key is the class name, + # and the value is the list of menus belonging to this class. + private variable menu_classes + + private variable item_number -1 + private variable current_menu {} + + #################################################################### + # + # PROTECTED DATA + # + #################################################################### + + # The menu Tk widget + protected variable Menu + + #################################################################### + # + # PUBLIC DATA + # + #################################################################### + + # None +} diff --git a/gdb/gdbtk/library/gdbtoolbar.itcl b/gdb/gdbtk/library/gdbtoolbar.itcl new file mode 100644 index 00000000000..6e06ffe79fa --- /dev/null +++ b/gdb/gdbtk/library/gdbtoolbar.itcl @@ -0,0 +1,345 @@ +# GDBToolBar +# Copyright 2000 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License (GPL) as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# ---------------------------------------------------------------------- +# Implements a toolbar. +# +# PUBLIC ATTRIBUTES: +# +# +# METHODS: +# +# configure ....... used to change public attributes +# +# PRIVATE METHODS +# +# X11 OPTION DATABASE ATTRIBUTES +# +# +# ---------------------------------------------------------------------- + +class GDBToolBar { + inherit itk::Widget + + # ------------------------------------------------------------------ + # CONSTRUCTOR - create widget + # ------------------------------------------------------------------ + constructor {args} { + + # Make a subframe so that the menu can't accidentally conflict + # with a name created by some subclass. + set ButtonFrame [frame $itk_interior.t] + + pack $ButtonFrame $itk_interior -fill both -expand true + + eval itk_initialize $args + } + + # ------------------------------------------------------------------ + # DESTRUCTOR - destroy window containing widget + # ------------------------------------------------------------------ + destructor { + + #destroy $this + } + + # ------------------------------------------------------------------ + # METHOD: toolbar_show - show the toolbar + # ------------------------------------------------------------------ + public method toolbar_show {} { + + if {[llength $button_list]} { + eval standard_toolbar $ButtonFrame $button_list + } + } + + #################################################################### + # Methods that deal with buttons. + #################################################################### + + # ------------------------------------------------------------------ + # PRIVATE METHOD: _register_button - Creates all the bookkeeping + # for a button, without actually inserting it in the toolbar. + # If the button will not be immediately inserted (INS == 0), + # sets its bindings and appearences to the same of a + # standard_toolbar button. + # ------------------------------------------------------------------ + private method _register_button {ins name class command balloon args} { + set bname $ButtonFrame.$name + set Buttons($name) $bname + set Buttons($bname,align) $button_align + + eval button $bname -command \$command $args + balloon register $bname $balloon + foreach elem $class { + switch $elem { + None {} + default { + lappend button_classes($elem) $name + } + } + } + + # If the button is not going to be inserted now... + if {! $ins} { + # This is a bit of a hack, but I need to bind the standard_toolbar bindings + # and appearances to these externally, since I am not inserting them in + # the original toolbar... + # FIXME: Have to add a method to the libgui toolbar to do this. + + # Make sure the button acts the way we want, not the default Tk way. + $bname configure -takefocus 0 -highlightthickness 0 \ + -relief flat -borderwidth 1 + set index [lsearch -exact [bindtags $bname] Button] + bindtags $bname [lreplace [bindtags $bname] $index $index ToolbarButton] + } + + return $bname + } + + # ------------------------------------------------------------------ + # METHOD: toolbar_create_button - Creates all the bookkeeping for a button, + # without actually inserting it in the toolbar. + # ------------------------------------------------------------------ + method toolbar_create_button {name class command balloon args} { + + return [eval _register_button 0 \$name \$class \$command \$balloon $args] + } + + # ------------------------------------------------------------------ + # METHOD: toolbar_add_button - Creates a button, and inserts it at the end + # of the button list. Call this when the toolbar is being + # set up, but has not yet been made. + # ------------------------------------------------------------------ + method toolbar_add_button {name class command balloon args} { + + lappend button_list \ + [eval _register_button 1 \$name \$class \$command \$balloon $args] + + } + + # ------------------------------------------------------------------ + # METHOD: toolbar_add_button_separator - + # ------------------------------------------------------------------ + + method toolbar_add_button_separator {} { + lappend button_list - + } + + # ------------------------------------------------------------------ + # METHOD: toolbar_button_right_justify - + # ------------------------------------------------------------------ + + method toolbar_button_right_justify {} { + lappend button_list -- + set button_align "right" + } + + # ------------------------------------------------------------------ + # METHOD: toolbar_add_label - Create a label to be inserted in the + # toolbar. + # ------------------------------------------------------------------ + + method toolbar_add_label {name text balloon args} { + set lname $ButtonFrame.$name + set Buttons($name) $lname + set Buttons($lname,align) $button_align + eval label $lname -text \$text $args + balloon register $lname $balloon + lappend button_list $lname + } + + # ------------------------------------------------------------------ + # METHOD: toolbar_insert_button - Inserts button "name" before + # button "before". + # The toolbar must be made, and the buttons must have been + # created before you run this. + # ------------------------------------------------------------------ + method toolbar_insert_button {name before} { + + if {[string first "-" $name] == 0} { + set name [string range $name 1 end] + set add_sep 1 + } else { + set add_sep 0 + } + + if {![info exists Buttons($name)] || ![info exists Buttons($before)]} { + error "toolbar_insert_buttons called with non-existant button" + } + + set before_col [gridCGet $Buttons($before) -column] + set before_row [gridCGet $Buttons($before) -row] + + set slaves [grid slaves $ButtonFrame] + + set incr [expr 1 + $add_sep] + foreach slave $slaves { + set slave_col [gridCGet $slave -column] + if {$slave_col >= $before_col} { + grid configure $slave -column [expr $slave_col + $incr] + } + } + if {$add_sep} { + grid $Buttons(-$name) -column $before_col -row $before_row + } + + # Now grid our button. Have to put in the pady since this button + # may not have been originally inserted by the libgui toolbar + # proc. + + grid $Buttons($name) -column [expr $before_col + $add_sep] \ + -row $before_row -pady 2 + + } + + # ------------------------------------------------------------------ + # METHOD: toolbar_remove_button - + # ------------------------------------------------------------------ + + method toolbar_remove_button {name} { + + if {[string first "-" $name] == 0} { + set name [string range $name 1 end] + set remove_sep 1 + } else { + set remove_sep 0 + } + + if {![info exists Buttons($name)] } { + error "toolbar_remove_buttons called with non-existant button $name" + } + + set name_col [gridCGet $Buttons($name) -column] + set name_row [gridCGet $Buttons($name) -row] + + grid remove $Buttons($name) + if {$remove_sep} { + set Buttons(-$name) [grid slaves $ButtonFrame \ + -column [expr $name_col - 1] \ + -row $name_row] + grid remove $Buttons(-$name) + } + + set slaves [grid slaves $ButtonFrame -row $name_row] + foreach slave $slaves { + set slave_col [gridCGet $slave -column] + if {($slave_col > $name_col) + && ! ([info exists Buttons($slave,align)] + && $Buttons($slave,align) == "right")} { + grid configure $slave -column [expr $slave_col - 1 - $remove_sep] + } + } + } + + # ------------------------------------------------------------------ + # METHOD: toolbar_configure_button - + # ------------------------------------------------------------------ + + method toolbar_configure_button {button args} { + eval $Buttons($button) configure $args + } + + # ------------------------------------------------------------------ + # METHOD: toolbar_bind_button - + # ------------------------------------------------------------------ + + method toolbar_bind_button {button key cmd} { + eval [list bind $Buttons($button) $key $cmd] + } + + # ------------------------------------------------------------------ + # METHOD: toolbar_set_button_balloon - + # ------------------------------------------------------------------ + + method toolbar_set_button_balloon {button text} { + eval [list balloon register $Buttons($button) $text] + } + + # ------------------------------------------------------------------ + # METHOD: toolbar_swap_button_lists - + # ------------------------------------------------------------------ + + method toolbar_swap_button_lists {in_list out_list} { + # Now swap out the buttons... + set first_out [lindex $out_list 0] + if {[info exists Buttons($first_out)] && [grid info $Buttons($first_out)] != ""} { + foreach button $in_list { + toolbar_insert_button $button $first_out + } + foreach button $out_list { + toolbar_remove_button $button + } + } elseif {[info exists Buttons($first_out)]} { + debug "Error in swap_button_list - $first_out not gridded..." + } else { + debug "Button $first_out is not in button list" + } + } + + # ------------------------------------------------------------------ + # METHOD: toolbar_button_class_find - Find a button class and returns + # its members. + # + # type - the token for the button class sought + # + # RETURNS: class members (list) if the class exists, {} otherwise. + # ------------------------------------------------------------------ + method toolbar_button_class_find {type} { + if {[info exists button_classes($type)]} { + return $button_classes($type) + } else { + return {} + } + } + + #################################################################### + # + # PRIVATE DATA + # + #################################################################### + + # This is the list of buttons that are being built up + # + private variable button_list {} + + # This is an array of buttons names -> Tk Window names + # and also of Tk Window names -> column position in grid + private variable Buttons + + # This array holds the button classes. The key is the class name, + # and the value is the list of buttons belonging to this class. + private variable button_classes + + # Tell if we are inserting buttons left or right justified + private variable button_align "left" + + #The frame to contain the buttons: + private variable ButtonFrame + + #################################################################### + # + # PROTECTED DATA + # + #################################################################### + + # None. + + #################################################################### + # + # PUBLIC DATA + # + #################################################################### + + # None. +} diff --git a/gdb/gdbtk/library/srcbar.tcl b/gdb/gdbtk/library/srcbar.tcl index 8249a5fbf37..feb48c2ce71 100644 --- a/gdb/gdbtk/library/srcbar.tcl +++ b/gdb/gdbtk/library/srcbar.tcl @@ -1,3 +1,5 @@ +# OBSOLETE: Please see gdbmenubar, gdbtoolbar, srcmenubar and srctoolbar +# # GDBSrcBar # Copyright 1997, 1998, 1999 Cygnus Solutions # diff --git a/gdb/gdbtk/library/srcmenubar.itcl b/gdb/gdbtk/library/srcmenubar.itcl new file mode 100644 index 00000000000..c308686c86f --- /dev/null +++ b/gdb/gdbtk/library/srcmenubar.itcl @@ -0,0 +1,695 @@ +# SrcMenuBar +# Copyright 2000 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License (GPL) as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# ---------------------------------------------------------------------- +# Implements a menubar that is attached to a source window. +# +# PUBLIC ATTRIBUTES: +# +# +# METHODS: +# +# configure ....... used to change public attributes +# +# PRIVATE METHODS +# +# X11 OPTION DATABASE ATTRIBUTES +# +# +# ---------------------------------------------------------------------- + +class SrcMenuBar { + inherit GDBMenuBar + + # ------------------------------------------------------------------ + # CONSTRUCTOR - create widget + # ------------------------------------------------------------------ + constructor {src args} { + set source $src + + if {! [create_menu_items]} { + destroy $this + } else { + [winfo toplevel $itk_interior] configure -menu $Menu + } + + eval itk_initialize $args + add_hook gdb_idle_hook "$this enable_ui 1" + add_hook gdb_busy_hook "$this enable_ui 0" + add_hook gdb_no_inferior_hook "$this enable_ui 2" + add_hook gdb_set_hook "$this set_hook" + add_hook control_mode_hook "$this set_control_mode" + } + + # ------------------------------------------------------------------ + # DESTRUCTOR - destroy window containing widget + # ------------------------------------------------------------------ + destructor { + remove_hook gdb_idle_hook "$this enable_ui 1" + remove_hook gdb_busy_hook "$this enable_ui 0" + remove_hook gdb_no_inferior_hook "$this enable_ui 2" + remove_hook gdb_set_hook "$this set_hook" + remove_hook control_mode_hook "$this set_control_mode" + + #destroy $this + } + + #################################################################### + # The next set of functions create the common menu groupings that + # are used in gdb menus. + # Private. Used at contruction time. + # These were previously at the GDBToolBar... + #################################################################### + + # ------------------------------------------------------------------ + # METHOD: create_menu_items - Add some menu items to the menubar. + # Returns 1 if any items added. + # ------------------------------------------------------------------ + private method create_menu_items {} { + + create_file_menu + + create_run_menu + + create_view_menu + + if {[pref get gdb/control_target]} { + create_control_menu + } + + if {[pref get gdb/mode]} { + create_trace_menu + } + + create_pref_menu + + create_help_menu + + return 1 + } + + # ------------------------------------------------------------------ + # METHOD: create_file_menu - Creates the standard file menu. + # ------------------------------------------------------------------ + + private method create_file_menu {} { + global enable_external_editor tcl_platform + + menubar_new_menu file "File" 0 + + if {[info exists enable_external_editor] && $enable_external_editor} { + menubar_add_menu_command None "Edit Source" \ + [code $source edit] + } + + menubar_add_menu_command Other "Open..." \ + "_open_file" -underline 0 -accelerator "Ctrl+O" + + menubar_add_menu_command Other "Source..." \ + "source_file" -underline 0 + + set sessions [session_list] + if {[llength $sessions]} { + menubar_add_menu_separator + set i 1 + foreach item $sessions { + menubar_add_menu_command Other "$i $item" \ + [list session_load $item] \ + -underline 0 + } + } + + menubar_add_menu_separator + + if {$tcl_platform(platform) == "windows"} { + menubar_add_menu_command None "Page Setup..." \ + [format { + set top %s + ide_winprint page_setup -parent $top + } [winfo toplevel [namespace tail $this]]] \ + -underline 8 + } + + menubar_add_menu_command None "Print Source..." \ + [code $source print] \ + -underline 0 -accelerator "Ctrl+P" + + menubar_add_menu_separator + + menubar_add_menu_command Other "Target Settings..." "set_target_name" \ + -underline 0 + + menubar_add_menu_separator + + menubar_add_menu_command None "Exit" gdbtk_quit -underline 1 + } + + # ------------------------------------------------------------------ + # METHOD: create_run_menu - Creates the standard run menu, + # or reconfigures it if it already exists. + # ------------------------------------------------------------------ + + private method create_run_menu {} { + + if {![menubar_menu_exists Run]} { + set run_menu [menubar_new_menu run "Run" 0] + } else { + set run_menu [menubar_clear_menu Run] + } + + set is_native [TargetSelection::native_debugging] + + # If we are on a Unix target, put in the attach options. "ps" doesn't + # give me the Windows PID yet, and the attach also seems flakey, so + # I will hold off on the Windows implementation for now. + + if {$is_native} { + if {[string compare $::tcl_platform(platform) windows] != 0} { + menubar_add_menu_command Attach "Attach to process" \ + [code $this do_attach $run_menu] \ + -underline 0 -accelerator "Ctrl+A" + } + } else { + menubar_add_menu_command Other "Connect to target" \ + "$this do_connect $run_menu" -underline 0 + } + + if {[pref get gdb/control_target]} { + if {!$is_native} { + menubar_add_menu_command Other "Download" Download::download_it \ + -underline 0 -accelerator "Ctrl+D" + } + menubar_add_menu_command Other "Run" [code $source inferior run] \ + -underline 0 -accelerator R + } + + if {$is_native} { + if {[string compare $::tcl_platform(platform) windows] != 0} { + menubar_add_menu_command Detach "Detach" \ + [code $this do_detach $run_menu] \ + -underline 0 -state disabled + } + } else { + menubar_add_menu_command Other "Disconnect" \ + [code $this do_disconnect $run_menu] -underline 0 -state disabled + } + + if {$is_native} { + menubar_add_menu_separator + menubar_add_menu_command Control "Kill" [code $this do_kill $run_menu] \ + -underline 0 -state disabled + } + + if { [pref get gdb/mode] } { + menubar_add_menu_separator + + menubar_add_menu_command Other "Start collection" "$this do_tstop" \ + -underline 0 -accelerator "Ctrl+B" + + menubar_add_menu_command Other "Stop collection" "$this do_tstop" \ + -underline 0 -accelerator "Ctrl+E" -state disabled + } + } + + # ------------------------------------------------------------------ + # METHOD: create_view_menu - Creates the standard view menu + # ------------------------------------------------------------------ + + private method create_view_menu {} { + + menubar_new_menu view "View" 0 + + menubar_add_menu_command Other "Stack" {ManagedWin::open StackWin} \ + -underline 0 -accelerator "Ctrl+S" + + menubar_add_menu_command Other "Registers" {ManagedWin::open RegWin} \ + -underline 0 -accelerator "Ctrl+R" + + menubar_add_menu_command Other "Memory" {ManagedWin::open MemWin} \ + -underline 0 -accelerator "Ctrl+M" + + menubar_add_menu_command Other "Watch Expressions" \ + {ManagedWin::open WatchWin} \ + -underline 0 -accelerator "Ctrl+W" + menubar_add_menu_command Other "Local Variables" \ + {ManagedWin::open LocalsWin} \ + -underline 0 -accelerator "Ctrl+L" + + if {[pref get gdb/control_target]} { + menubar_add_menu_command Other "Breakpoints" \ + {ManagedWin::open BpWin -tracepoints 0} \ + -underline 0 -accelerator "Ctrl+B" + } + + if {[pref get gdb/mode]} { + menubar_add_menu_command Other "Tracepoints" \ + {ManagedWin::open BpWin -tracepoints 1} \ + -underline 0 -accelerator "Ctrl+T" + menubar_add_menu_command Other "Tdump" {ManagedWin::open TdumpWin} \ + -underline 2 -accelerator "Ctrl+U" + } + + menubar_add_menu_command Other "Console" {ManagedWin::open Console} \ + -underline 2 -accelerator "Ctrl+N" + + menubar_add_menu_command Other "Function Browser" \ + {ManagedWin::open BrowserWin} \ + -underline 1 -accelerator "Ctrl+F" + menubar_add_menu_command Other "Thread List" \ + {ManagedWin::open ProcessWin} \ + -underline 0 -accelerator "Ctrl+H" + if {[info exists ::env(GDBTK_DEBUG)] && $::env(GDBTK_DEBUG)} { + menubar_add_menu_separator + menubar_add_menu_command Other "Debug Window" \ + {ManagedWin::open DebugWin} \ + -underline 3 -accelerator "Ctrl+U" + } + } + + # ------------------------------------------------------------------ + # METHOD: create_control_menu - Creates the standard control menu + # ------------------------------------------------------------------ + + private method create_control_menu {} { + + menubar_new_menu cntrl "Control" 0 + + menubar_add_menu_command Control "Step" [code $source inferior step] \ + -underline 0 -accelerator S + + menubar_add_menu_command Control "Next" [code $source inferior next] \ + -underline 0 -accelerator N + + menubar_add_menu_command Control "Finish" [code $source inferior finish] \ + -underline 0 -accelerator F + + menubar_add_menu_command Control "Continue" \ + [code $source inferior continue] \ + -underline 0 -accelerator C + + menubar_add_menu_separator + menubar_add_menu_command Control "Step Asm Inst" \ + [code $source inferior stepi] \ + -underline 1 -accelerator S + + menubar_add_menu_command Control "Next Asm Inst" \ + [code $source inferior nexti] \ + -underline 1 -accelerator N + + # menubar_add_menu_separator + # menubar_add_menu_command Other "Automatic Step" auto_step + } + + # ------------------------------------------------------------------ + # METHOD: create_trace_menu - Creates the standard trace menu + # ------------------------------------------------------------------ + + private method create_trace_menu {} { + + menubar_new_menu trace "Trace" 0 + + menubar_add_menu_command Other "Save Trace Commands..." \ + "save_trace_commands" \ + -underline 0 + + menubar_add_menu_separator + + menubar_add_menu_command Trace "Next Hit" {tfind_cmd tfind} \ + -underline 0 -accelerator N + + menubar_add_menu_command Trace "Previous Hit" {tfind_cmd "tfind -"} \ + -underline 0 -accelerator P + + menubar_add_menu_command Trace "First Hit" {tfind_cmd "tfind start"} \ + -underline 0 -accelerator F + + menubar_add_menu_command Trace "Next Line Hit" {tfind_cmd "tfind line"} \ + -underline 5 -accelerator L + + menubar_add_menu_command Trace "Next Hit Here" \ + {tfind_cmd "tfind tracepoint"} \ + -underline 9 -accelerator H + + menubar_add_menu_separator + menubar_add_menu_command Trace "Tfind Line..." \ + "ManagedWin::open TfindArgs -Type LN" \ + -underline 9 -accelerator E + + menubar_add_menu_command Trace "Tfind PC..." \ + "ManagedWin::open TfindArgs -Type PC" \ + -underline 7 -accelerator C + + menubar_add_menu_command Trace "Tfind Tracepoint..." \ + "ManagedWin::open TfindArgs -Type TP" \ + -underline 6 -accelerator T + + menubar_add_menu_command Trace "Tfind Frame..." \ + "ManagedWin::open TfindArgs -Type FR" \ + -underline 6 -accelerator F + } + + # ------------------------------------------------------------------ + # METHOD: create_pref_menu - Creates the standard preferences menu + # ------------------------------------------------------------------ + private method create_pref_menu {} { + + menubar_new_menu pref "Preferences" 0 + + menubar_add_menu_command Other "Global..." \ + "ManagedWin::open GlobalPref -transient" -underline 0 + + menubar_add_menu_command Other "Source..." \ + "ManagedWin::open SrcPref -transient" -underline 0 + } + + # ------------------------------------------------------------------ + # METHOD: create_help_menu - Creates the standard help menu + # ------------------------------------------------------------------ + private method create_help_menu {} { + + menubar_new_menu help "Help" 0 + menubar_add_menu_command Other "Help Topics" \ + {HtmlViewer::open_help index.html} \ + -underline 0 + menubar_add_menu_separator + menubar_add_menu_command Other "About GDB..." \ + {ManagedWin::open About -transient} \ + -underline 0 + } + + #################################################################### + # + #################################################################### + + # ------------------------------------------------------------------ + # METHOD: set_control_mode - sets up the srcbar for browsing + # a trace experiment. + # mode: 1 => browse mode + # 0 => control mode + # ------------------------------------------------------------------ + method set_control_mode {mode} { + debug "set_control_mode called with mode $mode" + if {$mode} { + set Browsing 1 + enable_ui 1 + } else { + set Browsing 0 + enable_ui 1 + } + } + + # ------------------------------------------------------------------ + # METHOD: do_attach: attach to a running target + # ------------------------------------------------------------------ + method do_attach {menu} { + gdbtk_attach_native + } + + # ------------------------------------------------------------------ + # METHOD: do_detach: detach from a running target + # ------------------------------------------------------------------ + method do_detach {menu} { + ::disconnect + gdbtk_idle + } + + # ------------------------------------------------------------------ + # METHOD: do_kill: kill the current target + # ------------------------------------------------------------------ + method do_kill {menu} { + gdb_cmd "kill" + run_hooks gdb_no_inferior_hook + } + + # ------------------------------------------------------------------ + # METHOD: do_connect: connect to a remote target + # in asynch mode if async is 1 + # ------------------------------------------------------------------ + method do_connect {menu {async 0}} { + global file_done + + debug "do_connect: menu=$menu async=$async" + + gdbtk_busy + + set result [gdbtk_attach_remote] + switch $result { + ATTACH_ERROR { + set successful 0 + } + + ATTACH_TARGET_CHANGED { + if {[pref get gdb/load/check] && $file_done} { + set err [catch {gdb_cmd "compare-sections"} errTxt] + if {$err} { + set successful 0 + tk_messageBox -title "Error" -message $errTxt \ + -icon error -type ok + break + } + } + + tk_messageBox -title "GDB" -message "Successfully connected" \ + -icon info -type ok + set successful 1 + } + + ATTACH_CANCELED { + tk_messageBox -title "GDB" -message "Connection Canceled" -icon info \ + -type ok + set successful 0 + } + + ATTACH_TARGET_UNCHANGED { + tk_messageBox -title "GDB" -message "Successfully connected" \ + -icon info -type ok + set successful 1 + } + + default { + dbug E "Unhandled response from gdbtk_attach_remote: \"$result\"" + set successful 0 + } + } + + gdbtk_idle + + if {$successful} { + $menu entryconfigure "Connect to target" -state disabled + $menu entryconfigure "Disconnect" -state normal + } else { + $menu entryconfigure "Connect to target" -state normal + $menu entryconfigure "Disconnect" -state disabled + } + + # Whenever we attach, we need to do an update + gdbtk_update + } + + # ------------------------------------------------------------------ + # METHOD: do_disconnect: disconnect from a remote target + # in asynch mode if async is 1. + # + # ------------------------------------------------------------------ + method do_disconnect {menu {async 0}} { + debug "$menu $async" + # + # For now, these are the same, but they might be different... + # + + disconnect $async + + $menu entryconfigure "Connect to target" -state normal + $menu entryconfigure "Disconnect" -state disabled + } + + # ------------------------------------------------------------------ + # METHOD: do_tstop: Change the GUI state, then do the tstop or + # tstart command, whichever is appropriate. + # + # ------------------------------------------------------------------ + method do_tstop {} { + debug "do_tstop called... Collecting is $Collecting" + + # FIXME: This must be done in conjuntion with the buttons + # or the states won't match + + if {!$Collecting} { + # + # Start the trace experiment + # + + if {$Browsing} { + set ret [tk_messageBox -title "Warning" -message \ +"You are currently browsing a trace experiment. +This command will clear the results of that experiment. +Do you want to continue?" \ + -icon warning -type okcancel -default ok] + if {[string compare $ret cancel] == 0} { + return + } + set_control_mode 1 + } + if {[tstart]} { + # FIXME: Must enable the Stop Collection menu item and + # disable the Start Collection item + set Collecting 1 + } else { + tk_messageBox -title Error -message "Error downloading tracepoint info" \ + -icon error -type ok + } + } else { + # + # Stop the trace experiment + # + + if {[tstop]} { + # FIXME: Must enable the Stop Collection menu item and + # disable the Start Collection item + set Collecting 0 + } + } + } + + # ------------------------------------------------------------------ + # METHOD: set_hook - run when user enters a `set' command. + # + # FIXME: Should not be accessing the base class internal data + # As the spec says, one must clear the menu and recreate it. + # ------------------------------------------------------------------ + method set_hook {varname value} { + debug "Got $varname = $value" + + if {$varname == "os"} { + # Make current_menu pointer point to the View Menu. + # FIXME: Should not be accessing the base class internal data directly + set view_menu [menu_find View] + # Restore the current_menu pointer. + set save_menu [menubar_set_current_menu $view_menu] + set title "Kernel Objects" + + # Look for the KOD menu entry... + if {[catch {$view_menu index $title} index]} { + set index none + } + + # FIXME: This assumes that the KOD menu is the last one as it does not + # adjust the index information kept by the GDBMenuBar class. + if {$value == ""} { + # No OS, so remove KOD from View menu. + if {$index != "none"} { + # FIXME: Should not be accessing the base class internal data + $view_menu delete $index + } + } else { + # Add KOD to View menu, but only if it isn't already there. + if {$index == "none"} { + menubar_add_menu_command Other $title {ManagedWin::open KodWin} \ + -underline 0 -accelerator "Ctrl+K" + } + } + + # Restore the current_menu pointer. + menubar_set_current_menu $save_menu + + global gdb_kod_cmd + set gdb_kod_cmd $value + } + } + + #################################################################### + # The following method enables/disables both menus and buttons. + #################################################################### + + # ------------------------------------------------------------------ + # METHOD: enable_ui - enable/disable the appropriate buttons and menus + # Called from the busy, idle, and no_inferior hooks. + # + # on must be: + # value Control Other Trace State + # 0 off off off gdb is busy + # 1 on on off gdb has inferior, and is idle + # 2 off on off gdb has no inferior, and is idle + # ------------------------------------------------------------------ + public method enable_ui {on} { + global tcl_platform + debug "$on - Browsing=$Browsing" + + # Do the enabling so that all the disabling happens first, this way if a + # button belongs to two groups, enabling takes precedence, which is + # probably right. + + switch $on { + 0 { + set enable_list {Control disabled \ + Other disabled \ + Trace disabled \ + Attach disabled \ + Detach disabled} + } + 1 { + if {!$Browsing} { + set enable_list {Trace disabled \ + Control normal \ + Other normal \ + Attach disabled \ + Detach normal } +# # set the states of stepi and nexti correctly +# _set_stepi + } else { + set enable_list {Control disabled Other normal Trace normal} + } + + } + 2 { + set enable_list {Control disabled \ + Trace disabled \ + Other normal \ + Attach normal \ + Detach disabled } + } + default { + debug "Unknown type: $on in enable_ui" + return + } + } + + debug "Enable list is: $enable_list" + foreach {type state} $enable_list { + set members [menubar_menu_class_find $type] + if {[llength $members]} { + menubar_change_menu_state $state $members + } + } + } + + #################################################################### + # + # PRIVATE DATA + # + #################################################################### + + # This is a handle on our parent source window. + private variable source {} + + #################################################################### + # + # PUBLIC DATA + # + #################################################################### + + # The next two determine the state of the application when Tracing is enabled. + + public variable Browsing 0 ;# Are we currently browsing a trace experiment? + public variable Collecting 0 ;# Are we currently collecting a trace exp.? +} diff --git a/gdb/gdbtk/library/srctoolbar.itcl b/gdb/gdbtk/library/srctoolbar.itcl new file mode 100644 index 00000000000..abd23aa729a --- /dev/null +++ b/gdb/gdbtk/library/srctoolbar.itcl @@ -0,0 +1,645 @@ +# SrcToolBar +# Copyright 2000 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License (GPL) as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# ---------------------------------------------------------------------- +# Implements a toolbar that is attached to a source window. +# +# PUBLIC ATTRIBUTES: +# +# +# METHODS: +# +# configure ....... used to change public attributes +# +# PRIVATE METHODS +# +# X11 OPTION DATABASE ATTRIBUTES +# +# +# ---------------------------------------------------------------------- + +class SrcToolBar { + inherit GDBToolBar + + # ------------------------------------------------------------------ + # CONSTRUCTOR - create widget + # ------------------------------------------------------------------ + constructor {src args} { + set source $src + _load_images + _load_src_images + + create_buttons + toolbar_show + + eval itk_initialize $args + add_hook gdb_idle_hook "$this enable_ui 1" + add_hook gdb_busy_hook "$this enable_ui 0" + add_hook gdb_no_inferior_hook "$this enable_ui 2" + add_hook gdb_trace_find_hook "$this handle_trace_find_hook" + } + + # ------------------------------------------------------------------ + # DESTRUCTOR - destroy window containing widget + # ------------------------------------------------------------------ + destructor { + global GDBSrcBar_state + + unset GDBSrcBar_state($this) + remove_hook gdb_idle_hook "$this enable_ui 1" + remove_hook gdb_busy_hook "$this enable_ui 0" + remove_hook gdb_no_inferior_hook "$this enable_ui 2" + remove_hook gdb_trace_find_hook "$this handle_trace_find_hook" + + #destroy $this + } + + #################################################################### + # The next set of functions are the generic button groups that gdb uses. + # Private. Used at contruction time. + # These were previously at the GDBToolBar... + #################################################################### + + # ------------------------------------------------------------------ + # METHOD: create_buttons - Add some buttons to the toolbar. + # Returns list of buttons in form acceptable + # to standard_toolbar. + # ------------------------------------------------------------------ + private method create_buttons {} { + global enable_external_editor + + toolbar_add_button stop None {} {} + _set_runstop + + if {[pref get gdb/mode]} { + toolbar_add_button tstop Control \ + [list $this do_tstop] "Start Collection" \ + -image Movie_on_img + + toolbar_add_button view Other [list $this set_control_mode 1] \ + "Switch to Browse Mode" -image watch_movie_img + + toolbar_add_button_separator + + } + + if {[pref get gdb/control_target]} { + create_control_buttons + if {[pref get gdb/mode]} { + create_trace_buttons 0 + } + } elseif {[get pref gdb/mode]} { + + # + # If we don't control the target, then we might as well + # put a copy of the trace controls on the source window. + # + create_trace_buttons 1 + } + + toolbar_add_button_separator + + create_window_buttons + + # Random bits of obscurity... + toolbar_bind_button reg <Button-3> "ManagedWin::open RegWin -force" + toolbar_bind_button mem <Button-3> "ManagedWin::open MemWin -force" + toolbar_bind_button watch <Button-3> "ManagedWin::open WatchWin -force" + toolbar_bind_button vars <Button-3> "ManagedWin::open LocalsWin -force" + + toolbar_add_button_separator + + if {[info exists enable_external_editor] && $enable_external_editor} { + toolbar_add_button edit Other [code $source edit] "Edit Source" \ + -image edit_img + + toolbar_add_button_separator + } + + toolbar_add_label addr $address "Address" -width 10 -relief sunken \ + -bd 1 -anchor e -font src-font + + toolbar_add_label line $line "Line Number" -width 6 -relief sunken \ + -bd 1 -anchor e -font src-font + + toolbar_button_right_justify + + create_stack_buttons + + # This feature has been disabled for now. + # checkbutton $ButtonFrame.upd -command "$this _toggle_updates" \ + # -variable GDBSrcBar_state($this) + # lappend button_list $ButtonFrame.upd + # global GDBSrcBar_state + # ::set GDBSrcBar_state($this) $updatevalue + # balloon register $ButtonFrame.upd "Toggle Window Updates" + } + + # ------------------------------------------------------------------ + # METHOD: create_control_buttons - Creates the step, continue, etc buttons. + # ------------------------------------------------------------------ + + private method create_control_buttons {} { + toolbar_add_button step Control [code $source inferior step] \ + "Step (S)" -image step_img + + toolbar_add_button next Control [code $source inferior next] \ + "Next (N)" -image next_img + + toolbar_add_button finish Control [code $source inferior finish] \ + "Finish (F)" -image finish_img + + toolbar_add_button continue Control [code $source inferior continue] \ + "Continue (C)" -image continue_img + + # A spacer before the assembly-level items looks good. It helps + # to indicate that these are somehow different. + toolbar_add_button_separator + + toolbar_add_button stepi Control [code $source inferior stepi] \ + "Step Asm Inst (S)" -image stepi_img + + toolbar_add_button nexti Control [code $source inferior nexti] \ + "Next Asm Inst (N)" -image nexti_img + + _set_stepi + + set Run_control_buttons {step next finish continue -stepi nexti} + + } + + # ------------------------------------------------------------------ + # METHOD: create_trace_buttons - Creates the next hit, etc. + # ------------------------------------------------------------------ + + private method create_trace_buttons {{show 0}} { + + if {$show} { + set command toolbar_add_button + } else { + set command toolbar_create_button + } + + $command tfindstart Trace {tfind_cmd "tfind start"} "First Hit <F>" \ + -image rewind_img + + $command tfind Trace {tfind_cmd tfind} "Next Hit <N>" -image next_hit_img + + $command tfindprev Trace {tfind_cmd "tfind -"} "Previous Hit <P>" \ + -image prev_hit_img + + $command tfindline Trace {tfind_cmd "tfind line"} "Next Line Hit <L>" \ + -image next_line_img + + $command tfindtp Trace { tfind_cmd "tfind tracepoint"} \ + "Next Hit Here <H>" -image next_check_img + + set Trace_control_buttons {tfindstart tfind tfindprev tfindline tfindtp} + } + + # ------------------------------------------------------------------ + # METHOD: create_window_buttons - Creates the registers, etc, buttons + # ------------------------------------------------------------------ + + private method create_window_buttons {} { + toolbar_add_button reg Other {ManagedWin::open RegWin} \ + "Registers (Ctrl+R)" -image reg_img + + toolbar_add_button mem Other {ManagedWin::open MemWin} \ + "Memory (Ctrl+M)" -image memory_img + + toolbar_add_button stack Other {ManagedWin::open StackWin} \ + "Stack (Ctrl+S)" -image stack_img + + toolbar_add_button watch Other {ManagedWin::open WatchWin} \ + "Watch Expressions (Ctrl+W)" -image watch_img + + toolbar_add_button vars Other {ManagedWin::open LocalsWin} \ + "Local Variables (Ctrl+L)" -image vars_img + + if {[pref get gdb/control_target]} { + toolbar_add_button bp Other {ManagedWin::open BpWin} \ + "Breakpoints (Ctrl+B)" -image bp_img + } + + if {[pref get gdb/mode]} { + toolbar_add_button tp Other {ManagedWin::open BpWin -tracepoints 1} \ + "Tracepoints (Ctrl+T)" -image tp_img + + toolbar_add_button tdump Trace {ManagedWin::open TdumpWin} \ + "Tdump (Ctrl+D)" -image tdump_img + } + + toolbar_add_button con Other {ManagedWin::open Console} \ + "Console (Ctrl+N)" -image console_img + } + + # ------------------------------------------------------------------ + # METHOD: create_stack_buttons - Creates the up down bottom stack buttons + # ------------------------------------------------------------------ + + private method create_stack_buttons {} { + + toolbar_add_button down {Trace Control} \ + [code $source stack down] \ + "Down Stack Frame" -image down_img + + toolbar_add_button up {Trace Control} \ + [code $source stack up] \ + "Up Stack Frame" -image up_img + + toolbar_add_button bottom {Trace Control} \ + [code $source stack bottom] \ + "Go to Bottom of Stack" -image bottom_img + + } + + #################################################################### + # + #################################################################### + + # ------------------------------------------------------------------ + # METHOD: _load_images - Load standard images. Private method. + # ------------------------------------------------------------------ + public method _load_images { {reconfig 0} } { + global gdb_ImageDir + if {!$reconfig && $_loaded_images} { + return + } + set _loaded_images 1 + + lappend imgs console reg stack vmake vars watch memory bp + foreach name $imgs { + image create photo ${name}_img -file [file join $gdb_ImageDir ${name}.gif] + } + } + + # ------------------------------------------------------------------ + # METHOD: _load_src_images - Load standard images. Private method. + # ------------------------------------------------------------------ + method _load_src_images { {reconf 0} } { + global gdb_ImageDir + + if {!$reconf && $_loaded_src_images} { + return + } + set _loaded_src_images 1 + + foreach name {run stop step next finish continue edit \ + stepi nexti up down bottom Movie_on Movie_off \ + next_line next_check next_hit rewind prev_hit \ + watch_movie run_expt tdump tp} { + image create photo ${name}_img -file [file join $gdb_ImageDir ${name}.gif] + } + } + + # ------------------------------------------------------------------ + # METHOD: _set_runstop - Set state of run/stop button. + # + # busy - Run button becomes disabled + # running - Stop button appears, allowing user to stop executing target + # downloading - Stop button appears, allowing user to interrupt downloading + # normal - Run button appears, allowing user to run/re-run exe + # ------------------------------------------------------------------ + public method _set_runstop {} { + dbug W $runstop + + switch $runstop { + busy { + toolbar_configure_button stop -state disabled + } + downloading { + toolbar_configure_button stop -state normal -image stop_img \ + -command [code $this cancel_download] + toolbar_set_button_balloon stop "Stop" + } + running { + toolbar_configure_button stop -state normal -image stop_img \ + -command [code $source inferior stop] + toolbar_set_button_balloon stop "Stop" + } + normal { + toolbar_configure_button stop -state normal -image run_img \ + -command [code $source inferior run] + toolbar_set_button_balloon stop "Run (R)" + } + default { + dbug W "unknown state $runstop" + } + } + } + + + # ------------------------------------------------------------------ + # METHOD: _set_stepi - Set state of stepi/nexti buttons. + # ------------------------------------------------------------------ + public method _set_stepi {} { + + # Only do this in synchronous mode + if {!$Tracing} { + # In source-only mode, disable these buttons. Otherwise, enable + # them. + if {$displaymode == "SOURCE"} { + set state disabled + } else { + set state normal + } + toolbar_configure_button stepi -state $state + toolbar_configure_button nexti -state $state + } + } + + # ------------------------------------------------------------------ + # METHOD: handle_trace_find_hook - response to the tfind command. + # If the command puts us in a new mode, then switch modes... + # ------------------------------------------------------------------ + method handle_trace_find_hook {mode from_tty} { + debug "mode: $mode, from_tty: $from_tty, Browsing: $Browsing" + if {[string compare $mode -1] == 0} { + if {$Browsing} { + set_control_mode 0 + } + } else { + if {!$Browsing} { + set_control_mode 1 + } + } + } + + # ------------------------------------------------------------------ + # METHOD: set_control_mode - sets up the srcbar for browsing + # a trace experiment. + # mode: 1 => browse mode + # 0 => control mode + # ------------------------------------------------------------------ + method set_control_mode {mode} { + debug "set_control_mode called with mode $mode" + if {$mode} { + set Browsing 1 + toolbar_configure_button view -image run_expt_img \ + -command "$this set_control_mode 0" + toolbar_set_button_balloon view "Switch to Control mode" + # Now swap out the buttons... + toolbar_swap_button_lists $Trace_control_buttons $Run_control_buttons + enable_ui 1 + } else { + if {$Browsing} { + tfind_cmd {tfind none} + } + set Browsing 0 + toolbar_configure_button view -image watch_movie_img \ + -command "$this set_control_mode 1" + toolbar_set_button_balloon view "Switch to Browse mode" + # Now swap out the buttons... + toolbar_swap_button_lists $Run_control_buttons $Trace_control_buttons + enable_ui 1 + } + run_hooks control_mode_hook $Browsing + } + + # ------------------------------------------------------------------ + # METHOD: _toggle_updates - Run when the update checkbutton is + # toggled. Private method. + # ------------------------------------------------------------------ + public method _toggle_updates {} { + global GDBSrcBar_state + if {$updatecommand != ""} { + uplevel \#0 $updatecommand $GDBSrcBar_state($this) + } + } + + # ------------------------------------------------------------------ + # METHOD: cancel_download + # ------------------------------------------------------------------ + public method cancel_download {} { + global download_dialog download_cancel_ok + + if {"$download_dialog" != ""} { + $download_dialog cancel + } else { + set download_cancel_ok 1 + } + } + + # ------------------------------------------------------------------ + # METHOD: reconfig - reconfigure the srcbar + # used when preferences change + # ------------------------------------------------------------------ + public method reconfig {} { + debug + _load_src_images 1 + _load_images 1 + # FIXME: Must Check if we are Tracing and set the buttons accordingly. + } + + # ------------------------------------------------------------------ + # METHOD: do_tstop: Change the GUI state, then do the tstop or + # tstart command, whichever is appropriate. + # + # ------------------------------------------------------------------ + method do_tstop {} { + debug "do_tstop called... Collecting is $Collecting" + + # FIXME: This must be done in conjunction with the menu or the + # states will mismatch. + + if {!$Collecting} { + # + # Start the trace experiment + # + + if {$Browsing} { + set ret [tk_messageBox -title "Warning" -message \ +"You are currently browsing a trace experiment. +This command will clear the results of that experiment. +Do you want to continue?" \ + -icon warning -type okcancel -default ok] + if {[string compare $ret cancel] == 0} { + return + } + set_control_mode 1 + } + if {[tstart]} { + toolbar_configure_button tstop -image Movie_off_img + toolbar_set_button_balloon tstop "End Collection" + set Collecting 1 + } else { + tk_messageBox -title Error -message "Error downloading tracepoint info" \ + -icon error -type ok + } + } else { + # + # Stop the trace experiment + # + + if {[tstop]} { + toolbar_configure_button tstop -image Movie_on_img + toolbar_set_button_balloon tstop "Start Collection" + set Collecting 0 + } + } + } + + #################################################################### + # The following method enables/disables both menus and buttons. + #################################################################### + + # ------------------------------------------------------------------ + # METHOD: enable_ui - enable/disable the appropriate buttons and menus + # Called from the busy, idle, and no_inferior hooks. + # + # on must be: + # value Control Other Trace State + # 0 off off off gdb is busy + # 1 on on off gdb has inferior, and is idle + # 2 off on off gdb has no inferior, and is idle + # ------------------------------------------------------------------ + public method enable_ui {on} { + global tcl_platform + debug "$on - Browsing=$Browsing" + + # Do the enabling so that all the disabling happens first, this way if a + # button belongs to two groups, enabling takes precedence, which is probably right. + + switch $on { + 0 { + # Busy + set enable_list {Control disabled \ + Other disabled \ + Trace disabled \ + Attach disabled \ + Detach disabled} + } + 1 { + # Idle, with inferior + if {!$Browsing} { + set enable_list {Trace disabled \ + Control normal \ + Other normal \ + Attach disabled \ + Detach normal } + # set the states of stepi and nexti correctly + _set_stepi + } else { + set enable_list {Control disabled Other normal Trace normal} + } + + } + 2 { + # Idle, no inferior + set enable_list {Control disabled \ + Trace disabled \ + Other normal \ + Attach normal \ + Detach disabled } + } + default { + debug "Unknown type: $on in enable_ui" + return + } + } + + debug "Enable list is: $enable_list" + foreach {type state} $enable_list { + dbug W $type + set class_list [toolbar_button_class_find $type] + if {[llength $class_list]} { + dbug W "$type $state \{$class_list\}" + foreach button $class_list { + dbug W "$type $button $state" + toolbar_configure_button $button -state $state + } + } +# if {[info exists menu_classes($type)]} { +# change_menu_state $menu_classes($type) $state +# } + } + + } + + #################################################################### + # + # PRIVATE DATA + # + #################################################################### + + # This is a handle on our parent source window. + private variable source {} + + # + # FIXME - Need to break the images into the sets needed for + # each button group, and load them when the button group is + # created. + + # This is set if we've already loaded the standard images. + private common _loaded_images 0 + + # This is set if we've already loaded the standard images. Private + # variable. + private common _loaded_src_images 0 + + # These buttons go in the control area when we are browsing + protected variable Trace_control_buttons + + # And these go in the control area when we are running + protected variable Run_control_buttons + + #################################################################### + # + # PUBLIC DATA + # + #################################################################### + + # This is the command that should be run when the `update' + # checkbutton is toggled. The current value of the checkbutton is + # appended to the command. + public variable updatecommand {} + + # This controls whether the `update' checkbutton is turned on or + # off. + public variable updatevalue 0 { + global GDBSrcBar_state + ::set GDBSrcBar_state($this) $updatevalue + } + + # This holds the text that is shown in the address label. + public variable address {} { + toolbar_configure_button addr -text $address -font src-font + } + + # This holds the text that is shown in the line label. + public variable line {} { + toolbar_configure_button line -text $line + } + + # This holds the source window's display mode. Valid values are + # SOURCE, ASSEMBLY, SRC+ASM, and MIXED. + public variable displaymode SOURCE { + _set_stepi + } + + # This indicates what is the inferior state. + # Possible values are: {busy running downloading normal} + public variable runstop normal { + dbug W "configuring runstop $runstop" + + # Set the Run/Stop button accordingly + _set_runstop + } + + # The next three determine the state of the application when Tracing is enabled. + + public variable Tracing 0 ;# Is tracing enabled for this gdb? + public variable Browsing 0 ;# Are we currently browsing a trace experiment? + public variable Collecting 0 ;# Are we currently collecting a trace experiment? +} diff --git a/gdb/gdbtk/library/srcwin.itb b/gdb/gdbtk/library/srcwin.itb index 29c603ab4c9..4c75adaded4 100644 --- a/gdb/gdbtk/library/srcwin.itb +++ b/gdb/gdbtk/library/srcwin.itb @@ -78,9 +78,12 @@ body SrcWin::destructor {} { body SrcWin::_build_win {} { global gdb_downloading gdb_running gdb_loaded + # add a menu to the source window + SrcMenuBar $this._menubar $this + # build source toolbar set _toolbar [conAdd toolbar -resizable 0] - GDBSrcBar $_toolbar $this \ + SrcToolBar $_toolbar $this \ -updatecommand [list $this toggle_updates] \ -updatevalue $do_updates diff --git a/gdb/gdbtk/library/tclIndex b/gdb/gdbtk/library/tclIndex index b6d7a70364f..393b5ac8bd1 100644 --- a/gdb/gdbtk/library/tclIndex +++ b/gdb/gdbtk/library/tclIndex @@ -89,7 +89,7 @@ set auto_index(session_list) [list source [file join $dir session.tcl]] set auto_index(GDBSrcBar) [list source [file join $dir srcbar.tcl]] set auto_index(TdumpWin) [list source [file join $dir tdump.tcl]] set auto_index(TfindArgs) [list source [file join $dir tfind_args.tcl]] -set auto_index(GDBToolBar) [list source [file join $dir toolbar.tcl]] +set auto_index(oldGDBToolBar) [list source [file join $dir toolbar.tcl]] set auto_index(TraceDlg) [list source [file join $dir tracedlg.tcl]] set auto_index(gdb_add_tracepoint) [list source [file join $dir tracedlg.tcl]] set auto_index(gdb_edit_tracepoint) [list source [file join $dir tracedlg.tcl]] @@ -116,6 +116,10 @@ set auto_index(::VariableWin::getLocals) [list source [file join $dir variables. set auto_index(WarningDlg) [list source [file join $dir warning.tcl]] set auto_index(::WarningDlg::constructor) [list source [file join $dir warning.tcl]] set auto_index(WatchWin) [list source [file join $dir watch.tcl]] +set auto_index(GDBMenuBar) [list source [file join $dir gdbmenubar.itcl]] +set auto_index(GDBToolBar) [list source [file join $dir gdbtoolbar.itcl]] +set auto_index(SrcMenuBar) [list source [file join $dir srcmenubar.itcl]] +set auto_index(SrcToolBar) [list source [file join $dir srctoolbar.itcl]] set auto_index(AttachDlg) [list source [file join $dir attachdlg.ith]] set auto_index(Block) [list source [file join $dir blockframe.ith]] set auto_index(Frame) [list source [file join $dir blockframe.ith]] diff --git a/gdb/gdbtk/library/toolbar.tcl b/gdb/gdbtk/library/toolbar.tcl index eb7d02165f5..2b3f87ce4c8 100644 --- a/gdb/gdbtk/library/toolbar.tcl +++ b/gdb/gdbtk/library/toolbar.tcl @@ -1,3 +1,5 @@ +# OBSOLETE: Please see gdbmenubar, gdbtoolbar, srcmenubar and srctoolbar +# # Menu, toolbar, and status window for GDBtk. # Copyright 1997, 1998, 1999 Cygnus Solutions # @@ -18,7 +20,7 @@ # and button sets. It does not actually add any buttons or # menus on its own, however. -class GDBToolBar { +class oldGDBToolBar { inherit itk::Widget # ------------------------------------------------------------------ |