Commit graph

1550 commits

Author SHA1 Message Date
Tom de Vries
f41c2f5edd [gdb/testsuite] Remove debug prints in gdb_find_gdc
When running the gdb.dlang test-cases, and forcing gdb_find_gdc to be used
rather than dejagnu's copy (mimicing what happens with an older dejagnu
without find_gdc), I run into these debug prints:
...
Tool Root: /data/vries/gdb/leap-15-4/build
CC: gdc
...

Remove these.

Tested on x86_64-linux.
2023-04-22 11:04:11 +02:00
Andrew Burgess
393946658f gdb/testsuite: accept script argument for mi_make_breakpoint_pending
This commit changes mi_make_breakpoint_pending to accept the 'script'
and 'times' arguments.

I've then added a new test that makes use of 'scripts' in
gdb.mi/mi-pending.exp and gdb.mi/mi-dprintf-pending.exp.

There is already a test in gdb.mi/mi-pending.exp that uses the 'times'
argument -- previously this argument was being ignored, but is now
used.

Reviewed-By: Tom Tromey <tom@tromey.com>
2023-04-14 22:16:17 +01:00
Andrew Burgess
5be45917f4 gdb/testsuite: avoid {"} pattern in lib/mi-support.exp
Commit:

  commit c569a946f6
  Date:   Fri Mar 24 10:45:37 2023 +0100

      [gdb/testsuite] Fix unbalanced quotes in mi_expect_stop argument

Introduced the use of {"} in mi-support.exp.  There is absolutely
nothing wrong with this in any way.  However, this is causing my
editor to get the syntax highlighting of this file wrong after this
point.

Maybe the real answer is to use a better editor, or fix my current
editor.... but I'm hoping I can instead take the lazy approach of just
changing {"} to "\"", which is handled fine, and means exactly the
same as far as I understand it.

There should be no change in what is tested after this commit.

Reviewed-By: Tom Tromey <tom@tromey.com>
2023-04-14 22:16:16 +01:00
Andrew Burgess
f7c3b037c0 gdb/testsuite: fix typo gdb_name_name -> gdb_test_name
Spotted a small typo in gdb_breakpoint proc, we use $gdb_name_name
instead of $gdb_test_name in one place.  Fixed in this commit.
2023-04-11 11:59:30 +01:00
Tom de Vries
31c5028017 [gdb/testsuite] Add -q to INTERNAL_GDBFLAGS
Whenever we start gdb in the testsuite, we have the rather verbose:
...
$ gdb
GNU gdb (GDB) 14.0.50.20230405-git
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb)
...

This makes gdb.log longer than necessary and harder to read.

We do need to test that the output is produced, but that should be limited to
one or a few test-cases.

Fix this by adding -q to INTERNAL_GDBFLAGS, such that we simply have:
...
$ gdb -q
(gdb)
...

Tested on x86_64-linux.
2023-04-07 10:26:02 +02:00
Tom de Vries
89447229c7 [gdb/testsuite] Fix gdb.threads/threadapply.exp with editing off
With test-case gdb.threads/threadapply.exp and editing set to on, we have:
...
(gdb) define remove^M
Type commands for definition of "remove".^M
End with a line saying just "end".^M
>remove-inferiors 3^M
>end^M
(gdb)
...
but with editing set to off, we run into:
...
(gdb) define remove^M
Type commands for definition of "remove".^M
End with a line saying just "end".^M
>remove-inferiors 3^M
end^M
>(gdb) FAIL: gdb.threads/threadapply.exp: thread_set=all: try remove: \
  define remove (timeout)
...

The commands are issued by this test:
...
	gdb_define_cmd "remove" {
	    "remove-inferiors 3"
	}
...
which does:
- gdb_test_multiple "define remove", followed by
- gdb_test_multiple "remove-inferiors 3\nend".

Proc gdb_test_multiple has special handling for multi-line commands, which
splits it up into subcommands, and for each subcommand issues it and then
waits for the resulting prompt (the secondary prompt ">" for all but the last
subcommand).

However, that doesn't work as expected in this case because the initial
gdb_test_multiple "define remove" fails to match all resulting output, and
consequently the secondary prompt resulting from "define remove" is counted as
if it was the one resulting from "remove-inferiors 3".

Fix this by matching the entire output of "define remove", including the
secondary prompt.

Tested on x86_64-linux.

PR testsuite/30288
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30288
2023-03-31 17:15:37 +02:00
Tom Tromey
b28937b874 Remove version_at_least
version_at_least is a less capable variant of version_compare, so this
patch removes it.
2023-03-29 10:13:12 -06:00
Tom Tromey
1fa14231ef Rewrite version_compare and rust_at_least
This rewrites version_compare to allow the input lists to have
different lengths, then rewrites rust_at_least to use version_compare.
2023-03-29 10:13:12 -06:00
Tom Tromey
52fcd590bd Introduce rust_at_least helper proc
This adds a 'rust_at_least' helper proc, for checking the version of
the Rust compiler in use.  It then changes various tests to use this
with 'require'.
2023-03-29 10:13:12 -06:00
Tom Tromey
3e8154778b Put pretty-printers to_string output in varobj result
PR mi/11335 points out that an MI varobj will not display the result
of a pretty-printer's "to_string" method.  Instead, it always shows
"{...}".

This does not seem very useful, and there have been multiple
complaints about it over the years.  This patch changes varobj to emit
this string when possible, and updates the test suite.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=11335
2023-03-28 12:17:58 -06:00
Simon Marchi
7cd38c3c56 gdb/testsuite: allow "require" callbacks to provide a reason
When an allow_* proc returns false, it can be a bit difficult what check
failed exactly, if the procedure does multiple checks.  To make
investigation easier, I propose to allow the "require" callbacks to be
able to return a list of two elements: the zero/non-zero value, and a
reason string.

Use the new feature in allow_hipcc_tests to demonstrate it (it's also
where I hit actually hit this inconvenience).  On my computer (where GDB
is built with amd-dbgapi support but where I don't have a suitable GPU
target), I get:

    UNSUPPORTED: gdb.rocm/simple.exp: require failed: allow_hipcc_tests (no suitable amdgpu targets found)

vs before:

    UNSUPPORTED: gdb.rocm/simple.exp: require failed: allow_hipcc_tests

Change-Id: Id1966535b87acfcbe9eac99f49dc1196398c6578
Approved-By: Tom de Vries <tdevries@suse.de>
2023-03-28 11:53:40 -04:00
Tom de Vries
d7f0f10189 [gdb/testsuite] Allow gdb.rust/expr.exp without rust compiler
Proc allow_rust_tests returns 0 when there's no rust compiler, but that gives
the wrong answer for gdb.rust/expr.exp, which doesn't require it.

Fix this by using can_compile rust in the test-cases that need it, and just
returning 1 in allow_rust_tests.

Tested on x86_64-linux.
2023-03-28 10:22:48 +02:00
Tom de Vries
29dd2d27b2 [gdb/testsuite] Add can_compile rust
If I deinstall the rust compiler, I get:
...
gdb compile failed, default_target_compile: Can't find rustc --color never.
UNTESTED: gdb.rust/watch.exp: failed to prepare
...

Fix this by adding can_compile rust, and using it in allow_rust_tests, such
that we have instead:
...
UNSUPPORTED: gdb.rust/watch.exp: require failed: allow_rust_tests
...

Since the rest of the code in allow_rust_tests is also about availability of
the rust compiler, move it to can_compile.

Tested on x86_64-linux.
2023-03-28 10:22:48 +02:00
Tom de Vries
7ec0e36e9f [gdb/testsuite] Unsupport gdb.rust for remote host
With test-case gdb.rust/watch.exp and remote host I run into:
...
Executing on host: gcc   watch.rs  -g  -lm   -o watch    (timeout = 300)
  ...
ld:watch.rs: file format not recognized; treating as linker script
ld:watch.rs:1: syntax error
  ...
UNTESTED: gdb.rust/watch.exp: failed to prepare
...

The problem is that find_rustc returns "" for remote host, so we fall back to gcc, which fails.

Fix this by returning 0 in allow_rust_tests for remote host.

Tested on x86_64-linux.
2023-03-28 10:22:48 +02:00
Tom de Vries
7e28879b3d [gdb/testsuite] Fix gnat_runtime_has_debug_info for remote host
Fix gnat_runtime_has_debug_info for remote host by checking for
allow_ada_tests.

This fixes an error for test-case gdb.testsuite/gdb-caching-proc.exp and
remote host.

Tested on x86_64-linux.
2023-03-27 23:11:41 +02:00
Tom de Vries
b0af93ad2b [gdb/testsuite] Skip do_self_tests on remote host
In do_self_tests we try to find out the location of the gdb to debug, which
will then be copied and renamed to xgdb.

In principle, the host board specifies the location of GDB, on host.

With remote host, we could upload that gdb from host to build/target, but we
would miss the data directory (which is listed as the reason to skip
do_self_tests for remote target).

We could fix that by instead taking the gdb from build instead, but that
wouldn't work with installed testing.

It seems easier to just skip this on remote host.

It could be made to work for the "[is_remote host] && [is_remote target]
&& host == target" scenario (see board local-remote-host-native.exp), but
that doesn't seem worth the effort.

Tested on x86_64-linux.
2023-03-27 17:40:06 +02:00
Tom de Vries
623f8c6b88 [gdb/testsuite] Fix gdb.dwarf2/gdb-index-cxx.exp for remote host
Fix test-case gdb.dwarf2/gdb-index-cxx.exp for remote host using
host_standard_output_file.

Tested on x86_64-linux.
2023-03-27 13:58:10 +02:00
Tom de Vries
a653ec1f36 [gdb/testsuite] Fix gdb.dwarf2/gdb-index.exp on remote host
Fix test-case gdb.dwarf2/gdb-index.exp on remote host using
gdb_remote_download and host_standard_output_file.

Also declare the test-case unsupported with readnow.

Tested on x86_64-linux.
2023-03-27 13:58:10 +02:00
Tom de Vries
d0498b325e [gdb/testsuite] Fix quoting issues in gdb.dwarf2 for remote host
A few test-cases in gdb.dwarf2 use something like:
...
  additional_flags=\"-DFOO=BAR + 10\"
...
which doesn't work on remote host.

Fix this by introducing a new proc quote_for_host that also works for remote
host, such that we have:
...
  additional_flags=[quote_for_host -DFOO=BAR + 10]
...

Tested on x86_64-linux.
2023-03-27 13:58:09 +02:00
Tom de Vries
845d99df89 [gdb/testsuite] Fix have_index for remote host
Proc have_index is mostly used with $binfile, which gives problems
for remote host.

Fix this by using "file tail" on the proc argument.

Tested on x86_64-linux.
2023-03-27 13:58:09 +02:00
Tom de Vries
1770eca698 [gdb/testsuite] Handle missing gdc in gdb.dlang/dlang-start.exp
On openSUSE Leap 15.4, I get:
...
Running gdb.dlang/dlang-start.exp ...
gdb compile failed, default_target_compile: Can't find gdc.
UNTESTED: gdb.dlang/dlang-start.exp: failed to prepare
...

Fix this by:
- introducing a new proc can_compile, and
- requiring "can_compile d" in the test-case,
such that I have instead:
...
Running gdb.dlang/dlang-start.exp ...
UNSUPPORTED: gdb.dlang/dlang-start.exp: require failed: can_compile d
...

Tested on x86_64-linux, on openSUSE Leap 15.4 and Fedora 37.
2023-03-27 11:35:26 +02:00
Tom de Vries
16fbc917fa [gdb/testsuite] Remove superfluous pid in temp files
While trying to use gdb_can_simple_compile with a d program, I ran into:
...
/data/vries/gdb/f37/build/gdb/testsuite/temp/105856/can_compile_d-105856.d: \
  error: module 'can_compile_d-105856' has non-identifier characters in \
  filename, use module declaration instead
...

The d compiler has a problem with the filename can_compile_d-105856.d, which
contains the pid.  The pid is added by gdb_simple_compile:
...
    set obj [standard_temp_file $name-[pid].$postfix]
...
but it's unnecessary because standard_temp_file already uses the pid.

Fix this by removing "[pid]" in all calls to standard_temp_file.

Tested on x86_64-linux.
2023-03-27 11:35:26 +02:00
Tom de Vries
95e592d9ab [gdb/testsuite] Introduce allow_dap_tests
Simon pointed out that with gdb.dap/*.exp and target board
native-gdbserver, we run into problems.

I see for each test-case:
...
+++ run
Traceback (most recent call last):
  File "startup.py", line 146, in exec_and_log
    output = gdb.execute(cmd, from_tty=True, to_string=True)
gdb.error: Don't know how to run.  Try "help target".
...

Likewise with target board native-extended-gdbserver.

Fix this by:
- adding a new proc allow_dap_tests,
- using it in all the gdb.dap tests, and
- bailing out if GDBFLAGS/INTERNAL_GDBFLAGS contains
  "set auto-connect-native-target off".

Tested on x86_64-linux.

Reported-By: Simon Marchi <simon.marchi@efficios.com>
Approved-By: Tom Tromey <tom@tromey.com>
2023-03-26 13:44:58 +02:00
Tom de Vries
c569a946f6 [gdb/testsuite] Fix unbalanced quotes in mi_expect_stop argument
In proc mi_expect_stop there's a proc argument reason that's handled like so:
...
set r "reason=\"$reason\","
...

That's fine for say:
...
set reason "foo"
...
for which this evaluates to:
...
set r "reason=\"foo\","
...

But there are more complex uses, for instance:
...
set reason "breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal"
...
which evaluates to:
...
set r "\"breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\""
...

Note how in this reason argument, the first two '\"' seems to form a pair
surrounding ',disp=', which is not the case, which is confusing.

Fix this by only adding the quotes in mi_expect_stop if the string doesn't
already contain quotes, such that we have the more readable:
...
set reason "\"breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\""
...

Tested on x86_64-linux.
2023-03-24 10:45:37 +01:00
Tom de Vries
91ffa03af1 [gdb/testsuite] Use gdb_remote_download in allow_opencl_tests
Simon reported that doing:
...
$ while make check-parallel TESTS='gdb.opencl/*.exp' -j 100; do true; done
...
could run into:
...
ERROR: remote_download to target of \
  /data/vries/gdb/src/gdb/testsuite/lib/opencl_kernel.cl to opencl_kernel.cl: \
  cp: cannot create regular file 'opencl_kernel.cl': File exists
...

Fix this by using gdb_remote_download (instead of plain remote_download) in
allow_opencl_test, which takes care of:
- downloading to a location which is safe for parallel testing, by
  using standard_output_file, and
- cleaning up the downloaded file, meaning we can remove the corresponding
  "remote_file target delete ${clprogram}" lines in allow_opencl_test.

Tested on x86_64-linux.

Reported-by: Simon Marchi <simon.marchi@efficios.com>
2023-03-23 14:54:28 +01:00
Tom de Vries
722c459603 [gdb/testsuite] Fix gdb.cp/*.exp for remote host
Fix a few test-cases in gdb.cp/*.exp for remote host using new proc
include_file.

Tested on x86_64-linux.
2023-03-22 09:37:41 +01:00
Simon Marchi
904d9b02a1 gdb: make "maintenance info line-table" show relocated addresses again
Commit 1acc9dca42 ("Change linetables to be objfile-independent")
changed "maintenance info line-table" to print unrelocated addresses
instead of relocated.  This breaks a few tests on systems where that
matters.  The ones I see are:

    Running /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.base/consecutive.exp ...
    FAIL: gdb.base/consecutive.exp: stopped at bp, 2nd instr (missing hex prefix)
    Running /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.base/async.exp ...
    FAIL: gdb.base/async.exp: stepi&
    FAIL: gdb.base/async.exp: nexti&
    FAIL: gdb.base/async.exp: finish&

These tests run "maintenance info line-table" to record the address of
some lines, and then use these addresses in expected patterns.  It
therefore expects these addresses to match the runtime addresses,
therefore the relocated addresses.

Add back the relocated addresses, next to the unrelocated addresses,
like so:

    INDEX  LINE   REL-ADDRESS        UNREL-ADDRESS      IS-STMT PROLOGUE-END
    0      6      0x0000555555555119 0x0000000000001119 Y
    1      7      0x000055555555511d 0x000000000000111d Y
    2      8      0x0000555555555123 0x0000000000001123 Y
    3      END    0x0000555555555125 0x0000000000001125 Y

The unrelocated addresses can always be useful trying to map this
information with a DWARF info dump.

Adjust the is_stmt_addresses proc in the testsuite to match the new
output.

Change-Id: I59558f167e13e63421c9e0f2cad192e7c95c10cf
2023-03-21 21:33:00 -04:00
Tom de Vries
33ddd9fc4f [gdb/testsuite] Fix gdb.xml/tdesc-reload.exp for remote host
Fix test-case gdb.xml/tdesc-reload.exp for remote host by using appropriate
filenames.

Tested on x86_64-linux.
2023-03-21 11:25:12 +01:00
Tom de Vries
80d6c79866 [gdb/testsuite] Handle remotedir in remote_upload
Dejagnu's remotedir implementation has support in remote_exec and
remote_download, but not remote_upload.

Consider the following scenario:
- downloading an executable to target,
- running it,
- uploading a file produced by the executable
while assuming remote target user remote-target with homedir
/home/remote-target and remotedir set to /home/remote-target/tmp.

Concretely, it looks like this:
...
 # binfile == "$outputs/gdb.abc/a.out"
 set target_binfile [remote_download target $binfile]
 # target_binfile == "/home/remote-target/tmp/a.out"
 remote_exec target $target_binfile
 # Running $target_binfile produced /home/remote-target/tmp/result.txt.
 set result [remote_upload target /home/remote-target/tmp/result.txt \
                 $outputs/gdb.abc/result.txt]
 # result == $outputs/gdb.abc/result.txt.
...

Add a remote_upload implementation that also handles remotedir in lib/gdb.exp,
overriding dejagnu's remote_upload, such that we can simplify the
remote_upload call to:
...
 set result [remote_upload target result.txt $outputs/gdb.abc/result.txt]
...

Tested on x86_64-linux.

PR testsuite/30250
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30250
2023-03-20 17:06:49 +01:00
Carl Love
334d405c2a Move step_until procedure
Procedure step_until from test gdb.reverse/step-indirect-call-thunk.exp
is moved to lib/gdb.exp and renamed repeat_cmd_until.  The existing procedure
gdb_step_until in lib/gdb.exp is simpler variant of the new repeat_cmd_until
procedure.  The existing procedure gdb_step_until is changed to just call
the new repeat_cmd_until procedure with the command set to "step" and an
optional CURRENT string.  The default CURRENT string is set to "\}" to work
with the existing uses of procedure gdb_step_until.
2023-03-17 16:02:48 -04:00
Tom de Vries
1850ef87c6 [gdb/testsuite] Handle remote host in gdb_load_shlib
With test-case gdb.arch/ftrace-insn-reloc.exp and host board
local-remote-host-notty and target board native-gdbserver I run into:
...
(gdb) tstart^M
Target returns error code '.In-process agent library not loaded in process.  \
  Fast and static trace points unavailable.'.^M
(gdb) FAIL: gdb.arch/ftrace-insn-reloc.exp: start trace experiment
...

Fix this by:
- handling remote host in gdb_load_shlib, and
- moving the gdb_load_shlib to after the clean_restart, such that the
  set solib-search-path can take effect.

Tested on x86_64-linux.
2023-03-17 19:25:18 +01:00
Tom de Vries
2a7d1e5ebb [gdb/testsuite] Handle REMOTE_HOST_USERNAME in local-remote-host
Handle REMOTE_HOST_USERNAME in local-remote-host, similar to how that's done for
REMOTE_TARGET_USERNAME in remote-gdbserver-on-localhost.

This helps to keep the home dir clean.

Since the setup makes $build/gdb/testsuite on build unreadable for the remote
host, we run into permission problems for GDB and the data-directory, so fix
this (as was done for gdbserver in gdbserver-base.exp) using file normalize.

Tested on x86_64-linux.
2023-03-17 19:25:18 +01:00
Tom de Vries
0eb0e08287 [gdb/testsuite] Fix have_avx for remote target
In proc have_avx we compile some source into an exec, resulting in a file $obj
on build, and then attempt to execute it on target:
...
    set result [remote_exec target $obj]
...

Fix this by using gdb_remote_download target.

Likewise in a few other procs that use "remote_exec target".

Tested on x86_64-linux.
2023-03-17 16:06:39 +01:00
Tom de Vries
4581f89b8d [gdb/testsuite] Handle precise-aligned-alloc.c for remote host
With test-case gdb.arch/i386-sse.exp (and likewise gdb.arch/i386-avx.exp) and
host board local-remote-host-notty and target board native-gdbserver I run
into:
...
gdb compile failed, i386-sse.c:68:10: fatal error: \
  ../lib/precise-aligned-alloc.c: No such file or directory
 #include "../lib/precise-aligned-alloc.c"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...

Fix this using '#include "precise-aligned-alloc.c"' and making that work with
non-remote and remote host.

Tested on x86_64-linux.
2023-03-17 16:06:39 +01:00
Tom de Vries
a14e3d11b2 [gdb/testsuite] Handle remote host in escape_for_host
With test-case gdb.arch/ftrace-insn-reloc.exp and host board
local-remote-host-notty and target board native-gdbserver, I run into:
...
FAIL: gdb.arch/ftrace-insn-reloc.exp: IPA loaded
...
due to having:
...
$ readelf -d ftrace-insn-reloc | grep RUNPATH
 0x000000000000001d (RUNPATH)            Library runpath: []
...
instead of:
...
$ readelf -d ftrace-insn-reloc | grep RUNPATH
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN]
...

Handle this in escape_for_host.

Tested on x86_64-linux.
2023-03-17 13:29:13 +01:00
Tom de Vries
ff000c4dbb [gdb/testsuite] Add escape_for_host
In gdb_compile we have:
...
           lappend new_options "ldflags=-Wl,-rpath,\\\$ORIGIN"
...
and we could improve readability by using {} rather than "":
...
           lappend new_options {ldflags=-Wl,-rpath,\$ORIGIN}
...

But rather than manually adding escapes in a string, add a new proc
escape_for_host that care of this for us, allowing us to write:
...
           lappend new_options [escape_for_host {ldflags=-Wl,-rpath,$ORIGIN}]
...

Tested on x86_64-linux.
2023-03-17 13:29:13 +01:00
Tom de Vries
bf8d2f9235 [gdb/testsuite] Declare ada unsupported for remote host
Currently gdb_ada_compile doesn't support remote host.

Make this explicit in allow_ada_tests.

Tested on x86_64-linux.
2023-03-17 10:34:18 +01:00
Tom de Vries
86091eae20 [gdb/testsuite] Unset DEBUGINFOD_URLS on remote host
When running test-case gdb.arch/i386-pkru.exp with host board
local-remote-host-notty and target board native-gdbserver on openSUSE
Tumbleweed (with DEBUGINFOD_URLS set), I run into:
...
This GDB supports auto-downloading debuginfo from the following URLs:^M
  <https://debuginfod.opensuse.org/>^M
Enable debuginfod for this session? (y or [n]) ^CQuit^M
(gdb) FAIL: gdb.arch/i386-pkru.exp: runto: run to main
...

The problem is that the unsetenv for DEBUGINFOD_URLS in default_gdb_init:
...
    # If DEBUGINFOD_URLS is set, gdb will try to download sources and
    # debug info for f.i. system libraries.  Prevent this.
    unset -nocomplain ::env(DEBUGINFOD_URLS)
...
doesn't work on remote host.

Fix this by using "set debuginfod enabled off" for remote host.

Tested on x86_64-linux.
2023-03-15 16:38:03 +01:00
Tom de Vries
72f160d012 [gdb/testsuite] Require ![is_remote host] for TUI
When running test-case gdb.tui/corefile-run.exp with both host and target board
local-remote-host-native.exp, we run into:
...
FAIL: gdb.tui/corefile-run.exp: load corefile
...
while this passes with USE_TUI=0.

The problem is that the TUI setup code uses "setenv TERM ansi", which has no
effect on remote host.

I can confirm this analysis by working around this problem in
local-remote-host-native.exp like this:
...
-    spawn $RSH -t -l $username $remote $cmd
+    spawn $RSH -t -l $username $remote "export TERM=ansi; $cmd"
...

For now, simply make TUI unsupported for remote host, by returning 0 in
prepare_for_tui.

Tested on x86_64-linux.
2023-03-13 17:20:09 +01:00
Tom de Vries
ed7d5797b5 [gdb/testsuite] Fix untested message in gdb.tui/corefile-run.exp
In test-case gdb.tui/corefile-run.exp, we have this bit:
...
require !use_gdb_stub
if { [target_info gdb_protocol] == "extended-remote" } {
    untested "not supported"
    return
}
...

So with target board native-gdbserver we get:
...
UNSUPPORTED: gdb.tui/corefile-run.exp: require failed: !use_gdb_stub
...
and with target board native-extended-gdbserver instead:
...
UNTESTED: gdb.tui/corefile-run.exp: not supported
...

Fix this by:
- adding an optional argument target_description to proc
  target_can_use_run_cmd
- handling the target_description == core &&
  [target_info gdb_protocol] == "extended-remote" case in the proc
- using require {target_can_use_run_cmd core}
such that now in both cases we have:
...
UNSUPPORTED: gdb.tui/corefile-run.exp: require failed: \
  target_can_use_run_cmd core
...

Tested on x86_64-linux.
2023-03-13 17:20:09 +01:00
Tom de Vries
e8850b5262 [gdb/testsuite] Fix gdb.mi/*.exp with remote-gdbserver-on-localhost
When running test-cases gdb.mi/*.exp with target board
remote-gdbserver-on-localhost, we run into a few fails.

Fix these (and make things more similar to the gdb.exp procs) by:
- factoring out mi_load_shlib out of mi_load_shlibs
- making mi_load_shlib use gdb_download_shlib, like
  gdb_load_shlib
- factoring out mi_locate_shlib out of mi_load_shlib
- making mi_locate_shlib check for mi_spawn_id, like
  gdb_locate_shlib
- using gdb_download_shlib and mi_locate_shlib in the test-cases.

Tested on x86_64-linux, with and without target board
remote-gdbserver-on-localhost.
2023-03-07 09:59:56 +01:00
Tom de Vries
71f1ab80f1 [gdb/testsuite] Allow args in gdb_caching_proc
Test-case gdb.base/morestack.exp contains:
...
require {have_compile_flag -fsplit-stack}
...
and I want to cache the result of have_compile_flag.

Currently gdb_caching_proc doesn't allow args, so I could add:
...
gdb_caching_proc have_compile_flag_fsplit_stack {
    return [have_compile_flag -fsplit-stack]
}
...
and then use that proc instead, but I find this cumbersome and
maintenance-unfriendly.

Instead, allow args in a gdb_caching_proc, such that I can simply do:
...
-proc have_compile_flag { flag } {
+gdb_caching_proc have_compile_flag { flag } {
...

Note that gdb_caching_procs with args do not work with the
gdb.base/gdb-caching-procs.exp test-case, so those procs are skipped.

Tested on x86_64-linux.

Reviewed-By: Tom Tromey <tom@tromey.com>
2023-03-06 16:49:19 +01:00
Tom de Vries
b50420fd05 [gdb/testsuite] Use regular proc syntax for gdb_caching_proc
A regular tcl proc with no args looks like:
...
proc foo {} {
     return 1
}
...
but a gdb_caching_proc deviates from that syntax by dropping the explicit no
args bit:
...
gdb_caching_proc foo {
     return 1
}
...

Make the gdb_caching_proc use the same syntax as regular procs, such that we
have instead:
...
gdb_caching_proc foo {} {
     return 1
}
...

Tested on x86_64-linux.

Reviewed-By: Tom Tromey <tom@tromey.com>
2023-03-06 16:49:19 +01:00
Simon Marchi
14ade91660 gdb: update some copyright years (2022 -> 2023)
The copyright years in the ROCm files (e.g. solib-rocm.c) are wrong,
they end in 2022 instead of 2023.  I suppose because I posted (or at
least prepared) the patches in 2022 but merged them in 2023, and forgot
to update the year.  I found a bunch of other files that are in the same
situation.  Fix them all up.

Change-Id: Ia55f5b563606c2ba6a89046f22bc0bf1c0ff2e10
Reviewed-By: Tom Tromey <tom@tromey.com>
2023-03-01 20:54:56 -05:00
Andrew Burgess
05ac6365e5 gdb/testsuite: fix failure in gdb.mi/mi-pending.exp with extended-remote
I currently see this failure when running the gdb.mi/mi-pending.exp
test using the native-extended-remote board:

  -break-insert -f -c x==4 mi-pendshr.c:pendfunc2
  &"No source file named mi-pendshr.c.\n"
  ^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="<PENDING>",pending="mi-pendshr.c:pendfunc2",cond="x==4",evaluated-by="host",times="0",original-location="mi-pendshr.c:pendfunc2"}
  (gdb)
  FAIL: gdb.mi/mi-pending.exp: MI pending breakpoint on mi-pendshr.c:pendfunc2 if x==4 (unexpected output)

The failure is caused by the 'evaluated-by="host"' string, which only
appears in the output when the test is run using the
native-extended-remote board.

I could fix this by just updating the pattern in
gdb.mi/mi-pending.exp, but I have instead updated mi-pending.exp to
make more use of the support procs in mi-support.exp.  This did
require making a couple of adjustments to mi-support.exp, but I think
the result is that mi-pending.exp is now easier to read, and I see no
failures with native-extended-remote anymore.

One of the test names has changed after this work, I think the old
test name was wrong - it described a breakpoint as pending when the
breakpoint was not pending, I suspect a copy & paste error.

But there's no changes to what is actually being tested after this
patch.

Approved-By: Pedro Alves <pedro@palves.net>
2023-02-28 10:56:28 +00:00
Andrew Burgess
47171eeb94 gdb/testsuite: introduce is_target_non_stop helper proc
I noticed that several tests included copy & pasted code to run the
'maint show target-non-stop' command, and then switch based on the
result.

In this commit I factor this code out into a helper proc in
lib/gdb.exp, and update all the places I could find that used this
pattern to make use of the helper proc.

There should be no change in what is tested after this commit.

Reviewed-By: Pedro Alves <pedro@palves.net>
2023-02-28 10:56:28 +00:00
Andrew Burgess
292deeba7d gdb/testsuite introduce foreach_mi_ui_mode helper proc
Introduce foreach_mi_ui_mode, a helper proc which can be used when
tests are going to be repeated once with the MI in the main UI, and
once with the MI on a separate UI.

The proc is used like this:

  foreach_mi_ui_mode VAR {
    # BODY
  }

The BODY will be run twice, once with VAR set to 'main' and once with
VAR set to 'separate', inside BODY we can then change the behaviour
based on the current UI mode.

The point of this proc is that we sometimes shouldn't run the separate
UI tests (when gdb_debug_enabled is true), and this proc hides all
this logic.  If the separate UI mode should not be used then BODY will
be run just once with VAR set to 'main'.

I've updated two tests that can make use of this helper proc.  I'm
going to add another similar test in a later commit.

There should be no change to what is tested with this commit.

Approved-By: Pedro Alves <pedro@palves.net>
2023-02-28 10:56:28 +00:00
Andrew Burgess
1ccc4abbb3 gdb/testsuite: extend the use of mi_clean_restart
The mi_clean_restart proc calls the mi_gdb_start proc passing no
arguments.

In this commit I add an extra (optional) argument to the
mi_clean_restart proc, and pass this through to mi_gdb_start.

The benefit of this is that we can now use mi_clean_restart when we
also want to pass the 'separate-mi-tty' or 'separate-inferior-tty'
flags to mi_gdb_start, and avoids having to otherwise duplicate the
contents of mi_clean_restart in different tests.

I've updated the obvious places where this new functionality can be
used, and I'm seeing no test regressions.

Reviewed-By: Pedro Alves <pedro@palves.net>
2023-02-28 10:56:28 +00:00
Andrew Burgess
2fd9a436c8 gdb: don't duplicate 'thread' field in MI breakpoint output
When creating a thread-specific breakpoint with a single location, the
'thread' field would be repeated in the MI output.  This can be seen
in two existing tests gdb.mi/mi-nsmoribund.exp and
gdb.mi/mi-pending.exp, e.g.:

  (gdb)
  -break-insert -p 1 bar
  ^done,bkpt={number="1",type="breakpoint",disp="keep",
	      enabled="y",
	      addr="0x000000000040110a",func="bar",
	      file="/tmp/mi-thread-specific-bp.c",
	      fullname="/tmp/mi-thread-specific-bp.c",
	      line="32",thread-groups=["i1"],
	      thread="1",thread="1",  <================ DUPLICATION!
	      times="0",original-location="bar"}

I know we need to be careful when adjusting MI output, but I'm hopeful
in this case, as the field is duplicated, and the field contents are
always identical, that we might get away with removing one of the
duplicates.

The change in GDB is a fairly trivial condition change.

We did have a couple of tests that contained the duplicate fields in
their expected output, but given there was no comment pointing out
this oddity either in the GDB code, or in the test, I suspect this was
more a case of copying whatever output GDB produced and using that as
the expected results.  I've updated these tests to remove the
duplication.

I've update lib/mi-support.exp to provide support for building
breakpoint patterns that contain the thread field, and I've made use
of this in a new test I've added that is just about creating
thread-specific breakpoints and checking the results.  The two tests I
mentioned above as being updated could also use the new
lib/mi-support.exp functionality, but I'm going to do that in a later
patch, this way it is clear what changes I'm actually proposing to
make to the expected output.

As I said, I hope that frontends will be able to handle this change,
but I still think its worth adding a NEWS entry, that way, if someone
runs into problems, there's a chance they can figure out what's going
on.

This should not impact CLI output at all.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Pedro Alves <pedro@palves.net>
2023-02-28 10:56:28 +00:00
Bruno Larsen
a3da2e7e55 gdb/testsuite: Improve testing of GDB's completion functions
When looking at some failures of gdb.linespec/cp-completion-aliases.exp,
I noticed that when a completion test will fail, it always fails with a
timeout.  This is because most completion tests use gdb_test_multiple
and only add a check for the correct output.  This commit adds new
options for both, tab and command completion.

For command completion, the new option will check if the prompt was
printed, and fail in this case. This is enough to know that the test has
failed because the check comes after the PASS path. For tab completion,
we have to check if GDB outputted more than just the input line, because
sometimes GDB would have printed a partial line before finishing with
the correct completion.

Approved-By: Tom Tromey <tom@tromey.com>
2023-02-27 10:52:23 +01:00