From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3814 invoked by alias); 19 Sep 2008 18:16:56 -0000 Received: (qmail 3806 invoked by uid 22791); 19 Sep 2008 18:16:55 -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; Fri, 19 Sep 2008 18:16:20 +0000 Received: (qmail 24033 invoked from network); 19 Sep 2008 18:16:18 -0000 Received: from unknown (HELO ?192.168.1.100?) (ams@127.0.0.2) by mail.codesourcery.com with ESMTPA; 19 Sep 2008 18:16:18 -0000 Message-ID: <48D3EC6C.8050809@codesourcery.com> Date: Fri, 19 Sep 2008 18:16:00 -0000 From: Andrew Stubbs User-Agent: Thunderbird 2.0.0.16 (X11/20080724) MIME-Version: 1.0 To: gdb@sourceware.org Subject: [commited] Detect bad debug info Content-Type: multipart/mixed; boundary="------------060704060100080904030200" 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/msg00113.txt.bz2 This is a multi-part message in MIME format. --------------060704060100080904030200 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 206 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 --------------060704060100080904030200 Content-Type: text/x-diff; name="bad-debug.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="bad-debug.patch" Content-length: 1223 2008-09-19 Andrew Stubbs * 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--