Commit Graph

95877 Commits

Author SHA1 Message Date
Edjunior Barbosa Machado f2cf6173f3 [PowerPC] Add support for TAR
This patch adds support for the Target Address Register for powerpc
linux native and core file targets, and in the powerpc linux server
stub.

gdb/ChangeLog:
2018-10-26  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>
	    Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* arch/ppc-linux-tdesc.h (tdesc_powerpc_isa207_vsx32l)
	(tdesc_powerpc_isa207_vsx64l): Declare.
	* arch/ppc-linux-common.h (PPC_LINUX_SIZEOF_TARREGSET): Define.
	(struct ppc_linux_features) <isa207>: New field.
	(ppc_linux_no_features): Add initializer for isa207 field.
	* arch/ppc-linux-common.c (ppc_linux_match_description): Return
	new tdescs.
	* nat/ppc-linux.h (PPC_FEATURE2_ARCH_2_07, PPC_FEATURE2_TAR)
	(NT_PPC_TAR): Define if not already defined.
	* features/Makefile (WHICH): Add rs6000/powerpc-isa207-vsx32l and
	rs6000/powerpc-isa207-vsx64l.
	(XMLTOC): Add rs6000/powerpc-isa207-vsx32l.xml and
	rs6000/powerpc-isa207-vsx64l.xml.
	* features/rs6000/power-tar.xml: New file.
	* features/rs6000/powerpc-isa207-vsx32l.xml: New file.
	* features/rs6000/powerpc-isa207-vsx64l.xml: New file.
	* features/rs6000/powerpc-isa207-vsx32l.c: Generate.
	* features/rs6000/powerpc-isa207-vsx64l.c: Generate.
	* regformats/rs6000/powerpc-isa207-vsx32l.dat: Generate.
	* regformats/rs6000/powerpc-isa207-vsx64l.dat: Generate.
	* ppc-linux-nat.c (fetch_register, fetch_ppc_registers): Call
	fetch_regset with the TAR regset.
	(store_register, store_ppc_registers): Call store_regset with the
	TAR regset.
	(ppc_linux_nat_target::read_description): Set isa207 field in the
	features struct if needed.
	* ppc-linux-tdep.c: Include
	features/rs6000/powerpc-isa207-vsx32l.c and
	features/rs6000/powerpc-isa207-vsx64l.c.
	(ppc32_regmap_tar, ppc32_linux_tarregset): New globals.
	(ppc_linux_iterate_over_regset_sections): Call back with the tar
	regset.
	(ppc_linux_core_read_description): Check if the tar section is
	present and set isa207 in the features struct.
	(_initialize_ppc_linux_tdep): Call
	initialize_tdesc_powerpc_isa207_vsx32l and
	initialize_tdesc_powerpc_isa207_vsx64l.
	* ppc-linux-tdep.h (ppc32_linux_tarregset): Declare.
	* ppc-tdep.h (gdbarch_tdep) <ppc_tar_regnum>: New field.
	(enum) <PPC_TAR_REGNUM>: New enum value.
	* rs6000-tdep.c (rs6000_gdbarch_init): Look for and validate tar
	feature.
	(ppc_process_record_op31): Record changes to TAR.

gdb/gdbserver/ChangeLog:
2018-10-26  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* configure.srv (ipa_ppc_linux_regobj): Add
	powerpc-isa207-vsx64l-ipa.o and powerpc-isa207-vsx32l-ipa.o.
	(powerpc*-*-linux*): Add powerpc-isa207-vsx32l.o and
	powerpc-isa207-vsx64l.o to srv_regobj, add rs6000/power-tar.xml,
	rs6000/powerpc-isa207-vsx32l.xml, and
	rs6000/powerpc-isa207-vsx64l.xml to srv_xmlfiles.
	* linux-ppc-tdesc-init.h (enum ppc_linux_tdesc)
	<PPC_TDESC_ISA207_VSX>: New enum value.
	(init_registers_powerpc_isa207_vsx32l): Declare.
	(init_registers_powerpc_isa207_vsx64l): Declare.
	* linux-ppc-low.c (ppc_fill_tarregset): New function.
	(ppc_store_tarregset): New function.
	(ppc_regsets): Add entry for the TAR regset.
	(ppc_arch_setup): Set isa207 in features struct when needed.  Set
	size for the TAR regsets.
	(ppc_get_ipa_tdesc_idx): Return PPC_TDESC_ISA207_VSX.
	(initialize_low_arch): Call init_registers_powerpc_isa207_vsx32l
	and init_registers_powerpc_isa207_vsx64l.
	* linux-ppc-ipa.c (get_ipa_tdesc): Handle PPC_TDESC_ISA207_VSX.
	(initialize_low_tracepoint): Call
	init_registers_powerpc_isa207_vsx32l and
	init_registers_powerpc_isa207_vsx64l.

gdb/testsuite/ChangeLog:
2018-10-26  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* gdb.arch/powerpc-tar.c: New file.
	* gdb.arch/powerpc-tar.exp: New file.

gdb/doc/ChangeLog:
2018-10-26  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* gdb.texinfo (PowerPC Features): Describe new feature
	"org.gnu.gdb.power.tar".
2018-10-26 10:11:33 -03:00
Edjunior Barbosa Machado 7ca18ed6d2 [PowerPC] Add support for PPR and DSCR
This patch adds gdb support for the Program Priorty Register and the
Data Stream Control Register, for the powerpc linux native and core
file targets, and for the powerpc linux server stub.

gdb/ChangeLog:
2018-10-26  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>
	    Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* arch/ppc-linux-tdesc.h (tdesc_powerpc_isa205_ppr_dscr_vsx32l)
	(tdesc_powerpc_isa205_ppr_dscr_vsx64l): Declare.
	* arch/ppc-linux-common.h (PPC_LINUX_SIZEOF_PPRREGSET)
	(PPC_LINUX_SIZEOF_DSCRREGSET): Define.
	(struct ppc_linux_features) <ppr_dscr>: New field.
	(ppc_linux_no_features): Add initializer for ppr_dscr field.
	* arch/ppc-linux-common.c (ppc_linux_match_description): Return
	new tdescs.
	* nat/ppc-linux.h (PPC_FEATURE2_DSCR, NT_PPC_PPR, NT_PPC_DSCR):
	Define if not already defined.
	* features/Makefile (WHICH): Add
	rs6000/powerpc-isa205-ppr-dscr-vsx32l and
	rs6000/powerpc-isa205-ppr-dscr-vsx64l.
	(XMLTOC): Add rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml and
	rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml.
	* features/rs6000/power-dscr.xml: New file.
	* features/rs6000/power-ppr.xml: New file.
	* features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml: New file.
	* features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml: New file.
	* features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c: Generate.
	* features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c: Generate.
	* regformats/rs6000/powerpc-isa205-ppr-dscr-vsx32l.dat: Generate.
	* regformats/rs6000/powerpc-isa205-ppr-dscr-vsx64l.dat: Generate.
	* ppc-linux-nat.c: Include <sys/uio.h>.
	(fetch_regset, store_regset, check_regset): New functions.
	(fetch_register, fetch_ppc_registers): Call fetch_regset with
	DSCR and PPR regsets.
	(store_register, store_ppc_registers): Call store_regset with
	DSCR and PPR regsets.
	(ppc_linux_get_hwcap2): New function.
	(ppc_linux_nat_target::read_description): Call
	ppc_linux_get_hwcap2 and check_regset, set ppr_dscr field in the
	features struct if needed.
	* ppc-linux-tdep.c: Include
	features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c and
	features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c.
	(ppc32_regmap_ppr, ppc32_regmap_dscr, ppc32_linux_pprregset)
	(ppc32_linux_dscrregset): New globals.
	(ppc_linux_iterate_over_regset_sections): Call back with the ppr
	and dscr regsets.
	(ppc_linux_core_read_description): Check if the ppr and dscr
	sections are present and set ppr_dscr in the features struct.
	(_initialize_ppc_linux_tdep): Call
	initialize_tdesc_powerpc_isa205_ppr_dscr_vsx32l and
	initialize_tdesc_powerpc_isa205_ppr_dscr_vsx64l.
	* ppc-linux-tdep.h (ppc32_linux_pprregset)
	(ppc32_linux_dscrregset): Declare.
	* ppc-tdep.h (struct gdbarch_tdep) <ppc_ppr_regnum>: New field.
	<ppc_dscr_regnum>: New field.
	(enum) <PPC_PPR_REGNUM, PPC_DSCR_REGNUM>: New enum values.
	* rs6000-tdep.c (rs6000_gdbarch_init): Look for and validate ppr
	and dscr features.
	(ppc_process_record_op31): Record changes to PPR and DSCR.

gdb/gdbserver/ChangeLog:
2018-10-26  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>
	    Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* configure.srv (ipa_ppc_linux_regobj): Add
	powerpc-isa205-ppr-dscr-vsx32l-ipa.o and
	powerpc-isa205-ppr-dscr-vsx64l-ipa.o.
	(powerpc*-*-linux*): Add powerpc-isa205-ppr-dscr-vsx32l.o and
	powerpc-isa205-ppr-dscr-vsx64l.o to srv_regobj, add
	rs6000/power-dscr.xml, rs6000/power-ppr.xml,
	rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml and
	rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml to srv_xmlfiles.
	* linux-ppc-tdesc-init.h (enum ppc_linux_tdesc)
	<PPC_TDESC_ISA205_PPR_DSCR_VSX>: New enum value.
	(init_registers_powerpc_isa205_ppr_dscr_vsx32l)
	(init_registers_powerpc_isa205_ppr_dscr_vsx64l): Declare.
	* linux-ppc-low.c: Include "elf/common.h" and <sys/uio.h>.
	(ppc_hwcap): Add comment.
	(ppc_hwcap2): New global.
	(ppc_check_regset, ppc_fill_pprregset, ppc_store_pprregset)
	(ppc_fill_dscrregset, ppc_store_dscrregset): New functions.
	(ppc_regsets): Add entries for the DSCR and PPR regsets.
	(ppc_arch_setup): Get AT_HWCAP2.  Set ppr_dscr in features struct
	when needed.  Set sizes for the the DSCR and PPR regsets.
	(ppc_get_ipa_tdesc_idx): Return PPC_TDESC_ISA205_PPR_DSCR_VSX.
	(initialize_low_arch): Call
	init_registers_powerpc_isa205_ppr_dscr_vsx32l and
	init_registers_powerpc_isa205_ppr_dscr_vsx64l.
	* linux-ppc-ipa.c (get_ipa_tdesc): Handle
	PPC_TDESC_ISA205_PPR_DSCR_VSX.
	(initialize_low_tracepoint): Call
	init_registers_powerpc_isa205_ppr_dscr_vsx32l and
	init_registers_powerpc_isa205_ppr_dscr_vsx64l.

gdb/testsuite/ChangeLog:
2018-10-26  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* gdb.arch/powerpc-ppr-dscr.c: New file.
	* gdb.arch/powerpc-ppr-dscr.exp: New file.

gdb/doc/ChangeLog:
2018-10-26  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* gdb.texinfo (PowerPC Features): Describe new features
	"org.gnu.gdb.power.ppr" and "org.gnu.gdb.power.dscr".
2018-10-26 10:03:46 -03:00
Pedro Franco de Carvalho 93b4691f0f [PowerPC] Refactor have_ initializers in rs6000-tdep.c
This patch refactors a series of initializers in rs6000_gdbarch_init
for clarity.  The have_fpu initializer is also changed to set the
variable to 0, like the other similar variables.  This doesn't affect
program behavior.

gdb/ChangeLog:
2018-10-26  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* rs6000-tdep.c (rs6000_gdbarch_init): Replace line wrapping by a
	second initializer line for the have_* variables.  Initialize
	have_fpu to 0 instead of 1.
2018-10-26 09:57:07 -03:00
Pedro Franco de Carvalho 71733a7bf6 [PowerPC] Fix indentation in arch/ppc-linux-common.c
This patch parenthesizes the tdesc selection expressions in
arch/ppc-linux-common.c so that they can be tab-indented.

gdb/ChangeLog:
2018-10-26  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* arch/ppc-linux-common.c (ppc_linux_match_description):
	Parenthesize tdesc assignements and indent them properly.
2018-10-26 09:54:04 -03:00
Pedro Franco de Carvalho 3d907528ca [PowerPC] Fix two if statements in gdb/ppc-linux-nat.c
This patch changes two if statements to else if statements in
ppc-linux-nat.c:fetch_register for clarity.

gdb/ChangeLog:
2018-10-26  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* ppc-linux-nat.c (fetch_register): Change if statement to else
	if.
	(store_register): Likewise.
2018-10-26 09:52:37 -03:00
Pedro Franco de Carvalho 500f01a0e2 [PowerPC] Remove rs6000_pseudo_register_reggroup_p
This patch removes rs6000_pseudo_register_reggroup_p.

Group membership for the pseudoregisters can be detected through their
types in default_register_reggroup_p through
tdesc_register_reggroup_p.

gdb/ChangeLog:
2018-10-26  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* rs6000-tdep.c: Remove reggroups.h include.
	(rs6000_pseudo_register_reggroup_p): Remove.
	(rs6000_gdbarch_init): Remove call to
	set_tdesc_pseudo_register_reggroup_p.
2018-10-26 09:51:08 -03:00
Pedro Franco de Carvalho 7ed29001c4 Add decfloat registers to float reggroup
This patch changes default_register_reggroup_p to return true when the
register type is decimal floating point and the reggroup is
float_reggroup.

gdb/ChangeLog:
2018-10-26  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* reggroups.c (default_register_reggroup_p): Return true for
	decfloat registers and float_reggroup.
2018-10-26 09:48:33 -03:00
Pedro Franco de Carvalho 5c849b222b [PowerPC] Don't zero-initialize vector register buffers
Now that linux-tdep.c already zero-initializes the buffer used for
generating core file notes, there is no need to do this in the linux
collect functions for the vector regset.  The memsets in gdbserver were
not useful to begin with.

gdb/ChangeLog:
2018-10-26  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* ppc-linux-tdep.c (ppc_linux_collect_vrregset): Remove.
	(ppc32_le_linux_vrregset, ppc32_be_linux_vrregset): Replace
	ppc_linux_collect_vrregset by regcache_collect_regset.

gdb/gdbserver/ChangeLog:
2018-10-26  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* linux-ppc-low.c (ppc_fill_vrregset): Remove memset calls.
2018-10-26 09:46:02 -03:00
Pedro Franco de Carvalho afde3032dd Zero-initialize linux note sections
This patches changes linux-tdep.c so that the buffer used to write
note sections when generating a core file is zero-initialized.  This
way, bytes that are not collected won't contain random
data (e.g. padding bytes).

gdb/ChangeLog:
2018-10-26  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* linux-tdep.c (linux_collect_regset_section_cb): Use
	std::vector<gdb_byte> instead of char * and malloc for buf.
	Remove xfree.
2018-10-26 09:41:20 -03:00
Sangamesh Mallayya b971899198 Fix SYMBOL_LANGUAGE assertion failure on AIX. 2018-10-26 15:31:36 +05:30
Andrew Burgess 0b0eff8b1d gdb/riscv: Remove redundant code, and catch more errors when accessing MISA
When reading the MISA register, the RISC-V specification says that, if
MISA can't be found then a default value of 0 should be assumed.

As such, this patch ensures that GDB ignores errors when accessing
both the new and old locations for the MISA register.

Additionally, this patch removes an unneeded flag parameter which
didn't provide any additional functionality beyond checking the MISA
for the default value of 0.

gdb/ChangeLog:

	* riscv-tdep.c (riscv_read_misa_reg): Update comment, remove
	READ_P parameter, catch and ignore register access errors from
	either the old or new MISA location.
	(riscv_has_feature): Update call to riscv_read_misa_reg.
2018-10-26 08:07:19 +01:00
GDB Administrator e8138a6b78 Automatic date update in version.in 2018-10-26 00:00:32 +00:00
Christoph Conrads b69e1ff350 ELF: update ld man page on `--gc-sections`
Commit 91ae256e33 fixes the behavior of ld when `--gc-sections` and
`--gc-keep-exported` are both given on the linker command line.  This
updates the ld documentation to suit.

	* ld.texi (--gc-sections): Update.
2018-10-26 09:01:36 +10:30
Tom de Vries ac732bc9fd [gdb/testsuite] Move valgrind-db-attach.{c,exp} to valgrind-bt.{c,exp}
Now that valgrind-db-attach.exp no longer use --db-attach, rename
valgrind-db-attach.{c,exp} to valgrind-bt.{c,exp}.

2018-10-25  Tom de Vries  <tdevries@suse.de>

    * gdb.base/valgrind-db-attach.c: Rename to ...
    * gdb.base/valgrind-bt.c: ... this.
    * gdb.base/valgrind-db-attach.exp: Rename to ...
    * gdb.base/valgrind-bt.exp: ... this.
2018-10-25 16:20:05 +02:00
Tom de Vries bfcc0eba9e [gdb/testsuite] Rewrite valgrind-db-attach.exp to use vgdb
The valgrind option --db-attach has been deprecated in version 3.10.0, and
removed in version 3.11.0, so the valgrind-db-attach.exp testcase is
unsupported starting version 3.11.0.

Rewrite the test-case to use vgdb instead (making it supported starting
version 3.7.0).

Tested on x86_64-linux with and without --target_board=native-gdbserver.

2018-10-25  Tom de Vries  <tdevries@suse.de>

	* gdb.base/valgrind-db-attach.exp: Rewrite to use vgdb.
2018-10-25 16:05:58 +02:00
Andrew Burgess b352ceb6b4 gdb/python: Make convert_values_to_python return gdbpy_ref<>
Make convert_values_to_python return a gdbpy_ref<> directly rather
than building a gdbpy_ref<>, releasing it, and then having a new
gdbpy_ref<> created to hold the result.

I also added a header comment to convert_values_to_python.

gdb/ChangeLog:

	* python/py-function.c (convert_values_to_python): Return
	gdbpy_ref<>. Add header comment.
	(fnpy_call): Adjust.
2018-10-25 12:20:18 +01:00
Andrew Burgess 50db9ef4c0 gdb/python: Make cmdpy_completer_helper return gdbpy_ref<>
Make cmdpy_completer_helper return a gdbpy_ref<> directly rather than
building a gdbpy_ref<>, releasing it, and then having a new
gdbpy_ref<> created to hold the result.

gdb/ChangeLog:

	* python/py-cmd.c (cmdpy_completer_helper): Return gdbpy_ref<>.
	(cmdpy_completer_handle_brkchars): Adjust.
	(cmdpy_completer): Adjust.
2018-10-25 12:20:18 +01:00
Andrew Burgess ee67fd7f3f gdb/riscv: Use correct regnum in riscv_linux_nat_target::fetch_registers
In riscv_linux_nat_target::fetch_registers, if we are asked to supply
all registers (regnum parameter is -1), then we currently end up
calling regcache::raw_supply_zeroed with the regnum -1, which is
invalid.  Instead we should be passing the regnum of the specific
register we wish to supply zeroed, in this case RISCV_CSR_MISA_REGNUM.

I removed the extra { ... } block in line with the coding standard
while editing this area.

gdb/ChangeLog:

	* riscv-linux-nat.c (riscv_linux_nat_target::fetch_registers):
	Pass correct regnum to raw_supply_zeroed.
2018-10-25 12:03:31 +01:00
H.J. Lu 0a640d7196 ELF: Hide symbols defined in discarded input sections
When assigning symbol version, we should hide debug symbols defined in
discarded sections from IR objects so that they can be removed later.

bfd/

	PR ld/23818
	* elflink.c (_bfd_elf_link_assign_sym_version): Hide symbols
	defined in discarded input sections.

ld/

	PR ld/23818
	* testsuite/ld-plugin/lto.exp: Run PR ld/23818 test.
	* testsuite/ld-plugin/pr23818.d: New file.
	* testsuite/ld-plugin/pr23818.t: Likewise.
	* testsuite/ld-plugin/pr23818a.c: Likewise.
	* testsuite/ld-plugin/pr23818b.c: Likewise.
2018-10-24 18:08:24 -07:00
GDB Administrator 0e139b8787 Automatic date update in version.in 2018-10-25 00:00:43 +00:00
Tom de Vries fe1a5cad30 [gdb/testsuite] Log wait status on process no longer exists error
Proc gdb_test_multiple can run into a process no longer exists error, but when
that happens it shows no details about the process:
...
ERROR: Process no longer exists
...

Fix this by showing the wait status of the process in the log:
...
ERROR: GDB process no longer exists
GDB process exited with wait status 8106 exp8 0 0 CHILDKILLED SIGSEGV \
  {segmentation violation}
...

In order to run the wait commmand we need an explicit pid, so we can't use
any_spawn_id, and duplicate the "-i any_spawn_id eof" pattern for gdb_spawn_id,
and add the wait status logging there.

Build and tested on x86_64-linux.

2018-10-24  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (gdb_test_multiple): Log wait status on process no
	longer exists error.
2018-10-24 16:22:58 +02:00
Alan Modra 8c246a60c0 cmse_scan segfault
elf_sym_hashes for as-needed libs will be zeroed if the library is
found to be not needed.  More than that, the local symbols for such a
library should not be considered by cmse_scan.

	* elf32-arm.c (elf32_arm_size_stubs): Ignore as-needed libs that
	were not needed.
2018-10-24 23:38:52 +10:30
Tom de Vries a76dc3b770 [gdb/testsuite] Rewrite catch-follow-exec.exp using gdb_test
The testcase catch-follow-exec.exp is written use gdb -batch in order to avoid
a GDB SIGTTOU.  After the commit of "Avoid GDB SIGTTOU on catch exec + set
follow-exec-mode new (PR 23368)", that no longer is necessary.

Rewrite the test using regular gdb_test commands.

Tested with x86_64-linux.

2018-10-24  Tom de Vries  <tdevries@suse.de>

	* gdb.base/catch-follow-exec.exp: Rewrite using gdb_test.
2018-10-24 13:18:04 +02:00
Tom de Vries 4df46df7a4 [gdb/testsuite] Handle removed valgrind option --db-attach
When running valgrind-db-attach.exp with valgrind version 3.13.0, we get:
...
PASS: gdb.base/valgrind-db-attach.exp: spawn valgrind
valgrind: Unknown option: --db-attach=yes
valgrind: Use --help for more information or consult the user manual.
ERROR: Process no longer exists
UNRESOLVED: gdb.base/valgrind-db-attach.exp: valgrind started
...

The valgrind option --db-attach has been deprecated in version 3.10.0, and
removed in version 3.11.0.

Fix valgrind-db-attach.exp to replace the ERROR/UNRESOLVED with:
...
UNSUPPORTED: gdb.base/valgrind-db-attach.exp: valgrind started
...

Tested on x86_64-linux.

2018-10-24  Tom de Vries  <tdevries@suse.de>

	* gdb.base/valgrind-db-attach.exp: Handle removed support for
	--db-attach in valgrind.
2018-10-24 13:11:26 +02:00
GDB Administrator 20784627bf Automatic date update in version.in 2018-10-24 00:00:40 +00:00
Hafiz Abid Qadeer bea556ab08 Fix failing cooked_read selftest for CSKY.
The problem was discussed and approved in
https://sourceware.org/ml/gdb-patches/2018-10/msg00514.html

2018-10-23  Hafiz Abid Qadeer  <abidh@codesourcery.com>

	* regcache.c (cooked_read_test): Add CSKY to the list of
	architectures with a save_reggroup
2018-10-23 23:16:58 +01:00
Simon Marchi 35ed81d4f4 Avoid GDB SIGTTOU on catch exec + set follow-exec-mode new (PR 23368)
Here's a summary of PR 23368:

  #include <unistd.h>
  int main (void)
  {
    char *exec_args[] = { "/bin/ls", NULL };
    execve (exec_args[0], exec_args, NULL);
  }

$ gdb -nx t -ex "catch exec" -ex "set follow-exec-mode new" -ex run
...
[1]  + 13146 suspended (tty output)  gdb -q -nx t -ex "catch exec" -ex "set follow-exec-mode new" -ex run
$

Here's what happens: when the inferior execs with "follow-exec-mode
new", we first "mourn" it before creating the new one.  This ends up
calling inflow_inferior_exit, which sets the per-inferior terminal state
to "is_ours":

  inf->terminal_state = target_terminal_state::is_ours;

At this point, the inferior's terminal_state is is_ours, while the
"reality", tracked by gdb_tty_state, is is_inferior (GDB doesn't own the
terminal).

Later, we continue processing the exec inferior event and decide we want
to stop (because of the "catch exec") and call target_terminal::ours to
make sure we own the terminal.  However, we don't actually go to the
target backend to change the settings, because the core thinks that no
inferior owns the terminal (inf->terminal_state is
target_terminal_state::is_ours, as checked in
target_terminal_is_ours_kind, for both inferiors).  When something in
readline tries to mess with the terminal settings, it generates a
SIGTTOU.

This patch fixes this by tranferring the state of the terminal from the
old inferior to the new inferior.

gdb/ChangeLog:

	PR gdb/23368
	* infrun.c (follow_exec): In the follow_exec_mode_new case,
	transfer terminal state from old new new inferior.
	* terminal.h (swap_terminal_info): New function.
	* inflow.c (swap_terminal_info): New function.
2018-10-23 17:00:41 -04:00
Tom Tromey 79b8d3b090 Fix use-after-free in record_btrace_start_replaying
-fsanitize=address showed a use-after-free in
record_btrace_start_replaying.  The bug occurred because
get_thread_current_frame returned a frame_info, but this object was
then invalidated before the return by ~scoped_restore_current_thread.

This patch fixes the problem by renaming get_thread_current_frame and
having it return a frame id.

gdb/ChangeLog
2018-10-23  Tom Tromey  <tom@tromey.com>

	* record-btrace.c (get_thread_current_frame_id): Rename from
	get_thread_current_frame.  Return a frame_id.
	(record_btrace_start_replaying): Update.
2018-10-23 13:45:33 -06:00
Andreas Krebbel f47998d69f S/390: Support vector alignment hints
This patch adds the vector alignment hints to the vector load and
store instructions as documented in the IBM z14 Principles of
Operations manual:

http://publibfi.boulder.ibm.com/epubs/pdf/dz9zr011.pdf

opcodes/ChangeLog:

2018-10-23  Andreas Krebbel  <krebbel@linux.ibm.com>

	* s390-opc.txt: Add vector load/store instructions with additional
	alignment parameter.

gas/ChangeLog:

2018-10-23  Andreas Krebbel  <krebbel@linux.ibm.com>

	* config/tc-s390.c (md_gather_operands): Fix for optional operands
	following memory addresses.
	* testsuite/gas/s390/zarch-arch12.d: Add regexp checks for new
	instruction variants.
	* testsuite/gas/s390/zarch-arch12.s: Emit new instruction
	variants.
2018-10-23 18:13:01 +02:00
John Darrington 51d21d60b3 GDB: New target s12z
gdb/
    * configure.tgt: Add configuration for s12z.
    * s12z-tdep.c:  New file.
    * NEWS: Mention new target.
2018-10-23 16:09:35 +02:00
John Darrington 88f5cc8cf8 GDB: Remote target can now accept the form unix::/path/to/socket.
Allow target remote to use the unix::/path/to/socket syntax as well as just
plain /path/to/socket

gdb/

  * ser-uds.c (uds_open): Use parse_connection_spec to deal with the
    comm form unix::/path/to/socket.

  * serial.c (serial_open): Consider the "unix:" prefix when deciding which
    interface to use.
2018-10-23 16:09:34 +02:00
John Darrington 0a163825df GDB: Fix documentation for invoking GDBSERVER
The documentation did not mention the possibility of invoking gdbserver
with the new connection forms such as tcp6:host:port.  This change fixes
that.

gdb/doc/

  * gdb.texinfo (Server): Tabulate the various permitted forms of the @var{comm}
   metasyntactical variable.  Include the unix:@var{host}:@var{socket} form as
   one of them.
2018-10-23 16:09:33 +02:00
John Darrington 6d0f8100c1 GDB: Document the unix::/path/to/socket of remote connection.
gdb/doc:
* gdb.texinfo (Connecting)[Remote Connection Commands]:  Provide alternative
  unix::/tmp/xxx example.  Include @code{unix::@var{local-socket}} in
  the list of remote and extended-remote syntaxes.
2018-10-23 16:09:32 +02:00
John Darrington f19c7ff839 GDBSERVER: Listen on a unix domain (instead of TCP) socket if requested.
When invoking gdbserver, if the COMM parameter takes the form "unix::/path/name"
then a local (unix) domain socket will be created with that name and gdbserver
will listen for connections on that.

    gdb/
    * NEWS: Mention new feature.

    gdb/gdbserver/
    * configure.ac (AC_CHECK_HEADERS): Add sys/un.h.
    * configure: Regenerate.
    * remote-utils.c (remote_prepare): Create a local socket if requested.
     (remote_open):  Don't attempt to open a file if it's a socket.
     (handle_accept_event): Display the name of the socket on connection.

   gdb/common/
   * netstuff.c (parse_connection_spec)[prefixes]: New member for local domain sockets.
2018-10-23 16:09:31 +02:00
John Darrington 2849d19feb S12Z: New 32 bit Reloc.
Third party tools produce 32 bit relocs  at index 6 with strange properties.
This change moves the existing 32 bit reloc (R_S12Z_EXT32) to index 7
and introduces a new one (R_S12Z_CW32) at index 6 to try to support code
generated by these tools.

  * bfd/elf32-s12z.c (elf_s12z_howto_table) [R_S12Z_CW32]: New member.
  * binutils/readelf.c (is_32bit_abs_reloc): Reloc type 7 is also 32 bit.
  * include/elf/s12z.h (elf_s12z_reloc_tpe) [RELOC_NUMBER (R_S12Z_CW32)]: New enum.
2018-10-23 16:09:30 +02:00
John Darrington 405b61965f S12Z: Handle 16 bit fixups which are constant.
Commit 1f38083f42 added a test
to check that the assembler handled fixups with resolved to
constant values.  We were not handling this in the case of
16 bit values.  This change fixes that.

* gas/config/tc-s12z.c (md_apply_fix): Handle BFD_RELOC_16
2018-10-23 16:09:29 +02:00
Andrew Burgess 420ecd9ce8 gdb/riscv: Give user-friendly names for CSRs
The recent commit:

    commit 0dbfcfffe9
    Date:   Tue Oct 16 22:40:09 2018 +0100

        gdb/riscv: Fix register access for register aliases

broke the CSR names for RISC-V, now all of the CSRs have names like,
csr0, csr1, csr2, etc.  This commit restores the previous
user-friendly names.

gdb/ChangeLog:

	* riscv-tdep.c (riscv_register_name): Use the user-friendly names
	for CSRs.
2018-10-23 13:27:56 +01:00
Alan Modra 45a0eaf770 PR23806, NULL pointer dereference in merge_strings
PR 23806
	* merge.c (_bfd_add_merge_section): Don't attempt to merge
	sections with ridiculously large alignments.
2018-10-23 21:09:09 +10:30
Alan Modra 102def4da8 PR23805, NULL pointer dereference in elf_link_input_bfd
PR 23805
	* elflink.c (elf_link_input_bfd): Don't segfault on finding
	STT_TLS symbols without any TLS sections.  Instead, change the
	symbol type to STT_NOTYPE.
2018-10-23 21:09:09 +10:30
Alan Modra ab419ddbb2 PR23804, buffer overflow in sec_merge_hash_lookup
PR 23804
	* merge.c (_bfd_add_merge_section): Don't attempt to merge
	sections where size is not a multiple of entsize.
2018-10-23 21:09:09 +10:30
Alan Modra 8e3152af14 alpha testsuite fixes
Fixes a couple of ERROR results due to .set difference on alpha.

	* testsuite/ld-elf/shared.exp: Don't build pr19073 test on alpha.
	* testsuite/ld-elf/pr18720b.c: Don't use .set on alpha.
2018-10-23 21:09:09 +10:30
Joel Brobecker 5a77b1b49f gdb/riscv: expect h/w watchpoints to trigger before the memory is written
When using QEMU as a RISCV simulator, hardware watchpoint events are
reported to GDB before the target memory gets written. GDB currently
expects the event to be reported after it is written. As a result of
this mismatch, upon receiving the event, GDB sees that the target
memory region has not changed, and therefore decides to ignore the
event. It therefore resumes the program's execution with a continue,
which is the start of an infinite loop between QEMU repeatedly
reporting the same watchpoint event over and over, and GDB repeatedly
ignoring it.

This patch fixes the issue by telling GDB to expect the watchpoint
event to be reported ahead of the memory region being modified.
Upon receiving the event, GDB then single-steps the program before
checking the watched memory value.

gdb/ChangeLog:

        * riscv-tdep.c (riscv_gdbarch_init): Set the gdbarch's
        have_nonsteppable_watchpoint attribute to 1.
2018-10-23 11:31:27 +01:00
Andrew Burgess 0dbfcfffe9 gdb/riscv: Fix register access for register aliases
Some confusion over how the register names and aliases are setup in
riscv means that we currently can't access registers through their
architectural name.

This commit fixes this issue, and moves some of the csr register
handling out of the alias handling code and deals with it separately.
This has the benefit that we can now directly access some arrays
rather than having to iterate over them.

A new test is added to ensure that register aliases now work
correctly.

gdb/ChangeLog:

	* riscv-tdep.c (riscv_gdb_reg_names): Update comment, and all
	register names.
	(struct register_alias): Rename to...
	(struct riscv_register_alias): ...this, and update comment.
	(riscv_register_aliases): Update type, and alias names.  Remove
	CSR names from this list.
	(riscv_register_name): Use riscv_gdb_reg_names for int and float
	register names.  Add an extra assertion.
	(riscv_is_regnum_a_named_csr): New function.
	(riscv_register_reggroup_p): Use riscv_is_regnum_a_named_csr.

gdb/testsuite/ChangeLog:

	* gdb.arch/riscv-reg-aliases.c: New file.
	* gdb.arch/riscv-reg-aliases.exp: New file.
2018-10-23 10:32:34 +01:00
GDB Administrator ba37fe2e8b Automatic date update in version.in 2018-10-23 00:00:53 +00:00
Jim Wilson 3399f1b303 RISC-V: NaN-box FP values smaller than an FP register.
The hardware requires that values in FP registers be NaN-boxed, so we must
extend them with 1's instead of 0's as we do for integer values.

	gdb/
	* riscv-tdep.c (riscv_push_dummy_call) <in_reg>: Check for value in
	FP reg smaller than FP reg size, and fill with -1 instead of 0.
2018-10-22 14:11:55 -07:00
Jim Wilson 270b9329b7 RISC-V: Print FP regs as union of float types.
A 64-bit FP register can hold either a single or double float value, so
print it as both types by using a union type for FP registers.  Likewise
for 128-bit regs which can also hold long double.

	gdb/
	* riscv-tdep.c (riscv_fpreg_d_type, riscv_fpreg_q_type): New.
	(riscv_register_type): Use them.
	(riscv_print_one_register_info): Handle union of floats same as float.
	* riscv-tdep.h (struct gdbarch_tdep): Add riscv_fpreg_d_type and
	riscv_fpreg_q_type fields.
2018-10-22 14:10:13 -07:00
John Darrington 192c2bfbd7 S12Z: Disassembly: Fallback to show the address if the symbol table is empty.
* opcodes/s12z-dis.c (decode_possible_symbol): Add fallback case.
  (rel_15_7): Likewise.
2018-10-22 20:53:15 +02:00
Alan Modra 1f38083f42 gas simple-forward test
Tests that target md_apply_fix can handle fixups that have resolved
down to a constant and thus do not need relocations.

Also a fix for eqv-dot xfails.

	* testsuite/gas/all/simple-forward.d,
	* testsuite/gas/all/simple-forward.s: New test.
	* testsuite/gas/all/gas.exp: Run it.
	* testsuite/gas/all/eqv-dot.d: xfail tic30 and tic54x.
2018-10-22 22:32:43 +10:30
Alan Modra e1748c54a2 Apply alpha BFD_RELOC_8 fixups
* config/tc-alpha.c (md_apply_fix): Handle BFD_RELOC_8 for fixups
	without a symbol.
	* testsuite/gas/all/gas.exp: Don't xfail forward test here..
	* testsuite/gas/all/forward.d: ..do so here, removing alpha.
2018-10-22 22:32:43 +10:30
Alan Modra 38cf168be5 PR23040, .uleb128 directive doesn't accept some valid expressions
What a trip down a rabbit hole this bug has been.

First observation: You can't use deferred_expression in s_leb128.
deferred_expression implements the semantics of .eqv or '==', saving
an expression with minimal simplification for assignment to a symbol
so that the expression is evaluated at uses of the symbol.  In
particular, the value of "dot" is not evaluated at the .eqv symbol
assignment, but later.  When s_leb128 uses deferred_expression,
"later" is at the end of assembly, giving entirely the wrong value of
"dot".  There is no way to fix this for the s_leb128 use without
breaking .equ (which incidentally was already somewhat broken, see
commit e4c2619ad1).  So, don't use deferred_expression in s_leb128.

But that leads to the gas test elf/dwarf2-17 failing, because view
symbols are calculated with a chain of expression symbols.  In the
dwarf2-17 .L1 case there is a "temp_sym_1 > temp_sym_2" expression,
with temp_sym_1 and temp_sym_2 on either side of a ".balign".  Since
".balign" and many other directives moving "dot" are not calculated on
the first (and only) pass over source, .L1 cannot be calculated until
final addresses are assigned to frags.  However, ".uleb128 .L1" *is*
calculated immediately, resulting in the wrong value.

The reason why .L1 is calculated immediately is that code in
expr.c:operand after the comment
	  /* If we have an absolute symbol or a reg, then we know its
	     value now.  */
does as it says and fixes the value of .L1, because .L1 is assigned
to absolute_section in dwarf2dbg.c:set_or_check_view.  So, correct
that to expr_section.

Unfortunately that fix leads to failure of the elf/dwarf2-5 test with
../gas/elf/dwarf2-5.s: Error: attempt to get value of unresolved symbol `.L5'
../gas/elf/dwarf2-5.s: Error: attempt to get value of unresolved symbol `.L11'
../gas/elf/dwarf2-5.s: Error: attempt to get value of unresolved symbol `.L12'
So why is that?  Well, it turns out that .L5 is defined in terms of
.L4, and apparently .L4 is undefined.  But .L4 clearly is defined,
otherwise we would hit an error when trying to use .L4 a little
earlier.  There are two copies of .L4!  So, symbols are cloned when
that should not happen.

Symbol cloning is a technique used by gas to support saving the value
of symbols that change between uses, but that isn't the case with
.L4.  Only one value is set and used for .L4, but indeed .L4 was being
cloned by symbol_clone_if_forward_ref.  This despite no forward refs
being present.  Also, .L4 is a local symbol and a cursory glance at
symbol_clone_if_forward_ref "if (symbolP && !LOCAL_SYMBOL_CHECK (symbolP))"
would seem to prevent cloning of local symbols.  All is not as it
seems though, a curse of using macros.  LOCAL_SYMBOL_CHECK modifies
its argument if a "struct local_symbol" is converted to the larger
"struct symbol", as happens when assigning a view symbol value.
That fact results in the recursive call to symbol_clone_if_forward_ref
returning a different address for "add_symbol".  This problem could
have been fixed by using symbol_same_p rather than comparing symbol
pointers, but I thought it better to use the real symbol throughout.
Note that symbol_find_exact also returns the real symbol for a
converted local symbol.

Finally, this patch does expose lack of support for forward symbol
definitions in various targets.  For example:
alpha-linux  +ERROR: ../ld/testsuite/ld-elf/pr11138-2.c: compilation failed
This is caused by view symbol uses.  On alpha-linux-gcc (GCC) 8.1.1
20180502 they happen to occur in .byte directives so were silently
broken in cases like elf/dwarf2-17 anyway.
/tmp/ccvtsMfU.s: Assembler messages:
/tmp/ccvtsMfU.s: Fatal error: unhandled relocation type BFD_RELOC_8
/tmp/ccvtsMfU.s: Fatal error: unhandled relocation type BFD_RELOC_8

md_apply_fix on those targets needs to handle fixups that resolve down
to a constant.

	PR 23040
	* symbols.c (get_real_sym): New function.
	(symbol_same_p): Use get_real_sym.
	(symbol_clone_if_forward_ref): Save real original add_symbol and
	op_symbol for comparison against that returned from lookup or
	recursive calls.
	* dwarf2dbg.c (set_or_check_view): Use expr_section for
	expression symbols, not absolute_section.
	(dwarf2_directive_loc): Check symbol_equated_p and tidy cloning
	of view symbols.
	* read.c (s_leb128): Don't use deferred_expression.
2018-10-22 13:34:02 +10:30