This is the mail archive of the insight@sourceware.org mailing list for the Insight project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch for Memory Window of Insight


Hi,
Please find below a patch for Insight (memwin.itb). It addresses the following problems of Memory Window:

1. On selecting the "Go To" option in pop-up menu of Memory Window with no active cell in table we get an error: 'wrong # args: should be ".memwin0.memwin goto addr"'. This patch handles that error.

2. If the user selects a cell, clears the contents of that cell i.e makes that cell blank and clicks on "Go To" in pop-up menu then that too gives an error. The error is same as mentioned in (1). This patch handles that error.

3. Select Octal/Signed Decimal/Unsigned Decimal Format by clicking "Preferences" in pop-up menu or from Addresses menu.
Now, select a cell in the table of Memory Window, edit the value of that cell and move to another cell. You will notice that the previous cell is updated but data is always Hexadecimal irrespective of the selected format (Octal,Signed Decimal,Unsigned Decimal,Hexadecimal etc.). This patch will now display the data in selected format for Octal, Signed Decimal, Unsigned Decimal and Hexadecimal Format.
Note: Binary Format still needs to be fixed.

4. When user moves to a new cell leaving the previous cell blank i.e no data then we get an error: 'expected integer but got ""'. This patch will handle that error.

5. Select any cell, type invalid values in that, say "xyz". Use the Go To option in pop-up menu. Memory window cells are disabled but at the top left of Memory Window the address is shown as "xyz". Now if you try to increment or decrement the address using the widget (Spinner Widget - Arrows) at the top left of Memory Window then Insight crashes. This patch handles that problem.

For gdb/gdbtk/ChangeLog:
============================================gdb/gdbtk/ChangeLog===========================================================
2005-09-01 Aditya Katti  <adityak@kpitcummins.com>

  * library/memwin.itb (do_popup):
  * library/memwin.itb (goto): Validates Address
  * library/memwin.itb (edit): Validates Address, Changes format of "val" to selected format for Octal, Signed Decimal, Unsigned Decimal and Hexadecimal Formats.
  
==========================================================================================================================



For gdb/gdbtk/library/memwin.itb:
========================================gdb/gdbtk/library/memwin.itb======================================================

*** insight-6.1/gdb/gdbtk/library/memwin.itb.orig	Fri Sep  2 15:40:00 2005
--- insight-6.1/gdb/gdbtk/library/memwin.itb	Wed Sep 14 12:16:20 2005
***************
*** 274,278 ****
    if {$col == $Numcols} { 
      # editing the ASCII field
!     set addr [gdb_incr_addr $current_addr [expr {$bytes_per_row * $row}]]
      set start_addr $addr
  
--- 274,283 ----
    if {$col == $Numcols} { 
      # editing the ASCII field
!     # Check whether address is valid using format
!     if { [catch {format "%x" $current_addr}] } {
!       return
!     } else {
!       set addr [gdb_incr_addr $current_addr [expr {$bytes_per_row * $row}]]
!     }
      set start_addr $addr
  
***************
*** 306,317 ****
      return
    }
! 
!   # calculate address based on row and column
!   set addr [gdb_incr_addr $current_addr [expr {$bytes_per_row * $row + $size * $col}]]
    #debug "  edit $row,$col         $addr = $val"
  
    # Pad the value with zeros, if necessary
    set s [expr {$size * 2}]
!   set val [format "0x%0${s}x" $val]
  
    # set memory
--- 311,329 ----
      return
    }
!   
!   # Check whether address is valid using format
!   if { [catch {format "%x" $current_addr}] } {
!     return
!   } else {
!     # calculate address based on row and column
!     set addr [gdb_incr_addr $current_addr [expr {$bytes_per_row * $row + $size * $col}]]
!   }
    #debug "  edit $row,$col         $addr = $val"
  
    # Pad the value with zeros, if necessary
    set s [expr {$size * 2}]
!   if { [catch {set val [format "0x%0${s}x" $val]}] } {
!     return
!   }
  
    # set memory
***************
*** 338,341 ****
--- 350,364 ----
    set val [string trimright $val]
    set val [string trimleft $val]
+   if { $format == "o" } {
+     # Selected Format is Octal
+     catch { set val [format "0%o" $val]}
+   }  elseif { $format == "u" } {
+     # Selected Format is Unsigned Decimal
+     catch { set val [format "%u" $val]}
+   }  elseif { $format == "d" } {
+     # Selected Format is Signed Decimal
+     catch { set val [format "%d" $val]}
+   }
+   
    set ${this}_memval($row,$col) $val
  }
***************
*** 544,550 ****
      return
    }
    set old_addr $current_addr
!   set current_addr [gdb_incr_addr $current_addr [expr {$bytes_per_row * $num}]]
! 
    # A memory address less than zero is probably not a good thing...
    #
--- 567,580 ----
      return
    }
+   
+   if { [catch {format "%x" $current_addr}] } {
+     return
+   } 
+   
    set old_addr $current_addr
!   if { [catch {set current_addr [gdb_incr_addr $current_addr [expr {$bytes_per_row * $num}]] } ] } {
!     return
!   }
!   
    # A memory address less than zero is probably not a good thing...
    #
***************
*** 662,666 ****
      -command [code $this _update_address 1]
    $itk_component(table).menu add command -label "Go To [$itk_component(table) curvalue]" -underline 0 \
!     -command "$this goto [$itk_component(table) curvalue]"
    $itk_component(table).menu add command -label "Open New Window at [$itk_component(table) curvalue]" -underline 0 \
      -command [list ManagedWin::open MemWin -force -addr_exp [$itk_component(table) curvalue]]
--- 692,696 ----
      -command [code $this _update_address 1]
    $itk_component(table).menu add command -label "Go To [$itk_component(table) curvalue]" -underline 0 \
!     -command [code $this goto [$itk_component(table) curvalue]]
    $itk_component(table).menu add command -label "Open New Window at [$itk_component(table) curvalue]" -underline 0 \
      -command [list ManagedWin::open MemWin -force -addr_exp [$itk_component(table) curvalue]]
***************
*** 675,682 ****
  # ------------------------------------------------------------------
  itcl::body MemWin::goto { addr } {
!   set current_addr $addr
!   $itk_interior.f.cntl delete 0 end
!   $itk_interior.f.cntl insert end $addr
!   _update_address 1
  }
  
--- 705,726 ----
  # ------------------------------------------------------------------
  itcl::body MemWin::goto { addr } {
!   set goto_error_flag "no_error"
!   # Check whether address is valid using format
!   if { [catch {set temp [format "%x" $addr]}]} {
!     if { [catch {set temp [format "%f" $addr]}]} {
!       set goto_error_flag "error" 
!     }
!   } else {
!     set temp 0x$temp
!   }
!   
!   if { $goto_error_flag == "error"} {
!     error_dialog "Invalid Address $addr"
!   } else {
!     set current_addr $temp
!     $itk_interior.f.cntl delete 0 end
!     $itk_interior.f.cntl insert end $temp
!     _update_address 1   
!   }
  }
  
=======================================================End Of Patch======================================================


Regards,
Aditya Katti
KPIT Cummins Infosystems Limited
Pune, INDIA



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]