* [PATCH] Report errors in MemWin
@ 2001-05-22 12:05 Keith Seitz
0 siblings, 0 replies; only message in thread
From: Keith Seitz @ 2001-05-22 12:05 UTC (permalink / raw)
To: Insight Maling List
Hi,
If gdb was unable to set memory in the memory window, it would silently
reset the result -- no error was posted.
This patch adds an error dialog to inform the user that the write failed.
Keith
ChangeLog:
2001-05-22 Keith Seitz <keiths@cygnus.com>
* memwin.ith (error_dialog): Declare public method.
* memwin.itb (error_dialog): Define.
(edit): When attempting to set memory, post an error dialog
if gdb told us an error occurred while writing the memory.
Patch:
Index: library/memwin.itb
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/memwin.itb,v
retrieving revision 1.2
diff -u -p -r1.2 memwin.itb
--- memwin.itb 2001/03/15 18:31:38 1.2
+++ memwin.itb 2001/05/22 19:02:27
@@ -289,7 +289,14 @@ body MemWin::edit { cell } {
foreach c [split $val ""] {
if {$c != $ascii_char} {
if {$c == "'"} {set c "\\'"}
- catch {gdb_cmd "set *(char *)($addr) = '$c'"}
+ set err [catch {gdb_cmd "set *(char *)($addr) = '$c'"} res]
+ if {$err} {
+ error_dialog [winfo toplevel $itk_interior] $res
+
+ # reset value
+ set ${this}_memval($row,$col) $saved_value
+ return
+ }
}
incr addr
}
@@ -315,7 +322,15 @@ body MemWin::edit { cell } {
set addr [expr {$current_addr + $bytes_per_row * $row + $size * $col}]
#debug " edit $row,$col [format "%x" $addr] = $val"
#set memory
- catch {gdb_cmd "set *($type($size) *)($addr) = $val"} res
+ set err [catch {gdb_cmd "set *($type($size) *)($addr) = $val"} res]
+ if {$err} {
+ error_dialog [winfo toplevel $itk_interior] $res
+
+ # reset value
+ set ${this}_memval($row,$col) $saved_value
+ return
+ }
+
# read it back
# FIXME - HACK ALERT - This call causes trouble with remotes on Windows.
# This routine is in fact called from within an idle handler triggered by
@@ -768,4 +783,18 @@ body MemWin::memMoveCell {w x y} {
if { $r < 0 } { set r 0 }
$w activate $r,$c
$w see active
+}
+
+# ------------------------------------------------------------
+# PUBLIC METHOD: error_dialog - Open and error dialog.
+# Arguments:
+# msg - The message to display in the dialog
+# modality - The dialog modailty. Default: task
+# type - The dialog type (tk_messageBox).
+# Default: ok
+# ------------------------------------------------------------
+body MemWin::error_dialog {msg {modality task} {type ok}} {
+ set parent [winfo toplevel [namespace tail $this]]
+ tk_messageBox -icon error -title Error -type $type \
+ -modal $modality -message $msg -parent $parent
}
Index: library/memwin.ith
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/memwin.ith,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 memwin.ith
--- memwin.ith 2000/02/07 00:19:42 1.1.1.1
+++ memwin.ith 2001/05/22 19:02:27
@@ -74,5 +74,6 @@ class MemWin {
method do_popup {x y}
method goto {addr}
method memMoveCell {w x y}
+ method error_dialog {msg {modality task} {type ok}}
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-05-22 12:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-22 12:05 [PATCH] Report errors in MemWin Keith Seitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).