Add command to list Ada exceptions

This patch adds a new command "info exceptions" whose purpose is to
provide the list of exceptions currently defined in the inferior.
The usage is:

    (gdb) info exceptions [REGEXP]

Without argument, the command lists all exceptions.  Otherwise,
only those whose name match REGEXP are listed.

For instance:

    (gdb) info exceptions
    All defined Ada exceptions:
    constraint_error: 0x613dc0
    program_error: 0x613d40
    storage_error: 0x613d00
    tasking_error: 0x613cc0
    global_exceptions.a_global_exception: 0x613a80
    global_exceptions.a_private_exception: 0x613ac0

The name of the command, as well as its output is part of a legacy
I inherited long ago. It's output being parsed by frontends such as
GPS, I cannot easily change it. Same for the command name.

The implementation is mostly self-contained, and is written in a way
that should make it easy to implement the GDB/MI equivalent. The
careful reviewer will notice that the code added in ada-lang.h could
normally be made private inside ada-lang.c.  But these will be used
by the GDB/MI implementation.  Rather than making those private now,
only to move them later, I've made them public right away.

gdb/ChangeLog:

        * ada-lang.h: #include "vec.h".
        (struct ada_exc_info): New.
        (ada_exc_info): New typedef.
        (DEF_VEC_O(ada_exc_info)): New vector.
        (ada_exceptions_list): Add declaration.
        * ada-lang.c (ada_is_exception_sym)
        (ada_is_non_standard_exception_sym, compare_ada_exception_info)
        (sort_remove_dups_ada_exceptions_list)
        (ada_exc_search_name_matches, ada_add_standard_exceptions)
        (ada_add_exceptions_from_frame, ada_add_global_exceptions)
        (ada_exceptions_list_1, ada_exceptions_list)
        (info_exceptions_command): New function.
        (_initialize_ada_language): Add "info exception" command.

gdb/testsuite/ChangeLog:

        * gdb.ada/info_exc: New testcase.
This commit is contained in:
Joel Brobecker 2013-11-07 17:40:48 +04:00
parent 304a8ac17c
commit 778865d3e2
7 changed files with 488 additions and 0 deletions

View file

@ -27,6 +27,7 @@ struct type_print_options;
#include "value.h"
#include "gdbtypes.h"
#include "breakpoint.h"
#include "vec.h"
/* Names of specific files known to be part of the runtime
system and that might consider (confusing) debugging information.
@ -389,6 +390,21 @@ extern void create_ada_exception_catchpoint
char *excep_string, char *cond_string, int tempflag, int disabled,
int from_tty);
/* Some information about a given Ada exception. */
typedef struct ada_exc_info
{
/* The name of the exception. */
const char *name;
/* The address of the symbol corresponding to that exception. */
CORE_ADDR addr;
} ada_exc_info;
DEF_VEC_O(ada_exc_info);
extern VEC(ada_exc_info) *ada_exceptions_list (const char *regexp);
/* Tasking-related: ada-tasks.c */
extern int valid_task_id (int);