Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] Add proper error message instead of gdb_assert
@ 2008-03-03 19:37 Markus Deuling
  2008-03-03 19:55 ` Mark Kettenis
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Markus Deuling @ 2008-03-03 19:37 UTC (permalink / raw)
  To: GDB Patches; +Cc: Ulrich Weigand

[-- Attachment #1: Type: text/plain, Size: 1163 bytes --]

Hi,

when trying to put > 1 values into an array (fortran subrange) which
comes from a register, register_size is called with regnum == -1.

The following example comes from SPU architecture. Currently GDB exits 
with a gdb_assert going wrong:

(gdb) set $r0%v2_int64(0:1)=(1,2)
../../../gdb-6.7/gdb/regcache.c:177: internal-error: register_size: Assertion `regnum >= 0 && regnum < (gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch))' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) y

This patch replaces that gdb_assert by a proper error message before
exiting:

(gdb) set $r2%v2_int64(0:1)=(1,1)
../../../gdb-6.7/gdb/regcache.c:185: internal-error: invalid register -1
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) 

If this patch is ok it would be great to have it in gdb 6.8. Ok?

ChangeLog:

        * regcache.c (register_size): Replace gdb_assert by a proper error
        message.


Regards,
Markus


-- 
  Markus Deuling
  GNU Toolchain for Linux on Cell BE
  deuling@de.ibm.com


[-- Attachment #2: fix-assert --]
[-- Type: text/plain, Size: 858 bytes --]

diff -urpN gdb-6.7-orig/gdb/regcache.c gdb-6.7/gdb/regcache.c
--- gdb-6.7-orig/gdb/regcache.c	2008-03-03 19:30:54.000000000 +0100
+++ gdb-6.7/gdb/regcache.c	2008-03-03 20:30:10.000000000 +0100
@@ -172,11 +172,18 @@ register_size (struct gdbarch *gdbarch, 
 {
   struct regcache_descr *descr = regcache_descr (gdbarch);
   int size;
-  gdb_assert (regnum >= 0
-	      && regnum < (gdbarch_num_regs (gdbarch)
-			   + gdbarch_num_pseudo_regs (gdbarch)));
-  size = descr->sizeof_register[regnum];
-  return size;
+
+ 
+  if (regnum >= 0 
+      && regnum < (gdbarch_num_regs (gdbarch)
+	 + gdbarch_num_pseudo_regs (gdbarch)))
+    {
+      size = descr->sizeof_register[regnum];
+      return size;
+    }
+
+  internal_error (__FILE__, __LINE__, _("invalid register %d"), regnum);
+  return 0;
 }
 
 /* The register cache for storing raw register values.  */

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-03-04  4:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-03 19:37 [patch] Add proper error message instead of gdb_assert Markus Deuling
2008-03-03 19:55 ` Mark Kettenis
2008-03-03 20:29   ` Michael Snyder
2008-03-03 20:37     ` Mark Kettenis
2008-03-04  4:09       ` Eli Zaretskii
2008-03-03 20:39     ` Daniel Jacobowitz
2008-03-03 20:46       ` Markus Deuling
2008-03-03 21:12       ` Markus Deuling
2008-03-03 21:17         ` Daniel Jacobowitz
2008-03-03 20:00 ` Ulrich Weigand
2008-03-03 20:30   ` Michael Snyder
2008-03-03 20:25 ` Michael Snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox