Re: [RFC/Ada 1/2] Add command to list Ada exceptions

Tom Tromey
2013-11-07T16:07:17Z

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

Joel> (gdb) info exceptions
Joel> All defined exceptions:
Joel> constraint_error: 0x613dc0

Since the name of the command is unavoidably generic, how about adding
"Ada" into the output somewhere, so that non-Ada users don't get
confused when the command doesn't do anything useful for them?

Like

(gdb) info exceptions
All defined Ada exceptions:
constraint_error: 0x613dc0

Joel> + for (i = 0; i < sizeof (standard_exc) / sizeof (char *); i++)

How about ARRAY_SIZE here?

Joel> +static void
Joel> +ada_add_exceptions_from_frame (regex_t *preg, struct frame_info *frame,
Joel> + VEC(ada_exc_info) **exceptions)
Joel> +{
[...]
Joel> + if (BLOCK_FUNCTION (block))

The current style requires a "!= NULL" here.

Joel> +VEC(ada_exc_info) *
Joel> +ada_exceptions_list (char *regexp)

I think regexp can be const.

Joel> + if (regexp != NULL)
Joel> + {
Joel> + int status;
Joel> +
Joel> + preg = alloca (sizeof (regex_t));
Joel> + status = regcomp (preg, regexp, REG_NOSUB);
Joel> + if (status != 0)
Joel> + {
Joel> + char *err = get_regcomp_error (status, preg);
Joel> +
Joel> + make_cleanup (xfree, err);
Joel> + error (_("Invalid regexp (%s): %s"), err, regexp);
Joel> + }
Joel> + make_regfree_cleanup (preg);
Joel> + }

These days there is compile_rx_or_error, which wraps all this up.

Joel> + printf_filtered (regexp
Joel> + ? "All exceptions matching regular expression \"%s\":\n"
Joel> + : "All defined exceptions:\n", regexp);

This needs an explicit "== NULL".

Tom