binutils-gdb.git
9 years agoFix bug with previous patch for unresolved TLS symbol.
Cary Coutant [Mon, 2 Feb 2015 19:46:45 +0000 (11:46 -0800)]
Fix bug with previous patch for unresolved TLS symbol.

We need to check that the output is executable before assuming that we
can replace the reference with zero.

2015-02-02  Cary Coutant  <ccoutant@google.com>

gold/
* x86_64.cc (Target_x86_64::Relocate::relocate_tls): Check for
executable output file.

9 years agoMention which return values need to be freed in lang_varobj_ops
Simon Marchi [Mon, 2 Feb 2015 18:17:08 +0000 (13:17 -0500)]
Mention which return values need to be freed in lang_varobj_ops

This is the result of a little bit of investigation of the C and Ada
languages, as well as some common sense.

gdb/ChangeLog:

* varobj.h (lang_varobj_ops): Mention which return values need
to be freed.

9 years agoxlc -z relro toc section fixes
Alan Modra [Mon, 2 Feb 2015 11:18:46 +0000 (21:48 +1030)]
xlc -z relro toc section fixes

Moving .toc out of .got caused us to lose toc sorting and multi-toc
support.

* emultempl/ppc64elf.em (toc_section_name): New var.
(ppc_after_open): Set it.
(ppc_before_allocation): Use it.
(gld${EMULATION_NAME}_after_allocation): Here too.

9 years agoNDS32/bfd: Add one more argument to control contents cache.
Kuan-Lin Chen [Mon, 2 Feb 2015 05:42:51 +0000 (13:42 +0800)]
NDS32/bfd: Add one more argument to control contents cache.

The hook bfd_elf32_bfd_get_relocated_section_contents frees contents in
gdb, and it make contents pointer mismatched.

9 years agoAdd missing i18n marker in dwarf2_evaluate_property warning message.
Joel Brobecker [Mon, 2 Feb 2015 03:54:02 +0000 (07:54 +0400)]
Add missing i18n marker in dwarf2_evaluate_property warning message.

gdb/ChangeLog:

        * dwarf2loc.c (dwarf2_evaluate_property): Add i18n marker.

9 years ago[Ada] Do not re-cache symbol-lookup result found from cache lookup.
Joel Brobecker [Mon, 2 Feb 2015 03:28:12 +0000 (07:28 +0400)]
[Ada] Do not re-cache symbol-lookup result found from cache lookup.

When ada-lang.c:ada_lookup_symbol_list_worker finds a match in
the symbol cache, it caches the result again, which is unecessary.
This patch fixes the code to avoid that.

gdb/ChangeLog:

        PR gdb/17856:
        * ada-lang.c (ada_lookup_symbol_list_worker): Do not re-cache
        results found in the cache.

Tested on x86_64-linux, no regression.

9 years ago[Ada] pspace_data->sym_cache is always NULL
Joel Brobecker [Mon, 2 Feb 2015 03:20:58 +0000 (07:20 +0400)]
[Ada] pspace_data->sym_cache is always NULL

The Ada symbol cache has been designed to have one instance of that
of that cache per program space, and for each instance to be created
on-demand. ada_get_symbol_cache is the function responsible for both
lookup and creation on demand.

Unfortunately, ada_get_symbol_cache forgot to store the reference
to newly created caches, thus causing it to:
  - Leak old caches;
  - Allocate a new cache each time the cache is being searched or
    a new entry is to be inserted.

This patch fixes the issue by avoiding the use of the local variable,
which indirectly allowed the bug to happen. We manipulate the reference
in the program-space data instead.

gdb/ChangeLog:

        PR gdb/17854:
        * ada-lang.c (ada_get_symbol_cache): Set pspace_data->sym_cache
        when allocating a new one.

9 years agoAutomatic date update in version.in
GDB Administrator [Mon, 2 Feb 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoremove myself from MAINTAINERS
Tom Tromey [Sun, 1 Feb 2015 18:59:27 +0000 (11:59 -0700)]
remove myself from MAINTAINERS

2015-02-01  Tom Tromey  <tom@tromey.com>

* MAINTAINERS: Remove myself.

9 years agoMove vptr_{fieldno,basetype} out of main_type, and update everything accordingly.
Doug Evans [Sun, 1 Feb 2015 05:40:57 +0000 (21:40 -0800)]
Move vptr_{fieldno,basetype} out of main_type, and update everything accordingly.

Every type has to pay the price in memory usage for their presence.
The proper place for them is in the type_specific field which exists
for this purpose.

gdb/ChangeLog:

* dwarf2read.c (process_structure_scope): Update setting of
TYPE_VPTR_BASETYPE, TYPE_VPTR_FIELDNO.
* gdbtypes.c (internal_type_vptr_fieldno): New function.
(set_type_vptr_fieldno): New function.
(internal_type_vptr_basetype): New function.
(set_type_vptr_basetype): New function.
(get_vptr_fieldno): Update setting of TYPE_VPTR_FIELDNO,
TYPE_VPTR_BASETYPE.
(allocate_cplus_struct_type): Initialize vptr_fieldno.
(recursive_dump_type): Printing of vptr_fieldno, vptr_basetype ...
(print_cplus_stuff): ... moved here.
(copy_type_recursive): Don't copy TYPE_VPTR_BASETYPE.
* gdbtypes.h (struct main_type): Members vptr_fieldno, vptr_basetype
moved to ...
(struct cplus_struct_type): ... here.  All uses updated.
(TYPE_VPTR_FIELDNO, TYPE_VPTR_BASETYPE): Rewrite.
(internal_type_vptr_fieldno, set_type_vptr_fieldno): Declare.
(internal_type_vptr_basetype, set_type_vptr_basetype): Declare.
* stabsread.c (read_tilde_fields): Update setting of
TYPE_VPTR_FIELDNO, TYPE_VPTR_BASETYPE.

gdb/testsuite/ChangeLog:

* gdb.base/maint.exp <maint print type argc>: Update expected output.

9 years agoMove TYPE_SELF_TYPE into new field type_specific.
Doug Evans [Sun, 1 Feb 2015 05:21:01 +0000 (21:21 -0800)]
Move TYPE_SELF_TYPE into new field type_specific.

This patch moves TYPE_SELF_TYPE into new field type_specific.self_type
for MEMBERPTR,METHODPTR types, and into type_specific.func_stuff
for METHODs, and then updates everything to use that.
TYPE_CODE_METHOD could share some things with TYPE_CODE_FUNC
(e.g. TYPE_NO_RETURN) and it seemed simplest to keep them together.

Moving TYPE_SELF_TYPE into type_specific.func_stuff for TYPE_CODE_METHOD
is also nice because when we allocate space for function types we assume
they're TYPE_CODE_FUNCs. If TYPE_CODE_METHODs don't need or use that
space then that space would be wasted, and cleaning that up would involve
more invasive changes.

In order to catch errant uses I've added accessor functions
that do some checking.

One can no longer assign to TYPE_SELF_TYPE like this:

  TYPE_SELF_TYPE (foo) = bar;

One instead has to do:

  set_type_self_type (foo, bar);

But I've left reading of the type to the macro:

  bar = TYPE_SELF_TYPE (foo);

In order to discourage bypassing the TYPE_SELF_TYPE macro
I've named the underlying function that implements it
internal_type_self_type.

While testing this I found the stabs reader leaving methods
as TYPE_CODE_FUNCs, hitting my newly added asserts.
Since the dwarf reader smashes functions to methods (via
smash_to_method) I've done a similar thing for stabs.

gdb/ChangeLog:

* cp-valprint.c (cp_find_class_member): Rename parameter domain_p
to self_p.
(cp_print_class_member): Rename local domain to self_type.
* dwarf2read.c (quirk_gcc_member_function_pointer): Rename local
domain_type to self_type.
(set_die_type) <need_gnat_info>: Handle
TYPE_CODE_METHODPTR, TYPE_CODE_MEMBERPTR, TYPE_CODE_METHOD.
* gdb-gdb.py (StructMainTypePrettyPrinter): Handle
TYPE_SPECIFIC_SELF_TYPE.
* gdbtypes.c (internal_type_self_type): New function.
(set_type_self_type): New function.
(smash_to_memberptr_type): Rename parameter domain to self_type.
Update setting of TYPE_SELF_TYPE.
(smash_to_methodptr_type): Update setting of TYPE_SELF_TYPE.
(smash_to_method_type): Rename parameter domain to self_type.
Update setting of TYPE_SELF_TYPE.
(check_stub_method): Call smash_to_method_type.
(recursive_dump_type): Handle TYPE_SPECIFIC_SELF_TYPE.
(copy_type_recursive): Ditto.
* gdbtypes.h (enum type_specific_kind): New value
TYPE_SPECIFIC_SELF_TYPE.
(struct main_type) <type_specific>: New member self_type.
(struct cplus_struct_type) <fn_field.type>: Update comment.
(TYPE_SELF_TYPE): Rewrite.
(internal_type_self_type, set_type_self_type): Declare.
* gnu-v3-abi.c (gnuv3_print_method_ptr): Rename local domain to
self_type.
(gnuv3_method_ptr_to_value): Rename local domain_type to self_type.
* m2-typeprint.c (m2_range): Replace TYPE_SELF_TYPE with
TYPE_TARGET_TYPE.
* stabsread.c (read_member_functions): Mark methods with
TYPE_CODE_METHOD, not TYPE_CODE_FUNC.  Update setting of
TYPE_SELF_TYPE.

9 years agogdbtypes.h (TYPE_SELF_TYPE): Renamed from TYPE_DOMAIN_TYPE.
Doug Evans [Sun, 1 Feb 2015 05:17:05 +0000 (21:17 -0800)]
gdbtypes.h (TYPE_SELF_TYPE): Renamed from TYPE_DOMAIN_TYPE.

gdb/ChangeLog:

* gdbtypes.h (TYPE_SELF_TYPE): Renamed from TYPE_DOMAIN_TYPE.
All uses updated.

9 years agoBe more strict about what kinds of types can be passed.
Doug Evans [Sun, 1 Feb 2015 05:14:17 +0000 (21:14 -0800)]
Be more strict about what kinds of types can be passed.

gdb/ChangeLog:

* gnu-v3-abi.c (gnuv3_dynamic_class): Assert only passed structs
or unions.  Return zero if union.
(gnuv3_get_vtable): Call check_typedef.  Assert only passed structs.
(gnuv3_rtti_type): Pass already-check_typedef'd value to
gnuv3_get_vtable.
(compute_vtable_size): Assert only passed structs.
(gnuv3_print_vtable): Don't call gnuv3_get_vtable for non-structs.

9 years agogdbtypes.c (copy_type_recursive): Handle all TYPE_SPECIFIC_FIELD kinds.
Doug Evans [Sun, 1 Feb 2015 05:13:02 +0000 (21:13 -0800)]
gdbtypes.c (copy_type_recursive): Handle all TYPE_SPECIFIC_FIELD kinds.

gdb/ChangeLog:

* gdbtypes.c (copy_type_recursive): Handle all TYPE_SPECIFIC_FIELD
kinds.

9 years agoAutomatic date update in version.in
GDB Administrator [Sun, 1 Feb 2015 00:00:13 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoChangeLog entries for max-completions patch.
Gary Benson [Sat, 31 Jan 2015 23:24:26 +0000 (15:24 -0800)]
ChangeLog entries for max-completions patch.

gdb/ChangeLog:

PR cli/9007
PR cli/11920
PR cli/15548
* cli/cli-cmds.c (complete_command): Notify user if max-completions
reached.
* common/common-exceptions.h (enum errors)
<MAX_COMPLETIONS_REACHED_ERROR>: New value.
* completer.h (get_max_completions_reached_message): New declaration.
(max_completions): Likewise.
(completion_tracker_t): New typedef.
(new_completion_tracker): New declaration.
(make_cleanup_free_completion_tracker): Likewise.
(maybe_add_completion_enum): New enum.
(maybe_add_completion): New declaration.
(throw_max_completions_reached_error): Likewise.
* completer.c (max_completions): New global variable.
(new_completion_tracker): New function.
(free_completion_tracker): Likewise.
(make_cleanup_free_completion_tracker): Likewise.
(maybe_add_completions): Likewise.
(throw_max_completions_reached_error): Likewise.
(complete_line): Remove duplicates and limit result to max_completions
entries.
(get_max_completions_reached_message): New function.
(gdb_display_match_list): Handle max_completions.
(_initialize_completer): New declaration and function.
* symtab.c: Include completer.h.
(completion_tracker): New static variable.
(completion_list_add_name): Call maybe_add_completion.
(default_make_symbol_completion_list_break_on_1): Renamed from
default_make_symbol_completion_list_break_on.  Maintain
completion_tracker across calls to completion_list_add_name.
(default_make_symbol_completion_list_break_on): New function.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: Include completer.h.
(tui_old_rl_display_matches_hook): New static global.
(tui_rl_display_match_list): Notify user if max-completions reached.
(tui_setup_io): Save/restore rl_completion_display_matches_hook.
* NEWS (New Options): Mention set/show max-completions.

gdb/doc/ChangeLog:

* gdb.texinfo (Command Completion): Document new
"set/show max-completions" option.

gdb/testsuite/ChangeLog:

* gdb.base/completion.exp: Disable completion limiting for
existing tests.  Add new tests to check completion limiting.
* gdb.linespec/ls-errs.exp: Disable completion limiting.

9 years agoAdd max-completions parameter, and implement tab-completion limiting.
Gary Benson [Sat, 31 Jan 2015 23:07:22 +0000 (15:07 -0800)]
Add max-completions parameter, and implement tab-completion limiting.

This commit adds a new exception, MAX_COMPLETIONS_REACHED_ERROR, to be
thrown whenever the completer has generated too many candidates to
be useful.  A new user-settable variable, "max_completions", is added
to control this behaviour.  A top-level completion limit is added to
complete_line_internal, as the final check to ensure the user never
sees too many completions.  An additional limit is added to
default_make_symbol_completion_list_break_on, to halt time-consuming
symbol table expansions.

gdb/ChangeLog:

PR cli/9007
PR cli/11920
PR cli/15548
* cli/cli-cmds.c (complete_command): Notify user if max-completions
reached.
* common/common-exceptions.h (enum errors)
<MAX_COMPLETIONS_REACHED_ERROR>: New value.
* completer.h (get_max_completions_reached_message): New declaration.
(max_completions): Likewise.
(completion_tracker_t): New typedef.
(new_completion_tracker): New declaration.
(make_cleanup_free_completion_tracker): Likewise.
(maybe_add_completion_enum): New enum.
(maybe_add_completion): New declaration.
(throw_max_completions_reached_error): Likewise.
* completer.c (max_completions): New global variable.
(new_completion_tracker): New function.
(free_completion_tracker): Likewise.
(make_cleanup_free_completion_tracker): Likewise.
(maybe_add_completions): Likewise.
(throw_max_completions_reached_error): Likewise.
(complete_line): Remove duplicates and limit result to max_completions
entries.
(get_max_completions_reached_message): New function.
(gdb_display_match_list): Handle max_completions.
(_initialize_completer): New declaration and function.
* symtab.c: Include completer.h.
(completion_tracker): New static variable.
(completion_list_add_name): Call maybe_add_completion.
(default_make_symbol_completion_list_break_on_1): Renamed from
default_make_symbol_completion_list_break_on.  Maintain
completion_tracker across calls to completion_list_add_name.
(default_make_symbol_completion_list_break_on): New function.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: Include completer.h.
(tui_old_rl_display_matches_hook): New static global.
(tui_rl_display_match_list): Notify user if max-completions reached.
(tui_setup_io): Save/restore rl_completion_display_matches_hook.
* NEWS (New Options): Mention set/show max-completions.

gdb/doc/ChangeLog:

* gdb.texinfo (Command Completion): Document new
"set/show max-completions" option.

gdb/testsuite/ChangeLog:

* gdb.base/completion.exp: Disable completion limiting for
existing tests.  Add new tests to check completion limiting.
* gdb.linespec/ls-errs.exp: Disable completion limiting.

9 years agoBuild list of completions as symbol tables are expanded.
Gary Benson [Sat, 31 Jan 2015 22:48:29 +0000 (14:48 -0800)]
Build list of completions as symbol tables are expanded.

This commit makes default_make_symbol_completion_list_break_on build
the list of completions as it expands the necessary symbol tables,
rather than expanding all necessary symbol tables first and then
building the completion lists second.  This allows for the early
termination of symbol table expansion if required.

gdb/ChangeLog:

* symtab.c (struct add_name_data) <code>: New field.
Updated comments.
(add_symtab_completions): New function.
(symtab_expansion_callback): Likewise.
(default_make_symbol_completion_list_break_on): Set datum.code.
Move minimal symbol scan before calling expand_symtabs_matching.
Scan known primary symtabs for externs and statics before calling
expand_symtabs_matching.  Pass symtab_expansion_callback as
expansion_notify argument to expand_symtabs_matching.  Do not scan
primary symtabs for externs and statics after calling
expand_symtabs_matching.

9 years agonew callback parameter expansion_notify for expand_symtabs_matching
Gary Benson [Sat, 31 Jan 2015 22:45:26 +0000 (14:45 -0800)]
new callback parameter expansion_notify for expand_symtabs_matching

This commit adds a new callback parameter, "expansion_notify", to the
top-level expand_symtabs_matching function and to all the vectorized
functions it defers to.  If expansion_notify is non-NULL, it will be
called every time a symbol table is expanded.

gdb/ChangeLog:

* symfile.h (expand_symtabs_exp_notify_ftype): New typedef.
(struct quick_symbol_functions) <expand_symtabs_matching>:
New argument expansion_notify.  All uses updated.
(expand_symtabs_matching): New argument expansion_notify.
All uses updated.
* symfile-debug.c (debug_qf_expand_symtabs_matching):
Also print expansion notify.
* symtab.c (expand_symtabs_matching_via_partial): Call
expansion_notify whenever a partial symbol table is expanded.
* dwarf2read.c (dw2_expand_symtabs_matching): Call
expansion_notify whenever a symbol table is instantiated.

9 years agogdb.ada/dyn_arrayidx.exp: Add additional_flags=-gnat12.
Doug Evans [Sat, 31 Jan 2015 22:26:54 +0000 (14:26 -0800)]
gdb.ada/dyn_arrayidx.exp: Add additional_flags=-gnat12.

gdb/testsuite/ChangeLog:

* gdb.ada/dyn_arrayidx.exp: Add additional_flags=-gnat12.

9 years agoRemove premature comments from previous patch to completer.c
Doug Evans [Sat, 31 Jan 2015 22:17:16 +0000 (14:17 -0800)]
Remove premature comments from previous patch to completer.c

These comments are for a followup patch.

9 years agoUnify CLI/TUI interface to readline tab completion.
Doug Evans [Sat, 31 Jan 2015 22:11:54 +0000 (14:11 -0800)]
Unify CLI/TUI interface to readline tab completion.

This copies a lot of code from readline, but this is temporary.
Readline currently doesn't export what we need.
The plan is to have something that has been working for awhile,
and then we'll have a complete story to present to the readline
maintainers.

gdb/ChangeLog:

* cli-out.c: #include completer.h, readline/readline.h.
(cli_mld_crlf, cli_mld_putch, cli_mld_puts): New functions.
(cli_mld_flush, cld_mld_erase_entire_line): Ditto.
(cli_mld_beep, cli_mld_read_key, cli_display_match_list): Ditto.
* cli-out.h (cli_display_match_list): Declare.
* completer.c (MB_INVALIDCH, MB_NULLWCH): New macros.
(ELLIPSIS_LEN): Ditto.
(gdb_get_y_or_n, gdb_display_match_list_pager): New functions.
(gdb_path_isdir, gdb_printable_part, gdb_fnwidth): Ditto.
(gdb_fnprint, gdb_print_filename): Ditto.
(gdb_complete_get_screenwidth, gdb_display_match_list_1): Ditto.
(gdb_display_match_list): Ditto.
* completer.h (mld_crlf_ftype, mld_putch_ftype): New typedefs.
(mld_puts_ftype, mld_flush_ftype, mld_erase_entire_line_ftype): Ditto.
(mld_beep_ftype, mld_read_key_ftype): Ditto.
(match_list_displayer): New struct.
(gdb_display_match_list): Declare.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: #include completer.h.
(printable_part, PUTX, print_filename, get_y_or_n): Delete.
(tui_mld_crlf, tui_mld_putch, tui_mld_puts): New functions.
(tui_mld_flush, tui_mld_erase_entire_line, tui_mld_beep): Ditto.
(tui_mld_getc, tui_mld_read_key): Ditto.
(tui_rl_display_match_list): Rewrite.
(tui_handle_resize_during_io): New arg for_completion.  All callers
updated.

9 years agoAdd symbol lookup cache.
Doug Evans [Sat, 31 Jan 2015 21:29:33 +0000 (13:29 -0800)]
Add symbol lookup cache.

gdb/ChangeLog:

Add symbol lookup cache.
* NEWS: Document new options and commands.
* symtab.c (symbol_cache_key): New static global.
(DEFAULT_SYMBOL_CACHE_SIZE, MAX_SYMBOL_CACHE_SIZE): New macros.
(SYMBOL_LOOKUP_FAILED): New macro.
(symbol_cache_slot_state): New enum.
(block_symbol_cache): New struct.
(symbol_cache): New struct.
(new_symbol_cache_size, symbol_cache_size): New static globals.
(hash_symbol_entry, eq_symbol_entry): New functions.
(symbol_cache_byte_size, resize_symbol_cache): New functions.
(make_symbol_cache, free_symbol_cache): New functions.
(get_symbol_cache, symbol_cache_cleanup): New function.
(set_symbol_cache_size, set_symbol_cache_size_handler): New functions.
(symbol_cache_lookup, symbol_cache_clear_slot): New function.
(symbol_cache_mark_found, symbol_cache_mark_not_found): New functions.
(symbol_cache_flush, symbol_cache_dump): New functions.
(maintenance_print_symbol_cache): New function.
(maintenance_flush_symbol_cache): New function.
(symbol_cache_stats): New function.
(maintenance_print_symbol_cache_statistics): New function.
(symtab_new_objfile_observer): New function.
(symtab_free_objfile_observer): New function.
(lookup_static_symbol, lookup_global_symbol): Use symbol cache.
(_initialize_symtab): Init symbol_cache_key.  New parameter
maint symbol-cache-size.  New maint commands print symbol-cache,
print symbol-cache-statistics, flush-symbol-cache.
Install new_objfile, free_objfile observers.

gdb/doc/ChangeLog:

* gdb.texinfo (Symbols): Document new commands
"maint print symbol-cache", "maint print symbol-cache-statistics",
"maint flush-symbol-cache".  Document new option
"maint set symbol-cache-size".

9 years agoPR symtab/17855
Joel Brobecker [Sat, 31 Jan 2015 20:43:02 +0000 (12:43 -0800)]
PR symtab/17855

gdb/ChangeLog:

PR symtab/17855
* symfile.c (clear_symtab_users): Move call to breakpoint_re_set
to end.

9 years agoAdd support for inlining scripts into .debug_gdb_scripts.
Doug Evans [Sat, 31 Jan 2015 20:01:13 +0000 (12:01 -0800)]
Add support for inlining scripts into .debug_gdb_scripts.

include/gdb/ChangeLog:

* section-scripts.h: Remove "future extension" comment.
(SECTION_SCRIPT_ID_PYTHON_TEXT): New macro.
(SECTION_SCRIPT_ID_SCHEME_TEXT): New macro.

gdb/ChangeLog:

* NEWS: Mention inlined scripts in .debug_gdb_scripts section.
* auto-load.c: #include ctype.h.
(struct auto_load_pspace_info): Replace member loaded_scripts with
new members loaded_script_files, loaded_script_texts.
(auto_load_pspace_data_cleanup): Update.
(init_loaded_scripts_info): Update.
(get_auto_load_pspace_data_for_loading): Update.
(maybe_add_script_file): Renamed from maybe_add_script.  All callers
updated.
(maybe_add_script_text): New function.
(clear_section_scripts): Update.
(source_script_file, execute_script_contents): New functions.
(source_section_scripts): Add support for
SECTION_SCRIPT_ID_PYTHON_TEXT, SECTION_SCRIPT_ID_GUILE_TEXT.
(print_scripts): New function.
(auto_load_info_scripts): Also print inlined scripts.
(maybe_print_unsupported_script_warning): Renamed from
unsupported_script_warning_print.  All callers updated.
(maybe_print_script_not_found_warning): Renamed from
script_not_found_warning_print.  All callers updated.
* extension-priv.h (struct extension_language_script_ops): New member
objfile_script_executor.
* extension.c (ext_lang_objfile_script_executor): New function.
* extension.h (objfile_script_executor_func): New typedef.
(ext_lang_objfile_script_executor): Declare.
* guile/guile-internal.h (gdbscm_execute_objfile_script): Declare.
* guile/guile.c (guile_extension_script_ops): Update.
* guile/scm-objfile.c (gdbscm_execute_objfile_script): New function.
* python/python.c (python_extension_script_ops): Update.
(gdbpy_execute_objfile_script): New function.

gdb/doc/ChangeLog:

* gdb.texinfo (dotdebug_gdb_scripts section): Update docs to
distinguish script files vs inlined scripts.
* python.texi (Python Auto-loading): Ditto.

gdb/testsuite/ChangeLog:

* gdb.guile/scm-section-script.c: Add duplicate inlined section script
entries.  Duplicate file section script entries.
* gdb.guile/scm-section-script.exp: Add tests for duplicate entries,
inlined entries.  Add test for safe-path rejection.
* gdb.python/py-section-script.c: Add duplicate inlined section script
entries.  Duplicate file section script entries.
* gdb.python/py-section-script.exp: Add tests for duplicate entries,
inlined entries.  Add test for safe-path rejection.

9 years agoMake sure TABs are expanded in TUI windows on MS-Windows.
Eli Zaretskii [Sat, 31 Jan 2015 08:47:14 +0000 (10:47 +0200)]
Make sure TABs are expanded in TUI windows on MS-Windows.

gdb/
2015-01-31  Eli Zaretskii  <eliz@gnu.org>

* tui/tui-io.c (tui_expand_tabs): New function.
(tui_puts, tui_redisplay_readline): Expand TABs into the
appropriate number of spaces.
* tui/tui-regs.c: Include tui-io.h.
(tui_register_format): Call tui_expand_tabs to expand TABs into
the appropriate number of spaces.
* tui/tui-io.h: Add prototype for tui_expand_tabs.

9 years agoAdd producer string to output of info source.
Doug Evans [Sat, 31 Jan 2015 04:49:51 +0000 (20:49 -0800)]
Add producer string to output of info source.

gdb/ChangeLog:

* NEWS: "info source" command now display producer string if present.
* source.c (source_info): Print producer string if present.

gdb/doc/ChangeLog:

* gdb.texinfo (Symbols) <info source>: Output now contains producer
string if present.

9 years agoAutomatic date update in version.in
GDB Administrator [Sat, 31 Jan 2015 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoFix varobj_delete comment
Simon Marchi [Fri, 30 Jan 2015 20:16:43 +0000 (15:16 -0500)]
Fix varobj_delete comment

gdb/ChangeLog:

* varobj.c (varobj_delete): Fix comment.

9 years agoMention that create_child takes ownership of the allocated name
Simon Marchi [Fri, 30 Jan 2015 20:14:46 +0000 (15:14 -0500)]
Mention that create_child takes ownership of the allocated name

gdb/ChangeLog:

* varobj.c (create_child): Modify comment.

9 years agoConstify some parameters in the varobj code
Simon Marchi [Fri, 30 Jan 2015 20:07:15 +0000 (15:07 -0500)]
Constify some parameters in the varobj code

To make it clear that some functions should not modify the variable
object, this patch adds the const qualifier where it makes sense to some
struct varobj * parameters. Most getters should take a const pointer to
guarantee they don't modify the object.

Unfortunately, I couldn't add it to some callbacks (such as name_of_child).
In the C implementation, they call c_describe_child, which calls
varobj_get_path_expr. varobj_get_path_expr needs to modify the object in
order to cache the computed value. It therefore can't take a const
pointer, and it affects the whole call chain. I suppose that's where you
would use a "mutable" in C++.

I did that to make sure there was no other cases like the one fixed in
the previous patch. I don't think it can hurt.

gdb/ChangeLog:

* ada-varobj.c (ada_number_of_children): Constify struct varobj *
parameter.
(ada_name_of_variable): Same.
(ada_path_expr_of_child): Same.
(ada_value_of_variable): Same.
(ada_value_is_changeable_p): Same.
(ada_value_has_mutated): Same.
* c-varobj.c (varobj_is_anonymous_child): Same.
(c_is_path_expr_parent): Same.
(c_number_of_children): Same.
(c_name_of_variable): Same.
(c_path_expr_of_child): Same.
(get_type): Same.
(c_value_of_variable): Same.
(cplus_number_of_children): Same.
(cplus_name_of_variable): Same.
(cplus_path_expr_of_child): Same.
(cplus_value_of_variable): Same.
* jv-varobj.c (java_number_of_children): Same.
(java_name_of_variable): Same.
(java_path_expr_of_child): Same.
(java_value_of_variable): Same.
* varobj.c (number_of_children): Same.
(name_of_variable): Same.
(is_root_p): Same.
(varobj_ensure_python_env): Same.
(varobj_get_objname): Same.
(varobj_get_expression): Same.
(varobj_get_display_format): Same.
(varobj_get_display_hint): Same.
(varobj_has_more): Same.
(varobj_get_thread_id): Same.
(varobj_get_frozen): Same.
(dynamic_varobj_has_child_method): Same.
(varobj_get_gdb_type): Same.
(is_path_expr_parent): Same.
(varobj_default_is_path_expr_parent): Same.
(varobj_get_language): Same.
(varobj_get_attributes): Same.
(varobj_is_dynamic_p): Same.
(varobj_get_child_range): Same.
(varobj_value_has_mutated): Same.
(varobj_get_value_type): Same.
(number_of_children): Same.
(name_of_variable): Same.
(check_scope): Same.
(varobj_editable_p): Same.
(varobj_value_is_changeable_p): Same.
(varobj_floating_p): Same.
(varobj_default_value_is_changeable_p): Same.
* varobj.h (struct lang_varobj_ops): Consitfy some struct varobj *
parameters.
(varobj_get_objname): Constify struct varobj * parameter.
(varobj_get_expression): Same.
(varobj_get_thread_id): Same.
(varobj_get_frozen): Same.
(varobj_get_child_range): Same.
(varobj_get_display_hint): Same.
(varobj_get_gdb_type): Same.
(varobj_get_language): Same.
(varobj_get_attributes): Same.
(varobj_editable_p): Same.
(varobj_floating_p): Same.
(varobj_has_more): Same.
(varobj_is_dynamic_p): Same.
(varobj_ensure_python_env): Same.
(varobj_default_value_is_changeable_p): Same.
(varobj_value_is_changeable_p): Same.
(varobj_get_value_type): Same.
(varobj_is_anonymous_child): Same.
(varobj_value_get_print_value): Same.
(varobj_default_is_path_expr_parent): Same.

9 years agoSet varobj->path_expr in varobj_get_path_expr
Simon Marchi [Fri, 30 Jan 2015 19:43:59 +0000 (14:43 -0500)]
Set varobj->path_expr in varobj_get_path_expr

It seems like different languages are doing this differently (e.g.
C and Ada). For C, var->path_expr is set inside c_path_expr_of_child.
The next time the value is requested, is it therefore not recomputed.
Ada does not set this field, but just returns the value. Since the field
is never set, the value is recomputed every time it is requested.

This patch makes it so that path_expr_of_child's only job is to compute
the path expression, not save/cache the value. The field is set by the
varobj common code.

gdb/ChangeLog:

* varobj.c (varobj_get_path_expr): Set var->path_expr.
* c-varobj.c (c_path_expr_of_child): Set local var instead of
child->path_expr.
(cplus_path_expr_of_child): Same.

9 years agoFree results of varobj_get_expression
Simon Marchi [Fri, 30 Jan 2015 18:56:56 +0000 (13:56 -0500)]
Free results of varobj_get_expression

varobj_get_expression returns an allocated string, which must be freed
by the caller.

gdb/ChangeLog:

* mi-cmd-var.c (print_varobj): Free varobj_get_expression
result.
(mi_cmd_var_info_expression): Same.
* varobj.c (varobj_get_expression): Mention in the comment that
the result must by freed by the caller.

9 years agoFree results of varobj_get_type and type_to_string
Simon Marchi [Fri, 30 Jan 2015 18:54:50 +0000 (13:54 -0500)]
Free results of varobj_get_type and type_to_string

varobj_get_type and type_to_string return an allocated string, which is
not freed at a couple of places.

New in v2:
 * Rename char * type to type_name.
 * Free in all cases in update_type_if_necessary.

gdb/ChangeLog:

* mi/mi-cmd-var.c (mi_cmd_var_info_type): Free result of
varobj_get_type.
(varobj_update_one): Same.
* varobj.c (update_type_if_necessary): Free curr_type_str and
new_type_str.
(varobj_get_type): Specify in comment that the result needs to be
freed by the caller.

9 years agoAutomatic date update in version.in
GDB Administrator [Fri, 30 Jan 2015 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoMove -rc before $aropts
H.J. Lu [Thu, 29 Jan 2015 19:11:03 +0000 (11:11 -0800)]
Move -rc before $aropts

* lib/ld-lib.exp (ar_simple_create): Move -rc before $aropts.

9 years agoPR symtab/17890
Doug Evans [Thu, 29 Jan 2015 18:26:38 +0000 (10:26 -0800)]
PR symtab/17890

gdb/ChangeLog:

PR symtab/17890
* dwarf2read.c (dwarf_decode_line_header): Punt if version > 4.

9 years agoThis patch adds IFUNC support for arm gold backend.
Han Shen [Thu, 29 Jan 2015 18:00:46 +0000 (10:00 -0800)]
This patch adds IFUNC support for arm gold backend.

This is a feature required in chromeos arm development work.

Tested:
1) Built passed all-gold on x86_64 machine
2) Tested with basic gold aarch64 ifunc unittests -
   a) global ifunc, statically/non-statically linked
   b) local ifunc, statically/non-statically linked
   c) global/local, other shared library routine mixed,
   statically/non-statically linked
   d) arm/thumb mode ifunc
   e) linking chrome browser passed

9 years agoRemove plugin_active_plugins_p()
H.J. Lu [Thu, 29 Jan 2015 12:56:39 +0000 (04:56 -0800)]
Remove plugin_active_plugins_p()

Replace plugin_active_plugins_p() with link_info.lto_plugin_active.

* ldfile.c (ldfile_try_open_bfd): Replace plugin_active_plugins_p()
with link_info.lto_plugin_active.
* ldlang.c (lang_process): Likewise.
* ldmain.c (add_archive_element): Likewise.
* plugin.c (plugin_active_plugins_p): Removed.
* plugin.h (plugin_active_plugins_p): Likewise.

9 years agoMerge GCC producer parsers. Allow digits in identifiers.
Mark Wielaard [Sun, 25 Jan 2015 10:20:39 +0000 (11:20 +0100)]
Merge GCC producer parsers. Allow digits in identifiers.

Both dwarf2read.c (checkproducer) and utils.c (producer_is_gcc_ge_4)
implemented a GCC producer parser that tried to extract the major and minor
version of GCC. Merge them into one GCC producer parser used by both. Also
allow digits in the identifier after "GNU " such as used by GCC5 like:
"GNU C11 5.0.0 20150123 (experimental) -mtune=generic -march=x86-64 -gdwarf-5"

gdb/ChangeLog:

* dwarf2read.c (checkproducer): Call producer_is_gcc.
* utils.c (producer_is_gcc_ge_4): Likewise.
(producer_is_gcc): New function.
* utils.h (producer_is_gcc): New declaration.

9 years agoCorrect GOLD PowerPC64 local-dynamic TLS linker optimization
Alan Modra [Thu, 29 Jan 2015 10:03:26 +0000 (20:33 +1030)]
Correct GOLD PowerPC64 local-dynamic TLS linker optimization

Similar to b86ac8e3

* powerpc.cc (Target_powerpc::Relocate::relocate): Correct GOT_TLSLD
and GOT_TLSGD to LE optimization.

9 years agoNDS32: Set branch instruction to relaxable.
Kuan-Lin Chen [Thu, 29 Jan 2015 07:49:02 +0000 (15:49 +0800)]
NDS32: Set branch instruction to relaxable.

Relaxable fragments can be relaxed when there are alignment requirements.
Besides, insert a dummy fragment in the final to make sure that all
alignment is traversed.  Finally, convert these fragments
in md_convert_frag with relax_table.

9 years agoFix patch author issue in gdb/ChangeLog entry.
Joel Brobecker [Thu, 29 Jan 2015 08:10:12 +0000 (12:10 +0400)]
Fix patch author issue in gdb/ChangeLog entry.

9 years agogdb/DWARF: Support for arrays whose bound is a discriminant.
Joel Brobecker [Mon, 5 Jan 2015 10:32:36 +0000 (14:32 +0400)]
gdb/DWARF: Support for arrays whose bound is a discriminant.

Consider the following declarations:

   type Array_Type is array (Integer range <>) of Integer;
   type Record_Type (N : Integer) is record
      A : Array_Type (1 .. N);
   end record;
   R : Record_Type := Get (10);

It defines what Ada programers call a "discriminated record", where
"N" is a component of that record called a "discriminant", and where
"A" is a component defined as an array type whose upper bound is
equal to the value of the discriminant.

So far, we rely on a number of fairly complex GNAT-specific encodings
to handle this situation. This patch is to enhance GDB to be able to
print this record in the case where the compiler has been modified
to replace those encodings by pure DWARF constructs.

In particular, the debugging information generated for the record above
looks like the following. "R" is a record..

        .uleb128 0x10   # (DIE (0x13e) DW_TAG_structure_type)
        .long   .LASF17 # DW_AT_name: "foo__record_type"

... whose is is of course dynamic (not our concern here)...

        .uleb128 0xd    # DW_AT_byte_size
        .byte   0x97    # DW_OP_push_object_address
        .byte   0x94    # DW_OP_deref_size
        .byte   0x4
        .byte   0x99    # DW_OP_call4
        .long   0x19b
        .byte   0x23    # DW_OP_plus_uconst
        .uleb128 0x7
        .byte   0x9     # DW_OP_const1s
        .byte   0xfc
        .byte   0x1a    # DW_OP_and
        .byte   0x1     # DW_AT_decl_file (foo.adb)
        .byte   0x6     # DW_AT_decl_line

... and then has 2 members, fist "n" (our discriminant);

        .uleb128 0x11   # (DIE (0x153) DW_TAG_member)
        .ascii "n\0"    # DW_AT_name
        .byte   0x1     # DW_AT_decl_file (foo.adb)
        .byte   0x6     # DW_AT_decl_line
        .long   0x194   # DW_AT_type
        .byte   0       # DW_AT_data_member_location

... and "A"...

        .uleb128 0x11   # (DIE (0x181) DW_TAG_member)
        .ascii "a\0"    # DW_AT_name
        .long   0x15d   # DW_AT_type
        .byte   0x4     # DW_AT_data_member_location

... which is an array ...

        .uleb128 0x12   # (DIE (0x15d) DW_TAG_array_type)
        .long   .LASF18 # DW_AT_name: "foo__record_type__T4b"
        .long   0x194   # DW_AT_type

... whose lower bound is implicitly 1, and the upper bound
a reference to DIE 0x153 = "N":

        .uleb128 0x13   # (DIE (0x16a) DW_TAG_subrange_type)
        .long   0x174   # DW_AT_type
        .long   0x153   # DW_AT_upper_bound

This patch enhanced GDB to understand references to other DIEs
where the DIE's address is at an offset of its enclosing type.
The difficulty was that the address used to resolve the array's
type (R's address + 4 bytes) is different from the address used
as the base to compute N's address (an offset to R's address).

We're solving this issue by using a stack of addresses rather
than a single address when trying to resolve a type. Each address
in the stack corresponds to each containing level. For instance,
if resolving the field of a struct, the stack should contain
the address of the field at the top, and then the address of
the struct.  That way, if the field makes a reference to an object
of the struct, we can retrieve the address of that struct, and
properly resolve the dynamic property references that struct.

gdb/ChangeLog:

        * gdbtypes.h (struct dynamic_prop): New PROP_ADDR_OFFSET enum
        kind.
        * gdbtypes.c (resolve_dynamic_type_internal): Replace "addr"
        parameter by "addr_stack" parameter.
        (resolve_dynamic_range): Replace "addr" parameter by
        "stack_addr" parameter.  Update function documentation.
        Update code accordingly.
        (resolve_dynamic_array, resolve_dynamic_union)
        (resolve_dynamic_struct, resolve_dynamic_type_internal): Likewise.
        (resolve_dynamic_type): Update code, following the changes made
        to resolve_dynamic_type_internal's interface.
        * dwarf2loc.h (struct property_addr_info): New.
        (dwarf2_evaluate_property): Replace "address" parameter
        by "addr_stack" parameter.  Adjust function documentation.
        (struct dwarf2_offset_baton): New.
        (struct dwarf2_property_baton): Update documentation of
        field "referenced_type" to be more general. New field
        "offset_info" in union data field.
        * dwarf2loc.c (dwarf2_evaluate_property): Replace "address"
        parameter by "addr_stack" parameter.  Adjust code accordingly.
        Add support for PROP_ADDR_OFFSET properties.
        * dwarf2read.c (attr_to_dynamic_prop): Add support for
        DW_AT_data_member_location attributes as well.  Use case
        statements instead of if/else condition.

gdb/testsuite/ChangeLog:

        * gdb.ada/disc_arr_bound: New testcase.

Tested on x86_64-linux, no regression.

9 years ago[Ada/varobj] number of children of null pointer to dynamic array.
Joel Brobecker [Wed, 14 Jan 2015 14:39:24 +0000 (18:39 +0400)]
[Ada/varobj] number of children of null pointer to dynamic array.

This is preparation work to avoid a regression in the Ada/varobj.
An upcoming patch is going to add support for types in DWARF
which have dynamic properties whose value is a reference to another
DIE.

Consider for instance the following declaration:

   type Variant_Type (N : Int := 0) is record
      F : String(1 .. N) := (others => 'x');
   end record;
   type Variant_Type_Access is access all Variant_Type;
   VTA : Variant_Type_Access := null;

This declares a variable "VTA" which is an access (=pointer)
to a variant record Variant_Type. This record contains two
components, the first being "N" (the discriminant), and the
second being "F", an array whose lower bound is 1, and whose
upper bound depends on the value of "N" (the discriminant).

Of interest to us, here, is that second component ("F"), and
in particular its bounds. The debugging info, and in particular
the info for the array looks like the following...

        .uleb128 0x9    # (DIE (0x91) DW_TAG_array_type)
        .long   .LASF16 # DW_AT_name: "bar__variant_type__T2b"
        .long   0xac    # DW_AT_GNAT_descriptive_type
        .long   0x2cb   # DW_AT_type
        .long   0xac    # DW_AT_sibling
        .uleb128 0xa    # (DIE (0xa2) DW_TAG_subrange_type)
        .long   0xc4    # DW_AT_type
        .long   0x87    # DW_AT_upper_bound
        .byte   0       # end of children of DIE 0x91

... where the upper bound of the array's subrange type is a reference
to "n"'s DIE (0x87):

        .uleb128 0x8    # (DIE (0x87) DW_TAG_member)
        .ascii "n\0"    # DW_AT_name
        [...]

Once the patch to handle this dynamic property gets applied,
this is what happens when creating a varobj for variable "VTA"
(whose value is null), and then trying to list its children:

    (gdb)
    -var-create vta * vta
    ^done,name="vta",numchild="2",value="0x0",
          type="bar.variant_type_access",has_more="0"
    (gdb)
    -var-list-children 1 vta
    ^done,numchild="2",
          children=[child={name="vta.n",[...]},
                    child={name="vta.f",exp="f",
                           numchild="43877616",  <<<<-----
                           value="[43877616]",   <<<<-----
                           type="array (1 .. n) of character"}],
          has_more="0"

It has an odd number of children.

In this case, we cannot really determine the number of children,
since that number depends on the value of a field in a record
for which we do not have a value. Up to now, the value we've been
displaying is zero - meaning we have an empty array.

What happens in this case, is that, because the VTA is a null pointer,
we're not able to resolve the pointer's target type, and therefore
end up asking ada_varobj_get_array_number_of_children to return
the number of elements in that array; for that, it relies blindly
on get_array_bounds, which assumes the type is no longer dynamic,
and therefore the reads the bound without seeing that it's value
is actually a reference rather than a resolved constant.

This patch prevents the issue by explicitly handling the case of
dynamic arrays, and returning zero child in that case.

gdb/ChangeLog:

        * ada-varobj.c (ada_varobj_get_array_number_of_children):
        Return zero if PARENT_VALUE is NULL and parent_type's
        range type is dynamic.

gdb/testsuite/ChangeLog:

        * gdb.ada/mi_var_array: New testcase.

Tested on x86_64-linux.

9 years agogdb/DWARF: dynamic subrange type of dynamic subrange type.
Joel Brobecker [Mon, 5 Jan 2015 14:39:02 +0000 (18:39 +0400)]
gdb/DWARF: dynamic subrange type of dynamic subrange type.

Consider the following code:

   type Record_Type (N : Integer) is record
      A : Array_Type (1 .. N);
   end record;
   [...]
   R : Record_Type := Get (10);

Trying to print the bounds of the array R.A yielded:

    (gdb) p r.a'last
    $4 = cannot find reference address for offset property

A slightly different example, but from the same cause:

    (gdb) ptype r
    type = <ref> record
        n: integer;
        a: array (cannot find reference address for offset property

Looking at the debugging info, "A" is described as...

        .uleb128 0x11   # (DIE (0x181) DW_TAG_member)
        .ascii "a\0"    # DW_AT_name
        .long   0x15d   # DW_AT_type
        [...]

... which is an array...

        .uleb128 0x12   # (DIE (0x15d) DW_TAG_array_type)
        .long   .LASF18 # DW_AT_name: "foo__record_type__T4b"
        .long   0x194   # DW_AT_type
        .long   0x174   # DW_AT_sibling

... whose bounds are described as:

        .uleb128 0x13   # (DIE (0x16a) DW_TAG_subrange_type)
        .long   0x174   # DW_AT_type
        .long   0x153   # DW_AT_upper_bound
        .byte   0       # end of children of DIE 0x15d

We can see above that the range has an implict lower value of
1, and an upper value which is a reference 0x153="n". All Good.

But looking at the array's subrange subtype, we see...

        .uleb128 0x14   # (DIE (0x174) DW_TAG_subrange_type)
        .long   0x153   # DW_AT_upper_bound
        .long   .LASF19 # DW_AT_name: "foo__record_type__T3b"
        .long   0x18d   # DW_AT_type

... another subrange type whose bounds are exactly described
the same way. So we have a subrange of a subrange, both with
one bound that's dynamic.

What happens in the case above is that GDB's resolution of "R.A"
yields a array whose index type has static bounds. However, the
subtype of the array's index type was left untouched, so, when
taking the subtype of the array's subrange type, we were left
with the unresolved subrange type, triggering the error above.

gdb/ChangeLog:

        * gdbtypes.c (is_dynamic_type_internal) <TYPE_CODE_RANGE>: Return
        nonzero if the type's subtype is dynamic.
        (resolve_dynamic_range): Also resolve the range's subtype.

Tested on x86_64-linux, no regression.

9 years agoFix build failure in symfile.c::unmap_overlay_command (GCC5 bug)
Alexander Klimov [Tue, 27 Jan 2015 17:56:45 +0000 (19:56 +0200)]
Fix build failure in symfile.c::unmap_overlay_command (GCC5 bug)

Compilation of (GDB) 7.9.50.20150127-cvs with (GCC) 5.0.0 20150127
fails with

In file included from symfile.c:32:0:
symfile.c: In function 'unmap_overlay_command':
objfiles.h:628:3: error: 'sec' may be used uninitialized in this
function [-Werror=maybe-uninitialized]
   for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
   ^
symfile.c:3442:23: note: 'sec' was declared here
   struct obj_section *sec;
                       ^
cc1: all warnings being treated as errors
make[2]: *** [symfile.o] Error 1
make[2]: Leaving directory `gdb/gdb'

While the bug was reported to GCC as
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64823>,
the attached patch simply initializes sec with NULL.

gdb/ChangeLog:

        * symfile.c (unmap_overlay_command): Initialize sec to NULL.

Tested on x86_64-linux.

9 years agoCorrect PowerPC64 local-dynamic TLS linker optimization
Alan Modra [Thu, 29 Jan 2015 00:39:55 +0000 (11:09 +1030)]
Correct PowerPC64 local-dynamic TLS linker optimization

The linker hardcoded r3 into a local-dynamic to local-exec TLS
optimization sequence.  This is normally the case since r3 is required
as a parameter to (the optimized out) __tls_get_addr call.  However,
it is possible for a compiler, LLVM in this case, to set up the
parameter value in another register then copy it to r3 before the
call.

When fixing this problem, I noticed that ppc32 had another bug when
optimizing away one of the TLS insns to a nop.

The patch also tidies a mask used by global-dynamic to initial-exec
TLS optimization, to just select the fields needed.  Leaving the
offset in the instruction wasn't a bug since it will be overwritten
anyway.

bfd/
* elf64-ppc.c (ppc64_elf_relocate_section): Correct GOT_TLSLD
optimization.  Tidy mask for GOT_TLSGD optimization.
* elf32-ppc.c (ppc_elf_relocate_section): Likewise.  Correct
location of nop zapping high insn too.
ld/testsuite/
* ld-powerpc/tlsld.d, * ld-powerpc/tlsld.s: New test.
* ld-powerpc/tlsld32.d, * ld-powerpc/tlsld32.s: New test.
* ld-powerpc/powerpc.exp: Run them.  Move tocvar and tocnovar.

9 years agoAutomatic date update in version.in
GDB Administrator [Thu, 29 Jan 2015 00:00:13 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoAllow undefined references to TLS symbols.
Cary Coutant [Wed, 28 Jan 2015 23:39:08 +0000 (15:39 -0800)]
Allow undefined references to TLS symbols.

When --warn-unresolved-symbols is used, gold tries to create a dynamic relocation
for it, and gives an internal error if the TLS segment has not already been
created. This patch allows the IE-to-LE optimization for an undefined symbol
when building an executable, which suppresses the dynamic relocation, and
relaxes the requirement to have a TLS segment when applying a relocation for
an undefined symbol.

2015-01-28  Cary Coutant  <ccoutant@google.com>

gold/
* x86_64.cc (Target_x86_64::Scan::global): Allow IE-to-LE optimization
for undef TLS symbols.
(Target_x86_64::Relocate::relocate_tls): Likewise.
(Target_x86_64::Relocate::tls_ie_to_le): Likewise.

9 years agoMake plugin_get_ir_dummy_bfd static
H.J. Lu [Wed, 28 Jan 2015 20:56:18 +0000 (12:56 -0800)]
Make plugin_get_ir_dummy_bfd static

* plugin.h (plugin_get_ir_dummy_bfd): Removed.  Move comments to
...
* plugin.c (plugin_get_ir_dummy_bfd): Here.  Make it static.

9 years agoThe initial support for LDPT_GET_VIEW
H.J. Lu [Wed, 28 Jan 2015 18:27:31 +0000 (10:27 -0800)]
The initial support for LDPT_GET_VIEW

This patch adds the initial support for LDPT_GET_VIEW.

ld/

PR ld/17878
* plugin.c (tv_header_tags(): Add LDPT_GET_VIEW.
(get_view): New function.
(set_tv_header): Handle LDPT_GET_VIEW.
* testplug.c (tag_names): Add LDPT_GET_VIEW.
(tv_get_view): New.
(dump_tv_tag): Handle LDPT_GET_VIEW.
(parse_tv_tag): Likewise.

ld/testsuite/

PR ld/17878
* ld-plugin/plugin-1.d: Add LDPT_GET_VIEW.
* ld-plugin/plugin-10.d: Likewise.
* ld-plugin/plugin-11.d: Likewise.
* ld-plugin/plugin-2.d: Likewise.
* ld-plugin/plugin-3.d: Likewise.
* ld-plugin/plugin-4.d: Likewise.
* ld-plugin/plugin-5.d: Likewise.
* ld-plugin/plugin-6.d: Likewise.
* ld-plugin/plugin-7.d: Likewise.
* ld-plugin/plugin-8.d: Likewise.
* ld-plugin/plugin-9.d: Likewise.

9 years agold: don't use ia64 register name in expression of pr16322 test
Jan Beulich [Wed, 28 Jan 2015 09:04:51 +0000 (10:04 +0100)]
ld: don't use ia64 register name in expression of pr16322 test

"f1" is a register name on ia64, and hence gets warned upon when used
as expression value:

.../binutils/2.25/ld/testsuite/ld-elf/pr16322.s: Assembler messages:
.../binutils/2.25/ld/testsuite/ld-elf/pr16322.s:6: Warning: register value used as expression

Change the name (and "p1" at once, which is a register name too, albeit
not currently causing any immediate problem).

ld/testsuite/
2015-01-28  Jan Beulich  <jbeulich@suse.com>

* ld-elf/pr16322.s (p1): Rename to px1.
(f1): Rename to fx1.

9 years agoPowerPC64 changes for xlc
Alan Modra [Tue, 27 Jan 2015 13:10:05 +0000 (23:40 +1030)]
PowerPC64 changes for xlc

The changes to reorder sections for better relro protection on powerpc64,
3e2b0f3123283c1b, and 5ad18f16, run into a problem with xlc.
xlc -qdatalocal puts global variables into .toc, which means that .toc
must be writable.  The simplest way to accomplish this is to edit the
linker script to remove .toc sections from .got on detecting xlc object
files.

bfd/
* elf64-ppc.h (struct ppc64_elf_params): Add "object_in_toc".
* elf64-ppc.c (ppc64_elf_add_symbol_hook): Assume that global symbols
in .toc indicate xlc compiled code that might require a rw .toc.
ld/
* emulparams/elf64ppc.sh (INITIAL_READWRITE_SECTIONS): Define.
* emultempl/ppc64elf.em (params): Init new field.
(ppc_after_open): New function.
(LDEMUL_AFTER_OPEN): Define.
* ldlang.c (lang_final): Whitespace fix.
ld/testsuite/
* ld-powerpc/tocvar.d, * ld-powerpc/tocvar.s: New test.
* ld-powerpc/tocnovar.d, * ld-powerpc/tocnovar.s: New test.
* ld-powerpc/powerpc.exp: Run tocvar and tocnovar.

9 years agoFT32 initial support
Alan Modra [Wed, 28 Jan 2015 05:06:43 +0000 (15:36 +1030)]
FT32 initial support

FT32 is a new 32-bit RISC core developed by FTDI for embedded applications.

* configure.ac: Add FT32 support.
* configure: Regenerate.
bfd/
* Makefile.am: Add FT32 files.
* archures.c (enum bfd_architecture): Add bfd_arch_ft32.
(bfd_mach_ft32): Define.
(bfd_ft32_arch): Declare.
(bfd_archures_list): Add bfd_ft32_arch.
* config.bfd: Handle FT32.
* configure.ac: Likewise.
* cpu-ft32.c: New file.
* elf32-ft32.c: New file.
* reloc.c (BFD_RELOC_FT32_10, BFD_RELOC_FT32_20, BFD_RELOC_FT32_17,
BFD_RELOC_FT32_18): Define.
* targets.c (_bfd_target_vector): Add ft32_elf32_vec.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
* Makefile.in: Regenerate.
* configure: Regenerate.
* po/SRC-POTFILES.in: Regenerate.
binutils/
* readelf.c: Add FT32 support.
gas/
* Makefile.am: Add FT32 files.
* config/tc-ft32.c: New file.
* config/tc-ft32.h: New file.
* configure.tgt: Add FT32 support.
* Makefile.in: Regenerate.
* po/POTFILES.in: Regenerate.
gas/testsuite/
* gas/ft32/ft32.exp: New file.
* gas/ft32/insn.d: New file.
* gas/ft32/insn.s: New file.
include/
* dis-asm.h (print_insn_ft32): Declare.
include/elf/
* common.h (EM_FT32): Define.
* ft32.h: New file.
include/opcode/
* ft32.h: New file.
ld/
* Makefile.am: Add FT32 files.
* configure.tgt: Handle FT32 target.
* emulparams/elf32ft32.sh: New file.
* scripttempl/ft32.sc: New file.
* Makefile.in: Regenerate.
opcodes/
* Makefile.am: Add FT32 files.
* configure.ac: Handle FT32.
* disassemble.c (disassembler): Call print_insn_ft32.
* ft32-dis.c: New file.
* ft32-opc.c: New file.
* Makefile.in: Regenerate.
* configure: Regenerate.
* po/POTFILES.in: Regenerate.

9 years agoAllow symbols in MEMORY region specification
Senthil Kumar Selvaraj [Wed, 28 Jan 2015 04:31:50 +0000 (15:01 +1030)]
Allow symbols in MEMORY region specification

This patch fixes PR 4643 by allowing symbols in the LENGTH and ORIGIN
fields of MEMORY regions.  Previously, only constants and constant
expressions are allowed.

For the AVR target, this helps define memory constraints more
accurately (per device), without having to create a ton of device
specific linker scripts.

ld/
PR 4643
* ldexp.c (fold_name): Fold LENGTH only after
lang_first_phase_enum.
* ldgram.y (memory_spec): Don't evaluate ORIGIN and LENGTH
rightaway.
* ldlang.h (struct memory_region_struct): Add origin_exp and
length_exp fields.
* ldlang.c (lang_do_memory_regions): New.
(lang_memory_region_lookup): Initialize origin_exp and
length_exp fields.
(lang_process): Call lang_do_memory_regions.
ld/testsuite/
* ld-scripts/memory.t: Define new symbol tred.
* ld-scripts/memory_sym.t: New.
* ld-scripts/script.exp: Perform MEMORY with symbols test, and
conditionally check values of linker symbols.

9 years agoNDS32/opcodes: Add new system registers.
Kuan-Lin Chen [Wed, 28 Jan 2015 01:12:59 +0000 (09:12 +0800)]
NDS32/opcodes: Add new system registers.

9 years agoAutomatic date update in version.in
GDB Administrator [Wed, 28 Jan 2015 00:00:13 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoAdd gdb.Objfile.username.
Doug Evans [Tue, 27 Jan 2015 18:13:52 +0000 (10:13 -0800)]
Add gdb.Objfile.username.

gdb/ChangeLog:

* NEWS: Mention gdb.Objfile.username.
* python/py-objfile.c (objfpy_get_username): New function.
(objfile_getset): Add "username".

gdb/doc/ChangeLog:

* python.texi (Objfiles In Python): Document Objfile.username.

gdb/testsuite/ChangeLog:

* gdb.python/py-objfile.exp: Add tests for objfile.username.
Add test for objfile.filename, objfile.username after objfile
has been unloaded.

9 years agoImprove docs of objfile filename method.
Doug Evans [Tue, 27 Jan 2015 18:03:15 +0000 (10:03 -0800)]
Improve docs of objfile filename method.

gdb/doc/ChangeLog:

* python.texi (Objfiles In Python) <Objfile.filename>: Improve docs.
* guile.texi (Objfiles In Guile) <objfile-filename>: Improve docs.

9 years agoFixes for invalid memory accesses triggered by running windres on corrupt binaries.
Nick Clifton [Tue, 27 Jan 2015 17:32:23 +0000 (17:32 +0000)]
Fixes for invalid memory accesses triggered by running windres on corrupt binaries.

PR binutils/17512
* rcparse.y: Add checks to avoid integer divide by zero.
* rescoff.c (read_coff_rsrc): Add check on the size of the
resource section.
(read_coff_res_dir): Add check on the nesting level.
Check for resource names overrunning the buffer.
* resrc.c (write_rc_messagetable): Update formatting.
Add check of 'elen' being zero.

9 years agoFixes for memory access violations triggered by running addr2line on fuzzed binaries.
Nick Clifton [Tue, 27 Jan 2015 15:49:12 +0000 (15:49 +0000)]
Fixes for memory access violations triggered by running addr2line on fuzzed binaries.

PR binutils/17512
* addr2line.c (slurp_symtab): If the symcount is zero, free the
symbol table pointer.

* dwarf2.c (concat_filename): Check for an empty directory table.
(scan_unit_for_symbols): Check for reading off the end of the
unit.
(parse_comp_unit): Check for a DW_AT_comp_dir attribute with a
non-string form.
* elf64-ppc.c (opd_entry_value): Fail if there are no relocs
available.

9 years agoFix memory access violations triggered by running dlltool on corrupt binaries.
Nick Clifton [Tue, 27 Jan 2015 11:30:15 +0000 (11:30 +0000)]
Fix memory access violations triggered by running dlltool on corrupt binaries.

PR binutils/17512
* dlltool.c (identify_search_archive): If the last archive was the
same as the current archive, terminate the loop.

* pdp11.c (aout_get_external_symbols): Return false if there are
no symbols.

9 years agoNDS32/gas: Limit the format of pseudo instruction la.
Kuan-Lin Chen [Tue, 27 Jan 2015 03:19:13 +0000 (11:19 +0800)]
NDS32/gas: Limit the format of pseudo instruction la.

9 years agoNDS32/gas: Fix md_parse_name hook.
Kuan-Lin Chen [Tue, 27 Jan 2015 03:08:07 +0000 (11:08 +0800)]
NDS32/gas: Fix md_parse_name hook.

9 years agoAutomatic date update in version.in
GDB Administrator [Tue, 27 Jan 2015 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoFix ARI warning in stack.c (return_command).
Mark Wielaard [Sat, 24 Jan 2015 14:08:32 +0000 (15:08 +0100)]
Fix ARI warning in stack.c (return_command).

gdb/ChangeLog

    * stack.c (return_command): Markup warning message with _.

9 years agocheck gdb.lookup_type return value in gdb.python/py-lookup-type.exp
Joel Brobecker [Wed, 21 Jan 2015 09:29:09 +0000 (10:29 +0100)]
check gdb.lookup_type return value in gdb.python/py-lookup-type.exp

This further improves this testcase to check the output of
our calls to gdb.lookup_type.

gdb/ChangeLog:

        * gdb.python/py-lookup-type.exp (test_lookup_type): Change
        the second test to print the name attribute of value
        returned by the call to gdb.lookup_type, and adjust
        the expected output accordingly.

9 years agoNDS32/bfd: Fix relax round setting.
Kuan-Lin Chen [Mon, 26 Jan 2015 02:48:01 +0000 (10:48 +0800)]
NDS32/bfd: Fix relax round setting.

9 years ago2015-01-25 Cary Coutant <ccoutant@google.com>
Cary Coutant [Mon, 26 Jan 2015 01:31:32 +0000 (17:31 -0800)]
2015-01-25  Cary Coutant  <ccoutant@google.com>

gold/
* output.cc (Output_segment::set_section_addresses): Fix calculation
of size of relro segment.

9 years agoAutomatic date update in version.in
GDB Administrator [Mon, 26 Jan 2015 00:01:31 +0000 (00:01 +0000)]
Automatic date update in version.in

9 years agoRemove testsuite compile errors with GCC5.
Mark Wielaard [Sun, 25 Jan 2015 15:42:05 +0000 (16:42 +0100)]
Remove testsuite compile errors with GCC5.

GCC5 defaults to the GNU11 standard for C and warns by default for
implicit function declarations and implicit return types.
https://gcc.gnu.org/gcc-5/porting_to.html

Fixing these issues in the testsuite turns 9 untested and 17 unsupported
testcases into 417 new passes when compiling with GCC5.

gdb/testsuite/ChangeLog:

        * gdb.arch/i386-bp_permanent.c (standard): New declaration.
        * gdb.base/disp-step-fork.c: Include unistd.h.
        * gdb.base/siginfo-obj.c: Include stdio.h.
        * gdb.base/siginfo-thread.c: Likewise.
        * gdb.mi/non-stop.c: Include unistd.h.
        * gdb.mi/nsthrexec.c: Include stdio.h.
        * gdb.mi/pthreads.c: Include unistd.h.
        * gdb.modula2/unbounded1.c (main): Declare returns int.
        * gdb.reverse/consecutive-reverse.c: Likewise.
        * gdb.threads/create-fail.c: Include unistd.h.
        * gdb.threads/killed.c: Likewise.
        * gdb.threads/linux-dp.c: Likewise.
        * gdb.threads/non-ldr-exc-1.c: Include stdio.h and string.h.
        * gdb.threads/non-ldr-exc-2.c: Likewise.
        * gdb.threads/non-ldr-exc-3.c: Likewise.
        * gdb.threads/non-ldr-exc-4.c: Likewise.
        * gdb.threads/pthreads.c: Include unistd.h.
        (main): Declare returns int.
        * gdb.threads/tls-main.c (foo): New declaration.
        * gdb.threads/watchpoint-fork-mt.c: Define _GNU_SOURCE.

9 years agoAutomatic date update in version.in
GDB Administrator [Sun, 25 Jan 2015 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agogdbtypes.h (TYPE_TYPE_SPECIFIC): Delete.
Doug Evans [Sat, 24 Jan 2015 19:17:08 +0000 (11:17 -0800)]
gdbtypes.h (TYPE_TYPE_SPECIFIC): Delete.

gdb/ChangeLog:

* gdbtypes.h (TYPE_TYPE_SPECIFIC): Delete.

9 years agoFix 100x slowdown regression on DWZ files
Jan Kratochvil [Sat, 24 Jan 2015 14:44:52 +0000 (15:44 +0100)]
Fix 100x slowdown regression on DWZ files

Since Fedora started to use DWZ DWARF compressor:
http://fedoraproject.org/wiki/Features/DwarfCompressor
GDB has slowed down a lot.  To make it clear - DWZ is DWARF structure
rearrangement, "compressor" does not mean any zlib style data compression.

This patch reduces LibreOffice backtrace from 5 minutes to 3 seconds (100x)
and it also reduces memory consumption 20x.
[ benchmark is at the bottom of this mail ]

Example of DWZ output:
------------------------------------------------------------------------------
  Compilation Unit @ offset 0xc4:
 <0><cf>: Abbrev Number: 17 (DW_TAG_partial_unit)
    <d0>   DW_AT_stmt_list   : 0x0
    <d4>   DW_AT_comp_dir    : (indirect string, offset: 0x6f): /usr/src/debug/gdb-7.7.1/build-x86_64-redhat-linux-gnu/gdb
 <1><d8>: Abbrev Number: 9 (DW_TAG_typedef)
    <d9>   DW_AT_name        : (indirect string, offset: 0x827dc): size_t
    <dd>   DW_AT_decl_file   : 4
    <de>   DW_AT_decl_line   : 212
    <df>   DW_AT_type        : <0xae>

  Compilation Unit @ offset 0xe4:
 <0><ef>: Abbrev Number: 13 (DW_TAG_partial_unit)
    <f0>   DW_AT_stmt_list   : 0x0
    <f4>   DW_AT_comp_dir    : (indirect string, offset: 0x6f): /usr/src/debug/gdb-7.7.1/build-x86_64-redhat-linux-gnu/gdb
 <1><f8>: Abbrev Number: 45 (DW_TAG_typedef)
    <f9>   DW_AT_name        : (indirect string, offset: 0x251): __off_t
    <fd>   DW_AT_decl_file   : 3
    <fe>   DW_AT_decl_line   : 131
    <ff>   DW_AT_type        : <0x68>

  Compilation Unit @ offset 0x62d9f9:
 <0><62da04>: Abbrev Number: 20 (DW_TAG_compile_unit)
[...]
    <62da12>   DW_AT_low_pc  : 0x807e10
    <62da1a>   DW_AT_high_pc     : 134
    <62da1c>   DW_AT_stmt_list   : 0xf557e
 <1><62da20>: Abbrev Number: 7 (DW_TAG_imported_unit)
    <62da21>   DW_AT_import  : <0xcf> [Abbrev Number: 17]
------------------------------------------------------------------------------

One can see all DW_TAG_partial_unit have DW_AT_stmt_list 0x0 which causes
repeated decoding of that .debug_line unit on each DW_TAG_imported_unit.

This was OK before as each DW_TAG_compile_unit has its own .debug_line unit.
But since the introduction of DW_TAG_partial_unit by DWZ one should cache
read-in DW_AT_stmt_list .debug_line units.

Fortunately one does not need to cache whole
        struct linetable *symtab->linetable
and other data from .debug_line mapping PC<->lines
------------------------------------------------------------------------------
 Line Number Statements:
  Extended opcode 2: set Address to 0x45c880
  Advance Line by 25 to 26
  Copy
------------------------------------------------------------------------------
as the only part of .debug_line which GDB needs for DW_TAG_partial_unit is:
------------------------------------------------------------------------------
 The Directory Table:
  ../../gdb
  /usr/include/bits
[...]
 The File Name Table:
  Entry Dir     Time    Size    Name
  1     1 0 0 gdb.c
  2     2 0 0 string3.h
[...]
------------------------------------------------------------------------------
specifically referenced in GDB for DW_AT_decl_file at a single place:
------------------------------------------------------------------------------
              fe = &cu->line_header->file_names[file_index - 1];
              SYMBOL_SYMTAB (sym) = fe->symtab;
------------------------------------------------------------------------------

This is because for some reason DW_TAG_partial_unit never contains PC-related
DWARF information.  I do not know exactly why, the compression ratio is a bit
lower due to it but thanksfully currently it is that way:
dwz.c:
------------------------------------------------------------------------------
        /* These attributes reference code, prevent moving
           DIEs with them.  */
        case DW_AT_low_pc:
        case DW_AT_high_pc:
        case DW_AT_entry_pc:
        case DW_AT_ranges:
          die->die_ck_state = CK_BAD;
+
  /* State of checksum computation.  Not computed yet, computed and
     suitable for moving into partial units, currently being computed
     and finally determined unsuitable for moving into partial units.  */
  enum { CK_UNKNOWN, CK_KNOWN, CK_BEING_COMPUTED, CK_BAD } die_ck_state : 2;
------------------------------------------------------------------------------
I have also verified also real-world Fedora debuginfo files really comply with
that assumption with dwgrep
https://github.com/pmachata/dwgrep
using:
------------------------------------------------------------------------------
dwgrep -e 'entry ?DW_TAG_partial_unit child* ( ?DW_AT_low_pc , ?DW_AT_high_pc , ?DW_AT_ranges )' /usr/lib/debug/**
------------------------------------------------------------------------------

BTW I think GDB already does not support the whole DW_TAG_imported_unit and
DW_TAG_partial_unit usage possibilities as specified by the DWARF standard.
I think GDB would not work if DW_TAG_imported_unit was used in some inner
level and not at the CU level (readelf -wi level <1>) - this is how DWZ is
using DW_TAG_imported_unit.  Therefore I do not think further assumptions
about DW_TAG_imported_unit and DW_TAG_partial_unit usage by DWZ are a problem
for GDB.

One could save the whole .debug_line decoded PC<->lines mapping (and not just
the DW_AT_decl_file table) but:
 * there are some problematic corner cases so one could do it incorrectly
 * there are no real world data to really test such patch extension
 * such extension could be done perfectly incrementally on top of this patch

------------------------------------------------------------------------------

benchmark - on Fedora 20 x86_64 and FSF GDB HEAD:
echo -e 'thread apply all bt\nset confirm no\nq'|./gdb -p `pidof soffice.bin` -ex 'set pagination off' -ex 'maintenance set per-command
space' -ex 'maintenance set per-command symtab' -ex 'maintenance set per-command time'

FSF GDB HEAD ("thread apply all bt"):
Command execution time: 333.693000 (cpu), 335.587539 (wall)
                                          ---sec
Space used: 1736404992 (+1477189632 for this command)
                         ----MB
vs.
THIS PATCH ("thread apply all bt"):
Command execution time: 2.595000 (cpu), 2.607573 (wall)
                                        -sec
Space used: 340058112 (+85917696 for this command)
                        --MB

FSF GDB HEAD ("thread apply all bt full"):
Command execution time: 466.751000 (cpu), 468.345837 (wall)
                                          ---sec
Space used: 2330132480 (+2070974464 for this command)
                         ----MB
vs.
THIS PATCH ("thread apply all bt full"):
Command execution time: 18.907000 (cpu), 18.964125 (wall)
                                         --sec
Space used: 364462080 (+110325760 for this command)
                        ---MB

------------------------------------------------------------------------------

gdb/ChangeLog
2015-01-24  Jan Kratochvil  <jan.kratochvil@redhat.com>

Fix 100x slowdown regression on DWZ files.
* dwarf2read.c (struct dwarf2_per_objfile): Add line_header_hash.
(struct line_header): Add offset and offset_in_dwz.
(dwarf_decode_lines): Add parameter decode_mapping to the declaration.
(free_line_header_voidp): New declaration.
(line_header_hash, line_header_hash_voidp, line_header_eq_voidp): New
functions.
(dwarf2_build_include_psymtabs): Update dwarf_decode_lines caller.
(handle_DW_AT_stmt_list): Use line_header_hash.
(free_line_header_voidp): New function.
(dwarf_decode_line_header): Initialize offset and offset_in_dwz.
(dwarf_decode_lines): New parameter decode_mapping, use it.
(dwarf2_free_objfile): Free line_header_hash.

9 years agoAutomatic date update in version.in
GDB Administrator [Sat, 24 Jan 2015 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoCatch exception in value_rtti_indirect_type
Simon Marchi [Fri, 23 Jan 2015 17:59:24 +0000 (12:59 -0500)]
Catch exception in value_rtti_indirect_type

In the situation described in bug 17416 [1]:

  * "set print object" is on;
  * The variable object is a pointer to a struct, and it contains an
    invalid value (e.g. NULL, or random uninitialized value);
  * The variable object (struct) has a child which is also a pointer to a
    struct;
  * We try to use "-var-list-children".

... an exception thrown in value_ind can propagate too far and leave an
half-built variable object, leading to a wrong state. This patch adds a
TRY_CATCH to catch it and makes value_rtti_indirect_type return NULL in
that case, meaning that the type of the pointed object could not be
found.

A test for the fix is also added.

New in v2:

  * Added test.
  * Restructured "catch" code.
  * Added details about the bug in commit log.

gdb/Changelog:

* valops.c (value_rtti_indirect_type): Catch exception thrown by
value_ind.

gdb/testsuite/ChangeLog

* gdb.mi/mi-var-list-children-invalid-grandchild.c: New file.
* gdb.mi/mi-var-list-children-invalid-grandchild.exp: New file.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=17416

9 years agoFix build errors when compiling nlmconv.c on a 32-bit host.
Nick Clifton [Fri, 23 Jan 2015 16:39:53 +0000 (16:39 +0000)]
Fix build errors when compiling nlmconv.c on a 32-bit host.

* nlmconv.c (powerpc_mangle_relocs): Fix build errors introduced
by recent delta, when compiling on for a 32-bit host.

9 years agoUse GCC5/DWARF5 DW_AT_noreturn to mark functions that don't return normally.
Mark Wielaard [Tue, 9 Dec 2014 10:45:41 +0000 (11:45 +0100)]
Use GCC5/DWARF5 DW_AT_noreturn to mark functions that don't return normally.

Add a flag field is_noreturn to struct func_type. Make calling_convention
a small bit field to not increase the size of the struct. Set is_noreturn
if the new GCC5/DWARF5 DW_AT_noreturn is set on a DW_TAG_subprogram.
Use this information to warn the user before doing a finish or return from
a function that does not return normally to its caller.

(gdb) finish
warning: Function endless does not return normally.
Try to finish anyway? (y or n)

(gdb) return
warning: Function does not return normally to caller.
Make endless return now? (y or n)

gdb/ChangeLog

* dwarf2read.c (read_subroutine_type): Set TYPE_NO_RETURN from
DW_AT_noreturn.
* gdbtypes.h (struct func_type): Add is_noreturn field flag. Make
calling_convention an 8 bit bit field.
(TYPE_NO_RETURN): New macro.
* infcmd.c (finish_command): Query if function does not return
normally.
* stack.c (return_command): Likewise.

gdb/testsuite/ChangeLog

* gdb.base/noreturn-return.c: New file.
* gdb.base/noreturn-return.exp: New file.
* gdb.base/noreturn-finish.c: New file.
* gdb.base/noreturn-finish.exp: New file.

include/ChangeLog

* dwarf2.def (DW_AT_noreturn): New DWARF5 attribute.

The dwarf2.h addition and the code to emit the new attribute is already in
the gcc tree.

9 years agoLinux: make target_is_async_p return false when async is off
Pedro Alves [Fri, 23 Jan 2015 11:12:39 +0000 (11:12 +0000)]
Linux: make target_is_async_p return false when async is off

linux_nat_is_async_p currently always returns true, even when the
target is _not_ async.  That confuses
gdb_readline_wrapper/gdb_readline_wrapper_cleanup, which
force-disables target-async while the secondary prompt is active.  As
a result, when gdb_readline_wrapper returns, the target is left async,
even through it was sync to begin with.

That can result in weird bugs, like the one the test added by this
commit exposes.

Ref: https://sourceware.org/ml/gdb-patches/2015-01/msg00592.html

gdb/ChangeLog:
2015-01-23  Pedro Alves  <palves@redhat.com>

* linux-nat.c (linux_is_async_p): New macro.
(linux_nat_is_async_p):
(linux_nat_terminal_inferior): Check whether the target can async
instead of whether it is already async.
(linux_nat_terminal_ours): Don't check whether the target is
async.
(linux_async_pipe): Use linux_is_async_p.

gdb/testsuite/ChangeLog:
2015-01-23  Pedro Alves  <palves@redhat.com>

* gdb.threads/continue-pending-after-query.c: New file.
* gdb.threads/continue-pending-after-query.exp: New file.

9 years agoFix filename in one of the recent gdb/ChangeLog entries (remove "gdb/").
Joel Brobecker [Fri, 23 Jan 2015 07:13:49 +0000 (08:13 +0100)]
Fix filename in one of the recent gdb/ChangeLog entries (remove "gdb/").

9 years agoAutomatic date update in version.in
GDB Administrator [Fri, 23 Jan 2015 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoHandle R_M32C_24 specially
DJ Delorie [Thu, 22 Jan 2015 22:30:58 +0000 (17:30 -0500)]
Handle R_M32C_24 specially

2015-01-22  DJ Delorie  <dj@redhat.com>

* elf32-m32c.c (m32c_apply_reloc_24): New.
(m32c_elf_howto_table): Use it for R_M32C_24.
(m32c_elf_relocate_section): Handle R_M32C_24 specially.

9 years agoIntroduce gdb_interact in testsuite
Anders Granlund [Thu, 22 Jan 2015 19:33:04 +0000 (14:33 -0500)]
Introduce gdb_interact in testsuite

gdb_interact is a small utility that we have found quite useful to debug
test cases.

Putting gdb_interact in a test suspends it and allows to interact with
gdb to inspect whatever you want. You can then type ">>>" to resume the
test execution. Of course, this is only for gdb devs. It wouldn't make
sense to leave a gdb_interact permanently in a test case.

When starting the interaction with the user, the script prints this
banner:

+------------------------------------------+
| Script interrupted, you can now interact |
| with by gdb. Type >>> to continue.       |
+------------------------------------------+

Notes:
* When gdb is launched, the gdb_spawn_id variable (lib/gdb.exp) is
  assigned -1. Given the name, I would expect it to contain the gdb
  expect spawn id, which is needed for interact. I changed all places
  that set gdb_spawn_id to -1 to set it to the actual gdb spawn id
  instead.

* When entering the "interact" mode, the last (gdb) prompt is already
  eaten by expect, so it doesn't show up on the terminal. Subsequent
  prompts do appear though. We tried to print "(gdb)" just before the
  interact to replace it. However, it could be misleading if you are
  debugging an MI test case, it makes you think that you are typing in a
  CLI prompt, when in reality it's MI. In the end I decided that since
  the feature is for developers who know what they're doing and that one
  is normally consciously using gdb_interact, the script doesn't need
  to babysit the user.

* There are probably some quirks depending on where in the script
  gdb_interact appears (e.g. it could interfere with following
  commands and make them fail), but it works for most cases. Quirks can
  always be fixed later.

The idea and original implementation was contributed by Anders
Granlund, a colleague of mine. Thanks to him.

gdb/testsuite/ChangeLog:

* gdb.base/statistics.exp: Assign spawn id to gdb_spawn_id.
* gdb.base/valgrind-db-attach.exp: Same.
* gdb.base/valgrind-infcall.exp: Same.
* lib/mi-support.exp (default_mi_gdb_start): Same.
* lib/prompt.exp (default_prompt_gdb_start): Same.
* lib/gdb.exp (default_gdb_spawn): Same.
(gdb_interact): New.

9 years agoSort threads for thread apply all
Jan Kratochvil [Thu, 22 Jan 2015 20:04:53 +0000 (21:04 +0100)]
Sort threads for thread apply all

downstream Fedora request:
Please make it easier to find the backtrace of the crashing thread
https://bugzilla.redhat.com/show_bug.cgi?id=1024504

Currently after loading a core file GDB prints:

Core was generated by `./threadcrash1'.
Program terminated with signal SIGSEGV, Segmentation fault.
8       *(volatile int *)0=0;
(gdb) _

there is nowhere seen which of the threads had crashed.  In reality GDB always
numbers that thread as #1 and it is the current thread that time.  But after
dumping all the info into a file for later analysis it is no longer obvious.
'thread apply all bt' even puts the thread #1 to the _end_ of the output!!!

I find maybe as good enough and with no risk of UI change flamewar to just
sort the threads by their number.  Currently they are printed as they happen
in the internal GDB list which has no advantage.  Printing thread #1 as the
first one with assumed 'thread apply all bt' (after the core file is loaded)
should make the complaint resolved I guess.

On Thu, 15 Jan 2015 20:29:07 +0100, Doug Evans wrote:
No objection to sorting the list, but if thread #1 is the important one,
then a concern could be it'll have scrolled off the screen (such a
concern has been voiced in another thread in another context),
and if not lost (say it's in an emacs buffer) one would still have
to scroll back to see it.
So one *could* still want #1 to be last.
Do we want an option to choose the sort direction?

gdb/ChangeLog
2015-01-22  Jan Kratochvil  <jan.kratochvil@redhat.com>

* NEWS (Changes since GDB 7.9): Add 'thread apply all' option
'-ascending'.
* thread.c (tp_array_compar_ascending, tp_array_compar): New.
(thread_apply_all_command): Parse CMD for tp_array_compar_ascending.
Sort tp_array using tp_array_compar.
(_initialize_thread): Extend thread_apply_all_command help.

gdb/doc/ChangeLog
2015-01-22  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.texinfo (Threads): Describe -ascending for thread apply all.

9 years agoPrint current thread after loading a core file
Jan Kratochvil [Thu, 22 Jan 2015 20:02:24 +0000 (21:02 +0100)]
Print current thread after loading a core file

downstream Fedora request:
Please make it easier to find the backtrace of the crashing thread
https://bugzilla.redhat.com/show_bug.cgi?id=1024504

Currently after loading a core file GDB prints:

Core was generated by `./threadcrash1'.
Program terminated with signal SIGSEGV, Segmentation fault.
8       *(volatile int *)0=0;
(gdb) _

there is nowhere seen which of the threads had crashed.  In reality GDB always
numbers that thread as #1 and it is the current thread that time.  But after
dumping all the info into a file for later analysis it is no longer obvious.
'thread apply all bt' even puts the thread #1 to the _end_ of the output!!!

Should GDB always print after loading a core file what "thread" command would
print?
[Current thread is 1 (Thread 0x7fcbe28fe700 (LWP 15453))]

BTW I think it will print the thread even when loading single/non-threaded
core file when other inferior(s) exist.  But that currently crashes
[Bug threads/12074] multi-inferior internal error
https://sourceware.org/bugzilla/show_bug.cgi?id=12074
plus I think that would be a correct behavior anyway.

gdb/ChangeLog
2015-01-22  Jan Kratochvil  <jan.kratochvil@redhat.com>

* corelow.c (core_open): Call also thread_command.
* gdbthread.h (thread_command): New prototype moved from ...
* thread.c (thread_command): ... here.
(thread_command): Make it global.

9 years agoAnother part of fixing "make TAGS".
Eli Zaretskii [Thu, 22 Jan 2015 19:07:31 +0000 (21:07 +0200)]
Another part of fixing "make TAGS".

libdecnumber/
2015-01-22  Eli Zaretskii  <eliz@gnu.org>

* Makefile.in (TAGS): New target, to avoid failures in "make TAGS".

9 years agomingw32: fix windows-termcap/curses check
Pedro Alves [Thu, 22 Jan 2015 18:30:01 +0000 (18:30 +0000)]
mingw32: fix windows-termcap/curses check

When GDB is configured with "--without-tui --with-curses" or "--with-tui",
$prefer_curses is set to yes.  But, that still doesn't mean that curses
will be used.  configure will still search for the curses library, and
continue building without it.  That's done here:

 curses_found=no
 if test x"$prefer_curses" = xyes; then
 ...
   AC_SEARCH_LIBS(waddstr, [ncurses cursesX curses])

   if test "$ac_cv_search_waddstr" != no; then
     curses_found=yes
   fi
 fi

So if waddstr is not found, meaning curses is not really
available, even though it'd be preferred, $prefer_curses is
'yes', but $curses_found is 'no'.

So the right fix to tell whether we're linking with curses is
$curses_found=yes.

gdb/ChangeLog:
2015-01-22  Pedro Alves  <palves@redhat.com>

* configure.ac [*mingw32*]: Check $curses_found instead of
$prefer_curses.
* configure: Regenerate.
* windows-termcap.c: Remove HAVE_CURSES_H, HAVE_NCURSES_H and
HAVE_NCURSES_NCURSES_H checks.

9 years agoFix MinGW TUI build
Eli Zaretskii [Thu, 22 Jan 2015 18:23:12 +0000 (20:23 +0200)]
Fix MinGW TUI build

gdb/
2015-01-22  Eli Zaretskii  <eliz@gnu.org>

* gdb/tui/tui.c (tui_enable) [__MINGW32__]: If the call to 'newterm'
fails with the 1st arg NULL, try again with "unknown".  Don't test
the "cup" capability: it isn't supported by the Windows port of
ncurses, but the Windows console driver is still capable of
supporting TUI.

9 years agocompile: Fix function pointers
Jan Kratochvil [Thu, 22 Jan 2015 18:18:16 +0000 (19:18 +0100)]
compile: Fix function pointers

TBH while I always comment reasons for each of the compilation options in
reality I tried them all and chose that combination that needs the most simple
compile/compile-object-load.c (ld.so emulation) implementation.

gdb/ChangeLog
2015-01-22  Jan Kratochvil  <jan.kratochvil@redhat.com>

* compile/compile.c (_initialize_compile): Use -fPIE for compile_args.

gdb/testsuite/ChangeLog
2015-01-22  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.compile/compile.exp (pointer to jit function): New test.

9 years agoPartial fix for "make TAGS".
Eli Zaretskii [Thu, 22 Jan 2015 18:05:59 +0000 (20:05 +0200)]
Partial fix for "make TAGS".

gdb/
2015-01-22  Eli Zaretskii  <eliz@gnu.org>

* Makefile.in (HFILES_NO_SRCDIR): Remove ada-varobj.h.
(ALLDEPFILES): Remove irix5-nat.c.  These two are part of the
reason that "make TAGS" is broken.

9 years agogdb/hppa-tdep.c: Fix logical working flow issues and check additional store instructions.
Chen Gang [Thu, 22 Jan 2015 12:47:10 +0000 (20:47 +0800)]
gdb/hppa-tdep.c: Fix logical working flow issues and check additional store instructions.

Original working flow has several issues:

 - typo issue: "(inst >> 26) == 0x1f && ..." for checking 'stw(m)'.

 - "(inst >> 6) == 0xa" needs to be "((inst >> 6) & 0xf) == 0xa".

And also need check additional store instructions:

 - For absolute memory: 'stby', 'stdby'.

 - For unaligned: 'stwa', 'stda'.

The original code also can be improved:

 - Remove redundant double check "(inst >> 26) == 0x1b" for 'stwm'.

 - Use 2 'switch' statements instead of all 'if' statements.

* hppa-tdep.c (inst_saves_gr): Fix logical working flow issues
and check additional store instructions.

9 years agoFixes memory access violations triggered by running dlltool on fuzzed binaries.
Nick Clifton [Thu, 22 Jan 2015 12:06:04 +0000 (12:06 +0000)]
Fixes memory access violations triggered by running dlltool on fuzzed binaries.

PR binutils/17512
* coffcode.h (handle_COMDAT): When searching for the section
symbol, make sure that there is space left in the symbol table.
* vms-alpha.c (_bfd_vms_slurp_ehdr): Add range checks.

9 years ago[GOLD] Correct powerpc64 ifunc plt entry test
Alan Modra [Thu, 22 Jan 2015 02:09:50 +0000 (12:39 +1030)]
[GOLD] Correct powerpc64 ifunc plt entry test

Found when attempting to build an ELFv2 Linux kernel.  We don't
generally need a plt entry for ELFv2 got relocs, only on ifunc, just
like ppc32.

* powerpc.cc (Target_powerpc::Scan::local <got relocs>): Correct
condition for need of ifunc plt entry.
(Target_powerpc::Scan::global <got relocs>): Likewise.

9 years agoAutomatic date update in version.in
GDB Administrator [Thu, 22 Jan 2015 00:00:13 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoFix memory access violations triggered by running strip on fuzzed binaries.
Nick Clifton [Wed, 21 Jan 2015 17:37:23 +0000 (17:37 +0000)]
Fix memory access violations triggered by running strip on fuzzed binaries.

PR binutils/17512
* coffcode.h (coff_set_arch_mach_hook): Check return value from
bfd_malloc.
(coff_slurp_line_table): Return FALSE if the line number
information was corrupt.
(coff_slurp_symbol_table): Return FALSE if the symbol information
was corrupt.
* mach-o.c (bfd_mach_o_bfd_copy_private_header_data): Always
initialise the fields of the dyld_info structure.
(bfd_mach_o_build_exec_seg_command): Replace assertion with an
error message and a return value.
(bfd_mach_o_layout_commands): Change the function to boolean.
Return FALSE if the function fails.
(bfd_mach_o_build_commands): Fail if bfd_mach_o_layout_commands
fails.
(bfd_mach_o_read_command): Fail if an unrecognised command is
encountered.
* peXXigen.c (_bfd_XXi_swap_aouthdr_in): Set bfd_error if the
read fails.
(slurp_symtab): Check the return from bfd_malloc.
(_bfd_XX_bfd_copy_private_bfd_data_common): Fail if the copy
encountered an error.
(_bfd_XXi_final_link_postscript): Fail if a section could not be
copied.
* peicode.h (pe_bfd_object_p): Fail if the header could not be
swapped in.
* tekhex.c (first_phase): Fail if the section is too big.
* versados.c (struct esdid): Add content_size field.
(process_otr): Use and check the new field.
(versados_get_section_contents): Check that the section exists and
that the requested data is available.

PR binutils/17512
* addr2line.c (main): Call bfd_set_error_program_name.
* ar.c (main): Likewise.
* coffdump.c (main): Likewise.
* cxxfilt.c (main): Likewise.
* dlltool.c (main): Likewise.
* nlmconv.c (main): Likewise.
* nm.c (main): Likewise.
* objdump.c (main): Likewise.
* size.c (main): Likewise.
* srconv.c (main): Likewise.
* strings.c (main): Likewise.
* sysdump.c (main): Likewise.
* windmc.c (main): Likewise.
* windres.c (main): Likewise.
* objcopy.c (main): Likewise.
(copy_relocations_in_section): Check for relocs without associated
symbol pointers.

9 years agoAdd myself as write-after-approval GDB maintainer.
Wei-cheng Wang [Tue, 20 Jan 2015 16:07:50 +0000 (00:07 +0800)]
Add myself as write-after-approval GDB maintainer.

gdb/ChangeLog:

* MAINTAINERS (Write After Approval): Add "Wei-cheng Wang".

9 years agoAdd missing comments in rs6000-tdep.c, ppc64-tdep.c and ppc-linux-tdep.c.
Wei-cheng Wang [Mon, 19 Jan 2015 15:34:07 +0000 (23:34 +0800)]
Add missing comments in rs6000-tdep.c, ppc64-tdep.c and ppc-linux-tdep.c.

gdb/ChangeLog:

* ppc-linux-tdep.c (ppc_skip_trampoline_code,
ppc_canonicalize_syscall, ppc_linux_syscall_record,
ppc_linux_record_signal, ppc_init_linux_record_tdep): Add comments.
* ppc64-tdep.c (ppc64_skip_trampoline_code): Likewise.
* rs6000-tdep.c (rs6000_epilogue_frame_cache,
rs6000_epilogue_frame_this_id, rs6000_epilogue_frame_prev_register,
rs6000_epilogue_frame_sniffer, ppc_record_vsr, ppc_process_record_op4,
ppc_process_record_op19, ppc_process_record_op31,
ppc_process_record_op59, ppc_process_record_op60,
ppc_process_record_op63): Likewise.

9 years agoAdd self to ARM Maintainers
Ramana Radhakrishnan [Wed, 21 Jan 2015 11:15:58 +0000 (11:15 +0000)]
Add self to ARM Maintainers

9 years agoThis patch fixes some illegal memory accesses triggered by running coffdump on fuzzed...
Nick Clifton [Wed, 21 Jan 2015 10:33:19 +0000 (10:33 +0000)]
This patch fixes some illegal memory accesses triggered by running coffdump on fuzzed binaries.

PR binutils/17512
* coffgrok.c (do_type): Check that computed ref exists.
(doit): Add range checks when computing section for scope.