From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15047 invoked by alias); 30 Jun 2011 09:38:11 -0000 Received: (qmail 15031 invoked by uid 22791); 30 Jun 2011 09:38:09 -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, 30 Jun 2011 09:37:49 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5U9bn8G003797 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 30 Jun 2011 05:37:49 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p5U9bmse002225 for ; Thu, 30 Jun 2011 05:37:48 -0400 From: Phil Muldoon To: gdb-patches@sourceware.org Subject: [patch] PR python/12438 Reply-to: pmuldoon@redhat.com X-URL: http://www.redhat.com Date: Thu, 30 Jun 2011 09:38:00 -0000 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-06/txt/msg00484.txt.bz2 This patch addresses bug PR python/12438. Mark - and other users - have asked that maint set python print-stack is off by default. This makes sense to me, as while stack-traces are useful, they can impact readability of GDB output. Python developers can always turn it back on again. Additionally, I have deprecated maint set/show python print-stack and promoted the setting to the more user visible set/show python print-backtrace. Finally a note on the name change. I wanted to keep print-stack, but it appears when you deprecate a command it deprecates it among all command lists. Deprecating it and adding it back after just un-deprecates the maint settings. I could not find a way of just deprecating maint set/show python print-stack, and leaving the user visible set python print-stack alone. If someone knows a way, I'll happily change it. Cheers, Phil -- 2011-06-30 Phil Muldoon PR python/12438 * python/python.c: Set gdbpy_should_print_stack default to off. (set_python): Deprecate maint set python print-stack to class_deprecate. (_initialize_python): Deprecate maint set/show python print-stack. Add new prefix command, python. Add new setting, print-backtrace. 2011-06-30 Phil Muldoon PR python/12438 * gdb.python/python.exp: Add maint set/show python print-stack deprecated tests. Add set/show python print-backtrace tests. 2011-06-30 Phil Muldoon PR python/12438 * gdb.texinfo (Python Commands): Add deprecate note to maint set/show python print-stack. Document set/show python print-backtrace. -- diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 3a705c2..61419b0 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -20791,11 +20791,21 @@ 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 -disabled. +This command is now deprecated. Instead use @code{set python print +backtrace} (@pxref{set python print-backtrace}). By default, +@value{GDBN} will not 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}, then Python stack printing is enabled; if +@code{off}, the default, then Python stack printing is disabled. + +@kindex set python print-backtrace +@item set python print-backtrace +@anchor{set python print-backtrace} +By default, @value{GDBN} will not print a backtrace when an error +occurs in a Python script. This can be controlled using @code{set +python print-backtrace}: if @code{on}, then Python backtrace printing +is enabled; if @code{off}, the default, then Python backtrace printing +is disabled. @end table It is also possible to execute a Python script from the @value{GDBN} diff --git a/gdb/python/python.c b/gdb/python/python.c index ddfe9ba..5c2ff40 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 @@ -944,7 +944,10 @@ struct cmd_list_element *show_python_list; static void set_python (char *args, int from_tty) { - help_list (set_python_list, "maintenance set python ", -1, gdb_stdout); + help_list (set_python_list, "maintenance set python ", + class_deprecated, gdb_stdout); + help_list (set_python_list, "set python ", all_commands, + gdb_stdout); } /* Function for use by 'maint show python' prefix command. */ @@ -963,6 +966,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 _("\ @@ -1002,6 +1008,35 @@ Enables or disables printing of Python stack traces."), &set_python_list, &show_python_list); + /* Deprecate maint set/show python print-stack in favour of + non-maintenance alternatives. */ + cmd_name = "python print-stack"; + cmd = lookup_cmd (&cmd_name, maintenance_set_cmdlist, "", -1, 0); + deprecate_cmd (cmd, "set python print-backtrace"); + cmd_name = "python print-stack"; /* Reset name. */ + cmd = lookup_cmd (&cmd_name, maintenance_show_cmdlist, "", -1, 0); + deprecate_cmd (cmd, "show python print-backtrace"); + + /* Add set/show python print-stack. */ + add_prefix_cmd ("python", no_class, show_python, + _("Prefix command for python preference settings."), + &show_python_list, "show python ", 0, + &showlist); + + add_prefix_cmd ("python", no_class, set_python, + _("Prefix command for python preference settings."), + &set_python_list, "set python ", 0, + &setlist); + + add_setshow_boolean_cmd ("print-backtrace", no_class, + &gdbpy_should_print_stack, _("\ +Enable or disable printing of Python backtraces on error."), _("\ +Show whether Python backtraces will be printed on error."), _("\ +Enables or disables printing of Python backtraces."), + NULL, NULL, + &set_python_list, + &show_python_list); + #ifdef HAVE_PYTHON #ifdef WITH_PYTHON_PATH /* Work around problem where python gets confused about where it is, diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp index a68dd24..a36c622 100644 --- a/gdb/testsuite/gdb.python/python.exp +++ b/gdb/testsuite/gdb.python/python.exp @@ -178,3 +178,19 @@ 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-backtrace'.*" \ + "Test deprecation maint show warning." +gdb_test "set python print-stack off" \ + "Warning: command 'set python print-stack' is deprecated.*Use 'set python print-backtrace'.*" \ + "Test deprecation maint set warning." +gdb_test "show python print-backtrace" \ + "Whether Python backtraces will be printed on error is off.*" \ + "Test print-backtrace show setting. Default off." +gdb_py_test_silent_cmd "set python print-backtrace on" \ + "Test print-backtrace set setting" 1 +gdb_test "show python print-backtrace" \ + "Whether Python backtraces will be printed on error is on.*" \ + "Test print-backtrace show setting. Check On."