summaryrefslogtreecommitdiff
path: root/gdb/gdbtk
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2006-01-24 01:32:26 +0000
committerKeith Seitz <keiths@redhat.com>2006-01-24 01:32:26 +0000
commitd02c820add1033ada5a016233c7e8713ee086c87 (patch)
tree548aee4a73e26954d2e66be24479f1aa5ecf7113 /gdb/gdbtk
parent2a98c808afe7e6e4cd0f4ddd1f0eb3c6a494038f (diff)
downloadgdb-d02c820add1033ada5a016233c7e8713ee086c87.tar.gz
From Andrew Stubbs <andrew.stubbs@st.com>:
* library/mempref.itb (MemPref::constructor): Allow the Byte Per Row combo box to accept arbitrary values. (MemPref::set_bytes_per_row): Validate the new value; reject invalid entries and round up to a multiple of the word size. (MemPref::apply): Read the value from the text box even if the user has not pressed return. (MemPref::enable_format): Ensure the bytes per row value is still valid. (MemPref::disable_format): Likewise. * library/mempref.ith (MemPref): Add $gbprlist. * library/help/memory.html: Update.
Diffstat (limited to 'gdb/gdbtk')
-rw-r--r--gdb/gdbtk/ChangeLog14
-rw-r--r--gdb/gdbtk/library/help/memory.html6
-rw-r--r--gdb/gdbtk/library/mempref.itb56
-rw-r--r--gdb/gdbtk/library/mempref.ith1
4 files changed, 66 insertions, 11 deletions
diff --git a/gdb/gdbtk/ChangeLog b/gdb/gdbtk/ChangeLog
index bd418033403..f671b68a0bd 100644
--- a/gdb/gdbtk/ChangeLog
+++ b/gdb/gdbtk/ChangeLog
@@ -1,6 +1,20 @@
2006-01-23 Keith Seitz <keiths@redhat.com>
From Andrew Stubbs <andrew.stubbs@st.com>:
+ * library/mempref.itb (MemPref::constructor): Allow the Byte Per Row
+ combo box to accept arbitrary values.
+ (MemPref::set_bytes_per_row): Validate the new value; reject invalid
+ entries and round up to a multiple of the word size.
+ (MemPref::apply): Read the value from the text box even if the user
+ has not pressed return.
+ (MemPref::enable_format): Ensure the bytes per row value is still valid.
+ (MemPref::disable_format): Likewise.
+ * library/mempref.ith (MemPref): Add $gbprlist.
+ * library/help/memory.html: Update.
+
+2006-01-23 Keith Seitz <keiths@redhat.com>
+
+ From Andrew Stubbs <andrew.stubbs@st.com>:
* library/helpviewer.tcl (open_help): Add firefox and opera to the
browser list used to display help.
diff --git a/gdb/gdbtk/library/help/memory.html b/gdb/gdbtk/library/help/memory.html
index 492974f5478..afa2fe8fb47 100644
--- a/gdb/gdbtk/library/help/memory.html
+++ b/gdb/gdbtk/library/help/memory.html
@@ -232,7 +232,9 @@ of bytes. By default, the Memory Window shows 128 bytes of memory.
Miscellaneous memory preferences include the option to display the ASCII
representation of the memory, including what character to use for non-ASCII
bytes (the "control" character). Additionally, users may specify the number
-of bytes per row, either four, eight, sixteen, or thirty-two. The default
-is sixteen bytes per row.
+of bytes per row, either by typing a number into the box or by choosing one
+from the list. The default is sixteen bytes per row. If the entered value is
+not a multiple of the cell size then it will be automatically rounded up. The
+maximum permitted value is 150 (before rounding).
</BODY>
</HTML>
diff --git a/gdb/gdbtk/library/mempref.itb b/gdb/gdbtk/library/mempref.itb
index 4a73aeaf69d..85937c7aabd 100644
--- a/gdb/gdbtk/library/mempref.itb
+++ b/gdb/gdbtk/library/mempref.itb
@@ -1,5 +1,5 @@
# Memory display preferences window for Insight.
-# Copyright (C) 1998, 1999, 2002, 2003 Red Hat
+# Copyright (C) 1998, 1999, 2002, 2003, 2006 Red Hat
#
# 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
@@ -41,6 +41,7 @@ itcl::body MemPref::constructor {args} {
set gnumbytes $numbytes
set gbpr $bpr
+ set gbprlist [list 4 8 16 32 64 128]
set gascii $ascii
set gascii_char $ascii_char
@@ -153,14 +154,11 @@ itcl::body MemPref::build_win {} {
label $fr.2.l -text "Bytes Per Row "
set Widgets(b-bytes_per_row) [::combobox::combobox $fr.2.c \
-command [code $this set_bytes_per_row] \
- -width 4 -editable 0 -font global/fixed \
+ -width 4 -editable 1 -font global/fixed \
-bg $::Colors(textbg)]
- $fr.2.c list insert end 4
- $fr.2.c list insert end 8
- $fr.2.c list insert end 16
- $fr.2.c list insert end 32
- $fr.2.c list insert end 64
- $fr.2.c list insert end 128
+ foreach item $gbprlist {
+ $fr.2.c list insert end $item
+ }
$fr.2.c configure -value $gbpr
pack $fr.2.l -side left -anchor e
@@ -264,7 +262,36 @@ itcl::body MemPref::check_numbytes {var index mode} {
# METHOD: set_bytes_per_row - combobox callback to set the bytes per row
# ------------------------------------------------------------------
itcl::body MemPref::set_bytes_per_row {w value} {
- set gbpr $value
+ if {[string is integer -strict $value] && [expr {$value != 0}]} {
+ # The input is a value number.
+ set gbpr $value
+ set gbpr [string trim $gbpr]
+
+ # Too high a number will cause a Segmentation fault.
+ if {[expr {$gbpr > 150}]} {set gbpr 150}
+
+ # Insert the value into the combo box list, if it isn't there already.
+ set found [lsearch $gbprlist $gbpr]
+
+ if {$found == -1} {
+ lappend gbprlist $gbpr
+ $Widgets(b-bytes_per_row) list insert end $gbpr
+ }
+
+ set s $gsize
+ if {$s == 3} {set s 4}
+ if {$s == 5} {set s 8}
+ set rem [expr {$gbpr % $s}]
+ if {$rem != 0} {
+ # The bytes-per-row is not a multiple of the size.
+ set gbpr [expr {$gbpr + ($s - $rem)}]
+ }
+ }
+
+ # Set the display to the new value. This may be different if the input
+ # was zero or not a number, or if the user entered any whitespace.
+ $Widgets(b-bytes_per_row) delete 0 end
+ $Widgets(b-bytes_per_row) insert end $gbpr
}
# ------------------------------------------------------------------
@@ -318,6 +345,9 @@ itcl::body MemPref::apply {} {
}
}
+ # Ensure the value has been read from the text field.
+ set_bytes_per_row "" [$Widgets(b-bytes_per_row) get]
+
# pass all the changed values back to parent
debug "$win configChange -size $size -numbytes $numbytes \
-format $format -ascii $gascii \
@@ -338,6 +368,10 @@ itcl::body MemPref::apply {} {
# METHOD: enable_format - turn on the format radio buttons
# ------------------------------------------------------------------
itcl::body MemPref::enable_format {} {
+ # First ensure bytes per row is a multiple of the size.
+ # Use the value of the widget, not $gbpr to ensure the typed value is kept.
+ set_bytes_per_row "" [$Widgets(b-bytes_per_row) get]
+
if {!$format_disabled} {
return
}
@@ -353,6 +387,10 @@ itcl::body MemPref::enable_format {} {
# METHOD: disable_format - turn off the format radio buttons
# ------------------------------------------------------------------
itcl::body MemPref::disable_format {} {
+ # First ensure bytes per row is a multiple of the size.
+ # Use the value of the widget, not $gbpr to ensure the typed value is kept.
+ set_bytes_per_row "" [$Widgets(b-bytes_per_row) get]
+
if {$format_disabled} {
return
}
diff --git a/gdb/gdbtk/library/mempref.ith b/gdb/gdbtk/library/mempref.ith
index 9c4b8c916f9..d1f5f723949 100644
--- a/gdb/gdbtk/library/mempref.ith
+++ b/gdb/gdbtk/library/mempref.ith
@@ -47,6 +47,7 @@ itcl::class MemPref {
variable gformat
variable gnumbytes
variable gbpr
+ variable gbprlist
variable gascii
variable gascii_char
variable gvar