From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15273 invoked by alias); 18 Mar 2010 17:07:15 -0000 Received: (qmail 15265 invoked by uid 22791); 18 Mar 2010 17:07:14 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,RCVD_IN_DNSWL_HI,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 18 Mar 2010 17:07:09 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2IH78wK013362 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 18 Mar 2010 13:07:08 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2IH77EN025821; Thu, 18 Mar 2010 13:07:07 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o2IH76Gc008116; Thu, 18 Mar 2010 13:07:07 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 8EF44379848; Thu, 18 Mar 2010 11:07:06 -0600 (MDT) From: Tom Tromey To: gdb-patches@sourceware.org Subject: RFC: finish_command_continuation and errors Reply-To: tromey@redhat.com Date: Thu, 18 Mar 2010 17:07:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2010-03/txt/msg00668.txt.bz2 I'd appreciate comments on this patch, particularly from Pedro. While debugging a gcj-compiled program yesterday, I got this error while trying to re-run: Cannot insert breakpoint 0. Error accessing memory address 0x3e1dc5: Input/output error. Looking at "maint info b" showed: (gdb) maint info b Num Type Disp Enb Address What 0 finish keep y 0x003ea395 ../../../../../trunk/libjava/classpath/tools/gnu/classpath/tools/javah/Main.java:414 inf 1 thread 1 stop only in thread 1 This can happen if gdb calls error while printing the return value. In this case, the finish breakpoint is never deleted. This patch fixes the problem by wrapping the call to print_return_value in a TRY_CATCH. Other fixes are possible, but I chose this one because it is small and occurs at the point in the code that must be exception-safe. Built and regtested on x86-64 (compile farm). I also tried it again on my test case, provoked the error, and used "maint info b" to verify that the finish breakpoint was deleted. I also glanced at the other continuation functions in infcmd.c, but none of them appeared to have a similar problem. Tom 2010-03-18 Tom Tromey * infcmd.c (finish_command_continuation): Wrap print_return_value in TRY_CATCH. Index: infcmd.c =================================================================== RCS file: /cvs/src/src/gdb/infcmd.c,v retrieving revision 1.259 diff -u -r1.259 infcmd.c --- infcmd.c 16 Feb 2010 21:18:46 -0000 1.259 +++ infcmd.c 18 Mar 2010 17:00:51 -0000 @@ -1420,7 +1420,19 @@ _("finish_command: function has no target type")); if (TYPE_CODE (value_type) != TYPE_CODE_VOID) - print_return_value (SYMBOL_TYPE (a->function), value_type); + { + volatile struct gdb_exception ex; + + TRY_CATCH (ex, RETURN_MASK_ALL) + { + /* print_return_value can throw an exception in some + circumstances. We need to catch this so that we still + delete the breakpoint. */ + print_return_value (SYMBOL_TYPE (a->function), value_type); + } + if (ex.reason < 0) + exception_print (gdb_stdout, ex); + } } /* We suppress normal call of normal_stop observer and do it here so