Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* [commited] Detect bad debug info
@ 2008-09-19 18:16 Andrew Stubbs
  2008-09-19 22:27 ` Mark Kettenis
  2008-09-24 12:18 ` Andreas Schwab
  0 siblings, 2 replies; 10+ messages in thread
From: Andrew Stubbs @ 2008-09-19 18:16 UTC (permalink / raw)
  To: gdb

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

Hi,

I have just committed the attached patch (approved privately by Daniel 
Jacobowitz).

The patch causes GDB to fail gracefully when it encounters a particular 
flavour of bad debug info.

Andrew Stubbs

[-- Attachment #2: bad-debug.patch --]
[-- Type: text/x-diff, Size: 1223 bytes --]

2008-09-19  Andrew Stubbs  <ams@codesourcery.com>

	* frame.c (get_frame_register_bytes): Detect bad debug info.

Index: gdb/frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.251
diff -u -p -r1.251 frame.c
--- gdb/frame.c	26 Aug 2008 17:40:24 -0000	1.251
+++ gdb/frame.c	19 Sep 2008 18:10:34 -0000
@@ -796,6 +796,8 @@ get_frame_register_bytes (struct frame_i
 			  CORE_ADDR offset, int len, gdb_byte *myaddr)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
+  int i;
+  int maxsize;
 
   /* Skip registers wholly inside of OFFSET.  */
   while (offset >= register_size (gdbarch, regnum))
@@ -804,6 +806,22 @@ get_frame_register_bytes (struct frame_i
       regnum++;
     }
 
+  /* Detect bad debug info.  */
+  maxsize = -offset;
+  for (i = regnum; i < gdbarch_num_regs (gdbarch); i++)
+    {
+      int thissize = register_size (gdbarch, i);
+      if (thissize == 0)
+	break;
+      maxsize += thissize;
+    }
+  if (len > maxsize)
+    {
+      warning (_("Bad debug information detected: "
+		 "Attempt to read %d bytes from registers."), len);
+      return 0;
+    }
+
   /* Copy the data.  */
   while (len > 0)
     {

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

end of thread, other threads:[~2008-09-24 13:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-19 18:16 [commited] Detect bad debug info Andrew Stubbs
2008-09-19 22:27 ` Mark Kettenis
2008-09-22  9:42   ` Andrew Stubbs
2008-09-22 12:50     ` Daniel Jacobowitz
2008-09-22 13:13       ` Andrew Stubbs
2008-09-22 13:33         ` Daniel Jacobowitz
2008-09-22 13:38           ` Andrew Stubbs
2008-09-22 14:27         ` Mark Kettenis
2008-09-24 12:18 ` Andreas Schwab
2008-09-24 13:00   ` Andreas Schwab

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