binutils-gdb/gdb/testsuite
Joel Brobecker 1b61134393 [Ada] avoid error message pollution with uninitialized tagged variable
Consider the following function...

  3 procedure Foo is
  4    I : Integer := Ident (10);
  5    Obj : Base;
  6 begin
  7    Obj.X := I;
  8    Do_Nothing (Obj.X'Address);
  9 end Foo;

... where type "Base" is defined as a plain tagged record. If the user
stops execution before "Obj" gets initialized (for example, by inserting
a breakpoint "on" the function - or in other words, by inserting a
breakpoint using the function name as the location), one might get
the following of output if you try printing the value of obj:

    (gdb) p obj
    object size is larger than varsize-limit
    object size is larger than varsize-limit
    object size is larger than varsize-limit
    $1 = object size is larger than varsize-limit
    (x => 4204154)

Same thing with "info locals":

   (gdb) info locals
    i = 0
    obj = object size is larger than varsize-limit
    (x => 4204154)

We have also seen different error messages such as "Cannot read
memory at 0x...".

The error happens because we are trying to read the dispatch table
of a tagged type variable before it gets initialized.  So the errors
might legitimately occur, and are supposed to be be contained.
However, the way things are written in ada-lang.c:ada_tag_name,
although the exception is in fact contained, the error message still
gets to be printed out.

This patch prevents this from happening by eliminating the use of
catch_errors, and using a TRY_CATCH block instead.  Doing this removed
the need to use functions specifically fitted for catch_errors, and
thus some other simplifications could me made.  In the end, the code
got reorganized a bit to better show the logic behind it, as well as
the common patterns.

gdb/ChangeLog:

        * ada-lang.c (struct tag_args): Delete.
        (ada_get_tsd_type): Function body moved up in source file.
        (ada_tag_name_1, ada_tag_name_2): Delete.
        (ada_get_tsd_from_tag): New function.
        (ada_tag_name_from_tsd): New function.
        (ada_tag_name): Use a TRY_CATCH block instead of catch_errors
        to determine the tag name.

gdb/testsuite/ChangeLog:

        * gdb.ada/tagged_not_init: New testcase.
2012-02-29 19:46:48 +00:00
..
boards 2012-01-27 Pedro Alves <palves@redhat.com> 2012-01-27 13:02:22 +00:00
config 2012-01-27 Pedro Alves <palves@redhat.com> 2012-01-27 13:02:22 +00:00
gdb.ada [Ada] avoid error message pollution with uninitialized tagged variable 2012-02-29 19:46:48 +00:00
gdb.arch 2012-02-21 Pedro Alves <palves@redhat.com> 2012-02-21 22:01:10 +00:00
gdb.asm 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
gdb.base gdb/ 2012-02-29 14:59:41 +00:00
gdb.cell Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
gdb.cp * gdb.cp/breakpoint.exp (test_breakpoint): Fix the runto_main 2012-02-27 20:48:25 +00:00
gdb.disasm 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
gdb.dwarf2 2012-02-21 Pedro Alves <palves@redhat.com> 2012-02-21 22:01:10 +00:00
gdb.fortran 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
gdb.gdb 2012-02-02 Pedro Alves <palves@redhat.com> 2012-02-02 18:09:07 +00:00
gdb.hp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
gdb.java 2012-01-19 Pedro Alves <palves@redhat.com> 2012-01-19 12:37:28 +00:00
gdb.linespec gdb 2012-01-16 20:40:53 +00:00
gdb.mi 2012-02-21 Pedro Alves <palves@redhat.com> 2012-02-21 22:01:10 +00:00
gdb.modula2 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
gdb.multi 2012-01-26 Pedro Alves <palves@redhat.com> 2012-01-26 10:09:43 +00:00
gdb.objc 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
gdb.opencl 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
gdb.opt 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
gdb.pascal 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
gdb.python PR python/12070: 2012-02-17 19:24:27 +00:00
gdb.reverse gdb/testsuite/ 2012-02-29 14:55:46 +00:00
gdb.server 2012-02-15 Pedro Alves <palves@redhat.com> 2012-02-15 12:51:17 +00:00
gdb.stabs 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
gdb.threads 2012-02-24 Pedro Alves <palves@redhat.com> 2012-02-24 14:06:29 +00:00
gdb.trace gdb/gdbserver: 2012-02-29 13:59:41 +00:00
gdb.xml Copyright year update in most files of the GDB Project. 2012-01-04 08:28:28 +00:00
lib 2012-02-21 Pedro Alves <palves@redhat.com> 2012-02-21 22:01:10 +00:00
ChangeLog [Ada] avoid error message pollution with uninitialized tagged variable 2012-02-29 19:46:48 +00:00
Makefile.in Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
TODO
aclocal.m4
configure
configure.ac Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
dg-extract-results.sh Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00