From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24636 invoked by alias); 22 Sep 2008 13:13:28 -0000 Received: (qmail 24626 invoked by uid 22791); 22 Sep 2008 13:13:27 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 22 Sep 2008 13:12:53 +0000 Received: (qmail 14683 invoked from network); 22 Sep 2008 13:12:51 -0000 Received: from unknown (HELO ?192.168.1.100?) (ams@127.0.0.2) by mail.codesourcery.com with ESMTPA; 22 Sep 2008 13:12:51 -0000 Message-ID: <48D799CC.4020103@codesourcery.com> Date: Mon, 22 Sep 2008 13:13:00 -0000 From: Andrew Stubbs User-Agent: Thunderbird 2.0.0.16 (X11/20080724) MIME-Version: 1.0 To: Mark Kettenis , gdb@sourceware.org Subject: Re: [commited] Detect bad debug info References: <48D3EC6C.8050809@codesourcery.com> <200809192224.m8JMOHEh032757@brahms.sibelius.xs4all.nl> <48D76849.90806@codesourcery.com> <20080922125011.GA25948@caradoc.them.org> In-Reply-To: <20080922125011.GA25948@caradoc.them.org> Content-Type: multipart/mixed; boundary="------------040300010803010200050002" X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-09/txt/msg00119.txt.bz2 This is a multi-part message in MIME format. --------------040300010803010200050002 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 335 Daniel Jacobowitz wrote: > On Mon, Sep 22, 2008 at 10:41:29AM +0100, Andrew Stubbs wrote: >> The patch ensures that the debugger never attempts to read beyond the end >> of the register file. > > Could you explain this in the code? I think it's more enlightening > than "bad debug info". Very well, how about the attached? Andrew --------------040300010803010200050002 Content-Type: text/x-diff; name="comment.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="comment.patch" Content-length: 929 2008-09-22 Andrew Stubbs * frame.c (get_frame_register_bytes): Comment improvments. Index: frame.c =================================================================== RCS file: /cvs/src/src/gdb/frame.c,v retrieving revision 1.252 diff -u -p -r1.252 frame.c --- frame.c 19 Sep 2008 18:12:17 -0000 1.252 +++ frame.c 22 Sep 2008 13:12:09 -0000 @@ -806,13 +806,14 @@ get_frame_register_bytes (struct frame_i regnum++; } - /* Detect bad debug info. */ + /* Ensure that we will not read beyond the end of the register file. + This can only ever happen if the debug information is bad. */ maxsize = -offset; for (i = regnum; i < gdbarch_num_regs (gdbarch); i++) { int thissize = register_size (gdbarch, i); if (thissize == 0) - break; + break; /* This register is not available on this architecture. */ maxsize += thissize; } if (len > maxsize) --------------040300010803010200050002--