Re: Several regressions and we branch soon.

Yao Qi
2015-06-24T11:55:14Z

Patrick Palka <patrick@parcs.ath.cx> writes:

> The problem here seems to be that the "show" function corresponding to
> the "mpx bound" command calls error("Intel(R) Memory Protection
> Extensions not supported on this target."); which throws an exception
> that causes the entire "info set"/"show" loop to exit early. Should

Yes, I think your analysis is correct.

> "show foo" ever throw an exception? Should the "info set"/"show" loop
> expect an exception to be thrown from a show function?

IMO, "show foo" shouldn't throw an exception.

>
> This diff fixes the default.exp FAILs as far as I can tell:
>

Thanks for the fix, but I feel that the original code has some drawbacks,

> diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
> index 42d0346..d11efa1 100644
> --- a/gdb/i386-tdep.c
> +++ b/gdb/i386-tdep.c
> @@ -8777,11 +8777,17 @@ i386_mpx_info_bounds (char *args, int from_tty)
> struct type *data_ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
>
> if (!i386_mpx_enabled ())
> - error (_("Intel(R) Memory Protection Extensions not\
> - supported on this target."));
> + {
> + printf_unfiltered (_("Intel(R) Memory Protection Extensions not "
> + "supported on this target.\n"));
> + return;
> + }
>
> if (args == NULL)
> - error (_("Address of pointer variable expected."));
> + {
> + printf_unfiltered (_("Address of pointer variable expected.\n"));
> + return;
> + }
>
> addr = parse_and_eval_address (args);

It is odd that command "info mpx bounds" requires an argument, which is
an address. The set/show command pair works in a way that command set
modify or update some state of GDB, and command info just display the
state of GDB. That is to say, "set mpx bounds ADDRESS" should set
address, which is stored somewhere in GDB (in a global variable or a
per-inferior variable), and "info mpx bounds" shows the current state or
setting in GDB, no argument is needed.

If this is a right direction, I can give a patch.

b.t.w, is it a good (or bad) idea to register this command if mpx
is supported on the target?

--
Yao (齐尧)