external/binutils.git
5 years agoRevert "Use wclrtoeol in tui_show_source_line"
Eli Zaretskii [Sat, 16 Mar 2019 12:13:43 +0000 (14:13 +0200)]
Revert "Use wclrtoeol in tui_show_source_line"

gdb/ChangeLog:
2019-03-16  Eli Zaretskii  <eliz@gnu.org>

* tui/tui-winsource.c (tui_show_source_line): Revert "Use
wclrtoeol in tui_show_source_line".  This reverts changes made in
commit 4a3045920bbe4e50a0f4920b0fdc4e88ef23015c.

(cherry picked from commit 798e1c302af509c31839c5c3b50c058b61206ee7)

5 years agoAutomatic date update in version.in
GDB Administrator [Sat, 16 Mar 2019 00:01:22 +0000 (00:01 +0000)]
Automatic date update in version.in

5 years agoAutomatic date update in version.in
GDB Administrator [Fri, 15 Mar 2019 00:00:57 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoThe NEWS file had two "New targets" sections for 8.3.
John Baldwin [Tue, 12 Mar 2019 20:56:53 +0000 (13:56 -0700)]
The NEWS file had two "New targets" sections for 8.3.

gdb/ChangeLog:

* NEWS: Combine separate "New targets" sections for 8.3.

5 years agoFix colors in TUI mode in MS-Windows build with ncurses
Eli Zaretskii [Thu, 14 Mar 2019 15:31:38 +0000 (17:31 +0200)]
Fix colors in TUI mode in MS-Windows build with ncurses

The MS-Windows port of ncurses fails to switch to a color pair if
one or both of the colors are the implicit default colors.  This
change records the default colors when TUI is initialized, and
then specifies them explicitly when a color pair uses the default
colors.  This allows color styling in TUI mode on MS-Windows.

gdb/ChangeLog:
2019-03-14  Eli Zaretskii  <eliz@gnu.org>

* tui/tui-io.c [__MINGW32__]: Include windows.h.  Declare
ncurses_norm_attr.
(tui_initialize_io) [__MINGW32__]: Record the default terminal
colors in ncurses_norm_attr.
(apply_ansi_escape) [__MINGW32__]: If a color in a color pair is
"none", replace it with the default color recorded in
ncurses_norm_attr.

(cherry picked from commit 3fff2c370cd658877be8107bfe9dde8dd0470b46)

5 years agoAvoid a crash in source_cache::extract_lines
Tom Tromey [Fri, 8 Mar 2019 20:59:27 +0000 (13:59 -0700)]
Avoid a crash in source_cache::extract_lines

If the first requested line is larger than the number of lines in the
source buffer, source_cache::extract_lines could crash, because it
would try to pass string::npos" to string::substr.

This patch avoids the crash by checking for this case.

This version of the patch changes get_source_lines to return
std::string.

2019-03-14  Tom Tromey  <tromey@adacore.com>

* source-cache.h (class source_cache) <get_source_lines>: Return
std::string.
* source-cache.c (source_cache::extract_lines): Handle case where
first_pos==npos.  Return std::string.
(source_cache::get_source_lines): Update.

5 years agoAdd the "set style source" command
Tom Tromey [Fri, 8 Mar 2019 20:54:07 +0000 (13:54 -0700)]
Add the "set style source" command

This adds "set style source" (and "show style source") commands.  This
gives the user control over whether source code is highlighted.

2019-03-14  Tom Tromey  <tromey@adacore.com>

* NEWS: Add item for "style sources" commands.
* source-cache.c (source_cache::get_source_lines): Check
source_styling.
* cli/cli-style.c (source_styling): New global.
(_initialize_cli_style): Add "style sources" commands.
(show_style_sources): New function.
* cli/cli-style.h (source_styling): Declare.

gdb/doc/ChangeLog
2019-03-14  Tom Tromey  <tromey@adacore.com>

* gdb.texinfo (Output Styling): Document "set style source" and
"show style source".

gdb/testsuite/ChangeLog
2019-03-14  Tom Tromey  <tromey@adacore.com>

* gdb.base/style.exp: Add "set style sources" test.

5 years agoMake TUI react to "set style enabled"
Tom Tromey [Fri, 8 Mar 2019 20:41:55 +0000 (13:41 -0700)]
Make TUI react to "set style enabled"

When the user toggles "set style enabled", the TUI should react by
redrawing the source window, if necessary.  This patch implements this
behavior.

No test because the TUI is generally not tested.

This version of the patch incorporates Pedro's patch to provide a
clean way to force the TUI to update the source window's contents.

2019-03-14  Pedro Alves  <palves@redhat.com>
    Tom Tromey  <tromey@adacore.com>

* tui/tui-winsource.h (tui_refill_source_window): Declare.
* tui/tui-winsource.c (tui_refill_source_window): New function,
from...
(tui_horizontal_source_scroll): ... here.  Move some logic.
* cli/cli-style.c (set_style_enabled): Notify new observable.
* tui/tui-hooks.c (tui_redisplay_source): New function.
(tui_attach_detach_observers): Attach or detach
tui_redisplay_source.
* observable.h (source_styling_changed): New observable.
* observable.c: Define source_styling_changed observable.

5 years agoAutomatic date update in version.in
GDB Administrator [Thu, 14 Mar 2019 00:01:00 +0000 (00:01 +0000)]
Automatic date update in version.in

5 years agoAutomatic date update in version.in
GDB Administrator [Wed, 13 Mar 2019 00:00:39 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoFix MinGW build with source-highlight
Eli Zaretskii [Tue, 12 Mar 2019 17:47:23 +0000 (19:47 +0200)]
Fix MinGW build with source-highlight

gdb/ChangeLog
2019-03-12  Eli Zaretskii  <eliz@gnu.org>

PR/24325
* source-cache.c: #undef open and close, to avoid unresolved
externals during linking.

(cherry picked from commit 3a3508220eecf27e1952a73cd3ea6d6314ce8e1d)

5 years agoAutomatic date update in version.in
GDB Administrator [Tue, 12 Mar 2019 00:00:53 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoAutomatic date update in version.in
GDB Administrator [Mon, 11 Mar 2019 00:00:46 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoAutomatic date update in version.in
GDB Administrator [Sun, 10 Mar 2019 00:01:33 +0000 (00:01 +0000)]
Automatic date update in version.in

5 years agoSupport styling on native MS-Windows console
Eli Zaretskii [Sat, 9 Mar 2019 06:44:56 +0000 (08:44 +0200)]
Support styling on native MS-Windows console

gdb/ChangeLog:
2019-03-08  Eli Zaretskii  <eliz@gnu.org>

PR/24315
* utils.c (can_emit_style_escape) [_WIN32]: Don't disable styling
on MS-Windows if $TERM is not defined.

* cli/cli-style.c: Set cli_styling to 1 in the MinGW build.

* posix-hdep.c (gdb_console_fputs):
* mingw-hdep.c (rgb_to_16colors, gdb_console_fputs): New
functions.
* ui-file.h (gdb_console_fputs): Add prototype.

* ui-file.c (stdio_file::puts): Call gdb_console_fputs, and fall
back to fputs only if the former returns zero.

(cherry picked from commit e4adb93903d4ae0b7ab2b5004364e50627df95f7)

5 years agoAutomatic date update in version.in
GDB Administrator [Sat, 9 Mar 2019 00:01:21 +0000 (00:01 +0000)]
Automatic date update in version.in

5 years agoAutomatic date update in version.in
GDB Administrator [Fri, 8 Mar 2019 00:01:48 +0000 (00:01 +0000)]
Automatic date update in version.in

5 years agoCan't interrupt process without controlling terminal on Solaris (PR gdb/8527)
Rainer Orth [Thu, 7 Mar 2019 21:00:05 +0000 (22:00 +0100)]
Can't interrupt process without controlling terminal on Solaris (PR gdb/8527)

If gdb attaches to a process that either has no controlling terminal,
or the controlling terminal differs from the one gdb is running under,
break/^C doesn't interrupt the debugged process on Solaris.

Fixed as follows, analogous to what all all other targets do.  Patch from
the PR, recently re-submitted by Brian Vandenberg.

Tested on amd64-pc-solaris2.11, sparcv9-sun-solaris2.11, and
x86_64-pc-linux-gnu.

2019-03-07  Brian Vandenberg  <phantall@gmail.com>
    Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gdb:
PR gdb/8527
* procfs.c (proc_wait_for_stop): Wrap write of PCWSTOP in
set_sigint_trap, clear_sigint_trap.

gdb/testsuite:
PR gdb/8527
* gdb.base/interrupt-daemon-attach.c,
gdb.base/interrupt-daemon-attach.exp: New test.

5 years agoAutomatic date update in version.in
GDB Administrator [Thu, 7 Mar 2019 00:01:40 +0000 (00:01 +0000)]
Automatic date update in version.in

5 years agoTestsuite: Ensure changing directory does not break the log file
Alan Hayward [Wed, 6 Mar 2019 09:52:08 +0000 (09:52 +0000)]
Testsuite: Ensure changing directory does not break the log file

get_compiler_info switches to a new log file before checking the compiler
to ensure the checks are not logged. Afterwards it restores back to using
the original log file. However, the logfile uses a relative path name -
if the current test has changed the current directory then all further
output for the test will be lost.  This can confuse the code that collates
the main gdb.log file at the end of a FORCE_PARALLEL run.

fullpath-expand.exp calls gdb_compile after changing the current directory.

The "Ensure stack protection is off for GCC" patch added a call to
get_compiler_info from inside of gdb_compile, causing log file collection
to break for FORCE_PARALLEL runs.

The ideal solution would be to ensure the log file is always created using
an absolute path name. However, this is set at multiple points in
Makefile.in and in some instances just relies on dejagnu common code to set
the log file directory to "."

The simpler and safer solution is to override the builtin cd function. The
new function checks the current log file and if the path is relative, then
it resets the logging using an absolute path. Finally it calls the builtin
cd.  This ensures get_compiler_info (and any other code) can correctly
backup and restore the current log file.

gdb/testsuite/ChangeLog:

* lib/gdb.exp (builtin_cd): rename of cd.
(cd): Override builtin.

5 years agoAutomatic date update in version.in
GDB Administrator [Wed, 6 Mar 2019 00:01:21 +0000 (00:01 +0000)]
Automatic date update in version.in

5 years agoUse '$enable_unittest' instead of '$development' on gdbserver/configure.srv (for...
Sergio Durigan Junior [Mon, 4 Mar 2019 17:44:20 +0000 (12:44 -0500)]
Use '$enable_unittest' instead of '$development' on gdbserver/configure.srv (for 'aarch64*-*-linux*' case)

On commit 8ecfd7bd4acd69213c06fac6de9af38299123547 ("Add parameter to
allow enabling/disabling selftests via configure") it seems that I
forgot to use the proper '$enable_unittest' variable when checking to
see whether to add selftest-related objects to 'srv_regobj'.  This
causes a build failure on Aarch64 when 'development=false' (which is
the case for the 8.3 branch) and 'enable_unittest=true'.

This patch fixes the problem by using '$enable_unittest' instead of
'$development' when performing the check.  As a reminder, it's
important to notice that '$enable_unittest's default value (i.e., when
the option '--enable-unit-tests' is not passed to configure) is the
same as '$development', so this patch doesn't affect the current
build.

I'd like to install this patch both on master and on the 8.3 branch.

OK?

gdb/gdbserver/ChangeLog:
2019-03-04  Sergio Durigan Junior  <sergiodj@redhat.com>

* configure.srv: Use '$enable_unittest' instead of '$development'
when checking whether to fill 'srv_regobj' on 'aarch64*-*-linux*'
case.

5 years agoAutomatic date update in version.in
GDB Administrator [Tue, 5 Mar 2019 00:01:29 +0000 (00:01 +0000)]
Automatic date update in version.in

5 years agoAutomatic date update in version.in
GDB Administrator [Mon, 4 Mar 2019 00:01:11 +0000 (00:01 +0000)]
Automatic date update in version.in

5 years agoAutomatic date update in version.in
GDB Administrator [Sun, 3 Mar 2019 00:02:14 +0000 (00:02 +0000)]
Automatic date update in version.in

5 years agoFix documentation of styles.
Eli Zaretskii [Sat, 2 Mar 2019 19:42:54 +0000 (21:42 +0200)]
Fix documentation of styles.

gdb/doc/ChangeLog:
2019-03-02  Eli Zaretskii  <eliz@gnu.org>

* gdb.texinfo (Output Styling): Fix typos.  Document the default
foreground colors of the available styles.

(cherry picked from commit e3624a40aeb31065c968d0d3a1d55fdf8e8a4e3c)

5 years agoAvoid compilation warnings on MinGW.
Eli Zaretskii [Sat, 2 Mar 2019 13:22:11 +0000 (15:22 +0200)]
Avoid compilation warnings on MinGW.

gdb/ChangeLog:
2019-03-02  Eli Zaretskii  <eliz@gnu.org>

* xml-syscall.c (xml_list_syscalls_by_group): Drop 'struct' from
for-loop range, to avoid compiler warnings.

* tui/tui.c (tui_enable) [__MINGW32__]: Don't declare 'cap', to
avoid compiler warnings about unused variables.

(cherry picked from commit a6a4b2c636b29de09dea890b448f99804ef7bc18)

5 years agoGDB no longer supports Windows before XP.
Eli Zaretskii [Sat, 2 Mar 2019 13:18:32 +0000 (15:18 +0200)]
GDB no longer supports Windows before XP.

gdb/ChangeLog:
2019-03-02  Eli Zaretskii  <eliz@gnu.org>

* NEWS: Mention end of support for native debugging on MS-Windows
before XP.

(cherry picked from commit 742a7df5f4a149f0818aaccfc432c4c0c9a6e26d)

5 years agoFix GDB compilation on MinGW (PR gdb/24292)
Eli Zaretskii [Sat, 2 Mar 2019 13:13:54 +0000 (15:13 +0200)]
Fix GDB compilation on MinGW (PR gdb/24292)

gdb/ChangeLog:
2019-03-02  Eli Zaretskii  <eliz@gnu.org>

PR gdb/24292
* common/netstuff.c:
* gdbserver/gdbreplay.c
* gdbserver/remote-utils.c:
* ser-tcp.c:
* unittests/parse-connection-spec-selftests.c [USE_WIN32API]:
Include ws2tcpip.h instead of wsiapi.h and winsock2.h.  Redefine
_WIN32_WINNT to 0x0501 if defined to a smaller value, as
'getaddrinfo' and 'freeaddrinfo' were not available before
Windows XP, and mingw.org's MinGW headers by default define
_WIN32_WINNT to 0x500.

(cherry picked from commit 41fa577fbc326402be49b3f03bc828e52dba8b88)

5 years agoAutomatic date update in version.in
GDB Administrator [Sat, 2 Mar 2019 00:01:40 +0000 (00:01 +0000)]
Automatic date update in version.in

5 years agoAutomatic date update in version.in
GDB Administrator [Fri, 1 Mar 2019 00:02:06 +0000 (00:02 +0000)]
Automatic date update in version.in

5 years agoAutomatic date update in version.in
GDB Administrator [Thu, 28 Feb 2019 00:01:49 +0000 (00:01 +0000)]
Automatic date update in version.in

5 years agoDocument fact that mininum Python version is now 2.6
Kevin Buettner [Fri, 22 Feb 2019 00:22:13 +0000 (17:22 -0700)]
Document fact that mininum Python version is now 2.6

gdb/ChangeLog:

* NEWS: Note minimum Python version.

gdb/doc/ChangeLog:

* gdb.texinfo (Configure Options): Document minimum python
version.

5 years agoBump GDB version number to 8.2.90.DATE-git.
Joel Brobecker [Wed, 27 Feb 2019 05:36:33 +0000 (09:36 +0400)]
Bump GDB version number to 8.2.90.DATE-git.

gdb/ChangeLog:

* version.in: Set GDB version number to 8.2.90.DATE-git.

5 years agoDocument the GDB 8.2.90 release in gdb/ChangeLog
Joel Brobecker [Wed, 27 Feb 2019 05:29:44 +0000 (09:29 +0400)]
Document the GDB 8.2.90 release in gdb/ChangeLog

gdb/ChangeLog:

GDB 8.2.90 released.

5 years agoSet GDB version number to 8.2.90.
Joel Brobecker [Wed, 27 Feb 2019 05:19:57 +0000 (09:19 +0400)]
Set GDB version number to 8.2.90.

gdb/ChangeLog:

* version.in: Set GDB version number to 8.2.90.

5 years agochange section name in gdb/NEWS for changes in GDB 8.3
Joel Brobecker [Wed, 27 Feb 2019 05:06:55 +0000 (09:06 +0400)]
change section name in gdb/NEWS for changes in GDB 8.3

gdb/ChangeLog:

        * NEWS: Change "Changes since GDB 8.2" into "Changes in GDB 8.3".

5 years agoSet development mode to "off" by default.
Joel Brobecker [Wed, 27 Feb 2019 04:53:29 +0000 (08:53 +0400)]
Set development mode to "off" by default.

bfd/ChangeLog:

* development.sh (development): Set to false.

5 years agoBump version to 8.2.90.DATE-git.
Joel Brobecker [Wed, 27 Feb 2019 04:52:26 +0000 (08:52 +0400)]
Bump version to 8.2.90.DATE-git.

Now that the GDB 8.3 branch has been created, we can
bump the version number.

gdb/ChangeLog:

GDB 8.3 branch created (143420fb0d5ae54323ba9953f0818c194635228d):
* version.in: Bump version to 8.2.90.DATE-git.

5 years agoFix build errors in aix-thread.c
Simon Marchi [Wed, 27 Feb 2019 04:45:50 +0000 (23:45 -0500)]
Fix build errors in aix-thread.c

This patch fixes a few instances of unused variable and shadowed local
variable errors.

gdb/ChangeLog:

* aix-thread.c (ptid_cmp): Remove unused variable.
(get_signaled_thread): Likewise.
(store_regs_user_thread): Likewise.
(store_regs_kernel_thread): Likewise.
(fetch_regs_kernel_thread): Remove shadowed variable.

5 years agoAutomatic date update in version.in
GDB Administrator [Wed, 27 Feb 2019 00:00:37 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agogdb/riscv: Use legacy register numbers in default target description
Andrew Burgess [Sat, 23 Feb 2019 20:07:47 +0000 (22:07 +0200)]
gdb/riscv: Use legacy register numbers in default target description

When the target description support was added to RISC-V, the register
numbers assigned to the fflags, frm, and fcsr control registers in the
default target descriptions didn't match the register numbers used by
GDB before the target description support was added.

What this means is that if a tools exists in the wild that is using
hard-coded register number, setup to match GDB's old numbering, then
this will have been broken (for fflags, frm, and fcsr) by the move to
target descriptions.  QEMU is such a tool.

There are a couple of solutions that could be used to work around this
issue:

 - The user can create their own xml description file with the
   register numbers setup to match their old tool, then load this by
   telling GDB 'set tdesc filename FILENAME'.

 - Update their old tool to use the newer default numbering scheme, or
   better yet add proper target description support to their tool.

 - We could have RISC-V GDB change to maintain the old defaults.

This patch changes GDB back to using the old numbering scheme.

This change is only visible to remote targets that don't supply their
own xml description file and instead rely on GDB's default numbering.

Note that even though 32bit-cpu.xml and 64bit-cpu.xml have changed,
the corresponding .c file has not, this is because the numbering added
to the registers in the xml files is number 0, this doesn't result in
any new C code being generated .

gdb/ChangeLog:

* features/riscv/32bit-cpu.xml: Add register numbers.
* features/riscv/32bit-fpu.c: Regenerate.
* features/riscv/32bit-fpu.xml: Add register numbers.
* features/riscv/64bit-cpu.xml: Add register numbers.
* features/riscv/64bit-fpu.c: Regenerate.
* features/riscv/64bit-fpu.xml: Add register numbers.

5 years agoFix new py-value.exp test case
Tom Tromey [Tue, 26 Feb 2019 19:12:30 +0000 (12:12 -0700)]
Fix new py-value.exp test case

The new test case in py-value.exp fails -- the code was changed to
throw ValueError, but the test still checks for TypeError.  This patch
fixes the problem.

I'm checking this in.  Tested on x86-64 Fedora 29.

gdb/testsuite/ChangeLog
2019-02-26  Tom Tromey  <tromey@adacore.com>

* gdb.python/py-value.exp (test_value_from_buffer): Check for
ValueError, not TypeError.

5 years agoDocument two argument form of gdb.Value constructor
Kevin Buettner [Sun, 17 Feb 2019 01:31:51 +0000 (18:31 -0700)]
Document two argument form of gdb.Value constructor

gdb/ChangeLog:

* NEWS: Mention two argument form of gdb.Value constructor.

gdb/doc/ChangeLog:

* python.texi (Values From Inferior): Document second form
of Value.__init__.

5 years agoAdd tests for gdb.Value(bufobj, type) constructor
Kevin Buettner [Sun, 17 Feb 2019 01:07:51 +0000 (18:07 -0700)]
Add tests for gdb.Value(bufobj, type) constructor

gdb/testsuite/ChangeLog:

* gdb.python/py-value.exp (test_value_from_buffer): New proc with
call from main program.

5 years agoDefine gdb.Value(bufobj, type) constructor
Kevin Buettner [Sun, 17 Feb 2019 00:46:33 +0000 (17:46 -0700)]
Define gdb.Value(bufobj, type) constructor

Provided a buffer BUFOBJ and a type TYPE, construct a gdb.Value object
with type TYPE, where the value's contents are taken from BUFOBJ.

E.g...

(gdb) python import struct
(gdb) python unsigned_int_type=gdb.lookup_type('unsigned int')
(gdb) python b=struct.pack('=I',0xdeadbeef)
(gdb) python v=gdb.Value(b, unsigned_int_type) ; print("%#x" % v)
0xdeadbeef

This two argument form of the gdb.Value constructor may also be used
to obtain gdb values from selected portions of buffers read with
Inferior.read_memory().  The test case (which is in a separate patch)
demonstrates this use case.

gdb/ChangeLog:

* python/py-value.c (convert_buffer_and_type_to_value): New
function.
(valpy_new): Parse arguments via gdb_PyArg_ParseTupleAndKeywords.
Add support for handling an optional second argument.  Call
convert_buffer_and_type_to_value as appropriate.

5 years agoDefine unique_ptr specialization for Py_buffer.
Kevin Buettner [Sun, 17 Feb 2019 00:33:47 +0000 (17:33 -0700)]
Define unique_ptr specialization for Py_buffer.

This patch causes PyBuffer_Release() to be called when the associated
buffer goes out of scope.  I've been using it as follows:

 ...
 Py_buffer_up buffer_up;
 Py_buffer py_buf;

 if (PyObject_CheckBuffer (obj)
     && PyObject_GetBuffer (obj, &py_buf, PyBUF_SIMPLE) == 0)
   {
      /* Got a buffer, py_buf, out of obj.  Cause it to released
         when it goes out of scope.  */
     buffer_up.reset (&py_buf);
   }
   ...

This snippet of code was taken directly from an upcoming patch to
python-value.c.

gdb/ChangeLog:

* python/python-internal.h (Py_buffer_deleter): New struct.
(Py_buffer_up): New typedef.

5 years agoAutomatic date update in version.in
GDB Administrator [Tue, 26 Feb 2019 00:00:25 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoFix BFD leak in dwarf2_get_dwz_file.
John Baldwin [Mon, 25 Feb 2019 22:25:01 +0000 (14:25 -0800)]
Fix BFD leak in dwarf2_get_dwz_file.

Previously if build_id_verify failed, dwz_bfd was cleared to NULL via
release(), but the BFD object was not destroyed.  Use reset() with
nullptr instead to delete the BFD.

gdb/ChangeLog:

* dwarf2read.c (dwarf2_get_dwz_file): Reset dwz_bfd to nullptr
instead of releasing ownership.

5 years agoFix crash when loading dwp files
Jordan Rupprecht [Mon, 25 Feb 2019 20:21:01 +0000 (12:21 -0800)]
Fix crash when loading dwp files

When loading dwp files, we create an array of ELF sections indexed by the ELF
section index in the dwp file. The size of this array is calculated by
section_count, as returned by bfd_count_sections, plus 1 (to account for the
null section at index 0). However, when loading the bfd file, strtab/symtab
sections are not added to the list, nor do they increment section_count, so
section_count is actually smaller than the number of ELF sections.

This happens to work when using GNU dwp, which lays out .debug section first,
with sections like .shstrtab coming at the end. Other tools, like llvm-dwp, put
.strtab first, and gdb crashes when loading those dwp files.

For instance, with the current state of gdb, loading a file like this:
$ readelf -SW <file.dwp>
[ 0] <empty>
[ 1] .debug_foo PROGBITS ...
[ 2] .strtab    STRTAB ...

... results in section_count = 2 (.debug is the only thing placed into
bfd->sections, so section_count + 1 == 2), and sectp->this_idx = 1 when mapping
over .debug_foo in dwarf2_locate_common_dwp_sections, which passes the
assertion that 1 < 2.

However, using a dwp file produced by llvm-dwp:
$ readelf -SW <file.dwp>
[ 0] <empty>
[ 1] .strtab    STRTAB ...
[ 2] .debug_foo PROGBITS ...

... results in section_count = 2 (.debug is the only thing placed into
bfd->sections, so section_count + 1 == 2), and sectp->this_idx = 2 when mapping
over .debug_foo in dwarf2_locate_common_dwp_sections, which fails the assertion
that 2 < 2.

The assertion hit is:

gdb/dwarf2read.c:13009: internal-error: void dwarf2_locate_common_dwp_sections(bfd*, asection*, void*): Assertion `elf_section_nr < dwp_file->num_sections' failed.

This patch changes the calculation of section_count to use elf_numsections,
which should return the actual number of ELF sections.

5 years agoFix BFD leak in solib-darwin.c
Tom Tromey [Thu, 21 Feb 2019 17:40:49 +0000 (10:40 -0700)]
Fix BFD leak in solib-darwin.c

commit 192b62ce0b4bb5c61188f570e127a26d2c32f716 ("Use class to manage
BFD reference counts") changed darwin_get_dyld_bfd to use:

+ dyld_bfd.release ();

rather than

-      do_cleanups (cleanup);

However, using release here leaks the BFD.  Instead, simply assigning
"sub" to "dyld_bfd" achieves what was meant.

gdb/ChangeLog
2019-02-25  Tom Tromey  <tromey@adacore.com>

* solib-darwin.c (darwin_get_dyld_bfd): Don't release dyld_bfd.

5 years agoExtend objdump's --dwarf=follow-links option so that separate debug info files will...
Nick Clifton [Mon, 25 Feb 2019 12:15:41 +0000 (12:15 +0000)]
Extend objdump's --dwarf=follow-links option so that separate debug info files will also be affected by other dump function, and symbol tables from separate debug info files will be used when disassembling the main file.

* objdump.c (sym_ok): New function.
(find_symbol_for_address): Use new function.
(disassemble_section): Compare sections by name, not pointer.
(dump_dwarf): Move code to initialise byte_get pointer and iterate
over separate debug files from here to ...
(dump_bfd): ... here.  Add parameter indicating that a separate
debug info file is being dumped.  For main file, pull in the
symbol tables from all separate debug info files.
(display_object): Update call to dump_bfd.
* doc/binutils.texi: Document extened behaviour of the
--dwarf=follow-links option.
* NEWS: Mention this new feature.
* testsuite/binutils-all/objdump.WK2: Update expected output.
* testsuite/binutils-all/objdump.exp (test_follow_debuglink): Add
options and dump file parameters.
Add extra test.
* testsuite/binutils-all/objdump.WK3: New file.
* testsuite/binutils-all/readelf.exp: Change expected output for
readelf -wKis test.
* testsuite/binutils-all/readelf.wKis: New file.

5 years agoAutomatic date update in version.in
GDB Administrator [Mon, 25 Feb 2019 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoRe: PowerPC __tls_get_addr arg parsing
Alan Modra [Sun, 24 Feb 2019 07:31:08 +0000 (18:01 +1030)]
Re: PowerPC __tls_get_addr arg parsing

Fixes non-ELF powerpc build failure:
tc-ppc.c:3009:1: error: â€˜parse_tls_arg’ defined but not used

* config/tc-ppc.c (parse_tls_arg): Wrap in #ifdef OBJ_ELF.

5 years agoPR24144, pdp11-ld overwriting section data with zeros
Alan Modra [Sun, 24 Feb 2019 06:14:48 +0000 (16:44 +1030)]
PR24144, pdp11-ld overwriting section data with zeros

bfd/
PR 24144
* pdp11.c (set_section_contents): Revert 2015-02-24 change.
gas/
PR 24144
* config/obj-aout.c (obj_aout_frob_file_before_fix): Write to end
of section to ensure file contents cover aligned section size.

5 years agoAutomatic date update in version.in
GDB Administrator [Sun, 24 Feb 2019 00:01:17 +0000 (00:01 +0000)]
Automatic date update in version.in

5 years agoUse '--readnever' when invoking GDB from gcore.in
Sergio Durigan Junior [Sat, 23 Feb 2019 15:05:19 +0000 (10:05 -0500)]
Use '--readnever' when invoking GDB from gcore.in

Back when I proposed the '--readnever' feature, I somehow forgot or
decided not to include the bits related to gcore.in in the original
patch.  This patch finally updates the gcore script to invoke GDB
using '--readnever'.

We've been carrying this patch on Fedora GDB for quite some time, and
as expected the corefiles generated by gcore on Fedora don't have
problems, which I think is the best indicator that the it's safe to
generate corefiles using '--readnever'.

gdb/ChangeLog:
2019-02-23  Sergio Durigan Junior  <sergiodj@redhat.com>

* gcore.in: Add '--readnever' option when invoking GDB.

5 years agoUpdate copyright year range in gdb.ada/mi_ref_changeable testcase
Joel Brobecker [Sat, 23 Feb 2019 12:23:22 +0000 (16:23 +0400)]
Update copyright year range in gdb.ada/mi_ref_changeable testcase

This patch fixes the copyright year range which escaped
the 2019 update, because the patch was submitted in 2018, but
only really pushed in 2019.

    Pushed: https://www.sourceware.org/ml/gdb-patches/2019-02/msg00109.html
    Submitted: https://www.sourceware.org/ml/gdb-patches/2018-12/msg00444.html

We normally are pretty good at remembering those little things,
but this one fell through the cracks. This commit fixes this,
by re-running the copyright.py script and checking in the changes
made by that script.

gdb/testsuite/ChangeLog:

* gdb.ada/mi_ref_changeable.exp: Update copyright year range.
* gdb.ada/mi_ref_changeable/foo_rb20_056.adb: Likewise.
* gdb.ada/mi_ref_changeable/pck.adb: Likewise.
* gdb.ada/mi_ref_changeable/pck.ads: Likewise.
* gdb.dwarf2/inlined_subroutine-inheritance.exp: Likewise.

5 years agoUpdate copyright year range in gdb.texinfo and refcard.tex
Joel Brobecker [Sat, 23 Feb 2019 12:14:23 +0000 (16:14 +0400)]
Update copyright year range in gdb.texinfo and refcard.tex

I missed those files which need to be updated manually when I did
the copyright year range update. The copyright.py script reminds
us of that fact with the following message at the end...

    REMINDER: Multiple copyright headers must be updated by hand:
       gdb/doc/gdb.texinfo
       gdb/doc/refcard.tex
       gdb/gdbarch.sh

... and somehow I missed this. This commit makes the change for
gdb.texinfo and refcard.tex. gdbarch.sh is being updated separately
by Andrew Burgess.

gdb/doc/ChangeLog:

* gdb.texinfo: Update copyright year ranges.
* refcard.tex: Likewise.

5 years agoAutomatic date update in version.in
GDB Administrator [Sat, 23 Feb 2019 00:00:56 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoUpdate my email address
Simon Marchi [Fri, 22 Feb 2019 20:53:52 +0000 (15:53 -0500)]
Update my email address

Since this is my last day at Ericsson, I am changing my email for my
personal one in the MAINTAINERS file.

5 years agoLook for build-id-based separate debug files under the sysroot
Simon Marchi [Fri, 22 Feb 2019 20:09:23 +0000 (15:09 -0500)]
Look for build-id-based separate debug files under the sysroot

When looking for a separate debug file that matches a given build-id,
GDB only looks in the host's debug dir (typically /usr/lib/debug).  This
patch makes it look in the sysroot as well.  This is to match the
behavior of GDB when using debuglink-based separate debug files,
introduced in :

402d2bfec42 ("Look for separate debug files in debug directories under a sysroot.")

In the following example, my sysroot is "/tmp/sysroot" and I am trying
to load symbols for
/tmp/sysroot/usr/lib/arm-linux-gnueabihf/gconv/EBCDIC-AT-DE.so.  This is
the current behavior:

    (gdb) file /tmp/sysroot/usr/lib/arm-linux-gnueabihf/gconv/EBCDIC-AT-DE.so
    Reading symbols from /tmp/sysroot/usr/lib/arm-linux-gnueabihf/gconv/EBCDIC-AT-DE.so...

    Looking for separate debug info (build-id) for /tmp/sysroot/usr/lib/arm-linux-gnueabihf/gconv/EBCDIC-AT-DE.so
      Trying /usr/lib/debug/.build-id/f3/d6594d2600e985812cd4ba2ad083ac2aceae22.debug... no, unable to compute real path

    <snip>
    (No debugging symbols found in /tmp/sysroot/usr/lib/arm-linux-gnueabihf/gconv/EBCDIC-AT-DE.so)

With this patch:

    (gdb) file /tmp/sysroot/usr/lib/arm-linux-gnueabihf/gconv/EBCDIC-AT-DE.so
    Reading symbols from /tmp/sysroot/usr/lib/arm-linux-gnueabihf/gconv/EBCDIC-AT-DE.so...

    Looking for separate debug info (build-id) for /tmp/sysroot/usr/lib/arm-linux-gnueabihf/gconv/EBCDIC-AT-DE.so
      Trying /usr/lib/debug/.build-id/f3/d6594d2600e985812cd4ba2ad083ac2aceae22.debug... no, unable to compute real path
      Trying /tmp/sysroot/usr/lib/debug/.build-id/f3/d6594d2600e985812cd4ba2ad083ac2aceae22.debug... yes!
    Reading symbols from /tmp/sysroot/usr/lib/debug/.build-id/f3/d6594d2600e985812cd4ba2ad083ac2aceae22.debug...

In the original code, there is a suspicious "abfd.release ()" in
build_id_to_debug_bfd, that I don't understand.  If a file with the
right name exists but its build-id note doesn't match, we release (leak)
our reference, meaning the file will stay open?  I removed it in the new
code, so that the reference is dropped if we end up not using that file.
I tested briefly by corrupting a separate debug file to trigger this
code, nothing exploded.

gdb/ChangeLog:

* build-id.c (build_id_to_debug_bfd_1): New function.
(build_id_to_debug_bfd): Look for separate debug file in
sysroot.

5 years agogdb: Update copyright year range generated by gdbarch.sh
Andrew Burgess [Fri, 22 Feb 2019 20:12:21 +0000 (20:12 +0000)]
gdb: Update copyright year range generated by gdbarch.sh

The copyright year that gdbarch.sh places into the generated files
gdbarch.{c,h} wasn't updated at the start of the year.  After this
commit the gdbarch.{c,h} files regenerate as the currently are in the
tree.

gdb/ChangeLog:

* gdbarch.sh: Update the copyright year range that is placed into
generated files.

5 years agoAdd missing ChangeLog entries for commit bb995d00b3eef2f48d0be895c3509a7ddd8280a1
Keith Seitz [Fri, 22 Feb 2019 20:05:37 +0000 (12:05 -0800)]
Add missing ChangeLog entries for commit bb995d00b3eef2f48d0be895c3509a7ddd8280a1

5 years agoFix symtab/23853: symlinked default symtab
Keith Seitz [Fri, 22 Feb 2019 17:39:35 +0000 (09:39 -0800)]
Fix symtab/23853: symlinked default symtab

This patch attempts to fix a bug dealing with setting breakpoints
in default symtabs that are symlinks.  For example:

(gdb) list
11    GNU General Public License for more details.
12
13    You should have received a copy of the GNU General Public License
14    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
15
16 static int
17 foo (void)
18 {
19   return 0; /* break here  */
20 }
(gdb)
21
22 int
23 main (void)
24 {
25   return foo ();
26 }
(gdb) b 19
No line 19 in the current file.
Make breakpoint pending on future shared library load? (y or [n])

The problem here is that when create_sals_line_offset sets the default
symtab, it immediately calls symtab_to_fullname, passing that fullname
to collect_symtabs_from_filename to find all matching symtabs.  This
fails because we end up looking for a symtab with the name of the
actual file on disk (which is different in this case because of the
symlink) instead of the one stored in the debug info.

Since we already have the lookup name of the default symtab, use it
instead of the fullname. [This fullname thing was originally added
in 2007 in a series dealing with *displaying* absolute file names.
Clearly, this instance has nothing to do with the display of file names.]

gdb/ChangeLog

PR symtab/23853
* linespec.c (create_sals_line_offset): Search for the default
symtab's filename instead of its fullname.

gdb/testsuite/ChangeLog

PR symtab/23853
* gdb.base/symlink-sourcefile.c: New file.
* gdb.base/symlink-sourcefile.exp: New file.

5 years agoExtend readelf and objdump so that they will display and follow multiple links to...
Nick Clifton [Fri, 22 Feb 2019 10:36:24 +0000 (10:36 +0000)]
Extend readelf and objdump so that they will display and follow multiple links to separate debug information files.

PR 23843
* dwarf.h (struct separate_info): New structure for containing
information on separate debug info files.
* dwarf.c (struct dwo_info): New structure for containing dwo
links.
(first_dwo_info): Chain of dwo_info structures.
(first_separate_file): Chain of separate_info structures.
(separate_debug_file, separate_debug_filename): Delete.
(fetch_alt_indirect_string): Scan all separate debug info files
for the requested string.
(add_dwo_info): New function.
(add_dwo_name): New function.
(add_dwo_dir): New function.
(add_dwo_id: New function.
(free_dwo_info): New function.
(read_and_display_attr_value): Store DWO data using the new
functions.
(load_debug_section_with_follow): If necessary, scan the list of
separate debug info files for the requested section.
(add_separate_debug_file): New function.
(load_separate_debug_info): Call add_separate_debug_file to store
the information on the newly loaded file.
(load_dwo_file): Likewise.
(load_separate_debif_file): Rename to load_separate_debug_files.
Change return type to boolean.  If following links then attempt to
load all separate debug info files, not just the first one.
(free_debug_memory): Release memory in dwo_info and separate_info
chains.
* objdump.c (dump_dwarf): Iterate over all loaded debg info files.
* readelf.c (process_object): Likewise.
* doc/debug.options.texi: Update descriptions of links and
follow-links options.
* testsuite/binutils-all/objdump.WK2: Update expected output.
* testsuite/binutils-all/readelf.k2: Likewise.
* NEWS: Announce the new feature.

5 years ago[arm][gas] Add support for Neoverse N1
Kyrylo Tkachov [Fri, 22 Feb 2019 09:59:05 +0000 (09:59 +0000)]
[arm][gas] Add support for Neoverse N1

This adds support for the Neoverse N1 CPU [1] to gas.
This was previously enabled under the Ares codename, which remains as
a valid option for -mcpu for compatibility reasons.

make check-gas passes on arm-none-eabi.

[1] https://community.arm.com/processors/b/blog/posts/arm-neoverse-n1-platform-accelerating-the-transformation-to-a-scalable-cloud-to-edge-infrastructure

2019-02-21  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

    * config/tc-arm.c (arm_cpus): Add neoverse-n1.
    * doc/c-arm.texi (-mcpu): Document neoverse-n1 value.

5 years ago[AArch64][gas] Add support for Neoverse E1
Kyrylo Tkachov [Fri, 22 Feb 2019 09:57:45 +0000 (09:57 +0000)]
[AArch64][gas] Add support for Neoverse E1

This adds support for the Neoverse E1 CPU [1] to gas.

make check-gas passes on aarch64-none-elf.

[1] https://community.arm.com/processors/b/blog/posts/arm-neoverse-e1-platform-empowering-the-infrastructure-to-meet-next-generation-throughput-demands

2019-02-21  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

    * config/tc-aarch64.c (aarch64_cpus): Add neoverse-e1.
    * doc/c-aarch64.texi (-mcpu): Document neoverse-e1 value.

5 years ago[AArch64][gas] Add support for Neoverse N1
Kyrylo Tkachov [Fri, 22 Feb 2019 09:56:50 +0000 (09:56 +0000)]
[AArch64][gas] Add support for Neoverse N1

This adds support for the Neoverse N1 [1] CPU to gas.
This was previously enabled under the Ares codename, which remains as
a valid option for -mcpu for compatibility reasons.

make check-gas passes on aarch64-none-elf.

[1] https://community.arm.com/processors/b/blog/posts/arm-neoverse-n1-platform-accelerating-the-transformation-to-a-scalable-cloud-to-edge-infrastructure

2019-02-21  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

    * config/tc-aarch64.c (aarch64_cpus): Add neoverse-n1.
    * doc/c-aarch64.texi (-mcpu): Document neoverse-n1 value.

5 years agoAutomatic date update in version.in
GDB Administrator [Fri, 22 Feb 2019 00:00:37 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoDocument style behavior in batch mode.
Alan Hayward [Thu, 21 Feb 2019 18:20:21 +0000 (18:20 +0000)]
Document style behavior in batch mode.

Style is disabled when running in batch mode.

gdb/ChangeLog:

* NEWS: Update style defaults.

gdb/doc/ChangeLog:

* gdb.texinfo: Update style defaults.

5 years agoFix typo in "show remotelogfile" docs
Tom Tromey [Thu, 21 Feb 2019 14:26:52 +0000 (07:26 -0700)]
Fix typo in "show remotelogfile" docs

I noticed a trailing "." in the @item for "show remotelogfile".
This removes it.  Committing as obvious.

gdb/doc/ChangeLog
2019-02-21  Tom Tromey  <tromey@adacore.com>

* gdb.texinfo (Remote Configuration): Remove trailing "." from
@item.

5 years agoDisable styling when running in batch mode
Alan Hayward [Thu, 21 Feb 2019 13:17:32 +0000 (13:17 +0000)]
Disable styling when running in batch mode

The GCC Guality testsuite within GCC compiles C/C++ files in GCC at
various optimization levels then debugs them in GDB, checking that
program values can be read.  This is done within the dejagnu framework.

The new style options in GDB have broken many of the tests due to the
testsuite being unable to process the new control characters.  The fix
in Guality is to either to improve the string matching or to disable
styling on the cli or init file (after checking gdb is recent enough
to support styling).

This fix will also need making an any other testsuites in the wild
that use GDB.

An alternative would be to automatically disable styling when using GDB
in batch mode.  The reasoning here is that batch mode is only used when
automating GDB and any output will be processed later either with text
processing tools or viewed in text editors, many of these will not
correctly handle the control characters by default.  This ensures GDB
continues to work as expected.  Anyone who explicitly wants styling in
batch mode can enable it either in the init file or adding to the batch
file - but that would not be the standard use case.

Patch simply disables style after reading the batch command flag, before
reading in the init file or batch file.

gdb/ChangeLog:

* main.c (captured_main_1): Disable styling in batch mode.

5 years agoFix illegal memory accesses by readelf when parsing corrupt IA64 unwind information.
Nick Clifton [Thu, 21 Feb 2019 10:54:12 +0000 (10:54 +0000)]
Fix illegal memory accesses by readelf when parsing corrupt IA64 unwind information.

PR 24247
* unwind-ia64.c: Include sysdep.h.
(unw_decode_x1): Check current pointer against end pointer before
accessing memory.
(unw_decode_x2): Likewise.
(unw_decode_x3): Likewise.
(unw_decode_x4): Likewise.
(unw_decode_r2): Likewise.
(unw_decode_p2_p5): Likewise.
(unw_decode_p7_p10): Likewise.
(unw_decode): Likewise.

5 years agoPowerPC __tls_get_addr arg parsing
Alan Modra [Thu, 21 Feb 2019 07:11:47 +0000 (17:41 +1030)]
PowerPC __tls_get_addr arg parsing

The syntax we ended up with for -m32 -fPIC calls to __tls_get_addr is
rather weird.
    bl __tls_get_addr+0x8000(gd0@tlsgd)@plt
This came about by accident, probably due to requiring the arg reloc
before the call reloc.

Of course the @plt really belongs with __tls_get_addr since it affects
the call rather than the call arg, and it isn't a great deal of
trouble to ensure the relocs are emitted in the correct order.  This
patch supports a newer syntax, like so:
    bl __tls_get_addr+0x8000@plt(gd0@tlsgd)

gas/
* config/tc-ppc.c (parse_tls_arg): New function, extracted..
(md_assembler): ..from here.  Call it after parsing other
suffix modifiers too.
ld/
* testsuite/ld-powerpc/tls32.s: Test new @plt syntax.

5 years agoAutomatic date update in version.in
GDB Administrator [Thu, 21 Feb 2019 00:00:40 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoFix typos in symtab_symbol_info
Tom Tromey [Fri, 8 Feb 2019 08:19:36 +0000 (01:19 -0700)]
Fix typos in symtab_symbol_info

symtab_symbol_info has a couple of messages that say "regulation
expression".  I think "regular expression" was meant, so this patch
changes it.

gdb/ChangeLog
2019-02-20  Tom Tromey  <tom@tromey.com>

* symtab.c (symtab_symbol_info): Fix typos.

gdb/testsuite/ChangeLog
2019-02-20  Tom Tromey  <tom@tromey.com>

* gdb.base/info_qt.exp: Update.

5 years agoFix potential illegal memory access by readelf when parsing a binary containing corru...
Nick Clifton [Wed, 20 Feb 2019 17:51:21 +0000 (17:51 +0000)]
Fix potential illegal memory access by readelf when parsing a binary containing corrupt system tap notes.

PR 24246
* readelf.c (print_stapsdt_note): Harden against corrupt notes.

5 years agoFix potential illegal memory access by readelf when parsing corrupt IA64 unwind infor...
Nick Clifton [Wed, 20 Feb 2019 17:25:33 +0000 (17:25 +0000)]
Fix potential illegal memory access by readelf when parsing corrupt IA64 unwind information.

PR 24244
* unwind-ia64.c (unw_decode_uleb128): Add end parameter, use it to
prevent walking off the end of the buffer.
(unw_decode_x1): Add end paramter, pass it to unw_decode_uleb128.
(unw_decode_x2): Likewise.
(unw_decode_x3): Likewise.
(unw_decode_x4): Likewise.
(unw_decode_r2): Pass the end parameter to unw_decode_uleb128.
(unw_decode_r3): Likewise.
(unw_decode_p7_p10): Likewise.
(unw_decode_b2): Likewise.
(unw_decode_b3_x4): Likewise.

5 years agoFix a illegal memory access fault when parsing a corrupt MIPS option section using...
Nick Clifton [Wed, 20 Feb 2019 17:03:47 +0000 (17:03 +0000)]
Fix a illegal memory access fault when parsing a corrupt MIPS option section using readelf.

PR 24243
* readelf.c (process_mips_specific): Check for an options section
that is too small to even contain a single option.

5 years agoHarden readelf's IA64 note display function so that it can handle corrupt notes.
Nick Clifton [Wed, 20 Feb 2019 15:35:06 +0000 (15:35 +0000)]
Harden readelf's IA64 note display function so that it can handle corrupt notes.

PR 24242
* readelf.c (print_ia64_vms_note): Harden against corrupt notes.

5 years agoUse upper case for metasyntactic variables in "help find"
Tom Tromey [Thu, 14 Feb 2019 14:58:58 +0000 (07:58 -0700)]
Use upper case for metasyntactic variables in "help find"

While answering a user's question on irc, I realized that the
metasyntactic variables in "help find" are not in upper case.  As you
know this is one of my pet quests, so here is a patch to fix this.
Tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-02-20  Tom Tromey  <tromey@adacore.com>

* findcmd.c (_initialize_mem_search): Use upper case for
metasyntactic variables.

5 years agoAArch64: Add default reggroups
Alan Hayward [Wed, 20 Feb 2019 11:56:23 +0000 (11:56 +0000)]
AArch64: Add default reggroups

AArch64 does not define any reggroups.  This causes "maintenance print
reggroups" to dump the default set (which is ok).

However, if a new group is added via an xml file, then this now becomes
the only group.

Fixes gdb.xml/tdesc-regs.exp on AArch64.

gdb/ChangeLog:

* aarch64-tdep.c (aarch64_add_reggroups): New function
(aarch64_gdbarch_init): Call aarch64_add_reggroups.

5 years agobfd: xtensa: fix callx relaxation
Max Filippov [Sat, 16 Feb 2019 00:43:23 +0000 (16:43 -0800)]
bfd: xtensa: fix callx relaxation

Big section alignment requirements between source and destination of a
long call can result in making call range bigger than what's reachable
by the call opcode. Add biggest section alignment of sections between
the call site and call destination to the call distance when making
long call relaxation decision.

2019-02-20  Eric Tsai  <erictsai@cadence.com>
bfd/
* elf32-xtensa.c (is_resolvable_asm_expansion): Scan output
sections between the call site and call destination and adjust
call distance by the largest alignment.

ld/
* testsuite/ld-xtensa/call_overflow.d: New test definition.
* testsuite/ld-xtensa/call_overflow1.s: New test source.
* testsuite/ld-xtensa/call_overflow2.s: New test source.
* testsuite/ld-xtensa/call_overflow3.s: New test source.
* testsuite/ld-xtensa/xtensa.exp: Add call_overflow test.

5 years agoAArch64: Add pauth core file section
Alan Hayward [Wed, 20 Feb 2019 10:39:28 +0000 (10:39 +0000)]
AArch64: Add pauth core file section

Used for the AArch64 pointer authentication code mask registers in Arm v8.3-a.

NT_ARM_PAC_MASK matches the value in Linux include/uapi/linux/elf.h

include/ChangeLog:

* elf/common.h (NT_ARM_PAC_MASK): Add define.

bfd/ChangeLog:

* elf-bfd.h (elfcore_write_aarch_pauth): Add declaration.
* elf.c (elfcore_grok_aarch_pauth): New function.
(elfcore_grok_note): Check for NT_ARM_PAC_MASK.
(elfcore_write_aarch_pauth): New function.
(elfcore_write_register_note): Check for AArch64 pauth section.

5 years agoCheck asprintf return value
Alan Modra [Wed, 20 Feb 2019 08:24:41 +0000 (18:54 +1030)]
Check asprintf return value

git a31b8bd9a05 introduced a warning (depending on your system
headers).

PR 24225
* elf32-nios2.c (nios2_elf32_relocate_section): Check asprintf
return value.

5 years agoUnsigned integer overflows in readelf checks
Alan Modra [Wed, 20 Feb 2019 07:52:50 +0000 (18:22 +1030)]
Unsigned integer overflows in readelf checks

PR 24132
PR 24138
* readelf.c (get_data): Avoid possibility of overflow when
checking for a read that may extend past end of file.
(process_program_headers): Likewise.

5 years agoUse or1k-darwin host SHARED_LIBADD for *-darwin.
Michael Roitzsch [Wed, 20 Feb 2019 04:17:40 +0000 (14:47 +1030)]
Use or1k-darwin host SHARED_LIBADD for *-darwin.

* configure.ac (SHARED_LIBADD): Add -liberty -lintl for all
Darwin hosts, not just or1k.
* configure: Regenerate.

5 years agoPR24233, Out of memory
Alan Modra [Wed, 20 Feb 2019 01:36:31 +0000 (12:06 +1030)]
PR24233, Out of memory

PR 24233
* objdump.c (dump_bfd_private_header): Print warning if
bfd_print_private_bfd_data returns false.

5 years agoFix error message and use-after-free on errors in nested sourced files
Simon Marchi [Wed, 20 Feb 2019 02:10:18 +0000 (21:10 -0500)]
Fix error message and use-after-free on errors in nested sourced files

Errors that happen in nested sourced files (when a sourced file sources
another file) lead to a wrong error message, or use-after-free.

For example, if I put this in "a.gdb":

    command_that_doesnt_exist

and this in "b.gdb":

   source a.gdb

and try to "source b.gdb" in GDB, the result may look like this:

    (gdb) source b.gdb
    b.gdb:1: Error in sourced command file:
    _that_doesnt_exist:1: Error in sourced command file:
    Undefined command: "command_that_doesnt_exist".  Try "help".

Notice the wrong file name where "a.gdb" should be.  The exact result
may differ, depending on the feelings of the memory allocator.

What happens is:

- The "source a.gdb" command is saved by command_line_append_input_line
  in command_line_input's static buffer.
- Since we are sourcing a file, the script_from_file function stores the
  script name (a.gdb) in the source_file_name global.  However, it doesn't
  do a copy, it just saves a pointer to command_line_input's static buffer.
- The "command_that_doesnt_exist" command is saved by
  command_line_append_input_line in command_line_input's static buffer.
  Depending on what xrealloc does, source_file_name may now point to
  freed memory, or at the minimum the data it was pointing to was
  overwritten.
- When the error is handled in script_from_file, we dererence
  source_file_name to print the name of the file in which the error
  occured.

To fix it, I made source_file_name an std::string, so that keeps a copy of
the file name instead of pointing to a buffer with a too small
lifetime.

With this patch, the expected filename is printed, and no use-after-free
occurs:

    (gdb) source b.gdb
    b.gdb:1: Error in sourced command file:
    a.gdb:1: Error in sourced command file:
    Undefined command: "command_that_doesnt_exist".  Try "help".

I passed explicit template parameters to make_scoped_restore
(<std::string, const std::string &>), so that the second parameter is
passed by reference and avoid a copy.

It was not as obvious as I first thought to change gdb.base/source.exp
to test this, because source commands inside sourced files are
interpreted relative to GDB's current working directory, not the
directory of the currently sourced file.  As a workaround, I moved the
snippet that tests errors after the snippet that adds the source
directory to the search path.  This way, the "source source-error-1.gdb"
line in source-error.exp manages to find the file.

For reference, here is what ASAN reports when use-after-free occurs:

(gdb) source b.gdb
=================================================================
==18498==ERROR: AddressSanitizer: heap-use-after-free on address 0x60c000019847 at pc 0x7f1d3645de8e bp 0x7ffdcb892e50 sp 0x7ffdcb8925c8
READ of size 6 at 0x60c000019847 thread T0
    #0 0x7f1d3645de8d in printf_common /build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors_format.inc:546
    #1 0x7f1d36477175 in __interceptor_vasprintf /build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:1525
    #2 0x5632eaffa277 in xstrvprintf(char const*, __va_list_tag*) /home/simark/src/binutils-gdb/gdb/common/common-utils.c:122
    #3 0x5632eaff96d1 in throw_it /home/simark/src/binutils-gdb/gdb/common/common-exceptions.c:351
    #4 0x5632eaff98df in throw_verror(errors, char const*, __va_list_tag*) /home/simark/src/binutils-gdb/gdb/common/common-exceptions.c:379
    #5 0x5632eaff9a2a in throw_error(errors, char const*, ...) /home/simark/src/binutils-gdb/gdb/common/common-exceptions.c:394
    #6 0x5632eafca21a in script_from_file(_IO_FILE*, char const*) /home/simark/src/binutils-gdb/gdb/cli/cli-script.c:1553
    #7 0x5632eaf8a500 in source_script_from_stream /home/simark/src/binutils-gdb/gdb/cli/cli-cmds.c:569
    #8 0x5632eaf8a735 in source_script_with_search /home/simark/src/binutils-gdb/gdb/cli/cli-cmds.c:605
    #9 0x5632eaf8ab20 in source_command /home/simark/src/binutils-gdb/gdb/cli/cli-cmds.c:664
    #10 0x5632eafa8b4a in do_const_cfunc /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:106
    #11 0x5632eafb0687 in cmd_func(cmd_list_element*, char const*, int) /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:1892
    #12 0x5632ebf3dd87 in execute_command(char const*, int) /home/simark/src/binutils-gdb/gdb/top.c:630
    #13 0x5632eb3b25d3 in command_handler(char const*) /home/simark/src/binutils-gdb/gdb/event-top.c:583
    #14 0x5632ebf3cf09 in read_command_file(_IO_FILE*) /home/simark/src/binutils-gdb/gdb/top.c:425
    #15 0x5632eafca054 in script_from_file(_IO_FILE*, char const*) /home/simark/src/binutils-gdb/gdb/cli/cli-script.c:1547
    #16 0x5632eaf8a500 in source_script_from_stream /home/simark/src/binutils-gdb/gdb/cli/cli-cmds.c:569
    #17 0x5632eaf8a735 in source_script_with_search /home/simark/src/binutils-gdb/gdb/cli/cli-cmds.c:605
    #18 0x5632eaf8ab20 in source_command /home/simark/src/binutils-gdb/gdb/cli/cli-cmds.c:664
    #19 0x5632eafa8b4a in do_const_cfunc /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:106
    #20 0x5632eafb0687 in cmd_func(cmd_list_element*, char const*, int) /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:1892
    #21 0x5632ebf3dd87 in execute_command(char const*, int) /home/simark/src/binutils-gdb/gdb/top.c:630
    #22 0x5632eb3b25d3 in command_handler(char const*) /home/simark/src/binutils-gdb/gdb/event-top.c:583
    #23 0x5632eb3b2f87 in command_line_handler(std::unique_ptr<char, gdb::xfree_deleter<char> >&&) /home/simark/src/binutils-gdb/gdb/event-top.c:770
    #24 0x5632eb3b0fe1 in gdb_rl_callback_handler /home/simark/src/binutils-gdb/gdb/event-top.c:213
    #25 0x5632ec1c8729 in rl_callback_read_char /home/simark/src/binutils-gdb/readline/callback.c:220
    #26 0x5632eb3b0b8f in gdb_rl_callback_read_char_wrapper_noexcept /home/simark/src/binutils-gdb/gdb/event-top.c:175
    #27 0x5632eb3b0da1 in gdb_rl_callback_read_char_wrapper /home/simark/src/binutils-gdb/gdb/event-top.c:192
    #28 0x5632eb3b2186 in stdin_event_handler(int, void*) /home/simark/src/binutils-gdb/gdb/event-top.c:511
    #29 0x5632eb3aa6a9 in handle_file_event /home/simark/src/binutils-gdb/gdb/event-loop.c:733
    #30 0x5632eb3aaf41 in gdb_wait_for_event /home/simark/src/binutils-gdb/gdb/event-loop.c:859
    #31 0x5632eb3a88ea in gdb_do_one_event() /home/simark/src/binutils-gdb/gdb/event-loop.c:347
    #32 0x5632eb3a89bf in start_event_loop() /home/simark/src/binutils-gdb/gdb/event-loop.c:371
    #33 0x5632eb76fbfc in captured_command_loop /home/simark/src/binutils-gdb/gdb/main.c:330
    #34 0x5632eb772ea8 in captured_main /home/simark/src/binutils-gdb/gdb/main.c:1176
    #35 0x5632eb773071 in gdb_main(captured_main_args*) /home/simark/src/binutils-gdb/gdb/main.c:1192
    #36 0x5632eabfe7f9 in main /home/simark/src/binutils-gdb/gdb/gdb.c:32
    #37 0x7f1d3554f222 in __libc_start_main (/usr/lib/libc.so.6+0x24222)
    #38 0x5632eabfe5dd in _start (/home/simark/build/binutils-gdb/gdb/gdb+0x195d5dd)

0x60c000019847 is located 7 bytes inside of 128-byte region [0x60c000019840,0x60c0000198c0)
freed by thread T0 here:
    #0 0x7f1d36502491 in __interceptor_realloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:105
    #1 0x5632eaff9f47 in xrealloc /home/simark/src/binutils-gdb/gdb/common/common-utils.c:62
    #2 0x5632eaff6b44 in buffer_grow(buffer*, char const*, unsigned long) /home/simark/src/binutils-gdb/gdb/common/buffer.c:40
    #3 0x5632eb3b271d in command_line_append_input_line /home/simark/src/binutils-gdb/gdb/event-top.c:614
    #4 0x5632eb3b28c6 in handle_line_of_input(buffer*, char const*, int, char const*) /home/simark/src/binutils-gdb/gdb/event-top.c:654
    #5 0x5632ebf402a6 in command_line_input(char const*, char const*) /home/simark/src/binutils-gdb/gdb/top.c:1252
    #6 0x5632ebf3cee9 in read_command_file(_IO_FILE*) /home/simark/src/binutils-gdb/gdb/top.c:422
    #7 0x5632eafca054 in script_from_file(_IO_FILE*, char const*) /home/simark/src/binutils-gdb/gdb/cli/cli-script.c:1547
    #8 0x5632eaf8a500 in source_script_from_stream /home/simark/src/binutils-gdb/gdb/cli/cli-cmds.c:569
    #9 0x5632eaf8a735 in source_script_with_search /home/simark/src/binutils-gdb/gdb/cli/cli-cmds.c:605
    #10 0x5632eaf8ab20 in source_command /home/simark/src/binutils-gdb/gdb/cli/cli-cmds.c:664
    #11 0x5632eafa8b4a in do_const_cfunc /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:106
    #12 0x5632eafb0687 in cmd_func(cmd_list_element*, char const*, int) /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:1892
    #13 0x5632ebf3dd87 in execute_command(char const*, int) /home/simark/src/binutils-gdb/gdb/top.c:630
    #14 0x5632eb3b25d3 in command_handler(char const*) /home/simark/src/binutils-gdb/gdb/event-top.c:583
    #15 0x5632ebf3cf09 in read_command_file(_IO_FILE*) /home/simark/src/binutils-gdb/gdb/top.c:425
    #16 0x5632eafca054 in script_from_file(_IO_FILE*, char const*) /home/simark/src/binutils-gdb/gdb/cli/cli-script.c:1547
    #17 0x5632eaf8a500 in source_script_from_stream /home/simark/src/binutils-gdb/gdb/cli/cli-cmds.c:569
    #18 0x5632eaf8a735 in source_script_with_search /home/simark/src/binutils-gdb/gdb/cli/cli-cmds.c:605
    #19 0x5632eaf8ab20 in source_command /home/simark/src/binutils-gdb/gdb/cli/cli-cmds.c:664
    #20 0x5632eafa8b4a in do_const_cfunc /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:106
    #21 0x5632eafb0687 in cmd_func(cmd_list_element*, char const*, int) /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:1892
    #22 0x5632ebf3dd87 in execute_command(char const*, int) /home/simark/src/binutils-gdb/gdb/top.c:630
    #23 0x5632eb3b25d3 in command_handler(char const*) /home/simark/src/binutils-gdb/gdb/event-top.c:583
    #24 0x5632eb3b2f87 in command_line_handler(std::unique_ptr<char, gdb::xfree_deleter<char> >&&) /home/simark/src/binutils-gdb/gdb/event-top.c:770
    #25 0x5632eb3b0fe1 in gdb_rl_callback_handler /home/simark/src/binutils-gdb/gdb/event-top.c:213
    #26 0x5632ec1c8729 in rl_callback_read_char /home/simark/src/binutils-gdb/readline/callback.c:220
    #27 0x5632eb3b0b8f in gdb_rl_callback_read_char_wrapper_noexcept /home/simark/src/binutils-gdb/gdb/event-top.c:175
    #28 0x5632eb3b0da1 in gdb_rl_callback_read_char_wrapper /home/simark/src/binutils-gdb/gdb/event-top.c:192
    #29 0x5632eb3b2186 in stdin_event_handler(int, void*) /home/simark/src/binutils-gdb/gdb/event-top.c:511

previously allocated by thread T0 here:
    #0 0x7f1d36502491 in __interceptor_realloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:105
    #1 0x5632eaff9f47 in xrealloc /home/simark/src/binutils-gdb/gdb/common/common-utils.c:62
    #2 0x5632eaff6b44 in buffer_grow(buffer*, char const*, unsigned long) /home/simark/src/binutils-gdb/gdb/common/buffer.c:40
    #3 0x5632eb3b271d in command_line_append_input_line /home/simark/src/binutils-gdb/gdb/event-top.c:614
    #4 0x5632eb3b28c6 in handle_line_of_input(buffer*, char const*, int, char const*) /home/simark/src/binutils-gdb/gdb/event-top.c:654
    #5 0x5632ebf402a6 in command_line_input(char const*, char const*) /home/simark/src/binutils-gdb/gdb/top.c:1252
    #6 0x5632ebf3cee9 in read_command_file(_IO_FILE*) /home/simark/src/binutils-gdb/gdb/top.c:422
    #7 0x5632eafca054 in script_from_file(_IO_FILE*, char const*) /home/simark/src/binutils-gdb/gdb/cli/cli-script.c:1547
    #8 0x5632eaf8a500 in source_script_from_stream /home/simark/src/binutils-gdb/gdb/cli/cli-cmds.c:569
    #9 0x5632eaf8a735 in source_script_with_search /home/simark/src/binutils-gdb/gdb/cli/cli-cmds.c:605
    #10 0x5632eaf8ab20 in source_command /home/simark/src/binutils-gdb/gdb/cli/cli-cmds.c:664
    #11 0x5632eafa8b4a in do_const_cfunc /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:106
    #12 0x5632eafb0687 in cmd_func(cmd_list_element*, char const*, int) /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:1892
    #13 0x5632ebf3dd87 in execute_command(char const*, int) /home/simark/src/binutils-gdb/gdb/top.c:630
    #14 0x5632eb3b25d3 in command_handler(char const*) /home/simark/src/binutils-gdb/gdb/event-top.c:583
    #15 0x5632eb3b2f87 in command_line_handler(std::unique_ptr<char, gdb::xfree_deleter<char> >&&) /home/simark/src/binutils-gdb/gdb/event-top.c:770
    #16 0x5632eb3b0fe1 in gdb_rl_callback_handler /home/simark/src/binutils-gdb/gdb/event-top.c:213
    #17 0x5632ec1c8729 in rl_callback_read_char /home/simark/src/binutils-gdb/readline/callback.c:220
    #18 0x5632eb3b0b8f in gdb_rl_callback_read_char_wrapper_noexcept /home/simark/src/binutils-gdb/gdb/event-top.c:175
    #19 0x5632eb3b0da1 in gdb_rl_callback_read_char_wrapper /home/simark/src/binutils-gdb/gdb/event-top.c:192
    #20 0x5632eb3b2186 in stdin_event_handler(int, void*) /home/simark/src/binutils-gdb/gdb/event-top.c:511
    #21 0x5632eb3aa6a9 in handle_file_event /home/simark/src/binutils-gdb/gdb/event-loop.c:733
    #22 0x5632eb3aaf41 in gdb_wait_for_event /home/simark/src/binutils-gdb/gdb/event-loop.c:859
    #23 0x5632eb3a88ea in gdb_do_one_event() /home/simark/src/binutils-gdb/gdb/event-loop.c:347
    #24 0x5632eb3a89bf in start_event_loop() /home/simark/src/binutils-gdb/gdb/event-loop.c:371
    #25 0x5632eb76fbfc in captured_command_loop /home/simark/src/binutils-gdb/gdb/main.c:330
    #26 0x5632eb772ea8 in captured_main /home/simark/src/binutils-gdb/gdb/main.c:1176
    #27 0x5632eb773071 in gdb_main(captured_main_args*) /home/simark/src/binutils-gdb/gdb/main.c:1192
    #28 0x5632eabfe7f9 in main /home/simark/src/binutils-gdb/gdb/gdb.c:32
    #29 0x7f1d3554f222 in __libc_start_main (/usr/lib/libc.so.6+0x24222)

SUMMARY: AddressSanitizer: heap-use-after-free /build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors_format.inc:546 in printf_common

gdb/ChangeLog:

* top.h (source_file_name): Change to std::string.
* top.c (source_file_name): Likewise.
(command_line_input): Adjust.
* cli/cli-script.c (script_from_file): Adjust.

gdb/testsuite/ChangeLog:

* gdb.base/source.exp: Move "error in sourced script" code to
the end.
* gdb.base/source-error.gdb: Move contents to
source-error-1.gdb.  Add new code to source source-error-1.gdb.
* gdb.base/source-error-1.gdb: New file, from previous
source-error.gdb.

5 years agoPR24236, Heap buffer overflow in _bfd_archive_64_bit_slurp_armap
Alan Modra [Tue, 19 Feb 2019 21:51:24 +0000 (08:21 +1030)]
PR24236, Heap buffer overflow in _bfd_archive_64_bit_slurp_armap

PR 24236
* archive64.c (_bfd_archive_64_bit_slurp_armap): Move code adding
sentinel NUL to string buffer nearer to loop where it is used.
Don't go past sentinel when scanning strings, and don't write
NUL again.
* archive.c (do_slurp_coff_armap): Simplify string handling to
archive64.c style.

5 years agoCheck whether symbols with MOVW_.ABS relocations require PLT entries (aarch64).
Egeyar Bagcioglu [Wed, 20 Feb 2019 00:12:44 +0000 (16:12 -0800)]
Check whether symbols with MOVW_.ABS relocations require PLT entries (aarch64).

2019-02-19  Egeyar Bagcioglu  <egeyar.bagcioglu@oracle.com>

gold/
     PR gold/23870
     * aarch64.cc (Target_aarch64::Scan::global): Check if a symbol with
     R_AARCH64_MOVW_.ABS_* relocations requires a PLT entry.
     * testsuite/Makefile.am: Add aarch64_pr23870 test case.
     * testsuite/Makefile.in: Regenerate.
     * testsuite/aarch64_pr23870_bar.c: New file.
     * testsuite/aarch64_pr23870_foo.c: New file.
     * testsuite/aarch64_pr23870_main.S: New file.

5 years agoAutomatic date update in version.in
GDB Administrator [Wed, 20 Feb 2019 00:00:41 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoMinor Ada task cleanups
Tom Tromey [Fri, 15 Feb 2019 21:05:38 +0000 (14:05 -0700)]
Minor Ada task cleanups

While working on the Ada task code, I noticed a few things that could
be cleaned up:

* task_list_valid_p was not set in all cases in ada_build_task_list.
  This causes many needless re-fetches of the task list.

* task_list_valid_p can be bool, and various functions can also return
  bool.

* Nothing checks the return value of read_known_tasks, so it can be
  changed to return void.

* The call to ada_build_task_list in
  ravenscar_thread_target::update_thread_list is redundant, because
  this is the first thing done by iterate_over_live_ada_tasks.

Tested using the internal AdaCore test suite against a ravenscar
target.

gdb/ChangeLog
2019-02-19  Tom Tromey  <tromey@adacore.com>

* ravenscar-thread.c
(ravenscar_thread_target::update_thread_list): Don't call
ada_build_task_list.
* ada-lang.h (ada_build_task_list): Don't declare.
* ada-tasks.c (struct ada_tasks_inferior_data)
<task_list_valid_p>: Now bool.
(read_known_tasks, ada_task_list_changed)
(ada_tasks_invalidate_inferior_data): Update.
(read_known_tasks_array): Return bool.
(read_known_tasks_list): Likewise.
(read_known_tasks): Return void.
(ada_build_task_list): Now static.

5 years agoFix a potential deadlock in some older Loongson 3A1000 MIPS processors.
Paul Hua [Tue, 19 Feb 2019 17:57:16 +0000 (17:57 +0000)]
Fix a potential deadlock in some older Loongson 3A1000 MIPS processors.

* NEWS: Mention -m[no-]fix-loongson3-llsc.
* configure.ac: Add --enable-mips-fix-loongson3-llsc.
Define DEFAULT_MIPS_FIX_LOONGSON3_LLSC.
* config.in: Regenerated.
* configure: Likewise.
* config/tc-mips.c (sync_insn, mips_fix_loongson3_llsc):
New variables.
(options): New OPTION_FIX_LOONGSON3_LLSC,
OPTION_NO_FIX_LOONGSON3_LLSC.
(md_longopts): Add -m[no-]fix-loongson3-llsc.
(md_begin): Initialize sync insn.
(fix_loongson3_llsc): New.
(append_insn): Call fix_loongson3_llsc.
(md_parse_option): Handle OPTION_FIX_LOONGSON3_LLSC,
OPTION_NO_FIX_LOONGSON3_LLSC.
(md_show_usage): Display -m[no-]fix-loongson3-llsc.
* doc/c-mips.texi: Document -m[no-]fix-loongson3-llsc,
--enable-mips-fix-loongson3-llsc=[yes|no].

5 years agoPR24235, Read memory violation in pei-x86_64.c
Alan Modra [Tue, 19 Feb 2019 12:18:44 +0000 (22:48 +1030)]
PR24235, Read memory violation in pei-x86_64.c

PR 24235
* pei-x86_64.c (pex64_bfd_print_pdata_section): Correct checks
attempting to prevent read past end of section.

5 years agoAutomatic date update in version.in
GDB Administrator [Tue, 19 Feb 2019 00:00:40 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agogdb: Allow gdbarch to override alignment for method and member pointers
Andrew Burgess [Mon, 18 Feb 2019 18:10:09 +0000 (18:10 +0000)]
gdb: Allow gdbarch to override alignment for method and member pointers

The code in type_align (gdbtypes.c) currently hard-codes the rules for
aligning method and member pointers.  It would seem better to forward
these types through the gdbarch hook, so that an architecture could
override the alignment of these types if needed.

Only 3 architectures currently override the gdbarch alignment hook,
these are arc, i386, and nio2.

For arc and nios the alignment rules are that alignment is the minimum
of 4-bytes and the type length.  As pointers are 4-bytes on these
targets, then (assuming method and members pointers are also 4-bytes)
there should be no change to the alignment after this patch.

For i386 the gdbarch alignment hook overrides for some INT and FLOAT
types only.  For method and member pointers we align on the type size
still, so there should be no change to the alignment after this patch.

I tested this on x86-64 GNU Linux with no regressions.

gdb/ChangeLog:

* gdbtypes.c (type_align): Allow alignment of TYPE_CODE_METHODPTR
and TYPE_CODE_MEMBERPTR to be overridden by the gdbarch.

5 years agoFix leaks of 'per program space' and 'per inferior' ada task data.
Philippe Waroquiers [Sun, 17 Feb 2019 16:58:17 +0000 (17:58 +0100)]
Fix leaks of 'per program space' and 'per inferior' ada task data.

Valgrind reports leaks such as the below.
Fix these leaks by changing ada_tasks_pspace_data_handle
and ada_tasks_inferior_data_handle to use the 'with_cleanup' register variant.

Tested on debian/amd64 natively and under Valgrind.

==26346== 56 bytes in 1 blocks are definitely lost in loss record 631 of 3,249
==26346==    at 0x4C2C4CC: operator new(unsigned long) (vg_replace_malloc.c:344)
==26346==    by 0x38F911: get_ada_tasks_inferior_data(inferior*) (ada-tasks.c:281)
==26346==    by 0x38FA3F: ada_tasks_invalidate_inferior_data (ada-tasks.c:1362)
==26346==    by 0x38FA3F: ada_tasks_new_objfile_observer(objfile*) (ada-tasks.c:1411)
==26346==    by 0x60CBC5: operator() (functional:2127)
==26346==    by 0x60CBC5: notify (observable.h:106)
==26346==    by 0x60CBC5: clear_symtab_users(enum_flags<symfile_add_flag>) (symfile.c:2903)
...

==26346== 104 bytes in 1 blocks are definitely lost in loss record 984 of 3,249
==26346==    at 0x4C2E0BC: calloc (vg_replace_malloc.c:762)
==26346==    by 0x4056F0: xcalloc (common-utils.c:84)
==26346==    by 0x38F8AE: xcnew<ada_tasks_pspace_data> (poison.h:122)
==26346==    by 0x38F8AE: get_ada_tasks_pspace_data(program_space*) (ada-tasks.c:253)
==26346==    by 0x38FA77: ada_tasks_invalidate_pspace_data (ada-tasks.c:1354)
==26346==    by 0x38FA77: ada_tasks_new_objfile_observer(objfile*) (ada-tasks.c:1394)
==26346==    by 0x60CBC5: operator() (functional:2127)
==26346==    by 0x60CBC5: notify (observable.h:106)
...

gdb/ChangeLog
2019-02-18  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* ada-task.c (_initialize_tasks): Use 'with_cleanup' register
variant for ada_tasks_pspace_data_handle and
ada_tasks_inferior_data_handle.
(ada_tasks_pspace_data_cleanup): New function.
(ada_tasks_inferior_data_cleanup): New function.

5 years agoPR24225, nios2 buffer overflow
Alan Modra [Mon, 18 Feb 2019 01:27:22 +0000 (11:57 +1030)]
PR24225, nios2 buffer overflow

PR 24225
* elf32-nios2.c (nios2_elf32_relocate_section): Use asprintf and
PRIx64 to generate warning messages.  Print local sym names too.