Commit Graph

90150 Commits

Author SHA1 Message Date
Pip Cet 8fb740dd30 Add minimal support for WebAssembly backend to the BFD library.
include * elf/wasm32.h: New file to support wasm32 architecture.

bfd * cpu-wasm32.c: New file to support wasm32 architecture.
    * elf32-wasm32.c: New file to support wasm32 architecture.
    * Makefile.am: Add wasm32 architecture.
    * archures.c: Likewise.
    * config.bfd: Likewise.
    * configure.ac: Likewise.
    * targets.c: Likewise.
2017-03-27 11:39:50 +01:00
Rinat Zelig c0c31e91ad Implement ARC NPS-400 Ultra Ip and Miscellaneous instructions.
opcodes	* arc-nps400-tbl.h: Add Ultra Ip and Miscellaneous instructions format.
	* arc-opc.c: Add defines. e.g. F_NJ, F_NM , F_NO_T, F_NPS_SR, F_NPS_M, F_NPS_CORE, F_NPS_ALL.
	(insert_nps_misc_imm_offset): New function.
	(extract_nps_misc imm_offset): New function.
	(arc_num_flag_operands): Add F_NJ, F_NM, F_NO_T.
	(arc_flag_special_cases): Add F_NJ, F_NM, F_NO_T.

include * opcode/arc.h (insn_class_t): Add ULTRAIP and MISC class.

gas     * testsuite/gas/arc/nps400-12.s: New file.
        * testsuite/gas/arc/nps400-12.d: New file.
2017-03-27 11:14:30 +01:00
GDB Administrator cf31b44f3c Automatic date update in version.in 2017-03-27 00:00:35 +00:00
Jim Wilson f124168208 Fix bug with cmn/adds where C flag was incorrectly set.
sim/aarch64/
	* simulator.c (set_flags_for_add32): Cast result to uint32_t in carry
	flag check.

	sim/testsuite/sim/aarch64/
	* adds.s: Add checks for values -2 and 1, where C is not set.
2017-03-25 20:32:02 -07:00
GDB Administrator 7ed687b257 Automatic date update in version.in 2017-03-26 00:00:20 +00:00
GDB Administrator 275c67ffb4 Automatic date update in version.in 2017-03-25 00:00:12 +00:00
Alan Hayward ed771251e1 Remove MAX_REGISTER_SIZE from target.c
gdb/
	* regcache.c (regcache_debug_print_register): New function.
	* regcache.h (regcache_debug_print_register): New declaration.
	* target.c (debug_print_register): Remove.
	(target_fetch_registers): Call regcache_debug_print_register.
	(target_store_registers): Likewise.
2017-03-24 16:53:05 +00:00
Pádraig Brady 568c1b9f50 Avoid segfault on invalid directory table
gdb was segfaulting during backtrace on a binary here, where
fe->dir_index parsed from the DWARF info was seen to access beyond the
provided include_dirs array.

This commit bounds the access to entries actually written to the
array, and was verified to output the backtrace correctly.

gdb/ChangeLog:

	* dwarf2read.c (setup_type_unit_groups): Ensure dir_index doesn't
	reference beyond the 'lh->include_dirs' array before accessing to
	it.
	(psymtab_include_file_name): Likewise.
	(dwarf_decode_lines_1): Likewise.
	(dwarf_decode_lines): Likewise.
	(file_file_name): Likewise.
2017-03-24 15:12:53 +00:00
Thomas Preud'homme 62785b0998 [GAS/ARM] Fix selected_cpu with default CPU and -mcpu
When GAS is compiled with DEFAULT_CPU set and then run with a -mcpu or
-march option, selected_cpu will be set to the default CPU. This means
the -mcpu is ignored which is surprising behavior. This commit instead
sets selected_cpu from the value passed to -mcpu/-march.

2017-03-24  Thomas preud'homme  <thomas.preudhomme@arm.com>

gas/
	* config/tc-arm.: (md_begin): Set selected_cpu from *mcpu_cpu_opt when
	CPU_DEFAULT is defined.
2017-03-24 13:23:36 +00:00
Maciej W. Rozycki c72cea5aec readelf: Fix incorrect "Version definition past end of section" message (ChangeLog)
Correct ChangeLog entry for commit c9f02c3e29 ("readelf: Fix incorrect
"Version definition past end of section" message").
2017-03-24 12:25:49 +00:00
GDB Administrator cad1105d6a Automatic date update in version.in 2017-03-24 00:00:33 +00:00
Simon Marchi 3e00d44feb Remove some unnecessary inferior_ptid setting/restoring when fetching/storing registers
Now that the to_fetch_registers, to_store_registers and
to_prepare_to_store target methods don't rely on the value of
inferior_ptid anymore, we can remove a bunch of now unnecessary setting
and restoring of inferior_ptid.

The asserts added recently in target_fetch_registers and
target_store_registers, which validate that inferior_ptid matches the
regcache's ptid, must go away.  It's the whole point of this effort, to
not require inferior_ptid to have a particular value when calling these
functions.

One thing that I noticed is how sol-thread.c's ps_lgetregs and friends
use the current value of inferior_ptid instead of what's passed as
argument (ph->ptid), unlike proc-service.c's versions of the same
functions.  Is it expected?  I left it like this in the current patch,
but unless there's a good reason for it to be that way, I guess we
should make it use the parameter.

gdb/ChangeLog:

	* fbsd-tdep.c (fbsd_corefile_thread): Don't set/restore
	inferior_ptid.
	* proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs,
	ps_lsetfpregs): Likewise.
	* regcache.c (regcache_raw_update, regcache_raw_write): Likewise.
	* sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs,
	ps_lsetfpregs): Likewise.
	* target.c (target_fetch_registers, target_store_registers):
	Remove asserts.
2017-03-23 13:37:06 -04:00
Alan Hayward 077ae656a6 Remove MAX_REGISTER_SIZE from sol-thread.c
gdb/
	* sol-thread.c (sol_thread_store_registers): Remove regcache calls.
2017-03-23 14:40:58 +00:00
Yao Qi 1e2b521d98 Handle PRFM in AArch64 process record
This patch fixes the bug of handling PRFM instruction.  PRFM is documented
in a table with other load and store instructions, but it doesn't do any
load or store.  This patch also adds a unit test to PRFM instruction.

gdb:

2017-03-23  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c (aarch64_process_record_test): Declare.
	(_initialize_aarch64_tdep): Register it.
	(aarch64_record_load_store): Handle PRFM instruction.
	(aarch64_process_record_test): New function.
2017-03-23 14:11:04 +00:00
Yao Qi 338771252e Fix code indentation
gdb:

2017-03-23  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c (aarch64_record_load_store): Fix code
	indentation.
2017-03-23 14:11:04 +00:00
Yao Qi a0eef9404b Remove AARCH64_RECORD_FAILURE
It is not used at all.

gdb:

2017-03-23  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c: Remove AARCH64_RECORD_FAILURE.
2017-03-23 14:11:04 +00:00
Andreas Arnez 1a5e158b68 Remove constness of libdir in do_start_initialization
The patch "Fix memory leak in python.c:do_start_initialization"
(https://sourceware.org/ml/gdb-patches/2017-03/msg00407.html) introduced a
compilation error on some platforms:

  ../../binutils-gdb/gdb/python/python.c: In function bool do_start_initialization():
  ../../binutils-gdb/gdb/python/python.c:1556:16: error: invalid conversion from const void* to void* [-fpermissive]
   xfree (libdir);
                ^

This is fixed by removing the constness of libdir's data type.

gdb/ChangeLog:

	* python/python.c (do_start_initialization): Remove 'const' from
	data type of libdir.
2017-03-23 12:51:14 +01:00
Philipp Rudo 3f2a3564b1 Fix memory leak in python.c:do_start_initialization
When intializing Python the path to the python binary is build the
following way

progname = concat (ldirname (python_libdir), SLASH_STRING, "bin",
		   SLASH_STRING, "python", (char *) NULL);

This is problematic as both concat and ldirname allocate memory for the
string they return.  Thus the memory allocated by ldirname cannot be
accessed afterwards causing a memory leak.  Fix it by temporarily storing
libdir in a variable and xfree it after concat.

gdb/ChangeLog:
	python/python.c (do_start_initialization): Fix memory leak.
2017-03-23 12:22:11 +01:00
GDB Administrator ad36c6ce7c Automatic date update in version.in 2017-03-23 00:00:42 +00:00
Palmer Dabbelt 19683c0408 Sanitize RISC-V GAS help text, documentation
It looks like I missed the GAS help text when going through all the
documentation last time, so it printed some of the old-format (never
upstream) arguments.  I fixed this, and when I went to check doc/ I
noticed it was missing the '-fpic'/'-fno-pic' options.
2017-03-22 15:46:52 -07:00
Max Filippov 24e5b4e682 gas: xtensa: make trampolines relaxation work with jumps in slots other than 0
add_jump_to_trampoline assumes that jump instruction is in slot 0,
when it's in other slot that results in fixup that references NULL symbol,
which results in segfault later in xtensa_make_cached_fixup.
Search for the non-NULL symbol in the tc_frag_data.slot_symbols and check
that there's exactly one such slot.

xtensa_relax_frag for RELAX_TRAMPOLINE reassigns fixup from the original
instruction with jump to generated jump in the trampoline frag, but does not
fix its fx_r_type or fx_size. That results in "undecodable fix" or
"fixup not contained within frag" error messages during relaxation.
Fix both these fields.

gas/
2017-03-22  Max Filippov  <jcmvbkbc@gmail.com>

	* config/tc-xtensa.c (xtensa_relax_frag): Change fx_size of the
	reassigned fixup to size of jump instruction (3) and fx_r_type
	to BFD_RELOC_XTENSA_SLOT0_OP, as there's only one slot.
	(add_jump_to_trampoline): Search
	origfrag->tc_frag_data.slot_symbols for the slot with non-NULL
	symbol and use that slot instead of slot 0.
2017-03-22 10:35:18 -07:00
Simon Marchi b67aeab02c Remove lwp -> pid conversion in linux_nat_xfer_partial
The linux_nat_xfer_partial does a conversion of inferior_ptid: if it's
an LWP (ptid::lwp != 0), it builds a new ptid with the lwp as
the pid and assigns that temporarily to inferior_ptid.  For example, if
inferior_ptid is:

  { .pid = 1234, .lwp = 1235 }

it will assign this to inferior_ptid for the duration of the call:

  { .pid = 1235, .lwp = 0 }

Instead of doing this, this patch teaches the inf-ptrace implementation
of xfer_partial to deal with ptids representing lwps by using
get_ptrace_pid.

Also, in linux_proc_xfer_spu and linux_proc_xfer_partial, we use ptid_get_lwp
instead of ptid_get_pid.  While not strictly necessary, since the content of
/proc/<pid> and /proc/<lwp> should be the same, it's a bit safer, because:

- some files under /proc/<pid>/ may not work if the <pid> thread is
  running, just like ptrace requires a stopped thread.  The current
  thread's lwp id is more likely to be in the necessary state (stopped).

- if the leader (<pid>) had exited and is thus now zombie, then several
  files under "/proc/<pid>" won't work, while they will if you use
  "/proc/<lwp>".

The testsuite found no regression on native amd64 linux.

gdb/ChangeLog:

	* inf-ptrace.c (inf_ptrace_xfer_partial): Get pid from ptid
	using get_ptrace_pid.
	* linux-nat.c (linux_nat_xfer_partial): Don't set/restore
	inferior_ptid.
	(linux_proc_xfer_partial, linux_proc_xfer_spu): Use lwp of
	inferior_ptid instead of pid.
2017-03-22 10:35:16 -04:00
Nick Clifton 11997a83a0 Sync top level config files with master versions in the FSF config project.
* config.sub: Sync with master version in config project.
	* config.guess: Likewise.
2017-03-22 14:01:03 +00:00
Yao Qi 79778b30dc Remove @code for python
There's no reason to use @code for Python the name of a programming
language.

gdb/doc:

2017-03-22  Yao Qi  <yao.qi@linaro.org>

	* python.texi (Inferiors In Python): Remove @code from Python.
2017-03-22 12:40:24 +00:00
Yao Qi ffdbe8642e Wrap locally used classes in anonymous namespace
Both aarch64-tdep.c and arm-tdep.c defines a class instruction_reader, which
violates ODR, but linker doesn't an emit error.  I fix this issue by wrapping
them by anonymous namespace, but I think it is better to apply this for all
locally used classes.

If it is a good idea to put locally used class into anonymous namespace, we
should document this rule into GDB coding convention, or even GCC coding
convention.  Note that anonymous namespace has been used in GCC but GCC
coding convention doesn't mention the it.

gdb:

2017-03-22  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c: Wrap locally used classes in anonymous
	namespace.
	* arm-tdep.c: Likewise.
	* linespec.c: Likewise.
	* ui-out.c: Likewise.
2017-03-22 12:35:31 +00:00
Jonah Graham 9d736fbf01 Import sys in gdb/python/lib/gdb/printer/bound_registers.py
Pick up missing bits from the patch merged in.

2017-03-22  Jonah Graham  <jonah@kichwacoders.com>

	PR gdb/19637
	* python/lib/gdb/printer/bound_registers.py: Import sys.
2017-03-22 11:22:07 +00:00
GDB Administrator 3e6c756700 Automatic date update in version.in 2017-03-22 00:00:28 +00:00
Sandra Loosemore 4c8798c992 Disable shared library tests for nios2-*-elf.
The Nios II processor documentation defines relocations for PIC and
shared libraries as part of the GNU/Linux ABI only; GCC rejects -fpic
on bare-metal.

2017-03-21  Sandra Loosemore  <sandra@codesourcery.com>

	ld/
	* testsuite/lib/ld-lib.exp (check_shared_lib_support): Return
	false for nios2-*-elf.
2017-03-21 13:25:09 -07:00
Simon Marchi 3de88e9afb windows: Use ptid from regcache in register fetch/store
Use the ptid from the regcache so we don't depend on the current value
of the inferior_ptid global.

Also, change how the current thread is passed to sub-functions.  The
windows_fetch_inferior_registers function sets current_thread then calls
do_windows_fetch_inferior_registers, which reads current_thread.  This
very much looks like passing a parameter through a global variable.  I
think it would be more straightforward to pass the thread as a
parameter.

gdb/ChangeLog:

	* windows-nat.c (do_windows_fetch_inferior_registers): Add
	windows_thread_info parameter and use it instead of
	current_thread.
	(windows_fetch_inferior_registers): Don't set current_thread,
	pass the thread to do_windows_fetch_inferior_registers.  Use
	ptid from regcache instead of inferior_ptid.
	(do_windows_store_inferior_registers): Add windows_thread_info
	parameter and use it instead of current_thread.
	(windows_store_inferior_registers): Don't set current_thread,
	pass the thread to do_windows_store_inferior_registers.  Use
	ptid from regcache instead of inferior_ptid.
2017-03-21 11:35:54 -04:00
Simon Marchi 0e7b8f6106 Remove remaining reference to struct serial::current_timeout
I get this when trying to build for --host=x68_64-w64-mingw32:

/home/emaisin/src/binutils-gdb/gdb/ser-mingw.c: In function 'void ser_windows_raw(serial*)':
/home/emaisin/src/binutils-gdb/gdb/ser-mingw.c:166:8: error: 'struct serial' has no member named 'current_timeout'
   scb->current_timeout = 0;
        ^~~~~~~~~~~~~~~

It is just a leftover from

  9bcbdca808
  PR remote/21188: Fix remote serial timeout

gdb/ChangeLog:

	* ser-mingw.c (ser_windows_raw): Remove reference to
	struct serial::current_timeout.
2017-03-21 11:35:42 -04:00
Andreas Krebbel 2253c8f089 S/390: Remove vx2 facility flag
This patch removes the vx2 facility flag.  It will not be used by GCC
and was a misnomer anyway.

Committed to mainline and 2.28 branch.

include/ChangeLog:

2017-03-21  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

	* opcode/s390.h (S390_INSTR_FLAG_VX2): Remove.
	(S390_INSTR_FLAG_FACILITY_MASK): Adjust value.

gas/ChangeLog:

2017-03-21  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

	* config/tc-s390.c (s390_parse_cpu): Remove S390_INSTR_FLAG_VX2
	from cpu_table.  Remove vx2, and novx2 from cpu_flags.

opcodes/ChangeLog:

2017-03-21  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

	* s390-mkopc.c (main): Remove vx2 check.
	* s390-opc.txt: Remove vx2 instruction flags.
2017-03-21 14:21:02 +01:00
Andi Kleen 4a14e30646 Add --inlines option to objdump to include scope backtrace of inlined functions when generating source line number information.
* objdump.c (unwind_inlines): Add.
	(option_values): Add OPTION_INLINES.
	(show_line): Unwind inlines if requested.
	(main): Parse OPTION_INLINES.
	(usage): Document --inlines.
	* doc/binutils.texi: Document --inlines.
	* NEWS: Likewise.
2017-03-21 13:05:19 +00:00
Rinat Zelig 645d3342ba arc/nps400: Add cp16/cp32 instructions to opcodes library
Instructions for loading or storing 16/32B data from one address type to
another.

gas/ChangeLog

	* testsuite/gas/arc/nps400-11.s: New file.
	* testsuite/gas/arc/nps400-11.d: New file.

include/ChangeLog

	* opcode/arc.h (insn_class_t): Add DMA class.

opcodes/ChangeLog

	* arc-nps400-tbl.h: Add cp32/cp16 instructions format.
	* arc-opc.c: Add F_NPS_NA, NPS_DMA_IMM_ENTRY, NPS_DMA_IMM_OFFSET.
	(insert_nps_imm_offset): New function.
	(extract_nps_imm_offset): New function.
	(insert_nps_imm_entry): New function.
	(extract_nps_imm_entry): New function.
2017-03-21 11:51:49 +00:00
Nick Clifton 75d7d2986c Update support for GNU BUILD notes so that version notes can contain extra information, and stack protection notes can contain numeric values.
* readelf.c (print_gnu_build_attribute_name): Allow stack
	protection notes to contain numeric values.  Use a colon rather
	than a space to separate a string name from its values.  Decode
	the numeric value of a stack protection note.
	* objcopy.c (merge_gnu_build_notes): Allow version notes to
	contain extra text after the protocol version number.
2017-03-21 11:48:57 +00:00
Ivo Raisr 5badf10a18 Decode properly flags of %ccr register on sparc64.
While at it, decode also properly one-bit flags for %fsr (accrued and
current exception flags were mixed up).

ChangeLog entry:
2017-03-21  Ivo Raisr  <ivo.raisr@oracle.com>

    	PR tdep/20928
    	* gdb/sparc-tdep.h (gdbarch_tdep) <sparc64_ccr_type>: New field.
    	* gdb/sparc64-tdep.c (sparc64_ccr_type): New function.
    	(sparc64_fsr_type): Fix %fsr decoding.

ChangeLog entry for testsuite:
2017-03-21  Ivo Raisr  <ivo.raisr@oracle.com>

    	PR tdep/20928
    	* gdb.arch/sparc64-regs.exp: New file.
    	* gdb.arch/sparc64-regs.S: Likewise.
2017-03-21 04:39:33 -07:00
Tristan Gingold 2170171889 ld: check overflow only for allocated sections.
* ldlang.c (lang_check_section_addresses): Check only for
	allocated sections.
2017-03-21 12:00:30 +01:00
Tim Wiederhake cee59b3fea Fix break on Python 2
This changes the return type of "gdb.BtraceInstruction.data ()" from
"memoryview" to "buffer" on Python 2.7 and below, similar to what
"gdb.Inferior.read_memory ()" does.
2017-03-21 08:19:59 +01:00
GDB Administrator 09220eae9d Automatic date update in version.in 2017-03-21 00:00:24 +00:00
Simon Marchi 639a9038c9 spu: Use ptid from regcache instead of inferior_ptid
The implementations of to_fetch_registers/to_store_registers in the spu
code use some functions that rely on inferior_ptid.  It's simpler for
now to set/restore inferior_ptid.

gdb/ChangeLog:

	* spu-linux-nat.c (spu_fetch_inferior_registers,
	spu_store_inferior_registers): Use ptid from regcache, set and
	restore inferior_ptid.
	* spu-multiarch.c (spu_fetch_registers, spu_store_registers):
	Likewise.
2017-03-20 18:23:47 -04:00
Simon Marchi bcc0c096d5 Use ptid from regcache in almost all remaining nat files
This patch contains almost all of the remaining changes needed to make
to_fetch_registers/to_store_registers/to_prepare_to_store independent of
inferior_ptid.  It contains only some "trivial" changes, the more
complicated ones are in separate patches.

gdb/ChangeLog:

	* i386-linux-nat.c (fetch_register, store_register,
	i386_linux_fetch_inferior_registers,
	i386_linux_store_inferior_registers): Use ptid from regcache.
	* ia64-linux-nat.c (ia64_linux_fetch_register,
	ia64_linux_store_register): Likewise.
	* inf-ptrace.c (inf_ptrace_fetch_register,
	inf_ptrace_store_register): Likewise.
	* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers,
	m32r_linux_store_inferior_registers): Likewise.
	* m68k-bsd-nat.c (m68kbsd_fetch_inferior_registers,
	m68kbsd_store_inferior_registers): Likewise.
	* m68k-linux-nat.c (fetch_register, store_register,
	m68k_linux_fetch_inferior_registers,
	m68k_linux_store_inferior_registers): Likewise.
	* m88k-bsd-nat.c (m88kbsd_fetch_inferior_registers,
	m88kbsd_store_inferior_registers): Likewise.
	* mips-fbsd-nat.c (mips_fbsd_fetch_inferior_registers,
	mips_fbsd_store_inferior_registers): Likewise.
	* mips-linux-nat.c (mips64_linux_regsets_fetch_registers,
	mips64_linux_regsets_store_registers): Likewise.
	* mips-nbsd-nat.c (mipsnbsd_fetch_inferior_registers,
	mipsnbsd_store_inferior_registers): Likewise.
	* mips-obsd-nat.c (mips64obsd_fetch_inferior_registers,
	mips64obsd_store_inferior_registers): Likewise.
	* nto-procfs.c (procfs_fetch_registers, procfs_store_registers):
	Likewise.
	* ppc-fbsd-nat.c (ppcfbsd_fetch_inferior_registers,
	ppcfbsd_store_inferior_registers): Likewise.
	* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers,
	ppc_linux_store_inferior_registers): Likewise.
	* ppc-nbsd-nat.c (ppcnbsd_fetch_inferior_registers,
	ppcnbsd_store_inferior_registers): Likewise.
	* ppc-obsd-nat.c (ppcobsd_fetch_registers,
	ppcobsd_store_registers): Likewise.
	* procfs.c (procfs_fetch_registers, procfs_store_registers):
	Likewise.
	* ravenscar-thread.c (ravenscar_fetch_registers,
	ravenscar_store_registers, ravenscar_prepare_to_store):
	Likewise.
	* record-btrace.c (record_btrace_fetch_registers,
	record_btrace_store_registers, record_btrace_prepare_to_store):
	Likewise.
	* remote-sim.c (gdbsim_fetch_register, gdbsim_store_register):
	Lookup inferior using ptid from regcache, instead of
	current_inferior.
	* remote.c (remote_fetch_registers, remote_store_registers): Use
	ptid from regcache.
	* rs6000-nat.c (fetch_register, store_register): Likewise.
	* s390-linux-nat.c (s390_linux_fetch_inferior_registers,
	s390_linux_store_inferior_registers): Likewise.
	* sh-nbsd-nat.c (shnbsd_fetch_inferior_registers,
	shnbsd_store_inferior_registers): Likewise.
	* sol-thread.c (sol_thread_fetch_registers,
	sol_thread_store_registers): Likewise.
	* sparc-nat.c (sparc_fetch_inferior_registers,
	sparc_store_inferior_registers): Likewise.
	* tilegx-linux-nat.c (fetch_inferior_registers,
	store_inferior_registers): Likewise.
	* vax-bsd-nat.c (vaxbsd_fetch_inferior_registers,
	vaxbsd_store_inferior_registers): Likewise.
	* xtensa-linux-nat.c (fetch_gregs, store_gregs, fetch_xtregs,
	store_xtregs): Likewise.
2017-03-20 17:37:36 -04:00
Artemiy Volkov c0f55cc689 Add rvalue reference tests and docs
This patch adds tests for the initial rvalue reference support patchset.  All
of the new tests are practically mirrored regular references tests and, except
for the demangler ones, are introduced in new files, which are set to be
compiled with -std=gnu++11.  Tested are printing of rvalue reference types and
values, rvalue reference parameters in function overloading, demangling of
function names containing rvalue reference parameters, casts to rvalue
reference types, application of the sizeof operator to rvalue reference types
and values, and support for rvalue references within the gdb python module.

gdb/ChnageLog

	PR gdb/14441
	* NEWS: Mention support for rvalue references in GDB and python.
	* doc/gdb.texinfo (C Plus Plus Expressions): Mention that GDB
	supports both lvalue and rvalue references.

gdb/testsuite/ChangeLog

	PR gdb/14441
	* gdb.cp/demangle.exp: Add rvalue reference tests.
	* gdb.cp/rvalue-ref-casts.cc: New file.
	* gdb.cp/rvalue-ref-casts.exp: New file.
	* gdb.cp/rvalue-ref-overload.cc: New file.
	* gdb.cp/rvalue-ref-overload.exp: New file.
	* gdb.cp/rvalue-ref-params.cc: New file.
	* gdb.cp/rvalue-ref-params.exp: New file.
	* gdb.cp/rvalue-ref-sizeof.cc: New file.
	* gdb.cp/rvalue-ref-sizeof.exp: New file.
	* gdb.cp/rvalue-ref-types.cc: New file.
	* gdb.cp/rvalue-ref-types.exp: New file.
	* gdb.python/py-rvalue-ref-value-cc.cc: New file.
	* gdb.python/py-rvalue-ref-value-cc.exp: New file.
2017-03-20 13:47:59 -07:00
Artemiy Volkov 15c0a2a930 Add rvalue references to overloading resolution
This patch introduces changes to rank_one_type() dealing with ranking an rvalue
reference type when selecting a best viable function from a set of candidate
functions. The 4 new added rules for rvalue references are:

1) An rvalue argument cannot be bound to a non-const lvalue reference parameter
and an lvalue argument cannot be bound to an rvalue reference parameter.
[C++11 13.3.3.1.4p3]

2) If a conversion to one type of reference is an identity conversion, and a
conversion to the second type of reference is a non-identity conversion, choose
the first type. [C++11 13.3.3.2p3]

3) An rvalue should be first tried to bind to an rvalue reference, and then to
an lvalue reference. [C++11 13.3.3.2p3]

4) An lvalue reference to a function gets higher priority than an rvalue
reference to a function. [C++11 13.3.3.2p3]

This patch is not exactly correct.  See c++/15372 for tracking overload
resolution bugs.

gdb/ChangeLog

	PR gdb/14441
	* gdbtypes.c (rank_one_type): Implement overloading
	resolution rules regarding rvalue references.
2017-03-20 13:47:57 -07:00
Artemiy Volkov aa0061181a Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.

gdb/ChangeLog

	PR gdb/14441
	* aarch64-tdep.c (aarch64_type_align)
	(aarch64_extract_return_value, aarch64_store_return_value): Change
	lvalue reference type checks to general reference type checks.
	* amd64-tdep.c (amd64_classify): Likewise.
	* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
	Likewise.
	* arm-tdep.c (arm_type_align, arm_extract_return_value)
	(arm_store_return_value): Likewise.
	* ax-gdb.c (gen_fetch, gen_cast): Likewise.
	* c-typeprint.c (c_print_type): Likewise.
	* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
	(cplus_number_of_children, cplus_describe_child): Likewise.
	* compile/compile-c-symbols.c (generate_vla_size): Likewise.
	* completer.c (expression_completer): Likewise.
	* cp-support.c (make_symbol_overload_list_adl_namespace):
	Likewise.
	* darwin-nat-info.c (info_mach_region_command): Likewise.
	* dwarf2loc.c (entry_data_value_coerce_ref)
	(value_of_dwarf_reg_entry): Likewise.
	* eval.c (ptrmath_type_p, evaluate_subexp_standard)
	(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
	Likewise.
	* findvar.c (extract_typed_address, store_typed_address):
	Likewise.
	* gdbtypes.c (rank_one_type): Likewise.
	* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
	* infcall.c (value_arg_coerce): Likewise.
	* language.c (pointer_type): Likewise.
	* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
	Likewise.
	* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
	* mn10300-tdep.c (mn10300_type_align): Likewise.
	* msp430-tdep.c (msp430_push_dummy_call): Likewise.
	* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
	(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
	Likewise.
	* printcmd.c (print_formatted, x_command): Likewise.
	* python/py-type.c (typy_get_composite, typy_template_argument):
	Likewise.
	* python/py-value.c (valpy_referenced_value)
	(valpy_get_dynamic_type, value_has_field): Likewise.
	* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
	* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
	* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
	* spu-tdep.c (spu_scalar_value_p): Likewise.
	* symtab.c (lookup_symbol_aux): Likewise.
	* typeprint.c (whatis_exp, print_type_scalar): Likewise.
	* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
	Likewise.
	* valops.c (value_cast_pointers, value_cast)
	(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
	(value_struct_elt, value_struct_elt_bitpos)
	(value_find_oload_method_list, find_overload_match)
	(value_rtti_indirect_type): Likewise.
	* valprint.c (val_print_scalar_type_p, generic_val_print):
	Likewise.
	* value.c (value_actual_type, value_as_address, unpack_long)
	(pack_long, pack_unsigned_long, coerce_ref_if_computed)
	(coerce_ref): Likewise.
	* varobj.c (varobj_get_value_type): Likewise.
2017-03-20 13:47:54 -07:00
Artemiy Volkov 3fcf899da1 Support rvalue references in the gdb python module (includes doc/)
This patch adds the ability to inspect rvalue reference types and values using
the gdb python module. This is achieved by creating two wrappers for
valpy_reference_value(), using the ReferenceExplorer class to handle the
objects of rvalue reference types and placing necessary checks for a
TYPE_CODE_RVALUE_REF type code next to the checks for a TYPE_CODE_REF type
code.

gdb/ChangeLog

	PR gdb/14441
	* doc/python.texi (Types in Python): Add TYPE_CODE_RVALUE_REF to
	table of constants.
	* python/lib/gdb/command/explore.py: Support exploring values
	of rvalue reference types.
	* python/lib/gdb/types.py: Implement get_basic_type() for
	rvalue reference types.
	* python/py-type.c (pyty_codes) <TYPE_CODE_RVALUE_REF>: New
	constant.
	* python/py-value.c (valpy_getitem): Add an rvalue reference
	check.
	(valpy_reference_value): Add new parameter "refcode".
	(valpy_lvalue_reference_value, valpy_rvalue_reference_value):
	New wrappers for valpy_reference_value().
	* python/py-xmethods.c (gdbpy_get_xmethod_result_type)
	(gdbpy_invoke_xmethod): Likewise.
2017-03-20 13:47:52 -07:00
Artemiy Volkov 4297a3f002 Support DW_TAG_rvalue_reference type
Make gdb DWARF reader understand the DW_TAG_rvalue_reference type tag. Handling
of this tag is done in the existing read_tag_reference_type() function, to
which we add a new parameter representing the kind of reference type
(lvalue vs rvalue).

gdb/ChangeLog

	PR gdb/14441
	* dwarf2read.c (process_die, read_type_die_1): Handle the
	DW_TAG_rvalue_reference_type DIE.
	(read_tag_reference_type): Add new parameter "refcode".
2017-03-20 13:47:50 -07:00
Artemiy Volkov e1cb321347 Implement printing of rvalue reference types and values
This patch provides the ability to print out names of rvalue reference types
and values of those types. This is done in full similarity to regular
references, and as with them, we don't print out "const" suffix because all
rvalue references are const.

gdb/ChangeLog

	PR gdb/14441
	* c-typeprint.c (c_print_type, c_type_print_varspec_prefix)
	(c_type_print_modifier, c_type_print_varspec_suffix)
	(c_type_print_base): Support printing rvalue reference types.
	* c-valprint.c (c_val_print, c_value_print): Support printing
	rvalue reference values.
2017-03-20 13:47:48 -07:00
Artemiy Volkov e4347c89f3 Implement demangling for rvalue reference type names
This patch fixes demangling of names containing rvalue reference typenames by
handling DEMANGLE_COMPONENT_RVALUE_REFERENCE demangle component.

gdb/ChangeLog

	PR gdb/14441
	* cp-name-parser.y (ptr_operator): Handle the '&&' token in
	typename.
	* cp-support.c (replace_typedefs): Handle
	DEMANGLE_COMPONENT_RVALUE_REFERENCE.
	* python/py-type.c (typy_lookup_type): Likewise.
2017-03-20 13:47:46 -07:00
Artemiy Volkov 53cc15f5fe Support rvalue reference type in parser
This patch implements correct parsing of C++11 rvalue reference typenames.
This is done in full similarity to the handling of regular references by adding
a '&&' token handling in c-exp.y, defining an rvalue reference type piece, and
implementing a follow type derivation in follow_types().

gdb/ChangeLog

	PR gdb/14441
	* c-exp.y (ptr_operator): Handle the '&&' token in the typename.
	* parse.c (insert_type): Change assert statement.
	(follow_types): Handle rvalue reference types.
	* parser-defs.h (enum type_pieces) <tp_rvalue_reference>: New
	constant.
2017-03-20 13:47:43 -07:00
Artemiy Volkov a65cfae5f8 Add ability to return rvalue reference values from value_ref
Parameterize value_ref() by the kind of reference type the value of which
is requested. Change all callers to use the new API.

gdb/ChangeLog

	PR gdb/14441
	* ada-lang.c (ada_evaluate_subexp): Adhere to the new
	value_ref() interface.
	* c-valprint.c (c_value_print): Likewise.
	* infcall.c (value_arg_coerce): Likewise.
	* python/py-value.c (valpy_reference_value): Likewise.
	* valops.c (value_cast, value_reinterpret_cast)
	(value_dynamic_cast, typecmp): Likewise.
	(value_ref): Parameterize by kind of return value reference type.
	* value.h (value_ref): Add new parameter "refcode".
2017-03-20 13:47:41 -07:00
Artemiy Volkov 3b22433085 Change {lookup,make}_reference_type API
Parameterize lookup_reference_type() and make_reference_type() by the kind of
reference type we want to look up. Create two wrapper functions
lookup_{lvalue,rvalue}_reference_type() for lookup_reference_type() to simplify
the API. Change all callers to use the new API.

gdb/Changelog

	PR gdb/14441
	* dwarf2read.c (read_tag_reference_type): Use
	lookup_lvalue_reference_type() instead of lookup_reference_type().
	* eval.c (evaluate_subexp_standard): Likewise.
	* f-exp.y: Likewise.
	* gdbtypes.c (make_reference_type, lookup_reference_type):
	Generalize with rvalue reference types.
	(lookup_lvalue_reference_type, lookup_rvalue_reference_type): New
	convenience wrappers for lookup_reference_type().
	* gdbtypes.h (make_reference_type, lookup_reference_type): Add a
	reference kind parameter.
	(lookup_lvalue_reference_type, lookup_rvalue_reference_type): Add
	wrappers for lookup_reference_type().
	* guile/scm-type.c (gdbscm_type_reference): Use
	lookup_lvalue_reference_type() instead of lookup_reference_type().
	* guile/scm-value.c (gdbscm_value_dynamic_type): Likewise.
	* parse.c (follow_types): Likewise.
	* python/py-type.c (typy_reference, typy_lookup_type): Likewise.
	* python/py-value.c (valpy_get_dynamic_type, valpy_getitem):
	Likewise.
	* python/py-xmethods.c (gdbpy_get_xmethod_result_type)
	(gdbpy_invoke_xmethod): Likewise.
	* stabsread.c: Provide extra argument to make_reference_type()
	call.
	* valops.c (value_ref, value_rtti_indirect_type): Use
	lookup_lvalue_reference_type() instead of lookup_reference_type().
2017-03-20 13:47:39 -07:00