deliverable/binutils-gdb.git
5 years agoAdd missing includes to gdb_assert.h and gdb_string_view.h
Christian Biesinger [Tue, 1 Oct 2019 18:36:07 +0000 (13:36 -0500)] 
Add missing includes to gdb_assert.h and gdb_string_view.h

gdb::string_view uses gdb_assert, so it should include that header.
And gdb_assert uses internal_error, so it should include errors.h.

gdb/ChangeLog:

2019-10-02  Christian Biesinger  <cbiesinger@google.com>

* gdbsupport/gdb_assert.h: Include errors.h.
* gdbsupport/gdb_string_view.h: Include gdb_assert.h.

5 years agogdb/testsuite: Fix py-format-string.exp on big-endian platforms
Andreas Arnez [Wed, 2 Oct 2019 18:01:44 +0000 (20:01 +0200)] 
gdb/testsuite: Fix py-format-string.exp on big-endian platforms

GDB's py-format-string test case depends on endianness.  In particular it
relies on the first byte of the machine representation of 42 (as an int)
to be 42 as well.  While this is indeed the case for little-endian
machines, big-endian machines store a zero in the first byte instead.  The
wrong assumption leads to lots of FAILs on such architectures.

Fix this by filling the affected union with bytes of the same value, such
that endianness does not matter.  Use the value 42, to keep the character
in the first byte unchanged.

gdb/testsuite/ChangeLog:

* gdb.python/py-format-string.c (string.h): New include.
(main): Fill a_struct_with_union.the_union.an_int with bytes of
the same value, for endianness-independence.
* gdb.python/py-format-string.exp (default_regexp_dict)
(test_pretty_structs, test_format): Adjust expected output to the
changed initialization.

5 years agoAdd $_ada_exception convenience variable
Tom Tromey [Fri, 31 May 2019 20:50:23 +0000 (14:50 -0600)] 
Add $_ada_exception convenience variable

This adds the $_ada_exception convenience variable.  It is set by the
Ada exception catchpoints, and holds the address of the exception
currently being thrown.  This is useful because it allows more
fine-grained filtering of exceptions than is possible using the
existing "catch" syntax.

This also simplifies Ada catchpoints somewhat; because the catchpoint
must now carry the "kind", it's possible to remove many helper
functions.

gdb/ChangeLog
2019-10-02  Tom Tromey  <tromey@adacore.com>

* NEWS: Add $_ada_exception entry.
* ada-lang.c (struct ada_catchpoint): Add constructor.
<m_kind>: New member.
(allocate_location_exception, re_set_exception): Remove
"ex" parameter.
(should_stop_exception): Compute $_ada_exception.
(check_status_exception, print_it_exception)
(print_one_exception, print_mention_exception): Remove
"ex" parameter.
(allocate_location_catch_exception, re_set_catch_exception)
(check_status_exception, print_it_catch_exception)
(print_one_catch_exception, print_mention_catch_exception)
(print_recreate_catch_exception)
(allocate_location_catch_exception_unhandled)
(re_set_catch_exception_unhandled)
(check_status_exception, print_it_catch_exception_unhandled)
(print_one_catch_exception_unhandled)
(print_mention_catch_exception_unhandled)
(print_recreate_catch_exception_unhandled)
(allocate_location_catch_assert, re_set_catch_assert)
(check_status_assert, print_it_catch_assert)
(print_one_catch_assert, print_mention_catch_assert)
(print_recreate_catch_assert)
(allocate_location_catch_handlers, re_set_catch_handlers)
(check_status_handlers, print_it_catch_handlers)
(print_one_catch_handlers, print_mention_catch_handlers)
(print_recreate_catch_handlers): Remove.
(create_ada_exception_catchpoint): Update.
(initialize_ada_catchpoint_ops): Update.

gdb/doc/ChangeLog
2019-10-02  Tom Tromey  <tromey@adacore.com>

* gdb.texinfo (Set Catchpoints, Convenience Vars): Document
$_ada_exception.

gdb/testsuite/ChangeLog
2019-10-02  Tom Tromey  <tromey@adacore.com>

* gdb.ada/catch_ex_std.exp: Add $_ada_exception test.

5 years agoBack out earlier Ada exception change
Tom Tromey [Fri, 14 Jun 2019 13:45:01 +0000 (07:45 -0600)] 
Back out earlier Ada exception change

commit 2ff0a9473 (Fix "catch exception" with dynamic linking) changed
how ada-lang.c creates expressions to determine if an exception
catchpoint should stop.

That patch is no longer needed now that copy relocations are handled
more directly.

gdb/ChangeLog
2019-10-02  Tom Tromey  <tromey@adacore.com>

* ada-lang.c (ada_lookup_simple_minsyms): Remove.
(create_excep_cond_exprs): Simplify exception string computation.
(ada_exception_catchpoint_cond_string): Likewise.

5 years agoMake print-file-var.exp test attribute visibility hidden, dlopen, and main symbol
Pedro Alves [Sat, 20 Jul 2019 00:20:35 +0000 (01:20 +0100)] 
Make print-file-var.exp test attribute visibility hidden, dlopen, and main symbol

Make gdb.base/print-file-var.exp test all combinations of:

  - attribute hidden in the this_version_id symbols or not
  - dlopen or not
  - this_version_id symbol in main file or not
  - C++

gdb/testsuite/ChangeLog
2019-10-02  Pedro Alves  <palves@redhat.com>
    Andrew Burgess  <andrew.burgess@embecosm.com>

* gdb.base/print-file-var-lib1.c: Include <stdio.h> and
"print-file-var.h".
(this_version_id) Use ATTRIBUTE_VISIBILITY.
(get_version_1): Print this_version_id and its address.
Add extern "C" wrappers around interface functions.
* gdb.base/print-file-var-lib2.c: Include <stdio.h> and
"print-file-var.h".
(this_version_id) Use ATTRIBUTE_VISIBILITY.
(get_version_2): Print this_version_id and its address.
Add extern "C" wrappers around interface functions.
* gdb.base/print-file-var-main.c: Include <dlfcn.h>, <assert.h>,
<stddef.h> and "print-file-var.h".
Add extern "C" wrappers around interface functions.
[VERSION_ID_MAIN] (this_version_id): Define.
(main): Define v0.  Use dlopen if SHLIB_NAME is defined.
* gdb.base/print-file-var.h: Add some #defines to simplify setting
up extern "C" blocks.
* gdb.base/print-file-var.exp (test): New, factored out from top
level.
(top level): Test all combinations of attribute hidden or not,
dlopen or not, and this_version_id symbol in main file or not.
Compile tests as both C++ and C, make test names unique.

5 years agoHandle copy relocations
Tom Tromey [Tue, 25 Jun 2019 18:50:45 +0000 (12:50 -0600)] 
Handle copy relocations

In ELF, if a data symbol is defined in a shared library and used by
the main program, it will be subject to a "copy relocation".  In this
scenario, the main program has a copy of the symbol in question, and a
relocation that tells ld.so to copy the data from the shared library.
Then the symbol in the main program is used to satisfy all references.

This patch changes gdb to handle this scenario.  Data symbols coming
from ELF shared libraries get a special flag that indicates that the
symbol's address may be subject to copy relocation.

I looked briefly into handling copy relocations by looking at the
actual relocations in the main program, but this seemed difficult to
do with BFD.

Note that no caching is done here.  Perhaps this could be changed if
need be; I wanted to avoid possible problems with either objfile
lifetimes and changes, or conflicts with the long-term (vapor-ware)
objfile splitting project.

gdb/ChangeLog
2019-10-02  Tom Tromey  <tromey@adacore.com>

* symmisc.c (dump_msymbols): Don't use MSYMBOL_VALUE_ADDRESS.
* ada-lang.c (lesseq_defined_than): Handle
LOC_STATIC.
* dwarf2read.c (dwarf2_per_objfile): Add can_copy
parameter.
(dwarf2_has_info): Likewise.
(new_symbol): Set maybe_copied on symbol when
appropriate.
* dwarf2read.h (dwarf2_per_objfile): Add can_copy
parameter.
<can_copy>: New member.
* elfread.c (record_minimal_symbol): Set maybe_copied
on symbol when appropriate.
(elf_symfile_read): Update call to dwarf2_has_info.
* minsyms.c (lookup_minimal_symbol_linkage): New
function.
* minsyms.h (lookup_minimal_symbol_linkage): Declare.
* symtab.c (get_symbol_address, get_msymbol_address):
New functions.
* symtab.h (get_symbol_address, get_msymbol_address):
Declare.
(SYMBOL_VALUE_ADDRESS, MSYMBOL_VALUE_ADDRESS): Handle
maybe_copied.
(struct symbol, struct minimal_symbol) <maybe_copied>:
New member.

5 years agoMake current_source_* per-program-space
Tom Tromey [Thu, 1 Aug 2019 15:34:40 +0000 (09:34 -0600)] 
Make current_source_* per-program-space

This changes current_source_symtab and current_source_line to be
per-program-space.  This ensures that switching inferiors will
preserve the current "list" location for that inferior, and also
ensures that the default expression evaluation context always comes
with the current inferior.

No test case, because the latter problem crops up with an existing
gdb.multi test case once this entire series has been applied.

gdb/ChangeLog
2019-10-02  Tom Tromey  <tromey@adacore.com>

* source.c (struct current_source_location): New.
(current_source_key): New global.
(current_source_symtab, current_source_line)
(current_source_pspace): Remove.
(get_source_location): New function.
(get_current_source_symtab_and_line)
(set_default_source_symtab_and_line)
(set_current_source_symtab_and_line)
(clear_current_source_symtab_and_line, select_source_symtab)
(info_source_command, print_source_lines_base)
(info_line_command, search_command_helper, _initialize_source):
Update.

5 years agoDon't call decode_line_with_current_source from select_source_symtab
Tom Tromey [Thu, 1 Aug 2019 15:17:14 +0000 (09:17 -0600)] 
Don't call decode_line_with_current_source from select_source_symtab

select_source_symtab currently calls decode_line_with_current_source.
However, this function iterates over all program spaces, and so it is
possible that it will return a "main" from some other program space.

This patch changes select_source_symtab to simply use the symbol it
already found in the current program space.

gdb/ChangeLog
2019-10-02  Tom Tromey  <tromey@adacore.com>

* source.c (select_source_symtab): Don't call
decode_line_with_current_source.

5 years agoSearch global block from basic_lookup_symbol_nonlocal
Andrew Burgess [Wed, 31 Jul 2019 19:05:37 +0000 (13:05 -0600)] 
Search global block from basic_lookup_symbol_nonlocal

This changes lookup_global_symbol to look in the global block
of the passed-in block.  If no block was passed in, it reverts to the
previous behavior.

This change is needed to ensure that 'FILENAME'::NAME lookups work
properly.  As debugging Pedro's test case showed, this was not working
properly in the case where multiple identical names could be found
(the one situation where this feature is truly needed :-).

This also removes some old comments from basic_lookup_symbol_nonlocal
that no longer apply.

Note that the new test cases for this change will appear in a later
patch.  They are in gdb.base/print-file-var.exp.

gdb/ChangeLog
2019-10-02  Andrew Burgess  <andrew.burgess@embecosm.com>

* symtab.c (lookup_global_symbol): Search global block.

5 years agoChange SYMBOL_VALUE_ADDRESS to be an rvalue
Tom Tromey [Tue, 25 Jun 2019 17:53:11 +0000 (11:53 -0600)] 
Change SYMBOL_VALUE_ADDRESS to be an rvalue

This changes SYMBOL_VALUE_ADDRESS to be an rvalue.  The symbol readers
generally assign using this, so this also introduces
SET_SYMBOL_VALUE_ADDRESS and updates the readers.  Making this change
is useful in a subsequent patch, which redefined SYMBOL_VALUE_ADDRESS.

gdb/ChangeLog
2019-10-02  Tom Tromey  <tromey@adacore.com>

* coffread.c (process_coff_symbol): Update.
* dwarf2read.c (var_decode_location, new_symbol): Update.
* mdebugread.c (parse_symbol): Update.
* objfiles.c (relocate_one_symbol): Update.
* stabsread.c (define_symbol, fix_common_block)
(scan_file_globals): Update.
* symtab.h (SYMBOL_VALUE_ADDRESS): Expand to an rvalue.
(SET_SYMBOL_VALUE_ADDRESS): New macro.
* xcoffread.c (process_xcoff_symbol): Update.

5 years agoUpdate my email address in gdb/MAINTAINERS
Andreas Arnez [Wed, 2 Oct 2019 14:01:44 +0000 (16:01 +0200)] 
Update my email address in gdb/MAINTAINERS

My email address at IBM has changed from arnez@linux.vnet.ibm.com to
arnez@linux.ibm.com.  Reflect that in the MAINTAINERS file.

gdb/ChangeLog:

* MAINTAINERS: Update my email address.

5 years ago-Bsymbolic is not for PIEs
Alan Modra [Mon, 23 Sep 2019 13:31:37 +0000 (23:01 +0930)] 
-Bsymbolic is not for PIEs

Despite PR19615, it doesn't make sense to use -Bsymbolic with PIEs.
Dynamic symbols in an executable won't be overridden anyway.

* ld.texi (-Bsymbolic, -Bsymbolic-functions): Don't mention PIEs.
* ld.h (symbolic_enum, dynamic_list_enum),
(args_type <symbolic, dynamic_list>): Move to..
* lexsup.c (parse_args): ..here, using auto vars opt_symbolic
and opt_dynamic_list rather than command_line fields.  Only
act on -Bsymbolic and -Bsymbolic-functions for shared library
output.  Free dynamic_list.

5 years agogdb: Remove a use of VEC from dwarf2read.{c,h}
Andrew Burgess [Wed, 25 Sep 2019 15:10:50 +0000 (16:10 +0100)] 
gdb: Remove a use of VEC from dwarf2read.{c,h}

Removes a use of VEC from dwarf2read.{c,h} and replaces it with
std::vector.  As far as possible this is a like for like replacement
with minimal refactoring.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* dwarf2read.c (struct type_unit_group) <tus>: Convert to
std::vector.
(build_type_psymtabs_reader): Update for std::vector.
(build_type_psymtab_dependencies): Likewise.
* dwarf2read.h: Remove use of DEF_VEC_P.
(typedef sig_type_ptr): Delete.

5 years agogdb: Change a VEC to std::vector in btrace.{c,h}
Andrew Burgess [Thu, 19 Sep 2019 17:17:59 +0000 (13:17 -0400)] 
gdb: Change a VEC to std::vector in btrace.{c,h}

Replace a VEC with a std::vector in btrace.h, and update btrace.c to
match.  It is worth noting that this code appears to be currently
untested by the GDB testsuite.  I've tried to do a like for like
replacement when moving to std::vector, with minimal refactoring to
try and avoid introducing any bugs.

As the new vector is inside a union I've currently used a pointer to
vector, which makes the code slightly uglier than it might otherwise
be, but again, due to lack of testing I'm reluctant to start
refactoring the code in a big way.

gdb/ChangeLog:

* btrace.c (btrace_maint_clear): Update to handle change from VEC
to std::vector.
(btrace_maint_decode_pt): Likewise, and move allocation of the
vector outside of the loop.
(btrace_maint_update_packets): Update to handle change from VEC to
std::vector.
(btrace_maint_print_packets): Likewise.
(maint_info_btrace_cmd): Likewise.
* btrace.h: Remove use of DEF_VEC_O.
(typedef btrace_pt_packet_s): Delete.
(struct btrace_maint_info) <packets>: Change fromm VEC to
std::vector.
* gdbsupport/btrace-common.h: Remove 'vec.h' include.

5 years agogdb: Remove a VEC from gdbsupport/btrace-common.h
Andrew Burgess [Mon, 16 Sep 2019 13:12:27 +0000 (09:12 -0400)] 
gdb: Remove a VEC from gdbsupport/btrace-common.h

Converts a VEC into a std::vector in gdbsupport/btrace-common.h.  This
commit just performs a mechanical conversion and doesn't do any
refactoring.  One consequence of this is that the std::vector must
actually be a pointer to std::vector as it is placed within a union.
It might be possible in future to refactor to a class hierarchy and
remove the need for a union, but I'd rather have that be a separate
change to make it easier to see the evolution of the code.

gdb/ChangeLog:

* btrace.c (btrace_compute_ftrace_bts): Update for std::vector,
make accesses into the vector constant references.
(btrace_add_pc): Update for std::vector.
(btrace_stitch_bts): Likewise.
(parse_xml_btrace_block): Likewise.
(btrace_maint_update_packets): Likewise.
(btrace_maint_print_packets): Likewise.
(maint_info_btrace_cmd): Likewise.
* gdbsupport/btrace-common.c (btrace_data::fini): Update for
std::vector.
(btrace_data::empty): Likewise.
(btrace_data_append): Likewise.
* gdbsupport/btrace-common.h: Remove use of DEF_VEC_O.
(typedef btrace_block_s): Delete.
(struct btrace_block): Add constructor.
(struct btrace_data_bts) <blocks>: Change to std::vector.
* nat/linux-btrace.c (perf_event_read_bts): Update for
std::vector.
(linux_read_bts): Likewise.

gdb/gdbserver/ChangeLog:

* linux-low.c (linux_low_read_btrace): Update for change to
std::vector.

5 years agoChange objcopy's --set-section-alignment option to take a byte alignment value rather...
Nick Clifton [Wed, 2 Oct 2019 10:55:02 +0000 (11:55 +0100)] 
Change objcopy's --set-section-alignment option to take a byte alignment value rather than a power of two alignment value.

PR 24942
* objcopy.c (copy_usage): Update description of
--set-section-alignment.
(copy_main): Interpret numeric argument of --set-section-alignment
as a byte alignment, not a power of two alignment.
* doc/binutils.texi: Update description of
--set-section-alignment.
* testsuite/binutils-all/set-section-alignment.d: New test.
* testsuite/binutils-all/objcopy.exp: Run the new test.

5 years agoAutomatic date update in version.in
GDB Administrator [Wed, 2 Oct 2019 00:00:22 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 years agoUse styled_string for "show logging filename"
Tom Tromey [Thu, 19 Sep 2019 13:31:28 +0000 (07:31 -0600)] 
Use styled_string for "show logging filename"

This changes "show logging filename" to style its output.

gdb/ChangeLog
2019-10-01  Tom Tromey  <tom@tromey.com>

* cli/cli-logging.c (show_logging_filename): Use styled_string.

gdb/testsuite/ChangeLog
2019-10-01  Tom Tromey  <tom@tromey.com>

* gdb.base/style.exp: Test "show logging filename".

5 years agoUse styled_string in more places
Tom Tromey [Wed, 18 Sep 2019 01:11:55 +0000 (19:11 -0600)] 
Use styled_string in more places

This adds more uses of styled_string, changing gdb to style some
output that was previously left unstyled.

gdb/ChangeLog
2019-10-01  Tom Tromey  <tom@tromey.com>

* stack.c (print_frame, info_frame_command_core): Use
styled_string.
* linux-thread-db.c (try_thread_db_load_1)
(try_thread_db_load_from_pdir_1): Use styled_string.
* auto-load.c (file_is_auto_load_safe, execute_script_contents)
(auto_load_section_scripts, info_auto_load_local_gdbinit)
(maybe_print_unsupported_script_warning)
(maybe_print_script_not_found_warning): Use styled_string.
* ada-lang.c (user_select_syms): Use styled_string.

5 years agoIntroduce metadata style
Tom Tromey [Wed, 3 Apr 2019 02:00:18 +0000 (20:00 -0600)] 
Introduce metadata style

This introduces a new "metadata" style and changes many places in gdb
to use it.  The idea here is to let the user distinguish gdb output
from output that (conceptually at least) comes directly from the
inferior.  The newly-styled category includes text that gdb
traditionally surrounds in "<...>", like "<unavailable>".

I only added a single test for this.  In many cases this output is
difficult to test.  Also, while developing this errors in the
implementation of the new printf formats showed up as regressions.

gdb/ChangeLog
2019-10-01  Tom Tromey  <tom@tromey.com>

* p-lang.c (pascal_printstr): Use metadata style.
* value.c (show_convenience): Use metadata style.
* valprint.c (valprint_check_validity, val_print_optimized_out)
(val_print_not_saved, val_print_unavailable)
(val_print_invalid_address, generic_val_print, val_print)
(value_check_printable, val_print_array_elements): Use metadata
style.
* ui-out.h (class ui_out) <field_fmt>: New overload.
<do_field_fmt>: Add style parameter.
* ui-out.c (ui_out::field_fmt): New overload.
* typeprint.c (type_print_unknown_return_type)
(val_print_not_allocated, val_print_not_associated): Use metadata
style.
* tui/tui-out.h (class tui_ui_out) <do_field_fmt>: Add style
parameter.
* tui/tui-out.c (tui_ui_out::do_field_fmt): Update.
* tracepoint.c (tvariables_info_1): Use metadata style.
* stack.c (print_frame_arg, print_frame_info, print_frame)
(info_frame_command_core): Use metadata style.
* skip.c (info_skip_command): Use metadata style.
* rust-lang.c (rust_print_enum): Use metadata style.
* python/py-prettyprint.c (print_stack_unless_memory_error): Use
metadata style.
* python/py-framefilter.c (py_print_single_arg): Use metadata
style.
* printcmd.c (do_one_display, print_variable_and_value): Use
metadata style.
* p-valprint.c (pascal_val_print)
(pascal_object_print_value_fields): Use metadata style.
* p-typeprint.c (pascal_type_print_base): Use metadata style.
* mi/mi-out.h (class mi_ui_out) <do_field_fmt>: Add style
parameter.
* mi/mi-out.c (mi_ui_out::do_field_fmt): Update.
* m2-valprint.c (m2_print_long_set): Use metadata style.
* m2-typeprint.c (m2_print_type): Use metadata style.
* infcmd.c (print_return_value_1): Use metadata style.
* gnu-v3-abi.c (print_one_vtable): Use metadata style.
* f-valprint.c (info_common_command_for_block): Use metadata
style.
* f-typeprint.c (f_type_print_base): Use metadata style.
* expprint.c (print_subexp_standard): Use metadata style.
* cp-valprint.c (cp_print_value_fields): Use metadata style.
* cli/cli-style.h (class cli_style_option): Add constructor.
(metadata_style): Declare.
* cli/cli-style.c (metadata_style): New global.
(_initialize_cli_style): Register metadata style.
* cli-out.h (class cli_ui_out) <do_field_fmt>: Add style
parameter.
* cli-out.c (cli_ui_out::do_field_fmt): Update.
* c-typeprint.c (c_type_print_base_struct_union)
(c_type_print_base_1): Use metadata style.
* breakpoint.c (watchpoint_value_print)
(print_one_breakpoint_location): Use metadata style.
* break-catch-syscall.c (print_one_catch_syscall): Use metadata
style.
* break-catch-sig.c (signal_catchpoint_print_one): Use metadata
style.
* ada-valprint.c (val_print_packed_array_elements, printstr)
(print_field_values, ada_val_print_ref, ada_val_print): Use
metadata style.
* ada-typeprint.c (print_array_type, ada_print_type): Use metadata
style.
* ada-tasks.c (print_ada_task_info, info_task): Use metadata
style.
* ada-lang.c (user_select_syms): Use metadata style.

gdb/testsuite/ChangeLog
2019-10-01  Tom Tromey  <tom@tromey.com>

* lib/gdb-utils.exp (style): Handle "metadata" argument.
* gdb.base/style.exp: Add metadata style test.

5 years agoStyle "pwd" output
Tom Tromey [Wed, 5 Jun 2019 02:00:40 +0000 (20:00 -0600)] 
Style "pwd" output

This changes the "pwd" command to style its output.

gdb/ChangeLog
2019-10-01  Tom Tromey  <tom@tromey.com>

* cli/cli-cmds.c (pwd_command): Style output.

gdb/testsuite/ChangeLog
2019-10-01  Tom Tromey  <tom@tromey.com>

* gdb.base/style.exp: Test "pwd".

5 years agoUse new %p format suffixes in gdb
Pedro Alves [Tue, 17 Sep 2019 23:03:28 +0000 (17:03 -0600)] 
Use new %p format suffixes in gdb

This changes various spots in gdb to use the new %p format suffixes.

gdb/ChangeLog
2019-10-01  Pedro Alves  <palves@redhat.com>
    Tom Tromey  <tom@tromey.com>

* symtab.c (print_symbol_info): Use %ps.
(print_msymbol_info): Use %ps.
* symfile.c (symbol_file_add_with_addrs): Use %ps.
* printcmd.c (print_variable_and_value): Use %ps.
* macrocmd.c (show_pp_source_pos): Use %ps.
* infrun.c (print_exited_reason): Use ui_out::message.
* breakpoint.c (watchpoint_check, print_one_breakpoint_location)
(describe_other_breakpoints): Use ui_out::message and new
formats.
(say_where): Use new formats.
(bkpt_print_it, tracepoint_print_one_detail): Use ui_out::message
and new formats.

5 years agoIntroduce gdb-specific %p format suffixes
Pedro Alves [Wed, 5 Jun 2019 08:17:16 +0000 (09:17 +0100)] 
Introduce gdb-specific %p format suffixes

This introduces a few gdb-specific %p format suffixes.  This is useful
for emitting gdb-specific output in an ergonomic way.  It also yields
code that is more i18n-friendly.

The comment before ui_out::message explains the details.

Note that the tests had to change a little.  When using one of the gdb
printf functions with styling, there can be spurious style changes
emitted to the output.  This did not seem worthwhile to fix, as the
low-level output functions are rather spaghetti-ish already, and I
didn't want to make them even worse.

This change also necessitated adding support for "*" as precision and
width in format_pieces.  These are used in various spots in gdb, and
it seemed better to me to implement them than to remove the uses.

gdb/ChangeLog
2019-10-01  Pedro Alves  <palves@redhat.com>
    Tom Tromey  <tom@tromey.com>

* unittests/format_pieces-selftests.c: Add gdb_format parameter.
(test_gdb_formats): New function.
(run_tests): Call it.
(test_format_specifier): Update.
* utils.h (fputs_filtered): Update comment.
(vfprintf_styled, vfprintf_styled_no_gdbfmt)
(fputs_styled_unfiltered): Declare.
* utils.c (fputs_styled_unfiltered): New function.
(vfprintf_maybe_filtered): Add gdbfmt parameter.
(vfprintf_filtered): Update.
(vfprintf_unfiltered, vprintf_filtered): Update.
(vfprintf_styled, vfprintf_styled_no_gdbfmt): New functions.
* ui-out.h (enum ui_out_flag) <unfiltered_output,
disallow_ui_out_field>: New constants.
(enum class field_kind): New.
(struct base_field_s, struct signed_field_s): New.
(signed_field): New function.
(struct string_field_s): New.
(string_field): New function.
(struct styled_string_s): New.
(styled_string): New function.
(class ui_out) <message>: Add comment.
<vmessage, call_do_message>: New methods.
<do_message>: Add style parameter.
* ui-out.c (ui_out::call_do_message, ui_out::vmessage): New
methods.
(ui_out::message): Rewrite.
* mi/mi-out.h (class mi_ui_out) <do_message>: Add style
parameter.
* mi/mi-out.c (mi_ui_out::do_message): Add style parameter.
* gdbsupport/format.h (class format_pieces) <format_pieces>: Add
gdb_extensions parameter.
(class format_piece): Add parameter to constructor.
(n_int_args): New field.
* gdbsupport/format.c (format_pieces::format_pieces): Add
gdb_extensions parameter.  Handle '*'.
* cli-out.h (class cli_ui_out) <do_message>: Add style parameter.
* cli-out.c (cli_ui_out::do_message): Add style parameter.  Call
vfprintf_styled_no_gdbfmt.
(cli_ui_out::do_field_string, cli_ui_out::do_spaces)
(cli_ui_out::do_text, cli_ui_out::field_separator): Allow
unfiltered output.
* ui-style.h (struct ui_file_style) <ptr>: New method.

gdb/testsuite/ChangeLog
2019-10-01  Tom Tromey  <tom@tromey.com>

* gdb.base/style.exp: Update tests.

5 years agoDon't create empty literal pieces
Tom Tromey [Sun, 22 Sep 2019 22:06:03 +0000 (16:06 -0600)] 
Don't create empty literal pieces

I noticed that format_pieces can create an empty literal piece.
However, there's never a need for one, so this patch removes the
possibility.

gdb/ChangeLog
2019-10-01  Tom Tromey  <tom@tromey.com>

* unittests/format_pieces-selftests.c: Update.  Add final format.
* gdbsupport/format.c (format_pieces::format_pieces): Don't add
empty literal pieces.

5 years agoRemove the ui_out_style_kind enum
Tom Tromey [Wed, 5 Jun 2019 22:21:24 +0000 (16:21 -0600)] 
Remove the ui_out_style_kind enum

This removes the ui_out_style_kind enum, in favor of simply using
ui_file_style references.  This simplifies the code somewhat.

gdb/ChangeLog
2019-10-01  Tom Tromey  <tom@tromey.com>

* ui-out.h (enum class ui_out_style_kind): Remove.
(class ui_out) <field_string, field_stsream, do_field_string>:
Change type of "style".
* ui-out.c (ui_out::field_core_addr, ui_out::field_stream)
(ui_out::field_string): Update.
* tui/tui-out.h (class tui_ui_out) <do_field_string>: Change type
of "style".
* tui/tui-out.c (tui_ui_out::do_field_string): Update.
* tracepoint.c (print_one_static_tracepoint_marker): Update.
* stack.c (print_frame_arg, print_frame_info, print_frame):
Update.
* source.c (print_source_lines_base): Update.
* solib.c (info_sharedlibrary_command): Update.
* skip.c (info_skip_command): Update.
* record-btrace.c (btrace_call_history_src_line)
(btrace_call_history): Update.
* python/py-framefilter.c (py_print_frame): Update.
* mi/mi-out.h (class mi_ui_out) <do_field_string>: Change type of
"style".
* mi/mi-out.c (mi_ui_out::do_table_header)
(mi_ui_out::do_field_signed, mi_ui_out::do_field_unsigned)
(mi_ui_out::do_field_string): Update.
* disasm.c (gdb_pretty_print_disassembler::pretty_print_insn):
Update.
* cli-out.h (class cli_ui_out) <do_field_string>: Change type of
"style".
* cli-out.c (cli_ui_out::do_table_header)
(cli_ui_out::do_field_signed, cli_ui_out::do_field_unsigned)
(cli_ui_out::do_field_skip, cli_ui_out::do_field_string)
(cli_ui_out::do_field_fmt): Update.
* breakpoint.c (print_breakpoint_location): Update.
(update_static_tracepoint): Update.

5 years agogdb/testsuite: Fix pretty-print.exp on big-endian platforms
Andreas Arnez [Tue, 1 Oct 2019 17:20:29 +0000 (19:20 +0200)] 
gdb/testsuite: Fix pretty-print.exp on big-endian platforms

The pretty-print test case fails on s390/s390x because it relies on a
little-endian representation of bit fields.  Little-endian architectures
typically allocate bit fields from least to most significant bit, but
big-endian architectures typically use the reverse order, allocating the
most significant bit first.  Thus the two bit fields in each of the test
case's unions overlap either in their lower or in their higher bits,
depending on the target's endianness:

    union {
      int three : 3;
      int four : 4;
    };

Now, when initializing 'three' with 3, 'four' will become 3 on little
endian targets, but 6 on big-endian targets, making it FAIL there.

Fix this by initializing the longer bit field instead and using an
all-ones bit pattern.  In this way the result does not depend on
endianness.  Use 'unsigned' instead of int for one of the bit fields in
each of the unions, to increase the variety of resulting values.

gdb/testsuite/ChangeLog:

* gdb.base/pretty-print.c (struct s1_t): Change fields 'three' and
'six' to unsigned.
(s1): Initialize fields 'four' and 'six' instead of 'three' and
'five'.  Use an all-ones bit pattern for each.
* gdb.base/pretty-print.exp: Adjust expected output of "print s1"
to its changed values.

5 years agoFix leak due to assigning a xstrdup-ed string to the std::string gdb_datadir
Philippe Waroquiers [Sun, 29 Sep 2019 16:26:23 +0000 (18:26 +0200)] 
Fix leak due to assigning a xstrdup-ed string to the std::string gdb_datadir

Valgrind reports the following leak:
==32623== 56 bytes in 1 blocks are definitely lost in loss record 1,099 of 6,654
==32623==    at 0x4835753: malloc (vg_replace_malloc.c:307)
==32623==    by 0x25CF67: xmalloc (alloc.c:60)
==32623==    by 0x65FBD9: xstrdup (xstrdup.c:34)
==32623==    by 0x413D9E: captured_main_1(captured_main_args*) (main.c:553)
==32623==    by 0x414FFA: captured_main (main.c:1172)
==32623==    by 0x414FFA: gdb_main(captured_main_args*) (main.c:1197)
==32623==    by 0x22531A: main (gdb.c:32)

Commit f2aec7f6d14 changed gdb_datadir to std::string.
So, xstrdup-ing the result of relocate_gdb_directory (returning a std::string)
is not needed and creates a leak.

Fix the leak by removing the xstrdup and the not needed c_str ().
Also removes a useless conversion of gdb_datadir to std::string.

gdb/ChangeLog
2019-10-01  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* main.c (relocate_gdbinit_path_maybe_in_datadir): Remove std::string
conversion of gdb_datadir.
(captured_main_1): Remove xstrdup when assigning to gdb_datadir,
remove not needed c_str ().

5 years ago[PATCH v2 2/4] DWARF 5 support: Handle DW_FORM_strx
Ali Tamur [Tue, 27 Aug 2019 01:40:18 +0000 (18:40 -0700)] 
[PATCH v2 2/4] DWARF 5 support: Handle DW_FORM_strx

* Handle DW_FORM_strx forms everywhere.

Tested with CC=/usr/bin/gcc (version 8.3.0) against master branch (also with
-gsplit-dwarf and -gdwarf-4 flags) and there was no increase in the set of
tests that fails.

This is part of an effort to support DWARF 5 in gdb.

gdb/ChangeLog:

        * dwarf2read.c (skip_one_die): Handle DW_FORM_strx forms.
        (dwarf2_string_attr): Likewise.

5 years agoAutomatic date update in version.in
GDB Administrator [Tue, 1 Oct 2019 00:00:41 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 years agoRemove extra whitespaces at the end of lines.
Ali Tamur [Mon, 30 Sep 2019 20:34:44 +0000 (13:34 -0700)] 
Remove extra whitespaces at the end of lines.

gdb/ChangeLog:

* dwarf2read.c (process_full_comp_unit): Remove whitespace at the EOL.
(process_full_type_unit): Likewise.
(dump_die_shallow): Likewise.
(cu_debug_loc_section): Likewise.

5 years agoUse std::sort instead of qsort in minsyms.c
Christian Biesinger [Sun, 29 Sep 2019 00:45:20 +0000 (19:45 -0500)] 
Use std::sort instead of qsort in minsyms.c

This has better typesafety and is also marginally faster (either
due to inlining or because it avoids indirection through a
function pointer).

Note that in this change:
-       return 1;               /* fn1 has no name, so it is "less".  */
+       return true;            /* fn1 has no name, so it is "less".  */
       else if (name1)          /* fn2 has no name, so it is "less".  */
-       return -1;
+       return false;
I am fairly sure the old code was wrong (ie. code didn't match the
comment and the comment seemed correct), so I fixed it.

gdb/ChangeLog:

2019-09-28  Christian Biesinger  <cbiesinger@google.com>

* minsyms.c (compare_minimal_symbols): Rename to...
(minimal_symbol_is_less_than): ...this, and adjust to STL
conventions (return bool, take arguments as references)
(minimal_symbol_reader::install): Call std::sort instead
of qsort.

5 years agoDisable all warnings in gdb.rust/traits.rs
Tom Tromey [Mon, 30 Sep 2019 16:33:39 +0000 (10:33 -0600)] 
Disable all warnings in gdb.rust/traits.rs

With rustc 1.37, I started seeing compiler warnings from the traits.rs
test case:

    warning: trait objects without an explicit `dyn` are deprecated

It seems to me that we generally do not want warnings in these test
cases.  At some point, we'll probably have to patch traits.rs to use
the "dyn" keyword; by that time I expect that all the Rust compilers
in common use will support it.  In the meantime it seemed simplest to
simply disable all warnings in this file.

gdb/testsuite/ChangeLog
2019-09-30  Tom Tromey  <tromey@adacore.com>

* gdb.rust/traits.rs: Disable all warnings.

5 years agoImprove some comments about msymbol handling
Christian Biesinger [Mon, 30 Sep 2019 01:15:38 +0000 (20:15 -0500)] 
Improve some comments about msymbol handling

This just clarifies some comments about the hashtables involved
in msymbols.

gdb/ChangeLog:

2019-09-29  Christian Biesinger  <cbiesinger@google.com>

* minsyms.h (msymbol_hash): Document that this is a case-insensitive
hash and why.
* objfiles.h (struct objfile_per_bfd_storage) <demangled_names_hash,
msymbol_hash, msymbol_demangled_hash>: Improve comments.

5 years agogdb: re-write add_psymbol_to_list doc, move it to header file
Simon Marchi [Mon, 30 Sep 2019 15:49:25 +0000 (11:49 -0400)] 
gdb: re-write add_psymbol_to_list doc, move it to header file

The comment above the add_psymbol_to_list function seems outdated and
misleading, here's an attempt at improving it.

gdb/ChangeLog:

* psymtab.c (add_psymbol_to_list): Move comment to psympriv.h.
* psympriv.h (add_psymbol_to_list): Move comment here and update
it.

5 years agoPR25046, readelf "Reading xxx bytes extends past end of file for dynamic section"
Alan Modra [Mon, 30 Sep 2019 04:34:08 +0000 (14:04 +0930)] 
PR25046, readelf "Reading xxx bytes extends past end of file for dynamic section"

PR 25046
* readelf.c (process_program_headers): Clear dynamic_addr and
dynamic_size earlier.

5 years agoAutomatic date update in version.in
GDB Administrator [Mon, 30 Sep 2019 00:00:33 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 years ago[gdb/contrib] cc-with-tweaks.sh: Create .dwz file in .tmp subdir
Tom de Vries [Sun, 29 Sep 2019 21:58:21 +0000 (23:58 +0200)] 
[gdb/contrib] cc-with-tweaks.sh: Create .dwz file in .tmp subdir

When running a test-case gdb.base/foo.exp with cc-with-dwz-m, a file
build/gdb/testsuite/outputs/gdb.base/foo/foo.dwz will be created, alongside
executable build/gdb/testsuite/outputs/gdb.base/foo/foo.

This can cause problems in f.i. test-cases that test file name completion.

Make these problems less likely by moving foo.dwz to a .tmp subdir:
build/gdb/testsuite/outputs/gdb.base/foo/.tmp/foo.dwz.

Tested on x86_64-linux.

gdb/ChangeLog:

2019-09-29  Tom de Vries  <tdevries@suse.de>

* contrib/cc-with-tweaks.sh (get_tmpdir): New function.
Use $tmpdir/$(basename "$output_file").dwz instead of
"${output_file}.dwz".

gdb/testsuite/ChangeLog:

2019-09-29  Tom de Vries  <tdevries@suse.de>

        * gdb.dwarf2/gdb-index.exp: Handle new location of .dwz file.

5 years ago[gdb/testsuite] Make pass message unique in gdb-index.exp for cc-with-dwz-m
Tom de Vries [Sun, 29 Sep 2019 21:51:50 +0000 (23:51 +0200)] 
[gdb/testsuite] Make pass message unique in gdb-index.exp for cc-with-dwz-m

With cc-with-dwz-m, we get:
...
PASS: gdb.dwarf2/gdb-index.exp: objcopy
PASS: gdb.dwarf2/gdb-index.exp: objcopy
...

Make the pass message unique by using with_test_prefix:
...
PASS: gdb.dwarf2/gdb-index.exp: objcopy
PASS: gdb.dwarf2/gdb-index.exp: modify dwz file: objcopy
...

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-09-29  Tom de Vries  <tdevries@suse.de>

* gdb.dwarf2/gdb-index.exp: Use with_test_prefix for second objcopy.

5 years agoAutomatic date update in version.in
GDB Administrator [Sun, 29 Sep 2019 00:00:40 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 years agogdb: include gdbarch.h in hppa-linux-nat.c
Simon Marchi [Sat, 28 Sep 2019 18:48:22 +0000 (14:48 -0400)] 
gdb: include gdbarch.h in hppa-linux-nat.c

hppa-linux-nat.c fails to build due to the gdbarch stuff not being
declared, for example:

    hppa-linux-nat.c: In function ‘void fetch_register(regcache*, int)’:
    hppa-linux-nat.c:230:7: error: ‘gdbarch_cannot_fetch_register’ was not declared in this scope
       if (gdbarch_cannot_fetch_register (gdbarch, regno))

Include gdbarch.h to fix it.

gdb/ChangeLog:

PR gdb/25045
* hppa-linux-nat.c: Include gdbarch.h.

5 years agoPR16794, gold ignores R_386_GOTOFF addend
Alan Modra [Wed, 11 Sep 2019 03:52:42 +0000 (13:22 +0930)] 
PR16794, gold ignores R_386_GOTOFF addend

An R_386_GOTOFF relocation has an addend, typically used when a
symbol can be replaced by its section symbol plus an offset.
psymval->value(object,0) is quite wrong then, fix it.

PR 16794
* i386.cc (Target_i386::Relocate::relocate <R_386_GOTOFF>): Don't
ignore addend, apply using pcrel32.
* x86_64.cc (Target_x86_64::Relocate::relocate <R_X86_64_GOTOFF64>):
Similarly use pcrel64.

5 years agoAutomatic date update in version.in
GDB Administrator [Sat, 28 Sep 2019 00:00:25 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 years ago[gdb/testsuite] Fix incomplete regexps in step-precsave.exp
Tom de Vries [Fri, 27 Sep 2019 15:04:59 +0000 (17:04 +0200)] 
[gdb/testsuite] Fix incomplete regexps in step-precsave.exp

The commit 68f7d34dd50 "[gdb/testsuite] Add KFAIL for missing support of
reverse-debugging of vmovd" rewrites a gdb_test into a gdb_test_multiple but
forgets to add the $gdb_prompt part in the regexp.

Add the missing parts of the regexps.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-09-27  Tom de Vries  <tdevries@suse.de>

* gdb.reverse/step-precsave.exp: Add missing $gdb_prompt in regexps.

5 years ago[gdb/testsuite] Add KFAIL for missing support of reverse-debugging of vmovd
Tom de Vries [Fri, 27 Sep 2019 08:36:18 +0000 (10:36 +0200)] 
[gdb/testsuite] Add KFAIL for missing support of reverse-debugging of vmovd

On my openSUSE Leap 15.1 system I run into:
...
(gdb) PASS: gdb.reverse/step-precsave.exp: turn on process record
break 76^M
Breakpoint 2 at 0x400654: file step-reverse.c, line 76.^M
(gdb) PASS: gdb.reverse/step-precsave.exp: breakpoint at end of main
continue^M
Continuing.^M
Process record does not support instruction 0xc5 at address 0x7ffff783fc70.^M
Process record: failed to record execution log.^M
^M
Program stopped.^M
0x00007ffff783fc70 in __memset_avx2_unaligned_erms () from /lib64/libc.so.6^M
(gdb) FAIL: gdb.reverse/step-precsave.exp: run to end of main
...

The problem is that the vmovd instruction is not supported in
reverse-debugging (PR record/23188).

Add a KFAIL for this PR.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-09-27  Tom de Vries  <tdevries@suse.de>

PR record/23188
* gdb.reverse/step-precsave.exp: Add kfail for PR record/23188.

5 years agoAutomatic date update in version.in
GDB Administrator [Fri, 27 Sep 2019 00:00:37 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 years agoRevert "Improve ptrace-error detection on Linux targets"
Sergio Durigan Junior [Thu, 26 Sep 2019 18:24:30 +0000 (14:24 -0400)] 
Revert "Improve ptrace-error detection on Linux targets"

This reverts commit 381beca6146ac68b57edf47d28cdb335fbd11635.

The patch hasn't been fully reviewed yet, and Pedro would like to see
more fixes.

5 years agoImprove ptrace-error detection on Linux targets
Sergio Durigan Junior [Fri, 16 Aug 2019 23:36:37 +0000 (19:36 -0400)] 
Improve ptrace-error detection on Linux targets

In Fedora GDB, we carry the following patch:

  https://src.fedoraproject.org/rpms/gdb/blob/8ac06474ff1e2aa4920d14e0666b083eeaca8952/f/gdb-attach-fail-reasons-5of5.patch

Its purpose is to try to detect a specific scenario where SELinux's
'deny_ptrace' option is enabled, which prevents GDB from ptrace'ing in
order to debug the inferior (PTRACE_ATTACH and PTRACE_TRACEME will
fail with EACCES in this case).

I like the idea of improving error detection and providing more
information to the user (a simple "Permission denied" can be really
frustrating), but I don't fully agree with the way the patch was
implemented: it makes GDB link against libselinux only for the sake of
consulting the 'deny_ptrace' setting, and then prints a warning if
ptrace failed and this setting is on.

My first thought (and attempt) was to make GDB print a generic warning
when a ptrace error happened; this message would just point the user
to our documentation, where she could find more information about
possible causes for the error (and try to diagnose/fix the problem).
This proved to be too simple, and I was convinced that it is actually
a good idea to go the extra kilometre and try to pinpoint the specific
problem (or problems) preventing ptrace from working, as well as
provide useful suggestions on how the user can fix things.

Here is the patch I came up with.  It implements a new function,
'linux_ptrace_restricted_fail_reason', which does a few things to
check what's wrong with ptrace:

  - It dlopen's "libselinux.so.1" and checks if the "deny_ptrace"
    option is enabled.

  - It reads the contents of "/proc/sys/kernel/yama/ptrace_scope" and
    checks if it's different than 0.

For each of these checks, if it succeeds, the user will see a message
informing about the restriction in place, and how it can be disabled.
For example, if "deny_ptrace" is enabled, the user will see:

  # gdb /usr/bin/true
  ...
  Starting program: /usr/bin/true
  warning: Could not trace the inferior process.
  warning: ptrace: Permission denied
  The SELinux 'deny_ptrace' option is enabled and preventing GDB
  from using 'ptrace'.  You can disable it by executing (as root):

    setsebool deny_ptrace off

  If you are debugging the inferior remotely, the ptrace restriction(s) need
  to be disabled in the target system (e.g., where GDBserver is running).
  During startup program exited with code 127.
  (gdb)

In case "/proc/sys/kernel/yama/ptrace_scope" is > 0:

  # gdb /usr/bin/true
  ...
  Starting program: /usr/bin/true
  warning: Could not trace the inferior process.
  warning: ptrace: Operation not permitted
  The Linux kernel's Yama ptrace scope is in effect, which can prevent
  GDB from using 'ptrace'.  You can disable it by executing (as root):

    echo 0 > /proc/sys/kernel/yama/ptrace_scope

  If you are debugging the inferior remotely, the ptrace restriction(s) need
  to be disabled in the target system (e.g., where GDBserver is running).
  During startup program exited with code 127.
  (gdb)

If both restrictions are enabled, both messages will show up.

This works for gdbserver as well, and actually fixes a latent bug I
found: when ptrace is restricted, gdbserver would hang due to an
unchecked ptrace call:

  # gdbserver :9988 /usr/bin/true
  gdbserver: linux_ptrace_test_ret_to_nx: Cannot PTRACE_TRACEME: Operation not permitted
  gdbserver: linux_ptrace_test_ret_to_nx: status 256 is not WIFSTOPPED!
  gdbserver: linux_ptrace_test_ret_to_nx: failed to kill child pid 2668100 No such process
  [ Here you would have to issue a C-c ]

Now, you will see:

  # gdbserver :9988 /usr/bin/true
  gdbserver: linux_ptrace_test_ret_to_nx: Cannot PTRACE_TRACEME: Permission denied
  gdbserver: linux_ptrace_test_ret_to_nx: status 256 is not WIFSTOPPED!
  gdbserver: linux_ptrace_test_ret_to_nx: failed to kill child pid 2766868 No such process
  gdbserver: Could not trace the inferior process.
  gdbserver: ptrace: Permission denied
  The SELinux 'deny_ptrace' option is enabled and preventing GDB
  from using 'ptrace'.  You can disable it by executing (as root):

    setsebool deny_ptrace off

  If you are debugging the inferior remotely, the ptrace restriction(s) need
  to be disabled in the target system (e.g., where GDBserver is running).
  #

(I decided to keep all the other messages, even though I find them a
bit distracting).

If GDB can't determine the cause for the failure, it will still print
the generic error message which tells the user to check our
documentation:

  There might be restrictions preventing ptrace from working.  Please see
  the appendix "Linux kernel ptrace restrictions" in the GDB documentation
  for more details.
  If you are debugging the inferior remotely, the ptrace restriction(s) need
  to be disabled in the target system (e.g., where GDBserver is running).

This means that the patch expands our documentation and creates a new
appendix section named "Linux kernel ptrace restrictions", with
sub-sections for each possible restriction that might be in place.

Notice how, on every message, we instruct the user to "do the right
thing" if gdbserver is being used.  This is because if the user
started gdbserver *before* any ptrace restriction was in place, and
then, for some reason, one or more restrictions get enabled, then the
error message will be displayed both on gdbserver *and* on the
connected GDB.  Since the user will be piloting GDB, it's important to
explicitly say that the ptrace restrictions are enabled in the target,
where gdbserver is running.

The current list of possible restrictions is:

  - SELinux's 'deny_ptrace' option (detected).

  - YAMA's /proc/sys/kernel/yama/ptrace_scope setting (detected).

  - seccomp on Docker containers (I couldn't find how to detect).

It's important to mention that all of this is Linux-specific; as far
as I know, SELinux, YAMA and seccomp are Linux-only features.

I tested this patch locally, on my Fedora 30 machine (actually, a
Fedora Rawhide VM), but I'm not proposing a testcase for it because of
the difficulty of writing one.

WDYT?

gdb/doc/ChangeLog:
2019-09-26  Sergio Durigan Junior  <sergiodj@redhat.com>

* gdb.texinfo (Linux kernel ptrace restrictions): New appendix
section.

gdb/ChangeLog:
2019-09-26  Sergio Durigan Junior  <sergiodj@redhat.com>
    Jan Kratochvil  <jan.kratochvil@redhat.com>
    Pedro Alves  <palves@redhat.com>

* gdbsupport/gdb-dlfcn.h (gdb_dlopen): Update comment and
mention that the function throws an error.
* inf-ptrace.c (default_inf_ptrace_me_fail_reason): New
function.
(inf_ptrace_me_fail_reason): New variable.
(inf_ptrace_me): Update call to 'trace_start_error_with_name'.
* inf-ptrace.h (inf_ptrace_me_fail_reason): New variable.
* linux-nat.c (attach_proc_task_lwp_callback): Call
'linux_ptrace_attach_fail_reason_lwp'.
(linux_nat_target::attach): Update call to
'linux_ptrace_attach_fail_reason'.
(_initialize_linux_nat): Set 'inf_ptrace_me_fail_reason'.
* nat/fork-inferior.c (trace_start_error_with_name): Add
optional 'append' argument.
* nat/fork-inferior.h (trace_start_error_with_name): Update
prototype.
* nat/linux-ptrace.c: Include "gdbsupport/gdb-dlfcn.h",
"gdbsupport/filestuff.h" and "nat/fork-inferior.h".
(selinux_ftype): New typedef.
(linux_ptrace_restricted_fail_reason): New function.
(linux_ptrace_attach_fail_reason_1): New function.
(linux_ptrace_attach_fail_reason): Change first argument type
from 'ptid_t' to 'pid_t'.  Call
'linux_ptrace_attach_fail_reason_1' and
'linux_ptrace_restricted_fail_reason'.
(linux_ptrace_attach_fail_reason_lwp): New function.
(linux_ptrace_me_fail_reason): New function.
(errno_pipe): New variable.
(linux_fork_to_function): Initialize pipe before forking.
(linux_child_function): Deal with errno-passing from child.
Handle ptrace error.
(linux_check_child_ptrace_errno): New function.
(linux_check_child_ptrace_errno): Call
'linux_check_child_ptrace_errno'.
* nat/linux-ptrace.h (linux_ptrace_attach_fail_reason): Update
prototype.
(linux_ptrace_attach_fail_reason_lwp): New prototype.
(linux_ptrace_me_fail_reason): New prototype.
* remote.c (extended_remote_target::attach): Handle error
message passed by the server when attach fails.

gdb/gdbserver/ChangeLog:
2019-09-26  Sergio Durigan Junior  <sergiodj@redhat.com>
    Pedro Alves  <palves@redhat.com>

* linux-low.c (linux_ptrace_fun): Call
'linux_ptrace_me_fail_reason'.
(attach_proc_task_lwp_callback): Call
'linux_ptrace_attach_fail_reason_lwp'.
(linux_attach): Call 'linux_ptrace_attach_fail_reason'.
* server.c (handle_v_attach): Use try..catch when calling
'attach_inferior', and send an error message to the client
when needed.
* thread-db.c (attach_thread): Call
'linux_ptrace_attach_fail_reason_lwp'.

5 years agoConvert symtab.h function signatures to use bool instead of int
Christian Biesinger [Tue, 24 Sep 2019 21:43:18 +0000 (16:43 -0500)] 
Convert symtab.h function signatures to use bool instead of int

gdb/ChangeLog:

2019-09-26  Christian Biesinger  <cbiesinger@google.com>

* blockframe.c (find_pc_partial_function): Change return type to bool.
* elfread.c (elf_gnu_ifunc_resolve_name): Likewise.
* minsyms.c (in_gnu_ifunc_stub): Likewise.
(stub_gnu_ifunc_resolve_name): Likewise.
* symtab.c (compare_filenames_for_search): Likewise.
(compare_glob_filenames_for_search): Likewise.
(matching_obj_sections): Likewise.
(symbol_matches_domain): Likewise.
(find_line_symtab): Change out param EXACT_MATCH to bool *.
(find_line_pc): Change return type to bool.
(find_line_pc_range): Likewise.
(producer_is_realview): Likewise.
* symtab.h (symbol_matches_domain): Likewise.
(find_pc_partial_function): Likewise.
(find_pc_line_pc_range): Likewise.
(in_gnu_ifunc_stub): Likewise.
(struct gnu_ifunc_fns) <gnu_ifunc_resolve_name>: Likewise.
(find_line_pc): Likewise.
(find_line_pc_range): Likewise.
(matching_obj_sections): Likewise.
(find_line_symtab): Change out parameter to bool.
(producer_is_realview): Change return type to bool.
(compare_filenames_for_search): Likewise.
(compare_glob_filenames_for_search): Likewise.

5 years agoRemove gdb_usleep.c
Tom Tromey [Sun, 17 Feb 2019 18:23:20 +0000 (11:23 -0700)] 
Remove gdb_usleep.c

I noticed that gdb_usleep is unused, so this patch removes it.

gdb/ChangeLog
2019-09-26  Tom Tromey  <tom@tromey.com>

* Makefile.in (COMMON_SFILES): Remove gdb_usleep.c.
(HFILES_NO_SRCDIR): Remove gdb_usleep.h.
* gdb_usleep.h: Remove.
* gdb_usleep.c: Remove.
* utils.c: Don't include gdb_usleep.h.

5 years agoDo not expose stub types to Python
Tom Tromey [Mon, 19 Aug 2019 19:41:34 +0000 (13:41 -0600)] 
Do not expose stub types to Python

dwarf2read.c will create stub types for Ada "Taft Amendment" types.
These stub types can currently be exposed to Python code, where they
show up as TYPE_CODE_VOID types (but that, mysteriously, can sometimes
be used in other ways).

While it's possible to work with such types by using strip_typedefs,
this seemed unpleasant to me.  This patch takes another approach
instead, which is to try not to expose stub types to Python users.

gdb/ChangeLog
2019-09-26  Tom Tromey  <tromey@adacore.com>

* python/py-type.c (type_to_type_object): Call check_typedef
for stub types.

gdb/testsuite/ChangeLog
2019-09-26  Tom Tromey  <tromey@adacore.com>

* gdb.ada/py_taft.exp: New file.
* gdb.ada/py_taft/main.adb: New file.
* gdb.ada/py_taft/pkg.adb: New file.
* gdb.ada/py_taft/pkg.ads: New file.

5 years agoRemove initialize_utils
Tom Tromey [Tue, 24 Sep 2019 23:52:08 +0000 (17:52 -0600)] 
Remove initialize_utils

initialize_utils only registers some commands, so it isn't necessary
to run it at any particular time during startup.  This patch removes
it and merges its contents into _initialize_utils.

Tested by the buildbot.

gdb/ChangeLog
2019-09-26  Tom Tromey  <tom@tromey.com>

* utils.h (initialize_utils): Don't declare.
* top.c (gdb_init): Don't call initialize_utils.
* utils.c (initialize_utils): Remove.  Move contents...
(_initialize_utils): ... here.

5 years agoPR24262, plugin search dir doesn't respect --libdir
Alan Modra [Thu, 26 Sep 2019 06:50:35 +0000 (16:20 +0930)] 
PR24262, plugin search dir doesn't respect --libdir

bfd/
PR 24262
* Makefile.am (AM_CPPFLAGS): Add -DLIBDIR.
* plugin.c (load_plugin): Search both ${libdir}/bfd-plugins and
${bindir}/../lib/bfd-plugins if different.
* Makefile.in: Regenerate.
ld/
PR 24262
* ld.texi (-plugin): Revert 2019-03-15 change.

5 years agoAutomatic date update in version.in
GDB Administrator [Thu, 26 Sep 2019 00:00:45 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 years agoRemove make_hex_string
Tom Tromey [Tue, 24 Sep 2019 23:36:07 +0000 (17:36 -0600)] 
Remove make_hex_string

I noticed that make_hex_string does essentially the same thing as
bin2hex, and furthermore is only called in a single spot.  This patch
removes make_hex_string.

Tested by the builtbot.

gdb/ChangeLog
2019-09-25  Tom Tromey  <tom@tromey.com>

* python/py-objfile.c (objfpy_get_build_id): Use bin2hex.
* utils.h (make_hex_string): Don't declare.
* utils.c (make_hex_string): Remove.

5 years agoSORT_BY_INIT_PRIORITY
Alan Modra [Wed, 25 Sep 2019 06:00:53 +0000 (15:30 +0930)] 
SORT_BY_INIT_PRIORITY

I was looking at the implementation of this script keyword today and
couldn't remember why we do what we do in get_init_priority, because
the comments explain how the init_priority is encoded but don't say
why it is necessary to extract the priority and sort on that.  So
after figuring out why (again), I wrote some more comments.

Then I simplified get_init_priority a little, adding some sanity
checking on the strtoul result.  This actually makes get_init_priority
support sorting by numerical suffix more generally, but I figure this
feature would be better as a new keyword (without the .ctors/.dtors
special case), so haven't documented the extension.

* ld.texi (SORT_BY_ALIGNMENT): Reword slightly.
(SORT_BY_INIT_PRIORITY): Elucidate.
* ldlang.c: Include limits.h.
(get_init_priority): Comment.  Change param to a section,
return an int.  Sanity check priority digits.  Support sorting
more sections with trailing digits.  Return -1 on error.
(compare_section): Adjust.

5 years agoSilence a build-time warning about constant comparisons when building with clang,
Nick Clifton [Wed, 25 Sep 2019 13:34:23 +0000 (14:34 +0100)] 
Silence a build-time warning about constant comparisons when building with clang,

 * emultempl/avrelf.em (_before_allocation): Silence build warning
 using clang.

5 years agoAutomatic date update in version.in
GDB Administrator [Wed, 25 Sep 2019 00:00:43 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 years ago[gdb/tdep] Handle mxcsr kernel bug on Intel Skylake CPUs
Tom de Vries [Tue, 24 Sep 2019 21:38:49 +0000 (23:38 +0200)] 
[gdb/tdep] Handle mxcsr kernel bug on Intel Skylake CPUs

On my openSUSE Leap 15.1 x86_64 Skylake system with the default (4.12) kernel,
I run into:
...
FAIL: gdb.base/gcore.exp: corefile restored all registers
...

The problem is that there's a difference in the mxcsr register value before
and after the gcore command:
...
- mxcsr          0x0                 [ ]
+ mxcsr          0x400440            [ DAZ OM ]
...

This can be traced back to amd64_linux_nat_target::fetch_registers, where
xstateregs is partially initialized by the ptrace call:
...
          char xstateregs[X86_XSTATE_MAX_SIZE];
          struct iovec iov;

          amd64_collect_xsave (regcache, -1, xstateregs, 0);
          iov.iov_base = xstateregs;
          iov.iov_len = sizeof (xstateregs);
          if (ptrace (PTRACE_GETREGSET, tid,
                      (unsigned int) NT_X86_XSTATE, (long) &iov) < 0)
            perror_with_name (_("Couldn't get extended state status"));

          amd64_supply_xsave (regcache, -1, xstateregs);
...
after which amd64_supply_xsave is called.

The amd64_supply_xsave call is supposed to only use initialized parts of
xstateregs, but due to a kernel bug on intel skylake (fixed from 4.14 onwards
by commit 0852b374173b "x86/fpu: Add FPU state copying quirk to handle XRSTOR
failure on Intel Skylake CPUs") it can happen that the mxcsr part of
xstateregs is not initialized, while amd64_supply_xsave expects it to be
initialized, which explains the FAIL mentioned above.

Fix the undetermined behaviour by initializing xstateregs before calling
ptrace, which makes sure we get a 0x0 for mxcsr when this kernel bug occurs,
and which also happens to fix the FAIL.

Furthermore, add an xfail for this FAIL which triggers the same kernel bug:
...
FAIL: gdb.arch/amd64-init-x87-values.exp: check_setting_mxcsr_before_enable: \
  check new value of MXCSR is still in place
...

Both FAILs pass when using a 5.3 kernel instead on the system mentioned above.

Tested on x86_64-linux.

gdb/ChangeLog:

2019-09-24  Tom de Vries  <tdevries@suse.de>

PR gdb/23815
* amd64-linux-nat.c (amd64_linux_nat_target::fetch_registers):
Initialize xstateregs before ptrace PTRACE_GETREGSET call.

gdb/testsuite/ChangeLog:

2019-09-24  Tom de Vries  <tdevries@suse.de>

PR gdb/24598
* gdb.arch/amd64-init-x87-values.exp: Add xfail.

5 years agoArm: Fix out of range conditional branch (PR/24991)
Tamar Christina [Tue, 24 Sep 2019 13:46:17 +0000 (14:46 +0100)] 
Arm: Fix out of range conditional branch (PR/24991)

The fix for PR12848 introduced an off by one error in the mask, this corrected
the negative overflows but not the positive overflows.  As a result the
conditional branch instructions accepted a too wide positive immediate which
resulted in it corrupting the instruction during encoding.

The relocation I believe has been incorrectly named, to be consistent with the
other relocations it should have been named BRANCH21 which is why the masks for
it are confusing.

I've replaced the masks with a function out_of_range_p which should make it
harder to make such mistakes.

The mask for BL/BLX on Armv6t+ is also wrong, the extended range is 25-bits
and so the mask should be checking for 24-bits for positive overflow.

gas/ChangeLog:

PR gas/24991
* config/tc-arm.c (out_of_range_p): New.
(md_apply_fix): Use it in BFD_RELOC_THUMB_PCREL_BRANCH9,
BFD_RELOC_THUMB_PCREL_BRANCH12, BFD_RELOC_THUMB_PCREL_BRANCH20,
BFD_RELOC_THUMB_PCREL_BRANCH23, BFD_RELOC_THUMB_PCREL_BRANCH25
* testsuite/gas/arm/pr24991.d: New test.
* testsuite/gas/arm/pr24991.l: New test.
* testsuite/gas/arm/pr24991.s: New test.

5 years agoPR25031, nm reports wrong address on 32bit
Alan Modra [Tue, 24 Sep 2019 13:17:13 +0000 (22:47 +0930)] 
PR25031, nm reports wrong address on 32bit

Using saved_format breaks when nm is presented with multiple object
files, some 32-bit and some 64-bit.

PR 25031
* nm.c (print_format_string): New.
(get_print_format): Delete saved_format.  Move earlier.
(set_print_width): Call get_print_format.
(print_value): Use print_format_string.

5 years ago[ARM]: Modify assembler to accept floating and signless datatypes for MVE instruction...
Srinath Parvathaneni [Tue, 24 Sep 2019 09:18:12 +0000 (10:18 +0100)] 
[ARM]: Modify assembler to accept floating and signless datatypes for MVE instruction VLDR.

This patch modifies assembler to accept the equivalent sized floating
and signless datatypes for VLDR instruction but as alias for the unsigned version.

gas/ChangeLog:

2019-09-23  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

* config/tc-arm.c (do_mve_vstr_vldr_RQ): Modify function to allow float
* and signless datatypes for few cases of VLDR instruction.
* testsuite/gas/arm/mve-vldr-bad-3.l: Modify.
* testsuite/gas/arm/mve-vldr-bad-3.s: Likewise.
* testsuite/gas/arm/mve-vstrldr-1.d: Likewise.
* testsuite/gas/arm/mve-vstrldr-1.s: Likewise.

5 years agoFix building gold with gcc-10.
Nick Clifton [Tue, 24 Sep 2019 09:07:56 +0000 (10:07 +0100)] 
Fix building gold with gcc-10.

   * descriptors.cc: Include <string>

5 years agoAutomatic date update in version.in
GDB Administrator [Tue, 24 Sep 2019 00:00:31 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 years agogdb/readline: Fix date in last ChangeLog entry
Andrew Burgess [Mon, 23 Sep 2019 21:36:42 +0000 (22:36 +0100)] 
gdb/readline: Fix date in last ChangeLog entry

Fixes the date in the last ChangeLog entry.

5 years agogdb/readline: fix use of an undefined variable
Andrew Burgess [Wed, 18 Sep 2019 19:13:25 +0000 (15:13 -0400)] 
gdb/readline: fix use of an undefined variable

This commit in binutils-gdb:

  commit 830b67068cebe7db0eb0db3fa19244e03859fae0
  Date:   Fri Jul 12 09:53:02 2019 +0200

      [readline] Fix heap-buffer-overflow in update_line

Which corresponds to this commit in upstream readline:

  commit 31547b4ea4a1a904e1b08e2bc4b4ebd5042aedaa
  Date:   Mon Aug 5 10:24:27 2019 -0400

      commit readline-20190805 snapshot

Introduced a use of an undefined variable, which can be seen using
valgrind:

  $ valgrind --tool=memcheck gdb
  GNU gdb (GDB) 8.3.50.20190918-git
  Copyright (C) 2019 Free Software Foundation, Inc.
  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  This is free software: you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.
  Type "show copying" and "show warranty" for details.
  This GDB was configured as "x86_64-pc-linux-gnu".
  Type "show configuration" for configuration details.
  For bug reporting instructions, please see:
  <http://www.gnu.org/software/gdb/bugs/>.
  Find the GDB manual and other documentation resources online at:
      <http://www.gnu.org/software/gdb/documentation/>.

  For help, type "help".
  Type "apropos word" to search for commands related to "word".
  ==24924== Conditional jump or move depends on uninitialised value(s)
  ==24924==    at 0x9986C3: rl_redisplay (display.c:710)
  ==24924==    by 0x9839CE: readline_internal_setup (readline.c:447)
  ==24924==    by 0x9A1C2B: _rl_callback_newline (callback.c:100)
  ==24924==    by 0x9A1C85: rl_callback_handler_install (callback.c:111)
  ==24924==    by 0x6195EB: gdb_rl_callback_handler_install(char const*) (event-top.c:319)
  ==24924==    by 0x61975E: display_gdb_prompt(char const*) (event-top.c:409)
  ==24924==    by 0x4FBFE3: cli_interp_base::pre_command_loop() (cli-interp.c:286)
  ==24924==    by 0x6E53DA: interp_pre_command_loop(interp*) (interps.c:321)
  ==24924==    by 0x731F30: captured_command_loop() (main.c:334)
  ==24924==    by 0x733568: captured_main(void*) (main.c:1182)
  ==24924==    by 0x7335CE: gdb_main(captured_main_args*) (main.c:1197)
  ==24924==    by 0x41325D: main (gdb.c:32)
  ==24924==
  (gdb)

The problem can be traced back to init_line_structures.  The very
first time this function is ever called its MINSIZE parameter is
always 0 and the global LINE_SIZE is 1024.  Prior to the above
mentioned commits we spot that the line_state variables have not yet
been initialised, and allocate them some new buffer, then we enter
this loop:

  for (n = minsize; n < line_size; n++)
    {
      visible_line[n] = 0;
      invisible_line[n] = 1;
    }

which would initialise everything from the incoming minimum up to the
potentially extended upper line size.

The problem is that the above patches added a new condition that would
bump up the minsize like this:

  if (minsize <= _rl_screenwidth) /* XXX - for gdb */
    minsize = _rl_screenwidth + 1;

So, the first time this function is called the incoming MINSIZE is 0,
the LINE_SIZE global is 1024, and if the _rl_screenwidth is 80, we see
that MINSIZE will be pushed up to 80.  We still notice that the line
state is uninitialised and allocate some buffers, then we enter the
initialisation loop:

  for (n = minsize; n < line_size; n++)
    {
      visible_line[n] = 0;
      invisible_line[n] = 1;
    }

And initialise from 80 to 1023 i the newly allocated buffers, leaving
0 to 79 uninitialised.

To confirm this is an issue, if we then look at rl_redisplay we see
that a call to init_line_structures is followed first by a call to
rl_on_new_line, which does initialise visible_line[0], but not
invisible_line[0].  Later in rl_redisplay we have this logic:

  if (visible_line[0] != invisible_line[0])
    rl_display_fixed = 0;

The use of invisible_line[0] here will be undefined.

Considering how this variable was originally initialised before the
above patches, this patch modifies the initialisation loop in
init_line_structures, to use the original value of MINSIZE.  With this
change the valgrind warning goes away.

readline/ChangeLog:

PR cli/24980
* display.c (init_line_structures): Initialise line_state using
original minsize value.

5 years agoAdd testsuite for the PRU simulator port
Dimitar Dimitrov [Mon, 23 Sep 2019 16:55:43 +0000 (17:55 +0100)] 
Add testsuite for the PRU simulator port

sim/testsuite/ChangeLog:

* configure: Regenerate.

sim/testsuite/sim/pru/ChangeLog:

* add.s: New test.
* allinsn.exp: New file.
* dmem-zero-pass.s: New test.
* dmem-zero-trap.s: New test.
* dram.s: New test.
* jmp.s: New test.
* loop-imm.s: New test.
* loop-reg.s: New test.
* mul.s: New test.
* subreg.s: New test.
* testutils.inc: New file.

5 years agosim: Add PRU simulator port
Dimitar Dimitrov [Mon, 23 Sep 2019 16:54:42 +0000 (17:54 +0100)] 
sim: Add PRU simulator port

A simulator port for the TI PRU I/O processor.

v1: https://sourceware.org/ml/gdb-patches/2016-12/msg00143.html
v2: https://sourceware.org/ml/gdb-patches/2017-02/msg00397.html
v3: https://sourceware.org/ml/gdb-patches/2017-02/msg00516.html
v4: https://sourceware.org/ml/gdb-patches/2018-06/msg00484.html
v5: https://sourceware.org/ml/gdb-patches/2019-08/msg00584.html
v6: https://sourceware.org/ml/gdb-patches/2019-09/msg00036.html

gdb/ChangeLog:

* NEWS: Mention new simulator port for PRU.

sim/ChangeLog:

* MAINTAINERS: Add myself as PRU maintainer.
* configure: Regenerated.
* configure.tgt: Add PRU.

sim/common/ChangeLog:

* gennltvals.sh: Add PRU libgloss target.
* nltvals.def: Regenerate from the latest libgloss sources.

sim/pru/ChangeLog:

* Makefile.in: New file.
* aclocal.m4: Regenerated.
* config.in: Regenerated.
* configure: Regenerated.
* configure.ac: New file.
* interp.c: New file.
* pru.h: New file.
* pru.isa: New file.
* sim-main.h: New file.

5 years agoMake ada_decode not use a static buffer
Christian Biesinger [Wed, 28 Aug 2019 20:40:31 +0000 (15:40 -0500)] 
Make ada_decode not use a static buffer

This makes it safer to use in general, and also allows using it on a
background thread in the future.

Inspired by tromey's patch at:
https://github.com/tromey/gdb/commit/1226cbdfa436297a5dec054d94592c45891afa93
(however, implemented in a different way)

gdb/ChangeLog:

2019-09-23  Christian Biesinger  <cbiesinger@google.com>

* ada-exp.y (write_object_remaining): Update.
* ada-lang.c (ada_decode): Return a std::string instead of a char*
and eliminate the static buffer.
(ada_decode_symbol): Update.
(ada_la_decode): Update.
(ada_sniff_from_mangled_name): Update.
(is_valid_name_for_wild_match): Update.
(ada_lookup_name_info::matches): Update and simplify.
(name_matches_regex): Update.
(ada_add_global_exceptions): Update.
* ada-lang.h (ada_decode): Update signature.
* ada-varobj.c (ada_varobj_describe_simple_array_child): Update.
* dwarf-index-write.c (debug_names::insert): Update.

5 years agold-plugin/pr24406-1.c: Correct buffer size to read
H.J. Lu [Mon, 23 Sep 2019 15:51:36 +0000 (08:51 -0700)] 
ld-plugin/pr24406-1.c: Correct buffer size to read

* testsuite/ld-plugin/pr24406-1.c (main): Correct buffer size
to read.

5 years agoPowerPC64 dynamic symbol tweaks
Alan Modra [Mon, 23 Sep 2019 06:36:22 +0000 (16:06 +0930)] 
PowerPC64 dynamic symbol tweaks

In check_relocs, bfd_link_pic true means ld is producing a shared
library or a position independent executable.  !bfd_link_pic means a
fixed position (ie. static) executable since the relocatable linking
case is excluded.  So it is appropriate to continue using bfd_link_pic
when testing whether non-pcrelative relocations should be dynamic, and
!bfd_link_pic for the special case of ifunc in static executables.
However, -Bsymbolic shouldn't affect PIEs (they are executables so
none of their symbols should be overridden) and PIEs can support copy
relocations, thus bfd_link_executable should be used in those cases
rather than bfd_link_pic.

I've also removed the test of ELIMINATE_COPY_RELOCS in check_relocs.
We can sort out what to do regarding copy relocs later, which allows
the code in check_relocs to be simplified.

* elf64-ppc.c (ppc64_elf_check_relocs): Use bfd_link_executable
in choosing between different actions for shared library and
non-shared library cases.  Delete ELIMINATE_COPY_RELOCS test.
(dec_dynrel_count): Likewise.  Account for ifunc special case.
(ppc64_elf_adjust_dynamic_symbol): Copy relocs are for executables,
not non-pic.
(allocate_dynrelocs): Comment fixes.  Delete ELIMINATE_COPY_RELOCS
test.

5 years agoimplicit conversion from enum ld_plugin_level to enum ld_plugin_status
Alan Modra [Mon, 23 Sep 2019 11:00:22 +0000 (20:30 +0930)] 
implicit conversion from enum ld_plugin_level to enum ld_plugin_status

This is a gcc10 warning fix.

gold/
* testsuite/plugin_new_section_layout.c (new_input_hook): Correct
return status enum values.

5 years agobfd Makefile update
Alan Modra [Mon, 23 Sep 2019 00:45:02 +0000 (10:15 +0930)] 
bfd Makefile update

* Makefile.am (SOURCE_HFILES): Add many missing .h files.
* Makefile.in: Regenerate.
* po/SRC-POTFILES.in: Regenerate.

5 years agolinker bfd.h tidy
Alan Modra [Mon, 23 Sep 2019 00:44:20 +0000 (10:14 +0930)] 
linker bfd.h tidy

bfd/
* bfd-in.h (bfd_symbol, bfd_section_already_linked),
(bfd_elf_version_tree): Delete forward declarations.
Move other forward decls and remaining elf function decl later.
(bfd_section_already_linked_table_init),
(bfd_section_already_linked_table_free),
(_bfd_handle_already_linked, _bfd_nearby_section),
(_bfd_fix_excluded_sec_syms): Move to bfdlink.h.
include/
* bfdlink.h (struct bfd_section_already_linked): Forward declare.
(bfd_section_already_linked_table_init),
(bfd_section_already_linked_table_free),
(_bfd_handle_already_linked, _bfd_nearby_section),
(_bfd_fix_excluded_sec_syms): Declare.

5 years agoecoff bfd.h tidy
Alan Modra [Mon, 23 Sep 2019 00:43:26 +0000 (10:13 +0930)] 
ecoff bfd.h tidy

bfd/
* bfd-in.h: Move ecoff function declarations..
* ecoff-bfd.h: ..to here, new file.
* ecoff.c: Include ecoff-bfd.h.
* ecofflink.c: Likewise.
* elf64-alpha.c: Likewise.
* elfxx-mips.c: Likewise.
* bfd-in2.h: Regenerate.
gas/
* config/obj-ecoff.c: Include ecoff-bfd.h.
* config/obj-elf.c: Likewise.

5 years agoelf bfd.h tidy
Alan Modra [Mon, 23 Sep 2019 00:42:31 +0000 (10:12 +0930)] 
elf bfd.h tidy

bfd/
* bfd-in.h (enum notice_asneeded_action): Move to bfdlink.h.
Move most other elf declarations..
* elf-bfd.h: ..to here.
* bfd-in2.h: Regenerate.
include/
* bfdlink.h (enum notice_asneeded_action): Define.
ld/
* deffilep.y: Include bfdlink.h.
* ldelf.c: Likewise.
* ldelfgen.c: Likewise.
* ldver.c: Likewise.
* mri.c: Likewise.
* emultempl/irix.em: Don't include ld.h, ldmain.h, libiberty.h.
Comment.

5 years agom68k bfd.h tidy
Alan Modra [Mon, 23 Sep 2019 00:41:29 +0000 (10:11 +0930)] 
m68k bfd.h tidy

bfd/
* bfd-in.h: Move m68k function declaration..
* cpu-m68k.h: ..to here, new file..
* elf32-m68k.h: ..and here, new file.
* elf32-m68k.c: Include cpu-m68k.h and elf32-m68k.h.
* bfd-in2.h: Regenerate.
ld/
* emultempl/m68kelf.em: Include elf32-m68k.h.
opcodes/
* m68k-dis.c: Include cpu-m68k.h

5 years agobfin bfd.h tidy
Alan Modra [Mon, 23 Sep 2019 00:40:28 +0000 (10:10 +0930)] 
bfin bfd.h tidy

bfd/
* bfd-in.h: Move bfin function declaration..
* elf32-bfin.h: ..to here, new file.
* elf32-bfin.c: Include elf32-bfin.h.
* bfd-in2.h: Regenerate.
ld/
* emultempl/bfin.em: Include elf32-bfin.h.

5 years agocr16 bfd.h tidy
Alan Modra [Mon, 23 Sep 2019 00:39:47 +0000 (10:09 +0930)] 
cr16 bfd.h tidy

bfd/
* bfd-in.h: Move cr16 function declaration..
* elf32-cr16.h: ..to here, new file.
* elf32-cr16.c: Include elf32-cr16.h.
* bfd-in2.h: Regenerate.
ld/
* emultempl/cr16elf.em: Include elf32-cr16.h.

5 years agoobsoleted bfd.h tidy
Alan Modra [Mon, 23 Sep 2019 00:39:07 +0000 (10:09 +0930)] 
obsoleted bfd.h tidy

* bfd-in.h (bfd_sunos_get_needed_list),
(bfd_sunos_record_link_assignment),
(bfd_sunos_size_dynamic_sections),
(bfd_i386linux_size_dynamic_sections),
(bfd_sparclinux_size_dynamic_sections): Delete obsolete decls.
* bfd-in2.h: Regenerate.

5 years agoxcoff bfd.h tidy
Alan Modra [Mon, 23 Sep 2019 00:38:33 +0000 (10:08 +0930)] 
xcoff bfd.h tidy

bfd/
* bfd-in.h: Move xcoff function declarations..
* xcofflink.h: ..to here, new file.
* xcofflink.c: Include xcofflink.h.
* coff-rs6000.c (bfd_xcoff_ar_archive_set_magic): Delete unused func.
* bfd-in2.h: Regenerate.
ld/
* emultempl/aix.em: Include xcofflink.h.

5 years agocoff bfd.h tidy
Alan Modra [Mon, 23 Sep 2019 00:37:40 +0000 (10:07 +0930)] 
coff bfd.h tidy

bfd/
* bfd-in.h: Delete coff forward refs and move coff declaration..
* coff-bfd.h: ..to here.
* bfd-in2.h: Regenerate.
binutils/
* dlltool.c: Include coff-bfd.h.

5 years agoarm bfd.h tidy
Alan Modra [Mon, 23 Sep 2019 00:36:45 +0000 (10:06 +0930)] 
arm bfd.h tidy

bfd/
* bfd-in.h: Move arm declaraions..
* cpu-arm.h: ..to here, new file..
* coff-arm.h: ..and here, new file..
* elf32-arm.h: ..and here, new file.
* cpu-arm.c: Include cpu-arm.h.
* coff-arm.c: Include cpu-arm.h and coff-arm.h.
* elf32-arm.c: Include cpu-arm.h and elf32-arm.h.
* pe-arm.c: Move function rename defines later.
* pe-arm-wince.c: Likewise and include sysdep.h and bfd.h early.
* bfd-in2.h: Regenerate.
gas/
* config/tc-arm.c: Include cpu-arm.h.
ld/
* emultempl/armelf.em: Include elf32-arm.h.
* emultempl/pe.em: Move func defines later and include coff-arm.h.

5 years agotic6x bfd.h tidy
Alan Modra [Mon, 23 Sep 2019 00:35:43 +0000 (10:05 +0930)] 
tic6x bfd.h tidy

* bfd-in.h: Move tic6x function declaration..
* elf32-tic6x.h: ..to here.
* bfd-in2.h: Regenerate.

5 years agoaarch64 bfd.h tidy
Alan Modra [Mon, 23 Sep 2019 00:34:50 +0000 (10:04 +0930)] 
aarch64 bfd.h tidy

bfd/
* bfd-in.h: Move aarch64 declarations and defines..
* cpu-aarch64.h: ..to here, new file..
* elfxx-aarch64.h: ..and here.
* cpu-aarch64.c: Include cpu-aarch64.h.
* elfnn-aarch64.c: Likewise.
* bfd-in2.h: Regenerate.
ld/
* emultempl/aarch64elf.em: Include elfxx-aarch64.h.

5 years agotic54x bfd.h tidy
Alan Modra [Mon, 23 Sep 2019 00:33:37 +0000 (10:03 +0930)] 
tic54x bfd.h tidy

* bfd-in.h: Delete ticoff function declarations.
* coff-tic54x.c (bfd_ticoff_set_section_load_page),
(bfd_ticoff_get_section_load_page): Make static.
* bfd-in2.h: Regenerate.

5 years agoh8300 bfd.h tidy
Alan Modra [Mon, 23 Sep 2019 00:33:04 +0000 (10:03 +0930)] 
h8300 bfd.h tidy

* bfd-in.h: Move h8300 function declaration to..
* cpu-h8300.h: ..here, new file.
* cpu-h8300.c: Include cpu-h8300.h.
* elf32-h8300.c: Likewise.
* bfd-in2.h: Regenerate.

5 years agoia64 bfd.h tidy
Alan Modra [Mon, 23 Sep 2019 00:32:25 +0000 (10:02 +0930)] 
ia64 bfd.h tidy

bfd/
* bfd-in.h: Move ia64 function declarations..
* elfxx-ia64.h: ..to here.
* bfd-in2.h: Regenerate.
ld/
* emultempl/ia64elf.em: Include elfxx-ia64.h.

5 years agov850 bfd.h tidy
Alan Modra [Mon, 23 Sep 2019 00:31:31 +0000 (10:01 +0930)] 
v850 bfd.h tidy

bfd/
* bfd-in.h: Move v850 function declarations..
* elf32-v850.h: ..to here, new file.
* elf32-v850.c: Include elf32-v850.h.
* bfd-in2.h: Regenerate.
ld/
* emultempl/v850elf.em: Include elf32-v850.h.

5 years agomips bfd.h tidy
Alan Modra [Mon, 23 Sep 2019 00:30:21 +0000 (10:00 +0930)] 
mips bfd.h tidy

bfd/
* bfd-in.h: Move mips function declaration to..
* elfxx-mips.h: ..here.
* bfd-in2.h: Regenerate.
opcodes/
* mips-dis.c: Include elfxx-mips.h.  Move "elf-bfd.h" and
"elf/mips.h" earlier.

5 years agocsky bfd.h tidy
Alan Modra [Mon, 23 Sep 2019 00:28:42 +0000 (09:58 +0930)] 
csky bfd.h tidy

bfd/
* bfd-in.h: Move csky function declarations to..
* elf32-csky.h: ..here, new file.
* elf32-csky.c: Include elf32-csky.h.
* bfd-in2.h: Regenerate.
ld/
* emultempl/cskyelf.em: Include elf32-csky.h.

5 years agoAutomatic date update in version.in
GDB Administrator [Mon, 23 Sep 2019 00:00:25 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 years agoPR25018, readelf crash on 32bits
Alan Modra [Sun, 22 Sep 2019 23:23:07 +0000 (08:53 +0930)] 
PR25018, readelf crash on 32bits

Pointer comparisons after adding an offset just don't work to catch
overflow when the offset is a larger type than the pointer.

PR 25018
* dwarf.c (get_type_signedness): Delete ineffective pointer
comparison check.  Properly range check uvalue offset on
recursive call.
(read_and_display_attr_value): Range check uvalue offset before
calling get_type_signedness.

5 years agoWork around gcc10 FAIL: S-records with constructors
Alan Modra [Sat, 21 Sep 2019 08:43:52 +0000 (18:13 +0930)] 
Work around gcc10 FAIL: S-records with constructors

gcc10 on x86_64 and powerpc64le recognises that the loop in
Foo::operator= can be turned into a call to memmove, which then
results in an undefined symbol when linking.  Avoid that by making the
loop smaller.

* testsuite/ld-srec/sr3.cc (FOO_MSG_LEN): Set to 4.

5 years ago[gdb/testsuite] Allow some tests in gdb.base/restore.exp to be unsupported
Tom de Vries [Sun, 22 Sep 2019 04:14:29 +0000 (06:14 +0200)] 
[gdb/testsuite] Allow some tests in gdb.base/restore.exp to be unsupported

We currently run into:
...
248       n = callee1 (n + l5);
(gdb) PASS: gdb.base/restore.exp: caller5 calls callee1; return callee now
print l1
$51 = <optimized out>
(gdb) FAIL: gdb.base/restore.exp: caller5 calls callee1; return restored l1 \
  to 32492
...

The problem is that we try to access the value of l1 in function caller5, but
variable l1 has no DW_AT_location attribute.  Since l1 is declared using the
register keyword, it's valid for gcc to emit no DW_AT_location at -O0.

Change the FAIL into an UNSUPPORTED.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-09-22  Tom de Vries  <tdevries@suse.de>

* gdb.base/restore.exp: Allow register variables to be optimized out at
-O0.

5 years agogdb: fix formatting in solib-svr4.c
Simon Marchi [Sun, 22 Sep 2019 02:13:49 +0000 (22:13 -0400)] 
gdb: fix formatting in solib-svr4.c

gdb/ChangeLog:

* solib-svr4.c (svr4_iterate_over_objfiles_in_search_order): Fix
formatting.

5 years agogdb: make watchpoint::val_valid a bool
Simon Marchi [Sat, 21 Sep 2019 23:50:40 +0000 (19:50 -0400)] 
gdb: make watchpoint::val_valid a bool

gdb/ChangeLog:

* breakpoint.h (struct watchpoint) <val_valid>: Change type to
bool.
* breakpoint.c (update_watchpoint): Assign false instead of 0,
true instead of 1.
(breakpoint_init_inferior): Likewise.
(watchpoint_check): Likewise.
(watch_command_1): Likewise.
(invalidate_bp_value_on_memory_change): Likewise.

5 years agoAutomatic date update in version.in
GDB Administrator [Sun, 22 Sep 2019 00:01:11 +0000 (00:01 +0000)] 
Automatic date update in version.in

5 years agogdb: change "nonzero" to "true" in comments
Simon Marchi [Sat, 21 Sep 2019 23:45:12 +0000 (19:45 -0400)] 
gdb: change "nonzero" to "true" in comments

These int fields have been converted to bool, so their doc should say
"true" and not "nonzero".

gdb/ChangeLog:

* breakpoint.h (bp_location) <inserted, permanent, duplicate>:
Change "nonzero" to "true" in documentation.

5 years agoReplace solib_global_lookup with gdbarch_iterate_over_objfiles_in_search_order
Christian Biesinger [Thu, 1 Aug 2019 16:53:03 +0000 (11:53 -0500)] 
Replace solib_global_lookup with gdbarch_iterate_over_objfiles_in_search_order

All implementations of either function use it for the same purpose (except
Darwin, which is a no-op): to prefer a symbol in the current objfile over
symbols with the same name in other objfiles. There does not seem to be a
reason to have both mechanisms for that purpose.

gdb/ChangeLog:

2019-09-20  Christian Biesinger  <cbiesinger@google.com>

* solib-darwin.c (darwin_lookup_lib_symbol): Remove.
(_initialize_darwin_solib): Don't set
darwin_so_ops.lookup_lib_global_symbol.
* solib-svr4.c (set_solib_svr4_fetch_link_map_offsets): Call
set_gdbarch_iterate_over_objfiles_in_search_order.
(elf_lookup_lib_symbol): Rename to...
(svr4_iterate_over_objfiles_in_search_order): this, and update
to iterate semantics.
(_initialize_svr4_solib): Don't set lookup_lib_global_symbol.
* solib.c (solib_global_lookup): Remove.
* solist.h (struct target_so_ops): Remove lookup_lib_global_symbol.
(solib_global_lookup): Remove.
* symtab.c (lookup_global_or_static_symbol): Remove call to
solib_global_lookup.

5 years agotc-i386.c gcc10 warning fix
Alan Modra [Sat, 21 Sep 2019 01:29:50 +0000 (10:59 +0930)] 
tc-i386.c gcc10 warning fix

.../gas/config/tc-i386.c: In function ‘md_parse_option’:
.../gas/config/tc-i386.c:11441:9: error: implicit conversion from ‘enum <anonymous>’ to ‘enum <anonymous>’ [-Werror=enum-conversion]
11441 |  vexwig = evexw0;
      |         ^
.../gas/config/tc-i386.c:11443:9: error: implicit conversion from ‘enum <anonymous>’ to ‘enum <anonymous>’ [-Werror=enum-conversion]
11443 |  vexwig = evexw1;
      |         ^

* config/tc-i386.c (md_parse_option): Fix warning on vexwig assignment.

This page took 0.052862 seconds and 4 git commands to generate.