From mboxrd@z Thu Jan 1 00:00:00 1970 From: Keith Seitz To: Insight Maling List Subject: [PATCH] Report errors in MemWin Date: Tue, 22 May 2001 12:05:00 -0000 Message-id: X-SW-Source: 2001-q2/msg00291.html 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 * 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}} } }