GDB Administrator [Tue, 26 Sep 2017 00:00:21 +0000 (00:00 +0000)]
Automatic date update in version.in
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.
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.
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.
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.
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.
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.
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.
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.
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'.
GDB Administrator [Mon, 25 Sep 2017 00:00:24 +0000 (00:00 +0000)]
Automatic date update in version.in
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.
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.
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.
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.
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.
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.
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.
GDB Administrator [Sun, 24 Sep 2017 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in
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.
GDB Administrator [Sat, 23 Sep 2017 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in
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>
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.
H.J. Lu [Fri, 22 Sep 2017 21:09:56 +0000 (14:09 -0700)]
Update ChangeLog entry for PR 22163
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
GDB Administrator [Fri, 22 Sep 2017 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Nick Clifton [Thu, 21 Sep 2017 08:04:43 +0000 (09:04 +0100)]
oops - changelog entry omitted from previous delta
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.
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.
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.
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.
GDB Administrator [Thu, 21 Sep 2017 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in
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'.
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.
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.
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.
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.
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.
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.
Walfred Tedeschi [Wed, 20 Sep 2017 12:47:04 +0000 (14:47 +0200)]
add ChangeLog from previous commit
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
Alan Modra [Tue, 19 Sep 2017 23:47:56 +0000 (09:17 +0930)]
[GOLD] PowerPC function address in non-PIC
ppc32, like many targets, defines the address of a function as the PLT
call stub code for functions referenced but not defined in a non-PIC
executable. ppc32 gold, unlike other targets, inherits the ppc64
multiple stub capability for dealing with very large binaries where
one set of stubs can't be reached from all code locations. This means
there can be multiple choices of address for a function, which might
cause function pointer comparison failures. So for ppc32, make
non-branch references always use the first stub group.
(PowerPC64 ELFv1 is always PIC so doesn't need to define the address
of an external function as the PLT stub. PowerPC64 ELFv2 needs a
special set of global entry stubs to serve as the address of external
functions, so it too is not affected by this bug.)
* powerpc.cc (Target_powerpc::Branch_info::make_stub): Put
stubs for ppc32 non-branch relocs in first stub table.
(Target_powerpc::Relocate::relocate): Resolve similarly.
GDB Administrator [Wed, 20 Sep 2017 00:00:30 +0000 (00:00 +0000)]
Automatic date update in version.in
John Baldwin [Mon, 11 Sep 2017 21:57:37 +0000 (14:57 -0700)]
Add a 'starti' command.
This works like 'start' but it stops at the first instruction rather
than the first line in main(). This is useful if one wants to single
step through runtime linker startup.
While here, introduce a RUN_ARGS_HELP macro for shared help text
between run, start, and starti. This includes expanding the help for
start and starti to include details from run's help text.
gdb/ChangeLog:
* NEWS (Changes since GDB 8.0): Add starti.
* infcmd.c (enum run_break): New.
(run_command_1): Queue pending event for RUN_STOP_AT_FIRST_INSN
case.
(run_command): Use enum run_how.
(start_command): Likewise.
(starti_command): New function.
(RUN_ARGS_HELP): New macro.
(_initialize_infcmd): Use RUN_ARGS_HELP for run and start
commands. Add starti command.
gdb/doc/ChangeLog:
* gdb.texinfo (Starting your Program): Add description of
starti command. Mention starti command as an alternative for
debugging the elaboration phase.
gdb/testsuite/ChangeLog:
* gdb.base/starti.c: New file.
* gdb.base/starti.exp: New file.
* lib/gdb.exp (gdb_starti_cmd): New procedure.
Maciej W. Rozycki [Tue, 19 Sep 2017 14:20:41 +0000 (15:20 +0100)]
MIPS/LD: Add OpenBSD/mips64 support
Complement commit
26eebcf553d7 ("Update OpenBSD/mips64 support"),
<https://sourceware.org/ml/binutils/2005-04/msg00382.html>, which added
OpenBSD/mips64 support to GAS, and also add it to LD, avoiding a build
failure at the configuration stage, like:
*** ld does not support target mips64-unknown-openbsd
*** see ld/configure.tgt for supported targets
make[1]: *** [configure-ld] Error 1
As per OS support only include n64 MIPS emulations, and use the
traditional ones, matching the choice already made with the addition of
GAS support.
ld/
* configure.tgt <mips64el-*-openbsd*, mips64-*-openbsd*>: New
targets.
Yao Qi [Tue, 19 Sep 2017 09:18:57 +0000 (10:18 +0100)]
Remove one explicit rule for monitor.o
gdb/monitor.c was removed by 40e0b27 (Delete the remaining ROM monitor
targets).
gdb:
2017-09-19 Yao Qi <yao.qi@linaro.org>
* Makefile.in (monitor.o): Remove the rule.
Yao Qi [Tue, 19 Sep 2017 09:10:03 +0000 (10:10 +0100)]
Use DISABLE_COPY_AND_ASSIGN
We have many classes that copy cotr and assignment operator are deleted,
so this patch replaces these existing mechanical code with macro
DISABLE_COPY_AND_ASSIGN.
gdb:
2017-09-19 Yao Qi <yao.qi@linaro.org>
* annotate.h (struct annotate_arg_emitter): Use
DISABLE_COPY_AND_ASSIGN.
* common/refcounted-object.h (refcounted_object): Likewise.
* completer.h (struct completion_result): Likewise.
* dwarf2read.c (struct dwarf2_per_objfile): Likewise.
* filename-seen-cache.h (filename_seen_cache): Likewise.
* gdbcore.h (thread_section_name): Likewise.
* gdb_regex.h (compiled_regex): Likewise.
* gdbthread.h (scoped_restore_current_thread): Likewise.
* inferior.h (scoped_restore_current_inferior): Likewise.
* jit.c (jit_reader): Likewise.
* linespec.h (struct linespec_result): Likewise.
* mi/mi-parse.h (struct mi_parse): Likewise.
* nat/fork-inferior.c (execv_argv): Likewise.
* progspace.h (scoped_restore_current_program_space): Likewise.
* python/python-internal.h (class gdbpy_enter): Likewise.
* regcache.h (regcache): Likewise.
* target-descriptions.c (struct tdesc_reg): Likewise.
(struct tdesc_type): Likewise.
(struct tdesc_feature): Likewise.
* ui-out.h (ui_out_emit_type): Likewise.
Alan Modra [Tue, 19 Sep 2017 03:52:49 +0000 (13:22 +0930)]
PowerPC64 stubs don't match calculated size
After the PR 21411 fix, the linker generated .eh_frame for ppc64 glink
can be edited by the generic code. The sequence of events goes
something like:
1) Some object file adds .eh_frame aligned to 8, making the output
.eh_frame aligned to at least 8, so linker generated .eh_frame FDE
is padded to an 8 byte boundary.
2) All .eh_frame past the glink .eh_frame is garbage collected.
3) Generic code detects that last FDE (the glink .eh_frame) doesn't
need to be padded to an 8 byte boundary, reducing size from 88 to
84.
4) elf64-ppc.c check fails.
PR 21441
* elf64-ppc.c (ppc64_elf_build_stubs): Don't check glink_eh_frame
size.
Alan Modra [Tue, 19 Sep 2017 02:29:30 +0000 (11:59 +0930)]
PR22150, ld keeps a version reference for gc'd symbols
elf_gc_sweep_symbol should run after verdefs are calculated, since
the verdef code creates symbols for the versions. However,
elf_gc_sweep_symbol needs to run before verrefs so as to not emit
useless verrefs for symbols that are gc'd.
I've also removed a _bfd_elf_link_renumber_dynsyms calls added by
Maciej after I fussed about it when reviewing. On further examination
the call appears to be unnecessary. Looking at renumber_dynsyms also
made me realize that the test to exclude .gnu.version has been wrong
since 2016-04-26 (git commit
d5486c4372), so fix that too.
PR 22150
* elflink.c (bfd_elf_size_dynamic_sections): Garbage collect
symbols before calculating verrefs. Don't renumber dynsyms
after gc. Exclude .gnu.version when zero or one dynsym.
Localize some vars and reindent.
Alan Modra [Tue, 19 Sep 2017 02:15:51 +0000 (11:45 +0930)]
[GOLD, PowerPC] Add --no-stub-group-multi
The trouble with stubs per output section is that ppc32 uses a plt
stub as the address of a global function. This needs to be unique,
otherwise we'll get multiple addresses for a function.
Obviously this is only a partial solution, since ppc32 will get
multiple stubs when code is larger than 33M. A proper fix will
involve selecting a unique stub to use for non-branch relocs.
* options.h (stub-group-multi): Default to true. Add
--no-stub-group-multi.
GDB Administrator [Tue, 19 Sep 2017 00:00:29 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Mon, 18 Sep 2017 20:05:25 +0000 (13:05 -0700)]
Check error return from bfd_canonicalize_dynamic_reloc
Since bfd_canonicalize_dynamic_reloc returns -1 on error, check it in
_bfd_x86_elf_get_synthetic_symtab.
PR ld/22148
* elfxx-x86.c (_bfd_x86_elf_get_synthetic_symtab): Check error
return from bfd_canonicalize_dynamic_reloc.
Simon Marchi [Mon, 18 Sep 2017 11:09:20 +0000 (13:09 +0200)]
dwarf2expr: Remove unused abort_expression label in execute_stack_op
The label abort_expression is unused, so remove it.
gdb/ChangeLog:
* dwarf2expr.c (dwarf_expr_context::execute_stack_op): Remove
label abort_expression.
Nick Clifton [Mon, 18 Sep 2017 08:21:38 +0000 (09:21 +0100)]
[PATCH] Sync libiberty/ & include/ with GCC - addendum: update elfcpp/dwarf.h with the new DW_CFA_DUP macro.
From the original email:
Note this brings in the interface files for libcc1/G++ as well, which
we will be needing in GDB soon anyway. That commit renamed a method
in the C interface and that required a small update to GDB's compile/
code, which I've included that in this patch to keep the tree
building.
From the follow up email:
That breaks gold:
g++ -DHAVE_CONFIG_H -I. -I../../binutils/gold -I../../binutils/gold -I../../binutils/gold/../include -I../../binutils/gold/../elfcpp -DLOCALEDIR="\"/usr/share/locale\"" -DBINDIR="\"/usr/bin\"" -DTOOLBINDIR="\"/usr/x86_64-linux/bin\"" -DTOOLLIBDIR="\"/usr/x86_64-linux/lib\"" -W -Wall -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -frandom-seed=dwarf_reader.o -O2 -g -MT dwarf_reader.o -MD -MP -MF .deps/dwarf_reader.Tpo -c -o dwarf_reader.o ../../binutils/gold/dwarf_reader.cc
In file included from ../../binutils/gold/../elfcpp/dwarf.h:83:0,
from ../../binutils/gold/dwarf_reader.cc:30:
../../binutils/gold/../include/dwarf2.def:781:1: error: expected ?}? before ?DW_CFA_DUP?
DW_CFA_DUP (DW_CFA_AARCH64_negate_ra_state, 0x2d)
GDB Administrator [Mon, 18 Sep 2017 00:00:30 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 17 Sep 2017 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Sat, 16 Sep 2017 12:22:11 +0000 (14:22 +0200)]
Refactor handle_qxfer_libraries and friends to use std::string
Using std::string in handle_qxfer_libraries and friends allow to
simplify the code. We don't have to manually free the buffer, and we
don't have to pre-compute the required space.
gdb/gdbserver/ChangeLog:
* server.c (accumulate_file_name_length): Remove.
(emit_dll_description): Adjust to std::string change.
(handle_qxfer_libraries): Use std::string to hold document.
Simon Marchi [Sat, 16 Sep 2017 12:19:31 +0000 (14:19 +0200)]
Make xml_escape_text return an std::string
This is a simple replacement, it allows removing some manual free'ing in
the callers.
gdb/ChangeLog:
* common/buffer.c (buffer_xml_printf): Adjust.
* common/xml-utils.c (xml_escape_text): Change return type to
std::string, update code accordingly.
* common/xml-utils.h (xml_escape_text): Change return type to
std::string.
* rs6000-aix-tdep.c (rs6000_aix_shared_library_to_xml): Adjust.
* windows-tdep.c (windows_xfer_shared_library): Adjust.
* unittests/xml-utils-selftests.c (test_xml_escape_text):
Adjust.
gdb/gdbserver/ChangeLog:
* linux-low.c (linux_qxfer_libraries_svr4): Adjust to change of
return type of xml_escape_text.
* server.c (emit_dll_description): Likewise.
Simon Marchi [Sat, 16 Sep 2017 12:16:27 +0000 (14:16 +0200)]
Add unit test for xml_escape_text
The following patch modifies xml_escape_text, so I took the opportunity
to write a unit test for it.
gdb/ChangeLog:
* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add new source file.
(SUBDIR_UNITTESTS_OBS): Add new object file.
* unittests/xml-utils-selftests.c: New file.
Simon Marchi [Sat, 16 Sep 2017 12:06:03 +0000 (14:06 +0200)]
Add selftests run filtering
With the growing number of selftests, I think it would be useful to be
able to run only a subset of the tests. This patch associates a name to
each registered selftest. It then allows doing something like:
(gdb) maintenance selftest aarch64
Running self-tests.
Running selftest aarch64-analyze-prologue.
Running selftest aarch64-process-record.
Ran 2 unit tests, 0 failed
or with gdbserver:
./gdbserver --selftest=aarch64
In both cases, only the tests that contain "aarch64" in their name are
ran. To help validate that the tests you want to run were actually ran,
it also prints a message with the test name before running each test.
Right now, all the arch-dependent tests are registered as a single test
of the selftests. To be able to filter those too, I made them
"first-class citizen" selftests. The selftest type is an interface,
with different implementations for "simple selftests" and "arch
selftests". The run_tests function simply iterates on that an invokes
operator() on each test.
I changed the tests data structure from a vector to a map, because
- it allows iterating in a stable (alphabetical) order
- it allows to easily verify if a test with a given name has been
registered, to avoid duplicates
There's also a new command "maintenance info selftests" that lists the
registered selftests.
gdb/ChangeLog:
* common/selftest.h (selftest): New struct/interface.
(register_test): Add name parameter, add new overload.
(run_tests): Add filter parameter.
(for_each_selftest_ftype): New typedef.
(for_each_selftest): New declaration.
* common/selftest.c (tests): Change type to
map<string, unique_ptr<selftest>>.
(simple_selftest): New struct.
(register_test): New function.
(register_test): Add name parameter and use it.
(run_tests): Add filter parameter and use it. Add prints.
Adjust to vector -> map change.
* aarch64-tdep.c (_initialize_aarch64_tdep): Add names when
registering selftests.
* arm-tdep.c (_initialize_arm_tdep): Likewise.
* disasm-selftests.c (_initialize_disasm_selftests): Likewise.
* dwarf2-frame.c (_initialize_dwarf2_frame): Likewise.
* dwarf2loc.c (_initialize_dwarf2loc): Likewise.
* findvar.c (_initialize_findvar): Likewise.
* gdbarch-selftests.c (_initialize_gdbarch_selftests): Likewise.
* maint.c (maintenance_selftest): Update call to run_tests.
(maintenance_info_selftests): New function.
(_initialize_maint_cmds): Register "maintenance info selftests"
command. Update "maintenance selftest" doc.
* regcache.c (_initialize_regcache): Add names when registering
selftests.
* rust-exp.y (_initialize_rust_exp): Likewise.
* selftest-arch.c (gdbarch_selftest): New struct.
(gdbarch_tests): Remove.
(register_test_foreach_arch): Add name parameter. Call
register_test.
(tests_with_arch): Remove, move most content to
gdbarch_selftest::operator().
(_initialize_selftests_foreach_arch): Remove.
* selftest-arch.h (register_test_foreach_arch): Add name
parameter.
(run_tests_with_arch): New declaration.
* utils-selftests.c (_initialize_utils_selftests): Add names
when registering selftests.
* utils.c (_initialize_utils): Likewise.
* unittests/array-view-selftests.c
(_initialize_array_view_selftests): Likewise.
* unittests/environ-selftests.c (_initialize_environ_selftests):
Likewise.
* unittests/function-view-selftests.c
(_initialize_function_view_selftests): Likewise.
* unittests/offset-type-selftests.c
(_initialize_offset_type_selftests): Likewise.
* unittests/optional-selftests.c
(_initialize_optional_selftests): Likewise.
* unittests/scoped_restore-selftests.c
(_initialize_scoped_restore_selftests): Likewise.
* NEWS: Document "maintenance selftest" and "maint info
selftests".
gdb/gdbserver/ChangeLog:
* server.c (captured_main): Accept argument for --selftest.
Update run_tests call.
* linux-x86-tdesc-selftest.c (initialize_low_tdesc): Add names
when registering selftests.
gdb/doc/ChangeLog:
* gdb.texinfo (Maintenance Commands): Document filter parameter
of "maint selftest". Document "maint info selftests" command.
Simon Marchi [Sat, 16 Sep 2017 11:45:56 +0000 (13:45 +0200)]
mi_load_progress: Restore current_uiout using a scoped_restore
Simply use a scoped_restore instead of manually saving and restoring
current_uiout.
gdb/ChangeLog:
* mi/mi-main.c (mi_load_progress): Restore current_uiout using a
scoped_restore.
Simon Marchi [Sat, 16 Sep 2017 11:45:55 +0000 (13:45 +0200)]
mi_load_progress: Use unique_ptr to manage ui_out lifetime
In mi_load_progress, we xfree a ui_out object. Because ui_out is not
trivially destructible, it should be freed with delete. This patch
makes use of a unique_ptr to do it.
gdb/ChangeLog:
* mi/mi-main.c (mi_load_progress): Make uiout variable
a unique_ptr.
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 0ee2605..0359dc1
100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -2325,7 +2325,6
@@ mi_load_progress (const char *section_name, static char
*previous_sect_name = NULL; int new_section; struct ui_out *saved_uiout;
- struct ui_out *uiout; struct mi_interp *mi = (struct mi_interp *)
current_interpreter ();
/* This function is called through deprecated_show_load_progress
@@ -2333,17 +2332,19 @@ mi_load_progress (const char *section_name,
of this function. */
saved_uiout = current_uiout;
+ std::unique_ptr<ui_out> uiout;
+
if (current_interp_named_p (INTERP_MI)
|| current_interp_named_p (INTERP_MI2))
- current_uiout = mi_out_new (2);
+ uiout.reset (mi_out_new (2));
else if (current_interp_named_p (INTERP_MI1))
- current_uiout = mi_out_new (1);
+ uiout.reset (mi_out_new (1));
else if (current_interp_named_p (INTERP_MI3))
- current_uiout = mi_out_new (3);
+ uiout.reset (mi_out_new (3));
else
return;
- uiout = current_uiout;
+ current_uiout = uiout.get ();
new_section = (previous_sect_name ?
strcmp (previous_sect_name, section_name) : 1);
@@ -2356,12 +2357,12 @@ mi_load_progress (const char *section_name,
fputs_unfiltered (current_token, mi->raw_stdout);
fputs_unfiltered ("+download", mi->raw_stdout);
{
- ui_out_emit_tuple tuple_emitter (uiout, NULL);
+ ui_out_emit_tuple tuple_emitter (uiout.get (), NULL);
uiout->field_string ("section", section_name);
uiout->field_int ("section-size", total_section);
uiout->field_int ("total-size", grand_total);
}
- mi_out_put (uiout, mi->raw_stdout);
+ mi_out_put (uiout.get (), mi->raw_stdout);
fputs_unfiltered ("\n", mi->raw_stdout);
gdb_flush (mi->raw_stdout);
}
@@ -2374,19 +2375,18 @@ mi_load_progress (const char *section_name,
fputs_unfiltered (current_token, mi->raw_stdout);
fputs_unfiltered ("+download", mi->raw_stdout);
{
- ui_out_emit_tuple tuple_emitter (uiout, NULL);
+ ui_out_emit_tuple tuple_emitter (uiout.get (), NULL);
uiout->field_string ("section", section_name);
uiout->field_int ("section-sent", sent_so_far);
uiout->field_int ("section-size", total_section);
uiout->field_int ("total-sent", total_sent);
uiout->field_int ("total-size", grand_total);
}
- mi_out_put (uiout, mi->raw_stdout);
+ mi_out_put (uiout.get (), mi->raw_stdout);
fputs_unfiltered ("\n", mi->raw_stdout);
gdb_flush (mi->raw_stdout);
}
- xfree (uiout);
current_uiout = saved_uiout;
}
Sergio Durigan Junior [Sun, 10 Sep 2017 16:17:18 +0000 (12:17 -0400)]
Use std::vector on tdesc->reg_defs (gdbserver/tdesc.h)
This is a followup patch to the build breakage fix on AArch64. While
doing the fix, I found it better to convert tdesc->reg_defs (on
gdbserver/tdesc.h) from using VEC to using std::vector. This makes
the code easier to read and maintain, and also is one more step
towards the C++fication.
Regtested on BuildBot.
2017-09-16 Sergio Durigan Junior <sergiodj@redhat.com>
* regcache.c (get_thread_regcache): Update code to use "std::vector"
instead of "VEC" for "target_desc.reg_defs".
(regcache_cpy): Likewise.
(registers_to_string): Likewise.
(registers_from_string): Likewise.
(find_regno): Likewise.
(supply_regblock): Likewise.
(regcache_raw_read_unsigned): Likewise.
* tdesc.c (init_target_desc): Likewise.
(tdesc_create_reg): Likewise.
* tdesc.h: Remove declaration of "tdesc_reg_p". Include <vector>.
(struct target_desc) <reg_defs>: Convert to "std::vector".
(target_desc): Do not initialize "reg_defs".
(~target_desc): Update code to use "std::vector" instead of "VEC"
for "target_desc.reg_defs".
(operator==): Likewise.
GDB Administrator [Sat, 16 Sep 2017 00:00:34 +0000 (00:00 +0000)]
Automatic date update in version.in
Pedro Alves [Fri, 15 Sep 2017 16:40:33 +0000 (17:40 +0100)]
Sync libiberty/ & include/ with GCC
Note this brings in the interface files for libcc1/G++ as well, which
we will be needing in GDB soon anyway. That commit renamed a method
in the C interface and that required a small update to GDB's compile/
code, which I've included that in this patch to keep the tree
building.
include/ChangeLog:
2017-09-15 Pedro Alves <palves@redhat.com>
* ansidecl.h (DISABLE_COPY_AND_ASSIGN): New macro.
2017-09-12 Jiong Wang <jiong.wang@arm.com>
* dwarf2.def (DW_CFA_AARCH64_negate_ra_state): New DW_CFA_DUP.
* dwarf2.h (DW_CFA_DUP): New define.
2017-08-21 Richard Biener <rguenther@suse.de>
* simple-object.h (simple_object_copy_lto_debug_sections): New
function.
2017-05-18 Martin Liska <mliska@suse.cz>
* ansidecl.h: Define CONSTEXPR macro.
2017-05-24 Nathan Sidwell <nathan@acm.org>
* libiberty.h (ASTRDUP): Adjust cast to avoid warning.
2017-01-30 Alexandre Oliva <aoliva@redhat.com>
Introduce C++ support in libcc1.
* gcc-c-fe.def (int_type_v0): Rename from...
(int_type): ... this. Introduce new version.
(float_type_v0): Rename from...
(float_type): ... this. Introduce new version.
(char_type): New.
* gcc-c-interface.h (gcc_c_api_version): Add GCC_C_FE_VERSION_1.
(gcc_type_array): Move...
* gcc-interface.h: ... here.
* gcc-cp-fe.def: New.
* gcc-cp-interface.h: New.
2016-04-29 Oleg Endo <olegendo@gcc.gnu.org>
* longlong.h (umul_ppmm): Remove SHMEDIA checks.
(__umulsidi3, count_leading_zeros): Remove SHMEDIA implementations.
2017-09-15 Yao Qi <yao.qi@linaro.org>
Pedro Alves <palves@redhat.com>
* ansidecl.h (DISABLE_COPY_AND_ASSIGN): New macro.
2017-09-12 Jiong Wang <jiong.wang@arm.com>
* dwarf2.def (DW_CFA_AARCH64_negate_ra_state): New DW_CFA_DUP.
* dwarf2.h (DW_CFA_DUP): New define.
2017-08-21 Richard Biener <rguenther@suse.de>
* simple-object.h (simple_object_copy_lto_debug_sections): New
function.
2017-05-18 Martin Liska <mliska@suse.cz>
* ansidecl.h: Define CONSTEXPR macro.
2017-05-24 Nathan Sidwell <nathan@acm.org>
* libiberty.h (ASTRDUP): Adjust cast to avoid warning.
2017-01-30 Alexandre Oliva <aoliva@redhat.com>
Introduce C++ support in libcc1.
* gcc-c-fe.def (int_type_v0): Rename from...
(int_type): ... this. Introduce new version.
(float_type_v0): Rename from...
(float_type): ... this. Introduce new version.
(char_type): New.
* gcc-c-interface.h (gcc_c_api_version): Add GCC_C_FE_VERSION_1.
(gcc_type_array): Move...
* gcc-interface.h: ... here.
* gcc-cp-fe.def: New.
* gcc-cp-interface.h: New.
2016-04-29 Oleg Endo <olegendo@gcc.gnu.org>
* longlong.h (umul_ppmm): Remove SHMEDIA checks.
(__umulsidi3, count_leading_zeros): Remove SHMEDIA implementations.
libiberty/ChangeLog:
2017-09-15 Nathan Sidwell <nathan@acm.org>
PR demangler/82195
* cp-demangle.c (d_name): Add 'toplevel' parm. Pass to ...
(d_local_name): ... here. Parse trailing function args on nested
local_name.
(d_encoding, d_special_name, d_class_enum_type): Adjust d_name calls.
* testsuite/demangle-expected: Add tests.
2017-09-15 Richard Biener <rguenther@suse.de>
PR lto/81968
* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
Iterate marking dependent sections necessary.
2017-09-15 Nathan Sidwell <nathan@acm.org>
* cp-demangle.c (is_fnqual_component_type): Reimplement using
FNQUAL_COMPONENT_CASE.
(d_encoding): Hold bare_function_type in local var.
(d_local_name): Build name in both cases and build result once.
Collapse switch-if to single conditional.
(d_local_name):
* testsuite/demangle-expected: Realign blank lines with tests.
2017-09-12 Jiong Wang <jiong.wang@arm.com>
* dwarfnames.c (DW_CFA_DUP): New define.
gdb/ChangeLog:
2017-09-15 Pedro Alves <palves@redhat.com>
* compile/compile-c-types.c (convert_enum, convert_int)
(convert_float): Adjust to refer to int_type_v0 and float_type_v0.
Simon Marchi [Fri, 15 Sep 2017 16:02:51 +0000 (18:02 +0200)]
gdbserver: Remove thread_to_gdb_id
As explained in the previous patch, the gdb_id concept is no longer
relevant. The function thread_to_gdb_id is trivial, it returns the
thread's ptid. Remove it and replace its usage with ptid_of.
The changes in nto-low.c and lynx-low.c are fairly straightforward, but
I was not able to build test them.
gdb/gdbserver/ChangeLog:
* inferiors.h (thread_to_gdb_id): Remove.
* inferiors.c (thread_to_gdb_id): Remove.
* server.c (handle_qxfer_threads_worker, handle_query): Adjust.
* lynx-low.c (lynx_resume, lynx_wait_1, lynx_fetch_registers,
lynx_store_registers, lynx_read_memory, lynx_write_memory):
Likewise.
* nto-low.c (nto_fetch_registers, nto_store_registers,
nto_stopped_by_watchpoint, nto_stopped_data_address): Likewise.
Simon Marchi [Fri, 15 Sep 2017 16:02:51 +0000 (18:02 +0200)]
gdbserver: Remove gdb_id_to_thread_id
From what I understand, this function is not doing anything useful as of
today.
Here's the result of my archeological research:
- The field thread_info::gdb_id was added in
a06660f7 Use LWP IDs for thread IDs in gdbserver
There was problem when using a 32-bits gdb with a 64-bits gdbserver.
For some reason that I don't fully understand, the thread ids
exchanged between gdb and gdbserver could overflow a 32 bits data
type. My guess is that they were the thread address (e.g. the
0x7ffff7f20b40 in "Thread 0x7ffff7f20b40 (LWP 1058)" today). This
patch changed that so gdb/gdbserver would talk in terms of the OS
assigned numerical id (as shown in ps). It therefore added a way to
convert between this gdb_id (the numerical id) and the thread id (the
address).
-
95954743cb Implement the multiprocess extensions, and add linux
multiprocess supportNon-stop mode support.
This patch made gdbserver deal with threads using their numerical ids
and not the address-like id. Starting from there, the gdb_id <->
thread id conversion was not needed anymore, since the remote protocol
and gdbserver were using the same kind of ids again. The gdb_id field
in the thread_info structure was also unused starting there.
-
d50171e4 Teach linux gdbserver to step-over-breakpoints.
This patch moved the thread_info structure around, and got rid of the
gdb_id field (which was unused).
Looking at the implementation of gdb_id_to_thread_id, it is not doing
anything useful. It is looking up a thread by ptid using
find_thread_ptid, which basically loops over all threads looking at
their entry.id field. If a thread with that ptid is found, it returns
its entry.id field. So it will always return the same thing as it input
(with the exception of if no thread exist with that ptid, then it will
return null_ptid).
gdb/gdbserver/ChangeLog:
* inferiors.h (gdb_id_to_thread_id): Remove.
* inferiors.c (gdb_id_to_thread_id): Remove.
* server.c (process_serial_event): Adjust to gdb_id_to_thread_id
removal. Move pid declaration closer to where it's used.
Simon Marchi [Fri, 15 Sep 2017 15:59:37 +0000 (17:59 +0200)]
gdbserver: Move detach code to its own function
The code required to handle the 'D' packet is non trivial, so move it
out to its own function.
The moved out code is identical, except for the call to strtol and some
breaks that became returns.
Tested manually, and by running gdb.base/*detach*.exp with
native-gdbserver and native-extended-gdbserver.
gdb/gdbserver/ChangeLog:
* server.c (handle_detach): New function.
(process_serial_event): Move code out, call handle_detach.
Simon Marchi [Fri, 15 Sep 2017 15:59:36 +0000 (17:59 +0200)]
Deduplicate require_running macros and move them up
I find it very confusing to define the require_running in the middle of
the file, and re-define it to something else later in the middle of the
same file. I think it would be better if those macros had different
names so that we know exactly what they do.
gdb/gdbserver/ChangeLog:
* server.c (require_running): Rename to ...
(require_running_or_return): ... this ...
(require_running_or_break): ... and this.
(handle_query, process_serial_event): Adjust.
Nick Clifton [Fri, 15 Sep 2017 15:18:20 +0000 (16:18 +0100)]
Add -l option to src-release script.
Since we are updating src-release.sh I thought I would check in this
small patch. It adds the option to create lzip compressed tarballs
via the -l command line option.
* src-release.sh (LZIPPROG): New define. Provides the name of the
lzip program.
(do_lz): New function. Compresses a tarball using the lzip
program.
(do_compress): Add support for lzip compression.
(usage): Mention -l option.
(build_release): Support -l option to invoke lzip compression.
Simon Marchi [Fri, 15 Sep 2017 14:41:35 +0000 (16:41 +0200)]
linux-low: Remove unused variables
gdb/gdbserver/ChangeLog:
* linux-low.c (linux_set_resume_request): Remove unused
variables.
Simon Marchi [Fri, 15 Sep 2017 14:41:34 +0000 (16:41 +0200)]
dwarf2read: Replace copy_string usages with savestring
copy_string does the exact same thing as savestring, so replace the
usages of the former with the latter.
gdb/ChangeLog:
* dwarf2read.c (copy_string): Remove.
(parse_macro_definition): Replace copy_string with savestring.
Simon Marchi [Fri, 15 Sep 2017 12:53:07 +0000 (14:53 +0200)]
gdbserver: Remove duplicate functions to find any thread of process
We have about 6 functions/callbacks to find_inferior meant to find a
thread that belongs to a given pid. Remove all but
find_any_thread_of_pid and replace their uses with
find_any_thread_of_pid.
gdb/gdbserver/ChangeLog:
* server.c (first_thread_of): Remove.
(process_serial_event): Replace usage of first_thread_of with
find_any_thread_of_pid.
* tracepoint.c (same_process_p): Remove.
(gdb_agent_about_to_close): Replace usage of same_process_p with
find_any_thread_of_pid.
* linux-x86-low.c (same_process_callback): Remove.
(x86_arch_setup_process_callback): Replace usage of
same_process_callback with find_any_thread_of_pid.
* thread-db.c (any_thread_of): Remove.
(switch_to_process): Replace usage of any_thread_of with
find_any_thread_of_pid.
* inferiors.c (thread_pid_matches_callback): Remove.
(find_thread_process): Adjust to use find_any_thread_of_pid.