This factors out all the yy-variables remapping to a single file,
instead of each parser having to do the same, with different prefixes.
With this, a parser just needs to define the prefix they want and
include yy-remap.h, which does the dirty job.
Note this renames the c_error, ada_error, etc. functions. Writing the
remapping pattern as:
#define yyerror GDB_YY_REMAP (error)
instead of:
#define yyerror GDB_YY_REMAP (yyerror)
would have avoided the renaming. However, that would be problematic
if we have a macro 'foo' in scope, when we write:
#define yyfoo GDB_YY_REMAP (foo)
as that would expand 'foo'.
The c_yyerror etc. naming end ups indicating that this is a yacc
related function more clearly, so feels like a good change, anyway.
gdb/ChangeLog:
2016-04-22 Pedro Alves <palves@redhat.com>
* ada-exp.y: Remove all yy symbol remappings.
(GDB_YY_REMAP_PREFIX): Define.
Include "yy-remap.h".
* ada-lang.c (ada_language_defn): Adjust.
* ada-lang.h (ada_error): Rename to ...
(ada_yyerror): ... this.
* c-exp.y: Remove all yy symbol remappings.
(GDB_YY_REMAP_PREFIX): Define.
Include "yy-remap.h".
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Adjust.
* c-lang.h (c_error): Rename to ...
(c_yyerror): ... this.
* d-exp.y: Remove all yy symbol remappings.
(GDB_YY_REMAP_PREFIX): Define.
Include "yy-remap.h".
* d-lang.c (d_language_defn): Adjust.
* d-lang.h (d_error): Rename to ...
(d_yyerror): ... this.
* f-exp.y: Remove all yy symbol remappings.
(GDB_YY_REMAP_PREFIX): Define.
Include "yy-remap.h".
* f-lang.c (f_language_defn): Adjust.
* f-lang.h (f_error): Rename to ...
(f_yyerror): ... this.
* go-exp.y: Remove all yy symbol remappings.
(GDB_YY_REMAP_PREFIX): Define.
Include "yy-remap.h".
* go-lang.c (go_language_defn): Adjust.
* go-lang.h (go_error): Rename to ...
(go_yyerror): ... this.
* jv-exp.y: Remove all yy symbol remappings.
(GDB_YY_REMAP_PREFIX): Define.
Include "yy-remap.h".
* jv-lang.c (java_language_defn): Adjust.
* jv-lang.h (java_error): Rename to ...
(java_yyerror): ... this.
* m2-exp.y: Remove all yy symbol remappings.
(GDB_YY_REMAP_PREFIX): Define.
Include "yy-remap.h".
* m2-lang.c (m2_language_defn): Adjust.
* m2-lang.h (m2_error): Rename to ...
(m2_yyerror): ... this.
* objc-exp.y: Remove all yy symbol remappings.
(GDB_YY_REMAP_PREFIX): Define.
Include "yy-remap.h".
* objc-lang.c (objc_language_defn): Adjust.
* opencl-lang.c (opencl_language_defn): Adjust.
* p-exp.y: Remove all yy symbol remappings.
(GDB_YY_REMAP_PREFIX): Define.
Include "yy-remap.h".
* p-lang.c (pascal_language_defn): Adjust.
* p-lang.h (pascal_error): Rename to ...
(pascal_yyerror): ... this.
* yy-remap.h: New file.
The assignment requires a cast in C++. We only use this macro for
vectors of chars, so adding (char *) diretly will do for now.
gdb/ChangeLog:
* ada-lang.h (GROW_VECT): Add cast.
As Pedro suggested on gdb-patches@ (see
https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this
change makes symbol lookup functions return a structure that includes
both the symbol found and the block in which it was found. This makes
it possible to get rid of the block_found global variable and thus makes
block hunting explicit.
gdb/
* ada-exp.y (write_object_renaming): Replace struct
ada_symbol_info with struct block_symbol. Update field
references accordingly.
(block_lookup, select_possible_type_sym): Likewise.
(find_primitive_type): Likewise. Also update call to
ada_lookup_symbol to extract the symbol itself.
(write_var_or_type, write_name_assoc): Likewise.
* ada-lang.h (struct ada_symbol_info): Remove.
(ada_lookup_symbol_list): Replace struct ada_symbol_info with
struct block_symbol.
(ada_lookup_encoded_symbol, user_select_syms): Likewise.
(ada_lookup_symbol): Return struct block_symbol instead of a
mere symbol.
* ada-lang.c (defns_collected): Replace struct ada_symbol_info
with struct block_symbol.
(resolve_subexp, ada_resolve_function, sort_choices,
user_select_syms, is_nonfunction, add_defn_to_vec,
num_defns_collected, defns_collected,
symbols_are_identical_enums, remove_extra_symbols,
remove_irrelevant_renamings, add_lookup_symbol_list_worker,
ada_lookup_symbol_list, ada_iterate_over_symbols,
ada_lookup_encoded_symbol, get_var_value): Likewise.
(ada_lookup_symbol): Return a block_symbol instead of a mere
symbol. Replace struct ada_symbol_info with struct
block_symbol.
(ada_lookup_symbol_nonlocal): Likewise.
(standard_lookup): Make block passing explicit through
lookup_symbol_in_language.
* ada-tasks.c (get_tcb_types_info): Update the calls to
lookup_symbol_in_language to extract the mere symbol out of the
returned value.
(ada_tasks_inferior_data_sniffer): Likewise.
* ax-gdb.c (gen_static_field): Likewise for the call to
lookup_symbol.
(gen_maybe_namespace_elt): Deal with struct symbol_in_block from
lookup functions.
(gen_expr): Likewise.
* c-exp.y: Likewise. Remove uses of block_found.
(lex_one_token, classify_inner_name, c_print_token): Likewise.
(classify_name): Likewise. Rename the "sym" local variable to
"bsym".
* c-valprint.c (print_unpacked_pointer): Likewise.
* compile/compile-c-symbols.c (convert_symbol_sym): Promote the
"sym" parameter from struct symbol * to struct block_symbol.
Use it to remove uses of block_found. Deal with struct
symbol_in_block from lookup functions.
(gcc_convert_symbol): Likewise. Update the call to
convert_symbol_sym.
* compile/compile-object-load.c (compile_object_load): Deal with
struct symbol_in_block from lookup functions.
* cp-namespace.c (cp_lookup_nested_symbol_1,
cp_lookup_nested_symbol, cp_lookup_bare_symbol,
cp_search_static_and_baseclasses,
cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports,
cp_lookup_symbol_imports_or_template,
cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace,
lookup_namespace_scope, cp_lookup_nonlocal,
find_symbol_in_baseclass): Return struct symbol_in_block instead
of mere symbols and deal with struct symbol_in_block from lookup
functions.
* cp-support.c (inspect_type, replace_typedefs,
cp_lookup_rtti_type): Deal with struct symbol_in_block from
lookup functions.
* cp-support.h (cp_lookup_symbol_nonlocal,
cp_lookup_symbol_from_namespace,
cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol):
Return struct symbol_in_block instead of mere symbols.
* d-exp.y (d_type_from_name, d_module_from_name, push_variable,
push_module_name):
Deal with struct symbol_in_block from lookup functions. Remove
uses of block_found.
* eval.c (evaluate_subexp_standard): Update call to
cp_lookup_symbol_namespace.
* f-exp.y: Deal with struct symbol_in_block from lookup
functions. Remove uses of block_found.
(yylex): Likewise.
* gdbtypes.c (lookup_typename, lookup_struct, lookup_union,
lookup_enum, lookup_template_type, check_typedef): Deal with
struct symbol_in_block from lookup functions.
* guile/scm-frame.c (gdbscm_frame_read_var): Likewise.
* guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise.
(gdbscm_lookup_global_symbol): Likewise.
* gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise.
* go-exp.y: Likewise. Remove uses of block_found.
(package_name_p, classify_packaged_name, classify_name):
Likewise.
* infrun.c (insert_exception_resume_breakpoint): Likewise.
* jv-exp.y (push_variable): Likewise.
* jv-lang.c (java_lookup_class, get_java_object_type): Likewise.
* language.c (language_bool_type): Likewise.
* language.h (struct language_defn): Update
la_lookup_symbol_nonlocal to return a struct symbol_in_block
rather than a mere symbol.
* linespec.c (find_label_symbols): Deal with struct
symbol_in_block from lookup functions.
* m2-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* mi/mi-cmd-stack.c (list_args_or_locals): Likewise.
* objc-lang.c (lookup_struct_typedef, find_imps): Likewise.
* p-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
* parse.c (write_dollar_variable): Likewise. Remove uses of
block_found.
* parser-defs.h (struct symtoken): Turn the SYM field into a
struct symbol_in_block.
* printcmd.c (address_info): Deal with struct symbol_in_block
from lookup functions.
* python/py-frame.c (frapy_read_var): Likewise.
* python/py-symbol.c (gdbpy_lookup_symbol,
gdbpy_lookup_global_symbol): Likewise.
* skip.c (skip_function_command): Likewise.
* solib-darwin.c (darwin_lookup_lib_symbol): Return a struct
symbol_in_block instead of a mere symbol.
* solib-spu.c (spu_lookup_lib_symbol): Likewise.
* solib-svr4.c (elf_lookup_lib_symbol): Likewise.
* solib.c (solib_global_lookup): Likewise.
* solist.h (solib_global_lookup): Likewise.
(struct target_so_ops): Update lookup_lib_global_symbol to
return a struct symbol_in_block rather than a mere symbol.
* source.c (select_source_symtab): Deal with struct
symbol_in_block from lookup functions.
* stack.c (print_frame_args, iterate_over_block_arg_vars):
Likewise.
* symfile.c (set_initial_language): Likewise.
* symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct
symbol_in_block.
(SYMBOL_LOOKUP_FAILED_P): New predicate as a macro.
(struct symbol_cache_slot): Turn the FOUND field into a struct
symbol_in_block.
(block_found): Remove.
(eq_symbol_entry): Update to deal with struct symbol_in_block in
cache slots.
(symbol_cache_lookup): Return a struct symbol_in_block rather
than a mere symbol.
(symbol_cache_mark_found): Add a BLOCK parameter to fill
appropriately the cache slots. Update callers.
(symbol_cache_dump): Update cache slots handling to the type
change.
(lookup_symbol_in_language, lookup_symbol, lookup_language_this,
lookup_symbol_aux, lookup_local_symbol,
lookup_symbol_in_objfile, lookup_global_symbol_from_objfile,
lookup_symbol_in_objfile_symtabs,
lookup_symbol_in_objfile_from_linkage_name,
lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal,
lookup_symbol_in_static_block, lookup_static_symbol,
lookup_global_symbol):
Return a struct symbol_in_block rather than a mere symbol. Deal
with struct symbol_in_block from other lookup functions. Remove
uses of block_found.
(lookup_symbol_in_block): Remove uses of block_found.
(struct global_sym_lookup_data): Turn the RESULT field into a
struct symbol_in_block.
(lookup_symbol_global_iterator_cb): Update references to the
RESULT field.
(search_symbols): Deal with struct symbol_in_block from lookup
functions.
* symtab.h (struct symbol_in_block): New structure.
(block_found): Remove.
(lookup_symbol_in_language, lookup_symbol,
basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block,
looku_static_symbol, lookup_global_symbol,
lookup_symbol_in_block, lookup_language_this,
lookup_global_symbol_from_objfile): Return a struct
symbol_in_block rather than just a mere symbol. Update comments
to remove mentions of block_found.
* valops.c (find_function_in_inferior,
value_struct_elt_for_reference, value_maybe_namespace_elt,
value_of_this): Deal with struct symbol_in_block from lookup
functions.
* value.c (value_static_field, value_fn_field): Likewise.
This patch renames symbols that happen to have names which are
reserved keywords in C++.
Most of this was generated with Tromey's cxx-conversion.el script.
Some places where later hand massaged a bit, to fix formatting, etc.
And this was rebased several times meanwhile, along with re-running
the script, so re-running the script from scratch probably does not
result in the exact same output. I don't think that matters anyway.
gdb/
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
Rename symbols whose names are reserved C++ keywords throughout.
gdb/gdbserver/
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
Rename symbols whose names are reserved C++ keywords throughout.
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.
This commit does most of the mechanical removal. IOW, the easy part.
procfs.c isn't touched beyond removing a couple obvious bits that are
guarded by a couple macros defined in config/alpha/nm-osf3.h. Going
beyond that for procfs.c & co would be a harder excision that
potentially affects Solaris.
Some comments in the generic alpha code ABIs that may still be
relevant and I wouldn't know what to do with them. That can always be
done on a separate pass, preferably by someone who can test on alpha.
A couple other spots have references to OSF/Tru64 and related files
being removed, but it felt like removing them would make things worse,
not better. We can revisit those when we next need to touch that
code.
I didn't remove a reference to osf in testsuite/lib/future.exp, as I
believe that code is imported from DejaGNU.
Built and tested on x86_64 Fedora 20, with --enable-targets=all.
Tested that building for --target=alpha-osf3 on x86_64 Fedora 20
fails with:
checking for default auto-load directory... $debugdir:$datadir/auto-load
checking for default auto-load safe-path... $debugdir:$datadir/auto-load
*** Configuration alpha-unknown-osf3 is obsolete.
*** Support has been REMOVED.
make[1]: *** [configure-gdb] Error 1
make[1]: Leaving directory `build-osf'
make: *** [all] Error 2
gdb/
2014-10-17 Pedro Alves <palves@redhat.com>
* Makefile.in (ALL_64_TARGET_OBS): Remove alpha-osf1-tdep.o.
(HFILES_NO_SRCDIR): Remove config/alpha/nm-osf3.h.
(ALLDEPFILES): Remove alpha-nat.c, alpha-osf1-tdep.c and
solib-osf.c.
* NEWS: Mention that support for alpha*-*-osf* has been removed.
* ada-lang.h [__alpha__ && __osf__]
(ADA_KNOWN_RUNTIME_FILE_NAME_PATTERNS): Delete.
* alpha-nat.c, alpha-osf1-tdep.c: Delete files.
* alpha-tdep.c (alpha_gdbarch_init): Remove reference to
GDB_OSABI_OSF1.
* config/alpha/alpha-osf3.mh, config/alpha/nm-osf3.h: Delete
files.
* config/djgpp/fnchange.lst (config/alpha/alpha-osf1.mh)
(config/alpha/alpha-osf2.mh, config/alpha/alpha-osf3.mh): Delete.
* configure: Regenerate.
* configure.ac: Remove references to osf.
* configure.host: Handle alpha*-*-osf* in the obsolete hosts
section. Remove all other references to osf.
* configure.tgt: Add alpha*-*-osf* to the obsolete targets section.
Remove all other references to osf.
* dec-thread.c: Delete file.
* defs.h (GDB_OSABI_OSF1): Delete.
* inferior.h (START_INFERIOR_TRAPS_EXPECTED): New unconditionally
defined.
* osabi.c (gdb_osabi_names): Delete "OSF/1".
* procfs.c (procfs_debug_inferior) [PROCFS_DONT_TRACE_FAULTS]:
Delete code.
(unconditionally_kill_inferior)
[PROCFS_NEED_CLEAR_CURSIG_FOR_KILL]: Delete code.
* solib-osf.c: Delete file.
gdb/testsuite/
2014-10-17 Pedro Alves <palves@redhat.com>
* gdb.base/callfuncs.exp: emove references to osf.
* gdb.base/sigall.exp: Likewise.
* gdb.gdb/selftest.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.mi/non-stop.c: Likewise.
* gdb.mi/pthreads.c: Likewise.
* gdb.reverse/sigall-precsave.exp: Likewise.
* gdb.reverse/sigall-reverse.exp: Likewise.
* gdb.threads/pthreads.c: Likewise.
* gdb.threads/pthreads.exp: Likewise.
gdb/doc/
2014-10-17 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Ada Tasks and Core Files): Delete mention of Tru64.
(SVR4 Process Information): Delete mention of OSF/1.
I happen to notice this extern function declaration in ada-lang.h
which does not actually exist...
gdb/ChangeLog:
* ada-lang.h (clear_ada_sym_cache): Delete.
This patch adds a new command "info exceptions" whose purpose is to
provide the list of exceptions currently defined in the inferior.
The usage is:
(gdb) info exceptions [REGEXP]
Without argument, the command lists all exceptions. Otherwise,
only those whose name match REGEXP are listed.
For instance:
(gdb) info exceptions
All defined Ada exceptions:
constraint_error: 0x613dc0
program_error: 0x613d40
storage_error: 0x613d00
tasking_error: 0x613cc0
global_exceptions.a_global_exception: 0x613a80
global_exceptions.a_private_exception: 0x613ac0
The name of the command, as well as its output is part of a legacy
I inherited long ago. It's output being parsed by frontends such as
GPS, I cannot easily change it. Same for the command name.
The implementation is mostly self-contained, and is written in a way
that should make it easy to implement the GDB/MI equivalent. The
careful reviewer will notice that the code added in ada-lang.h could
normally be made private inside ada-lang.c. But these will be used
by the GDB/MI implementation. Rather than making those private now,
only to move them later, I've made them public right away.
gdb/ChangeLog:
* ada-lang.h: #include "vec.h".
(struct ada_exc_info): New.
(ada_exc_info): New typedef.
(DEF_VEC_O(ada_exc_info)): New vector.
(ada_exceptions_list): Add declaration.
* ada-lang.c (ada_is_exception_sym)
(ada_is_non_standard_exception_sym, compare_ada_exception_info)
(sort_remove_dups_ada_exceptions_list)
(ada_exc_search_name_matches, ada_add_standard_exceptions)
(ada_add_exceptions_from_frame, ada_add_global_exceptions)
(ada_exceptions_list_1, ada_exceptions_list)
(info_exceptions_command): New function.
(_initialize_ada_language): Add "info exception" command.
gdb/testsuite/ChangeLog:
* gdb.ada/info_exc: New testcase.
This patch introduces two new GDB/MI commands implementing the equivalent
of the "catch exception" and "catch assert" GDB/CLI commands.
gdb/ChangeLog:
* breakpoint.h (init_ada_exception_breakpoint): Add parameter
"enabled".
* breakpoint.c (init_ada_exception_breakpoint): Add parameter
"enabled". Set B->ENABLE_STATE accordingly.
* ada-lang.h (ada_exception_catchpoint_kind): Move here from
ada-lang.c.
(create_ada_exception_catchpoint): Add declaration.
* ada-lang.c (ada_exception_catchpoint_kind): Move to ada-lang.h.
(create_ada_exception_catchpoint): Make non-static. Add new
parameter "disabled". Use it in call to
init_ada_exception_breakpoint.
(catch_ada_exception_command): Add parameter "enabled" in call
to create_ada_exception_catchpoint.
(catch_assert_command): Likewise.
* mi/mi-cmds.h (mi_cmd_catch_assert, mi_cmd_catch_exception):
Add declarations.
* mi/mi-cmds.c (mi_cmds): Add the "catch-assert" and
"catch-exception" commands.
* mi/mi-cmd-catch.c: Add #include "ada-lang.h".
(mi_cmd_catch_assert, mi_cmd_catch_exception): New functions.
This is another patch in my ongoing series to "split" objfile to share
more read-only data across inferiors. See
http://sourceware.org/gdb/wiki/ObjfileSplitting
When symbols are finally shared, there will be no back-link from the
symbol to its containing objfile, because there may be more than one
such objfile. So, all such back-links must be removed.
One hidden back-link is the msymbol_objfile function. Since
(eventually) a symbol may appear in more than one objfile, trying to
look up the objfile given just a symbol cannot work.
This patch removes msymbol_objfile in favor of using a bound minimal
symbol. It introduces a new function to make this conversion simpler
in some spots.
The bonus of this patch is that using msymbol_objfile is slower than
simply looking up the owning objfile in the first place.
Built and regtested on x86-64 Fedora 18.
* ada-exp.y (write_var_or_type): Use bound_minimal_symbol.
* ada-lang.c (ada_lookup_simple_minsym): Return
bound_minimal_symbol.
* ada-lang.h (ada_lookup_simple_minsym): Update.
* c-exp.y (variable): Use lookup_bound_minimal_symbol.
* f-exp.y (variable): Use lookup_bound_minimal_symbol.
* go-exp.y (variable): Use lookup_bound_minimal_symbol.
* jv-exp.y (push_expression_name): Use lookup_bound_minimal_symbol.
* m2-exp.y (variable): Use lookup_bound_minimal_symbol.
* minsyms.c (msymbol_objfile): Remove.
(lookup_minimal_symbol_internal): New function, from
lookup_minimal_symbol.
(lookup_minimal_symbol): Rewrite using
lookup_minimal_symbol_internal.
(lookup_bound_minimal_symbol): New function.
* minsyms.h (msymbol_objfile): Remove.
(lookup_bound_minimal_symbol): Declare.
* p-exp.y (variable): Use lookup_bound_minimal_symbol.
* parse.c (write_exp_msymbol): Change parameter to a
bound_minimal_symbol.
(write_dollar_variable): Use lookup_bound_minimal_symbol.
* parser-defs.h (write_exp_msymbol): Update.
* printcmd.c (address_info): Use lookup_bound_minimal_symbol.
* symfile.c (simple_read_overlay_table): Use
lookup_bound_minimal_symbol.
* symtab.c (skip_prologue_sal): Don't use msymbol_objfile.
(search_symbols): Likewise.
(print_msymbol_info): Take a bound_minimal_symbol argument.
(symtab_symbol_info, rbreak_command): Update.
* symtab.h (struct symbol_search) <msymbol>: Change type
to bound_minimal_symbol.
* valops.c (find_function_in_inferior): Use
lookup_bound_minimal_symbol.
* value.c (value_fn_field): Use lookup_bound_minimal_symbol.
Two modifications:
1. The addition of 2013 to the copyright year range for every file;
2. The use of a single year range, instead of potentially multiple
year ranges, as approved by the FSF.
For displaying the full view of a class-wide object, GDB relies on
the assumption that this view will have the same address as the
address of the object. In the case of simple inheritance, this
assumption is correct; the proper type is deduced by decoding
the tag of the object and converting the result to this full-view
type.
Consider for example an abstract class Shape, a child Circle
which implements an interface Drawable, and the corresponding
following objects:
My_Circle : Circle := ((1, 2), 3);
My_Shape : Shape'Class := Shape'Class (My_Circle);
My_Drawable : Drawable'Class := Drawable'Class (My_Circle);
To display My_Shape, the debugger first extracts the tag (an internal
field, usually the first one of the record):
(gdb) p my_shape'address
$2 = (system.address) 0x8063e28
(gdb) x/x my_shape'address
0x8063e28 <classes__my_shape>: 0x08059ec4
Then the type specific data and the expanded name of the tag is read
from there:
(gdb) p my_shape'tag
$3 = (access ada.tags.dispatch_table) 0x8059ec4 (classes.circle)
To get the full view, the debugger converts to the corresponding type:
(gdb) p {classes.circle}0x8063e28
$4 = (center => (x => 1, y => 2), radius => 3)
Now, in the case of multiple inheritance, the assumption does not hold
anymore. The address that we have usually points to some
place lower. The offset to the original address is saved in the field
Offset_To_Top of the metadata that are above the tag, at address
obj'tag - 8. In the case of my_shape, this offset is 0:
(gdb) x/x my_shape'tag - 8
0x8059ebc <classes__circleT+12>: 0x00000000
...but in the case of an interface-wide object, it is not null:
(gdb) x/x my_drawable'tag - 8
0x8063b28 <classes__classes__circle_classes__drawable1T56s+12>: 0x00000004
(gdb) p {classes.circle}(my_drawable'address - 4)
$7 = (center => (x => 1, y => 2), radius => 3)
The following change handles this relocation in the most common cases.
Remaining cases that are still to be investigated are signaled by
comments.
gdb/ChangeLog:
* ada-lang.h (ada_tag_value_at_base_address): New function
declaration.
* ada-lang.c (is_ada95_tag, ada_tag_value_at_base_address):
New functions.
(ada_to_fixed_type_1, ada_evaluate_subexp): Let ada_tag_base_address
relocate the class-wide value if need be.
(ada_value_struct_elt, ada_value_ind, ada_coerce_ref):
Let ada_tag_value_at_base_address relocate the class-wide access/ref
before dereferencing it.
* ada-valprint.c (ada_val_print_1): Relocate to base address
before displaying the content of an interface-wide ref.
gdb/testsuite/ChangeLog:
* gdb.ada/ptype_tagged_param.exp: Adjust expected output in
ptype test.
On x86_64-windows with GCC 4.7 (using native SEH info), the debugger
behaves as follow:
(gdb) catch exception unhandled
Catchpoint 1: unhandled Ada exceptions
(gdb) run
Starting program: C:\[...]\b.exe
Catchpoint 1, unhandled CONSTRAINT_ERROR at 0x000000000040cc57 in _GCC_specific_handler ([...]) at ../../../src/libgcc/unwind-seh.c:289
[...]
This is after compiler the following code:
procedure B is
begin
raise Constraint_Error;
end B;
... using the following command:
% gnatmake -g b
When hitting the exception catchpoint, it should have gone up the stack
all the way until finding the frame corresponding to procedure B.
But if stopped short because unwind-seh.c is compiled with debugging
information, and the debugger is also able to locate that source file.
To prevent this from happening, this patch adds unwind-seh.c to the list
of files that should be ignored, regardless of other factors.
gdb/ChangeLog:
* ada-lang.h (ADA_KNOWN_RUNTIME_FILE_NAME_PATTERNS): Add entry for
"unwind-seh.c".
This makes ada_lookup_encoded_symbol more consistent with other functions
such as ada_lookup_symbol_list, and also makes it clearer in the code
using that function that symbol and block are related.
gdb/ChangeLog:
* ada-lang.c (ada_lookup_encoded_symbol): Now returns void.
Replace block_found argument by symbol_info. Adjust
implementation accordingly. Add function documentation.
(ada_lookup_symbol): Adjust to new ada_lookup_encoded_symbol.
Fix documentation.
* ada-lang.h (ada_lookup_encoded_symbol): Update declaration.
* ada-exp.y (write_object_renaming): Adjust to new
ada_lookup_encoded_symbol API.
This is a minor improvement in ada_find_renaming_symbol: What we were
doing was going from a symbol, get its name, and then search for
renamings. But if the original symbol was already itself a renaming,
then we'd look the symbol up again to return it. Since we had the
symbol in the first place, we shouldn't need to look it up again.
This is what this patch does: Modify ada_find_renaming_symbol to
take a symbol instead of the symbol's (linkage) name, and then updates
the one caller.
gdb/ChangeLog:
* ada-lang.h (ada_find_renaming_symbol): Replace parameter
"name" with "struct symbol *name_sym".
* ada-exp.y (write_var_or_type): Update call to
ada_find_renaming_symbol.
* ada-lang.c (ada_find_renaming_symbol): Replace parameter
"name" with "struct symbol *name_sym". Adjust Implementation
accordingly. Adjust the function documentation.
This patch introduces two new functions that will be used to support
the implementation of the ada-varobj effort. The function descriptions
should say it all...
gdb/ChangeLog:
* ada-lang.h (ada_get_decoded_value, ada_get_decoded_type): Add
declaration.
* ada-lang.c (ada_get_decoded_value, ada_get_decoded_type): New
function.
and fields.name members from char * to const char *. All uses updated.
(struct cplus_struct_type): Change type of fn_fieldlists.name member
from char * to const char *. All uses updated.
(type_name_no_tag): Update.
(lookup_unsigned_typename, lookup_signed_typename): Update.
* gdbtypes.c (type_name_no_tag): Change result type
from char * to const char *. All callers updated.
(lookup_unsigned_typename, lookup_signed_typename): Change type of
name parameter from char * to const char *.
* symtab.h (struct cplus_specific): Change type of demangled_name
member from char * to const char *. All uses updated.
(struct general_symbol_info): Change type of name and
mangled_lang.demangled_name members from char * to const char *.
All uses updated.
(symbol_get_demangled_name, symbol_natural_name): Update.
(symbol_demangled_name, symbol_search_name): Update.
* symtab.c (symbol_get_demangled_name): Change result type
from char * to const char *. All callers updated.
(symbol_natural_name, symbol_demangled_name): Ditto.
(symbol_search_name): Ditto.
(completion_list_add_name): Change type of symname,sym_text,
text,word parameters from char * to const char *.
(completion_list_objc_symbol): Change type of sym_text,
text,word parameters from char * to const char *.
* ada-lang.c (find_struct_field): Change type of name parameter
from char * to const char *.
(encoded_ordered_before): Similarly for N0,N1 parameters.
(old_renaming_is_invisible): Similarly for function_name parameter.
(ada_type_name): Change result type from char * to const char *.
All callers updated.
* ada-lang.h (ada_type_name): Update.
* buildsym.c (hashname): Change type of name parameter
from char * to const char *.
* buildsym.h (hashname): Update.
* dbxread.c (end_psymtab): Change type of include_list parameter
from char ** to const char **.
* dwarf2read.c (determine_prefix): Change result type
from char * to const char *. All callers updated.
* f-lang.c (find_common_for_function): Change type of name, funcname
parameters from char * to const char *.
* f-lang.c (find_common_for_function): Update.
* f-valprint.c (list_all_visible_commons): Change type of funcname
parameters from char * to const char *.
* gdbarch.sh (static_transform_name): Change type of name parameter
and result from char * to const char *.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* i386-sol2-tdep.c (i386_sol2_static_transform_name): Change type
of name parameter from char * to const char *.
* jv-lang.c (java_primitive_type_from_name): Ditto.
(java_demangled_signature_length): Similarly for signature parameter.
(java_demangled_signature_copy): Ditto.
(java_demangle_type_signature): Ditto.
* jv-lang.h (java_primitive_type_from_name): Update.
(java_demangle_type_signature): Update.
* objc-lang.c (specialcmp): Change type of a,b parameters
from char * to const char *.
* p-lang.c (is_pascal_string_type): Change type of arrayname parameter
from char * to const char *. All callers updated.
* p-lang.h (is_pascal_string_type): Update.
* solib-frv.c (find_canonical_descriptor_in_load_object): Change type
of name parameter from char * to const char *.
* sparc-sol2-tdep.c (sparc_sol2_static_transform_name): Ditto.
* utils.c (fprintf_symbol_filtered): Ditto.
* defs.h (fprintf_symbol_filtered): Update.
* sparc-tdep.h (sparc_sol2_static_transform_name): Update.
* stabsread.h (end_psymtab): Update.
* stack.c (find_frame_funname): Change type of funname parameter
from char ** to const char **.
* stack.h (find_frame_funname): Update.
* typeprint.c (type_print): Change type of varstring parameter
from char * to const char *.
* value.h (type_print): Update.
* xcoffread.c (xcoff_start_psymtab): Change type of filename parameter
from char * to const char *. All callers updated.
(xcoff_end_psymtab): Change type of include_list parameter
from char ** to const char **. All callers updated.
(swap_sym): Similarly for name parameter. All callers updated.
* coffread.c (patch_type): Add (char*) cast to xfree parameter.
Use xstrdup.
(process_coff_symbol): Use xstrdup.
* stabsread.c (stabs_method_name_from_physname): Renamed from
update_method_name_from_physname. Change result type from void
to char *. All callers updated.
(read_member_functions): In has_destructor case, store name in objfile
obstack instead of malloc space. In !has_stub case, fix mem leak.
This patch introduces a new GDB/MI command: -ada-tasks-info,
which is meant to be the MI equivalent of the CLI `info tasks'
command.
This new command returns an array, with each row corresponding
to one task. For now, the columns of the array corresponds to
the columns displayed in the CLI output.
gdb/ChangeLog:
* ada-lang.h (struct inferior): Declare.
(print_ada_task_info): Add declaration.
* ada-tasks.c (print_ada_task_info): Make non-static.
* mi/mi-cmds.c (mi_cmds): Add "ada-task-info".
* mi/mi-cmds.h (mi_cmd_ada_task_info): Add declaration.
* mi/mi-main.c: #include "ada-lang.h".
(mi_cmd_list_features): Add "ada-task-info" to the list
of supported features.
(mi_cmd_ada_task_info): New function.
Originally, this function had a parameter called `warn_if_null'
which would trigger a message to be printed on stdout if the
program was found to not use Ada tasking. It used one of the printf_
functions for that, which is wrong when considering the context of
GDB/MI interpreters.
So, this patch changes this function to stop printing the message,
and leaves that part to the callers instead. It also changes the
semantics slightly to return the number of tasks found, rather than
a yes/no answer. Not strictly needed, but simple enough to do, and
potentially useful later.
gdb/ChangeLog:
* ada-lang.h (ada_build_task_list): Remove parameter
`warn_if_null'.
* ada-tasks.c (ada_build_task_list): Remove parameter
`warn_if_null'. Adjust implementation and documentation.
(valid_task_id, ada_get_environment_task)
iterate_over_live_ada_tasks): Adjust call to ada_build_task_list.
(info_tasks_command): Adjust implementation.
(task_command): Likewise.
* ravenscar-thread.c (ravenscar_find_new_threads): Fix call
to ada_build_task_list.
* breakpoint.c (bpstat_stop_status): Call the check_status
breakpoint_ops method.
(print_one_breakpoint_location): Also print the condition for Ada
exception catchpoints.
(allocate_bp_location): New, factored out from
allocate_bp_location.
(allocate_bp_location): Adjust. Call the owner breakpoint's
allocate_location method, if there is one.
(free_bp_location): Call the locations's dtor method, if there is
one.
(init_raw_breakpoint_without_location): New breakpoint_ops
parameter. Use it.
(set_raw_breakpoint_without_location): Adjust.
(init_raw_breakpoint): New breakpoint_ops parameter. Pass it down.
(set_raw_breakpoint): Adjust.
(catch_fork_breakpoint_ops, catch_vfork_breakpoint_ops)
(catch_syscall_breakpoint_ops): Install NULL allocate_location,
re_set and check_status methods.
(init_catchpoint): Don't memset, initialize thread, addr_string
and enable_state. Pass the ops down to init_raw_breakpoint.
(install_catchpoint): Rename to ...
(install_breakpoint): ... this, and make extern.
(create_fork_vfork_event_catchpoint): Adjust.
(catch_exec_breakpoint_ops): Install NULL allocate_location,
re_set and check_status methods.
(create_syscall_event_catchpoint): Adjust.
(ranged_breakpoint_ops, watchpoint_breakpoint_ops)
(masked_watchpoint_breakpoint_ops): Install NULL
allocate_location, re_set and check_status methods.
(catch_exec_command_1): Adjust.
(gnu_v3_exception_catchpoint_ops): Install NULL allocate_location,
re_set and check_status methods.
(create_ada_exception_breakpoint): Rename to ...
(init_ada_exception_breakpoint): ... this. Add a struct
breakpoint parameter, and delete the exp_string, cond_string and
cond parameters. Use init_raw_breakpoint, and don't install or
mention the breakpoint yet. Don't clear breakpoint fields that
init_raw_breakpoint already clears.
(re_set_breakpoint): Delete, split into ...
(breakpoint_re_set_default, prepare_re_set_context): ... these new
functions.
(breakpoint_re_set_one): Call the breakpoint's
breakpoint_ops->re_set implementation, if there's one. Adjust.
* breakpoint.h: Forward declare struct bpstats and struct bp_location.
(struct bp_location_ops): New type.
(struct bp_location): New field `ops'.
(struct breakpoint_ops): New `allocate_location', `re_set' and
`check_status' fields. Make `breakpoint_hit''s description match
reality.
(init_bp_location): Declare.
(breakpoint_re_set_default): Declare.
(create_ada_exception_breakpoint): Rename to ...
(init_ada_exception_breakpoint): ... this. Add a struct
breakpoint parameter, and delete the exp_string, cond_string and
cond parameters.
(install_breakpoint): Declare.
* ada-lang.c: Include exceptions.h.
<Ada exceptions description>: Update.
(struct ada_catchpoint_location): New type.
(ada_catchpoint_location_dtor): New function.
(ada_catchpoint_location_ops): New global.
(ada_catchpoint): New type.
(create_excep_cond_exprs): New function.
(dtor_exception, allocate_location_exception, re_set_exception)
(should_stop_exception, check_status_exception): New functions.
(print_one_exception, print_mention_exception)
(print_recreate_exception): Adjust.
(dtor_catch_exception, allocate_location_catch_exception)
(re_set_catch_exception, check_status_catch_exception): New
functions.
(catch_exception_breakpoint_ops): Install them.
(dtor_catch_exception_unhandled)
(allocate_location_catch_exception_unhandled)
(re_set_catch_exception_unhandled)
(check_status_catch_exception_unhandled): New functions.
(catch_exception_unhandled_breakpoint_ops): Install them.
(dtor_catch_assert, allocate_location_catch_assert)
(re_set_catch_assert, check_status_catch_assert): New functions.
(catch_assert_breakpoint_ops): Install them.
(ada_exception_catchpoint_p): Delete.
(catch_ada_exception_command_split)
(ada_exception_catchpoint_cond_string): Rename exp_string
parameter to excep_string. Adjust.
(ada_parse_catchpoint_condition): Delete.
(ada_exception_sal): Rename the exp_string parameter to
excep_string. Delete the cond_string and cond parameters.
Adjust.
(ada_decode_exception_location): Rename the exp_string parameter
to excep_string. Delete the cond_string and cond parameters.
Adjust.
(create_ada_exception_catchpoint): New function.
(catch_ada_exception_command, ada_decode_assert_location)
(catch_assert_command): Adjust.
* ada-lang.h (ada_exception_catchpoint_p): Delete declaration.
* ada-lang.c: Include arch-utils.h.
(ada_decode_exception_location): Make static.
(catch_ada_exception_command): Moved here from breakpoint.c.
(ada_decode_assert_location): Make static.
(catch_assert_command): Moved here from breakpoint.c.
(_initialize_ada_lang): Install the exception and assert
catchpoint commands here.
* ada-lang.h (ada_decode_exception_location)
(ada_decode_assert_location): Delete declarations.
* breakpoint.c (CATCH_PERMANENT, CATCH_TEMPORARY): Moved to
breakpoint.h.
(create_ada_exception_breakpoint): Make extern.
(catch_ada_exception_command, catch_assert_command): Moved to
ada-lang.c.
(add_catch_command): Make extern.
(_initilize_breakpoint): Don't install the exception and assert
catchpoint commands here.
* breakpoint.h (CATCH_PERMANENT, CATCH_TEMPORARY): Moved from
breakpoint.c
(add_catch_command, create_ada_exception_breakpoint): Declare.
This patch enhances the debugger to distinguish between fat pointers
that represent either: array types, or array access types. In the latter
case, the object/type is encoded as a typedef type pointing to the fat
pointer.
The first part of the change is to adjust ada_check_typedef to avoid
stripping the typedef layer when it points to a fat pointer. The rest
of the patch is adjustments required in various places to deal with
the fact that the type is uses might now be a typedef.
gdb/ChangeLog:
* ada-lang.h (ada_coerce_to_simple_array): Add declaration.
* ada-lang.c (ada_typedef_target_type): New function.
(desc_base_type): Add handling of fat pointer typedefs.
(ada_coerce_to_simple_array): Make non-static.
(decode_packed_array_bitsize): Add handling of fat pointer typedefs.
Add assertion.
(ada_template_to_fixed_record_type_1, ada_to_fixed_type)
(ada_check_typedef): Add handling of fat pointer typedefs.
(ada_evaluate_subexp) [OP_FUNCALL]: Likewise.
* ada-typeprint.c (ada_print_type): Add handling of fat pointer
typedefs.
* ada-valprint.c (ada_val_print_1): Convert fat pointers that are not
array accesses to simple arrays rather than simple array pointers.
(ada_value_print): In the case of array descriptors, do not print
the value type description unless it is an array access.
gdb/testsuite/ChangeLog:
* gdb.ada/lang_switch.exp: Correct expected parameter value.
gdb/doc/ChangeLog:
* gdb.texinfo (Ada Glitches): Remove paragraph describing the
occasional case where the debugger prints an array address
instead of the array itself.
This is a new routine that is being generated by the expander in
the context of controlled types. This patch adds it to the list of such
routines so that the debugger does not show it when selecting the first
"user" frame (when switching tasks for instance).
gdb/ChangeLog:
* ada-lang.h (ADA_KNOWN_AUXILIARY_FUNCTION_NAME_PATTERNS): Add
"_finalizer" to the list.
When one of the parameter values in a subprogram calls is an array
whose value does not come from inferior memory, the debugger first
copies the array value in inferior memory. Up to now, the memory
used to hold that copy was taken from the stack (just below the SP),
but this is causing problems on SPARC v9.
So the immediate fix is to follow what C does with arrays and strings,
which is allocate memory on the heap.
gdb/ChangeLog:
* ada-lang.c: #include "value.h".
(ensure_lval): Delete advance declaration. Remove gdbarch and sp
arguments. Implement using value_allocate_space_in_inferior
instead of allocating memory from the stack.
(make_array_descriptor): Remove gdbarch and sp parameters. Update
calls to ensure_lval.
(ada_convert_actual): Remove gdbarch and sp parameters. Update
calls to make_array_descriptor and ensure_lval.
* ada-lang.h (ada_convert_actual): Update declaration.
* infcall.c (value_arg_coerce): Update call to ada_convert_actual.
This new function is needed by the ravenscar-thread layer.
gdb/ChangeLog:
* ada-tasks.c (iterate_over_live_ada_tasks): New function.
* ada-lang.h (iterate_over_live_ada_tasks): Declare.
This patch enhances GDB to take advantage of a recent change in the GNAT
encoding regarding XA types. A detailed description of the logic has
been added at the start of ada_fixup_array_indexes_type to give the
context behind this enhancement.
2010-05-17 Joel Brobecker <brobecker@adacore.com>
* ada-lang.c (to_fixed_range_type): The the raw index type as
argument instead of the raw type name. Remove orig_type parameter.
Update calls throughout.
(ada_fixup_array_indexes_type): New function.
(ada_array_bound_from_type): Add call to ada_fixup_array_indexes_type.
* ada-lang.h (ada_fixup_array_indexes_type): Add declaration.
* ada-typeprint.c (print_range_type): Renames print_range_type_named.
Remove name parameter.
(print_array_type): Add call to ada_fixup_array_indexes_type.
Update calls to print_range_type.
(ada_print_type): Update calls to print_range_type.
This implements a rudimentary version of the la_print_typedef method
for Ada. Ada usually does not use typedefs, but there is one exception:
pointers to unconstrained arrays. Without this patch, we sometimes
get an error in the "info types" output:
(gdb) info types new_integer_type
All types matching regular expression "new_integer_type":
File foo.adb:
Language not supported.
For now, we treat the typedef as if it did not exist - using the
underlying type instead. This is the right thing to do for most cases,
the only exception being access to array types. Since we already have
a general issue in handling these pointers (we confuse them with fat
pointers), we will enhance ada_print_typedef to handle these pointers
at the same time we address the general issue.
gdb/ChangeLog:
* ada-typeprint.c (ada_print_typedef): New function.
* ada-lang.h (ada_print_typedef): Add declaration.
* ada-lang.c (ada_language_defn): set la_print_typdef field
to ada_print_typedef.
gdb/testsuite/ChangeLog:
* info_types.c, info_types.exp: New files.
Tested on x86_64-linux.
The problem is printing the wrong value for dynamic local variables
when using the "info locals" command. Consider the following code:
procedure Print (I1 : Positive; I2 : Positive) is
type My_String is array (I1 .. I2) of Character;
I : My_String := (others => 'A');
S : String (1 .. I2 + 3) := (others => ' ');
begin
S (I1 .. I2) := String (I); -- BREAK
Put_Line (S);
end Print;
After the debugger stopped at BREAK, we try printing all local variables.
Here is what we get:
(gdb) info locals
i = "["00"]["00"]"
s = "["00"]["00"]["00"]["00"]["00"]["00"]["00"]["00"]"
Curiously, printing their value using the "print" command works:
(gdb) print i
$1 = "AA"
(gdb) print s
$2 = " "
We traced the problem to trying to get the contents of a variable
(call to value_contents) before "fix'ing" it. For those not familiar
with the Ada language support, "fixing" a value consists of swapping
the value's dynamic type with a static version that is appropriate
for our actual value. As a result, the dynamic type was used to
determine the value size, which is zero, and thus the value contents
was empty.
gdb/ChangeLog:
* valprint.c (common_val_print): Fix the value before extracting
its contents.
* ada-lang.c (ada_to_fixed_value): Make this function extern.
* ada-lang.h (ada_to_fixed_value): New function declaration.
* ada-valprint.c (ada_value_print): Use ada_to_fixed_value
to avoid code duplication and fix a bug in the handling of
fixed types contents.
gdb/testsuite/ChangeLog:
* gdb.ada/dyn_loc: New testcase.