The comments about mixed case in the testcase are actually a red
herring. The problem here is that we'd get to
ada_lookup_encoded_symbol with "my_table", which wraps the looked up
name in "<>"s to force a verbatim match, and that in turn disables
wild matching.
Fix this by swapping around the internals of ada_lookup_encoded_symbol
and ada_lookup_symbol, thus avoiding the encoding and
verbatim-wrapping in the ada_lookup_symbol case, the case that starts
with a user-provided lookup name.
Ada encoding is still done of course, in the ada_lookup_name_info
ctor. This could be also seen as avoiding the double-encoding problem
in a different way.
gdb/ChangeLog:
2018-01-05 Pedro Alves <palves@redhat.com>
PR gdb/22670
* ada-lang.c (ada_lookup_encoded_symbol): Reimplement in terms of
ada_lookup_symbol.
(ada_lookup_symbol): Reimplement in terms of
ada_lookup_symbol_list, bits factored out from
ada_lookup_encoded_symbol.
gdb/testsuite/ChangeLog:
2018-01-05 Pedro Alves <palves@redhat.com>
PR gdb/22670
* gdb.ada/info_addr_mixed_case.exp: Remove kfail. Extend test to
exercise lower case too, and to exercise both full matching and
wild matching.
Consider the following code, which creates a local variable B
which is a renaming whose expression references a subprogram
parameter:
procedure Flip (Bits : in out Bits_Type; I : Natural) is
begin
declare
B : Boolean renames Bits (I);
begin
B := not B; -- BREAK
end;
end Flip;
Trying to print the value of B when at the "BREAK" line currently
does not work:
(gdb) p b
Could not find i
What happens is the following: For the renaming, GNAT generates
a variable whose name is encoded as follow:
b___XR_bits___XEXSi
GDB properly detects that variable, determines that, to compute
the variable's value, we start from the symbol "Bits", which
we then have to subscript (XS) using 'i' as the index. The error
occurs while trying to find 'i'.
This is because we forgot to pass the block in the call to
ada_lookup_encoded_symbol, which this patch fixes.
gdb/ChangeLog:
* ada-exp.y (write_object_renaming): When subscripting an array
using a symbol as the index, pass the block in call to
ada_lookup_encoded_symbol when looking that symbol up.
gdb/testsuite/ChangeLog:
* gdb.ada/rename_subscript_param: New testcase.
Tested on x86_64-linux.
Note: This requires the following GCC patch:
| 2017-04-25 Pierre-Marie de Rodat <derodat@adacore.com>
|
| * exp_dbug.adb: In Debug_Renaming_Declaration,
| when dealing with indexed component, accept to produce a renaming
| symbol when the index is an IN parameter or when it is a name
| defined in an outer scope.
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.
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.
Consider the following code:
type Table is array (Character) of Natural;
My_Table : Table := (others => 4874);
Printing this table in gdb leads to:
(gdb) p my_table
$1 = ('["00"]' => 4874 <repeats 256 times>)
In this case, the index of the first element in this array is also
the first element of the index type (character type). Similar to what
we do we enumeration types, we do not need to print the index of the
first element when printing the array.
This patch fixes this issue and changes the output as follow:
(gdb) p my_table
$1 = (4874 <repeats 256 times>)
gdb/ChangeLog:
* ada-valprint.c (print_optional_low_bound): Handle
character-indexed array printing like boolean-indexed array
printing.
gdb/testuite/ChangeLog:
* testsuite/gdb.ada/array_char_idx/pck.ads (Table): New type.
(My_Table): New global variable.
* testsuite/gdb.ada/array_char_idx.exp: Add test.
Tested on x86_64-linux.
Now that the GDB 8.1 branch has been created, we can
bump the version number.
gdb/ChangeLog:
GDB 8.1 branch created (5219ac6237):
* version.in: Bump version to 8.1.50.DATE-git.
gas/
* testsuite/gas/riscv/priv-reg.s: Add missing stval and mtval.
* testsuite/gas/riscv/priv-reg.d: Likewise.
include/
* opcode/riscv-opc.h (CSR_SBADADDR): Rename to CSR_STVAL. Rename
DECLARE_CSR entry. Add alias to map sbadaddr to CSR_STVAL.
(CSR_MBADADDR): Rename to CSR_MTVAL. Rename DECLARE_CSR entry.
Add alias to map mbadaddr to CSR_MTVAL.
This commit adds a new testcase testing the "check-psymtabs" and
"check-symtabs" maintenance commands.
The "maintenance check-psymtabs" commands is currently known to
produce some errors. While the situation was admetedly made worse
by the following patch...
commit b5ec771e60
Date: Wed Nov 8 14:22:32 2017 +0000
Subject: Introduce lookup_name_info and generalize Ada's FULL/WILD name matching
... hence the reference to PR gdb/22670, the command was already
spotting one inconsistency prior to it:
(gdb) maintenance check-psymtabs
Global symbol `interfaces__cS' only found in /[...]/b~var_arr_typedef.adb psymtab
For now, the "check-psymtab" test is KFAIL-ed.
gdb/testsuite/ChangeLog:
PR gdb/22670
* gdb.ada/maint_with_ada: New testcase.
Tested on x86_64-linux.
This patch adds a new testcase to demonstrate a regression introduced by:
commit b5ec771e60
Date: Wed Nov 8 14:22:32 2017 +0000
Subject: Introduce lookup_name_info and generalize Ada's FULL/WILD name matching
The purpose of the testcase is to verify that a user can insert
a breakpoint on a C function while debugging Ada, even if the name
of the function includes uppercase letters, requiring us to use
Ada's "<...>" notation to tell the GDB that the symbol name should
be looked up verbatim.
As of the commit above, GDB is no longer finding the function:
(gdb) break <MixedCaseFunc>
Function "<MixedCaseFunc>" not defined.
Make breakpoint pending on future shared library load? (y or [n])
Before the patch, the breakpoint was inserted without problem.
gdb/testsuite/ChangeLog:
PR gdb/22670
* gdb.ada/bp_c_mixed_case: New testcase.
Tested on x86_64-linux; generates a KPASS before the regression
was introduced, and now generates a KFAIL.
This patch adds a new test to demonstrate a regression introduced by:
commit b5ec771e60
Date: Wed Nov 8 14:22:32 2017 +0000
Subject: Introduce lookup_name_info and generalize Ada's FULL/WILD name matching
The original purpose of the new test is to exercise the "complete"
command with an expression for which a large number of matches are
returned and to verify that each match returned is a plausible match.
In this particular case, the commit above causes GDB to generate
additional matches which should in fact not appear in the list
(internally generated symbols, or symbols that should be enclosed
between "<...>"). These extraneous entries are easy to spot, because
they have uppercase characters, such as:
break ada__stringsS
break ada__strings__R11s
[etc]
For now, the new test is KFAIL'ed, to avoid generating a new FAIL
while we work on fixing that regression.
gdb/testsuite/ChangeLog:
PR gdb/22670
* gdb.ada/complete.exp: Add "complete break ada" test.
Tested on x86_64-linux with GDB built before and after the patch
that caused the regression (b5ec771e60).
The test passes before the regression, and generates a KFAIL after.
This patch adds a new testcase to demonstrate a regression introduced by:
commit b5ec771e60
Date: Wed Nov 8 14:22:32 2017 +0000
Subject: Introduce lookup_name_info and generalize Ada's FULL/WILD name matching
The purpose of the testcase is to verify that a user can use any
casing for an Ada symbol name passed to the "info address" command.
After the patch above was applied, GDB was no longer able to find
the symbol:
(gdb) info address My_Table
No symbol "My_Table" in current context.
gdb/testsuite/ChangeLog:
PR gdb/22670
* gdb.ada/info_addr_mixed_case: New testcase.
Tested on x86_64-linux, both before and after the patch.
I am checking in the attached patch which updates the binutils
support for version 3 binary annotation notes. (Version 3 adds
an end address to the ranges covered by the notes, so that it
is possible to detect gaps in the coverage).
This patch also stops the note merging feature of objcopy from
executing if the notes have relocations against them. This makes the
code simpler, and prevents the problems with architectures which have
unusual relocation management issues.
* objcopy.c (objcopy_internal_note): New structure.
(gap_exists): New function.
(is_open_note): New function.
(is_func_note): New function.
(is_64bit): New function.
(merge_gnu_build_notes): Handle v3 notes. Do not merge
if there are relocations against the notes.
* readelf.c (get_note_type): Use short names for build attribute
notes.
(print_symbol_for_build_attribute): Rename to
get_symbol_for_build_attribute. Returns the found symbol rather
than printing it.
(print_gnu_build_attribute_description): Maintain address ranges
for function notes as well as global notes. Handle v3 notes.
(print_gnu_build_attribute_name): Use more space for printing the
name in wide mode.
* testsuite/binutils-all/note-2-32.s: Use .dc.l instead of .word.
Eliminate symbol references in order to remove the need for
relocations.
* testsuite/binutils-all/note-2-64.s: Likewise.
* testsuite/binutils-all/note-3-32.s: Add a size to the note_1
symbol.
* testsuite/binutils-all/note-3-64.s: Likewise.
* testsuite/binutils-all/mips/mips-note-2r-n32.d: Update expected
output.
* testsuite/binutils-all/mips/mips-note-2r-n64.d: Likewise.
* testsuite/binutils-all/mips/mips-note-2r.d: Likewise.
* testsuite/binutils-all/note-2-32.d: Likewise.
* testsuite/binutils-all/note-2-64.d: Likewise.
* testsuite/binutils-all/note-3-32.d: Likewise.
* testsuite/binutils-all/note-3-64.d: Likewise.
* testsuite/binutils-all/note-4-64.s: New test. Checks v3 notes.
* testsuite/binutils-all/note-4-32.s: New test.
* testsuite/binutils-all/note-4-64.d: New test result file.
* testsuite/binutils-all/note-4-32.d: New test result file.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
My patch
dwarf2read: Silence -Wenum-compare-switch warning
132448f835
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.
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.
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".
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.
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.
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.
These two enumerators are unused, remove them.
gdb/ChangeLog:
* target.h (enum target_object) <TARGET_OBJECT_HPUX_UREGS,
TARGET_OBJECT_HPUX_SOLIB_GOT>: Remove.