Commit Graph

95014 Commits

Author SHA1 Message Date
Tom Tromey c486b6106a Pass the correct argument to the observer in reread_symbols
This is actually a patch I found via another route.  Joel had asked me
to write a test, but I still have not found the time to do this.
Meanwhile, -Wunused-variable also found this error.

gdb/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* symfile.c (reread_symbols): Notify iter, not objfile.
2018-07-22 13:20:05 -06:00
Tom Tromey 494f80a932 Fix ravenscar-thread.c to use arch_ops
The change to turn target ops into methods accidentally introduced a
bug in ravenscar-thread.c, changing some calls that were using
"arch_ops" to use the target beneath.

This patch changes ravenscar-thread.c to use these variables where
appropriate.

gdb/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* ravenscar-thread.c (ravenscar_thread_target::store_registers):
	Use arch_ops.
	(ravenscar_thread_target::prepare_to_store): Likewise.
2018-07-22 13:20:04 -06:00
Tom Tromey c51f6a54c2 Call value_fetch_lazy when needed in pretty-printers
This removes some unused variables, and replaces the calls to
value_contents_for_printing with a call to value_fetch_lazy, when
needed.

gdb/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* python/py-prettyprint.c (gdbpy_apply_val_pretty_printer): Remove
	unused variable.  Call value_fetch_lazy when needed.
	* guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer):
	Remove unused variable.  Call value_fetch_lazy when needed.
2018-07-22 13:20:04 -06:00
Tom Tromey 374fd1fd7b Remove declarations from m32c-tdep.c
This removes some unused declarations from m32c-tdep.c.  Initially I
had thought that this entire code block was dead, but Simon pointed
out that it is not; so this patch simply removes some declarations.

gdb/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* m32c-tdep.c (mark_dma): Return void.
	(make_regs): Remove unused declarations.
2018-07-22 13:20:03 -06:00
Tom Tromey d5e9a511c4 Call some functions in guile/ for effect
This changes a couple of spots in guile/ to remove a variable
declaration but to still call a function for effect.

gdb/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* guile/scm-cmd.c (gdbscm_dont_repeat): Call
	cmdscm_get_valid_command_smob_arg_unsafe for effect.
	* guile/scm-block.c (gdbscm_make_block_syms_iter): Call
	bkscm_get_valid_block_smob_arg_unsafe for effect.
2018-07-22 13:20:03 -06:00
Tom Tromey 996d693a07 Use a previously unused variable in bfin-tdep.c
This changes bfin_push_dummy_call to use the result of check_typedef.
Calling check_typedef for effect was probably ok as well, but this
seemed a little nicer.

gdb/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* bfin-tdep.c (bfin_push_dummy_call): Use arg_type, not
	value_type.
2018-07-22 13:20:02 -06:00
Tom Tromey 1576637036 Unused variable fixes related to conditional compilation
This patch fixes various unused variable warnings that are related to
conditional compilation.  In these cases, either the variable is now
protected by the same #if as its uses, or the declaration is simply
lowered into the conditionally-compiled block.

gdb/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* windows-nat.c (saved_context): Conditionally define.
	* remote.c (remote_target::remote_btrace_maybe_reopen):
	Conditionally declare "warned".
	* inflow.c (sigquit_ours): Conditionally define.
	(new_tty): Move "tty" declaration inside #if.
	* guile/guile.c (guile_datadir): Conditionally define.
	* charset.c (set_be_le_names): Move some declarations inside #if.
	* btrace.c (parse_xml_btrace): Move "errcode" declaration inside
	#if.
	(parse_xml_btrace_conf): Likewise.
2018-07-22 13:20:02 -06:00
Tom Tromey f4e80e1301 Remove an unused variable from spu_get_overlay_table
This removes an unused variable from spu_get_overlay_table, replacing
it with an explanatory comment.

gdb/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* spu-tdep.c (spu_get_overlay_table): Remove unused variable.
2018-07-22 13:20:01 -06:00
Tom Tromey 8d49165d83 Simple unused variable removals
This patch holds all the straightforward unused variable deletions.

gdb/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* guile/scm-value.c (gdbscm_value_call): Remove unused variables.
	* guile/scm-math.c (vlscm_unop_gdbthrow, vlscm_binop_gdbthrow)
	(vlscm_convert_typed_value_from_scheme): Remove unused variable.
	* buildsym-legacy.c (get_macro_table): Remove unused variable.
	* stack.c (frame_apply_level_command): Remove unused variable.
	* tic6x-tdep.c (tic6x_push_dummy_call): Remove unused variable.
	* sparc64-tdep.c (adi_examine_command): Remove unused variable.
	* rs6000-lynx178-tdep.c (rs6000_lynx178_push_dummy_call): Remove
	unused variable.
	* nios2-tdep.c (nios2_push_dummy_call): Remove unused variable.
	* mep-tdep.c (mep_push_dummy_call): Remove unused variable.
	* ada-lang.c (ada_lookup_symbol_list_worker): Remove unused
	variable.
	* amd64-tdep.c (amd64_supply_xsave): Remove unused variable.
	* arm-tdep.c (arm_record_data_proc_misc_ld_str): Remove unused
	variable.
	* breakpoint.c (check_no_tracepoint_commands, update_watchpoint):
	Remove unused variable.
	* cli/cli-script.c (recurse_read_control_structure): Remove unused
	variable.
	* common/tdesc.c (print_xml_feature::visit): Remove unused
	variable.
	* compile/compile-object-load.c (store_regs): Remove unused
	variables.
	* complaints.c (clear_complaints): Remove unused variable.
	* corelow.c (core_target_open): Remove unused variable.
	* fbsd-tdep.c (fbsd_core_info_proc_status): Remove unused
	variable.
	* guile/scm-frame.c (gdbscm_frame_read_var): Remove unused
	variable.
	* guile/scm-symtab.c (stscm_print_sal_smob): Remove unused
	variable.
	* guile/scm-type.c (gdbscm_field_baseclass_p): Remove unused
	variable.
	* guile/scm-utils.c (gdbscm_parse_function_args): Remove unused
	variable.
	* hppa-tdep.c (hppa_stub_frame_unwind_cache): Remove unused
	variable.
	* ia64-tdep.c (examine_prologue): Remove unused variable.
	* infcall.c (run_inferior_call): Remove unused variable.
	* inferior.c (exit_inferior): Remove unused variable.
	* infrun.c (infrun_thread_ptid_changed): Remove unused variable.
	* linespec.c (decode_line_2): Remove unused variable.
	* linux-nat.c (super_close): Remove.
	* linux-tdep.c (linux_info_proc): Remove unused variable.
	* mi/mi-main.c (mi_execute_command): Remove unused variable.
	* microblaze-linux-tdep.c (microblaze_linux_sigtramp_cache):
	Remove unused variable.
	* parse.c (find_minsym_type_and_address): Remove unused variable.
	* printcmd.c (info_symbol_command, printf_floating): Remove unused
	variable.
	* python/py-breakpoint.c (bppy_set_commands): Remove unused
	variable.
	* python/py-unwind.c (unwind_infopy_dealloc): Remove unused
	variables.
	* record-btrace.c (record_btrace_target::store_registers): Remove
	unused variable.
	(cmd_show_record_btrace_cpu): Remove unused variable.
	* riscv-tdep.c (riscv_register_reggroup_p)
	(riscv_push_dummy_call, riscv_return_value): Remove unused
	variable.
	* rust-exp.y (literal): Remove unused variable.
	* rust-lang.c (rust_evaluate_subexp) <OP_RUST_ARARAY>: Remove
	unused variable.
	<STRUCTOP_ANONYMOUS>: Likewise.
	* s390-linux-tdep.c (s390_linux_init_abi_31)
	(s390_linux_init_abi_64): Remove unused variable.
	* ser-ming2.c (ser_windows_read_prim, pipe_select_thread)
	(file_select_thread, net_windows_open, _initialize_ser_windows):
	Remove unused variables.
	* symtab.c (find_pc_sect_line): Remove unused variable.
	* target-memory.c (compute_garbled_blocks): Remove unused
	variable.
	(target_write_memory_blocks): Remove unused variable.
	* target.c (target_stack::unpush): Remove unused variables.
	* tracepoint.c (start_tracing, all_tracepoint_actions)
	(merge_uploaded_trace_state_variables)
	(print_one_static_tracepoint_marker): Remove unused variable.
	* unittests/basic_string_view/element_access/char/1.cc (test01):
	Remove unused variable.
	* windows-nat.c (windows_continue, windows_add_all_dlls)
	(do_initial_windows_stuff, windows_nat_target::create_inferior):
	Remove unused variables.
2018-07-22 13:20:01 -06:00
H.J. Lu c7213af9b3 x86: Determine vector length from the last vector operand
Determine VEX/EVEXE vector length from the last multi-length vector
operand.

	* config/tc-i386.c (build_vex_prefix): Determine vector
	length from the last multi-length vector operand.
	(build_evex_prefix): Likewise.
2018-07-22 12:00:39 -07:00
Simon Marchi 17cbafdbbe Fix -Wunused-variable warnings related to conditional compilation
Some variables are not used when !HAVE_ELF, so avoid declaring them in
that case.

gdb/ChangeLog:

	* arm-tdep.c (arm_gdbarch_init): Declare attr_arch and
	attr_profile in HAVE_ELF.
	* rs6000-tdep.c (bfd_uses_spe_extensions): Declare vector_abi in
	HAVE_ELF.
2018-07-21 22:23:33 -04:00
GDB Administrator dcc0660f04 Automatic date update in version.in 2018-07-22 00:01:12 +00:00
H.J. Lu dd40ce22d0 gas/config/tc-i386.c: Break long line
* config/tc-i386.c (match_simd_size): Break long line.
	(match_mem_size): Likewise.
2018-07-21 10:57:54 -07:00
Eric Botcazou 2376f038d1 Initialize GOT slot for local symbol in non-PIC link.
On ARM/VxWorks 7, the R_ARM_TARGET2 relocation used for exception handling
is R_ARM_GOT_PREL; moreover in Ada you can define local exceptions. In this
case, you may end up with a GOT relocation against a local symbol in a
non-PIC link and the ARM linker leaves the GOT slot uninitialized, unlike
for example the i386 or the SPARC linkers in the same situation.

bfd/
	* elf32-arm.c (elf32_arm_final_link_relocate) <R_ARM_GOT32>: Small
	cleanup for the case of a global symbol that binds locally.  Also
	install a value in the GOT slot in the case of a local symbol in
	a non-PIC link.
2018-07-21 15:00:40 +02:00
Simon Marchi 0ee6c332f3 Rename some frame unwind function parameters
I am currently working with these functions, and though this renaming
could help to reason about the code.  Some functions take a frame and
will return the value associated to that frame, others will return the
value associated to the previous frame.  Those usually conveniently
contain "unwind" in their name, but naming the variable next_frame
instead of frame helps remembering which frame we are dealing with.

I also included a little typo fix at the top of frame.h.

gdb/ChangeLog:

	* frame.c (frame_register_unwind): Change parameter name.
	(frame_unwind_register): Likewise.
	(frame_unwind_register_value): Likewise.
	(frame_unwind_register_signed): Likewise.
	(frame_unwind_register_unsigned): Likewise.
	* frame.h (frame_register_unwind): Likewise.
	(frame_unwind_register): Likewise.
	(frame_unwind_register_value): Likewise.
	(frame_unwind_register_signed): Likewise.
	(frame_unwind_register_unsigned): Likewise.
	(frame_unwind_arch): Likewise.
2018-07-20 22:19:51 -04:00
GDB Administrator bef891d212 Automatic date update in version.in 2018-07-21 00:00:33 +00:00
Maciej W. Rozycki e2e31f1039 Update my e-mail address, limit maintenance to MIPS I-IV ISAs
binutils/
	* MAINTAINERS: Update my e-mail address, downgrade to MIPS I-IV
	ISA maintenance.

	gdb/
	* MAINTAINERS: Update my e-mail address, downgrade to MIPS I-IV
	ISA maintenance.

	sim/
	* MAINTAINERS: Update my e-mail address, downgrade to MIPS I-IV
	ISA maintenance.
2018-07-21 00:14:01 +01:00
H.J. Lu 7a54636a02 x86: Rename match_reg_size to match_operand_size
match_reg_size checks size for both memory and register operands.  This
patch renamed match_reg_size to match_operand_size and updated comments
for

commit 3ac21baa84
Author: Jan Beulich <jbeulich@novell.com>
Date:   Mon Jul 16 08:19:21 2018 +0200

    x86: fix operand size checking

which added one argument to match_reg_size, match_simd_size and
match_mem_size.

	* config/tc-i386.c (match_reg_size): Renamed to ...
	(match_operand_size): This.  Update comments.
	(match_simd_size): Update comments.  Replace match_reg_size
	with match_operand_size.
	(match_mem_size): Likewise.
	(operand_size_match): Replace match_reg_size with
	match_operand_size.
2018-07-20 12:55:14 -07:00
H.J. Lu d5f4da5e33 ld: Discard .rel.* and .rela.* sections
On many targets, like x86, .rel.dyn/.rela.dyn section is combined from
different .rel/.rela sections by -z combreloc.  To discard dynamic
relocation section, we need to discard .rel.* and .rela.* sections
instead of .rel.dyn and .rela.dyn sections.

Note: This test fails for targets which issue a warning when dynamic
section is discarded.

	* testsuite/ld-elf/reloc-discard.ld: Discard .rel.* and .rela.*
	sections instead of .rel.dyn and .rela.dyn sections.
2018-07-20 09:58:45 -07:00
Maciej W. Rozycki 2d38991535 MIPS/Linux/native: Convert to `get_ptrace_pid' for PID extraction
Use `get_ptrace_pid' to get the ptrace PID from `inferior_ptid' rather
than extracting it by hand.

	gdb/
	* mips-linux-nat.c (mips_linux_nat_target::read_description):
	Call `get_ptrace_pid' rather than extracting the ptrace PID by
	hand.
2018-07-20 17:28:08 +01:00
H.J. Lu 241e64e3b4 x86: Add a GNU_PROPERTY_X86_ISA_1_USED note if needed
When -z separate-code, which is enabled by default for Linux/x86, is
used to create executable, ld won't place any data in the code-only
PT_LOAD segment.  If there are no data sections placed before the
code-only PT_LOAD segment, the program headers won't be mapped into
any PT_LOAD segment.  When the executable tries to access it (based
on the program header address passed in AT_PHDR), it will lead to
segfault.  This patch inserts a GNU_PROPERTY_X86_ISA_1_USED note if
there may be no data sections before the text section so that the
first PT_LOAD segment won't be code-only and will contain the program
header.

Testcases are adjusted to either pass "-z noseparate-code" to ld or
discard the .note.gnu.property section.  A Linux/x86 run-time test is
added.

bfd/

	PR ld/23428
	* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): If the
	separate code program header is needed, make sure that the first
	read-only PT_LOAD segment has no code by adding a
	GNU_PROPERTY_X86_ISA_1_USED note.

ld/

	PR ld/23428
	* testsuite/ld-elf/linux-x86.S: New file.
	* testsuite/ld-elf/linux-x86.exp: Likewise.
	* testsuite/ld-elf/pr23428.c: Likewise.
	* testsuite/ld-elf/sec64k.exp: Pass "-z noseparate-code" to ld
	for Linux/x86 targets.
	* testsuite/ld-i386/abs-iamcu.d: Likewise.
	* testsuite/ld-i386/abs.d: Likewise.
	* testsuite/ld-i386/pr12718.d: Likewise.
	* testsuite/ld-i386/pr12921.d: Likewise.
	* testsuite/ld-x86-64/abs-k1om.d: Likewise.
	* testsuite/ld-x86-64/abs-l1om.d: Likewise.
	* testsuite/ld-x86-64/abs.d: Likewise.
	* testsuite/ld-x86-64/pr12718.d: Likewise.
	* testsuite/ld-x86-64/pr12921.d: Likewise.
	* testsuite/ld-linkonce/zeroeh.ld: Discard .note.gnu.property
	section.
	* testsuite/ld-scripts/print-memory-usage.t: Likewise.
	* testsuite/ld-scripts/size-2.t: Likewise.
	* testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Use ld
	to create executable if language is "asm".
2018-07-20 09:19:00 -07:00
Keith Seitz cbb09508e4 Rename remaining members of buildsym_compunit to start with "m_"
This renames all the remaining members of buildsym_compunit to start
with "m_" to follow the general naming convention.

gdb/ChangeLog
2018-07-20  Keith Seitz  <keiths@redhat.com>

	* buildsym.h (struct buildsym_compunit) <m_objfile, m_subfiles,
	m_main_subfile, m_comp_dir, m_producer, m_debugformat,
	m_compunit_symtab, m_language>: Add "m_" prefix.
	Update all uses.
	* buildsym.c: Update all uses.
2018-07-20 09:42:56 -06:00
Tom Tromey bfe2e011c0 Remove record_line_ftype
The record_line_ftype typedef was only used in the DWARF reader, and
we removed those uses a few patches ago.  So, remove the typedef.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym-legacy.h (record_line): Don't use record_line_ftype.
	* buildsym.h (record_line_ftype): Remove typedef.
2018-07-20 09:42:56 -06:00
Tom Tromey 0e6f30610f Remove some unused buildsym functions
Now that the DWARF reader uses the builder-based API, we can remove a
few "legacy" functions that were only ever called by it.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym-legacy.h (augment_type_symtab): Don't declare.
	(end_expandable_symtab): Likewise.
	(end_symtab_get_static_block): Likewise.
	(end_symtab_from_static_block): Likewise.
	* buildsym-legacy.c (augment_type_symtab): Remove.
	(end_expandable_symtab): Remove.
	(end_symtab_get_static_block): Remove.
	(end_symtab_from_static_block): Remove.
2018-07-20 09:42:55 -06:00
Tom Tromey 804d27291b Convert the DWARF reader to new-style buildysm
This converts the DWARF reader to use the new-style buildsym API.  A
new buildsym_compunit is created for each CU and is used to construct
the symbol table.  In some cases the CU must be passed to functions
which previously did not accept it.  FWIW I tend to think that most
methods in the DWARF reader ought to be methods on the dwarf2_cu
object.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* dwarf2read.c: Include buildsym.h.
	(struct dwarf2_cu) <builder>: New method.
	(fixup_go_packaging): Update.
	(process_full_comp_unit, process_full_type_unit): Update.  Don't
	use scoped_free_pendings.
	(using_directives): Add "cu" parameter, remove "language".
	(read_import_statement, setup_type_unit_groups, )
	(read_func_scope, read_lexical_block_scope)
	(dwarf2_record_block_ranges, read_namespace): Update.
	(lnp_state_machine::lnp_state_machine): Add cu parameter.
	(lnp_state_machine::handle_end_sequence): Update.
	(class lnp_state_machine) <m_cu>: New member.
	<m_record_line_callback>: Remove.
	<m_currently_recording_lines>: New member.
	(lnp_state_machine::handle_set_file): Update.
	(noop_record_line): Remove.
	(dwarf_record_line_p): Add cu parameter.
	(dwarf_record_line_1, dwarf_finish_line): Likewise.
	(lnp_state_machine::record_line)
	(lnp_state_machine::lnp_state_machine)
	(lnp_state_machine::check_line_address, dwarf_decode_lines_1)
	(dwarf_decode_lines): Update.
	(dwarf2_start_subfile): Add cu parameter.
	(dwarf2_start_symtab, new_symbol): Update.
	(macro_start_file, dwarf_decode_macro_bytes): Add cu parameter.
	Remove dwarf2_per_objfile parameter.
	(dwarf_decode_macros): Update.
2018-07-20 09:42:54 -06:00
Tom Tromey 80e649fcac Parameterize cp_scan_for_anonymous_namespaces
This changes cp_scan_for_anonymous_namespaces to use the
buildsym_compunit API, rather than the function-based API.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* stabsread.c (define_symbol): Update.
	* buildsym-legacy.h (get_buildsym_compunit): Declare.
	* dwarf2read.c (new_symbol): Update.
	* cp-support.h (cp_scan_for_anonymous_namespaces): Update.
	* cp-namespace.c: Include buildsym.h.
	(cp_scan_for_anonymous_namespaces): Add "compunit" parameter.
	* buildsym-legacy.c (get_buildsym_compunit): New function.
2018-07-20 09:42:53 -06:00
Tom Tromey 0baae8dbd3 Introduce buildsym-legacy.h
This introduces a new header, buildsym-legacy.h, and changes all the
symbol readers to use it.  The idea is to put the function-based
interface, that relies on the buildsym_compunit global, into a
separate header.  Then when a symbol reader is updated to use the new
interface, it can simply not include buildsym-legacy.h, so it's easy
to be sure that the new API is used everywhere.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* xcoffread.c: Include buildsym-legacy.h.
	* windows-nat.c: Include buildsym-legacy.h.
	* stabsread.c: Include buildsym-legacy.h.
	* mdebugread.c: Include buildsym-legacy.h.
	* buildsym-legacy.h: New file.
	* buildsym-legacy.c: New file, from buildsym.c.
	* go32-nat.c: Include buildsym-legacy.h.
	* dwarf2read.c: Include buildsym-legacy.h.
	* dbxread.c: Include buildsym-legacy.h.
	* cp-namespace.c: Include buildsym-legacy.h.
	* coffread.c: Include buildsym-legacy.h.
	* buildsym.h: Move some contents to buildsym-legacy.h.
	* buildsym.c: Include buildsym-legacy.h.  Move many functions to
	buildsym-legacy.c.
	* Makefile.in (HFILES_NO_SRCDIR): Add buildsym-legacy.h.
2018-07-20 09:42:53 -06:00
Tom Tromey ab209f6fa9 Move struct buildsym_compunit to buildsym.h
This moves struct buildsym_compunit to buildsym.h.  Now that the
members are private, and it no longer affects any global state in
buildsym.c, an instance can be used directly for symtab creation.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym.h (struct buildsym_compunit): Move from buildsym.c.
	* buildsym.c (struct buildsym_compunit): Move to buildsym.h.
	(buildsym_compunit::buildsym_compunit)
	(buildsym_compunit::~buildsym_compunit)
	(buildsym_compunit::get_macro_table): Define.
2018-07-20 09:42:52 -06:00
Tom Tromey 74c72eac23 Remove reset_symtab_globals
This patch arranges for the remaining buildsym global --
buildsym_compunit -- to only be cleared by the wrapper functions, not
by methods on struct buildsym_compunit.  In the process,
reset_symtab_globals is removed.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym.c (reset_symtab_globals): Remove.
	(buildsym_compunit::end_symtab_from_static_block): Update.
	(buildsym_compunit::augment_type_symtab): Update.
	(end_symtab_from_static_block): Call free_buildsym_compunit.
	(augment_type_symtab, end_symtab, end_expandable_symtab):
	Likewise.
2018-07-20 09:42:51 -06:00
Tom Tromey da6580e59c Do not use buildsym.h in some files
A few files no longer need to include buildsym.h.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* arch-utils.c: Do not include buildsym.h.
	* mipsread.c: Do not include buildsym.h.
	* machoread.c: Do not include buildsym.h.
	* elfread.c: Do not include buildsym.h.
2018-07-20 09:42:51 -06:00
Tom Tromey 4a2125f531 Add many methods to buildsym_compunit
This adds many methods to buildsym_compunit and makes the data members
private.  Essentially the entire buildsym API is now available as a
method on buildsym_compunit.  However, standalone functions are still
provided, as this is what the sybmol readers actually use.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym.c (buildsym_compunit::buildsym_compunit): Do more
	initialization.
	(buildsym_compunit): Add new constructor.
	(struct buildsym_compunit) <get_last_source_file, finish_block,
	record_block_range, start_subfile, patch_subfile_names,
	push_subfile, pop_subfile, record_line, get_compunit_symtab,
	set_last_source_start_addr, get_last_source_start_addr,
	get_local_using_directives, set_local_using_directives,
	get_global_using_directives, outermost_context_p,
	get_current_context_stack, get_context_stack_depth,
	get_current_subfile, get_local_symbols, get_file_symbols,
	get_global_symbols, record_debugformat, record_producer,
	push_context, pop_context, end_symtab_get_static_block,
	end_symtab_from_static_block, end_symtab, end_expandable_symtab>:
	New public methods.
	<record_pending_block, finish_block_internal, make_blockvector,
	watch_main_source_file_lossage, end_symtab_with_blockvector>: New
	private methods.
	Update all users.
2018-07-20 09:42:50 -06:00
Tom Tromey 6b213a4778 Remove parameter from record_pending_block
This removes a redundant parameter from record_pending_block.  It also
moves record_pending_block earlier in the file, so that a forward
declaration is no longer needed.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym.c (record_pending_block): Move earlier.  Remove objfile
	parameter.
	(finish_block_internal): Update.
2018-07-20 09:42:49 -06:00
Tom Tromey b80a981d08 Remove EXTERN from buildsym.h
Nothing in buildsym.h relies on the "EXTERN" method of
declaration/definition, so remove the traces.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym.h (EXTERN): Don't define or undef.
	* buildsym.c (EXTERN): Don't define.
2018-07-20 09:42:49 -06:00
Tom Tromey ddb7060226 Remove a TODO
This removes a TODO comment -- the work has been done.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym.c: Remove TODO comment.
2018-07-20 09:42:48 -06:00
Tom Tromey b37dd3bcaa Remove buildsym_init
Now that buildsym_init does nothing, it can be removed.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* coffread.c (coff_symtab_read): Update.
	* xcoffread.c (xcoff_psymtab_to_symtab_1): Update.
	(xcoff_new_init): Update.
	* mipsread.c (mipscoff_new_init): Update.
	* mdebugread.c (mdebug_build_psymtabs): Update.
	* elfread.c (elf_new_init): Update.
	* dwarf2read.c (process_full_comp_unit, process_full_type_unit):
	Update.
	* dbxread.c (dbx_new_init, dbx_psymtab_to_symtab_1)
	(coffstab_build_psymtabs, elfstab_build_psymtabs)
	(stabsect_build_psymtabs): Update.
	* buildsym.h (buildsym_init): Don't declare.
	* buildsym.c: Update comment.
	(prepare_for_building): Remove.
	(start_symtab, restart_symtab): Update.
	(reset_symtab_globals): Update comment.
	(buildsym_init): Remove.
2018-07-20 09:42:47 -06:00
Tom Tromey e148f09d75 Move the symbol lists to buildsym_compunit
This moves the global symbol lists into buildsym_compunit, adds
accessors, and updates all the users.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (read_xcoff_symtab, process_xcoff_symbol): Update.
	* stabsread.c (patch_block_stabs, define_symbol, read_type)
	(read_enum_type, common_block_start, common_block_end)
	(cleanup_undefined_types_1, finish_global_stabs): Update.
	* mdebugread.c (psymtab_to_symtab_1): Update.
	* dwarf2read.c (fixup_go_packaging, read_func_scope)
	(read_lexical_block_scope, new_symbol): Update.
	* dbxread.c (process_one_symbol): Update.
	* coffread.c (coff_symtab_read, process_coff_symbol)
	(coff_read_enum_type): Update.
	* buildsym.h (file_symbols, global_symbols, local_symbols): Don't
	declare.
	(get_local_symbols, get_file_symbols, get_global_symbols): New
	functions.
	* buildsym.c (~buildsym_compunit): Clean up m_file_symbols and
	m_global_symbols.
	<m_file_symbols, m_local_symbols, m_global_symbols>: New members.
	(~scoped_free_pendings): Update.
	(finish_block, prepare_for_building, reset_symtab_globals)
	(end_symtab_get_static_block, end_symtab_with_blockvector)
	(augment_type_symtab, push_context): Update.
	(get_local_symbols, get_file_symbols, get_global_symbols): New
	functions.
	(buildsym_init): Update.
2018-07-20 09:42:46 -06:00
Tom Tromey 93b8bea414 Set list_in_scope later in DWARF reader
Currently the DWARF reader sets the list_in_scope member of the CU
when first starting to process symbols.  Future changes will make this
assert -- code will not be able to refer to these lists until after
start_symtab has been called.  This patch prepares for the problem by
arranging to initialize list_in_scope in dwarf2_start_symtab.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* dwarf2read.c (process_full_comp_unit): Do not set list_in_scope.
	(process_full_type_unit): Likewise.
	(dwarf2_start_symtab): Set list_in_scope.
2018-07-20 09:42:46 -06:00
Tom Tromey f62f6af5da Do not look at file symbols when reading psymtabs
The DWARF reader was setting the list_in_scope member when reading
partial symbols.  however, this member is only useful when reading
full symbols.  Future patches will make this assert, so remove these
unneeded initializations.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* dwarf2read.c (process_psymtab_comp_unit_reader)
	(build_type_psymtabs_reader): Do not set list_in_scope.
2018-07-20 09:42:45 -06:00
Tom Tromey 1d376700df Remove free_pendings
buildsym.c currently keeps a free list of "struct pending"s.  However,
this didn't seem necessary to me, and so this patch removes the free
list.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym.c (free_pendings): Remove.
	(add_symbol_to_list, scoped_free_pendings)
	(finish_block_internal, buildsym_init): Update.
2018-07-20 09:42:44 -06:00
Tom Tromey c233e9c641 Remove the "listhead" argument from finish_block
finish_block is only ever called with "&local_symbols" as the
"listhead" argument.  So, remove this argument.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (read_xcoff_symtab): Update.
	* dwarf2read.c (read_func_scope, read_lexical_block_scope):
	Update.
	* dbxread.c (process_one_symbol): Update.
	* coffread.c (coff_symtab_read): Update.
	* buildsym.h (finish_block): Update.
	* buildsym.c (finish_block): Remove "listhead" argument.
	(end_symtab_get_static_block): Update.
2018-07-20 09:42:44 -06:00
Tom Tromey 5ac045503d Move pending_blocks and pending_block_obstack to buildsym_compunit
This moves the pending_blocks and pending_block_obstack into
buildsym_compunit.

The obstack could perhaps be merged with the addrmap obstack, but I
did not do that in this series.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym.h (class scoped_free_pendings): Remove constructor.
	* buildsym.c (struct buildsym_compunit) <free_pending_blocks>: New
	method.
	<m_pending_block_obstack, m_pending_blocks>: New members.
	(pending_block_obstack, pending_blocks): Remove.
	(scoped_free_pendings::scoped_free_pendings): Default.
	(~scoped_free_pendings): Update.
	(free_pending_blocks): Remove.
	(finish_block_internal, record_pending_block, make_blockvector)
	(end_symtab_get_static_block, augment_type_symtab, push_context)
	(buildsym_init): Update.
2018-07-20 09:42:43 -06:00
Tom Tromey 7ea05a7b63 Move pending addrmap globals to buildsym_compunit
This moves the pending addrmap-related globals into buildsym_compunit.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym.c (struct buildsym_compunit) <m_pending_addrmap,
	m_pending_addrmap_obstack, m_pending_addrmap_interesting>: New
	members.
	(pending_addrmap, pending_addrmap_obstack)
	(pending_addrmap_interesting): Remove.
	(scoped_free_pendings, record_block_range, make_blockvector)
	(prepare_for_building, reset_symtab_globals, buildsym_init):
	Update.
2018-07-20 09:42:43 -06:00
Tom Tromey 3c65e5b31c Move current_subfile to buildsym_compunit
This moves the global current_subfile into buildsym_compunit.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (process_linenos): Update.
	* stabsread.c (define_symbol, read_type, read_enum_type): Update.
	* mdebugread.c (psymtab_to_symtab_1): Update.
	* dwarf2read.c (setup_type_unit_groups)
	(lnp_state_machine::handle_set_file, dwarf_record_line_p)
	(lnp_state_machine::record_line, dwarf_decode_lines): Update.
	* dbxread.c (process_one_symbol): Update.
	* coffread.c (coff_symtab_read, enter_linenos)
	(process_coff_symbol): Update.
	* buildsym.h (current_subfile): Don't declare.
	(get_current_subfile): Declare.
	* buildsym.c (struct buildsym_compunit) <m_current_subfile>: New
	member.
	(start_subfile, free_buildsym_compunit, push_subfile)
	(prepare_for_building, start_symtab): Update.
	(get_current_subfile): New function.
2018-07-20 09:42:42 -06:00
Tom Tromey a60f3166aa Move the context stack to buildsym_compunit
This moves the context stack globals to be members of
buildsym_compunit, changing the type to a std::vector in the process.

Because the callers expect the context stack object to be valid after
being popped, at Simon's suggestion I've changed pop_context to return
the object rather than the pointer.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* coffread.c (coff_symtab_read): Update.
	* xcoffread.c (read_xcoff_symtab): Update.
	* dwarf2read.c (new_symbol): Update.
	(read_func_scope, read_lexical_block_scope): Update.
	* dbxread.c (process_one_symbol): Update.
	* buildsym.h (context_stack, context_stack_depth): Don't declare.
	(outermost_context_p): Remove macro.
	(outermost_context_p, get_current_context_stack)
	(get_context_stack_depth): Declare.
	(pop_context): Return struct context_stack.
	* buildsym.c (struct buildsym_compunit) <m_context_stack: New
	member.
	(context_stack_size): Remove.
	(INITIAL_CONTEXT_STACK_SIZE): Remove.
	(prepare_for_building, end_symtab_get_static_block)
	(augment_type_symtab, push_context): Update.
	(pop_context): Return struct context_stack.
	(outermost_context_p, get_current_context_stack)
	(get_context_stack_depth): New functions.
	(buildsym_init): Update.
2018-07-20 09:42:41 -06:00
Tom Tromey 56ba65a047 Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y.  This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers.  Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.

Tested on x86-64 Fedora 26.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* rust-exp.y: Now a pure parser.  Update all rules.
	(%union): Move earlier.
	(current_parser, work_obstack): Remove globals.
	(rust_parser, ~rust_parser): Update.
	(class rust_parser) <copy_name, concat3, crate_name, super_name,
	lex_character, lex_number, lex_string, lex_identifier,
	rust_lookup_type, convert_params_to_types, convert_ast_to_type,
	convert_name, convert_params_to_expression,
	convert_ast_to_expression, ast_basic_type, ast_operation,
	ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
	ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
	ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
	ast_array_type, ast_slice_type, ast_reference_type,
	ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
	(rust_parse): Update.
	(rustyyerror, rustyylex): Add parser parameter.
	(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
	(rust_lex_stringish_test, rust_lex_test_sequence)
	(rust_lex_test_trailing_dot, rust_lex_test_completion)
	(rust_lex_test_push_back, rust_lex_tests): Update.
2018-07-20 09:40:18 -06:00
Andre Simoes Dias Vieira 3ba174474d [PATCH, LD, AArch64] Fix ifunc testisms
This patch fixes some ifunc testisms after H.J. Lu's patch to enable the
use of IFUNC pointers in position dependent code for binutils. See PR
LD/23169 in binutils bugzilla.

The aarch64 ifunc error message test was changed to no longer expect
this error message as this is now an accepted combination. This patch
also disables the executable tests added by H.J. Lu for aarch64, just as
Alan Modra did with his patch, as these tests only seem to work on some
architectures.

ld/ChangeLog:
2018-07-19  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	* testsuite/ld-aarch64/ifunc-9.d: Remove no longer expected error.
	* testsuite/ld-ifunc/ifunc.exp: Disable tests for aarch64.
2018-07-20 16:35:37 +01:00
Tom de Vries 232a00325b [gdb/testsuite] Make noclone conditional in vla-optimized-out.c
Make the noclone attribute on f1 in vla-optimized-out.c conditional.  This
makes the test-case by default identical to
gcc/testsuite/gcc.dg/guality/vla-1.c.

Tested on x86_64-linux.

2018-07-20  Tom de Vries  <tdevries@suse.de>

	* gdb.base/vla-optimized-out.c: Make noclone attribute conditional on
	NOCLONE macro.
	* gdb.base/vla-optimized-out.exp: Use additional_flags -DNOCLONE.
2018-07-20 17:04:02 +02:00
Nick Clifton 3391569f21 Close memory and resource leaks detected by coverity in the binutils directory.
* objcopy.c (add_specific_symbols): Free buffer on exit.
	(add_redefine_syms_file): Close file handle on exit.
	(copy_object): Close file handle on early exit.
	Free buffer on early exit.
	Free gaps buffers once they are no longer needed.
	* dwarf.c (display_debug_frames): Free allocated memory on exit.
	(load_separate_debug_info): Free allocate memory on early exit.
2018-07-20 15:05:34 +01:00
Chenghua Xu 8095d2f70e MIPS/GAS: Split Loongson MMI Instructions from loongson2f/3a
The MMI instruction set has been implemented in many Loongson
processors.  There is a lot of software optimized for MMI.  This patch
splits MMI from loongson2f/3a, and adds GAS and disassembler options for
MMI instructions.

2018-07-20  Chenghua Xu  <paul.hua.gm@gmail.com>
            Maciej W. Rozycki  <macro@mips.com>

bfd/
	* elfxx-mips.c (print_mips_ases): Add MMI extension.

binutils/
	* readelf.c (print_mips_ases): Add MMI extension.

gas/
	* NEWS: Mention MultiMedia extensions Instructions (MMI)
	support.
	* config/tc-mips.c (options): Add OPTION_LOONGSON_MMI and
	OPTION_NO_LOONGSON_MMI.
	(md_longopts): Likewise.
	(mips_ases): Define availability for MMI.
	(mips_convert_ase_flags): Map ASE_LOONGSON_MMI to
	AFL_ASE_LOONGSON_MMI.
	(mips_cpu_info_table): Add ASE_LOONGSON_MMI for loongson2f/3a.
	(md_show_usage): Add help for -mloongson-mmi and
	-mno-loongson-mmi.
	* doc/as.texi: Document -mloongson-mmi, -mno-loongson-mmi.
	* doc/c-mips.texi: Document -mloongson-mmi, -mno-loongson-mmi,
	.set loongson-mmi and .set noloongson-mmi.
	* testsuite/gas/mips/loongson-2f.d: Move mmi test to ...
	* testsuite/gas/mips/loongson-2f-mmi.d: Here.  Add ISA/ASE
	flag verification.
	* testsuite/gas/mips/loongson-2f.s: Move mmi test to ...
	* testsuite/gas/mips/loongson-2f-mmi.s: Here.
	* testsuite/gas/mips/loongson-3a.d: Move mmi test to ...
	* testsuite/gas/mips/loongson-3a-mmi.d: Here.  Add ISA/ASE
	flag verification.
	* testsuite/gas/mips/loongson-3a.s: Move mmi test to ...
	* testsuite/gas/mips/loongson-3a-mmi.s: Here.
	* testsuite/gas/mips/mips.exp: Run loongson-2f-mmi and
	loongson-3a-mmi tests.

include/
	* elf/mips.h (AFL_ASE_MMI): New macro.
	(AFL_ASE_MASK): Update to include AFL_ASE_LOONGSON_MMI.
	* opcode/mips.h (ASE_LOONGSON_MMI): New macro.

opcodes/
	* mips-dis.c (mips_arch_choices): Add MMI to loongson2f and
	loongson3a descriptors.
	(parse_mips_ase_option): Handle -M loongson-mmi option.
	(print_mips_disassembler_options): Document -M loongson-mmi.
	* mips-opc.c (LMMI): New macro.
	(mips_opcodes): Replace IL2F|IL3A marking with LMMI for MMI
	instructions.
2018-07-20 13:21:33 +01:00
Maciej W. Rozycki db841b6fcd MIPS/LD: Fix crashing with a discarded dynamic relocation section
Fix a crash that occurs in `_bfd_mips_elf_finish_dynamic_sections' if a
dynamic relocation section has been created, but marked to be discarded
by an assignment to the /DISCARD/ output section in a linker script.
In that case the output section is the absolute section, which has no
ELF section data attached, so trying to set its `sh_size' parameter
causes a null pointer dereference.

This is only done as the value for the DT_RELSZ dynamic entry is being
set, so fix the problem by not creating DT_REL, DT_RELSZ or DT_RELENT
dynamic entries in the first place if the dynamic relocation section
will not be output, as with no dynamic relocation data present these
would not serve their purpose anyway.

Add a generic ELF test case to verify that no dynamic relocation data is
reported in the dynamic segment.

	bfd/
	* elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Do not
	create DT_REL, DT_RELSZ or DT_RELENT dynamic entries if the
	dynamic relocation section will be discarded from output.
	(_bfd_mips_elf_finish_dynamic_sections) <DT_RELSZ>: Assert that
	the dynamic relocation section will be retained in output.

	ld/
	* testsuite/ld-elf/reloc-discard.d: New test.
	* testsuite/ld-elf/reloc-discard.ld: New test linker script.
	* testsuite/ld-elf/reloc-discard.s: New test source.
2018-07-20 13:21:33 +01:00