From 3d0b0fa396d73f8c06709d0c2001366d9d8d5239 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Tue, 30 Sep 2008 20:42:21 +0000 Subject: [PATCH] * ada-lang.c (standard_exc): New static constant. (ada_exception_catchpoint_cond_string): Add special handling for the predefined exceptions. --- gdb/ChangeLog | 6 ++++++ gdb/ada-lang.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9b8d0f488b8..4a02fb7c5d7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2008-09-30 Joel Brobecker + + * ada-lang.c (standard_exc): New static constant. + (ada_exception_catchpoint_cond_string): Add special handling + for the predefined exceptions. + 2008-09-30 Joel Brobecker * ada-lang.c (ADA_RETAIN_DOTS): Delete this dead macro. Update diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 2b73bdbdab9..45a59f2c57c 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -9650,6 +9650,15 @@ enum exception_catchpoint_kind ex_catch_assert }; +/* Ada's standard exceptions. */ + +static char *standard_exc[] = { + "constraint_error", + "program_error", + "storage_error", + "tasking_error" +}; + typedef CORE_ADDR (ada_unhandled_exception_name_addr_ftype) (void); /* A structure that describes how to support exception catchpoints @@ -10334,6 +10343,35 @@ ada_exception_breakpoint_ops (enum exception_catchpoint_kind ex) static char * ada_exception_catchpoint_cond_string (const char *exp_string) { + int i; + + /* The standard exceptions are a special case. They are defined in + runtime units that have been compiled without debugging info; if + EXP_STRING is the not-fully-qualified name of a standard + exception (e.g. "constraint_error") then, during the evaluation + of the condition expression, the symbol lookup on this name would + *not* return this standard exception. The catchpoint condition + may then be set only on user-defined exceptions which have the + same not-fully-qualified name (e.g. my_package.constraint_error). + + To avoid this unexcepted behavior, these standard exceptions are + systematically prefixed by "standard". This means that "catch + exception constraint_error" is rewritten into "catch exception + standard.constraint_error". + + If an exception named contraint_error is defined in another package of + the inferior program, then the only way to specify this exception as a + breakpoint condition is to use its fully-qualified named: + e.g. my_package.constraint_error. */ + + for (i = 0; i < sizeof (standard_exc) / sizeof (char *); i++) + { + if (strcmp (standard_exc [i], exp_string) == 0) + { + return xstrprintf ("long_integer (e) = long_integer (&standard.%s)", + exp_string); + } + } return xstrprintf ("long_integer (e) = long_integer (&%s)", exp_string); } -- 2.30.2