This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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] [ia64] Fixup breakpoints errors handling


Hi,

found out the code could already for example internal_error on uninitialized
memory after failed target_read_memory.  Do not try to continue after failed
memory read as the whole function would fail anyway.

This patch was regression tested together with the previous one.
This patch depends on the previous patch:
	[patch] [ia64] Fix (#2) shadowing of breakpoints
	http://sourceware.org/ml/gdb-patches/2009-09/msg00130.html


Thanks,
Jan


gdb/
2009-09-05  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* ia64-tdep.c (ia64_memory_insert_breakpoint)
	(ia64_memory_remove_breakpoint): Return immediately if any of memory
	reads fail.  Do not combine the VAL values.

--- gdb/ia64-tdep.c	2009-09-05 18:47:53.000000000 +0200
+++ gdb/ia64-tdep.c	2009-09-05 18:26:41.000000000 +0200
@@ -629,6 +629,11 @@ ia64_memory_insert_breakpoint (struct gd
      breakpoint instruction bits region.  */
   cleanup = make_show_memory_breakpoints_cleanup (0);
   val = target_read_memory (addr, bundle, BUNDLE_LEN);
+  if (val != 0)
+    {
+      do_cleanups (cleanup);
+      return val;
+    }
 
   /* Slot number 2 may skip at most 2 bytes at the beginning.  */
   bp_tgt->shadow_len = BUNDLE_LEN - 2;
@@ -643,7 +648,12 @@ ia64_memory_insert_breakpoint (struct gd
      placed breakpoints.  It is due to our SHADOW_CONTENTS overlapping the real
      breakpoint instruction bits region.  */
   make_show_memory_breakpoints_cleanup (1);
-  val |= target_read_memory (addr, bundle, BUNDLE_LEN);
+  val = target_read_memory (addr, bundle, BUNDLE_LEN);
+  if (val != 0)
+    {
+      do_cleanups (cleanup);
+      return val;
+    }
 
   /* Check for L type instruction in slot 1, if present then bump up the slot
      number to the slot 2.  */
@@ -664,9 +674,8 @@ ia64_memory_insert_breakpoint (struct gd
 
   bp_tgt->placed_size = bp_tgt->shadow_len;
 
-  if (val == 0)
-    val = target_write_memory (addr + slotnum, bundle + slotnum,
-			       bp_tgt->shadow_len);
+  val = target_write_memory (addr + slotnum, bundle + slotnum,
+			     bp_tgt->shadow_len);
 
   do_cleanups (cleanup);
   return val;
@@ -693,6 +702,11 @@ ia64_memory_remove_breakpoint (struct gd
      breakpoint instruction bits region.  */
   cleanup = make_show_memory_breakpoints_cleanup (1);
   val = target_read_memory (addr, bundle_mem, BUNDLE_LEN);
+  if (val != 0)
+    {
+      do_cleanups (cleanup);
+      return val;
+    }
 
   /* Check for L type instruction in slot 1, if present then bump up the slot
      number to the slot 2.  */
@@ -721,8 +735,7 @@ ia64_memory_remove_breakpoint (struct gd
   /* In BUNDLE_MEM be careful to modify only the bits belonging to SLOTNUM and
      never any other possibly also stored in SHADOW_CONTENTS.  */
   replace_slotN_contents (bundle_mem, instr_saved, slotnum);
-  if (val == 0)
-    val = target_write_memory (addr, bundle_mem, BUNDLE_LEN);
+  val = target_write_memory (addr, bundle_mem, BUNDLE_LEN);
 
   do_cleanups (cleanup);
   return val;


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