external/binutils.git
6 years agoRemove some ld --trace output
Alan Modra [Mon, 29 Oct 2018 07:39:59 +0000 (18:09 +1030)]
Remove some ld --trace output

This output really belongs in ld --verbose.

* ldmain.c (main): Print emulation mode and "deleting executable"
for --verbose, not --trace.
(add_archive_element): Only print "no new IR symbols" for --verbose.

6 years agoSimplify --sysroot=/
Alan Modra [Mon, 29 Oct 2018 07:39:39 +0000 (18:09 +1030)]
Simplify --sysroot=/

Prepending '/' to absolute paths doesn't gain us much, and results in
the current implementation of --trace emitting silly path-in-sysroot
output, eg.
/lib/ld-linux-x86-64.so.2 (//lib/ld-linux-x86-64.so.2)

* ldmain.c (get_sysroot): Return "" for "--sysroot=/".

6 years agoMove struc-symbol.h to symbols.c
Alan Modra [Mon, 29 Oct 2018 06:07:24 +0000 (16:37 +1030)]
Move struc-symbol.h to symbols.c

This file was never supposed to be widely used.  The fact that it has
found its way into many gas files led to bugs, typically when code
expecting a symbolS* to point at a struct symbol is presented with a
struct local_symbol.  Also, commit 158184ac9e changed these structs in
2012 but didn't catch all places where symbol bsym was being used to
test for a local_symbol.

* Makefile.am (HFILES): Delete struc-symbol.h.
* doc/internals.texi: Delete struc-symbol.h reference and out
of date local symbol description.
* struc-symbol.h: Delete.  Move contents to..
* symbols.c: ..here.
(symbol_on_chain, symbol_symbolS): New functions.
* symbols.h (symbol_on_chain, symbol_symbolS): Declare.
* cgen.c: Don't #include struc-symbol.h.
(gas_cgen_parse_operand): Don't test for local_symbol using
bsym, instead call symbol_symbolS.  Use symbol_get_bfdsym.
(weak_operand_overflow_check, make_right_shifted_expr): Use
symbol accessors.
* config/obj-coff.c: Don't #include struc-symbol.h.
(GET_FILENAME_STRING): Delete.
* config/obj-elf.c: Don't #include struc-symbol.h.
(elf_file_symbol): Use symbol accessors.
(elf_adjust_symtab): Call symbol_on_chain.
* config/obj-evax.c: Don't #include struc-symbol.h.
* config/tc-nds32.c: Likewise.
* config/tc-rl78.c: Likewise.
* config/tc-rx.c: Likewise.
* config/tc-alpha.c: Likewise.
(add_to_link_pool, s_alpha_comm): Use symbol accessors.
* config/tc-arc.c: Don't #include struc-symbol.h.
(arc_check_relocs): Use symbol accessors, testing gas symbol
section rather than bfd symbol section.
* config/tc-avr.c: Don't #include struc-symbol.h.
(avr_patch_gccisr_frag): Use symbol accessors.
* config/tc-bfin.c: Don't #include struc-symbol.h.
(bfin_loop_beginend): Use symbol accessors.
* config/tc-csky.c: Don't #include struc-symbol.h.
(v2_work_movih, v2_work_ori): Use symbol accessors.  Check for
absolute symbol as well as O_constant.
* config/tc-riscv.c: Don't #include struc-symbol.h.
(riscv_pre_output_hook): Use symbol accessors.
* config/tc-s390.c: Don't #include struc-symbol.h.
(s390_literals): Use symbol accessors.
* config/tc-score.c (s3_build_la_pic, s3_build_lwst_pic): Use
symbol accessors.
(s3_relax_branch_inst16, s3_relax_cmpbranch_inst32): Don't
test symbol bsym.
* config/tc-score7.c: Don't #include struc-symbol.h.
(s7_build_la_pic, s7_build_lwst_pic): Use symbol accessors.
(s7_b32_relax_to_b16): Don't test symbol bsym.
* config/tc-sh.c: Don't #include struc-symbol.h.
(insert_loop_bounds): Use symbol accessors.
(sh_frob_section): Remove bogus symbol canonicalization.
* config/tc-tic54x.c: Don't #include struc-symbol.h.
(tic54x_bss): Use symbol accessors.
* config/tc-tilegx.c: Don't #include struc-symbol.h.
(emit_tilegx_instruction, tilegx_parse_name): Use symbol accessors.
* config/tc-tilepro.c: Don't #include struc-symbol.h.
(emit_tilepro_instruction, tilepro_parse_name): Use accessors.
* config/tc-xtensa.c: Don't #include struc-symbol.h.
(xg_assemble_vliw_tokens): Use symbol accessors.
(xg_order_trampoline_chain): Likewise.
* ehopt.c: Don't #include struc-symbol.h.
(check_eh_frame): Correct local symbol test.  Use symbol accessors.
* write.c: Don't #include struc-symbol.h.
(create_note_reloc, maybe_generate_build_notes): Use symbol accessors.
* Makefile.in: Regenerate.
* po/POTFILES.in: Regenerate.

6 years agold -r script fixes
Alan Modra [Thu, 25 Oct 2018 23:31:54 +0000 (10:01 +1030)]
ld -r script fixes

For ld -r, we generally set the VMA of sections to zero.  This is done
to make the output of ld -r most similar to that output by the
assembler, which generally has sections starting at VMA zero.  In some
cases that covers for backend bugs which would mis-handle relocatable
object files with non-zero section VMAs.

This patch fixes a few sections that didn't have zero VMAs for ld -r.
A missing zero on .note.gnu.build-id and .eh_frame_hdr doesn't matter
much since these are linker generated symbols only output on final
link, but it's good to be consistent.

* Makefile.am (ei386beos.c, ei386go32.c): Correct dependencies.
* Makefile.in: Regenerate.
* scripttempl/elf.sc (.note.gnu.build-id, .eh_frame_hdr): Set
address with ${RELOCATING-0}.
* scripttempl/arclinux.sc: Likewise.
* scripttempl/armbpabi.sc: Likewise.
* scripttempl/avr.sc: Likewise.
* scripttempl/elf64hppa.sc: Likewise.
* scripttempl/elf_chaos.sc: Likewise.
* scripttempl/elfarc.sc: Likewise.
* scripttempl/elfxtensa.sc: Likewise.
* scripttempl/mep.sc: Likewise.
* scripttempl/nds32elf.sc: Likewise.
* scripttempl/pru.sc: Likewise.
* scripttempl/elf32msp430.sc: Likewise, and for other sections.
* scripttempl/epiphany_4x4.sc: Similarly.

6 years agoGDB: Only build for "unix:" connections if AF_LOCAL is supported.
John Darrington [Sun, 28 Oct 2018 19:14:24 +0000 (20:14 +0100)]
GDB: Only build for "unix:" connections if AF_LOCAL is supported.

Commit f19c7ff839d7a32ebb48482ae7d318fb46ca823d added a new member to the
prefixes array which included a use of the symbol AF_LOCAL.   Unfortunately,
not all systems declare this symbol.    This change only compiles the "unix:"
member if the system knows about AF_LOCAL.

gdb/ChangeLog:

* configure.ac: New test HAVE_AF_LOCAL
* common/netstuff.c (parse_connection_spec) [prefixes]: Only compile "unix:"
   if HAVE_AF_LOCAL is true.
* configure: regenerate.
* config.in: regenerate.

6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 29 Oct 2018 00:00:35 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agogdb/riscv: Add back missing braces in riscv-linux-nat.c
Andrew Burgess [Sun, 28 Oct 2018 10:43:26 +0000 (10:43 +0000)]
gdb/riscv: Add back missing braces in riscv-linux-nat.c

In this commit:

    commit ee67fd7f3f6ca78eede2862e309c0bcf266bbd7e
    Date:   Thu Oct 25 12:03:31 2018 +0100

        gdb/riscv: Use correct regnum in riscv_linux_nat_target::fetch_registers

I incorrectly removed a set of braces in violation of the GDB coding
standard.  This commit adds them back.

gdb/ChangeLog:

* riscv-linux-nat.c (riscv_linux_nat_target::fetch_registers):
Add missing braces.  No functional change.

6 years agoCorrect ChangeLog
Alan Modra [Sun, 28 Oct 2018 05:44:35 +0000 (16:14 +1030)]
Correct ChangeLog

6 years agoPR23837, Segmentation fault in resolve_symbol_value
Alan Modra [Sun, 28 Oct 2018 05:27:17 +0000 (15:57 +1030)]
PR23837, Segmentation fault in resolve_symbol_value

Local symbols don't have a sy_frag field.

PR 23837
* config/tc-hppa.c: Don't include struc-symbol.h.
(pa_build_unwind_subspace): Call get_symbol_frag rather than
referencing sy_frag.

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 28 Oct 2018 00:00:46 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoOBVIOUS Use report_unrecognized_option_error in 'demangle' and 'info macro' commands.
Philippe Waroquiers [Sat, 27 Oct 2018 19:25:44 +0000 (21:25 +0200)]
OBVIOUS Use report_unrecognized_option_error in 'demangle' and 'info macro' commands.

Rather than have some local logic to throw an error for an unrecognized option,
use the new cli-utils.h function throwing an error.

At the same time, fix some wrong indentation in info_macro_command
and fix a small bug in 'demangle' error handling:

Without the patch:
  (gdb) demangle -L c++ abcd
  Unrecognized option 'c++' to demangle command.  Try "help demangle".
  (gdb)

With the patch:
  (gdb) demangle -L c++ abcd
  Unrecognized option '-L' to demangle command.  Try "help demangle".

2018-10-27  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* macrocmd.c (info_macro_command): Use report_unrecognized_option_error
to report a bad option and fix indentation.
* demangle.c (demangle_command): Use report_unrecognized_option_error
to report a bad option and correctly report the bad option.

6 years agoCache a copy of the user's shell on macOS
Tom Tromey [Mon, 17 Sep 2018 18:29:22 +0000 (12:29 -0600)]
Cache a copy of the user's shell on macOS

Recent versions of macOS have a feature called System Integrity
Protection.  Among other things, This feature prevents ptrace from
tracing certain programs --- for example, the programs in /bin, which
includes typical shells.

This means that startup-with-shell does not work properly.  This is PR
cli/23364.  Currently there is a workaround in gdb to disable
startup-with-shell when this feature might be in use.

This patch changes gdb to be a bit more precise about when
startup-with-shell will not work, by checking whether the shell
executable is restricted.

If the shell is restricted, then this patch will also cause gdb to
cache a copy of the shell in the gdb cache directory, and then reset
the SHELL environment variable to point to this copy.  This lets
startup-with-shell work again.

Tested on High Sierra by trying to start a program using redirection,
and by running startup-with-shell.exp.

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

PR cli/23364:
* darwin-nat.c (copied_shell): New global.
(may_have_sip): Rename from should_disable_startup_with_shell.
(copy_shell_to_cache, maybe_cache_shell): New functions.
(darwin_nat_target::create_inferior): Update.  Use
copied_shell.

6 years agoDo not reopen temporary files
Tom Tromey [Thu, 20 Sep 2018 22:30:47 +0000 (16:30 -0600)]
Do not reopen temporary files

The current callers of mkostemp close the file descriptor and then
re-open it with fopen.  It seemed better to me to continue to use the
already-opened file descriptor, so this patch rearranges the code a
little in order to do so.  It takes care to ensure that the files are
only unlinked after the file descriptor in question is closed, as
before.

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

* unittests/scoped_fd-selftests.c (test_to_file): New function.
(run_tests): Call test_to_file.
* dwarf-index-write.c (write_psymtabs_to_index): Do not reopen
temporary files.
* common/scoped_fd.h (scoped_fd::to_file): New method.

6 years agoUse mkostemp, not mkstemp
Tom Tromey [Thu, 20 Sep 2018 22:04:04 +0000 (16:04 -0600)]
Use mkostemp, not mkstemp

I noticed that gdb could leak file descriptors coming from mkstemp.
This patch fixes the problem by importing the gnulib mkostemp instead,
and then changing gdb to pass O_CLOEXEC.

A small gnulib patch was needed.  This has already been accepted
upstream.

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

* unittests/scoped_mmap-selftests.c (test_normal): Use
gdb_mkostemp_cloexec.
* unittests/scoped_fd-selftests.c (test_destroy, test_release):
Use gdb_mkostemp_cloexec.
* gnulib/aclocal-m4-deps.mk, gnulib/aclocal.m4,
gnulib/config.in, gnulib/configure,
gnulib/import/Makefile.am, gnulib/import/Makefile.in,
gnulib/import/m4/gnulib-cache.m4,
gnulib/import/m4/gnulib-comp.m4: Update.
* gnulib/import/m4/mkostemp.m4: New file.
* gnulib/import/m4/mkstemp.m4: Remove.
* gnulib/import/mkostemp.c: New file.
* gnulib/import/mkstemp.m4: Remove.
* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Remove
mkstemp, add mkostemp.  Apply new patch.
* gnulib/import/stdlib.in.h: Apply patch.
* gnulib/patches/0002-mkostemp-mkostemps-Fix-compilation-error-in-C-mode-o.patch:
New file.
* dwarf-index-write.c (write_psymtabs_to_index): Use
gdb_mkostemp_cloexec.
* common/filestuff.h (gdb_mkostemp_cloexec): New function.

6 years agoMove mkdir_recursive to common/filestuff.c
Tom Tromey [Mon, 17 Sep 2018 16:48:20 +0000 (10:48 -0600)]
Move mkdir_recursive to common/filestuff.c

This moves mkdir_recursive from dwarf-index-cache.c to
common/filestuff.c, and also changes it to return a boolean that says
whether or not it worked.

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

* unittests/mkdir-recursive-selftests.c: New file.
* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
unittests/mkdir-recursive-selftests.c.
* dwarf-index-cache.c (mkdir_recursive): Move to
common/filestuff.c.
(index_cache::store): Check return value of mkdir_recursive.
(create_dir_and_check, test_mkdir_recursive): Move to new file.
(_initialize_index_cache): Don't register test.
* common/filestuff.h (mkdir_recursive): Declare.
* common/filestuff.c (mkdir_recursive): Move from
dwarf-index-cache.c.  Return bool.

6 years agoMove make_temp_filename to common/pathstuff.c
Tom Tromey [Fri, 14 Sep 2018 17:28:45 +0000 (11:28 -0600)]
Move make_temp_filename to common/pathstuff.c

Currently make_temp_filename is a function local to
write_psymtabs_to_index.  This patch moves it to pathstuff.c so that
it can be used from other places in gdb.

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

* dwarf-index-write.c (write_psymtabs_to_index): Move
make_temp_filename to common/pathstuff.c.
* common/pathstuff.h (make_temp_filename): Declare.
* common/pathstuff.c (make_temp_filename): New function, moved
from dwarf-index-write.c.

6 years agoUnify shell-finding logic
Tom Tromey [Fri, 14 Sep 2018 16:35:45 +0000 (10:35 -0600)]
Unify shell-finding logic

I noticed several places in gdb that were using getenv("SHELL") and
then falling back to "/bin/sh" if it returned NULL.  This unifies
these into a single function.

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

* procfs.c (procfs_target::create_inferior): Use get_shell.
* cli/cli-cmds.c (shell_escape): Use get_shell.
* windows-nat.c (windows_nat_target::create_inferior): Use
get_shell.
* common/pathstuff.c (get_shell): New function.
* nat/fork-inferior.c (SHELL_FILE, get_startup_shell): Remove.
(fork_inferior): Use get_shell.
* common/pathstuff.h (get_shell): Declare.

6 years agoRemove a bunch of usages of gdb_suppress_tests in 'runto_main'.
Philippe Waroquiers [Thu, 25 Oct 2018 20:42:58 +0000 (22:42 +0200)]
Remove a bunch of usages of gdb_suppress_tests in 'runto_main'.

In the 'info -q -t' patch series, I started a new test from
gdb.threads/threadapply.exp, that uses an obsolete way to do
runto_main.

This patch changes all occurrences of runto_main using gdb_suppress_tests
to use instead fail+return.

Note that there are still about 220 occurrences of gdb_suppress_tests
but unclear (to me) if these can be similarly trivially be replaced by a
fail+return.  Further cleanup can be done in follow-up patches.

Tests run on Debian/x86_64.

gdb/testsuite/ChangeLog
2018-10-27  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* gdb.arch/altivec-regs.exp: Do not use gdb_suppress_tests in
runto_main, use fail + return instead.
gdb.arch/amd64-byte.exp: Likewise.
gdb.arch/amd64-dword.exp: Likewise.
gdb.arch/amd64-word.exp: Likewise.
gdb.arch/e500-abi.exp: Likewise.
gdb.arch/e500-regs.exp: Likewise.
gdb.arch/gdb1291.exp: Likewise.
gdb.arch/gdb1431.exp: Likewise.
gdb.arch/i386-avx.exp: Likewise.
gdb.arch/i386-byte.exp: Likewise.
gdb.arch/i386-prologue.exp: Likewise.
gdb.arch/i386-sse.exp: Likewise.
gdb.arch/i386-word.exp: Likewise.
gdb.arch/iwmmxt-regs.exp: Likewise.
gdb.arch/pa-nullify.exp: Likewise.
gdb.arch/powerpc-prologue.exp: Likewise.
gdb.arch/s390-tdbregs.exp: Likewise.
gdb.arch/vsx-regs.exp: Likewise.
gdb.asm/asm-source.exp: Likewise.
gdb.base/auxv.exp: Likewise.
gdb.base/bigcore.exp: Likewise.
gdb.base/overlays.exp: Likewise.
gdb.base/savedregs.exp: Likewise.
gdb.base/setshow.exp: Likewise.
gdb.base/sigaltstack.exp: Likewise.
gdb.base/sigbpt.exp: Likewise.
gdb.base/siginfo-addr.exp: Likewise.
gdb.base/siginfo-obj.exp: Likewise.
gdb.base/siginfo-thread.exp: Likewise.
gdb.base/siginfo.exp: Likewise.
gdb.base/signull.exp: Likewise.
gdb.base/sigrepeat.exp: Likewise.
gdb.base/structs2.exp: Likewise.
gdb.threads/threadapply.exp: Likewise.
gdb.threads/watchthreads.exp: Likewise.
gdb.threads/watchthreads2.exp: Likewise.

6 years agoAdd a test case for info args|functions|locals|variables [-q] [-t TYPEREGEXP] [NAMERE...
Philippe Waroquiers [Thu, 5 Jul 2018 20:39:41 +0000 (22:39 +0200)]
Add a test case for info args|functions|locals|variables [-q] [-t TYPEREGEXP] [NAMEREGEXP]

Add a test case for info args|functions|locals|variables [-q] [-t TYPEREGEXP] [NAMEREGEXP]

gdb/testsuite/ChangeLog
2018-10-27  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* gdb.base/info_qt.c: New file.
* gdb.base/info_qt.exp: New file.

6 years agoAnnounce changes in NEWS to info [args|functions|locals|variables]
Philippe Waroquiers [Sun, 1 Jul 2018 21:02:41 +0000 (23:02 +0200)]
Announce changes in NEWS to info [args|functions|locals|variables]

Announce changes in NEWS to info [args|functions|locals|variables]

gdb/ChangeLog
2018-10-27  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* NEWS: Mention changes to 'info [args|functions|locals|variables]'

6 years agoDocument changes to info [args|functions|locals|variables]
Philippe Waroquiers [Sun, 1 Jul 2018 21:02:14 +0000 (23:02 +0200)]
Document changes to info [args|functions|locals|variables]

Document changes to info [args|functions|locals|variables]

gdb/doc/ChangeLog
2018-10-27  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* gdb.texinfo (Information About a Frame): Document changes
to 'info args' and 'info locals'.
(Examining the Symbol Table): Document changes to 'info functions'
and 'info variables'.

6 years agoAdd [-q] [-t TYPEREGEXP] [NAMEREGEXP] args to info [args|functions|locals|variables]
Philippe Waroquiers [Sun, 1 Jul 2018 20:56:56 +0000 (22:56 +0200)]
Add [-q] [-t TYPEREGEXP] [NAMEREGEXP] args to info [args|functions|locals|variables]

Add [-q] [-t TYPEREGEXP] [NAMEREGEXP] args to info [args|functions|locals|variables]

Main changes are:
* stack.c: Add two regexp preg and treg to print_variable_and_value_data
  and used them inside do_print_variable_and_value to filter the
  variables to print.

* symtab.h: Add a new function bool treg_matches_sym_type_name, that
  factorises type matching logic.

* symtab.c: Add type/name matching logic to 'info functions|variables'.

* stack.c : Add type/name matching logic to 'info args|locals'.

gdb/ChangeLog
2018-10-27  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* stack.c (print_variable_and_value_data): Add preg and treg.
(print_frame_local_vars): Add quiet, regexp and t_regexp arguments,
and update callers.
(print_frame_arg_vars): Likewise.
(prepare_reg): New function.
(info_locals_command): Extract info print args and use them.
(info_args_command): Likewise.
(_initialize_stack): Modify on-line help.
* symtab.c (treg_matches_sym_type_name): New function.
(search_symbols): New arg t_regexp.
(symtab_symbol_info): New args quiet, regexp, t_regexp.
(info_variables_command): Extract info print args and use them.
(info_functions_command): Likewise.
(info_types_command): Update call to symtab_symbol_info.
(_initialize_symtab): Modify on-line help.
* symtab.h (treg_matches_sym_type_name): New function.
(search_symbols): New t_regexp arg.

6 years agoNew cli-utils.h/.c function extract_info_print_args
Philippe Waroquiers [Sun, 1 Jul 2018 20:46:41 +0000 (22:46 +0200)]
New cli-utils.h/.c function extract_info_print_args

New cli-utils.h/.c function extract_info_print_args factorizes
the extraction of the args '[-q] [-t TYPEREGEXP] [NAMEREGEXP]'.
New cli-utils.h/.c function report_unrecognized_option_error
factorizes reporting an unknown option for a command.

These functions will be used by the commands
  info [args|functions|locals|variables]

As extract_info_print_args will be used for 'info functions|variables' which
already have the NAMEREGEXP arg, it provides a backward compatible
behaviour.

cli-utils.c has a new static function extract_arg_maybe_quoted
that extracts an argument, possibly quoted.  The behaviour of this
function is similar to the parsing done by gdb_argv.

gdb/ChangeLog
2018-10-27  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* cli-utils.c (extract_arg_maybe_quoted): New function.
(extract_info_print_args): New function.
(info_print_args_help): New function.
(report_unrecognized_option_error): New function.
* cli-utils.h (extract_arg_maybe_quoted): New function.
(extract_info_print_args): New function.
(info_print_args_help): New function.
(report_unrecognized_option_error): New function.

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 27 Oct 2018 00:01:21 +0000 (00:01 +0000)]
Automatic date update in version.in

6 years agoRemove DEF_VECs from symtab.h
Tom Tromey [Sun, 14 Oct 2018 18:18:21 +0000 (12:18 -0600)]
Remove DEF_VECs from symtab.h

This removes a couple of DEF_VECs from symtab.h, replacing them with
std::vector at the points of use.

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

* dwarf2read.c (recursively_compute_inclusions): Use std::vector.
(compute_compunit_symtab_includes): Update.
* symtab.h: (symtab_ptr): Remove typedef.  Don't define a VEC.
(compunit_symtab_ptr): Likewise.

6 years agoTreat all unknown auxv tags on FreeBSD as unknown.
John Baldwin [Fri, 26 Oct 2018 17:20:56 +0000 (10:20 -0700)]
Treat all unknown auxv tags on FreeBSD as unknown.

Previously, default_print_auxv_entry was called for any auxv entries
without a known AT_FREEBSD_* tag.  However, this resulted in false
positive matches when FreeBSD added a new tag that has an existing
AT_* tag with a different meaning.  Instead, only call
default_print_auxv_entry for specific tag values for which FreeBSD
matches the default AT_* values.

gdb/ChangeLog:

* fbsd-tdep.c (fbsd_print_auxv_entry): Only use
default_print_auxv_entry for specific tag values.

6 years agoSupport AT_HWCAP2 on FreeBSD.
John Baldwin [Fri, 26 Oct 2018 17:20:56 +0000 (10:20 -0700)]
Support AT_HWCAP2 on FreeBSD.

include/ChangeLog:

* elf/common.h (AT_FREEBSD_HWCAP2): Define.

gdb/ChangeLog:

* fbsd-tdep.c (fbsd_print_auxv_entry): Handle AT_FREEBSD_HWCAP2.

6 years agoRISC-V: Linux signal frame support.
Jim Wilson [Fri, 26 Oct 2018 17:32:58 +0000 (10:32 -0700)]
RISC-V: Linux signal frame support.

Add support for recognizing signal trampolines, parsing the signal frame,
and reading register values from it.

gdb/
* riscv-linux-tdep.c: Include tramp-frame.h and trad-frame.h.
(riscv_linux_sigframe_init): Declare.
(RISCV_INST_LI_A7_SIGRETURN, RISCV_INT_ECALL): New.
(riscv_linux_sigframe): New.
(SIGFRAME_SIGINFO_SIZE, UCONTEXT_MCONTEXT_OFFSET): New.
(riscv_linux_sigframe_init): Define.
(riscv_linux_init_abi): Call tramp_frame_prepend_unwinder.

6 years agoRISC-V: Linux signal frame support.
Jim Wilson [Fri, 26 Oct 2018 17:29:46 +0000 (10:29 -0700)]
RISC-V: Linux signal frame support.

Make riscv_isa_flen available to the linux native code, and clean up duplicate
comments.

gdb/
* riscv-tdep.c (riscv_isa_xlen): Refer to riscv-tdep.h comment.
(riscv_isa_flen): Likewise.  Drop static.
* riscv-tdep.h (riscv_isa_xlen): Move riscv-tdep.c comment to here.
(riscv_isa_flen): Likewise.

6 years ago[PowerPC] Add support for HTM registers
Edjunior Barbosa Machado [Fri, 26 Oct 2018 12:37:55 +0000 (09:37 -0300)]
[PowerPC] Add support for HTM registers

This patch adds support for Hardware Transactional Memory registers
for the powerpc linux native and core file targets, and for the
pwoerpc linux server stub.

These registers include both the HTM special-purpose registers (TFHAR,
TEXASR and TFIAR) as well as the set of registers that are
checkpointed (saved) when a transaction is initiated, which the
processor restores in the event of a transaction failure.

The set of checkpointed general-purpose registers is returned by the
linux kernel in the same format as the regular general-purpose
registers, defined in struct pt_regs.  However, the architecture
specifies that only some of the registers present in pt_regs are
checkpointed (GPRs 0-31, CR, XER, LR and CTR).  The kernel fills the
slots for MSR and NIP with other info.  The other fields usually don't
have meaningful values.  GDB doesn't define registers that are not
checkpointed in the architecture, but when generating a core file, GDB
fills the slot for the checkpointed MSR with the regular MSR.  These
are usually similar, although some bits might be different, and in
some cases the checkpointed MSR will have a value of 0 in a
kernel-generated core-file.  The checkpointed NIP is filled with TFHAR
by GDB in the core-file, which is what the kernel does.  The other
fields are set to 0 by GDB.

Core files generated by the kernel have a note section for
checkpointed GPRs with the same size for both 32-bit and 64-bit
threads, and the values for the registers of a 32-bit thread are
squeezed in the first half, with no useful data in the second half.
GDB generates a smaller note section for 32-bit threads, but can read
both sizes.

The checkpointed XER is required to be 32-bit in the target
description documentation, even though the more recent ISAs define it
as 64-bit wide, since the high-order 32-bits are reserved, and because
in Linux there is no way to get a 64-bit checkpointed XER for 32-bit
threads.  If this changes in the future, the target description
feature requirement can be relaxed to allow for a 64-bit checkpointed
XER.

Access to the checkpointed CR (condition register) can be confusing.
The architecture only specifies that CR fields 1 to 7 (the 24 least
significant bits) are checkpointed, but the kernel provides all 8
fields (32 bits).  The value of field 0 is not masked by ptrace, so it
will sometimes show the result of some kernel operation, probably
treclaim., which sets this field.

The checkpointed registers are marked not to be saved and restored.
Inferior function calls during an active transaction don't work well,
and it's unclear what should be done in this case.  TEXASR and TFIAR
can be altered asynchronously, during transaction failure recording,
so they are also not saved and restored.  For consistency neither is
TFHAR.

Record and replay also doesn't work well when transactions are
involved.  This patch doesn't address this, so the values of the HTM
SPRs will sometimes be innacurate when the record/relay target is
enabled.  For instance, executing a "tbegin." alters TFHAR and TEXASR,
but these changes are not currently recorded.

Because the checkpointed registers are only available when a
transaction is active (or suspended), ptrace can return ENODATA when
gdb tries to read these registers and the inferior is not in a
transactional state.  The registers are set to the unavailable state
when this happens.  When gbd tries to write to one of these registers,
and it is unavailable, an error is raised.

The "fill" functions for checkpointed register sets in the server stub
are not implemented for the same reason as for the EBB register set,
since ptrace can also return ENODATA for checkpointed regsets.  The
same issues with 'G' packets apply here.

Just like for the EBB registers, tracepoints will not mark the
checkpointed registers as unavailable if the inferior was not in a
transaction, so their content will also show 0 instead of
<unavailable> when inspecting trace data.

The new tests record the values of the regular registers before
stepping the inferior through a "tbegin." instruction to start a
transaction, then the checkpointed registers are checked against the
recorded pre-transactional values.  New values are written to the
checkpointed registers and recorded, the inferior continues until the
transaction aborts (which is usually immediately when it is resumed),
and the regular registers are checked against the recorded values,
because the abort should have reverted the registers to these values.

Like for the EBB registers, target_store_registers will ignore the
checkpointed registers when called with -1 as the regno
argument (store all registers in one go).

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_htm_vsx32l)
(tdesc_powerpc_isa207_htm_vsx64l): Declare.
* arch/ppc-linux-common.h (PPC_LINUX_SIZEOF_TM_SPRREGSET)
(PPC32_LINUX_SIZEOF_CGPRREGSET, PPC64_LINUX_SIZEOF_CGPRREGSET)
(PPC_LINUX_SIZEOF_CFPRREGSET, PPC_LINUX_SIZEOF_CVMXREGSET)
(PPC_LINUX_SIZEOF_CVSXREGSET, PPC_LINUX_SIZEOF_CPPRREGSET)
(PPC_LINUX_SIZEOF_CDSCRREGSET, PPC_LINUX_SIZEOF_CTARREGSET):
Define.
(struct ppc_linux_features) <htm>: New field.
(ppc_linux_no_features): Add initializer for htm field.
* arch/ppc-linux-common.c (ppc_linux_match_description): Return
new tdescs.
* nat/ppc-linux.h (PPC_FEATURE2_HTM, NT_PPC_TM_CGPR)
(NT_PPC_TM_CFPR, NT_PPC_TM_CVMX, NT_PPC_TM_CVSX)
(NT_PPC_TM_SPR, NT_PPC_TM_CTAR, NT_PPC_TM_CPPR, NT_PPC_TM_CDSCR):
Define if not already defined.
* features/Makefile (WHICH): Add rs6000/powerpc-isa207-htm-vsx32l
and rs6000/powerpc-isa207-htm-vsx64l.
(XMLTOC): Add rs6000/powerpc-isa207-htm-vsx32l.xml and
rs6000/powerpc-isa207-htm-vsx64l.xml.
* features/rs6000/power-htm-spr.xml: New file.
* features/rs6000/power-htm-core.xml: New file.
* features/rs6000/power64-htm-core.xml: New file.
* features/rs6000/power-htm-fpu.xml: New file.
* features/rs6000/power-htm-altivec.xml: New file.
* features/rs6000/power-htm-vsx.xml: New file.
* features/rs6000/power-htm-ppr.xml: New file.
* features/rs6000/power-htm-dscr.xml: New file.
* features/rs6000/power-htm-tar.xml: New file.
* features/rs6000/powerpc-isa207-htm-vsx32l.xml: New file.
* features/rs6000/powerpc-isa207-htm-vsx64l.xml: New file.
* features/rs6000/powerpc-isa207-htm-vsx32l.c: Generate.
* features/rs6000/powerpc-isa207-htm-vsx64l.c: Generate.
* regformats/rs6000/powerpc-isa207-htm-vsx32l.dat: Generate.
* regformats/rs6000/powerpc-isa207-htm-vsx64l.dat: Generate.
* ppc-linux-nat.c (fetch_register, fetch_ppc_registers): Call
fetch_regset with HTM regsets.
(store_register, store_ppc_registers): Call store_regset with HTM
regsets.
(ppc_linux_nat_target::read_description): Set htm field in the
features struct if needed.
* ppc-linux-tdep.c: Include
features/rs6000/powerpc-isa207-htm-vsx32l.c and
features/rs6000/powerpc-isa207-htm-vsx64l.c.
(ppc32_regmap_tm_spr, ppc32_regmap_cgpr, ppc64_le_regmap_cgpr)
(ppc64_be_regmap_cgpr, ppc32_regmap_cfpr, ppc32_le_regmap_cvmx)
(ppc32_be_regmap_cvmx, ppc32_regmap_cvsx, ppc32_regmap_cppr)
(ppc32_regmap_cdscr, ppc32_regmap_ctar): New globals.
(ppc32_linux_tm_sprregset, ppc32_linux_cgprregset)
(ppc64_be_linux_cgprregset, ppc64_le_linux_cgprregset)
(ppc32_linux_cfprregset, ppc32_le_linux_cvmxregset)
(ppc32_be_linux_cvmxregset, ppc32_linux_cvsxregset)
(ppc32_linux_cpprregset, ppc32_linux_cdscrregset)
(ppc32_linux_ctarregset): New globals.
(ppc_linux_cgprregset, ppc_linux_cvmxregset): New functions.
(ppc_linux_collect_core_cpgrregset): New function.
(ppc_linux_iterate_over_regset_sections): Call back with the htm
regsets.
(ppc_linux_core_read_description): Check if the tm spr section is
present and set htm in the features struct.
(_initialize_ppc_linux_tdep): Call
initialize_tdesc_powerpc_isa207_htm_vsx32l and
initialize_tdesc_powerpc_isa207_htm_vsx64l.
* ppc-linux-tdep.h (ppc_linux_cgprregset, ppc_linux_cvmxregset):
Declare.
(ppc32_linux_tm_sprregset, ppc32_linux_cfprregset)
(ppc32_linux_cvsxregset, ppc32_linux_cpprregset)
(ppc32_linux_cdscrregset, ppc32_linux_ctarregset): Declare.
* ppc-tdep.h (struct gdbarch_tdep) <have_htm_spr, have_htm_core>:
New fields.
<have_htm_fpu, have_htm_altivec, have_htm_vsx>:
Likewise.
<ppc_cppr_regnum, ppc_cdscr_regnum, ppc_ctar_regnum>: Likewise.
<ppc_cdl0_regnum, ppc_cvsr0_regnum, ppc_cefpr0_regnum>: Likewise.
(enum) <PPC_TFHAR_REGNUM, PPC_TEXASR_REGNUM, PPC_TFIAR_REGNUM>:
New enum fields.
<PPC_CR0_REGNUM, PPC_CCR_REGNUM, PPC_CXER_REGNUM>: Likewise.
<PPC_CLR_REGNUM, PPC_CCTR_REGNUM, PPC_CF0_REGNUM>: Likewise.
<PPC_CFPSCR_REGNUM, PPC_CVR0_REGNUM, PPC_CVSCR_REGNUM>: Likewise.
<PPC_CVRSAVE_REGNUM, PPC_CVSR0_UPPER_REGNUM>: Likewise.
<PPC_CPPR_REGNUM, PPC_CDSCR_REGNUM>: Likewise.
<PPC_CTAR_REGNUM>: Likewise.
(PPC_IS_TMSPR_REGNUM, PPC_IS_CKPTGP_REGNUM, PPC_IS_CKPTFP_REGNUM)
(PPC_IS_CKPTVMX_REGNUM, PPC_IS_CKPTVSX_REGNUM): Define.
* rs6000-tdep.c (IS_CDFP_PSEUDOREG, IS_CVSX_PSEUDOREG)
(IS_CEFP_PSEUDOREG): Define.
(rs6000_register_name): Hide the upper halves of checkpointed VSX
registers.  Return names for the checkpointed DFP, VSX, and EFP
pseudo registers.
(rs6000_pseudo_register_type): Remove initial assert and raise an
internal error in the else clause instead.  Return types for the
checkpointed DFP, VSX, and EFP pseudo registers.
(dfp_pseudo_register_read, dfp_pseudo_register_write): Handle
checkpointed DFP pseudo registers.
(vsx_pseudo_register_read, vsx_pseudo_register_write): Handle
checkpointed VSX pseudo registers.
(efp_pseudo_register_read, efp_pseudo_register_write): Rename
from efpr_pseudo_register_read and
efpr_pseudo_register_write.  Handle checkpointed EFP pseudo
registers.
(rs6000_pseudo_register_read, rs6000_pseudo_register_write):
Handle checkpointed DFP, VSX, and EFP registers.
(dfp_ax_pseudo_register_collect, vsx_ax_pseudo_register_collect)
(efp_ax_pseudo_register_collect): New functions.
(rs6000_ax_pseudo_register_collect): Move DFP, VSX and EFP pseudo
register logic to new functions.  Handle checkpointed DFP, VSX,
and EFP pseudo registers.
(rs6000_gdbarch_init): Look for and validate the htm features.
Include checkpointed DFP, VSX and EFP pseudo-registers.
* NEWS: Mention access to PPR, DSCR, TAR, EBB/PMU registers and
HTM registers.

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

* configure.srv (ipa_ppc_linux_regobj): Add
powerpc-isa207-htm-vsx32l-ipa.o and
powerpc-isa207-htm-vsx64l-ipa.o.
(powerpc*-*-linux*): Add powerpc-isa207-htm-vsx32l.o and
powerpc-isa207-htm-vsx64l.o to srv_regobj.  Add
rs6000/power-htm-spr.xml, rs6000/power-htm-core.xml,
rs6000/power64-htm-core.xml, rs6000/power-htm-fpu.xml,
rs6000/power-htm-altivec.xml, rs6000/power-htm-vsx.xml,
rs6000/power-htm-ppr.xml, rs6000/power-htm-dscr.xml,
rs6000/power-htm-tar.xml, rs6000/powerpc-isa207-htm-vsx32l.xml,
and rs6000/powerpc-isa207-htm-vsx64l.xml to srv_xmlfiles.
* linux-ppc-tdesc-init.h (enum ppc_linux_tdesc)
<PPC_TDESC_ISA207_HTM_VSX>: New enum value.
(init_registers_powerpc_isa207_htm_vsx32l)
(init_registers_powerpc_isa207_htm_vsx64l): Declare.
* linux-ppc-low.c (ppc_fill_tm_sprregset, ppc_store_tm_sprregset)
(ppc_store_tm_cgprregset, ppc_store_tm_cfprregset)
(ppc_store_tm_cvrregset, ppc_store_tm_cvsxregset)
(ppc_store_tm_cpprregset, ppc_store_tm_cdscrregset)
(ppc_store_tm_ctarregset): New functions.
(ppc_regsets): Add entries for HTM regsets.
(ppc_arch_setup): Set htm in features struct when needed.  Set
sizes for the HTM regsets.
(ppc_get_ipa_tdesc_idx): Return PPC_TDESC_ISA207_HTM_VSX.
(initialize_low_arch): Call
init_registers_powerpc_isa207_htm_vsx32l and
init_registers_powerpc_isa207_htm_vsx64l.
* linux-ppc-ipa.c (get_ipa_tdesc): Handle
PPC_TDESC_ISA207_HTM_VSX.
(initialize_low_tracepoint): Call
init_registers_powerpc_isa207_htm_vsx32l and
init_registers_powerpc_isa207_htm_vsx64l.

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

* gdb.arch/powerpc-htm-regs.c: New file.
* gdb.arch/powerpc-htm-regs.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.htm.spr", "org.gnu.gdb.power.htm.core",
"org.gnu.gdb.power.htm.fpu", "org.gnu.gdb.power.htm.altivec",
"org.gnu.gdb.power.htm.vsx", "org.gnu.gdb.power.htm.ppr",
"org.gnu.gdb.power.htm.dscr", "org.gnu.gdb.power.htm.tar".

6 years ago[PowerPC] Reject tdescs with VSX and no FPU or Altivec
Pedro Franco de Carvalho [Fri, 26 Oct 2018 12:37:55 +0000 (09:37 -0300)]
[PowerPC] Reject tdescs with VSX and no FPU or Altivec

Currently rs6000_gdbarch_init will accept a tdesc with the
"org.gnu.gdb.power.vsx" feature but without the
"org.gnu.gdb.power.altivec" or "org.gnu.gdb.power.fpu".

It isn't clear from the standard features documentation that these are
requirements.  However, these tdescs would cause trouble in the VSX
pseudo-register functions, so this patch will cause them to be
rejected.

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

* rs6000-tdep.c (rs6000_gdbarch_init): Reject tdescs with vsx but
without altivec or fpu.

6 years ago[PowerPC] Add support for EBB and PMU registers
Edjunior Barbosa Machado [Fri, 26 Oct 2018 12:37:54 +0000 (09:37 -0300)]
[PowerPC] Add support for EBB and PMU registers

This patch adds support for registers of the Event Based Branching and
Performance Monitoring Units for the powerpc linux native and core
file targets, and for the powerpc linux server stub.

All three EBB registers are accessible.  Only a subset of the PMU
registers can be accessed through ptrace.  Because of this, the PMU
registers are enumerated individually in gdbarch_tdep, as opposed to
having a single "have_pmu" flag.  This is intended to make it easier
to add additional PMU registers in the future, since checking a
"have_pmu" flag elsewhere in the code would no longer be correct.  The
tdesc feature is named org.gnu.gdb.power.linux.pmu because of this.

It's unclear if it makes sense to save and restore these registers
across function calls, since some of them can be modified
asynchronously.  They are also not tracked in record-replay mode.

The kernel can return ENODATA when ptrace is used to get the EBB
registers, unless a linux performance event that uses EBB is open in
the inferior.  For this reason, the "fill" functions in the server
stub for the ebb register sets is not implemented.

Since gdbserver writes all registers in one go before resuming the
inferior, this error would not be detected at the time the user tries
to write to one of the registers on the client side, and gdbserver
would print out warnings every time it resumes the inferior when no
ebb performance event is opened, so there is currently no
straightforward way to handle this case.  This means the ebb registers
in the client-side regcache can become dirty when the user tries to
write to them, until the inferior is resumed and stopped again.

A related issue is that 'G' packets used to write to unrelated
registers will include bad data for the EBB registers if they are
unavailable, since no register status information is included in the
'G' packet.  This data won't be written to the inferior by the
gdbserver stub because the "fill" functions are not implemented, and
currently the gdbserver stub doesn't change the status of the
registers in its own regcache in response to 'G' packets.

Another limitation for the ebb registers is that traceframes don't
record if registers are available or not, so if these registers are
collected when a tracepoint is hit and the inferior has no ebb event
opened, the user will see zero values for all of them, instead of the
usual <unavailable>.

Because these registers are often unavailable, trying to store them
with target_store_registers with -1 for the regno argument (all
registers) would almost always fail, so they are ignored in this case.

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

* arch/ppc-linux-common.h (PPC_LINUX_SIZEOF_EBBREGSET)
(PPC_LINUX_SIZEOF_PMUREGSET): Declare.
* nat/ppc-linux.h (PPC_FEATURE2_EBB, NT_PPC_EBB, NT_PPC_PMU):
Define if not already defined.
* features/rs6000/power-ebb.xml: New file.
* features/rs6000/power-linux-pmu.xml: New file.
* features/rs6000/powerpc-isa207-vsx32l.xml: Include ebb and pmu
features.
* features/rs6000/powerpc-isa207-vsx64l.xml: Likewise.
* features/rs6000/powerpc-isa207-vsx32l.c: Re-generate.
* features/rs6000/powerpc-isa207-vsx64l.c: Re-generate.
* regformats/rs6000/powerpc-isa207-vsx32l.dat: Re-generate.
* regformats/rs6000/powerpc-isa207-vsx64l.dat: Re-generate.
* ppc-linux-nat.c (fetch_register, fetch_ppc_registers): Call
fetch_regset with ebb and pmu regsets.
(store_register, store_ppc_registers): Call store_regset with ebb
and pmu regsets.
(ppc_linux_nat_target::read_description): Set isa207 field in the
features struct if ebb and pmu are avaiable.
* ppc-linux-tdep.c (ppc32_regmap_ebb, ppc32_regmap_pmu)
(ppc32_linux_ebbregset, ppc32_linux_pmuregset): New globals.
(ppc_linux_iterate_over_regset_sections): Call back with the ebb
and pmu regsets.
(ppc_linux_core_read_description): Check if the pmu section is
present and set isa207 in the features struct.
* ppc-linux-tdep.h (ppc32_linux_ebbregset)
(ppc32_linux_pmuregset): Declare.
* ppc-tdep.h (struct gdbarch_tdep) <ppc_mmcr0_regnum>: New field.
<ppc_mmcr2_regnum, ppc_siar_regnum, ppc_sdar_regnum>: New fields.
<ppc_sier_regnum>: New field.
(enum): <PPC_BESCR_REGNUM, PPC_EBBHR_REGNUM, PPC_EBBRR_REGNUM>:
New enum values.
<PPC_MMCR0_REGNUM, PPC_MMCR2_REGNUM, PPC_SIAR_REGNUM>: New enum
values.
<PPC_SDAR_REGNUM, PPC_SIER_REGNUM>: New enum values.
(PPC_IS_EBB_REGNUM, PPC_IS_PMU_REGNUM): Define.
* rs6000-tdep.c (rs6000_gdbarch_init): Look for and validate the
ebb and pmu features.

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

* configure.srv (powerpc*-*-linux*): Add rs6000/power-ebb.xml and
rs6000/power-linux-pmu.xml to srv_xmlfiles.
* linux-ppc-low.c (ppc_store_ebbregset, ppc_fill_pmuregset)
(ppc_store_pmuregset): New functions.
(ppc_regsets): Add entries for ebb and pmu regsets.
(ppc_arch_setup): Set isa207 in features struct if the ebb and
pmu regsets are available.  Set sizes for these regsets.

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.ebb" and "org.gnu.gdb.power.linux.pmu".

6 years ago[PowerPC] Add support for TAR
Edjunior Barbosa Machado [Fri, 26 Oct 2018 12:37:54 +0000 (09:37 -0300)]
[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".

6 years ago[PowerPC] Add support for PPR and DSCR
Edjunior Barbosa Machado [Fri, 26 Oct 2018 12:37:54 +0000 (09:37 -0300)]
[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".

6 years ago[PowerPC] Refactor have_ initializers in rs6000-tdep.c
Pedro Franco de Carvalho [Fri, 26 Oct 2018 12:37:54 +0000 (09:37 -0300)]
[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.

6 years ago[PowerPC] Fix indentation in arch/ppc-linux-common.c
Pedro Franco de Carvalho [Fri, 26 Oct 2018 12:37:54 +0000 (09:37 -0300)]
[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.

6 years ago[PowerPC] Fix two if statements in gdb/ppc-linux-nat.c
Pedro Franco de Carvalho [Fri, 26 Oct 2018 12:37:54 +0000 (09:37 -0300)]
[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.

6 years ago[PowerPC] Remove rs6000_pseudo_register_reggroup_p
Pedro Franco de Carvalho [Fri, 26 Oct 2018 12:37:53 +0000 (09:37 -0300)]
[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.

6 years agoAdd decfloat registers to float reggroup
Pedro Franco de Carvalho [Fri, 26 Oct 2018 12:37:53 +0000 (09:37 -0300)]
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.

6 years ago[PowerPC] Don't zero-initialize vector register buffers
Pedro Franco de Carvalho [Fri, 26 Oct 2018 12:37:53 +0000 (09:37 -0300)]
[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.

6 years agoZero-initialize linux note sections
Pedro Franco de Carvalho [Fri, 26 Oct 2018 12:37:53 +0000 (09:37 -0300)]
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.

6 years agoFix SYMBOL_LANGUAGE assertion failure on AIX.
Sangamesh Mallayya [Fri, 26 Oct 2018 10:01:36 +0000 (15:31 +0530)]
Fix SYMBOL_LANGUAGE assertion failure on AIX.

6 years agogdb/riscv: Remove redundant code, and catch more errors when accessing MISA
Andrew Burgess [Tue, 23 Oct 2018 11:10:23 +0000 (12:10 +0100)]
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.

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 26 Oct 2018 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoELF: update ld man page on `--gc-sections`
Christoph Conrads [Thu, 25 Oct 2018 19:21:41 +0000 (21:21 +0200)]
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.

6 years ago[gdb/testsuite] Move valgrind-db-attach.{c,exp} to valgrind-bt.{c,exp}
Tom de Vries [Thu, 25 Oct 2018 14:09:57 +0000 (16:09 +0200)]
[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.

6 years ago[gdb/testsuite] Rewrite valgrind-db-attach.exp to use vgdb
Tom de Vries [Thu, 25 Oct 2018 09:03:23 +0000 (11:03 +0200)]
[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.

6 years agogdb/python: Make convert_values_to_python return gdbpy_ref<>
Andrew Burgess [Mon, 10 Sep 2018 11:05:22 +0000 (12:05 +0100)]
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.

6 years agogdb/python: Make cmdpy_completer_helper return gdbpy_ref<>
Andrew Burgess [Mon, 10 Sep 2018 10:48:28 +0000 (11:48 +0100)]
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.

6 years agogdb/riscv: Use correct regnum in riscv_linux_nat_target::fetch_registers
Andrew Burgess [Thu, 25 Oct 2018 11:03:31 +0000 (12:03 +0100)]
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.

6 years agoELF: Hide symbols defined in discarded input sections
H.J. Lu [Thu, 25 Oct 2018 01:08:13 +0000 (18:08 -0700)]
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.

6 years agoAutomatic date update in version.in
GDB Administrator [Thu, 25 Oct 2018 00:00:43 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years ago[gdb/testsuite] Log wait status on process no longer exists error
Tom de Vries [Wed, 24 Oct 2018 10:54:33 +0000 (12:54 +0200)]
[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.

6 years agocmse_scan segfault
Alan Modra [Wed, 24 Oct 2018 04:38:28 +0000 (15:08 +1030)]
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.

6 years ago[gdb/testsuite] Rewrite catch-follow-exec.exp using gdb_test
Tom de Vries [Tue, 23 Oct 2018 21:54:21 +0000 (23:54 +0200)]
[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.

6 years ago[gdb/testsuite] Handle removed valgrind option --db-attach
Tom de Vries [Wed, 24 Oct 2018 07:49:44 +0000 (09:49 +0200)]
[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.

6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 24 Oct 2018 00:00:40 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoFix failing cooked_read selftest for CSKY.
Hafiz Abid Qadeer [Tue, 23 Oct 2018 22:16:58 +0000 (23:16 +0100)]
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

6 years agoAvoid GDB SIGTTOU on catch exec + set follow-exec-mode new (PR 23368)
Simon Marchi [Tue, 23 Oct 2018 21:00:33 +0000 (17:00 -0400)]
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.

6 years agoFix use-after-free in record_btrace_start_replaying
Tom Tromey [Sat, 28 Jul 2018 20:19:09 +0000 (14:19 -0600)]
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.

6 years agoS/390: Support vector alignment hints
Andreas Krebbel [Tue, 23 Oct 2018 16:02:37 +0000 (18:02 +0200)]
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.

6 years agoGDB: New target s12z
John Darrington [Mon, 9 Jul 2018 18:54:26 +0000 (20:54 +0200)]
GDB:  New target s12z

gdb/
    * configure.tgt: Add configuration for s12z.
    * s12z-tdep.c:  New file.
    * NEWS: Mention new target.

6 years agoGDB: Remote target can now accept the form unix::/path/to/socket.
John Darrington [Sat, 13 Oct 2018 16:12:01 +0000 (18:12 +0200)]
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.

6 years agoGDB: Fix documentation for invoking GDBSERVER
John Darrington [Sat, 13 Oct 2018 15:27:05 +0000 (17:27 +0200)]
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.

6 years agoGDB: Document the unix::/path/to/socket of remote connection.
John Darrington [Sat, 13 Oct 2018 14:48:01 +0000 (16:48 +0200)]
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.

6 years agoGDBSERVER: Listen on a unix domain (instead of TCP) socket if requested.
John Darrington [Sat, 22 Sep 2018 10:35:41 +0000 (12:35 +0200)]
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.

6 years agoS12Z: New 32 bit Reloc.
John Darrington [Wed, 3 Oct 2018 10:26:42 +0000 (12:26 +0200)]
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.

6 years agoS12Z: Handle 16 bit fixups which are constant.
John Darrington [Tue, 23 Oct 2018 13:33:18 +0000 (15:33 +0200)]
S12Z:  Handle 16 bit fixups which are constant.

Commit 1f38083f425e03faf55595414daf291306738222 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

6 years agogdb/riscv: Give user-friendly names for CSRs
Andrew Burgess [Tue, 23 Oct 2018 12:23:34 +0000 (13:23 +0100)]
gdb/riscv: Give user-friendly names for CSRs

The recent commit:

    commit 0dbfcfffe9abbc5198bce95eb8c66b6bc9b364be
    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.

6 years agoPR23806, NULL pointer dereference in merge_strings
Alan Modra [Tue, 23 Oct 2018 08:32:06 +0000 (19:02 +1030)]
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.

6 years agoPR23805, NULL pointer dereference in elf_link_input_bfd
Alan Modra [Tue, 23 Oct 2018 08:00:22 +0000 (18:30 +1030)]
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.

6 years agoPR23804, buffer overflow in sec_merge_hash_lookup
Alan Modra [Tue, 23 Oct 2018 07:59:24 +0000 (18:29 +1030)]
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.

6 years agoalpha testsuite fixes
Alan Modra [Tue, 23 Oct 2018 05:20:43 +0000 (15:50 +1030)]
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.

6 years agogdb/riscv: expect h/w watchpoints to trigger before the memory is written
Joel Brobecker [Tue, 23 Oct 2018 10:27:50 +0000 (11:27 +0100)]
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.

6 years agogdb/riscv: Fix register access for register aliases
Andrew Burgess [Tue, 16 Oct 2018 21:40:09 +0000 (22:40 +0100)]
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.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 23 Oct 2018 00:00:53 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoRISC-V: NaN-box FP values smaller than an FP register.
Jim Wilson [Mon, 22 Oct 2018 21:11:55 +0000 (14:11 -0700)]
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.

6 years agoRISC-V: Print FP regs as union of float types.
Jim Wilson [Mon, 22 Oct 2018 21:10:13 +0000 (14:10 -0700)]
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.

6 years agoS12Z: Disassembly: Fallback to show the address if the symbol table is empty.
John Darrington [Mon, 22 Oct 2018 14:59:47 +0000 (16:59 +0200)]
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.

6 years agogas simple-forward test
Alan Modra [Mon, 22 Oct 2018 03:19:21 +0000 (13:49 +1030)]
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.

6 years agoApply alpha BFD_RELOC_8 fixups
Alan Modra [Mon, 22 Oct 2018 10:00:40 +0000 (20:30 +1030)]
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.

6 years agoPR23040, .uleb128 directive doesn't accept some valid expressions
Alan Modra [Sat, 20 Oct 2018 11:52:37 +0000 (22:22 +1030)]
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.

6 years agoIntroduce gdbarch_num_cooked_regs
Simon Marchi [Mon, 22 Oct 2018 02:29:21 +0000 (22:29 -0400)]
Introduce gdbarch_num_cooked_regs

The expression

  gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch)

is used quite often to find the number of cooked registers (raw + pseudo
registers).  This patch introduces gdbarch_num_cooked_regs, which does
the equivalent.  It substantially reduces required wrapping in some
places, so should improve readability.

There is a for loop in m68hc11_frame_unwind_cache that had iterated
until (the equivalent of) gdbarch_num_cooked_regs (gdbarch) - 1.  During
review, we concluded that this is most likely an off-by-one mistake, so
I replaced it with gdbarch_num_cooked_regs (gdbarch).

gdb/ChangeLog:

* gdbarch.sh (gdbarch_num_cooked_regs): New.
* gdbarch.h: Re-generate.
* ax-gdb.c (gen_expr): Use gdbarch_num_cooked_regs.
* dwarf2-frame.c (dwarf2_frame_cache): Likewise.
* eval.c (evaluate_subexp_standard): Likewise.
* findvar.c (value_of_register): Likewise.
(value_of_register_lazy): Likewise.
(address_from_register): Likewise.
* frame.c (get_frame_register_bytes): Likewise.
* gdbarch-selftests.c (register_to_value_test): Likewise.
* h8300-tdep.c (h8300_register_type): Likewise.
* i386-tdep.c (i386_dbx_reg_to_regnum): Likewise.
(i386_svr4_reg_to_regnum): Likewise.
* infcmd.c (default_print_registers_info): Likewise.
(registers_info): Likewise.
(print_vector_info): Likewise.
(default_print_float_info): Likewise.
* m68hc11-tdep.c (m68hc11_frame_unwind_cache): Likewise.
* mdebugread.c (mdebug_reg_to_regnum): Likewise.
* mi/mi-main.c (mi_cmd_data_list_register_names): Likewise.
(mi_cmd_data_list_changed_registers): Likewise.
(mi_cmd_data_list_register_values): Likewise.
(mi_cmd_data_write_register_values): Likewise.
(mi_cmd_trace_frame_collected): Likewise.
* mips-tdep.c (print_gp_register_row): Likewise.
(mips_print_registers_info): Likewise.
* nds32-tdep.c (nds32_gdbarch_init): Likewise.
* regcache.c (init_regcache_descr): Likewise.
(register_size): Likewise.
(register_dump::dump): Likewise.
(cooked_read_test): Likewise.
(cooked_write_test): Likewise.
* rs6000-tdep.c (rs6000_register_sim_regno): Likewise.
(rs6000_gdbarch_init): Likewise.
* stabsread.c (stab_reg_to_regnum): Likewise.
* stack.c (info_frame_command): Likewise.
* target-descriptions.c (tdesc_register_name): Likewise.
* trad-frame.c (trad_frame_alloc_saved_regs): Likewise.
* tui/tui-regs.c (tui_show_register_group): Likewise.
* user-regs.c (user_reg_map_name_to_regnum): Likewise.
(user_reg_map_regnum_to_name): Likewise.
(value_of_user_reg): Likewise.
(maintenance_print_user_registers): Likewise.
* xtensa-tdep.c (xtensa_find_register_by_name): Likewise.
(xtensa_register_name): Likewise.
(xtensa_register_type): Likewise.
(xtensa_reg_to_regnum): Likewise.
(xtensa_pseudo_register_read): Likewise.
(xtensa_pseudo_register_write): Likewise.

6 years agoAllocate buffer with proper size in amd64_pseudo_register_{read_value,write}
Simon Marchi [Mon, 22 Oct 2018 02:09:24 +0000 (22:09 -0400)]
Allocate buffer with proper size in amd64_pseudo_register_{read_value,write}

Running "maintenance selftest" on an amd64 build with AddressSanitizer
enabled, I get this:

==18126==ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address 0x7ffdf72397c1 at pc 0x7fb5f437b011 bp 0x7ffdf7239740 sp 0x7ffdf7238ee8
WRITE of size 8 at 0x7ffdf72397c1 thread T0
    #0 0x7fb5f437b010 in __interceptor_memcpy /build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:737
    #1 0x55a1f899c1b3 in readable_regcache::raw_read(int, unsigned char*) /home/simark/src/binutils-gdb/gdb/regcache.c:530
    #2 0x55a1f7db241b in amd64_pseudo_register_read_value /home/simark/src/binutils-gdb/gdb/amd64-tdep.c:384
    #3 0x55a1f8413a2e in gdbarch_pseudo_register_read_value(gdbarch*, readable_regcache*, int) /home/simark/src/binutils-gdb/gdb/gdbarch.c:1992
    #4 0x55a1f899c9d1 in readable_regcache::cooked_read(int, unsigned char*) /home/simark/src/binutils-gdb/gdb/regcache.c:636
    #5 0x55a1f89a2251 in cooked_read_test /home/simark/src/binutils-gdb/gdb/regcache.c:1649

In amd64_pseudo_register_read_value, when we try to read the al
register, for example, we need to read rax and extract al from it.  We
allocate a buffer of the size of al (1 byte):

  gdb_byte *raw_buf = (gdb_byte *) alloca (register_size (gdbarch, regnum));

but read in it the whole rax value (8 bytes):

  status = regcache->raw_read (gpnum, raw_buf);

Fix it by allocating a buffer correctly sized for the full register from
which the smaller register is extracted.  The
amd64_pseudo_register_write function had the same problem.

gdb/ChangeLog:

* amd64-tdep.c (amd64_pseudo_register_read_value): Use
correctly-sized buffer with raw_read.
(amd64_pseudo_register_write): Use correctly-sized buffer for
raw_read/raw_write.

6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 22 Oct 2018 00:00:58 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 21 Oct 2018 00:01:05 +0000 (00:01 +0000)]
Automatic date update in version.in

6 years ago[PUSHED/OBVIOUS] ensure help set print type gives the correct help.
Philippe Waroquiers [Sat, 20 Oct 2018 21:00:52 +0000 (23:00 +0200)]
[PUSHED/OBVIOUS] ensure help set print type gives the correct help.

Without this patch:
  (gdb) help set print type
  Generic command for setting how types print.

  List of show print type subcommands:

  show print type methods -- Set printing of methods defined in classes
  ...

With this patch:
  (gdb) h set print type
  Generic command for setting how types print.

  List of set print type subcommands:

  set print type methods -- Set printing of methods defined in classes
  ...

6 years agoFix "make info" in gdb
Tom Tromey [Sat, 20 Oct 2018 18:18:20 +0000 (12:18 -0600)]
Fix "make info" in gdb

"make info" in gdb was broken by my last patch.  This fixes it.
Tested by rebuilding; committing as obvious.

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

* gdb.texinfo (TUI Commands): Add @end table.
(TUI Configuration): Remove stray @end table.

6 years agoGDB: Documentation: Remove greengrocer's apostrophe.
John Darrington [Sat, 13 Oct 2018 18:07:34 +0000 (20:07 +0200)]
GDB: Documentation: Remove greengrocer's apostrophe.

gdb/doc/gdb.texinfo (gdbserver man): "it's symbol" --> its symbol.

6 years agoPR23800, .eqv doesn't always defer expression evaluation
Alan Modra [Sat, 20 Oct 2018 00:42:46 +0000 (11:12 +1030)]
PR23800, .eqv doesn't always defer expression evaluation

.eqv (and ==) ought not simplify expressions involving dot or other
symbols set by .eqv.  If such simplification occurs, the value of dot
will be that at the assignment rather than at the place where the
symbol is used.

PR 23800
* expr.c (expr): Don't simplify expressions involving forward_ref
symbols when mode is expr_defer.
* config/tc-spu.c (spu_cons): Parse expression using normal
expression evaluation if @ppu is not detected.
* testsuite/gas/all/eqv-dot.d,
* testsuite/gas/all/eqv-dot.s: New test.
* testsuite/gas/all/gas.exp: Run it.

6 years agoPR23788, objcopy: failed to find link section
Alan Modra [Fri, 19 Oct 2018 13:32:17 +0000 (00:02 +1030)]
PR23788, objcopy: failed to find link section

Symbol tables can change when a number of objcopy options are used.
I figure string tables are similarly changeable.

PR 23788
* elf.c (section_match): Don't require a size match for SHT_SYMTAB
or SHT_STRTAB.

6 years agoRelax a -r --gc-sections requirement
Alan Modra [Fri, 19 Oct 2018 13:29:11 +0000 (23:59 +1030)]
Relax a -r --gc-sections requirement

A symbol root is not needed if --gc-keep-exported is also given.

* ldlang.c (lang_end): Don't error if no --entry or --undefined
is given with -r -gc-sections if --gc-keep-exported.

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 20 Oct 2018 00:00:40 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoDeprecate and replace the "tabset" command
Tom Tromey [Mon, 3 Sep 2018 01:41:41 +0000 (19:41 -0600)]
Deprecate and replace the "tabset" command

The "tabset" command sets the tab width as used by the TUI for source
and disassembly display.

This command has long seemed to be misnamed to me.  It is more in
keeping with gdb design to call it "set tui tab-width".  Also, making
this change allows for the corresponding "show" command to work.

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

PR tui/18388:
* NEWS: Mention tabset deprecation.
* tui/tui-win.c (tui_tab_width, internal_tab_width): New globals.
(update_tab_width): New function.
(tui_set_tab_width, tui_show_tab_width): New functions.
(tui_set_tab_width_command): Use update_tab_width.
(_initialize_tui_win): Move to end of file.  Deprecate "tabset".
Add new "set tui tab-width" command.
* tui/tui-source.c (tui_set_source_content): Update.
* tui/tui-disasm.c (tui_set_disassem_content): Update.
* tui/tui-data.h (tui_default_tab_len, tui_set_default_tab_len):
Don't declare.
(tui_tab_width): Declare.
* tui/tui-data.c (default_tab_len, tui_default_tab_len)
(tui_set_default_tab_len): Remove.

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

PR tui/18388:
* gdb.texinfo (TUI Commands): Remove tabset documentation.
(TUI Configuration): Document "set tui tab-width".

6 years agoMinor cleanups in tui-io.c
Tom Tromey [Sun, 2 Sep 2018 00:44:33 +0000 (18:44 -0600)]
Minor cleanups in tui-io.c

I noticed that a couple of functions in tui-io.c could be static, and
that a couple more were unused and could be removed.

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

* tui/tui-io.h (key_is_start_sequence, key_is_end_sequence)
(key_is_backspace, tui_getc): Don't declare.
* tui/tui-io.c (key_is_start_sequence): Now static.
(key_is_end_sequence, key_is_backspace): Remove.
(tui_getc): Now static.

6 years agoClear static_links in reread_symbols
Tom Tromey [Thu, 26 Jul 2018 23:54:00 +0000 (17:54 -0600)]
Clear static_links in reread_symbols

-fsanitize=address pointed out a use-after free in
objfile_register_static_link.  The bug turned out to be that
reread_symbols does not clear the static_links field; this leaves a
hash table that is filled with freed pointers.

Jan's (now quite old) idea of replacing reread_symbols with a simple
delete/new still seems good to me, and it's worth noting that it would
have avoided this bug.

Tested by the buildbot and by observing the change with
-fsanitize=address.

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

* symfile.c (reread_symbols): Clear "static_links".

6 years agoArm: Skip new binary decode tests on pe targets
Tamar Christina [Fri, 19 Oct 2018 15:18:37 +0000 (16:18 +0100)]
Arm: Skip new binary decode tests on pe targets

The two new test I added require the use of the ".inst" directive which the PE
targets don't support.  Because of that I excluded *-unknown-pe but the mask needs
to be wider.  I am now excluding *-*-pe.

gas/ChangeLog:

* testsuite/gas/arm/undefined-insn-arm.d: Widen pe skip.
* testsuite/gas/arm/undefined-insn-thumb.d: Likewise.

6 years agoAarch64: Better termination checks for sigcontext reading
Alan Hayward [Fri, 19 Oct 2018 12:51:00 +0000 (13:51 +0100)]
Aarch64: Better termination checks for sigcontext reading

When reading the reserved section in the sigcontext ensure the
address is updated on an unknown section. Also add additional
checks to prevent reading past the end of the array.

Fixes gdb.base/savedregs.exp

* aarch64-linux-tdep.c (AARCH64_SIGCONTEXT_RESERVED_SIZE): New
define.
(aarch64_linux_sigframe_init): Extra boundary checks.

6 years agoS390: Fix crash when remote tdesc doesn't define vec128
Andreas Arnez [Fri, 19 Oct 2018 12:05:08 +0000 (14:05 +0200)]
S390: Fix crash when remote tdesc doesn't define vec128

I've encountered a GDB crash when trying to read registers from a remote
stub that provided a target.xml with vector registers, but without the
'vec128' data type.  The crash is caused by NULL register type entries for
the "concatenated" pseudo-registers v0-v15.  These NULL entries are
introduced by the logic in s390_pseudo_register_type(), where the tdesc
type 'vec128' is returned unconditionally -- even if it doesn't exist (is
NULL).

The fixed logic for determining a "concatenated" vector register's type
now returns the type of the raw register v16 instead.  This also makes
sure that all vector register have the same type.

gdb/ChangeLog:

* s390-tdep.c (s390_pseudo_register_type): For v0-v15 don't yield
the possibly non-existent tdesc type 'vec128', but the type of raw
register v16 instead.

6 years agoFix cli_interp::cli_uiout resource leak found by Coverity
Gary Benson [Fri, 19 Oct 2018 10:51:41 +0000 (11:51 +0100)]
Fix cli_interp::cli_uiout resource leak found by Coverity

This commit fixes a resource leak found by Coverity, where cli_interp's
constructor creates a new cli_ui_out, but there was no corresponding
destructor to free it.

gdb/ChangeLog:

* cli/cli-interp.c (cli_interp::~cli_interp): New function.