Commit graph

48166 commits

Author SHA1 Message Date
Tom Tromey
59505f2cec Unify "catch fork" and "catch vfork"
I noticed that "catch fork" and "catch vfork" are nearly identical.
This patch simplifies the code by unifying these two cases.
2022-01-18 10:34:05 -07:00
Tom Tromey
d322d6d69d Move gdb_regex to gdbsupport
This moves the gdb_regex convenience class to gdbsupport.
2022-01-18 10:14:43 -07:00
Tom Tromey
0589ca4e7b Introduce gdb-hashtab module in gdbsupport
gdb has some extensions and helpers for working with the libiberty
hash table.  This patch consolidates these and moves them to
gdbsupport.
2022-01-18 10:14:43 -07:00
Tom Tromey
bf31fd38f0 Move gdb obstack code to gdbsupport
This moves the gdb-specific obstack code -- both extensions like
obconcat and obstack_strdup, and things like auto_obstack -- to
gdbsupport.
2022-01-18 10:14:42 -07:00
Tom Tromey
7904e9613e Move gdb_argv to gdbsupport
This moves the gdb_argv class to a new header in gdbsupport.
2022-01-18 10:14:42 -07:00
Tom Tromey
5947982f1d Simplify event_location_probe
event_location_probe currently stores two strings, but really only
needs one.  This patch simplifies it and removes some unnecessary
copies as well.
2022-01-18 10:01:20 -07:00
Tom Tromey
85e428a69f Use std::string in event_location
This changes event_location to use std::string, removing some manual
memory management, and an unnecessary string copy.
2022-01-18 10:01:19 -07:00
Tom Tromey
2b0c285ea5 Split event_location into subclasses
event_location uses the old C-style discriminated union approach.
However, it's better to use subclassing, as this makes the code
clearer and removes some chances for error.  This also enables future
cleanups to avoid manual memory management and copies.
2022-01-18 10:01:16 -07:00
Tom Tromey
49a9cf56ff Remove EL_* macros from location.c
This patch removes the old-style EL_* macros from location.c.  This
cleans up the code by itself, IMO, but also enables further cleanups
in subsequent patches.
2022-01-18 10:00:01 -07:00
Tom Tromey
7910e2dee3 Boolify explicit_to_string_internal
This changes explicit_to_string_internal to use 'bool' rather than
'int'.
2022-01-18 10:00:00 -07:00
Tom Tromey
dab863ef40 Remove a use of xfree in location.c
This small cleanup removes a use of xfree from location.c, by
switching to unique_xmalloc_ptr.  One function is only used in
location.c, so it is made static.  And, another function is changed to
avoid a copy.
2022-01-18 10:00:00 -07:00
Simon Marchi
e53c95d40b gdb: use ptid_t::to_string instead of target_pid_to_str in debug statements
Same idea as 0fab795564 ("gdb: use ptid_t::to_string in infrun debug
messages"), but throughout GDB.

Change-Id: I62ba36eaef29935316d7187b9b13d7b88491acc1
2022-01-18 11:28:33 -05:00
Andrew Burgess
cced7cacec gdb: preserve | in connection details string
Consider this GDB session:

  $ gdb -q
  (gdb) target remote  | gdbserver - ~/tmp/hello.x
  Remote debugging using | gdbserver - ~/tmp/hello.x
  ... snip ...
  (gdb) info connections
    Num  What                              Description
  * 1    remote gdbserver - ~/tmp/hello.x  Remote target using gdb-specific protocol
  (gdb) python conn = gdb.selected_inferior().connection
  (gdb) python print(conn.details)
  gdbserver - ~/tmp/hello.x
  (gdb)

I think there are two things wrong here, first in the "What" column of
the 'info connections' output, I think the text should be:

  remote | gdbserver - ~/tmp/hello.x

to correctly show the user how the connection was established.  And in
a similar fashion, I think that the `details` string of the
gdb.TargetConnection object should be:

  | gdbserver - ~/tmp/hello.x

This commit makes this change.  Currently the '|' is detected and
removed in gdb/serial.c.  The string passed to the pipe_ops
structure (from gdb/ser-pipe.c), doesn't then, contain the `|`, this
is instead implied by the fact that it is a pipes based implementation
of the serial_ops interface.

After this commit we still detect the `|` in gdb/serial.c, but we now
store the full string (including the `|`) in the serial::name member
variable.

For pipe based serial connections, this name is only used for
displaying the two fields I mention above, and in pipe_open (from
gdb/ser-pipe.c), and in pipe_open, we now know to skip over the `|`.

The benefit I see from this change is that GDB's output now more
accurately reflects the commands used to start a target, thus making
it easier for a user to understand what is going on.
2022-01-18 11:45:52 +00:00
Tiezhu Yang
709a3d07f3 gdb: testsuite: print explicit test result for gdb.base/dfp-test.exp
In the current code, if decimal floating point is not supported for
this target, there is no binary file dfp-test, and also there is no
test result after execute the following commands:

  $ make check-gdb TESTS="gdb.base/dfp-test.exp"
  $ grep error gdb/testsuite/gdb.log
  /home/loongson/gdb.git/gdb/testsuite/gdb.base/dfp-test.c:39:1: error: decimal floating point not supported for this target
  [...]
  $ cat gdb/testsuite/gdb.sum
  [...]
  Running target unix
  Running /home/loongson/gdb.git/gdb/testsuite/gdb.base/dfp-test.exp ...

		  === gdb Summary ===
  [...]

With this patch:

  $ make check-gdb TESTS="gdb.base/dfp-test.exp"
  $ cat gdb/testsuite/gdb.sum
  [...]
  Running target unix
  Running /home/loongson/gdb.git/gdb/testsuite/gdb.base/dfp-test.exp ...
  UNSUPPORTED: gdb.base/dfp-test.exp: decimal floating point not supported for this target.

		  === gdb Summary ===

  # of unsupported tests		1
  [...]

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-01-18 15:17:57 +08:00
Simon Marchi
8bf10e2e77 gdb/infrun: rename variable and move to more specific scope
Move the "started" variable to the scope it's needed, and rename it to
"step_over_started".

Change-Id: I56f3384dbd328f55198063bb855edda10f1492a3
2022-01-17 05:51:41 -05:00
Joel Brobecker
a3f3402131 gdb/copyright.py: Do not update gdbsupport/Makefile.in
This file is generated, so we should not modify it (any modification
we make is going to be undone at the next re-generation anyway).
2022-01-16 13:50:38 +04:00
Simon Marchi
513569fbb7 gdb.dlang/demangle.exp: update expected output for _D8demangle4testFnZv
Since commit ce2d3708bc ("Synchronize binutils libiberty sources with
gcc version."), I see this failure:

    demangle _D8demangle4testFnZv^M
    demangle.test(typeof(null))^M
    (gdb) FAIL: gdb.dlang/demangle.exp: _D8demangle4testFnZv

The commit imported the commit 0e32a5aa8bc9 ("libiberty: Add support for
D `typeof(*null)' types") from the gcc repository.  That commit includes
an update to libiberty/testsuite/d-demangle-expected, which updates a
test for the exact same mangled name:

     _D8demangle4testFnZv
    -demangle.test(none)
    +demangle.test(typeof(null))

I don't know anything about D, but give that the change was made by Iain
Buclaw, the D language maintainer, I trust him on that.

Fix our test by updating the expected output in the same way.

Note: it's not really useful to have all these D demangling tests in the
GDB testsuite, since there are demangling tests in libiberty.  We should
consider removing them, but we first need to make sure that everything
that is covered in gdb/testsuite/gdb.dlang/demangle.exp is also covered
in libiberty/testsuite/d-demangle-expected.

Change-Id: If2b290ea8367b8e1e0b90b20d4a6e0bee517952d
2022-01-14 15:09:32 -05:00
Nils-Christian Kempke
2026dcfcc0 gdb/testsuite: enable __INTEL_LLVM_COMPILER preprocessor in get_compiler_info
Intel Next Gen compiler defines preprocessor __INTEL_LLVM_COMPILER and provides
version info in __clang_version__ e.g. value: 12.0.0 (icx 2020.10.0.1113).

gdb/testsuite/ChangeLog:
2020-12-07  Abdul Basit Ijaz  <abdul.b.ijaz@intel.com>

	* lib/compiler.c: Add Intel next gen compiler pre-processor check.
	* lib/compiler.cc: Ditto.
	* lib/fortran.exp (fortran_main): Check Intel next gen compiler in
	test_compiler_info.
2022-01-14 14:32:29 +00:00
Andrew Burgess
4b74833d1a gdb: don't use -Wmissing-prototypes with g++
This commit aims to not make use of -Wmissing-prototypes when
compiling with g++.

Use of -Wmissing-prototypes was added with this commit:

  commit a0761e34f0
  Date:   Wed Mar 11 15:15:12 2020 -0400

      gdb: enable -Wmissing-prototypes warning

Because clang can provide helpful warnings with this flag.
Unfortunately, g++ doesn't accept this flag, and will give this
warning:

  cc1plus: warning: command line option ‘-Wmissing-prototypes’ is valid for C/ObjC but not for C++

In theory the fact that this flag is not supported should be detected
by the configure check in gdbsupport/warning.m4, but for users of
ccache, this check doesn't work due to a long standing ccache issue:

  https://github.com/ccache/ccache/issues/738

The ccache problem is that -W... options are reordered on the command
line, and so -Wmissing-prototypes is seen before -Werror.  Usually
this doesn't matter, but the above warning (about the flag not being
valid) is issued before the -Werror flag is processed, and so is not
fatal.

There have been two previous attempts to fix this that I'm aware of.
The first is:

  https://sourceware.org/pipermail/gdb-patches/2021-September/182148.html

In this attempt, instead of just relying on a compile to check if a
flag is valid, the proposal was to both compile and link.  As linking
doesn't go through ccache, we don't suffer from the argument
reordering problem, and the link phase will correctly fail when using
-Wmissing-prototypes with g++.  The configure script will then disable
the use of this flag.

This approach was rejected, and the suggestion was to only add the
-Wmissing-prototypes flag if we are compiling with gcc.

The second attempt, attempts this approach, and can be found here:

  https://sourceware.org/pipermail/gdb-patches/2021-November/183076.html

This attempt only adds the -Wmissing-prototypes flag is the value of
GCC is not 'yes'.  This feels like it is doing the right thing,
unfortunately, the GCC flag is really a 'is gcc like' flag, not a
strict, is gcc check.  As such, GCC is set to 'yes' for clang, which
would mean the flag was not included for clang or gcc.  The entire
point of the original commit was to add this flag for clang, so
clearly the second attempt is not sufficient either.

In this new attempt I have added gdbsupport/compiler-type.m4, this
file defines AM_GDB_COMPILER_TYPE.  This macro sets the variable
GDB_COMPILER_TYPE to either 'gcc', 'clang', or 'unknown'.  In future
the list of values might be extended to cover other compilers, if this
is ever useful.

I've then modified gdbsupport/warning.m4 to only add the problematic
-Wmissing-prototypes flag if GDB_COMPILER_TYPE is not 'gcc'.

I've tested this with both gcc and clang and see the expected results,
gcc no longer attempts to use the -Wmissing-prototypes flag, while
clang continues to use it.

When compiling using ccache, I am no longer seeing the warning.
2022-01-13 10:25:45 +00:00
Andrew Burgess
993248f443 gdb: add some extra debug information to attach_command
While working on another patch I wanted to add some extra debug
information to the attach_command function.  This required me to add a
new function to convert the thread_info::state variable to a string.

The new debug might be useful to others, and the state to string
function might be useful in other locations, so I thought I'd merge
it.
2022-01-13 10:13:16 +00:00
Tiezhu Yang
e31cf164b4 gdb: testsuite: make string[] type as char in gdb.base/charset.c
This reverts the commit ff656e2e1c ("gdb: testsuite: fix failed
testcases in gdb.base/charset.exp").

The original test code has no problem. On an architecture where
char is signed, then both 'A' and ebcdic_us_string[7] will yield
-63, which makes the equality true. On an architecture where char
is unsigned, then both 'A' and ebcdic_us_string[7] will yield 193,
which also makes the equality true.

The test cases only failed on LoongArch. The default type of char
is signed char on LoongArch, like x86-64. But when use gdb print
command on LoongArch, the default type of char is unsigned char,
this is wrong, I will look into it later, sorry for that.

On LoongArch:

  $ cat test_char.c
  #include <stdio.h>

  int main()
  {
          char c1 = 193;
          unsigned char c2 = 193;

          printf("%d\n", c1);
          printf("%d\n", c1 == c2);

          return 0;
  }
  $ gcc test_char.c -o test_char
  $ ./test_char
  -63
  0

  (gdb) set target-charset EBCDIC-US
  (gdb) print 'A'
  $1 = 193 'A'
  (gdb) print /c 'A'
  $2 = 193 'A'
  (gdb) print /u 'A'
  $3 = 193
  (gdb) print /d 'A'
  $4 = -63
  (gdb) print /x 'A'
  $5 = 0xc1

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-01-13 11:12:55 +08:00
Carl Love
8d4e4d13af gdb Power 9 add test for HW watchpoint support.
The Power 9 processor revision 2.2 has HW watchpoint support disabled due
to a HW bug.  The support is fixed in Power 9 processor revision 2.3.  This
patch add a test to lib/gdb.exp for Power to determine if the processor
supports HW watchpoints or not.  If the Power processor doesn't support HW
watchpoints the proceedure skip_hw_watchpoint_tests will return 1 to
disable the various HW watchpoint tests.

The patch has been tested on Power 9, processor revesions 2.2 and 2.3.  The
patch has also been tested on Power 10.  No regression test failures were
found.
2022-01-12 11:56:58 -06:00
Andrew Burgess
61671e9792 gdb/python: add gdb.host_charset function
We already have gdb.target_charset and gdb.target_wide_charset.  This
commit adds gdb.host_charset along the same lines.
2022-01-12 16:00:07 +00:00
Tankut Baris Aktemur
51eebae32a gdb/testsuite: fix gdb.python/py-events.exp for finding process id
When executed with --target_board=native-extended-gdbserver, the
gdb.python/py-events.exp test errors out with

  ERROR: tcl error sourcing /path/to/gdb/testsuite/gdb.python/py-events.exp.
  ERROR: can't read "process_id": no such variable
      while executing
  "lappend expected "ptid: \\($process_id, $process_id, 0\\)" "address: $addr""
      (file "/path/to/gdb/testsuite/gdb.python/py-events.exp" line 103)
      invoked from within
  "source /path/to/gdb/testsuite/gdb.python/py-events.exp"
      ("uplevel" body line 1)
      invoked from within
  "uplevel #0 source /path/to/gdb/testsuite/gdb.python/py-events.exp"
      invoked from within
  "catch "uplevel #0 source $test_file_name""

There are multiple problems around this:

1. The process_id variable is not initialized to a default value.

2. The test attempts to find the PID of the current thread, but the
   regexp that it uses is not tailored for the output printed by the
   remote target.

3. The test uses "info threads" to find the current thread PID.
   Using the "thread" command instead is simpler.

Fix these problems.
2022-01-12 16:19:19 +01:00
Tom Tromey
ae9adb3651 Don't mention "serial" in target remote description
PR remote/9177 points out that "info files" mentions "serial" a couple
of times:

    Remote serial target in gdb-specific protocol:
    Debugging a target over a serial line.

However, often the remote target isn't really a serial connection.

It seems to me that this text could be a bit clearer; and furthermore
since "info files" prints the target's long description,
remote_target::files_info doesn't really add much and can simply be
removed.

Regression tested on x86-64 Fedora 34.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=9177
2022-01-12 07:43:57 -07:00
Andrew Burgess
643b126809 gdb: add 'maint set/show gnu-source-highlight enabled' command
In a later commit I want to address an issue with the Python pygments
based code styling solution.  As this approach is only used when the
GNU Source Highlight library is not available, testing bugs in this
area can be annoying, as it requires GDB to be rebuilt with use of GNU
Source Highlight disabled.

This commit adds a pair of new maintenance commands:

  maintenance set gnu-source-highlight enabled on|off
  maintenance show gnu-source-highlight enabled

these commands can be used to disable use of the GNU Source Highlight
library, allowing me, in a later commit, to easily test bugs that
would otherwise be masked by GNU Source Highlight being used.

I made this a maintenance command, rather than a general purpose
command, as it didn't seem like this was something a general user
would need to adjust.  We can always convert the maintenance command
to a general command later if needed.

There's no test for this here, but this feature will be used in a
later commit.
2022-01-12 11:33:31 +00:00
Andrew Burgess
0e42221ac2 gdb: erase items from the source_cache::m_offset_cache
The source_cache class has two member variables m_source_map, which
stores the file contents, and m_offset_cache, which stores offsets
into the file contents.

As source files are read the contents of the file, as well as the
offset data, are stored in the cache using these two member variables.

Whenever GDB needs either the files contents, or the offset data,
source_cache::ensure is called.  This function looks for the file in
m_source_map, and if it's found then this implies the file is also in
m_offset_cache, and we're done.

If the file is not in m_source_map then GDB calls
source_cache::get_plain_source_lines to open the file and read its
contents.  ::get_plain_source_lines also calculates the offset data,
which is then inserted into m_offset_cache.

Back in ::ensure, the file contents are added into m_source_map.  And
finally, if m_source_map contains more than MAX_ENTRIES, an entry is
removed from m_source_map.

The problem is entries are not removed from m_offset_cache at the same
time.

This means that if a program contains enough source files, GDB will
hold at most MAX_ENTRIES cached source file contents, but can contain
offsets data for every source file.

Now, the offsets data is going to be smaller than the cached file
contents, so maybe there's no harm here.  But, when we reload the file
contents we always recalculate the offsets data.  And, when we
::get_line_charpos asking for offset data we still call ::ensure which
will ends up loading and caching the file contents.

So, given the current code does the work of reloading the offset data
anyway, we may as well save memory by capping m_offset_cache to
MAX_ENTRIES just like we do m_source_map.

That's what this commit does.

There should be no user visible changes after this commit, except for
ever so slightly lower memory usage in some cases.
2022-01-12 11:33:14 +00:00
Andrew Burgess
3937077888 gdb: new 'maint flush source-cache' command
This commit adds a new 'maint flush source-cache' command, this
flushes the cache of source file contents.

After flushing GDB is forced to reread source files the next time any
source lines are to be displayed.

I've added a test for this new feature.  The test is a little weird,
in that it modifies a source file after compilation, and makes use of
the cache flush so that the changes show up when listing the source
file.  I'm not sure when such a situation would ever crop up in real
life, but maybe we can imagine such cases.

In reality, this command is useful for testing the syntax highlighting
within GDB, we can adjust the syntax highlighting settings, flush the
cache, and then get the file contents re-highlighted using the new
settings.
2022-01-12 11:19:48 +00:00
Andrew Burgess
8864ef428d gdb: rename lin-lwp to linux-nat in set/show debug
Rename 'set debug lin-lwp' to 'set debug linux-nat' and 'show debug
lin-lwp' to 'show debug linux-nat'.

I've updated the documentation and help text to match, as well as
making it clear that the debug that is coming out relates to all
aspects of Linux native inferior support, not just the LWP aspect of
it.

The boundary between general "native" target debug, and the lwp
specific part of that debug was always a little blurry, but the actual
debug variable inside GDB is debug_linux_nat, and the print routine
linux_nat_debug_printf, is used throughout the linux-nat.c file, not
just for lwp related debug, so the new name seems to make more sense.
2022-01-12 10:51:03 +00:00
Tiezhu Yang
295114a64f gdb: testsuite: fix wrong comment in gdb.base/charset.c
In gdb/testsuite/gdb.base/charset.c, use "IBM1047" instead of "EBCDIC"
to fix the wrong comment.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-01-12 08:33:49 +08:00
Tiezhu Yang
ff656e2e1c gdb: testsuite: fix failed testcases in gdb.base/charset.exp
In gdb/testsuite/gdb.base/charset.c, the last argument is greater than 127
when call fill_run() in EBCDIC-US and IBM1047, but the type of string[] is
char, this will change the value due to sign extension.

For example, ebcdic_us_string[7] will be -63 instead of the original 193 in
EBCDIC-US.

Make the type of string[] as unsigned char to fix the following six failed
testcases:

  $ grep FAIL gdb/testsuite/gdb.sum
  FAIL: gdb.base/charset.exp: check value of parsed character literal in EBCDIC-US
  FAIL: gdb.base/charset.exp: check value of parsed string literal in EBCDIC-US
  FAIL: gdb.base/charset.exp: check value of escape that doesn't exist in EBCDIC-US
  FAIL: gdb.base/charset.exp: check value of parsed character literal in IBM1047
  FAIL: gdb.base/charset.exp: check value of parsed string literal in IBM1047
  FAIL: gdb.base/charset.exp: check value of escape that doesn't exist in IBM1047

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-01-12 08:31:02 +08:00
Tiezhu Yang
4cfa9e3f28 gdb: add Tiezhu Yang to MAINTAINERS
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-01-10 14:36:36 +08:00
Tom Tromey
a42a74331c Reduce use of unfiltered output in Darwin code
The Darwin code uses unfiltered output liberally.  This patch changes
this code to send some output to gdb_stdlog (in some cases via the use
of debug_prefixed_printf_cond_nofunc), or to gdb_stderr, or to simply
switch to filtered output.

Note that I didn't switch inferior_debug to use
debug_prefixed_printf_cond_nofunc, because that would affect the
output by removing the information about the inferior.  I wasn't sure
if this was important or not, so I left it in.

v2 of this patch uses warning rather than prints to gdb_stderr, and
removes some trailing whitespace.

I can't compile this patch, so it's "best effort".
2022-01-09 18:59:52 -07:00
Andrew Burgess
038d8b4635 gdb/hurd: handle inferiors exiting
While testing on GNU/Hurd (i386) I noticed that GDB crashes when an
inferior exits, with this error:

  inferior.c:293: internal-error: inferior* find_inferior_pid(process_stratum_target*, int): Assertion `pid != 0' failed.

The problem appears to be in gnu_nat_target::wait.

We always set inferior_ptid to null_ptid before calling target_wait,
this has been the case since the multi-target changes were made to GDB
in commit:

  commit 5b6d1e4fa4
  Date:   Fri Jan 10 20:06:08 2020 +0000

      Multi-target support

With follow up changes in commit:

  commit 24ed6739b6
  Date:   Thu Jan 30 14:35:40 2020 +0000

      gdb/remote: Restore support for 'S' stop reply packet

Unfortunately, the GNU/Hurd target is still relying on the value of
inferior_ptid in the case where an inferior exits - we return the
value of inferior_ptid as the pid of the process that exited.  This
was fine in the single target world, where inferior_ptid identified
the one running inferior, but this is no longer good enough.

Instead, we should return a ptid containing the pid of the process
that exited, as obtained from the wait event, and this is what this
commit does.

I've not run the full testsuite on GNU/Hurd as there appear to be lots
of other issues with this target that makes running the full testsuite
very painful, but I think this looks like a small easy improvement.
2022-01-08 22:12:57 +00:00
Tom Tromey
249f1cf8e6 Add explicit check for nullptr to target_announce_attach
Lancelot pointed out that target_announce_attach was missing an
explicit check against nullptr.  This patch adds it.
2022-01-08 09:45:27 -07:00
Hannes Domani
24fe764c8a Add _sigsys info to siginfo struct
This patch adds information about _sigsys structure from newer
kernels, so that $_siginfo decoding can show information about
_sigsys, making it easier for developers to debug seccomp failures.
Requested in PR gdb/24283.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=24283
2022-01-08 14:17:49 +01:00
Tiezhu Yang
bc2e7c7daa gdb: testsuite: show print array-indexes after set in arrayidx.exp
Add "show print array-indexes" testcases after set print array-indexes
to off or on.

Without this patch:

    PASS: gdb.base/arrayidx.exp: set print array-indexes to off
    PASS: gdb.base/arrayidx.exp: print array with array-indexes off
    PASS: gdb.base/arrayidx.exp: set print array-indexes to on
    PASS: gdb.base/arrayidx.exp: print array with array-indexes on

With this patch:

    PASS: gdb.base/arrayidx.exp: set print array-indexes to off
    PASS: gdb.base/arrayidx.exp: show print array-indexes is off
    PASS: gdb.base/arrayidx.exp: print array with array-indexes off
    PASS: gdb.base/arrayidx.exp: set print array-indexes to on
    PASS: gdb.base/arrayidx.exp: show print array-indexes is on
    PASS: gdb.base/arrayidx.exp: print array with array-indexes on

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-01-08 14:43:00 +04:00
Lancelot SIX
202fb84085 gdb/testsuite: Remove duplicates from gdb.mi/mi-catch-load.exp
When I run the testsuite, I have:

    Running .../gdb/testsuite/gdb.mi/mi-catch-load.exp ...
    DUPLICATE: gdb.mi/mi-catch-load.exp: breakpoint at main
    DUPLICATE: gdb.mi/mi-catch-load.exp: mi runto main

Fix by grouping the various phases in with_test_prefix blocks.  Since
the tests now have a prefix, remove the manually written prefixes in
testnames.

Also change some messages with the pattern "(timeout) $testname" into
"$estname (timeout)" since tools will handle this as $testname[1] (which
is what we want in this particular scenario).

Tested on x86_64-linux.

[1] https://sourceware.org/gdb/wiki/GDBTestcaseCookbook#Do_not_use_.22tail_parentheses.22_on_test_messages
2022-01-07 22:43:34 +00:00
Lancelot SIX
4df98d9d31 gdb/testsuite: Remove duplicates from gdb.threads/staticthreads.ex
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.threads/staticthreads.exp ...
    DUPLICATE: gdb.threads/staticthreads.exp: couldn't compile staticthreads.c: unrecognized error

Fix by using foreach_with_prefix instead of foreach when preparing the
test case.

Testeed on x86_64-linux both in a setup where the test fails to prepare
and in a setup where the test fails to setup.
2022-01-07 22:43:34 +00:00
Lancelot SIX
0b6180fe6e gdb/testsuite: Remove duplicates from gdb.mi/mi-language.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.mi/mi-language.exp ...
    DUPLICATE: gdb.mi/mi-language.exp: set lang ada

This is due to an erroneous explicit test name.  This explicit test name
also happens to be useless (at least it would have been if it was
correct) since it only repeats the command, so just remove the explicit
test name and let the command be used as default test name.  Also remove
explicit test name at another location in the file since it also just
repeat the command.

Tested on x86_64-linux.
2022-01-07 22:43:34 +00:00
Lancelot SIX
dd1655dfc3 gdb/testsuite: Remove duplicates from gdb.mi/mi-nonstop-exit.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.mi/mi-nonstop-exit.exp ...
    DUPLICATE: gdb.mi/mi-nonstop-exit.exp: breakpoint at main
    DUPLICATE: gdb.mi/mi-nonstop-exit.exp: mi runto main

This test runs the same sequence of operations twice.  Refactor the code
by running both of those sequences within a foreach_with_prefix block to
ensure that the commands have unique test names.

Tested on x86_64-linux.
2022-01-07 22:43:34 +00:00
Lancelot SIX
94e3acde23 gdb/testsuite: Remove duplicates from gdb.mi/mi-nonstop.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.mi/mi-nonstop.exp ...
    DUPLICATE: gdb.mi/mi-nonstop.exp: check varobj, w1, 1
    DUPLICATE: gdb.mi/mi-nonstop.exp: stacktrace of stopped thread

Fix by adjusting the problematic test names.

Tested on x86_64-linux.
2022-01-07 22:43:34 +00:00
Lancelot SIX
b4130189f9 gdb/testsuite: Remove duplicates from gdb.mi/mi-nsthrexec.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.mi/mi-nsthrexec.exp ...
    DUPLICATE: gdb.mi/mi-nsthrexec.exp: breakpoint at main

Fix by adjusting the duplicated test name.

Tested on x86_64-linux.
2022-01-07 22:43:34 +00:00
Lancelot SIX
b64f5c8817 gdb/testsuite: Remove duplicates from gdb.base/watchpoints.exp
When running the testsuite, I have:

    Running ../gdb/testsuite/gdb.base/watchpoints.exp ...
    DUPLICATE: gdb.base/watchpoints.exp: watchpoint hit, first time

Fix by adjusting the test names where appropriate.

Tested on x86_64-linux.
2022-01-07 22:43:34 +00:00
Lancelot SIX
c6336a6db0 gdb/testsuite: Remove duplicates from gdb.base/nested-subp2.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/nested-subp2.exp ...
    DUPLICATE: gdb.base/nested-subp2.exp: continue to the STOP marker
    DUPLICATE: gdb.base/nested-subp2.exp: print c
    DUPLICATE: gdb.base/nested-subp2.exp: print count

Fix by using with_test_prefix to differentiate the test that are
performed at different points during the execution of the debuggee.

Tested on x86_64-linux.
2022-01-07 22:43:34 +00:00
Lancelot SIX
8cc261b781 gdb/testsuite: Remove duplicates from gdb.base/call-signal-resume.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/call-signal-resume.exp ...
    DUPLICATE: gdb.base/call-signal-resume.exp: dummy stack frame number
    DUPLICATE: gdb.base/call-signal-resume.exp: set confirm off
    DUPLICATE: gdb.base/call-signal-resume.exp: return

This is due to the fact that a pattern was probably copy/pasted to
re-use the logic while not adjusting the test names to avoid the
duplication.

Fix by removing the redundant tests ('set confirm off' only needs to be
used once) and adjusting the test names where appropriate.

Tested on x86_64-linux.
2022-01-07 22:43:34 +00:00
Lancelot SIX
148ac50e89 gdb/testsuite: Remove duplicates from gdb.base/pointers.exp
When I run the testsuite, I have :

    Running .../gdb/testsuite/gdb.base/pointers.exp ...
    DUPLICATE: gdb.base/pointers.exp: pointer assignment

Fix by placing the sections with duplication in with_test_prefix blocks.
This removes the duplication and gives a better organization the file.

Tested on x86_64-linux.
Co-Authored-By: Pedro Alves <pedro@palves.net>
2022-01-07 22:43:34 +00:00
Lancelot SIX
bfc9663f9b gdb/testsuite: Remove duplicates from gdb.base/unload.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/unload.exp ...
    DUPLICATE: gdb.base/unload.exp: continuing to unloaded libfile

Fix by adjusting the test name.

Tested on x86_64-linux.
2022-01-07 22:43:33 +00:00
Lancelot SIX
bcce3429ff gdb/testsuite: Remove duplicates from gdb.base/define-prefix.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/define-prefix.exp ...
    DUPLICATE: gdb.base/define-prefix.exp: define user command: ghi-prefix-cmd

Fix by adjusting test names.

Tested on x86_64-linux.
2022-01-07 22:43:33 +00:00
Lancelot SIX
2dc330089a gdb/testsuite: Remove duplicates from gdb.base/funcargs.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/funcargs.exp ...
    DUPLICATE: gdb.base/funcargs.exp: run to call2a

Fix by using proc_with_prefix instead on plain proc to create logical
function blocks.

Tested on x86_64-linux.
2022-01-07 22:43:33 +00:00