From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 481 invoked by alias); 12 Dec 2003 20:51:11 -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 474 invoked from network); 12 Dec 2003 20:51:09 -0000 Received: from unknown (HELO nick.uklinux.net) (194.247.50.135) by sources.redhat.com with SMTP; 12 Dec 2003 20:51:09 -0000 Received: by nick.uklinux.net (Postfix, from userid 501) id 62F0975FDE; Fri, 12 Dec 2003 20:43:17 +0000 (GMT) From: Nick Roberts MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16346.10340.488095.107663@nick.uklinux.net> Date: Fri, 12 Dec 2003 20:51:00 -0000 To: Andrew Cagney , jmolenda@apple.com Cc: gdb-patches@sources.redhat.com Subject: Re: RFC (gdb/mi): -stack-list-locals In-Reply-To: <3FD75E64.1020508@gnu.org> References: <16319.64137.458928.417189@nick.uklinux.net> <3FC3F85F.8050007@gnu.org> <16332.423.456414.834703@nick.uklinux.net> <16341.13503.256676.933542@nick.uklinux.net> <3FD75E64.1020508@gnu.org> X-SW-Source: 2003-12/txt/msg00338.txt.bz2 These (two) patches uses 1) get_selected_frame instead of deprecated_selected_frame. 2) SYMBOL_PRINT_NAME instead of DEPRECATED_SYMBOL_NAME. 3) enum for print_values. Jason Molenda writes: > ...Right now we have a > non-standard meaning for -stack-list-locals 2, and the FSF gdb will > have a different meaning for 2 with this patch going in. No complaints > or anything, but it's unpleasant. I don't see why both our changes can't be accommodated. This patch uses a switch statement for each value of print_values. If for some reason Apple need -stack-list-locals 2, I dont mind using another value. Everybody seems to want Apple's changes, including their management. Rather than being unpleasant, perhaps this is an opportunity to make the case to that management for resources to contribute back to the FSF. Nick http://www.nick.uklinux.net *** mi-cmd-stack.c.~1.19.~ 2003-06-12 23:29:37.000000000 +0100 --- mi-cmd-stack.c 2003-12-11 00:53:34.000000000 +0000 *************** *** 29,34 **** --- 29,35 ---- #include "block.h" #include "stack.h" #include "dictionary.h" + #include "gdb_string.h" static void list_args_or_locals (int locals, int values, struct frame_info *fi); *************** *** 137,146 **** enum mi_cmd_result mi_cmd_stack_list_locals (char *command, char **argv, int argc) { if (argc != 1) error ("mi_cmd_stack_list_locals: Usage: PRINT_VALUES"); ! list_args_or_locals (1, atoi (argv[0]), deprecated_selected_frame); return MI_CMD_DONE; } --- 138,159 ---- enum mi_cmd_result mi_cmd_stack_list_locals (char *command, char **argv, int argc) { + struct frame_info *frame; + enum print_values print_values; + if (argc != 1) error ("mi_cmd_stack_list_locals: Usage: PRINT_VALUES"); ! frame = get_selected_frame (); ! ! if (strcmp (argv[0], "1") == 0 || strcmp (argv[0], "all-values") == 0) ! print_values = PRINT_ALL_VALUES; ! else if (strcmp (argv[0], "2") == 0 || strcmp (argv[0], "simple-values") == 0) ! print_values = PRINT_SIMPLE_VALUES; ! else ! print_values = PRINT_NO_VALUES; ! ! list_args_or_locals (1, print_values, frame); return MI_CMD_DONE; } *************** *** 218,223 **** --- 231,237 ---- int nsyms; struct cleanup *cleanup_list; static struct ui_stream *stb = NULL; + struct type *type; stb = ui_out_stream_new (uiout); *************** *** 268,291 **** if (print_me) { struct cleanup *cleanup_tuple = NULL; ! if (values) cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); ! ui_out_field_string (uiout, "name", DEPRECATED_SYMBOL_NAME (sym)); ! if (values) ! { ! struct symbol *sym2; ! if (!locals) ! sym2 = lookup_symbol (DEPRECATED_SYMBOL_NAME (sym), ! block, VAR_DOMAIN, ! (int *) NULL, ! (struct symtab **) NULL); ! else sym2 = sym; print_variable_value (sym2, fi, stb->stream); ui_out_field_stream (uiout, "value", stb); do_cleanups (cleanup_tuple); } } } --- 282,320 ---- if (print_me) { struct cleanup *cleanup_tuple = NULL; ! if (values != PRINT_NO_VALUES) cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); ! ui_out_field_string (uiout, "name", SYMBOL_PRINT_NAME (sym)); ! struct symbol *sym2; ! if (!locals) ! sym2 = lookup_symbol (SYMBOL_PRINT_NAME (sym), ! block, VAR_DOMAIN, ! (int *) NULL, ! (struct symtab **) NULL); ! else sym2 = sym; + switch (values) + { + case PRINT_SIMPLE_VALUES: + type = check_typedef (sym2->type); + type_print (sym2->type, "", stb->stream, -1); + ui_out_field_stream (uiout, "type", stb); + if (TYPE_CODE (type) != TYPE_CODE_ARRAY && + TYPE_CODE (type) != TYPE_CODE_STRUCT && + TYPE_CODE (type) != TYPE_CODE_UNION) + { + print_variable_value (sym2, fi, stb->stream); + ui_out_field_stream (uiout, "value", stb); + } + do_cleanups (cleanup_tuple); + break; + case PRINT_ALL_VALUES: print_variable_value (sym2, fi, stb->stream); ui_out_field_stream (uiout, "value", stb); do_cleanups (cleanup_tuple); + break; } } } *** mi-cmds.h.~1.10.~ 2003-10-24 22:30:52.000000000 +0100 --- mi-cmds.h 2003-12-10 20:09:22.000000000 +0000 *************** *** 48,53 **** --- 48,59 ---- MI_CMD_QUIET }; + enum print_values { + PRINT_NO_VALUES, + PRINT_ALL_VALUES, + PRINT_SIMPLE_VALUES + }; + typedef enum mi_cmd_result (mi_cmd_argv_ftype) (char *command, char **argv, int argc); /* Older MI commands have this interface. Retained until all old