This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
[commited] Detect bad debug info
- From: Andrew Stubbs <ams at codesourcery dot com>
- To: gdb at sourceware dot org
- Date: Fri, 19 Sep 2008 19:16:12 +0100
- Subject: [commited] Detect bad debug info
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
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)
{