summaryrefslogtreecommitdiff
path: root/gdb/gdbtk
diff options
context:
space:
mode:
authorMartin Hunt <hunt@redhat.com>2002-12-17 20:29:12 +0000
committerMartin Hunt <hunt@redhat.com>2002-12-17 20:29:12 +0000
commit5301be4cd9b0c1571a3b6cb289e0e3b7a2a04fcb (patch)
tree923a1bd4c5f2410308ef84dc39b42c44216a534c /gdb/gdbtk
parentde9fc5150d3b76bc58bf8a6695cd9ce76bbde866 (diff)
downloadgdb-5301be4cd9b0c1571a3b6cb289e0e3b7a2a04fcb.tar.gz
2002-12-17 Martin M. Hunt <hunt@redhat.com>
* library/regwin.itb (_load_prefs): Get list of registers from the group name. (_build_win): Remove old menu system. Replace with an optionmenu that contains all the valid group names for this architecture. (_layout_table): No need to update old menu. (_but3): Add "Close" to popup menu. (_delete_from_display): No need to update old menu. (_display_all): Ditto. (_post_menu): Deleted. (_select_group): New method. Callback for group optionmenu. * library/regwin.ith: New private variable _group. New private method _select_group. Removed _post_menu. * generic/gdbtk-register.c: Include reggroups.h. (gdb_register_info): Add "group" and "grouplist". (gdb_regformat): Fix Tcl_WrongNumArgs call so it doesn't crash. (gdb_reggrouplist): New function. Returns the names of the register groups. (gdb_reggroup): New function. Returns the register numbers of the registers in a group.
Diffstat (limited to 'gdb/gdbtk')
-rw-r--r--gdb/gdbtk/ChangeLog24
-rw-r--r--gdb/gdbtk/generic/gdbtk-register.c92
-rw-r--r--gdb/gdbtk/library/regwin.itb203
-rw-r--r--gdb/gdbtk/library/regwin.ith5
4 files changed, 161 insertions, 163 deletions
diff --git a/gdb/gdbtk/ChangeLog b/gdb/gdbtk/ChangeLog
index cb613270bbe..9bcbebbc0b6 100644
--- a/gdb/gdbtk/ChangeLog
+++ b/gdb/gdbtk/ChangeLog
@@ -1,3 +1,27 @@
+2002-12-17 Martin M. Hunt <hunt@redhat.com>
+
+ * library/regwin.itb (_load_prefs): Get list of registers from
+ the group name.
+ (_build_win): Remove old menu system. Replace with an optionmenu
+ that contains all the valid group names for this architecture.
+ (_layout_table): No need to update old menu.
+ (_but3): Add "Close" to popup menu.
+ (_delete_from_display): No need to update old menu.
+ (_display_all): Ditto.
+ (_post_menu): Deleted.
+ (_select_group): New method. Callback for group optionmenu.
+
+ * library/regwin.ith: New private variable _group.
+ New private method _select_group. Removed _post_menu.
+
+ * generic/gdbtk-register.c: Include reggroups.h.
+ (gdb_register_info): Add "group" and "grouplist".
+ (gdb_regformat): Fix Tcl_WrongNumArgs call so it doesn't crash.
+ (gdb_reggrouplist): New function. Returns the names of the
+ register groups.
+ (gdb_reggroup): New function. Returns the register numbers of the
+ registers in a group.
+
2002-12-06 Andrew Cagney <ac131313@redhat.com>
* generic/gdbtk-cmds.c (gdb_update_mem): Don't add a 0x prefix.
diff --git a/gdb/gdbtk/generic/gdbtk-register.c b/gdb/gdbtk/generic/gdbtk-register.c
index 8a53b3b39ed..6466407ae54 100644
--- a/gdb/gdbtk/generic/gdbtk-register.c
+++ b/gdb/gdbtk/generic/gdbtk-register.c
@@ -21,6 +21,7 @@
#include "defs.h"
#include "frame.h"
#include "regcache.h"
+#include "reggroups.h"
#include "value.h"
#include "target.h"
#include "gdb_string.h"
@@ -43,6 +44,9 @@ static int map_arg_registers (Tcl_Interp *, int, Tcl_Obj **,
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;
@@ -117,13 +121,14 @@ gdb_register_info (ClientData clientData, Tcl_Interp *interp, int objc,
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 };
+ 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 [regnum1 ... regnumN]");
+ Tcl_WrongNumArgs (interp, 1, objv, "name|size|value|type|format|groups [regnum1 ... regnumN]");
return TCL_ERROR;
}
@@ -180,6 +185,12 @@ gdb_register_info (ClientData clientData, Tcl_Interp *interp, int objc,
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;
}
@@ -467,7 +478,7 @@ gdb_regformat (ClientData clientData, Tcl_Interp *interp,
if (objc != 3)
{
- Tcl_WrongNumArgs (interp, 1, objv, "regno type format");
+ Tcl_WrongNumArgs (interp, 0, objv, "gdb_reginfo regno type format");
return TCL_ERROR;
}
@@ -488,3 +499,74 @@ gdb_regformat (ClientData clientData, Tcl_Interp *interp,
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;
+}
+
diff --git a/gdb/gdbtk/library/regwin.itb b/gdb/gdbtk/library/regwin.itb
index 29518db3e49..0cb1962627f 100644
--- a/gdb/gdbtk/library/regwin.itb
+++ b/gdb/gdbtk/library/regwin.itb
@@ -80,10 +80,10 @@ itcl::body RegWin::_load_prefs {} {
set _reg_display_list {}
set _register(hidden) {}
- foreach r [gdb_reginfo name -numbers] {
+ 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
@@ -202,17 +202,6 @@ itcl::body RegWin::_build_win {} {
$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
@@ -235,71 +224,33 @@ itcl::body RegWin::_build_win {} {
$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
+ itk_component add frame {
+ frame $itk_interior.m
}
- $_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
+ 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
- # Create register->format cascade menu
- itk_component add reg_format {
- menu $itk_component(reg_menu).format -tearoff false
- } {
- ignore -tearoff
+ # 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
}
- $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]
}
# ------------------------------------------------------------------
@@ -404,12 +355,6 @@ itcl::body RegWin::_layout_table {} {
incr x 2
}
}
-
- # Update register menu
- if {[llength $_register(hidden)] != 0} {
- $itk_component(reg_menu) entryconfigure $_menuitems(display_all_registers) \
- -state normal
- }
}
# ------------------------------------------------------------------
@@ -637,6 +582,11 @@ itcl::body RegWin::_but3 {x y X Y} {
$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
}
}
@@ -659,9 +609,6 @@ itcl::body RegWin::_delete_from_display {rn} {
# Relayout table
_layout_table
-
- $itk_component(reg_menu) entryconfigure $_menuitems(display_all_registers) \
- -state normal
}
}
@@ -674,16 +621,11 @@ itcl::body RegWin::_delete_from_display {rn} {
# ------------------------------------------------------------------
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 {}
@@ -815,79 +757,6 @@ itcl::body RegWin::_move {direction} {
}
}
-# ------------------------------------------------------------------
-# 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
@@ -1022,6 +891,26 @@ 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
+}
+
#
# Gdb Events
diff --git a/gdb/gdbtk/library/regwin.ith b/gdb/gdbtk/library/regwin.ith
index f44ca9e1f23..47be705f2f9 100644
--- a/gdb/gdbtk/library/regwin.ith
+++ b/gdb/gdbtk/library/regwin.ith
@@ -28,6 +28,9 @@ itcl::class RegWin {
# 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
@@ -74,7 +77,7 @@ itcl::class RegWin {
method _edit {x y}
method _move {direction}
method _open_memory {rn}
- method _post_menu {}
+ method _select_group {}
method _select_cell {cell}
method _unedit {}