old-cross-binutils/gdb/testsuite/gdb.ada
Pierre-Marie de Rodat 22cee43f9a [Ada] Add support for subprogram renamings
Consider the following declaration:

    function Foo (I : Integer) return Integer renames Pack.Bar;

As Foo is not materialized as a routine whose name is derived from Foo,
GDB currently cannot use it:

    (gdb) print foo(0)
    No definition of "foo" in current context.

However, compilers can emit DW_TAG_imported_declaration in order to
materialize the fact that Foo is actually another name for Pack.Bar.
This commit enhances the DWARF reader to record global renamings (it
used to put global ones in a static block) and enhances the Ada engine
to leverage this information during symbol lookup.

gdb/ChangeLog:

	* ada-lang.c: Include namespace.h
	(aux_add_nonlocal_symbols): Fix a function name in comment.
	(ada_add_block_renamings): New.
	(add_nonlocal_symbols): Add global renamings handling.
	(ada_lookup_symbol_list_worker): Move the symbol lookup part
	to...
	(ada_add_all_symbols): ... this new function.
	(ada_add_block_symbols): Try to match the input name against the
	"using directives list", perform a recursive symbol lookup on
	the matched declarations.
	* block.h (struct block): Move the_namespace to top-level as
	namespace_info. Remove the language_specific field.
	(BLOCK_NAMESPACE): Update access to the namespace_info field.
	* buildsym.h (using_directives): Rename into...
	(local_using_directives): ... this.
	(global_using_directives): New.
	(struct context_stack): Rename the using_directives field into
	local_using_directives.
	* buildsym.c (finish_block_internal): Deal with the proper
	using directives repository (local or global).
	(prepare_for_building): Reset local_using_directives. Assert
	that there is no pending global using directive.
	(reset_symtab_globals): Reset global_using_directives and
	local_using_directives.
	(end_symtab_get_static_block): Don't ignore symtabs that have
	only using directives.
	(push_context): Update references to local_using_directives.
	(buildsym_init): Do not reset using_directives.
	* cp-support.c: Include namespace.h.
	* cp-support.h (struct using_direct): Move to namespace.h.
	(cp_add_using_directives): Move to namespace.h.
	* cp-namespace.c: Include namespace.h
	(cp_add_using_directive): Move to namespace.c, rename it to
	add_using_directive, add a "using_directives" argument and use
	it as the pending using directives repository.  All callers
	updated.
	* dwarf2read.c (using_directives): New.
	(read_import_statement): Call using_directives.
	(read_func_scope): Update references to local_using_directives.
	(read_lexical_block_scope): Likewise.
	(read_namespace): Update the heading comment, call
	using_directives.
	* namespace.h: New file.
	* namespace.c: New file.
	* Makefile.in (SFILES): Add namespace.c.
	(COMMON_OBS): Add namespace.o

gdb/testsuite/ChangeLog:

	* gdb.ada/fun_renaming.exp: New testcase.
	* gdb.ada/fun_renaming/fun_renaming.adb: New file.
	* gdb.ada/fun_renaming/pack.adb: New file.
	* gdb.ada/fun_renaming/pack.ads: New file.

Tested on x86_64-linux.  Support for this in GCC is in the pipeline: see
<https://gcc.gnu.org/ml/gcc-patches/2015-07/msg02166.html>.
2015-08-13 09:33:42 +02:00
..
addr_arith
aliased_array
arr_arr
array_bounds
array_char_idx
array_return
array_subscript_addr
arraydim
arrayidx
arrayparam
arrayptr
atomic_enum
bad-task-bp-keyword
bp_enum_homonym
bp_on_var
bp_range_type
bp_reset
byte_packed_arr Non bit-packed packed arrays as variable-length fields 2015-05-15 14:00:57 -07:00
call_pn
catch_ex
char_enum
char_param
complete
cond_lang
disc_arr_bound gdb/DWARF: Support for arrays whose bound is a discriminant. 2015-01-29 12:08:47 +04:00
dot_all
dyn_arrayidx
dyn_loc
enum_idx_packed
exec_changed testcase for PR symtab/17855 2015-02-22 09:11:55 -08:00
expr_delims
exprs
fixed_cmp
fixed_points
float_param
formatted_ref
frame_args
fullname_bp
fun_addr
fun_in_declare
fun_renaming [Ada] Add support for subprogram renamings 2015-08-13 09:33:42 +02:00
funcall_param
funcall_ref Do not consider reference types as dynamic 2015-04-03 15:23:49 +02:00
homonym
info_exc
info_locals_renaming
int_deref
interface
iwide
lang_switch
mi_catch_ex
mi_dyn_arr
mi_ex_cond
mi_exc_info
mi_interface
mi_task_arg
mi_task_info
mi_var_array
mod_from_name
n_arr_bound
nested
null_array
null_record
O2_float_param
operator_bp
optim_drec
out_of_line_in_inlined DWARF: cannot break on out-of-line function nested inside inlined function. 2015-05-05 11:06:09 -07:00
packed_array
packed_tagged
pckd_arr_ren
pckd_neg [Ada] problem printing negative integer values in packed arrays. 2015-05-15 07:37:15 -07:00
pkd_arr_elem
pp-rec-component
print_chars
ptr_typedef
ptype_field
ptype_tagged_param
py_range
rdv_wait
rec_comp [Ada] Preserve typedef layer when getting struct element 2015-04-27 11:04:47 +02:00
rec_return
ref_param
ref_tick_size
same_enum
set_pckd_arr_elt
set_wstr
small_reg_param
start
str_ref_cmp
str_uninit
sym_print_name
taft_type
tagged
tagged_access
tagged_not_init
task_bp
tasks
tick_last_segv
tick_length_array_enum_idx
type_coercion
unc_arr_ptr_in_var_rec
uninitialized_vars
var_arr_attrs
var_arr_typedef gdb/gdbtypes: fix handling of typedef layers between array types 2015-07-23 14:59:58 +02:00
var_rec_arr testsuite/gdb.ada/var_rec_arr: New testcase. 2015-05-05 10:48:21 -07:00
variant_record_packed_array
watch_arg
whatis_array_val
widewide
win_fu_syms
addr_arith.exp
aliased_array.exp
arr_arr.exp
array_bounds.exp
array_char_idx.exp
array_return.exp
array_subscript_addr.exp
arraydim.exp
arrayidx.exp
arrayparam.exp
arrayptr.exp
assign_1.exp
atomic_enum.exp
bad-task-bp-keyword.exp
boolean_expr.exp
bp_enum_homonym.exp
bp_on_var.exp
bp_range_type.exp
bp_reset.exp
byte_packed_arr.exp Non bit-packed packed arrays as variable-length fields 2015-05-15 14:00:57 -07:00
call_pn.exp
catch_ex.exp
char_enum.exp
char_param.exp
complete.exp Share the "multi_line" helper among all testcases 2015-04-01 15:06:39 +02:00
cond_lang.exp
disc_arr_bound.exp gdb/DWARF: Support for arrays whose bound is a discriminant. 2015-01-29 12:08:47 +04:00
dot_all.exp
dyn_arrayidx.exp gdb.ada/dyn_arrayidx.exp: Add additional_flags=-gnat12. 2015-01-31 14:26:54 -08:00
dyn_loc.exp
enum_idx_packed.exp
exec_changed.exp testcase for PR symtab/17855 2015-02-22 09:11:55 -08:00
expr_delims.exp
exprs.exp
fixed_cmp.exp
fixed_points.exp
float_param.exp
formatted_ref.exp
frame_args.exp
fullname_bp.exp
fun_addr.exp
fun_in_declare.exp
fun_renaming.exp [Ada] Add support for subprogram renamings 2015-08-13 09:33:42 +02:00
funcall_param.exp
funcall_ref.exp Do not consider reference types as dynamic 2015-04-03 15:23:49 +02:00
gnat_ada.gpr
homonym.exp
info_exc.exp gdb.ada/info_exc.exp: Adjust expected output in "info exception" test. 2015-07-20 15:18:24 -07:00
info_locals_renaming.exp
info_types.c
info_types.exp
int_deref.exp
interface.exp
iwide.exp
lang_switch.exp
Makefile.in
mi_catch_ex.exp
mi_dyn_arr.exp
mi_ex_cond.exp
mi_exc_info.exp
mi_interface.exp
mi_task_arg.exp
mi_task_info.exp
mi_var_array.exp
mod_from_name.exp
n_arr_bound.exp
nested.exp
null_array.exp
null_record.exp
O2_float_param.exp
operator_bp.exp
optim_drec.exp
out_of_line_in_inlined.exp out of line functions nested inside inline functions. 2015-05-05 11:08:14 -07:00
packed_array.exp
packed_tagged.exp Share the "multi_line" helper among all testcases 2015-04-01 15:06:39 +02:00
pckd_arr_ren.exp
pckd_neg.exp [Ada] problem printing negative integer values in packed arrays. 2015-05-15 07:37:15 -07:00
pkd_arr_elem.exp
pp-rec-component.exp
pp-rec-component.py
print_chars.exp
print_pc.exp
ptr_typedef.exp
ptype_arith_binop.exp
ptype_field.exp Share the "multi_line" helper among all testcases 2015-04-01 15:06:39 +02:00
ptype_tagged_param.exp
py_range.exp
rdv_wait.exp
rec_comp.exp [Ada] Preserve typedef layer when getting struct element 2015-04-27 11:04:47 +02:00
rec_return.exp
ref_param.exp
ref_tick_size.exp
same_enum.exp
set_pckd_arr_elt.exp
set_wstr.exp
small_reg_param.exp
start.exp
str_ref_cmp.exp
str_uninit.exp
sym_print_name.exp Share the "multi_line" helper among all testcases 2015-04-01 15:06:39 +02:00
taft_type.exp
tagged.exp Share the "multi_line" helper among all testcases 2015-04-01 15:06:39 +02:00
tagged_access.exp
tagged_not_init.exp
task_bp.exp
tasks.exp
tick_last_segv.exp
tick_length_array_enum_idx.exp
type_coercion.exp
unc_arr_ptr_in_var_rec.exp
uninitialized_vars.exp
var_arr_attrs.exp
var_arr_typedef.exp gdb/gdbtypes: fix handling of typedef layers between array types 2015-07-23 14:59:58 +02:00
var_rec_arr.exp testsuite/gdb.ada/var_rec_arr: New testcase. 2015-05-05 10:48:21 -07:00
variant_record_packed_array.exp
watch_arg.exp
whatis_array_val.exp
widewide.exp
win_fu_syms.exp