Commit Graph

119705 Commits

Author SHA1 Message Date
Tom de Vries
60202b0ced [gdb/testsuite] Fix gdb.python/py-mi-cmd.exp with python 3.13
When running test-case gdb.python/py-mi-cmd.exp with python 3.13, I run into:
...
Expecting: ^(-pycmd exp[^M
]+)?(.*&"Traceback \(most recent call last\):.."^M
&"[^^M
]+py-mi-cmd.py[^^M
]+"^M
&"[^^M
]+raise gdb.GdbError\(\).."^M
&"gdb.GdbError.."^M
\^error,msg="Error occurred in Python\."[^M
]+[(]gdb[)] ^M
[ ]*)
-pycmd exp^M
&"Traceback (most recent call last):\n"^M
&"  File \"py-mi-cmd.py\", line 76, in invoke\n    raise gdb.GdbError()\n"^M
&"gdb.GdbError\n"^M
^error,msg="Error occurred in Python."^M
(gdb) ^M
FAIL: gdb.python/py-mi-cmd.exp: -pycmd exp (unexpected output)
...

In contrast, with python 3.12 I have:
...
Expecting: ^(-pycmd exp[^M
]+)?(.*&"Traceback \(most recent call last\):.."^M
&"[^^M
]+py-mi-cmd.py[^^M
]+"^M
&"[^^M
]+raise gdb.GdbError\(\).."^M
&"gdb.GdbError.."^M
\^error,msg="Error occurred in Python\."[^M
]+[(]gdb[)] ^M
[ ]*)
-pycmd exp^M
&"Traceback (most recent call last):\n"^M
&"  File \"py-mi-cmd.py\", line 76, in invoke\n"^M
&"    raise gdb.GdbError()\n"^M
&"gdb.GdbError\n"^M
^error,msg="Error occurred in Python."^M
(gdb) ^M
PASS: gdb.python/py-mi-cmd.exp: -pycmd exp
...

To make it easier to understand what we're looking at, let's take this out of
the mi interpreter context and use the cli interpreter:
...
$ gdb -q -batch -ex "set trace-commands on" -x gdb.in
+set python print-stack full
+source py-mi-cmd.py
+python pycmd1('-pycmd')
+python pycmd1.invoke (pycmd1, ["exp"])
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "py-mi-cmd.py", line 76, in invoke
    raise gdb.GdbError()
gdb.GdbError
gdb.in:4: Error in sourced command file:
Error occurred in Python.
...

Interestingly, this is what we're seeing with both python 3.12 and 3.13.

The difference between the python versions is that:
- with python 3.12 each line is printed by itself, and
- with python 3.13 two particular lines are printed toghether.

With the cli interpreter, that makes no difference, because the '\n' is
interpreted.

But with the mi interpreter, that causes a difference in output because the
'\n' is not interpreted, but rather printed literally.

Fix this by accepting the new output in addition to the old one.

Tested on aarch64-linux.

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>

PR testsuite/31913
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31913
2024-08-20 15:57:36 +02:00
Vladimir Mezentsev
4456cb827f gprofng: add hardware counters for Appliedmicro processor
gprofng/ChangeLog
2024-08-15  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>.

	* common/hwc_cpus.h: New constant for Appliedmicro processor.
	* common/hwctable.c: Add the hwc table for Appliedmicro processor.
	* src/hhwc_arm64_amcc.h: New file.
	* src/collctrl.cc (read_int): Use strtol instead of atoi.
2024-08-19 17:26:20 -07:00
GDB Administrator
1b32f601b1 Automatic date update in version.in 2024-08-20 00:00:12 +00:00
Indu Bhagat
5ffe413283 gas: ginsn: x86: pacify Wmaybe-uininitialized compiler warning
Fix PR binutils/32091

After commit d56083b504, some gcc versions
may warn about unintialized usage of ginsn_func.  Albeit false positive,
adapt the code to escape the warning.

gas/config/
	* tc-i386-ginsn.c (x86_ginsn_indirect_branch): Early exit if
	unexpected args.
2024-08-19 11:08:39 -07:00
Andreas Schwab
03b09d2e34 Fix m68k OS ABI sniffer
Do not override the generic OS ABI sniffer.

Fixes: 3eba3a011a ("Various m68k fixes for gdb")
2024-08-19 19:28:49 +02:00
Tom Tromey
8be66a3708 Ensure gdb.ada/multiarray.exp runs in both modes
gdb.ada/multiarray.exp has a loop that looks like it should run the
test in both 'all' and 'minimal' encodings mode.  However, the body of
the loop doesn't actually use the 'flags' variable.  This was an
oversight in the original commit.
2024-08-19 10:48:18 -06:00
Nick Clifton
73fbc50f4b Remove Walter Lee as maintainer for Tile Gx and Tile Pro 2024-08-19 16:34:29 +01:00
Andrew Burgess
195795b0fd gdb: fix a target: prefix issue in find_separate_debug_file
Following on from the previous commit, this commit fixes the two KFAIL
in gdb.base/sysroot-debug-lookup.exp when not using the
native-extended-gdbserver board.

The failures in this test, when using the 'unix' board, are logged as
bug PR gdb/31804.  The problem appears to be caused by the use of the
child_path function in find_separate_debug_file.

What happens on the 'unix' board is that the file is specified to GDB
with a target: prefix, however GDB spots that the target filesystem is
local to GDB and so opens the file without a target: prefix.  When we
call into find_separate_debug_file the DIR and CANON_DIR arguments,
which are computed from the objfile_name() no longer have a target:
prefix.

However, in this test if the file was opened with a target: prefix,
then the sysroot also has a target: prefix.  When child_path is called
it looks for a common prefix between CANON_DIR (from the objfile_name)
and the sysroot.  However, the sysroot still has the target: prefix,
which means the child_path() call fails and returns nullptr.

What I think we need to do is this: if the sysroot has a target:
prefix, and the target filesystem is local to GDB, then we should
strip the target: prefix from the sysroot, just as we do when opening
a file (see gdb_bfd_open in gdb_bfd.c).

Now, when we make the child_path() call neither the sysroot nor
CANON_DIR will have a target: prefix, the child_path() call will
succeed, and GDB will correctly find the debug information.

There is just one remaining issue, the last path we look in when
searching for debug information is built by starting with the sysroot,
then adding the debug directory, see this line:

  debugfile = path_join (target_prefix_str, root.c_str (),
                         debugdir.get (), base_path, debuglink);

The target_prefix_str is set to target: if DIR has a target: prefix,
and DIR should have a target: prefix if the file we're looking for was
opened with a target: prefix.  However, in our case the file was in a
local filesystem so GDB stripped the prefix off.

The sysroot however, does have the target: prefix, and the test is
expecting to see GDB look within a file with the target: prefix.

Given that the above line is about looking within a sub-directory of
the sysroot, I think we should not be stripping the target: prefix off
the sysroot path (as we do when building ROOT), instead, we should, in
this case, not use TARGET_PREFIX_STR, and instead just use GDB's
sysroot as it is (in this case with the target: prefix).

With these fixes in place I now see no failures when using the 'unix',
'native-gdbserver', or 'native-extended-gdbserver' boards with this
test, and the KFAILs can be removed.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31804
2024-08-19 15:02:56 +01:00
Andrew Burgess
ea4c968ce5 gdb: avoid '//' in filenames when searching for debuginfo
I spotted that the gdb.base/sysroot-debug-lookup.exp test that I added
recently actually had a KPASS when run with the
native-extended-gdbserver board.  This was an oversight when adding
the test.

The failures in this test, when using the 'unix' board, are logged as
bug PR gdb/31804.  The problem appears to be caused by the use of the
child_path function in find_separate_debug_file.

What happens on the 'unix' board is that the file is specified to GDB
with a target: prefix, however GDB spots that the target filesystem is
local to GDB and so opens the file without a target: prefix.  When we
call into find_separate_debug_file the DIR and CANON_DIR arguments,
which are computed from the objfile_name() no longer have a target:
prefix.

However, in this test if the file was opened with a target: prefix,
then the sysroot also has a target: prefix.  When child_path is called
it looks for a common prefix between CANON_DIR (from the objfile_name)
and the sysroot.  However, the sysroot still has the target: prefix,
which means the child_path() call fails and returns nullptr.

What happens in the native-extended-gdbserver case is that GDB doesn't
see the target filesystem as local.  Now the filename retains the
target: prefix, which means that in the child_path() call both the
sysroot and the CANON_DIR have a target: prefix, and so the
child_path() call succeeds.  This allows GDB to progress, try some
additional paths, and then find the debug information.

So, this commit changes gdb.base/sysroot-debug-lookup.exp to expect
the test to succeed when using the native-extended-gdbserver protocol.

This leaves one KFAIL when using the native-extended-gdbserver board,
we find the debug information but (apparently) find it in the wrong
file.  What's happening is that when GDB builds the filename for the
debug information we end up with a '//' string as a directory
separator, the test regexp only expects a single separator.

Instead of just fixing the test regexp, I've updated the path_join
function in gdbsupport/pathstuff.{cc,h} to allow for absolute paths to
appear in the argument list after the first argument.  This means it's
now possible to do this:

  auto result = path_join ("/a/b/c", "/d/e/f");
  gdb_assert (result == "/a/b/c/d/e/f");

Additionally I've changed path_join so that it avoids adding
unnecessary directory separators.  In the above case when the two
paths were joined GDB only added a single separator between 'c' and
'd'.  But additionally, if we did this:

  auto result = path_join ("/a/b/c/", "/d/e/f");
  gdb_assert (result == "/a/b/c/d/e/f");

We'd still only get a single separator.

With these changes to path_join I can now make use of this function in
find_separate_debug_file.  With this done I now have no KFAIL when
using the native-extended-gdbserver board.

After this commit we still have 2 KFAIL when not using the
native-gdbserver and unix boards, these will be addressed in the next
commit.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31804

Reviewed-By: Keith Seitz <keiths@redhat.com>
2024-08-19 15:02:56 +01:00
Guinevere Larsen
a078084852 gdb: Fix printing frame when reversing out of a recursive call with clang
Commit bf2813aff8 introduced some logic to
not refresh the step frame id if it detects that the inferior is reverse
stepping out of a recursive call, so that we would still print frame
information once the inferior stops.

However, that logic was overly specific, and wouldn't be hit for
inferiors compiled with clang because clang adds line table entries that
aren't statements, making process_event_stop_test go through a different
branch on the relevant if statement.

Fix this by not making the code that detects "reversing out of a
recursion" an else clause to the previous if, but a standalone if block.

Approved-by: Kevin Buettner <kevinb@redhat.com>
2024-08-19 09:12:05 -03:00
GDB Administrator
d71c16aec2 Automatic date update in version.in 2024-08-19 00:00:29 +00:00
Tom de Vries
9747e37ed4 [gdb] Prune inferior after switching inferior
Usually with test-case gdb.python/py-progspace-events.exp I get:
...
(gdb) inferior 1^M
[Switching to inferior 1 [process 4116] (py-progspace-events)]^M
[Switching to thread 1.1 (Thread 0xf77d0ce0 (LWP 4116))]^M
28      { /* Nothing.  */ }^M
(gdb) PASS: gdb.python/py-progspace-events.exp: inferior 1
step^M
FreeProgspaceEvent: <gdb.Progspace object at 0xabf4f850>^M
do_parent_stuff () at py-progspace-events.c:41^M
41        ++global_var;^M
(gdb) PASS: gdb.python/py-progspace-events.exp: step
...

But occasionally I run into the following FAIL:
...
(gdb) inferior 1^M
[Switching to inferior 1 [process 5199] (py-progspace-events)]^M
[Switching to thread 1.1 (Thread 0xf77d0ce0 (LWP 5199))]^M
28      { /* Nothing.  */ }^M
(gdb) FreeProgspaceEvent: <gdb.Progspace object at 0xabaf03a0>^M
FAIL: gdb.python/py-progspace-events.exp: inferior 1 (timeout)
...

This is caused by a race between the handling of an event, and the
"inferior 1" command.

In the passing case, the event is handled first.  During which prune_inferiors
is called, but it can't remove inferior 2, because it's still the current one.

In the failing case, the "inferior 1" command is handled first.  Then during
handling of the event, prune_inferiors is called, and it can remove inferior 2
because it's no longer the current one.

This looks like a test-case issue to me, but ISTM that we can do better: by
calling prune_inferiors asap, at the end of the "inferior 1" command, we
stabilize the moment when the inferior is removed:
...
(gdb) inferior 1^M
[Switching to inferior 1 [process 5199] (py-progspace-events)]^M
[Switching to thread 1.1 (Thread 0xf77d0ce0 (LWP 5199))]^M
28      { /* Nothing.  */ }^M
FreeProgspaceEvent: <gdb.Progspace object at 0xabaf03a0>^M
(gdb) PASS: gdb.python/py-progspace-events.exp: inferior 1
...

This also allows us to simplify the test-case by removing the step command,
which is no longer required to trigger the pruning of the inferior.

Tested on x86_64-linux.

Approved-by: Kevin Buettner <kevinb@redhat.com>

PR gdb/31440
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31440
2024-08-18 20:51:29 +02:00
GDB Administrator
f9b44496e6 Automatic date update in version.in 2024-08-18 00:00:17 +00:00
Nick Clifton
baeb0a958c Update release readme after making 2.43.1 release 2024-08-17 19:14:44 +01:00
GDB Administrator
fe70001da2 Automatic date update in version.in 2024-08-17 00:00:27 +00:00
Tom Tromey
807f697b17 Fix DAP failure when fetching global variables
The relatively new "globals" scope code in DAP has a fairly obvious
bug -- the fetch_one_child method should return a tuple with two
elements, but instead just returns the variable's value.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32029
Reviewed-By: Tom de Vries <tdevries@suse.de>
2024-08-16 08:47:00 -06:00
Tom de Vries
798bb5cc53 [gdb/testsuite] Fix gdb.dwarf2/dw2-fixed-point.exp on arm-linux
With test-case gdb.dwarf2/dw2-fixed-point.exp on arm-linux I run into:
...
(gdb) PASS: gdb.dwarf2/dw2-fixed-point.exp: set lang ada
print pck.fp1_var^M
$1 = 0.3125^M
(gdb) FAIL: gdb.dwarf2/dw2-fixed-point.exp: print pck.fp1_var
...

The problem is that the thumb prologue analyzer overshoot, setting the
breakpoint for main after line 49:
...
    46  int
    47  main (void)
    48  {
    49    pck__fp1_var++;
...
and consequently we see the value of pck.fp1_var after line 49 instead of
before line 49.  This is PR tdep/31981.

Work around this by removing line 49 and all similar subsequent lines, which
turn out to be dead code.

Approved-By: Luis Machado <luis.machado@arm.com>

Tested on arm-linux.
2024-08-16 14:22:46 +02:00
Tom de Vries
51f38ebfc4 [gdb/testsuite] Fix gdb.arch/arm-single-step-kernel-helper.exp
On arm-linux I run into:
...
(gdb) p *kernel_user_helper_version^M
Cannot access memory at address 0xffff0ffc^M
(gdb) FAIL: gdb.arch/arm-single-step-kernel-helper.exp: check kernel helper version
...

What the test-case is trying to do, is to access a special address in the arm
linux kernel [1] using ptrace, which doesn't seem to work.

This is with kernel version 6.1.55.  Perhaps this used to work, but the kernel
was modified to be more strict with respect to access to this special address.

Fix this by making the inferior access that special address instead.

Tested on arm-linux.

Approved-By: Luis Machado <luis.machado@arm.com>

PR testsuite/32070
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32070

[1] https://www.kernel.org/doc/Documentation/arm/kernel_user_helpers.txt
2024-08-16 14:22:46 +02:00
Felix Willgerodt
bc737bc7fb gdb: Fix gdb.python/py-record-btrace.exp test
My previous patch

commit 8958aefd34 (HEAD)
Author: Felix Willgerodt <felix.willgerodt@intel.com>
Date:   Mon Feb 25 15:30:29 2019 +0100

    python: Add clear() to gdb.Record.

exposed a clear function for btrace data in python and added some tests
for it.  That caused a regression (PR 32086) when recording with bts.

This is reproducible even without my patch, when adding
"maintenance btrace clear" to the test.

When comparing the instructions that get recorded in both cases, the traces
are almost identical, just that the first 3 instructions are missing.

Before clear:

(gdb) record instruction-history 1,100
1	   0x0000555555555163 <main+12>:	movl   $0x0,-0x4(%rbp)
2	   0x000055555555516a <main+19>:	movl   $0x0,-0x8(%rbp)
3	   0x0000555555555171 <main+26>:	jmp    0x555555555184 <main+45>
4	   0x0000555555555184 <main+45>:	cmpl   $0x63,-0x4(%rbp)
5	   0x0000555555555188 <main+49>:	jle    0x555555555173 <main+28>
6	   0x0000555555555173 <main+28>:	mov    -0x8(%rbp),%eax
7	   0x0000555555555176 <main+31>:	mov    %eax,%edi
...

After clear:

(gdb) record instruction-history 1,100
1	   0x0000555555555184 <main+45>:	cmpl   $0x63,-0x4(%rbp)
2	   0x0000555555555188 <main+49>:	jle    0x555555555173 <main+28>
3	   0x0000555555555173 <main+28>:	mov    -0x8(%rbp),%eax
4	   0x0000555555555176 <main+31>:	mov    %eax,%edi
...

The GDB manual describes this behaviour already:

	maint btrace clear
	Discard the branch trace data. The data will be fetched anew and
	the branch trace will be recomputed when needed.

	This implicitly truncates the branch trace to a single branch trace
	buffer. When updating branch trace incrementally, the branch trace
	available to GDB may be bigger than a single branch trace buffer.

The test with BTS is updating the recorded trace incrementally.  After the
clear, the buffer of raw trace data available is not enough to recompute the
whole trace as it was before the clear(), and the first 3 instructions are
missing.

As increasing the buffer size for BTS didn't help, I propose to fix the test
by moving the testing of clear to the end of the test.

Approved-By: Tom de Vries <tdevries@suse.de>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32086
2024-08-16 11:07:21 +02:00
Jan Beulich
50e19e6e6c gas: don't open-code LEX_*NAME
... except in read.c's definition of lex_type[], where readbility would
otherwise suffer.
2024-08-16 08:35:16 +02:00
Jan Beulich
4b939bab12 opcodes/cgen: drop trailing whitespace also for cris
While 919b75f7e2 ("Trailing space in opcodes/ generated files") took
care of permanently zapping trailing whitespace, 5471128011
("opcodes: cris: move desc & opc files from sim/") then didn't enhance
the newly added code accordingly.
2024-08-16 08:34:50 +02:00
GDB Administrator
81e9e54636 Automatic date update in version.in 2024-08-16 00:00:17 +00:00
H.J. Lu
5e3c96bded Revert "Arm: correct macro use in gas testsuite"
This reverts commit cfa18744d4.

commit 6ae8a30d44
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Aug 9 11:59:31 2024 +0200

    gas: have scrubber retain more whitespace

has been reverted to fix PR gas/32073.
2024-08-15 09:49:33 -07:00
H.J. Lu
a1299dc71e Revert "bfin: correct macro use in gas testsuite"
This reverts commit a1b7023447.

commit 6ae8a30d44
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Aug 9 11:59:31 2024 +0200

    gas: have scrubber retain more whitespace

has been reverted to fix PR gas/32073.
2024-08-15 09:49:33 -07:00
H.J. Lu
5835278179 Revert "ia64: correct macro use in gas testsuite"
This reverts commit 2231ac9b9e.

commit 6ae8a30d44
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Aug 9 11:59:31 2024 +0200

    gas: have scrubber retain more whitespace

has been reverted to fix PR gas/32073.
2024-08-15 09:49:33 -07:00
H.J. Lu
4184396d58 Revert "MIPS: correct macro use in gas and ld testsuites"
This reverts commit c0e9aca554.

commit 6ae8a30d44
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Aug 9 11:59:31 2024 +0200

    gas: have scrubber retain more whitespace

has been reverted to fix PR gas/32073.
2024-08-15 09:49:33 -07:00
Tom Tromey
d47600c85d Add another constructor to scoped_restore_current_language
While working on something else, I noticed that this is relatively
common:

  scoped_restore_current_language save;
  set_language (something);

This patch adds a second constructor to
scoped_restore_current_language to simplify this idiom.

Reviewed-By: Tom de Vries <tdevries@suse.de>
2024-08-15 10:14:37 -06:00
Dimitar Dimitrov
5c8f918639 gas: pru: Fix trailing whitespace handling
With commit 6ae8a30d44, arguments followed
by a C-style comment ended up with a trailing space.  That extra space
character confused the PRU register name matching, leading to spurious
errors about unrecognized registers.  This affected existing code like
newlib's setjmp.s for pru.

Fix by stripping the trailing whitespace for any argument.

Even with 6ae8a30d44 reverted, this patch
is safe to be applied.

Successfully regression-tested with GCC and newlib testsuites for pru-unknown-elf.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2024-08-15 18:14:42 +03:00
H.J. Lu
a6f8fe0a9e lto: Don't include unused LTO archive members in output
When plugin_object_p is called by elf_link_is_defined_archive_symbol to
check if a symbol in archive is a real definition, set archive member
plugin_format to bfd_plugin_yes_unused to avoid including the unused LTO
archive members in linker output.  When plugin_object_p is called as
known used, call plugin claim_file if plugin_format is bfd_plugin_unknown
or bfd_plugin_yes_unused.

To get the proper support for archives with LTO common symbols with GCC,
the GCC fix for

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116361

is needed.

bfd/

	PR ld/32083
	* archures.c (bfd_arch_get_compatible): Treat bfd_plugin_yes_unused
	the same as bfd_plugin_yes.
	* elflink.c (elf_link_is_defined_archive_symbol): Likewise.
	* bfd.c (bfd_plugin_format): Add bfd_plugin_yes_unused.
	* plugin.c (try_claim): Try claim_file_v2 first.
	* bfd-in2.h: Regenerated.

ld/

	PR ld/32083
	* plugin.c (plugin_call_claim_file): Add an argument to return
	if LDPT_REGISTER_CLAIM_FILE_HOOK_V2 is used.
	(plugin_object_p): When KNOWN_USED is false, we call plugin
	claim_file if plugin_format is bfd_plugin_unknown and set
	plugin_format to bfd_plugin_yes_unused on LTO object.  When
	KNOWN_USED is true, we call plugin claim_file if plugin_format
	is bfd_plugin_unknown or bfd_plugin_yes_unused.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-15 03:54:11 -07:00
Vladimir Mezentsev
72e96189d8 gprofng: fix typo in src/collctrl.cc
gprofng/ChangeLog
2024-08-13  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	* src/collctrl.cc (read_cpuinfo): Fix typo.
2024-08-14 19:30:29 -07:00
GDB Administrator
6dac711fa2 Automatic date update in version.in 2024-08-15 00:00:35 +00:00
Tom Tromey
7e2d5218ff Log gdb version and configuration in DAP
I think it would be useful for gdb's DAP logs to come with the version
and configuration information.  This might make debugging some bug
reports a little simpler.
2024-08-14 10:11:29 -06:00
Tom Tromey
d1b72c2649 Notify Python when breakpoint symbol changes
A DAP user noticed that breakpoints set by address were never updated
to show their location after the DAP launch request.  It turns out
that gdb does not emit the breakpoint-modified event when this sort of
breakpoint is updated.

This patch changes gdb to notify the breakpoint-modified observer when
a breakpoint location's symbol changes.  This in turn causes the DAP
event to be emitted.

Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-08-14 10:08:58 -06:00
Tom Tromey
f238737757 Fix failure with C++ exceptions in DAP
While working on earlier patches, I noticed that the DAP C++ exception
test had some strange results in the log.  Digging into this, I found
that while the Ada catchpoints emit a "bkptno" field in the MI result,
the C++ ones do not -- but the DAP code was relying on this.

This patch fixes the problem by changing which field is examined, and
then updates the tests to verify this.

Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-08-14 10:08:58 -06:00
Tom Tromey
0c3bfda0ac Make DAP instruction breakpoints unverified
Currently, when a DAP client uses setInstructionBreakpoints, the
resulting breakpoints are created as "verified", even though there is
no symbol file and thus the breakpoint can't possibly have a source
location.

This patch changes the DAP code to assume that all breakpoints are
unverified before launch.

Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-08-14 10:08:58 -06:00
Tom Tromey
0341f2767a Introduce exec_mi_and_log for DAP
This adds a new exec_mi_and_log function that wraps gdb.execute_mi and
logs the command.  This can be handy when debugging DAP.

Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-08-14 10:08:58 -06:00
H.J. Lu
8be33827cd ld: Add an LTO test for common symbol override
Linker checks if a symbol in an archive member is a real definition, not
common, before including the archive member in the link output so that
only a real definition in archive will override the common symbol in
object file.  Add an LTO test to verify that a real definition in archive
overrides the common symbol in object file.

	* testsuite/ld-plugin/common-1.c: New file.
	* testsuite/ld-plugin/definition-1.c: Likewise.
	* testsuite/ld-plugin/lto.exp: Run common tests.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-14 08:40:18 -07:00
Tom Tromey
b5e0214aad Remove unnecessary default argument from initialize_block_iterator
I noticed that initialize_block_iterator has a default value for one
of its arguments, but this is not needed as this function has a single
caller that always passes all arguments.  This patch removes the
default.  Tested by rebuilding.
2024-08-14 06:54:00 -06:00
Xi Ruoyao
d15180ebed LoongArch: Fix DT_RELR and relaxation interaction
Due to the way BFD implements DT_RELR as a part of relaxation, if in a
relax trip size_relative_relocs has changed the layout, when
relax_section runs only the vma of the section being relaxed is
guaranteed to be updated.  Then bad thing can happen.  For example, when
linking an auxilary program _freeze_module in the Python 3.12.4 building
system (with PGO + LTO), before sizing the .relr.dyn section, the vma of
.text is 30560 and the vma of .rodata is 2350944; in the final
executable the vma of .text is 36704 and the vma of .rodata is 2357024.
The vma increase is expected because .relr.dyn is squashed somewhere
before .text.  But size_relative_relocs may see the state in which .text
is at 36704 but .rodata "is" still at 2350944.  Thus the distance
between .text and .rodata can be under-estimated and overflowing
R_LARCH_PCREL20_S2 reloc can be created.

To avoid this issue, if size_relative_relocs is updating the size of
.relr.dyn, just supress the normal relaxation in this relax trip.  In
this situation size_relative_relocs should have been demending the next
relax trip, so the normal relaxation can happen in the next trip.

I tried to make a reduced test case but failed.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
2024-08-14 17:45:02 +08:00
Xi Ruoyao
91e0b46551 LoongArch: Fix assertion failure with DT_RELR
In the DT_RELR implementation I missed a code path emiting relative
reloc entries.  Then the already packed relative reloc entries will be
(unnecessarily) pushed into .rela.dyn but we've not allocated the space
for them, triggering an assertion failure.

Unfortunately I failed to notice the issue until profiled bootstrapping
GCC with LTO and -Wl,-z,pack-relative-relocs.  The failure can be easily
triggered by linking a "hello world" program with -fprofile-generate and
LTO:

    $ PATH=$HOME/ld-test:$PATH gcc hw.c -fprofile-generate -Wl,-z,pack-relative-relocs -flto
    /home/xry111/git-repos/binutils-build/TEST/ld: BFD (GNU Binutils) 2.43.50.20240802 assertion fail ../../binutils-gdb/bfd/elfnn-loongarch.c:2628
    /home/xry111/git-repos/binutils-build/TEST/ld: BFD (GNU Binutils) 2.43.50.20240802 assertion fail ../../binutils-gdb/bfd/elfnn-loongarch.c:2628
    collect2: error: ld returned 1 exit status

And the reduced test case is just incredibly simple (included in the
patch) so it seems I'm just stupid enough to fail to detect it before.
Let's fix it now anyway.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
2024-08-14 17:45:02 +08:00
Jan Beulich
8c1cd86034 gas: correct .irpc handling with empty string
Following 69cab370cf ("gas: adjust handling of quotes for .irpc") the
closing quote was mistakenly treated as the first quoted character.
2024-08-14 11:25:34 +02:00
Jan Beulich
c0177034c9 x86: correct .insn with opcode extension and VEX/XOP/EVEX encoding
When VexVVVV handling was re-worked, .insn broke: When an opcode
extension is in use, VexVVVV_DST needs using now, as ModR/M.reg is
already occupied, matching what c8866e3ec5 ("x86: Drop using
extension_opcode to encode vvvv register") did.

While adding (bad) POP2 forms, also slightly adjust existing ones:
No need to use XMM registers, and no need to specify %r8 when really
%rax is meant twice (EVEX.vvvv not really being the culprit there, or
else EVEX.V' would also have needed mentioning).
2024-08-14 11:25:12 +02:00
Felix Willgerodt
3bf62223f0 btrace: Extend ptwrite event decoding.
Call the ptwrite filter function whenever a ptwrite event is decoded.
The returned string is written to the aux_data string table and a
corresponding auxiliary instruction is appended to the function segment.

Approved-By: Markus Metzger <markus.t.metzger@intel.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-08-14 11:20:57 +02:00
Felix Willgerodt
6be9971c93 btrace, python: Enable ptwrite filter registration.
By default GDB will be printing the hex payload of the ptwrite package as
auxiliary information.  To customize this, the user can register a ptwrite
filter function in python, that takes the payload and the PC as arguments and
returns a string which will be printed instead.  Registering the filter
function is done using a factory pattern to make per-thread filtering easier.

Approved-By: Markus Metzger <markus.t.metzger@intel.com>
2024-08-14 11:20:57 +02:00
Felix Willgerodt
77a33bb024 btrace, linux: Enable ptwrite packets.
Enable ptwrite in the PT config, if it is supported by the kernel.

Approved-By: Markus Metzger <markus.t.metzger@intel.com>
2024-08-14 11:20:56 +02:00
Felix Willgerodt
ccc480801b btrace, gdbserver: Add ptwrite to btrace_config_pt.
This enables gdb and gdbserver to communicate about ptwrite support.  If
ptwrite support would be enabled unconditionally, GDBs with older libipt
versions would break.

Approved-By: Markus Metzger <markus.t.metzger@intel.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-08-14 11:20:56 +02:00
Felix Willgerodt
8958aefd34 python: Add clear() to gdb.Record.
This function allows to clear the trace data from python, forcing to
re-decode the trace for successive commands.
This will be used in future ptwrite patches, to trigger re-decoding when
the ptwrite filter changes.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Markus Metzger <markus.t.metzger@intel.com>
2024-08-14 11:20:56 +02:00
Felix Willgerodt
bea4f6fac4 python: Introduce gdb.RecordAuxiliary class.
Auxiliary instructions are no real instructions and get their own object
class, similar to gaps. gdb.Record.instruction_history is now possibly a
list of gdb.RecordInstruction, gdb.RecordGap or gdb.RecordAuxiliary
objects.

This patch is in preparation for the new ptwrite feature, which is based on
auxiliary instructions.

Approved-By: Markus Metzger <markus.t.metzger@intel.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-08-14 11:20:56 +02:00
Felix Willgerodt
d5e1495d99 btrace: Handle stepping and goto for auxiliary instructions.
Print the auxiliary data when stepping. Don't allow to goto an auxiliary
instruction.

This patch is in preparation for the new ptwrite feature, which is based on
auxiliary instructions.

Approved-By: Markus Metzger <markus.t.metzger@intel.com>
2024-08-14 11:20:56 +02:00
Felix Willgerodt
4195751c5c btrace: Enable auxiliary instructions in record function-call-history.
Print the auxiliary data when a btrace_insn of type BTRACE_INSN_AUX
is encountered in the function-call-history.  Printing is
active by default, it can be silenced with the /a modifier.

This patch is in preparation for the new ptwrite feature, which is based on
auxiliary instructions.

Approved-By: Markus Metzger <markus.t.metzger@intel.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-08-14 11:20:56 +02:00