From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6869 invoked by alias); 22 Dec 2008 14:18:42 -0000 Received: (qmail 6861 invoked by uid 22791); 22 Dec 2008 14:18:42 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,KAM_MX,KAM_STOCKGEN,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 22 Dec 2008 14:18:07 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id mBMEI3xj013766; Mon, 22 Dec 2008 09:18:03 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id mBMEI2Ub024140; Mon, 22 Dec 2008 09:18:02 -0500 Received: from opsy.redhat.com (vpn-12-219.rdu.redhat.com [10.11.12.219]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id mBMEI23p005701; Mon, 22 Dec 2008 09:18:02 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id 8D678378623; Mon, 22 Dec 2008 07:18:01 -0700 (MST) To: Joel Brobecker Cc: gdb-patches@sourceware.org Subject: Re: RFA: fix pretty-printing in "bt full" References: <20081222050024.GD25416@adacore.com> From: Tom Tromey Reply-To: Tom Tromey Date: Mon, 22 Dec 2008 14:18:00 -0000 In-Reply-To: <20081222050024.GD25416@adacore.com> (Joel Brobecker's message of "Mon\, 22 Dec 2008 09\:00\:24 +0400") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (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: 2008-12/txt/msg00378.txt.bz2 >>>>> "Joel" == Joel Brobecker writes: Joel> Just one comment: How about letting print_variable_value do all Joel> the indenting instead of having the caller indent the first line? Joel> I think that would simplify the usage as well as the description. Joel> What do you think? Ok, here's another version. This one renames the function, since after its purpose changed the old name seemed incorrect. Also, this may introduce a behavior change in print_frame_arg_vars. I haven't tried to test this, but the old code printed the variable name before looking up the second symbol; it seems to me that the new code could fail while looking up the second symbol and then not print anything. Built and regtested on x86-64 (compile farm). Tom 2008-12-22 Tom Tromey * stack.c (print_block_frame_locals): Print spaces, not tabs. Update for call to print_variable_and_value. (print_frame_arg_vars): Update. * value.h (print_variable_and_value): Rename from print_variable_value. Add 'name' and 'indent' parameters. * printcmd.c (print_variable_and_value): Rename from print_variable_value. Add 'name' and 'indent' parameters. Use common_val_print. * f-valprint.c (info_common_command): Update. diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index f893b49..a2d2a20 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -566,9 +566,7 @@ info_common_command (char *comname, int from_tty) while (entry != NULL) { - printf_filtered ("%s = ", SYMBOL_PRINT_NAME (entry->symbol)); - print_variable_value (entry->symbol, fi, gdb_stdout); - printf_filtered ("\n"); + print_variable_and_value (NULL, entry->symbol, fi, gdb_stdout, 0); entry = entry->next; } } diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 6d6b915..c4262d5 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1731,17 +1731,28 @@ disable_display_command (char *args, int from_tty) /* Print the value in stack frame FRAME of a variable specified by a - struct symbol. */ + struct symbol. NAME is the name to print; if NULL then VAR's print + name will be used. STREAM is the ui_file on which to print the + value. INDENT specifies the number of indent levels to print + before printing the variable name. */ void -print_variable_value (struct symbol *var, struct frame_info *frame, - struct ui_file *stream) +print_variable_and_value (const char *name, struct symbol *var, + struct frame_info *frame, + struct ui_file *stream, int indent) { - struct value *val = read_var_value (var, frame); + struct value *val; struct value_print_options opts; + if (!name) + name = SYMBOL_PRINT_NAME (var); + + fprintf_filtered (stream, "%s%s = ", n_spaces (2 * indent), name); + + val = read_var_value (var, frame); get_user_print_options (&opts); - value_print (val, stream, &opts); + common_val_print (val, stream, indent, &opts, current_language); + fprintf_filtered (stream, "\n"); } static void diff --git a/gdb/stack.c b/gdb/stack.c index 3c1019b..51dd1bc 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1374,12 +1374,7 @@ print_block_frame_locals (struct block *b, struct frame_info *frame, if (SYMBOL_IS_ARGUMENT (sym)) break; values_printed = 1; - for (j = 0; j < num_tabs; j++) - fputs_filtered ("\t", stream); - fputs_filtered (SYMBOL_PRINT_NAME (sym), stream); - fputs_filtered (" = ", stream); - print_variable_value (sym, frame, stream); - fprintf_filtered (stream, "\n"); + print_variable_and_value (NULL, sym, frame, stream, 4 * num_tabs); break; default: @@ -1575,8 +1570,6 @@ print_frame_arg_vars (struct frame_info *frame, struct ui_file *stream) if (SYMBOL_IS_ARGUMENT (sym)) { values_printed = 1; - fputs_filtered (SYMBOL_PRINT_NAME (sym), stream); - fputs_filtered (" = ", stream); /* We have to look up the symbol because arguments can have two entries (one a parameter, one a local) and the one we @@ -1591,8 +1584,8 @@ print_frame_arg_vars (struct frame_info *frame, struct ui_file *stream) sym2 = lookup_symbol (SYMBOL_LINKAGE_NAME (sym), b, VAR_DOMAIN, NULL); - print_variable_value (sym2, frame, stream); - fprintf_filtered (stream, "\n"); + print_variable_and_value (SYMBOL_PRINT_NAME (sym), sym2, + frame, stream, 0); } } diff --git a/gdb/value.h b/gdb/value.h index a882004..2961919 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -557,9 +557,11 @@ extern int val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream, const struct value_print_options *options); -extern void print_variable_value (struct symbol *var, - struct frame_info *frame, - struct ui_file *stream); +extern void print_variable_and_value (const char *name, + struct symbol *var, + struct frame_info *frame, + struct ui_file *stream, + int indent); extern int check_field (struct type *, const char *);