From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12524 invoked by alias); 1 Feb 2007 20:51:56 -0000 Received: (qmail 12514 invoked by uid 22791); 1 Feb 2007 20:51:55 -0000 X-Spam-Check-By: sourceware.org Received: from viper.snap.net.nz (HELO viper.snap.net.nz) (202.37.101.8) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 01 Feb 2007 20:51:46 +0000 Received: from kahikatea.snap.net.nz (185.62.255.123.dynamic.snap.net.nz [123.255.62.185]) by viper.snap.net.nz (Postfix) with ESMTP id DA8E83D8422 for ; Fri, 2 Feb 2007 09:51:42 +1300 (NZDT) Received: by kahikatea.snap.net.nz (Postfix, from userid 500) id 960F74F71C; Fri, 2 Feb 2007 09:51:41 +1300 (NZDT) From: Nick Roberts MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <17858.21211.33629.685339@kahikatea.snap.net.nz> Date: Thu, 01 Feb 2007 20:51:00 -0000 To: gdb-patches@sourceware.org Subject: [PATCH] Catch errors in value_get_print_value X-Mailer: VM 7.19 under Emacs 22.0.93.5 X-IsSubscribed: yes 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-02/txt/msg00010.txt.bz2 Currently when common_val_print throws an error from install_new_value it gets caught in mi_execute_command and prints an MI error (^error,...) without cleaning up. This patch catches the error in value_get_print_value so that GDB can proceed normally. It could be adapted to output something like "" but I think the empty string works better. To see what currently happens, compile: #include typedef struct { float a; float b; } substruct; struct substruct1 { float a1; substruct b1; }; main () { struct substruct1 *abc4 = NULL; int i = 1; } ------------------- and run under GDB as follows: ~"Using host libthread_db library \"/lib/libthread_db.so.1\".\n" (gdb) start &"start\n" Breakpoint 1 at 0x8048365: file temp4.c, line 15. Starting program: /home/nickrob/temp4 main () at temp4.c:15 15 struct substruct1 *abc4 = NULL; ^done (gdb) n &"n\n" 16 int i = 1; ^done (gdb) -var-create - * abc4 ^done,name="var1",numchild="2",type="struct substruct1 *" (gdb) -var-list-children --all-values var1 &"Cannot access memory at address 0x4\n" ^error,msg="Cannot access memory at address 0x4" (gdb) -var-list-children --all-values var1 &&"Duplicate variable object name\n" ^error,msg="Duplicate variable object name" (gdb) -- Nick http://www.inet.net.nz/~nickrob 2007-02-02 Nick Roberts * varobj.c (value_get_print_value): Catch errors from common_val_print. *** varobj.c 02 Feb 2007 09:32:33 +1300 1.82 --- varobj.c 02 Feb 2007 09:48:59 +1300 *************** value_get_print_value (struct value *val *** 1702,1707 **** --- 1702,1708 ---- struct ui_file *stb; struct cleanup *old_chain; char *thevalue; + struct gdb_exception except; if (value == NULL) return NULL; *************** value_get_print_value (struct value *val *** 1709,1715 **** stb = mem_fileopen (); old_chain = make_cleanup_ui_file_delete (stb); ! common_val_print (value, stb, format_code[(int) format], 1, 0, 0); thevalue = ui_file_xstrdup (stb, &dummy); do_cleanups (old_chain); --- 1710,1720 ---- stb = mem_fileopen (); old_chain = make_cleanup_ui_file_delete (stb); ! TRY_CATCH (except, RETURN_MASK_ERROR) ! { ! common_val_print (value, stb, format_code[(int) format], 1, 0, 0); ! } ! thevalue = ui_file_xstrdup (stb, &dummy); do_cleanups (old_chain);