Xavier Roirand [Wed, 22 Nov 2017 09:40:39 +0000 (10:40 +0100)]
(Ada) New command to stop at start of exception handler.
When using gdb for debugging Ada source code, there are several catchpoint
types you can define in order to stop upon certain conditions. Let's
use this small example:
procedure Foo is
begin
begin
raise Constraint_Error;
exception
when Program_Error =>
null;
when Constraint_Error =>
null;
when others =>
null;
end;
end Foo;
One can stop when the exception is being raised by using the exception
catchpoint like below:
(gdb) catch exception
Catchpoint 1: all Ada exceptions
(gdb)
In that case, when running Foo, gdb will stop at the line where the exception
was raised:
begin
>>> raise Constraint_Error;
exception
This patch introduces new type of catchpoint, when the user wants to stop
at the location of the exception handling.
Imagine we want to stop on any exception handled by the program, we can do:
(gdb) catch handlers
Catchpoint 1: all Ada exceptions handlers
(gdb) r
Starting program: /tmp/foo
By doing so, when running Foo, gdb will stop here:
Catchpoint 1, exception at 0x000000000040255a in foo () at foo.adb:25
25 when Constraint_Error =>
(gdb)
It is also possible to stop when the Constraint_Error exception is being
handled in this program. With this patch, we can use:
(gdb) catch handlers Constraint_Error
Catchpoint 1: `Constraint_Error' Ada exception handlers
(gdb)
Like for other catchpoint, you can set a condition when adding a catchpoint
on exception handlers.
Here the handlers catchpoint checks Global_Var:
(gdb) catch handlers Constraint_Error if Global_Var /= 0
gdb/ChangeLog:
* ada-lang.h (ada_exception_catchpoint_kind) <ada_catch_handlers>:
Add field.
* ada-lang.c (struct exception_support_info) <catch_handlers_sym>:
Add field.
(default_exception_support_info) <catch_handlers_sym>: Add field.
(exception_support_info_fallback) <catch_handlers_sym>: Add field.
(ada_exception_name_addr_1): Add "catch handlers" handling.
(ada_exception_catchpoint_cond_string) <ex>: New parameter.
Update all callers.
(create_excep_cond_exprs) <ex>: Add parameter.
(re_set_exception): Update create_excep_cond_exprs call.
(print_it_exception, print_one_exception, print_mention_exception)
(print_recreate_exception): Add "catch handler" handling.
(allocate_location_catch_handlers, re_set_catch_handlers)
(check_status_catch_handlers, print_it_catch_handlers)
(print_one_catch_handlers, print_mention_catch_handlers)
(print_recreate_catch_handlers): New function.
(catch_handlers_breakpoint_ops): New variable.
(catch_ada_exception_command_split) <is_catch_handlers_cmd>:
Add parameter. Add "catch handler" handling.
(ada_exception_sym_name, ada_exception_breakpoint_ops):
Add "catch handler" handling.
(ada_exception_catchpoint_cond_string): Add "catch handler"
handling.
(create_ada_exception_catchpoint): Update create_excep_cond_exprs
call.
(catch_ada_handlers_command): New function.
(initialize_ada_catchpoint_ops): Initialize "catch handlers"
operations structure.
(_initialize_ada_language): Add "catch handlers" command entry.
* NEWS: Document "catch handlers" feature.
gdb/doc/ChangeLog:
* gdb.texinfo (Set Catchpoints): Add documentation for new
"catch handlers" action.
gdb/testsuite/ChangeLog:
* gdb.ada/excep_handle.exp: New testcase.
* gdb.ada/excep_handle/foo.adb: New file.
* gdb.ada/excep_handle/pck.ads: New file.
Tested on x86_64-linux.
Alan Modra [Wed, 3 Jan 2018 05:17:27 +0000 (15:47 +1030)]
Update year range in copyright notice of binutils files
Alan Modra [Wed, 3 Jan 2018 05:15:17 +0000 (15:45 +1030)]
ChangeLog rotation
Joel Brobecker [Wed, 3 Jan 2018 03:50:38 +0000 (07:50 +0400)]
Unbreak spurious fails in gdb.base/step-line.exp
My copyright year update in the copyright headers of the step-line
testcase caused it to start failing, due to shift in line numbers.
FAIL: gdb.base/step-line.exp: continue to f1
FAIL: gdb.base/step-line.exp: next to dummy 2
FAIL: gdb.base/step-line.exp: next over dummy 2
FAIL: gdb.base/step-line.exp: step into f2
FAIL: gdb.base/step-line.exp: next over dummy 4
FAIL: gdb.base/step-line.exp: next to dummy 5
FAIL: gdb.base/step-line.exp: next to dummy 6
FAIL: gdb.base/step-line.exp: next over dummy 6
FAIL: gdb.base/step-line.exp: next to dummy 7
FAIL: gdb.base/step-line.exp: next to dummy 8
FAIL: gdb.base/step-line.exp: next over dummy 8
FAIL: gdb.base/step-line.exp: next to dummy 9
FAIL: gdb.base/step-line.exp: next to dummy 10
FAIL: gdb.base/step-line.exp: next over dummy 10
This was caused by the copyright.py script after I changed it to
also update this testcase, which made the following transformation:
- Copyright (C) 2001-2017
- Free Software Foundation, Inc.
+ Copyright (C) 2001-2018 Free Software Foundation, Inc.
We can easily unbreak the testcase without having to go back to
manual edits each year by adding an extra line in the header.
gdb/testsuite/ChangeLog:
* gdb.base/step-line.c: Add extra empty line in copyright header.
* gdb.base/step-line.inp: Likewise.
Tested on x86_64-linux.
GDB Administrator [Wed, 3 Jan 2018 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in
Nick Clifton [Tue, 2 Jan 2018 17:15:16 +0000 (17:15 +0000)]
Fix compile time warning (in the ARM simulator) about a print statement with insufficient arguments.
PR 22663
* maverick.c (DSPCDP4): Add missing parameter to debug print
statement.
Nick Clifton [Tue, 2 Jan 2018 12:13:17 +0000 (12:13 +0000)]
Fix typo in do_mrs function in ARM assembler.
PR 18119
* config/tc-arm.c (do_mrs): Fix test of bits 16-19 in non-banked
version of ARM MRS instruction.
Jan Beulich [Tue, 2 Jan 2018 10:44:04 +0000 (11:44 +0100)]
x86: partial revert of
10c17abdd0
Other than the variables in tc-i386.c using them, OPERAND_TYPE_REGYMM
and OPERAND_TYPE_REGZMM they aren't entirely unused. No need to update
i386-init.h though, as it mistakenly wasn't updated by the original
commit.
Joel Brobecker [Tue, 2 Jan 2018 03:53:55 +0000 (22:53 -0500)]
[gdb/Ada] slices of arrays with dynamic strides
Consider the following Ada code:
procedure Nested (L, U : Integer) is
subtype Small_Type is Integer range L .. U;
type Record_Type (I : Small_Type := L) is record
S : String (1 .. I);
end record;
type Array_Type is array (Integer range <>) of Record_Type;
A1 : Array_Type :=
(1 => (I => 0, S => <>),
2 => (I => 1, S => "A"),
3 => (I => 2, S => "AB"));
procedure Discard (R : Record_Type) is
begin
null;
end Discard;
begin
Discard (A1 (1)); -- STOP
end;
Trying to print a slice of that array currently yields:
(gdb) p a1(1..3)
$1 = ((i => 0, s => ""), (i => 0, s => ""), (i => 0, s => ""))
We expected instead:
(gdb) p a1(1..3)
$1 = ((i => 0, s => ""), (i => 1, s => "A"), (i => 2, s => "AB"))
This is because the functions we use in ada-lang.c to create the type
of the array slice (ada_value_slice and ada_value_slice_from_ptr) was
not taking into account the stride of the array. This patch fixes this.
gdb/ChangeLog:
* ada-lang.c (ada_value_slice_from_ptr): Take array stride into
account when creating the array type of the slice.
(ada_value_slice): Likewise.
gdb/testsuite/ChangeLog:
* gdb.ada/dyn_stride.exp: Add slice test.
Note that, with the current use of ada_value_slice, the enhancement
to handle dynamic array strides seems unnecessary, because I do not
see how an array with a dynamic stride can be referenced by either
by reference or pointer. Since references are coerced to array pointers,
in both cases, the slice is performed by ada_value_slice_from_ptr.
But ada_value_slice is enhanced nonetheless, in the spirit of making
the code more robust, in case we missed something, and also as similar
as possible with its from_ptr counterpart.
tested on x86_64-linux.
Joel Brobecker [Tue, 2 Jan 2018 03:47:18 +0000 (22:47 -0500)]
Add support for dynamic DW_AT_byte_stride.
This patch adds support for DW_AT_byte_stride, using Ada as one
example of where this would be useful. However, the implementation
is language-agnostic.
Consider the following Ada code:
procedure Nested (L, U : Integer) is
subtype Small_Type is Integer range L .. U;
type Record_Type (I : Small_Type := L) is record
S : String (1 .. I);
end record;
type Array_Type is array (Integer range <>) of Record_Type;
A1 : Array_Type :=
(1 => (I => 0, S => <>),
2 => (I => 1, S => "A"),
3 => (I => 2, S => "AB"));
procedure Discard (R : Record_Type) is
begin
null;
end Discard;
begin
Discard (A1 (1)); -- STOP
end;
It defines an array A1 of Record_Type, which is a variant record
type whose maximum size actually depends on the value of the
parameters passed when calling Nested. As a result, the stride
of the array A1 cannot be known statically, which leads the compiler
to generate a dynamic DW_AT_byte_stride attribute for our type.
Here is what the debugging info looks like with GNAT:
.uleb128 0x10 # (DIE (0x14e) DW_TAG_array_type)
.long .LASF17 # DW_AT_name: "foo__nested__T18b"
.long 0x141 # DW_AT_byte_stride
.long 0xdc # DW_AT_type
.uleb128 0x11 # (DIE (0x15f) DW_TAG_subrange_type)
.long 0x166 # DW_AT_type
.byte 0x3 # DW_AT_upper_bound
.byte 0 # end of children of DIE 0x14e
There DW_AT_byte_stride is a reference to a local (internal)
variable:
.uleb128 0x9 # (DIE (0x141) DW_TAG_variable)
.long .LASF6 # DW_AT_name: "foo__nested__T18b___PAD___XVZ"
This patch enhances GDB to handle this dynamic byte stride attribute
by first adding a new dynamic_prop_node_kind (DYN_PROP_BYTE_STRIDE)
to store the array dynamic stride info (when dynamic). It then enhances
the dynamic type resolver to handle this dynamic property.
Before applying this patch, trying to print the value of some of
A1's elements after having stopped at the "STOP" comment does not
work. For instance:
(gdb) p a1(2)
Cannot access memory at address 0x80000268dec0
With this patch applied, GDB now prints the value of all 3 elements
correctly:
(gdb) print A1(1)
$1 = (i => 0, s => "")
(gdb) print A1(2)
$2 = (i => 1, s => "A")
(gdb) print A1(3)
$3 = (i => 2, s => "AB")
gdb/ChangeLog:
* gdbtypes.h (enum dynamic_prop_node_kind) <DYN_PROP_BYTE_STRIDE>:
New enum value.
(create_array_type_with_stride): Add byte_stride_prop parameter.
* gdbtypes.c (create_array_type_with_stride) <byte_stride_prop>:
New parameter. Update all callers in this file.
(array_type_has_dynamic_stride): New function.
(is_dynamic_type_internal, resolve_dynamic_array): Add handling
of arrays with dynamic byte strides.
* dwarf2read.c (read_array_type): Add support for dynamic
DW_AT_byte_stride attributes.
gdb/testsuite/ChangeLog:
* gdb.ada/dyn_stride: New testcase.
Tested on x86_64-linux.
Joel Brobecker [Tue, 2 Jan 2018 03:41:36 +0000 (22:41 -0500)]
treat Ada DW_TAG_unspecified_type DIEs as stub types
Consider the gdb.ada/taft_type.exp testcase, which exercises
the situation where a variable is defined using a type which
is a pointer to an incomplete type, with the actual type
definition being provided by another unit. Up to now, the
strategy used by GNAT when generating the DWARF debugging info
was to produce a incomplete DW_TAG_enumeration_type DIE with
a DW_AT_declaration flag attached to it:
.uleb128 0x4 # (DIE (0x3e) DW_TAG_enumeration_type)
.long .LASF4 # DW_AT_name: "pck__empty"
# DW_AT_declaration
However, a more standard way for the compiler to describe
this kind of type is to use the DW_TAG_unspecified_type tag.
When the compiler is enhanced to do so, we'll need to treat
such types as stubs -- we only do so with types from Ada units,
however, as the meaning of this TAG is intentionally left
permissive and language-specific by the DWARF standard.
Without this patch, running the testcase above with an enhanced
compiler now yields:
(gdb) print w.e.all
Attempt to dereference a generic pointer.
FAIL: gdb.ada/taft_type.exp: print w.e.all
gdb/ChangeLog:
* dwarf2read.c (read_unspecified_type): Treat
DW_TAG_enumeration_type DIEs from Ada units as stubs.
Tested on x86_64-linux, fixes the FAIL in gdb.ada/taft_type.exp above.
Joel Brobecker [Mon, 1 Jan 2018 04:43:02 +0000 (08:43 +0400)]
Update copyright year range in all GDB files
gdb/ChangeLog:
Update copyright year range in all GDB files
Joel Brobecker [Mon, 1 Jan 2018 04:18:16 +0000 (08:18 +0400)]
gdb/copyright.py: Remove testsuite/gdb.base/step-line.{c,inp} special handling
In the past, these files needed to be handled by hand, because
the testcase was sensitive to the length of the header, which was
potentially changing when new copyright years were added to
the copyright header. Now that we simply maintain and update
a range, the length of the copyright header should not change
as a consequence of the update performed by this script, so
special handling of those files is no longer necessary.
gdb/ChangeLog:
* copyright.py (BY_HAND): Remove gdb/testsuite/gdb.base/step-line.inp
and gdb/testsuite/gdb.base/step-line.c.
Joel Brobecker [Mon, 1 Jan 2018 04:30:28 +0000 (08:30 +0400)]
gdb/copyright.py: Do not forget to remind about MULTIPLE_COPYRIGHT_HEADERS
There is a small logical error in the part of the script that
dumps the list of files in BY_HAND + MULTIPLE_COPYRIGHT_HEADERS
but only checkis the contents of BY_HAND. The issue becomes
apparent as soon as BY_HAND is empty. Prevent this from happening
by treating the two lists separately, as this allows us to provide
a more informative message in the case of MULTIPLE_COPYRIGHT_HEADERS.
gdb/ChangeLog:
* copyright.py (main): Dump the contents of
MULTIPLE_COPYRIGHT_HEADERS (separately) from BY_HAND,
even if BY_HAND is empty.
Joel Brobecker [Mon, 1 Jan 2018 04:12:21 +0000 (08:12 +0400)]
Update copyright year in version message of GDB, GDBserver and GDBreplay
gdb/ChangeLog:
* top.c (print_gdb_version): Update Copyright year in version
message.
gdb/gdbserver/ChangeLog:
* gdbreplay.c (gdbreplay_version): Update copyright year in
version message.
* server.c (gdbserver_version): Likewise.
Joel Brobecker [Mon, 1 Jan 2018 04:07:25 +0000 (08:07 +0400)]
Yearly rotation of the gdb/ChangeLog file
gdb/ChangeLog
* config/djgpp/fnchange.lst: Add entry for gdb/ChangeLog-2017.
GDB Administrator [Tue, 2 Jan 2018 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Mon, 1 Jan 2018 00:00:38 +0000 (00:00 +0000)]
Automatic date update in version.in
Ruslan Kabatsayev [Sat, 30 Dec 2017 19:14:41 +0000 (22:14 +0300)]
Avoid indexing std::vector past the end
The code here wants to find address of an element, and often this
element is one past the end of std::vector. Dereferencing that element
leads to undefined behavior, so it's better to simply use pointer
arithmetic instead of taking address of invalid dereference.
gdb/ChangeLog:
* psymtab.c (recursively_search_psymtabs): Use pointer arithmetic
instead of dereferencing std::vector past the end.
Simon Marchi [Sun, 31 Dec 2017 04:33:26 +0000 (23:33 -0500)]
Only ignore -Wenum-compare-switch if it exists
My patch
dwarf2read: Silence -Wenum-compare-switch warning
132448f8359a268f34f074b0908b5255b568da06
made some parts of dwarf2read.c ignore warnings about switch using enums
of different kinds. What I did not realize was that older Clang
versions (prior to 6) did not have that warning, and therefore give this
error:
/home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:24187:7: error: unknown warning group '-Wenum-compare-switch', ignored [-Werror,-Wunknown-pragmas]
DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES
^
/home/emaisin/src/binutils-gdb/gdb/common/diagnostics.h:42:3: note: expanded from macro 'DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES'
DIAGNOSTIC_IGNORE ("-Wenum-compare-switch")
^
/home/emaisin/src/binutils-gdb/gdb/common/diagnostics.h:27:3: note: expanded from macro 'DIAGNOSTIC_IGNORE'
_Pragma (STRINGIFY (GCC diagnostic ignored option))
^
<scratch space>:10:25: note: expanded from here
GCC diagnostic ignored "-Wenum-compare-switch"
^
Clang has a way to test if it knows about a particular warning. This
patch uses that feature to only define
DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES to something if the
warning is recognized by the Clang version being used. I tested
building dwarf2read.c with clang 4, 5, 6, as well as gcc.
gdb/ChangeLog:
* common/diagnostics.h
(DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES): Only
define if the compiler knows about -Wenum-compare-switch.
Simon Marchi [Sun, 31 Dec 2017 02:24:29 +0000 (21:24 -0500)]
dwarf2read: Silence -Wenum-compare-switch warning
Compiling with Clang 6 gives:
/home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:24385:14: error: comparison of two values with different enumeration types in switch statement ('enum dwarf_macro_record_type' and 'dwarf_macinfo_record_type') [-Werror,-Wenum-compare-switch]
case DW_MACINFO_vendor_ext:
^~~~~~~~~~~~~~~~~~~~~
/home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:24561:7: error: comparison of two values with different enumeration types in switch statement ('enum dwarf_macro_record_type' and 'dwarf_macinfo_record_type') [-Werror,-Wenum-compare-switch]
case DW_MACINFO_vendor_ext:
^~~~~~~~~~~~~~~~~~~~~
This code uses the two enum types on purpose, because it handles both
.debug_macro and .debug_macinfo sections. Add some pragmas to disable
the warning in these specific cases.
gdb/ChangeLog:
* dwarf2read.c (dwarf_decode_macro_bytes): Ignore
-Wenum-compare-switch warning.
(dwarf_decode_macros): Likewise.
Tom Tromey [Thu, 23 Nov 2017 04:45:53 +0000 (21:45 -0700)]
C++-ify parser_state
This mildly C++-ifies parser_state and stap_parse_info -- just enough
to remove some cleanups.
This version includes the changes implemented by Simon.
Regression tested by the buildbot.
gdb/ChangeLog
2017-12-30 Tom Tromey <tom@tromey.com>
Simon Marchi <simon.marchi@ericsson.com>
* stap-probe.h (struct stap_parse_info): Add constructor,
destructor.
* stap-probe.c (stap_parse_argument): Update.
* rust-exp.y (rust_lex_tests): Update.
* parser-defs.h (struct parser_state): Add constructor,
destructor, release method.
<expout>: Change type to expression_up.
(null_post_parser): Change type.
(initialize_expout, reallocate_expout): Remove.
* parse.c (parser_state::parser_state): Rename from
initialize_expout.
(parser_state::release): Rename from reallocate_expout.
(write_exp_elt, parse_exp_in_context_1, increase_expout_size):
Update.
(null_post_parser): Change type of "exp".
* dtrace-probe.c (dtrace_probe::build_arg_exprs): Update.
* ada-lang.c (resolve, resolve_subexp)
(replace_operator_with_call): Change type of "expp".
* language.h (struct language_defn) <la_post_parser>: Change type
of "expp".
GDB Administrator [Sun, 31 Dec 2017 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Sat, 30 Dec 2017 05:10:05 +0000 (00:10 -0500)]
Make mapped_debug_names and mapped_index final
When compiling with Clang 6, I see these warnings:
/home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:25421:5: error: destructor called on non-final 'mapped_index' that has virtual functions but non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor]
data->index_table->~mapped_index ();
^
In file included from /home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:31:
In file included from /home/emaisin/src/binutils-gdb/gdb/defs.h:28:
In file included from /home/emaisin/src/binutils-gdb/gdb/common/common-defs.h:92:
In file included from /home/emaisin/src/binutils-gdb/gdb/common/gdb_unique_ptr.h:23:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/memory:81:
/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/bits/unique_ptr.h:76:2: error: delete called on non-final 'mapped_debug_names' that has virtual functions but non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor]
delete __ptr;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/bits/unique_ptr.h:236:4: note: in instantiation of member function 'std::default_delete<mapped_debug_names>::operator()' requested here
get_deleter()(__ptr);
^
/home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:2374:21: note: in instantiation of member function 'std::unique_ptr<mapped_debug_names, std::default_delete<mapped_debug_names> >::~unique_ptr' requested here
dwarf2_per_objfile::dwarf2_per_objfile (struct objfile *objfile_,
^
This patch silences these warnings by making the classes final.
gdb/ChangeLog:
* dwarf2read.c (struct mapped_debug_names): Make final.
(struct mapped_index): Make final.
Simon Marchi [Sat, 30 Dec 2017 04:32:13 +0000 (23:32 -0500)]
Ignore warning about using different types of enums in switch
When compiling with clang 6, I see a bunch of warnings like this:
/home/emaisin/src/binutils-gdb/gdb/amd64-linux-tdep.c:1427:8: error: comparison of two values with different enumeration types in switch statement ('enum amd64_syscall' and 'amd
64_x32_syscall') [-Werror,-Wenum-compare-switch]
case amd64_x32_sys_move_pages:
^~~~~~~~~~~~~~~~~~~~~~~~
In this switch, we indeed use enumerators of both types
amd64_x32_syscall and amd64_syscall. This is done on purpose, and the
enum values are chosen so that they are complementary.
I think it's still a useful warning, so I chose to ignore just that
particular case.
gdb/ChangeLog:
* common/diagnostics.h
(DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES): New macro.
* amd64-linux-tdep.c (amd64_canonicalize_syscall): Use it.
Simon Marchi [Sat, 30 Dec 2017 02:56:58 +0000 (21:56 -0500)]
Remove unnecessary call to get_thread_db_info
In thread_db_detach, we call get_thread_db_info to first check if there
exists a thread_db_info entry for the pid to detach. If there is, then
we call delete_thread_db_info. It's unnecessary to call
get_thread_db_info in the first place, since delete_thread_db_info
handles the case where no thread_db_info entry exist for the given pid.
gdb/ChangeLog:
* linux-thread-db.c (thread_db_detach): Remove call to
delete_thread_db_info.
GDB Administrator [Sat, 30 Dec 2017 00:00:30 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Fri, 29 Dec 2017 00:00:34 +0000 (00:00 +0000)]
Automatic date update in version.in
Jim Wilson [Thu, 28 Dec 2017 21:21:46 +0000 (13:21 -0800)]
RISC-V: Add missing privileged spec registers.
gas/
* testsuite/gas/riscv/priv-reg.d, testsuite/gas/riscv/priv-reg.s: New.
include/
* opcode/riscv-opc.h (DECLARE_CSR): Add missing privileged registers.
Sort to match privileged spec documentation order.
(DECLARE_CSR_ALIAS): Add ubadaddr, and comments.
Simon Marchi [Thu, 28 Dec 2017 17:29:33 +0000 (12:29 -0500)]
Remove unused HP-UX TARGET_OBJECT_ enums
These two enumerators are unused, remove them.
gdb/ChangeLog:
* target.h (enum target_object) <TARGET_OBJECT_HPUX_UREGS,
TARGET_OBJECT_HPUX_SOLIB_GOT>: Remove.
GDB Administrator [Thu, 28 Dec 2017 00:00:21 +0000 (00:00 +0000)]
Automatic date update in version.in
Stafford Horne [Wed, 27 Dec 2017 14:36:31 +0000 (23:36 +0900)]
tdesc: handle arbitrary strings in tdesc_register_in_reggroup_p
tdesc_register_in_reggroup_p in now able to handle arbitrary
groups. This is useful when groups are created while the
target descriptor file is received from the remote.
This can be the case of a soft core target processor where
registers/groups can change.
gdb/ChangeLog:
yyyy-mm-dd Franck Jullien <franck.jullien@gmail.com>
Stafford Horne <shorne@gmail.com>
* target-descriptions.c (tdesc_register_in_reggroup_p): Support
arbitrary strings.
(tdesc_use_registers): Add logic to register new reggroups.
(tdesc_reg::group): Update comment to indicate we allow
arbitrary strings.
* NEWS (Changes since GDB 8.0): Announce that GDB supports
arbitrary reggroups.
gdb/testsuite/ChangeLog:
yyyy-mm-dd Stafford Horne <shorne@gmail.com>
* gdb.xml/extra-regs.xml: Add example foo reggroup.
* gdb.xml/tdesc-regs.exp: Add test to check for foo reggroup.
gdb/doc/ChangeLog:
yyyy-mm-dd Stafford Horne <shorne@gmail.com>
* gdb.texinfo (Target Description Format): Explain that arbitrary
strings are now allowed for register groups.
Stafford Horne [Wed, 27 Dec 2017 14:36:31 +0000 (23:36 +0900)]
reggroups: Add reggroup_gdbarch_new, reggroup_find for dynamic reggroups
Traditionally reggroups have been created via reggroup_new() during
initialization code and never freed. Now, if we want to initialize
reggroups dynamically (i.e. in target description) we should be able to
free them. Create this function reggroup_gdbarch_new() which will
allocate the reggroup memory onto the passed gdbarch obstack.
Also creating reggroup_find() as a utility to find a gdbarch registered
reggroup object by name.
gdb/ChangeLog:
yyyy-mm-dd Stafford Horne <shorne@gmail.com>
* reggroups.c (reggroup_gdbarch_new): New function.
(reggroup_find): New function.
* reggroups.h (reggroup_gdbarch_new): New function.
(reggroup_find): New function.
Stafford Horne [Wed, 27 Dec 2017 14:36:30 +0000 (23:36 +0900)]
reggroups: Convert reggroups from post_init to pre_init
Currently the reggroups gdbarch_data cannot be manipulated until after
the gdbarch is completely initialized. This is usually done when the
object init depends on architecture specific fields. In the case of
reggroups it only depends on the obstack being available.
Coverting this to pre_init allows using reggroups during gdbarch
initialization. This is needed to allow registering arbitrary reggroups
during gdbarch initializations.
gdb/ChangeLog:
yyyy-mm-dd Stafford Horne <shorne@gmail.com>
* reggroups.c (reggroups_init): Change to depend only on
obstack rather than gdbarch.
(reggroup_add): Remove logic for forcing premature init.
(_initialize_reggroup): Set `reggroups_data` with
gdbarch_data_register_pre_init() rather than
gdbarch_data_register_post_init().
Stafford Horne [Wed, 27 Dec 2017 14:36:30 +0000 (23:36 +0900)]
reggroups: Add test and docs for `info reg $reggroup` feature
Until now this feature has existed but was not documented. Adding docs
and tests.
gdb/ChangeLog:
yyyy-mm-dd Stafford Horne <shorne@gmail.com>
* infcmd.c (_initialize_infcmd): Add help for info reg $reggroup
and info all-registers $reggroup feature.
gdb/doc/ChangeLog:
yyyy-mm-dd Stafford Horne <shorne@gmail.com>
* gdb.texinfo (Registers): Document info reg $reggroup feature.
gdb/testsuite/ChangeLog:
yyyy-mm-dd Stafford Horne <shorne@gmail.com>
* gdb.base/reggroups.c: New file.
* gdb.base/reggroups.exp: New file.
GDB Administrator [Wed, 27 Dec 2017 00:00:21 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Tue, 26 Dec 2017 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Mon, 25 Dec 2017 00:00:30 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 24 Dec 2017 00:00:39 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Sat, 23 Dec 2017 21:25:06 +0000 (16:25 -0500)]
Add ATTRIBUTE_PRINTF to printf_field_type_assignment
Get rid of:
/home/simark/src/binutils-gdb/gdb/target-descriptions.c:2026:25: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
vprintf_unfiltered (fmt, args);
when building with clang.
gdb/ChangeLog:
* target-descriptions.c (print_c_tdesc)
<printf_field_type_assignment>: Add ATTRIBUTE_PRINTF.
GDB Administrator [Sat, 23 Dec 2017 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Fri, 22 Dec 2017 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Thu, 21 Dec 2017 23:19:17 +0000 (18:19 -0500)]
Do not emit "field_type" var if not needed on "maint print c-tdesc"
While fiddling a bit with -Wunused-variable, Sergio noticed that "maint
print c-tdesc" was always generating code for the "tdesc_type
*field_type" variable, even when it wasn't used. This is caught by GCC
when using -Wunused-variable, of course.
This patch changes the print_c_tdesc class to only output the field
declaration when we actually need it.
It shouldn't be necessary to do the same with the other variable
declarations (type_with_fields and element_type), because they are
always if they are declared.
The C files in features/ are regenerated, some declarations of
field_type are removed, as expected, while some others move to where
they are used for the first time.
gdb/ChangeLog:
* target-descriptions.c (print_c_tdesc) <visit>: Don't output
field_type declaration, use printf_field_type_assignment
instead.
<printf_field_type_assignment>: New method.
* features/aarch64-core.c, features/aarch64-fpu.c
features/arc-arcompact.c, features/arc-v2.c,
features/arm/arm-with-iwmmxt.c, features/i386/32bit-core.c,
features/i386/32bit-mpx.c, features/i386/32bit-sse.c,
features/i386/64bit-avx512.c, features/i386/64bit-core.c,
features/i386/64bit-mpx.c, features/i386/64bit-sse.c,
features/i386/x32-core.c, features/or1k.c,
features/rs6000/powerpc-7400.c,
features/rs6000/powerpc-altivec32.c,
features/rs6000/powerpc-altivec32l.c,
features/rs6000/powerpc-altivec64.c,
features/rs6000/powerpc-altivec64l.c,
features/rs6000/powerpc-cell32l.c,
features/rs6000/powerpc-cell64l.c,
features/rs6000/powerpc-isa205-altivec32l.c,
features/rs6000/powerpc-isa205-altivec64l.c,
features/rs6000/powerpc-isa205-vsx32l.c,
features/rs6000/powerpc-isa205-vsx64l.c,
features/rs6000/powerpc-vsx32.c,
features/rs6000/powerpc-vsx32l.c,
features/rs6000/powerpc-vsx64.c,
features/rs6000/powerpc-vsx64l.c, features/s390-gs-linux64.c,
features/s390-tevx-linux64.c, features/s390-vx-linux64.c,
features/s390x-gs-linux64.c, features/s390x-tevx-linux64.c,
features/s390x-vx-linux64.c: Re-generate.
Uros Bizjak [Thu, 21 Dec 2017 01:42:05 +0000 (20:42 -0500)]
Remove write-only assignment in rs6000-tdep.c
The result of this memory read is never used, so it can be removed.
gdb/ChangeLog:
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Remove
write-only assignment to "insn" variable.
GDB Administrator [Thu, 21 Dec 2017 00:00:39 +0000 (00:00 +0000)]
Automatic date update in version.in
Jim Wilson [Wed, 20 Dec 2017 21:37:44 +0000 (13:37 -0800)]
RISC-V: Add compressed instruction hints, and a few misc cleanups.
gas/
* config/tc-riscv.c (risc_ip) <o>: Add comment.
* testsuite/gas/riscv/c-nonzero-imm.d,
* testsuite/gas/riscv/c-nonzero-imm.l,
* testsuite/gas/riscv/c-nonzero-imm.s,
* testsuite/gas/riscv/c-nonzero-reg.d,
* testsuite/gas/riscv/c-nonzero-reg.l,
* testsuite/gas/riscv/c-nonzero-reg.s,
* testsuite/gas/riscv/c-zero-imm-64.d,
* testsuite/gas/riscv/c-zero-imm-64.s,
* testsuite/gas/riscv/c-zero-imm.d, testsuite/gas/riscv/c-zero-imm.s,
* testsuite/gas/riscv/c-zero-reg.d,
* testsuite/gas/riscv/c-zero-reg.s: New.
opcodes/
* riscv-opc.c (match_c_add_with_hint, match_c_lui_with_hint): New.
(riscv_opcodes) <li>: Delete "d,0" line. Change Cj to Co.
<andi, and, add, addiw, addw, c.addi>: Change Cj to Co.
<add>: Add explanatory comment for 4-operand add instruction.
<c.nop>: Add support for immediate operand.
<c.mv, c.add>: Use match_c_add_with_hint instead of match_c_add.
<c.lui>: Use match_c_lui_with_hint instead of match_c_lui.
<c.li, c.slli>: Use match_opcode instead of match_rd_nonzero.
Ulrich Weigand [Wed, 20 Dec 2017 12:59:14 +0000 (13:59 +0100)]
[Cell/B.E.] Fix regression due to gdbarch_significant_addr_bit
On Cell/B.E. multi-architecture debugging we use a "merged" address space
that encodes both the main PowerPC address space and the local store address
spaces of all active SPUs. This will always occupy 64 bits.
However, gdbarch_addr_bit is set to 32 on SPU, and may be set to 32 as well
on PowerPC. Since the new gdbarch_significant_addr_bit defaults to the
value of gdbarch_addr_bit, this means addresses may be improperly truncated.
Work around this problem by explicitly setting gdbarch_significant_addr_bit
to 64 both for the SPU target and also for PowerPC target that support
Cell/B.E. execution.
gdb/ChangeLog:
2017-12-20 Ulrich Weigand <uweigand@de.ibm.com>
* spu-tdep.c (spu_gdbarch_init): Set set_gdbarch_significant_addr_bit
to 64 bits.
(ppc_linux_init_abi): Likewise, if Cell/B.E. is supported.
Simon Marchi [Wed, 20 Dec 2017 03:09:40 +0000 (22:09 -0500)]
Fix ChangeLog formatting
Doing some unrelated grepping found that there were some missing
spaces, fix it.
GDB Administrator [Wed, 20 Dec 2017 00:00:21 +0000 (00:00 +0000)]
Automatic date update in version.in
Tamar Christina [Tue, 19 Dec 2017 12:05:20 +0000 (12:05 +0000)]
Correct disassembly of dot product instructions.
Dot products deviate from the normal disassembly rules for lane indexed
instruction. Their canonical representation is in the form of:
v0.2s, v0.8b, v0.4b[0] instead of v0.2s, v0.8b, v0.b[0] to try to denote
that these instructions select 4x 1 byte elements instead of a single 1 byte
element.
Previously we were disassembling them following the normal rules, this patch
corrects the disassembly.
gas/
PR gas/22559
* config/tc-aarch64.c (vectype_to_qualifier): Support AARCH64_OPND_QLF_S_4B.
* gas/testsuite/gas/aarch64/dotproduct.d: Update disassembly.
include/
PR gas/22559
* aarch64.h (aarch64_opnd_qualifier): Add AARCH64_OPND_QLF_S_4B.
opcodes/
PR gas/22559
* aarch64-asm.c (aarch64_ins_reglane): Change AARCH64_OPND_QLF_S_B to
AARCH64_OPND_QLF_S_4B
* aarch64-dis.c (aarch64_ext_reglane): Change AARCH64_OPND_QLF_S_B to
AARCH64_OPND_QLF_S_4B
* aarch64-opc.c (aarch64_opnd_qualifiers): Add 4b variant.
* aarch64-tbl.h (QL_V2DOT): Change S_B to S_4B.
Tamar Christina [Tue, 19 Dec 2017 12:04:13 +0000 (12:04 +0000)]
Add support for V_4B so we can properly reject it.
Previously parse_vector_type_for_operand was changed to allow the use of 4b
register size for indexed lane instructions. However this had the unintended
side effect of also allowing 4b for normal vector registers.
Because this support was only partial the rest of the tool silently treated
4b as 8b and continued. This patch adds full support for 4b so it can be
properly distinguished from 8b and the correct errors are generated.
With this patch you still can't encode any instruction which actually requires
v<num>.4b but such instructions don't exist so to prevent needing a workaround
in get_vreg_qualifier_from_value this was just omitted.
gas/
PR gas/22529
* config/tc-aarch64.c (vectype_to_qualifier): Support AARCH64_OPND_QLF_V_4B.
* gas/testsuite/gas/aarch64/pr22529.s: New.
* gas/testsuite/gas/aarch64/pr22529.d: New.
* gas/testsuite/gas/aarch64/pr22529.l: New.
include/
PR gas/22529
* opcode/aarch64.h (aarch64_opnd_qualifier): Add AARCH64_OPND_QLF_V_4B.
opcodes/
PR gas/22529
* aarch64-opc.c (aarch64_opnd_qualifiers): Add 4b variant.
Nick Clifton [Tue, 19 Dec 2017 09:48:40 +0000 (09:48 +0000)]
Stop readelf from complaining about relocation sections with an sh_info field of 0 in dynamic executables.
PR 22587
* readelf.c (process_section_headers): Do not complain about an
sh_info field of 0 in relocation sections of ET_EXEC or ET_DYN
type executables.
GDB Administrator [Tue, 19 Dec 2017 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Mon, 18 Dec 2017 11:57:08 +0000 (22:27 +1030)]
PR22626, invalid dynindx used for dynamic relocs against section syms
_bfd_elf_link_renumber_dynsyms is called twice by the linker. The
first call in bfd_elf_size_dynamic_sections is just to answer the
question as to whether there are there any dynamic symbols. The
second call in bfd_elf_size_dynsym_hash_dynstr sets the st_shndx value
that dynamic symbols will have. strip_excluded_output_sections is
called between these two calls. So sections seen on the first
_bfd_elf_link_renumber_dynsyms pass might differ from those seen on
the second pass. Unfortunately, that can result in a stripped
section's dynamic symbol being assigned a dynindx on the first pass
but not corrected to the final value (of zero, ie. not dynamic) on the
second pass. PowerPC, x86, mips, and most other targets that emit
dynamic section symbols, just test that section symbol dynindx is
non-zero before using a given section symbol in dynamic relocations.
This patch prevents _bfd_elf_link_renumber_dynsyms from setting any
section symbol dynindx on the first pass.
PR 22626
* elflink.c (_bfd_elf_link_renumber_dynsyms): Don't set section
dynindx when section_sym_count is NULL.
(bfd_elf_size_dynamic_sections): Pass NULL section_sym_count to
preliminary _bfd_elf_link_renumber_dynsyms call.
Alan Modra [Fri, 15 Dec 2017 06:38:56 +0000 (17:08 +1030)]
Test binutils_assemble return value
This is a followup to "binutils nm testsuite tidy". Since the perror
in binutils_assemble has been removed, we need to take more care in
failure paths.
The patch also fixed a number of .exp files that have multiple tests,
where an assembly failure returns from the .exp file. In most cases
it is nicer to attempt all tests.
* testsuite/binutils-all/ar.exp (unique_symbol): Don't run AR
if assembly fails.
* testsuite/binutils-all/arc/objdump.exp (check_assembly): If
objfile is empty, fail test.
* testsuite/binutils-all/arm/objdump.exp: Don't return if assembly
fails for a test, continue on to other tests.
* testsuite/binutils-all/bfin/objdump.exp: Likewise.
* testsuite/binutils-all/hppa/objdump.exp: Likewise.
* testsuite/binutils-all/m68k/objdump.exp: Likewise.
* testsuite/binutils-all/vax/objdump.exp: Likewise.
* testsuite/binutils-all/size.exp: Likewise.
* testsuite/binutils-all/nm.exp: Likewise. Move PR12753 test.
* testsuite/binutils-all/objcopy.exp: Don't perror on assembly fail.
* testsuite/binutils-all/objdump.exp: Report assembly fails.
Nick Clifton [Mon, 18 Dec 2017 17:57:18 +0000 (17:57 +0000)]
Decode expression lists used with DW_AT_byte_size and other DWARF attributes.
PR 22532
* dwarf.c (read_and_display_attr_value): Add attributes that might
use the DW_FORM_exprloc form, and if so, display the decoded
location expression list.
Nick Clifton [Mon, 18 Dec 2017 09:37:57 +0000 (09:37 +0000)]
Resolve PR 22493 - the encoding to be used when pushing the stack pointer onto the stack.
PR 22493
* config/tc-arm.c (encode_ldmstm): Do not use A2 encoding of the
PUSH insn when pushing the stack pointer.
Jan Beulich [Mon, 18 Dec 2017 08:37:15 +0000 (09:37 +0100)]
x86: fold certain AVX and AVX2 templates
Just like for instructions in GPRs, there's no need to have separate
templates for otherwise identical insns acting on XMM or YMM registers
(or memory of the same size).
Jan Beulich [Mon, 18 Dec 2017 08:36:14 +0000 (09:36 +0100)]
x86: fold RegXMM/RegYMM/RegZMM into RegSIMD
... qualified by their respective sizes, allowing to drop FirstXmm0 at
the same time.
Jan Beulich [Mon, 18 Dec 2017 08:35:01 +0000 (09:35 +0100)]
x86: drop FloatReg and FloatAcc
Express them as Reg|Tbyte and Acc|Tbyte respectively.
Jan Beulich [Mon, 18 Dec 2017 08:34:00 +0000 (09:34 +0100)]
x86: replace Reg8, Reg16, Reg32, and Reg64
Use a combination of a single new Reg bit and Byte, Word, Dword, or
Qword instead.
Besides shrinking the number of operand type bits this has the benefit
of making register handling more similar to accumulator handling (a
generic flag is being accompanied by a "size qualifier"). It requires,
however, to split a few insn templates, as it is no longer correct to
have combinations like Reg32|Reg64|Byte. This slight growth in size will
hopefully be outweighed by this change paving the road for folding a
presumably much larger number of templates later on.
Joel Brobecker [Mon, 18 Dec 2017 03:39:33 +0000 (22:39 -0500)]
improved error message when getting an exception printing a variable
Consider the following Ada code defining a global variable whose
type is an array of static bounds (1 .. 2), but where its elements
are a variant record whose size is not statically known:
type Ints is array (Natural range <>) of Integer;
type Bounded_Ints (Max_Size : Natural) is record
Length : Natural := 0;
Objs : Ints (1 .. Max_Size);
end record;
type Ints_Doubled is array (1 .. 2) of Bounded_Ints (Idem (0));
Global : Ints_Doubled;
When compiling this program at -O2 using a GCC-6.4-based compiler
on x86_64-linux, trying to print the value of that global variable
yields:
(gdb) p global
$1 =
Let's look at the debugging info, which starts with the global
variable itself...
.uleb128 0x19 # (DIE (0x25e) DW_TAG_variable)
.long .LASF32 # DW_AT_name: "fd__global"
.long 0x273 # DW_AT_type
... its type is a reference to a typedef ...
.uleb128 0x14 # (DIE (0x273) DW_TAG_reference_type)
.byte 0x8 # DW_AT_byte_size
.long 0x202 # DW_AT_type
[...]
.uleb128 0x15 # (DIE (0x202) DW_TAG_typedef)
.long .LASF19 # DW_AT_name: "fd__ints_doubled"
.long 0x20d # DW_AT_type
... of an array (1..2) ...
.uleb128 0x2 # (DIE (0x20d) DW_TAG_array_type)
.long .LASF19 # DW_AT_name: "fd__ints_doubled"
.long 0x15b # DW_AT_type
.long 0x221 # DW_AT_sibling
.uleb128 0x16 # (DIE (0x21a) DW_TAG_subrange_type)
.long 0x40 # DW_AT_type
.sleb128 2 # DW_AT_upper_bound
.byte 0 # end of children of DIE 0x20d
... of a struct whose name is fd__Tints_doubledC:
.uleb128 0x10 # (DIE (0x15b) DW_TAG_structure_type)
.long .LASF11 # DW_AT_name: "fd__Tints_doubledC"
.long 0x1e4 # DW_AT_GNAT_descriptive_type
# DW_AT_artificial
.long 0x1e4 # DW_AT_sibling
.uleb128 0x7 # (DIE (0x16a) DW_TAG_member)
.long .LASF4 # DW_AT_name: "max_size"
[snip]
The error occurs while Ada evaluator is trying to "fix"
the element type inside the array, so as to determine its actual
size. For that, it searches for a parallel "XVZ" variable,
which, when found, contains the object's actual size.
Unfortunately in our case, the variable exists but has been
optimized out, as seen by the presence of a variable DIE in
the debugging info, but with no address attribute:
.uleb128 0x18 # (DIE (0x24e) DW_TAG_variable)
.long .LASF31 # DW_AT_name: "fd__Tints_doubledC___XVZ"
.long 0x257 # DW_AT_type
# DW_AT_artificial
Discussing this with some members of AdaCore's compiler team,
it is expected that the optimizer can get rid of this variable,
and we don't want to pessimize the code just to improve debuggability,
since -O2 is about performance. So, the idea of this patch is
not to make it work, but provide a bit more information to help
users understand what kind of error is preventing GDB from being
able to print the variable's value.
The first hurdle we had to clear was the fact that ada_val_print
traps all exceptions (including QUIT ones!), and does so completly
silently. So, the fix was to add a trace of the exception being
generated. While doing so, we fix an old XXX/FIXME by only catching
errors, letting QUIT exceptions go through.
Once this is done, we now get an error message, which gives a first
clue as to what was happening:
(gdb) p fd.global
$1 = <error reading variable: value has been optimized out>
However, it would be more useful to know which value it was
that was optimized out. For that purpose, we enhanced
ada-lang.c::ada_to_fixed_type_1 so as to re-throw the error
with a message which indicates which variable we failed to read.
With those changes, the new output is now:
(gdb) p fd.global
$1 = <error reading variable: unable to read value of fd__Tints_doubledC___XVZ (value has been optimized out)>
gdb/ChangeLog:
* ada-lang.c (ada_to_fixed_type_1): Rethrow errors with
a more detailed exception message when getting an exception
while trying to read the value of an XVZ variable.
* ada-valprint.c (ada_val_print): Only catch RETURN_MASK_ERROR
exceptions. Print an error message when an exception is caught.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/ada-valprint-error.c: New file.
* gdb.dwarf2/ada-valprint-error.exp: New file.
Tested on x86_64-linux
Joel Brobecker [Mon, 18 Dec 2017 03:09:27 +0000 (22:09 -0500)]
(Ada) crash assigning to record component which is an array
Consider the following code, which declares a variabled called "input"
of type "parameter", which is a record with one component called "u2",
where the type of that component is a simple 3-element array of
floating point values:
type Float_Array_3 is array (1 .. 3) of Float;
type parameters is record
u2 : Float_Array_3;
end record;
input : parameters;
Trying to assign a value to input.u2 causes GDB to crash:
(gdb) p input.u2 := (0.25,0.5,0.75)
[1] 20228 segmentation fault (core dumped) [...]/gdb
The crash occurs because input.u2 is described in the debugging
info as a typedef of an array. Indeed, input's type is:
<1><ae9>: Abbrev Number: 7 (DW_TAG_structure_type)
<aea> DW_AT_name : (indirect string, offset: 0x1045): target_wrapper__parameters
[...]
<2><af5>: Abbrev Number: 8 (DW_TAG_member)
<af6> DW_AT_name : u2
[...]
<afb> DW_AT_type : <0xaca>
and, looking at DIE 0xaca to get input.u2's type, we see:
<1><aca>: Abbrev Number: 4 (DW_TAG_typedef)
<acb> DW_AT_name : (indirect string, offset: 0x1060): target_wrapper__float_array_3
[...]
<ad1> DW_AT_type : <0xad5>
We can also confirm, following the DW_AT_type attribute (0xad5), that
it's a typedef of our array:
<1><ad5>: Abbrev Number: 5 (DW_TAG_array_type)
<ad6> DW_AT_name : (indirect string, offset: 0x1060): target_wrapper__float_array_3
[...]
In fact, this scenario uncovered 2 areas where typedef handling
is missing, thus causing a crash. The first happens inside
assign_aggregate:
if (ada_is_direct_array_type (lhs_type))
{
lhs = ada_coerce_to_simple_array (lhs);
lhs_type = value_type (lhs);
low_index = TYPE_ARRAY_LOWER_BOUND_VALUE (lhs_type);
high_index = TYPE_ARRAY_UPPER_BOUND_VALUE (lhs_type);
}
Here, lhs_type is a TYPE_CODE_TYPEDEF. ada_is_direct_array_type
knows how to handle it, but TYPE_ARRAY_LOWER_BOUND_VALUE assumes
that the given type is a TYPE_CODE_ARRAY. As such, it ends up
accessing some fields in lhs_type which it shouldn't, and kaboom.
We fixed this issue by making sure that the TYPE_CODE_TYPEDEF
layer gets stripped.
Once this is done, we hit a different kind of error, also leading to
a SEGV, this time in assign_component. The code looks like this:
if (TYPE_CODE (value_type (lhs)) == TYPE_CODE_ARRAY)
[...]
else
[...]
Because once again lhs is a TYPE_CODE_TYPEDEF, the check fail,
and we end up assuming that lhs is a struct, executing the "else"
block, which is:
else
{
elt = ada_index_struct_field (index, lhs, 0, value_type (lhs));
elt = ada_to_fixed_value (elt);
}
Since lhs is not a struct, ada_index_struct_field returns NULL,
which ada_to_fixed_value does not handle well, hence another crash.
This patch fixes this other issue the same way, by stripping
TYPE_CODE_TYPEDEF layers.
gdb/ChangeLog:
* ada-lang.c (assign_component): Strip any TYPE_CODE_TYPEDEF
layer from lhs' type.
(assign_aggregate): Likewise.
gdb/testsuite:
* gdb.ada/assign_arr: New testcase.
Tested on x86_64-linux.
Xavier Roirand [Mon, 18 Dec 2017 02:59:07 +0000 (21:59 -0500)]
Ada: fix bad handling in ada_convert_actual
Using this small example:
procedure Foo is
type Integer_Access is access all Integer;
procedure P (A : Integer_Access) is
begin
null;
end P;
begin
P (null);
end Foo;
and doing this debug session:
(gdb) b p
Breakpoint 1 at 0x402d67: file foo.adb, line 7.
(gdb) print p(null)
Breakpoint 1, foo.p (a=0x641010) at foo.adb:10
... ^^^^^^^^^^
shows that something goes wrong between the initial null value and the
received parameter value in the 'f' function.
The value for the parameter 'a' we get is the address of the value we
would expect instead of the value itself. This can be checked by doing:
(gdb) p *a
$1 = 0
Before this fix, in ada_convert_value, this function was looking to the
actual value (the null value here) to determine if the formal (parameter
'a' in the procedure 'P' in this exemple) requires a pointer or not which
is a wrong assumption and leads to push the address of the value to the
inferior instead of the value itself.
This is fixed by this patch.
gdb/ChangeLog:
* ada-lang.c (ada_convert_actual): Change the way actual value
are passed to the inferior when the inferior expects a pointer type.
gdb/testsuite/ChangeLog:
* gdb.ada/funcall_ptr: New testcase.
Tested on x86_64-linux.
GDB Administrator [Mon, 18 Dec 2017 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Sun, 17 Dec 2017 17:40:54 +0000 (09:40 -0800)]
x86: Check pseudo prefix without instruction
Pseudo prefixes must be used on an instruction. Issue an error when
pseudo prefix is used without instruction.
PR gas/22623
* gas/config/tc-i386.c (output_insn): Check pseudo prefix
without instruction.
* testsuite/gas/i386/i386.exp: Run inval-pseudo.
* testsuite/gas/i386/inval-pseudo.l: New file.
* testsuite/gas/i386/inval-pseudo.s: Likewise.
GDB Administrator [Sun, 17 Dec 2017 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in
Stafford Horne [Sat, 16 Dec 2017 22:20:51 +0000 (07:20 +0900)]
gdb: Fix function parameter alignments in or1k-tdep.c.
As suggested by Joel Brobecker <brobecker@adacore.com> and as per fsf
coding standards. Also fix a few more issues with directly printing
pointers.
gdb/ChangeLog:
* gdb/or1k-tdep.c (show_or1k_debug): Fix function parameter alignment.
(or1k_analyse_inst): Likewise.
(or1k_single_step_through_delay): Likewise.
(or1k_frame_cache): Fix parameter alignment and use paddress()
instead of %x.
Stafford Horne [Sat, 16 Dec 2017 22:20:50 +0000 (07:20 +0900)]
gdb: Add news entries for new or1k target.
gdb/ChangeLog:
yyyy-mm-dd Stafford Horne <shorne@gmail.com>
* NEWS (Changes since GDB 8.0): Mention new or1k target and new
commands to set/show or1k debug.
Sergio Durigan Junior [Sat, 16 Dec 2017 03:33:07 +0000 (22:33 -0500)]
Fix ARI warning on gdb/typeprint.c:whatis_exp
I forgot to indent the "if" clause properly and put the "&&" at the
beginning of the line, so ARI complained. This commit fixed it.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
* typeprint.c (whatis_exp): Fix ARI warning and reindent "if"
condition.
GDB Administrator [Sat, 16 Dec 2017 00:00:33 +0000 (00:00 +0000)]
Automatic date update in version.in
Sergio Durigan Junior [Mon, 20 Nov 2017 21:34:59 +0000 (16:34 -0500)]
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
Sergio Durigan Junior [Mon, 11 Dec 2017 16:57:19 +0000 (11:57 -0500)]
Reorganize code to handle TYPE_CODE_{STRUCT,UNION} on 'c_type_print_base'
While doing the 'ptype /o' work, I noticed that 'c_type_print_base'
was very long, with a big amount of code just to handle the case of
TYPE_CODE_{STRUCT,UNION}. This made working with the function a bit
difficult, specially because of the level of indentation.
This commit moves this part of the code to their own functions. Now
we have a 'c_type_print_base_struct_union' with most of the code, and
also 'need_access_label_p', which is a subset of the code that was
also a good candidate for having its own function.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
* c-typeprint.c (need_access_label_p): New function.
(c_type_print_base_struct_union): New function.
(c_type_print_base): Move code to handle
TYPE_CODE_{STRUCT,UNION} to the functions mentioned above.
Nick Clifton [Fri, 15 Dec 2017 18:55:39 +0000 (18:55 +0000)]
Update documentation regarding the bfd returned by bfd_openr_next_archived_file
PR 22571
* archive.c (bfd_openr_next_archived_file): Extend the
documentation to note that it is necessary to call
bfd_check_format on the rrturned bfd before using it.
Richard Henderson [Fri, 15 Dec 2017 18:19:42 +0000 (18:19 +0000)]
Fix PR19061, gdb hangs/spins-on-cpu when debugging any program on Alpha
This fixes PR19061, where gdb hangs/spins-on-cpu when debugging any
program on Alpha.
(This patch is Uros' forward port of the patch from comment #5
of the PR [1].)
Patch was tested on alphaev68-linux-gnu, also tested with gcc's
testsuite, where it fixed all hangs in guality.exp and
simulate-thread.exp testcases.
[1] https://sourceware.org/bugzilla/show_bug.cgi?id=19061#c5
gdb/ChangeLog:
2017-12-15 Richard Henderson <rth@redhat.com>
Uros Bizjak <ubizjak@gmail.com>
PR gdb/19061
* alpha-tdep.c (alpha_software_single_step): Call
alpha_deal_with_atomic_sequence here.
(set_gdbarch_software_single_step): Set to
alpha_software_single_step.
* nat/linux-ptrace.h [__alpha__]: Define GDB_ARCH_IS_TRAP_BRKPT
and GDB_ARCH_IS_TRAP_HWBKPT.
Yao Qi [Fri, 15 Dec 2017 10:45:27 +0000 (10:45 +0000)]
Skip 'maintenance check xml-descriptions' if XML is disabled
I see the following test failure when gdb is configured without XML
support,
maintenance check xml-descriptions binutils-gdb/gdb/testsuite/../features
warning: Can not parse XML target description; XML support was disabled at compile time^M
Tested 29 XML files, 29 failed
(gdb) FAIL: gdb.gdb/unittest.exp: maintenance check xml-descriptions ${srcdir}/../features
gdb/testsuite:
2017-12-15 Yao Qi <yao.qi@linaro.org>
* gdb.gdb/unittest.exp: Skip 'maintenance check xml-descriptions'
if XML is disabled.
Yao Qi [Fri, 15 Dec 2017 10:45:27 +0000 (10:45 +0000)]
Skip parse_memory_map_tests if XML is disabled
I find a fail in gdb unit test when gdb is configured without XML
support.
warning: Can not parse XML memory map; XML support was disabled at compile time^M
Self test failed: self-test failed at ../../binutils-gdb/gdb/unittests/memory-map-selftests.c:65
...
Ran 31 unit tests, 1 failed^M
(gdb) FAIL: gdb.gdb/unittest.exp: maintenance selftest
gdb:
2017-12-15 Yao Qi <yao.qi@linaro.org>
* unittests/memory-map-selftests.c: Wrap test with HAVE_LIBEXPAT.
Dimitar Dimitrov [Fri, 15 Dec 2017 04:45:47 +0000 (06:45 +0200)]
Fix disassembly for PowerPC
* disassemble.c (disassemble_init_for_target): Don't put PRU
between powerpc and rs6000 cases.
Jan Beulich [Fri, 15 Dec 2017 08:14:52 +0000 (09:14 +0100)]
x86: correct operand type checks
Again these look to be typos: No template currently allows for any two
(or all three) of RegXMM, RegYMM, and RegZMM in a single operand. Quite
clearly ! are missing, after the addition of which the checks for the
first and (if present) second operands also fully match up.
Jan Beulich [Fri, 15 Dec 2017 08:13:54 +0000 (09:13 +0100)]
x86: drop stray CheckRegSize uses
They are relevant only when multiple operands permit registers:
operand_type_register_match() returns true if either operand is not a
register one. IOW
grep -i CheckRegSize i386-opc.tbl | grep -Ev "(Reg[8136]|Acc).*,.*(Reg|Acc)"
should produce no output.
Jan Beulich [Fri, 15 Dec 2017 08:12:37 +0000 (09:12 +0100)]
x86: correct abort check
I'm rather certain the missing ! was just a typo, the more with the
similar check in mind that's in the same function a few hundred lines
down (in the body of "if (vex_reg != (unsigned int) ~0)"). Of course
this can't be demonstrated by a test case - internal data structure
consistency is being checked here, and neither form of the check
triggers with any current template.
It is also not really clear to me why operand_type_equal() is being used
in the {X,Y,Z}MM register check here, rather than just testing the
respective bits: Just like Reg32|Reg64 is legal in an operand template,
I don't see why e.g. RegXMM|RegYMM wouldn't be. For example it ought to
be possible to combine
vaddpd, 3, 0x6658, None, 1, CpuAVX, Modrm|Vex|VexOpcode=0|VexVVVV=1|VexW=1|IgnoreSize|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf, { Xmmword|Unspecified|BaseIndex|Disp8|Disp16|Disp32|Disp32S|RegXMM, RegXMM, RegXMM }
vaddpd, 3, 0x6658, None, 1, CpuAVX, Modrm|Vex=2|VexOpcode=0|VexVVVV=1|VexW=1|IgnoreSize|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf, { Ymmword|Unspecified|BaseIndex|Disp8|Disp16|Disp32|Disp32S|RegYMM, RegYMM, RegYMM }
into a single template (with setting of VEX.L suitably handled elsewhere
if that's not already happening anyway).
Additionally I don't understand why this uses abort() instead of
gas_assert().
Both of these latter considerations then also apply to the
aforementioned other check in the same function.
Alan Modra [Fri, 15 Dec 2017 04:29:58 +0000 (14:59 +1030)]
[GOLD] PR22602, handle __tls_get_addr forwarders properly
We never need to resolve_forwards() a symbol found by hash table lookup
such as target->tls_get_addr_opt() but we do potentially need to do so
for random symbols seen on relocs. So these calls were in the wrong
order, resulting in missing stubs and an assertion failure.
PR 22602
* powerpc.cc (Target_powerpc::Branch_info::mark_pltcall): Resolve
forwards before replacing __tls_get_addr.
(Target_powerpc::Branch_info::make_stub): Likewise.
Xavier Roirand [Fri, 15 Dec 2017 03:38:17 +0000 (22:38 -0500)]
(Ada) Handle same component names when searching in tagged types
Consider the following code:
type Top_T is tagged record
N : Integer := 1;
U : Integer := 974;
A : Integer := 48;
end record;
type Middle_T is new Top.Top_T with record
N : Character := 'a';
C : Integer := 3;
end record;
type Bottom_T is new Middle.Middle_T with record
N : Float := 4.0;
C : Character := '5';
X : Integer := 6;
A : Character := 'J';
end record;
Tagged records in Ada provide object-oriented features, and what
is interesting in the code above is that a child tagged record
introduce additional components (fields) which sometimes have
the same name as one of the components in the parent. For instance,
Bottom_T introduces a component named "C", while at the same time
inheriting from Middle_T which also has a component named "C";
so, in essence, type Bottom_T has two components with the same name!
And before people start wondering why the language can possibly
be allowing that, this can only happen if the parent type has
a private definition. In our case, this was brought to our attention
when the parent was a generic paramenter.
With that in mind... Let's say we now have a variable declared
and initialized as follow:
TC : Top_A := new Bottom_T;
And then we use this variable to call this function
procedure Assign (Obj: in out Top_T; TV : Integer);
as follow:
Assign (Top_T (B), 12);
Now, we're in the debugger, and we're inside that procedure
(Top.Assign in our gdb testcase), and we want to print
the value of obj.c:
Usually, the tagged record or one of the parent type owns the
component to print and there's no issue but in this particular
case, what does it mean to ask for Obj.C ? Since the actual
type for object is type Bottom_T, it could mean two things: type
component C from the Middle_T view, but also component C from
Bottom_T. So in that "undefined" case, when the component is
not found in the non-resolved type (which includes all the
components of the parent type), then resolve it and see if we
get better luck once expanded.
In the case of homonyms in the derived tagged type, we don't
guaranty anything, and pick the one that's easiest for us
to program.
This patch fixes the behavior like described above.
gdb/ChangeLog:
* ada-lang.c (ada_value_primitive_field): Handle field search
in case of homonyms.
(find_struct_field): Ditto.
(ada_search_struct_field): Ditto.
(ada_value_struct_elt): Ditto.
(ada_lookup_struct_elt_type): Ditto.
gdb/testsuite/ChangeLog:
* gdb.ada/same_component_name: New testcase.
Tested on x86_64-linux.
GDB Administrator [Fri, 15 Dec 2017 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Thu, 14 Dec 2017 20:46:47 +0000 (15:46 -0500)]
py-breakpoint: Don't use the 'p' PyArg_ParseTupleAndKeywords format specifier
In Python 3, the 'p' format specifier can be passed to
PyArg_ParseTupleAndKeywords to test the argument for truth and convert
it to a boolean value (the p stands for predicate). However, it is not
available in Python 2, causing this error:
Traceback (most recent call last):
File "test.py", line 1, in <module>
b1 = gdb.Breakpoint("foo", qualified=False)
TypeError: argument 10 (impossible<bad format char>)
This patch changes it to the 'O' specifier, which returns the Python
object passed in without transformation, and uses PyObject_IsTrue on it.
This is what is done for the other boolean parameters of this function
(internal and temporary).
This fixes the test gdb.python/py-breakpoint.exp for Python 2.
gdb/ChangeLog:
* python/py-breakpoint.c (bppy_init): Use 'O' format specifier
for "qualified" and use PyObject_IsTrue.
Nick Clifton [Thu, 14 Dec 2017 12:48:55 +0000 (12:48 +0000)]
Update the address of the FSF in the copyright notice of files which were using the old address.
top * COPYING.LIBGLOSS: Update address of FSF in copyright notice.
bfd * cpu-mt.c: Update address of FSF in copyright notice.
* elf32-m32c.c: Likewise.
* elf32-mt.c: Likewise.
* elf32-rl78.c: Likewise.
* elf32-rx.c: Likewise.
* elf32-rx.h: Likewise.
* elf32-spu.h: Likewise.
* hosts/x86-64linux.h: Likewise.
etc * add-log.el: Update address of FSF in copyright notice.
gas * config/tc-m32c.c: Update address of FSF in copyright notice.
* config/tc-m32c.h: Likewise.
* config/tc-mt.c: Likewise.
* config/tc-mt.h: Likewise.
* config/tc-visium.c: Likewise.
* config/tc-visium.h: Likewise.
* testsuite/gas/rx/explode: Likewise.
ld * testsuite/ld-mn10300/mn10300.exp: Update address of FSF in
copyright notice.
Alan Modra [Thu, 14 Dec 2017 08:27:02 +0000 (18:57 +1030)]
binutils nm testsuite tidy
We can run the gnu_unique_object symbol test on all ELF targets.
Those that don't support the symbol type and fail to assemble can just
be resolved as "unsupported". This means binutils_assemble can't
report an error on assembly failure, but it probably should never have
done that anyway.
* testsuite/lib/utils-lib.exp (default_binutils_assemble_flags):
Don't perror on assembler diagnostic output.
* testsuite/binutils-all/nm.exp: Run unique symbol test on all
ELF targets. Resolve as "unsupported" on assembly failure.
Jan Kratochvil [Thu, 14 Dec 2017 09:00:17 +0000 (10:00 +0100)]
DWARF-5 .debug_names DW_IDX_type_unit fix
The .debug_names completely misses its support as it did not even produce
DW_IDX_type_unit.
gdb/ChangeLog
2017-12-14 Jan Kratochvil <jan.kratochvil@redhat.com>
* dwarf2read.c (dw2_debug_names_iterator::next): Support
DW_IDX_type_unit.
(debug_names::dwarf5_offset_size, unit_kind): New.
(debug_names::insert): Add parameter kind.
(debug_names::build): Support DW_IDX_type_unit.
(debug_names::recursively_write_psymbols): Update
(debug_names::write_psymbols caller.
(debug_names::write_one_signatured_type_data)
(debug_names::write_one_signatured_type): New.
(debug_names::index_key, debug_names::symbol_value)
(debug_names::write_psymbols): Add kind.
(debug_names::write_one_signatured_type): New.
(write_debug_names): Move dwarf5_offset_size to debug_names.
Use debug_names::write_one_signatured_type for type units.
Joel Brobecker [Thu, 14 Dec 2017 05:05:24 +0000 (00:05 -0500)]
Ada: unable to compare strings (Attempt to compare array with non-array)
Consider the following Ada Code:
type Str is new String (1 .. 4);
My_str : Str := "ABCD";
This simply declares a 4-character string type. Trying to perform
equality tests using it currently yield an error:
(gdb) p my_str = my_str
Attempt to compare array with non-array
(gdb) p my_str = "ABCD"
Attempt to compare array with non-array
The error occurs because my_str is defined as an object whose
type is a typdef to a TYPE_CODE_ARRAY, which ada_value_equal
is not expecting at all (yet). This patch fixes this oversight.
gdb/ChangeLog:
* ada-lang.c (ada_value_equal): Add handling of typedef types
when comparing array objects.
gdb/testsuite/ChangeLog:
* gdb.ada/str_binop_equal: New testcase.
Tested on x86_64-linux.
Joel Brobecker [Thu, 14 Dec 2017 03:36:42 +0000 (22:36 -0500)]
(Ada) Add support for task switching when debugging core files
The reasons for not supporting task switching when debugging core files
appear to now mostly be OBE. In particular, on GNU/Linux, the thread
layer is now able to retrieve the same thread info as in the live
process. So, this patch is mostly about just removing the guard
that limited the use of task switching to live processes.
gdb/ChangeLog:
* ada-tasks.c (read_atcb): Properly set task_info->ptid
when !target_has_execution as well.
(task_command): Remove error when !target_has_execution.
gdb/testsuite/ChangeLog:
* gdb.ada/task_switch_in_core: New testcase.
GDB Administrator [Thu, 14 Dec 2017 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in
Jim Wilson [Wed, 13 Dec 2017 22:59:42 +0000 (14:59 -0800)]
Add missing RISC-V fsrmi and fsflagsi instructions.
PR 22599
gas/
* testsuite/gas/riscv/fsxxi.d, testsuite/gas/riscv/fsxxi.s: New.
opcodes/
* riscv-opc.c (riscv_opcodes) <fsrmi, fsflagsi>: New.
Simon Marchi [Wed, 13 Dec 2017 16:37:09 +0000 (11:37 -0500)]
python: Add qualified parameter to gdb.Breakpoint
This patch adds the possibility to pass a qualified=True|False parameter
when creating a breakpoint in Python. It is equivalent to using
-qualified in a linespec. The parameter actually accepts any Python
value, and converts it to boolean using Python's standard rules for
that (https://docs.python.org/3/library/stdtypes.html#truth).
Unlike the -source/-line/-function/-label parameters, it is possible to
use -qualified with a "normal" (non-explicit) linespec. Therefore, it
is possible (unlike these other parameters) to use this new parameter
along with the spec parameter.
I updated the py-breakpoint.exp test. To be able to test multiple
locations using a namespace, I had to switch the test case to compile as
C++. If we really wanted to, we could run it as both C and C++, but
omit the C++-specific parts when running it as C.
gdb/ChangeLog:
* location.h (string_to_event_location): Add match_type
parameter.
* location.c (string_to_event_location): Likewise.
* python/py-breakpoint.c (bppy_init): Handle qualified
parameter.
gdb/doc/ChangeLog:
* python.texi (Manipulating breakpoints using Python): Document
qualified parameter to gdb.Breakpoint.
gdb/testsuite/ChangeLog:
* gdb.python/py-breakpoint.c (foo_ns::multiply): New function.
* gdb.python/py-breakpoint.exp: Compile the test case as c++,
call test_bkpt_qualified.
(test_bkpt_qualified): New proc.
Pedro Alves [Wed, 13 Dec 2017 16:38:50 +0000 (16:38 +0000)]
Tighten regexp of lib/completion-support.exp:test_gdb_complete_tab_multiple
While writing the tests included in the previous commit, I noticed
that test_gdb_complete_tab_multiple would not FAIL if GDB happens to
show more completions than expected before the expected list.
E.g., with something like this, expecting "p foo" to complete to
"foo2" and "foo3":
test_gdb_complete_tab_multiple "p foo" "" {
"foo2"
"foo3"
}
and then if foo actually completes to:
(gdb) p foo[TAB]
foo1 foo2 foo3
^^^^
we'd still PASS. (Note the spurious "foo1" above.)
This tightens the regexp with a beginning anchor thus making the
completions above cause a FAIL. Other similar functions in
completion-support.exp already do something like this; I had just
missed this one originally. Thankfully, this did not expose any
problems in the gdb.linespec/ tests. Phew.
gdb/testsuite/ChangeLog:
2017-12-13 Pedro Alves <palves@redhat.com>
* lib/completion-support.exp (test_gdb_complete_tab_multiple):
Tighten regexp by matching with an anchor.
Pedro Alves [Wed, 13 Dec 2017 16:38:50 +0000 (16:38 +0000)]
Fix regression: expression completer and scope operator (PR gdb/22584)
I noticed this regression in the expression completer:
"(gdb) p std::[TAB]" => "(gdb) p std::std::"
obviously we should have not completed to "std::std::".
The problem is that in the earlier big completer rework, I missed
taking into account the fact that with expressions, the completion
word point is not always at the start of the symbol name (it is with
linespecs).
The fix is to run the common prefix / LCD string (what readline uses
to expand the input line) through make_completion_match_str too.
New testcase included, exercising both TAB completion and the complete
command.
gdb/ChangeLog:
2017-12-13 Pedro Alves <palves@redhat.com>
* completer.c (completion_tracker::maybe_add_completion): New
'text' and 'word' parameters. Use make_completion_match_str.
(completion_tracker::add_completion): New 'text' and 'word'
parameters. Pass down.
(completion_tracker::recompute_lowest_common_denominator): Change
parameter type to gdb::unique_xmalloc_ptr rval ref. Adjust.
* completer.h (completion_tracker::add_completion): New 'text' and
'word' parameters.
(completion_tracker::recompute_lowest_common_denominator): Change
parameter type to gdb::unique_xmalloc_ptr rval ref.
(completion_tracker::recompute_lowest_common_denominator): Change
parameter type to gdb::unique_xmalloc_ptr rval ref.
* symtab.c (completion_list_add_name): Pass down 'text' and 'word'
as well.
gdb/testsuite/ChangeLog:
2017-12-13 Pedro Alves <palves@redhat.com>
* gdb.cp/cpcompletion.exp: Load completion-support.exp.
("expression with namespace"): New set of tests.
* gdb.cp/pr9594.cc (Test_NS::foo, Test_NS::bar)
(Nested::Test_NS::qux): New.
* lib/completion-support.exp (test_gdb_complete_cmd_multiple): Add
defaults to 'start_quote_char' and 'end_quote_char' parameters.
Pedro Alves [Wed, 13 Dec 2017 16:38:49 +0000 (16:38 +0000)]
Factor out final completion match string building
We have several places doing essentially the same thing; factor them
out to a central place. Some of the places overallocate for no good
reason, or use strcat unnecessarily. The centralized version is more
precise and to the point.
(I considered making the gdb::unique_xmalloc_ptr overload version of
make_completer_match_str try to realloc (not xrealloc) probably
avoiding an allocation in most cases, but that'd be probably overdoing
it, and also, now that I'm writing this I thought I'd try to see how
could we ever get to filename_completer with "text != word", but I
couldn't figure it out. Running the testsuite with 'gdb_assert (text
== word);' never tripped on the assertion either. So post gdb 8.1,
I'll probably propose a patch to simplify filename_completer a bit,
and the gdb::unique_xmalloc_str overload can be removed then.)
gdb/ChangeLog:
2017-12-13 Pedro Alves <palves@redhat.com>
* cli/cli-decode.c (complete_on_cmdlist, complete_on_enum): Use
make_completion_match_str.
* completer.c: Use gdb::unique_xmalloc_ptr and
make_completion_match_str.
(make_completion_match_str_1): New.
(make_completion_match_str(const char *, const char *,
const char *)): New.
(make_completion_match_str(gdb::unique_xmalloc_ptr<char> &&,
const char *, const char *)): New.
* completer.h (make_completion_match_str(const char *,
const char *, const char *)): New.
(make_completion_match_str(gdb::unique_xmalloc_ptr<char> &&,
const char *, const char *)): New.
* interps.c (interpreter_completer): Use make_completion_match_str.
* symtab.c (completion_list_add_name, add_filename_to_list): Use
make_completion_match_str.
Simon Marchi [Wed, 13 Dec 2017 16:26:51 +0000 (11:26 -0500)]
python doc: Rework Breakpoint.__init__ doc
I find the documentation of the gdb.Breakpoint constructor hard to read
and not very informative, especially since we have added the new
linespec parameters. There are multiple problems (some are subjective):
- It's not clear that you should use either the spec string or the
explicit arguments, not both.
- It's not clear what combination of parameters you can use.
- The big block of text describing the arguments is hard to read.
- Currently, it seems like the "spec" argument is mandatory, even though
it is not (if you use explicit linespec).
- The square bracket nesting
[arg1 [, arg2[, arg3]]]
makes it seems like if you specify arg3, you must specify arg1 and
arg2 (it's not the case here).
This patch tries to address these problems.
gdb/doc/ChangeLog:
* python.texi (Manipulating breakpoints using Python): Split doc
of Breakpoint.__init__ in two, split text in multiple
paragraphs, don't nest parameter square brackets.
Renlin Li [Wed, 13 Dec 2017 12:11:25 +0000 (12:11 +0000)]
[BFD][AARCH64]Disallow R_AARCH64_ABS32(LP64) & R_AARCH64_ABS16 in const section of shared object.
R_AARCH64_ABS64, R_AARCH64_ABS32 and R_AARCH64_ABS16 are data relocations
supported in AArch64 elf ABI.
R_AARCH64_ABS64 under LP64 is allowed in shared object and a dynamic relocation entry
will be generated. This allows the dynamic linker to do further symbol resolution.
R_AARCH64_ABS32 likewise is allowed in shared object, however under ILP32 abi.
The original behavior for R_AARCH64_ABS32 under LP64 is that, it's allowed
in shared object and silently resolved at static linking time.
No dynamic relocation entry is generate for it.
R_AARCH64_ABS16 is allowed in shared object under both L64 and ILP32.
It's resolved at static linking time as well.
Under LP64, the address should be 64-bit. R_AARCH64_ABS32 relocation indicates
an address that is only sized 32 bits which is meaningless in LP64 shared object.
It's useful to error out.
I have checked glibc dynamic linker code, R_AARCH64_ABS16 is not supported at all. So
R_AARCH64_ABS16 should be reject in shared object completely.
In this patch, R_AARCH64_ABS32 is rejected under LP64 in constant section of shared object.
R_AARCH64_ABS16 is rejected in constant section of shared object in both ABI.
This will sometimes provide useful information for buggy code.
Stafford Horne [Wed, 13 Dec 2017 15:00:51 +0000 (00:00 +0900)]
gdb: Fix ARI warnings in or1k-tdep.c
Fix a few issues not using the gettext _() wrapper and issues where
we are using %p directly instead of the dedicated host/target functions.
gdb/ChangeLog:
yyyy-mm-dd Stafford Horne <shorne@gmail.com>
* or1k-tdep.c (or1k_analyse_inst): Use _() wrapper for message
strings.
(or1k_unwind_pc): Use paddress() instead of %p.
(or1k_unwind_sp): Likewise.
(or1k_frame_cache): Use host_address_to_string()/paddress()
instead of %p and use _() wrapper for message strings.
Simon Marchi [Wed, 13 Dec 2017 14:33:54 +0000 (09:33 -0500)]
Fix typo in gdb_ari.sh
gdb/ChangeLog:
* contrib/ari/gdb_ari.sh: Fix typo in help.