Commit Graph

103551 Commits

Author SHA1 Message Date
GDB Administrator
b5978f7dee Automatic date update in version.in 2020-12-25 00:00:22 +00:00
GDB Administrator
065440a290 Automatic date update in version.in 2020-12-24 00:00:31 +00:00
GDB Administrator
cdb04c69ef Automatic date update in version.in 2020-12-23 00:00:23 +00:00
GDB Administrator
4c5df995cb Automatic date update in version.in 2020-12-22 00:00:31 +00:00
GDB Administrator
af40c13550 Automatic date update in version.in 2020-12-21 00:00:17 +00:00
GDB Administrator
bb94a43eac Automatic date update in version.in 2020-12-20 00:00:18 +00:00
GDB Administrator
3639436bef Automatic date update in version.in 2020-12-19 00:00:17 +00:00
GDB Administrator
ab91f7fe0f Automatic date update in version.in 2020-12-18 00:00:30 +00:00
GDB Administrator
081a480696 Automatic date update in version.in 2020-12-17 00:00:33 +00:00
GDB Administrator
20c256c726 Automatic date update in version.in 2020-12-16 00:00:30 +00:00
GDB Administrator
8b0dcfd47c Automatic date update in version.in 2020-12-15 00:00:33 +00:00
GDB Administrator
a05b378489 Automatic date update in version.in 2020-12-14 00:00:28 +00:00
GDB Administrator
125aa25b17 Automatic date update in version.in 2020-12-13 00:00:30 +00:00
GDB Administrator
8030c16ad5 Automatic date update in version.in 2020-12-12 00:00:32 +00:00
GDB Administrator
1757dad1a5 Automatic date update in version.in 2020-12-11 00:00:36 +00:00
GDB Administrator
be4fd5ee3e Automatic date update in version.in 2020-12-10 00:00:35 +00:00
Simon Marchi
969da52cb0 gdb: address review comments of previous series
I forgot to include fixes for review comments I got before pushing the
previous commits (or I pushed the wrong commits).  This one fixes it.

 - Return {} instead of false in get_discrete_low_bound and
   get_discrete_high_bound.
 - Compute high bound after confirming low bound is valid in
   get_discrete_bounds.

gdb/ChangeLog:

	* gdbtypes.c (get_discrete_low_bound, get_discrete_high_bound):
	Return {} instead of false.
	(get_discrete_bounds): Compute high bound only if low bound is
	valid.

Change-Id: I5f9a66b3672adfac9441068c899ab113ab2c331a
2020-12-09 15:36:28 -05:00
Simon Marchi
138084b248 gdb: fix value_subscript when array upper bound is not known
Since commit 7c6f271296 ("gdb: make get_discrete_bounds check for
non-constant range bounds"), subscripting  flexible array member fails:

    struct no_size
    {
      int n;
      int items[];
    };

    (gdb) p *ns
    $1 = {n = 3, items = 0x5555555592a4}
    (gdb) p ns->items[0]
    Cannot access memory at address 0xfffe555b733a0164
    (gdb) p *((int *) 0x5555555592a4)
    $2 = 101  <--- we would expect that
    (gdb) p &ns->items[0]
    $3 = (int *) 0xfffe5559ee829a24  <--- wrong address

Since the flexible array member (items) has an unspecified size, the array type
created for it in the DWARF doesn't have dimensions (this is with gcc 9.3.0,
Ubuntu 20.04):

    0x000000a4:   DW_TAG_array_type
                    DW_AT_type [DW_FORM_ref4]       (0x00000038 "int")
                    DW_AT_sibling [DW_FORM_ref4]    (0x000000b3)

    0x000000ad:     DW_TAG_subrange_type
                      DW_AT_type [DW_FORM_ref4]     (0x00000031 "long unsigned int")

This causes GDB to create a range type (TYPE_CODE_RANGE) with a defined
constant low bound (dynamic_prop with kind PROP_CONST) and an undefined
high bound (dynamic_prop with kind PROP_UNDEFINED).

value_subscript gets both bounds of that range using
get_discrete_bounds.  Before commit 7c6f271296, get_discrete_bounds
didn't check the kind of the dynamic_props and would just blindly read
them as if they were PROP_CONST.  It would return 0 for the high bound,
because we zero-initialize the range_bounds structure.  And it didn't
really matter in this case, because the returned high bound wasn't used
in the end.

Commit 7c6f271296 changed get_discrete_bounds to return a failure if
either the low or high bound is not a constant, to make sure we don't
read a dynamic prop that isn't a PROP_CONST as a PROP_CONST.  This
change made get_discrete_bounds start to return a failure for that
range, and as a result would not set *lowp and *highp.  And since
value_subscript doesn't check get_discrete_bounds' return value, it just
carries on an uses an uninitialized value for the low bound.  If
value_subscript did check the return value of get_discrete_bounds, we
would get an error message instead of a bogus value.  But it would still
be a bug, as we wouldn't be able to print the flexible array member's
elements.

Looking at value_subscript, we see that the low bound is always needed,
but the high bound is only needed if !c_style.  So, change
value_subscript to use get_discrete_low_bound and
get_discrete_high_bound separately.  This fixes the case described
above, where the low bound is known but the high bound isn't (and is not
needed).  This restores the original behavior without accessing a
dynamic_prop in a wrong way.

A test is added.  In addition to the case described above, a case with
an array member of size 0 is added, which is a GNU C extension that
existed before flexible array members were introduced.  That case
currently fails when compiled with gcc <= 8.  gcc <= 8 produces DWARF
similar to the one shown above, while gcc 9 adds a DW_AT_count of 0 in
there, which makes the high bound known.  A case where an array member
of size 0 is the only member of the struct is also added, as that was
how PR 28675 was originally reported, and it's an interesting corner
case that I think could trigger other funny bugs.

Question about the implementation: in value_subscript, I made it such
that if the low or high bound is unknown, we fall back to zero.  That
effectively makes it the same as it was before 7c6f271296.  But should
we instead error() out?

gdb/ChangeLog:

	PR 26875, PR 26901
	* gdbtypes.c (get_discrete_low_bound): Make non-static.
	(get_discrete_high_bound): Make non-static.
	* gdbtypes.h (get_discrete_low_bound): New declaration.
	(get_discrete_high_bound): New declaration.
	* valarith.c (value_subscript): Only fetch high bound if
	necessary.

gdb/testsuite/ChangeLog:

	PR 26875, PR 26901
	* gdb.base/flexible-array-member.c: New test.
	* gdb.base/flexible-array-member.exp: New test.

Change-Id: I832056f80e6c56f621f398b4780d55a3a1e299d7
2020-12-09 15:35:18 -05:00
Simon Marchi
bd1768de21 gdb: split get_discrete_bounds in two
get_discrete_bounds is not flexible for ranges (TYPE_CODE_RANGE), in the
sense that it returns true (success) only if both bounds are present and
constant values.

This is a problem for code that only needs to know the low bound and
fails unnecessarily if the high bound is unknown.

Split the function in two, get_discrete_low_bound and
get_discrete_high_bound, that both return an optional.  Provide a new
implementation of get_discrete_bounds based on the two others, so the
callers don't have to be changed.

gdb/ChangeLog:

	* gdbtypes.c (get_discrete_bounds): Implement with
	get_discrete_low_bound and get_discrete_high_bound.
	(get_discrete_low_bound): New.
	(get_discrete_high_bound): New.

Change-Id: I986b5e9c0dd969800e3fb9546af9c827d52e80d0
2020-12-09 15:31:44 -05:00
Simon Marchi
f47d1c255d gdb: make get_discrete_bounds return bool
get_discrete_bounds currently has three possible return values (see its
current doc for details).  It appears that for all callers, it would be
sufficient to have a boolean "worked" / "didn't work" return value.

Change the return type of get_discrete_bounds to bool and adjust all
callers.  Doing so simplifies the following patch.

gdb/ChangeLog:

	* gdbtypes.h (get_discrete_bounds): Return bool, adjust all
	callers.
	* gdbtypes.c (get_discrete_bounds): Return bool.

Change-Id: Ie51feee23c75f0cd7939742604282d745db59172
2020-12-09 15:23:56 -05:00
Simon Marchi
f5fca0ec15 gdb: make discrete_position return optional
Instead of returning a boolean status and returning the value through a
pointer, return an optional that does both jobs.  This helps in the
following patches, and I think it is an improvement in general.

gdb/ChangeLog:

	* ada-lang.c (ada_value_slice_from_ptr): Adjust.
	(ada_value_slice): Adjust.
	(pos_atr): Adjust.
	* gdbtypes.c (get_discrete_bounds): Adjust.
	(discrete_position): Return optional.
	* gdbtypes.h (discrete_position): Return optional.

Change-Id: I758dbd8858b296ee472ed39ec35db1dbd624a5ae
2020-12-09 14:05:48 -05:00
GDB Administrator
8d55943698 Automatic date update in version.in 2020-12-09 00:00:44 +00:00
GDB Administrator
7205c99163 Automatic date update in version.in 2020-12-08 00:00:47 +00:00
GDB Administrator
eca082c05c Automatic date update in version.in 2020-12-07 00:00:34 +00:00
Giancarlo Frix
47c4623c75 s390: Fix BC instruction breakpoint handling
This fixes a long-lived bug in the s390 port.

When trying to step over a breakpoint set on a BC (branch on condition)
instruction with displaced stepping on IBM Z, gdb would incorrectly
adjust the pc regardless of whether or not the branch was taken. Since
the branch target is an absolute address, this would cause the inferior
to jump around wildly whenever the branch was taken, either crashing it
or causing it to behave unpredictably.

It turns out that the logic to handle BC instructions correctly was in
the code, but that the enum value representing its opcode has always
been incorrect.

This patch corrects the enum value to the actual opcode, fixing the
stepping problem. The enum value is also used in the prologue analysis
code, so this also fixes a minor bug where more of the prologue would
be read than was necessary.

gdb/ChangeLog:

        PR breakpoints/27009
        * s390-tdep.h (op_bc): Correct BC opcode value.
2020-12-06 14:30:53 +04:00
GDB Administrator
bc6989cbd3 Automatic date update in version.in 2020-12-06 00:00:39 +00:00
GDB Administrator
a4245c0961 Automatic date update in version.in 2020-12-05 00:00:28 +00:00
Shahab Vahedi
4cf1920e40 Update gdb/ChangeLog to reflect the PR for a bug fix
This is just an update in the gdb/ChangeLog to reflect a newly
created PR [27015] for a bugfix commit:

abaf3df9  arc: Write correct "eret" value during register collection
2020-12-04 16:28:37 +01:00
Shahab Vahedi
abaf3df98b arc: Write correct "eret" value during register collection
In collect_register() function of arc-linux-tdep.c, the "eret"
(exception return) register value was not being reported correctly.
This patch fixes that.

Background:
When asked for the "pc" value, we have to update the "eret" register
with GDB's STOP_PC.  The "eret" instructs the kernel code where to
jump back when an instruction has stopped due to a breakpoint.  This
is how collect_register() was doing so:

--------------8<--------------
  if (regnum == gdbarch_pc_regnum (gdbarch))
    regnum = ARC_ERET_REGNUM;
  regcache->raw_collect (regnum, buf + arc_linux_core_reg_offsets[regnum]);
-------------->8--------------

Root cause:
Although this is using the correct offset (ERET register's), it is also
changing the REGNUM itself.  Therefore, raw_collect (regnum, ...) is
not reading from "pc" anymore.

v2:
- Fix a copy/paste issue as rightfully addressed by Tom [1].

[1]
https://sourceware.org/pipermail/gdb-patches/2020-November/173208.html

gdb/ChangeLog:

	* arc-linux-tdep.c (collect_register): Populate "eret" by
	"pc" value from the regcache when asked for "pc" value.
2020-12-04 11:41:47 +01:00
GDB Administrator
774f775cad Automatic date update in version.in 2020-12-04 00:00:48 +00:00
GDB Administrator
a2e9100aa8 Automatic date update in version.in 2020-12-03 00:00:34 +00:00
GDB Administrator
866f1b1c9a Automatic date update in version.in 2020-12-02 00:00:42 +00:00
GDB Administrator
2ff9a46fd6 Automatic date update in version.in 2020-12-01 00:00:48 +00:00
GDB Administrator
1429d8beb4 Automatic date update in version.in 2020-11-30 00:00:40 +00:00
Hannes Domani
815c8f80e2 Fix Value.format_string docu for static members argument
The argument is called static_members, not static_fields.

gdb/doc/ChangeLog:

2020-11-29  Hannes Domani  <ssbssa@yahoo.de>

	PR python/26974
	* python.texi: Fix docu for static members argument.
2020-11-29 19:11:38 +01:00
Hannes Domani
b03dac541f Don't delete the locator win info
The locator win info is special because it is static, all the others are
created dynamically.

gdb/ChangeLog:

2020-11-29  Hannes Domani  <ssbssa@yahoo.de>

	PR tui/26973
	* tui/tui-layout.c (tui_apply_current_layout): Don't delete the
	static locator win info.
2020-11-29 18:53:52 +01:00
GDB Administrator
f2fb5e6f21 Automatic date update in version.in 2020-11-29 00:00:41 +00:00
GDB Administrator
9ca51a9034 Automatic date update in version.in 2020-11-28 00:00:45 +00:00
GDB Administrator
8dad16200e Automatic date update in version.in 2020-11-27 00:00:55 +00:00
GDB Administrator
2d409e3adc Automatic date update in version.in 2020-11-26 00:00:47 +00:00
GDB Administrator
fe3088f6ef Automatic date update in version.in 2020-11-25 00:00:35 +00:00
GDB Administrator
12f93c92d0 Automatic date update in version.in 2020-11-24 00:00:47 +00:00
GDB Administrator
08d79fde1a Automatic date update in version.in 2020-11-23 00:00:32 +00:00
GDB Administrator
6427533f8f Automatic date update in version.in 2020-11-22 00:00:35 +00:00
GDB Administrator
a7ca0db2a9 Automatic date update in version.in 2020-11-21 00:00:39 +00:00
GDB Administrator
68f7ee1f46 Automatic date update in version.in 2020-11-20 00:00:37 +00:00
GDB Administrator
77477f6d04 Automatic date update in version.in 2020-11-19 00:00:33 +00:00
GDB Administrator
a90a7eb266 Automatic date update in version.in 2020-11-18 00:00:36 +00:00
GDB Administrator
45c0714276 Automatic date update in version.in 2020-11-17 00:00:36 +00:00
GDB Administrator
c7409b74dd Automatic date update in version.in 2020-11-16 00:00:35 +00:00