external/binutils.git
6 years agoPoison XNEW and friends for types that should use new/delete
Simon Marchi [Fri, 24 Nov 2017 15:42:01 +0000 (10:42 -0500)]
Poison XNEW and friends for types that should use new/delete

This patch (finally!) makes it so that trying to use XNEW with a type
that requires "new" will cause a compilation error.  The criterion I
initially used to allow a type to use XNEW (which calls malloc in the
end) was std::is_trivially_constructible, but then realized that gcc 4.8
did not have it.  Instead, I went with:

  using IsMallocatable = std::is_pod<T>;

which is just a bit more strict, which doesn't hurt.  A similar thing is
done for macros that free instead of allocated, the criterion is:

  using IsFreeable = gdb::Or<std::is_trivially_destructible<T>, std::is_void<T>>;

Trying to use XNEW on a type that requires new will result in an error
like this:

    In file included from /home/simark/src/binutils-gdb/gdb/common/common-utils.h:26:0,
                     from /home/simark/src/binutils-gdb/gdb/common/common-defs.h:78,
                     from /home/simark/src/binutils-gdb/gdb/defs.h:28,
                     from /home/simark/src/binutils-gdb/gdb/lala.c:1:
    /home/simark/src/binutils-gdb/gdb/common/poison.h: In instantiation of ‘T* xnew() [with T = bar]’:
    /home/simark/src/binutils-gdb/gdb/lala.c:13:3:   required from here
    /home/simark/src/binutils-gdb/gdb/common/poison.h:103:3: error: static assertion failed: Trying to use XNEW with a non-POD data type.  Use operator new instead.
       static_assert (IsMallocatable<T>::value, "Trying to use XNEW with a non-POD\
       ^~~~~~~~~~~~~

Generated-code-wise, it adds one more function call (xnew<T>) when using
XNEW and building with -O0, but it all goes away with optimizations
enabled.

gdb/ChangeLog:

* common/common-utils.h: Include poison.h.
(xfree): Remove declaration, add definition with static_assert.
* common/common-utils.c (xfree): Remove.
* common/poison.h (IsMallocatable): Define.
(IsFreeable): Define.
(free): Delete for non-freeable types.
(xnew): New.
(XNEW): Undef and redefine.
(xcnew): New.
(XCNEW): Undef and redefine.
(xdelete): New.
(XDELETE): Undef and redefine.
(xnewvec): New.
(XNEWVEC): Undef and redefine.
(xcnewvec): New.
(XCNEWVEC): Undef and redefine.
(xresizevec): New.
(XRESIZEVEC): Undef and redefine.
(xdeletevec): New.
(XDELETEVEC): Undef and redefine.
(xnewvar): New.
(XNEWVAR): Undef and redefine.
(xcnewvar): New.
(XCNEWVAR): Undef and redefine.
(xresizevar): New.
(XRESIZEVAR): Undef and redefine.

6 years agoCreate private_thread_info hierarchy
Simon Marchi [Fri, 24 Nov 2017 15:40:31 +0000 (10:40 -0500)]
Create private_thread_info hierarchy

There are multiple definitions of the private_thread_info structure
compiled in the same GDB build.  Because of the one definition rule, we
need to change this if we want to be able to make them non-POD (e.g. use
std::vector fields).  This patch creates a class hierarchy, with
private_thread_info being an abstract base class, and all the specific
implementations inheriting from it.

In order to poison XNEW/xfree for non-POD types, it is also needed to
get rid of the xfree in thread_info::~thread_info, which operates on an
opaque type.  This is replaced by thread_info::priv now being a
unique_ptr, which calls the destructor of the private_thread_info
subclass when the thread is being destroyed.

Including gdbthread.h from darwin-nat.h gave these errors:

/Users/simark/src/binutils-gdb/gdb/gdbthread.h:609:3: error: must use 'class' tag to refer to type 'thread_info' in this scope
  thread_info *m_thread;
  ^
  class
/usr/include/mach/thread_act.h:240:15: note: class 'thread_info' is hidden by a non-type declaration of 'thread_info' here
kern_return_t thread_info
              ^

It turns out that there is a thread_info function in the Darwin/XNU/mach API:

  http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/thread_info.html

Therefore, I had to add the class keyword at a couple of places in gdbthread.h,
I don't really see a way around it.

gdb/ChangeLog:

* gdbthread.h (private_thread_info): Define structure type, add
virtual pure destructor.
(thread_info) <priv>: Change type to unique_ptr.
<private_dtor>: Remove.
* thread.c (add_thread_with_info): Adjust to use of unique_ptr.
(private_thread_info::~private_thread_info): Provide default
implementation.
(thread_info::~thread_info): Don't call private_dtor nor
manually free priv.
* aix-thread.c (private_thread_info): Rename to ...
(aix_thread_info): ... this.
(get_aix_thread_info): New.
(sync_threadlists): Adjust.
(iter_tid): Adjust.
(aix_thread_resume): Adjust.
(aix_thread_fetch_registers): Adjust.
(aix_thread_store_registers): Adjust.
(aix_thread_extra_thread_info): Adjust.
* darwin-nat.h (private_thread_info): Rename to ...
(darwin_thread_info): ... this.
(get_darwin_thread_info): New.
* darwin-nat.c (darwin_init_thread_list): Adjust.
(darwin_check_new_threads): Adjust.
(thread_info_from_private_thread_info): Adjust.
* linux-thread-db.c (private_thread_info): Rename to ...
(thread_db_thread_info): ... this, initialize fields.
(get_thread_db_thread_info): New.
<dying>: Change type to bool.
(update_thread_state): Adjust to type rename.
(record_thread): Adjust to type rename an use of unique_ptr.
(thread_db_pid_to_str): Likewise.
(thread_db_extra_thread_info): Likewise.
(thread_db_thread_handle_to_thread_info): Likewise.
(thread_db_get_thread_local_address): Likewise.
* nto-tdep.h (private_thread_info): Rename to ...
(nto_thread_info): ... this, initialize fields.
(get_nto_thread_info): New.
<name>: Change type to std::string.
* nto-tdep.c (nto_extra_thread_info): Adjust to type rename and
use of unique_ptr.
* nto-procfs.c (update_thread_private_data_name): Adjust to
std::string change, allocate nto_private_thread_info with new.
(update_thread_private_data): Adjust to unique_ptr.
* remote.c (private_thread_info): Rename to ...
(remote_thread_info): ... this, initialize data members with
default values.
<extra, name>: Change type to std::string.
<thread_handle>: Change type to non-pointer.
(free_private_thread_info): Remove.
(get_private_info_thread): Rename to...
(get_remote_thread_info): ... this, change return type, adjust to
use of unique_ptr, use remote_thread_info constructor.
(remote_add_thread): Adjust.
(get_private_info_ptid): Rename to...
(get_remote_thread_info): ...this, change return type.
(remote_thread_name): Use get_remote_thread_info, adjust to
change to std::string.
(struct thread_item) <~thread_item>: Remove.
<thread_handle>: Make non pointer.
(start_thread): Adjust to thread_item::thread_handle type
change.
(remote_update_thread_list): Adjust to type name change, move
strings from temporary to long-lived object instead of
duplicating.
(remote_threads_extra_info): Use get_remote_thread_info.
(process_initial_stop_replies): Likewise.
(resume_clear_thread_private_info): Likewise.
(remote_resume): Adjust to type name change.
(remote_commit_resume): Use get_remote_thread_info.
(process_stop_reply): Adjust to type name change.
(remote_stopped_by_sw_breakpoint): Use get_remote_thread_info.
(remote_stopped_by_hw_breakpoint): Likewise.
(remote_stopped_by_watchpoint): Likewise.
(remote_stopped_data_address): Likewise.
(remote_core_of_thread): Likewise.
(remote_thread_handle_to_thread_info): Use
get_private_info_thread, adjust to thread_handle field type
change.

6 years agoremote: C++ify thread_item and threads_listing_context
Simon Marchi [Fri, 24 Nov 2017 15:40:13 +0000 (10:40 -0500)]
remote: C++ify thread_item and threads_listing_context

This patch C++ifies the thread_item and threads_listing_context
structures in remote.c.  thread_item::{extra,name} are changed to
std::string.  As a result, there's a bit of awkwardness in
remote_update_thread_list, where we have to xstrdup those strings when
filling the private_thread_info structure.  This is removed in the
following patch, where private_thread_info is also C++ified and its
corresponding fields made std::string too.  The xstrdup then becomes an
std::move.

Other than that there's nothing really special, it's a usual day-to-day
VEC -> vector and char* -> std::string change.  It allows removing a
cleanup in remote_update_thread_list.

Note that an overload of hex2bin that returns a gdb::byte_vector is
added, with corresponding selftests.

gdb/ChangeLog:

* remote.c (struct thread_item): Add constructor, disable copy
construction and copy assignment, define default move
construction and move assignment.
<extra, name>: Change type to std::string.
<core>: Initialize.
<thread_handle>: Make non-pointer.
(thread_item_t): Remove typedef.
(DEF_VEC_O(thread_item_t)): Remove.
(threads_listing_context) <contains_thread>: New method.
<remove_thread>: New method.
<items>: Change type to std::vector.
(clear_threads_listing_context): Remove.
(threads_listing_context_remove): Remove.
(remote_newthread_step): Use thread_item constructor, adjust to
change to std::vector.
(start_thread): Use thread_item constructor, adjust to change to
std::vector.
(end_thread): Adjust to change to std::vector and std::string.
(remote_get_threads_with_qthreadinfo): Use thread_item
constructor, adjust to std::vector.
(remote_update_thread_list): Adjust to change to std::vector and
std::string, use threads_listing_context methods.
(remove_child_of_pending_fork): Adjust.
(remove_new_fork_children): Adjust.
* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add rsp-low-selftests.c.
(SUBDIR_UNITTESTS_OBS): Add rsp-low-selftests.o.
* unittests/rsp-low-selftests.c: New file.
* common/rsp-low.h: Include common/byte-vector.h.
(hex2bin): New overload.
* common/rsp-low.c (hex2bin): New overload.

6 years agoCreate private_inferior class hierarchy
Simon Marchi [Fri, 24 Nov 2017 15:39:30 +0000 (10:39 -0500)]
Create private_inferior class hierarchy

There are currently multiple definitions of private_inferior, defined in
remote.c and darwin-nat.h.  The patch that poisons XNEW and friends for
non-POD types trips on that, because private_inferior is freed in
~inferior(), where it is an opaque type.  Since the compiler can't tell
whether the type is POD, it gives an error.  Also, we can't start using
C++ features in these structures (make them non-POD) as long as there
are multiple definitions with the same name.  For these reasons, this
patch makes a class hierarchy, with private_inferior being the abstract
base class, and darwin_inferior & remote_inferior inheriting from it.
Destruction is done through the virtual destructor.

I stumbled on some suspicious code in the darwin implementation though.
darwin_check_new_threads does an XCNEW(darwin_thread_t) when it finds a
new thread, allocating a new structure for it (darwin_thread_t is a
typedef for private_thread_info).  It then VEC_safe_pushes it in a
vector defined as DEF_VEC_O (a vector of objects).  This means that the
structure content gets copied in the vector.  The thread_info object is
created with the XCNEW'ed structure as the private thread info, while
the rest of the code works with the instance in the vector.  We have
therefore two distinct instances of darwin_thread_t/private_thread_info
for each thread.  This is not really a problem in practice, because
thread_info::priv is not used in the darwin code.  I still find it weird
and far from ideal, so I tried to fix it by changing the vector to be a
vector of pointers.  There should now be a single instance of the
structure for each thread.  The deallocation of the
darwin_thread_t/private_thread_info structure is done by the thread_info
destructor.

I am able to build on macOS, but not really test, since the port seems a
bit broken.  I am not able to debug reliably on the machine I have
access to, which runs macOS 10.12.6.

gdb/ChangeLog:

* inferior.h (private_inferior): Define structure type, add
virtual pure destructor.
(inferior) <priv>: Change type to unique_ptr.
* inferior.c (private_inferior::~private_inferior): Provide
default implementation.
(inferior::~inferior): Don't free priv field.
(exit_inferior_1): Likewise.
* darwin-nat.h (struct darwin_exception_info): Initialize fields.
(darwin_exception_info): Remove typedef.
(DEF_VEC_O (darwin_thread_t)); Remove.
(private_inferior): Rename to ...
(darwin_private_inferior): ... this, extend private_inferior.
(get_darwin_inferior): New.
<threads>: Change type to std::vector of darwin_thread_t pointers.
* darwin-nat.c (darwin_check_new_threads): Adjust.
(find_inferior_task_it): Adjust.
(darwin_find_thread); Adjust.
(darwin_suspend_inferior): Adjust.
(darwin_resume_inferior): Adjust.
(darwin_find_new_inferior): Adjust.
(darwin_decode_notify_message): Adjust.
(darwin_send_reply): Adjust.
(darwin_resume_inferior_threads): Adjust.
(darwin_suspend_inferior_threads): Adjust.
(darwin_decode_message): Adjust.
(darwin_wait): Adjust.
(darwin_interrupt): Adjust.
(darwin_deallocate_threads): Adjust.
(darwin_mourn_inferior): Adjust, don't free private data.
(darwin_reply_to_all_pending_messages): Adjust.
(darwin_stop_inferior): Adjust.
(darwin_setup_exceptions): Adjust.
(darwin_kill_inferior): Adjust.
(darwin_setup_request_notification): Adjust.
(darwin_attach_pid): Adjust.
(darwin_init_thread_list): Adjust.
(darwin_setup_fake_stop_event): Adjust.
(darwin_attach): Adjust.
(darwin_detach): Adjust.
(darwin_xfer_partial): Adjust.
(set_enable_mach_exceptions): Adjust.
(darwin_pid_to_exec_file): Adjust.
(darwin_get_ada_task_ptid): Adjust.
* darwin-nat-info.c (get_task_from_args): Adjust.
(info_mach_ports_command): Adjust.
(info_mach_region_command): Adjust.
(info_mach_exceptions_command): Adjust.
* remote.c (private_inferior): Rename to ...
(remote_private_inferior): ... this, initialize fields.
(get_remote_inferior); New.
(remote_commit_resume): Use get_remote_inferior.
(check_pending_event_prevents_wildcard_vcont_callback): Likewise.

6 years agoDocument linespec/explicit locations & completion improvements (manual + NEWS)
Pedro Alves [Fri, 24 Nov 2017 15:21:16 +0000 (15:21 +0000)]
Document linespec/explicit locations & completion improvements (manual + NEWS)

gdb/ChangeLog:
2017-11-24  Pedro Alves  <palves@redhat.com>

* NEWS: Mention linespecs and explicit locations, and completion
improvements.

gdb/doc/ChangeLog:
2017-11-24  Pedro Alves  <palves@redhat.com>

* gdb.texinfo (Completion): Update need-quoting examples.  Remove
false claim that GDB inserts quoting automatically.
(Symbols): Add anchor.

6 years agoRemove dead code in regcache::dump
Yao Qi [Fri, 24 Nov 2017 14:58:45 +0000 (14:58 +0000)]
Remove dead code in regcache::dump

footnote_register_size in regcache::dump is a constant zero, so the
condition check against footnote_register_size is dead code.  The code
writing to footnote_register_size was removed by 01e1877.

This patche removes footnote_register_size and the dead code.

gdb:

2017-11-24  Yao Qi  <yao.qi@linaro.org>

* regcache.c (regcache::dump): Remove footnote_register_size.

6 years agoelf: Properly compute offsets of note descriptor and next note
H.J. Lu [Fri, 24 Nov 2017 14:41:40 +0000 (06:41 -0800)]
elf: Properly compute offsets of note descriptor and next note

According to gABI, in a note entry, the note name field, not note name
size, is padded for the note descriptor.  And the note descriptor field,
not note descriptor size, is padded for the next note entry.  Also notes
are aligned to 4 bytes in 32-bit objects and 8 bytes in 64-bit objects.
Since on Linux, .note.ABI-tag and .note.gnu.build-id notes are always
aligned to 4 bytes, we need to use alignment of note section or note
segment, instead of assuming alignment based on ELF file class.

Tested on i686 and x86-64.

bfd/

PR binutils/22444
* elf.c (elf_read_notes): Add an argument for note aligment.
(elf_parse_notes): Likewise.
(_bfd_elf_make_section_from_shdr): Pass section aligment to
elf_parse_notes.
(bfd_section_from_phdr): Pass segment aligment to elf_read_notes.
(elf_parse_notes): Add an argument for note aligment.  Use
ELF_NOTE_DESC_OFFSET to get the offset of the note descriptor.
Use ELF_NOTE_NEXT_OFFSET to get the offset of the next note
entry.
(elf_read_notes): Add an argument for note aligment and pass it
to elf_parse_notes.

binutils/

PR binutils/22444
* readelf.c (process_notes_at): Use ELF_NOTE_DESC_OFFSET to get
the offset of the note descriptor.  Use ELF_NOTE_NEXT_OFFSET to
get the offset of the next note entry.

include/

PR binutils/22444
* elf/external.h (ELF_ALIGN_UP): New.
(ELF_NOTE_DESC_OFFSET): Likewise.
(ELF_NOTE_NEXT_OFFSET): Likewise.

6 years agocooked_read test for readonly regcache
Yao Qi [Fri, 24 Nov 2017 13:04:30 +0000 (13:04 +0000)]
cooked_read test for readonly regcache

This patch adds a test to check cooked_read for readonly regcache.  For
raw registers, cooked_read get either REG_VALID or REG_UNKNOWN, depends on
the raw register is in save_reggroup or not.  For pseudo register,
cooked_read get different result in different ports.

gdb:

2017-11-24  Yao Qi  <yao.qi@linaro.org>

* regcache.c (cooked_read_test): Add more test for readonly
regcache.

6 years agoregcache::cooked_read unit test
Yao Qi [Fri, 24 Nov 2017 13:04:30 +0000 (13:04 +0000)]
regcache::cooked_read unit test

This patch adds a unit test to regcache::cooked_read.  This unit test is a
little different from normal unit test, it is more about conformance test
or interaction test.  This test pass both raw register number and pseudo
register number to regcache::cooked_read, in order to inspect 1) return
value of cooked_read, 2) how are target_ops to_xfer_partial,
to_{fetch,store}_registers called (because regcache is updated by means of
these three target_ops methods).  With this test here, we have a clear
picture about how each port of GDB get cooked registers.

This patch also shares some code on mock target.

gdb:

2017-11-24  Yao Qi  <yao.qi@linaro.org>

* gdbarch-selftests.c (test_target_has_registers): Move it to
target.c.
(test_target_has_stack): Likewise.
(test_target_has_memory): Likewise.
(test_target_prepare_to_store): Likewise.
(test_target_store_registers): Likewise.
(test_target_ops): Likewise.
* regcache.c: Include selftest-arch.h and gdbthread.h.
(target_ops_no_register): New class.
(test_target_fetch_registers): New.
(test_target_store_registers): New.
(test_target_xfer_partial): New.
(readwrite_regcache): New.
(cooked_read_test): New.
(_initialize_regcache): Register the test.
* target.c: (test_target_has_registers): Moved from
gdbarch-selftests.c.
(test_target_has_stack): Likewise.
(test_target_has_memory): Likewise.
(test_target_prepare_to_store): Likewise.
(test_target_store_registers): Likewise.
* target.h (test_target_ops): New class.

6 years agoAdd xml selftests for aarch64 target description.
Alan Hayward [Fri, 24 Nov 2017 10:28:58 +0000 (10:28 +0000)]
Add xml selftests for aarch64 target description.

gdb/
* aarch64-tdep.c (_initialize_aarch64_tdep): Add target desc
selftest.

gdbserver/
* configure.srv: Add linux-aarch64-tdesc-selftest.o.
* linux-aarch64-low.c (initialize_low_arch): Call init func.
* linux-aarch64-tdesc-selftest.c: New file.
* linux-aarch64-tdesc.h (initialize_low_tdesc): New declaration.

6 years agoUse flexible target descriptors for aarch64
Alan Hayward [Fri, 24 Nov 2017 10:20:48 +0000 (10:20 +0000)]
Use flexible target descriptors for aarch64

gdb/
* aarch64-tdep.c (_initialize_aarch64_tdep): Remove init.
* arch/aarch64.c (aarch64_create_target_description): Create
new target description.
* features/Makefile: Add new files.
* features/aarch64.c: Remove file.
* features/aarch64-core.c: New autogenerated file.
* features/aarch64-fpu.c: New autogenerated file.
* target-descriptions.c (maint_print_c_tdesc_cmd): Check for aarch64.

gdbserver/
* linux-aarch64-ipa.c (initialize_low_tracepoint): Remove init.
* linux-aarch64-low.c (initialize_low_arch): Remove init.
* linux-aarch64-tdesc.c (aarch64_linux_read_description): Add init.

6 years agogdbserver: add aarch64_create_target_description
Alan Hayward [Fri, 24 Nov 2017 10:04:53 +0000 (10:04 +0000)]
gdbserver: add aarch64_create_target_description

gdbserver/
* configure.srv: Add new files.
* linux-aarch64-ipa.c (get_ipa_tdesc): Call
aarch64_linux_read_description.
* linux-aarch64-low.c (aarch64_linux_read_description):
Merge with aarch64_arch_setup.
(aarch64_arch_setup): Call aarch64_linux_read_description.
* linux-aarch64-tdesc.c: New file.
* linux-aarch64-tdesc.h: New file.

6 years agoAdd aarch64_create_target_description
Alan Hayward [Fri, 24 Nov 2017 10:00:54 +0000 (10:00 +0000)]
Add aarch64_create_target_description

gdb/
* Makefile.in: Add new files.
* aarch64-linux-nat.c (aarch64_linux_read_description): Call
aarch64_read_description.
* aarch64-linux-tdep.c (aarch64_linux_core_read_description):
Call aarch64_read_description.
* aarch64-tdep.c (aarch64_read_description): New function.
(aarch64_gdbarch_init): Call aarch64_read_description.
* aarch64-tdep.h (aarch64_read_description): New function.
* arch/aarch64.c: New file.
* configure.tgt: Add new files.

6 years agoChange value_contents_eq return bool
Yao Qi [Fri, 24 Nov 2017 10:47:27 +0000 (10:47 +0000)]
Change value_contents_eq return bool

This patch changes value_contents_eq return type from int to bool.

gdb:

2017-11-24  Yao Qi  <yao.qi@linaro.org>

* mi/mi-main.c (register_changed_p): Update.
* value.c (value_contents_bits_eq): Change return type.
(value_contents_eq): Likewise.
* value.h: Update comments.

6 years agoChange register_changed_p returns bool
Yao Qi [Fri, 24 Nov 2017 10:47:27 +0000 (10:47 +0000)]
Change register_changed_p returns bool

register_changed_p actually returns bool, but return type is still int.
This patch changes the return type to bool.  The caller of
register_changed_p also checked whether the return value can be negative,
which is not needed now.  Such check was added in fb40c2090 in 2000,
at that moment, register_changed_p returns -1 when
read_relative_register_raw_bytes fails.  I can tell from its name that
it reads register contents, but we don't have this function called inside
register_changed_p, and the regcache is read-only.

gdb:

2017-11-24  Yao Qi  <yao.qi@linaro.org>

* mi/mi-main.c (mi_cmd_data_list_changed_registers): Remove
local 'changed'.  Remove error.
(register_changed_p): Change return type to bool.

6 years agoChange tic6x target descriptions
Yao Qi [Fri, 24 Nov 2017 09:29:43 +0000 (09:29 +0000)]
Change tic6x target descriptions

This patch changes tic6x target descriptions to be more flexible.  Rebuild
tic6x-uclinux GDBserver with my x86 g++, and the unit test passes.

gdb:

2017-11-24  Yao Qi  <yao.qi@linaro.org>

* arch/tic6x.c: New file.
* arch/tic6x.h: New file.
* features/Makefile (FEATURE_XMLFILES): Add tic6x-c6xp.xml,
tic6x-core.xml and tic6x-gp.xml.
* features/tic6x-c6xp.c: Generated.
* features/tic6x-core.c: Generated.
* features/tic6x-gp.c: Generated.
* target-descriptions.c (maint_print_c_tdesc_cmd): Match
"tic6x-".

gdb/gdbserver:

2017-11-24  Yao Qi  <yao.qi@linaro.org>

* configure.srv: Set $srv_regobj for tic6x-linux.
* linux-tic6x-low.c: Include "arch/tic6x.h" and "tdesc.h".
(tic6x_read_description): Move some code to tic6x_arch_setup.
(tic6x_tdesc_test): New function.
(initialize_low_arch): Call selftests::register_test.

6 years agox86: reject further invalid AVX-512 masking constructs
Jan Beulich [Fri, 24 Nov 2017 07:42:57 +0000 (08:42 +0100)]
x86: reject further invalid AVX-512 masking constructs

For one the register type used for masking should be validated. And then
we shouldn't accept input producing encodings which will #UD when
executed, as is the case when EVEX.Z is set while EVEX.AAA is zero.

6 years agox86: don't omit disambiguating suffixes from "fi*"
Jan Beulich [Fri, 24 Nov 2017 07:42:04 +0000 (08:42 +0100)]
x86: don't omit disambiguating suffixes from "fi*"

"fi*" typically come in two (loads/stores: three) flavors, distinguished
by the suffix. Don't omit the 's' one when disassembling.

6 years agoFix memory leak in list_available_thread_groups
Simon Marchi [Fri, 24 Nov 2017 02:56:19 +0000 (21:56 -0500)]
Fix memory leak in list_available_thread_groups

Commit

  C++ify osdata
  479f8de1b3b7e69ca8d557bbe9d843c7d1bc89c5

introduced a memory leak.  We allocate std::vectors and insert them in a
map, but never free them.  Instead, the map value type can be
std::vector objects directly.

gdb/ChangeLog:

* mi/mi-main.c (list_available_thread_groups): Change map value
type to std::vector.

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 24 Nov 2017 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoFix vax/ns32k/mmix gas testsuite regression.
Jim Wilson [Thu, 23 Nov 2017 21:11:40 +0000 (13:11 -0800)]
Fix vax/ns32k/mmix gas testsuite regression.

gas/
* testsuite/gas/all/err-fakelabel.s (dg-error): Also accept fatal error
string.

6 years agoFix build error with --enable-targets=all.
Jim Wilson [Thu, 23 Nov 2017 20:30:47 +0000 (12:30 -0800)]
Fix build error with --enable-targets=all.

gas/
* as.c (INITIALIZING_EMULS): Define.
* config/obj-multi.h (FAKE_LABEL_NAME): When INITIALIZING_EMULS set,
don't define it.

6 years agoFix clang warnings about copy elision
Simon Marchi [Thu, 23 Nov 2017 18:51:50 +0000 (13:51 -0500)]
Fix clang warnings about copy elision

When building with clang, I get:

/home/emaisin/src/binutils-gdb/gdb/osdata.c:107:9: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
                             std::move (std::string (body_text)));
                             ^
/home/emaisin/src/binutils-gdb/gdb/osdata.c:107:9: note: remove std::move call here
                             std::move (std::string (body_text)));
                             ^~~~~~~~~~~                       ~
/home/emaisin/src/binutils-gdb/gdb/osdata.c:181:10: error: moving a local object in a return statement prevents copy elision [-Werror,-Wpessimizing-move]
  return std::move (osdata);
         ^
/home/emaisin/src/binutils-gdb/gdb/osdata.c:181:10: note: remove std::move call here
  return std::move (osdata);
         ^~~~~~~~~~~      ~

Indeed, those two std::move are unnecessary.

gdb/ChangeLog:

* osdata.c (osdata_end_column, get_osdata): Remove std::move.

6 years agoRevert unexpected rename in previous patch
Simon Marchi [Thu, 23 Nov 2017 16:05:22 +0000 (11:05 -0500)]
Revert unexpected rename in previous patch

While working on the previous patch, I renamed variables whose type I
changed to let the compiler help me find their usages, but I forgot to
rename one back to its original name.  This patch fixes it.

gdb/ChangeLog:

* varobj.c (struct varobj_dynamic) <children_requested_>: Rename
back to...
<children_requested>: ... this.
(varobj_get_num_children, varobj_update): Adjust.

6 years agoChange int -> bool where applicable throughout varobj
Simon Marchi [Thu, 23 Nov 2017 16:00:56 +0000 (11:00 -0500)]
Change int -> bool where applicable throughout varobj

This patch changes all the "int" I could find in varobj.{c,h} that are
really boolean values to use bool.  I followed the ramifications
(parameters and return values of exported functions), so the changes
spilled a bit on other, related files (ada-varobj.c and c-varobj.c).

gdb/ChangeLog:

* ada-varobj.c (ada_value_is_changeable_p): Change int to bool where applicable.
(ada_value_has_mutated): Likewise.
* c-varobj.c (varobj_is_anonymous_child): Likewise.
(c_is_path_expr_parent): Likewise.
* mi/mi-cmd-var.c (varobj_update_one): Likewise.
(mi_cmd_var_set_frozen): Likewise.
(mi_cmd_var_update_iter): Likewise.
(mi_cmd_var_update): Likewise.
* varobj.c (pretty_printing): Likewise.
(varobj_enable_pretty_printing): Likewise.
(struct varobj_root) <floating, is_valid>: Likewise.
(struct varobj_dynamic) <children_requested>: Likewise.
(delete_variable): Likewise.
(delete_variable_1): Likewise.
(install_variable): Likewise.
(update_type_if_necessary): Likewise.
(install_new_value): Likewise.
(value_of_root): Likewise.
(is_root_p): Likewise.
(varobj_create): Likewise.
(varobj_delete): Likewise.
(varobj_has_more): Likewise.
(varobj_set_frozen): Likewise.
(varobj_get_frozen): Likewise.
(install_dynamic_child): Likewise.
(dynamic_varobj_has_child_method): Likewise.
(update_dynamic_varobj_children): Likewise.
(varobj_get_num_children): Likewise.
(varobj_list_children): Likewise.
(is_path_expr_parent): Likewise.
(varobj_default_is_path_expr_parent): Likewise.
(varobj_is_dynamic_p): Likewise.
(varobj_set_value): Likewise.
(varobj_value_has_mutated): Likewise.
(varobj_update): Likewise.
(check_scope): Likewise.
(value_of_root_1): Likewise.
(varobj_value_get_print_value): Likewise.
(varobj_editable_p): Likewise.
(varobj_value_is_changeable_p): Likewise.
(varobj_floating_p): Likewise.
(varobj_default_value_is_changeable_p): Likewise.
(varobj_invalidate_iter): Likewise.
* varobj.h (struct varobj_update_result) <type_changed,
children_changed, changed, value_installed>: Likewise.
(struct varobj) <updated, frozen, not_fetched>: Likewise.
(struct lang_varobj_ops) <value_is_changeable_p,
value_has_mutated, is_path_expr_parent>: Likewise.
(varobj_delete): Likewise.
(varobj_set_frozen): Likewise.
(varobj_get_frozen): Likewise.
(varobj_set_value): Likewise.
(varobj_update): Likewise.
(varobj_editable_p): Likewise.
(varobj_floating_p): Likewise.
(varobj_has_more): Likewise.
(varobj_is_dynamic_p): Likewise.
(varobj_default_value_is_changeable_p): Likewise.
(varobj_value_is_changeable_p): Likewise.
(varobj_is_anonymous_child): Likewise.
(varobj_default_is_path_expr_parent): Likewise.

6 years agoAvoid bogus compile time warning from clang by initialising local data structure...
Pavel I. Kryukov [Thu, 23 Nov 2017 15:53:04 +0000 (15:53 +0000)]
Avoid bogus compile time warning from clang by initialising local data structure using memset.

PR 22485
* readelf.c (process_archive): Use memset to initiaise
thin_filedata structure.

6 years ago[testsuite] Pass -g3 to clang in gdb.base/macscp.exp
Yao Qi [Thu, 23 Nov 2017 15:30:56 +0000 (15:30 +0000)]
[testsuite] Pass -g3 to clang in gdb.base/macscp.exp

clang accepts option -g3 too.  I checked the manual of xlc and icc, looks
they don't accept -g3 option, so I don't pass -g3 for them.

gdb/testsuite:

2017-11-23  Yao Qi  <yao.qi@linaro.org>

* gdb.base/macscp.exp: Append -g3 to additional_flags for clang.

6 years agoAdd Disp8MemShift for AVX512 VAES instructions.
Igor Tsimbalist [Wed, 22 Nov 2017 11:40:32 +0000 (14:40 +0300)]
Add Disp8MemShift for AVX512 VAES instructions.

opcodes/
* i386-opc.tbl: Add Disp8MemShift for AVX512 VAES instructions.
* i386-tbl.h: Regenerate.

gas/
* testsuite/gas/i386/avx512f_vaes-intel.d: Regenerate.
* testsuite/gas/i386/avx512f_vaes.d: Likewise.
* testsuite/gas/i386/avx512f_vaes-wig1-intel.d: Likewise.
* testsuite/gas/i386/avx512f_vaes-wig1.d: Likewise.
* testsuite/gas/i386/avx512vl_vaes-intel.d: Likewise.
* testsuite/gas/i386/avx512vl_vaes.d: Likewise.
* testsuite/gas/i386/x86-64-avx512f_vaes.s: Add instructions with disp8*N.
* testsuite/gas/i386/x86-64-avx512f_vaes-intel.d: Regenerate.
* testsuite/gas/i386/x86-64-avx512f_vaes.d: Likewise.
* testsuite/gas/i386/x86-64-avx512f_vaes-wig.s: Add instructions with disp8*N.
* testsuite/gas/i386/x86-64-avx512f_vaes-wig1-intel.d: Regenerate.
* testsuite/gas/i386/x86-64-avx512f_vaes-wig1.d: Likewise.
* testsuite/gas/i386/x86-64-avx512vl_vaes-intel.d: Regenerate.
* testsuite/gas/i386/x86-64-avx512vl_vaes.d: Likewise.
* testsuite/gas/i386/x86-64-avx512vl_vaes-wig.s: Add instructions with disp8*N.
* testsuite/gas/i386/x86-64-avx512vl_vaes-wig1-intel.d: Regenerate.
* testsuite/gas/i386/x86-64-avx512vl_vaes-wig1.d: Regenerate.

6 years agoDon't move weak alias dyn_relocs to weakdef
Alan Modra [Wed, 22 Nov 2017 10:37:03 +0000 (21:07 +1030)]
Don't move weak alias dyn_relocs to weakdef

I did this for powerpc64 a while ago.  Not moving weak symbol
dyn_relocs to the strong alias makes for a much simpler test for
dynamic relocs in relocate_section.

This patch implements the change for powerpc and hppa.  Other targets
could benefit from similar changes.

* elf32-hppa.c (pc_dynrelocs): Define.
(elf32_hppa_copy_indirect_symbol): Don't copy dyn_relocs to weakdefs.
(alias_readonly_dynrelocs): New function.
(elf32_hppa_adjust_dynamic_symbol): Don't clear non_got_ref to
indicate dyn_relocs should be discarded, discard them here.
Use alias_readonly_dynrelocs.
(allocate_dynrelocs): Don't test or clear non_got_ref.
(elf32_hppa_relocate_section): Simplify test for dynamic relocs.
* elf32-ppc.c (ppc_elf_copy_indirect_symbol): Don't copy dyn_relocs
to weakdefs.
(alias_readonly_dynrelocs, pc_dynrelocs): New functions.
(ppc_elf_adjust_dynamic_symbol): Don't clear non_got_ref to
indicate dyn_relocs should be discarded, discard them here.
Use alias_readonly_dynrelocs.
(allocate_dynrelocs): Don't test or clear non_got_ref.
(ppc_elf_relocate_section): Simplify test for dynamic relocs.

6 years agoDelete powerpc64 symbol weakref field
Alan Modra [Wed, 22 Nov 2017 07:02:50 +0000 (17:32 +1030)]
Delete powerpc64 symbol weakref field

Now that u.alias is circular, weakref just duplicates its function.
Also, function symbols shouldn't be on the alias list so there is no
need to use alias_readonly_dynrelocs with them.

* elf64-ppc.c (struct ppc_link_hash_entry): Delete weakref field.
(ppc64_elf_copy_indirect_symbol): Don't set weakref.
(alias_readonly_dynrelocs): Use u.alias rather than weakref.
(ppc64_elf_adjust_dynamic_symbol): Don't use
alias_readonly_dynrelocs for function symbols.

6 years agoRename u.weakdef and make it a circular list
Alan Modra [Wed, 22 Nov 2017 07:00:55 +0000 (17:30 +1030)]
Rename u.weakdef and make it a circular list

This makes the elf_link_hash_entry weakdef field, currently used to
point from a weak symbol to a strong alias, a circular list so that
all aliases can be found from any of them.  A new flag, is_weakalias,
distinguishes the weak symbol from a strong alias, and is used in all
places where we currently test u.weakdef != NULL.

With the original u.weakdef handling it was possible to have two or
more weak symbols pointing via u.weakdef to a strong definition.
Obviously that situation can't map to a circular list; One or more of
the weak symbols must point at another weak alias rather than the
strong definition.  To handle that, I've added an accessor function to
return the strong definition.

* elf-bfd.h (struct elf_link_hash_entry): Add is_weakalias.
Rename u.weakdef to u.alias and update comment.
(weakdef): New static inline function.
* elflink.c (bfd_elf_record_link_assignment) Test is_weakalias
rather than u.weakdef != NULL, and use weakdef function.
(_bfd_elf_adjust_dynamic_symbol): Likewise.
(_bfd_elf_fix_symbol_flags): Likewise.  Clear is_weakalias on
all aliases if def has been overridden in a regular object, not
u.weakdef.
(elf_link_add_object_symbols): Delete new_weakdef flag.  Test
is_weakalias and use weakdef.  Set is_weakalias and circular
u.alias.  Update comments.
(_bfd_elf_gc_mark_rsec): Test is_weakalias rather than
u.weakdef != NULL and use weakdef function.
* elf-m10300.c (_bfd_mn10300_elf_adjust_dynamic_symbol): Test
is_weakalias rather than u.weakdef != NULL and use weakdef
function.  Assert that def is strong defined.
* elf32-arc.c (elf_arc_adjust_dynamic_symbol): Likewise.
* elf32-arm.c (elf32_arm_adjust_dynamic_symbol): Likewise.
* elf32-bfin.c (elf32_bfinfdpic_adjust_dynamic_symbol): Likewise.
(bfin_adjust_dynamic_symbol): Likewise.
* elf32-cr16.c (_bfd_cr16_elf_adjust_dynamic_symbol): Likewise.
* elf32-cris.c (elf_cris_adjust_dynamic_symbol): Likewise.
* elf32-frv.c (elf32_frvfdpic_adjust_dynamic_symbol): Likewise.
* elf32-hppa.c (elf32_hppa_adjust_dynamic_symbol): Likewise.
* elf32-i370.c (i370_elf_adjust_dynamic_symbol): Likewise.
* elf32-lm32.c (lm32_elf_adjust_dynamic_symbol): Likewise.
* elf32-m32r.c (m32r_elf_adjust_dynamic_symbol): Likewise.
* elf32-m68k.c (elf_m68k_adjust_dynamic_symbol): Likewise.
* elf32-metag.c (elf_metag_adjust_dynamic_symbol): Likewise.
* elf32-microblaze.c (microblaze_elf_adjust_dynamic_symbol): Likewise.
* elf32-nds32.c (nds32_elf_adjust_dynamic_symbol): Likewise.
* elf32-nios2.c (nios2_elf32_adjust_dynamic_symbol): Likewise.
* elf32-or1k.c (or1k_elf_adjust_dynamic_symbol): Likewise.
* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Likewise.
* elf32-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
* elf32-score.c (s3_bfd_score_elf_adjust_dynamic_symbol): Likewise.
* elf32-score7.c (s7_bfd_score_elf_adjust_dynamic_symbol): Likewise.
* elf32-sh.c (sh_elf_adjust_dynamic_symbol): Likewise.
* elf32-tic6x.c (elf32_tic6x_adjust_dynamic_symbol): Likewise.
* elf32-tilepro.c (tilepro_elf_gc_mark_hook): Likewise.
(tilepro_elf_adjust_dynamic_symbol): Likewise.
* elf32-vax.c (elf_vax_adjust_dynamic_symbol): Likewise.
* elf32-xtensa.c (elf_xtensa_adjust_dynamic_symbol): Likewise.
* elf64-alpha.c (elf64_alpha_adjust_dynamic_symbol): Likewise.
* elf64-hppa.c (elf64_hppa_adjust_dynamic_symbol): Likewise.
* elf64-ia64-vms.c (elf64_ia64_adjust_dynamic_symbol): Likewise.
* elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise.
(ppc64_elf_adjust_dynamic_symbol): Likewise.
* elf64-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
* elf64-sh64.c (sh64_elf64_adjust_dynamic_symbol): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_adjust_dynamic_symbol): Likewise.
* elfnn-ia64.c (elfNN_ia64_adjust_dynamic_symbol): Likewise.
* elfnn-riscv.c (riscv_elf_adjust_dynamic_symbol): Likewise.
* elfxx-mips.c (_bfd_mips_elf_adjust_dynamic_symbol): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_gc_mark_hook): Likewise.
(_bfd_sparc_elf_adjust_dynamic_symbol): Likewise.
* elfxx-tilegx.c (tilegx_elf_gc_mark_hook): Likewise.
(tilegx_elf_adjust_dynamic_symbol): Likewise.
* elfxx-x86.c (_bfd_x86_elf_adjust_dynamic_symbol): Likewise.

6 years agoAdd libmsvcrt, libmsvcrt-os and libucrtbase to the list of libraries for which the...
Martin Storsjo [Thu, 23 Nov 2017 12:07:24 +0000 (12:07 +0000)]
Add libmsvcrt, libmsvcrt-os and libucrtbase to the list of libraries for which the automatic generation of exported variables should be disabled.

In the latest git version of mingw-w64, one can set the default
libmsvcrt.a to actually be the import library of another CRT version,
to facilitate switching to ucrtbase.dll. In these versions, the
traditional libmsvcrt.a (for linking to msvcrt.dll) is also provided
with the name libmsvcrt-os.a.

The import libraries for the CRT also contain a number of compatibility
wrapper functions. The ones in libmsvcrt.a have so far been excluded
automatically since they in most cases come with a corresponding
__imp_foo function. None of these make sense to export automatically
from a DLL though, so add these libraries to the exclude list.

libucrtbase.a contains a number of compatibility wrapper functions
that don't have a corresponding __imp_foo symbol, which cause
these symbols to be exported from DLLs.

This can be worked around on the mingw-w64 side by adding extra
__imp_ symbols, but since they aren't strictly necessary for linking
to succeed, it's probably better long-term to add these libraries to
the exclusion list.

ld * pe-dll.c (autofilter_liblist): Add libmsvcrt, libmsvcrt-os and
libucrtbase.

6 years agox86: fix AVX-512 16-bit addressing
Jan Beulich [Thu, 23 Nov 2017 10:04:18 +0000 (11:04 +0100)]
x86: fix AVX-512 16-bit addressing

Despite EVEX encodings not being available in real and VM86 modes,
16-bit addressing still needs to be handled properly for 16-bit
protected mode as well as 16-bit addressing in 32-bit mode. Neither
should displacements be dropped silently by the assembler, nor should
the disassembler fail to correctly scale 8-bit displacements.

6 years agox86-64: always use unsigned 32-bit reloc for 32-bit addressing w/o base reg
Jan Beulich [Thu, 23 Nov 2017 10:02:30 +0000 (11:02 +0100)]
x86-64: always use unsigned 32-bit reloc for 32-bit addressing w/o base reg

Except for %eip-relative addressing, where we don't have a suitable
relocation type silently wrapping at the 4G boundary, consistently
force use of R_X86_64_32 (in ELF terms) instead of its sign-extending
counterpart. This wasn't right in case there was no base register in
the addressing expression.

6 years agox86: drop redundant VSIB handling code
Jan Beulich [Thu, 23 Nov 2017 10:00:44 +0000 (11:00 +0100)]
x86: drop redundant VSIB handling code

The vecsib && !base_reg case is already being handled (in a more correct
manner) by earlier code.

6 years agox86: correct UDn
Jan Beulich [Thu, 23 Nov 2017 09:59:48 +0000 (10:59 +0100)]
x86: correct UDn

Make the assembler recognize UD0, supporting only the newer form
expecting a ModR/M byte.

Make assembler and disassembler properly emit / expect a ModR/M byte for
UD1.

For the testsuite, as arch-4 already tests all UDn, avoid producing a
huge delta for other tests using UD2B by making them use UD2 instead.

6 years agox86/Intel: don't report multiple errors for a single insn operand
Jan Beulich [Thu, 23 Nov 2017 09:57:54 +0000 (10:57 +0100)]
x86/Intel: don't report multiple errors for a single insn operand

Multiple errors are more confusing than helpful, as the more generic
one often implies a sufficiently different adjustment than would
actually be needed to fix the code. Additionally it makes it more
cumbersome to add missing error checks, as the testsuite then needs
extra updating.

6 years agoConvert DTrace probe interface to C++ (and perform some cleanups)
Sergio Durigan Junior [Mon, 13 Nov 2017 06:29:39 +0000 (01:29 -0500)]
Convert DTrace probe interface to C++ (and perform some cleanups)

This patch converts the DTrace probe
interface (gdb/dtrace-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.

The main changes were the conversion of 'struct dtrace_probe' to 'class
dtrace_probe', and a new 'class dtrace_static_probe_ops' to replace the
use of 'dtrace_probe_ops'.  Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively.  I believe it's now a bit simpler to understand the
logic behind the dtrace-probe interface.

There are several helper functions used to parse parts of a dtrace
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).

I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain.  And, as usual, some cleanups
here and there.

Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies.  But it
should be easier to review in separate logical units.

I wasn't able to test these modifications because the current test
framework for DTrace probes is not working.  See
<https://sourceware.org/bugzilla/show_bug.cgi?id=22420>.

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

* dtrace-probe.c (struct probe_ops dtrace_probe_ops): Delete.
(struct dtrace_probe_arg) <dtrace_probe_arg>: New constructor.
<type_str>: Convert to 'std::string'.
<expr>: Convert to 'expression_up'.
(dtrace_probe_arg_s): Delete type and VEC.
(dtrace_probe_enabler_s): Likewise.
(struct dtrace_probe): Replace by...
(class dtrace_static_probe_ops): ...this and...
(class dtrace_probe): ...this.
(dtrace_probe_is_linespec): Rename to...
(dtrace_static_probe_ops::is_linespec): ...this.  Adjust code
to reflect change.
(dtrace_process_dof_probe): Use 'std::vector' instead of VEC.
Adjust code.  Create new instance of 'dtrace_probe'.
(dtrace_build_arg_exprs): Rename to...
(dtrace_probe::build_arg_exprs): ...this.  Adjust code to
reflect change.
(dtrace_get_probes): Rename to...
(dtrace_static_probe_ops::get_probes): ...this.  Adjust code
to reflect change.
(dtrace_get_arg): Rename to...
(dtrace_probe::get_arg_by_number): ...this.  Adjust code to
reflect change.
(dtrace_probe_is_enabled): Rename to...
(dtrace_probe::is_enabled): ...this.  Adjust code to reflect
change.
(dtrace_get_probe_address): Rename to...
(dtrace_probe::get_relocated_address): ...this.  Adjust code
to reflect change.
(dtrace_get_probe_argument_count): Rename to...
(dtrace_probe::get_argument_count): ...this.  Adjust code to
reflect change.
(dtrace_can_evaluate_probe_arguments): Rename to...
(dtrace_probe::can_evaluate_arguments): ...this.  Adjust code
to reflect change.
(dtrace_evaluate_probe_argument): Rename to...
(dtrace_probe::evaluate_argument): ...this.  Adjust code to
reflect change.
(dtrace_compile_to_ax): Rename to...
(dtrace_probe::compile_to_ax): ...this.  Adjust code to
reflect change.
(dtrace_probe_destroy): Delete.
(dtrace_type_name): Rename to...
(dtrace_static_probe_ops::type_name): ...this.  Adjust code to
reflect change.
(dtrace_probe::get_static_ops): New method.
(dtrace_gen_info_probes_table_header): Rename to...
(dtrace_static_probe_ops::gen_info_probes_table_header):
...this.  Adjust code to reflect change.
(dtrace_gen_info_probes_table_values): Rename to...
(dtrace_probe::gen_info_probes_table_values): ...this.  Adjust
code to reflect change.
(dtrace_enable_probe): Rename to...
(dtrace_probe::enable_probe): ...this.  Adjust code to reflect
change.
(dtrace_disable_probe): Rename to...
(dtrace_probe::disable_probe): ...this.  Adjust code to reflect
change.
(struct probe_ops dtrace_probe_ops): Delete.
(info_probes_dtrace_command): Call 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_dtrace_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.

6 years agoConvert SystemTap probe interface to C++ (and perform some cleanups)
Sergio Durigan Junior [Mon, 13 Nov 2017 06:05:57 +0000 (01:05 -0500)]
Convert SystemTap probe interface to C++ (and perform some cleanups)

This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.

The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'.  Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively.  I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.

There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).

I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain.  And, as usual, some cleanups
here and there.

Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies.  But it
should be easier to review in separate logical units.

I've regtested this patch on BuildBot, no regressions found.

gdb/ChangeLog:
2017-11-22  Sergio Durigan Junior  <sergiodj@redhat.com>
    Simon Marchi  <simark@simark.ca>

* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete.  Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this.  Rename variables to add 'm_'
prefix.  Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'.  Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this.  Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this.  Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this.  Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this.  Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this.  Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this.  Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this.  Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this.  Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this.  Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this.  Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this.  Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this.  Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this.  Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.

6 years agoConvert generic probe interface to C++ (and perform some cleanups)
Sergio Durigan Junior [Mon, 13 Nov 2017 05:28:24 +0000 (00:28 -0500)]
Convert generic probe interface to C++ (and perform some cleanups)

This patch converts the generic probe interface (gdb/probe.[ch]) to
C++, and also performs some cleanups that were on my TODO list for a
while.

The main changes were the conversion of 'struct probe' to 'class
probe', and 'struct probe_ops' to 'class static_probe_ops'.  The
former now contains all the "dynamic", generic methods that act on a
probe + the generic data related to it; the latter encapsulates a
bunch of "static" methods that relate to the probe type, but not to a
specific probe itself.

I've had to do a few renamings (e.g., on 'struct bound_probe' the
field is called 'probe *prob' now, instead of 'struct probe *probe')
because GCC was complaining about naming the field using the same name
as the class.  Nothing major, though.  Generally speaking, the logic
behind and the design behind the code are the same.

Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies.  But it
should be easier to review in separate logical units.

I've regtested this patch on BuildBot, no regressions found.

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

* break-catch-throw.c (fetch_probe_arguments): Use
'probe.prob' instead of 'probe.probe'.
* breakpoint.c (create_longjmp_master_breakpoint): Call
'can_evaluate_arguments' and 'get_relocated_address' methods
from probe.
(create_exception_master_breakpoint): Likewise.
(add_location_to_breakpoint): Use 'sal->prob' instead of
'sal->probe'.
(bkpt_probe_insert_location): Call 'set_semaphore' method from
probe.
(bkpt_probe_remove_location): Likewise, for 'clear_semaphore'.
* elfread.c (elf_get_probes): Use 'static_probe_ops' instead
of 'probe_ops'.
(probe_key_free): Call 'delete' on probe.
(check_exception_resume): Use 'probe.prob' instead of
'probe.probe'.
* location.c (string_to_event_location_basic): Call
'probe_linespec_to_static_ops'.
* probe.c (class any_static_probe_ops): New class.
(any_static_probe_ops any_static_probe_ops): New variable.
(parse_probes_in_pspace): Receive 'static_probe_ops' as
argument.  Adjust code to reflect change.
(parse_probes): Use 'static_probe_ops' instead of
'probe_ops'.  Adjust code to reflect change.
(find_probes_in_objfile): Call methods to get name and
provider from probe.
(find_probe_by_pc): Use 'result.prob' instead of
'result.probe'.  Call 'get_relocated_address' method from
probe.
(collect_probes): Adjust comment and argument list to receive
'static_probe_ops' instead of 'probe_ops'.  Adjust code to
reflect change.  Call necessary methods from probe.
(compare_probes): Call methods to get name and provider from
probes.
(gen_ui_out_table_header_info): Receive 'static_probe_ops'
instead of 'probe_ops'.  Use 'std::vector' instead of VEC,
adjust code accordingly.
(print_ui_out_not_applicables): Likewise.
(info_probes_for_ops): Rename to...
(info_probes_for_spops): ...this.  Receive 'static_probe_ops'
as argument instead of 'probe_ops'.  Adjust code.  Call
necessary methods from probe.
(info_probes_command): Use 'info_probes_for_spops'.
(enable_probes_command): Pass correct argument to
'collect_probes'.  Call methods from probe.
(disable_probes_command): Likewise.
(get_probe_address): Move to 'any_static_probe_ops::get_address'.
(get_probe_argument_count): Move to
'any_static_probe_ops::get_argument_count'.
(can_evaluate_probe_arguments): Move to
'any_static_probe_ops::can_evaluate_arguments'.
(evaluate_probe_argument): Move to
'any_static_probe_ops::evaluate_argument'.
(probe_safe_evaluate_at_pc): Use 'probe.prob' instead of
'probe.probe'.
(probe_linespec_to_ops): Rename to...
(probe_linespec_to_static_ops): ...this.  Adjust code.
(probe_any_is_linespec): Rename to...
(any_static_probe_ops::is_linespec): ...this.
(probe_any_get_probes): Rename to...
(any_static_probe_ops::get_probes): ...this.
(any_static_probe_ops::type_name): New method.
(any_static_probe_ops::gen_info_probes_table_header): New
method.
(compute_probe_arg): Use 'pc_probe.prob' instead of
'pc_probe.probe'.  Call methods from probe.
(compile_probe_arg): Likewise.
(std::vector<const probe_ops *> all_probe_ops): Delete.
(std::vector<const static_probe_ops *> all_static_probe_ops):
New variable.
(_initialize_probe): Use 'all_static_probe_ops' instead of
'all_probe_ops'.
* probe.h (struct info_probe_column) <field_name>: Delete
extraneous newline
(info_probe_column_s): Delete type and VEC.
(struct probe_ops): Delete.  Replace with...
(class static_probe_ops): ...this and...
(clas probe): ...this.
(struct bound_probe) <bound_probe>: Delete extraneous
newline.  Adjust constructor to receive 'probe' instead of
'struct probe'.
<probe>: Rename to...
<prob>: ...this.  Delete extraneous newline.
<objfile>: Delete extraneous newline.
(register_probe_ops): Delete unused prototype.
(info_probes_for_ops): Rename to...
(info_probes_for_spops): ...this.  Adjust comment.
(get_probe_address): Move to 'probe::get_address'.
(get_probe_argument_count): Move to
'probe::get_argument_count'.
(can_evaluate_probe_arguments): Move to
'probe::can_evaluate_arguments'.
(evaluate_probe_argument): Move to 'probe::evaluate_argument'.
* solib-svr4.c (struct svr4_info): Adjust comment.
(struct probe_and_action) <probe>: Rename to...
<prob>: ...this.
(register_solib_event_probe): Receive 'probe' instead of
'struct probe' as argument.  Use 'prob' instead of 'probe'
when applicable.
(solib_event_probe_action): Call 'get_argument_count' method
from probe.  Adjust comment.
(svr4_handle_solib_event): Adjust comment.  Call
'evaluate_argument' method from probe.
(svr4_create_probe_breakpoints): Call 'get_relocated_address'
from probe.
(svr4_create_solib_event_breakpoints): Use 'probe' instead of
'struct probe'.  Call 'can_evaluate_arguments' from probe.
* symfile.h: Forward declare 'class probe' instead of 'struct
probe'.
* symtab.h: Likewise.
(struct symtab_and_line) <probe>: Rename to...
<prob>: ...this.
* tracepoint.c (start_tracing): Use 'prob' when applicable.
Call probe methods.
(stop_tracing): Likewise.

6 years agoAutomatic date update in version.in
GDB Administrator [Thu, 23 Nov 2017 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years ago(Ada) ravenscar-thread.c: remove unwanted trailing \n in call to warning
Joel Brobecker [Wed, 22 Nov 2017 22:30:41 +0000 (14:30 -0800)]
(Ada) ravenscar-thread.c: remove unwanted trailing \n in call to warning

A recent patch introduced a call to warning, and the string used
had a trailing newline, which is not correct; the nightly ARI run
caught it, so this patch removes it.

gdb/ChangeLog:

        * ravenscar-thread.c (ravenscar_inferior_created): Remove
        trailing newline at end of string in call to warning.

Tested on powerpc-eabispe, no regression.

6 years agoC++ify osdata
Simon Marchi [Wed, 22 Nov 2017 21:12:06 +0000 (16:12 -0500)]
C++ify osdata

This patch c++ifies the osdata structure: osdata_column, osdata_item and
osdata.  char* are replaced with std::string and VEC are replaced with
std::vector.  This allows to get rid of a great deal of cleanup and
free'ing code.

I replaced the splay tree in list_available_thread_groups with an
std::map.  Unless there's a good advantage to keep using a splay tree,
I think using the standard type should make things simpler to
understand.

gdb/ChangeLog:

* osdata.h: Include vector isntead of vec.h.
(osdata_column_s): Remove typedef.
(struct osdata_column): Add constructor.
<name, value>: Change type to std::string.
(DEF_VEC_O (osdata_column_s)): Remove.
(osdata_item_s): Remove typedef.
(struct osdata_item) <columns>: Change type to std::vector.
(DEF_VEC_O (osdata_item_s)): Remove.
(struct osdata): Add constructor.
<type>: Change type to std::string.
<items>: Change type to std::vector.
(osdata_p): Remove typedef.
(DEF_VEC_P (osdata_p)): Remove.
(osdata_parse): Return a unique_ptr.
(osdata_free): Remove.
(make_cleanup_osdata_free): Remove.
(get_osdata): Return a unique_ptr.
(get_osdata_column): Return pointer to std::string, take a
reference to osdata_item as parameter.
* osdata.c (struct osdata_parsing_data) <osdata>: Change type to
unique_ptr.
<property_name>: Change type to std::string.
(osdata_start_osdata): Allocate osdata with new and adjust.
(osdata_start_item): Adjust.
(osdata_start_column): Adjust.
(osdata_end_column): Adjust.
(clear_parsing_data): Remove.
(osdata_parse): Return a unique_ptr and adjust, remove cleanup.
(osdata_item_clear): Remove.
(get_osdata): return a unique_ptr and adjust.
(get_osdata_column): Return a pointer to std::string and adjust.
(info_osdata): Adjust.
* mi/mi-main.c: Include <map>.
(free_vector_of_osdata_items): Remove.
(list_available_thread_groups): Adjust, use std::map instead of
splay tree.

6 years agoShow optimized out local variables in "info locals"
Simon Marchi [Wed, 22 Nov 2017 20:51:44 +0000 (15:51 -0500)]
Show optimized out local variables in "info locals"

Currently, optimized out variables are not shown when doing "info
locals".  Some users found that confusing, thinking GDB forgot to print
their variable.  This patch adds them to the "info locals" output.  I
added a test in gdb.dwarf2 to test for that behavior.  I think doing a
synthetic DWARF test is the easiest way to have an optimized out local
variable for sure.

However, this change reveals what I think is a bug in GDB, see:

http://lists.dwarfstd.org/pipermail/dwarf-discuss-dwarfstd.org/2017-September/004394.html

This patch marks the tests in inline-locals.exp that start failing as
KFAIL.  I'd like to tackle this bug eventually, but I don't have the
time right now.  I think it's still better to show an extra erroneous
entry than to not show the optimized out variables at all.  I haven't
created a bug in bugzilla yet, but if we agree it's indeed a bug,  I'll
create one and update the setup_kfail lines with the actual bug number
before pushing.

gdb/ChangeLog:

* stack.c (iterate_over_block_locals): Add LOC_OPTIMIZED_OUT
case in switch.

gdb/testsuite/ChangeLog:

* gdb.opt/inline-locals.exp: Mark tests as KFAIL.
* gdb.dwarf2/info-locals-optimized-out.exp: New file.
* gdb.dwarf2/info-locals-optimized-out.c: New file.

6 years agoRemove DEF_VEC_P (varobj_p)
Simon Marchi [Wed, 22 Nov 2017 20:08:07 +0000 (15:08 -0500)]
Remove DEF_VEC_P (varobj_p)

The last patch removed the last usage of this type, so we can remove it.

gdb/ChangeLog:

* varobj.h (DEF_VEC_P (varobj_p)): Remove.

6 years agoReplace VEC (varobj_update_result) with std::vector
Simon Marchi [Wed, 22 Nov 2017 20:08:06 +0000 (15:08 -0500)]
Replace VEC (varobj_update_result) with std::vector

This patch replaces makes varobj_update return an std::vector, and
updates the fallouts.

To make that easier, the varobj_update_result is c++ified a bit.  I
added a constructor and initialized its fields in-class.  The newobj
vector is also made an std::vector, so that it's automatically freed
when varobj_update_result is destroyed and handled correctly by the
default move constructor.  I disabled copy constructor and assignment
for that structure, because normally it never needs to be copied, only
moved.

As a result, the newobj parameter of update_dynamic_varobj_children must
be changed to an std::vector.  The patch converts the other vector
parameters of update_dynamic_varobj_children to std::vector.  It's not
strictly necessary to do it in the same patch, but I think it makes
sense to do it.

gdb/ChangeLog:

* varobj.h (struct varobj_update_result): Add constructor, add
move constructor, disable copy and assign, initialize fields.
<newobj>: Change type to std::vector.
(varobj_update): Return std::vector.
* varobj.c (install_dynamic_child): Change VEC parameters to
std::vector and adjust.
(update_dynamic_varobj_children): Likewise.
(varobj_update): Return std::vector and adjust.
* mi/mi-cmd-var.c (varobj_update_one): Adjust to vector changes.

6 years agoMake varobj::children an std::vector
Simon Marchi [Wed, 22 Nov 2017 20:08:06 +0000 (15:08 -0500)]
Make varobj::children an std::vector

This patch makes the children field of varobj an std::vector, and
updates the fallout.

One note is that varobj::parent must be made non-const.  The reason is
that when a child deletes itself, it modifies its writes NULL to its
slot in its parent's children vector.  With the VEC, the const didn't
made the parent's children vector content const, only the pointer to it,
but with std::vector, even the content is.

gdb/ChangeLog:

* varobj.h (struct varobj) <parent>: Remove const.
<children>: Change type to std::vector.
(varobj_list_children): Return std::vector const reference.
(varobj_restrict_range): Change parameter type to std::vector
const reference.
* varobj.c (varobj_has_more): Adjust.
(varobj_restrict_range): Change parameter type to std::vector
const reference and adjust.
(install_dynamic_child): Adjust.
(update_dynamic_varobj_children): Adjust.
(varobj_list_children): Return std::vector const reference and
adjust.
(varobj_add_child): Adjust.
(update_type_if_necessary): Adjust.
(varobj_update): Adjust.
(delete_variable_1): Adjust.
* ada-varobj.c (ada_value_has_mutated): Adjust.
* mi/mi-cmd-var.c (mi_cmd_var_list_children): Adjust.

6 years agoBasic c++ification of varobj
Simon Marchi [Wed, 22 Nov 2017 20:08:05 +0000 (15:08 -0500)]
Basic c++ification of varobj

This patch does a basic c++ification or the varobj data structure.

  - varobj: add constructor and destructor, initialize fields
  - varobj_root: initialize fields
  - varobj_dynamic: initialize fields

This allows getting rid of new_variable, new_root_variable.
free_variable essentially becomes varobj's destructor.  This also allows
getting rid of a cleanup, make_cleanup_free_variable, which was only
used in varobj_create in case the varobj creation fails.  It is replaced
with a unique_ptr.

gdb/ChangeLog:

* varobj.h (struct varobj): Add constructor and destructor,
initialize fields.
* varobj.c (struct varobj_root): Initialize fields.
(struct varobj_dynamic): Initialize fields.
(varobj_create): Use unique_ptr instead of cleanup.  Create
varobj with new instead of new_root_variable.
(delete_variable_1): Free variable with delete instead of
free_variable.
(create_child_with_value): Create variable with new instead of
new_variable.
(varobj::varobj): New.
(varobj::~varobj): New (body mostly coming from free_variable).
(new_variable): Remove.
(free_variable): Remove.
(do_free_variable_cleanup): Remove.
(make_cleanup_free_variable): Remove.

6 years agoRiscv ld-elf/stab failure and fake label cleanup.
Jim Wilson [Wed, 22 Nov 2017 19:20:48 +0000 (11:20 -0800)]
Riscv ld-elf/stab failure and fake label cleanup.

* as.c: Include write.h.
(common_emul_init): Use FAKE_LABEL_NAME.
* ecoff.c (add_file, ecoff_directive_end, ecoff_directive_loc):
Likewise.
(ecoff_build_symbols): Use FAKE_LABEL_CHAR.
* expr.c (get_symbol_name): Use FAKE_LABEL_CHAR.  Accept only if
input_from_string is TRUE.
* read.c (input_from_string): New.
(read_symbol_name): Use FAKE_LABEL_CHAR.  Accept only if
input_from_string is TRUE.
(temp_ilp): Set input_from_string to TRUE.
(restore_ilp): Set input_from_string to FALSE.
* read.h (input_from_string): Declare.
* symbols.c: Include write.h
(S_IS_LOCAL): Check for FAKE_LABEL_CHAR.
(symbol_relc_make_sym): Fix comment refering to default fake label
string.
* write.h (FAKE_LABEL_CHAR): New.
* config/tc-riscv.h (FAKE_LABEL_CHAR): Define.
* testsuite/gas/all/err-fakelabel.s: New.

6 years agoUpdate docs on filling text with nops.
Jim Wilson [Wed, 22 Nov 2017 19:09:30 +0000 (11:09 -0800)]
Update docs on filling text with nops.

gas/
* doc/as.texinfo (.align): Change some to most for text nop fill.
(.balign, .p2align): Likewise.

6 years agoRemove obsolete core-regset.c
Ulrich Weigand [Wed, 22 Nov 2017 18:57:05 +0000 (19:57 +0100)]
Remove obsolete core-regset.c

The last target that used core-regset.c (FreeBSD/alpha) has been
removed with GDB 8.0, and since then this file is obsolete.

6 years ago[testsuite] Pass pthreads in prepare_for_testing
Yao Qi [Wed, 22 Nov 2017 16:50:53 +0000 (16:50 +0000)]
[testsuite] Pass pthreads in prepare_for_testing

"pthreads" in the right flag to pass in prepare_for_testing to linker,
instead of additional_flags.  Without this patch, the test case can't be
complied by clang.

gdb compile failed, clang: warning: -lpthread: 'linker' input unused

gdb/testsuite:

2017-11-22  Yao Qi  <yao.qi@linaro.org>

* gdb.base/info-os.exp: Pass pthreads.
* gdb.multi/multi-attach.exp: Likewise.

6 years ago[testsuite] Don't skip gdb.dwarf2/pr10770.exp for non-gcc compiler
Yao Qi [Wed, 22 Nov 2017 14:46:30 +0000 (14:46 +0000)]
[testsuite] Don't skip gdb.dwarf2/pr10770.exp for non-gcc compiler

gdb.dwarf2/pr10770.exp can be used for non-gcc compiler, at least clang.
This patch removes the restriction to only use gcc.  If other compilers,
like xlc or icc, can't compile the .c file, test result is not changed.

gdb/testsuite:

2017-11-22  Yao Qi  <yao.qi@linaro.org>

* gdb.dwarf2/pr10770.exp: Remove code skipping non-gcc
compiler.

6 years agoRemove Vec_Disp8 field for vgf2p8mulb for AVX flavor.
Igor Tsimbalist [Mon, 20 Nov 2017 16:23:28 +0000 (19:23 +0300)]
Remove Vec_Disp8 field for vgf2p8mulb for AVX flavor.

* i386-opc.tbl: Remove Vec_Disp8 from vgf2p8mulb.
* i386-tbl.h: Regenerate.

6 years ago[testsuite] Pass -pie in ldflags
Yao Qi [Wed, 22 Nov 2017 14:35:01 +0000 (14:35 +0000)]
[testsuite] Pass -pie in ldflags

-pie is a linker flag, it should be passed via "ldflags", instead
of "additional_flags".  Otherwise, clang complains,

clang: warning: argument unused during compilation: '-pie'

gdb/testsuite:

2017-11-22  Yao Qi  <yao.qi@linaro.org>

* gdb.base/attach-pie-noexec.exp: Pass "-pie" in ldflags.
* gdb.base/break-interp.exp: Likewise.
* gdb.base/jit-attach-pie.exp: Likewise.

6 years agoUpdate ChangeLog
Igor Tsimbalist [Wed, 22 Nov 2017 14:23:38 +0000 (17:23 +0300)]
Update ChangeLog

6 years agoRemove Vec_Disp8 from vpcompressb and vpexpandb.
Igor Tsimbalist [Mon, 20 Nov 2017 16:14:32 +0000 (19:14 +0300)]
Remove Vec_Disp8 from vpcompressb and vpexpandb.

* i386-opc.tbl: Remove Vec_Disp8 from vpcompressb and vpexpandb.
* i386-tbl.h: Regenerate.

6 years ago[GAS/ARM] Clarify relation between reg_expected_msgs and arm_reg_type
Thomas Preud'homme [Wed, 22 Nov 2017 14:02:49 +0000 (14:02 +0000)]
[GAS/ARM] Clarify relation between reg_expected_msgs and arm_reg_type

Uses of reg_expected_msgs rely on each arm_reg_type enumerator to have a
message entry in the same order as the enumerator declaration. This is
not clearly stated in the definition of both the arm_reg_type enum and
the reg_expected_msgs. Worse, there is nothing to ensure both are kept
in sync.

As an attempt towards this, this patch uses C99 array designators to
ensure that each message is associated with the right arm_reg_type. A
comment is also added near the definition of arm_reg_type to point to
the reg_expected_msgs array. Finally, the array is synced with
arm_reg_type by adding the missing error message for REG_TYPE_RNB.

2017-11-22  Thomas Preud'homme  <thomas.preudhomme@arm.com>

gas/
* config/tc-arm.c (arm_reg_type): Comment on the link with
reg_expected_msgs.
(reg_expected_msgs): Initialize using array designators with
arm_reg_type index.

6 years agoTarget FP: Make use of MPFR if available
Ulrich Weigand [Wed, 22 Nov 2017 12:53:43 +0000 (13:53 +0100)]
Target FP: Make use of MPFR if available

This second patch introduces mfpr_float_ops, an new implementation
of target_float_ops.  This implements precise emulation of target
floating-point formats using the MPFR library.  This is then used
to perform operations on types that do not match any host type.

Note that use of MPFR is still not required.  The patch adds
a configure option --with-mpfr similar to --with-expat.  If use of
MPFR is disabled via the option or MPFR is not available, code will
fall back to current behavior.  This means that operations on types
that do not match any host type will be implemented on the host
long double type instead.

A new test case verifies that we can correctly print the largest
__float128 value now.

gdb/ChangeLog:
2017-11-22  Ulrich Weigand  <uweigand@de.ibm.com>

* NEWS: Document use of GNU MPFR.
* README: Likewise.

* Makefile.in (LIBMPFR): Add define.
(CLIBS): Add $(LIBMPFR).
* configure.ac: Add --with-mpfr configure option.
* configure: Regenerate.
* config.in: Regenerate.

* target-float.c [HAVE_LIBMPFR]: Include <mpfr.h>.
(class mpfr_float_ops): New type.
(mpfr_float_ops::from_target): Two new overloaded functions.
(mpfr_float_ops::to_target): Likewise.
(mpfr_float_ops::to_string): New function.
(mpfr_float_ops::from_string): Likewise.
(mpfr_float_ops::to_longest): Likewise.
(mpfr_float_ops::from_longest): Likewise.
(mpfr_float_ops::from_ulongest): Likewise.
(mpfr_float_ops::to_host_double): Likewise.
(mpfr_float_ops::from_host_double): Likewise.
(mpfr_float_ops::convert): Likewise.
(mpfr_float_ops::binop): Likewise.
(mpfr_float_ops::compare): Likewise.
(get_target_float_ops): Use mpfr_float_ops if available.

gdb/doc/ChangeLog:
2017-11-22  Ulrich Weigand  <uweigand@de.ibm.com>

* gdb.texinfo (Requirements): Document use of GNU MPFR.

gdb/testsuite/ChangeLog:
2017-11-22  Ulrich Weigand  <uweigand@de.ibm.com>

* gdb.base/float128.c (large128): New variable.
* gdb.base/float128.exp: Add test to print largest __float128 value.

6 years agoTarget FP: Refactor use of host floating-point arithmetic
Ulrich Weigand [Wed, 22 Nov 2017 12:51:49 +0000 (13:51 +0100)]
Target FP: Refactor use of host floating-point arithmetic

Prepare for using MPFR to implement floating-point arithmetic by
refactoring the way host floating-point arithmetic is currently used.

In particular, fix the following two problems that cause different
(and incorrect) results due to using host arithmetic:

- Current processing always uses host "long double", and then converts
  back to the actual target format.  This may introduce rounding errors.

- Conversion of FP values to LONGEST simply does a host C++ type cast.
  However the result of such a cast is undefined if the source value
  is outside the representable range.  MPFR always has defined behavior
  here (returns the minimum or maximum representable value).

To fix the first issue, I've now created not just one set of routines
using host FP arithmetic (on long double), but instead three different
sets of routines, one each for host float, double, and long double.
Operations can then be performed in the desired type directly, avoiding
the extra rounding step.  Using C++ templates, the three sets can all
share the same source code without duplication.

To fix the second issue, I'm simply enforcing the same conversion rule
(which makes sense anyway) when converting out-of-range values from
FP to LONGEST.

To contain the code complexity with the variety of options now possible,
I've created a new class "target_float_ops".  There are a total of five
separate implementations of this:

  host_float_ops<float>        Implemented via host FP in given type
  host_float_ops<double>
  host_float_ops<long double>
  mpfr_float_ops               Implemented via MPFR if available
  decimal_float_ops            Implemented via libdecnumber

Note instead of using the DOUBLEST define, this always just uses the
"long double" data type.  But since we now require C++11 anyway, this
type must in any case be avaialble unconditionally.

Most target floating-point operations simply dispatch to a (virtual)
member routine of this class.  Which implementation to choose is
determined from the target types involved, and whether they match
some host type or not.  E.g. any operation on a single type that
matches a host type is performed in that type.  Operations involving
two types that both match host types are performed in the larger one
(according to C/C++ implicit conversion rules).  Operations that
involve any type that does not match a host type are performed using
MPFR.  (And of course operations involving decimal FP are performed
using libdecnumber.)

This first patch implements the refactoring of target-float.c as
described above, introduing the host_float_ops and decimal_float_ops
classes, and using them.  Use of MPFR is introduced in the second patch.
A bit of special-case handling code is moved around to as to avoid
code duplication between host_float_ops and mpfr_float_ops.

Note that due to the changes mentioned above, I've had to update (fix)
the floating-point register values tested in the gdb.arch/vsx-regs.exp
test case.  (The new values now work both with host arithmetic and MPFR.)

gdb/ChangeLog:
2017-11-22  Ulrich Weigand  <uweigand@de.ibm.com>

* target-float.c: Do not include <math.h>.
Include <cmath> and <limits>.
(DOUBLEST): Do not define.
(class target_float_ops): New type.
(class host_float_ops): New templated type.
(class decimal_float_ops): New type.

(floatformat_to_doublest): Rename to ...
(host_float_ops<T>::from_target): ... this.  Use template type T
instead of DOUBLEST.  Use C++ math routines.  Update recursive calls.
(host_float_ops<T>::from_target): New overload using a type argument.
(floatformat_from_doublest): Rename to ...
(host_float_ops<T>::to_target): ... this.  Use template type T
instead of DOUBLEST.  Use C++ math routines.  Update recursive calls.
(host_float_ops<T>::to_target): New overload using a type argument.
(floatformat_printf_format): New function.
(struct printf_length_modifier): New templated type.
(floatformat_to_string): Rename to ...
(host_float_ops<T>::to_string): ... this.  Use type instead of
floatformat argument.  Use floatformat_printf_format and
printf_length_modifier.  Remove special handling of invalid numbers,
infinities and NaN (moved to target_float_to_string).
(struct scanf_length_modifier): New templated type.
(floatformat_from_string): Rename to ...
(host_float_ops<T>::from_string): ... this.  Use type instead of
floatformat argument.  Use scanf_length_modifier.
(floatformat_to_longest): Rename to ...
(host_float_ops<T>::to_longest): ... this.  Use type instead of
floatformat argument.  Handle out-of-range values deterministically.
(floatformat_from_longest): Rename to ...
(host_float_ops<T>::from_longest): ... this.  Use type instead of
floatformat argument.
(floatformat_from_ulongest): Rename to ...
(host_float_ops<T>::from_ulongest): ... this.  Use type instead of
floatformat argument.
(floatformat_to_host_double): Rename to ...
(host_float_ops<T>::to_host_double): ... this.  Use type instead of
floatformat argument.
(floatformat_from_host_double): Rename to ...
(host_float_ops<T>::from_host_double): ... this.  Use type instead of
floatformat argument.
(floatformat_convert): Rename to ...
(host_float_ops<T>::convert): ... this.  Use type instead of
floatformat arguments.  Remove handling of no-op conversions.
(floatformat_binop): Rename to ...
(host_float_ops<T>::binop): ... this.  Use type instead of
floatformat arguments.
(floatformat_compare): Rename to ...
(host_float_ops<T>::compare): ... this.  Use type instead of
floatformat arguments.

(match_endianness): Use type instead of length/byte_order arguments.
(set_decnumber_context): Likewise.
(decimal_from_number): Likewise.  Update calls.
(decimal_to_number): Likewise.
(decimal_is_zero): Likewise.  Update calls.  Move to earlier in file.
(decimal_float_ops::to_host_double): New dummy function.
(decimal_float_ops::from_host_double): Likewise.
(decimal_to_string): Rename to ...
(decimal_float_ops::to_string): ... this.  Use type instead of
length/byte_order arguments.  Update calls.
(decimal_from_string): Rename to ...
(decimal_float_ops::from_string): ... this.  Use type instead of
length/byte_order arguments.  Update calls.
(decimal_from_longest): Rename to ...
(decimal_float_ops::from_longest): ... this.  Use type instead of
length/byte_order arguments.  Update calls.
(decimal_from_ulongest): Rename to ...
(decimal_float_ops::from_ulongest): ... this.  Use type instead of
length/byte_order arguments.  Update calls.
(decimal_to_longest): Rename to ...
(decimal_float_ops::to_longest): ... this.  Use type instead of
length/byte_order arguments.  Update calls.
(decimal_binop): Rename to ...
(decimal_float_ops::binop): ... this.  Use type instead of
length/byte_order arguments.  Update calls.
(decimal_compare): Rename to ...
(decimal_float_ops::compare): ... this.  Use type instead of
length/byte_order arguments.  Update calls.
(decimal_convert): Rename to ...
(decimal_float_ops::convert): ... this.  Use type instead of
length/byte_order arguments.  Update calls.

(target_float_same_category_p): New function.
(target_float_same_format_p): Likewise.
(target_float_format_length): Likewise.
(enum target_float_ops_kind): New type.
(get_target_float_ops_kind): New function.
(get_target_float_ops): Three new overloaded functions.

(target_float_is_zero): Update call.
(target_float_to_string): Add special handling of invalid numbers,
infinities and NaN (moved from floatformat_to_string).  Use
target_float_ops callback.
(target_float_from_string): Use target_float_ops callback.
(target_float_to_longest): Likewise.
(target_float_from_longest): Likewise.
(target_float_from_ulongest): Likewise.
(target_float_to_host_double): Likewise.
(target_float_from_host_double): Likewise.
(target_float_convert): Add special case for no-op conversions.
Use target_float_ops callback.
(target_float_binop): Use target_float_ops callback.
(target_float_compare): Likewise.

gdb/testsuite/ChangeLog:
2017-11-22  Ulrich Weigand  <uweigand@de.ibm.com>

* gdb.arch/vsx-regs.exp: Update register content checks.

6 years agoFix build with GCC 8: strncpy ->strcpy
Yao Qi [Wed, 22 Nov 2017 12:22:11 +0000 (12:22 +0000)]
Fix build with GCC 8: strncpy ->strcpy

Recent gcc 8 trunk emits the warning below,

../../binutils-gdb/gdb/python/py-gdb-readline.c:79:15: error: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
       strncpy (q, p, n);
       ~~~~~~~~^~~~~~~~~
../../binutils-gdb/gdb/python/py-gdb-readline.c:73:14: note: length computed here
   n = strlen (p);
       ~~~~~~~^~~

gdb:

2017-11-22  Yao Qi  <yao.qi@linaro.org>

* python/py-gdb-readline.c (gdbpy_readline_wrapper): Use strcpy.

6 years agoFix build with GCC 8: strncpy -> memcpy
Yao Qi [Wed, 22 Nov 2017 12:22:11 +0000 (12:22 +0000)]
Fix build with GCC 8: strncpy -> memcpy

Recent gcc 8 trunk emits the warning below,

../../../binutils-gdb/gdb/gdbserver/remote-utils.c:1204:14: error: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying 6 bytes from a string of the same length [-Werror=stringop-truncation]
      strncpy (buf, "watch:", 6);
      ~~~~~~~~^~~~~~~~~~~~~~~~~~

../../binutils-gdb/gdb/cli/cli-decode.c:1118:15: error: ‘char* strncpy(char*, const char*, size_t)’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
       strncpy (cmdtype1 + 1, cmdtype, len - 1);
       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../binutils-gdb/gdb/cli/cli-decode.c:1110:16: note: length computed here
   len = strlen (cmdtype);
         ~~~~~~~^~~~~~~~~
../../binutils-gdb/gdb/cli/cli-decode.c:1120:15: error: ‘char* strncpy(char*, const char*, size_t)’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
       strncpy (cmdtype2, cmdtype, len - 1);
       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../binutils-gdb/gdb/cli/cli-decode.c:1110:16: note: length computed here
   len = strlen (cmdtype);
         ~~~~~~~^~~~~~~~~

../../binutils-gdb/gdb/cp-namespace.c:1071:11: error: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying 2 bytes from a string of the same length [-Werror=stringop-truncation]
   strncpy (full_name + scope_length, "::", 2);
   ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This patch fixes it by using memcpy instead of strncpy.

gdb:

2017-11-22  Yao Qi  <yao.qi@linaro.org>

* cli/cli-decode.c (help_list): Use memcpy instead of strncpy.
* cp-namespace.c (cp_lookup_transparent_type_loop): Likewise.

gdb/gdbserver:

2017-11-22  Yao Qi  <yao.qi@linaro.org>

* remote-utils.c (prepare_resume_reply): Use memcpy.

6 years ago[ARC] Fix handling of ARCv2 H-register class.
claziss [Wed, 22 Nov 2017 09:46:45 +0000 (10:46 +0100)]
[ARC] Fix handling of ARCv2 H-register class.

For ARCv2, h-regs are only valid unitl r31.

gas/
2017-11-21  Claudiu Zissulescu <claziss@synopsys.com>

        * testsuite/gas/arc/hregs-err.s: New test.

opcodes/
2017-11-21  Claudiu Zissulescu <claziss@synopsys.com>

        * arc-opc.c (insert_rhv2): Check h-regs range.

6 years agox86: Add tests for -n option of x86 assembler
H.J. Lu [Wed, 22 Nov 2017 00:44:29 +0000 (16:44 -0800)]
x86: Add tests for -n option of x86 assembler

The -n command-line of x86 assembler disables optimization of alignment
directives, like ".balign 8, 0x90", with multi-byte nop instructions
such as leal 0(%esi),%esi.

PR gas/22464
* testsuite/gas/i386/align-1.s: New file.
* testsuite/gas/i386/align-1a.d: Likewise.
* testsuite/gas/i386/align-1b.d: Likewise.
* testsuite/gas/i386/i386.exp: Run align-1a and align-1b.

6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 22 Nov 2017 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoravenscar: update inferior ptid with event ptid
Jerome Guitton [Tue, 21 Nov 2017 22:10:01 +0000 (14:10 -0800)]
ravenscar: update inferior ptid with event ptid

When debugging a program using a ravenscar runtime, the thread
layer sometimes gets confused, and even missing some threads.
This was traced to an assumption that ravenscar_wait was making,
which is that calling the "to_wait" target_ops method would
set the inferior_ptid, so that we could then use that assumption
to update our thread_list and current ptid. However, this has not
been the case for quite a while now. This patch fixes the problem
by assigning inferior_ptid the ptid returned by "to_wait".

gdb/ChangeLog:

* ravenscar-thread.c (ravenscar_wait): Update inferior ptid
with event ptid from the lower layer before doing the
ravenscar-specific update.

6 years ago(Ada) crash connecting to TSIM simulator
Joel Brobecker [Tue, 21 Nov 2017 22:04:38 +0000 (14:04 -0800)]
(Ada) crash connecting to TSIM simulator

Connecting to a TSIM simulator over the remote protocol causes GDB
to crash with the following failed assertion:

    (gdb) tar remote :1234
    Remote debugging using :1234
    /[...]/gdb/ravenscar-thread.c:182: internal-error: ravenscar_update_inferior_ptid: Assertion `!is_ravenscar_task (inferior_ptid)' failed.
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    Quit this debugging session? (y or n) y

What happens is the following. Upon connection to the target, GDB
sends a 'qfThreadInfo' query, which is the query asking the target
for the ID of the first thread, and TSIM replies 'm0':

    Sending packet: $qfThreadInfo#bb...Ack
    Packet received: m0

As a result of this, GDB takes the '0' as the TID, and because of it,
constructs a ptid whose value is {42000, 0, 0}. This trips our
!is_ravenscar_task check, because all it does to identify threads
corresponding to ravenscar tasks is that their lwp is null, because
that's how we construct their ptid.

But this is unfortunatly not sufficient when debugging with TSIM,
because the thread ID that TSIM returns causes the creation of
a ptid whose lwp is zero, which matches the current identification
scheme and yet is clearly not a ravenscar task.

The fix is to also make sure that the ptid's tid field is nonzero.

gdb/ChangeLog:

        * ravenscar-thread.c (is_ravenscar_task): Also verify that
        the ptid's TID is nonzero.

6 years agoproblem debugging ravenscar programs if runtime is stripped
Joel Brobecker [Tue, 21 Nov 2017 22:03:06 +0000 (14:03 -0800)]
problem debugging ravenscar programs if runtime is stripped

Trying to debug a program using a stripped version of the ravenscar
runtime, we can get the following error:

    (gdb) cont
    Continuing.
    Cannot find Ada_Task_Control_Block type. Aborting

This is because the ravenscar-thread layer makes the assumption that
the runtime is built the way we expect it, meaning that the Ada tasking
units we rely on for Ada tasking debugging, are built with debugging
information, and that this debug information has not been stripped from
the runtime.

When this assumption is not true, resuming such a program can trigger
the error above, which then leads GDB a little confused. For instance,
we can see things like:

     (gdb) bt
     Target is executing.

This patch fixes the issue by disabling the ravenscar thread layer
if we detect that the runtime is missing some of the debugging info
we need in order to support Ada task debugging. This is the best
we can do, as the ravenscar-thread layer actually depends on the
ada-tasks layer to implement thread debugging.

gdb/ChangeLog:

        * ada-lang.h (ada_get_tcb_types_info): Add declaration.
        * ada-tasks.c (ada_get_tcb_types_info): Renames get_tcb_types_info.
        Make non-static.  Change return type to char *.  Adjust code
        accordingly.  Rewrite the function's documentation.
        (read_atcb): Adjust call to get_tcb_types_info accordingly.
        * ravenscar-thread.c (ravenscar_inferior_created): Check that
        we have enough debugging information in the runtime to support
        Ada task debugging before we enable the ravenscar-thread layer.

6 years agoAdd multiple-CPU support in ravenscar-thread.c
Joel Brobecker [Tue, 21 Nov 2017 22:00:30 +0000 (14:00 -0800)]
Add multiple-CPU support in ravenscar-thread.c

This patch reworks the ravenscar-thread layer to remove the
assumption that the target only has 1 CPU. In particular,
when connected to a QEMU target over the remote protocol,
QEMU reports each CPU as one thread. This patch adapts
the ravenscar-thread layer to this, and adds a large comment
explaining the general design of this unit.

gdb/ChangeLog:

        * ada-lang.h (ada_get_task_info_from_ptid): Add declaration.
        * ada-tasks.c (ada_get_task_info_from_ptid): New function.
        * ravenscar-thread.c: Add into comment.
        (base_magic_null_ptid): Delete.
        (base_ptid): Change documentation.
        (ravenscar_active_task): Renames ravenscar_running_thread.
        All callers updated throughout.
        (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function.
        (ravenscar_task_is_currently_active): Likewise.
        (get_base_thread_from_ravenscar_task): Ditto.
        (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs.
        (ravenscar_runtime_initialized): Likewise.
        (get_running_thread_id): Add new parameter "cpu".  Adjust
        implementation to handle this new parameter.
        (ravenscar_fetch_registers): Small adjustment to use
        is_ravenscar_task and ravenscar_task_is_currently_active in
        order to decide whether to use the target beneath or this
        module's arch_ops.
        (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise.
        (ravenscar_stopped_by_sw_breakpoint): Use
        get_base_thread_from_ravenscar_task to get the underlying
        thread, rather than using base_ptid.
        (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint)
        (ravenscar_stopped_data_address, ravenscar_core_of_thread):
        Likewise.
        (ravenscar_inferior_created): Do not set base_magic_null_ptid.

6 years agoProvide the "Base CPU" in output of "info task" (if set by runtime).
Joel Brobecker [Tue, 21 Nov 2017 21:58:00 +0000 (13:58 -0800)]
Provide the "Base CPU" in output of "info task" (if set by runtime).

At the user level, this patch enhances the debugger to print the ID
of the base CPU a task is running on:

        (gdb) info task 3
        Ada Task: 0x13268
        Name: raven1
        Thread: 0x13280
        LWP: 0
 !!!->  Base CPU: 1
        No parent
        Base Priority: 127
        State: Runnable

This new field is only printed when the base CPU is nonzero or, in
other words, if the base CPU info is being provided by the runtime.
For instance, on native systems, where threads/processes can "jump"
from CPU to CPU, the info is not available, and the output of the
command above then remains unchanged.

At the internal level, the real purpose of this change is to prepare
the way for ravenscar-thread to start handling SMP systems. For that,
we'll need to know which CPU each task is running on...  More info
on that in the commit that actually adds support for it.

gdb/ChangeLog:

        * ada-lang.h (struct ada_task_info) <base_cpu>: New field.
        * ada-lang.c (struct atcb_fieldno) <base_cpu>: New field.
        (get_tcb_types_info): Set fieldnos.base_cpu.
        (read_atcb): Set task_info->base_cpu.
        (info_task): Print "Base CPU" info if set by runtime.

6 years agowatchpoint regression debugging with remote protocol (bare metal)
Joel Brobecker [Tue, 21 Nov 2017 21:42:48 +0000 (13:42 -0800)]
watchpoint regression debugging with remote protocol (bare metal)

We have noticed a regression in our watchpoint support when debugging
through the remote protocol a program running on a bare metal platform,
when the program uses what we call the Ravenscar Runtime.

This runtime is a subset of the Ada runtime defined by the Ravenscar
Profile.  One of the nice things about this runtime is that it provides
tasking, which is equivalent to the concept of threads in C (it is
actually often mapped to threads, when available). For bare metal
targets, however, there is no OS, and therefore no thread layer.
What we did, then, was add a ravenscar-thread layer, which has insider
knowledge of the runtime to get the list of threads, but also all
necessary info to perform thread switching.

For the record, the commit which caused the regression is:

    commit 799a2abe613be0645b84f5aaa050f2f91e6ae3f7
    Date:   Mon Nov 30 16:05:16 2015 +0000
    Subject: remote: stop reason and watchpoint data address per thread

    Running local-watch-wrong-thread.exp with "maint set target-non-stop
    on" exposes that gdb/remote.c only records whether the target stopped
    for a breakpoint/watchpoint plus the watchpoint data address *for the
    last reported remote event*.  But in non-stop mode, we need to keep
    that info per-thread, as each thread can end up with its own
    last-status pending.

Our testcase is very simple. We have a package defining a global
variable named "Watch"...

    package Pck is
       Watch : Integer := 1974;
    end Pck;

... and a main subprogram which changes its value

    procedure Foo is
    begin
       Pck.Watch := Pck.Watch + 1;
    end Foo;

To reproduce, we built our program as usual, started it in QEMU,
and then connected GDB to QEMU...

    (gdb) target remote :4444
    (gdb) break _ada_foo
    (gdb) cont  <--- this is to make sure the program is started
                     and the variable we want to watch is initialized

... at which point we try to use a watchpoint on our global variable:

    (gdb) watch watch

... but, upon resuming the execution with a "cont", we expected to
get a watchpoint-hit notification, such as...

    (gdb) cont
    Hardware watchpoint 2: watch

    Old value = 1974
    New value = 1975
    0xfff00258 in foo () at /[...]/foo.adb:6
    6       end Foo;

... but unfortunately, we get a SIGTRAP instead:

    (gdb) cont
    Program received signal SIGTRAP, Trace/breakpoint trap.
    foo () at /[...]/foo.adb:6
        6   end Foo;

What happens is that, on the one hand, the change in remote.c
now stores the watchpoint-hit notification info in the thread
that received it; and on the other hand, we have a ravenscar-thread
layer which manages the thread list on top of the remote protocol
layer. The two of them get disconnected, and this eventually results
in GDB not realizing that we hit a watchpoint.  Below is how:

First, once connected and just before inserting our watchpoint,
we have the ravenscar-thread layer which built the list of threads
by extracting some info from inferior memory, giving us the following
two threads:

      (gdb) info threads
      Id   Target Id         Frame
      1    Thread 0 "0Q@" (Ravenscar task) foo () at /[...]/foo.adb:5
    * 2    Thread 0x24618 (Ravenscar task) foo () at /[...]/foo.adb:5

The first thread is the only thread QEMU told GDB about. The second
one is a thread that the ravenscar-thread added. QEMU has now way
to know about those threads, since they are really embedded inside
the program; that's why we have the ravenscar layer, which uses
inside-knowledge to extract the list of threads.

Next, we insert a watchpoint, which applies to all threads. No problem
so far.

Then, we continue; meaning that GDB sends a Z2 packet to QEMU to
get the watchpoint inserted, then a vCont to resume the program's
execution. The program hits the watchpoints, and thererfore QEMU
reports it back:

        Packet received: T05thread:01;watch:000022c4;

Since QEMU knows about one thread and one thread only, it stands
to reason that it would say that the event applies to thread:01,
which is our first thread in the "info threads" listing. That
thread has a ptid of {42000, lwp=1, tid=0}.

This is where Pedro's change kicks in: Seeing this event, and
having determined that the event was reported for thread 01,
and therefore ptid {42000, lwp=1, tid=0}, it saves the watchpoint-hit
event info in the private area of that thread/ptid. Once this is
done, remote.c's event-wait layer returns.

Enter the ravenscar-thread layer of the event-wait, which does
a little dance to delegate the wait to underlying layers with
ptids that those layers know about, and then when the target_beneath's
to_wait is done, tries to figure out which thread is now the active
thread. The code looks like this:

  1.    inferior_ptid = base_ptid;
  2.    beneath->to_wait (beneath, base_ptid, status, 0);
  3.    [...]
  4.        ravenscar_update_inferior_ptid ();
  5.
  6.    return inferior_ptid;

Line 1 is where we reset inferior_ptid to the ptid that
the target_beneath layer knows about, allowing us to then
call its to_wait implementation (line 2). And then, upon
return, we call ravenscar_update_inferior_ptid, which reads
inferior memory to determine which thread is actually active,
setting inferior_ptid accordingly. Then we return that
inferior_ptid (which, again, neither QEMU and therefore nor
the remote.c layer knows about).

Upon return, we eventually arrive to the part where we try
to handle the inferior event: we discover that we got a SIGTRAP
and, as part of its handling, we call watchpoints_triggered,
which calls target_stopped_by_watchpoint, which eventually
remote_stopped_by_watchpoint, where Pedro's change kicks in
again:

    struct thread_info *thread = inferior_thread ();
    return (thread->priv != NULL
            && thread->priv->stop_reason == TARGET_STOPPED_BY_WATCHPOINT);

Because the ravenscar-thread layer changed the inferior_ptid
to the ptid of the active thread, inferior_thread now returns
the private data of that thread. This is not the thread that
QEMU reported the watchpoint-hit on, and thus, the function
returns "no watchpoint hit, mister". Hence GDB not understanding
the SIGTRAP, thus reporting it verbatim.

The way we chose to fix the issue is by making sure that the
ravenscar-thread layer doesn't let the remote layer be called
with inferior_ptid being set to a thread that the remote layer
does not know about.

gdb/ChangeLog:

        * ravenscar-thread.c (ravenscar_stopped_by_sw_breakpoint)
        (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint)
        (ravenscar_stopped_data_address, ravenscar_core_of_thread):
        New functions.
        (init_ravenscar_thread_ops): Set the to_stopped_by_sw_breakpoint,
        to_stopped_by_hw_breakpoint, to_stopped_by_watchpoint,
        to_stopped_data_address and to_core_of_thread fields of
        ravenscar_ops.

6 years agoAdd a test for PR binutils/22451
H.J. Lu [Tue, 21 Nov 2017 21:41:10 +0000 (13:41 -0800)]
Add a test for PR binutils/22451

Check in the object file generated from the older assembler as a
compressed file.

PR binutils/22451
* testsuite/binutils-all/x86-64/objects.exp: New file.
* testsuite/binutils-all/x86-64/pr22451.o.bz2: Likewise.

6 years ago[PowerPC] Detect different long double floating-point formats
Ulrich Weigand [Tue, 21 Nov 2017 17:50:59 +0000 (18:50 +0100)]
[PowerPC] Detect different long double floating-point formats

Current versions of GCC support switching the format used for "long double"
to either IBM double double or IEEE-128.  The resulting binary is marked
via different setting of the Tag_GNU_Power_ABI_FP GNU attribute.

This patch checks this attribute to detect the format of the default
"long double" type and sets GDB's notion of the format accordingly.

The patch also adds support for the "__ibm128" type, which always uses
IBM double double format independent of the format used for "long double".

A new test case verifies that all three types, "long double", "__float128",
and "__ibm128" are correctly detected in all three compiler settings,
the default setting, -mabi=ieeelongdouble, and -mabi=ibmlongdouble.

gdb/ChangeLog:
2017-11-21  Ulrich Weigand  <uweigand@de.ibm.com>

* ppc-tdep.h (enum powerpc_long_double_abi): New data type.
(struct gdbarch_tdep): New member long_double_abi.
* rs6000-tdep.c (rs6000_gdbarch_init): Initialize long_double_abi
member of tdep struct based on Tag_GNU_Power_ABI_FP attribute.
* ppc-linux-tdep.c (ppc_linux_init_abi): Install long double data
format depending on long_double_abi tdep member.
(ppc_floatformat_for_type): Handle __ibm128 type.

gdb/testsuite/ChangeLog:
2017-11-21  Ulrich Weigand  <uweigand@de.ibm.com>

* gdb.arch/ppc-longdouble.exp: New file.
* gdb.arch/ppc-longdouble.c: Likewise.

6 years agogdb.ada/minsyms.exp: Don't hardcode the variable's address
Pedro Alves [Tue, 21 Nov 2017 16:04:42 +0000 (16:04 +0000)]
gdb.ada/minsyms.exp: Don't hardcode the variable's address

This new testcase has a test that fails like this here:

  $1 = (<data variable, no debug info> *) 0x60208c <some_minsym>
  (gdb) FAIL: gdb.ada/minsyms.exp: print &some_minsym

The problem is that the testcase hardcodes an expected address for the
"some_minsym" variable, which obviously isn't stable.

Fix that by expecting $hex instead.

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

* gdb.ada/minsyms.exp: Accept any address for 'some_minsym'.

6 years agoStop the v850 linker from converting to other output formats whilst linking.
Nick Clifton [Tue, 21 Nov 2017 14:15:51 +0000 (14:15 +0000)]
Stop the v850 linker from converting to other output formats whilst linking.

PR 22419
* emultempl/v850elf.em (v850_create_output_section_statements):
New function.  Generate an error if attempting to convert the
format of the output file.
* testsuite/ld-unique/pr21529.d: Skip for the V850.
* testsuite/ld-elf/pr21884.d: Skip for the V850.

6 years ago[ARC] [COMMITTED] Update test pattern patching.
claziss [Tue, 21 Nov 2017 14:04:22 +0000 (15:04 +0100)]
[ARC] [COMMITTED] Update test pattern patching.

2017-11-21  Claudiu Zissulescu  <claziss@synopsys.com>

* testsuite/binutils-all/arc/objdump.exp: Update pattern matching
expression.

6 years ago[ARC] Improve printing of pc-relative instructions.
claziss [Tue, 21 Nov 2017 13:03:03 +0000 (14:03 +0100)]
[ARC] Improve printing of pc-relative instructions.

opcodes/
2017-11-21  Claudiu Zissulescu <claziss@synopsys.com>

* arc-dis.c (print_insn_arc): Pretty print pc-relative offsets.
* arc-opc.c (SIMM21_A16_5): Make it pc-relative.

gas/
2017-11-21  Claudiu Zissulescu <claziss@synopsys.com>

* testsuite/gas/arc/b.d : Update test.
* testsuite/gas/arc/bl.d: Likewise.
* testsuite/gas/arc/jli-1.d: Likewise.
* testsuite/gas/arc/lp.d: Likewise.
* testsuite/gas/arc/pcl-relocs.d: Likewise.
* testsuite/gas/arc/pcrel-relocs.d: Likewise.
* testsuite/gas/arc/pic-relocs.d: Likewise.
* testsuite/gas/arc/plt-relocs.d: Likewise.
* testsuite/gas/arc/pseudos.d: Likewise.
* testsuite/gas/arc/relax-avoid2.d: Likewise.
* testsuite/gas/arc/relax-avoid3.d: Likewise.
* testsuite/gas/arc/relax-b.d: Likewise.
* testsuite/gas/arc/tls-relocs.d: Likewise.
* testsuite/gas/arc/relax-add01.d: Likewise.
* testsuite/gas/arc/relax-add04.d: Likewise.
* testsuite/gas/arc/relax-ld01.d: Likewise.
* testsuite/gas/arc/relax-sub01.d: Likewise.
* testsuite/gas/arc/relax-sub02.d: Likewise.
* testsuite/gas/arc/relax-sub04.d: Likewise.
* testsuite/gas/arc/pcl-print.s: New file.
* testsuite/gas/arc/pcl-print.d: Likewise.
* testsuite/gas/arc/nps400-12.d: Likewise.

ld/
2017-11-21  Claudiu Zissulescu <claziss@synopsys.com>

* testsuite/ld-arc/jli-simple.d: Update test.

6 years agoAdd ability to follow dwo links to readelf/objdump.
Nick Clifton [Tue, 21 Nov 2017 13:12:04 +0000 (13:12 +0000)]
Add ability to follow dwo links to readelf/objdump.

* dwarf.c (dwo_name, dwo_dir, dwo_id, dwo_id_len): New variables.
(read_and_display_attr_value): Record dwo variables if requested.
(display_augmentation_data): Rename to display_data and make
generic.
(load_dwo_file): New function.  Loads a separate dwarf object
file.
(load_separate_debug_file): Add reporting and loading of separate
dwarf objet files.
* readelf.c (process_section_headers): Add do_debug_links to list
of flags requiring a debug dump.
(display_debug_section): Tidy up code.
* doc/debug.options.texi: Add note that dwo links will also be
followed.
* testsuite/binutils-all/debuglink.s: Tidy code.
* testsuite/binutils-all/dwo.s: New test file.
* testsuite/binutils-all/readelf.wk2: New file - expected output
from readelf.
* testsuite/binutils-all/readelf.exp: Run the new test.

6 years agoFix build failure in darwin-nat.c
Simon Marchi [Tue, 21 Nov 2017 04:29:10 +0000 (23:29 -0500)]
Fix build failure in darwin-nat.c

Fix:

/Users/simark/src/binutils-gdb/gdb/darwin-nat.c:2404:3: error: no matching function for call to 'add_setshow_boolean_cmd'
  add_setshow_boolean_cmd ("mach-exceptions", class_support,
  ^~~~~~~~~~~~~~~~~~~~~~~

gdb/ChangeLog:

* darwin-nat.c (set_enable_mach_exceptions): Constify parameter.

6 years agoAdd NULL bfd test to elf_symbol_from
Alan Modra [Mon, 20 Nov 2017 23:34:05 +0000 (10:04 +1030)]
Add NULL bfd test to elf_symbol_from

A followup to PR22443.

* elf-bfd.h (elf_symbol_from): Check for NULL symbol bfd.
* elfcode.h (elf_slurp_reloc_table_from_section): Add FIXME comment.

6 years agoxtensa error message
Alan Modra [Mon, 20 Nov 2017 23:55:18 +0000 (10:25 +1030)]
xtensa error message

* config/tc-xtensa.c (finish_vinsn): Avoid multiple ngettext calls
in error message.

6 years agoFix mapped_index::find_name_components_bounds upper bound computation
Pedro Alves [Tue, 21 Nov 2017 00:02:46 +0000 (00:02 +0000)]
Fix mapped_index::find_name_components_bounds upper bound computation

Here we want to find where we'd insert "after", so we want
std::lower_bound, not std::upper_bound.

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

* dwarf2read.c (mapped_index::find_name_components_bounds)
<completion mode, upper bound>: Use std::lower_bound instead of
std::upper_bound.
(test_mapped_index_find_name_component_bounds): Remove incorrect
"t1_fund" from expected symbols.

6 years agoUnit test name-component bounds searching directly
Pedro Alves [Tue, 21 Nov 2017 00:02:46 +0000 (00:02 +0000)]
Unit test name-component bounds searching directly

This commit factors out the name-components-vector building and bounds
searching out of dw2_expand_symtabs_matching_symbol into separate
functions, and adds unit tests that:

 - expose both the latent bug mentioned in the previous commit, and
   also,

 - for completeness exercise the 0xff character handling fixed in the
   previous commit more directly.

The actual fix for the now-exposed bug is left for the following
patch.

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

* dwarf2read.c (mapped_index::name_components_casing): New field.
(mapped_index) <build_name_components,
find_name_components_bounds): Declare new methods.
(mapped_index::find_name_components_bounds)
(mapped_index::build_name_components): New methods, factored out
from dw2_expand_symtabs_matching_symbol.
(check_find_bounds_finds)
(test_mapped_index_find_name_component_bounds): New.
(run_test): Rename to ...
(test_dw2_expand_symtabs_matching_symbol): ... this.
(run_test): Reimplement.

6 years ago0xff chars in name components table; cp-name-parser lex UTF-8 identifiers
Pedro Alves [Tue, 21 Nov 2017 00:02:46 +0000 (00:02 +0000)]
0xff chars in name components table; cp-name-parser lex UTF-8 identifiers

The find-upper-bound-for-completion algorithm in the name components
accelerator table in dwarf2read.c increments a char in a string, and
asserts that it's not incrementing a 0xff char, but that's incorrect.

First, we shouldn't be calling gdb_assert on input.

Then, if "char" is signed, comparing a caracther with "0xff" will
never yield true, which is caught by Clang with:

  error: comparison of constant 255 with expression of type '....' (aka 'char') is always true [-Werror,-Wtautological-constant-out-of-range-compare]
    gdb_assert (after.back () != 0xff);
~~~~~~~~~~~~~ ^  ~~~~

And then, 0xff is a valid character on non-UTF-8/ASCII character sets.
E.g., it's 'ÿ' in Latin1.  While GCC nor Clang support !ASCII &&
!UTF-8 characters in identifiers (GCC supports UTF-8 characters only
via UCNs, see https://gcc.gnu.org/onlinedocs/cpp/Character-sets.html),
but other compilers might (Visual Studio?), so it doesn't hurt to
handle it correctly.  Testing is covered by extending the
dw2_expand_symtabs_matching unit tests with relevant cases.

However, without further changes, the unit tests still fail...  The
problem is that cp-name-parser.y assumes that identifiers are ASCII
(via ISALPHA/ISALNUM).  This commit fixes that too, so that we can
unit test the dwarf2read.c changes.  (The regular C/C++ lexer in
c-lang.y needs a similar treatment, but I'm leaving that for another
patch.)

While doing this, I noticed a thinko in the computation of the upper
bound for completion in dw2_expand_symtabs_matching_symbol.  We're
using std::upper_bound but we should use std::lower_bound.  I extended
the unit test with a case that I thought would expose it, this one:

 +  /* These are used to check that the increment-last-char in the
 +     matching algorithm for completion doesn't match "t1_fund" when
 +     completing "t1_func".  */
 +  "t1_func",
 +  "t1_func1",
 +  "t1_fund",
 +  "t1_fund1",

The algorithm actually returns "t1_fund1" as lower bound, so "t1_fund"
matches incorrectly.  But turns out the problem is masked because
later here:

  for (;lower != upper; ++lower)
    {
      const char *qualified = index.symbol_name_at (lower->idx);

      if (!lookup_name_matcher.matches (qualified)

the lookup_name_matcher.matches check above filters out "t1_fund"
because that doesn't start with "t1_func".

I'll fix the latent bug in follow up patches, after factoring things
out a bit in a way that allows unit testing the relevant code more
directly.

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

* cp-name-parser.y (cp_ident_is_alpha, cp_ident_is_alnum): New.
(symbol_end): Use cp_ident_is_alnum.
(yylex): Use cp_ident_is_alpha and cp_ident_is_alnum.
* dwarf2read.c (make_sort_after_prefix_name): New function.
(dw2_expand_symtabs_matching_symbol): Use it.
(test_symbols): Add more symbols.
(run_test): Add tests.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 21 Nov 2017 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoFix gdb.base/whatis-ptype-typedefs.exp on 32-bit archs
Pedro Alves [Mon, 20 Nov 2017 23:03:17 +0000 (23:03 +0000)]
Fix gdb.base/whatis-ptype-typedefs.exp on 32-bit archs

The gdb.base/whatis-ptype-typedefs.exp testcase has several tests that
fail on 32-bit architectures.  E.g., on 'x86-64 -m32', I see:

 ...
 FAIL: gdb.base/whatis-ptype-typedefs.exp: lang=c: cast: whatis (float_typedef) v_uchar_array_t_struct_typedef (invalid)
 FAIL: gdb.base/whatis-ptype-typedefs.exp: lang=c: cast: ptype (float_typedef) v_uchar_array_t_struct_typedef (invalid)
 ...

gdb.log:

 (gdb) whatis (float_typedef) v_uchar_array_t_struct_typedef
 type = float_typedef
 (gdb) FAIL: gdb.base/whatis-ptype-typedefs.exp: lang=c: cast: whatis (float_typedef) v_uchar_array_t_struct_typedef (invalid)

As Simon explained [1], the issue boils down to the fact that on
64-bit, this is an invalid cast:

 (gdb) p (float_typedef) v_uchar_array_t_struct_typedef
 Invalid cast.

while on 32 bits it is valid:

 (gdb) p (float_typedef) v_uchar_array_t_struct_typedef
 $1 = 1.16251721e-41

The expression basically tries to cast an array (which decays to a
pointer) to a float.  The cast works on 32 bits because a float and a
pointer are of the same size, and value_cast works in that case:

~~~
   More general than a C cast: accepts any two types of the same length,
   and if ARG2 is an lvalue it can be cast into anything at all.  */
~~~

On 64 bits, they are not the same size, so it ends throwing the
"Invalid cast" error.

The testcase is expecting the invalid cast behavior, thus the FAILs.

A point of these tests was to cover as many code paths in value_cast
as possible, as a sort of documentation of the current behavior:

    # The main idea here is testing all the different paths in the
    # value casting code in GDB (value_cast), making sure typedefs are
    # preserved.
...
    # We try all combinations, even those that don't parse, or are
    # invalid, to catch the case of a regression making them
    # inadvertently valid.  For example, these convertions are
    # invalid:
...

In that spirit, this commit makes the testcase adjust itself depending
on size of floats and pointers, and also test floats of different
sizes.

Passes cleanly on x86-64 GNU/Linux both -m64/-m32.

[1] - https://sourceware.org/ml/gdb-patches/2017-11/msg00382.html

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

* gdb.base/whatis-ptype-typedefs.c (double_typedef)
(long_double_typedef): New typedefs.
Use DEF on double and long double.
* gdb.base/whatis-ptype-typedefs.exp: Add double and long double
cases.
(run_tests): New 'float_ptr_same_size', 'double_ptr_same_size',
and 'long_double_ptr_same_size' locals.  Use them to decide
whether cast from array/function to float is valid/invalid.

6 years agoFix handling of GNU Property notes that are not in a GNU NOTE PROPERTY section.
Nick Clifton [Mon, 20 Nov 2017 15:32:55 +0000 (15:32 +0000)]
Fix handling of GNU Property notes that are not in a GNU NOTE PROPERTY section.

PR 22450
gas * elf-properties.c (_bfd_elf_link_setup_gnu_properties): Skip
objects without a GNU_PROPERTY note section when looking for a bfd
onto which notes can be accumulated.

ld * testsuite/ld-elf/elf.exp: Add --defsym ALIGN=2|3 to assembler
command line depending upon the size of the target address space.
* testsuite/ld-elf/pr22450.s: New test file.
* testsuite/ld-elf/pr22450.d: New test driver.
* testsuite/config/default.exp: Add note that LD_CLASS refers to
the size of the host linker not the size of the target linker.

6 years agomingw gas testsuite fix
Alan Modra [Mon, 20 Nov 2017 11:34:30 +0000 (22:04 +1030)]
mingw gas testsuite fix

Some x86_64 targets pad sections with nops.

* testsuite/gas/i386/x86-64-reg-bad.l: Accept trailing padding.

6 years agoPR22451, strip no longer works on older object files
Alan Modra [Mon, 20 Nov 2017 11:05:09 +0000 (21:35 +1030)]
PR22451, strip no longer works on older object files

Setting SHF_GROUP unconditionally on rel/rela sections associated with
SHF_GROUP sections fails badly with objcopy/strip and ld -r if the
input file SHT_GROUP section didn't specify the rel/rela sections.
This patch rearranges where SHF_GROUP is set for rel/rela sections.

PR 22451
PR 22460
* elf.c (_bfd_elf_init_reloc_shdr): Delete "sec_hdr" parameter
and leave rel_hdr->sh_flags zero.  Update calls.
(bfd_elf_set_group_contents): Check input rel/rela SHF_GROUP
flag when !gas before adding rel/rela section to group.  Set
output rel/rela SHF_GROUP flags.

6 years agoRemove usage of find_inferior when calling kill_one_lwp_callback
Simon Marchi [Mon, 20 Nov 2017 03:23:28 +0000 (22:23 -0500)]
Remove usage of find_inferior when calling kill_one_lwp_callback

Replace with for_each_thread.

gdb/gdbserver/ChangeLog:

* linux-low.c (kill_one_lwp_callback): Return void, take
argument directly, don't filter on pid.
(linux_kill): Use for_each_thread.

6 years agoRemove usages of find_thread when calling need_step_over_p
Simon Marchi [Mon, 20 Nov 2017 03:23:27 +0000 (22:23 -0500)]
Remove usages of find_thread when calling need_step_over_p

Replace with find_thread.

gdb/gdbserver/ChangeLog:

* linux-low.c (need_step_over_p): Return bool, remove dummy
argument.
(linux_resume, proceed_all_lwps): Use find_thread.

6 years agoRemove usage of find_thread when calling resume_status_pending_p
Simon Marchi [Mon, 20 Nov 2017 03:23:26 +0000 (22:23 -0500)]
Remove usage of find_thread when calling resume_status_pending_p

Replace with find_thread.  Instead of setting the flag in the callback,
make the callback return true/false, and check the result against NULL
in the caller.

gdb/gdbserver/ChangeLog:

* linux-low.c (resume_status_pending_p): Return bool, remove
flag_p argument.
(linux_resume): Use find_thread.

6 years agoRemove usage of find_inferior when calling linux_set_resume_request
Simon Marchi [Mon, 20 Nov 2017 03:23:26 +0000 (22:23 -0500)]
Remove usage of find_inferior when calling linux_set_resume_request

Replace it with for_each_thread.

gdb/gdbserver/ChangeLog:

* linux-low.c (struct thread_resume_array): Remove.
(linux_set_resume_request): Return void, take arguments
directly.
(linux_resume): Use for_each_thread.

6 years agoRemove usage of find_inferior in linux_stabilize_threads
Simon Marchi [Mon, 20 Nov 2017 03:23:25 +0000 (22:23 -0500)]
Remove usage of find_inferior in linux_stabilize_threads

Simply replace with find_thread.

gdb/gdbserver/ChangeLog:

* linux-low.c (stuck_in_jump_pad_callback): Change prototype,
return bool, remove data argument.
(linux_stabilize_threads): Use find_thread.

6 years agoRemove usage of find_inferior in unsuspend_all_lwps
Simon Marchi [Mon, 20 Nov 2017 03:23:24 +0000 (22:23 -0500)]
Remove usage of find_inferior in unsuspend_all_lwps

Replace with for_each_thread.  I inlined unsuspend_one_lwp in
unsuspend_all_lwps, since it is very simple.

gdb/gdbserver/ChangeLog:

* linux-low.c (unsuspend_one_lwp): Remove.
(unsuspend_all_lwps): Use for_each_thread, inline code from
unsuspend_one_lwp.

6 years agoRemove usage of find_inferior in iterate_over_lwps
Simon Marchi [Mon, 20 Nov 2017 03:23:23 +0000 (22:23 -0500)]
Remove usage of find_inferior in iterate_over_lwps

Replace find_inferior with find_thread.  Since it may be useful in the
future, I added another overload to find_thread which filters based on a
ptid (using ptid_t::matches), so now iterate_over_lwps doesn't have to
do the filtering itself.  iterate_over_lwps_filter is removed and
inlined into iterate_over_lwps.

gdb/gdbserver/ChangeLog:

* gdbthread.h (find_thread): Add overload with ptid_t filter.
* linux-low.c (struct iterate_over_lwps_args): Remove.
(iterate_over_lwps_filter): Remove.
(iterate_over_lwps): Use find_thread.

6 years agoRemove usage of find_inferior in reset_lwp_ptrace_options_callback
Simon Marchi [Mon, 20 Nov 2017 03:23:22 +0000 (22:23 -0500)]
Remove usage of find_inferior in reset_lwp_ptrace_options_callback

Replace with for_each_thread, and inline code from
reset_lwp_ptrace_options_callback.

gdb/gdbserver/ChangeLog:

* linux-low.c (reset_lwp_ptrace_options_callback): Remove.
(linux_handle_new_gdb_connection): Use for_each_thread, inline
code from reset_lwp_ptrace_options_callback.

6 years agoRemove usages of find_inferior in linux-arm-low.c
Simon Marchi [Mon, 20 Nov 2017 03:23:22 +0000 (22:23 -0500)]
Remove usages of find_inferior in linux-arm-low.c

Replace two usages with the overload of for_each_thread that filters on
pid.  It allows to simplify the callback a little bit.

gdb/gdbserver/ChangeLog:

* linux-arm-low.c (struct update_registers_data): Remove.
(update_registers_callback): Return void, take arguments
directly, don't check thread's pid.
(arm_insert_point, arm_remove_point): Use for_each_thread.

6 years agoRemove usage of find_inferior in win32-low.c
Simon Marchi [Mon, 20 Nov 2017 03:23:21 +0000 (22:23 -0500)]
Remove usage of find_inferior in win32-low.c

Replace with for_each_thread.

gdb/gdbserver/ChangeLog:

* win32-low.c (continue_one_thread): Return void, take argument
directly.
(child_continue): Use for_each_thread.

6 years agoRemove usage of find_inferior in win32-i386-low.c
Simon Marchi [Mon, 20 Nov 2017 03:23:20 +0000 (22:23 -0500)]
Remove usage of find_inferior in win32-i386-low.c

Straightforward replacement of find_inferior with the overload of
for_each_thread that filters on pid.  I am able to build-test this
patch, but not run it.

gdb/gdbserver/ChangeLog:

* win32-i386-low.c (update_debug_registers_callback): Rename
to ...
(update_debug_registers): ... this, return void, remove pid_p arg.
(x86_dr_low_set_addr, x86_dr_low_set_control): Use for_each_thread.