binutils-gdb.git
4 years agoMove read_offset_1 to leb.c
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Move read_offset_1 to leb.c

This moves read_offset_1 to leb.c, as it is a low-level data-reading
function.  It is also renamed to remove the "_1", because gdb can use
overloading now, and this is clearer.

2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (read_offset_1): Move to leb.c.
(read_abbrev_offset, read_offset, dwarf_decode_line_header)
(dwarf_decode_macro_bytes): Update.
* dwarf2/leb.c (read_offset): Rename; move from read.c.
* dwarf2/leb.h (read_offset): Declare.

Change-Id: I048140598acfa76eade2cc529ab7933d4b9ca0b3

4 years agoConvert dwarf2_section_size to a method
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Convert dwarf2_section_size to a method

This changes dwarf2_section_size to be a method on
dwarf2_section_info.

2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (dwarf2_section_size): Remove.
(error_check_comp_unit_head, dwarf2_symbol_mark_computed):
Update.
* dwarf2/section.h (struct dwarf2_section_info) <get_size>: New method.

Change-Id: I12928fee5c84350ce98883e329357b86888d639b

4 years agoUnify read_initial_length implementations
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Unify read_initial_length implementations

There are two implementations of read_initial_length in gdb.  This
merges them and moves the resulting function to leb.c.

2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (read_initial_length): Move to leb.c.
* dwarf2/leb.h (read_initial_length): Declare.
* dwarf2/leb.c (read_initial_length): Move from read.c.  Add
handle_nonstd parameter.
* dwarf2/frame.c (read_initial_length): Remove.
(decode_frame_entry_1): Update.

Change-Id: I34d37bad0f8a584bfa781432cba25e05e1bd5750

4 years agoAdd some methods to dwarf2_per_cu_data
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Add some methods to dwarf2_per_cu_data

This changes a few helper functions to be methods on
dwarf2_per_cu_data.

2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/loc.c (dwarf2_find_location_expression)
(dwarf_evaluate_loc_desc::get_tls_address)
(dwarf_evaluate_loc_desc::push_dwarf_reg_entry_value)
(rw_pieced_value, dwarf2_evaluate_loc_desc_full)
(dwarf2_locexpr_baton_eval, dwarf2_evaluate_property)
(dwarf2_compile_property_to_c)
(dwarf2_loc_desc_get_symbol_read_needs)
(dwarf2_compile_expr_to_ax, locexpr_describe_location)
(locexpr_tracepoint_var_ref, locexpr_generate_c_location)
(loclist_describe_location, loclist_tracepoint_var_ref)
(loclist_generate_c_location): Update.
* compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update.
* dwarf2/loc.h (dwarf2_per_cu_objfile, dwarf2_per_cu_addr_size)
(dwarf2_per_cu_ref_addr_size, dwarf2_per_cu_offset_size)
(dwarf2_per_cu_text_offset, dwarf2_version): Don't declare.
* dwarf2/read.c (dwarf2_per_cu_data::objfile)
(dwarf2_per_cu_data::addr_size)
(dwarf2_per_cu_data::ref_addr_size)
(dwarf2_per_cu_data::text_offset)
(dwarf2_per_cu_data::addr_type): Now methods.
(per_cu_header_read_in): Make per_cu "const".
(dwarf2_version): Remove.
(dwarf2_per_cu_data::int_type): Now a method.
(dwarf2_per_cu_data::_addr_sized_int_type): Likewise.
(set_die_type, read_array_type, read_subrange_index_type)
(read_tag_string_type, read_subrange_type): Update.
* dwarf2/read.h (struct dwarf2_per_cu_data) <addr_size,
offset_size, ref_addr_size, text_offset, addr_type, version,
objfile, int_type, addr_sized_int_type>: Declare methods.

Change-Id: I07a42fa26e00795352389fa7a0cc1c12997d26f7

4 years agoMove dwarf2_per_cu_data::imported_symtabs earlier
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Move dwarf2_per_cu_data::imported_symtabs earlier

This moves dwarf2_per_cu_data::imported_symtabs earlier, near where
the other data members are located.

2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/read.h (struct dwarf2_per_cu_data) <imported_symtabs>:
Move earlier.

Change-Id: I314ddaa6f67c53a848e513b3f6d42913bd957833

4 years agoMove DWARF line_header to new file
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Move DWARF line_header to new file

This moves the line_header class to a pair of new files, making
dwarf2/read.c somewhat smaller.

2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/read.h (dwarf_line_debug): Declare.
* Makefile.in (COMMON_SFILES): Add dwarf2/line-header.c.
* dwarf2/read.c: Move line_header code to new files.
(dwarf_line_debug): No longer static.
* dwarf2/line-header.c: New file.
* dwarf2/line-header.h: New file.

Change-Id: I8d9d8a2398b4e888e20cc5dd68d041c28b5a06e3

4 years agoChange line_table methods to return unique_xmalloc_ptr
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Change line_table methods to return unique_xmalloc_ptr

This changes the two new line_table methods to return
unique_xmalloc_ptr.  This removes a bit of manual memory management.

2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (struct line_header) <file_full_name,
file_file_name>: Return unique_xmalloc_ptr.
(line_header::file_file_name): Update.
(line_header::file_full_name): Update.
(dw2_get_file_names_reader): Update.
(macro_start_file): Update.

Change-Id: I9442dba43882fb26097d0770a291eea2b03913a4

4 years agoChange file_full_name and file_file_name methods
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Change file_full_name and file_file_name methods

This changes file_full_name and file_file_name methods to be methods
on line_header.  This seems more clear to me.

2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (struct line_header) <file_full_name,
file_file_name>: Declare methods.
(dw2_get_file_names_reader): Update.
(file_file_name): Now a method.
(file_full_name): Likewise.
(macro_start_file): Update.

Change-Id: I50d3e91665a9637c732e1e8d8e4263764c766d9c

4 years agoMove dwarf_always_disassemble to dwarf2/loc.c
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Move dwarf_always_disassemble to dwarf2/loc.c

dwarf_always_disassemble is only used in dwarf2/loc.c, so move the
definition and the command infrastructure to that file.

2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (dwarf_always_disassemble)
(show_dwarf_always_disassemble): Move to loc.c.
(_initialize_dwarf2_read): Move "always-disassemble" registration
to loc.c.
* dwarf2/read.h (dwarf_always_disassemble): Don't declare.
* dwarf2/loc.c (dwarf_always_disassemble): Move from read.c.  Now
static.
(show_dwarf_always_disassemble): Move from read.c.
(_initialize_dwarf2loc): Move always-disassemble from read.c.

Change-Id: I33fb88112e98e583c3f4919d20e4d100f2ea0124

4 years agoChange dwarf2_per_objfile::quick_file_names_table to htab_up
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Change dwarf2_per_objfile::quick_file_names_table to htab_up

This changes dwarf2_per_objfile::quick_file_names_table to be an
htab_up.  This just removes a bit of manual management.

2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (~dwarf2_per_objfile): Update.
(create_quick_file_names_table): Return htab_up.
(dw2_get_file_names_reader, dw2_forget_cached_source_info):
Update.
* dwarf2/read.h (struct dwarf2_per_objfile)
<quick_file_names_table>: Now htab_up.

Change-Id: I4ff2fce8b8af27f4bfe01a11b97a889edfd23151

4 years agoMinor simplification in abbrev_table::read
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Minor simplification in abbrev_table::read

abbrev_table::read increments cur_abbrev->num_attrs in the inner loop,
but there's no need to do this, as the information is already stored
in the temporary vector.

2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/abbrev.c (abbrev_table::read): Simplify.

Change-Id: I765f12850ffa1c6066e884bb22c94468d1abdba4

4 years agoUse htab_up in abbrev_table
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Use htab_up in abbrev_table

This changes abbrev_table to use an htab_up rather than an ad hoc,
bucket-based hash table.

2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/abbrev.c (abbrev_table): Move constructor from header.
Rewrite.
(abbrev_table::add_abbrev, abbrev_table::lookup_abbrev): Rewrite.
* dwarf2/abbrev.h (struct abbrev_info) <next>: Remove.
(abbrev_table::abbrev_table): No longer inline.
(ABBREV_HASH_SIZE): Remove.
(abbrev_table::m_abbrevs): Now an htab_up.

Change-Id: Icbaa8e49501f9c43218d6a81a7e8c4d3a77d65dc

4 years agoMinor cleanups in abbrev_table
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Minor cleanups in abbrev_table

This cleans up the DWARF abbrev_table API a bit, primarily by making
various methods and members private.

2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (read_cutu_die_from_dwo): Update.
(cutu_reader): Update.
(build_type_psymtabs_1): Update.
* dwarf2/abbrev.c (abbrev_table::read): Rename.
(abbrev_table::alloc_abbrev): Update.
* dwarf2/abbrev.h (abbrev_table_up): Move earlier.
(abbrev_table::read): New static method, renamed from
abbrev_table_read_table.
(abbrev_table::alloc_abbrev)
(abbrev_table::add_abbrev): Now private.
(abbrev_table::abbrev_table): Now private.
(abbrev_table::m_abbrev_obstack): Now private.  Rename.

Change-Id: I320dca83b799f672909ae66f73b7aca266adbaf9

4 years agoChange dwarf2_per_objfile::die_type_hash to htab_up
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Change dwarf2_per_objfile::die_type_hash to htab_up

This changes dwarf2_per_objfile::die_type_hash to be an htab_up,
moving its contents off the objfile obstack.

2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (set_die_type, get_die_type_at_offset): Update.
* dwarf2/read.h (struct dwarf2_per_objfile) <die_type_hash>: Now
htab_up.

Change-Id: Ic651f99ebf71bf7ad2dc2880192adacf7b60964a

4 years agoChange dwp_file to use htab_up
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Change dwp_file to use htab_up

This changes dwp_file to use htab_up for the loaded_cus and loaded_tus
members.  This lets us avoid allocating the contents of these hash
tables on the objfile obstack.

2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (struct dwp_file) <loaded_cus, loaded_tus>: Now
htab_up.
(lookup_dwo_unit_in_dwp): Update.
(allocate_dwp_loaded_cutus_table): Return htab_up.  Don't allocate
on obstack.

Change-Id: Id61209bf5c6c6faa0c067195af31fbcf26813a3a

4 years agoDon't allocate DWO file hash on obstack
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Don't allocate DWO file hash on obstack

This changes allocate_dwo_file_hash_table so that it does not use the
objfile obstack to store the contents of the hash table.

2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (allocate_dwo_file_hash_table): Don't allocate on
obstack.

Change-Id: Ic20a618acc7277e56aa18580c68f75c793bef97b

4 years agoChange dwarf2_per_objfile::line_header_hash to htab_up
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Change dwarf2_per_objfile::line_header_hash to htab_up

This changes dwarf2_per_objfile::line_header_hash to be an htab_up,
and changes it to use heap allocation.

2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (~dwarf2_per_objfile): Don't delete
line_header_hash.
(handle_DW_AT_stmt_list): Update.  Don't allocate on obstack.
* dwarf2/read.h (struct dwarf2_per_objfile) <line_header_hash>:
Change type to htab_up.

Change-Id: Icb148a270838c0f96f38fc4a28b5b77d067927b6

4 years agoChange dwarf2_per_objfile::type_unit_groups to htab_up
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Change dwarf2_per_objfile::type_unit_groups to htab_up

This changes dwarf2_per_objfile::type_unit_groups to be an htab_up,
again allowing us to move the memory used by the hash table from the
objfile obstack to the heap.

2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (allocate_type_unit_groups_table): Return
htab_up.  Don't allocate on obstack.
(get_type_unit_group, dwarf2_build_psymtabs_hard): Update.
* dwarf2/read.h (struct dwarf2_per_objfile) <type_unit_groups>:
Change type to htab_up.

Change-Id: Ia045df0ff3ec30aac813da5a9a2314a607ef7ec8

4 years agoChange dwarf2_per_objfile::signatured_types to be htab_up
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Change dwarf2_per_objfile::signatured_types to be htab_up

This changes dwarf2_per_objfile::signatured_types to be an htab_up.
This in turn lets us change it not to use the objfile obstack for
allocation; obstack allocation for hash tables is a bad practice
because it leads to excess memory use if the table is ever resized.

gdb/ChangeLog
2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/read.h (struct dwarf2_per_objfile) <signatured_types>:
Change type to htab_up.
* dwarf2/read.c (create_signatured_type_table_from_index)
(create_signatured_type_table_from_debug_names)
(create_all_type_units, add_type_unit)
(lookup_dwo_signatured_type, lookup_signatured_type)
(process_skeletonless_type_unit): Update.
(create_debug_type_hash_table, create_debug_types_hash_table):
Change type of types_htab.
(allocate_signatured_type_table, allocate_dwo_unit_table): Return
htab_up.  Don't allocate on obstack.
(create_cus_hash_table): Change type of cus_htab parameter.
(struct dwo_file) <cus, tus>: Now htab_up.
(lookup_dwo_signatured_type, lookup_dwo_cutu)
(process_dwo_file_for_skeletonless_type_units, lookup_dwo_cutu)
(queue_and_load_all_dwo_tus): Update.
* dwarf2/index-write.c (write_gdbindex): Update.
(write_debug_names): Update.

Change-Id: I290a209b96945fb5f415c82723b62830e9c4b467

4 years agoRemove DWARF queue-related globals
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Remove DWARF queue-related globals

This removes some queue-related globals from the DWARF reader, in
favor of a new member on dwarf2_per_objfile.  Globals must be avoided
in this code, because they prevent multi-threading the reader.

gdb/ChangeLog
2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/read.h (struct dwarf2_queue_item): Move from
dwarf2/read.c.  Remove "next" member.  Add constructor ntad
destructor.
(struct dwarf2_per_objfile) <queue>: New member.
* dwarf2/read.c (struct dwarf2_queue_item): Move to
dwarf2/read.h.
(dwarf2_queue, dwarf2_queue_tail): Remove.
(class dwarf2_queue_guard): Add parameter to constructor.  Use
DISABLE_COPY_AND_ASSIGN.
<m_per_objfile>: New member.
<~dwarf2_queue_guard>: Rewrite.
(dw2_do_instantiate_symtab, queue_comp_unit, process_queue):
Update.
(~dwarf2_queue_item): New.

Change-Id: Ied1f6ff3691352a66c4709b0b2cba0588f49f79a

4 years agoIntroduce die_info::has_children
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Introduce die_info::has_children

Many functions take a "has_children" parameter (either as an in- or
out-parameter).  However, it seems to me that it makes more sense to
have "has_children" be an attribute of a DIE.  Making this change
allows this parameter to be eliminated in many places.

gdb/ChangeLog
2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (struct die_info) <has_children>: New member.
(dw2_get_file_names_reader): Remove has_children.
(dw2_get_file_names): Update.
(read_cutu_die_from_dwo): Remove has_children.
(cutu_reader::init_tu_and_read_dwo_dies)
(cutu_reader::cutu_reader): Update.
(process_psymtab_comp_unit_reader, build_type_psymtabs_reader):
Remove has_children.
(build_type_psymtabs_1, process_skeletonless_type_unit)
(load_partial_comp_unit, load_full_comp_unit): Update.
(create_dwo_cu_reader): Remove has_children.
(create_cus_hash_table, read_die_and_children): Update.
(read_full_die_1,read_full_die): Remove has_children.
(read_signatured_type): Update.
(class cutu_reader) <has_children>: Remove.

Change-Id: I0d3d51ae9379554a66032648d51124bba07f87b4

4 years agoMove DWARF code to dwarf2/ subdirectory
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Move DWARF code to dwarf2/ subdirectory

This moves all the remaining DWARF code to the new dwarf2
subdirectory.  This is just a simple renaming, with updates to
includes as needed.

gdb/ChangeLog
2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/expr.c: Rename from dwarf2expr.c.
* dwarf2/expr.h: Rename from dwarf2expr.h.
* dwarf2/frame-tailcall.c: Rename from dwarf2-frame-tailcall.c.
* dwarf2/frame-tailcall.h: Rename from dwarf2-frame-tailcall.h.
* dwarf2/frame.c: Rename from dwarf2-frame.c.
* dwarf2/frame.h: Rename from dwarf2-frame.h.
* dwarf2/index-cache.c: Rename from dwarf-index-cache.c.
* dwarf2/index-cache.h: Rename from dwarf-index-cache.h.
* dwarf2/index-common.c: Rename from dwarf-index-common.c.
* dwarf2/index-common.h: Rename from dwarf-index-common.h.
* dwarf2/index-write.c: Rename from dwarf-index-write.c.
* dwarf2/index-write.h: Rename from dwarf-index-write.h.
* dwarf2/loc.c: Rename from dwarf2loc.c.
* dwarf2/loc.h: Rename from dwarf2loc.h.
* dwarf2/read.c: Rename from dwarf2read.c.
* dwarf2/read.h: Rename from dwarf2read.h.
* dwarf2/abbrev.c, aarch64-tdep.c, alpha-tdep.c,
amd64-darwin-tdep.c, arc-tdep.c, arm-tdep.c, bfin-tdep.c,
compile/compile-c-symbols.c, compile/compile-cplus-symbols.c,
compile/compile-loc2c.c, cris-tdep.c, csky-tdep.c, findvar.c,
gdbtypes.c, guile/scm-type.c, h8300-tdep.c, hppa-bsd-tdep.c,
hppa-linux-tdep.c, i386-darwin-tdep.c, i386-linux-tdep.c,
i386-tdep.c, iq2000-tdep.c, m32c-tdep.c, m68hc11-tdep.c,
m68k-tdep.c, microblaze-tdep.c, mips-tdep.c, mn10300-tdep.c,
msp430-tdep.c, nds32-tdep.c, nios2-tdep.c, or1k-tdep.c,
riscv-tdep.c, rl78-tdep.c, rs6000-tdep.c, rx-tdep.c, s12z-tdep.c,
s390-tdep.c, score-tdep.c, sh-tdep.c, sparc-linux-tdep.c,
sparc-tdep.c, sparc64-linux-tdep.c, sparc64-tdep.c, tic6x-tdep.c,
tilegx-tdep.c, v850-tdep.c, xstormy16-tdep.c, xtensa-tdep.c:
Update.
* Makefile.in (COMMON_SFILES): Update.
(HFILES_NO_SRCDIR): Update.

Change-Id: Ied9ce1436cd27ac4a4cffef10ec92e396f181928

4 years agoRemove die_reader_specs::comp_dir
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Remove die_reader_specs::comp_dir

die_reader_specs::comp_dir is assigned but never read; this patch
removes it.

gdb/ChangeLog
2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2read.c (struct die_reader_specs) <comp_dir>: Remove.
(init_cu_die_reader, read_cutu_die_from_dwo): Update.

Change-Id: I9818a2593197a6972cddec23cd2f3dd0ce28f580

4 years agoDon't declare die_info in dwarf2read.h
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Don't declare die_info in dwarf2read.h

There's no need to forward-declare struct die_info in dwarf2read.h.

gdb/ChangeLog
2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2read.h (struct die_info): Don't declare.

Change-Id: I0b8dbf99558b9547d418cfd8ef387a21f7dfa660

4 years agoRemove die_info_ptr typedef
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Remove die_info_ptr typedef

die_info_ptr is not used and so can be removed.

gdb/ChangeLog
2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2read.h (die_info_ptr): Remove typedef.

Change-Id: Ibd0a5ad55876dc96a35b658adc36348f01e48884

4 years agoChange attr_form_is_block to be a method
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Change attr_form_is_block to be a method

This changes attr_form_is_block to be a method.  This is done
separately because, unlike the other attribute functions,
attr_form_is_block had special handling for the case where the
argument was NULL.  This required auditing each call site; in most
cases, NULL was already ruled out, but in a few spots, an additional
check was needed.

gdb/ChangeLog
2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2read.c (read_call_site_scope)
(handle_data_member_location, dwarf2_add_member_fn)
(mark_common_block_symbol_computed, read_common_block)
(attr_to_dynamic_prop, partial_die_info::read)
(var_decode_location, dwarf2_fetch_die_loc_sect_off)
(dwarf2_symbol_mark_computed, set_die_type): Update.
* dwarf2/attribute.h (struct attribute) <form_is_block>: Declare
method.
(attr_form_is_block): Don't declare.
* dwarf2/attribute.c (attribute::form_is_block): Now a method.

Change-Id: Idfb290c61d738301ab991666f43e0b9cf577b2ae

4 years agoChange some attribute functions to be methods
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Change some attribute functions to be methods

This changes most of the attribute-related functions to be methods.
(attr_form_is_block changed in a subsequent patch.)

gdb/ChangeLog
2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2read.c (dwarf2_find_base_address, )
(read_call_site_scope, rust_containing_type)
(dwarf2_get_pc_bounds, dwarf2_record_block_ranges)
(handle_data_member_location, dwarf2_add_member_fn)
(get_alignment, read_structure_type, process_structure_scope)
(mark_common_block_symbol_computed, read_common_block)
(read_tag_string_type, attr_to_dynamic_prop, read_subrange_type)
(partial_die_info::read, read_attribute_value, new_symbol)
(lookup_die_type, dwarf2_get_ref_die_offset)
(dwarf2_get_attr_constant_value, follow_die_ref_or_sig)
(dwarf2_fetch_die_loc_sect_off, get_DW_AT_signature_type)
(dwarf2_symbol_mark_computed): Update.
* dwarf2/attribute.h (struct attribute) <value_as_address,
form_is_section_offset, form_is_constant, form_is_ref>: Declare
methods.
(value_as_address, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Don't declare.
* dwarf2/attribute.c (attribute::value_as_address)
(attribute::form_is_section_offset, attribute::form_is_constant)
(attribute::form_is_ref): Now methods.

Change-Id: I320dad13002c59b848dc86c39d5d7111c8a15bdc

4 years agoCreate dwarf2/attribute.[ch]
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Create dwarf2/attribute.[ch]

This moves the attribute-related code out of dwarf2read.c and into the
new files dwarf2/attribute.[ch].

gdb/ChangeLog
2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2read.c (struct attribute, DW_STRING)
(DW_STRING_IS_CANONICAL, DW_UNSND, DW_BLOCK, DW_SND, DW_ADDR)
(DW_SIGNATURE, struct dwarf_block, attr_value_as_address)
(attr_form_is_block, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Move.
* dwarf2/attribute.h: New file.
* dwarf2/attribute.c: New file, from dwarf2read.c.
* Makefile.in (COMMON_SFILES): Add dwarf2/attribute.c.

Change-Id: I1ea4c146256a1b9e38b66f1c605d782a14eeded7

4 years agoCreate dwarf2/abbrev.[ch]
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Create dwarf2/abbrev.[ch]

This moves the abbrev table code out of dwarf2read.c and into new
files dwarf2/abbrev.[ch].

gdb/ChangeLog
2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2read.c (abbrev_table_up, struct abbrev_info)
(struct attr_abbrev, ABBREV_HASH_SIZE, struct abbrev_table):
Move.
(read_cutu_die_from_dwo, build_type_psymtabs_1): Update.
(abbrev_table::alloc_abbrev, abbrev_table::add_abbrev)
(abbrev_table::lookup_abbrev, abbrev_table_read_table): Move to
abbrev.c.
* dwarf2/abbrev.h: New file.
* dwarf2/abbrev.c: New file, from dwarf2read.c.
* Makefile.in (COMMON_SFILES): Add dwarf2/abbrev.c.

Change-Id: I87911bc5297de4407587ca849fef8e8d19136c30

4 years agoChange section functions to be methods of dwarf2_section_info
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Change section functions to be methods of dwarf2_section_info

This changes various section-related functions to be methods on
dwarf2_section_info.  I think this clarifies the role of these
functions.  This also changes one such function to return bool.

gdb/ChangeLog
2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2read.c (dwarf2_section_buffer_overflow_complaint)
(dwarf2_section_size, dwarf2_get_section_info)
(create_signatured_type_table_from_debug_names)
(create_addrmap_from_aranges, read_debug_names_from_section)
(get_gdb_index_contents_from_section, read_comp_unit_head)
(error_check_comp_unit_head, read_abbrev_offset)
(create_debug_type_hash_table, init_cu_die_reader)
(read_cutu_die_from_dwo, dwarf2_build_psymtabs_hard)
(read_comp_units_from_section, create_cus_hash_table)
(create_dwp_hash_table, create_dwo_unit_in_dwp_v1)
(create_dwp_v2_section, dwarf2_rnglists_process)
(dwarf2_ranges_process, read_die_and_siblings, read_full_die)
(abbrev_table_read_table, read_indirect_string_at_offset_from)
(read_indirect_string_from_dwz, read_addr_index_1)
(read_str_index, dwarf_decode_line_header, skip_form_bytes)
(dwarf_decode_macro_bytes, dwarf_decode_macros)
(fill_in_loclist_baton): Update.
* dwarf2/section.h (struct dwarf2_section_info) <get_name,
get_containing_section, get_bfd_owner, get_bfd_section,
get_file_name, get_id, get_flags, empty, read>: Declare methods.
(dwarf2_read_section, get_section_name, get_section_file_name)
(get_containing_section, get_section_bfd_owner)
(get_section_bfd_section, get_section_name, get_section_file_name)
(get_section_id, get_section_flags, dwarf2_section_empty_p): Don't
declare.
* dwarf2/section.c (dwarf2_section_info::get_containing_section)
(dwarf2_section_info::get_bfd_owner)
(dwarf2_section_info::get_bfd_section)
(dwarf2_section_info::get_name)
(dwarf2_section_info::get_file_name, dwarf2_section_info::get_id)
(dwarf2_section_info::get_flags, dwarf2_section_info::empty)
(dwarf2_section_info::read): Now methods.
* dwarf-index-write.c (class debug_names): Update.

Change-Id: Ic849f182f57a18bad6b1c7c3b9368005d307758a

4 years agoCreate dwarf2/section.[ch]
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Create dwarf2/section.[ch]

This moves some section-handling code from dwarf2read.c into new
files, dwarf2/section.[ch].

gdb/ChangeLog
2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2read.h (struct dwarf2_section_info, dwarf2_read_section):
Move to dwarf2/section.h.
* dwarf2read.c (get_containing_section, get_section_bfd_owner)
(get_section_bfd_section, get_section_name)
(get_section_file_name, get_section_id, get_section_flags)
(dwarf2_section_empty_p, dwarf2_read_section): Moe to
dwarf2/section.c.
* dwarf2/section.h: New file.
* dwarf2/section.c: New file, from dwarf2read.c.
* Makefile.in (COMMON_SFILES): Add dwarf2/section.c.

Change-Id: I9f8498094cf99d9521e9481622ce8adbd453daf4

4 years agoCreate dwarf2/leb.[ch]
Tom Tromey [Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)]
Create dwarf2/leb.[ch]

This moves some scalar-unpacking code into a couple of new files,
dwarf2/leb.h and dwarf2/leb.c.

gdb/ChangeLog
2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2read.h (read_unsigned_leb128): Don't declare.
* dwarf2read.c (read_1_byte, read_1_signed_byte, read_2_bytes)
(read_2_signed_bytes, read_3_bytes, read_4_bytes)
(read_4_signed_bytes, read_8_bytes): Move to dwarf2/leb.h.
(read_unsigned_leb128, read_signed_leb128): Move to dwarf2/leb.c.
* dwarf2/leb.h: New file, from dwarf2read.c.
* dwarf2/leb.c: New file, from dwarf2read.c.
* dwarf2-frame.c (read_1_byte, read_4_bytes, read_8_bytes):
Remove.
* Makefile.in (CONFIG_SRC_SUBDIR): Add dwarf2.
(COMMON_SFILES): Add dwarf2/leb.c.

Change-Id: Idd19647686c8f959d226a95fdfca4db47c6e96d0

4 years agoDocument the GDB 9.1 release in gdb/ChangeLog
Joel Brobecker [Sat, 8 Feb 2020 13:02:16 +0000 (17:02 +0400)]
Document the GDB 9.1 release in gdb/ChangeLog

gdb/ChangeLog:

GDB 9.1 released.

4 years agoAutomatic date update in version.in
GDB Administrator [Sat, 8 Feb 2020 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoMake fputs_unfiltered use fputs_maybe_filtered
Iain Buclaw [Wed, 5 Feb 2020 11:45:13 +0000 (12:45 +0100)]
Make fputs_unfiltered use fputs_maybe_filtered

This patch redefines fputs_unfiltered in utils.c, with new behavior to
forward parameters to fputs_maybe_filtered.  This makes
fputs_unfiltered identical to fputs_filtered, except filtering is
disabled.

Some callers of fputs_unfiltered have been updated to use ui_file_puts
where they were using other ui_file_* functions anyway for IO.

This fixes the problem I saw with \032\032post-prompt annotation being
flushed to stdout in the wrong order.

2020-02-05  Iain Buclaw  <ibuclaw@gdcproject.org>

PR gdb/25190:
        * gdb/remote-sim.c (gdb_os_write_stderr): Update.
        * gdb/remote.c (remote_console_output): Update.
        * gdb/ui-file.c (fputs_unfiltered): Rename to...
        (ui_file_puts): ...this.
        * gdb/ui-file.h (ui_file_puts): Add declaration.
        * gdb/utils.c (emit_style_escape): Update.
        (flush_wrap_buffer): Update.
        (fputs_maybe_filtered): Update.
        (fputs_unfiltered): Add function.

Change-Id: I17ed5078f71208344f2f8ab634a6518b1af6e213

4 years agoMake gdb_flush also flush the wrap buffer
Iain Buclaw [Wed, 5 Feb 2020 11:25:09 +0000 (12:25 +0100)]
Make gdb_flush also flush the wrap buffer

This changes gdb_flush to also flush the internal wrap buffer.  A few
places needed to continue using the previous approach, so this also
introduces ui_file_flush for those.

2020-02-05  Iain Buclaw  <ibuclaw@gdcproject.org>

        * gdb/event-loop.c (gdb_wait_for_event): Update.
        * gdb/printcmd.c (printf_command): Update.
        * gdb/remote-fileio.c (remote_fileio_func_write): Update.
        * gdb/remote-sim.c (gdb_os_flush_stdout): Update.
        (gdb_os_flush_stderr): Update.
        * gdb/remote.c (remote_console_output): Update.
        * gdb/ui-file.c (gdb_flush): Rename to...
        (ui_file_flush): ...this.
        (stderr_file::write): Update.
        (stderr_file::puts): Update.
        * gdb/ui-file.h (gdb_flush): Rename to...
        (ui_file_flush): ...this.
        * gdb/utils.c (gdb_flush): Add function.
        * gdb/utils.h (gdb_flush): Add declaration.

Change-Id: I7ca143d30f03dc39f218f6e880eb9bca9e15af39

4 years agoRevert basenames_may_differ patch
Tom Tromey [Wed, 5 Feb 2020 09:53:44 +0000 (10:53 +0100)]
Revert basenames_may_differ patch

Commit a0c1ffedc regressed certain cases coming from Eclipse.
See PR breakpoints/24915.

gdb/ChangeLog
2020-02-07  Tom Tromey  <tromey@adacore.com>

PR breakpoints/24915:
* source.c (find_and_open_source): Do not check basenames_may_differ.

gdb/testsuite/ChangeLog
2020-02-07  Tom Tromey  <tromey@adacore.com>

PR breakpoints/24915:
* gdb.base/annotate-symlink.exp: Use setup_xfail.

Change-Id: Iadbf42f35eb40c95ad32b2108ae25d8f199998bd

4 years agounique.exp: Update contains_unique_symbol
H.J. Lu [Fri, 7 Feb 2020 20:01:58 +0000 (12:01 -0800)]
unique.exp: Update contains_unique_symbol

Since commit 9fc0b501af78b changed symbols from a/b to a_val/b_val,
contains_unique_symbol needs adjustment.

* testsuite/ld-unique/unique.exp (contains_unique_symbol): Updated.

4 years agoMove gdbserver to top level
Tom Tromey [Sun, 15 Dec 2019 14:37:06 +0000 (07:37 -0700)]
Move gdbserver to top level

This patch moves gdbserver to the top level.

This patch is as close to a pure move as possible -- gdbserver still
builds its own variant of gnulib and gdbsupport.  Changing this will
be done in a separate patch.

[v2] Note that, per Simon's review comment, this patch changes the
tree so that gdbserver is not built for or1k or score.  This makes
sense, because there is apparently not actually a gdbserver port here.

[v3] This version of the patch also splits out some configury into a
new file, gdbserver/configure.host, so that the top-level configure
script can simply rely on it in order to decide whether gdbserver
should be built.

[v4] This version adds documentation and removes some unnecessary
top-level dependencies.

[v5] Update docs to mention "make all-gdbserver" and change how
top-level configure decides whether to build gdbserver, switching to a
single, shared script.

Tested by the buildbot.

ChangeLog
2020-02-07  Tom Tromey  <tom@tromey.com>
    Pedro Alves  <palves@redhat.com>

* src-release.sh (GDB_SUPPORT_DIRS): Add gdbserver.
* gdbserver: New directory, moved from gdb/gdbserver.
* configure.ac (host_tools): Add gdbserver.
Only build gdbserver on certain systems.
* Makefile.in, configure: Rebuild.
* Makefile.def (host_modules, dependencies): Add gdbserver.
* MAINTAINERS: Add gdbserver.

gdb/ChangeLog
2020-02-07  Tom Tromey  <tom@tromey.com>

* README: Update gdbserver documentation.
* gdbserver: Move to top level.
* configure.tgt (build_gdbserver): Remove.
* configure.ac: Remove --enable-gdbserver.
* configure: Rebuild.
* Makefile.in (distclean): Don't mention gdbserver.

Change-Id: I826b7565b54604711dc7a11edea0499cd51ff39e

4 years agoUpdate release making notes.
Nick Clifton [Fri, 7 Feb 2020 15:13:23 +0000 (15:13 +0000)]
Update release making notes.

* README-how-to-make-a-release: Add note about updating the
  GAS/NEWS URL in the next release.

4 years agoAdd support for the GBZ80 and Z80N variants of the Z80 architecture, and add DWARF...
Sergey Belyashov [Fri, 7 Feb 2020 14:53:46 +0000 (14:53 +0000)]
Add support for the GBZ80 and Z80N variants of the Z80 architecture, and add DWARF debug info support to the Z80 assembler.

PR 25469
bfd * archures.c: Add GBZ80 and Z80N machine values.
* reloc.c: Add BFD_RELOC_Z80_16_BE.
* coff-z80.c: Add support for new reloc.
* coffcode.h: Add support for new machine values.
* cpu-z80.c: Add support for new machine names.
* elf32-z80.c: Add support for new reloc.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.

binutils* readelf.c (get_machine_flags): Add support for Z80N machine
number.

gas * config/tc-z80.c: Add -gbz80 command line option to generate code
for the GameBoy Z80.  Add support for generating DWARF.
* config/tc-z80.h: Add support for DWARF debug information
generation.
* doc/c-z80.texi: Document new command line option.
* testsuite/gas/z80/gbz80_all.d: New file.
* testsuite/gas/z80/gbz80_all.s: New file.
* testsuite/gas/z80/z80.exp: Run the new tests.
* testsuite/gas/z80/z80n_all.d: New file.
* testsuite/gas/z80/z80n_all.s: New file.
* testsuite/gas/z80/z80n_reloc.d: New file.

include * coff/internal.h (R_IMM16BE): Define.
* elf/z80.h (EF_Z80_MACH_Z80N): Define.
(R_Z80_16_BE): New reloc.

ld * emulparams/elf32z80.sh: Use z80 emulation.
* emultempl/z80.em: Make generic to both COFF and ELF Z80 emulations.
* emultempl/z80elf.em: Delete.
* testsuite/ld-elf/pr22450.d: Expect to fail for the Z80.
* testsuite/ld-elf/sec64k.exp: Fix Z80 assembly.
* testsuite/ld-unique/pr21529.s: Avoid register name conflict.
* testsuite/ld-unique/unique.s: Likewise.
* testsuite/ld-unique/unique_empty.s: Likewise.
* testsuite/ld-unique/unique_shared.s: Likewise.
* testsuite/ld-unique/unique.d: Updated expected output.
* testsuite/ld-z80/arch_z80n.d: New file.
* testsuite/ld-z80/comb_arch_z80_z80n.d: New file.
* testsuite/ld-z80/labels.s: Add more labels.
* testsuite/ld-z80/relocs.s: Add more reloc tests.
* testsuite/ld-z80/relocs_f_z80n.d: New file

opcodes * z80-dis.c: Add support for GBZ80 opcodes.

4 years agopr25022.d: Xfail more targets without ldelf_before_place_orphans
H.J. Lu [Fri, 7 Feb 2020 13:08:16 +0000 (05:08 -0800)]
pr25022.d: Xfail more targets without ldelf_before_place_orphans

PR ld/25022
* testsuite/ld-elf/pr25022.d: Xfail more targets which don't use
ldelf_before_place_orphans.

4 years agoStop the BFD library from complaining if a segment has no sections attached to it.
Nick Clifton [Fri, 7 Feb 2020 12:55:05 +0000 (12:55 +0000)]
Stop the BFD library from complaining if a segment has no sections attached to it.

PR 23932
* elf.c (rewrite_elf_program_header): Do not complain if no
sections are mapped to a segment.

4 years agoSilcence a compile time warning message building the binutils with gcc-10 on an s390...
Nick Clifton [Fri, 7 Feb 2020 12:49:42 +0000 (12:49 +0000)]
Silcence a compile time warning message building the binutils with gcc-10 on an s390 host.

* dwarf.c (display_debug_lines_decoded): Force a NUL termination
of the truncated file name.

4 years agoELF: Discard a section if any of its linked-to sections has been discarded
H.J. Lu [Fri, 7 Feb 2020 03:42:52 +0000 (19:42 -0800)]
ELF: Discard a section if any of its linked-to sections has been discarded

Add ldelf_before_place_orphans to call before lang_place_orphans to
discard a section if any of its linked-to sections has been discarded.

PR ld/25022
* emultempl/aix.em (ld_${EMULATION_NAME}_emulation): Add
before_place_orphans_default.
* emultempl/armcoff.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/beos.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/generic.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/linux.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/msp430.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/pe.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/pep.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/ticoff.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/vanilla.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/elf.em (ld_${EMULATION_NAME}_emulation): Use
ldelf_before_place_orphans.
* ldelf.c (ldelf_before_place_orphans): New.
* ldelf.h (ldelf_before_place_orphans): Likewise.
* ldemul.c (ldemul_before_place_orphans): Likewise.
(before_place_orphans_default): Likewise.
* ldemul.h (ldemul_before_place_orphans): Likewise.
(before_place_orphans_default): Likewise.
(ld_emulation_xfer_struct): Add before_place_orphans.
* ldlang.c (lang_process): Call ldemul_before_place_orphans
before lang_place_orphans.
* testsuite/ld-elf/pr25022.d: New file.
* testsuite/ld-elf/pr25022.s: Likewise.
* testsuite/ld-elf/pr25022.t: Likewise.

4 years agold: Issue an error for GC on __patchable_function_entries section
H.J. Lu [Fri, 7 Feb 2020 03:37:54 +0000 (19:37 -0800)]
ld: Issue an error for GC on __patchable_function_entries section

__patchable_function_entries section is generated by a compiler with
-fpatchable-function-entry=XX.  The assembly code looks like this:

---
.text
.globl _start
.type _start, %function
_start:
.section __patchable_function_entries,"aw",%progbits
.dc.a .LPFE1
.text
.LPFE1:
.byte 0
---

But --gc-sections will silently remove __patchable_function_entries
section and generate corrupt result.  This patch disallows garbage
collection on __patchable_function_entries section without linked-to
section.

bfd/

PR ld/25490
* elflink.c (_bfd_elf_gc_mark_extra_sections): Issue an error
for garbage collection on __patchable_function_entries section
without linked-to section.

ld/

PR ld/25490
* testsuite/ld-elf/pr25490-1.d: New file.
* testsuite/ld-elf/pr25490-1.s: Likewise.

4 years agoELF: Support the section flag 'o' in .section directive
H.J. Lu [Fri, 7 Feb 2020 02:04:58 +0000 (18:04 -0800)]
ELF: Support the section flag 'o' in .section directive

As shown in

https://sourceware.org/bugzilla/show_bug.cgi?id=25490

--gc-sections will silently remove __patchable_function_entries section
and generate corrupt result.  This patch adds the section flag 'o' to
.section directive:

.section __patchable_function_entries,"awo",@progbits,foo
.section __patchable_function_entries,"awoG",@progbits,foo,foo,comdat
.section __patchable_function_entries,"awo",@progbits,bar,unique,4
.section __patchable_function_entries,"awoG",@progbits,foo,foo,comdat,unique,1

which specifies the symbol name which the section references.  Assmebler
will set its elf_linked_to_section to a local section where the symbol
is defined.

Linker is updated to call mark_hook if gc_mark of any of its linked-to
sections is set after all sections, except for backend specific ones,
have been garbage collected.

bfd/

PR gas/25381
* bfd-in2.h: Regenerated.
* elflink.c (_bfd_elf_gc_mark_extra_sections): Call mark_hook
on section if gc_mark of any of its linked-to sections is set
and don't set gc_mark again.
* section.c (asection): Add linked_to_symbol_name to map_head
union.

gas/

PR gas/25381
* config/obj-elf.c (get_section): Also check
linked_to_symbol_name.
(obj_elf_change_section): Also set map_head.linked_to_symbol_name.
(obj_elf_parse_section_letters): Handle the 'o' flag.
(build_group_lists): Renamed to ...
(build_additional_section_info): This.  Set elf_linked_to_section
from map_head.linked_to_symbol_name.
(elf_adjust_symtab): Updated.
* config/obj-elf.h (elf_section_match): Add linked_to_symbol_name.
* doc/as.texi: Document the 'o' flag.
* testsuite/gas/elf/elf.exp: Run PR gas/25381 tests.
* testsuite/gas/elf/section18.d: New file.
* testsuite/gas/elf/section18.s: Likewise.
* testsuite/gas/elf/section19.d: Likewise.
* testsuite/gas/elf/section19.s: Likewise.
* testsuite/gas/elf/section20.d: Likewise.
* testsuite/gas/elf/section20.s: Likewise.
* testsuite/gas/elf/section21.d: Likewise.
* testsuite/gas/elf/section21.l: Likewise.
* testsuite/gas/elf/section21.s: Likewise.

ld/

PR ld/24526
PR ld/25021
PR ld/25490
* testsuite/ld-elf/elf.exp: Run PR ld/25490 tests.
* testsuite/ld-elf/pr24526.d: New file.
* testsuite/ld-elf/pr24526.s: Likewise.
* testsuite/ld-elf/pr25021.d: Likewise.
* testsuite/ld-elf/pr25021.s: Likewise.
* testsuite/ld-elf/pr25490-2-16.rd: Likewise.
* testsuite/ld-elf/pr25490-2-32.rd: Likewise.
* testsuite/ld-elf/pr25490-2-64.rd: Likewise.
* testsuite/ld-elf/pr25490-2.s: Likewise.
* testsuite/ld-elf/pr25490-3-16.rd: Likewise.
* testsuite/ld-elf/pr25490-3-32.rd: Likewise.
* testsuite/ld-elf/pr25490-3-64.rd: Likewise.
* testsuite/ld-elf/pr25490-3.s: Likewise.
* testsuite/ld-elf/pr25490-4-16.rd: Likewise.
* testsuite/ld-elf/pr25490-4-32.rd: Likewise.
* testsuite/ld-elf/pr25490-4-64.rd: Likewise.
* testsuite/ld-elf/pr25490-4.s: Likewise.
* testsuite/ld-elf/pr25490-5-16.rd: Likewise.
* testsuite/ld-elf/pr25490-5-32.rd: Likewise.
* testsuite/ld-elf/pr25490-5-64.rd: Likewise.
* testsuite/ld-elf/pr25490-5.s: Likewise.
* testsuite/ld-elf/pr25490-6-16.rd: Likewise.
* testsuite/ld-elf/pr25490-6-32.rd: Likewise.
* testsuite/ld-elf/pr25490-6-64.rd: Likewise.
* testsuite/ld-elf/pr25490-6.s: Likewise.

4 years agoAutomatic date update in version.in
GDB Administrator [Fri, 7 Feb 2020 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agosim/aarch64: Fix register ordering bug in blr (PR sim/25318)
Carlo Bramini [Thu, 6 Feb 2020 22:50:26 +0000 (22:50 +0000)]
sim/aarch64: Fix register ordering bug in blr (PR sim/25318)

A comment in the implementation of blr says:

  /* The pseudo code in the spec says we update LR before fetching.
     the value from the rn.  */

With 'rn' being the register holding the destination address.

This may have been true at one point, but the ISA manual now clearly
shows the destination register being read before the link register is
written.

This commit updates the implementation of blr to match.

sim/aarch64/ChangeLog:

PR sim/25318
* simulator.c (blr): Read destination register before calling
aarch64_save_LR.

Change-Id: Icb1c556064e3d9c807ac28440475caa205ab1064

4 years agogdb: Catch exceptions if the source file is not found
Shahab Vahedi [Thu, 6 Feb 2020 15:20:37 +0000 (16:20 +0100)]
gdb: Catch exceptions if the source file is not found

The source_cache::ensure method may throw an exception through
the invocation of source_cache::get_plain_source_lines. This
happens when the source file is not found. The expected behaviour
of "ensure" is only returning "true" or "false" according to the
documentation in the header file.

So far, if gdb is in source layout and a file is missing, you see
some outputs like below:

 ,---------------------------------------------.
 | test.c file is loaded in the source window. |
 |                                             |
 | int main()                                  |
 | ...                                         |
 |---------------------------------------------|
 | Remote debugging using :1234                |
 | __start () at /path/to/crt0.S:141           |
 | /path/to/crt0.S: No such file or directory. |
 | (gdb) p/x $pc                               |
 | $1 = 0x124                                  |
 | (gdb) n                                     |
 | /path/to/crt0.S: No such file or directory. |
 | (gdb) p/x $pc                               |
 | $2 = 0x128                                  |
 | (gdb) [pressing arrow-down key]             |
 | (gdb) terminate called after throwing an    |
 |       instance of 'gdb_exception_error'     |
 `---------------------------------------------'
Other issues have been encountered as well [1].

The patch from Pedro [2] which is about preventing exceptions
from crossing the "readline" mitigates the situation by not
causing gdb crash, but still there are lots of errors printed:

 ,---------------------------------------------.
 | test.c file is loaded in the source window. |
 |                                             |
 | int main()                                  |
 | ...                                         |
 |---------------------------------------------|
 | Remote debugging using :1234                |
 | __start () at /path/to/crt0.S:141           |
 | /path/to/crt0.S: No such file or directory. |
 | (gdb) [pressing arrow-down key]             |
 | /path/to/crt0.S: No such file or directory. |
 | (gdb) [pressing arrow-down key]             |
 | /path/to/crt0.S: No such file or directory. |
 | (gdb) [pressing arrow-up key]               |
 | /path/to/crt0.S: No such file or directory. |
 `---------------------------------------------'

With the changes of this patch, the behavior is like:
 ,---------------------------------------------.
 | initially, source window is empty because   |
 | crt0.S is not found and according to the    |
 | program counter that is the piece of code   |
 | being executed.                             |
 |                                             |
 | later, when we break at main (see commands  |
 | below), this window will be filled with the |
 | the contents of test.c file.                |
 |---------------------------------------------|
 | Remote debugging using :1234                |
 | __start () at /path/to/crt0.S:141           |
 | (gdb) p/x $pc                               |
 | $1 = 0x124                                  |
 | (gdb) n                                     |
 | (gdb) p/x $pc                               |
 | $2 = 0x128                                  |
 | (gdb) b main                                |
 | Breakpoint 1 at 0x334: file test.c, line 8. |
 | (gdb) cont                                  |
 | Continuing.                                 |
 | Breakpoint 1, main () at hello.c:8          |
 | (gdb) n                                     |
 | (gdb)                                       |
 `---------------------------------------------'

There is no crash and the error message is completely
gone. Maybe it is good practice that the error is
shown inside the source window.

I tested this change against gdb.base/list-missing-source.exp
and there was no regression.

[1]
It has also been observed in the past that the register
values are not transferred from qemu's gdb stub, see:
https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/issues/226

[2]
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=2f267673f0fdee9287e6d404ecd4f2d29da0d2f2

gdb/ChangeLog:

* source-cache.c (source_cache::ensure): Surround
get_plain_source_lines with a try/catch.
(source_cache::get_line_charpos): Get rid of try/catch
and only check for the return value of "ensure".
* tui/tui-source.c (tui_source_window::set_contents):
Simplify "nlines" calculation.

gdb/testsuite/ChangeLog:

* gdb.tui/tui-missing-src.exp: Add the "missing source
file" test for the TUI.

4 years agogdb/testsuite: Avoid leaking a port number into results summary
Andrew Burgess [Thu, 6 Feb 2020 16:37:10 +0000 (16:37 +0000)]
gdb/testsuite: Avoid leaking a port number into results summary

Give a test a real name in order to avoid including a port number in
the results summary file - which makes comparing test results between
runs hard.

gdb/testsuiteChangeLog:

* gdb.server/multi-ui-errors.exp: Give a test a real name to avoid
including a port number in the output.

Change-Id: I19334e176ac15aee2a9732a6060c58153d9fb793

4 years agogdb: Add myself as one of GDB maintainer
Shahab Vahedi [Thu, 6 Feb 2020 15:56:40 +0000 (16:56 +0100)]
gdb: Add myself as one of GDB maintainer

May this be the beginning of a great flow of patches.

2020-02-06  Shahab Vahedi  <shahab@synopsys.com>

* MAINTAINERS (Write After Approval): Add myself.

4 years ago[2.34] Mention x86 assembler options to align branches
H.J. Lu [Thu, 6 Feb 2020 15:50:16 +0000 (07:50 -0800)]
[2.34] Mention x86 assembler options to align branches

* NEWS: Mention x86 assembler options to align branches for
binutils 2.34.

4 years agocheck_gc_sections_available: Mark z80 as not supported
H.J. Lu [Thu, 6 Feb 2020 14:40:30 +0000 (06:40 -0800)]
check_gc_sections_available: Mark z80 as not supported

[hjl@gnu-cfl-2 tmpdir]$ ../ld-new -V --gc-sections pr22319.o
GNU ld (GNU Binutils) 2.34.50.20200206
  Supported emulations:
   elf32z80
../ld-new: warning: gc-sections option ignored
../ld-new: warning: cannot find entry symbol _start; defaulting to 0000000000000100
[hjl@gnu-cfl-2 tmpdir]$

* testsuite/lib/ld-lib.exp (check_gc_sections_available): Mark
z80 as not supported.

4 years agoV850/BFD: Fix uninitialized `insn[4]' with R_V850_LONGJUMP warning
Maciej W. Rozycki [Thu, 6 Feb 2020 13:38:31 +0000 (13:38 +0000)]
V850/BFD: Fix uninitialized `insn[4]' with R_V850_LONGJUMP warning

Correctly point at `insn[2]' rather than `insn[4]' in determining that
the third instruction from where an R_V850_LONGJUMP relocation points at
is not a recognized one, fixing a problem with commit 86aba9dbfa7e ("Add
linker relaxation to v850 toolchain") resulting in a build failure like:

.../bfd/elf32-v850.c: In function 'v850_elf_relax_section':
.../bfd/elf32-v850.c:3854:5: error: 'insn[4]' may be used uninitialized in this function [-Werror=maybe-uninitialized]
 3854 |     _bfd_error_handler
      |     ^~~~~~~~~~~~~~~~~~
 3855 |       /* xgettext:c-format */
      |       ~~~~~~~~~~~~~~~~~~~~~~~
 3856 |       (_("%pB: %#" PRIx64 ": warning: %s points to "
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 3857 |          "unrecognized insn %#x"),
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~
 3858 |        abfd,
      |        ~~~~~
 3859 |        (uint64_t) (irel->r_offset + no_match),
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 3860 |        "R_V850_LONGJUMP",
      |        ~~~~~~~~~~~~~~~~~~
 3861 |        insn[no_match]);
      |        ~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Makefile:1608: recipe for target 'elf32-v850.lo' failed
make[4]: *** [elf32-v850.lo] Error 1

with GCC 10.

bfd/
* elf32-v850.c (v850_elf_relax_section): Fix the index used for
reporting an unrecognized instruction with R_V850_LONGJUMP.

4 years agoFix attributation of previous delta
Nick Clifton [Thu, 6 Feb 2020 13:34:00 +0000 (13:34 +0000)]
Fix attributation of previous delta

4 years agoJump visualization: Handle the case where the disassembled bytes occupy two lines.
Thomas Troeger [Thu, 6 Feb 2020 13:17:19 +0000 (13:17 +0000)]
Jump visualization: Handle the case where the disassembled bytes occupy two lines.

* objdump.c (print_jump_visualisation): New function.
(disassemble_bytes): Call new function.

4 years agox86: Run unique tests only for ELF targets
H.J. Lu [Thu, 6 Feb 2020 12:44:39 +0000 (04:44 -0800)]
x86: Run unique tests only for ELF targets

* testsuite/gas/i386/i386.exp: Run unique and x86-64-unique
only for ELF targets.
* testsuite/gas/i386/unique.d: Don't xfail.
* testsuite/gas/i386/x86-64-unique.d: Likewise.

4 years agoEnable ld-ifunc tests for more targets
Alan Modra [Thu, 6 Feb 2020 00:53:43 +0000 (11:23 +1030)]
Enable ld-ifunc tests for more targets

Also fix some ix86 fails.

* testsuite/ld-ifunc/ifunc.exp: Enable for more targets, specifying
targets that don't support ifunc rather than ones that do.
(contains_irelative_reloc): Match R_PARISC_IPLT.
* testsuite/ld-ifunc/lib.c: Don't use .set in asm.
* testsuite/ld-ifunc/ifunc-23-x86.s,
* testsuite/ld-ifunc/ifunc-24-x86.s,
* testsuite/ld-ifunc/ifunc-25-x86.s,
* testsuite/ld-ifunc/ifunc-4-local-x86.s,
* testsuite/ld-ifunc/ifunc-4-x86.s: Define _main.
* testsuite/ld-ifunc/ifunc-10-i386.d,
* testsuite/ld-ifunc/ifunc-11-i386.d,
* testsuite/ld-ifunc/ifunc-12-i386.d,
* testsuite/ld-ifunc/ifunc-13-i386.d,
* testsuite/ld-ifunc/ifunc-14a-i386.d,
* testsuite/ld-ifunc/ifunc-14b-i386.d,
* testsuite/ld-ifunc/ifunc-14c-i386.d,
* testsuite/ld-ifunc/ifunc-14d-i386.d,
* testsuite/ld-ifunc/ifunc-14e-i386.d,
* testsuite/ld-ifunc/ifunc-14f-i386.d,
* testsuite/ld-ifunc/ifunc-15-i386.d,
* testsuite/ld-ifunc/ifunc-16-i386-now.d,
* testsuite/ld-ifunc/ifunc-16-i386.d,
* testsuite/ld-ifunc/ifunc-17a-i386.d,
* testsuite/ld-ifunc/ifunc-17b-i386.d,
* testsuite/ld-ifunc/ifunc-18a-i386.d,
* testsuite/ld-ifunc/ifunc-18b-i386.d,
* testsuite/ld-ifunc/ifunc-19a-i386.d,
* testsuite/ld-ifunc/ifunc-19b-i386.d,
* testsuite/ld-ifunc/ifunc-2-i386-now.d,
* testsuite/ld-ifunc/ifunc-2-i386.d,
* testsuite/ld-ifunc/ifunc-2-local-i386-now.d,
* testsuite/ld-ifunc/ifunc-2-local-i386.d,
* testsuite/ld-ifunc/ifunc-20-i386.d,
* testsuite/ld-ifunc/ifunc-21-i386.d,
* testsuite/ld-ifunc/ifunc-22-i386.d,
* testsuite/ld-ifunc/ifunc-26.d,
* testsuite/ld-ifunc/ifunc-5a-i386.d,
* testsuite/ld-ifunc/ifunc-5a-local-i386.d,
* testsuite/ld-ifunc/ifunc-5b-i386.d,
* testsuite/ld-ifunc/ifunc-5b-local-i386.d,
* testsuite/ld-ifunc/ifunc-5r-local-i386.d,
* testsuite/ld-ifunc/ifunc-6a-i386.d,
* testsuite/ld-ifunc/ifunc-6b-i386.d,
* testsuite/ld-ifunc/ifunc-7a-i386.d,
* testsuite/ld-ifunc/ifunc-7b-i386.d,
* testsuite/ld-ifunc/ifunc-8-i386.d,
* testsuite/ld-ifunc/ifunc-9-i386.d,
* testsuite/ld-ifunc/pr17154-i386-now.d,
* testsuite/ld-ifunc/pr17154-i386.d: xfail lynxos, nto, and solaris.

4 years agoxfail x86 gas unique test
Alan Modra [Thu, 6 Feb 2020 00:22:29 +0000 (10:52 +1030)]
xfail x86 gas unique test

* testsuite/gas/i386/unique.d: xfail for non-elf targets.
* testsuite/gas/i386/x86-64-unique.d: Likewise.

4 years agombind gas tests and supports_gnu_osabi testsuite infrastructure
Alan Modra [Wed, 5 Feb 2020 05:49:17 +0000 (16:19 +1030)]
mbind gas tests and supports_gnu_osabi testsuite infrastructure

With the addition of section16 tests we have multiple tests
advertising themselves as "mbind sections" and "mbind section
contents".  This patch fixes that, and fails on quite a few targets
that force an OSABI value.  It's a pain specifying all the relevant
arm targets on an xfail line, so I wrote supports_gnu_osabi.

binutils/
* testsuite/lib/binutils-common.exp (match_target): Accept '!' before
TCL procedure.
(supports_gnu_osabi): New procedure.
(is_generic): New, from ld-lib.exp.
(supports_gnu_unique): Use the above.
gas/
* testsuite/gas/elf/section12a.d: Use supports_gnu_osabi in
xfail, and rename test.
* testsuite/gas/elf/section12b.d: Likewise.
* testsuite/gas/elf/section16a.d: Likewise.
* testsuite/gas/elf/section16b.d: Likewise.
ld/
* testsuite/lib/ld-lib.exp (is_generic): Delete.
* testsuite/ld-unique/unique.exp: Exclude tic6x.

4 years agoi386-moss and i386-openbsd ld config
Alan Modra [Thu, 6 Feb 2020 00:38:37 +0000 (11:08 +1030)]
i386-moss and i386-openbsd ld config

i386-moss is an ELF target needing ldelf.c.  x86 openbsd wouldn't even
build, so I added entries to do the same as netbsd.  Quite likely this
isn't ideal but if the openbsd folk don't contribute their changes
this is what they get.

* configure.tgt (i[3-7]86-*-moss*): Don't clear targ_extra_ofiles.
(i[3-7]86-*-openbsd*, x86_64-*-openbsd*): Add.

4 years agoDisambiguate info_print_options
Ali Tamur [Sat, 25 Jan 2020 03:40:40 +0000 (19:40 -0800)]
Disambiguate info_print_options

struct info_print_options is defined in both symtab.c and stack.c, which is
an ODR violation. So, I am renaming info_print_options and related
structs/functions in symtab.c:

info_print_options                ==> info_vars_funcs_options
info_print_options_defs           ==> info_vars_funcs_options_defs
make_info_print_options_def_group ==> make_info_vars_funcs_options_def_group
info_print_command_completer      ==> info_vars_funcs_command_completer

gdb/ChangeLog:

* symtab.c (info_print_options): Rename to
info_vars_funcs_options.
(info_print_options_defs): Rename to
info_vars_funcs_options_defs.
(make_info_print_options_def_group): Rename to
make_info_vars_funcs_options_def_group.
(info_print_command_completer): Rename to
info_vars_funcs_command_completer.
(info_variables_command): Apply name changes.
(info_functions_command): Likewise.
(_initialize_symtab): Likewise.

4 years agoAutomatic date update in version.in
GDB Administrator [Thu, 6 Feb 2020 00:00:33 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoFix base class function call
Christian Biesinger [Wed, 5 Feb 2020 17:43:22 +0000 (11:43 -0600)]
Fix base class function call

This was a typo introduced in f6ac5f3d63e03a81c4ff3749aba234961cc9090e.

Found by looking through NetBSD's GDB patches:
https://github.com/NetBSD/pkgsrc-wip/blob/master/gdb-netbsd/patches/patch-gdb_sparc-nat.h

This patch can't be tested on Linux because Linux does not use the
sparc_target template.

gdb/ChangeLog:

2020-02-05  Christian Biesinger  <cbiesinger@google.com>

* sparc-nat.h (struct sparc_target) <xfer_partial>: Fix base class
function call.

Change-Id: I4fa88cbdc365efe89b84cc0619b60db38718d9ce

4 years agoFix header guard name in #endif comment
Christian Biesinger [Wed, 5 Feb 2020 17:33:42 +0000 (11:33 -0600)]
Fix header guard name in #endif comment

Makes the comment match the macro name in the #define/#ifdef.

gdb/ChangeLog:

2020-02-05  Christian Biesinger  <cbiesinger@google.com>

* ppc-nbsd-tdep.h: Fix macro name in #endif comment.

Change-Id: If7b2e49e65495b8eb9ed7b6c9a11277579a93a05

4 years agoRISC-V/Linux/native: Factor out target description determination
Maciej W. Rozycki [Wed, 5 Feb 2020 17:21:12 +0000 (17:21 +0000)]
RISC-V/Linux/native: Factor out target description determination

In preparation for RISC-V/Linux `gdbserver' support factor out parts of
native target description determination code that can be shared between
the programs.

gdb/
* nat/riscv-linux-tdesc.h: New file.
* nat/riscv-linux-tdesc.c: New file, taking code from...
* riscv-linux-nat.c (riscv_linux_nat_target::read_description):
... here.
* configure.nat <linux> <riscv*>: Add nat/riscv-linux-tdesc.o to
NATDEPFILES.

4 years agoAutomatic date update in version.in
GDB Administrator [Wed, 5 Feb 2020 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoRe: Support fusion for ELFv2 stubs
Alan Modra [Tue, 4 Feb 2020 20:42:48 +0000 (07:12 +1030)]
Re: Support fusion for ELFv2 stubs

git commit 397998fc32a3 changed the stubs but not the comments.

* elf64-ppc.c (ppc_stub_plt_branch): Match comment with reality.

4 years agogdb/fortran: Allow for using Flang in Fortran testing
Alok Kumar Sharma [Tue, 4 Feb 2020 17:17:20 +0000 (17:17 +0000)]
gdb/fortran: Allow for using Flang in Fortran testing

In lib/fortran.exp, in the helper function fortran_int4, there is
currently no support for the LLVM Fortran compiler, Flang.  As a
result we return the default pattern 'unknown' to match against all
4-byte integer types, which causes many tests to fail.

The same is true for all of the other helper functions related to
finding a suitable type pattern.

This commit adds support for Flang.  There should be no change when
testing with gfortran.

gdb/testsuite/ChangeLog:

* lib/fortran.exp (fortran_int4): Handle clang.
(fortran_int8): Likewise.
(fortran_real4): Likewise.
(fortran_real8): Likewise.
(fortran_complex4): Likewise.
(fortran_logical4): Likewise.
(fortran_character1): Likewise.

Change-Id: Ife0d9828f78361fbd992bf21af746042b017dafc

4 years agogdb/sim: Assert that the simulator ptid is not null_ptid
Andrew Burgess [Tue, 4 Feb 2020 09:07:16 +0000 (09:07 +0000)]
gdb/sim: Assert that the simulator ptid is not null_ptid

We assign the simulator inferior a fake ptid.  If this ptid is ever
set to null_ptid then we are going to run into problems - the
simulator ptid is what we return from gdbsim_target::wait, and this in
turn is used to look up the inferior data with a call to
find_inferior_pid, which asserts the pid is not 0 (which it is in
null_pid).

This commit adds an assert that the simulator's fake pid is not
null_ptid.  There should be no user visible changes after this commit.

gdb/ChangeLog:

* remote-sim.c (sim_inferior_data::sim_inferior_data): Assert that
we don't set the fake simulator ptid to the null_ptid.

Change-Id: I6e08effe70e70855aea13c9caf4fd6913d5af56d

4 years ago[gdb/testsuite] Add note to 'Race detection' entry in README
Tom de Vries [Tue, 4 Feb 2020 16:36:17 +0000 (17:36 +0100)]
[gdb/testsuite] Add note to 'Race detection' entry in README

Add note to 'Race detection' entry in README about the possibility that
check-read1 makes failing tests pass.

gdb/testsuite/ChangeLog:

2020-02-04  Tom de Vries  <tdevries@suse.de>

* README (Race detection): Add note.

Change-Id: I12ef2f0ec35abc5a0221585bf30e5f4f0616aa7c

4 years ago[gdb/testsuite] Make inferior_exited_re match a single line
Tom de Vries [Tue, 4 Feb 2020 16:30:05 +0000 (17:30 +0100)]
[gdb/testsuite] Make inferior_exited_re match a single line

The current inferior_exited_re regexp contains a '.*':
...
set inferior_exited_re "(?:\\\[Inferior \[0-9\]+ \\(.*\\) exited)"
...

This means that while matching a single line:
...
$ tclsh
% set re "(?:\\\[Inferior \[0-9\]+ \\(.*\\) exited)"
(?:\[Inferior [0-9]+ \(.*\) exited)
% set line "\[Inferior 1 (process 33) exited\]\n"
[Inferior 1 (process 33) exited]

% regexp $re $line
1
...
it also matches more than one line:
...
$ tclsh
% set re "(?:\\\[Inferior \[0-9\]+ \\(.*\\) exited)"
(?:\[Inferior [0-9]+ \(.*\) exited)
% set line "\[Inferior 1 (process 33) exited\]\n\[Inferior 2 (process 44) exited\]\n"
[Inferior 1 (process 33) exited]
[Inferior 2 (process 44) exited]

% regexp $re $line
1
...

Fix this by using "\[^\n\r\]*" instead of ".*".

Build and reg-tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-02-04  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (inferior_exited_re): Use "\[^\n\r\]*" instead of ".*".

Change-Id: Id7b1dcecd8c7fda3d1ab34b4fa1364d301748333

4 years agoMinor fix for R_PPC_VLE_ADDR20
Alan Modra [Tue, 4 Feb 2020 11:04:45 +0000 (21:34 +1030)]
Minor fix for R_PPC_VLE_ADDR20

It is incorrect to "continue" in the ppc_elf_relocate_section reloc
processing loop except when editing or deleting relocs.  The normal
loop processing arranges to write the relocs if shuffling them over a
deleted entry.  Deleting only happens for debug sections currently and
those sections won't contain R_PPC_VLE_ADDR20 relocs, so this patch
doesn't fix a bug that would trigger with any normal object file.

* elf32-ppc.c (ppc_elf_relocate_section): After applying
R_PPC_VLE_ADDR20, goto copy_reloc.

4 years agoMissing objdump dependency od-elf32_avr
Alan Modra [Tue, 4 Feb 2020 05:44:55 +0000 (16:14 +1030)]
Missing objdump dependency od-elf32_avr

* Makefile.am (CFILES): Add od-elf32_avr.c.
* Makefile.in: Regenerate.
* po/POTFILES.in: Regenerate.

4 years ago[gdb/testsuite] Use non-capturing parentheses for inferior_exited_re
Tom de Vries [Tue, 4 Feb 2020 08:53:50 +0000 (09:53 +0100)]
[gdb/testsuite] Use non-capturing parentheses for inferior_exited_re

The inferior_exited_re regexp uses capturing parentheses by default:
...
set inferior_exited_re "(\\\[Inferior \[0-9\]+ \\(.*\\) exited)"
...

The parentheses are there to be able to use the expression as an atom, f.i.,
to have '+' apply to the whole regexp in "${inferior_exited_re}+".

But the capturing is not necessary, and it can be confusing because it's not
obvious in a regexp using "$inferior_exited_re (bla|bli)" that the first
captured expression is in $inferior_exited_re.

Replace by non-capturing parentheses.  If we still want to capture the
expression, we can simply (and more clearly) use "($inferior_exited_re)".

Build and reg-tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-02-04  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (inferior_exited_re): Use non-capturing parentheses.

Change-Id: I7640c6129b1ada617424d6a63730d4b119c58ef3

4 years agoChange ints to bools around thread_info executing/resumed
Simon Marchi [Tue, 4 Feb 2020 04:02:28 +0000 (23:02 -0500)]
Change ints to bools around thread_info executing/resumed

Switch thread_info::resumed to bool (thread_info::executing already is a bool),
and try to change everything more or less related to that to consistently use
true/false instead of 1/0.

gdb/ChangeLog:

* fork-child.c (gdb_startup_inferior): Use bool instead of int.
* gdbthread.h (class thread_info) <resumed>: Likewise.
* infrun.c (resume_1): Likewise.
(proceed): Likewise.
(infrun_thread_stop_requested): Likewise.
(stop_all_threads): Likewise.
(handle_inferior_event): Likewise.
(restart_threads): Likewise.
(finish_step_over): Likewise.
(keep_going_stepped_thread): Likewise.
* linux-nat.c (attach_proc_task_lwp_callback): Likewise.
(linux_handle_extended_wait): Likewise.
* record-btrace.c (get_thread_current_frame_id): Likewise.
* record-full.c (record_full_wait_1): Likewise.
* remote.c (remote_target::process_initial_stop_replies): Likewise.
* target.c (target_resume): Likewise.
* thread.c (set_running_thread): Likewise.

4 years agoubsan: d30v: negation of -2147483648
Alan Modra [Mon, 3 Feb 2020 22:00:22 +0000 (08:30 +1030)]
ubsan: d30v: negation of -2147483648

include/
* opcode/d30v.h (struct pd_reg): Make value field unsigned.
opcodes/
* d30v-dis.c (print_insn): Make "val" and "opnum" unsigned.

4 years agogdb: fix powerpc disassembly tests
Rogerio Alves [Mon, 3 Feb 2020 20:55:03 +0000 (17:55 -0300)]
gdb: fix powerpc disassembly tests

This patch fixes test failures power8 and power9 caused by changes on
opcodes:

The dissasembler does not emit whitespace for instructions
anymore (c2b1c2754526acff8aae2fe8f5a56c2dd11d0b7f)

The dissasembler generates extended mnemonics for some instructions
instead (aae9718e4d4e8d01dcee22684e82b000203d3e52)

The ldmx instruction was removed. This instruction was never
implemented (6fbc939cfdbdf02f205c20925583738b0f835e62)

gdb/testsuite/ChangeLog:
2020-02-03  Rogerio A. Cardoso  <rcardoso@linux.ibm.com>

* gdb.arch/powerpc-power8.exp: Delete trailing whitespace of
tbegin., tend. instructions. Replace bctar-, bctar+, bctarl-,
bctarl+ extended mnemonics when avaliable by bgttar, bnstarl,
blttar, bnetarl.
* gdb.arch/powerpc-power8.s: Fix comments. Fix instructions
binary for blttar, bnetarl.
* gdb.arch/powerpc-power9.exp: Delete trailing whitespace of
wait instruction. Delete ldmx test.
* gdb.arch/powerpc-power9.s: Delete ldmx instruction.

4 years agoFixed gdb to print arrays with very high indexes
Alok Kumar Sharma [Tue, 4 Feb 2020 01:24:34 +0000 (20:24 -0500)]
Fixed gdb to print arrays with very high indexes

In the function f77_print_array_1, the variable 'i' which holds the
index is of datatype 'int', while bounds are of datatype LONGEST. Due to
size of int being smaller than LONGEST, the variable 'i' stores
incorrect values for high indexes (higher than max limit of int).  Due
to this issue in sources, two abnormal behaviors are seen while printing
arrays with high indexes (please check array-bounds-high.f90) For high
indexes with negative sign, gdb prints empty array even if the array has
elements.

    (gdb) p arr
    $1 = ()

For high indexes with positive sign, gdb crashes.  We have now changed
the datatype of 'i' to LONGEST which is same as datatype of bounds.

gdb/ChangeLog:

* f-valprint.c (f77_print_array_1): Changed datatype of index
variable to LONGEST from int to enable it to contain bound
values correctly.

gdb/testsuite/ChangeLog:

* gdb.fortran/array-bounds-high.exp: New file.
* gdb.fortran/array-bounds-high.f90: New file.

Change-Id: Ie2dce9380a249e634e2684b9c90f225e104369b7

4 years agoAutomatic date update in version.in
GDB Administrator [Tue, 4 Feb 2020 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoreadelf: add missing newlines to error messages
Andreas Schwab [Sun, 2 Feb 2020 09:15:22 +0000 (10:15 +0100)]
readelf: add missing newlines to error messages

* readelf.c (dump_relocations, dump_relocations)
(decode_arm_unwind_bytecode, process_dynamic_section)
(get_symbol_visibility, get_alpha_symbol_other): Add newline to
error message.

4 years agoRISC-V/Linux/native: Determine FLEN dynamically
Maciej W. Rozycki [Mon, 3 Feb 2020 12:07:02 +0000 (12:07 +0000)]
RISC-V/Linux/native: Determine FLEN dynamically

Fix RISC-V native Linux support to handle a 64-bit FPU (FLEN == 64) with
both RV32 and RV64 systems, which is a part of the current Linux ABI for
hard-float systems, rather than assuming that (FLEN == XLEN) in target
description determination and that (FLEN == 64) in register access.

We can do better however and not rely on any particular value of FLEN
and probe for it dynamically, by observing that the PTRACE_GETREGSET
ptrace(2) call will only accept an exact regset size, and that will
reflect FLEN.  Therefore iterate over the call in target description
determination with a geometrically increasing regset size until a match
is marked by a successful ptrace(2) call completion or we run beyond the
maximum size we can support.

Update register accessors accordingly, using FLEN determined to size the
buffer used for NT_PRSTATUS requests and then to exchange data with the
regcache.

Also handle a glibc bug where ELF_NFPREG is defined in terms of NFPREG,
however NFPREG is nowhere defined.

gdb/
* riscv-linux-nat.c [!NFPREG] (NFPREG): New macro.
(supply_fpregset_regnum, fill_fpregset): Handle regset buffer
offsets according to FLEN determined.
(riscv_linux_nat_target::read_description): Determine FLEN
dynamically.
(riscv_linux_nat_target::fetch_registers): Size regset buffer
according to FLEN determined.
(riscv_linux_nat_target::store_registers): Likewise.

4 years agoFix compilation error with musl in gdb/testsuite/gdb.base/fileio.c
Lukas Durfina [Mon, 3 Feb 2020 10:36:17 +0000 (14:36 +0400)]
Fix compilation error with musl in gdb/testsuite/gdb.base/fileio.c

Musl is giving warnings about these includes in this way:
warning: #warning redirecting incorrect #include <sys/errno.h> to <errno.h>
warning: #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h>

gdb/testsuite/Changelog:

* gdb.base/fileio.c: Remove #include of <sys/errno.h>.
Replace #include of <sys/fcntl.h> by <fcntl.h>.

4 years agobinutils: drop redundant 'program_name' definition (-fno-common)
Sergei Trofimovich [Sat, 1 Feb 2020 23:16:11 +0000 (23:16 +0000)]
binutils: drop redundant 'program_name' definition (-fno-common)

* coffdump.c (program_name): Drop redundant definition.
* srconv.c (program_name): Likewise
* sysdump.c (program_name): Likewise

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
4 years agoubsan: m32c: left shift of negative value
Alan Modra [Mon, 3 Feb 2020 00:56:30 +0000 (11:26 +1030)]
ubsan: m32c: left shift of negative value

cpu/
* m32c.cpu (f-dsp-64-s16): Mask before shifting signed value.
opcodes/
* m32c-ibld.c: Regenerate.

4 years agosection.c: Fix typo in comments (withe -> with)
H.J. Lu [Mon, 3 Feb 2020 01:14:12 +0000 (17:14 -0800)]
section.c: Fix typo in comments (withe -> with)

* bfd-in2.h: Regenerated.
* section.c (SEC_ASSEMBLER_SECTION_ID): Fix a typo in comments.

4 years agoELF: Add support for unique section ID to assembler
H.J. Lu [Mon, 3 Feb 2020 01:07:51 +0000 (17:07 -0800)]
ELF: Add support for unique section ID to assembler

Clang's integrated assembler supports multiple section with the same
name:

.section .text,"ax",@progbits,unique,1
nop
.section .text,"ax",@progbits,unique,2
nop

"unique,N" assigns the number, N, as the section ID, to a section.  The
valid values of the section ID are between 0 and 4294967295.  It can be
used to distinguish different sections with the same section name.

This is useful with -fno-unique-section-names -ffunction-sections.
-ffunction-sections by default generates .text.foo, .text.bar, etc.
Using the same string can save lots of space in .strtab.

This patch adds section_id to bfd_section and reuses the linker
internal bit in BFD section flags, SEC_LINKER_CREATED, for assmebler
internal use to mark valid section_id.  It also updates objdump to
compare section pointers if 2 sections comes from the same file since
2 different sections can have the same section name.

bfd/

PR gas/25380
* bfd-in2.h: Regenerated.
* ecoff.c (bfd_debug_section): Add section_id.
* section.c (bfd_section): Add section_id.
(SEC_ASSEMBLER_SECTION_ID): New.
(BFD_FAKE_SECTION): Add section_id.

binutils/

PR gas/25380
* objdump.c (sym_ok): Return FALSE if 2 sections are in the
same file with different section pointers.

gas/

PR gas/25380
* config/obj-elf.c (section_match): Removed.
(get_section): Also match SEC_ASSEMBLER_SECTION_ID and
section_id.
(obj_elf_change_section): Replace info and group_name arguments
with match_p.  Also update the section ID and flags from match_p.
(obj_elf_section): Handle "unique,N".  Update call to
obj_elf_change_section.
* config/obj-elf.h (elf_section_match): New.
(obj_elf_change_section): Updated.
* config/tc-arm.c (start_unwind_section): Update call to
obj_elf_change_section.
* config/tc-ia64.c (obj_elf_vms_common): Likewise.
* config/tc-microblaze.c (microblaze_s_data): Likewise.
(microblaze_s_sdata): Likewise.
(microblaze_s_rdata): Likewise.
(microblaze_s_bss): Likewise.
* config/tc-mips.c (s_change_section): Likewise.
* config/tc-msp430.c (msp430_profiler): Likewise.
* config/tc-rx.c (parse_rx_section): Likewise.
* config/tc-tic6x.c (tic6x_start_unwind_section): Likewise.
* doc/as.texi: Document "unique,N" in .section directive.
* testsuite/gas/elf/elf.exp: Run "unique,N" tests.
* testsuite/gas/elf/section15.d: New file.
* testsuite/gas/elf/section15.s: Likewise.
* testsuite/gas/elf/section16.s: Likewise.
* testsuite/gas/elf/section16a.d: Likewise.
* testsuite/gas/elf/section16b.d: Likewise.
* testsuite/gas/elf/section17.d: Likewise.
* testsuite/gas/elf/section17.l: Likewise.
* testsuite/gas/elf/section17.s: Likewise.
* testsuite/gas/i386/unique.d: Likewise.
* testsuite/gas/i386/unique.s: Likewise.
* testsuite/gas/i386/x86-64-unique.d: Likewise.
* testsuite/gas/i386/i386.exp: Run unique and x86-64-unique.

ld/

PR gas/25380
* testsuite/ld-i386/pr22001-1c.S: Use "unique,N" in .section
directives.
* testsuite/ld-i386/tls-gd1.S: Likewise.
* testsuite/ld-x86-64/pr21481b.S: Likewise.

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 3 Feb 2020 00:00:49 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoelf/section13.s: Replace @nobits with %nobits
H.J. Lu [Sun, 2 Feb 2020 16:20:18 +0000 (08:20 -0800)]
elf/section13.s: Replace @nobits with %nobits

* testsuite/gas/elf/section13.s: Replace @nobits with %nobits.

4 years agomoxie: don't force big-endian mode
Gitea [Sun, 2 Feb 2020 01:59:19 +0000 (20:59 -0500)]
moxie: don't force big-endian mode

4 years agoAutomatic date update in version.in
GDB Administrator [Sun, 2 Feb 2020 00:01:01 +0000 (00:01 +0000)]
Automatic date update in version.in

4 years agoUpdate release making documentation
Nick Clifton [Sat, 1 Feb 2020 13:14:16 +0000 (13:14 +0000)]
Update release making documentation

4 years agoMove pending obsolete targets onto the definitely obsolete list
Nick Clifton [Sat, 1 Feb 2020 13:13:14 +0000 (13:13 +0000)]
Move pending obsolete targets onto the definitely obsolete list

4 years agoubsan: frv: left shift of negative value
Alan Modra [Sat, 1 Feb 2020 02:38:43 +0000 (13:08 +1030)]
ubsan: frv: left shift of negative value

More non-bugs flagged by ubsan, unless you happen to be compiling for
a 1's complement host.

cpu/
* frv.cpu (f-u12): Multiply rather than left shift signed values.
(f-label16, f-label24): Likewise.
opcodes/
* frv-ibld.c: Regenerate.

4 years agogdb: Do not print empty-group regs when printing general ones
Shahab Vahedi [Fri, 31 Jan 2020 22:10:11 +0000 (22:10 +0000)]
gdb: Do not print empty-group regs when printing general ones

When the command "info registers" (same as "info registers general"),
is issued, _all_ the registers from a tdesc XML are printed. This
includes the registers with empty register groups (set as "") which
are supposed to be only printed by "info registers all" (or "info
all-registers").

This bug got introduced after all the overhauls that the
tdesc_register_in_reggroup_p() went through. You can see that the
logic of tdesc_register_in_reggroup_p() did NOT remain the same after
all those changes:

  git difftool c9c895b9666..HEAD -- gdb/target-descriptions.c

With the current implementation, when the reg->group is an empty
string, this function returns -1, while in the working revision
(c9c895b9666), it returned 0. This patch makes sure that the 0 is
returned again.

The old implementation of tdesc_register_in_reggroup_p() returned
-1 when "reggroup" was set to "all_reggroups" at line 4 below:

1  tdesc_register_reggroup_p (...)
2  {
3   ...
4   ret = tdesc_register_in_reggroup_p (gdbarch, regno, reggroup);
5   if (ret != -1)
6     return ret;
7
8   return default_register_reggroup_p (gdbarch, regno, reggroup);
9  }

As a result, the execution continued at line 8 and the
default_register_reggroup_p(..., reggroup=all_reggroups) would
return 1. However, with the current implementation of
tdesc_register_in_reggroup_p() that allows checking against any
arbitrary group name, it returns 0 when comparing the "reg->group"
against the string "all" which is the group name for "all_reggroups".
I have added a special check to cover this case and
"info all-registers" works as expected.

gdb/ChangeLog:

* target-descriptions.c (tdesc_register_in_reggroup_p): Return 0
when reg->group is empty and reggroup is not.

Change-Id: I9eaf9d7fb36410ed5684ae652fe4756b1b2e61a3

4 years agoAutomatic date update in version.in
GDB Administrator [Sat, 1 Feb 2020 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years ago[gdb/testsuite] Fix typo in gdb.server/server-kill-python.exp
Tom de Vries [Fri, 31 Jan 2020 23:05:42 +0000 (00:05 +0100)]
[gdb/testsuite] Fix typo in gdb.server/server-kill-python.exp

Fix typo '$gdb_tst_name' -> '$gdb_test_name'.

gdb/testsuite/ChangeLog:

2020-02-01  Tom de Vries  <tdevries@suse.de>

* gdb.server/server-kill-python.exp: Fix $gdb_tst_name typo.

Change-Id: Iad050dab0e8aad2f2692e54e398021558250f1ac

4 years agonios2: Add BFD support for GOT-relative DW_EH_PE_datarel encodings
Sandra Loosemore [Fri, 31 Jan 2020 18:34:42 +0000 (10:34 -0800)]
nios2: Add BFD support for GOT-relative DW_EH_PE_datarel encodings

There's already existing logic to handle this on other targets, so
this patch just makes nios2 use it.

2020-01-31  Sandra Loosemore  <sandra@codesourcery.com>

bfd/
* elf-eh-frame.c (_bfd_elf_write_section_eh_frame): DW_EH_PE_datarel
encodings are relative to the GOT on nios2, too.

4 years agonios2: recognize %gotoff relocation in assembler
Sandra Loosemore [Fri, 31 Jan 2020 18:32:48 +0000 (10:32 -0800)]
nios2: recognize %gotoff relocation in assembler

The nios2 ABI documentation lists %gotoff as assembler syntax for the
R_NIOS2_GOTOFF relocation, used to represent a 32-bit GOT-relative offset
in data sections.  This was previously unimplemented in GAS.

2020-01-31  Sandra Loosemore  <sandra@codesourcery.com>

gas/
* config/tc-nios2.c (nios2_cons): Handle %gotoff as well as
%tls_ldo.