old-cross-binutils/gdb/testsuite/gdb.ada
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
..
aliased_array [Ada] Handle reference to array descriptors 2012-02-29 19:33:02 +00:00
array_bounds Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
array_return Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
array_subscript_addr Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
arrayidx Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
arrayparam Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
arrayptr Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
atomic_enum Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
call_pn Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
catch_ex Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
char_enum Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
char_param Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
complete Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
cond_lang Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
dyn_loc Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
enum_idx_packed [Ada] print packed arrays indexed by enumerated type 2012-02-29 19:34:40 +00:00
exec_changed Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
exprs Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
fixed_cmp Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
fixed_points Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
formatted_ref Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
frame_args Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
fullname_bp Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
fun_addr Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
fun_in_declare Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
funcall_param Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
homonym Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
int_deref Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
interface Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
lang_switch Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
mi_catch_ex Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
mi_task_arg GDB/MI: crash printing "_task" (Ada) argument 2012-02-03 07:32:40 +00:00
mi_task_info Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
mod_from_name Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
nested Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
null_array Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
null_record Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
packed_array Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
packed_tagged Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
print_chars Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
ptr_typedef Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
ptype_field Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
ptype_tagged_param Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
rec_return Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
ref_param Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
ref_tick_size Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
same_enum Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
small_reg_param Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
start Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
str_ref_cmp Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
sym_print_name Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
taft_type Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
tagged Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
tagged_not_init [Ada] avoid error message pollution with uninitialized tagged variable 2012-02-29 19:46:48 +00:00
task_bp Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
tasks Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
tick_last_segv Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
type_coercion Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
uninitialized_vars Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
variant_record_packed_array Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
watch_arg Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
whatis_array_val [Ada] whatis not printing array type name for value from history 2012-02-29 19:29:12 +00:00
widewide Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
aliased_array.exp [Ada] Handle reference to array descriptors 2012-02-29 19:33:02 +00:00
array_bounds.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
array_return.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
array_subscript_addr.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
arrayidx.exp [Ada] print packed arrays indexed by enumerated type 2012-02-29 19:34:40 +00:00
arrayparam.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
arrayptr.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
assign_1.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
atomic_enum.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
boolean_expr.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
call_pn.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
catch_ex.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
char_enum.exp Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
char_param.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
complete.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
cond_lang.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
dyn_loc.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
enum_idx_packed.exp [Ada] print packed arrays indexed by enumerated type 2012-02-29 19:34:40 +00:00
exec_changed.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
exprs.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
fixed_cmp.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
fixed_points.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
formatted_ref.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
frame_args.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
fullname_bp.exp Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
fun_addr.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
fun_in_declare.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
funcall_param.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
gnat_ada.gpr Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
homonym.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
info_types.c Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
info_types.exp Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
int_deref.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
interface.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
lang_switch.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
Makefile.in 2011-02-22 Michael Snyder <msnyder@vmware.com> 2011-02-22 20:52:49 +00:00
mi_catch_ex.exp Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
mi_task_arg.exp GDB/MI: crash printing "_task" (Ada) argument 2012-02-03 07:32:40 +00:00
mi_task_info.exp 2012-01-18 Pedro Alves <palves@redhat.com> 2012-01-18 17:00:17 +00:00
mod_from_name.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
nested.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
null_array.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
null_record.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
packed_array.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
packed_tagged.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
print_chars.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
print_pc.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
ptr_typedef.exp Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
ptype_arith_binop.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
ptype_field.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
ptype_tagged_param.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
rec_return.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
ref_param.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
ref_tick_size.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
same_enum.exp Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
small_reg_param.exp Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
start.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
str_ref_cmp.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
sym_print_name.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
taft_type.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
tagged.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
tagged_not_init.exp [Ada] avoid error message pollution with uninitialized tagged variable 2012-02-29 19:46:48 +00:00
task_bp.exp Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00
tasks.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
tick_last_segv.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
type_coercion.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
uninitialized_vars.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
variant_record_packed_array.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
watch_arg.exp 2012-01-16 Pedro Alves <palves@redhat.com> 2012-01-16 16:21:53 +00:00
whatis_array_val.exp [Ada] whatis not printing array type name for value from history 2012-02-29 19:29:12 +00:00
widewide.exp Copyright year update in most files of the GDB Project. 2012-01-04 08:17:56 +00:00