Compare commits

...

162 Commits

Author SHA1 Message Date
Joel Brobecker
23c84db5b3 Set GDB version number to 15.2.
This commit changes gdb/version.in to 15.2.
2024-09-29 10:04:37 +02:00
GDB Administrator
0252f80e2d Automatic date update in version.in 2024-09-29 00:00:23 +00:00
GDB Administrator
5d9b7e7274 Automatic date update in version.in 2024-09-28 00:00:47 +00:00
GDB Administrator
5fc6163431 Automatic date update in version.in 2024-09-27 00:00:24 +00:00
GDB Administrator
c9013a8511 Automatic date update in version.in 2024-09-26 00:00:48 +00:00
Tom de Vries
4ff12ed8a6 [gdb/python] Make sure python sys.exit makes gdb exit
With gdb 15.1, python sys.exit no longer makes gdb exit:
...
$ gdb -q -batch -ex "python sys.exit(2)" -ex "print 123"; echo $?
Python Exception <class 'SystemExit'>: 2
Error occurred in Python: 2
$1 = 123
0
...

This is a change in behaviour since commit a207f6b3a3 ("Rewrite "python"
command exception handling"), first available in gdb 15.1.

This patch reverts to the old behaviour by handling PyExc_SystemExit in
gdbpy_handle_exception, such what we have instead:
...
$ gdb -q -batch -ex "python sys.exit(2)" -ex "print 123"; echo $?
2
...

Tested on x86_64-linux, with python 3.6 and 3.13.

Tested-By: Guinevere Larsen <blarsen@redhat.com>
Approved-By: Tom Tromey <tom@tromey.com>

PR python/31946
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31946
2024-09-26 00:36:21 +02:00
GDB Administrator
37cba8b06c Automatic date update in version.in 2024-09-25 00:00:29 +00:00
GDB Administrator
f4887f348a Automatic date update in version.in 2024-09-24 00:00:50 +00:00
GDB Administrator
6869c5ee9e Automatic date update in version.in 2024-09-23 00:00:43 +00:00
GDB Administrator
0f40ae10c7 Automatic date update in version.in 2024-09-22 00:00:24 +00:00
GDB Administrator
7898a62f32 Automatic date update in version.in 2024-09-21 00:00:39 +00:00
GDB Administrator
ba51e24c34 Automatic date update in version.in 2024-09-20 00:00:33 +00:00
GDB Administrator
62eb742c4f Automatic date update in version.in 2024-09-19 00:00:59 +00:00
GDB Administrator
ff6e00ab63 Automatic date update in version.in 2024-09-18 00:01:28 +00:00
GDB Administrator
8aecb61b34 Automatic date update in version.in 2024-09-17 00:00:55 +00:00
GDB Administrator
eb95d7939d Automatic date update in version.in 2024-09-16 00:00:28 +00:00
Tom de Vries
21528df40e [gdb/symtab] Revert "Change handling of DW_TAG_enumeration_type in DWARF scanner"
After adding dwarf assembly to test-case gdb.dwarf2/enum-type.exp that adds
this debug info:
...
 <1><11f>: Abbrev Number: 3 (DW_TAG_enumeration_type)
    <120>   DW_AT_specification: <0x130>
 <2><124>: Abbrev Number: 4 (DW_TAG_enumerator)
    <125>   DW_AT_name        : val1
    <12a>   DW_AT_const_value : 1
 <2><12b>: Abbrev Number: 0
 <1><12c>: Abbrev Number: 5 (DW_TAG_namespace)
    <12d>   DW_AT_name        : ns
 <2><130>: Abbrev Number: 6 (DW_TAG_enumeration_type)
    <131>   DW_AT_name        : e
    <133>   DW_AT_type        : <0x118>
    <137>   DW_AT_declaration : 1
...
I run into an assertion failure:
...
(gdb) file enum-type^M
Reading symbols from enum-type...^M
cooked-index.h:214: internal-error: get_parent: \
  Assertion `(flags & IS_PARENT_DEFERRED) == 0' failed.^M
...

This was reported in PR32160 comment 1.

This is a regression since commit 4e417d7bb1 ("Change handling of
DW_TAG_enumeration_type in DWARF scanner").

Fix this by reverting the commit.

[ Also drop the kfails for PR31900 and PR32158, which are regressions by that
same commit. ]

That allows us to look at the output of "maint print objfiles", and for val1
we get an entry without parent:
...
    [27] ((cooked_index_entry *) 0x7fbbb4002ef0)
    name:       val1
    canonical:  val1
    qualified:  val1
    DWARF tag:  DW_TAG_enumerator
    flags:      0x0 []
    DIE offset: 0x124
    parent:     ((cooked_index_entry *) 0)
...
which is incorrect, as noted in that same comment, but an improvement over the
assertion failure, and I don't think that ever worked.  This is to be
addressed in a follow-up patch.

Reverting the commit begs the question: what was it trying to fix in the first
place, and do we need a different fix?  I've investigated this and filed
PR32160 to track this.

My guess is that the commit was based on a misunderstand of what we track
in cooked_indexer::m_die_range_map.

Each DIE has two types of parent DIEs:
- a DIE that is the parent as indicated by the tree structure in which DIEs
  occur, and
- a DIE that represent the parent scope.

In most cases, these two are the same, but some times they're not.

The debug info above demonstrates such a case.  The DIE at 0x11f:
- has a tree-parent: the DIE representing the CU, and
- has a scope-parent: DIE 0x12c representing namespace ns.

In cooked_indexer::m_die_range_map, we track scope-parents, and the commit
tried to add a tree-parent instead.

So, I don't think we need a different fix, and propose we backport the reversal
for gdb 15.2.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31900
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32158
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32160
(cherry picked from commit a2860473ef)
2024-09-15 15:30:53 +02:00
Tom de Vries
9ca807bc5f [gdb/testsuite] Add regression test for PR32158
Consider test-case:
...
namespace ns {
  enum class ec {
    val2 = 2
  };
}

int main () {
  return (int)ns::ec::val2;
}
...
compiled with debug info:
...
$ g++ test.c -g
...

When looking at the cooked index entry for val2 using "maint print objfiles",
we get:
...
    [7] ((cooked_index_entry *) 0x7f8ecc002ef0)
    name:       val2
    canonical:  val2
    qualified:  ns::val2
    DWARF tag:  DW_TAG_enumerator
    flags:      0x0 []
    DIE offset: 0xe9
    parent:     ((cooked_index_entry *) 0x7f8ecc002e90) [ns]
...
which is wrong, there is no source level entity ns::val2.

This is PR symtab/32158.

This is a regression since commit 4e417d7bb1 ("Change handling of
DW_TAG_enumeration_type in DWARF scanner").

Reverting the commit on current trunk fixes the problem, and gets us instead:
...
    [7] ((cooked_index_entry *) 0x7fba70002ef0)
    name:       val2
    canonical:  val2
    qualified:  ns::ec::val2
    DWARF tag:  DW_TAG_enumerator
    flags:      0x0 []
    DIE offset: 0xe9
    parent:     ((cooked_index_entry *) 0x7fba70002ec0) [ec]
...

Add a regression test for this PR in test-case gdb.dwarf2/enum-type-c++.exp.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32158
(cherry picked from commit 93a20d956e)
2024-09-15 15:30:53 +02:00
Tom de Vries
cac6b1f3b0 [gdb/testsuite] Add gdb.dwarf2/enum-type-c++.exp, regression test for PR31900.
Consider the following test-case:
...
$ cat a.h
namespace ns {

class A {
public:
  enum {
    val1 = 1
  };
};

}
$ cat main.c

ns::A a;

int
main (void)
{
  return 0;
}
$ cat val1.c

int u1 = ns::A::val1;
...
compiled with debug info:
...
$ g++ main.c val1.c -g
...

When trying to print ns::A::val with current trunk and gdb 15.1 we get:
...
$ gdb -q -batch a.out -ex "print ns::A::val1"
There is no field named val1
...

This PR c++/31900.

With gdb 14.2 we get the expected:
...
$ gdb -q -batch a.out -ex "print ns::A::val1"
$1 = ns::A::val1
...

This is a regression since commit 4e417d7bb1 ("Change handling of
DW_TAG_enumeration_type in DWARF scanner").

Reverting the commit on current trunk fixes the problem.

So how does this problem happen?

First, let's consider the current trunk, with the commit reverted.

Gdb looks for the entry ns::A::val1, and find this entry:
...
    [29] ((cooked_index_entry *) 0x7f7830002ef0)
    name:       val1
    canonical:  val1
    qualified:  ns::A::val1
    DWARF tag:  DW_TAG_enumerator
    flags:      0x0 []
    DIE offset: 0x15a
    parent:     ((cooked_index_entry *) 0x7f7830002ec0) [A]
...
and expands the corresponding CU val1.c containing this debug info:
...
 <2><14a>: Abbrev Number: 3 (DW_TAG_class_type)
    <14b>   DW_AT_name        : A
    <14d>   DW_AT_byte_size   : 1
 <3><150>: Abbrev Number: 4 (DW_TAG_enumeration_type)
    <151>   DW_AT_encoding    : 7       (unsigned)
    <152>   DW_AT_byte_size   : 4
    <153>   DW_AT_type        : <0x163>
    <159>   DW_AT_accessibility: 1      (public)
 <4><15a>: Abbrev Number: 5 (DW_TAG_enumerator)
    <15b>   DW_AT_name        : val1
    <15f>   DW_AT_const_value : 1
 <4><160>: Abbrev Number: 0
 <3><161>: Abbrev Number: 0
 <2><162>: Abbrev Number: 0
...
after which it finds ns::A::val1 in the expanded symtabs.

Now let's consider the current trunk as is (so, with the commit present).

Gdb looks for the entry ns::A::val1, but doesn't find it because the val1
entry is missing its parent:
...
   [29] ((cooked_index_entry *) 0x7f5240002ef0)
    name:       val1
    canonical:  val1
    qualified:  val1
    DWARF tag:  DW_TAG_enumerator
    flags:      0x0 []
    DIE offset: 0x15a
    parent:     ((cooked_index_entry *) 0)
...

Then gdb looks for the entry ns::A, and finds this entry:
...
   [3] ((cooked_index_entry *) 0x7f5248002ec0)
    name:       A
    canonical:  A
    qualified:  ns::A
    DWARF tag:  DW_TAG_class_type
    flags:      0x0 []
    DIE offset: 0xdd
    parent:     ((cooked_index_entry *) 0x7f5248002e90) [ns]
...
which corresponds to this debug info, which doesn't contain val1
due to -fno-eliminate-unused-debug-types:
...
 <2><dd>: Abbrev Number: 3 (DW_TAG_class_type)
    <de>   DW_AT_name        : A
    <e0>   DW_AT_byte_size   : 1
 <2><e3>: Abbrev Number: 0
...

Gdb expands the corresponding CU main.c, after which it doesn't find
ns::A::val1 in the expanded symtabs.

The root cause of the problem is the missing parent on the val1
cooked_index_entry, but this only becomes user-visible through the
elaborate scenario above.

Add a test-case gdb.dwarf2/enum-type-c++.exp that contains a regression test
for this problem that doesn't rely on expansion state or
-feliminate-unused-debug-types, but simply tests for the root cause by
grepping for ns::A::val1 in the output of "maint print objfile".

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31900
(cherry picked from commit 2693187cc5)
2024-09-15 15:30:53 +02:00
GDB Administrator
b99d8c2e96 Automatic date update in version.in 2024-09-15 00:00:41 +00:00
GDB Administrator
838176b1d7 Automatic date update in version.in 2024-09-14 00:00:19 +00:00
GDB Administrator
2b19251be8 Automatic date update in version.in 2024-09-13 00:00:56 +00:00
GDB Administrator
f86feb2a7f Automatic date update in version.in 2024-09-12 00:00:37 +00:00
GDB Administrator
fa08fd1d77 Automatic date update in version.in 2024-09-11 00:00:37 +00:00
GDB Administrator
9ade3065a1 Automatic date update in version.in 2024-09-10 00:00:39 +00:00
GDB Administrator
846d33f338 Automatic date update in version.in 2024-09-09 00:00:26 +00:00
H.J. Lu
68163a5c4f gdb-15-branch: Clear the X86_XSTATE_MPX bit in XCRO for x32
commit 868883583e
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Sat Mar 23 16:17:36 2024 +0000

    gdb/arch: assert that X86_XSTATE_MPX is not set for x32

added

  if (xcr0 & X86_XSTATE_MPX)
    {
      /* MPX is not available on x32.  */
      gdb_assert (!is_x32);
      regnum = create_feature_i386_64bit_mpx (tdesc.get (), regnum);
    }

But x32 is a software convention.  There is no x32 mode in hardware and
CPU always returns the 64-bit mode XCR0 value for x32 processes.  This
regression was fixed on master branch by

commit bf616be991 (HEAD)
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Thu Jan 25 14:25:57 2024 +0000

    gdb/gdbserver: share some code relating to target description creation

which used the gdbserver code to clear the X86_XSTATE_MPX bit in XCR0 for
x32.  Fix this regression on gdb-15-branch by clearing the X86_XSTATE_MPX
bit in XCR0 for x32 in gdb.

	PR gdb/32143
	* x86-linux-nat.c (x86_linux_nat_target::read_description): Clear
	the X86_XSTATE_MPX bit in XCR0 for x32.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-09-08 16:03:09 -07:00
GDB Administrator
897204a988 Automatic date update in version.in 2024-09-08 00:00:53 +00:00
GDB Administrator
c331455027 Automatic date update in version.in 2024-09-07 00:00:52 +00:00
GDB Administrator
fdcd19f594 Automatic date update in version.in 2024-09-06 00:00:32 +00:00
GDB Administrator
1f7b8cce76 Automatic date update in version.in 2024-09-05 00:00:46 +00:00
Dmitry Neverov
9542d1b3a0 Recognize -2 as a tombstone value in .debug_line
Commit a8caed5d7f handled the tombstone
value -1 used by lld (https://reviews.llvm.org/D81784).  The
referenced lld commit also uses the tombstone value -2 for
pre-DWARF-v5
(e618ccbf43).

If not handled, -2 breaks the pc step range calculation and triggers
the assertion:

  gdb/infrun.c:2794: internal-error: resume_1: Assertion
  `pc_in_thread_step_range (pc, tp)' failed.

This commit adds -2 tombstone value and handles it in the same way as -1.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31727
Cherry-picked from e814012b2b
Approved-By: Tom Tromey <tom@tromey.com>
2024-09-04 20:38:12 +02:00
GDB Administrator
4210743723 Automatic date update in version.in 2024-09-04 00:00:33 +00:00
GDB Administrator
2daf900f61 Automatic date update in version.in 2024-09-03 00:00:43 +00:00
GDB Administrator
f74feca10c Automatic date update in version.in 2024-09-02 00:00:37 +00:00
GDB Administrator
9c8ee57a0f Automatic date update in version.in 2024-09-01 00:00:32 +00:00
GDB Administrator
865b7d5d83 Automatic date update in version.in 2024-08-31 00:00:37 +00:00
GDB Administrator
3831f9d6f1 Automatic date update in version.in 2024-08-30 00:00:36 +00:00
GDB Administrator
5b1b2884ce Automatic date update in version.in 2024-08-29 00:00:37 +00:00
GDB Administrator
1210b9b0ed Automatic date update in version.in 2024-08-28 00:00:30 +00:00
GDB Administrator
05d5112c10 Automatic date update in version.in 2024-08-27 00:00:39 +00:00
GDB Administrator
f086ab70d5 Automatic date update in version.in 2024-08-26 00:00:39 +00:00
GDB Administrator
524b5ad7db Automatic date update in version.in 2024-08-25 00:00:22 +00:00
GDB Administrator
5a8e6d7e78 Automatic date update in version.in 2024-08-24 00:00:21 +00:00
GDB Administrator
867d8e09d7 Automatic date update in version.in 2024-08-23 00:00:48 +00:00
Tom de Vries
de553d417e [gdb] Handle ^C during disassembly
In PR gdb/32025, a fatal error was reported when sending a SIGINT to gdb while
disassembling.

I managed to reproduce this on aarch64-linux in a Leap 15.5 container using
this trigger patch:
...
 gdb_disassembler_memory_reader::dis_asm_read_memory
   (bfd_vma memaddr, gdb_byte *myaddr, unsigned int len,
    struct disassemble_info *info) noexcept
 {
+  set_quit_flag ();
   return target_read_code (memaddr, myaddr, len);
 }
...
and a simple gdb command line calling the disassemble command:
...
$ gdb -q -batch a.out -ex "disassemble main"
...

The following scenario leads to the fatal error:
- the disassemble command is executed,
- set_quit_flag is called in
  gdb_disassembler_memory_reader::dis_asm_read_memory, pretending that a
  user pressed ^C,
- target_read_code calls QUIT, which throws a
  gdb_exception_quit,
- the exception propagation mechanism reaches c code in libopcodes and a fatal
  error triggers because the c code is not compiled with -fexception.

Fix this by:
- wrapping the body of gdb_disassembler_memory_reader::dis_asm_read_memory in
  catch_exceptions (which consequently needs moving to a header file), and
- reraising the caught exception in default_print_insn using QUIT.

Tested on aarch64-linux.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32025
(cherry picked from commit c45c3b4162)
2024-08-22 11:43:32 +02:00
GDB Administrator
731a801b1e Automatic date update in version.in 2024-08-22 00:01:41 +00:00
GDB Administrator
2c9e05f3a6 Automatic date update in version.in 2024-08-21 00:01:36 +00:00
GDB Administrator
fa0424d0e3 Automatic date update in version.in 2024-08-20 00:00:42 +00:00
GDB Administrator
67196cabf5 Automatic date update in version.in 2024-08-19 00:00:55 +00:00
GDB Administrator
98032324bc Automatic date update in version.in 2024-08-18 00:00:33 +00:00
GDB Administrator
3aa3fd0c2e Automatic date update in version.in 2024-08-17 00:01:47 +00:00
GDB Administrator
771c98e80e Automatic date update in version.in 2024-08-16 00:00:30 +00:00
GDB Administrator
f171f7e8df Automatic date update in version.in 2024-08-15 00:01:44 +00:00
GDB Administrator
2ed13e3b58 Automatic date update in version.in 2024-08-14 00:01:01 +00:00
GDB Administrator
9e58138c75 Automatic date update in version.in 2024-08-13 00:01:12 +00:00
GDB Administrator
7b14ea4637 Automatic date update in version.in 2024-08-12 00:01:21 +00:00
GDB Administrator
a0ac39eba6 Automatic date update in version.in 2024-08-11 00:01:26 +00:00
GDB Administrator
056d54b711 Automatic date update in version.in 2024-08-10 00:01:22 +00:00
GDB Administrator
7aa46e36e1 Automatic date update in version.in 2024-08-09 00:01:32 +00:00
GDB Administrator
07f7e1c042 Automatic date update in version.in 2024-08-08 00:01:34 +00:00
Hannes Domani
b822630603 Mark unavailable bytes of limited-length arrays when allocating contents
Using 'output' to print arrays larger than max-value-size, with only
repeating elements, can cause gdb to crash:
```
$ cat a.c:
char a[1000000];

int main()
{
  return a[0];
}
$ gdb -q a
(gdb) print a
$1 = {0 '\000' <repeats 65536 times>, <unavailable> <repeats 934464 times>}
(gdb) output a

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
```

Using 'print' works, because value::record_latest sets the unavailable
bytes of the value when it's added to the value history.
But 'outout' doesn't do that, so the printing tries to access more bytes
than are available.

The original problem in PR32015 was about using 'print' of a dynamic
array in a D program.
Here the crash happens because for 'print' the value was a struct with
length/ptr fields, which is converted in d-valprint.c into an array.
So value::record_latest didn't have a chance to mark the unavailable
bytes in this case.

To make sure the unavailable bytes always match the contents, this fixes
it by marking the unavailable bytes immediately after the contents are
allocated.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32015
Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
(cherry picked from commit 8fdd2b2bcd)
2024-08-07 15:05:06 +02:00
GDB Administrator
f3fed29a2c Automatic date update in version.in 2024-08-07 00:00:40 +00:00
GDB Administrator
74b18e3538 Automatic date update in version.in 2024-08-06 00:00:57 +00:00
GDB Administrator
7ae383fd7a Automatic date update in version.in 2024-08-05 00:01:04 +00:00
GDB Administrator
a443ee2422 Automatic date update in version.in 2024-08-04 00:01:12 +00:00
GDB Administrator
1260e51a7f Automatic date update in version.in 2024-08-03 00:00:40 +00:00
GDB Administrator
87984f7698 Automatic date update in version.in 2024-08-02 00:00:52 +00:00
GDB Administrator
23b8eaaff0 Automatic date update in version.in 2024-08-01 00:01:15 +00:00
GDB Administrator
416907555e Automatic date update in version.in 2024-07-31 00:00:52 +00:00
GDB Administrator
a363b89f09 Automatic date update in version.in 2024-07-30 00:01:13 +00:00
GDB Administrator
0770a377d1 Automatic date update in version.in 2024-07-29 00:00:37 +00:00
GDB Administrator
afc5aff69f Automatic date update in version.in 2024-07-28 00:01:23 +00:00
GDB Administrator
dc36238f1d Automatic date update in version.in 2024-07-27 00:01:25 +00:00
GDB Administrator
79cc1a2d92 Automatic date update in version.in 2024-07-26 00:00:59 +00:00
GDB Administrator
278329cf8f Automatic date update in version.in 2024-07-25 00:00:57 +00:00
GDB Administrator
46042a600e Automatic date update in version.in 2024-07-24 00:01:12 +00:00
Simon Marchi
760242224f gdb/solib-frv: move lm_info object to solib
I noticed that the lm_info_frv objects created in frv_current_sos are
never moved to the solib object.  This bug was introduced in 8971d2788e
("gdb: link so_list using intrusive_list"), which mistakenly removed the
line

    sop->lm_info = std::move (li);

... probably due so a bad merge conflict resolution.

Re-add this line.

If merged in master, I would cherry-pick this to gdb-15-branch.

Change-Id: I609a1a5ad39e93f70a95ea5ebe3f8ff4ab6a8db2
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32005
Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-07-23 10:34:47 -04:00
GDB Administrator
ef812cfbf2 Automatic date update in version.in 2024-07-23 00:00:44 +00:00
GDB Administrator
42fcd11a89 Automatic date update in version.in 2024-07-22 00:00:27 +00:00
GDB Administrator
bb49d104a5 Automatic date update in version.in 2024-07-21 00:01:09 +00:00
GDB Administrator
7ff33e182c Automatic date update in version.in 2024-07-20 00:00:36 +00:00
GDB Administrator
2d25abcf7d Automatic date update in version.in 2024-07-19 00:00:33 +00:00
GDB Administrator
ef1b80e913 Automatic date update in version.in 2024-07-18 00:00:35 +00:00
GDB Administrator
e9d2651cb2 Automatic date update in version.in 2024-07-17 00:00:34 +00:00
GDB Administrator
de136936c7 Automatic date update in version.in 2024-07-16 00:00:43 +00:00
Hannes Domani
e7c91a1ff9 Fix loading a saved recording
Currently you get this assertion failure if you try to execute the
inferior after loading a saved recording, when no recording was done
earlier in the same gdb session:
```
$ gdb -q c -ex "record restore test.rec"
Reading symbols from c...
[New LWP 26428]
Core was generated by `/tmp/c'.
Restored records from core file /tmp/test.rec.
(gdb) c
Continuing.
../../gdb/inferior.c:293: internal-error: inferior* find_inferior_pid(process_stratum_target*, int): Assertion `pid != 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
```

The change in step-precsave.exp triggers this bug, since now the
recording is loaded in a new gdb session, where
record_full_resume_ptid was never set.

The fix is to simply set record_full_resume_ptid when resuming a loaded
recording.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31971
Approved-By: Guinevere Larsen <blarsen@redhat.com>
2024-07-15 18:24:57 +02:00
GDB Administrator
4a8ff36655 Automatic date update in version.in 2024-07-15 00:00:21 +00:00
GDB Administrator
b178b3d8d0 Automatic date update in version.in 2024-07-14 00:00:43 +00:00
GDB Administrator
ea91792f47 Automatic date update in version.in 2024-07-13 00:00:24 +00:00
GDB Administrator
76604451b4 Automatic date update in version.in 2024-07-12 00:00:43 +00:00
GDB Administrator
8d3ad0528d Automatic date update in version.in 2024-07-11 00:00:30 +00:00
GDB Administrator
2b04f85455 Automatic date update in version.in 2024-07-10 00:01:18 +00:00
GDB Administrator
60c75436e4 Automatic date update in version.in 2024-07-09 00:00:35 +00:00
GDB Administrator
e885320150 Automatic date update in version.in 2024-07-08 00:00:25 +00:00
Joel Brobecker
f6535ad6bf Bump GDB's version number to 15.1.90.DATE-git.
This commit changes gdb/version.in to 15.1.90.DATE-git.

This commit also makes the following changes in gdb/testsuite:

	* gdb.base/default.exp: Change $_gdb_minor to 2.
2024-07-07 09:49:14 -07:00
Joel Brobecker
7b20890ad6 Set GDB version number to 15.1.
This commit changes gdb/version.in to 15.1.
2024-07-07 09:31:12 -07:00
GDB Administrator
35ad5708a7 Automatic date update in version.in 2024-07-07 00:00:22 +00:00
GDB Administrator
ef5930bd0f Automatic date update in version.in 2024-07-06 00:00:34 +00:00
Hannes Domani
f7e429d581 Fix cast types for opencl
The bitshift tests for opencl have these failures:

print /x (signed char) 0x0f << 8
No type named signed char.
(gdb) FAIL: gdb.base/bitshift.exp: lang=opencl: 8-bit, promoted: print /x (signed char) 0x0f << 8
print (signed char) 0x0f << 8
No type named signed char.
(gdb) FAIL: gdb.base/bitshift.exp: lang=opencl: 8-bit, promoted: print (signed char) 0x0f << 8

Apparently opencl doesn't have the 'signed' modifier for types, only
the 'unsigned' modifier.
Even 'char' is guaranteed to be signed if no modifier is used, so
this changes the casts to match this logic.

Approved-By: Tom Tromey <tom@tromey.com>
2024-07-05 21:43:08 +02:00
Hannes Domani
2de28d2f45 Fix 64-bit shifts where long only has 32-bit size
On systems where long has 32-bit size you get these failures:

print 1 << (unsigned long long) 0xffffffffffffffff
Cannot export value 18446744073709551615 as 32-bits unsigned integer (must be between 0 and 4294967295)
(gdb) FAIL: gdb.base/bitshift.exp: lang=c: max-uint64: print 1 << (unsigned long long) 0xffffffffffffffff
print 1 >> (unsigned long long) 0xffffffffffffffff
Cannot export value 18446744073709551615 as 32-bits unsigned integer (must be between 0 and 4294967295)
(gdb) FAIL: gdb.base/bitshift.exp: lang=c: max-uint64: print 1 >> (unsigned long long) 0xffffffffffffffff
print -1 << (unsigned long long) 0xffffffffffffffff
Cannot export value 18446744073709551615 as 32-bits unsigned integer (must be between 0 and 4294967295)
(gdb) FAIL: gdb.base/bitshift.exp: lang=c: max-uint64: print -1 << (unsigned long long) 0xffffffffffffffff
print -1 >> (unsigned long long) 0xffffffffffffffff
Cannot export value 18446744073709551615 as 32-bits unsigned integer (must be between 0 and 4294967295)
(gdb) FAIL: gdb.base/bitshift.exp: lang=c: max-uint64: print -1 >> (unsigned long long) 0xffffffffffffffff

Fixed by changing the number-of-bits variable to ULONGEST.

Approved-By: Tom Tromey <tom@tromey.com>
2024-07-05 21:43:03 +02:00
Hannes Domani
cec2e207d0 Fix too-large or negative right shift of negative numbers
As seen in these test failures:

print -1 >> -1
warning: right shift count is negative
$N = 0
(gdb) FAIL: gdb.base/bitshift.exp: lang=c: neg lhs/rhs: print -1 >> -1
print -4 >> -2
warning: right shift count is negative
$N = 0
(gdb) FAIL: gdb.base/bitshift.exp: lang=c: neg lhs/rhs: print -4 >> -2

Fixed by restoring the logic from before the switch to gmp.

Approved-By: Tom Tromey <tom@tromey.com>
2024-07-05 21:42:58 +02:00
Hannes Domani
edd3f7be25 Fix right shift of negative numbers
PR31590 shows that right shift of negative numbers doesn't work
correctly since GDB 14:

(gdb) p (-3) >> 1
$1 = -1

GDB 13 and earlier returned the correct value -2.
And there actually is one test that shows the failure:

print -1 >> 1
$84 = 0
(gdb) FAIL: gdb.base/bitshift.exp: lang=asm: rsh neg lhs: print -1 >> 1

The problem was introduced with the change to gmp functions in
commit 303a881f87.
It's wrong because gdb_mpz::operator>> uses mpz_tdif_q_2exp, which
always rounds toward zero, and the gmp docu says this:

For positive n both mpz_fdiv_q_2exp and mpz_tdiv_q_2exp are simple
bitwise right shifts.
For negative n, mpz_fdiv_q_2exp is effectively an arithmetic right shift
treating n as two's complement the same as the bitwise logical functions
do, whereas mpz_tdiv_q_2exp effectively treats n as sign and magnitude.

So this changes mpz_tdiv_q_2exp to mpz_fdiv_q_2exp, since it
does right shifts for both positive and negative numbers.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31590
Approved-By: Tom Tromey <tom@tromey.com>
2024-07-05 21:42:53 +02:00
Hannes Domani
041fb9da7d Restore bitshift.exp tests
Commit cdd4206647 unintentionally disabled all tests of bitshift.exp,
so it actually just does this:

Running /c/src/repos/binutils-gdb.git/gdb/testsuite/gdb.base/bitshift.exp ...
PASS: gdb.base/bitshift.exp: complete set language

		=== gdb Summary ===

 # of expected passes		1

It changed the 'continue' of unsupported languages to 'return', and
since ada is the first language and is unsupported, no tests were run.

This changes it back to 'continue', and the following patches fix
the regressions that were introduced since then unnoticed.

Approved-By: Tom Tromey <tom@tromey.com>
2024-07-05 21:42:49 +02:00
GDB Administrator
b1f7227b7e Automatic date update in version.in 2024-07-05 00:00:40 +00:00
GDB Administrator
0c7862ac50 Automatic date update in version.in 2024-07-04 00:01:05 +00:00
GDB Administrator
f6c0e1bad2 Automatic date update in version.in 2024-07-03 00:00:42 +00:00
GDB Administrator
d36933683a Automatic date update in version.in 2024-07-02 00:01:11 +00:00
GDB Administrator
d417a64fc2 Automatic date update in version.in 2024-07-01 00:01:32 +00:00
GDB Administrator
8d134aa67f Automatic date update in version.in 2024-06-30 00:01:20 +00:00
GDB Administrator
d432cd83c0 Automatic date update in version.in 2024-06-29 00:01:43 +00:00
GDB Administrator
476ed517b2 Automatic date update in version.in 2024-06-28 00:00:49 +00:00
GDB Administrator
3eb137638e Automatic date update in version.in 2024-06-27 00:01:27 +00:00
GDB Administrator
a21a737e01 Automatic date update in version.in 2024-06-26 00:01:56 +00:00
GDB Administrator
1396b91045 Automatic date update in version.in 2024-06-25 00:01:02 +00:00
Hannes Domani
390359aea1 Fix gdb.lookup_type for function-local types
Looking for a type defined locally in a function doesn't work
any more since the introduction of TYPE_DOMAIN:
```
(gdb) python print (gdb.lookup_type ('main()::Local'))
Python Exception <class 'gdb.error'>: No type named main()::Local.
Error occurred in Python: No type named main()::Local.
```

cp_search_static_and_baseclasses was simply missing a check for
SEARCH_TYPE_DOMAIN, now it works again:
```
(gdb) python print (gdb.lookup_type ('main()::Local'))
Local
```

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31922
Approved-By: Tom Tromey <tom@tromey.com>
2024-06-24 19:41:17 +02:00
Martin Simmons
72429c2a17 Include needed unordered_map header
Compiling on FreeBSD 13.2 with the default clang version 14.0.5 and top level
configure options --with-python=/usr/local/bin/python3.9 gives this error:

  CXX    ada-exp.o
./../binutils-gdb/gdb/ada-exp.y💯8: error: no template named 'unordered_map' in namespace 'std'
  std::unordered_map<std::string, std::vector<ada_index_var_operation *>>
  ~~~~~^
1 error generated.

This change fixes it.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31918
Approved-By: Tom Tromey <tom@tromey.com>
(cherry picked from commit c702f1ad8a)
2024-06-24 06:24:48 -06:00
GDB Administrator
dd6d09fd2b Automatic date update in version.in 2024-06-24 00:00:57 +00:00
GDB Administrator
ccda71a89a Automatic date update in version.in 2024-06-23 00:00:40 +00:00
GDB Administrator
e7b3fd348f Automatic date update in version.in 2024-06-22 00:01:20 +00:00
Pedro Alves
f33b87956f [gdb/tdep] Fix gdb.base/watchpoint-running.exp on {arm,ppc64le}-linux
When running test-case gdb.base/watchpoint-running on ppc64le-linux (and
similar on arm-linux), we get:
...
(gdb) watch global_var^M
warning: Error when detecting the debug register interface. \
  Debug registers will be unavailable.^M
Watchpoint 2: global_var^M
(gdb) FAIL: $exp: all-stop: hardware: watch global_var
FAIL: $exp: all-stop: hardware: watchpoint hit (timeout)
...

The problem is that ppc_linux_dreg_interface::detect fails to detect the
hardware watchpoint interface, because the calls to ptrace return with errno
set to ESRCH.

This is a feature of ptrace: if a call is done while the tracee is not
ptrace-stopped, it returns ESRCH.

Indeed, in the test-case "watch global_var" is executed while the inferior is
running, and that triggers the first call to ppc_linux_dreg_interface::detect.

And because the detection failure is cached, subsequent attempts at setting
hardware watchpoints will also fail, even if the tracee is ptrace-stopped.

The way to fix this is to make sure that ppc_linux_dreg_interface::detect is
called when we know that the thread is ptrace-stopped, which in the current
setup is best addressed by using target-specific post_attach and
post_startup_inferior overrides.  However, as we can see in
aarch64_linux_nat_target, that causes code duplication.

Fix this by:
- defining a new target hook low_init_process, called from
  linux_init_ptrace_procfs, which is called from both
  linux_nat_target::post_attach and linux_nat_target::post_startup_inferior,
- adding implementations for ppc_linux_nat_target and arm_linux_nat_target
  that detect the hardware watchpoint interface,
- replacing the aarch64_linux_nat_target implementations of post_attach and
  post_startup_inferior with a low_init_process implementation.

Tested on ppc64le-linux, arm-linux, aarch64-linux and x86_64-linux.

Co-Authored-By: Tom de Vries <tdevries@suse.de>
Approved-By: Luis Machado <luis.machado@arm.com>

PR tdep/31834
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31834
PR tdep/31705
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31705

(cherry picked from commit 50de502a4f)
2024-06-21 16:46:50 +02:00
GDB Administrator
7d3de2ad64 Automatic date update in version.in 2024-06-21 00:01:22 +00:00
Tom de Vries
1aa3b72f07 [gdb/python] Fix gdb.python/py-disasm.exp on arm-linux
After fixing test-case gdb.python/py-disasm.exp to recognize the arm nop:
...
	nop	{0}
...
we run into:
...
disassemble test^M
Dump of assembler code for function test:^M
   0x004004d8 <+0>:     push    {r11}           @ (str r11, [sp, #-4]!)^M
   0x004004dc <+4>:     add     r11, sp, #0^M
   0x004004e0 <+8>:     nop     {0}^M
=> 0x004004e4 <+12>:    Python Exception <class 'ValueError'>: Buffer \
  returned from read_memory is sized 0 instead of the expected 4^M
^M
unknown disassembler error (error = -1)^M
(gdb) FAIL: $exp: global_disassembler=ShowInfoRepr: disassemble test
...

This is caused by this code in gdbpy_disassembler::read_memory_func:
...
  gdbpy_ref<> result_obj (PyObject_CallMethod ((PyObject *) obj,
                                              "read_memory",
                                              "KL", len, offset));
...
where len has type "unsigned int", while "K" means "unsigned long long" [1].

Fix this by using "I" instead, meaning "unsigned int".

Also, offset has type LONGEST, which is typedef'ed to int64_t, while "L" means
"long long".

Fix this by using type gdb_py_longest for offset, in combination with format
character "GDB_PY_LL_ARG".  Likewise in disasmpy_info_read_memory.

Tested on arm-linux.

Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
Approved-By: Tom Tromey <tom@tromey.com>

PR python/31845
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31845

[1] https://docs.python.org/3/c-api/arg.html

(cherry picked from commit 4cd214dce4)
2024-06-20 15:54:16 +02:00
GDB Administrator
9c6d76c0d7 Automatic date update in version.in 2024-06-20 00:01:18 +00:00
GDB Administrator
bdda01fd9b Automatic date update in version.in 2024-06-19 00:00:59 +00:00
GDB Administrator
db432c3d50 Automatic date update in version.in 2024-06-18 00:00:34 +00:00
GDB Administrator
af91ec845e Automatic date update in version.in 2024-06-17 00:00:54 +00:00
GDB Administrator
7738a8af9d Automatic date update in version.in 2024-06-16 00:00:39 +00:00
GDB Administrator
44709ad8f5 Automatic date update in version.in 2024-06-15 00:00:49 +00:00
GDB Administrator
d1f2ec5e93 Automatic date update in version.in 2024-06-14 00:01:20 +00:00
GDB Administrator
a49df3daea Automatic date update in version.in 2024-06-13 00:01:09 +00:00
Kilian Kilger
4239c6015a fix division by zero in target_read_string()
Under certain circumstances, a floating point exception in
target_read_string() can happen when the type has been obtained
by a call to stpy_lazy_string_elt_type(). In the latter function,
a call to check_typedef() has been forgotten. This makes
type->length = 0 in this case.

(cherry picked from commit 8130c1a430)
2024-06-12 08:18:47 -06:00
Ciaran Woodward
f41400ee71 Fix printing strings on macOS Sonoma
On macOS sonoma, printing a string would only print the first
character. For instance, if there was a 'const char *s = "foobar"',
then the 'print s' command would print '$1 = "f"' rather than the
expected '$1 = "foobar"'.

It seems that this is due to Apple silently replacing the version
of libiconv they ship with the OS to one which silently fails to
handle the 'outbytesleft' parameter correctly when using 'wchar_t'
as a target encoding.

This specifically causes issues when using iterating through a
string as wchar_iterator does.

This bug is visible even if you build for an old version of macOS,
but then run on Sonoma. Therefore this fix in the code applies
generally to macOS, and not specific to building on Sonoma. Building
for an older version and expecting forwards compatibility is a
common situation on macOS.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31853
Approved-By: Tom Tromey <tom@tromey.com>

(cherry picked from commit bb2981798f)
2024-06-12 11:20:36 +01:00
GDB Administrator
0c7da7665f Automatic date update in version.in 2024-06-12 00:00:59 +00:00
GDB Administrator
2681e24698 Automatic date update in version.in 2024-06-11 00:00:39 +00:00
GDB Administrator
02be73cce7 Automatic date update in version.in 2024-06-10 00:01:04 +00:00
GDB Administrator
05187655ae Automatic date update in version.in 2024-06-09 00:01:01 +00:00
Eli Zaretskii
48db4a8344 gdb: Avoid compilation warning in gcore.c.
See https://sourceware.org/pipermail/gdb-patches/2024-June/209726.html
for the details.

Approved-By: Tom Tromey <tom@tromey.com>
(cherry picked from commit e222ed2ce5)
2024-06-08 10:24:45 +03:00
GDB Administrator
2feb7c1810 Automatic date update in version.in 2024-06-08 00:01:18 +00:00
Thiago Jung Bauermann
3504ea2946 gdb/testsuite: Add gdb.arch/aarch64-mops-watchpoint.exp
Test behaviour of watchpoints triggered by MOPS instructions.  This test
is similar to gdb.base/memops-watchpoint.exp, but specifically for MOPS
instructions rather than whatever instructions are used in the libc's
implementation of memset/memcpy/memmove.

There's a separate watched variable for each set of instructions so that
the testcase can test whether GDB correctly identified the watchpoint
that triggered in each case.

Approved-By: Luis Machado <luis.machado@arm.com>
Tested-By: Luis Machado <luis.machado@arm.com>
(cherry picked from commit 55e3fcf5e5)
2024-06-07 18:43:00 -03:00
Thiago Jung Bauermann
8fb41483be gdb/aarch64: Add record support for MOPS instructions.
There are two kinds of MOPS instructions: set instructions and copy
instructions.  Within each group there are variants with minor
differences in how they read or write to memory — e.g., non-temporal
read and/or write, unprivileged read and/or write and permutations of
those — but they work in the same way in terms of the registers and
regions of memory that they modify.

The new gdb.reverse/aarch64-mops.exp testcase verifies that MOPS
instructions are recorded and correctly reversed.  Not all variants of the
copy and set instructions are tested, since there are many and the record
and replay target processes them in the same way.

PR tdep/31666
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31666
Approved-By: Luis Machado <luis.machado@arm.com>
Tested-By: Luis Machado <luis.machado@arm.com>

(cherry picked from commit ebd06ca6b9)
2024-06-07 18:42:58 -03:00
Thiago Jung Bauermann
8215789c47 gdb/aarch64: Disable displaced single-step for MOPS instructions
The AArch64 MOPS (Memory Operation) instructions provide a standardised
instruction sequence to perform a memset, memcpy or memmove.  A sequence is
always composed of three instructions: a prologue instruction, a main
instruction and an epilogue instruction.  As an illustration, here are the
implementations of these memory operations in glibc 2.39:

  (gdb) disassemble/r
  Dump of assembler code for function __memset_mops:
  => 0x0000fffff7e8d780 <+0>:     d503201f        nop
     0x0000fffff7e8d784 <+4>:     aa0003e3        mov     x3, x0
     0x0000fffff7e8d788 <+8>:     19c10443        setp    [x3]!, x2!, x1
     0x0000fffff7e8d78c <+12>:    19c14443        setm    [x3]!, x2!, x1
     0x0000fffff7e8d790 <+16>:    19c18443        sete    [x3]!, x2!, x1
     0x0000fffff7e8d794 <+20>:    d65f03c0        ret
  End of assembler dump.

  (gdb) disassemble/r
  Dump of assembler code for function __memcpy_mops:
  => 0x0000fffff7e8c580 <+0>:     d503201f        nop
     0x0000fffff7e8c584 <+4>:     aa0003e3        mov     x3, x0
     0x0000fffff7e8c588 <+8>:     19010443        cpyfp   [x3]!, [x1]!, x2!
     0x0000fffff7e8c58c <+12>:    19410443        cpyfm   [x3]!, [x1]!, x2!
     0x0000fffff7e8c590 <+16>:    19810443        cpyfe   [x3]!, [x1]!, x2!
     0x0000fffff7e8c594 <+20>:    d65f03c0        ret
  End of assembler dump.

  (gdb) disassemble/r
  Dump of assembler code for function __memmove_mops:
  => 0x0000fffff7e8d180 <+0>:     d503201f        nop
     0x0000fffff7e8d184 <+4>:     aa0003e3        mov     x3, x0
     0x0000fffff7e8d188 <+8>:     1d010443        cpyp    [x3]!, [x1]!, x2!
     0x0000fffff7e8d18c <+12>:    1d410443        cpym    [x3]!, [x1]!, x2!
     0x0000fffff7e8d190 <+16>:    1d810443        cpye    [x3]!, [x1]!, x2!
     0x0000fffff7e8d194 <+20>:    d65f03c0        ret
  End of assembler dump.

The Arm Architecture Reference Manual says that "the prologue, main, and
epilogue instructions are expected to be run in succession and to appear
consecutively in memory".  Therefore this patch disables displaced stepping
on them.

The testcase verifies that MOPS sequences are correctly single-stepped.

PR tdep/31666
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31666
Approved-By: Luis Machado <luis.machado@arm.com>
Tested-By: Luis Machado <luis.machado@arm.com>

(cherry picked from commit b995344c11)
2024-06-07 18:42:27 -03:00
GDB Administrator
3e61e9a527 Automatic date update in version.in 2024-06-07 00:00:57 +00:00
Andrew Burgess
9b1ed1f3b5 gdb/doc: use POD2MAN5 when appropriate
In commit:

  commit 824083f34c
  Date:   Fri Apr 12 17:47:20 2024 +0100

      gdb/doc: use silent-rules.mk in the Makefile

I rewrote the rules for building the man pages.  While doing this I
accidentally switched from using MAN2POD5 to MAN2POD1 for generating
the file gdbinit.5.

Restore use of MAN2POD5 where appropriate.
2024-06-06 18:04:33 +01:00
GDB Administrator
a89164f88c Automatic date update in version.in 2024-06-06 00:01:03 +00:00
GDB Administrator
116e8a3821 Automatic date update in version.in 2024-06-05 00:01:16 +00:00
GDB Administrator
3ad94add7f Automatic date update in version.in 2024-06-04 00:01:10 +00:00
GDB Administrator
8af148e476 Automatic date update in version.in 2024-06-03 00:00:32 +00:00
GDB Administrator
1e1cc01596 Automatic date update in version.in 2024-06-02 00:00:27 +00:00
Joel Brobecker
ec7683e3d7 Bump GDB's version number to 15.0.91.DATE-git.
This commit changes gdb/version.in to 15.0.91.DATE-git.
2024-06-01 08:56:22 -07:00
Joel Brobecker
80fba8a24f Set GDB version number to 15.0.91.
This commit changes gdb/version.in to 15.0.91.
2024-06-01 08:46:30 -07:00
GDB Administrator
5fcf2ea766 Automatic date update in version.in 2024-06-01 00:00:50 +00:00
GDB Administrator
909e567305 Automatic date update in version.in 2024-05-31 00:00:42 +00:00
GDB Administrator
8b69689d8b Automatic date update in version.in 2024-05-30 00:00:29 +00:00
Andrew Burgess
9c2db7a3c7 gdb/doc: don't have .pod targets separate to man page targets
While preparing the new release it was discovered that commit:

  commit 824083f34c
  Date:   Fri Apr 12 17:47:20 2024 +0100

      gdb/doc: use silent-rules.mk in the Makefile

was causing problems.  Given a release tar file, an attempt to build
and install GDB would give an error like this:

  [...]
    TEXI2POD gdb.pod
  cannot find GDBvn.texi at ../../../gdb-15.0.50.20240508/gdb/doc/../../etc/texi2pod.pl line 251, <GEN0> line 16.
  make[5]: *** [Makefile:663: gdb.pod] Error 2

The problem here is how the man pages are built, and how they are
distributed within a release.

Within the development (git) tree, the man page files are not part of
the source tree, these files are built as needed.  Within a release
tar file though, the man pages are included.  The idea being that a
user can build and install GDB, including getting the man pages,
without having to install the tools needed to generate the man pages.

The man pages are generated in a two step process.  First the .texi
file is processed with texi2pod to create a .pod file, then this .pod
file is processed to create the .1 or .5 man file.

Prior to the above commit these two steps were combined into a single
recipe, this meant that when a user performed a build/install from a
release tree all of the dependencies, as well as the final result,
were all present in the source tree, and so nothing needed to be
rebuilt.

However, the above commit split the two steps apart.  Now we had a
separate rule for building the .pod files, and the .1/.5 man page
files depended on the relevant .pod file.

As the .pod files are not shipped in a GDB release, this meant that
one of the dependencies of the man page files was now missing.  As a
result if a user tried to install from a release tree a rebuild of the
.pod files would be attempted, and if that succeeded then building the
man pages would follow that.

Unfortunately, building the .pod files would fail as the GDBvn.texi
file, though present in the source tree, was not present in the build
tree, which is where it is needed for the .pod file generation to
work.

To fix this, I propose merging the .pod creation and the .1/.5 man
page creation back into a single recipe.  Having these two steps split
is probably the "cleaner" solution, but makes it harder for us to
achieve our goal of shipping the prebuilt man page files.  I've added
a comment explaining what's going on (such a comment would have
prevented this mistake having been made in the first place).

One possibly weird thing here is that I have left both an
ECHO_TEXI2POD and a ECHO_TEXI2MAN in the rule $(MAN1S) and $(MAN5S)
recipes.  This is 100% not going to break anything, these just print
two different progress messages while executing the recipes, but I'm
not sure if this is considered poor style or not.  Maybe we're only
supposed to have a single ECHO_* per recipe?

Anyway, even if this is poor style, I figure it really is just a style
thing.  We can tweak this later as needed.  Otherwise, this commit
should fix the current issue blocking the next GDB release.

Approved-By: Tom Tromey <tom@tromey.com>
2024-05-29 22:28:51 +01:00
GDB Administrator
97b31937d6 Automatic date update in version.in 2024-05-29 00:00:35 +00:00
GDB Administrator
d5185bee0b Automatic date update in version.in 2024-05-28 00:00:45 +00:00
GDB Administrator
6aabfa4522 Automatic date update in version.in 2024-05-27 00:00:39 +00:00
Joel Brobecker
5194ca4da1 Set GDB version number to 15.0.90.
This commit changes gdb/version.in to 15.0.90.
2024-05-26 09:15:48 -07:00
Joel Brobecker
d2c4f42000 gdb/NEWS: Replace "Chagnes since GDB 14" to "Changes in GDB 15"
This commit changes the title of the section to refer to the actual
release version number, now that all changes listed are confirmed
to be part of the upcoming GDB 15 release.
2024-05-26 09:13:27 -07:00
Joel Brobecker
85f8f79ea8 Set development mode to "off" by default.
This is done by setting the "development" variable to "false"
in bfd/development.sh.
2024-05-26 08:57:38 -07:00
Joel Brobecker
38e47144a5 Bump version to 15.0.90.DATE-git.
Now that the GDB 15 branch has been created,
this commit bumps the version number in gdb/version.in to
15.0.90.DATE-git

For the record, the GDB 15 branch was created
from commit 3a624d9f1c.
2024-05-26 08:57:12 -07:00
49 changed files with 1211 additions and 104 deletions

View File

@@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Controls whether to enable development-mode features by default.
development=true
development=false
# Indicate whether this is a release branch.
experimental=true

View File

@@ -16,7 +16,7 @@
In releases, the date is not included in either version strings or
sonames. */
#define BFD_VERSION_DATE 20240526
#define BFD_VERSION_DATE 20240929
#define BFD_VERSION @bfd_version@
#define BFD_VERSION_STRING @bfd_version_package@ @bfd_version_string@
#define REPORT_BUGS_TO @report_bugs_to@

View File

@@ -1,7 +1,7 @@
What has changed in GDB?
(Organized release by release)
*** Changes since GDB 14
*** Changes in GDB 15
* The MPX commands "show/set mpx bound" have been deprecated, as Intel
listed MPX as removed in 2019.

View File

@@ -78,12 +78,6 @@ public:
int can_do_single_step () override;
/* Override the GNU/Linux inferior startup hook. */
void post_startup_inferior (ptid_t) override;
/* Override the GNU/Linux post attach hook. */
void post_attach (int pid) override;
/* These three defer to common nat/ code. */
void low_new_thread (struct lwp_info *lp) override
{ aarch64_linux_new_thread (lp); }
@@ -93,6 +87,7 @@ public:
{ aarch64_linux_prepare_to_resume (lp); }
void low_new_fork (struct lwp_info *parent, pid_t child_pid) override;
void low_init_process (pid_t pid) override;
void low_forget_process (pid_t pid) override;
/* Add our siginfo layout converter. */
@@ -844,29 +839,18 @@ ps_get_thread_area (struct ps_prochandle *ph,
}
/* Implement the virtual inf_ptrace_target::post_startup_inferior method. */
/* Implement the "low_init_process" target_ops method. */
void
aarch64_linux_nat_target::post_startup_inferior (ptid_t ptid)
{
low_forget_process (ptid.pid ());
aarch64_linux_get_debug_reg_capacity (ptid.pid ());
linux_nat_target::post_startup_inferior (ptid);
}
/* Implement the "post_attach" target_ops method. */
void
aarch64_linux_nat_target::post_attach (int pid)
aarch64_linux_nat_target::low_init_process (pid_t pid)
{
low_forget_process (pid);
/* Set the hardware debug register capacity. If
aarch64_linux_get_debug_reg_capacity is not called
(as it is in aarch64_linux_child_post_startup_inferior) then
software watchpoints will be used instead of hardware
watchpoints when attaching to a target. */
/* Set the hardware debug register capacity. This requires the process to be
ptrace-stopped, otherwise detection will fail and software watchpoints will
be used instead of hardware. If we allow this to be done lazily, we
cannot guarantee that it's called when the process is ptrace-stopped, so
do it now. */
aarch64_linux_get_debug_reg_capacity (pid);
linux_nat_target::post_attach (pid);
}
/* Implement the "read_description" target_ops method. */

View File

@@ -3808,10 +3808,12 @@ aarch64_displaced_step_copy_insn (struct gdbarch *gdbarch,
if (aarch64_decode_insn (insn, &inst, 1, NULL) != 0)
return NULL;
/* Look for a Load Exclusive instruction which begins the sequence. */
if (inst.opcode->iclass == ldstexcl && bit (insn, 22))
/* Look for a Load Exclusive instruction which begins the sequence,
or for a MOPS instruction. */
if ((inst.opcode->iclass == ldstexcl && bit (insn, 22))
|| AARCH64_CPU_HAS_FEATURE (*inst.opcode->avariant, MOPS))
{
/* We can't displaced step atomic sequences. */
/* We can't displaced step atomic sequences nor MOPS instructions. */
return NULL;
}
@@ -5186,6 +5188,71 @@ aarch64_record_asimd_load_store (aarch64_insn_decode_record *aarch64_insn_r)
return AARCH64_RECORD_SUCCESS;
}
/* Record handler for Memory Copy and Memory Set instructions. */
static unsigned int
aarch64_record_memcopy_memset (aarch64_insn_decode_record *aarch64_insn_r)
{
if (record_debug)
debug_printf ("Process record: memory copy and memory set\n");
uint8_t op1 = bits (aarch64_insn_r->aarch64_insn, 22, 23);
uint8_t op2 = bits (aarch64_insn_r->aarch64_insn, 12, 15);
uint32_t reg_rd = bits (aarch64_insn_r->aarch64_insn, 0, 4);
uint32_t reg_rn = bits (aarch64_insn_r->aarch64_insn, 5, 9);
uint32_t record_buf[3];
uint64_t record_buf_mem[4];
if (op1 == 3 && op2 > 11)
/* Unallocated instructions. */
return AARCH64_RECORD_UNKNOWN;
/* Set instructions have two registers and one memory region to be
recorded. */
record_buf[0] = reg_rd;
record_buf[1] = reg_rn;
aarch64_insn_r->reg_rec_count = 2;
ULONGEST dest_addr;
regcache_raw_read_unsigned (aarch64_insn_r->regcache, reg_rd, &dest_addr);
LONGEST length;
regcache_raw_read_signed (aarch64_insn_r->regcache, reg_rn, &length);
/* In one of the algorithm options a processor can implement, the length
in Rn has an inverted sign. */
if (length < 0)
length *= -1;
record_buf_mem[0] = length;
record_buf_mem[1] = dest_addr;
aarch64_insn_r->mem_rec_count = 1;
if (op1 != 3)
{
/* Copy instructions have an additional register and an additional
memory region to be recorded. */
uint32_t reg_rs = bits (aarch64_insn_r->aarch64_insn, 16, 20);
record_buf[2] = reg_rs;
aarch64_insn_r->reg_rec_count++;
ULONGEST source_addr;
regcache_raw_read_unsigned (aarch64_insn_r->regcache, reg_rs,
&source_addr);
record_buf_mem[2] = length;
record_buf_mem[3] = source_addr;
aarch64_insn_r->mem_rec_count++;
}
MEM_ALLOC (aarch64_insn_r->aarch64_mems, aarch64_insn_r->mem_rec_count,
record_buf_mem);
REG_ALLOC (aarch64_insn_r->aarch64_regs, aarch64_insn_r->reg_rec_count,
record_buf);
return AARCH64_RECORD_SUCCESS;
}
/* Record handler for load and store instructions. */
static unsigned int
@@ -5463,6 +5530,10 @@ aarch64_record_load_store (aarch64_insn_decode_record *aarch64_insn_r)
if (insn_bits10_11 == 0x01 || insn_bits10_11 == 0x03)
record_buf[aarch64_insn_r->reg_rec_count++] = reg_rn;
}
/* Memory Copy and Memory Set instructions. */
else if ((insn_bits24_27 & 1) == 1 && insn_bits28_29 == 1
&& insn_bits10_11 == 1 && !insn_bit21)
return aarch64_record_memcopy_memset (aarch64_insn_r);
/* Advanced SIMD load/store instructions. */
else
return aarch64_record_asimd_load_store (aarch64_insn_r);

View File

@@ -36,6 +36,7 @@
%{
#include <ctype.h>
#include <unordered_map>
#include "expression.h"
#include "value.h"
#include "parser-defs.h"

View File

@@ -37,6 +37,7 @@
#include "auxv.h"
#include "observable.h"
#include "solib-target.h"
#include "event-top.h"
#include "gdbsupport/version.h"
@@ -1040,7 +1041,11 @@ default_print_insn (bfd_vma memaddr, disassemble_info *info)
info->mach, current_program_space->exec_bfd ());
gdb_assert (disassemble_fn != NULL);
return (*disassemble_fn) (memaddr, info);
int res = (*disassemble_fn) (memaddr, info);
QUIT;
return res;
}
/* See arch-utils.h. */

View File

@@ -103,6 +103,7 @@ public:
/* Handle process creation and exit. */
void low_new_fork (struct lwp_info *parent, pid_t child_pid) override;
void low_init_process (pid_t pid) override;
void low_forget_process (pid_t pid) override;
};
@@ -805,6 +806,19 @@ arm_linux_process_info_get (pid_t pid)
return proc;
}
/* Implement the "low_init_process" target_ops method. */
void
arm_linux_nat_target::low_init_process (pid_t pid)
{
/* Set the hardware debug register capacity. This requires the process to be
ptrace-stopped, otherwise detection will fail and software watchpoints will
be used instead of hardware. If we allow this to be done lazily, we
cannot guarantee that it's called when the process is ptrace-stopped, so
do it now. */
arm_linux_get_hwbp_cap ();
}
/* Called whenever GDB is no longer debugging process PID. It deletes
data structures that keep track of debug register state. */

View File

@@ -287,10 +287,10 @@ cp_search_static_and_baseclasses (const char *name,
struct type *scope_type = scope_sym.symbol->type ();
/* If the scope is a function/method, then look up NESTED as a local
static variable. E.g., "print 'function()::static_var'". */
static variable or type. E.g., "print 'function()::static_var'". */
if ((scope_type->code () == TYPE_CODE_FUNC
|| scope_type->code () == TYPE_CODE_METHOD)
&& (domain & SEARCH_VAR_DOMAIN) != 0)
&& (domain & (SEARCH_VAR_DOMAIN | SEARCH_TYPE_DOMAIN)) != 0)
return lookup_symbol (nested, scope_sym.symbol->value_block (),
domain, NULL);

View File

@@ -197,7 +197,12 @@ gdb_disassembler_memory_reader::dis_asm_read_memory
(bfd_vma memaddr, gdb_byte *myaddr, unsigned int len,
struct disassemble_info *info) noexcept
{
return target_read_code (memaddr, myaddr, len);
auto res = catch_exceptions<int, -1> ([&]
{
return target_read_code (memaddr, myaddr, len);
});
return res;
}
/* Wrapper of memory_error. */

View File

@@ -658,17 +658,30 @@ annotate/index.html: $(ANNOTATE_DOC_FILES)
-I $(srcdir) \
$(srcdir)/annotate.texinfo
# Man pages
%.pod : gdb.texinfo $(GDB_DOC_FILES)
$(ECHO_TEXI2POD) $(TEXI2POD) $(MANCONF) -D$* < $(srcdir)/gdb.texinfo > $@
$(MAN1S) : %.1 : %.pod $(GDB_DOC_FILES)
# Man pages. The TEXI2POD and TEXI2MAN steps are performed within a
# single recipe to support how we distribute GDB releases. A release
# includes the .1 and .5 man pages in the source tree, but not the
# .pod files.
#
# When building and installing a release of GDB it should not be
# necessary to rebuild the .1 or .5 man page files, nor should it be
# necessary to rebuild the .pod files.
#
# If we split the .pod creation from the creation of the .1 and .5
# pages, then the .pod files must become a dependency, this will
# trigger an attempt to rebuild these files while building and
# installing a release of GDB, which is something we don't want.
$(MAN1S) : %.1 : $(GDB_DOC_FILES)
$(ECHO_TEXI2POD) $(TEXI2POD) $(MANCONF) -D$* < $(srcdir)/gdb.texinfo > $*.pod
$(ECHO_TEXI2MAN) ($(POD2MAN1) $*.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
$(SILENCE) rm -f $*.pod
$(MAN5S) : %.5 : %.pod $(GDB_DOC_FILES)
$(ECHO_TEXI2MAN) ($(POD2MAN1) $*.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
$(MAN5S) : %.5 : $(GDB_DOC_FILES)
$(ECHO_TEXI2POD) $(TEXI2POD) $(MANCONF) -D$* < $(srcdir)/gdb.texinfo > $*.pod
$(ECHO_TEXI2MAN) ($(POD2MAN5) $*.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
$(SILENCE) rm -f $*.pod
force:

View File

@@ -16440,12 +16440,6 @@ cooked_indexer::index_dies (cutu_reader *reader,
flags &= ~IS_STATIC;
flags |= parent_entry->flags & IS_STATIC;
}
/* If the parent is an enum, but not an enum class, then use the
grandparent instead. */
if (this_parent_entry != nullptr
&& this_parent_entry->tag == DW_TAG_enumeration_type
&& !is_enum_class)
this_parent_entry = this_parent_entry->get_parent ();
if (abbrev->tag == DW_TAG_namespace
&& m_language == language_cplus
@@ -16505,7 +16499,15 @@ cooked_indexer::index_dies (cutu_reader *reader,
break;
case DW_TAG_enumeration_type:
info_ptr = recurse (reader, info_ptr, this_entry, fully);
/* We need to recurse even for an anonymous enumeration.
Which scope we record as the parent scope depends on
whether we're reading an "enum class". If so, we use
the enum itself as the parent, yielding names like
"enum_class::enumerator"; otherwise we inject the
names into our own parent scope. */
info_ptr = recurse (reader, info_ptr,
is_enum_class ? this_entry : parent_entry,
fully);
continue;
case DW_TAG_module:
@@ -17914,8 +17916,8 @@ public:
we're processing the end of a sequence. */
void record_line (bool end_sequence);
/* Check ADDRESS is -1, or zero and less than UNRELOCATED_LOWPC, and if true
nop-out rest of the lines in this sequence. */
/* Check ADDRESS is -1, -2, or zero and less than UNRELOCATED_LOWPC, and if
true nop-out rest of the lines in this sequence. */
void check_line_address (struct dwarf2_cu *cu,
const gdb_byte *line_ptr,
unrelocated_addr unrelocated_lowpc,
@@ -18325,13 +18327,16 @@ lnp_state_machine::check_line_address (struct dwarf2_cu *cu,
unrelocated_addr unrelocated_lowpc,
unrelocated_addr address)
{
/* Linkers resolve a symbolic relocation referencing a GC'd function to 0 or
-1. If ADDRESS is 0, ignoring the opcode will err if the text section is
/* Linkers resolve a symbolic relocation referencing a GC'd function to 0,
-1 or -2 (-2 is used by certain lld versions, see
https://github.com/llvm/llvm-project/commit/e618ccbf431f6730edb6d1467a127c3a52fd57f7).
If ADDRESS is 0, ignoring the opcode will err if the text section is
located at 0x0. In this case, additionally check that if
ADDRESS < UNRELOCATED_LOWPC. */
if ((address == (unrelocated_addr) 0 && address < unrelocated_lowpc)
|| address == (unrelocated_addr) -1)
|| address == (unrelocated_addr) -1
|| address == (unrelocated_addr) -2)
{
/* This line table is for a function which has been
GCd by the linker. Ignore it. PR gdb/12528 */

View File

@@ -24,6 +24,8 @@
#include <signal.h>
#include "extension.h"
struct cmd_list_element;
/* The current quit handler (and its type). This is called from the
@@ -81,6 +83,29 @@ extern void quit_serial_event_set ();
extern void quit_serial_event_clear ();
/* Wrap f (args) and handle exceptions by:
- returning val, and
- calling set_quit_flag or set_force_quit_flag, if needed. */
template <typename R, R val, typename F, typename... Args>
static R
catch_exceptions (F &&f, Args&&... args)
{
try
{
return f (std::forward<Args> (args)...);
}
catch (const gdb_exception &ex)
{
if (ex.reason == RETURN_QUIT)
set_quit_flag ();
else if (ex.reason == RETURN_FORCED_QUIT)
set_force_quit_flag ();
}
return val;
}
extern void display_gdb_prompt (const char *new_prompt);
extern void gdb_setup_readline (int);
extern void gdb_disable_readline (void);

View File

@@ -528,7 +528,7 @@ objfile_find_memory_regions (struct target_ops *self,
find_memory_region_ftype func, void *obfd)
{
/* Use objfile data to create memory sections. */
bfd_vma temp_bottom, temp_top;
bfd_vma temp_bottom = 0, temp_top = 0;
/* Call callback function for each objfile section. */
for (objfile *objfile : current_program_space->objfiles ())

View File

@@ -930,29 +930,6 @@ gdb_bfd_openw (const char *filename, const char *target)
return gdb_bfd_ref_ptr::new_reference (result);
}
/* Wrap f (args) and handle exceptions by:
- returning val, and
- calling set_quit_flag or set_force_quit_flag, if needed. */
template <typename R, R val, typename F, typename... Args>
static R
catch_exceptions (F &&f, Args&&... args)
{
try
{
return f (std::forward<Args> (args)...);
}
catch (const gdb_exception &ex)
{
if (ex.reason == RETURN_QUIT)
set_quit_flag ();
else if (ex.reason == RETURN_FORCED_QUIT)
set_force_quit_flag ();
}
return val;
}
/* See gdb_bfd.h. */
gdb_bfd_ref_ptr

View File

@@ -76,8 +76,19 @@ typedef wint_t gdb_wint_t;
We exploit this fact in the hope that there are hosts that define
this but which do not support "wchar_t" as an encoding argument to
iconv_open. We put the endianness into the encoding name to avoid
hosts that emit a BOM when the unadorned name is used. */
#if defined (__STDC_ISO_10646__)
hosts that emit a BOM when the unadorned name is used.
Also, on version 14 macOS 'Sonoma', the implementation of iconv was
changed in such a way that breaks the way that gdb was using it.
Specifically, using wchar_t as an intermediate encoding silently
breaks when attempting to do character-by-character encoding.
By using the intermediate_encoding function to choose a suitable
encoding to put in the wchar_t, the iconv implementation behaves as
we expect it to. Strictly speaking, this seems to be a bug in
Sonoma specifically, but it is desirable for binaries built for
older versions of macOS to still work on newer ones such as Sonoma,
so there is no version check here for this workaround. */
#if defined (__STDC_ISO_10646__) || defined (__APPLE__)
#define USE_INTERMEDIATE_ENCODING_FUNCTION
#define INTERMEDIATE_ENCODING intermediate_encoding ()
const char *intermediate_encoding (void);

View File

@@ -280,13 +280,13 @@ struct gdb_mpz
gdb_mpz operator>> (unsigned long nbits) const
{
gdb_mpz result;
mpz_tdiv_q_2exp (result.m_val, m_val, nbits);
mpz_fdiv_q_2exp (result.m_val, m_val, nbits);
return result;
}
gdb_mpz &operator>>= (unsigned long nbits)
{
mpz_tdiv_q_2exp (m_val, m_val, nbits);
mpz_fdiv_q_2exp (m_val, m_val, nbits);
return *this;
}

View File

@@ -454,6 +454,12 @@ linux_init_ptrace_procfs (pid_t pid, int attached)
linux_ptrace_init_warnings ();
linux_proc_init_warnings ();
proc_mem_file_is_writable ();
/* Let the arch-specific native code do any needed initialization.
Some architectures need to call ptrace to check for hardware
watchpoints support, etc. Call it now, when we know the tracee
is ptrace-stopped. */
linux_target->low_init_process (pid);
}
linux_nat_target::~linux_nat_target ()

View File

@@ -164,6 +164,12 @@ public:
virtual void low_new_clone (struct lwp_info *parent, pid_t child_lwp)
{}
/* The method to call, if any, when we have a new (from run/attach,
not fork) process to debug. The process is ptrace-stopped when
this is called. */
virtual void low_init_process (pid_t pid)
{}
/* The method to call, if any, when a process is no longer
attached. */
virtual void low_forget_process (pid_t pid)

View File

@@ -545,6 +545,8 @@ struct ppc_linux_nat_target final : public linux_nat_target
void low_new_clone (struct lwp_info *, pid_t) override;
void low_init_process (pid_t pid) override;
void low_forget_process (pid_t pid) override;
void low_prepare_to_resume (struct lwp_info *) override;
@@ -2705,6 +2707,19 @@ ppc_linux_nat_target::remove_watchpoint (CORE_ADDR addr, int len,
return 0;
}
/* Implement the "low_init_process" target_ops method. */
void
ppc_linux_nat_target::low_init_process (pid_t pid)
{
/* Set the hardware debug register capacity. This requires the process to be
ptrace-stopped, otherwise detection will fail and software watchpoints will
be used instead of hardware. If we allow this to be done lazily, we
cannot guarantee that it's called when the process is ptrace-stopped, so
do it now. */
m_dreg_interface.detect (ptid_t (pid, pid));
}
/* Clean up the per-process info associated with PID. When using the
HWDEBUG interface, we also erase the per-thread state of installed
debug registers for all the threads that belong to the group of PID.

View File

@@ -667,12 +667,13 @@ disasmpy_info_read_memory (PyObject *self, PyObject *args, PyObject *kw)
disasm_info_object *obj = (disasm_info_object *) self;
DISASMPY_DISASM_INFO_REQUIRE_VALID (obj);
LONGEST length, offset = 0;
gdb_py_longest length, offset = 0;
gdb::unique_xmalloc_ptr<gdb_byte> buffer;
static const char *keywords[] = { "length", "offset", nullptr };
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "L|L", keywords,
&length, &offset))
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw,
GDB_PY_LL_ARG "|" GDB_PY_LL_ARG,
keywords, &length, &offset))
return nullptr;
/* The apparent address from which we are reading memory. Note that in
@@ -849,13 +850,14 @@ gdbpy_disassembler::read_memory_func (bfd_vma memaddr, gdb_byte *buff,
/* The DisassembleInfo.read_memory method expects an offset from the
address stored within the DisassembleInfo object; calculate that
offset here. */
LONGEST offset = (LONGEST) memaddr - (LONGEST) obj->address;
gdb_py_longest offset
= (gdb_py_longest) memaddr - (gdb_py_longest) obj->address;
/* Now call the DisassembleInfo.read_memory method. This might have been
overridden by the user. */
gdbpy_ref<> result_obj (PyObject_CallMethod ((PyObject *) obj,
"read_memory",
"KL", len, offset));
"I" GDB_PY_LL_ARG, len, offset));
/* Handle any exceptions. */
if (result_obj == nullptr)

View File

@@ -266,7 +266,7 @@ stpy_lazy_string_elt_type (lazy_string_object *lazy)
{
case TYPE_CODE_PTR:
case TYPE_CODE_ARRAY:
return realtype->target_type ();
return check_typedef (realtype->target_type ());
default:
/* This is done to preserve existing behaviour. PR 20769.
E.g., gdb.parse_and_eval("my_int_variable").lazy_string().type. */

View File

@@ -390,6 +390,35 @@ gdbpy_handle_exception ()
if (fetched_error.type_matches (PyExc_KeyboardInterrupt))
throw_quit ("Quit");
else if (fetched_error.type_matches (PyExc_SystemExit))
{
gdbpy_ref<> value = fetched_error.value ();
gdbpy_ref<> code (PyObject_GetAttrString (value.get (), "code"));
int exit_arg;
if (code.get () == Py_None)
{
/* CODE == None: exit status is 0. */
exit_arg = 0;
}
else if (code.get () != nullptr && PyLong_Check (code.get ()))
{
/* CODE == integer: exit status is aforementioned integer. */
exit_arg = PyLong_AsLong (code.get ());
}
else
{
if (code.get () == nullptr)
gdbpy_print_stack ();
/* Otherwise: exit status is 1, print code to stderr. */
if (msg != nullptr)
gdb_printf (gdb_stderr, "%s\n", msg.get ());
exit_arg = 1;
}
quit_force (&exit_arg, 0);
}
else if (! fetched_error.type_matches (gdbpy_gdberror_exc)
|| msg == NULL || *msg == '\0')
{

View File

@@ -2072,6 +2072,7 @@ record_full_core_target::resume (ptid_t ptid, int step,
enum gdb_signal signal)
{
record_full_resume_step = step;
record_full_resume_ptid = ptid;
record_full_resumed = 1;
record_full_execution_dir = ::execution_direction;
}

View File

@@ -382,6 +382,8 @@ frv_current_sos ()
li->map = loadmap;
li->got_value = got_addr;
li->lm_addr = lm_addr;
sop->lm_info = std::move (li);
/* Fetch the name. */
addr = extract_unsigned_integer (lm_buf.l_name,
sizeof (lm_buf.l_name),

View File

@@ -0,0 +1,73 @@
/* This file is part of GDB, the GNU debugger.
Copyright 2024 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#define TEST_STRING "Just a test string."
#define BUF_SIZE sizeof(TEST_STRING)
int
main (void)
{
char source[BUF_SIZE] = TEST_STRING;
char dest[BUF_SIZE];
char *p, *q;
long size, zero;
/* Note: The prfm instruction in the asm statements below is there just
to allow the testcase to recognize when the PC is at the instruction
right after the MOPS sequence. */
p = dest;
size = sizeof (dest);
zero = 0;
/* Break memset. */
/* memset implemented in MOPS instructions. */
__asm__ volatile ("setp [%0]!, %1!, %2\n\t"
"setm [%0]!, %1!, %2\n\t"
"sete [%0]!, %1!, %2\n\t"
"prfm pldl3keep, [%0, #0]\n\t"
: "+&r"(p), "+&r"(size)
: "r"(zero)
: "memory");
p = dest;
q = source;
size = sizeof (dest);
/* Break memcpy. */
/* memcpy implemented in MOPS instructions. */
__asm__ volatile ("cpyfp [%0]!, [%1]!, %2!\n\t"
"cpyfm [%0]!, [%1]!, %2!\n\t"
"cpyfe [%0]!, [%1]!, %2!\n\t"
"prfm pldl3keep, [%0, #0]\n\t"
: "+&r" (p), "+&r" (q), "+&r" (size)
:
: "memory");
p = dest;
q = source;
size = sizeof (dest);
/* Break memmove. */
/* memmove implemented in MOPS instructions. */
__asm__ volatile ("cpyp [%0]!, [%1]!, %2!\n\t"
"cpym [%0]!, [%1]!, %2!\n\t"
"cpye [%0]!, [%1]!, %2!\n\t"
"prfm pldl3keep, [%0, #0]\n\t"
: "+&r" (p), "+&r" (q), "+&r" (size)
:
: "memory");
return 0;
}

View File

@@ -0,0 +1,98 @@
# Copyright 2024 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This file is part of the GDB testsuite.
# Test single stepping through MOPS (memory operations) instruction sequences.
require allow_aarch64_mops_tests
standard_testfile
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
[list debug additional_flags=-march=armv9.3-a]] } {
return -1
}
# If the inferior is rescheduled to another CPU while a main or epilogue
# instruction is executed, the OS resets the inferior back to the prologue
# instruction, so we need to allow for that possibility.
proc step_through_sequence { prefix } {
set count 0
while { [is_at_instruction ${prefix}p] == 1 && $count < 50 } {
incr count
# The stepi output isn't useful to detect whether we stepped over
# the instruction.
gdb_test "stepi" "\[^\r\n\]+" "step over ${prefix}p"
if { [is_at_instruction ${prefix}m] == 1 } {
pass "stepped over ${prefix}p"
} else {
fail "stepped over ${prefix}e"
return 0
}
gdb_test "stepi" "\[^\r\n\]+" "step over ${prefix}m"
if { [is_at_instruction ${prefix}e] == 1 } {
pass "stepped over ${prefix}m"
} elseif { [is_at_instruction ${prefix}p] == 1 } {
# The inferior was rescheduled to another CPU.
pass "${prefix}m: reset back to prologue"
continue
} else {
fail "stepped over ${prefix}m"
return 0
}
gdb_test "stepi" "\[^\r\n\]+" "step over ${prefix}e"
if { [is_at_instruction prfm] == 1 } {
pass "stepped over ${prefix}e"
return 1
} elseif { [is_at_instruction ${prefix}p] == 1 } {
# The inferior was rescheduled to another CPU.
pass "${prefix}e: reset back to prologue"
continue
}
}
fail "step through $prefix sequence"
return 0
}
if ![runto_main] {
return -1
}
gdb_breakpoint ${srcfile}:[gdb_get_line_number "Break memset"]
gdb_breakpoint ${srcfile}:[gdb_get_line_number "Break memcpy"]
gdb_breakpoint ${srcfile}:[gdb_get_line_number "Break memmove"]
gdb_continue_to_breakpoint "memset breakpoint"
if { [arrive_at_instruction setp] } {
step_through_sequence set
}
gdb_continue_to_breakpoint "memcpy breakpoint"
if { [arrive_at_instruction cpyfp] } {
step_through_sequence cpyf
}
gdb_continue_to_breakpoint "memmove breakpoint"
if { [arrive_at_instruction cpyp] } {
step_through_sequence cpy
}

View File

@@ -0,0 +1,66 @@
/* This test program is part of GDB, the GNU debugger.
Copyright 2024 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
int
main (void)
{
char source[40] __attribute__ ((aligned (8)))
= "This is a relatively long string...";
char a[40] __attribute__ ((aligned (8)))
= "String to be overwritten with zeroes";
char b[40] __attribute__ ((aligned (8)))
= "Another string to be memcopied...";
char c[40] __attribute__ ((aligned (8)))
= "Another string to be memmoved...";
char *p, *q;
long size, zero;
/* Break here. */
p = a;
size = sizeof (a);
zero = 0;
/* memset implemented in MOPS instructions. */
__asm__ volatile ("setp [%0]!, %1!, %2\n\t"
"setm [%0]!, %1!, %2\n\t"
"sete [%0]!, %1!, %2\n\t"
: "+&r"(p), "+&r"(size)
: "r"(zero)
: "memory");
p = b;
q = source;
size = sizeof (b);
/* memmove implemented in MOPS instructions. */
__asm__ volatile ("cpyp [%0]!, [%1]!, %2!\n\t"
"cpym [%0]!, [%1]!, %2!\n\t"
"cpye [%0]!, [%1]!, %2!\n\t"
: "+&r" (p), "+&r" (q), "+&r" (size)
:
: "memory");
p = c;
q = source;
size = sizeof (c);
/* memcpy implemented in MOPS instructions. */
__asm__ volatile ("cpyfp [%0]!, [%1]!, %2!\n\t"
"cpyfm [%0]!, [%1]!, %2!\n\t"
"cpyfe [%0]!, [%1]!, %2!\n\t"
: "+&r" (p), "+&r" (q), "+&r" (size)
:
: "memory");
return 0;
}

View File

@@ -0,0 +1,79 @@
# Copyright 2024 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Test a binary that uses MOPS (Memory Operations) instructions.
# This test is similar to gdb.base/memops-watchpoint.exp, but specifically
# tests MOPS instructions rather than whatever instructions are used in the
# system libc's implementation of memset/memcpy/memmove.
require allow_hw_watchpoint_tests allow_aarch64_mops_tests
standard_testfile
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
[list debug additional_flags=-march=armv9.3-a]] } {
return -1
}
set linespec ${srcfile}:[gdb_get_line_number "Break here"]
if ![runto ${linespec}] {
return -1
}
gdb_test "watch -location a\[28\]" \
"(Hardware w|W)atchpoint ${decimal}: -location a\\\[28\\\]" \
"set watch on a"
gdb_test "watch -location b\[28\]" \
"(Hardware w|W)atchpoint ${decimal}: -location b\\\[28\\\]" \
"set watchpoint on b"
gdb_test "watch -location c\[28\]" \
"(Hardware w|W)atchpoint ${decimal}: -location c\\\[28\\\]" \
"set watchpoint on c"
gdb_test "continue" \
[multi_line \
"Continuing\\." \
"" \
"Hardware watchpoint ${decimal}: -location a\\\[28\\\]" \
"" \
"Old value = 104 'h'" \
"New value = 0 '\\\\000'" \
"$hex in main \\(\\) at .*aarch64-mops-watchpoint.c:$decimal" \
"${decimal}\\s+__asm__ volatile \\(\"setp.*\\\\n\\\\t\""] \
"continue until set watchpoint hits"
gdb_test "continue" \
[multi_line \
"Continuing\\." \
"" \
"Hardware watchpoint ${decimal}: -location b\\\[28\\\]" \
"" \
"Old value = 101 'e'" \
"New value = 114 'r'" \
"$hex in main \\(\\) at .*aarch64-mops-watchpoint.c:$decimal" \
"${decimal}\\s+__asm__ volatile \\(\"cpyp.*\\\\n\\\\t\""] \
"continue until cpy watchpoint hits"
gdb_test "continue" \
[multi_line \
"Continuing\\." \
"" \
"Hardware watchpoint ${decimal}: -location c\\\[28\\\]" \
"" \
"Old value = 100 'd'" \
"New value = 114 'r'" \
"$hex in main \\(\\) at .*aarch64-mops-watchpoint.c:$decimal" \
"${decimal}\\s+__asm__ volatile \\(\"cpyfp.*\\\\n\\\\t\""] \
"continue until cpyf watchpoint hits"

View File

@@ -123,10 +123,12 @@ proc make_val_cast {lang signed bits val} {
return "$val as ${sign_prefix}$bits"
} else {
# C-like cast.
if {$signed} {
if {!$signed} {
set sign_prefix "unsigned "
} elseif {$lang == "opencl"} {
set sign_prefix ""
} else {
set sign_prefix "un"
set sign_prefix "signed "
}
if {$bits == 8} {
set type "char"
@@ -143,7 +145,7 @@ proc make_val_cast {lang signed bits val} {
} else {
error "$lang: unsupported bits"
}
return "(${sign_prefix}signed $type) $val"
return "(${sign_prefix}$type) $val"
}
}
@@ -178,7 +180,7 @@ proc test_shifts {} {
"unknown" "ada" "modula-2" "pascal" "fortran"
}
if {[lsearch -exact $skip_langs $lang] >= 0} {
return
continue
}
gdb_test_no_output "set language $lang"
@@ -344,8 +346,11 @@ proc test_shifts {} {
with_test_prefix "rsh neg lhs" {
test_shift $lang "print -1 >> 0" " = -1"
test_shift $lang "print -1 >> 1" " = -1"
test_shift $lang "print -2 >> 1" " = -1"
test_shift $lang "print -3 >> 1" " = -2"
test_shift $lang "print -8 >> 1" " = -4"
test_shift $lang "print [make_int64 $lang -8] >> 1" " = -4"
test_rshift_tl $lang "print -8 >> 100" " = -1"
}
# Make sure an unsigned 64-bit value with high bit set isn't
@@ -360,6 +365,18 @@ proc test_shifts {} {
test_rshift_tl $lang \
"print -1 >> [make_uint64 $lang 0xffffffffffffffff]" " = -1"
}
# Check if shift value isn't silently truncated to 32bit.
with_test_prefix "lower-32bit-zero" {
test_lshift_tl $lang \
"print 1 << [make_uint64 $lang 0x100000000]" " = 0"
test_rshift_tl $lang \
"print 1 >> [make_uint64 $lang 0x100000000]" " = 0"
test_lshift_tl $lang \
"print -1 << [make_uint64 $lang 0x100000000]" " = 0"
test_rshift_tl $lang \
"print -1 >> [make_uint64 $lang 0x100000000]" " = -1"
}
}
}

View File

@@ -692,7 +692,7 @@ set show_conv_list \
{$_gdb_setting_str = <internal function _gdb_setting_str>} \
{$_gdb_setting = <internal function _gdb_setting>} \
{$_gdb_major = 15} \
{$_gdb_minor = 1} \
{$_gdb_minor = 2} \
{$_shell_exitsignal = void} \
{$_shell_exitcode = 0} \
}

View File

@@ -41,6 +41,8 @@ int large_2d_array[][10] = {
{90, 91, 92, 93, 94, 95, 96, 97, 98, 99}
};
char large_empty_string[100000] = "";
int
main ()
{

View File

@@ -240,3 +240,13 @@ with_test_prefix "with unlimited print elements" {
"value is not available" \
"output expression referring unavailable element from history"
}
gdb_test_no_output "set max-value-size 10000"
gdb_test_no_output "set print elements 200"
gdb_test "print large_empty_string" \
" = \\\{0 '\\\\000' <repeats 10000 times>, <unavailable> <repeats 90000 times>\\\}" \
"print large empty string which is not fully available"
gdb_test -nonl "output large_empty_string" \
"\\\{0 '\\\\000' <repeats 10000 times>, <unavailable> <repeats 90000 times>\\\}" \
"output large empty string which is not fully available"

View File

@@ -0,0 +1,35 @@
/* This testcase is part of GDB, the GNU debugger.
Copyright 2024 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
namespace ns {
class A {
public:
enum {
val1 = 1
};
};
enum class ec
{
val2 = 2,
};
}
int u1 = ns::A::val1;
int u2 = (int)ns::ec::val2;

View File

@@ -0,0 +1,54 @@
# Copyright 2024 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
require !readnow
load_lib dwarf.exp
# This test can only be run on targets which support DWARF-2 and use gas.
require dwarf2_support
standard_testfile main.c .cc
if { [prepare_for_testing "failed to prepare" $testfile \
[list $srcfile $srcfile2] {debug c++}] } {
return -1
}
require {string equal [have_index $binfile] ""}
set re_ws "\[ \t\]"
# Regression test for PR31900.
set val1 ns::A::val1
gdb_test_lines "maint print objfiles" \
"val1 has a parent" \
[multi_line \
"" \
"$re_ws+qualified:$re_ws+$val1" \
".*"]
gdb_test "print $val1" " = $val1"
# Regression test for PR32158.
set val2 ns::ec::val2
gdb_test_lines "maint print objfiles" \
"val2 has correct parent" \
[multi_line \
"" \
"$re_ws+qualified:$re_ws+$val2" \
".*"]
gdb_test "print $val2" " = $val2"

View File

@@ -65,6 +65,41 @@ Dwarf::assemble $asm_file {
}
}
}
cu {} {
DW_TAG_compile_unit {
{DW_AT_language @DW_LANG_C_plus_plus}
{DW_AT_name tmp.c}
{DW_AT_comp_dir /tmp}
} {
declare_labels integer_label forward
integer_label: DW_TAG_base_type {
{DW_AT_byte_size 4 DW_FORM_sdata}
{DW_AT_encoding @DW_ATE_signed}
{DW_AT_name int}
}
DW_TAG_enumeration_type {
{DW_AT_specification :$forward}
} {
DW_TAG_enumerator {
{DW_AT_name val1}
{DW_AT_const_value 1 DW_FORM_sdata}
}
}
DW_TAG_namespace {
{DW_AT_name ns}
} {
forward: DW_TAG_enumeration_type {
{DW_AT_name e}
{DW_AT_type :$integer_label}
{DW_AT_declaration 1 flag}
}
}
}
}
}
if { [prepare_for_testing "failed to prepare" ${testfile} \

View File

@@ -65,7 +65,7 @@ proc py_remove_all_disassemblers {} {
#
# Each different disassembler tests some different feature of the
# Python disassembler API.
set nop "(nop|nop\t0)"
set nop "(nop|nop\t0|[string_to_regexp nop\t{0}])"
set unknown_error_pattern "unknown disassembler error \\(error = -1\\)"
set addr_pattern "\r\n=> ${curr_pc_pattern} <\[^>\]+>:\\s+"
set base_pattern "${addr_pattern}${nop}"

View File

@@ -46,7 +46,7 @@ def check_building_disassemble_result():
def is_nop(s):
return s == "nop" or s == "nop\t0"
return s == "nop" or s == "nop\t0" or s == "nop\t{0}"
# Remove all currently registered disassemblers.

View File

@@ -118,6 +118,11 @@ main ()
c.a_method (0, 1);
c.a_const_method (0, 1);
C::a_static_method (0, 1);
struct Local { int g; } l;
l.g = 5;
typedef int IntType;
IntType it = 6;
#endif
enum E e;

View File

@@ -85,6 +85,12 @@ proc test_fields {lang} {
gdb_test "python print (gdb.parse_and_eval ('C::a_static_method').type.fields ()\[0\].type)" "int"
gdb_test "python print (gdb.parse_and_eval ('C::a_static_method').type.fields ()\[1\].type)" "char"
gdb_test "python print (gdb.parse_and_eval ('c')\['a_static_method'\].type.fields ()\[0\].type)" "int"
# Test function-local types.
gdb_test "python print (gdb.lookup_type ('main()::Local'))" "Local"
gdb_test "python print (gdb.lookup_type ('main()::Local').fields ()\[0\].type)" "int"
gdb_test "python print (gdb.lookup_type ('main()::IntType'))" "IntType"
gdb_test "python print (gdb.lookup_type ('main()::IntType').target ())" "int"
}
# Test normal fields usage in structs.

View File

@@ -0,0 +1,69 @@
# Copyright 2024 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Check that python sys.exit makes gdb exit, with the correct exit status.
require allow_python_tests
# Have this code in a proc avoids clashing with runtest variable exit_status.
proc do_test { n {expected_exit_status ""} {msg ""}} {
if { $expected_exit_status == "" } {
set expected_exit_status $n
}
with_test_prefix $n {
clean_restart
# Regression test for PR python/31946.
set seen_message 0
gdb_test_multiple "python sys.exit ($n)" "python sys.exit" {
-re "\r\n$msg\r\n" {
set seen_message 1
exp_continue
}
eof {
set wait_status [wait -i $::gdb_spawn_id]
clear_gdb_spawn_id
verbose -log "GDB process exited with wait status $wait_status"
set os_error [lindex $wait_status 2]
set exit_status [lindex $wait_status 3]
gdb_assert \
{ $os_error == 0 \
&& $exit_status == $expected_exit_status } \
$gdb_test_name
if { $msg != "" } {
gdb_assert { $seen_message }
}
}
}
}
}
# Test sys.exit (<int>).
do_test 0
do_test 1
do_test 2
# Test sys.exit (None).
do_test None 0
# Test sys.exit (<string>).
do_test {"Error Message"} 1 "Error Message"
do_test {""} 1

View File

@@ -0,0 +1,78 @@
/* This test program is part of GDB, the GNU debugger.
Copyright 2024 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <string.h>
#define INITIAL_STRING "Initial fill value."
#define NEW_STRING "Just a test string."
#define BUF_SIZE sizeof(NEW_STRING)
int
main (void)
{
char dest[BUF_SIZE] = INITIAL_STRING;
char source[BUF_SIZE] = NEW_STRING;
register char *p asm ("x19");
register char *q asm ("x20");
register long size asm ("x21");
register long zero asm ("x22");
p = dest;
size = BUF_SIZE;
zero = 0;
/* Before setp. */
/* memset implemented in MOPS instructions. */
__asm__ volatile ("setp [%0]!, %1!, %2\n\t"
"setm [%0]!, %1!, %2\n\t"
"sete [%0]!, %1!, %2\n\t"
: "+&r"(p), "+&r"(size)
: "r"(zero)
: "memory");
/* After sete. */
p = dest;
q = source;
size = BUF_SIZE;
memcpy (dest, INITIAL_STRING, sizeof (dest));
/* Before cpyp. */
/* memmove implemented in MOPS instructions. */
__asm__ volatile ("cpyp [%0]!, [%1]!, %2!\n\t"
"cpym [%0]!, [%1]!, %2!\n\t"
"cpye [%0]!, [%1]!, %2!\n\t"
: "+&r" (p), "+&r" (q), "+&r" (size)
:
: "memory");
/* After cpye. */
p = dest;
q = source;
size = BUF_SIZE;
memcpy (dest, INITIAL_STRING, sizeof (dest));
/* Before cpyfp. */
/* memcpy implemented in MOPS instructions. */
__asm__ volatile ("cpyfp [%0]!, [%1]!, %2!\n\t"
"cpyfm [%0]!, [%1]!, %2!\n\t"
"cpyfe [%0]!, [%1]!, %2!\n\t"
: "+&r" (p), "+&r" (q), "+&r" (size)
:
: "memory");
/* After cpyfe. */
p = dest;
return 0;
}

View File

@@ -0,0 +1,186 @@
# Copyright 2024 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Test instruction record for AArch64 FEAT_MOPS instructions.
# Based on gdb.reverse/ppc_record_test_isa_3_1.exp
#
# The basic flow of the record tests are:
# 1) Stop before executing the instructions of interest. Record
# the initial value of the registers that the instruction will
# change, i.e. the destination register.
# 2) Execute the instructions. Record the new value of the
# registers that changed.
# 3) Reverse the direction of the execution and execute back to
# just before the instructions of interest. Record the final
# value of the registers of interest.
# 4) Check that the initial and new values of the registers are
# different, i.e. the instruction changed the registers as expected.
# 5) Check that the initial and final values of the registers are
# the same, i.e. GDB record restored the registers to their
# original values.
require allow_aarch64_mops_tests
standard_testfile
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
[list debug additional_flags=-march=armv9.3-a]] } {
return -1
}
if ![runto_main] {
return -1
}
gdb_test_no_output "record full"
foreach_with_prefix insn_prefix {"set" "cpy" "cpyf"} {
global decimal hex
set before_seq [gdb_get_line_number "Before ${insn_prefix}p"]
set after_seq [gdb_get_line_number "After ${insn_prefix}e"]
gdb_test "break $before_seq" \
"Breakpoint $decimal at $hex: file .*/aarch64-mops.c, line $decimal\\." \
"break before instruction sequence"
gdb_continue_to_breakpoint "about to execute instruction sequence" \
[multi_line ".*/aarch64-mops.c:$decimal" \
"$decimal\[ \t\]+__asm__ volatile \\(\"${insn_prefix}p \[^\r\n\]+\""]
# Depending on the compiler, the line number information may put GDB a few
# instructions before the beginning of the asm statement.
arrive_at_instruction "${insn_prefix}p"
# Add a breakpoint that we're sure is at the prologue instruction.
gdb_test "break *\$pc" \
"Breakpoint $decimal at $hex: file .*/aarch64-mops.c, line $decimal\\." \
"break at prologue instruction"
# Record the initial memory and register values.
set dest_initial [get_valueof "/x" "dest" "unable to read initial" \
"get dest initial value"]
set x19_initial [capture_command_output "info register x19" ""]
set x21_initial [capture_command_output "info register x21" ""]
# The set instructions use the ZERO variable, but not Q nor SOURCE,
# and the other instructions are the opposite.
if {[string compare $insn_prefix "set"] == 0} {
set x22_initial [capture_command_output "info register x22" ""]
} else {
set x20_initial [capture_command_output "info register x20" ""]
set source_initial [get_valueof "/x" "source" "unable to read initial" \
"get source initial value"]
}
gdb_test "break $after_seq" \
"Breakpoint $decimal at $hex: file .*/aarch64-mops.c, line $decimal\\." \
"break after instruction sequence"
gdb_continue_to_breakpoint "executed instruction sequence" \
[multi_line ".*/aarch64-mops.c:$decimal" "$decimal\[ \t\]+p = dest;"]
# Record the new memory and register values.
set dest_new [get_valueof "/x" "dest" "unable to read new" \
"get dest new value"]
set x19_new [capture_command_output "info register x19" ""]
set x21_new [capture_command_output "info register x21" ""]
if {[string compare $insn_prefix "set"] == 0} {
set x22_new [capture_command_output "info register x22" ""]
} else {
set x20_new [capture_command_output "info register x20" ""]
set source_new [get_valueof "/x" "source" "unable to read new" \
"get source new value"]
}
# Execute in reverse to before the instruction sequence.
gdb_test_no_output "set exec-direction reverse"
gdb_continue_to_breakpoint "reversed execution of instruction sequence" \
[multi_line ".*/aarch64-mops.c:$decimal" \
"$decimal\[ \t\]+__asm__ volatile \\(\"${insn_prefix}p \[^\r\n\]+\""]
# Record the final memory and register values.
set dest_final [get_valueof "/x" "dest" "unable to read final" \
"get dest final value"]
set x19_final [capture_command_output "info register x19" ""]
set x21_final [capture_command_output "info register x21" ""]
if {[string compare $insn_prefix "set"] == 0} {
set x22_final [capture_command_output "info register x22" ""]
} else {
set x20_final [capture_command_output "info register x20" ""]
set source_final [get_valueof "/x" "source" "unable to read final" \
"get source final value"]
}
# Check initial and new values of dest are different.
gdb_assert [string compare $dest_initial $dest_new] \
"check dest initial value versus dest new value"
# Check initial and new values of x19 are different.
gdb_assert [string compare $x19_initial $x19_new] \
"check x19 initial value versus x19 new value"
# Check initial and new values of x21 are different.
gdb_assert [string compare $x21_initial $x21_new] \
"check x21 initial value versus x21 new value"
if {[string compare $insn_prefix "set"] == 0} {
# Check initial and new values of x22 are the same.
# The register with the value to set shouldn't change.
gdb_assert ![string compare $x22_initial $x22_new] \
"check x22 initial value versus x22 new value"
} else {
# Check initial and new values of x20 are different.
gdb_assert [string compare $x20_initial $x20_new] \
"check x20 initial value versus x20 new value"
# Check initial and new values of source are the same.
gdb_assert ![string compare $source_initial $source_new] \
"check source initial value versus source new value"
}
# Check initial and final values of dest are the same.
gdb_assert ![string compare $dest_initial $dest_final] \
"check dest initial value versus dest final value"
# Check initial and final values of x19 are the same.
gdb_assert ![string compare $x19_initial $x19_final] \
"check x19 initial value versus x19 final value"
# Check initial and final values of x21 are the same.
gdb_assert ![string compare $x21_initial $x21_final] \
"check x21 initial value versus x21 final value"
if {[string compare $insn_prefix "set"] == 0} {
# Check initial and final values of x22 are the same.
gdb_assert ![string compare $x22_initial $x22_final] \
"check x22 initial value versus x22 final value"
} else {
# Check initial and final values of x20 are the same.
gdb_assert ![string compare $x20_initial $x20_final] \
"check x20 initial value versus x20 final value"
# Check initial and final values of source are the same.
gdb_assert ![string compare $source_initial $source_final] \
"check source initial value versus source final value"
}
# Restore forward execution and go to end of recording.
gdb_test_no_output "set exec-direction forward"
gdb_test "record goto end" \
[multi_line \
"Go forward to insn number $decimal" \
"#0 main \\(\\) at .*/aarch64-mops.c:$decimal" \
"$decimal\[ \t\]+p = dest;"]
}

View File

@@ -69,6 +69,8 @@ with_timeout_factor 10 {
gdb_test "kill" "" "kill process, prepare to debug log file" \
"Kill the program being debugged\\? \\(y or n\\) " "y"
clean_restart ${binfile}
gdb_test "record restore $precsave" \
"Restored records from core file .*" \
"reload core file"

View File

@@ -848,6 +848,44 @@ proc gdb_continue_to_breakpoint {name {location_pattern .*}} {
}]
}
# Check whether GDB is stopped at the given instruction.
# INSTRUCTION should be just its mnemonic, without any arguments.
proc is_at_instruction { instruction } {
global gdb_prompt hex
set test "pc points to $instruction"
gdb_test_multiple {x/i $pc} $test {
-re -wrap "=> $hex \[^\r\n\]+:\t$instruction\t\[^\r\n\]+" {
return 1
}
-re "\r\n$gdb_prompt $" {
return 0
}
}
return 0
}
# Single-steps GDB until it arrives at the given instruction.
# INSTRUCTION should be just its mnemonic, without any arguments.
proc arrive_at_instruction { instruction } {
set count 0
while { [is_at_instruction $instruction] != 1 } {
gdb_test -nopass "stepi" "\[^\r\n\]+" \
"stepi #$count to reach $instruction"
incr count
if { $count > 50 } {
fail "didn't reach $instruction"
return 0
}
}
return 1
}
# gdb_internal_error_resync:
#
@@ -4496,6 +4534,67 @@ proc aarch64_supports_sme_svl { length } {
return 1
}
# Run a test on the target to see if it supports AArch64 MOPS (Memory
# Operations) extensions. Return 1 if so, 0 if it does not. Note this
# causes a restart of GDB.
gdb_caching_proc allow_aarch64_mops_tests {} {
global srcdir subdir gdb_prompt inferior_exited_re
set me "allow_aarch64_mops_tests"
if { ![is_aarch64_target]} {
return 0
}
# ARMv9.3-A contains the MOPS extension. The test program doesn't use it,
# but take the opportunity to check whether the toolchain knows about MOPS.
set compile_flags "{additional_flags=-march=armv9.3-a}"
# Compile a program that tests the MOPS feature.
set src {
#include <stdbool.h>
#include <sys/auxv.h>
#ifndef HWCAP2_MOPS
#define HWCAP2_MOPS (1UL << 43)
#endif
int main() {
bool mops_supported = getauxval (AT_HWCAP2) & HWCAP2_MOPS;
return !mops_supported;
}
}
if {![gdb_simple_compile $me $src executable $compile_flags]} {
return 0
}
# Compilation succeeded so now run it via gdb.
clean_restart $obj
gdb_run_cmd
gdb_expect {
-re ".*$inferior_exited_re with code 01.*${gdb_prompt} $" {
verbose -log "\n$me mops support not detected"
set allow_mops_tests 0
}
-re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
verbose -log "\n$me: mops support detected"
set allow_mops_tests 1
}
default {
warning "\n$me: default case taken"
set allow_mops_tests 0
}
}
gdb_exit
remote_file build delete $obj
verbose "$me: returning $allow_mops_tests" 2
return $allow_mops_tests
}
# A helper that compiles a test case to see if __int128 is supported.
proc gdb_int128_helper {lang} {
return [gdb_can_simple_compile "i128-for-$lang" {

View File

@@ -1086,7 +1086,7 @@ type_length_bits (type *type)
static bool
check_valid_shift_count (enum exp_opcode op, type *result_type,
type *shift_count_type, const gdb_mpz &shift_count,
unsigned long &nbits)
ULONGEST &nbits)
{
if (!shift_count_type->is_unsigned ())
{
@@ -1112,7 +1112,7 @@ check_valid_shift_count (enum exp_opcode op, type *result_type,
}
}
nbits = shift_count.as_integer<unsigned long> ();
nbits = shift_count.as_integer<ULONGEST> ();
if (nbits >= type_length_bits (result_type))
{
/* In Go, shifting by large amounts is defined. Be silent and
@@ -1291,7 +1291,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
case BINOP_LSH:
{
unsigned long nbits;
ULONGEST nbits;
if (!check_valid_shift_count (op, result_type, type2, v2, nbits))
v = 0;
else
@@ -1301,9 +1301,23 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
case BINOP_RSH:
{
unsigned long nbits;
ULONGEST nbits;
if (!check_valid_shift_count (op, result_type, type2, v2, nbits))
v = 0;
{
/* Pretend the too-large shift was decomposed in a
number of smaller shifts. An arithmetic signed
right shift of a negative number always yields -1
with such semantics. This is the right thing to
do for Go, and we might as well do it for
languages where it is undefined. Also, pretend a
shift by a negative number was a shift by the
negative number cast to unsigned, which is the
same as shifting by a too-large number. */
if (v1 < 0 && !result_type->is_unsigned ())
v = -1;
else
v = 0;
}
else
v = v1 >> nbits;
}

View File

@@ -1716,10 +1716,6 @@ value::record_latest ()
fetch_lazy ();
}
ULONGEST limit = m_limited_length;
if (limit != 0)
mark_bytes_unavailable (limit, m_enclosing_type->length () - limit);
/* Mark the value as recorded in the history for the availability check. */
m_in_history = true;
@@ -3931,6 +3927,11 @@ value::fetch_lazy_memory ()
if (len > 0)
read_value_memory (this, 0, stack (), addr,
contents_all_raw ().data (), len);
/* If only part of an array was loaded, mark the rest as unavailable. */
if (m_limited_length > 0)
mark_bytes_unavailable (m_limited_length,
m_enclosing_type->length () - m_limited_length);
}
/* See value.h. */

View File

@@ -1 +1 @@
15.0.50.DATE-git
15.2

View File

@@ -180,6 +180,12 @@ x86_linux_nat_target::read_description ()
xcr0 = xstateregs[(I386_LINUX_XSAVE_XCR0_OFFSET
/ sizeof (uint64_t))];
#ifdef __x86_64__
/* No MPX on x32. */
if (is_x32)
xcr0 &= ~X86_XSTATE_MPX;
#endif
m_xsave_layout = x86_fetch_xsave_layout (xcr0, x86_xsave_length ());
}
}