This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA/Ada] exception catchpoints: support multiple versions of runtimes


Hello,

Maybe two or three weeks after we contributed the support for Ada exception
catchpoints, we had to make some modifications in our runtime to maintain
support for unhandled exceptions: With the current GDB sources, what
we do is that we break on __gnat_unhandled_exception, and then when we
hit that breakpoint, go up the call stack until we find
__gnat_raise_nodefer_with_msg. We then extract the name of the exception
from a local variable "Id".

Well, because __gnat_raise_nodefer_with_msg is a "noreturn" function,
things stopped working. The compiler is becoming more and more effective
in its optimizations and tricking it into being able to inspect that
variable in a unified way for all the targets we support has become
too much of an issue.

So instead, we have introduced a new unit (System.Exceptions, specs
are in s-except.ads), that defines a certain number of hooks that
the runtime calls when the debugger needs to know about exceptions.
The idea is to have this unit compiled at -O0 instead of -O1,
and to no longer require to go up the call stack to fetch the name
of the exception.

So, with recent versions of GNAT, exception catchpoints should break
on __gnat_debug_raise_exception. Unhandled exception catchpoints should
still be breaking on __gnat_unhandled_exception (no change in the name
this time), but the exception name can be directly extracted from
the function parameter (named "E"). Catchpoints on failed assertions
are unchanged.

I hope that these changes will be pushed to the FSF GCC soon.

Here is a patch that allows us to support both the new scheme as
well as the old one. So it can be applied today. The idea is to
introduce a new structure that describes the parts that differ
between one version of the runtime and the other. The parts that
are common are unchanged. And we have a sniffer that determines
which description to use.

I have tested this patch with both an older version of the compiler
as well as a recent one, and in both cases catch_ex.exp has all passes.

2007-03-06  Joel Brobecker  <brobecker@adacore.com>

        Add support for multiple versions of the Ada runtime:
        * ada-lang.c: Update general comments on how Ada exception catchpoints
        are implemented.
        (raise_sym_name, raise_unhandled_sym_name, raise_assert_sym_name)
        (__gnat_raise_nodefer_with_msg): Delete.
        (ada_unhandled_exception_name_addr_ftype): New type.
        (exception_support_info): New type.
        (ada_unhandled_exception_name_addr): Add forward declaration.
        (ada_unhandled_exception_name_addr_from_raise): Likewise.
        (default_exception_support_info): New constant.
        (exception_support_info_fallback): Likewise.
        (exception_info): New global variable.
        (ada_exception_support_info_sniffer): New function.
        (ada_executable_changed_observer): Likewise.
        (ada_unhandled_exception_name_addr_from_raise): Renamed from
        ada_unhandled_exception_name_addr.
        (ada_unhandled_exception_name_addr): Reimplement to match the
        latest Ada runtime implementation.
        (error_breakpoint_runtime_sym_not_found): Delete.
        (ada_exception_sym_name): Get the exception sym name from
        exception_info rather than hardcoding it.
        (ada_exception_sal): Add call to ada_exception_support_info_sniffer.
        Update error handling.
        * Makefile.in (ada-lang.o): Add dependency on observer.h.

Tested in x86-linux, no regression. Before applying these changes,
I think we get 1 FAIL when I use a recent version of GNAT.

OK to apply?

Thanks,
-- 
Joel

Attachment: catchex.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]