* [patch] PR python/12438
@ 2011-06-30 9:38 Phil Muldoon
2011-06-30 19:58 ` Tom Tromey
2011-10-17 13:00 ` Kevin Pouget
0 siblings, 2 replies; 11+ messages in thread
From: Phil Muldoon @ 2011-06-30 9:38 UTC (permalink / raw)
To: gdb-patches
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 <pmuldoon@redhat.com>
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 <pmuldoon@redhat.com>
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 <pmuldoon@redhat.com>
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."
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] PR python/12438
2011-06-30 9:38 [patch] PR python/12438 Phil Muldoon
@ 2011-06-30 19:58 ` Tom Tromey
2011-07-07 16:16 ` Phil Muldoon
2011-10-17 13:00 ` Kevin Pouget
1 sibling, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2011-06-30 19:58 UTC (permalink / raw)
To: pmuldoon; +Cc: gdb-patches
>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> 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?
Tom
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] PR python/12438
2011-06-30 19:58 ` Tom Tromey
@ 2011-07-07 16:16 ` Phil Muldoon
2011-07-07 18:47 ` Eli Zaretskii
2011-07-07 18:52 ` Tom Tromey
0 siblings, 2 replies; 11+ messages in thread
From: Phil Muldoon @ 2011-07-07 16:16 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
Tom Tromey <tromey@redhat.com> writes:
>>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> 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 \", <incomplete sequence \\\\302>"
+ 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.*" \
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] PR python/12438
2011-07-07 16:16 ` Phil Muldoon
@ 2011-07-07 18:47 ` Eli Zaretskii
2011-07-07 18:52 ` Tom Tromey
1 sibling, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2011-07-07 18:47 UTC (permalink / raw)
To: pmuldoon; +Cc: tromey, gdb-patches
> From: Phil Muldoon <pmuldoon@redhat.com>
> Cc: gdb-patches@sourceware.org
> Date: Thu, 07 Jul 2011 17:11:36 +0100
>
> --- 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
Thanks. This part is okay, but please lose the @pxref and the anchor,
because the referenced part is just one line away. Instead, say
something like "..., described below."
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] PR python/12438
2011-07-07 16:16 ` Phil Muldoon
2011-07-07 18:47 ` Eli Zaretskii
@ 2011-07-07 18:52 ` Tom Tromey
2011-07-11 17:16 ` Phil Muldoon
1 sibling, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2011-07-07 18:52 UTC (permalink / raw)
To: pmuldoon; +Cc: gdb-patches
>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
Phil> I was adding the new commands to the old list. So you were quite
Phil> right. Sorry about that ;)
No problem.
I think this change should have a NEWS entry -- both to document that
the default changed and to mention the new commands.
Phil> +struct cmd_list_element *maint_set_python_list;
Phil> +struct cmd_list_element *maint_show_python_list;
Phil> +
Phil> +/* Lists for 'set python' commands. */
Phil> +
Phil> +struct cmd_list_element *user_set_python_list;
Phil> +struct cmd_list_element *user_show_python_list;
These can all be static.
Code bits ok with that change.
Tom
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] PR python/12438
2011-07-07 18:52 ` Tom Tromey
@ 2011-07-11 17:16 ` Phil Muldoon
0 siblings, 0 replies; 11+ messages in thread
From: Phil Muldoon @ 2011-07-11 17:16 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
Tom Tromey <tromey@redhat.com> writes:
>>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
>
> Phil> I was adding the new commands to the old list. So you were quite
> Phil> right. Sorry about that ;)
>
> No problem.
>
> I think this change should have a NEWS entry -- both to document that
> the default changed and to mention the new commands.
>
> Phil> +struct cmd_list_element *maint_set_python_list;
> Phil> +struct cmd_list_element *maint_show_python_list;
> Phil> +
> Phil> +/* Lists for 'set python' commands. */
> Phil> +
> Phil> +struct cmd_list_element *user_set_python_list;
> Phil> +struct cmd_list_element *user_show_python_list;
>
> These can all be static.
>
> Code bits ok with that change.
So committed with doc and code changes.
Cheers
Phil
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] PR python/12438
2011-06-30 9:38 [patch] PR python/12438 Phil Muldoon
2011-06-30 19:58 ` Tom Tromey
@ 2011-10-17 13:00 ` Kevin Pouget
2011-10-17 13:49 ` Phil Muldoon
2011-10-19 20:56 ` Tom Tromey
1 sibling, 2 replies; 11+ messages in thread
From: Kevin Pouget @ 2011-10-17 13:00 UTC (permalink / raw)
To: pmuldoon, Tom Tromey; +Cc: gdb-patches
On Thu, Jun 30, 2011 at 11:37 AM, Phil Muldoon <pmuldoon@redhat.com> wrote:
>
> 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.
Hello,
I have a question regarding this patch, which was committed at the end of June,
wouldn't GDB let the user know, one way or an other, that there was
something wrong happened ?
when you run a command, and see to "warning/error" message, you expect
that everything went right, but that's not true when this flag is set,
is it?
I don't know if Python allows to do it, but i think it would be nice
to see something like:
> NameError: global name 'comp' is not define
which is the last line of a python stacktrace
Thanks,
Kevin
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] PR python/12438
2011-10-17 13:00 ` Kevin Pouget
@ 2011-10-17 13:49 ` Phil Muldoon
2011-10-19 20:56 ` Tom Tromey
1 sibling, 0 replies; 11+ messages in thread
From: Phil Muldoon @ 2011-10-17 13:49 UTC (permalink / raw)
To: Kevin Pouget; +Cc: Tom Tromey, gdb-patches
Kevin Pouget <kevin.pouget@gmail.com> writes:
> On Thu, Jun 30, 2011 at 11:37 AM, Phil Muldoon <pmuldoon@redhat.com> wrote:
>>
>> 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.
>
> Hello,
>
> I have a question regarding this patch, which was committed at the end of June,
> wouldn't GDB let the user know, one way or an other, that there was
> something wrong happened ?
>
> when you run a command, and see to "warning/error" message, you expect
> that everything went right, but that's not true when this flag is set,
> is it?
>
> I don't know if Python allows to do it, but i think it would be nice
> to see something like:
>
>> NameError: global name 'comp' is not define
>
> which is the last line of a python stacktrace
It was set that way so that "shipped" versions of GDB would not have
endless amounts of exceptions when pretty-printing. However I too have
begun to have second thoughts. I do multiple builds, and, inevitably, I
forget to turn error-printing back on, so that really throws me
sometimes. Fortunately, the should-print/should-not-print and the
resultant exception printing code is located centrally. I think your
idea is a good one, though I am trying to decide how useful that
information would be, and if something additional brief data should be
printed.
Cheers,
Phil
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] PR python/12438
2011-10-17 13:00 ` Kevin Pouget
2011-10-17 13:49 ` Phil Muldoon
@ 2011-10-19 20:56 ` Tom Tromey
2011-10-20 12:33 ` Phil Muldoon
2011-10-21 9:43 ` Kevin Pouget
1 sibling, 2 replies; 11+ messages in thread
From: Tom Tromey @ 2011-10-19 20:56 UTC (permalink / raw)
To: Kevin Pouget; +Cc: pmuldoon, gdb-patches
Kevin> I have a question regarding this patch, which was committed at
Kevin> the end of June, wouldn't GDB let the user know, one way or an
Kevin> other, that there was something wrong happened ?
I think gdbpy_print_stack is mostly called in "internal" situations,
where printing something will mess up the output.
Ordinary commands and such that fail should convert the Python exception
to a gdb exception, leading to what you'd expect.
I might be misremembering. Concrete examples would help.
Kevin> I don't know if Python allows to do it, but i think it would be nice
Kevin> to see something like:
>> NameError: global name 'comp' is not define
Kevin> which is the last line of a python stacktrace
I think it could be done.
We can always add more values for "maint set python print-stack".
Tom
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] PR python/12438
2011-10-19 20:56 ` Tom Tromey
@ 2011-10-20 12:33 ` Phil Muldoon
2011-10-21 9:43 ` Kevin Pouget
1 sibling, 0 replies; 11+ messages in thread
From: Phil Muldoon @ 2011-10-20 12:33 UTC (permalink / raw)
To: Tom Tromey; +Cc: Kevin Pouget, gdb-patches
Tom Tromey <tromey@redhat.com> writes:
>>> NameError: global name 'comp' is not define
>
> Kevin> which is the last line of a python stacktrace
>
> I think it could be done.
> We can always add more values for "maint set python print-stack".
We deprecated that command when we flipped the stack-trace switch. The
new command is "set python print-stack"
Cheers,
Phil
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] PR python/12438
2011-10-19 20:56 ` Tom Tromey
2011-10-20 12:33 ` Phil Muldoon
@ 2011-10-21 9:43 ` Kevin Pouget
1 sibling, 0 replies; 11+ messages in thread
From: Kevin Pouget @ 2011-10-21 9:43 UTC (permalink / raw)
To: Tom Tromey; +Cc: pmuldoon, gdb-patches
On Wed, Oct 19, 2011 at 10:56 PM, Tom Tromey <tromey@redhat.com> wrote:
> Kevin> I have a question regarding this patch, which was committed at
> Kevin> the end of June, wouldn't GDB let the user know, one way or an
> Kevin> other, that there was something wrong happened ?
>
> I think gdbpy_print_stack is mostly called in "internal" situations,
> where printing something will mess up the output.
>
> Ordinary commands and such that fail should convert the Python exception
> to a gdb exception, leading to what you'd expect.
>
> I might be misremembering. Concrete examples would help.
I don't think so about gdbpy_print_stack, I think it's used every time
an exception is caught, either originating from [user-] python code,
or from GDB's internals
the first example I can thing about it:
class BP(gdb.Breakpoint):
def stop(self):
raise ValueError
which will silently fail if "set python print-stack" is off
> Kevin> I don't know if Python allows to do it, but i think it would be nice
> Kevin> to see something like:
>
>>> NameError: global name 'comp' is not define
>
> Kevin> which is the last line of a python stacktrace
>
> I think it could be done.
> We can always add more values for "maint set python print-stack".
I posted a bug report for that;
http://sourceware.org/bugzilla/show_bug.cgi?id=13329
I'll give in a try in the next weeks or so, if still available
Thanks,
Kevin
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2011-10-21 8:42 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-30 9:38 [patch] PR python/12438 Phil Muldoon
2011-06-30 19:58 ` Tom Tromey
2011-07-07 16:16 ` Phil Muldoon
2011-07-07 18:47 ` Eli Zaretskii
2011-07-07 18:52 ` Tom Tromey
2011-07-11 17:16 ` Phil Muldoon
2011-10-17 13:00 ` Kevin Pouget
2011-10-17 13:49 ` Phil Muldoon
2011-10-19 20:56 ` Tom Tromey
2011-10-20 12:33 ` Phil Muldoon
2011-10-21 9:43 ` Kevin Pouget
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox