From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24402 invoked by alias); 29 Nov 2011 13:57:35 -0000 Received: (qmail 24391 invoked by uid 22791); 29 Nov 2011 13:57:33 -0000 X-SWARE-Spam-Status: No, hits=-7.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 29 Nov 2011 13:57:14 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pATDvDY9019876 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 29 Nov 2011 08:57:13 -0500 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pATDvCfF017287; Tue, 29 Nov 2011 08:57:12 -0500 From: Phil Muldoon To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [python] [patch] PR python/13329 References: Reply-to: pmuldoon@redhat.com X-URL: http://www.redhat.com Date: Tue, 29 Nov 2011 13:57:00 -0000 In-Reply-To: (Tom Tromey's message of "Thu, 17 Nov 2011 13:54:16 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2011-11/txt/msg00810.txt.bz2 Tom Tromey writes: > Phil> +/* 0 if we should not print the stack when catching a Python error, > Phil> + 1 to print the full stack, 2 to just print the message. */ > Phil> +static int gdbpy_should_print_stack = 2; > > It is more normal, though not exclusively the case (I think), to just > use the string constants here. Because they are constant strings you > can just compare them with ==. > > That is, you can just remove this variable. > > Phil> +/* The extended exception printing variable. 'full' if we want to > Phil> + print the error message and stack, 'none' if we want to print > Phil> + nothing, and 'message' if we only want to print the error > Phil> + message. */ > Phil> +static const char *gdbpy_should_print_stack_extended = > Phil> + python_excp_message; > > ... and rename this to gdbpy_should_print_stack and use it directly. > > Phil> +/* When setting the 'python print-stack' with an enum, set the > Phil> + gdbpy_should_print_stack correspondingly. */ > Phil> +static void > Phil> +set_python_excp_mode (char *args, int i, struct cmd_list_element *c) I have to keep/add these functions around to be compatible with "maint set python print-stack" which is a boolean parameter. So it was my view we still operate on the gdbpy_should_print_stack variable in gdbpy_print_stack function, and have the "set function" just set gdbpy_should_print_stack from the enum command. I can do what you wish, but I would have to write a "set" function to set the enum constant instead. > With the above change you won't need this function. > > Phil> + add_setshow_enum_cmd ("print-stack", no_class, python_excp_enums, > Phil> + &gdbpy_should_print_stack_extended, _("\ > Phil> +Set mode for Python stack dump on error."), _("\ > Phil> +Show the mode of Python stack printing on error."), _("\ > Phil> +none == no stack or message will be printed.\n\ > Phil> +full == a message and a stack will be printed.\n\ > Phil> +message == an error message without a stack will be printed."), > Phil> + set_python_excp_mode, NULL, > Phil> + &user_set_python_list, > Phil> + &user_show_python_list); > > I'm surprised this is backward compatible. The user command "set python print-stack" has not been published in a release so it is not compatible; I believe it is within our API pledge to change whatever we like until that feature is released. "maint set python print-stack" still works, but is deprecated. For the variable gdbpy_should_print_stack, 0 is still off, 1 is full, 2 is message only. The "maint set python print-stack" will only ever set off or full. > Phil> -gdb_test_no_output "set python print-stack on" > Phil> +gdb_test_no_output "set python print-stack full" > > You should leave in some compatibility tests for the old values. Do you mean use "maint set python print-stack" here? > I didn't look but you should try the old code to see exactly what values > it accepted. I thought the boolean set/shows took more than just on/off. I will, but the result remains the same. 0 for off, > 0 for on. Cheers Phil