This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: [commited] Detect bad debug info
- From: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- To: ams at codesourcery dot com
- Cc: gdb at sourceware dot org
- Date: Sat, 20 Sep 2008 00:24:17 +0200 (CEST)
- Subject: Re: [commited] Detect bad debug info
- References: <48D3EC6C.8050809@codesourcery.com>
> Date: Fri, 19 Sep 2008 19:16:12 +0100
> From: Andrew Stubbs <ams@codesourcery.com>
>
> 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.
Would it be possible to add some detail about this? "a particular
falvour of bad debug info" is pretty non-informative.
Thanks,
Mark
> 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)
> {
>
> --------------060704060100080904030200--
>