Commit Graph

94874 Commits

Author SHA1 Message Date
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
Rainer Orth 0458ca4440 Specify architecture for SPARC gas tests
A couple of SPARC gas tests FAIL on Solaris/SPARC (both
sparc-sun-solaris2.11 and sparcv9-sun-solaris2.11):

FAIL: sparc PAUSE
FAIL: sparc CBCOND
FAIL: sparc CFR
FAIL: sparc CRYPTO
FAIL: sparc HPC+VIS3
FAIL: sparc IMA
FAIL: sparc OSA2015 %mwait asr and MWAIT instruction
FAIL: sparc OSA2015 %mcdper asr
FAIL: sparc SPARC5 and VIS4.0
FAIL: OSA2015 crypto instructions
FAIL: SPARC6
FAIL: FPCMPSHL OSA2017 instructions
FAIL: OSA2017 ONADD/ONSUB/ONMUL/ONDIV instructions.
FAIL: OSA2017 RLE instructions
FAIL: sparc64 rdasr
FAIL: sparc64 rdpr
FAIL: sparc64 rdhpr
FAIL: sparc64 wrasr
FAIL: sparc64 wrpr

It turns out there's a common pattern here: failures happen for all
tests that use SPARC ISA extensions beyond sparcv9, e.g. for the sparc
PAUSE test:

regexp_diff match failure
regexp "^   0:  b7 80 40 02     wr  %g1, %g2, %pause$"
line   "   0:   b7 80 40 02     wr  %g1, %g2, %asr27"
[...]
regexp_diff match failure
regexp "^   8:  b7 80 20 08     pause  8$"
line   "   8:   b7 80 20 08     wr  8, %asr27"
[...]

The fix is easy, actually: just as the tests specify the ISA extension
to use as a gas flag, the same needs to be done for objdump.  For the
test above, which has -Av9v, this means passing -msparc:v9v to objdump.
Doing so makes all but two (unrelated; to be reported separately)
failures go away.

This doesn't happen on Linux/SPARC, where gas emits GNU object attributes
matching the hardcare capabilities used.  Since gas doesn't yet implement
Solaris-style object capabilites, the explicit -march is needed, but only
passed on Solaris.

Tested on both sparc-sun-solaris2.11 and sparcv9-sun-solaris2.11.

	* testsuite/gas/sparc/sparc.exp (set_tests_arch): New proc.
	Prefix v9c, v9d, v9v, v9m, v9m8 tests with corresponding
	set_tests_arch.
2018-07-20 11:15:57 +02:00
DJ Delorie 79f5b65e3e Remove myself from target-specific MAINTAINERS
[binutils]
	* MAINTAINERS (RL78, RX): Remove myself as maintainer.
[sim]
	* MAINTAINERS (rl78, m32c, rx, v850): Remove myself as maintainer.
2018-07-19 22:08:51 -04:00
GDB Administrator 8f153adc1d Automatic date update in version.in 2018-07-20 00:00:47 +00:00
Pedro Alves 4c6933327e Eliminate remaining gdb/guile cleanups
The remaining gdb/guile cleanups all handle the memory returned by
gdbscm_scm_to_c_string.

This commit makes gdbscm_scm_to_c_string return a
gdb::unique_xmalloc_ptr instead of a naked pointer, and eliminates the
remaining cleanups.

gdb/ChangeLog:
2018-07-19  Pedro Alves  <palves@redhat.com>

	* guile/guile-internal.h (gdbscm_scm_to_c_string): Now returns a
	gdb::unique_xmalloc_ptr.
	* guile/scm-breakpoint.c (gdbscm_set_breakpoint_condition_x):
	Adjust to use dbscm_wrap and gdb::unique_xmalloc_ptr.
	* guile/scm-exception.c (gdbscm_exception_message_to_string): Use
	copy-initialization.
	* guile/scm-pretty-print.c (ppscm_print_children): Use
	gdb::unique_xmalloc_ptr instead of cleanups.
	(gdbscm_apply_val_pretty_printer): Remove cleanups.
	* guile/scm-string.c (gdbscm_scm_to_c_string): Now returns a
	gdb::unique_xmalloc_ptr.
	* guile/scm-type.c (gdbscm_type_field, gdbscm_type_has_field_p):
	Adjust to use gdb::unique_xmalloc_ptr.
	* guile/scm-utils.c (extract_arg): Adjust.
	* guile/scm-value.c (gdbscm_value_field): Adjust to use
	gdb::unique_xmalloc_ptr instead of a cleanup.
2018-07-19 16:34:55 +01:00
Tom Tromey 4581dc8297 Remove make_cleanup_value_free_to_mark
Pedro's patch to introduce gdbscm_wrap removed the last caller of
make_cleanup_value_free_to_mark.  This patch removes this function.

I'm checking this in as obvious.  Tested by rebuilding, and by
grepping.

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

	* utils.c (do_value_free_to_mark)
	(make_cleanup_value_free_to_mark): Remove.
	* utils.h (make_cleanup_value_free_to_mark): Remove.
2018-07-19 08:52:24 -06:00
Tom de Vries fbb1d502ee [gdb/testsuite] Fix regexp in list-thread-groups-available.exp
I ran into a gdb.mi/list-thread-groups-available.exp failure:
...
Running gdb/testsuite/gdb.mi/list-thread-groups-available.exp ...
FAIL: gdb.mi/list-thread-groups-available.exp:
        list available thread groups (unexpected output)
PASS: gdb.mi/list-thread-groups-available.exp:
        list available thread groups with filter
...
When doing an experiment of running it 100 times in a row, the failure
reproduced 3 times.

Analyzing the original failure led to insufficient quoting of square brackets
in a regexp.  This patch fixes the regexp, which resulted in 0 failures in a
100-in-a-row run.

Tested on x86_64-linux.

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

	* gdb.mi/list-thread-groups-available.exp (cores_re): Fix quoting in
	regular	expression.
2018-07-19 16:51:22 +02:00
Eli Zaretskii db3410f80f Fix GDB build using mingw.org's MinGW
libiberty/
2018-07-18  Eli Zaretskii  <eliz@gnu.org>

	PR gdb/23434
	* libiberty/simple-object-elf.c (ENOTSUP): If not defined by
        errno.h, redirect ENOTSUP to ENOSYS.
2018-07-19 16:54:06 +03:00
Nick Clifton 442a6ce858 Stop potential memory leaks in dwarf CIE reader.
* dwarf.c (read_cie): Free allocated memory before returning with
	a failure result.
2018-07-19 14:23:31 +01:00
Pedro Alves 43cc6c3adb gdbscm_wrap, really forward args
Commit 557e56be26 ("Eliminate most remaining cleanups under
gdb/guile/") missed adding the && to Args to really forward the
arguments properly.  Noticed by inspection.

gdb/ChangeLog:
2018-07-19  Pedro Alves  <palves@redhat.com>

	* guile/guile-internal.h (gdbscm_wrap): Really make 'args' a
	forwarding reference.
2018-07-19 10:56:47 +01:00
Andreas Krebbel f559b440bb S/390: Set the htm flag on PPA
The PPA instruction will be emitted by GCC transactional execution
builtins so it needs to be accepted with just -mhtm and without
-march=zEC12.

opcodes/ChangeLog:

2018-07-19  Andreas Krebbel  <krebbel@linux.ibm.com>

	* s390-opc.txt (PPA): Add the htm flag.
2018-07-19 10:03:55 +02:00
Jan Beulich 5f32791e1e x86: fold narrowing VCVT* templates
When multiple (here: two) forms of an insn take different width inputs
but produce identical size outputs (here: RegXMM), the templates can be
combined.

Also drop IgnoreSize (and the now redundant size specifiers) wherever
applicable.
2018-07-19 08:36:19 +02:00
Jan Beulich 625cbd7ac1 x86: fold VFPCLASSP{D,S} templates
These are special because they may not have a register operand to derive
the vector length from, which requires to also deal with the braodcast
case when determining vector length in build_evex_prefix().

Also drop IgnoreSize (and the now redundant size specifiers) from their
suffixed counterparts.
2018-07-19 08:35:38 +02:00
Jan Beulich 86b15c3204 x86: fold various AVX512* templates 2018-07-19 08:34:45 +02:00
Jan Beulich cf769ed505 x86: fold various AVX512DQ templates 2018-07-19 08:34:01 +02:00
Jan Beulich 8282b7ad0d x86: fold various AVX512BW templates 2018-07-19 08:32:17 +02:00
Jan Beulich 755908cce5 x86: fold various AVX512CD templates 2018-07-19 08:31:24 +02:00
Jan Beulich 7091c61201 x86: fold various AVX512VL templates into their AVX512F counterparts 2018-07-19 08:29:35 +02:00
Jan Beulich c30be56ebf x86: pre-process opcodes table before parsing
Instead of expanding macro-like constructs in i386-gen, have the C pre-
processor do this for us. Besides being a prerequisite for the next
template folding steps, this also paves the way for removing various
hidden dependencies between #define-s in i386-opc.h and plain literal
numbers used in i386-opc.tbl.

The #undef of None is solely to leave the generated i386-tbl.h entirely
unchanged.
2018-07-19 08:28:29 +02:00
GDB Administrator e387da76fc Automatic date update in version.in 2018-07-19 00:00:39 +00:00
Pedro Alves 3a5f2a48ff Eliminate cleanup in gdbscm_execute_gdb_command
Note: the "may be modified" comment is no longer true nowadays.

gdb/ChangeLog:
2018-07-18  Pedro Alves  <palves@redhat.com>

	* guile/guile.c (gdbscm_execute_gdb_command): Adjust to use
	gdbscm_wrap.  Use gdb::unique_xmalloc_ptr<char> instead of a
	cleanup.
2018-07-18 23:41:06 +01:00
Pedro Alves 557e56be26 Eliminate most remaining cleanups under gdb/guile/
The main complication with the Guile code is that we have two types of
exceptions to consider.  GDB/C++ exceptions, and Guile/SJLJ
exceptions.  Code that is facing the Guile interpreter must not throw
GDB exceptions, instead Scheme exceptions must be thrown.  Also,
because Guile exceptions are SJLJ based, Guile-facing code must not
use local objects with dtors, unless wrapped in a scope with a
TRY/CATCH, because the dtors won't otherwise be run when a Guile
exceptions is thrown.

This commit adds a new gdbscm_wrap wrapper function than encapsulates
a pattern I noticed in many of the functions using
GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS.  The wrapper is written
such that you can pass either a lambda to it, or a function plus a
variable number of forwarded args.  I used a lambda when its body
would be reasonably short, and a separate function in the larger
cases.

This also convers a few functions that were using
GDBSCM_HANDLE_GDB_EXCEPTION to use gdbscm_wrap too because they
followed a similar pattern.

A few cases of make_cleanup calls are replaced with explicit xfree
calls.  The make_cleanup/do_cleanups calls in those cases are
pointless, because do_cleanups won't be called when a Scheme exception
is thrown.

We also have a couple cases of Guile-facing code using RAII-type
objects to manage memory, but those are incorrect, exactly because
their dtor won't be called if a Guile exception is thrown.

gdb/ChangeLog:
2018-07-18  Pedro Alves  <palves@redhat.com>

	* guile/guile-internal.h: Add comment about mixing GDB and Scheme
	exceptions.
	(GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS): Delete.
	(gdbscm_wrap): New.
	* guile/scm-frame.c (gdbscm_frame_read_register): Use xfree
	directly instead of a cleanup.
	* guile/scm-math.c (vlscm_unop_gdbthrow): New, factored out from ...
	(vlscm_unop): ... this.  Reimplement using gdbscm_wrap.
	(vlscm_binop_gdbthrow): New, factored out from ...
	(vlscm_binop): ... this.  Reimplement using gdbscm_wrap.
	(vlscm_rich_compare): Use gdbscm_wrap.
	* guile/scm-symbol.c (gdbscm_lookup_symbol): Use xfree directly
	instead of a cleanup.
	(gdbscm_lookup_global_symbol): Use xfree directly instead of a
	cleanup.
	* guile/scm-type.c (gdbscm_type_field, gdbscm_type_has_field_p):
	Use xfree directly instead of a cleanup.
	* guile/scm-value.c (gdbscm_make_value, gdbscm_make_lazy_value):
	Adjust to use gdbscm_wrap and scoped_value_mark.
	(gdbscm_value_optimized_out_p): Adjust to use gdbscm_wrap.
	(gdbscm_value_address, gdbscm_value_dereference)
	(gdbscm_value_referenced_value): Adjust to use gdbscm_wrap and
	scoped_value_mark.
	(gdbscm_value_dynamic_type): Use scoped_value_mark.
	(vlscm_do_cast, gdbscm_value_field): Adjust to use gdbscm_wrap and
	scoped_value_mark.
	(gdbscm_value_subscript, gdbscm_value_call): Adjust to use
	gdbscm_wrap and scoped_value_mark.
	(gdbscm_value_to_string): Use xfree directly instead of a
	cleanup.  Move 'buffer' unique_ptr to TRY scope.
	(gdbscm_value_to_lazy_string): Use xfree directly instead of a
	cleanup.  Move 'buffer' unique_ptr to TRY scope.  Use
	scoped_value_mark.
	(gdbscm_value_fetch_lazy_x): Use gdbscm_wrap.
	(gdbscm_parse_and_eval): Adjust to use gdbscm_wrap and
	scoped_value_mark.
	(gdbscm_history_ref, gdbscm_history_append_x): Adjust to use
	gdbscm_wrap.
2018-07-18 22:55:59 +01:00
Tom de Vries 42dc7699a2 [gdb/exp] Fix printing of type of optimized out vla
Consider this snippet from gcc/testsuite/gcc.dg/guality/vla-1.c:
...
int __attribute__((noinline))
f1 (int i)
{
  char a[i + 1];
  a[0] = 5;             /* { dg-final { gdb-test .+1 "i" "5" } } */
  return a[0];          /* { dg-final { gdb-test . "sizeof (a)" "6" } } */
}
...

When we compile the test-case with -O1 -g, and query the size of optimized
out vla 'a', we get:
...
$ ./gdb -batch -ex "b f1" -ex "r" -ex "p sizeof (a)" vla-1.exe
Breakpoint 1 at 0x4004a8: file vla-1.c, line 17.

Breakpoint 1, f1 (i=i@entry=5) at vla-1.c:17
17        return a[0];
$1 = 0
...
while we expect a size of '6'.

The problem is that default_read_var_value does not resolve the dynamic type
of a variable if the variable is optimized out.

This patch fixes that, and consequently gdb prints '6', as expected.

Tested on x86_64-linux.

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

	* findvar.c (default_read_var_value): Also resolve dynamic type for
	LOC_OPTIMIZED_OUT vars.

	* gdb.base/vla-optimized-out.c: New test.
	* gdb.base/vla-optimized-out.exp: New file.
2018-07-18 22:02:34 +02:00
Maciej W. Rozycki 6592ceed48 microMIPS: Add SYSCALL instruction decoding
Fix a bug with commit 4cc0665f24 ("microMIPS support"),
<https://sourceware.org/ml/gdb-patches/2012-05/msg00724.html>, and add
missing microMIPS SYSCALL instruction decoding needed to determine the
location to put a breakpoint at when single-stepping though a syscall.

	gdb/
	* mips-tdep.c (micromips_next_pc): Add SYSCALL instruction
	decoding.
2018-07-18 19:17:39 +01:00
Maciej W. Rozycki d3554ec1ed BFD/XCOFF: Fix storage class setting for weak defined symbols
Fix an issue with commit 8602d4fea6 ("Add AIX weak support"),
<https://sourceware.org/ml/binutils/2009-03/msg00189.html>, and use the
correct condition to set the storage class for weak defined symbols.

The context here is as follows:

  else if ((h->root.type == bfd_link_hash_defined
            || h->root.type == bfd_link_hash_defweak)
           && h->smclas == XMC_XO)
    {
      BFD_ASSERT (bfd_is_abs_section (h->root.u.def.section));
      isym.n_value = h->root.u.def.value;
      isym.n_scnum = N_UNDEF;
      if (h->root.type == bfd_link_hash_undefweak
          && C_WEAKEXT == C_AIX_WEAKEXT)
        isym.n_sclass = C_WEAKEXT;
      else
        isym.n_sclass = C_EXT;
      aux.x_csect.x_smtyp = XTY_ER;
    }

so clearly the inner condition can never be true.  Correct the condition
then to check for the `bfd_link_hash_defweak' symbol type instead here,
and in a similar place a little further down in the same function.

	bfd/
	* xcofflink.c (xcoff_write_global_symbol): Fix symbol type
	checks for defined weak symbols.
2018-07-18 17:51:54 +01:00
Maciej W. Rozycki 972450a72c MIPS/GAS/testsuite: Correct whitespace issues with Loongson tests
Remove CR characters, trailing whitespace and space characters appearing
immediately before a tab character, and replace spaces with tabs, all
across Loongson GAS tests.

	gas/
	* testsuite/gas/mips/loongson-2e.d: Correct whitespace issues.
	* testsuite/gas/mips/loongson-2f.d: Likewise.
	* testsuite/gas/mips/loongson-2f-2.d: Likewise.
	* testsuite/gas/mips/loongson-2f-3.d: Likewise.
	* testsuite/gas/mips/loongson-3a.d: Likewise.
	* testsuite/gas/mips/loongson-3a-2.d: Likewise.
	* testsuite/gas/mips/loongson-2e.s: Likewise.
	* testsuite/gas/mips/loongson-2f.s: Likewise.
	* testsuite/gas/mips/loongson-2f-3.s: Likewise.
	* testsuite/gas/mips/loongson-3a.s: Likewise.
	* testsuite/gas/mips/loongson-3a-2.s: Likewise.
2018-07-18 14:08:37 +01:00
H.J. Lu 11a322db5c x86: Split vcvtps2{,u}qq and vcvttps2{,u}qq
After

commit 1b54b8d7e4
Author: Jan Beulich <jbeulich@novell.com>
Date:   Mon Dec 18 09:36:14 2017 +0100

    x86: fold RegXMM/RegYMM/RegZMM into RegSIMD

    ... qualified by their respective sizes, allowing to drop FirstXmm0 at
    the same time.

folded RegXMM, RegYMM and RegZMM into RegSIMD, it's no longer impossible
to distinguish if Xmmword can represent a memory reference when operand
specification contains SIMD register. For example, template operands
specification like these

RegXMM|...|Xmmword|...

and

RegXMM|...

The Xmmword bitfield is always set by RegXMM which is represented by
"RegSIMD|Xmmword".  This patch splits each of vcvtps2qq, vcvtps2uqq,
vcvttps2qq and vcvttps2uqq into 2 templates: one template only has
RegXMM source operand and the other only has mempry source operand.

gas/

	PR gas/23418
	* testsuite/gas/i386/xmmword.s: Add tests for vcvtps2qq,
	vcvtps2uqq, vcvttps2qq and vcvttps2uqq.
	* testsuite/gas/i386/xmmword.l: Updated.

opcodes/

	PR gas/23418
	* i386-opc.h (Byte): Update comments.
	(Word): Likewise.
	(Dword): Likewise.
	(Fword): Likewise.
	(Qword): Likewise.
	(Tbyte): Likewise.
	(Xmmword): Likewise.
	(Ymmword): Likewise.
	(Zmmword): Likewise.
	* i386-opc.tbl: Split vcvtps2qq, vcvtps2uqq, vcvttps2qq and
	vcvttps2uqq.
	* i386-tbl.h: Regenerated.
2018-07-18 05:33:50 -07:00
Andreas Krebbel afca762f59 S/390: Improve partial relro support for 64 bit
Currently on S/390 the .got.plt always comes first which prevents the
GNU_RELRO segment from being extended across the non-plt GOT entries.

Just swapping both unfortunately is not that simple since our ABI
requires the _GLOBAL_OFFSET_TABLE_ symbol to point to the very
beginning of the entire GOT. Of the 3 magic GOT entries the first is
accessed via got pointer while second and third are being accessed via
DT_PLTGOT.  In order to keep them together we make DT_PLTGOT to point
to the .got instead of .got.plt.  However, this violates an assumption
in the dynamic linker prelink undo code about the GOTPLT entries
starting at DT_PLTGOT + 3.  We got rid of this requirement with a
Glibc patch already in version 2.24:
https://sourceware.org/ml/libc-alpha/2016-06/msg01302.html

So the S/390 relro GOT layout will look like this with this patch:

      +----------------------------------+
      |got[0]: DYNAMIC                   |   <--- _GLOBAL_OFFSET_TABLE_ == DT_PLTGOT .got
      |got[1]: link_map parm             |
      |got[2]: &_dl_runtime_resolve      |
      +----------------------------------+
      |                                  |   non-plt GOT entries
      |                                  |
      |                                  |
      +----------------------------------+
      |                                  |   <--- .gotplt, PLT GOT entries
      |                                  |
      |                                  |
      |                                  |
      +----------------------------------+

The patch detects the current layout in size_dynamic_section in order
to deal also with linker scripts not generated by this ld version.
With partial relro enabled we pick a linker script where .got and
.got.plt are swapped which then triggers the rest of the logic.

ld/ChangeLog:

2018-07-18  Andreas Krebbel  <krebbel@linux.ibm.com>

	* emulparams/elf64_s390.sh: Define GENERATE_RELRO_SCRIPT and
	SEPARATE_GOTPLT.
	* testsuite/ld-s390/gotreloc_64-relro-1.dd: New test.
	* testsuite/ld-s390/gotreloc_64-norelro-1.dd: Renamed from ...
	* testsuite/ld-s390/gotreloc_64-1.dd: ... this.
	* testsuite/ld-s390/s390.exp: Split the GOT testcase into two.

bfd/ChangeLog:

2018-07-18  Andreas Krebbel  <krebbel@linux.ibm.com>

	* elf-s390-common.c (s390_gotplt_after_got_p): New function.
	(s390_got_pointer): New function.
	(s390_got_offset): New function.
	(s390_gotplt_offset): New function.
	* elf64-s390.c (allocate_dynrelocs): Adjust comment.
	(elf_s390_size_dynamic_sections): Move space for magic GOT entries
	from .got.plt to .got if necessary and pick the right location for
	_GLOBAL_OFFSET_TABLE_.
	(elf_s390_relocate_section): Use the wrapper functions from
	elf-s390-common.c to deal with both possible layouts (either .got
	or .got.plt first).
	(elf_s390_finish_dynamic_sections): Likewise.
	(elf_s390_finish_dynamic_symbol): Make the location of the GOT
	magic entries conditional.
2018-07-18 13:20:06 +02:00
Andreas Krebbel a38137289e ld: Enable using separate linker script for -z relro
With this patch dedicated linker scripts can be generated for partial
relro triggered by defining GENERATE_RELRO_SCRIPT in the target
specific scripts.

This is necessary for e.g. S/390 where usually the .got.plt comes
first and prevents the relro segment from being extended across the
non-plt GOT entries.

The patch started with the work from Marcin taken from the mwk user
branches.  However, the patch needed substantial changes due to the
'separate code' feature which got committed in the meantime.

ld/ChangeLog:

2018-07-18  Andreas Krebbel  <krebbel@linux.ibm.com>
	    Marcin Kościelnicki <koriakin@0x04.net>

	* emultempl/elf32.em: Add code to pick dedicated linker scripts
	for partial relro.
	* genscripts.sh: Generate dedicated linker scripts for partial relro.
2018-07-18 13:20:06 +02:00
Nick Clifton 0984c34e76 Updated French translation for gold and Spanish translation for ld.
ld	* po/es.po: Updated Spanish translation.
gold	* po/fr.po: Updated French translation.
2018-07-18 08:37:38 +01:00
GDB Administrator 012ab41373 Automatic date update in version.in 2018-07-18 00:00:35 +00:00
Tom Tromey c6c6149af4 Return unique_xmalloc_ptr from gdbscm_scm_to_string
This changes gdbscm_scm_to_string to return a unique_xmalloc_ptr and
then fixes all the callers.  This allows for the removal of some
cleanups.

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

	* guile/scm-param.c (pascm_set_func, pascm_show_func)
	(compute_enum_list, pascm_set_param_value_x)
	(gdbscm_parameter_value): Update.
	* guile/guile-internal.h (gdbscm_scm_to_string): Update.
	(gdbscm_scm_to_host_string): Update.
	* guile/scm-math.c (vlscm_convert_typed_value_from_scheme):
	Update.
	* guile/scm-cmd.c (cmdscm_add_completion): Update.
	* guile/scm-pretty-print.c (ppscm_print_string_repr): Update.
	* guile/scm-string.c (gdbscm_scm_to_string): Return
	unique_xmalloc_ptr.
	(gdbscm_scm_to_host_string): Likewise.
2018-07-17 13:21:48 -06:00
Tom Tromey a1a31cb8dc Return unique_xmalloc_ptr from gdbscm_safe_eval_string
This changes gdbscm_safe_eval_string to return a unique_xmalloc_ptr.
This allows for the removal of some cleanups.  It also fixes a
potential latent memory leak in gdbscm_set_backtrace.

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

	* guile/guile.c (gdbscm_eval_from_control_command): Update.
	* guile/guile-internal.h (gdbscm_safe_eval_string): Update.
	* guile/scm-objfile.c (gdbscm_execute_objfile_script): Update.
	* guile/scm-safe-call.c (gdbscm_safe_eval_string): Return
	unique_xmalloc_ptr.
2018-07-17 13:21:47 -06:00
Tom Tromey 15bf30027b Change gdbscm_exception_message_to_string to return a unique_xmalloc_ptr
This changes gdbscm_exception_message_to_string to return a
unique_xmalloc_ptr, allowing for the removal of some cleanups.
unique_xmalloc_ptr was chosen because at the root of the call chains
is a function from Guile that returns a malloc'd string.

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

	* guile/scm-param.c (pascm_signal_setshow_error): Update.
	* guile/guile-internal.h (gdbscm_exception_message_to_string):
	Update.
	* guile/scm-cmd.c (cmdscm_function): Update.
	* guile/scm-pretty-print.c
	(ppscm_print_exception_unless_memory_error): Update.
	* guile/scm-exception.c (gdbscm_exception_message_to_string):
	Return unique_xmalloc_ptr.
2018-07-17 13:21:47 -06:00
Tom Tromey 7eb1a66c26 Use std::string in ppscm_make_pp_type_error_exception
This changes ppscm_make_pp_type_error_exception to use std::string,
removing a cleanup.

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

	* guile/scm-pretty-print.c (ppscm_make_pp_type_error_exception):
	Use string_printf.
2018-07-17 13:21:46 -06:00
Maciej W. Rozycki c691de6a16 BFD: Use `bfd_is_abs_symbol' to determine whether a symbol is absolute
Use `bfd_is_abs_symbol' to determine whether a symbol is absolute,
avoiding a problem with ordinary symbols defined in a linker script
outside an output section definition.  Such symbols have its owning
section set to the absolute section up to the final link phase.  A flag
has been added to the link hash to identify such symbols.  Rather than
checking the flag by hand, use the macro that does it uniformly for all
users.

	bfd/
	* elf32-nds32.c (nds32_elf_relax_loadstore): Use
	`bfd_is_abs_symbol' rather than `bfd_is_abs_section' in checking
	whether the symbol is absolute.
	(nds32_elf_relax_lo12): Likewise.
	* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Likewise.
	(elfNN_aarch64_check_relocs): Likewise.
	* xcofflink.c (xcoff_need_ldrel_p): Likewise.
	(bfd_xcoff_import_symbol): Likewise.
	(xcoff_write_global_symbol): Likewise.
2018-07-17 20:04:53 +01:00
Maciej W. Rozycki d5c928c053 LD: Export relative-from-absolute symbol marking to BFD
It is usually possible to tell absolute and ordinary symbols apart in
BFD throughout the link, by checking whether the section that owns the
symbol is absolute or not.

That however does not work for ordinary symbols defined in a linker
script outside an output section statement.  Initially such symbols are
entered into to the link hash as absolute symbols, owned by the absolute
section.  A flag is set in the internal linker expression defining such
symbols to tell the linker to convert them to section-relative ones in
the final phase of the link.  That flag is however not accessible to BFD
linker code, including BFD target code in particular.

Add a flag to the link hash then to copy the information held in the
linker expression.  Define a macro, `bfd_is_abs_symbol', for BFD code to
use where determining whether a symbol is absolute or ordinary is
required before the final link phase.

This macro will correctly identify the special `__ehdr_start' symbol as
ordinary throughout link, for example, even though early on it will be
assigned to the absolute section.  Of course this does not let BFD code
identify what the symbol's ultimate section will be before the final
link phase has converted this symbol (in `update_definedness').

	include/
	* bfdlink.h (bfd_link_hash_entry): Add `rel_from_abs' member.

	bfd/
	* linker.c (bfd_is_abs_symbol): New macro.
	* bfd-in2.h: Regenerate.

	ld/
	* ldexp.c (exp_fold_tree_1) <etree_assign, etree_provide>
	<etree_provided>: Copy expression's `rel_from_abs' flag to the
	link hash.
2018-07-17 20:04:53 +01:00
Jim Wilson 27724bad00 RISC-V: Don't decrement pc after break.
gdb/
	* riscv-tdep.c (riscv_has_feature): Delete comment that refers to
	set_gdbarch_decr_pc_after_break.  Call riscv_read_misa_reg always.
	(riscv_gdbarch_init): Delete local has_compressed_isa.  Delete now
	unecessary braces after EF_RISCV_RVC test.  Delete call to
	set_gdbarch_decr_pc_after_break.
2018-07-17 09:44:42 -07:00
Jim Wilson ce73f31015 RISC-V: Correct legacy misa register number.
gdb/
	* riscv-tdep.h (DECLARE_CSR): Use RISCV_FIRST_CSR_REGNUM instead of
	RISCV_LAST_FP_REGNUM + 1.
	(RSICV_CSR_LEGACY_MISA_REGNUM): Add RISCV_FIRST_CSR_REGNUM.
2018-07-17 09:42:23 -07:00
Tom Tromey 056dec39ed Remove --disable-gdbcli
I think it doesn't really make sense to allow building gdb without the
CLI.  Perhaps at one time this was a goal, but libgdb is long gone and
the CLI is intrinsic to gdb.

So, this patch removes the implementation of this configure option.
It is still recognized (this is autoconf's default), but does nothing.

This simplifies configure.ac and Makefile.in a bit.

Tested by rebuilding.

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

	* configure.ac: Remove --disable-gdbcli.
	* configure: Rebuild.
	* Makefile.in (SUBDIR_CLI_DEPS, SUBDIR_CLI_LDFLAGS)
	(SUBDIR_CLI_CFLAGS): Remove.
	(SFILES): Use SUBDIR_CLI_SRCS.
	(COMMON_OBS): Use SUBDIR_CLI_OBS.
2018-07-17 09:54:17 -06:00
Tom Tromey 4735f0edf4 Use scoped_free_pendings in coff_symtab_read
PR gdb/18624 concerns an assertion failure that occurs when setting a
breakpoint in a Go program on Windows.

What happens here is that coff_symtab_read uses buildsym but does not
instantiate scoped_free_pendings.  So, the struct pending objects are
never released.  Later, dwarf2read.c calls buildsym_init, which
asserts.

This patch fixes the problem by instantiating scoped_free_pendings in
coff_symtab_read.

Tested using the test executable from the PR.  I don't know how to
test this more fully.

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

	PR gdb/18624:
	* coffread.c (coff_symtab_read): Use scoped_free_pendings.
2018-07-17 09:30:57 -06:00