Sergio Durigan Junior [Sat, 25 Nov 2017 15:57:58 +0000 (10:57 -0500)]
Adding ChangeLog entry for the last commit.
Sergio Durigan Junior [Sat, 25 Nov 2017 06:13:03 +0000 (01:13 -0500)]
Fix PR gdb/22491: Regression when setting SystemTap probe semaphores
Pedro has kindly pointed out that
gdb.arch/amd64-stap-optional-prefix.exp was failing after my
C++-ification patches touching the probe interface. The failure is
kind of cryptic:
77 break -pstap bar
78 Breakpoint 3 at 0x40048d
79 (gdb) PASS: gdb.arch/amd64-stap-optional-prefix.exp: bar: break -pstap bar
80 continue
81 Continuing.
82
83 Program received signal SIGILL, Illegal instruction.
84 main () at amd64-stap-optional-prefix.S:26
85 26 STAP_PROBE1(probe, foo, (%rsp))
It took me a while to figure out where this SIGILL is coming from.
Initially I thought it was something related to writing registers to
the inferior when dealing with probe arguments, but I discarded this
since the arguments were not touching any registers.
In the end, this was a mistake that was introduced during the review
process of the patch. When setting/clearing a SystemTap probe's
semaphore, the code was using 'm_address' (which refers the probe's
address) instead of 'm_sem_addr' (which refers to the semaphore's
address). This caused GDB to write a bogus value in the wrong memory
position, which in turn caused the SIGILL.
I am pushing this patch to correct the mistake.
On a side note: I told Pedro that the BuildBot hadn't caught the
failure during my try build, and for a moment there was a suspicion
that the BuildBot might be at fault here. However, I investigate this
and noticed that I only did one try build, with a patch that was
correctly using 'm_sem_addr' where applicable, and therefore no
failure should have happened indeed. I probably should have requested
another try build after addressing the review's comments, but they
were mostly basic and I didn't think it was needed. Oh, well.
2017-11-25 Sergio Durigan Junior <sergiodj@redhat.com>
PR gdb/22491
* stap-probe.c (relocate_address): New function.
(stap_probe::get_relocated_address): Use 'relocate_address'.
(stap_probe::set_semaphore): Use 'relocate_address' and pass
'm_sem_addr'.
(stap_probe::clear_semaphore): Likewise.
Pedro Alves [Sat, 25 Nov 2017 00:33:05 +0000 (00:33 +0000)]
Use TOLOWER in SYMBOL_HASH_NEXT
The support for setting breakpoint in functions with ABI tags patch
will add a use of SYMBOL_HASH_NEXT in cp-support.c, which fails to
compile with:
src/gdb/cp-support.c:38:0:
src/gdb/cp-support.c: In function ‘unsigned int cp_search_name_hash(const char*)’:
src/gdb/../include/safe-ctype.h:148:20: error: ‘do_not_use_tolower_with_safe_ctype’ was not declared in this scope
#define tolower(c) do_not_use_tolower_with_safe_ctype
^
src/gdb/minsyms.h:174:18: note: in expansion of macro ‘tolower’
((hash) * 67 + tolower ((unsigned char) (c)) - 113)
^
src/gdb/cp-support.c:1677:14: note: in expansion of macro ‘SYMBOL_HASH_NEXT’
hash = SYMBOL_HASH_NEXT (hash, *string);
^
This fixes the problem before it happens.
I was somewhat worried about whether this might have an impact with
languages that are case insensitive, but I convinced myself that it
doesn't. As bonus, this improves GDB's minsym interning performance a
bit (3%-10%). See
<https://sourceware.org/ml/gdb/2017-11/msg00021.html>.
gdb/ChangeLog:
2017-11-25 Pedro Alves <palves@redhat.com>
* dictionary.c: Include "safe-ctype.h".
* minsyms.c: Include "safe-ctype.h".
* minsyms.c (SYMBOL_HASH_NEXT): Use TOLOWER instead of tolower.
Pedro Alves [Sat, 25 Nov 2017 00:20:31 +0000 (00:20 +0000)]
Fix completing an empty string
Earlier while working on the big completer rework series, I managed to
break
(gdb) [TAB]
locally, and make GDB crash, but only notice a few weeks down the
road, because we have no test for that...
I also noticed that:
(gdb) [TAB]
didn't work (didn't show all commands as matches), even though
entering a command with leading whitespace works:
(gdb) help
This commit fixes the latter and adds a testcase that covers both
issues.
The gdb.base/completion.exp change is necessary because the new test
has a file name that also starts with "gdb.base/complet", making that
particular test ambiguous. Adding another letter disambiguates.
gdb/ChangeLog:
2017-11-25 Pedro Alves <palves@redhat.com>
* completer.c (complete_line_internal_1): Skip spaces until the
start of the command.
gdb/testsuite/ChangeLog:
2017-11-25 Pedro Alves <palves@redhat.com>
* gdb.base/complete-empty.exp: New file.
* gdb.base/completion.exp: Adjust.
Pedro Alves [Sat, 25 Nov 2017 00:09:25 +0000 (00:09 +0000)]
Add comprehensive C++ operator linespec/location/completion tests
This exercises the special handling C++ operators require in several
places in the linespec parser, both the linespec and explicit location
completers, symbol lookup, etc. Particularly, makes sure all that
works without quoting.
Note that despite the apparent smallish size, this adds thousands of
tests to the testsuite, due to combination explosion (linespecs,
explicit locations, tab completion, complete command, completion at
different points in each function, etc.)
Grows the gdb.linespec/ tests like this:
-# of expected passes 3464
+# of expected passes 7823
gdb/testsuite/ChangeLog:
2017-11-25 Pedro Alves <palves@redhat.com>
* gdb.linespec/cpls-ops.cc: New file.
* gdb.linespec/cpls-ops.exp: New file.
* lib/completion-support.exp (test_complete_prefix_range_re): New,
factored out from ...
(test_complete_prefix_range): ... this.
GDB Administrator [Sat, 25 Nov 2017 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in
Pedro Alves [Fri, 24 Nov 2017 23:41:12 +0000 (23:41 +0000)]
Comprehensive C++ linespec/completer tests
Exercises all sorts of aspects fixed by previous patches, going back a
few months.
- Exercises label completion, linespecs and explicit locations.
- Exercises both quoting vs non-quoting, source filenames, function
names, labels, with both linespecs and explicit locations.
- Tests corner cases around not-quoting function names, and
whitespace and/and completing inside a parameter or template
argument list, anonymous namespace awareness, etc.
E.g.,
"break foo<[TAB]" -> "break foo<int>()"
"break bar ( int[TAB]" -> "break bar ( int)
"break ( anon" -> "break ( anonymous namespace)::func()"
"b cfunc() [tab]" -> "b cfunc() const"
"b rettype templfunc[tab]" -> "b rettype templfunc<bar>()"
... and others.
- Tests the "b source.c[TAB] -> b source.cc:" feature. I.e., colon
auto-appending.
- Exercises corner cases around C++ "operator<" / "operator<<".
(Much more extensive C++ operator completion/linespec handling in a
separate patch.)
- Exercises both tab completion and "complete" command completion,
using routines that handle it automatically, to ensure no test
forgets either mode.
- Many of the completion tests test completion at at prefix of a
given tricky name, to make sure all corner cases are covered.
E.g., completing before, at and after ":", "(", "<".
- Exercises "keyword" completion. I.e., "b function() [TAB]"
displaying "if task thread" as completion match list. Likewise for
display explicit location options matches at the appropriate
points.
- Ensures that the completer finds the same breakpoint locations that
setting a breakpoint finds.
- Tests that linespec/location completion doesn't find data symbols.
- Tests that expression completion still kicks in after a
linespec/location keyword. I.e., this:
"b function () if global1 + global[TAB]"
knows that after "if", you're completing on an expression, and thus
breaks words after "if" as an expression and matches on "global" as
a data symbol.
- Adds common routines to help with all the above, to be used by
multiple completion and linespec/location test cases.
- More...
Grows the gdb.linespec/ tests like this:
-# of expected passes 573
+# of expected passes 3464
gdb/testsuite/ChangeLog:
2017-11-24 Pedro Alves <palves@redhat.com>
* gdb.linespec/cpcompletion.exp: New file.
* gdb.linespec/cpls-hyphen.cc: New file.
* gdb.linespec/cpls.cc: New file.
* gdb.linespec/cpls2.cc: New file.
* gdb.linespec/explicit.exp: Load completion-support.exp. Adjust
test to use test_gdb_complete_unique. Add label completion,
keyword completion and explicit location completion tests.
* lib/completion-support.exp: New file.
Pedro Alves [Fri, 24 Nov 2017 23:30:04 +0000 (23:30 +0000)]
Make strcmp_iw NOT ignore whitespace in the middle of tokens
currently "b func tion" manages to set a breakpoint at "function" !
All these years I had never noticed this, but now that the linespec
completer actually works, this easily happens by accident, with:
"b func t<tab>"
expecting to get "thread", but getting instead:
"b func tion"
...
Also, this:
"b rettypefunc<int>"
manages to set a breakpoint on "rettype func<int>()".
These things happen due to strcmp_iw "magic".
Fix it by teaching strcmp_iw about when can it skip whitespace. This
required handling user-defined operators, and scope operators,
complicating the code a bit, unfortunately. I added unit tests for
all the corner cases I stumbled on, as I was developing this, and then
in the end wrote a testsuite testcase covering many of the same things
and more (to be added later).
gdb/ChangeLog:
2017-11-24 Pedro Alves <palves@redhat.com>
* cp-support.c (cp_symbol_name_matches_1): New, factored out from
cp_fq_symbol_name_matches. Pass language_cplus to
strncmp_with_mode.
(cp_fq_symbol_name_matches): Call cp_symbol_name_matches_1.
(selftests::test_cp_symbol_name_cmp): New.
(_initialize_cp_support): Register "cp_symbol_name_matches"
selftests.
* language.c (default_symbol_name_matcher): Pass language_minimal
to strncmp_iw_with_mode.
* utils.c: Include "cp-support.h" and <algorithm>.
(valid_identifier_name_char, cp_skip_operator_token, skip_ws)
(cp_is_operator): New functions.
(strncmp_iw_with_mode): Use them. Add language parameter. Don't
skip whitespace in the symbol name when the lookup name doesn't
have spaces, and vice versa.
(strncmp_iw, strcmp_iw): Pass language to strncmp_iw_with_mode.
* utils.h (strncmp_iw_with_mode): Add language parameter.
H.J. Lu [Fri, 24 Nov 2017 22:49:36 +0000 (14:49 -0800)]
Re-apply "elf: Properly compute offsets of note descriptor and next note"
CORE PT_NOTE segments may have p_align values of 0 or 1. gABI specifies
that PT_NOTE alignment should be aligned to 4 bytes for 32-bit objects
and to 8 bytes for 64-bit objects. If segment alignment is less than 4,
we use 4 byte alignment.
Joel Brobecker [Fri, 24 Nov 2017 22:09:42 +0000 (17:09 -0500)]
(Ada) provide the exception message when hitting an exception catchpoint
This patch enhances the debugger to print the exception message, when
available, as part of an exception catchpoint hit notification (both
GDB/CLI and GDB/MI). For instance, with the following code...
procedure A is
begin
raise Constraint_Error with "hello world";
end A;
... instead of printing...
Catchpoint 1, CONSTRAINT_ERROR at 0x000000000040245c in a () at a.adb:3
... it now prints:
Catchpoint 1, CONSTRAINT_ERROR (hello world) at 0x000000000040245c in a ()
^^^^^^^^^^^^^
This enhancement requires runtime support. If not present, the debugger
just behaves as before.
In GDB/MI mode, if the exception message is available, it is provided
as an extra field named "exception-message" in the catchpoint notification:
*stopped,bkptno="1",[...],exception-name="CONSTRAINT_ERROR",
exception-message="hello world",[...]
gdb/ChangeLog:
* ada-lang.c (ada_exception_message_1, ada_exception_message):
New functions.
(print_it_exception): If available, display the exception
message as well.
* NEWS: Document new feature.
gdb/doc/ChangeLog:
* gdb.texinfo (GDB/MI Ada Exception Information): Document
new "exception-message" field.
gdb/testsuite/ChangeLog:
* gdb.ada/catch_ex.exp, gdb.ada/mi_catch_ex.exp,
gdb.ada/mi_ex_cond.exp: Accept optional exception message in
when hitting an exception catchpoint.
Simon Marchi [Fri, 24 Nov 2017 22:10:25 +0000 (17:10 -0500)]
Fix issues with gdb-memory-map.dtd
While writing a unit test for parse_memory_map, I tried to validate my
test input against gdb-memory-map.dtd, and found a few problems with it.
This doesn't influence how gdb parses it (AFAIK it doesn't use the
linked dtd), but if you edit the xml file in an editor that supports
dtds, you'll get plenty of errors.
- The <memory-map> element accepts exactly one <memory> OR <property>
as a child. This is a problem because you can't have multiple
<memory> elements and you shouldn't be able to have <property> elements
as direct children of <memory-map>.
- The <memory> element wants exactly one <property> child. This is
wrong, since you could have zero or more (even though we only
support one kind of property currently).
- I have no idea wht the device attribute of <memory> is, GDB doesn't
read that. I searched back in time a bit but couldn't find a trace
of it.
I took the opportunity to tighten what is accepted as a value of the
memory type and property name attributes. We currently accept any
string, but we can restrict them to the values GDB really accepts (and
which are documented).
AFAIK, this "file" only exists in the documentation, in gdb.texinfo, so
this is what I modified. However, it's also available at
http://sourceware.org/gdb/gdb-memory-map.dtd. This one should be
updated too, but I don't know how that should be done.
gdb/doc/ChangeLog:
* gdb.texinfo (Memory Map Format): Update gdb-memory-map.dtd.
Ulrich Weigand [Fri, 24 Nov 2017 21:04:41 +0000 (22:04 +0100)]
[spu] Fix spu-linux gdbserver build
Fix a typo in a newly added argument name.
gdb/ChangeLog:
2017-11-24 Ulrich Weigand <uweigand@de.ibm.com>
* spu-low.c (spu_create_inferior): Fix typo in argument name.
Ulrich Weigand [Fri, 24 Nov 2017 21:03:28 +0000 (22:03 +0100)]
[spu] Fix spu-linux native build
Add missing file to NATDEPFILES.
gdb/ChangeLog:
2017-11-24 Ulrich Weigand <uweigand@de.ibm.com>
* configure.nat <spu-linux>: Add fork-inferior.o to NATDEPFILES.
Simon Marchi [Fri, 24 Nov 2017 20:41:23 +0000 (15:41 -0500)]
Revert "elf: Properly compute offsets of note descriptor and next note"
This reverts commit
650444eb540f9fd85e821567a3f943b4bc41b8be.
With this patch, running the GDB test case gdb.base/auxv.exp is stuck in
an infinite loop, consuming memory to the point that it renders the
machine unusable. I am reverting it so we can take our time to
investigate while not killing all the developers' machines.
Jim Wilson [Fri, 24 Nov 2017 17:31:59 +0000 (09:31 -0800)]
Add reference to implicit use in _bfd_elf_is_local_label_name.
gas/
* write.h (FAKE_LABEL_CHAR): Expand comment.
H.J. Lu [Fri, 24 Nov 2017 16:58:43 +0000 (08:58 -0800)]
Update PR ld/21562 tests for underscore targets
We also need to provide __start_scnfoo and __stop_scnfoo with the extra
leading underscore for underscore targets.
This patch fixed:
FAIL: ld-elf/pr21562k
FAIL: ld-elf/pr21562l
FAIL: ld-elf/pr21562m
FAIL: ld-elf/pr21562n
for metag-linux,
* testsuite/ld-elf/pr21562c.t: Also provide ___start_scnfoo and
___stop_scnfoo.
* testsuite/ld-elf/pr21562d.t: Likewise.
Philipp Rudo [Fri, 24 Nov 2017 10:05:57 +0000 (11:05 +0100)]
Workaround build bug with GCC 6.2.1
Building GDB with GCC 6.2.1 gives multiple errors like
gdb/dtrace-probe.c: In member function ‘void dtrace_probe::build_arg_exprs(gdbarch*)’:
gdb/dtrace-probe.c:627:8: error: types may not be defined in a for-range-declaration [-Werror]
for (struct dtrace_probe_arg &arg : m_args
Fix it by removing the 'struct' keyword.
A similar Bug was already fixed for GCC 6.3.1
https://sourceware.org/ml/gdb-patches/2017-10/msg00442.html
gdb/ChangeLog:
* dtrace-probe.c (dtrace_probe::build_arg_exprs)
(dtrace_probe::is_enabled, dtrace_probe::enable)
(dtrace_probe::disable): Remove keyword 'struct' at for-range
variable
* probe.c (gen_ui_out_table_header_info)
(print_ui_out_not_applicables): Remove keyword 'struct' at
for-range variable
Alan Hayward [Fri, 24 Nov 2017 15:54:57 +0000 (15:54 +0000)]
Fix aarch64-none-elf build error
gdb/
* configure.tgt: Add arch/aarch64.o
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
GDB Administrator [Fri, 24 Nov 2017 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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'.
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'.
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.
GDB Administrator [Thu, 23 Nov 2017 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Igor Tsimbalist [Wed, 22 Nov 2017 14:23:38 +0000 (17:23 +0300)]
Update ChangeLog
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.
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.
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.
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.
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.
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.
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.
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.
GDB Administrator [Wed, 22 Nov 2017 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in
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.
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.
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.
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.
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.
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.
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.
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.
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'.
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.
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.
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.
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.
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.
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.
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.
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.