binutils-gdb/gdb/testsuite/gdb.ada
Joel Brobecker c1b5a1a6e7 Internal error trying to print uninitialized string.
Trying to print the value of a string whose size is not known at
compile-time before it gets assigned a value can lead to the following
internal error:

    (gdb) p my_str
    $1 =
    /[...]/utils.c:1089: internal-error: virtual memory exhausted.

What happens is that my_str is described as a reference to an array
type whose bounds are dynamic. During the read of that variable's
value (in default_read_var_value), we end up resolving dynamic types
which, for reference types, makes us also resolve the target of that
reference type. This means we resolve our variable to a reference
to an array whose bounds are undefined, and unfortunately very far
appart.

So, when we pass that value to ada-valprint, and in particular to
da_val_print_ref, we eventually try to allocate too large of a buffer
corresponding to the (bogus) size of our array, hence the internal
error.

This patch fixes the problem by adding a size_check before trying
to print the dereferenced value. To perform this check, a function
that was previously specific to ada-lang.c (check_size) gets
exported, and renamed to something less prone to name collisions
(ada_ensure_varsize_limit).

gdb/ChangeLog:

        * ada-lang.h (ada_ensure_varsize_limit): Declare.
        * ada-lang.c (check_size): Remove advance declaration.
        (ada_ensure_varsize_limit): Renames check_size.
        Replace calls to check_size by calls to ada_ensure_varsize_limit
        throughout.
        * ada-valprint.c (ada_val_print_ref): Add call to
        ada_ensure_varsize_limit.  Add comment explaining why.

gdb/testsuite/ChangeLog:

        * gdb.ada/str_uninit: New testcase.
2014-12-13 11:00:24 -05:00
..
O2_float_param Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
addr_arith [Ada] Error adding/subtracting pointer value to/from integral. 2014-10-14 14:05:11 -07:00
aliased_array Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
arr_arr [Ada] Ignore __XA types when redundant. 2014-11-19 12:48:07 +04:00
array_bounds Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
array_char_idx Try printing array range using the name of its index type 2014-01-27 08:27:21 +04:00
array_return Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
array_subscript_addr Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
arraydim Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
arrayidx Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
arrayparam Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
arrayptr Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
atomic_enum Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
bad-task-bp-keyword Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
bp_enum_homonym Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
bp_on_var Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
bp_range_type Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
bp_reset Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
call_pn Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
catch_ex Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
char_enum Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
char_param Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
complete Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
cond_lang GDB testsuite: Fix warnings with -std=gnu11 2014-11-13 10:20:44 +01:00
dot_all Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
dyn_arrayidx Add gdb.ada/dyn_arrayidx testcase. 2014-04-28 15:48:11 -04:00
dyn_loc Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
enum_idx_packed Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
exec_changed Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
expr_delims Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
exprs Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
fixed_cmp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
fixed_points Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
float_param Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
formatted_ref Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
frame_args Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
fullname_bp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
fun_addr Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
fun_in_declare Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
funcall_param Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
homonym Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
info_exc Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
info_locals_renaming Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
int_deref Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
interface Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
iwide Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
lang_switch Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi_catch_ex Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi_dyn_arr [varobj] false type-changed status for reference to Ada array 2014-03-28 06:22:24 -07:00
mi_ex_cond Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi_exc_info Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi_interface varobj/Ada: Missing children for interface-wide tagged types 2014-01-07 08:29:04 +04:00
mi_task_arg Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi_task_info Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mod_from_name Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
n_arr_bound Handling of empty Ada ranges with a negative upper bound. 2014-11-21 07:07:07 +04:00
nested Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
null_array Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
null_record Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
operator_bp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
optim_drec Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
packed_array Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
packed_tagged Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
pckd_arr_ren [testsuite/Ada] New testcase for packed array renaming. 2014-03-17 08:45:55 -07:00
pkd_arr_elem varsize-limit error printing element of packed array... 2014-11-19 12:06:19 +04:00
pp-rec-component Ada: Fix missing call to pretty-printer for fields of records. 2014-01-07 08:17:40 +04:00
print_chars Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
ptr_typedef Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
ptype_field Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
ptype_tagged_param Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
py_range Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
rdv_wait Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
rec_return Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
ref_param Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
ref_tick_size Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
same_enum Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
set_pckd_arr_elt Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
set_wstr Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
small_reg_param Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
start Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
str_ref_cmp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
str_uninit Internal error trying to print uninitialized string. 2014-12-13 11:00:24 -05:00
sym_print_name Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
taft_type Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tagged Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tagged_access [Ada] Full view of tagged type with ptype 2014-03-10 14:40:35 +01:00
tagged_not_init Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
task_bp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tasks Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tick_last_segv Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tick_length_array_enum_idx Wrong type for 'Length result. 2014-02-10 13:15:43 +04:00
type_coercion Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
unc_arr_ptr_in_var_rec Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
uninitialized_vars Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
variant_record_packed_array Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
watch_arg Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
whatis_array_val Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
widewide Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
win_fu_syms Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
Makefile.in * Makefile.in (clean): Remove Fission .dwo and .dwp files. 2012-05-17 19:03:59 +00:00
O2_float_param.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
addr_arith.exp [Ada] Error adding/subtracting pointer value to/from integral. 2014-10-14 14:05:11 -07:00
aliased_array.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
arr_arr.exp [Ada] Ignore __XA types when redundant. 2014-11-19 12:48:07 +04:00
array_bounds.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
array_char_idx.exp Try printing array range using the name of its index type 2014-01-27 08:27:21 +04:00
array_return.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
array_subscript_addr.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
arraydim.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
arrayidx.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
arrayparam.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
arrayptr.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
assign_1.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
atomic_enum.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
bad-task-bp-keyword.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
boolean_expr.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
bp_enum_homonym.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
bp_on_var.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
bp_range_type.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
bp_reset.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
call_pn.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
catch_ex.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
char_enum.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
char_param.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
complete.exp Skip tests on completion and readline when readline lib isn't used 2014-03-26 21:11:08 +08:00
cond_lang.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
dot_all.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
dyn_arrayidx.exp Add gdb.ada/dyn_arrayidx testcase. 2014-04-28 15:48:11 -04:00
dyn_loc.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
enum_idx_packed.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
exec_changed.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
expr_delims.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
exprs.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
fixed_cmp.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
fixed_points.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
float_param.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
formatted_ref.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
frame_args.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
fullname_bp.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
fun_addr.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
fun_in_declare.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
funcall_param.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
gnat_ada.gpr Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
homonym.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
info_exc.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
info_locals_renaming.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
info_types.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
info_types.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
int_deref.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
interface.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
iwide.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
lang_switch.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi_catch_ex.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi_dyn_arr.exp [varobj] false type-changed status for reference to Ada array 2014-03-28 06:22:24 -07:00
mi_ex_cond.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi_exc_info.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi_interface.exp varobj/Ada: Missing children for interface-wide tagged types 2014-01-07 08:29:04 +04:00
mi_task_arg.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi_task_info.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mod_from_name.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
n_arr_bound.exp Handling of empty Ada ranges with a negative upper bound. 2014-11-21 07:07:07 +04:00
nested.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
null_array.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
null_record.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
operator_bp.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
optim_drec.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
packed_array.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
packed_tagged.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
pckd_arr_ren.exp [testsuite/Ada] New testcase for packed array renaming. 2014-03-17 08:45:55 -07:00
pkd_arr_elem.exp varsize-limit error printing element of packed array... 2014-11-19 12:06:19 +04:00
pp-rec-component.exp Remove path from gdb.ada/pp-rec-component.exp "source" test 2014-01-10 07:57:11 +04:00
pp-rec-component.py Ada: Fix missing call to pretty-printer for fields of records. 2014-01-07 08:17:40 +04:00
print_chars.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
print_pc.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
ptr_typedef.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
ptype_arith_binop.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
ptype_field.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
ptype_tagged_param.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
py_range.exp Fix prints in tests for Python 3 2014-11-28 11:36:52 -05:00
rdv_wait.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
rec_return.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
ref_param.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
ref_tick_size.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
same_enum.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
set_pckd_arr_elt.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
set_wstr.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
small_reg_param.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
start.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
str_ref_cmp.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
str_uninit.exp Internal error trying to print uninitialized string. 2014-12-13 11:00:24 -05:00
sym_print_name.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
taft_type.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tagged.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tagged_access.exp [Ada] Full view of tagged type with ptype 2014-03-10 14:40:35 +01:00
tagged_not_init.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
task_bp.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tasks.exp Multiple Ada task-specific breakpoints at the same address. 2014-02-26 14:22:33 +00:00
tick_last_segv.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tick_length_array_enum_idx.exp Wrong type for 'Length result. 2014-02-10 13:15:43 +04:00
type_coercion.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
unc_arr_ptr_in_var_rec.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
uninitialized_vars.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
variant_record_packed_array.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
watch_arg.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
whatis_array_val.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
widewide.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
win_fu_syms.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00