(Ada) Fix Length attribute on array access
Consider the following variable "Indexed_By_Enum", declared as
an access to an array whose index type is an enumerated type
whose underlying values have "gaps":
type Enum_With_Gaps is (LIT0, LIT1, LIT2, LIT3, LIT4);
for Enum_With_Gaps use (LIT0 => 3,
LIT1 => 5,
LIT2 => 8,
LIT3 => 13,
LIT4 => 21);
for Enum_With_Gaps'size use 16;
type MyWord is range 0 .. 16#FFFF# ;
for MyWord'Size use 16;
type AR is array (Enum_With_Gaps range <>) of MyWord;
type AR_Access is access AR;
Indexed_By_Enum : AR_Access :=
new AR'(LIT1 => 1, LIT2 => 43, LIT3 => 42, LIT4 => 41);
Trying to print the length (number of elements) of this array using
the 'Length attribute does not work:
(gdb) print indexed_by_enum'length
'POS only defined on discrete types
The problem occurs while trying to get the array's index type.
It was using TYPE_INDEX_TYPE for that. It does not work for Ada arrays
in general; use ada_index_type instead.
gdb/ChangeLog:
* ada-lang.c (ada_array_length): Use ada_index_type instead of
TYPE_INDEX_TYPE.
gdb/testsuite/ChangeLog:
* gdb.ada/arr_acc_idx_w_gap: New testcase.
Tested on x86_64-linux.
2018-01-05 09:03:59 +01:00
|
|
|
|
2018-01-05 Jerome Guitton <guitton@adacore.com>
|
|
|
|
|
|
|
|
|
|
* ada-lang.c (ada_array_length): Use ada_index_type instead of
|
|
|
|
|
TYPE_INDEX_TYPE.
|
|
|
|
|
|
memory error printing component of record from convenience variable
Consider the following situation Ada code:
type Kind_T is (One, Two, Three);
type Time_Set_T is array (Kind_T) of Integer;
type T is record
Started : Time_Set_T;
end record;
Null_T : constant T := (Started => (others => 0));
My_Item : Pck.T := Pck.Null_T;
Trying to print the value of My_Item.Started is no problem:
(gdb) p item.started
$1 = (0, 0, 0)
However, if you save My_Item into a convenience variable first,
and then try to print a component of that record, you get
an unexpected memory error, instead of getting the same result.
For instance:
(gdb) set variable $item := item
(gdb) p $item.started
Cannot access memory at address 0x0
The issue occurs when, after we extracted the component from
the convenience variable, we next try to "fix" it (which is
ada-lang speak for resolving the type into a static type).
This is done in ada_to_fixed_value, which delegates to
ada_to_fixed_value_create via:
val = ada_to_fixed_value_create (value_type (val),
value_address (val), val);
And looking at ada_to_fixed_value_create, we see that:
struct type *type = ada_to_fixed_type (type0, 0, address, NULL, 1);
if (type == type0 && val0 != NULL)
return val0;
else
return value_from_contents_and_address (type, 0, address);
The part that interests us, in this case, is the "else" branch,
where we obviously make the implicit assumption that our object
has an address, which is not true, in this case, because we are
actually dealing with a convenience variable.
This patch plugs that hole by adding special handing for situations
where val does not live in memory. In that case, we just create
a not_lval value using val's contents.
gdb/ChangeLog:
* ada-lang.c (ada_to_fixed_value_create): Add handling of
the case where VALUE_LVAL (val0) is not lval_memory.
gdb/testsuite/ChangeLog:
* gdb.ada/convvar_comp: New testcase.
Tested on x86_64-linux.
2018-01-05 08:37:38 +01:00
|
|
|
|
2018-01-05 Joel Brobecker <brobecker@adacore.com>
|
|
|
|
|
|
|
|
|
|
* ada-lang.c (ada_to_fixed_value_create): Add handling of
|
|
|
|
|
the case where VALUE_LVAL (val0) is not lval_memory.
|
|
|
|
|
|
2018-01-05 08:39:10 +01:00
|
|
|
|
2018-01-05 Xavier Roirand <roirand@adacore.com>
|
2018-01-05 05:47:05 +01:00
|
|
|
|
|
|
|
|
|
* ada-valprint.c (print_optional_low_bound): Handle
|
|
|
|
|
character-indexed array printing like boolean-indexed array
|
|
|
|
|
printing.
|
|
|
|
|
|
2018-01-05 05:18:05 +01:00
|
|
|
|
2018-01-05 Joel Brobecker <brobecker@adacore.com>
|
|
|
|
|
|
|
|
|
|
* NEWS: Create a new section for the next release branch.
|
|
|
|
|
Rename the section of the current branch, now that it has
|
|
|
|
|
been cut.
|
|
|
|
|
|
2018-01-05 05:08:09 +01:00
|
|
|
|
2018-01-05 Joel Brobecker <brobecker@adacore.com>
|
|
|
|
|
|
|
|
|
|
GDB 8.1 branch created (5219ac6237c272b938c28517bf371429260c71e7):
|
|
|
|
|
* version.in: Bump version to 8.1.50.DATE-git.
|
|
|
|
|
|
(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.
2017-11-22 10:40:39 +01:00
|
|
|
|
2018-01-03 Xavier Roirand <roirand@adacore.com>
|
|
|
|
|
|
|
|
|
|
* 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/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.
2018-01-02 04:53:55 +01:00
|
|
|
|
2018-01-02 Joel Brobecker <brobecker@adacore.com>
|
|
|
|
|
|
|
|
|
|
* 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.
|
|
|
|
|
|
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.
2018-01-02 04:47:18 +01:00
|
|
|
|
2018-01-02 Joel Brobecker <brobecker@adacore.com>
|
|
|
|
|
|
|
|
|
|
* 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.
|
|
|
|
|
|
2018-01-02 04:41:36 +01:00
|
|
|
|
2018-01-02 Joel Brobecker <brobecker@adacore.com>
|
|
|
|
|
|
|
|
|
|
* dwarf2read.c (read_unspecified_type): Treat
|
|
|
|
|
DW_TAG_enumeration_type DIEs from Ada units as stubs.
|
|
|
|
|
|
2018-01-01 05:43:02 +01:00
|
|
|
|
2018-01-01 Joel Brobecker <brobecker@adacore.com>
|
|
|
|
|
|
|
|
|
|
Update copyright year range in all GDB files.
|
|
|
|
|
|
2018-01-01 05:18:16 +01:00
|
|
|
|
2018-01-01 Joel Brobecker <brobecker@adacore.com>
|
|
|
|
|
|
|
|
|
|
* copyright.py (BY_HAND): Remove gdb/testsuite/gdb.base/step-line.inp
|
|
|
|
|
and gdb/testsuite/gdb.base/step-line.c.
|
|
|
|
|
|
2018-01-01 05:30:28 +01:00
|
|
|
|
2018-01-01 Joel Brobecker <brobecker@adacore.com>
|
|
|
|
|
|
|
|
|
|
* copyright.py (main): Dump the contents of
|
|
|
|
|
MULTIPLE_COPYRIGHT_HEADERS (separately) from BY_HAND,
|
|
|
|
|
even if BY_HAND is empty.
|
|
|
|
|
|
2018-01-01 05:12:21 +01:00
|
|
|
|
2018-01-01 Joel Brobecker <brobecker@adacore.com>
|
|
|
|
|
|
|
|
|
|
* top.c (print_gdb_version): Update Copyright year in version
|
|
|
|
|
message.
|
|
|
|
|
|
2018-01-01 05:07:25 +01:00
|
|
|
|
2018-01-01 Joel Brobecker <brobecker@adacore.com>
|
2017-12-30 20:14:41 +01:00
|
|
|
|
|
2018-01-01 05:07:25 +01:00
|
|
|
|
* config/djgpp/fnchange.lst: Add entry for gdb/ChangeLog-2017.
|
2017-12-30 20:14:41 +01:00
|
|
|
|
|
2018-01-01 05:07:25 +01:00
|
|
|
|
For older changes see ChangeLog-2017.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
mode: change-log
|
|
|
|
|
left-margin: 8
|
|
|
|
|
fill-column: 74
|
|
|
|
|
version-control: never
|
2007-08-10 00:44:38 +02:00
|
|
|
|
coding: utf-8
|
1999-04-16 03:35:26 +02:00
|
|
|
|
End:
|