From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18262 invoked by alias); 7 Jul 2011 16:12:03 -0000 Received: (qmail 18244 invoked by uid 22791); 7 Jul 2011 16:12:01 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD 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, 07 Jul 2011 16:11:47 +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 p67GBjbU022998 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 7 Jul 2011 12:11:46 -0400 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 p67GBaiT000995; Thu, 7 Jul 2011 12:11:37 -0400 From: Phil Muldoon To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [patch] PR python/12438 References: Reply-to: pmuldoon@redhat.com X-URL: http://www.redhat.com Date: Thu, 07 Jul 2011 16:16:00 -0000 In-Reply-To: (Tom Tromey's message of "Thu, 30 Jun 2011 13:58:05 -0600") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (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-07/txt/msg00240.txt.bz2 Tom Tromey writes: >>>>>> "Phil" == Phil Muldoon writes: > > Phil> Additionally, I have deprecated maint set/show python print-stack and > Phil> promoted the setting to the more user visible set/show python > Phil> print-backtrace. Finally a note on the name change. I wanted to keep > Phil> print-stack, but it appears when you deprecate a command it deprecates > Phil> it among all command lists. > > I don't see how this could be the case. deprecate_cmd just deprecates a > single cmd_list_element. Could you try without the name change, and > then see what the underlying problem is instead? I was adding the new commands to the old list. So you were quite right. Sorry about that ;) Regenerated patch: diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 129a46b..9ff3c2c 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -20801,10 +20801,16 @@ End with a line saying just "end". @kindex maint set python print-stack @item maint set python print-stack -By default, @value{GDBN} will print a stack trace when an error occurs -in a Python script. This can be controlled using @code{maint set -python print-stack}: if @code{on}, the default, then Python stack -printing is enabled; if @code{off}, then Python stack printing is +This command is now deprecated. Instead use @code{set python +print-stack} (@pxref{set python print-stack}). + +@kindex set python print-stack +@item set python print-stack +@anchor{set python print-stack} +By default, @value{GDBN} will not print a stack trace when an error +occurs in a Python script. This can be controlled using @code{set +python print-stack}: if @code{on}, then Python stack printing is +enabled; if @code{off}, the default, then Python stack printing is disabled. @end table diff --git a/gdb/python/python.c b/gdb/python/python.c index ddfe9ba..0cca4c5 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -36,7 +36,7 @@ /* True if we should print the stack when catching a Python error, false otherwise. */ -static int gdbpy_should_print_stack = 1; +static int gdbpy_should_print_stack = 0; #ifdef HAVE_PYTHON @@ -936,23 +936,46 @@ gdbpy_breakpoint_has_py_cond (struct breakpoint_object *bp_obj) /* Lists for 'maint set python' commands. */ -struct cmd_list_element *set_python_list; -struct cmd_list_element *show_python_list; +struct cmd_list_element *maint_set_python_list; +struct cmd_list_element *maint_show_python_list; + +/* Lists for 'set python' commands. */ + +struct cmd_list_element *user_set_python_list; +struct cmd_list_element *user_show_python_list; /* Function for use by 'maint set python' prefix command. */ static void -set_python (char *args, int from_tty) +maint_set_python (char *args, int from_tty) { - help_list (set_python_list, "maintenance set python ", -1, gdb_stdout); + help_list (maint_set_python_list, "maintenance set python ", + class_deprecated, gdb_stdout); } /* Function for use by 'maint show python' prefix command. */ static void -show_python (char *args, int from_tty) +maint_show_python (char *args, int from_tty) +{ + cmd_show_list (maint_show_python_list, from_tty, ""); +} + +/* Function for use by 'set python' prefix command. */ + +static void +user_set_python (char *args, int from_tty) +{ + help_list (user_set_python_list, "set python ", all_commands, + gdb_stdout); +} + +/* Function for use by 'show python' prefix command. */ + +static void +user_show_python (char *args, int from_tty) { - cmd_show_list (show_python_list, from_tty, ""); + cmd_show_list (user_show_python_list, from_tty, ""); } /* Initialize the Python code. */ @@ -963,6 +986,9 @@ extern initialize_file_ftype _initialize_python; void _initialize_python (void) { + char *cmd_name; + struct cmd_list_element *cmd; + add_com ("python", class_obscure, python_command, #ifdef HAVE_PYTHON _("\ @@ -984,13 +1010,13 @@ This command is only a placeholder.") #endif /* HAVE_PYTHON */ ); - add_prefix_cmd ("python", no_class, show_python, + add_prefix_cmd ("python", no_class, maint_show_python, _("Prefix command for python maintenance settings."), - &show_python_list, "maintenance show python ", 0, + &maint_show_python_list, "maintenance show python ", 0, &maintenance_show_cmdlist); - add_prefix_cmd ("python", no_class, set_python, + add_prefix_cmd ("python", no_class, maint_set_python, _("Prefix command for python maintenance settings."), - &set_python_list, "maintenance set python ", 0, + &maint_set_python_list, "maintenance set python ", 0, &maintenance_set_cmdlist); add_setshow_boolean_cmd ("print-stack", class_maintenance, @@ -999,8 +1025,37 @@ Enable or disable printing of Python stack dump on error."), _("\ Show whether Python stack will be printed on error."), _("\ Enables or disables printing of Python stack traces."), NULL, NULL, - &set_python_list, - &show_python_list); + &maint_set_python_list, + &maint_show_python_list); + + /* Deprecate maint set/show python print-stack in favour of + non-maintenance alternatives. */ + cmd_name = "print-stack"; + cmd = lookup_cmd (&cmd_name, maint_set_python_list, "", -1, 0); + deprecate_cmd (cmd, "set python print-stack"); + cmd_name = "print-stack"; /* Reset name. */ + cmd = lookup_cmd (&cmd_name, maint_show_python_list, "", -1, 0); + deprecate_cmd (cmd, "show python print-stack"); + + /* Add set/show python print-stack. */ + add_prefix_cmd ("python", no_class, user_show_python, + _("Prefix command for python preference settings."), + &user_show_python_list, "show python ", 0, + &showlist); + + add_prefix_cmd ("python", no_class, user_set_python, + _("Prefix command for python preference settings."), + &user_set_python_list, "set python ", 0, + &setlist); + + add_setshow_boolean_cmd ("print-stack", no_class, + &gdbpy_should_print_stack, _("\ +Enable or disable printing of Python stack dump on error."), _("\ +Show whether Python stack will be printed on error."), _("\ +Enables or disables printing of Python stack traces."), + NULL, NULL, + &user_set_python_list, + &user_show_python_list); #ifdef HAVE_PYTHON #ifdef WITH_PYTHON_PATH diff --git a/gdb/testsuite/gdb.python/py-function.exp b/gdb/testsuite/gdb.python/py-function.exp index ffadb5b..d579435 100644 --- a/gdb/testsuite/gdb.python/py-function.exp +++ b/gdb/testsuite/gdb.python/py-function.exp @@ -93,6 +93,7 @@ gdb_py_test_multiple "Test Normal Error" \ "NormalError ()" "" \ "end" "" +gdb_test_no_output "set python print-stack on" gdb_test "print \$normalerror()" "Traceback.*File.*line 5.*in invoke.*RuntimeError.*This is a Normal Error.*" \ "Test a Runtime error. There should be a stack trace." diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp index 1fd8c6f..911725f 100644 --- a/gdb/testsuite/gdb.python/py-prettyprint.exp +++ b/gdb/testsuite/gdb.python/py-prettyprint.exp @@ -97,6 +97,7 @@ proc run_lang_tests {lang} { gdb_test_no_output "python pp_ls_encoding = 'UTF-8'" gdb_test "print estring2" "\"embedded \", " + gdb_test_no_output "set python print-stack on" gdb_test "print hint_error" "Exception: hint failed\r\nhint_error_val" gdb_test "print c" " = container \"container\" with 2 elements = {$nl *.0. = 23,$nl *.1. = 72$nl}" diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp index e0deb63..8906bbc 100644 --- a/gdb/testsuite/gdb.python/python.exp +++ b/gdb/testsuite/gdb.python/python.exp @@ -178,3 +178,18 @@ gdb_test "python gdb.write(\"Foo\\n\")" "Foo" "Test default write" gdb_test "python gdb.write(\"Error stream\\n\", stream=gdb.STDERR)" "Error stream" "Test stderr write" gdb_test "python gdb.write(\"Normal stream\\n\", stream=gdb.STDOUT)" "Normal stream" "Test stdout write" gdb_test "python gdb.write(\"Log stream\\n\", stream=gdb.STDLOG)" "Log stream" "Test stdlog write" + +# Deprecate maint set/show python print-stack +gdb_test "maint show python print-stack" \ + "Warning: command 'maintenance show python print-stack' is deprecated.*Use 'show python print-stack'.*" \ + "Test deprecation maint show warning." +gdb_test "maint set python print-stack off" \ + "Warning: command 'maintenance set python print-stack' is deprecated.*Use 'set python print-stack'.*" \ + "Test deprecation maint set warning." +gdb_test "show python print-stack" \ + "Whether Python stack will be printed on error is off.*" \ + "Test print-backtrace show setting. Default off." +gdb_py_test_silent_cmd "set python print-stack on" \ + "Test print-backtrace set setting" 1 +gdb_test "show python print-stack" \ + "Whether Python stack will be printed on error is on.*" \