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]

[commit, spu] Do not error out if backchain is unreadable


Hello,

this changes spu_frame_unwind_cache to use safe_read_memory_integer
instead of read_memory_unsigned_integer to access the backchain.

This prevents commands to be aborted due to memory_error if the
backchain is unreadable (in case of stack corruption etc).

Tested on spu-elf with no regressions, committed to mainline.

Bye,
Ulrich


ChangeLog:

	* spu-tdep.c (spu_frame_unwind_cache): Do not error if
	backchain is unreadable.


diff -urNp src-orig/gdb/spu-tdep.c src/gdb/spu-tdep.c
--- src-orig/gdb/spu-tdep.c	2008-05-01 02:08:28.000000000 +0200
+++ src/gdb/spu-tdep.c	2008-07-12 19:09:46.927516553 +0200
@@ -888,15 +888,17 @@ spu_frame_unwind_cache (struct frame_inf
   /* Otherwise, fall back to reading the backchain link.  */
   else
     {
-      CORE_ADDR reg, backchain;
+      CORE_ADDR reg;
+      LONGEST backchain;
+      int status;
 
       /* Get the backchain.  */
       reg = get_frame_register_unsigned (this_frame, SPU_SP_REGNUM);
-      backchain = read_memory_unsigned_integer (reg, 4);
+      status = safe_read_memory_integer (reg, 4, &backchain);
 
       /* A zero backchain terminates the frame chain.  Also, sanity
          check against the local store size limit.  */
-      if (backchain != 0 && backchain < SPU_LS_SIZE)
+      if (status && backchain > 0 && backchain < SPU_LS_SIZE)
 	{
 	  /* Assume the link register is saved into its slot.  */
 	  if (backchain + 16 < SPU_LS_SIZE)
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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