This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [python] [patch] PR python/13329

>>>>> "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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]