From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28355 invoked by alias); 14 Sep 2007 21:40:19 -0000 Received: (qmail 28346 invoked by uid 22791); 14 Sep 2007 21:40:18 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 14 Sep 2007 21:40:09 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id D3DB72AA7C6 for ; Fri, 14 Sep 2007 17:40:07 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id nIRJXzoUBuIK for ; Fri, 14 Sep 2007 17:40:07 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 7AA602AA7C4 for ; Fri, 14 Sep 2007 17:40:07 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 28889E7B58; Fri, 14 Sep 2007 14:40:05 -0700 (PDT) Date: Fri, 14 Sep 2007 21:40:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [commit/RFA] Add assert inside insert_step_resume_breakpoint_at_frame Message-ID: <20070914214005.GA22603@adacore.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="sdtB3X0nJg68CQEu" Content-Disposition: inline User-Agent: Mutt/1.4.2.2i Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-09/txt/msg00185.txt.bz2 --sdtB3X0nJg68CQEu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 2046 Hello, I just came across a very particular set of conditions that lead insert_step_resume_breakpoint_at_frame to be passed a NULL frame, causing the debugger to crash. Basically, the debugger was doing a "next". During the course of this operation, it landed inside a function called by the code I was stepping over. This function was an internally-genearted function for which no debugging info is generated. So GDB tried to insert a breakpoint at the return address. Unfortunately, trying to get the previous frame failed because of a combination of factors: - The debugging info was stabs. With stabs, the N_FUN entries that define a function only provide the function start address. At this time of writing, the compiler is not generated the unnamed N_FUN entries used by GCC to specify the function end address - The funtion we called is placed immediately after the main (function). - This results in GDB thinking that the function we stepped over from goes over a range of instruction that is too wide. It ends up including our internally generated function. - So get_prev_frame accidently determines that we're inside the main function, and thus stops the backtracing by returning a NULL frame. This is a pretty unlikely situation, but I think we should add an assert that "return_frame" is not NULL before dereferencing it. It's a lot cleaner to report an assertion failure rather than crashing. As for us, we are working on enhancing the compiler to generate that empty N_FUN stabs entry. 2007-09-14 Joel Brobecker * infrun.c (insert_step_resume_breakpoint_at_frame): Add assertion that return_frame is not null. Tested on x86-linux, no regression. This also prevents the crash initially observed. This seems pretty straightforward and safe, but I'll give it a week for comments before checking in. -- Joel --sdtB3X0nJg68CQEu Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="infrun.diff" Content-length: 494 Index: infrun.c =================================================================== RCS file: /cvs/src/src/gdb/infrun.c,v retrieving revision 1.246 diff -u -p -r1.246 infrun.c --- infrun.c 10 Sep 2007 18:49:26 -0000 1.246 +++ infrun.c 14 Sep 2007 21:28:04 -0000 @@ -2868,6 +2868,7 @@ insert_step_resume_breakpoint_at_frame ( { struct symtab_and_line sr_sal; + gdb_assert (return_frame != NULL); init_sal (&sr_sal); /* initialize to zeros */ sr_sal.pc = gdbarch_addr_bits_remove --sdtB3X0nJg68CQEu--