From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25242 invoked by alias); 5 May 2006 19:25:46 -0000 Received: (qmail 25232 invoked by uid 22791); 5 May 2006 19:25:44 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Fri, 05 May 2006 19:25:38 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1Fc5vj-00013Q-LK; Fri, 05 May 2006 15:25:35 -0400 Date: Fri, 05 May 2006 19:25:00 -0000 From: Daniel Jacobowitz To: Vladimir Prus Cc: gdb-patches@sources.redhat.com Subject: Re: MI: type prefixes for values Message-ID: <20060505192535.GM31029@nevyn.them.org> Mail-Followup-To: Vladimir Prus , gdb-patches@sources.redhat.com References: <17427.54333.236860.258115@kahikatea.snap.net.nz> <20060317191207.GA19068@nevyn.them.org> <20060324030332.GB2853@nevyn.them.org> <20060324202056.GA26748@nevyn.them.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.8i X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-05/txt/msg00086.txt.bz2 On Fri, Apr 28, 2006 at 10:32:34AM +0400, Vladimir Prus wrote: > > Any comments on the patch I've send two weeks ago? Note that I'm not longer > interested in this patch myself, since I no longer use "--stack-list-frames > --all-values" in KDevelop, but I believe the patch affects the MI support > in Emacs that Nick is working on. After thinking about it for a bit, let's not do it this way. I think we could put a catch at the right place and make all possible memory errors come out consistently - I'm thinking something like volatile struct gdb_exception except; int ret = 0; ... TRY_CATCH (except, RETURN_MASK_ERROR) { ret = val_print (...); } if (except.reason < 0) fprintf_filtered (stream, _("")); return ret; This would probably either require additional changes, to use common_val_print and value_field et cetera in more places, or else have to be placed in val_print directly, around the call to LA_VAL_PRINT. The latter is easier. Here's a patch; before it I get: (gdb) i locals ref = (int &) @0x2ae2e8dc0392: 1287883081 ref3 = (int &) @0x2ae2e90bc7a0: -385103520 ref5 = (int &) @0x0: Cannot access memory at address 0x0 After: (gdb) i locals ref = (int &) @0x2ac1ec165392: 1287883081 ref3 = (int &) @0x2ac1ec4617a0: -330950304 ref5 = (int &) @0x0: ref7 = (int &) @0x40041b: 147096392 ref9 = (int &) @0x400588: 352685384 ref2 = (int &) @0x2ac1ec4630c0: -330969896 ref4 = (int &) @0x2ac1ec460fe0: -330952736 ref6 = (int &) @0x2ac1ec270ca0: 0 ref8 = (int &) @0x4005f0: 610568524 Similarly: (gdb) interpreter-exec mi "-stack-list-locals 1" ^done,locals=[{name="ref",value="(int &) @0x2ba30c30d392: 1287883081"},{name="ref3",value="(int &) @0x2ba30c6097a0: 207657312"},{name="ref5",value="(int &) @0x0: "},{name="ref7",value="(int &) @0x40041b: 147096392"},{name="ref9",value="(int &) @0x400588: 352685384"},{name="ref2",value="(int &) @0x2ba30c60b0c0: 207637720"},{name="ref4",value="(int &) @0x2ba30c608fe0: 207654880"},{name="ref6",value="(int &) @0x2ba30c418ca0: 0"},{name="ref8",value="(int &) @0x4005f0: 610568524"}] We already print out various messages for error conditions; I think adding a new one is fine. How about you? This patch doesn't touch the issue of type prefixes, leaving that to deal with separately. -- Daniel Jacobowitz CodeSourcery 2006-05-05 Daniel Jacobowitz * valprint.c: Include "exceptions.h". (val_print): If something goes wrong while printing, supply an error message. Index: valprint.c =================================================================== RCS file: /cvs/src/src/gdb/valprint.c,v retrieving revision 1.59 diff -u -p -r1.59 valprint.c --- valprint.c 18 Jan 2006 21:24:19 -0000 1.59 +++ valprint.c 5 May 2006 19:23:53 -0000 @@ -34,6 +34,7 @@ #include "valprint.h" #include "floatformat.h" #include "doublest.h" +#include "exceptions.h" #include @@ -205,6 +206,9 @@ val_print (struct type *type, const gdb_ CORE_ADDR address, struct ui_file *stream, int format, int deref_ref, int recurse, enum val_prettyprint pretty) { + volatile struct gdb_exception except; + int ret = 0; + struct type *real_type = check_typedef (type); if (pretty == Val_pretty_default) { @@ -224,8 +228,15 @@ val_print (struct type *type, const gdb_ return (0); } - return (LA_VAL_PRINT (type, valaddr, embedded_offset, address, - stream, format, deref_ref, recurse, pretty)); + TRY_CATCH (except, RETURN_MASK_ERROR) + { + ret = LA_VAL_PRINT (type, valaddr, embedded_offset, address, + stream, format, deref_ref, recurse, pretty); + } + if (except.reason < 0) + fprintf_filtered (stream, _("")); + + return ret; } /* Check whether the value VAL is printable. Return 1 if it is; Index: Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.811 diff -u -p -r1.811 Makefile.in --- Makefile.in 23 Apr 2006 14:15:01 -0000 1.811 +++ Makefile.in 5 May 2006 19:24:26 -0000 @@ -2773,7 +2773,8 @@ valops.o: valops.c $(defs_h) $(symtab_h) $(cp_support_h) $(observer_h) valprint.o: valprint.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \ $(value_h) $(gdbcore_h) $(gdbcmd_h) $(target_h) $(language_h) \ - $(annotate_h) $(valprint_h) $(floatformat_h) $(doublest_h) + $(annotate_h) $(valprint_h) $(floatformat_h) $(doublest_h) \ + $(exceptions_h) value.o: value.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \ $(value_h) $(gdbcore_h) $(command_h) $(gdbcmd_h) $(target_h) \ $(language_h) $(scm_lang_h) $(demangle_h) $(doublest_h) \