This is the mail archive of the insight@sources.redhat.com 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]

[PATCH] Stop internal_error on memwin


Hi,

Recent changes to convert Insight from using parse_and_eval_* to
string_to_core_addr and core_addr_to_string is causing string_to_core_addr
to call internal_error because error conditions can cause strings like "No
registers." to show up in the string to be converted.

Memwin needs to be partially rewritten to clean up this error-handling
mess, but for now, this patch will prevent the internal_errors.

Keith

ChangeLog
2001-11-01  Keith Seitz  <keiths@redhat.com>

	* library/memwin.itb (update_addr): Evaluate the address
	to be sent to gdb_get_mem to prevent passing error strings
	to string_to_coreaddr in gdb_get_mem.

Patch
Index: library/memwin.itb
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/memwin.itb,v
retrieving revision 1.10
diff -u -p -r1.10 memwin.itb
--- memwin.itb	2001/08/09 20:43:54	1.10
+++ memwin.itb	2001/11/01 20:45:21
@@ -480,7 +480,7 @@ body MemWin::update_address { {ae ""} }
 	return
       }
     }
-  } elseif {[string match {\$*} $addr_exp]} {
+  } elseif {[regexp {\$[a-zA-Z_]} $addr_exp]} {
     # Looks like a local variable
     catch {gdb_eval "$addr_exp"} current_addr
     if {$current_addr == "No registers.\n"} {
@@ -493,7 +493,7 @@ body MemWin::update_address { {ae ""} }
     }
   } else {
     # something really strange, like "0.1" or ""
-    BadExpr "Can't Evaluate \"$addr_expr\""
+    BadExpr "Can't Evaluate \"$addr_exp\""
     return
   }

@@ -581,46 +581,49 @@ body MemWin::update_addr {} {
     set asc ""
   }

-  set retVal [catch {gdb_get_mem $addr $format \
-		       $size $nb $bytes_per_row $asc} vals]
+  # Last chance to verify addr
+  if {![catch {gdb_eval $addr}]} {
+    set retVal [catch {gdb_get_mem $addr $format \
+			 $size $nb $bytes_per_row $asc} vals]

-  if {$retVal || [llength $vals] == 0}  {
-    # FIXME gdb_get_mem does not always return an error when addr is invalid.
-    BadExpr "Couldn't get memory at address: \"$addr\""
-    gdbtk_idle
-    debug "gdb_get_mem returned return code: $retVal and value: \"$vals\""
-    return
-  }
-
-  set mlen 0
-  for {set n 0} {$n < $nb} {incr n $bytes_per_row} {
-    set x [format "0x%x" $addr]
-    if {[string length $x] > $mlen} {
-      set mlen [string length $x]
+    if {$retVal || [llength $vals] == 0}  {
+      # FIXME gdb_get_mem does not always return an error when addr is invalid.
+      BadExpr "Couldn't get memory at address: \"$addr\""
+      gdbtk_idle
+      debug "gdb_get_mem returned return code: $retVal and value: \"$vals\""
+      return
     }
-    set ${this}_memval($row,-1) $x
-    for { set col 0 } { $col < $num } { incr col } {
-      set x [lindex $vals $nextval]
-      if {[string length $x] > $maxlen} {set maxlen [string length $x]}
-      set ${this}_memval($row,$col) $x
-      incr nextval
+
+    set mlen 0
+    for {set n 0} {$n < $nb} {incr n $bytes_per_row} {
+      set x [format "0x%x" $addr]
+      if {[string length $x] > $mlen} {
+	set mlen [string length $x]
+      }
+      set ${this}_memval($row,-1) $x
+      for { set col 0 } { $col < $num } { incr col } {
+	set x [lindex $vals $nextval]
+	if {[string length $x] > $maxlen} {set maxlen [string length $x]}
+	set ${this}_memval($row,$col) $x
+	incr nextval
+      }
+      if {$ascii} {
+	set x [lindex $vals $nextval]
+	if {[string length $x] > $maxalen} {set maxalen [string length $x]}
+	set ${this}_memval($row,$col) $x
+	incr nextval
+      }
+      incr addr $bytes_per_row
+      incr row
     }
+    # set default column width to the max in the data columns
+    $itk_interior.t configure -colwidth [expr {$maxlen + 1}]
+    # set border column width
+    $itk_interior.t width -1 [expr {$mlen + 1}]
     if {$ascii} {
-      set x [lindex $vals $nextval]
-      if {[string length $x] > $maxalen} {set maxalen [string length $x]}
-      set ${this}_memval($row,$col) $x
-      incr nextval
+      # set ascii column width
+      $itk_interior.t width $Numcols [expr {$maxalen + 1}]
     }
-    incr addr $bytes_per_row
-    incr row
-  }
-  # set default column width to the max in the data columns
-  $itk_interior.t configure -colwidth [expr {$maxlen + 1}]
-  # set border column width
-  $itk_interior.t width -1 [expr {$mlen + 1}]
-  if {$ascii} {
-    # set ascii column width
-    $itk_interior.t width $Numcols [expr {$maxalen + 1}]
   }

   gdbtk_idle


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