From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31812 invoked by alias); 17 Nov 2011 20:55:32 -0000 Received: (qmail 31798 invoked by uid 22791); 17 Nov 2011 20:55:32 -0000 X-SWARE-Spam-Status: No, hits=-7.6 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; Thu, 17 Nov 2011 20:55:18 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pAHKtIFN014051 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 17 Nov 2011 15:55:18 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id pAHKt8xJ026090; Thu, 17 Nov 2011 15:55:18 -0500 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id pAHKsGj4021250; Thu, 17 Nov 2011 15:54:27 -0500 From: Tom Tromey To: pmuldoon@redhat.com Cc: gdb-patches@sourceware.org Subject: Re: [python] [patch] PR python/13329 References: Date: Thu, 17 Nov 2011 20:55:00 -0000 In-Reply-To: (Phil Muldoon's message of "Wed, 09 Nov 2011 15:35:59 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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/msg00487.txt.bz2 >>>>> "Phil" == Phil Muldoon writes: Phil> 2011-11-09 Phil Muldoon Phil> PR python/13329 Phil> +/* set python print-stack choices. */ Capital "s". Phil> +static const char *python_excp_enums[] = { I usually put the "{" on a new line here. It seems more GNU-ish to me. 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) 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. 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. 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. Tom