diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 66eb397..e9c20c9 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -12534,35 +12534,20 @@ ada_add_global_exceptions (regex_t *preg, VEC(ada_exc_info) **exceptions) } } -/* Return a vector of ada_exc_info. - - If REGEXP is NULL, all exceptions are included in the result. - Otherwise, it should contain a valid regular expression, - and only the exceptions whose name match that regular expression - are included in the result. +/* Implements ada_exceptions_list with the regular expression passed + as a regex_t, rather than a string. - The exceptions are sorted in the following order: - - Standard exceptions (defined by the Ada language), in - alphabetical order; - - Exceptions only visible from the current frame, in - alphabetical order; - - Exceptions whose scope is global, in alphabetical order. */ + If not NULL, PREG is used to filter out exceptions whose names + do not match. Otherwise, all exceptions are listed. */ -VEC(ada_exc_info) * -ada_exceptions_list (const char *regexp) +static VEC(ada_exc_info) * +ada_exceptions_list_1 (regex_t *preg) { VEC(ada_exc_info) *result = NULL; struct cleanup *old_chain = make_cleanup (VEC_cleanup (ada_exc_info), &result); - regex_t *preg = NULL; int prev_len; - if (regexp != NULL) - { - preg = alloca (sizeof (regex_t)); - compile_rx_or_error (preg, regexp, _("invalid regular expression")); - } - /* First, list the known standard exceptions. These exceptions need to be handled separately, as they are usually defined in runtime units that have been compiled without debugging info. */ @@ -12592,6 +12577,38 @@ ada_exceptions_list (const char *regexp) return result; } +/* Return a vector of ada_exc_info. + + If REGEXP is NULL, all exceptions are included in the result. + Otherwise, it should contain a valid regular expression, + and only the exceptions whose names match that regular expression + are included in the result. + + The exceptions are sorted in the following order: + - Standard exceptions (defined by the Ada language), in + alphabetical order; + - Exceptions only visible from the current frame, in + alphabetical order; + - Exceptions whose scope is global, in alphabetical order. */ + +VEC(ada_exc_info) * +ada_exceptions_list (const char *regexp) +{ + VEC(ada_exc_info) *result = NULL; + struct cleanup *old_chain = NULL; + regex_t reg; + + if (regexp != NULL) + old_chain = compile_rx_or_error (®, regexp, + _("invalid regular expression")); + + result = ada_exceptions_list_1 (regexp != NULL ? ® : NULL); + + if (old_chain != NULL) + do_cleanups (old_chain); + return result; +} + /* Implement the "info exceptions" command. */ static void