external/binutils.git
7 years agoConstify add_cmd gdb_bfd.c
Tom Tromey [Sun, 10 Sep 2017 02:55:20 +0000 (20:55 -0600)]
Constify add_cmd gdb_bfd.c

This constifies a command function in gdb_bfd.c.

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* gdb_bfd.c (maintenance_info_bfds): Constify.

7 years agoAdd add_cmd function overloads
Tom Tromey [Sun, 10 Sep 2017 02:51:33 +0000 (20:51 -0600)]
Add add_cmd function overloads

This adds two add_cmd overloads: one whose callback takes a const char *,
and one that doesn't accept a function at all.  The no-function overload
was introduced to avoid ambiguity when NULL was passed as the function.

Long term the goal is for all commands to take const arguments, and
for the non-const variants to be removed entirely.

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* cli/cli-decode.c (add_cmd, set_cmd_cfunc): New function
overloads.
(do_add_cmd): Rename from add_cmd.  Don't call set_cmd_cfunc.
(do_const_cfunc): New function.
(cmd_cfunc_eq): New overload.
(cli_user_command_p): Check do_const_cfunc.
* cli/cli-decode.h (struct cmd_list_element) <function>: New field
const_cfunc.
* command.h (add_cmd): Add const overload and no-function
overload.
(set_cmd_cfunc): Add const overload.
(cmd_const_cfunc_ftype): Declare.
(cmd_cfunc_eq): Add const overload.
* breakpoint.c, cli-cmds.c, cli-dump.c, guile/scm-cmd.c,
python/py-cmd.c, target.c, tracepoint.c: Use no-function add_cmd
overload.

7 years agoAdd support for __VA_OPT__
Tom Tromey [Mon, 18 Sep 2017 02:36:41 +0000 (20:36 -0600)]
Add support for __VA_OPT__

C++2a adds a "__VA_OPT__" feature that can be used to control the
pesky "," emission when the final (variable) argument of a variadic
macro is empty.  This patch implements this feature for gdb.  (A patch
to implement it for gcc is pending.)

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* macroexp.c (get_next_token_for_substitution): New function.
(substitute_args): Call it.  Check for __VA_OPT__.

gdb/testsuite/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* gdb.base/macscp.exp: Add __VA_OPT__ tests.

7 years agoPrevent an infinite loop in the DWARF parsing code when encountering a CU structure...
Nick Clifton [Wed, 27 Sep 2017 09:42:51 +0000 (10:42 +0100)]
Prevent an infinite loop in the DWARF parsing code when encountering a CU structure with a small negative size.

PR 22219
* dwarf.c (process_debug_info): Add a check for a negative
cu_length field.

7 years agoPR22216, infinite loop in readelf process_symbol_table
Alan Modra [Wed, 27 Sep 2017 05:44:00 +0000 (15:14 +0930)]
PR22216, infinite loop in readelf process_symbol_table

This should make readelf bombproof given a fuzzed DT_HASH.  Also
removes a bogus check that would have resulted in wrong histograms.

PR 22216
* readelf.c (process_symbol_table): Check that DT_HASH symbol
chains are only visited once, and report an error if not.  Display
invalid symbol index if chain is out of range.  Use the same logic
when calculating histograms rather than the PR 17531 fix.  Delete
bogus check that chained index is less than number of buckets.

7 years agonds32: Fix a tautological comparison.
Kuan-Lin Chen [Wed, 27 Sep 2017 05:04:35 +0000 (13:04 +0800)]
nds32: Fix a tautological comparison.

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 27 Sep 2017 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agox86-64: Don't pass output_bfd to info->callbacks->minfo
H.J. Lu [Tue, 26 Sep 2017 21:41:22 +0000 (14:41 -0700)]
x86-64: Don't pass output_bfd to info->callbacks->minfo

Don't pass output_bfd to info->callbacks->minfo when dumping local IFUNC
functions in the map file.

PR ld/22199
* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Don't pass
output_bfd to info->callbacks->minfo.

7 years agodwarf2read: Restrict ICC workaround to ICC<14
Walfred Tedeschi [Tue, 26 Sep 2017 17:26:41 +0000 (18:26 +0100)]
dwarf2read: Restrict ICC workaround to ICC<14

GDB has a workaround for DWARF output by ICC, related to missing
DW_AT_declaration on incomplete types.  The bug was fixed in ICC 14,
so this commit adjusts GDB accordingly.

For the version check, this adds a new parser function for the ICC
producer string.  While at it, it also adds unit tests for the
producer parsing covering the new function and preexisting parsers.

gdb/ChangeLog:
2017-09-26  Walfred Tedeschi  <walfred.tedeschi@intel.com>
    Pedro Alves <palves@redhat.com>

* dwarf2read.c (dwarf2_cu): Remove field producer_is_icc and add
producer_is_icc_lt_14.
(producer_is_icc_lt_14): New function.
(check_producer): Add code for checking version of ICC.
(producer_is_icc): Move to producer.c.
(read_structure_type): Restrict ICC workaround to ICC<14.
* producer.c: Include selftest.h.
(producer_is_icc, producer_parsing_tests, _initialize_producer):
New functions.
* producer.h (producer_is_icc): New declaration.

7 years agoMove GDB producer parsing routines to a separate file
Walfred Tedeschi [Tue, 26 Sep 2017 17:26:41 +0000 (18:26 +0100)]
Move GDB producer parsing routines to a separate file

gdb/ChangeLog:
2017-09-26  Walfred Tedeschi  <walfred.tedeschi@intel.com>

* Makefile.in (SFILES): Add producer.c.
(COMMON_OBS): Add producer.o
* amd64-tdep.c (producer.h): Add new include.
* dwarf2read.c (producer.h): Add new include.
* producer.c: New file.
* producer.h: New file.
* utils.c (producer_is_gcc, producer_is_gcc_ge_4): Move to
producer.c.
* utils.h (producer_is_gcc, producer_is_gcc_ge_4): Move to
producer.h.

7 years agoUse "switch_to_thread" more thoroughly on gdbserver
Sergio Durigan Junior [Fri, 15 Sep 2017 04:27:53 +0000 (00:27 -0400)]
Use "switch_to_thread" more thoroughly on gdbserver

This is a technical debt that I left when I ported "switch_to_thread"
to gdbserver.  It's a simple patch that converts occurences of:

  current_thread = find_thread_ptid (ptid);

to:

  switch_to_thread (ptid);

This patch also converts a simple "if" to a "gdb_assert" on
gdbserver's version of "switch_to_thread":

  gdb_assert (ptid != minus_one_ptid);

This change makes the code more similar to what GDB already does.

Regtested on BuildBot.

gdb/gdbserver/ChangeLog:
2017-09-26  Sergio Durigan Junior  <sergiodj@redhat.com>

* gdbthread.h: Include "common-gdbthread.h".
* inferiors.c (switch_to_thread): Use "gdb_assert" instead of
"if" when validating the ptid.
* remote-utils.c: Include "gdbthread.h".
(prepare_resume_reply): Use "switch_to_thread".
* target.c (done_accessing_memory): Likewise.

7 years agoAllow linking GDB with ncursesw
Matthias Klose [Tue, 26 Sep 2017 15:23:19 +0000 (16:23 +0100)]
Allow linking GDB with ncursesw

Triggered by https://launchpad.net/bugs/1275210, to be able to cope
with UTF-8 characters in gdbtui.

Reference:
  https://sourceware.org/ml/gdb-patches/2017-09/msg00356.html

gdb/ChangeLog:
2017-09-26  Matthias Klose  <doko@ubuntu.com>

* configure.ac: Search ncursesw before ncurses.
Check ncursesw/ncurses.h before ncurses/ncurses.h.
* gdb_curses.h: Include <ncursesw/ncurses.h>
* config.in, configure: Regenerate.

7 years agoFix an assertion failure when parsing a fuzzed x86_64 ELF binary.
Nick Clifton [Tue, 26 Sep 2017 15:03:10 +0000 (16:03 +0100)]
Fix an assertion failure when parsing a fuzzed x86_64 ELF binary.

PR 22172
* elf64-x86-64.c (elf_x86_64_info_to_howto): Do not trigger an
assertion failure if elf_x86_64_rtype_to_howto has already issued
an error message.

7 years agoFix incorrect register mask.
Cary Coutant [Tue, 26 Sep 2017 14:33:04 +0000 (07:33 -0700)]
Fix incorrect register mask.

PR gold/22213
* sparc.cc (Target_sparc): Fix incorrect register mask.

7 years agoTidy reading data in read_formatted_entries
Alan Modra [Tue, 26 Sep 2017 13:50:06 +0000 (23:20 +0930)]
Tidy reading data in read_formatted_entries

Using read_attribute_value accomplishes two things: It checks for
unexpected formats, and ensures the buffer pointer always increments.

PR 22210
* dwarf2.c (read_formatted_entries): Use read_attribute_value to
read data.

7 years agoAvoid needless resource usage when processing a corrupt DWARF directory or file name...
Nick Clifton [Tue, 26 Sep 2017 13:37:47 +0000 (14:37 +0100)]
Avoid needless resource usage when processing a corrupt DWARF directory or file name table.

PR 22210
* dwarf2.c (read_formatted_entries): Fail early if we know that
the loop parsing data entries will overflow the end of the
section.

7 years agoRemove support for Solaris < 10 (PR gdb/22185)
Rainer Orth [Tue, 26 Sep 2017 13:19:10 +0000 (15:19 +0200)]
Remove support for Solaris < 10 (PR gdb/22185)

Given that GCC has obsoleted/removed support for Solaris 9 in GCC 4.9/5 in 2013:

    https://gcc.gnu.org/gcc-4.9/changes.html
    https://gcc.gnu.org/ml/gcc-patches/2013-05/msg00728.html

and the last gdb version that can be compiled with gcc 4.9 is 7.12.1 only when
configured with --disable-build-with-cxx, it's time to obsolete/remove support
for Solaris < 10.

This patch does this, simplifying configure.nat along the way (only a single
sol2 configuration with variants for i386 and sparc).

Some configure checks for older Solaris versions can go, too, and the check
for libthread_db.so.1 removed:

* Since Solaris 10, dlopen has moved to libc and libdl.so is just a
  filter on ld.so.1, so no need to check.

* $RDYNAMIC is already handled above (and is a no-op with Solaris ld
  anyway).

Both proc-service.c and sol-thread.c lose support for (Solaris-only)
PROC_SERVICE_IS_OLD.

The attached revised patch has been tested on sparcv9-sun-solaris2.10,
sparcv9-sun-solaris2.11.4, amd64-pc-solaris2.10, amd64-pc-solaris2.11.4,
and x86_64-pc-linux-gnu.

I've also started an i386-pc-solaris2.9 build to check that it really
stops as expected.

PR gdb/22185
* configure.host <*-*-solaris2.[01], *-*-solaris2.[2-9]*>: Mark as
obsolete.
Use gdb_host sol2 for i[34567]86-*-solaris2*, x86_64-*-solaris2*.
Remove i386sol2 support.
* configure.nat <i386sol2>: Remove.
<sol2-64>: Fold into ...
<sol2>: ... this.
Move common settings to default section.
Add sol-thread.o.
* configure.tgt <i[34567]86-*-solaris2.1[0-9]*,
x86_64-*-solaris2.1[0-9]*>: Rename to ...
<i[34567]86-*-solaris2*, x86_64-*-solaris2*>: ... this.
<i[34567]86-*-solaris*>: Remove.
<sparc-*-solaris2.[0-6], sparc-*-solaris2.[0-6].*>: Remove.

* configure.ac: Remove wctype in libw check.
(_MSE_INT_H): Don't define on Solaris 7-9.
<solaris*>: Remove libthread_db.so.1 check.
* configure: Regenerate.
* config.in: Regenerate.

* proc-service.c: Remove PROC_SERVICE_IS_OLD handling.
(gdb_ps_prochandle_t, gdb_ps_read_buf_t, gdb_ps_write_buf_t)
(gdb_ps_size_t): Remove.
Use base types in users.
* sol-thread.c: Likewise, also for gdb_ps_addr_t.

* NEWS (Changes since GDB 8.0): Document Solaris 2.0-9 removal.

7 years agoFix gdb 8.1 Solaris/SPARC compilation (PR build/22206)
Rainer Orth [Tue, 26 Sep 2017 12:58:53 +0000 (14:58 +0200)]
Fix gdb 8.1 Solaris/SPARC compilation (PR build/22206)

When testing my Solaris < 10 removal patch on Solaris/SPARC, I found
that gdb mainline is currently broken there due to the recent SPARC M7
ADI patches:

/vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c:1876:0: error: "PSR_ICC" redefined [-Werror]
 #define PSR_ICC  0x00f00000
 ^
In file included from /usr/include/v7/sys/privregs.h:24:0,
                 from /usr/include/sys/regset.h:420,
                 from /usr/include/sys/ucontext.h:21,
                 from /usr/include/sys/signal.h:231,
                 from /usr/include/sys/procset.h:23,
                 from /usr/include/sys/wait.h:25,
                 from /usr/include/stdlib.h:21,
                 from build-gnulib/import/stdlib.h:36,
                 from /vol/src/gnu/gdb/gdb/local/gdb/common/common-defs.h:53,
                 from /vol/src/gnu/gdb/gdb/local/gdb/defs.h:28,
                 from /vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c:20:
/usr/include/v7/sys/psr.h:35:0: note: this is the location of the previous definition
 #define PSR_ICC  0x00F00000 /* integer condition codes */
 ^
/vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c:1878:0: error: "PSR_IMPL" redefined [-Werror]
 #define PSR_IMPL 0xf0000000
 ^
In file included from /usr/include/v7/sys/privregs.h:24:0,
                 from /usr/include/sys/regset.h:420,
                 from /usr/include/sys/ucontext.h:21,
                 from /usr/include/sys/signal.h:231,
                 from /usr/include/sys/procset.h:23,
                 from /usr/include/sys/wait.h:25,
                 from /usr/include/stdlib.h:21,
                 from build-gnulib/import/stdlib.h:36,
                 from /vol/src/gnu/gdb/gdb/local/gdb/common/common-defs.h:53,
                 from /vol/src/gnu/gdb/gdb/local/gdb/defs.h:28,
                 from /vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c:20:
/usr/include/v7/sys/psr.h:41:0: note: this is the location of the previous definition
 #define PSR_IMPL 0xF0000000 /* implementation */
 ^

Comparing Solaris 11.4 <v7/sys/psr.h> and sparc64-tdep.c, there are more
inconsistencies:

<v7/sys/psr.h>:

#define PSR_S 0x00000080 /* supervisor mode */
#define PSR_ICC 0x00F00000 /* integer condition codes */
#define PSR_VER 0x0F000000 /* mask version */
#define PSR_IMPL 0xF0000000 /* implementation */
#define PSR_RSV 0x000FC000 /* reserved */

sparc64-tdep.c:

#define PSR_S 0x00000080
#define PSR_ICC 0x00f00000
#define PSR_VERS 0x0f000000
#define PSR_IMPL 0xf0000000
#define PSR_V8PLUS 0xff000000
#define PSR_XCC 0x000f0000

Apart from the capitalization differences that trip g++, the names
differ (PSR_VER vs. PSR_VERS), PSR_XCC is included in Solaris' PSR_RSV,
and there's no PSR_V8PLUS on Solaris either.

/vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c: In function `int adi_tag_fd()':
/vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c:296:63: error: format `%d' expects argument of type `int', but argument 4 has type `pid_t {aka long int}' [-Werror=format=]
   snprintf (cl_name, sizeof(cl_name), "/proc/%d/adi/tags", pid);
                                                               ^
/vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c: In function `bool adi_is_addr_mapped(CORE_ADDR, std::size_t)':
/vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c:314:64: error: format `%d' expects argument of type `int', but argument 4 has type `pid_t {aka long int}' [-Werror=format=]
   snprintf (filename, sizeof filename, "/proc/%d/adi/maps", pid);
                                                                ^

You cannot always print a pid_t, which can be either int or long on
Solaris, as an int.

Obviously, the ADI patch which modifies code shared between all SPARC
targets, hasn't been tested on anything but Linux/SPARC.

The patch below includes the minimal fixes necessary to unbreak the
Solaris/SPARC build.

However, as detailed in the PR, there's more breakage here: apart from
not bothering to implement ADI support on Solaris, the code contains
several more changes to shared/common SPARC code that are simply wrong
on anything but Linux/SPARC.

The patch was tested on sparcv9-sun-solaris2.10 and
sparcv9-sun-solaris2.11.4 (build and gdb/gdb gdb/gdb smoke test only).

PR build/22206
* sparc64-tdep.c (adi_tag_fd): Print pid as long.
(adi_is_addr_mapped): Likewise.
(PSR_ICC): Don't redefine.
(PSR_IMPL): Likewise.

7 years agoPR22209, invalid memory read in find_abstract_instance_name
Alan Modra [Tue, 26 Sep 2017 12:17:24 +0000 (21:47 +0930)]
PR22209, invalid memory read in find_abstract_instance_name

This patch adds bounds checking for DW_FORM_ref_addr die refs, and
calculates them relative to the first .debug_info section.  See the
big comment for why calculating relative to the current .debug_info
section was wrong for relocatable object files.

PR 22209
* dwarf2.c (struct comp_unit): Delete sec_info_ptr field.
(find_abstract_instance_name): Calculate DW_FORM_ref_addr relative
to stash->info_ptr_memory, and check die_ref is within that memory.
Set info_ptr_end correctly when another CU is refd.  Check die_ref
for DW_FORM_ref4 etc. is within CU.

7 years agoFix address violations when parsing a corrupt DWARF linenumber table.
Nick Clifton [Tue, 26 Sep 2017 11:14:42 +0000 (12:14 +0100)]
Fix address violations when parsing a corrupt DWARF linenumber table.

PR 22154
* dwarf.c (get_line_filename_and_dirname): Add extra checks for
buffer overruns.

7 years agoLD/testsuite: Fix undefined symbol tests for MIPS and S+core targets
Maciej W. Rozycki [Tue, 26 Sep 2017 11:09:50 +0000 (12:09 +0100)]
LD/testsuite: Fix undefined symbol tests for MIPS and S+core targets

Fix commit 647d4de92e06 ("Test undefined symbols in shared libraries")
and remove "undefined symbols in shared lib (dyn reloc)" test failures
for MIPS and S+core targets.

This test assumes 3 dynamic relocation entries, however the respective
psABIs define an extra single dummy *_NONE relocation at the beginning
of the dynamic relocation table, which results in test output like the
following for MIPS:

Relocation section '.rel.dyn' at offset 0x33c contains 4 entries:
 Offset     Info    Type            Sym.Value  Sym. Name
00000000  00000000 R_MIPS_NONE
00010364  00000903 R_MIPS_REL32      00000000   undef_pfun
00010360  00000a03 R_MIPS_REL32      00000000   undef_data
00010368  00000b03 R_MIPS_REL32      00000000   undef_notype

and S+core:

Relocation section '.rel.dyn' at offset 0x274 contains 4 entries:
 Offset     Info    Type            Sym.Value  Sym. Name
00000000  00000000 R_SCORE_NONE
5ffe0464  00000e12 R_SCORE_REL32     00000000   undef_notype
5ffe045c  00000f12 R_SCORE_REL32     00000000   undef_data
5ffe0460  00001012 R_SCORE_REL32     00000000   undef_pfun

targets respectively, and also n64 MIPS targets pad relocation triplets
they use with extra *_NONE relocations, resulting in output like this:

Relocation section '.rel.dyn' at offset 0x4c0 contains 4 entries:
  Offset          Info           Type           Sym. Value    Sym. Name
000000000000  000000000000 R_MIPS_NONE
                    Type2: R_MIPS_NONE
                    Type3: R_MIPS_NONE
000000010508  000900001203 R_MIPS_REL32      0000000000000000 undef_pfun
                    Type2: R_MIPS_64
                    Type3: R_MIPS_NONE
000000010500  000a00001203 R_MIPS_REL32      0000000000000000 undef_data
                    Type2: R_MIPS_64
                    Type3: R_MIPS_NONE
000000010510  000b00001203 R_MIPS_REL32      0000000000000000 undef_notype
                    Type2: R_MIPS_64
                    Type3: R_MIPS_NONE

Expect the right number of *_NONE relocations then, and adjust the total
number of relocations expected accordingly.

ld/
* testsuite/ld-undefined/undefined.exp: Correct the dyn reloc
test for MIPS and S+core targets.

7 years agoAllow the macw and macl instructions to be used on CPUs that have emacs support.
Nick Clifton [Tue, 26 Sep 2017 09:33:32 +0000 (10:33 +0100)]
Allow the macw and macl instructions to be used on CPUs that have emacs support.

From PR 22123:

  The common opcodes of emac and mac seem to be only implemented for mac.

  To reproduce:

    echo "macw %d3l,%a0l" > /tmp/dummy.S
    m68k-unknown-elf-as -m5208  /tmp/dummy.S

  Outputs something like:
    /tmp/dummy.S: Assembler messages:
    /tmp/dummy.S:1: Error: operands mismatch -- statement `macw %d3l,%a0l' ignored

  This behavior occurs only if the CPU supports only emac but not explicitly mac (but emac is a superset of mac).

7 years agoAdd README file for creating binutils releases
Nick Clifton [Tue, 26 Sep 2017 09:07:23 +0000 (10:07 +0100)]
Add README file for creating binutils releases

7 years agoFix FAILs in compare-sections.exp
Thomas Preud'homme [Tue, 26 Sep 2017 08:57:18 +0000 (09:57 +0100)]
Fix FAILs in compare-sections.exp

compare-sections.exp has two cases that are not handled appropriately:
1) value read with msb set
2) error while patching that section

This patch adapts the "get value of read-only section" test to print
the value as an unsigned integer to fix 1) and test for the error
message to not set the written variable if read-only section cannot
be written to so as to solve 2).

2017-09-26  Thomas Preud'homme  <thomas.preudhomme@arm.com>
    Pedro Alves  <palves@redhat.com>

gdb/testsuite/
* gdb.base/compare-sections.exp (get value of read-only section): Read
as unsigned value.
(corrupt read-only section): Likewise and don't set written if patching
failed.

7 years agoPR21732, String-concatenated message can not be translated
Alan Modra [Tue, 26 Sep 2017 01:58:04 +0000 (11:28 +0930)]
PR21732, String-concatenated message can not be translated

Preprocessor tokens like DWARF_VMA_FMT and BFD_VMA_FMT are not
understood by gettext, and cause the translation string to be
truncated.  Even if it were not truncated, we wouldn't want a value
that changes depending on host or configure options to be put in a
translation string.

PR 21732
* dwarf.c (READ_ULEB): Don't use DWARF_VMA_FMT in translated string.
(READ_SLEB): Likewise.
* readelf.c (bfd_vmatoa): New function.
(get_data, get_dynamic_data): Use it for printing error messages.

7 years agoRemove the last cleanup from regcache.c
Tom Tromey [Sat, 23 Sep 2017 21:54:36 +0000 (15:54 -0600)]
Remove the last cleanup from regcache.c

This removes the last cleanup from regcache.c by changing one function
to use std::string.

gdb/ChangeLog
2017-09-25  Tom Tromey  <tom@tromey.com>

* regcache.c (regcache::dump): Use string_printf.

7 years agoRemove make_cleanup_regcache_invalidate
Tom Tromey [Sat, 23 Sep 2017 21:53:30 +0000 (15:53 -0600)]
Remove make_cleanup_regcache_invalidate

This removes make_cleanup_regcache_invalidate in favor of a simple
RAII class that handles register invalidation.

gdb/ChangeLog
2017-09-25  Tom Tromey  <tom@tromey.com>

* regcache.c (class regcache_invalidator): New.
(struct register_to_invalidate): Remove.
(make_cleanup_regcache_invalidate): Remove.
(regcache::raw_write): Use regcache_invalidator.

7 years agoRemove make_cleanup_regcache_xfree
Tom Tromey [Sat, 23 Sep 2017 21:34:30 +0000 (15:34 -0600)]
Remove make_cleanup_regcache_xfree

This removes make_cleanup_regcache_xfree in favor of using
std::unique_ptr as the return type of frame_save_as_regcache.

gdb/ChangeLog
2017-09-25  Tom Tromey  <tom@tromey.com>

* spu-tdep.c (spu2ppu_sniffer): Update.
* regcache.h (make_cleanup_regcache_xfree): Don't declare.
* regcache.c (do_regcache_xfree, make_cleanup_regcache_xfree):
Remove.
* ppc-linux-tdep.c (ppu2spu_sniffer): Update.
* mi/mi-main.c (mi_cmd_data_list_changed_registers): Update.
* frame.h (frame_save_as_regcache): Return std::unique_ptr.
* frame.c (frame_save_as_regcache): Return std::unique_ptr.
(frame_pop): Update.

7 years agoRemove regcache_xfree
Tom Tromey [Sat, 23 Sep 2017 20:41:07 +0000 (14:41 -0600)]
Remove regcache_xfree

This removes regcache_xfree in favor of plain "delete".

gdb/ChangeLog
2017-09-25  Tom Tromey  <tom@tromey.com>

* spu-tdep.c (spu2ppu_dealloc_cache): Use delete.
* regcache.h (regcache_xfree): Don't declare.
* regcache.c (regcache_xfree): Remove.
(do_regcache_xfree): Use delete.
* ppc-linux-tdep.c (ppu2spu_dealloc_cache): Use delete.
* linux-fork.c (free_fork): Use delete.
(fork_save_infrun_state): Likewise.
* jit.c (jit_dealloc_cache): Use delete.
* infrun.c (discard_infcall_suspend_state): Use delete.

7 years agoRemove regcache_xmalloc
Tom Tromey [Sat, 23 Sep 2017 20:39:56 +0000 (14:39 -0600)]
Remove regcache_xmalloc

This patch removes regcache_xmalloc in favor of plain "new".

gdb/ChangeLog
2017-09-25  Tom Tromey  <tom@tromey.com>

* regcache.h (regcache_xmalloc): Don't declare.
(regcache_raw_set_cached_value): Update comment.
* regcache.c (regcache_xmalloc): Remove.
* ppc-linux-tdep.c (ppu2spu_sniffer): Use new.
* jit.c (jit_frame_sniffer): Use new.
* frame.c (frame_save_as_regcache): Use new.

7 years agoPR22205, .debug_line file table NULL filename
Alan Modra [Tue, 26 Sep 2017 00:08:26 +0000 (09:38 +0930)]
PR22205, .debug_line file table NULL filename

The PR22200 fuzzer testcase found one way to put NULLs into .debug_line
file tables.  PR22205 finds another.  This patch gives up on trying to
prevent NULL files in the file table and instead just copes with them.
Arguably, this is better than giving up and showing no info from
.debug_line.  I've also fixed a case where the fairly recent DWARF5
support in handling broken DWARG could result in uninitialized memory
reads, and made a small tidy.

PR 22205
* dwarf2.c (concat_filename): Return "<unknown>" on NULL filename.
(read_formatted_entries): Init "fe".
(decode_line_info <DW_LNE_define_file>): Use line_info_add_file_name.

7 years agoPR22204, Lack of DW_LNE_end_sequence causes "infinite" loop
Alan Modra [Tue, 26 Sep 2017 00:02:18 +0000 (09:32 +0930)]
PR22204, Lack of DW_LNE_end_sequence causes "infinite" loop

PR 22204
* dwarf2.c (decode_line_info): Ensure line_ptr stays within
bounds in inner loop.

7 years agoAutomatic date update in version.in
GDB Administrator [Tue, 26 Sep 2017 00:00:21 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoFree memory returned from bfd_get_synthetic_symtab
H.J. Lu [Mon, 25 Sep 2017 21:07:01 +0000 (14:07 -0700)]
Free memory returned from bfd_get_synthetic_symtab

PR binutils/22203
* nm.c (display_rel_file): Free memory returned from
bfd_get_synthetic_symtab.

7 years agoS390: Document guarded-storage register support
Andreas Arnez [Mon, 25 Sep 2017 14:02:24 +0000 (16:02 +0200)]
S390: Document guarded-storage register support

This documents the newly added support for guarded-storage registers on
IBM z.

gdb/ChangeLog:

* NEWS: Advertise support for guarded-storage registers on IBM z.

gdb/doc/ChangeLog:

* gdb.texinfo (S/390 and System z Features): Document the new
features org.gnu.gdb.s390.gs and org.gnu.gdb.s390.gsbc.

7 years agoS390: Add guarded-storage register support to gdbserver
Andreas Arnez [Mon, 25 Sep 2017 14:02:23 +0000 (16:02 +0200)]
S390: Add guarded-storage register support to gdbserver

Enable gdbserver to deal with the new guarded-storage register sets.

gdb/gdbserver/ChangeLog:

* configure.srv (s390*-*-linux*): Add s390-gs-linux64.o and
s390x-gs-linux64.o to srv_regobj.  Add s390-gs-linux64.xml,
s390x-gs-linux64.xml, s390-gs.xml, and s390-gsbc.xml to
srv_xmlfiles.  Add s390-gs-linux64-ipa.o and
s390x-gs-linux64-ipa.o to ipa_obj.
* linux-s390-low.c (HWCAP_S390_GS): New define.
(s390_fill_gs, s390_store_gs, s390_fill_gsbc, s390_store_gsbc):
New functions.
(s390_regsets): Add regsets for NT_S390_GS_CB and NT_S390_GS_BC.
(s390_arch_setup): Check for guarded-storage support and choose
appropriate tdesc.
(initialize_low_arch): Invoke init_registers_s390_gs_linux64 and
init_registers_s390x_gs_linux64.
* linux-s390-tdesc.h (enum s390_linux_tdesc) <S390_TDESC_GS>: New
enum value.
(init_registers_s390x_gs_linux64, tdesc_s390x_gs_linux64)
(init_registers_s390_gs_linux64, tdesc_s390_gs_linux64): Declare.

7 years agoS390: Add guarded-storage register support to GDB
Andreas Arnez [Mon, 25 Sep 2017 14:02:23 +0000 (16:02 +0200)]
S390: Add guarded-storage register support to GDB

Recognize targets with the new guarded-storage feature and then present
the guarded-storage registers and the Linux-specific guarded-storage
broadcast control block appropriately.

gdb/ChangeLog:

* s390-linux-nat.c (have_regset_gs): New static variable.
(s390_linux_fetch_inferior_registers): Handle guarded-storage
control block and guarded-storage broadcast control regsets.
(s390_read_description): Detect whether the target has
guarded-storage support, return appropriate tdesc.
* s390-linux-tdep.c (features/s390-gs-linux64.c): New include.
(features/s390x-gs-linux64.c): Likewise.
(struct gdbarch_tdep) <have_gs>: New field.
(s390_regmap_gs, s390_regmap_gsbc, s390_gs_regset)
(s390_gsbc_regset): New variables.
(s390_iterate_over_regset_sections): Iterate over s390_gs_regset
and s390_gsbc_regset, if applicable.
(s390_core_read_description): Check whether core file was from a
target with guarded-storage support; include appropriate regsets.
(s390_gdbarch_init): Add registers for guarded-storage support.
(_initialize_s390_tdep): Initialize new target descriptions that
include registers for guarded-storage support.
* s390-linux-tdep.h (HWCAP_S390_GS, S390_GSD_REGNUM)
(S390_GSSM_REGNUM, S390_GSEPLA_REGNUM)
(S390_BC_GSD_REGNUM, S390_BC_GSSM_REGNUM): New defines.
(S390_NUM_REGS): Adjust macro definition.
(s390_gs_regset, s390_gsbc_regset, tdesc_s390_gs_linux64)
(tdesc_s390x_gs_linux64): New declarations.

7 years agoS390: Add guarded-storage register definitions and tdescs
Andreas Arnez [Mon, 25 Sep 2017 14:02:23 +0000 (16:02 +0200)]
S390: Add guarded-storage register definitions and tdescs

Newer Linux kernel versions offer two new register sets in support of the
z/Architecture's guarded storage facility.  This patch adds XML
descriptions and the respective autogenerated .c and .dat files for
s390/s390x targets with this feature.

gdb/ChangeLog:

* features/s390-gs-linux64.xml: New file.
* features/s390-gs.xml: New file.
* features/s390-gsbc.xml: New file.
* features/s390x-gs-linux64.xml: New file.
* features/Makefile (WHICH): Add s390-gs-linux64 and
s390x-gs-linux64.
(s390-gs-linux64-expedite, s390x-gs-linux64-expedite): New macros.
(XMLTOC): Add s390-gs-linux64.xml and s390x-linux64.xml.
* features/s390-gs-linux64.c: New generated file.
* features/s390x-gs-linux64.c: New file.
* regformats/s390-gs-linux64.dat: New file.
* regformats/s390x-gs-linux64.dat: New file.

7 years agoPR22202, buffer overflow in parse_die
Alan Modra [Mon, 25 Sep 2017 10:50:38 +0000 (20:20 +0930)]
PR22202, buffer overflow in parse_die

There was a complete lack of sanity checking in dwarf1.c

PR 22202
* dwarf1.c (parse_die): Sanity check pointer against section limit
before dereferencing.
(parse_line_table): Likewise.

7 years agoPR22201, DW_AT_name with out of bounds reference
Alan Modra [Mon, 25 Sep 2017 10:16:34 +0000 (19:46 +0930)]
PR22201, DW_AT_name with out of bounds reference

DW_AT_name ought to always have a string value.

PR 22201
* dwarf2.c (scan_unit_for_symbols): Ignore DW_AT_name unless it
has string form.
(parse_comp_unit): Likewise.

7 years agoPR22200, DWARF5 .debug_line sanity check
Alan Modra [Mon, 25 Sep 2017 09:33:46 +0000 (19:03 +0930)]
PR22200, DWARF5 .debug_line sanity check

The format_count entry can't be zero unless the count is also zero.

PR 22200
* dwarf2.c (read_formatted_entries): Error on format_count zero.

7 years agoInitialize 'imm' on opcodes/aarch64-opc.c:expand_fp_imm (and fix breakage on mingw)
Sergio Durigan Junior [Thu, 21 Sep 2017 15:46:48 +0000 (11:46 -0400)]
Initialize 'imm' on opcodes/aarch64-opc.c:expand_fp_imm (and fix breakage on mingw)

Hi,

While compiling GDB using a mingw compiler from Fedora 26:

  ../gdb/configure --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 \
    --disable-binutils --disable-ld --disable-gold --disable-gas --disable-sim \
    --disable-gprof  --enable-targets=all

I stumbled upon a simple occurrence of -Werror=maybe-uninitialized:

  ../../gdb/opcodes/aarch64-opc.c: In function 'expand_fp_imm':
  ../../gdb/opcodes/aarch64-opc.c:2880:10: error: 'imm' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     return imm;
    ^~~

It is the compiler's fault, because this function always assigns to
'imm' if the necessary conditions are met, and it calls "assert (0)"
otherwise, but I thought it'd be clearer to have 'imm' explicitly set
to zero anyway.

opcodes/ChangeLog:
2017-09-21  Sergio Durigan Junior  <sergiodj@redhat.com>

* aarch64-opc.c (expand_fp_imm): Initialize 'imm'.

7 years agoAutomatic date update in version.in
GDB Administrator [Mon, 25 Sep 2017 00:00:24 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoPR22197, buffer overflow in bfd_get_debug_link_info_1
Alan Modra [Sun, 24 Sep 2017 12:06:18 +0000 (21:36 +0930)]
PR22197, buffer overflow in bfd_get_debug_link_info_1

PR 22197
* opncls.c (bfd_get_debug_link_info_1): Properly check that crc is
within section bounds.

7 years agoPR22191, memory leak in dwarf2.c
Alan Modra [Sun, 24 Sep 2017 07:40:14 +0000 (17:10 +0930)]
PR22191, memory leak in dwarf2.c

table->sequences is a linked list before it is replaced by a bfd_alloc
array in sort_line_sequences.

PR 22191
* dwarf2.c (decode_line_info): Properly free line sequences on error.

7 years agoPR22187, infinite loop in find_abstract_instance_name
Alan Modra [Sun, 24 Sep 2017 05:07:16 +0000 (14:37 +0930)]
PR22187, infinite loop in find_abstract_instance_name

This patch prevents the simple case of infinite recursion in
find_abstract_instance_name by ensuring that the attributes being
processed are not the same as the previous call.

The patch also does a little cleanup, and leaves in place some changes
to the nested_funcs array that I made when I wrongly thought looping
might occur in scan_unit_for_symbols.

PR 22187
* dwarf2.c (find_abstract_instance_name): Add orig_info_ptr and
pname param.  Return status.  Make name const.  Don't abort,
return an error.  Formatting.  Exit if current info_ptr matches
orig_info_ptr.  Update callers.
(scan_unit_for_symbols): Start at nesting_level of zero.  Make
nested_funcs an array of structs for extensibility.  Formatting.

7 years agoPR22186, divide-by-zero in decode_line_info
Alan Modra [Sun, 24 Sep 2017 05:06:48 +0000 (14:36 +0930)]
PR22186, divide-by-zero in decode_line_info

PR 22186
* dwarf2.c (decode_line_info): Fail on lh.line_range of zero
rather than dividing by zero.

7 years agoPR22169, heap-based buffer overflow in read_1_byte
Alan Modra [Sun, 24 Sep 2017 05:06:16 +0000 (14:36 +0930)]
PR22169, heap-based buffer overflow in read_1_byte

The .debug_line header length field doesn't include the length field
itself, ie. it's the size of the rest of .debug_line.

PR 22169
* dwarf2.c (decode_line_info): Correct .debug_line unit_length check.

7 years agoPR22167, NULL pointer dereference in scan_unit_for_symbols
Alan Modra [Sun, 24 Sep 2017 05:05:33 +0000 (14:35 +0930)]
PR22167, NULL pointer dereference in scan_unit_for_symbols

PR 22167
* dwarf2.c (scan_unit_for_symbols): Check u.blk->data is non-NULL.

7 years agoPR22166, SHT_GNU_verneed memory allocation
Alan Modra [Sun, 24 Sep 2017 05:04:57 +0000 (14:34 +0930)]
PR22166, SHT_GNU_verneed memory allocation

The sanity check covers the previous minimim size, plus that the size
is at least enough for sh_info verneed entries.

Also, since we write all verneed fields or exit with an error, there
isn't any need to zero the memory allocated for verneed entries.

PR 22166
* elf.c (_bfd_elf_slurp_version_tables): Test sh_info on
SHT_GNU_verneed section for sanity.  Don't zalloc memory for
verref.

7 years agoAutomatic date update in version.in
GDB Administrator [Sun, 24 Sep 2017 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoRemoved unused declaration
Tom Tromey [Sat, 23 Sep 2017 20:00:21 +0000 (14:00 -0600)]
Removed unused declaration

An earlier patch of mine removed make_cleanup_override_quit_handler,
but neglected to remove the declaration.  This patch removes it.
Tested by rebuilding.  I'm committing this as obvious.

ChangeLog
2017-09-23  Tom Tromey  <tom@tromey.com>

* defs.h (make_cleanup_override_quit_handler): Don't declare.

7 years agoAutomatic date update in version.in
GDB Administrator [Sat, 23 Sep 2017 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoChange type of scoped_input_handler::m_quit_handler
Tom Tromey [Thu, 21 Sep 2017 15:54:25 +0000 (09:54 -0600)]
Change type of scoped_input_handler::m_quit_handler

Simon pointed out that scoped_input_handler::m_quit_handler must have
the correct scoped_restore_tmpl type, to avoid binding to a temporary.
This patch fixes the problem.

gdb/ChangeLog
2017-09-22  Tom Tromey  <tom@tromey.com>

* utils.c (class scoped_input_handler) <m_quit_handler>: Change
type to scoped_restore_tmpl.
<scoped_input_handler>: Initialize m_quit_handler directly.

Reviewed-By: Pedro Alves <palves@redhat.com>
7 years agox86: Guard against corrupted PLT
H.J. Lu [Fri, 22 Sep 2017 21:15:40 +0000 (14:15 -0700)]
x86: Guard against corrupted PLT

There should be only one entry in PLT for a given symbol.  Set howto to
NULL after processing a PLT entry to guard against corrupted PLT so that
the duplicated PLT entries are skipped.

PR binutils/22170
* elfxx-x86.c (_bfd_x86_elf_get_synthetic_symtab): Guard against
corrupted PLT.

7 years agoUpdate ChangeLog entry for PR 22163
H.J. Lu [Fri, 22 Sep 2017 21:09:56 +0000 (14:09 -0700)]
Update ChangeLog entry for PR 22163

7 years agoLVU: dump loclists with locviews
Alexandre Oliva [Fri, 22 Sep 2017 20:05:51 +0000 (17:05 -0300)]
LVU: dump loclists with locviews

When dumping location lists, also dump locview lists that may be
interspersed with them, and bring view pairs next to the corresponding
location list entries.

This patch supports DW_AT_GNU_locviews as a separate attribute for
DWARF4- loc_lists and split (dwo) loclists, as well as DWARF5
loclists.

It also supports, in DWARF5 loclists, the proposed
DW_LLE_GNU_view_pair loclist entry type proposed for DWARF6.

The tests use 32-bit DWARF, even on 64-bit targets, resolving offsets
to constants so as to reduce the risk that relocations be created for
them, or that the offsets be rejected as nonconstants.

The patch also adds an xfail to an unrelated test, namely dw5, so that
no unexpected fails remain on nds32*-elf, one of the tested targets.

Reviewed-by: Alan Modra <amodra@gmail.com>
for  include/ChangeLog

* dwarf2.def (DW_AT_GNU_locviews): New.
* dwarf2.h (enum dwarf_location_list_entry_type): Add
DW_LLE_GNU_view_pair.
(DW_LLE_view_pair): Define.

for  binutils/ChangeLog

* dwarf.h (debug_info): Add loc_views and num_loc_views.
* dwarf.c (vm1): New constant.
(print_dwarf_view): New function.
(read_and_display_attr_value): Support DW_AT_GNU_locviews.
(process_debug_info): Keep num_loc_offsets and num_loc_views
in sync.
(display_view_pair_list): New function.
(display_loc_list_dwo): Take vstart_ptr; update it.  Dump
location view pairs before the range they apply to, when a
viewlist augments the loc list.
(display_loc_list): Likewise.  Check view numbers in range
tests.
(display_loclists_list): Likewise.  Handle view pair entries,
and warn on trailing ones.
(loc_views): New variable.
(loc_offsets_compar): Compare loc_views if loc_offsets are the
same.
(display_debug_loc): Check and sort loc_views too.  Accept
loc_view as expected_start.  Skip if lists and views are the
same.  Dump locview list separately in order, and pass the
locview list base to each list dump function.  Warn and skip
overlap and hole checking if we find loclists and locviews to
not be adjacent.
* testsuite/binutils-all/locview-1.s: New.
* testsuite/binutils-all/readelf.locview-1: New.
* testsuite/binutils-all/locview-2.s: New.
* testsuite/binutils-all/readelf.locview-2: New.
* testsuite/binutils-all/readelf.exp: Run new tests.  Fix
option spelling in pr18374 fail message.  XFAIL dw5 test on
nds32*-elf.

7 years agoGet rid of "gdb_dirbuf" and use "getcwd (NULL, 0)"
Sergio Durigan Junior [Mon, 11 Sep 2017 04:54:33 +0000 (00:54 -0400)]
Get rid of "gdb_dirbuf" and use "getcwd (NULL, 0)"

Currently we have "current_directory" and "gdb_dirbuf" globals, which
means that we basically have two possible places to consult when we
want to know GDB's current working directory.

This is not ideal and can lead to confusion.  Moreover, the way we're
using "gdb_difbuf" along with "getcwd" is problematic because we
declare the buffer with "1024" elements hardcoded, which does not take
into account longer pathnames that are possible in many filesystems.
Using "PATH_MAX" would also not be a solution because of portability
problems.  Therefore, the best solution is to rely on the fact that
"getcwd (NULL, 0)" will "do the right thing" and return a
heap-allocated string containing the full path.  With the new "getcwd"
module from gnulib, it is now possible to do that without worrying
about breaking some host.

With this patch "current_directory" is now the only place to check for
GDB's cwd.

Reviewed-by: Pedro Alves <palves@redhat.com>
gdb/ChangeLog:
2017-09-22  Sergio Durigan Junior  <sergiodj@redhat.com>

* cli/cli-cmds.c (pwd_command): Use "getcwd (NULL, 0)".
(cd_command): Likewise.  Free "current_directory" before
assigning to it.
* main.c (captured_main_1): Use "getcwd (NULL, 0)".
* mi/mi-cmd-env.c (mi_cmd_env_pwd): Likewise.
* top.c (gdb_dirbuf): Remove global declaration.
* top.h (gdb_dirbuf): Likewise.

7 years agoImport "glob" and "getcwd" modules from gnulib
Sergio Durigan Junior [Sat, 9 Sep 2017 00:09:12 +0000 (20:09 -0400)]
Import "glob" and "getcwd" modules from gnulib

These two modules are necessary because of the rework that will be
done in the "change directory" logic on GDB/gdbserver in the next
commits.

First, we will get rid of the "gdb_dirbuf" global variable and instead
rely on the fact that "getcwd (NULL, 0)", which is a GNU extension,
returns a heap-allocated string with the necessary bytes to hold the
full path.  This is a good practice not only because globals are not
ideal but also because there is no good way to know beforehand the
size of the full pathname allowed in the filesystem ("PATH_MAX" is not
portable and does not reflect all the possible filesystems out there).

We will also have a way to "cd" to a directory also on gdbserver, but
in order to do that uniformly, there must be a way to do tilde
expansion on directories provided by the user.  Currently, GDB uses
"tilde_expand" from readline to do that, but gdbserver doesn't link
against readline and therefore cannot use this function.  The solution
is to use "glob" instead, which can perform tilde expansion as a GNU
extension.  Therefore, we need gnulib's version of "glob".

A special note is necessary for gdb/ser-tcp.c.  It defines "close" as
"closesocket" on Win32 targets.  If we leave the code as is, this
would conflict with gnulib's definition of "close".  Therefore, in
order to keep the same code path from before this import, I decided to
"#undef close" first, and then let the original (re)definition of it
take place.

gdb/ChangeLog:
2017-09-22  Sergio Durigan Junior  <sergiodj@redhat.com>

* gnulib/aclocal.m4: Regenerate.
* gnulib/config.in: Regenerate.
* gnulib/configure: Regenerate.
* gnulib/import/Makefile.am: Regenerate.
* gnulib/import/Makefile.in: Regenerate.
* gnulib/import/assure.h: New file.
* gnulib/import/at-func.c: Likewise
* gnulib/import/chdir-long.c: New file.
* gnulib/import/chdir-long.h: New file.
* gnulib/import/cloexec.c: New file.
* gnulib/import/cloexec.h: New file.
* gnulib/import/close.c: New file.
* gnulib/import/closedir.c: New file.
* gnulib/import/dirent-private.h: New file.
* gnulib/import/dup-safer.c: New file.
* gnulib/import/dup.c: New file.
* gnulib/import/dup2.c: New file.
* gnulib/import/error.c: New file.
* gnulib/import/error.h: New file.
* gnulib/import/exitfail.c: New file.
* gnulib/import/exitfail.h: New file.
* gnulib/import/fchdir.c: New file.
* gnulib/import/fcntl.c: New file.
* gnulib/import/fcntl.in.h: New file.
* gnulib/import/fd-hook.c: New file.
* gnulib/import/fd-hook.h: New file.
* gnulib/import/fd-safer.c: New file.
* gnulib/import/fdopendir.c: New file.
* gnulib/import/filename.h: New file.
* gnulib/import/filenamecat-lgpl.c: New file.
* gnulib/import/filenamecat.h: New file.
* gnulib/import/fstat.c: New file.
* gnulib/import/fstatat.c: New file.
* gnulib/import/getcwd-lgpl.c: New file.
* gnulib/import/getcwd.c: New file.
* gnulib/import/getdtablesize.c: New file.
* gnulib/import/getlogin_r.c: New file.
* gnulib/import/getprogname.c: New file.
* gnulib/import/getprogname.h: New file.
* gnulib/import/gettext.h: New file.
* gnulib/import/glob-libc.h: New file.
* gnulib/import/glob.c: New file.
* gnulib/import/glob.in.h: New file.
* gnulib/import/intprops.h: New file.
* gnulib/import/m4/chdir-long.m4: New file.
* gnulib/import/m4/close.m4: New file.
* gnulib/import/m4/closedir.m4: New file.
* gnulib/import/m4/d-ino.m4: New file.
* gnulib/import/m4/d-type.m4: New file.
* gnulib/import/m4/dup.m4: New file.
* gnulib/import/m4/dup2.m4: New file.
* gnulib/import/m4/error.m4: New file.
* gnulib/import/m4/fchdir.m4: New file.
* gnulib/import/m4/fcntl.m4: New file.
* gnulib/import/m4/fcntl_h.m4: New file.
* gnulib/import/m4/fdopendir.m4: New file.
* gnulib/import/m4/filenamecat.m4: New file.
* gnulib/import/m4/fstat.m4: New file.
* gnulib/import/m4/fstatat.m4: New file.
* gnulib/import/m4/getcwd-abort-bug.m4: New file.
* gnulib/import/m4/getcwd-path-max.m4: New file.
* gnulib/import/m4/getcwd.m4: New file.
* gnulib/import/m4/getdtablesize.m4: New file.
* gnulib/import/m4/getlogin_r.m4: New file.
* gnulib/import/m4/getprogname.m4: New file.
* gnulib/import/m4/glob.m4: New file.
* gnulib/import/m4/gnulib-cache.m4: Regenerate.
* gnulib/import/m4/gnulib-comp.m4: Regenerate.
* gnulib/import/m4/mempcpy.m4: New file.
* gnulib/import/m4/memrchr.m4: New file.
* gnulib/import/m4/mode_t.m4: New file.
* gnulib/import/m4/msvc-inval.m4: New file.
* gnulib/import/m4/msvc-nothrow.m4: New file.
* gnulib/import/m4/open.m4: New file.
* gnulib/import/m4/openat.m4: New file.
* gnulib/import/m4/opendir.m4: New file.
* gnulib/import/m4/readdir.m4: New file.
* gnulib/import/m4/realloc.m4: New file.
* gnulib/import/m4/rewinddir.m4: New file.
* gnulib/import/m4/save-cwd.m4: New file.
* gnulib/import/m4/strdup.m4: New file.
* gnulib/import/m4/strerror.m4: New file.
* gnulib/import/m4/unistd-safer.m4: New file.
* gnulib/import/mempcpy.c: New file.
* gnulib/import/memrchr.c: New file.
* gnulib/import/msvc-inval.c: New file.
* gnulib/import/msvc-inval.h: New file.
* gnulib/import/msvc-nothrow.c: New file.
* gnulib/import/msvc-nothrow.h: New file.
* gnulib/import/open.c: New file.
* gnulib/import/openat-die.c: New file.
* gnulib/import/openat-priv.h: New file.
* gnulib/import/openat-proc.c: New file.
* gnulib/import/openat.c: New file.
* gnulib/import/openat.h: New file.
* gnulib/import/opendir.c: New file.
* gnulib/import/pipe-safer.c: New file.
* gnulib/import/readdir.c: New file.
* gnulib/import/realloc.c: New file.
* gnulib/import/rewinddir.c: New file.
* gnulib/import/save-cwd.c: New file.
* gnulib/import/save-cwd.h: New file.
* gnulib/import/strdup.c: New file.
* gnulib/import/strerror-override.c: New file.
* gnulib/import/strerror-override.h: New file.
* gnulib/import/strerror.c: New file.
* gnulib/import/unistd--.h: New file.
* gnulib/import/unistd-safer.h: New file.
* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add
"getcwd" and "glob".
* ser-tcp.c: Undefine "close" before redefining it.

7 years ago[GOLD] Set non-exec stack for aarch64
Jim Wilson [Fri, 22 Sep 2017 14:58:28 +0000 (07:58 -0700)]
[GOLD] Set non-exec stack for aarch64

GNU-stack notes added in 2004, aarch64 port added in 2012, so no old object
files with missing GNU-stack notes that we need to worry about.

gold/
* aarch64.cc (Target_aarch64::aarch64_info): Set
is_default_stack_executable to false.

7 years agogdbserver x86 on win32: call init_target_desc
Simon Marchi [Fri, 22 Sep 2017 14:51:55 +0000 (16:51 +0200)]
gdbserver x86 on win32: call init_target_desc

When trying to run gdbserver compiled for x86 win32 under wine, I get:

  $ wine ./gdbserver/gdbserver.exe --once :1234 ./test
  /home/emaisin/src/binutils-gdb/gdb/gdbserver/regcache.c:177: A problem internal to GDBserver has been detected.
  regcache* new_register_cache(const target_desc*): Assertion `tdesc->registers_size != 0' failed.

It seems like on that platform, init_target_desc is never called, so
registers_size is never computed.

My first thought was to call init_target_desc somewhere in win32-low.c,
but it turns out that when using win32 on arm, the target description is
already initialized by the generated code.  My second thought was to
call it in {i386,amd64}_create_target_description, but those functions
are shared with GDB, and init_target_desc is gdbserver-specific.  So I
ended up with the simplest fix, calling it in i386_arch_setup.

Now I hit some other problem:

  $ wine ./gdbserver/gdbserver.exe --once :1234 ./test
  Killing process(es): 39
  No program to debug
  Exiting

but still, I think fixing the tdesc issue this is a step forward.

gdb/gdbserver/ChangeLog:

* win32-i386-low.c (i386_arch_setup): Call init_target_desc.

7 years agox86: Return -1 if bfd_canonicalize_dynamic_reloc returns 0
H.J. Lu [Fri, 22 Sep 2017 14:25:16 +0000 (07:25 -0700)]
x86: Return -1 if bfd_canonicalize_dynamic_reloc returns 0

Stop if bfd_canonicalize_dynamic_reloc returns 0.

PR ld/22163
* elfxx-x86.c (_bfd_x86_elf_get_synthetic_symtab): Also return
-1 if bfd_canonicalize_dynamic_reloc returns 0.

7 years agoAdd a test for PR ld/22150
H.J. Lu [Fri, 22 Sep 2017 13:58:48 +0000 (06:58 -0700)]
Add a test for PR ld/22150

PR ld/22150
* testsuite/ld-elf/pr22150.vd: New file.
* testsuite/ld-elf/pr22150.ver: Likewise.
* testsuite/ld-elf/pr22150a.s: Likewise.
* testsuite/ld-elf/pr22150b.s: Likewise.
* testsuite/ld-elf/shared.exp: Run PR ld/22150 tests.

7 years agobfd/version.h: Add rationale for BFD_VERSION_DATE
Pedro Alves [Fri, 22 Sep 2017 13:57:52 +0000 (14:57 +0100)]
bfd/version.h: Add rationale for BFD_VERSION_DATE

bfd/ChangeLog:
2017-09-22  Pedro Alves  <palves@redhat.com>
    Alan Modra  <amodra@gmail.com>

* version.h: Add comment.

7 years agoFix sometimes-uninitialized warning in gdbscm_value_address
Simon Marchi [Thu, 21 Sep 2017 14:37:40 +0000 (16:37 +0200)]
Fix sometimes-uninitialized warning in gdbscm_value_address

I am getting this warning with clang:

/home/emaisin/src/binutils-gdb/gdb/guile/scm-value.c:439:11: error: variable 'address' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
      if (res_val != NULL)
          ^~~~~~~~~~~~~~~
/home/emaisin/src/binutils-gdb/gdb/guile/scm-value.c:444:32: note: uninitialized use occurs here
      if (gdbscm_is_exception (address))
                               ^~~~~~~
/home/emaisin/src/binutils-gdb/gdb/guile/scm-value.c:439:7: note: remove the 'if' if its condition is always true
      if (res_val != NULL)
      ^~~~~~~~~~~~~~~~~~~~
/home/emaisin/src/binutils-gdb/gdb/guile/scm-value.c:427:18: note: initialize the variable 'address' to silence this warning
      SCM address;
                 ^
                  = nullptr

We can get rid of it with a small refactoring.  I think it's a bit
cleaner/safer to initialize address with a pessimistic value and assign
it on success.  Then there's no chance of using it uninitialized.  If I
understand correctly, the NULL check on res_val was to check whether
value_addr threw, and that if value_addr returns without throwing, the
result will never be NULL.  If that's true, we can skip the res_val
variable.

Tested by running gdb.guile/*.exp locally.

gdb/ChangeLog:

* guile/scm-value.c (gdbscm_value_address): Initialize address,
get rid of res_val.

7 years agoFix gdb 8.1 Solaris compilation
Rainer Orth [Fri, 22 Sep 2017 08:42:45 +0000 (10:42 +0200)]
Fix gdb 8.1 Solaris compilation

I just tried to compile gdb trunk on Solaris 11.4 (formerly 12), and
failed for a couple of reasons:

*

In file included from /usr/include/python2.7/Python.h:128:0,
                 from /vol/src/gnu/gdb/gdb/dist/gdb/python/python-internal.h:94,
                 from /vol/src/gnu/gdb/gdb/dist/gdb/python/py-instruction.h:23,
                 from /vol/src/gnu/gdb/gdb/dist/gdb/python/py-instruction.c:21:
/usr/include/python2.7/ceval.h:67:0: error: ignoring #pragma no_inline  [-Werror=unknown-pragmas]
 #pragma no_inline(PyEval_EvalFrameEx)
 ^

  New in Solaris 11.4: <python2.7/ceval.h> uses a Studio-only #pragma.
  I've disabled the warning in warnings.m4.

*

/vol/src/gnu/gdb/gdb/dist/gdb/ser-pipe.c: In function â€˜int pipe_open(serial*, const char*)’:
/vol/src/gnu/gdb/gdb/dist/gdb/ser-pipe.c:77:9: error: â€˜pid_t vfork()’ is deprecated (declared at /usr/include/unistd.h:659) [-Werror=deprecated-declarations]
   pid = vfork ();
         ^
/vol/src/gnu/gdb/gdb/dist/gdb/ser-pipe.c:77:16: error: â€˜pid_t vfork()’ is deprecated (declared at /usr/include/unistd.h:659) [-Werror=deprecated-declarations]
   pid = vfork ();
                ^

  Since Solaris 11, vfork () is marked deprecated in <unistd.h>.

  cf. vfork(2):

       The  vfork()  and vforkx() functions are deprecated. Their sole legiti-
       mate use as a prelude to an immediate call to a function from the  exec
       family can be achieved safely by posix_spawn(3C) or posix_spawnp(3C).

  Again, I've disabled the warning.

*

/vol/src/gnu/gdb/gdb/dist/gdb/cli/cli-cmds.c: In function â€˜void shell_escape(const char*, int)’:
/vol/src/gnu/gdb/gdb/dist/gdb/cli/cli-cmds.c:750:14: error: â€˜pid_t vfork()’ is deprecated (declared at /usr/include/unistd.h:659) [-Werror=deprecated-declarations]
   if ((pid = vfork ()) == 0)
              ^
/vol/src/gnu/gdb/gdb/dist/gdb/cli/cli-cmds.c:750:21: error: â€˜pid_t vfork()’ is deprecated (declared at /usr/include/unistd.h:659) [-Werror=deprecated-declarations]
   if ((pid = vfork ()) == 0)
                     ^

  Same problem.

*

/vol/src/gnu/gdb/gdb/dist/gdb/procfs.c: In function â€˜void procfs_init_inferior(target_ops*, int)’:
/vol/src/gnu/gdb/gdb/dist/gdb/procfs.c:4380:30: error: â€˜START_INFERIOR_TRAPS_EXPECTED’ was not declared in this scope
   gdb_startup_inferior (pid, START_INFERIOR_TRAPS_EXPECTED);
                              ^

  defined in nat/fork-inferior.h, need to include that header

/vol/src/gnu/gdb/gdb/dist/gdb/procfs.c: In function â€˜void procfs_create_inferior(target_ops*, const char*, const string&, char**, int)’:
/vol/src/gnu/gdb/gdb/dist/gdb/procfs.c:4605:38: error: â€˜fork_inferior’ was not declared in this scope
          NULL, NULL, shell_file, NULL);
                                      ^

  likewise

/vol/src/gnu/gdb/gdb/dist/gdb/procfs.c: In function â€˜void procfs_info_proc(target_ops*, const char*, info_proc_what)’:
/vol/src/gnu/gdb/gdb/dist/gdb/procfs.c:5124:20: error: â€˜argv’ was not declared in this scope
   for (char *arg : argv)
                    ^

  Typo, should be built_argv instead!

*

Undefined                       first referenced
 symbol                             in file
fork_inferior(char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char**, void (*)(), void (*)(int), void (*)(), char const*, void (*)(char const*, char* const*, char* const*)) procfs.o
startup_inferior(int, int, target_waitstatus*, ptid_t*) fork-child.o
ld: fatal: symbol referencing errors
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:2249: gdb] Error 1

  Need to add fork-inferior.o to NATDEPFILES.

With the changes below, I can build gdb on sparcv9-sun-solaris2.11 and
amd64-pc-solaris2.11 and a simple smoke test (gdb/gdb gdb/gdb) works.

7 years ago[GOLD] clone assert breakage
Alan Modra [Fri, 22 Sep 2017 05:41:12 +0000 (15:11 +0930)]
[GOLD] clone assert breakage

* resolve.cc (clone): Fix got_offset_list test.

7 years ago[GOLD] Set non-exec stack for ppc64
Alan Modra [Fri, 22 Sep 2017 01:34:41 +0000 (11:04 +0930)]
[GOLD] Set non-exec stack for ppc64

gcc doesn't emit stack notes for ELFv1, since ELFv1 never needs an
executable stack.  Note that ELFv1 is usually big-endian and ELFv2
little-endian, but the ABI is really orthogonal to endiannes.

* powerpc.cc (Target_powerpc<64,*>::powerpc_info): Set
is_default_stack_executable false.

7 years agoreadelf tests
Alan Modra [Thu, 21 Sep 2017 22:57:01 +0000 (08:27 +0930)]
readelf tests

We have multiple tests that report failure to assemble without saying
exactly what test is failing.

* testsuite/binutils-all/readelf.exp: Don't perror and exit on
bintest.s assembly failure.  Report tests unresolved instead.
Likewise for version note test, pr18374, decompress, and dw5
tests.
(readelf_test): Set testname to include both option and binary
file name.  Use for pass/fail.

7 years agoAutomatic date update in version.in
GDB Administrator [Fri, 22 Sep 2017 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoreadelf: Handle E_MIPS_MACH_5900
Maciej W. Rozycki [Thu, 21 Sep 2017 23:54:19 +0000 (00:54 +0100)]
readelf: Handle E_MIPS_MACH_5900

Fix commit e407c74b5b60 ("Support for MIPS R5900 (Sony Playstation 2)"),
<https://sourceware.org/ml/binutils/2012-12/msg00240.html>, and add the
handling of E_MIPS_MACH_5900, correctly showing `5900' among `Flags:' in
the output of `-h' rather than `unknown CPU'.

binutils/
* readelf.c (get_machine_flags) <E_MIPS_MACH_5900>: New case.

gas/
* testsuite/gas/mips/elf_mach_5900.d: New test.
* testsuite/gas/mips/mips.exp: Run it.

7 years agoPR gas/21762: MIPS: Fix .stabs directive marking labels as MIPS16
James Cowgill [Thu, 21 Sep 2017 23:54:19 +0000 (00:54 +0100)]
PR gas/21762: MIPS: Fix .stabs directive marking labels as MIPS16

If a .stabs directive was used before another .set directive in a MIPS
source file, s_mips_stab would call mips_mark_labels without having
initialized the mips_opts structure yet.  Fix this by calling
file_mips_check_options which will initialize mips_opts if necessary.

gas/
PR gas/21762
* config/tc-mips.c (s_mips_stab): Insert call to
file_mips_check_options.
* testsuite/gas/mips/micromips@stabs-symbol-type.d: New test.
* testsuite/gas/mips/mips.exp: Run the new tests.
* testsuite/gas/mips/mips16@stabs-symbol-type.d: New test.
* testsuite/gas/mips/stabs-symbol-type.d: New test.
* testsuite/gas/mips/stabs-symbol-type.s: New test source.

7 years agoTest case for Inferior.thread_from_thread_handle
Kevin Buettner [Thu, 5 May 2016 19:39:36 +0000 (12:39 -0700)]
Test case for Inferior.thread_from_thread_handle

As the title says, this is a test case for
Inferior.thread_from_thread_handle, a python method which will,
given a thread library dependent thread handle, find the GDB thread
which corresponds to that thread handle (in the inferior under
consideration).

The C file for this test case causes the thread handles for the
main thread and two child threads to be placed into an array.  The
test case runs to one of the functions (do_something()) at which point,
it retrieves the thread handles from the array and attempts to find the
corresponding thread in GDB's internal thread list.

I use barriers to make sure that both threads have actually started;
execution will stop when one of the threads breaks at do_something.

Thanks to Simon Marchi for suggestions for forcing the thread
numbering to be stable.

gdb/testsuite/ChangeLog:

* gdb.python/py-thrhandle.c, gdb.python/py-thrhandle.exp: New
files.

7 years agoDocumentation for qXfer:threads:read handle attribute
Kevin Buettner [Thu, 6 Apr 2017 21:55:32 +0000 (14:55 -0700)]
Documentation for qXfer:threads:read handle attribute

gdb/doc/ChangeLog:

* gdb.texinfo (qXfer:threads:read): Add documentation for handle
attribute.

7 years agoAdd thread_handle_to_thread_info support for remote targets
Kevin Buettner [Tue, 4 Apr 2017 23:17:05 +0000 (16:17 -0700)]
Add thread_handle_to_thread_info support for remote targets

This patch adds support to remote targets for converting a thread
handle to a thread_info struct pointer.

A thread handle is fetched via a "handle" attribute which has been
added to the qXfer:threads:read query packet.  An implementation is
provided in gdbserver for targets using the Linux kernel.

gdb/gdbserver/ChangeLog:

* linux-low.h (struct lwp_info): Add new field, thread_handle.
(thread_db_thread_handle): Declare.
* linux-low.c (linux_target_ops): Initialize thread_handle.
* server.c (handle_qxfer_threads_worker): Add support for
"handle" attribute.
* target.h (struct target_ops): Add new function pointer,
thread_handle.
(target_thread_handle): Define.
* thread-db.c (find_one_thread, attach_thread): Set thread_handle
field in lwp.
(thread_db_thread_handle): New function.

gdb/ChangeLog:

* remote.c (vector): Include.
(struct private_thread_info): Add field, thread_handle.
(free_private_thread_info): Deallocate storage associated with
thread handle.
(get_private_info_thread): Initialize `thread_handle' field.
(struct thread_item): Add field, thread_handle.
(clear_threads_listing_context): Deallocate storage associated
with thread handle.
(start_thread): Add support for "handle" attribute.
(thread_attributes): Add "handle".
(remote_get_threads_with_qthreadinfo): Initialize thread_handle
field.
(remote_update_thread_list): Update thread_handle.
(remote_thread_handle_to_thread_info): New function.
(init_remote_ops): Initialize to_thread_handle_to_thread_info.

7 years agoAdd thread_db_notice_clone to gdbserver
Kevin Buettner [Tue, 4 Apr 2017 22:25:43 +0000 (15:25 -0700)]
Add thread_db_notice_clone to gdbserver

While working on a patch for fetching a thread handle in gdbserver, I
ran into a circumstance in which tests in gdb.mi/mi-nsmoribund.exp
would occasionally fail.  Over a large enough number of runs, it would
fail roughly 2% of the time.

That thread handle patch caused find_one_thread() to be called on
every stop.  find_one_thread() calls td_ta_map_lwp2thr() which, in
turn, can cause ps_get_thread_area() to be called.
ps_get_thread_area() makes a call to ptrace() for getting the thread
area address.  If this should happen when the thread is not stopped,
the call to ptrace will return error which in turn propogates back to
find_one_thread().  find_one_thread() calls error() in this instance
which causes the program to die.

This patch causes find_one_thread() to be called upon reciept of a
clone event.  Since the clone is stopped, the circumstances described
above cannot occur.

gdb/gdbserver/ChangeLog:

* linux-low.c (handle_extended_wait): Call thread_db_notice_clone().
* linux-low.h (thread_db_notice_clone): Declare.
* thread-db.c (thread_db_notice_clone): New function.

7 years agoDocumentation for Inferior.thread_from_thread_handle
Kevin Buettner [Wed, 4 May 2016 23:46:50 +0000 (16:46 -0700)]
Documentation for Inferior.thread_from_thread_handle

gdb/doc/ChangeLog:

* python.texi (Inferiors In Python): Add description for method
Inferior.thread_from_thread_handle.

7 years agoAdd `thread_from_thread_handle' method to (Python) gdb.Inferior
Kevin Buettner [Wed, 4 May 2016 23:23:08 +0000 (16:23 -0700)]
Add `thread_from_thread_handle' method to (Python) gdb.Inferior

gdb/ChangeLog:
* python/py-inferior.c (gdbpy_thread_from_thread_handle): New
function.
(inferior_object_methods): Add gdbpy_thread_from_thread_handle.
* python/python-internal.h (thread_object_type): Declare.

7 years agoAdd target method for converting thread handle to thread_info struct pointer
Kevin Buettner [Wed, 4 May 2016 22:21:12 +0000 (15:21 -0700)]
Add target method for converting thread handle to thread_info struct pointer

This patch adds a target method named `to_thread_handle_to_thread_info'.
It is intended to map a thread library specific thread handle (such as
pthread_t for the pthread library) to the corresponding GDB internal
thread_info struct (pointer).

An implementation is provided for Linux pthreads; see linux-thread-db.c.

gdb/ChangeLog:

* target.h (struct target_ops): Add to_thread_handle_to_thread_info.
(target_thread_handle_to_thread_info): Declare.
* target.c (target_thread_handle_to_thread_info): New function.
* target-delegates.c: Regenerate.
* gdbthread.h (find_thread_by_handle): Declare.
* thread.c (find_thread_by_handle): New function.
* linux-thread-db.c (thread_db_thread_handle_to_thread_info): New
function.
(init_thread_db_ops): Register thread_db_thread_handle_to_thread_info.

7 years agogdbserver: Remove traces of ancient Hc handling
Pedro Alves [Thu, 21 Sep 2017 15:52:33 +0000 (16:52 +0100)]
gdbserver: Remove traces of ancient Hc handling

Back in commit f0db101d9897 ("gdbserver: don't pick a random thread if
the current thread dies"), a couple years ago, the last references to
set_desired_thread(0) [select the Hc thread] were removed, and all the
remaining calls to set_desired_thread pass '1', meaning general
thread.  This means we can simplify set_desired_thread.

gdb/gdbserver/ChangeLog:
2017-09-21  Pedro Alves  <palves@redhat.com>

* server.c (gdb_read_memory, handle_status, process_serial_event)
(handle_serial_event, handle_target_event): Adjust to
set_desired_thread prototype change.
* target.c (set_desired_thread): Remove 'use_general' parameter
and adjust.
* target.h (set_desired_thread): Remove 'use_general' parameter.

7 years agoS/390: Fix Elf note swap s390_gs_bc vs. s390_gs_cb
Andreas Arnez [Thu, 21 Sep 2017 15:45:18 +0000 (17:45 +0200)]
S/390: Fix Elf note swap s390_gs_bc vs. s390_gs_cb

Fix two typos that resulted in swapping the BFD names for the core note
register sections NT_S390_GS_CB and NT_S390_GS_BC.

bfd/ChangeLog:

* elf.c (elfcore_grok_note): For the cases NT_S390_GS_CB and
NT_S390_GS_BC, correct the previously swapped invocations of
elfcore_grok_s390_gs_bc and elfcore_grok_s390_gs_cb.

7 years agoReduce excessive .eh_frame alignment for powerpc
Alan Modra [Thu, 21 Sep 2017 00:24:04 +0000 (09:54 +0930)]
Reduce excessive .eh_frame alignment for powerpc

PowerPC64 .cfi directives use DW_EH_PE_sdata4 encoding for .eh_frame,
so there is no real reason why .eh_frame should be 8 byte aligned.

gas/
* config/tc-ppc.h (EH_FRAME_ALIGNMENT): Define.
ld/
* testsuite/ld-powerpc/tlsopt5.wf: Update for reduced alignment.

7 years agolinux-waitpid: Get rid of format string warning
Simon Marchi [Thu, 21 Sep 2017 13:19:40 +0000 (15:19 +0200)]
linux-waitpid: Get rid of format string warning

Clang gives this warning:

/home/emaisin/src/binutils-gdb/gdb/gdbserver/../nat/linux-waitpid.c:45:25: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
      vfprintf (stderr, format, args);
                        ^~~~~~

Get rid of it by adding ATTRIBUTE_PRINTF.

gdb/ChangeLog:

* nat/linux-waitpid.c (linux_debug): Add ATTRIBUTE_PRINTF.

7 years agomicroblaze-tdep: Add ATTRIBUTE_PRINTF to microblaze_debug
Simon Marchi [Thu, 21 Sep 2017 12:09:33 +0000 (14:09 +0200)]
microblaze-tdep: Add ATTRIBUTE_PRINTF to microblaze_debug

I am getting this warning with clang:

/home/emaisin/src/binutils-gdb/gdb/microblaze-tdep.c:94:28: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
       vprintf_unfiltered (fmt, args);
                           ^~~

Adding ATTRIBUTE_PRINTF to microblaze_debug gets rid of it.  Strangely,
gcc doesn't warn about non-literal format strings when calling vprintf
(or a vprintf-style function, like vprintf_unfiltered).  I filed this
gcc bug:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82206

gdb/ChangeLog:

* microblaze-tdep.c (microblaze_debug): Add ATTRIBUTE_PRINTF.

7 years agoFix aarch64-freebsd build failure
Yao Qi [Thu, 21 Sep 2017 08:19:23 +0000 (09:19 +0100)]
Fix aarch64-freebsd build failure

I happen to see that fbsd-tdep.o is missing for target aarch64-freebsd,
and it causes the build failure,

aarch64-fbsd-tdep.o: In function `aarch64_fbsd_init_abi(gdbarch_info, gdbarch*)':
binutils-gdb/gdb/aarch64-fbsd-tdep.c:186: undefined reference to `fbsd_init_abi(gdbarch_info, gdbarch*)'
binutils-gdb/gdb/aarch64-fbsd-tdep.c:189: undefined reference to `svr4_lp64_fetch_link_map_offsets()'
binutils-gdb/gdb/aarch64-fbsd-tdep.c:189: undefined reference to `set_solib_svr4_fetch_link_map_offsets(gdbarch*, link_map_offsets* (*)())'

This patch fixed it.

gdb:

2017-09-21  Yao Qi  <yao.qi@linaro.org>

* configure.tgt (aarch64*-*-freebsd*): Add fbsd-tdep.o solib-svr4.o
to gdb_target_obs.

7 years agooops - changelog entry omitted from previous delta
Nick Clifton [Thu, 21 Sep 2017 08:04:43 +0000 (09:04 +0100)]
oops - changelog entry omitted from previous delta

7 years ago[SIM, ARM] Fix build failure
Yao Qi [Thu, 21 Sep 2017 08:02:25 +0000 (09:02 +0100)]
[SIM, ARM] Fix build failure

This patch fixes the build failure by using disassembler to get
disassemble function pointer, and do the disassembly, because
print_insn_little_arm is no longer visible outside opcodes/

binutils-gdb/sim/arm/wrapper.c:98:10: error: implicit declaration of function 'print_insn_little_arm' [-Werror=implicit-function-declaration]
   size = print_insn_little_arm (0, & info);
          ^

sim/arm:

2017-09-21  Yao Qi  <yao.qi@linaro.org>

* wrapper.c (print_insn): Use disassembler instead of
print_insn_little_arm.

7 years agoChange counted_command_line to a shared_ptr
Tom Tromey [Tue, 22 Aug 2017 03:51:11 +0000 (21:51 -0600)]
Change counted_command_line to a shared_ptr

This changes counted_command_line to be a typedef for std::shared_ptr
and removes the associated cleanups.  In the long run I believe that
cmd_list_element should also be changed to use a shared_ptr.

gdb/ChangeLog
2017-09-20  Tom Tromey  <tom@tromey.com>

* breakpoint.c (struct counted_command_line): Remove.
(breakpoint_commands): Update.
(alloc_counted_command_line, incref_counted_command_line)
(decref_counted_command_line, do_cleanup_counted_command_line)
(make_cleanup_decref_counted_command_line): Remove.
(breakpoint_set_commands, commands_command_1, ~bpstats, bpstats)
(bpstat_clear_actions, bpstat_do_actions_1, watchpoint_check)
(bpstat_stop_status, print_one_breakpoint_location, ~breakpoint)
(save_breakpoints): Update.
* breakpoint.h (counted_command_line): Now a typedef to
shared_ptr.
(struct breakpoint) <commands>: Now a counted_command_line.
(struct bpstats) <command>: Likewise.

7 years agoUse function_view in a couple of places in breakpoint.c
Tom Tromey [Tue, 22 Aug 2017 03:37:45 +0000 (21:37 -0600)]
Use function_view in a couple of places in breakpoint.c

This changes iterate_over_related_breakpoints and
map_breakpoint_numbers to take a function_view.  Then, it simplifies
the callers by using lambdas.  This then allows the removal of some
bookkeeping types.

gdb/ChangeLog
2017-09-20  Tom Tromey  <tom@tromey.com>

* breakpoint.c (struct commands_info, do_map_commands_command):
Remove.
(commands_command_1): Update.
(iterate_over_related_breakpoints): Take a function_view.
(do_delete_breakpoint, do_map_delete_breakpoint): Remove.
(delete_command): Update.
(map_breakpoint_numbers): Take a function_view.
(do_disable_breakpoint, do_map_delete_breakpoint): Remove.
(disable_command): Update.
(do_enable_breakpoint, do_map_enable_breakpoint): Remove.
(enable_command): Update.
(struct disp_data, do_enable_breakpoint_disp)
(do_map_enable_once_breakpoint, do_map_enable_count_breakpoint)
(do_map_enable_delete_breakpoint): Remove.
(enable_once_command, enable_count_command, enable_delete_command)
(delete_trace_variable_command): Update.

7 years agoAllocate bpstats with new
Tom Tromey [Tue, 22 Aug 2017 03:08:59 +0000 (21:08 -0600)]
Allocate bpstats with new

This changes struct bpstats to be allocated with new and freed with
delete, adding constructors and a destructor in the process.  This
allows the removal of one cleanup and clears the way for more to
follow.

gdb/ChangeLog
2017-09-20  Tom Tromey  <tom@tromey.com>

* breakpoint.c (~bpstats): Rename from bpstat_free.  Update.
(bpstat_clear): Use delete.
(bpstats): New constructors.
(bpstat_copy, bpstat_stop_status): Use new.
(dprintf_after_condition_true): Update.
* breakpoint.h (bpstats::bpstats): Add constructors.
(bpstats::~bpstats): Add destructor.

7 years agoAutomatic date update in version.in
GDB Administrator [Thu, 21 Sep 2017 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoeval.c:evaluate_subexp_standard: Use RAII to avoid leaks
Pedro Alves [Wed, 20 Sep 2017 23:34:41 +0000 (00:34 +0100)]
eval.c:evaluate_subexp_standard: Use RAII to avoid leaks

While working on the no-debug-info debugging improvements series, I
noticed these bare xfree calls, which lead to leaks if
evaluate_subexp_standard throws.

Fix that by reworking make_params as a RAII class.  Ends up
eliminating a couple heap allocations too.

gdb/ChangeLog:
2017-09-20  Pedro Alves  <palves@redhat.com>

* eval.c (make_params): Delete, refactored as ...
(class fake_method): ... this new type's ctor.
(fake_method::~fake_method): New.
(evaluate_subexp_standard): Use 'fake_method'.

7 years agoCheck for export dynamic symbol options when doing symbol resolution in plugins.
Teresa Johnson [Wed, 20 Sep 2017 22:43:37 +0000 (15:43 -0700)]
Check for export dynamic symbol options when doing symbol resolution in plugins.

2017-09-20  Teresa Johnson  <tejohnson@google.com>
* plugin.cc (is_visible_from_outside): Check for export dynamic symbol
        option and list.
* testsuite/Makefile.am (plugin_test_12): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/export_dynamic_plugin.cc: New test source.
* testsuite/plugin_test_12.sh: New test script.

7 years agoRemove make_cleanup_restore_target_terminal
Tom Tromey [Wed, 20 Sep 2017 03:56:36 +0000 (21:56 -0600)]
Remove make_cleanup_restore_target_terminal

This removes make_cleanup_restore_target_terminal and generally
C++-ifies target terminal handling.  It changes all target_terminal_*
functions to be static members of a new target_terminal class and
changes the cleanup to be a scoped_* class.
make_cleanup_override_quit_handler is also removed in favor of simply
using scoped_restore.

Note that there are some files in this patch that I could not compile.
Considering that some of the rewrites were automated, and that none of
these files involed cleanups, I feel that this is relatively safe.

Regression tested by the buildbot.

gdb/ChangeLog
2017-09-20  Tom Tromey  <tom@tromey.com>

* windows-nat.c (get_windows_debug_event, windows_wait)
(do_initial_windows_stuff, windows_attach): Update.
* utils.c (vwarning, internal_vproblem): Update.
(ui_unregister_input_event_handler_cleanup)
(prepare_to_handle_input): Remove.
(class scoped_input_handler): New.
(defaulted_query, prompt_for_continue): Update.
* tui/tui-hooks.c (tui_refresh_frame_and_register_information):
Update.
* top.c (undo_terminal_modifications_before_exit): Update.
* target/target.h (target_terminal_init, target_terminal_inferior)
(target_terminal_ours): Don't declare.
(class target_terminal): New.
* target.h (target_terminal_is_inferior, target_terminal_is_ours)
(target_terminal_ours_for_output)
(make_cleanup_restore_target_terminal): Don't declare.
(target_terminal_info): Remove.
* target.c (enum terminal_state, terminal_state): Remove.
(target_terminal::terminal_state): Define.
(target_terminal::init): Rename from target_terminal_init.
(target_terminal::inferior): Rename from
target_terminal_inferior.
(target_terminal::ours): Rename from target_terminal_ours.
(target_terminal::ours_for_output): Rename from
target_terminal_ours_for_output.
(target_terminal::info): New method.
(cleanup_restore_target_terminal)
(make_cleanup_restore_target_terminal): Remove.
* solib.c (handle_solib_event): Update.
* remote.c (remote_serial_quit_handler): Update.
(remote_terminal_inferior, remote_wait_as): Update.
* record-full.c (record_full_wait_1): Update.
* nto-procfs.c (procfs_create_inferior): Update.
* nat/fork-inferior.c (startup_inferior): Update.
* mi/mi-interp.c (mi_new_thread, mi_thread_exit)
(mi_record_changed, mi_inferior_added, mi_inferior_appeared)
(mi_inferior_exit, mi_inferior_removed, mi_traceframe_changed)
(mi_tsv_created, mi_tsv_deleted, mi_tsv_modified)
(mi_breakpoint_created, mi_breakpoint_deleted)
(mi_breakpoint_modified, mi_on_resume, mi_solib_loaded)
(mi_solib_unloaded, mi_command_param_changed, mi_memory_changed)
(mi_user_selected_context_changed, report_initial_inferior):
Update.
* linux-nat.c (linux_nat_attach, linux_nat_terminal_ours)
(linux_nat_terminal_inferior): Update.
* infrun.c (follow_fork_inferior)
(handle_vfork_child_exec_or_exit, do_target_resume)
(check_curr_ui_sync_execution_done, handle_inferior_event_1)
(handle_signal_stop, maybe_remove_breakpoints, normal_stop):
Update.
* inflow.c (child_terminal_init, info_terminal_command): Update.
* infcmd.c (post_create_inferior, continue_1, prepare_one_step)
(attach_command): Update.
* infcall.c (call_thread_fsm_should_stop): Update.
* gnu-nat.c (gnu_attach): Update.
* extension.c (struct active_ext_lang_state)
(restore_active_ext_lang): Update.
* exceptions.c (print_flush): Update.
* event-top.c (async_enable_stdin, default_quit_handler): Update.
(struct quit_handler_cleanup_data, restore_quit_handler)
(restore_quit_handler_dtor, make_cleanup_override_quit_handler):
Remove.
* cp-support.c (gdb_demangle): Update.
* breakpoint.c (update_inserted_breakpoint_locations)
(insert_breakpoint_locations, handle_jit_event)
(disable_breakpoints_in_unloaded_shlib): Update.
* annotate.c (annotate_breakpoints_invalid)
(annotate_frames_invalid): Update.

gdb/gdbserver/ChangeLog
2017-09-20  Tom Tromey  <tom@tromey.com>

* target.c (target_terminal::terminal_state): Define.
(target_terminal::init): Rename from target_terminal_init.
(target_terminal::inferior): Rename from
target_terminal_inferior.
(target_terminal::ours): Rename from target_terminal_ours.
(target_terminal::ours_for_output, target_terminal::info): New.

7 years agoOverload catch_command_errors
Tom Tromey [Tue, 12 Sep 2017 20:14:33 +0000 (14:14 -0600)]
Overload catch_command_errors

This changes catch_command_errors_const to be an overload of
catch_command_errors, which may mildly help future constification
efforts.

Tested by rebuilding.

gdb/ChangeLog
2017-09-20  Tom Tromey  <tom@tromey.com>

* main.c (catch_command_errors): Rename from
catch_command_errors_const.
(captured_main_1): Update.

7 years agoMake "list ambiguous" show symbol names too
Pedro Alves [Wed, 20 Sep 2017 15:12:54 +0000 (16:12 +0100)]
Make "list ambiguous" show symbol names too

Currently, with an ambiguous "list first,last", we get:

  (gdb) list bar,main
  Specified first line 'bar' is ambiguous:
  file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 97
  file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 98

This commit makes gdb's output above a bit clearer by printing the
symbol name as well:

  (gdb) list bar,main
  Specified first line 'bar' is ambiguous:
  file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 97, symbol: "bar(A)"
  file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 98, symbol: "bar(B)"

And while at it, makes gdb print the symbol name when actually listing
multiple locations too.  I.e., before (with "set listsize 2"):

  (gdb) list bar
  file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 97
  96
  97      int bar (A) { return 11; }
  file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 98
  97      int bar (A) { return 11; }
  98      int bar (B) { return 22; }

After:

  (gdb) list bar
  file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 97, symbol: "bar(A)"
  96
  97      int bar (A) { return 11; }
  file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 98, symbol: "bar(B)"
  97      int bar (A) { return 11; }
  98      int bar (B) { return 22; }

Currently, the result of decoding a linespec loses information about
the original symbol that was found.  All we end up with is an address.
This makes it difficult to find the original symbol again to get at
its print name.  Fix that by storing a pointer to the symbol in the
sal.  We already store the symtab and obj_section, so it feels like a
natural progression to me.  This avoids having to do any extra symbol
lookup too.

gdb/ChangeLog:
2017-09-20  Pedro Alves  <palves@redhat.com>

* cli/cli-cmds.c (list_command): Use print_sal_location.
(print_sal_location): New function.
(ambiguous_line_spec): Use print_sal_location.
* linespec.c (symbol_to_sal): Record the symbol in the sal.
* symtab.c (find_function_start_sal): Likewise.
* symtab.h (symtab_and_line::symbol): New field.

gdb/testsuite/ChangeLog:
2017-09-20  Pedro Alves  <palves@redhat.com>

* gdb.base/list-ambiguous.exp (test_list_ambiguous_symbol): Expect
symbol names in gdb's output.
* gdb.cp/overload.exp ("list all overloads"): Likewise.

7 years agoFix "list ambiguous_variable"
Pedro Alves [Wed, 20 Sep 2017 15:12:54 +0000 (16:12 +0100)]
Fix "list ambiguous_variable"

The "list" command allows specifying the name of variables as
argument, not just functions, so that users can type "list
a_global_variable".

That support is a broken when it comes to ambiguous locations though.

If there's more than one such global variable in the program, e.g.,
static globals in different compilation units, GDB ends up listing the
source of the first variable it finds, only.

linespec.c does find both symbol and minsym locations for all the
globals.  The problem is that it ends up merging all the resulting
sals into one, because they all have address, zero.  I.e., all sals
end up with sal.pc == 0, so maybe_add_address returns false for all
but the first.

The zero addresses appear because:

- in the minsyms case, linespec.c:minsym_found incorrectly treats all
  minsyms as if they were function/text symbols.  In list mode we can
  end up with data symbols there, and we shouldn't be using
  find_pc_sect_line on data symbols.

- in the debug symbols case, symbol_to_sal misses recording an address
  (sal.pc) for non-block, non-label symbols.

gdb/ChangeLog:
2017-09-20  Pedro Alves  <palves@redhat.com>

* linespec.c (minsym_found): Handle non-text minsyms.
(symbol_to_sal): Record a sal.pc for non-block, non-label symbols.

gdb/testsuite/ChangeLog:
2017-09-20  Pedro Alves  <palves@redhat.com>

* gdb.base/list-ambiguous.exp (test_list_ambiguous_function):
Rename to ...
(test_list_ambiguous_symbol): ... this and add a symbol name
parameter.  Adjust.
(test_list_ambiguous_function): Reimplement on top of
test_list_ambiguous_symbol and also test listing ambiguous
variables.
* gdb.base/list-ambiguous0.c (ambiguous): Rename to ...
(ambiguous_fun): ... this.
(ambiguous_var): New.
* gdb.base/list-ambiguous1.c (ambiguous): Rename to ...
(ambiguous_fun): ... this.
(ambiguous_var): New.

7 years ago[OBV] amd64-features-makefile: add missing backslash.
Walfred Tedeschi [Wed, 20 Sep 2017 13:24:47 +0000 (15:24 +0200)]
[OBV] amd64-features-makefile: add missing backslash.

In an old commit the backslash of was missing in the rule for creating the
i386-avx-mpx-avx512-pku.dat file.  No need to regenerate the files, this
was done by another commit from Yao.

2017-09-20  Walfred Tedeschi  <walfred.tedeschi@intel.com>

* features/Makefile (i386-avx-mpx-avx512-pku.dat): Add backslash.

7 years agoadd ChangeLog from previous commit
Walfred Tedeschi [Wed, 20 Sep 2017 12:47:04 +0000 (14:47 +0200)]
add ChangeLog from previous commit

7 years agogdb - avx512: tests were failing due to missing memory aligment.
Walfred Tedeschi [Wed, 20 Sep 2017 11:42:21 +0000 (13:42 +0200)]
gdb - avx512: tests were failing due to missing memory aligment.

Test was running on a fault during code execution.  Analysis have shown
that the wrong instruction had been used.  An instruction that takes
not alligned memory is more appropriated for the task.

ChangeLog:

2017-09-20  Walfred Tedeschi  <walfred.tedeschi@intel.com>

gdb/testesuite/ChangeLog:
* gdb.arch/i386-avx512.c (move_zmm_data_to_reg): Use
vmovups instead vmovaps.
(move_zmm_data_to_memory): Use vmovups instead vmovaps.

Change-Id: I4a95560861ef1792ed6ce86578fdd726162863f1