Index: generic/gdbtk-register.c =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-register.c,v retrieving revision 1.12 diff -p -r1.12 gdbtk-register.c *** generic/gdbtk-register.c 30 Nov 2002 17:49:21 -0000 1.12 --- generic/gdbtk-register.c 17 Dec 2002 20:27:26 -0000 *************** *** 21,26 **** --- 21,27 ---- #include "defs.h" #include "frame.h" #include "regcache.h" + #include "reggroups.h" #include "value.h" #include "target.h" #include "gdb_string.h" *************** static int map_arg_registers (Tcl_Interp *** 43,48 **** --- 44,52 ---- static void register_changed_p (int, void *); static void setup_architecture_data (void); static int gdb_regformat (ClientData, Tcl_Interp *, int, Tcl_Obj **); + static int gdb_reggroup (ClientData, Tcl_Interp *, int, Tcl_Obj **); + static int gdb_reggrouplist (ClientData, Tcl_Interp *, int, Tcl_Obj **); + static void get_register_types (int regnum, void *arg); static char *old_regs = NULL; *************** gdb_register_info (ClientData clientData *** 117,129 **** int index; void *argp; void (*func)(int, void *); ! static char *commands[] = {"changed", "name", "size", "value", "type", "format", NULL}; ! enum commands_enum { REGINFO_CHANGED, REGINFO_NAME, REGINFO_SIZE, ! REGINFO_VALUE, REGINFO_TYPE, REGINFO_FORMAT }; if (objc < 2) { ! Tcl_WrongNumArgs (interp, 1, objv, "name|size|value|type|format [regnum1 ... regnumN]"); return TCL_ERROR; } --- 121,134 ---- int index; void *argp; void (*func)(int, void *); ! static char *commands[] = {"changed", "name", "size", "value", "type", ! "format", "group", "grouplist", NULL}; ! enum commands_enum { REGINFO_CHANGED, REGINFO_NAME, REGINFO_SIZE, REGINFO_VALUE, ! REGINFO_TYPE, REGINFO_FORMAT, REGINFO_GROUP, REGINFO_GROUPLIST }; if (objc < 2) { ! Tcl_WrongNumArgs (interp, 1, objv, "name|size|value|type|format|groups [regnum1 ... regnumN]"); return TCL_ERROR; } *************** gdb_register_info (ClientData clientData *** 180,185 **** --- 185,196 ---- case REGINFO_FORMAT: return gdb_regformat (clientData, interp, objc, objv); + case REGINFO_GROUP: + return gdb_reggroup (clientData, interp, objc, objv); + + case REGINFO_GROUPLIST: + return gdb_reggrouplist (clientData, interp, objc, objv); + default: return TCL_ERROR; } *************** gdb_regformat (ClientData clientData, Tc *** 467,473 **** if (objc != 3) { ! Tcl_WrongNumArgs (interp, 1, objv, "regno type format"); return TCL_ERROR; } --- 478,484 ---- if (objc != 3) { ! Tcl_WrongNumArgs (interp, 0, objv, "gdb_reginfo regno type format"); return TCL_ERROR; } *************** gdb_regformat (ClientData clientData, Tc *** 488,490 **** --- 499,572 ---- return TCL_OK; } + + + /* gdb_reggrouplist returns the names of the register groups */ + /* for the current architecture. */ + /* Usage: gdb_reginfo groups */ + + static int + gdb_reggrouplist (ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj **objv) + { + struct reggroup *const *groups; + int i = 0; + + if (objc != 0) + { + Tcl_WrongNumArgs (interp, 0, objv, "gdb_reginfo grouplist"); + return TCL_ERROR; + } + + groups = reggroups (current_gdbarch); + + while (groups[i] != NULL) { + if (reggroup_type (groups[i]) == USER_REGGROUP) + Tcl_ListObjAppendElement (NULL, result_ptr->obj_ptr, Tcl_NewStringObj (reggroup_name(groups[i]), -1)); + i++; + } + return TCL_OK; + } + + + /* gdb_reggroup returns the names of the registers in a group. */ + /* Usage: gdb_reginfo group groupname */ + + static int + gdb_reggroup (ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj **objv) + { + struct reggroup *const *group; + char *groupname; + int regnum; + + if (objc != 1) + { + Tcl_WrongNumArgs (interp, 0, objv, "gdb_reginfo group groupname"); + return TCL_ERROR; + } + + groupname = Tcl_GetStringFromObj (objv[0], NULL); + if (groupname == NULL) + { + gdbtk_set_result (interp, "could not read groupname"); + return TCL_ERROR; + } + + for (group = reggroups (current_gdbarch); *group != NULL; group++) + { + if (strcmp (groupname, reggroup_name (*group)) == 0) + break; + } + + if (*group == NULL) + return TCL_ERROR; + + for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++) + { + if (gdbarch_register_reggroup_p (current_gdbarch, regnum, *group)) + Tcl_ListObjAppendElement (NULL, result_ptr->obj_ptr, Tcl_NewIntObj (regnum)); + } + return TCL_OK; + } + Index: library/regwin.itb =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/library/regwin.itb,v retrieving revision 1.22 diff -p -r1.22 regwin.itb *** library/regwin.itb 5 Dec 2002 18:32:10 -0000 1.22 --- library/regwin.itb 17 Dec 2002 20:27:27 -0000 *************** itcl::body RegWin::_load_prefs {} { *** 80,89 **** set _reg_display_list {} set _register(hidden) {} ! foreach r [gdb_reginfo name -numbers] { set nm [lindex $r 0] set rn [lindex $r 1] - set size [string length $nm] if {$size > $_max_label_width} { set _max_label_width $size --- 80,89 ---- set _reg_display_list {} set _register(hidden) {} ! set regs [gdb_reginfo group $_group] ! foreach r [gdb_reginfo name -numbers $regs] { set nm [lindex $r 0] set rn [lindex $r 1] set size [string length $nm] if {$size > $_max_label_width} { set _max_label_width $size *************** itcl::body RegWin::_build_win {} { *** 202,218 **** $itk_component(hscroll) configure -command [code $itk_component(table) xview] $itk_component(vscroll) configure -command [code $itk_component(table) yview] - grid $itk_component(table) -row 0 -column 0 -sticky news - grid $itk_component(vscroll) -row 0 -column 1 -sticky ns - grid $itk_component(hscroll) -row 1 -column 0 -sticky ew - grid columnconfigure $itk_interior 0 -weight 1 - grid rowconfigure $itk_interior 0 -weight 1 - - # Add sizebox for windows - if {[string compare $::tcl_platform(platform) "windows"] == 0} { - ide_sizebox $itk_interior.sbox - place $itk_interior.sbox -relx 1.0 -rely 1.0 -anchor se - } # Create/configure tags for various display styles # normal - the "normal" display style --- 202,207 ---- *************** itcl::body RegWin::_build_win {} { *** 235,305 **** $itk_component(table) tag raise edit $itk_component(table) tag raise sel ! # Register to receive notifications on preference changes ! # (Note that these are not supported by the preference dialogs, but...) ! #foreach opt [list highlight select header] { ! # pref add_hook gdb/font/${opt}_fg [code $this _prefs_changed] ! # pref add_hook gdb/font/${opt}_bg [code $this _prefs_changed] ! #} ! ! # Create toplevel menubar ! itk_component add menubar { ! menu $itk_interior.m -tearoff false ! } { ! ignore -tearoff } ! $_top configure -menu $itk_component(menubar) ! ! # Create register menu ! itk_component add reg_menu { ! menu $itk_component(menubar).reg -tearoff false \ ! -postcommand [code $this _post_menu] ! } { ! ignore -tearoff ! } ! $itk_component(menubar) add cascade -menu $itk_component(reg_menu) \ ! -label "Register" -underline 0 ! # Create register->format cascade menu ! itk_component add reg_format { ! menu $itk_component(reg_menu).format -tearoff false ! } { ! ignore -tearoff } - $itk_component(reg_menu) add cascade -menu $itk_component(reg_format) \ - -label "Format" -underline 0 - $itk_component(reg_format) add radio -label "Hex" -value x \ - -underline 0 -state disabled -command [code $this update dummy] - $itk_component(reg_format) add radio -label "Decimal" -value d \ - -underline 0 -state disabled -command [code $this update dummy] - $itk_component(reg_format) add radio -label "Unsigned" -value u \ - -underline 0 -state disabled -command [code $this update dummy] - $itk_component(reg_format) add radio -label "Floating Point" -value f \ - -underline 0 -state disabled -command [code $this update dummy] - $itk_component(reg_menu) add command -label "Open Memory Window" \ - -underline 7 -state disabled - set _menuitems(open_memory) [$itk_component(reg_menu) index last] - $itk_component(reg_menu) add command -label "Add to Watch" \ - -underline 7 -state disabled - set _menuitems(add_to_watch) [$itk_component(reg_menu) index last] - $itk_component(reg_menu) add separator - $itk_component(reg_menu) add command -label "Remove from Display" \ - -underline 0 -state disabled - set _menuitems(remove_from_display) [$itk_component(reg_menu) index last] - $itk_component(reg_menu) add command -label "Display all Registers" \ - -underline 0 -state disabled -command [code $this _display_all] - set _menuitems(display_all_registers) [$itk_component(reg_menu) index last] - $itk_component(reg_menu) add separator - $itk_component(reg_menu) add command -label "Close" \ - -underline 0 -command [code delete object $this] - # Add popup menu - we populate it in the event handler itk_component add popup { menu $itk_interior.pop -tearoff 0 } {} - $itk_component(popup) configure \ - -disabledforeground [$itk_component(menubar) cget -fg] } # ------------------------------------------------------------------ --- 224,256 ---- $itk_component(table) tag raise edit $itk_component(table) tag raise sel ! itk_component add frame { ! frame $itk_interior.m } ! iwidgets::optionmenu $itk_component(frame).opt -labeltext "Group:" \ ! -labelpos w -command [code $this _select_group] ! eval $itk_component(frame).opt insert end [gdb_reginfo grouplist] ! $itk_component(frame).opt select "all" ! ! pack $itk_component(frame).opt -anchor nw ! grid $itk_component(frame) -row 0 -columnspan 2 -sticky news ! grid $itk_component(table) -row 1 -column 0 -sticky news ! grid $itk_component(vscroll) -row 1 -column 1 -sticky ns ! grid $itk_component(hscroll) -row 2 -column 0 -sticky ew ! grid columnconfigure $itk_interior 0 -weight 1 ! grid rowconfigure $itk_interior 0 -weight 0 ! grid rowconfigure $itk_interior 1 -weight 1 ! # Add sizebox for windows ! if {[string compare $::tcl_platform(platform) "windows"] == 0} { ! ide_sizebox $itk_interior.sbox ! place $itk_interior.sbox -relx 1.0 -rely 1.0 -anchor se } # Add popup menu - we populate it in the event handler itk_component add popup { menu $itk_interior.pop -tearoff 0 } {} } # ------------------------------------------------------------------ *************** itcl::body RegWin::_layout_table {} { *** 404,415 **** incr x 2 } } - - # Update register menu - if {[llength $_register(hidden)] != 0} { - $itk_component(reg_menu) entryconfigure $_menuitems(display_all_registers) \ - -state normal - } } # ------------------------------------------------------------------ --- 355,360 ---- *************** itcl::body RegWin::_but3 {x y X Y} { *** 637,642 **** --- 582,592 ---- $itk_component(popup) add command \ -label "Help" -command {open_help register.html} + # Close + $itk_component(popup) add separator + $itk_component(popup) add command -label "Close" \ + -underline 0 -command [code delete object $this] + tk_popup $itk_component(popup) $X $Y } } *************** itcl::body RegWin::_delete_from_display *** 659,667 **** # Relayout table _layout_table - - $itk_component(reg_menu) entryconfigure $_menuitems(display_all_registers) \ - -state normal } } --- 609,614 ---- *************** itcl::body RegWin::_delete_from_display *** 674,689 **** # ------------------------------------------------------------------ itcl::body RegWin::_display_all {} { - $itk_component(reg_menu) entryconfigure $_menuitems(display_all_registers) \ - -state disabled - # Unhide all hidden registers foreach r $_register(hidden) { pref setd gdb/reg/[gdb_reginfo name $r] {} } - set _register(hidden) {} - # Note which register is active and restore it if {[catch {$itk_component(table) index active} cell]} { set active {} --- 621,631 ---- *************** itcl::body RegWin::_move {direction} { *** 815,893 **** } } - # ------------------------------------------------------------------ - # NAME: private method RegWin::_post_menu - # DESCRIPTION: Configures the Register menu before it is posted - # - # ARGUMENTS: None - # RETURNS: Nothing - # ------------------------------------------------------------------ - itcl::body RegWin::_post_menu {} { - global gdb_running - - # Configure the menu for the active cell - if {![catch {$itk_component(table) index active} cell] - && [info exists _register($cell)] && $gdb_running} { - - set code $_type($_register($cell),code) - - $itk_component(reg_menu) entryconfigure $_menuitems(remove_from_display) \ - -state normal -command [code $this _delete_from_display $_register($cell)] - - set state normal - - for {set i 0} {$i <= [$itk_component(reg_format) index end]} {incr i} { - $itk_component(reg_format) entryconfigure $i \ - -state $state \ - -variable [scope _format($_register($cell))] \ - -command [code $this _change_format $_register($cell)] - } - - if {$code == "float"} { - # disable decimal and unsigned - $itk_component(reg_format) entryconfigure 1 -state disabled - $itk_component(reg_format) entryconfigure 2 -state disabled - } elseif {$code == "int"} { - # disable float - $itk_component(reg_format) entryconfigure 3 -state disabled - } - - # memory window - if {$code == "int"} { - $itk_component(reg_menu) entryconfigure $_menuitems(open_memory) \ - -state normal -command [code $this _open_memory $_register($cell)] - } else { - $itk_component(reg_menu) entryconfigure $_menuitems(open_memory) \ - -state disabled - } - - # add to watch - $itk_component(reg_menu) entryconfigure $_menuitems(add_to_watch) \ - -state normal -command [code $this _add_to_watch $_register($cell)] - - } else { - # Disable everything - $itk_component(reg_menu) entryconfigure $_menuitems(remove_from_display) \ - -state disabled -command {} - - for {set i 0} {$i <= [$itk_component(reg_format) index end]} {incr i} { - $itk_component(reg_format) entryconfigure $i -state disabled \ - -variable {} - } - - $itk_component(reg_menu) entryconfigure $_menuitems(open_memory) \ - -state disabled -command {} - - $itk_component(reg_menu) entryconfigure $_menuitems(add_to_watch) \ - -state disabled -command {} - - if {0} { - $itk_component(reg_menu) entryconfigure $_menuitems(edit) \ - -state disabled -command {} - } - } - } - # ------------------------------------------------------------------ # NAME: private method RegWin::_select_cell --- 757,762 ---- *************** itcl::body RegWin::_change_format {rn {n *** 1020,1025 **** --- 889,914 ---- # ------------------------------------------------------------------ itcl::body RegWin::_update_register {rn} { set _data($_cell($rn)) [_get_value $rn] + } + + # ------------------------------------------------------------------ + # NAME: private_method RegWin::_select_group + # DESCRIPTION: Changes the register group. Callback + # + # ARGUMENTS: + # + # RETURNS: Nothing + # ------------------------------------------------------------------ + itcl::body RegWin::_select_group {} { + set gr [$itk_component(frame).opt get] + if {$gr == ""} { + return + } + set _group $gr + # Clear gdb's change list + catch {gdb_reginfo changed} + update "" + _layout_table } Index: library/regwin.ith =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/library/regwin.ith,v retrieving revision 1.10 diff -p -r1.10 regwin.ith *** library/regwin.ith 15 Oct 2002 21:19:51 -0000 1.10 --- library/regwin.ith 17 Dec 2002 20:27:27 -0000 *************** itcl::class RegWin { *** 28,33 **** --- 28,36 ---- # Mapping of table cell index to register number variable _register + # the register group that is displayed + variable _group "all" + # Mapping of register number to table cell index. "hidden" if # the register was "removed" from the display. variable _cell *************** itcl::class RegWin { *** 74,80 **** method _edit {x y} method _move {direction} method _open_memory {rn} ! method _post_menu {} method _select_cell {cell} method _unedit {} --- 77,83 ---- method _edit {x y} method _move {direction} method _open_memory {rn} ! method _select_group {} method _select_cell {cell} method _unedit {}