From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4635 invoked by alias); 2 Jan 2005 22:13:56 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 4336 invoked from network); 2 Jan 2005 22:13:44 -0000 Received: from unknown (HELO lisa.goe.net) (134.76.166.209) by sourceware.org with SMTP; 2 Jan 2005 22:13:44 -0000 Received: from mutter.goe.net (mail@mutter-lisa0.a11.private [192.168.31.26]) by lisa.goe.net (8.12.10/8.12.10) with ESMTP id j02MDgva024953 for ; Sun, 2 Jan 2005 23:13:42 +0100 Received: from igel.a11.private ([192.168.31.91] helo=igel.home) by mutter.goe.net with esmtp (Exim 4.42) id 1ClDyn-0001XO-Pn for gdb-patches@sources.redhat.com; Sun, 02 Jan 2005 23:13:41 +0100 Received: by igel.home (Postfix, from userid 500) id 61E5710C641; Sun, 2 Jan 2005 23:01:46 +0100 (CET) To: gdb-patches@sources.redhat.com Subject: Don't error out when variable not available From: Andreas Schwab X-Yow: Should I do my BOBBIE VINTON medley? Date: Sun, 02 Jan 2005 22:13:00 -0000 Message-ID: User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2005-01/txt/msg00002.txt.bz2 With the introduction of DWARF location lists it became impossible to get the full list of local variables of a function when any of them is not available. This is especially annoying when the first local or function parameter is missing. Here is an attempt at correcting this. It is suboptimal because it still prints the error message including the newline which badly messes up the output. Any idea how to fix that properly? Andreas. 2005-01-02 Andreas Schwab * findvar.c (read_var_value_no_error, read_var_value_no_error_1) (struct read_var_value_args): New. * value.h (read_var_value_no_error): Declare it. * printcmd.c (print_variable_value): Use read_var_value_no_error. * stack.c (print_frame_args): Likewise. --- gdb/findvar.c.~1.82.~ 2004-11-17 00:55:13.000000000 +0100 +++ gdb/findvar.c 2005-01-02 22:48:01.469889953 +0100 @@ -589,6 +589,39 @@ addresses have not been bound by the dyn return v; } =20 +/* Like read_var_value, but catch errors and return NULL if any + occured. */ + +struct read_var_value_args +{ + struct symbol *var; + struct frame_info *frame; + struct value *val; +}; + +static int +read_var_value_no_error_1 (void *data) +{ + struct read_var_value_args *args =3D data; + struct value *val; + + val =3D read_var_value (args->var, args->frame); + args->val =3D val; + return 0; +} + +struct value * +read_var_value_no_error (struct symbol *var, struct frame_info *frame) +{ + struct read_var_value_args args; + + args.var =3D var; + args.frame =3D frame; + args.val =3D NULL; + catch_errors (read_var_value_no_error_1, &args, NULL, RETURN_MASK_ERROR); + return args.val; +} + /* Return a value of type TYPE, stored in register REGNUM, in frame FRAME. =20 --- gdb/printcmd.c.~1.81.~ 2004-11-13 01:24:52.000000000 +0100 +++ gdb/printcmd.c 2005-01-02 22:58:56.751697758 +0100 @@ -1708,9 +1708,10 @@ void print_variable_value (struct symbol *var, struct frame_info *frame, struct ui_file *stream) { - struct value *val =3D read_var_value (var, frame); + struct value *val =3D read_var_value_no_error (var, frame); =20 - value_print (val, stream, 0, Val_pretty_default); + if (val !=3D NULL) + value_print (val, stream, 0, Val_pretty_default); } =20 static void --- gdb/stack.c.~1.119.~ 2004-11-13 01:24:52.000000000 +0100 +++ gdb/stack.c 2005-01-02 22:37:25.785526361 +0100 @@ -347,7 +347,7 @@ print_frame_args (struct symbol *func, s we do not know. We pass 2 as "recurse" to val_print because our standard indentation here is 4 spaces, and val_print indents 2 for each recurse. */ - val =3D read_var_value (sym, fi); + val =3D read_var_value_no_error (sym, fi); =20 annotate_arg_value (val =3D=3D NULL ? NULL : value_type (val)); =20 --- gdb/value.h.~1.61.~ 2004-11-17 00:55:14.000000000 +0100 +++ gdb/value.h 2005-01-02 22:35:28.716424395 +0100 @@ -293,6 +293,9 @@ extern int symbol_read_needs_frame (stru extern struct value *read_var_value (struct symbol *var, struct frame_info *frame); =20 +extern struct value *read_var_value_no_error (struct symbol *var, + struct frame_info *frame); + extern struct value *locate_var_value (struct symbol *var, struct frame_info *frame); =20 --=20 Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, Maxfeldstra=C3=9Fe 5, 90409 N=C3=BCrnberg, Germany Key fingerprint =3D 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."