Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: ams@codesourcery.com
Cc: gdb@sourceware.org
Subject: Re: [commited] Detect bad debug info
Date: Fri, 19 Sep 2008 22:27:00 -0000	[thread overview]
Message-ID: <200809192224.m8JMOHEh032757@brahms.sibelius.xs4all.nl> (raw)
In-Reply-To: <48D3EC6C.8050809@codesourcery.com> (message from Andrew Stubbs 	on Fri, 19 Sep 2008 19:16:12 +0100)

> 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--
> 


  reply	other threads:[~2008-09-19 22:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-19 18:16 Andrew Stubbs
2008-09-19 22:27 ` Mark Kettenis [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200809192224.m8JMOHEh032757@brahms.sibelius.xs4all.nl \
    --to=mark.kettenis@xs4all.nl \
    --cc=ams@codesourcery.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox