Compare commits

...

129 Commits

Author SHA1 Message Date
Joel Brobecker
c599303f92 Set GDB version number to 11.1.
gdb/ChangeLog:

	* version.in: Set GDB version number to 11.1.
2021-09-12 18:32:10 -07:00
GDB Administrator
73a2711e86 Automatic date update in version.in 2021-09-13 00:00:33 +00:00
GDB Administrator
23b81cc63e Automatic date update in version.in 2021-09-12 00:00:16 +00:00
GDB Administrator
0c177cbe0a Automatic date update in version.in 2021-09-11 00:00:19 +00:00
Tom de Vries
7883d1e157 [gdb/testsuite] Handle unrecognized command line option in gdb_compile_test
When running the gdb testsuite with gnatmake-4.8, I get many fails of the
following form:
...
gcc: error: unrecognized command line option '-fgnat-encodings=all'^M
gnatmake: "gdb.ada/O2_float_param/foo.adb" compilation error^M
compiler exited with status 1
compilation failed: gcc ... gdb.ada/O2_float_param/foo.adb
gcc: error: unrecognized command line option '-fgnat-encodings=all'
gnatmake: "gdb.ada/O2_float_param/foo.adb" compilation error
FAIL: gdb.ada/O2_float_param.exp: scenario=all: compilation foo.adb
...

Fix this by marking the test unsupported instead, such that we have:
...
UNSUPPORTED: gdb.ada/O2_float_param.exp: scenario=all: compilation foo.adb \
  (unsupported option '-fgnat-encodings=all')
...

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-09-10  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (gdb_compile_test): Handle unrecognized command line
	option.
2021-09-10 18:36:36 +02:00
GDB Administrator
55fc911ad6 Automatic date update in version.in 2021-09-10 00:00:19 +00:00
Tom Tromey
b06653b60a Add ChangeLog entry for previous patch
I forgot to 'git commit' the ChangeLog for the previous patch.

2021-09-08  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.h (dwarf2_per_objfile::resize_symtabs): Remove.
	* dwarf2/read.c (all_comp_units_iterator, all_comp_units_range):
	New classes.
	(dwarf2_per_objfile::symtab_set_p)
	(dwarf2_per_objfile::get_symtab, dwarf2_per_objfile::set_symtab):
	Adjust to resizeable vectors.
	(dwarf2_gdb_index::expand_symtabs_matching)
	(dwarf2_base_index_functions::map_symbol_filenames)
	(dwarf2_debug_names_index::expand_symtabs_matching): Use
	all_comp_units_range.
	(dwarf2_initialize_objfile, dwarf2_build_psymtabs)
	(add_type_unit): Don't call resize_symtabs.
2021-09-09 09:58:12 -06:00
Tom de Vries
5e6741a157 [gdb/testsuite] Fix gdb.base/coredump-filter-build-id.exp with older eu-unstrip
On openSUSE Leap 42.3 with eu-unstrip 0.158, we run into:
...
(gdb) PASS: gdb.base/coredump-filter-build-id.exp: save corefile
First line of eu-unstrip: \
  0x400000+0x202000 f4ae8502bd6a14770182382316bc595e9dc6f08b@0x400284 - - [exe]
FAIL: gdb.base/coredump-filter-build-id.exp: gcore dumped mapping with build-id
...

The test expects an actual file name instead of '[exe]', but that only got
introduced with eu-unstrip 0.161.  Before it printed '[exe]' or '[pie]'.

Fix this by updating the regexp.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-09-09  Tom de Vries  <tdevries@suse.de>

	* gdb.base/coredump-filter-build-id.exp: Handle older eu-unstrip.
2021-09-09 13:55:02 +02:00
Tom de Vries
127e9f8549 [gdb/testsuite] Fix various issues in gdb.mi/mi-sym-info.exp
I noticed this failure in gdb.mi/mi-sym-info.exp with gcc-4.8:
...
FAIL: gdb.mi/mi-sym-info.exp: -symbol-info-functions --max-results 1 \
  (unexpected output)
...
due to function f2 instead of f3 being listed.

AFAICT, this is caused by a difference in debug info:
...
$ readelf -wi outputs/gdb.mi/mi-sym-info/mi-sym-info1.o \
  | egrep "DW_AT_name.*: f[1-3]"
    <72>   DW_AT_name        : f1
    <a1>   DW_AT_name        : f2
    <d0>   DW_AT_name        : f3
...
vs:
...
$ readelf -wi outputs/gdb.mi/mi-sym-info/mi-sym-info1.o \
  | egrep "DW_AT_name.*: f[1-3]"
    <f4>   DW_AT_name        : f3
    <123>   DW_AT_name        : f2
    <152>   DW_AT_name        : f1
...
and the command documentation does not mention an imposed order, so fix this
by allowing f2 as well.

Doing this fix, it made sense to do a refactoring of adding f2_re and f3_re
variables, in order to write (?:$f2_re|$f3_re), and I applied the same pattern
overall.

Furthermore, I found a silent FAIL due to calling mi_gdb_proc with 2 args, fix
by updating the regexp.

Then I ran with clang and found another FAIL, fix by updating the regexp.

Tested on x86_64-linux with gcc-4.8.5, gcc-7.5.0, gcc-11.2.1, clang-7.0.1 and
clang-12.0.1.

gdb/testsuite/ChangeLog:

2021-09-09  Tom de Vries  <tdevries@suse.de>

	* gdb.mi/mi-sym-info.exp: Fix regexps.  Add missing message argument
	to mi_gdb_test.  Factor out regexps for functions and variables.
2021-09-09 13:55:02 +02:00
GDB Administrator
706ff47ce2 Automatic date update in version.in 2021-09-09 00:00:21 +00:00
Tom Tromey
de2143d60b Fix two regressions caused by CU / TU merging
PR symtab/28160 and PR symtab/27893 concern GDB crashes in the test
suite when using the "fission" target board.  They are both caused by
the patches that merge the list of CUs with the list of TUs (and to a
lesser degree by the patches to share DWARF data across objfiles), and
the underlying issue is the same: it turns out that reading a DWO can
cause new type units to be created.  This means that the list of
dwarf2_per_cu_data objects depends on precisely which CUs have been
expanded.  However, because the type units can be created while
expanding a CU means that the vector of CUs can expand while it is
being iterated over -- a classic mistake.  Also, because a TU can be
added later, it means the resize_symtabs approach is incorrect.

This patch fixes resize_symtabs by removing it, and having set_symtab
resize the vector on demand.  It fixes the iteration problem by
introducing a safe (index-based) iterator and changing the relevant
spots to use it.

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

(cherry picked from commit d58e54bd27)
2021-09-08 14:50:50 -06:00
Luis Machado
cdf4e8ae55 Revert: [AArch64] MTE corefile support
bfd     * elf.c (elfcore_make_memtag_note_section): New function.
		(elfcore_grok_note): Handle NT_MEMTAG note types.

	binutils* readelf.c (get_note_type): Handle NT_MEMTAG note types.

	include * elf/common.h (NT_MEMTAG): New constant.
		(NT_MEMTAG_TYPE_AARCH_MTE): New constant.
2021-09-08 08:58:44 -03:00
GDB Administrator
dd0fea103f Automatic date update in version.in 2021-09-08 00:00:27 +00:00
John Baldwin
aaa394b7df fbsd-nat: Don't use '%jd' and '%ju' with printf_filtered.
The handler for 'info proc status' for native processes on FreeBSD
uses the 'j' size modifier along with uintmax_t / intmax_t casts to
output integer values for types such as off_t that are not aliases of
a basic C type such as 'int' or 'long'.  printf_filtered does not
support the 'j' modifer, so this resulted in runtime errors in
practice:

(gdb) info proc stat
process 8674
Name: ls
State: T (stopped)
Parent process: 8673
Process group: 8674
Session id: 2779
Unrecognized format specifier 'j' in printf

Instead, use plongest and pulongest to generate the output strings of
these integer values.

gdb/ChangeLog:

	* fbsd-nat.c (fbsd_nat_target::info_proc): Use plongest and
	pulongest instead of %j.
2021-09-07 16:09:17 -07:00
GDB Administrator
1aa04a582c Automatic date update in version.in 2021-09-07 00:00:19 +00:00
GDB Administrator
244d1aadd7 Automatic date update in version.in 2021-09-06 00:00:26 +00:00
GDB Administrator
2b195da8a2 Automatic date update in version.in 2021-09-05 00:00:30 +00:00
Tom de Vries
a6e40b53ef [gdb/testsuite] Check avx support in gdb.arch/amd64-disp-step-avx.exp
On a machine on Open Build Service I'm running into a SIGILL for test-case
gdb.arch/amd64-disp-step-avx.exp:
...
Program received signal SIGILL, Illegal instruction.^M
test_rip_vex2 () at gdb.arch/amd64-disp-step-avx.S:40^M
40              vmovsd ro_var(%rip),%xmm0^M
(gdb) FAIL: gdb.arch/amd64-disp-step-avx.exp: vex2: \
  continue to test_rip_vex2_end
...
The SIGILL happens when trying to execute the first avx instruction in the
executable.

I can't directly access the machine, but looking at the log for test-case
gdb.arch/i386-avx.exp, it seems that there's no avx support:
...
Breakpoint 1, main (argc=1, argv=0x7fffffffd6b8) at gdb.arch/i386-avx.c:68^M
68        if (have_avx ())^M
(gdb) print have_avx ()^M
$1 = 0^M
...

Fix this by:
- adding a gdb_caching_proc have_avx, similar to have_mpx, using the have_avx
  function from gdb.arch/i386-avx.c
- using proc have_avx in both gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp
  and gdb/testsuite/gdb.arch/i386-avx.exp.

Tested on my x86_64-linux laptop with avx support, where both test-cases pass.

gdb/testsuite/ChangeLog:

2021-09-04  Tom de Vries  <tdevries@suse.de>

	PR testsuite/26950
	* gdb/testsuite/gdb.arch/i386-avx.c (main): Remove call to have_avx.
	(have_avx): Move ...
	* gdb/testsuite/lib/gdb.exp (have_avx): ... here.  New proc.
	* gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp: Use have_avx.
	* gdb/testsuite/gdb.arch/i386-avx.exp: Same.
2021-09-04 12:11:35 +02:00
GDB Administrator
76c001c234 Automatic date update in version.in 2021-09-04 00:00:24 +00:00
Tom de Vries
e34a209edf [gdb/testsuite] Add untested case in gdb.gdb/complaints.exp
When building gdb with "-Wall -O2 -g -flto=auto", I run into:
...
(gdb) call clear_complaints()^M
No symbol "clear_complaints" in current context.^M
(gdb) FAIL: gdb.gdb/complaints.exp: clear complaints
...

The problem is that lto has optimized away clear_complaints, and consequently
the selftests cannot run.

Fix this by:
- using info function to detect presence of clear_complaints
- handling the absence of clear_complaints by calling untested
...
(gdb) UNTESTED: gdb.gdb/complaints.exp: \
  Cannot find clear_complaints, skipping test
...

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-09-03  Tom de Vries  <tdevries@suse.de>

	* gdb.gdb/complaints.exp: Use untested if clear_complaints cannot
	be found.
2021-09-03 17:40:10 +02:00
Tom de Vries
5c177fed07 [gdb/testsuite] Add untested case in selftest_setup
When building gdb with "-Wall -O2 -g -flto=auto", I run into:
...
FAIL: gdb.gdb/python-helper.exp: breakpoint in captured_main \
  (got interactive prompt)
FAIL: gdb.gdb/python-helper.exp: run until breakpoint at captured_main
WARNING: Couldn't test self
...
and similar in gdb.gdb/selftest.exp.

The first FAIL in more detail:
...
(gdb) break captured_main^M
Function "captured_main" not defined.^M
Make breakpoint pending on future shared library load? (y or [n]) n^M
(gdb) FAIL: gdb.gdb/python-helper.exp: breakpoint in captured_main \
  (got interactive prompt)
...

The problem is that lto has optimized away the captured_main function
and consequently the selftests dependent on that cannot run.

Fix this by:
- using gdb_breakpoint to detect failure to set the breakpoint
- handling the failure to set a breakpoint by calling untested
- not emitting the warning if we've already got untested
such that we have:
...
(gdb) UNTESTED: gdb.gdb/python-helper.exp: Cannot set breakpoint at \
  captured_main, skipping testcase.
...

gdb/testsuite/ChangeLog:

2021-09-03  Tom de Vries  <tdevries@suse.de>

	* lib/selftest-support.exp: Emit untested when not being able to set
	breakpoint.
2021-09-03 15:13:14 +02:00
GDB Administrator
c6c2468fdf Automatic date update in version.in 2021-09-03 00:00:38 +00:00
GDB Administrator
26db900e8d Automatic date update in version.in 2021-09-02 00:00:29 +00:00
Tom de Vries
c52e9db30f [gdb/testsuite] Fix dwo path in fission-*.S
[ Using $build for /home/vries/gdb_versions/devel/build to make things a bit
more readable. ]

When using make check// to run test-case gdb.dwarf2/fission-base.exp:
...
( cd $build/gdb; make check//unix RUNTESTFLAGS="fission-base.exp" )
...
we run into:
...
(gdb) file \
  $build/gdb/testsuite.unix/outputs/gdb.dwarf2/fission-base/fission-base^M
Reading symbols from \
  $build/gdb/testsuite.unix/outputs/gdb.dwarf2/fission-base/fission-base...^M
warning: Could not find DWO CU \
  $build/gdb/testsuite.1/outputs/gdb.dwarf2/fission-base/fission-base.dwo \
  (0x807060504030201) referenced by CU at offset 0xc7 [in module \
  $build/gdb/testsuite.unix/outputs/gdb.dwarf2/fission-base/fission-base]^M
...

The problem is that the executable refers to the dwo file using path name
$build/gdb/testsuite.1/outputs/gdb.dwarf2/fission-base/fission-base.dwo,
while the actual dwo file is at
$build/gdb/testsuite.unix/outputs/gdb.dwarf2/fission-base/fission-base.dwo.

This is caused by this trick in fission-base.S:
...
 #define XSTR(s) STR(s)
 #define STR(s) #s
   ...
   .asciz XSTR(DWO)        # DW_AT_GNU_dwo_name
...
and:
...
$ echo | gcc -E -dD - | grep "define unix"
...

I used this trick to avoid doing additional_flags=-DDWO=\"$dwo\", since I was
concerned that there could be quoting issues.

However, I've found other uses of this pattern, f.i. in
gdb/testsuite/gdb.base/corefile-buildid.exp:
...
  additional_flags=-DSHLIB_NAME=\"$dlopen_lib\"]
...

So, fix this by:
- using additional_flags=-DDWO=\"$dwo\" and
- using plain DWO instead of XSTR(DWO)

Likewise in other gdb.dwarf2/fission*.exp test-cases.

Tested on x86_64-linux, using make check//unix.

gdb/testsuite/ChangeLog:

2021-09-01  Tom de Vries  <tdevries@suse.de>

	PR testsuite/28298
	* gdb.dwarf2/fission-base.S: Use DWO instead of XSTR(DWO).
	* gdb.dwarf2/fission-loclists-pie.S: Same.
	* gdb.dwarf2/fission-loclists.S: Same.
	* gdb.dwarf2/fission-reread.S: Same.
	* gdb.dwarf2/fission-base.exp: Use additional_flags=-DDWO=\"$dwo\".
	* gdb.dwarf2/fission-loclists-pie.exp: Same.
	* gdb.dwarf2/fission-loclists.exp: Same.
	* gdb.dwarf2/fission-reread.exp: Same.
2021-09-01 20:14:53 +02:00
Tom de Vries
351b63eca9 [gdb/testsuite] Fix gdb.fortran/call-no-debug.exp symbol search
On openSUSE Tumbleweed I ran into:
...
(gdb) ptype outstring_func.part^M
No symbol "outstring_func" in current context.^M
(gdb) FAIL: gdb.fortran/call-no-debug.exp: ptype outstring_func.part
...
while on openSUSE Leap 15.2 I have instead:
...
(gdb) ptype string_func_^M
type = <unknown return type> ()^M
(gdb) PASS: gdb.fortran/call-no-debug.exp: ptype string_func_
...

The difference is caused by the result for "info function string_func", which
is this for the latter:
...
(gdb) info function string_func^M
All functions matching regular expression "string_func":^M
^M
Non-debugging symbols:^M
0x000000000040089c  string_func_^M
...
but this for the former:
...
(gdb) info function string_func^M
All functions matching regular expression "string_func":^M
^M
Non-debugging symbols:^M
0x00000000004012bb  string_func_^M
0x00007ffff7bac5b0  outstring_func.part^M
0x00007ffff7bb1a00  outstring_func.part^M
...

The extra symbols are part of glibc:
...
$ nm /lib64/libc.so.6 | grep string_func
00000000000695b0 t outstring_func.part.0
000000000006ea00 t outstring_func.part.0
...

If glibc debug info is installed, we get instead:
...
(gdb) info function string_func^M
All functions matching regular expression "string_func":^M
^M
File /usr/src/debug/glibc-2.33-9.1.x86_64/stdio-common/vfprintf-internal.c:^M
236:    static int outstring_func(int, size_t, const unsigned int *, FILE *);^M
^M
File vfprintf-internal.c:^M
236:    static int outstring_func(int, size_t, const unsigned char *, FILE *);^M
^M
Non-debugging symbols:^M
0x00000000004012bb  string_func_^M
...
and the FAIL doesn't trigger.

Fix this by calling "info function string_func" before starting the exec, such
that only symbols of the exec are taken into account.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-09-01  Tom de Vries  <tdevries@suse.de>

	* gdb.fortran/call-no-debug.exp: Avoid shared lib symbols for
	find_mangled_name calls.
2021-09-01 11:38:02 +02:00
GDB Administrator
5b766b015c Automatic date update in version.in 2021-09-01 00:00:25 +00:00
GDB Administrator
8ba9495958 Automatic date update in version.in 2021-08-31 00:00:22 +00:00
Tom de Vries
e1652de24a [gdb/cli] Don't assert on empty string for core-file
With current gdb we run into:
...
$ gdb -batch '' ''
: No such file or directory.
pathstuff.cc:132: internal-error: \
  gdb::unique_xmalloc_ptr<char> gdb_abspath(const char*): \
  Assertion `path != NULL && path[0] != '\0'' failed.
...

Fix this by skipping the call to gdb_abspath in core_target_open in the
empty-string case, such that we have instead:
...
$ gdb -batch '' ''
: No such file or directory.
: No such file or directory.
$
...

Tested on x86_64-linux.

gdb/ChangeLog:

2021-08-30  Tom de Vries  <tdevries@suse.de>

	PR cli/28290
	* gdb/corelow.c (core_target_open): Skip call to gdb_abspath in the
	empty-string case.

gdb/testsuite/ChangeLog:

2021-08-30  Tom de Vries  <tdevries@suse.de>

	PR cli/28290
	* gdb.base/batch-exit-status.exp: Add gdb '' and gdb '' '' tests.
2021-08-30 16:03:15 +02:00
GDB Administrator
897254e073 Automatic date update in version.in 2021-08-30 00:00:17 +00:00
GDB Administrator
0f6a3150d5 Automatic date update in version.in 2021-08-29 00:00:20 +00:00
GDB Administrator
7350820d0d Automatic date update in version.in 2021-08-28 00:00:22 +00:00
GDB Administrator
f566731d15 Automatic date update in version.in 2021-08-27 00:00:23 +00:00
GDB Administrator
c986baa363 Automatic date update in version.in 2021-08-26 00:00:27 +00:00
GDB Administrator
1862155361 Automatic date update in version.in 2021-08-25 00:00:21 +00:00
GDB Administrator
106177faac Automatic date update in version.in 2021-08-24 00:00:23 +00:00
Tom de Vries
2840a1862b [gdb] Fix 'not in executable format' error message
With trying to load a non-executable file into gdb, we run into PR26880:
...
$ gdb -q -batch test.c
"0x7ffc87bfc8d0s": not in executable format: \
  file format not recognized
...

The problem is caused by using %ps in combination with the error function
(note that confusingly, it does work in combination with the warning
function).

Fix this by using plain "%s" instead.

Tested on x86_64-linux.

gdb/ChangeLog:

2021-08-23  Tom de Vries  <tdevries@suse.de>

	PR gdb/26880
	* gdb/exec.c (exec_file_attach): Use %s instead of %ps in call to
	error function.

gdb/testsuite/ChangeLog:

2021-08-23  Tom de Vries  <tdevries@suse.de>

	PR gdb/26880
	* gdb.base/non-executable.exp: New file.
2021-08-23 21:08:51 +02:00
GDB Administrator
61bdb9457a Automatic date update in version.in 2021-08-23 00:00:18 +00:00
GDB Administrator
eccb3ba799 Automatic date update in version.in 2021-08-22 00:00:22 +00:00
GDB Administrator
e284d00d3e Automatic date update in version.in 2021-08-21 00:00:30 +00:00
GDB Administrator
e0e48e8cf9 Automatic date update in version.in 2021-08-20 00:00:19 +00:00
GDB Administrator
8f1a907b47 Automatic date update in version.in 2021-08-19 00:00:56 +00:00
GDB Administrator
89c2f0e527 Automatic date update in version.in 2021-08-18 00:00:44 +00:00
GDB Administrator
6fc08811a1 Automatic date update in version.in 2021-08-17 00:00:46 +00:00
GDB Administrator
8609cba017 Automatic date update in version.in 2021-08-16 00:00:40 +00:00
GDB Administrator
dc1daf51ae Automatic date update in version.in 2021-08-15 00:01:17 +00:00
GDB Administrator
c9e63461e5 Automatic date update in version.in 2021-08-14 00:00:38 +00:00
GDB Administrator
86cf585239 Automatic date update in version.in 2021-08-13 00:00:49 +00:00
Tom Tromey
d2374b0755 Update documentation to mention Pygments
Philippe Blain pointed out that the gdb documentation does not mention
that Pygments may be used for source highlighting.  This patch updates
the docs to reflect how highlighting is actually done.

(cherry picked from commit 6a33fa0efe)

gdb/doc/ChangeLog
2021-08-12  Tom Tromey  <tromey@adacore.com>

	* gdb.texinfo (Output Styling): Mention Pygments.
2021-08-12 14:29:56 -06:00
GDB Administrator
fb1b7fcec2 Automatic date update in version.in 2021-08-12 00:00:52 +00:00
GDB Administrator
1780f3e77e Automatic date update in version.in 2021-08-11 00:00:42 +00:00
GDB Administrator
b80f2606ef Automatic date update in version.in 2021-08-10 00:00:46 +00:00
GDB Administrator
d26ac0b905 Automatic date update in version.in 2021-08-09 00:00:51 +00:00
GDB Administrator
246c1d7974 Automatic date update in version.in 2021-08-08 00:00:40 +00:00
GDB Administrator
b3dc0eac65 Automatic date update in version.in 2021-08-07 00:00:41 +00:00
Tom de Vries
a656ee0831 [gdb/symtab] Fix zero address complaint for shlib
In PR28004 the following warning / Internal error is reported:
...
$ gdb -q -batch \
    -iex "set sysroot $(pwd -P)/repro" \
    ./repro/gdb \
    ./repro/core \
    -ex bt
  ...
 Program terminated with signal SIGABRT, Aborted.
 #0  0x00007ff8fe8e5d22 in raise () from repro/usr/lib/libc.so.6
 [Current thread is 1 (LWP 1762498)]
 #1  0x00007ff8fe8cf862 in abort () from repro/usr/lib/libc.so.6
 warning: (Internal error: pc 0x7ff8feb2c21d in read in psymtab, \
           but not in symtab.)
 warning: (Internal error: pc 0x7ff8feb2c218 in read in psymtab, \
           but not in symtab.)
  ...
 #2  0x00007ff8feb2c21e in __gnu_debug::_Error_formatter::_M_error() const \
   [clone .cold] (warning: (Internal error: pc 0x7ff8feb2c21d in read in \
   psymtab, but not in symtab.)

) from repro/usr/lib/libstdc++.so.6
...

The warning is about the following:
- in find_pc_sect_compunit_symtab we try to find the address
  (0x7ff8feb2c218 / 0x7ff8feb2c21d) in the symtabs.
- that fails, so we try again in the partial symtabs.
- we find a matching partial symtab
- however, the partial symtab has a full symtab, so
  we should have found a matching symtab in the first step.

The addresses are:
...
(gdb) info sym 0x7ff8feb2c218
__gnu_debug::_Error_formatter::_M_error() const [clone .cold] in \
  section .text of repro/usr/lib/libstdc++.so.6
(gdb) info sym 0x7ff8feb2c21d
__gnu_debug::_Error_formatter::_M_error() const [clone .cold] + 5 in \
  section .text of repro/usr/lib/libstdc++.so.6
...
which correspond to unrelocated addresses 0x9c218 and 0x9c21d:
...
$ nm -C  repro/usr/lib/libstdc++.so.6.0.29 | grep 000000000009c218
000000000009c218 t __gnu_debug::_Error_formatter::_M_error() const \
  [clone .cold]
...
which belong to function __gnu_debug::_Error_formatter::_M_error() in
/build/gcc/src/gcc/libstdc++-v3/src/c++11/debug.cc.

The partial symtab that is found for the addresses is instead the one for
/build/gcc/src/gcc/libstdc++-v3/src/c++98/bitmap_allocator.cc, which is
incorrect.

This happens as follows.

The bitmap_allocator.cc CU has DW_AT_ranges at .debug_rnglist offset 0x4b50:
...
    00004b50 0000000000000000 0000000000000056
    00004b5a 00000000000a4790 00000000000a479c
    00004b64 00000000000a47a0 00000000000a47ac
...

When reading the first range 0x0..0x56, it doesn't trigger the "start address
of zero" complaint here:
...
      /* A not-uncommon case of bad debug info.
         Don't pollute the addrmap with bad data.  */
      if (range_beginning + baseaddr == 0
          && !per_objfile->per_bfd->has_section_at_zero)
        {
          complaint (_(".debug_rnglists entry has start address of zero"
                       " [in module %s]"), objfile_name (objfile));
          continue;
        }
...
because baseaddr != 0, which seems incorrect given that when loading the
shared library individually in gdb (and consequently baseaddr == 0), we do see
the complaint.

Consequently, we run into this case in dwarf2_get_pc_bounds:
...
  if (low == 0 && !per_objfile->per_bfd->has_section_at_zero)
    return PC_BOUNDS_INVALID;
...
which then results in this code in process_psymtab_comp_unit_reader being
called with cu_bounds_kind == PC_BOUNDS_INVALID, which sets the set_addrmap
argument to 1:
...
      scan_partial_symbols (first_die, &lowpc, &highpc,
                            cu_bounds_kind <= PC_BOUNDS_INVALID, cu);
...
and consequently, the CU addrmap gets build using address info from the
functions.

During that process, addrmap_set_empty is called with a range that includes
0x9c218 and 0x9c21d:
...
(gdb) p /x start
$7 = 0x9989c
(gdb) p /x end_inclusive
$8 = 0xb200d
...
but it's called for a function at DIE 0x54153 with DW_AT_ranges at 0x40ae:
...
    000040ae 00000000000b1ee0 00000000000b200e
    000040b9 000000000009989c 00000000000998c4
    000040c3 <End of list>
...
and neither range includes 0x9c218 and 0x9c21d.

This is caused by this code in partial_die_info::read:
...
            if (dwarf2_ranges_read (ranges_offset, &lowpc, &highpc, cu,
                                    nullptr, tag))
             has_pc_info = 1;
...
which pretends that the function is located at addresses 0x9989c..0xb200d,
which is indeed not the case.

This patch fixes the first problem encountered: fix the "start address of
zero" complaint warning by removing the baseaddr part from the condition.
Same for dwarf2_ranges_process.

The effect is that:
- the complaint is triggered, and
- the warning / Internal error is no longer triggered.

This does not fix the observed problem in partial_die_info::read, which is
filed as PR28200.

Tested on x86_64-linux.

Co-Authored-By: Simon Marchi <simon.marchi@polymtl.ca>

gdb/ChangeLog:

2021-08-06  Simon Marchi  <simon.marchi@polymtl.ca>
	    Tom de Vries  <tdevries@suse.de>

	PR symtab/28004
	* dwarf2/read.c (dwarf2_rnglists_process, dwarf2_ranges_process):
	Fix zero address complaint.

gdb/testsuite/ChangeLog:

2021-08-06  Simon Marchi  <simon.marchi@polymtl.ca>
	    Tom de Vries  <tdevries@suse.de>

	PR symtab/28004
	* gdb.dwarf2/dw2-zero-range-shlib.c: New test.
	* gdb.dwarf2/dw2-zero-range.c: New test.
	* gdb.dwarf2/dw2-zero-range.exp: New file.
2021-08-06 18:02:28 +02:00
GDB Administrator
76e1bef3bf Automatic date update in version.in 2021-08-06 00:00:39 +00:00
GDB Administrator
91a78f327b Automatic date update in version.in 2021-08-05 00:01:00 +00:00
GDB Administrator
e649c6c2a2 Automatic date update in version.in 2021-08-04 00:00:46 +00:00
GDB Administrator
4b7e7a3499 Automatic date update in version.in 2021-08-03 00:00:48 +00:00
Tom Tromey
3e5ec878a4 Avoid crash in varobj deletion
PR varobj/28131 points out a crash in the varobj deletion code.  It
took a while to reproduce this, but essentially what happens is that a
top-level varobj deletes its root object, then deletes the "dynamic"
object.  However, deletion of the dynamic object may cause
~py_varobj_iter to run, which in turn uses gdbpy_enter_varobj:

gdbpy_enter_varobj::gdbpy_enter_varobj (const struct varobj *var)
: gdbpy_enter (var->root->exp->gdbarch, var->root->exp->language_defn)
{
}

However, because var->root has already been destroyed, this is
invalid.

I've added a new test case.  This doesn't reliably crash, but the
problem can easily be seen under valgrind (and, I presume, with ASAN,
though I did not try this).

Tested on x86-64 Fedora 32.  I also propose putting this on the GDB 11
branch, with a suitable ChangeLog entry of course.

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

(cherry picked from commit 4d0754c5f5)

gdb/ChangeLog
2021-08-02  Tom Tromey  <tromey@adacore.com>

	PR varobj/28131
	* varobj.c (~varobj): Delete 'dynamic' before 'root'.

gdb/testsuite/ChangeLog
2021-08-02  Tom Tromey  <tromey@adacore.com>

	PR varobj/28131
	* gdb.python/py-mi-var-info-path-expression.exp: Add regression
	test.
2021-08-02 09:48:58 -06:00
Shahab Vahedi
e4c1aea498 gdb: Make the builtin "boolean" type an unsigned type
When printing the fields of a register that is of a custom struct type,
the "unpack_bits_as_long ()" function is used:

    do_val_print (...)
      cp_print_value_fields (...)
        value_field_bitfield (...)
          unpack_value_bitfield (...)
            unpack_bits_as_long (...)

This function may sign-extend the extracted field while returning it:

    val >>= lsbcount;

    if (...)
      {
        valmask = (((ULONGEST) 1) << bitsize) - 1;
        val &= valmask;
        if (!field_type->is_unsigned ())
  	  if (val & (valmask ^ (valmask >> 1)))
  	      val |= ~valmask;
      }

    return val;

lsbcount:   Number of lower bits to get rid of.
bitsize:    The bit length of the field to be extracted.
val:        The register value.
field_type: The type of field that is being handled.

While the logic here is correct, there is a problem when it is
handling "field_type"s of "boolean".  Those types are NOT marked
as "unsigned" and therefore they end up being sign extended.
Although this is not a problem for "false" (0), it definitely
causes trouble for "true".

This patch constructs the builtin boolean type as such that it is
marked as an "unsigned" entity.

The issue tackled here was first encountered for arc-elf32 target
running on an x86_64 machine.  The unit-test introduced in this change
has passed for all the targets (--enable-targets=all) running on the
same x86_64 host.

gdb/ChangeLog:

	PR gdb/28104
	* gdbtypes.c (gdbtypes_post_init): Use
	"arch_boolean_type (..., unsigned=1, ...) to construct
	"boolean".
	cp-valprint.c (test_print_flags): New.
	(_initialize_cp_valprint): Run the "test_print_flags" unit-test.
2021-08-02 13:04:48 +02:00
GDB Administrator
3bea08edb3 Automatic date update in version.in 2021-08-02 00:00:44 +00:00
GDB Administrator
f9e4d38eec Automatic date update in version.in 2021-08-01 00:00:41 +00:00
GDB Administrator
33a6518147 Automatic date update in version.in 2021-07-31 00:00:51 +00:00
Tom de Vries
7fab8f850f [gdb/build] Disable attribute nonnull
With trunk gcc (12.0) we're running into a -Werror=nonnull-compare build
breaker in gdb, which caused a broader review of the usage of the nonnull
attribute.

The current conclusion is that it's best to disable this.  This is explained
at length in the gdbsupport/common-defs.h comment.

Tested by building with trunk gcc.

gdbsupport/ChangeLog:

2021-07-30  Tom de Vries  <tdevries@suse.de>

	* common-defs.h (ATTRIBUTE_NONNULL): Disable.
2021-07-30 14:12:30 +02:00
GDB Administrator
c0f71837f8 Automatic date update in version.in 2021-07-30 00:00:37 +00:00
GDB Administrator
4e0069d879 Automatic date update in version.in 2021-07-29 00:00:49 +00:00
Tom de Vries
52a49e1615 [gdb/symtab] Fix unhandled dwarf expression opcode with gcc-11 -gdwarf-5
[ I've confused things by forgetting to add -gdwarf-4 in $subject of
commit 0057a7ee0d "[gdb/testsuite] Add KFAILs for gdb.ada FAILs with
gcc-11".  So I'm adding here -gdwarf-5 in $subject, even though -gdwarf-5 is
the default for gcc-11.  I keep getting confused because of working with a
system gcc-11 compiler that was patched to switch the default back to
-gdwarf-4. ]

When running test-case gdb.ada/arrayptr.exp with gcc-11 (and default
-gdwarf-5), I run into:
...
(gdb) print pa_ptr.all^M
Unhandled dwarf expression opcode 0xff^M
(gdb) FAIL: gdb.ada/arrayptr.exp: scenario=all: print pa_ptr.all
...

What happens is that pa_ptr:
...
 <2><1523>: Abbrev Number: 3 (DW_TAG_variable)
    <1524>   DW_AT_name        : pa_ptr
    <1529>   DW_AT_type        : <0x14fa>
...
has type:
...
 <2><14fa>: Abbrev Number: 2 (DW_TAG_typedef)
    <14fb>   DW_AT_name        : foo__packed_array_ptr
    <1500>   DW_AT_type        : <0x1504>
 <2><1504>: Abbrev Number: 4 (DW_TAG_pointer_type)
    <1505>   DW_AT_byte_size   : 8
    <1505>   DW_AT_type        : <0x1509>
...
which is a pointer to a subrange:
...
 <2><1509>: Abbrev Number: 12 (DW_TAG_subrange_type)
    <150a>   DW_AT_lower_bound : 0
    <150b>   DW_AT_upper_bound : 0x3fffffffffffffffff
    <151b>   DW_AT_name        : foo__packed_array
    <151f>   DW_AT_type        : <0x15cc>
    <1523>   DW_AT_artificial  : 1
 <1><15cc>: Abbrev Number: 5 (DW_TAG_base_type)
    <15cd>   DW_AT_byte_size   : 16
    <15ce>   DW_AT_encoding    : 7      (unsigned)
    <15cf>   DW_AT_name        : long_long_long_unsigned
    <15d3>   DW_AT_artificial  : 1
...
with upper bound of form DW_FORM_data16.

In gdb/dwarf/attribute.h we have:
...
  /* Return non-zero if ATTR's value falls in the 'constant' class, or
     zero otherwise.  When this function returns true, you can apply
     the constant_value method to it.
     ...
     DW_FORM_data16 is not considered as constant_value cannot handle
     that.  */
  bool form_is_constant () const;
...
so instead we have attribute::form_is_block (DW_FORM_data16) == true.

Then in attr_to_dynamic_prop for the upper bound, we get a PROC_LOCEXPR
instead of a PROP_CONST and end up trying to evaluate the constant
0x3fffffffffffffffff as if it were a locexpr, which causes the
"Unhandled dwarf expression opcode 0xff".

In contrast, with -gdwarf-4 we have:
...
    <164c>   DW_AT_upper_bound : 18 byte block: \
      9e 10 ff ff ff ff ff ff ff ff 3f 0 0 0 0 0 0 0 \
      (DW_OP_implicit_value 16 byte block: \
        ff ff ff ff ff ff ff ff 3f 0 0 0 0 0 0 0 )
...

Fix the dwarf error by translating the DW_FORM_data16 constant into a
PROC_LOCEXPR, effectively by prepending 0x9e 0x10, such that we have same
result as with -gdwarf-4:
...
(gdb) print pa_ptr.all^M
That operation is not available on integers of more than 8 bytes.^M
(gdb) KFAIL: gdb.ada/arrayptr.exp: scenario=all: print pa_ptr.all \
  (PRMS: gdb/20991)
...

Tested on x86_64-linux, with gcc-11 and target board
unix/gdb:debug_flags=-gdwarf-5.

gdb/ChangeLog:

2021-07-28  Tom de Vries  <tdevries@suse.de>

	* dwarf2/read.c (attr_to_dynamic_prop): Handle DW_FORM_data16.
2021-07-28 10:17:44 +02:00
GDB Administrator
791b706a9e Automatic date update in version.in 2021-07-28 00:00:44 +00:00
Tom de Vries
c12608fcff [gdb/testsuite] Add xfail for PR gcc/101643
With gcc 8.5.0 I run into:
...
(gdb) print bad^M
$2 = (0 => 0 <repeats 25 times>)^M
(gdb) FAIL: gdb.ada/big_packed_array.exp: scenario=minimal: print bad
...
while with gcc 9.3.1 we have instead:
...
(gdb) print bad^M
$2 = (false <repeats 196 times>)^M
(gdb) PASS: gdb.ada/big_packed_array.exp: scenario=minimal: print bad
...

This is caused by gcc PR, which I've filed at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101643 "[debug, ada] packed array
not described as packed".

Fix by marking this as XFAIL.

Tested on x86_64-linux.

gdb/ChangeLog:

2021-07-27  Tom de Vries  <tdevries@suse.de>

	PR testsuite/26904
	* gdb/testsuite/gdb.ada/big_packed_array.exp: Add xfail.
2021-07-27 17:14:18 +02:00
Tom de Vries
7e292f1ab8 [gdb/testsuite] Add xfail for PR gcc/101633
With gcc 7.5.0, I run into:
...
(gdb) print objects^M
$1 = ((tag => object, values => ()), (tag => unused))^M
(gdb) FAIL: gdb.ada/array_of_variant.exp: scenario=minimal: print entire array
...
while with gcc 8.5.0 we have:
...
(gdb) print objects^M
$1 = ((tag => object, values => (2, 2, 2, 2, 2)), (tag => unused))^M
(gdb) PASS: gdb.ada/array_of_variant.exp: scenario=minimal: print entire array
...

This is due to a gcc PR, which I've filed at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101633 "Bug 101633 - [debug]
DW_TAG_subrange_type missing DW_AT_upper_bound".

Fix by marking this and related FAILs as XFAIL.

Tested on x86_64-linux.

gdb/ChangeLog:

2021-07-27  Tom de Vries  <tdevries@suse.de>

	PR testsuite/26903
	* gdb/testsuite/gdb.ada/array_of_variant.exp: Add xfails.
2021-07-27 17:14:17 +02:00
GDB Administrator
26e4f978b0 Automatic date update in version.in 2021-07-27 00:00:45 +00:00
Frederic Cambus
1693a7cf35 Update the NetBSD system call table to match NetBSD-current.
Generated from sys/sys/syscall.h revision 1.319.

We can safely remove the _lwp_gettid syscall, which was never exposed
in libc and never made it into a release.

gdb/ChangeLog:

2021-07-26  Frederic Cambus  <fred@statdns.com>

	* syscalls/netbsd.xml: Regenerate.
2021-07-26 08:14:48 -07:00
Shahab Vahedi
70417f28b5 gdb: Fix numerical field extraction for target description "flags"
The "val_print_type_code_flags ()" function is responsible for
extraction of fields for "flags" data type.  These data types are
used when describing a custom register type in a target description
XML.  The logic used for the extraction though is not sound:

    unsigned field_len = TYPE_FIELD_BITSIZE (type, field);
    ULONGEST field_val
      = val >> (TYPE_FIELD_BITPOS (type, field) - field_len + 1);

TYPE_FIELD_BITSIZE: The bit length of the field to be extracted.
TYPE_FIELD_BITPOS:  The starting position of the field; 0 is LSB.
val:                The register value.

Imagine you have a field that starts at position 1 and its length
is 4 bits.  According to the third line of the code snippet the
shifting right would become "val >> -2", or "val >> 0xfff...fe"
to be precise.  That will result in a "field_val" of 0.

The correct extraction should be:

    ULONGEST field_val = val >> TYPE_FIELD_BITPOS (type, field);

The rest of the algorithm that masks out the higher bits is OK.

gdb/ChangeLog:
2021-07-26  Shahab Vahedi  <shahab@synopsys.com>
            Simon Marchi  <simon.marchi@efficios.com>

	PR gdb/28103
	* valprint.c (val_print_type_code_flags): Merely shift the VAL
	to the right to get rid of the lower bits.
	(test_print_flags): New.
	(_initialize_valprint): Invoke the "test_print_flags" as a unit-test.

Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
2021-07-26 15:05:09 +02:00
Tankut Baris Aktemur
86271cfa32 gdb/mi: handle no condition argument case for -break-condition
As reported in PR gdb/28076 [1], passing no condition argument to the
-break-condition command (e.g.: "-break-condition 2") should clear the
condition for breakpoint 2, just like CLI's "condition 2", but instead
an error message is returned:

  ^error,msg="-break-condition: Missing the <number> and/or <expr> argument"

The current implementation of the -break-condition command's argument
handling (79aabb7308 "gdb/mi: add a '--force' flag to the
'-break-condition' command") was done according to the documentation,
where the condition argument seemed mandatory.  However, the
-break-condition command originally (i.e. before the 79aabb7308
patch) used the CLI's "cond" command, and back then not passing a
condition argument was clearing out the condition.  So, this is a
regression in terms of the behavior.

Fix the argument handling of the -break-condition command to allow not
having a condition argument, and also update the document to make the
behavior clear.  Also add test cases to test the scenarios which were
previously not covered.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=28076

gdb/ChangeLog:
2021-07-26  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	PR gdb/28076
	* mi/mi-cmd-break.c (mi_cmd_break_condition): Handle the case
	of having no condition argument.

gdb/doc/ChangeLog:
2021-07-26  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	PR gdb/28076
	* gdb.texinfo (GDB/MI Breakpoint Commands): Mention clearing
	the condition in the -break-condition command.

gdb/testsuite/ChangeLog:
2021-07-26  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	PR gdb/28076
	* gdb.mi/mi-break.exp: Add more tests to check clearing the
	breakpoint condition.
2021-07-26 08:28:12 +02:00
GDB Administrator
fc3f144a3e Automatic date update in version.in 2021-07-26 00:00:40 +00:00
GDB Administrator
011ab47fa4 Automatic date update in version.in 2021-07-25 00:00:37 +00:00
GDB Administrator
f0927d2036 Automatic date update in version.in 2021-07-24 00:00:33 +00:00
GDB Administrator
c47bde01bb Automatic date update in version.in 2021-07-23 00:00:43 +00:00
Tom de Vries
5924fafaf6 [gdb/testsuite] Fix FAILs due to PR gcc/101575
When running test-case gdb.ada/formatted_ref.exp with gcc-11 and target board
unix/gdb:debug_flags=-gdwarf-4 we run into:
...
(gdb) print/x s^M
No definition of "s" in current context.^M
(gdb) FAIL: gdb.ada/formatted_ref.exp: print/x s
...
which is caused by "runto defs.adb:20" taking us to defs__struct1IP:
...
(gdb) break defs.adb:20^M
Breakpoint 1 at 0x402cfd: defs.adb:20. (2 locations)^M
(gdb) run ^M
Starting program: formatted_ref ^M
^M
Breakpoint 1, defs__struct1IP () at defs.adb:20^M
20            return s.x;                   -- Set breakpoint marker here.^M
(gdb) print s1'access^M
...
instead of the expected defs.f1:
...
(gdb) break defs.adb:20^M
Breakpoint 1 at 0x402d0e: file defs.adb, line 20.^M
(gdb) run ^M
Starting program: formatted_ref ^M
^M
Breakpoint 1, defs.f1 (s=...) at defs.adb:20^M
20            return s.x;                   -- Set breakpoint marker here.^M
...

This is caused by incorrect line info due to gcc PR 101575 - "[gcc-11,
-gdwarf-4] Missing .file <n> directive causes invalid line info".

Fix this by when landing in defs__struct1IP:
- xfailing the runto, and
- issuing a continue to land in defs.f1.

Likewise in a few other test-cases.

Tested on x86_64-linux, with:
- system gcc.
- gcc-11 and target boards unix/gdb:debug_flags=-gdwarf-4 and
  unix/gdb:debug_flags=-gdwarf-5.

gdb/testsuite/ChangeLog:

2021-07-22  Tom de Vries  <tdevries@suse.de>

	* gdb.ada/formatted_ref.exp: Add xfail for PR gcc/101575.
	* gdb.ada/iwide.exp: Same.
	* gdb.ada/pkd_arr_elem.exp: Same.
2021-07-22 17:21:21 +02:00
Tom de Vries
f08513e821 [gdb/testsuite] Fix gdb.cp/step-and-next-inline.exp with gcc-11
When running test-case gdb.cp/step-and-next-inline.exp with gcc-11, I run
into:
...
KPASS: gdb.cp/step-and-next-inline.exp: no_header: next step 1 \
  (PRMS symtab/25507)
FAIL: gdb.cp/step-and-next-inline.exp: no_header: next step 2
KPASS: gdb.cp/step-and-next-inline.exp: no_header: next step 3 \
  (PRMS symtab/25507)
...

[ Note that I get the same result with gcc-11 and target board
unix/gdb:debug_flags=-gdwarf-4, so this is not a dwarf 4 vs 5 issue. ]

With gcc-10, I have this trace:
...
64        get_alias_set (&xx);
get_alias_set (t=0x601038 <xx>) at step-and-next-inline.cc:51
51        if (t != NULL
40        if (t->x != i)
52            && TREE_TYPE (t).z != 1
43        return x;
53            && TREE_TYPE (t).z != 2
43        return x;
54            && TREE_TYPE (t).z != 3)
43        return x;
main () at step-and-next-inline.cc:65
65        return 0;
...
and with gcc-11, I have instead:
...
64        get_alias_set (&xx);
get_alias_set (t=0x601038 <xx>) at step-and-next-inline.cc:51
51        if (t != NULL
52            && TREE_TYPE (t).z != 1
43        return x;
53            && TREE_TYPE (t).z != 2
43        return x;
54            && TREE_TYPE (t).z != 3)
43        return x;
main () at step-and-next-inline.cc:65
65        return 0;
...
and with clang-10, I have instead:
...
64        get_alias_set (&xx);
get_alias_set (t=0x601034 <xx>) at step-and-next-inline.cc:51
51        if (t != NULL
52            && TREE_TYPE (t).z != 1
53            && TREE_TYPE (t).z != 2
54            && TREE_TYPE (t).z != 3)
51        if (t != NULL
57      }
main () at step-and-next-inline.cc:65
65        return 0;
...

The test-case tries to verify that we don't step into inlined function
tree_check (lines 40-43) (so, with the clang trace we get that right).

The test-case then tries to kfail the problems when using gcc, but this is
done in such a way that the testing still gets out of sync after a failure.
That is: the "next step 2" check that is supposed to match
"TREE_TYPE (t).z != 2" is actually matching "TREE_TYPE (t).z != 1":
...
(gdb) next^M
52            && TREE_TYPE (t).z != 1^M
(gdb) PASS: gdb.cp/step-and-next-inline.exp: no_header: next step 2
...

Fix this by issuing extra nexts to arrive at the required lines.

Tested on x86_64-linux, with gcc-8, gcc-9, gcc-10, gcc-11, clang-8, clang-10
and clang-12.

gdb/testsuite/ChangeLog:

2021-07-22  Tom de Vries  <tdevries@suse.de>

	* gdb.cp/step-and-next-inline.cc (tree_check, get_alias_set, main):
	Tag closing brace with comment.
	* gdb.cp/step-and-next-inline.h: Update to keep identical with
	step-and-next-inline.cc.
	* gdb.cp/step-and-next-inline.exp: Issue extra next when required.
2021-07-22 02:10:07 +02:00
GDB Administrator
1f0f4c0f55 Automatic date update in version.in 2021-07-22 00:00:45 +00:00
Tom de Vries
0e9c2a33e4 [gdb/testsuite] Fix FAILs due to PR gcc/101452
When running test-case gdb.base/ptype-offsets.exp with gcc-11 (with -gdwarf-5
default) or gcc-10 with target board unix/gdb:debug_flags=-gdwarf-5 we run
into this regression:
...
 (gdb) ptype/o static_member^M
 /* offset      |    size */  type = struct static_member {^M
-                               static static_member Empty;^M
 /*      0      |       4 */    int abc;^M
 ^M
                                /* total size (bytes):    4 */^M
                              }^M
-(gdb) PASS: gdb.base/ptype-offsets.exp: ptype/o static_member
+(gdb) FAIL: gdb.base/ptype-offsets.exp: ptype/o static_member
...

This is caused by missing debug info, which I filed as gcc PR101452 - "[debug,
dwarf-5] undefined static member removed by
-feliminate-unused-debug-symbols".

It's not clear yet whether this is a bug or a feature, but work around this in
the test-cases by:
- defining the static member
- adding additional_flags=-fno-eliminate-unused-debug-types.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-07-21  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (gcc_major_version): New proc.
	* gdb.base/ptype-offsets.cc: Define static member static_member::Empty.
	* gdb.cp/templates.exp: Define static member using -DGCC_BUG.
	* gdb.cp/m-static.exp: Add
	additional_flags=-fno-eliminate-unused-debug-types.
	* gdb.cp/pr-574.exp: Same.
	* gdb.cp/pr9167.exp: Same.
2021-07-21 14:22:16 +02:00
Tom de Vries
f26101b199 [gdb/testsuite] Add KFAILs for gdb.ada FAILs with gcc-11
With gcc-11 we run into:
...
(gdb) print pa_ptr.all^M
That operation is not available on integers of more than 8 bytes.^M
(gdb) KFAIL: gdb.ada/arrayptr.exp: scenario=all: print pa_ptr.all (PRMS: gdb/20991)
...

This is due to PR exp/20991 - "__int128 type support".  Mark this and similar
FAILs as KFAIL.

Also mark this FAIL:
....
(gdb) print pa_ptr(3)^M
cannot subscript or call something of type `foo__packed_array_ptr'^M
(gdb) FAIL: gdb.ada/arrayptr.exp: scenario=minimal: print pa_ptr(3)
...
as a KFAIL for PR ada/28115 - "Support packed array encoded as
DW_TAG_subrange_type".

Tested on x86_64-linux, with gcc-10 and gcc-11.

gdb/testsuite/ChangeLog:

2021-07-21  Tom de Vries  <tdevries@suse.de>

	* gdb.ada/arrayptr.exp: Add KFAILs for PR20991 and PR28115.
	* gdb.ada/exprs.exp: Add KFAILs for PR20991.
	* gdb.ada/packed_array_assign.exp: Same.
2021-07-21 14:22:16 +02:00
GDB Administrator
647c0a29f2 Automatic date update in version.in 2021-07-21 00:00:47 +00:00
Luis Machado
4f3fb91acc Fix printing of non-address types when memory tagging is enabled
When the architecture supports memory tagging, we handle
pointer/reference types in a special way, so we can validate tags and
show mismatches.

Unfortunately, the currently implementation errors out when the user
prints non-address values: composite types, floats, references, member
functions and other things.

Vector registers:

 (gdb) p $v0
 Value can't be converted to integer.

Non-existent internal variables:

 (gdb) p $foo
 Value can't be converted to integer.

The same happens for complex types and printing struct/union types.

There are a few problems here.

The first one is that after print_command_1 evaluates the expression
to print, the tag validation code call value_as_address
unconditionally, without making sure we have have a suitable type
where it makes to sense to call it.  That results in value_as_address
(if it isn't given a pointer-like type) trying to treat the value as
an integer and convert it to an address, which #1 - doesn't make sense
(i.e., no sense in validating tags after "print 1"), and throws for
non-integer-convertible types.  We fix this by making sure we have a
pointer or reference type first, and only if so then proceed to check
if the address-like value has tags.

The second is that we're calling value_as_address even if we have an
optimized out or unavailable value, which throws, because the value's
contents aren't fully accessible/readable.  This error currently
escapes out and aborts the print.  This case is fixed by checking for
optimized out / unavailable explicitly.

Third, the tag checking process does not gracefully handle exceptions.
If any exception is thrown from the tag validation code, we abort the
print.  E.g., the target may fail to access tags via a running thread.
Or the needed /proc files aren't available.  Or some other untold
reason.  This is a bit too rigid.  This commit changes print_command_1
to catch errors, print them, and still continue with the normal
expression printing path instead of erroring out and printing nothing
useful.

With this patch, printing works correctly again:

 (gdb) p $v0
 $1 = {d = {f = {2.0546950501119882e-81, 2.0546950501119882e-81}, u = {3399988123389603631, 3399988123389603631}, s = {
       3399988123389603631, 3399988123389603631}}, s = {f = {1.59329203e-10, 1.59329203e-10, 1.59329203e-10, 1.59329203e-10}, u = {
       791621423, 791621423, 791621423, 791621423}, s = {791621423, 791621423, 791621423, 791621423}}, h = {bf = {1.592e-10,
       1.592e-10, 1.592e-10, 1.592e-10, 1.592e-10, 1.592e-10, 1.592e-10, 1.592e-10}, f = {0.11224, 0.11224, 0.11224, 0.11224, 0.11224,
       0.11224, 0.11224, 0.11224}, u = {12079, 12079, 12079, 12079, 12079, 12079, 12079, 12079}, s = {12079, 12079, 12079, 12079,
       12079, 12079, 12079, 12079}}, b = {u = {47 <repeats 16 times>}, s = {47 <repeats 16 times>}}, q = {u = {
       62718710765820030520700417840365121327}, s = {62718710765820030520700417840365121327}}}
 (gdb) p $foo
 $2 = void
 (gdb) p 2 + 2i
 $3 = 2 + 2i

gdb/ChangeLog

2021-07-20  Luis Machado  <luis.machado@linaro.org>
	    Pedro Alves  <pedro@palves.net>

	PR gdb/28110
	* gdbarch.sh: Updated documentation for gdbarch_tagged_address_p.
	* gdbarch.h: Regenerate.
	* printcmd.c (should_validate_memtags): Reorder comparisons and only
	validate tags for pointer and reference types.  Skip validation of
	optimized out or unavailable values.
	(print_command_1): Guard call memory tagging validation code with
	a try/catch block.

Co-Authored-By: Pedro Alves <pedro@palves.net>
Change-Id: I82bf00ac88d23553b3f7563c9872dfa6ca1f2207
2021-07-20 07:27:13 -03:00
GDB Administrator
bbfd0b2867 Automatic date update in version.in 2021-07-20 00:00:42 +00:00
Tom Tromey
e22715ce30 Avoid expression parsing crash with unknown language
PR gdb/28093 points out that gdb crashes when language is set to
"unknown" and expression parsing is attempted.  At first I thought
this was a regression due to the expression rewrite, but it turns out
that older versions crash as well.

This patch avoids the crash by changing the default expression parser
to throw an exception.  I think this is preferable -- the current
behavior of silently doing nothing does not really make sense.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28093
(cherry picked from commit dcd482c1b7)

gdb/ChangeLog
2021-07-19  Tom Tromey  <tromey@adacore.com>

	PR gdb/28093
	* language.c (auto_or_unknown_language::parser): Call error.

gdb/testsuite/ChangeLog
2021-07-19  Tom Tromey  <tromey@adacore.com>

	PR gdb/28093
	* gdb.base/langs.exp: Add tests.
2021-07-19 11:01:47 -06:00
GDB Administrator
51799bd45f Automatic date update in version.in 2021-07-19 00:00:30 +00:00
GDB Administrator
85e022aa1a Automatic date update in version.in 2021-07-18 00:00:47 +00:00
Sergey Belyashov
28b48aa109 Add basic Z80 CPU support
Supported ISAs:
- Z80 (all undocumented instructions)
- Z180
- eZ80 (Z80 mode only)

Datasheets:
Z80: https://www.zilog.com/manage_directlink.php?filepath=docs/z80/um0080&extn=.pdf
Z180: https://www.zilog.com/manage_directlink.php?filepath=docs/z180/ps0140&extn=.pdf
eZ80: http://www.zilog.com/force_download.php?filepath=YUhSMGNEb3ZMM2QzZHk1NmFXeHZaeTVqYjIwdlpHOWpjeTlWVFRBd056Y3VjR1Jt

To debug Z80 programs using GDB you must configure and embed
z80-stub.c to your program (SDCC compiler is required). Or
you may use some simulator with GDB support.

gdb/ChangeLog:

	* Makefile.in (ALL_TARGET_OBS): Add z80-tdep.c.
	* NEWS: Mention z80 support.
	* configure.tgt: Handle z80*.
	* features/Makefile (XMLTOC): Add z80.xml.
	* features/z80-cpu.xml: New.
	* features/z80.c: Generate.
	* features/z80.xml: New.
	* z80-tdep.c: New file.
	* z80-tdep.h: New file.

gdb/stubs/ChangeLog:

	* z80-stub.c: New file.

Change-Id: Id0b7a6e210c3f93c6853c5e3031b7bcee47d0db9
2021-07-17 10:23:54 -04:00
GDB Administrator
97f3dfbc4f Automatic date update in version.in 2021-07-17 00:00:36 +00:00
GDB Administrator
a35647809a Automatic date update in version.in 2021-07-16 00:00:24 +00:00
GDB Administrator
e8bd220d37 Automatic date update in version.in 2021-07-15 00:00:31 +00:00
Tom de Vries
26e27615ab [gdb/testsuite] Fix gdb.base/gold-gdb-index.exp
When running test-case gdb.base/gold-gdb-index.exp on openSUSE Tumbleweed,
I run into:
...
FAIL: gdb.base/gold-gdb-index.exp: maint info symtabs
...

This is due to a dummy .gdb_index:
...
Contents of the .gdb_index section:

Version 7

CU table:

TU table:

Address table:

Symbol table:
...

The dummy .gdb_index is ignored when loading the symbols, and instead partial
symbols are used.  Consequently, we get the same result as if we'd removed
-Wl,--gdb-index from the compilation.

Presumably, gold fails to generate a proper .gdb_index because it lacks
DWARF5 support.

Anyway, without a proper .gdb_index we can't test the gdb behaviour we're
trying to excercise.  Fix this by detecting whether we actually used a
.gdb_index for symbol loading.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-07-14  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (have_index): New proc.
	* gdb.base/gold-gdb-index.exp: Use have_index.
2021-07-14 11:46:50 +02:00
GDB Administrator
7d11b094f4 Automatic date update in version.in 2021-07-14 00:00:28 +00:00
Lancelot SIX
f1d9f19978 Use /bin/sh as shebang in gdb/make-init-c
While testing the NixOS[1] packaging for gdb-11.0.90.tar.xz, I got the
following error:

  [...]
  CXX    aarch32-tdep.o
  CXX    gdb.o
  GEN    init.c
  /nix/store/26a78ync552m8j4sbjavhvkmnqir8c9y-bash-4.4-p23/bin/bash: ./make-init-c: /usr/bin/env: bad interpreter: No such file or directory
  make[2]: *** [Makefile:1866: stamp-init] Error 126
  make[2]: *** Waiting for unfinished jobs....
  make[2]: Leaving directory '/build/gdb-11.0.90/gdb'
  make[1]: *** [Makefile:9814: all-gdb] Error 2
  make[1]: Leaving directory '/build/gdb-11.0.90'
  make: *** [Makefile:903: all] Error 2
  builder for '/nix/store/xs8my3rrc3l4kdlbpx0azh6q0v0jxphr-gdb-gdb-11.0.90.drv' failed with exit code 2
  error: build of '/nix/store/xs8my3rrc3l4kdlbpx0azh6q0v0jxphr-gdb-gdb-11.0.90.drv' failed

In the nix build environment, /usr/bin/env is not present, only /bin/sh
is.  This patch makes sure that gdb/make-init-c uses '/bin/sh' as
interpreter as this is the only one available on this platform.

I do not think this change will cause regressions on any other
configuration.

[1] https://nixos.org/

gdb/Changelog

	* make-init-c: Use /bin/sh as shebang.
2021-07-13 23:09:14 +01:00
Pedro Alves
3e0910a5f0 Avoid letting exceptions escape gdb_bfd_iovec_fileio_close (PR gdb/28080)
Before PR gdb/28080 was fixed by the previous patch, GDB was crashing
like this:

 (gdb) detach
 Detaching from program: target:/any/program, process 3671843
 Detaching from process 3671843
 Ending remote debugging.
 [Inferior 1 (process 3671843) detached]
 In main
 terminate called after throwing an instance of 'gdb_exception_error'
 Aborted (core dumped)

Here's the exception above being thrown:

 (top-gdb) bt
 #0  throw_error (error=TARGET_CLOSE_ERROR, fmt=0x555556035588 "Remote connection closed") at src/gdbsupport/common-exceptions.cc:222
 #1  0x0000555555bbaa46 in remote_target::readchar (this=0x555556a11040, timeout=10000) at src/gdb/remote.c:9440
 #2  0x0000555555bbb9e5 in remote_target::getpkt_or_notif_sane_1 (this=0x555556a11040, buf=0x555556a11058, forever=0, expecting_notif=0, is_notif=0x0) at src/gdb/remote.c:9928
 #3  0x0000555555bbbda9 in remote_target::getpkt_sane (this=0x555556a11040, buf=0x555556a11058, forever=0) at src/gdb/remote.c:10030
 #4  0x0000555555bc0e75 in remote_target::remote_hostio_send_command (this=0x555556a11040, command_bytes=13, which_packet=14, remote_errno=0x7fffffffcfd0, attachment=0x0, attachment_len=0x0) at src/gdb/remote.c:12137
 #5  0x0000555555bc1b6c in remote_target::remote_hostio_close (this=0x555556a11040, fd=8, remote_errno=0x7fffffffcfd0) at src/gdb/remote.c:12455
 #6  0x0000555555bc1bb4 in remote_target::fileio_close (During symbol reading: .debug_line address at offset 0x64f417 is 0 [in module build/gdb/gdb]
 this=0x555556a11040, fd=8, remote_errno=0x7fffffffcfd0) at src/gdb/remote.c:12462
 #7  0x0000555555c9274c in target_fileio_close (fd=3, target_errno=0x7fffffffcfd0) at src/gdb/target.c:3365
 #8  0x000055555595a19d in gdb_bfd_iovec_fileio_close (abfd=0x555556b9f8a0, stream=0x555556b11530) at src/gdb/gdb_bfd.c:439
 #9  0x0000555555e09e3f in opncls_bclose (abfd=0x555556b9f8a0) at src/bfd/opncls.c:599
 #10 0x0000555555e0a2c7 in bfd_close_all_done (abfd=0x555556b9f8a0) at src/bfd/opncls.c:847
 #11 0x0000555555e0a27a in bfd_close (abfd=0x555556b9f8a0) at src/bfd/opncls.c:814
 #12 0x000055555595a9d3 in gdb_bfd_close_or_warn (abfd=0x555556b9f8a0) at src/gdb/gdb_bfd.c:626
 #13 0x000055555595ad29 in gdb_bfd_unref (abfd=0x555556b9f8a0) at src/gdb/gdb_bfd.c:715
 #14 0x0000555555ae4730 in objfile::~objfile (this=0x555556515540, __in_chrg=<optimized out>) at src/gdb/objfiles.c:573
 #15 0x0000555555ae955a in std::_Sp_counted_ptr<objfile*, (__gnu_cxx::_Lock_policy)2>::_M_dispose (this=0x555556c20db0) at /usr/include/c++/9/bits/shared_ptr_base.h:377
 #16 0x000055555572b7c8 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x555556c20db0) at /usr/include/c++/9/bits/shared_ptr_base.h:155
 #17 0x00005555557263c3 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (this=0x555556bf0588, __in_chrg=<optimized out>) at /usr/include/c++/9/bits/shared_ptr_base.h:730
 #18 0x0000555555ae745e in std::__shared_ptr<objfile, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr (this=0x555556bf0580, __in_chrg=<optimized out>) at /usr/include/c++/9/bits/shared_ptr_base.h:1169
 #19 0x0000555555ae747e in std::shared_ptr<objfile>::~shared_ptr (this=0x555556bf0580, __in_chrg=<optimized out>) at /usr/include/c++/9/bits/shared_ptr.h:103
 #20 0x0000555555b1c1dc in __gnu_cxx::new_allocator<std::_List_node<std::shared_ptr<objfile> > >::destroy<std::shared_ptr<objfile> > (this=0x5555564cdd60, __p=0x555556bf0580) at /usr/include/c++/9/ext/new_allocator.h:153
 #21 0x0000555555b1bb1d in std::allocator_traits<std::allocator<std::_List_node<std::shared_ptr<objfile> > > >::destroy<std::shared_ptr<objfile> > (__a=..., __p=0x555556bf0580) at /usr/include/c++/9/bits/alloc_traits.h:497
 #22 0x0000555555b1b73e in std::__cxx11::list<std::shared_ptr<objfile>, std::allocator<std::shared_ptr<objfile> > >::_M_erase (this=0x5555564cdd60, __position=std::shared_ptr<objfile> (expired, weak count 1) = {get() = 0x555556515540}) at /usr/include/c++/9/bits/stl_list.h:1921
 #23 0x0000555555b1afeb in std::__cxx11::list<std::shared_ptr<objfile>, std::allocator<std::shared_ptr<objfile> > >::erase (this=0x5555564cdd60, __position=std::shared_ptr<objfile> (expired, weak count 1) = {get() = 0x555556515540}) at /usr/include/c++/9/bits/list.tcc:158
 #24 0x0000555555b19576 in program_space::remove_objfile (this=0x5555564cdd20, objfile=0x555556515540) at src/gdb/progspace.c:210
 #25 0x0000555555ae4502 in objfile::unlink (this=0x555556515540) at src/gdb/objfiles.c:487
 #26 0x0000555555ae5a12 in objfile_purge_solibs () at src/gdb/objfiles.c:875
 #27 0x0000555555c09686 in no_shared_libraries (ignored=0x0, from_tty=1) at src/gdb/solib.c:1236
 #28 0x00005555559e3f5f in detach_command (args=0x0, from_tty=1) at src/gdb/infcmd.c:2769

Note frame #14:

 #14 0x0000555555ae4730 in objfile::~objfile (this=0x555556515540, __in_chrg=<optimized out>) at src/gdb/objfiles.c:573

That's a dtor, thus noexcept.  That's the reason for the
std::terminate.

The previous patch fixed things such that the exception above isn't
thrown anymore.  However, it's possible that e.g., the remote
connection drops just while a user types "nosharedlibrary", or some
other reason that leads to objfile::~objfile, and then we end up the
same std::terminate problem.

Also notice that frames #9-#11 are BFD frames:

 #9  0x0000555555e09e3f in opncls_bclose (abfd=0x555556bc27e0) at src/bfd/opncls.c:599
 #10 0x0000555555e0a2c7 in bfd_close_all_done (abfd=0x555556bc27e0) at src/bfd/opncls.c:847
 #11 0x0000555555e0a27a in bfd_close (abfd=0x555556bc27e0) at src/bfd/opncls.c:814

BFD is written in C and thus throwing exceptions over such frames may
either not clean up properly, or, may abort if bfd is not compiled
with -fasynchronous-unwind-tables (x86-64 defaults that on, but not
all GCC ports do).

Thus frame #8 seems like a good place to swallow exceptions.  More so
since in this spot we already ignore target_fileio_close return
errors.  That's what this commit does.  Without the previous fix, we'd
see:

 (gdb) detach
 Detaching from program: target:/any/program, process 2197701
 Ending remote debugging.
 [Inferior 1 (process 2197701) detached]
 warning: cannot close "target:/lib64/ld-linux-x86-64.so.2": Remote connection closed

Note it prints a warning, which would still be a regression compared
to GDB 10, if it weren't for the previous fix.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

	PR gdb/28080
	* gdb_bfd.c (gdb_bfd_close_warning): New.
	(gdb_bfd_iovec_fileio_close): Wrap target_fileio_close in
	try/catch and print warning on exception.
	(gdb_bfd_close_or_warn): Use gdb_bfd_close_warning.

Change-Id: Ic7a26ddba0a4444e3377b0e7c1c89934a84545d7
2021-07-13 15:34:51 +01:00
Pedro Alves
97c5ca8c34 Fix detach with target remote (PR gdb/28080)
Commit 408f66864a ("detach in all-stop
with threads running") regressed "detach" with "target remote":

 (gdb) detach
 Detaching from program: target:/any/program, process 3671843
 Detaching from process 3671843
 Ending remote debugging.
 [Inferior 1 (process 3671843) detached]
 In main
 terminate called after throwing an instance of 'gdb_exception_error'
 Aborted (core dumped)

Here's the exception above being thrown:

 (top-gdb) bt
 #0  throw_error (error=TARGET_CLOSE_ERROR, fmt=0x555556035588 "Remote connection closed") at src/gdbsupport/common-exceptions.cc:222
 #1  0x0000555555bbaa46 in remote_target::readchar (this=0x555556a11040, timeout=10000) at src/gdb/remote.c:9440
 #2  0x0000555555bbb9e5 in remote_target::getpkt_or_notif_sane_1 (this=0x555556a11040, buf=0x555556a11058, forever=0, expecting_notif=0, is_notif=0x0) at src/gdb/remote.c:9928
 #3  0x0000555555bbbda9 in remote_target::getpkt_sane (this=0x555556a11040, buf=0x555556a11058, forever=0) at src/gdb/remote.c:10030
 #4  0x0000555555bc0e75 in remote_target::remote_hostio_send_command (this=0x555556a11040, command_bytes=13, which_packet=14, remote_errno=0x7fffffffcfd0, attachment=0x0, attachment_len=0x0) at src/gdb/remote.c:12137
 #5  0x0000555555bc1b6c in remote_target::remote_hostio_close (this=0x555556a11040, fd=8, remote_errno=0x7fffffffcfd0) at src/gdb/remote.c:12455
 #6  0x0000555555bc1bb4 in remote_target::fileio_close (During symbol reading: .debug_line address at offset 0x64f417 is 0 [in module build/gdb/gdb]
 this=0x555556a11040, fd=8, remote_errno=0x7fffffffcfd0) at src/gdb/remote.c:12462
 #7  0x0000555555c9274c in target_fileio_close (fd=3, target_errno=0x7fffffffcfd0) at src/gdb/target.c:3365
 #8  0x000055555595a19d in gdb_bfd_iovec_fileio_close (abfd=0x555556b9f8a0, stream=0x555556b11530) at src/gdb/gdb_bfd.c:439
 #9  0x0000555555e09e3f in opncls_bclose (abfd=0x555556b9f8a0) at src/bfd/opncls.c:599
 #10 0x0000555555e0a2c7 in bfd_close_all_done (abfd=0x555556b9f8a0) at src/bfd/opncls.c:847
 #11 0x0000555555e0a27a in bfd_close (abfd=0x555556b9f8a0) at src/bfd/opncls.c:814
 #12 0x000055555595a9d3 in gdb_bfd_close_or_warn (abfd=0x555556b9f8a0) at src/gdb/gdb_bfd.c:626
 #13 0x000055555595ad29 in gdb_bfd_unref (abfd=0x555556b9f8a0) at src/gdb/gdb_bfd.c:715
 #14 0x0000555555ae4730 in objfile::~objfile (this=0x555556515540, __in_chrg=<optimized out>) at src/gdb/objfiles.c:573
 #15 0x0000555555ae955a in std::_Sp_counted_ptr<objfile*, (__gnu_cxx::_Lock_policy)2>::_M_dispose (this=0x555556c20db0) at /usr/include/c++/9/bits/shared_ptr_base.h:377
 #16 0x000055555572b7c8 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x555556c20db0) at /usr/include/c++/9/bits/shared_ptr_base.h:155
 #17 0x00005555557263c3 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (this=0x555556bf0588, __in_chrg=<optimized out>) at /usr/include/c++/9/bits/shared_ptr_base.h:730
 #18 0x0000555555ae745e in std::__shared_ptr<objfile, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr (this=0x555556bf0580, __in_chrg=<optimized out>) at /usr/include/c++/9/bits/shared_ptr_base.h:1169
 #19 0x0000555555ae747e in std::shared_ptr<objfile>::~shared_ptr (this=0x555556bf0580, __in_chrg=<optimized out>) at /usr/include/c++/9/bits/shared_ptr.h:103
 #20 0x0000555555b1c1dc in __gnu_cxx::new_allocator<std::_List_node<std::shared_ptr<objfile> > >::destroy<std::shared_ptr<objfile> > (this=0x5555564cdd60, __p=0x555556bf0580) at /usr/include/c++/9/ext/new_allocator.h:153
 #21 0x0000555555b1bb1d in std::allocator_traits<std::allocator<std::_List_node<std::shared_ptr<objfile> > > >::destroy<std::shared_ptr<objfile> > (__a=..., __p=0x555556bf0580) at /usr/include/c++/9/bits/alloc_traits.h:497
 #22 0x0000555555b1b73e in std::__cxx11::list<std::shared_ptr<objfile>, std::allocator<std::shared_ptr<objfile> > >::_M_erase (this=0x5555564cdd60, __position=std::shared_ptr<objfile> (expired, weak count 1) = {get() = 0x555556515540}) at /usr/include/c++/9/bits/stl_list.h:1921
 #23 0x0000555555b1afeb in std::__cxx11::list<std::shared_ptr<objfile>, std::allocator<std::shared_ptr<objfile> > >::erase (this=0x5555564cdd60, __position=std::shared_ptr<objfile> (expired, weak count 1) = {get() = 0x555556515540}) at /usr/include/c++/9/bits/list.tcc:158
 #24 0x0000555555b19576 in program_space::remove_objfile (this=0x5555564cdd20, objfile=0x555556515540) at src/gdb/progspace.c:210
 #25 0x0000555555ae4502 in objfile::unlink (this=0x555556515540) at src/gdb/objfiles.c:487
 #26 0x0000555555ae5a12 in objfile_purge_solibs () at src/gdb/objfiles.c:875
 #27 0x0000555555c09686 in no_shared_libraries (ignored=0x0, from_tty=1) at src/gdb/solib.c:1236
 #28 0x00005555559e3f5f in detach_command (args=0x0, from_tty=1) at src/gdb/infcmd.c:2769

So frame #28 already detached the remote process, and then we're
purging the shared libraries.  GDB had opened remote shared libraries
via the target: sysroot, so it tries closing them.  GDBserver is
tearing down already, so remote communication breaks down and we close
the remote target and throw TARGET_CLOSE_ERROR.

Note frame #14:

 #14 0x0000555555ae4730 in objfile::~objfile (this=0x555556515540, __in_chrg=<optimized out>) at src/gdb/objfiles.c:573

That's a dtor, thus noexcept.  That's the reason for the
std::terminate.

Stepping back a bit, why do we still have open remote files if we've
managed to detach already, and, we're debugging with "target remote"?
The reason is that commit 408f66864a
makes detach_command hold a reference to the target, so the remote
target won't be finally closed until frame #28 returns.  It's closing
the target that invalidates target file I/O handles.

This commit fixes the issue by not relying on target_close to
invalidate the target file I/O handles, instead invalidate them
immediately in remote_unpush_target.  So when GDB purges the solibs,
and we end up in target_fileio_close (frame #7 above), there's nothing
to do, and we don't try to talk with the remote target anymore.

The regression isn't seen when testing with
--target_board=native-gdbserver, because that does "set sysroot" to
disable the "target:" sysroot, for test run speed reasons.  So this
commit adds a testcase that explicitly tests detach with "set sysroot
target:".

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

	PR gdb/28080
	* remote.c (remote_unpush_target): Invalidate file I/O target
	handles.
	* target.c (fileio_handles_invalidate_target): Make extern.
	* target.h (fileio_handles_invalidate_target): Declare.

gdb/testsuite/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

	PR gdb/28080
	* gdb.base/detach-sysroot-target.exp: New.
	* gdb.base/detach-sysroot-target.c: New.

Reported-By: Jonah Graham <jonah@kichwacoders.com>

Change-Id: I851234910172f42a1b30e731161376c344d2727d
2021-07-13 15:34:02 +01:00
Tom de Vries
58a136f3e7 [gdb/testsuite] Fix check-libthread-db.exp FAILs with glibc 2.33
When running test-case gdb.threads/check-libthread-db.exp on openSUSE
Tumbleweed with glibc 2.33, I get:
...
(gdb) maint check libthread-db^M
Running libthread_db integrity checks:^M
  Got thread 0x7ffff7c79b80 => 9354 => 0x7ffff7c79b80; errno = 0 ... OK^M
libthread_db integrity checks passed.^M
(gdb) FAIL: gdb.threads/check-libthread-db.exp: user-initiated check: \
  libpthread.so not initialized (pattern 2)
...

The test-case expects instead:
...
  Got thread 0x0 => 9354 => 0x0 ... OK^M
...
which is what I get on openSUSE Leap 15.2 with glibc 2.26, and what is
described in the test-case like this:
...
    # libthread_db should fake a single thread with th_unique == NULL.
...

Using a breakpoint on check_thread_db_callback we can compare the two
scenarios, and find that in the latter case we hit this code in glibc function
iterate_thread_list in nptl_db/td_ta_thr_iter.c:
...
  if (next == 0 && fake_empty)
    {
      /* __pthread_initialize_minimal has not run.  There is just the main
         thread to return.  We cannot rely on its thread register.  They
         sometimes contain garbage that would confuse us, left by the
         kernel at exec.  So if it looks like initialization is incomplete,
         we only fake a special descriptor for the initial thread.  */
      td_thrhandle_t th = { ta, 0 };
      return callback (&th, cbdata_p) != 0 ? TD_DBERR : TD_OK;
    }
...
while in the former case we don't because this preceding statement doesn't
result in next == 0:
...
  err = DB_GET_FIELD (next, ta, head, list_t, next, 0);
...

Note that the comment mentions __pthread_initialize_minimal, but in both cases
it has already run before we hit the callback, so it's possible the comment is
no longer accurate.

The change in behaviour bisect to glibc commit 1daccf403b "nptl: Move stack
list variables into _rtld_global", which moves the initialization of stack
list variables such as __stack_user to an earlier moment, which explains well
enough the observed difference.

Fix this by updating the regexp patterns to agree with what libthread-db is
telling us.

Tested on x86_64-linux, both with glibc 2.33 and 2.26.

gdb/testsuite/ChangeLog:

2021-07-13  Tom de Vries  <tdevries@suse.de>

	PR testsuite/27690
	* gdb.threads/check-libthread-db.exp: Update patterns for glibc 2.33.
2021-07-13 16:11:38 +02:00
Simon Marchi
1bdfa2b1a8 gdb: disable commit-resumed on -exec-interrupt --thread-group
As reported in PR gdb/28077, we hit an internal error when using
-exec-interrupt with --thread-group:

    info threads
    &"info threads\n"
    ~"  Id   Target Id             Frame \n"
    ~"* 1    process 403312 \"loop\" (running)\n"
    ^done
    (gdb)
    -exec-interrupt --thread-group i1
    ~"/home/simark/src/binutils-gdb/gdb/target.c:3768: internal-error: void target_stop(ptid_t): Assertion `!proc_target->commit_resumed_state' failed.\nA problem internal to GDB has been detected,\nfurther debugging may prove unreliable.\nQuit this debugging session? (y or n) "

This is because this code path never disables commit-resumed (a
requirement for calling target_stop, as documented in
process_stratum_target::»commit_resumed_state) before calling
target_stop.

The other 3 code paths in mi_cmd_exec_interrupt use interrupt_target_1,
which does it.  But the --thread-group code path uses its own thing
which doesn't do it.  Fix this by adding a scoped_disable_commit_resumed
in this code path.

Calling -exec-interrupt with --thread-group is apparently not tested at
the moment (which is why this bug could creep in).  Add a new test for
that.  The test runs two inferiors and tries to interrupt them with
"-exec-interrupt --thread-group X".

This will need to be merged in the gdb-11-branch, so here are ChangeLog
entries:

gdb/ChangeLog:

	* mi/mi-main.c (mi_cmd_exec_interrupt): Use
	scoped_disable_commit_resumed in the --thread-group case.

gdb/testsuite/ChangeLog:

	* gdb.mi/interrupt-thread-group.c: New.
	* gdb.mi/interrupt-thread-group.exp: New.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28077
Change-Id: I615efefcbcaf2c15d47caf5e4b9d82854b2a2fcb
2021-07-13 09:26:50 -04:00
John Ericson
29e079b876 Fix some dangling references to netbsd-tdep
These files were renamed in 1b71cfcfdc,
but evidentially a few dangling references were left behind. This causes
builds to fail:

    $ ./configure --target i686-netbsdelf
    $ make
    make: *** No rule to make target 'nbsd-tdep.c', needed by 'nbsd-tdep.o'.  Stop.

gdb/ChangeLog:

	* sparc-tdep.h: Fix comment.
	* netbsd-tdep.c (nbsd_info_proc_mappings_header): Fix comment.
	(nbsd_init_abi): Fix comment.
	* configure.tgt (*-*-netbsd* | *-*-knetbsd*-gnu): Fix netbsd
	file name.
	(alpha*-*-openbsd*): Likewise.
	(sparc-*-openbsd*): Likewise.
	(sparc64-*-openbsd*): Likewise.

Change-Id: I18a0873902dccadd238615577aac4e08772fa2c8
2021-07-13 00:57:52 -04:00
GDB Administrator
969168ce6f Automatic date update in version.in 2021-07-13 00:00:35 +00:00
Tom de Vries
d6771741f3 [gdb/testsuite] Fix gdb.btrace/tsx.exp on system with tsx disabled in microcode
Recently I started to see this fail with trunk:
...
(gdb) record instruction-history^M
1          0x00000000004004ab <main+4>: call   0x4004b7 <test>^M
2          0x00000000004004c6 <test+15>:        mov    $0x1,%eax^M
3          0x00000000004004cb <test+20>:        ret    ^M
(gdb) FAIL: gdb.btrace/tsx.exp: speculation indication
...

This is due to an intel microcode update (1) that disables Intel TSX by default.

Fix this by updating the pattern.

Tested on x86_64-linux, with both gcc 7.5.0 and clang 12.0.1.

[1] https://www.intel.com/content/www/us/en/support/articles/000059422/processors.html

gdb/testsuite/ChangeLog:

2021-07-12  Tom de Vries  <tdevries@suse.de>

	PR testsuite/28057
	* gdb.btrace/tsx.exp: Add pattern for system with tsx disabled in
	microcode.
2021-07-12 17:33:42 +02:00
Tom de Vries
29119da49d [gdb/testsuite] Fix gdb.mi/mi-info-sources.exp for extra debug info
When running test-case gdb.mi/mi-info-sources.exp, I run into:
...
Running src/gdb/testsuite/gdb.mi/mi-info-sources.exp ...
ERROR: internal buffer is full.
...
due to extra debug info from the shared libraries.

Fix this by using "nosharedlibrary".

Then I run into these FAILs:
...
FAIL: gdb.mi/mi-info-sources.exp: debug_read=false: \
  -file-list-exec-source-files (unexpected output)
FAIL: gdb.mi/mi-info-sources.exp: debug_read=true: \
  -file-list-exec-source-files (unexpected output)
FAIL: gdb.mi/mi-info-sources.exp: debug_read=true: \
  -file-list-exec-source-files --group-by-objfile, look for \
  mi-info-sources.c (unexpected output)
FAIL: gdb.mi/mi-info-sources.exp: debug_read=true: \
  -file-list-exec-source-files --group-by-objfile, look for \
  mi-info-sources-base.c (unexpected output)
...
due to openSUSE executables which have debug info for objects from sources
like sysdeps/x86_64/crtn.S.

Fix these by updating the patterns, and adding "maint expand-symtabs" to
reliably get fully-read objfiles.

Then I run into FAILs when using the readnow target board.  Fix these by
skipping the relevant tests.

Then I run into FAILs when using the cc-with-gnu-debuglink board.  Fix these
by updating the patterns.

Tested on x86_64-linux, with native, check-read1, readnow, cc-with-gdb-index,
cc-with-debug-names, cc-with-gnu-debuglink, cc-with-dwz, cc-with-dwz-m.

gdb/testsuite/ChangeLog:

2021-07-12  Tom de Vries  <tdevries@suse.de>

	* lib/mi-support.exp (mi_readnow): New proc.
	* gdb.mi/mi-info-sources.exp: Use nosharedlibrary.  Update patterns.
	Skip tests for readnow.  Use "maint expand-symtabs".
2021-07-12 14:46:54 +02:00
GDB Administrator
7ad7599a96 Automatic date update in version.in 2021-07-12 00:00:22 +00:00
Tom Tromey
2814ff8388 Fix warning in symtab.c
The compiler gives this warning when building symtab.c:

../../binutils-gdb/gdb/symtab.c:4247:28: warning: 'to_match' may be used uninitialized in this function [-Wmaybe-uninitialized]

This patch fixes the warning by adding a gdb_assert_not_reached.

gdb/ChangeLog:

        * gdb/symtab.c (info_sources_filter::matches): Add default
        case hander in switch statement.

(cherry picked from commit b6aeb717a8)
2021-07-11 06:59:33 -07:00
GDB Administrator
5496271fd4 Automatic date update in version.in 2021-07-11 00:00:22 +00:00
GDB Administrator
3e2cf22eef Automatic date update in version.in 2021-07-10 00:00:23 +00:00
GDB Administrator
789b4fb594 Automatic date update in version.in 2021-07-09 00:00:25 +00:00
Simon Marchi
ff32938d44 gdb: don't set Linux-specific displaced stepping methods in s390_gdbarch_init
According to bug 28056, running an s390x binary gives:

    (gdb) run
    Starting program: /usr/bin/ls
    /home/ubuntu/tmp/gdb-11.0.90.20210705/gdb/linux-tdep.c:2550: internal-error: displaced_step_prepare_status linux_displaced_step_prepare(gdbarch*, thread_info*, CORE_ADDR&): Assertion `gdbarch_data->num_disp_step_buffers > 0' failed.

This is because the s390 architecture registers some Linux-specific
displaced stepping callbacks in the OS-agnostic s390_gdbarch_init:

    set_gdbarch_displaced_step_prepare (gdbarch, linux_displaced_step_prepare);
    set_gdbarch_displaced_step_finish (gdbarch, linux_displaced_step_finish);
    set_gdbarch_displaced_step_restore_all_in_ptid
      (gdbarch, linux_displaced_step_restore_all_in_ptid);

But then the Linux-specific s390_linux_init_abi_any passes
num_disp_step_buffers=0 to linux_init_abi:

    linux_init_abi (info, gdbarch, 0);

The problem happens when linux_displaced_step_prepare is called for the
first time.  It tries to allocate the displaced stepping buffers, but
sees that the number of displaced stepping buffers for that architecture
is 0, which is unexpected / invalid.

s390_gdbarch_init should not register the linux_* callbacks, that is
expected to be done by linux_init_abi.  If debugging a bare-metal s390
program, or an s390 program on another OS GDB doesn't know about, we
wouldn't want to use them.  We would either register no callbacks, if
displaced stepping isn't supported, or register a different set of
callbacks if we wanted to support displaced stepping in those cases.

The commit that refactored the displaced stepping machinery and
introduced these set_gdbarch_displaced_step_* calls is 187b041e25
("gdb: move displaced stepping logic to gdbarch, allow starting
concurrent displaced steps").  However, even before that,
s390_gdbarch_init did:

  set_gdbarch_displaced_step_location (gdbarch, linux_displaced_step_location);

... which already seemed wrong.  The Linux-specific callback was used
even for non-Linux system.  Maybe that was on purpose, because it would
also happen to work in some other non-Linux case, or maybe it was simply
a mistake.  I'll assume that this was a small mistake when
s390-tdep.{h,c} where factored out of s390-linux-tdep.c, in d6e5894564
("s390: Split up s390-linux-tdep.c into two files").

Fix this by removing the setting of these displaced step callbacks from
s390_gdbarch_init.  Instead, pass num_disp_step_buffers=1 to
linux_init_abi, in s390_linux_init_abi_any.  Doing so will cause
linux_init_abi to register these same callbacks.  It will also mean that
when debugging a bare-metal s390 executable or an executable on another
OS that GDB doesn't know about, gdbarch_displaced_step_prepare won't be
set, so displaced stepping won't be used.

This patch will need to be merged in the gdb-11-branch, since this is a
GDB 11 regression, so here's the ChangeLog entry:

gdb/ChangeLog:

	* s390-linux-tdep.c (s390_linux_init_abi_any): Pass 1 (number
	of displaced stepping buffers to linux_init_abi.
	* s390-tdep.c (s390_gdbarch_init): Don't set the Linux-specific
	displaced-stepping gdbarch callbacks.

Change-Id: Ieab2f8990c78fde845ce7378d6fd4ee2833800d5
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28056
2021-07-08 10:05:16 -04:00
Simon Marchi
6f0fe250d9 gdb/Makefile.in: remove testsuite from SUBDIRS
When distclean-ing a configured / built gdb directory, like so:

    $ ./configure && make all-gdb && make distclean

The distclean operation fails with:

    Missing testsuite/Makefile

If we look at the SUBDIRS variable in the generated gdb/Makefile,
testsuite is there twice:

    SUBDIRS = doc  testsuite data-directory testsuite

So we try distclean-ing the testsuite directory twice.  The second time,
gdb/testsuite/Makefile doesn't exist, so it fails.

The first "testsuite" comes from the @subdirs@ replacement, because of
the `AC_CONFIG_SUBDIRS` macro in gdb/configure.ac.  The second one is
hard-coded in gdb/Makefile.in:

    SUBDIRS = doc @subdirs@ data-directory testsuite

The hard-coded was added by:

    bdbbcd5774 ("Always build 'all' in gdb/testsuite")

which came after `testsuite` was removed from @subdirs@ by:

    f99d1d3749 ("Remove gdb/testsuite/configure")

My commit a100a94530 ("gdb/testsuite: restore configure script")
should have removed the hard-coded `testsuite`, since it added it back
as a "subdir", but I missed it because I only looked f99d1d3749 to
write my patch.

Fix this by removing the hard-coded one.

This patch should be pushed to both master and gdb-11-branch, hence the
ChangeLog entry:

gdb/ChangeLog:

	* Makefile.in (SUBDIRS): Remove testsuite.

Change-Id: I63e5590b1a08673c646510b3ecc74600eae9f92d
2021-07-08 09:57:23 -04:00
Tom de Vries
732236a76e [gdb/testsuite] Fix gdb.guile/scm-breakpoint.exp with guile 3.0
When running test-case gdb.guile/scm-breakpoint.exp on openSUSE Tumbleweed
with guile 3.0, I run into:
...
(gdb) guile (define cp (make-breakpoint "syscall" #:type BP_CATCHPOINT))^M
ERROR: In procedure make-breakpoint:^M
In procedure gdbscm_make_breakpoint: unsupported breakpoint type in \
  position 3: "BP_CATCHPOINT"^M
Error while executing Scheme code.^M
(gdb) FAIL: gdb.guile/scm-breakpoint.exp: test_catchpoints: \
  create a catchpoint via the api
...

The same test passes on openSUSE Leap 15.2 with guile 2.0, where the second
line of the error message starts with the same prefix as the first:
...
ERROR: In procedure gdbscm_make_breakpoint: unsupported breakpoint type in \
  position 3: "BP_CATCHPOINT"^M
...

I observe the same difference in many other tests, f.i.:
...
(gdb) gu (print (value-add i '()))^M
ERROR: In procedure value-add:^M
In procedure gdbscm_value_add: Wrong type argument in position 2: ()^M
Error while executing Scheme code.^M
(gdb) PASS: gdb.guile/scm-math.exp: catch error in guile type conversion
...
but it doesn't cause FAILs anywhere else.

Fix this by updating the regexp to make the "ERROR: " prefix optional.

Tested on x86_64-linux, with both guile 2.0 and 3.0.

gdb/testsuite/ChangeLog:

2021-07-08  Tom de Vries  <tdevries@suse.de>

	* gdb.guile/scm-breakpoint.exp: Make additional "ERROR: " prefix in
	exception printing optional.
2021-07-08 11:17:05 +02:00
GDB Administrator
e7ca24a166 Automatic date update in version.in 2021-07-08 00:00:25 +00:00
GDB Administrator
76deb9291d Automatic date update in version.in 2021-07-07 00:00:26 +00:00
Simon Marchi
8043d65ba2 gdb/testsuite: restore configure script
Commit f99d1d3749 ("Remove gdb/testsuite/configure") removed
gdb/testsuite/configure, as anything gdb/testsuite/configure did could
be done by gdb/configure.

There is however one use case that popped up when this changed
propagated to downstream consumers, to run the testsuite on an already
built GDB.  In the workflow of ROCm-GDB at AMD, a GDB package is built
in a CI job.  This GDB package is then tested on different machines /
hardware configurations as part of other CI jobs.  To achieve this,
those CI jobs only configure the testsuite directory and run "make
check" with an appropriate board file.

In light of this use case, the way I see it is that gdb/testsuite could
be considered its own project.  It could be stored in a completely
different repo if we want to, it just happens to be stored inside gdb/.

Since the only downside of having gdb/testsuite/configure is that it
takes a few more seconds to run, but on the other hand it's quite useful
for some people, I propose re-adding it.

In a sense, this is revert of f99d1d3749, but it's not a direct
git-revert, as some things have changed since.

gdb/ChangeLog:

	* configure.ac: Remove things that were moved from
	testsuite/configure.ac.
	* configure: Re-generate.

gdb/testsuite/ChangeLog:

	* configure.ac: Restore.
	* configure: Re-generate.
	* aclocal.m4: Re-generate.
	* Makefile.in (distclean): Add config.status.
	(Makefile): Adjust paths.
	(lib/pdtrace): Adjust paths.
	(config.status): Add.

Change-Id: Ic38c79485e1835712d9c99649c9dfb59667254f1
2021-07-06 15:00:57 -04:00
Tom de Vries
52e44e8d29 [gdb/testsuite] Fix fail in gdb.fortran/ptype-on-functions.exp with gcc-7
Since commit 05b8577206 "gdb/fortran: Add type info of formal parameter for
clang" I see:
...
(gdb) ptype say_string^M
type = void (character*(*), integer(kind=4))^M
(gdb) FAIL: gdb.fortran/ptype-on-functions.exp: ptype say_string
...

The part of the commit causing the fail is:
...
 gdb_test "ptype say_string" \
-    "type = void \\(character\\*\\(\\*\\), integer\\(kind=\\d+\\)\\)"
+    "type = void \\(character\[^,\]+, $integer8\\)"
...
which fails to take into account that for gcc-7 and before, the type for
string length of a string argument is int, not size_t.

Fix this by allowing both $integer8 and $integer4.

Tested on x86_64-linux, with gcc-7 and gcc-10.

gdb/testsuite/ChangeLog:

2021-07-06  Tom de Vries  <tdevries@suse.de>

	* gdb.fortran/ptype-on-functions.exp: Allow both $integer8 and
	$integer4 for size of string length.
2021-07-06 17:04:14 +02:00
GDB Administrator
5354f52ba2 Automatic date update in version.in 2021-07-06 00:00:26 +00:00
Simon Marchi
fa8740b675 gdb: fall back on sigpending + sigwait if sigtimedwait is not available
The macOS platform does not provide sigtimedwait, so we get:

      CXX    compile/compile.o
    In file included from /Users/smarchi/src/binutils-gdb/gdb/compile/compile.c:46:
    /Users/smarchi/src/binutils-gdb/gdb/../gdbsupport/scoped_ignore_signal.h:69:4: error: use of undeclared identifier 'sigtimedwait'
              sigtimedwait (&set, nullptr, &zero_timeout);
              ^

An alternative to sigtimedwait with a timeout of 0 is to use sigpending,
to first check which signals are pending, and then sigwait, to consume
them.  Since that's slightly more expensive (2 syscalls instead of 1),
keep using sigtimedwait for the platforms that provide it, and fall back
to sigpending + sigwait for the others.

gdbsupport/ChangeLog:

	* scoped_ignore_signal.h (struct scoped_ignore_signal)
	<~scoped_ignore_signal>: Use sigtimedwait if HAVE_SIGTIMEDWAIT
	is defined, else use sigpending + sigwait.

Change-Id: I2a72798337e81dd1bbd21214736a139dd350af87
Co-Authored-By: John Baldwin <jhb@FreeBSD.org>
2021-07-05 09:56:10 -04:00
Simon Marchi
507af45f62 gdbsupport/common.m4: check for sigtimedwait
The next patch will make the use of sigtimedwait conditional to whether
the platform provides it.  Start by adding a configure check for it.

gdbsupport/ChangeLog:

	* common.m4 (GDB_AC_COMMON): Check for sigtimedwait.
	* config.in, configure: Re-generate.

gdb/ChangeLog:

	* config.in, configure: Re-generate.

gdbserver/ChangeLog:

	* config.in, configure: Re-generate.

Change-Id: Ic7613fe14521b966b4d991bbcd0933ab14629c05
2021-07-05 09:56:05 -04:00
GDB Administrator
4165a99398 Automatic date update in version.in 2021-07-05 00:00:21 +00:00
Simon Marchi
5d91a235cd gdb: return early if no execution in darwin_solib_create_inferior_hook
When loading a file using the file command on macOS, we get:

    $ ./gdb -nx --data-directory=data-directory -q -ex "file ./test"
    Reading symbols from ./test...
    Reading symbols from /Users/smarchi/build/binutils-gdb/gdb/test.dSYM/Contents/Resources/DWARF/test...
    /Users/smarchi/src/binutils-gdb/gdb/thread.c:72: internal-error: struct thread_info *inferior_thread(): Assertion `current_thread_ != nullptr' failed.
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    Quit this debugging session? (y or n)

The backtrace is:

    * frame #0: 0x0000000101fcb826 gdb`internal_error(file="/Users/smarchi/src/binutils-gdb/gdb/thread.c", line=72, fmt="%s: Assertion `%s' failed.") at errors.cc:52:3
      frame #1: 0x00000001018a2584 gdb`inferior_thread() at thread.c:72:3
      frame #2: 0x0000000101469c09 gdb`get_current_regcache() at regcache.c:421:31
      frame #3: 0x00000001015f9812 gdb`darwin_solib_get_all_image_info_addr_at_init(info=0x0000603000006d00) at solib-darwin.c:464:34
      frame #4: 0x00000001015f7a04 gdb`darwin_solib_create_inferior_hook(from_tty=1) at solib-darwin.c:515:5
      frame #5: 0x000000010161205e gdb`solib_create_inferior_hook(from_tty=1) at solib.c:1200:3
      frame #6: 0x00000001016d8f76 gdb`symbol_file_command(args="./test", from_tty=1) at symfile.c:1650:7
      frame #7: 0x0000000100abab17 gdb`file_command(arg="./test", from_tty=1) at exec.c:555:3
      frame #8: 0x00000001004dc799 gdb`do_const_cfunc(c=0x000061100000c340, args="./test", from_tty=1) at cli-decode.c:102:3
      frame #9: 0x00000001004ea042 gdb`cmd_func(cmd=0x000061100000c340, args="./test", from_tty=1) at cli-decode.c:2160:7
      frame #10: 0x00000001018d4f59 gdb`execute_command(p="t", from_tty=1) at top.c:674:2
      frame #11: 0x0000000100eee430 gdb`catch_command_errors(command=(gdb`execute_command(char const*, int) at top.c:561), arg="file ./test", from_tty=1, do_bp_actions=true)(char const*, int), char const*, int, bool) at main.c:523:7
      frame #12: 0x0000000100eee902 gdb`execute_cmdargs(cmdarg_vec=0x00007ffeefbfeba0 size=1, file_type=CMDARG_FILE, cmd_type=CMDARG_COMMAND, ret=0x00007ffeefbfec20) at main.c:618:9
      frame #13: 0x0000000100eed3a4 gdb`captured_main_1(context=0x00007ffeefbff780) at main.c:1322:3
      frame #14: 0x0000000100ee810d gdb`captured_main(data=0x00007ffeefbff780) at main.c:1343:3
      frame #15: 0x0000000100ee8025 gdb`gdb_main(args=0x00007ffeefbff780) at main.c:1368:7
      frame #16: 0x00000001000044f1 gdb`main(argc=6, argv=0x00007ffeefbff8a0) at gdb.c:32:10
      frame #17: 0x00007fff20558f5d libdyld.dylib`start + 1

The solib_create_inferior_hook call in symbol_file_command was added by
commit ea142fbfc9 ("Fix breakpoints on file reloads for PIE
binaries").  It causes solib_create_inferior_hook to be called while
the inferior is not running, which darwin_solib_create_inferior_hook
does not expect.  darwin_solib_get_all_image_info_addr_at_init, in
particular, assumes that there is a current thread, as it tries to get
the current thread's regcache.

Fix it by adding a target_has_execution check and returning early.  Note
that there is a similar check in svr4_solib_create_inferior_hook.

gdb/ChangeLog:

	* solib-darwin.c (darwin_solib_create_inferior_hook): Return
	early if no execution.

Change-Id: Ia11dd983a1e29786e5ce663d0fcaa6846dc611bb
2021-07-04 18:50:02 -04:00
GDB Administrator
45959f27d9 Automatic date update in version.in 2021-07-04 00:00:25 +00:00
Joel Brobecker
afc60144d1 Bump GDB version number to 11.0.90.DATE-git.
gdb/ChangeLog:

	* version.in: Set GDB version number to 11.0.90.DATE-git.
2021-07-03 11:37:04 -07:00
Joel Brobecker
3c21f80eb4 Document the GDB 11.0.90 release in gdb/ChangeLog
gdb/ChangeLog:

	GDB 11.0.90 released.
2021-07-03 11:36:36 -07:00
Joel Brobecker
14b921356f Set GDB version number to 11.0.90.
gdb/ChangeLog:

	* version.in: Set GDB version number to 11.0.90.
2021-07-03 11:15:08 -07:00
Joel Brobecker
466ee06bda gdb/NEWS: Replace "Changes since GDB 10" by "Changes in GDB 11".
gdb/ChangeLog:

        * NEWS: Replace "Changes since GDB 10" by "Changes in GDB 11".
2021-07-03 11:04:49 -07:00
Joel Brobecker
828264c1d2 Set development mode to "off" by default.
bfd/ChangeLog:

	* development.sh (development): Set to false.
2021-07-03 10:42:20 -07:00
Joel Brobecker
633fd34015 Bump version to 11.0.90.DATE-git.
Now that the GDB 11 branch has been created, we can
bump the version number.

gdb/ChangeLog:

	GDB 11 branch created (4b51505e33):
	* version.in: Bump version to 11.0.90.DATE-git.
2021-07-03 10:41:28 -07:00
119 changed files with 10187 additions and 545 deletions

View File

@@ -1,3 +1,16 @@
2021-09-07 Luis Machado <luis.machado@linaro.org>
Revert: [AArch64] MTE corefile support
2021-05-21 Luis Machado <luis.machado@linaro.org>
* elf.c (elfcore_make_memtag_note_section): New function.
(elfcore_grok_note): Handle NT_MEMTAG note types.
2021-07-03 Joel Brobecker <brobecker@adacore.com>
* development.sh (development): Set to false.
2021-07-03 Nick Clifton <nickc@redhat.com>
* version.m4: Update version number.

View File

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

View File

@@ -9599,23 +9599,6 @@ elfcore_make_auxv_note_section (bfd *abfd, Elf_Internal_Note *note,
return true;
}
static bool
elfcore_make_memtag_note_section (bfd *abfd, Elf_Internal_Note *note,
size_t offs)
{
asection *sect = bfd_make_section_anyway_with_flags (abfd, ".memtag",
SEC_HAS_CONTENTS);
if (sect == NULL)
return false;
sect->size = note->descsz - offs;
sect->filepos = note->descpos + offs;
sect->alignment_power = 1 + bfd_get_arch_size (abfd) / 32;
return true;
}
/* prstatus_t exists on:
solaris 2.5+
linux 2.[01] + glibc
@@ -10676,8 +10659,6 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
return elfcore_make_note_pseudosection (abfd, ".note.linuxcore.siginfo",
note);
case NT_MEMTAG:
return elfcore_make_memtag_note_section (abfd, note, 0);
}
}

View File

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

View File

@@ -1,3 +1,11 @@
2021-09-07 Luis Machado <luis.machado@linaro.org>
Revert: [AArch64] MTE corefile support
2021-05-21 Luis Machado <luis.machado@linaro.org>
* readelf.c (get_note_type): Handle NT_MEMTAG note types.
2021-07-03 Nick Clifton <nickc@redhat.com>
* configure: Regenerate.

View File

@@ -18843,8 +18843,6 @@ get_note_type (Filedata * filedata, unsigned e_type)
return _("NT_SIGINFO (siginfo_t data)");
case NT_FILE:
return _("NT_FILE (mapped files)");
case NT_MEMTAG:
return _("NT_MEMTAG (memory tags)");
default:
break;
}

View File

@@ -1,3 +1,211 @@
2021-09-13 Joel Brobecker <brobecker@adacore.com>
* version.in: Set GDB version number to 11.1.
2021-09-08 Tom Tromey <tom@tromey.com>
* dwarf2/read.h (dwarf2_per_objfile::resize_symtabs): Remove.
* dwarf2/read.c (all_comp_units_iterator, all_comp_units_range):
New classes.
(dwarf2_per_objfile::symtab_set_p)
(dwarf2_per_objfile::get_symtab, dwarf2_per_objfile::set_symtab):
Adjust to resizeable vectors.
(dwarf2_gdb_index::expand_symtabs_matching)
(dwarf2_base_index_functions::map_symbol_filenames)
(dwarf2_debug_names_index::expand_symtabs_matching): Use
all_comp_units_range.
(dwarf2_initialize_objfile, dwarf2_build_psymtabs)
(add_type_unit): Don't call resize_symtabs.
2021-09-07 John Baldwin <jhb@FreeBSD.org>
* fbsd-nat.c (fbsd_nat_target::info_proc): Use plongest and
pulongest instead of %j.
2021-08-30 Tom de Vries <tdevries@suse.de>
PR cli/28290
* gdb/corelow.c (core_target_open): Skip call to gdb_abspath in the
empty-string case.
2021-08-23 Tom de Vries <tdevries@suse.de>
PR gdb/26880
* gdb/exec.c (exec_file_attach): Use %s instead of %ps in call to
error function.
2021-08-06 Simon Marchi <simon.marchi@polymtl.ca>
Tom de Vries <tdevries@suse.de>
PR symtab/28004
* dwarf2/read.c (dwarf2_rnglists_process, dwarf2_ranges_process):
Fix zero address complaint.
2021-08-02 Tom Tromey <tromey@adacore.com>
PR varobj/28131
* varobj.c (~varobj): Delete 'dynamic' before 'root'.
2021-08-02 Shahab Vahedi <shahab@synopsys.com>
PR gdb/28104
* gdbtypes.c (gdbtypes_post_init): Use
"arch_boolean_type (..., unsigned=1, ...) to construct
"boolean".
cp-valprint.c (test_print_flags): New.
(_initialize_cp_valprint): Run the "test_print_flags" unit-test.
2021-07-28 Tom de Vries <tdevries@suse.de>
* dwarf2/read.c (attr_to_dynamic_prop): Handle DW_FORM_data16.
2021-07-27 Tom de Vries <tdevries@suse.de>
PR testsuite/26904
* gdb/testsuite/gdb.ada/big_packed_array.exp: Add xfail.
2021-07-27 Tom de Vries <tdevries@suse.de>
PR testsuite/26903
* gdb/testsuite/gdb.ada/array_of_variant.exp: Add xfails.
2021-07-26 Frederic Cambus <fred@statdns.com>
* syscalls/netbsd.xml: Regenerate.
2021-07-26 Shahab Vahedi <shahab@synopsys.com>
Simon Marchi <simon.marchi@efficios.com>
PR gdb/28103
* valprint.c (val_print_type_code_flags): Merely shift the VAL
to the right to get rid of the lower bits.
(test_print_flags): New.
(_initialize_valprint): Invoke the "test_print_flags" as a unit-test.
2021-07-26 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
PR gdb/28076
* mi/mi-cmd-break.c (mi_cmd_break_condition): Handle the case
of having no condition argument.
2021-07-20 Luis Machado <luis.machado@linaro.org>
Pedro Alves <pedro@palves.net>
PR gdb/28110
* gdbarch.sh: Updated documentation for gdbarch_tagged_address_p.
* gdbarch.h: Regenerate.
* printcmd.c (should_validate_memtags): Reorder comparisons and only
validate tags for pointer and reference types. Skip validation of
optimized out or unavailable values.
(print_command_1): Guard call memory tagging validation code with
a try/catch block.
2021-07-19 Tom Tromey <tromey@adacore.com>
PR gdb/28093
* language.c (auto_or_unknown_language::parser): Call error.
2021-07-17 Sergey Belyashov <Sergey.Belyashov@gmail.com>
* Makefile.in (ALL_TARGET_OBS): Add z80-tdep.c.
* NEWS: Mention z80 support.
* configure.tgt: Handle z80*.
* features/Makefile (XMLTOC): Add z80.xml.
* features/z80-cpu.xml: New.
* features/z80.c: Generate.
* features/z80.xml: New.
* z80-tdep.c: New file.
* z80-tdep.h: New file.
2021-07-13 Lancelot Six <lsix@lancelotsix.com>
* make-init-c: Use /bin/sh as shebang.
2021-07-13 Pedro Alves <pedro@palves.net>
PR gdb/28080
* gdb_bfd.c (gdb_bfd_close_warning): New.
(gdb_bfd_iovec_fileio_close): Wrap target_fileio_close in
try/catch and print warning on exception.
(gdb_bfd_close_or_warn): Use gdb_bfd_close_warning.
2021-07-13 Pedro Alves <pedro@palves.net>
PR gdb/28080
* remote.c (remote_unpush_target): Invalidate file I/O target
handles.
* target.c (fileio_handles_invalidate_target): Make extern.
* target.h (fileio_handles_invalidate_target): Declare.
2021-07-13 Simon Marchi <simon.marchi@polymtl.ca>
* mi/mi-main.c (mi_cmd_exec_interrupt): Use
scoped_disable_commit_resumed in the --thread-group case.
2021-07-13 John Ericson <git@JohnEricson.me>
* sparc-tdep.h: Fix comment.
* netbsd-tdep.c (nbsd_info_proc_mappings_header): Fix comment.
(nbsd_init_abi): Fix comment.
* configure.tgt (*-*-netbsd* | *-*-knetbsd*-gnu): Fix netbsd
file name.
(alpha*-*-openbsd*): Likewise.
(sparc-*-openbsd*): Likewise.
(sparc64-*-openbsd*): Likewise.
2021-07-11 Tom Tromey <tom@tromey.com>
Committed by Joel Brobecker <brobecker@adacore.com>:
* gdb/symtab.c (info_sources_filter::matches): Add default
case hander in switch statement.
2021-07-08 Simon Marchi <simon.marchi@polymtl.ca>
* s390-linux-tdep.c (s390_linux_init_abi_any): Pass 1 (number
of displaced stepping buffers to linux_init_abi.
* s390-tdep.c (s390_gdbarch_init): Don't set the Linux-specific
displaced-stepping gdbarch callbacks.
2021-07-08 Simon Marchi <simon.marchi@polymtl.ca>
* Makefile.in (SUBDIRS): Remove testsuite.
2021-07-06 Simon Marchi <simon.marchi@polymtl.ca>
* configure.ac: Remove things that were moved from
testsuite/configure.ac.
* configure: Re-generate.
2021-07-05 Simon Marchi <simon.marchi@polymtl.ca>
* config.in, configure: Re-generate.
2021-07-04 Simon Marchi <simon.marchi@polymtl.ca>
* solib-darwin.c (darwin_solib_create_inferior_hook): Return
early if no execution.
2021-07-03 Joel Brobecker <brobecker@adacore.com>
* version.in: Set GDB version number to 11.0.90.DATE-git.
2021-07-03 Joel Brobecker <brobecker@adacore.com>
GDB 11.0.90 released.
2021-07-03 Joel Brobecker <brobecker@adacore.com>
* version.in: Set GDB version number to 11.0.90.
2021-07-03 Joel Brobecker <brobecker@adacore.com>
* NEWS: Replace "Changes since GDB 10" by "Changes in GDB 11".
2021-07-03 Joel Brobecker <brobecker@adacore.com>
GDB 11 branch created (4b51505e33441c6165e7789fa2b6d21930242927):
* version.in: Bump version to 11.0.90.DATE-git.
2021-07-02 Tom Tromey <tromey@adacore.com>
* ada-exp.y (chop_selector, chop_separator, write_selectors)

View File

@@ -852,7 +852,8 @@ ALL_TARGET_OBS = \
xstormy16-tdep.o \
xtensa-config.o \
xtensa-linux-tdep.o \
xtensa-tdep.o
xtensa-tdep.o \
z80-tdep.o
# The following native-target dependent variables are defined on
# configure.nat.
@@ -1591,7 +1592,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \
$(SUBDIR_TARGET_OBS) \
$(SUBDIR_GCC_COMPILE_OBS)
SUBDIRS = doc @subdirs@ data-directory testsuite
SUBDIRS = doc @subdirs@ data-directory
CLEANDIRS = $(SUBDIRS)
# List of subdirectories in the build tree that must exist.

View File

@@ -1,7 +1,7 @@
What has changed in GDB?
(Organized release by release)
*** Changes since GDB 10
*** Changes in GDB 11
* The 'set disassembler-options' command now supports specifying options
for the ARC target.
@@ -424,6 +424,7 @@ alias [-a] [--] ALIAS = COMMAND [DEFAULT-ARGS...]
GNU/Linux/RISC-V (gdbserver) riscv*-*-linux*
BPF bpf-unknown-none
Z80 z80-unknown-*
* Python API

View File

@@ -414,6 +414,9 @@
/* Define to 1 if you have the `sigsetmask' function. */
#undef HAVE_SIGSETMASK
/* Define to 1 if you have the `sigtimedwait' function. */
#undef HAVE_SIGTIMEDWAIT
/* Define to 1 if you have the `socketpair' function. */
#undef HAVE_SOCKETPAIR

90
gdb/configure vendored
View File

@@ -619,14 +619,10 @@ ac_includes_default="\
# include <unistd.h>
#endif"
ac_header_list=
enable_option_checking=no
ac_header_list=
ac_subst_vars='LTLIBOBJS
LIBOBJS
NM_TRANSFORM_NAME
GAS_TRANSFORM_NAME
READELF_TRANSFORM_NAME
STRIP_TRANSFORM_NAME
GCORE_TRANSFORM_NAME
GDB_TRANSFORM_NAME
XSLTPROC
@@ -637,7 +633,6 @@ LIBXXHASH
HAVE_LIBXXHASH
CTF_DEPS
LIBCTF
enable_libctf
LTLIBBABELTRACE
LIBBABELTRACE
HAVE_LIBBABELTRACE
@@ -668,7 +663,6 @@ GDBTKLIBS
X_LIBS
X_LDFLAGS
X_CFLAGS
subdirs
TK_XINCLUDES
TK_DEPS
TK_LIBRARY
@@ -776,7 +770,7 @@ PKG_CONFIG_PATH
PKG_CONFIG
HAVE_NATIVE_GCORE_TARGET
TARGET_OBS
RPATH_ENVVAR
subdirs
GDB_DATADIR
DEBUGDIR
MAKEINFO_EXTRA_FLAGS
@@ -882,7 +876,6 @@ with_gdb_datadir
with_relocated_sources
with_auto_load_dir
with_auto_load_safe_path
enable_shared
enable_targets
enable_64_bit_bfd
enable_gdbmi
@@ -963,7 +956,8 @@ DEBUGINFOD_LIBS
YACC
YFLAGS
XMKMF'
ac_subdirs_all='gdbtk'
ac_subdirs_all='testsuite
gdbtk'
# Initialize some variables set by options.
ac_init_help=
@@ -1589,7 +1583,6 @@ Optional Features:
sometimes confusing) to the casual installer
--enable-plugins Enable support for plugins
--disable-largefile omit support for large files
--enable-shared build shared libraries [default=yes]
--enable-targets=TARGETS
alternative target configurations
--enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)
@@ -6623,34 +6616,9 @@ _ACEOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5
$as_echo "$with_auto_load_safe_path" >&6; }
# Enable shared libraries.
# Check whether --enable-shared was given.
if test "${enable_shared+set}" = set; then :
enableval=$enable_shared;
else
enable_shared=yes
fi
# If we have shared libraries, try to set RPATH_ENVVAR reasonably,
# such that we can find the shared libraries in the build tree.
if test $enable_shared = no; then
# The variable `RPATH_ENVVAR' itself is not likely to be used on any
# platform.
RPATH_ENVVAR=RPATH_ENVVAR
else
# The variable `LD_LIBRARY_PATH' is used on most platforms.
RPATH_ENVVAR=LD_LIBRARY_PATH
# The following exceptions are taken from Libtool 1.4.3.
case $host_os in
aix*)
if test $host_cpu != ia64; then
RPATH_ENVVAR=LIBPATH
fi ;;
darwin* | rhapsody*)
RPATH_ENVVAR=DYLD_LIBRARY_PATH ;;
esac
fi
subdirs="$subdirs testsuite"
# Check whether to support alternative target configurations
@@ -13857,7 +13825,7 @@ fi
for ac_func in fdwalk getrlimit pipe pipe2 poll socketpair sigaction \
ptrace64 sbrk setns sigaltstack sigprocmask \
setpgid setpgrp getrusage getauxval
setpgid setpgrp getrusage getauxval sigtimedwait
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -18325,9 +18293,7 @@ $as_echo "${private_dir}" >&6; }
CONFIG_OBS="${CONFIG_OBS} gdbres.o"
fi
subdirs="$subdirs gdbtk"
subdirs="$subdirs gdbtk"
fi
fi
@@ -19209,7 +19175,6 @@ fi
# If nativefile (NAT_FILE) is not set in configure.nat, we link to an
# empty version.
@@ -19841,44 +19806,6 @@ ac_config_files="$ac_config_files gcore"
ac_config_files="$ac_config_files Makefile gdb-gdb.gdb gdb-gdb.py doc/Makefile data-directory/Makefile"
# Transform the name of some programs for the testsuite/lib/pdtrace
# test tool.
gdb_ac_transform=`echo "$program_transform_name" | sed -e 's/\\$\\$/\\$/g'`
STRIP_TRANSFORM_NAME=`echo strip | sed -e "$gdb_ac_transform"`
if test "x$STRIP_TRANSFORM_NAME" = x; then
STRIP_TRANSFORM_NAME=strip
fi
gdb_ac_transform=`echo "$program_transform_name" | sed -e 's/\\$\\$/\\$/g'`
READELF_TRANSFORM_NAME=`echo readelf | sed -e "$gdb_ac_transform"`
if test "x$READELF_TRANSFORM_NAME" = x; then
READELF_TRANSFORM_NAME=readelf
fi
gdb_ac_transform=`echo "$program_transform_name" | sed -e 's/\\$\\$/\\$/g'`
GAS_TRANSFORM_NAME=`echo as | sed -e "$gdb_ac_transform"`
if test "x$GAS_TRANSFORM_NAME" = x; then
GAS_TRANSFORM_NAME=as
fi
gdb_ac_transform=`echo "$program_transform_name" | sed -e 's/\\$\\$/\\$/g'`
NM_TRANSFORM_NAME=`echo nm | sed -e "$gdb_ac_transform"`
if test "x$NM_TRANSFORM_NAME" = x; then
NM_TRANSFORM_NAME=nm
fi
ac_config_files="$ac_config_files testsuite/lib/pdtrace"
ac_config_files="$ac_config_files testsuite/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -20608,8 +20535,6 @@ do
"gdb-gdb.py") CONFIG_FILES="$CONFIG_FILES gdb-gdb.py" ;;
"doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
"data-directory/Makefile") CONFIG_FILES="$CONFIG_FILES data-directory/Makefile" ;;
"testsuite/lib/pdtrace") CONFIG_FILES="$CONFIG_FILES testsuite/lib/pdtrace" ;;
"testsuite/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/Makefile" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
@@ -21240,7 +21165,6 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
"depdir":C) $SHELL $ac_aux_dir/mkinstalldirs $DEPDIR ;;
"nm.h":L) echo > stamp-nmh ;;
"gcore":F) chmod +x gcore ;;
"testsuite/lib/pdtrace":F) chmod +x testsuite/lib/pdtrace ;;
esac
done # for ac_tag

View File

@@ -153,31 +153,7 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir,
[Directories safe to hold auto-loaded files.])
AC_MSG_RESULT([$with_auto_load_safe_path])
# Enable shared libraries.
AC_ARG_ENABLE(shared,
AS_HELP_STRING([--enable-shared], [build shared libraries [default=yes]]),,
enable_shared=yes)
# If we have shared libraries, try to set RPATH_ENVVAR reasonably,
# such that we can find the shared libraries in the build tree.
if test $enable_shared = no; then
# The variable `RPATH_ENVVAR' itself is not likely to be used on any
# platform.
RPATH_ENVVAR=RPATH_ENVVAR
else
# The variable `LD_LIBRARY_PATH' is used on most platforms.
RPATH_ENVVAR=LD_LIBRARY_PATH
# The following exceptions are taken from Libtool 1.4.3.
case $host_os in
aix*)
if test $host_cpu != ia64; then
RPATH_ENVVAR=LIBPATH
fi ;;
darwin* | rhapsody*)
RPATH_ENVVAR=DYLD_LIBRARY_PATH ;;
esac
fi
AC_SUBST(RPATH_ENVVAR)
AC_CONFIG_SUBDIRS(testsuite)
# Check whether to support alternative target configurations
AC_ARG_ENABLE(targets,
@@ -2195,7 +2171,6 @@ else
LIBCTF=
CTF_DEPS=
fi
AC_SUBST(enable_libctf)
AC_SUBST(LIBCTF)
AC_SUBST(CTF_DEPS)
@@ -2261,13 +2236,5 @@ GDB_AC_TRANSFORM([gdb], [GDB_TRANSFORM_NAME])
GDB_AC_TRANSFORM([gcore], [GCORE_TRANSFORM_NAME])
AC_CONFIG_FILES([gcore], [chmod +x gcore])
AC_CONFIG_FILES([Makefile gdb-gdb.gdb gdb-gdb.py doc/Makefile data-directory/Makefile])
# Transform the name of some programs for the testsuite/lib/pdtrace
# test tool.
GDB_AC_TRANSFORM(strip, STRIP_TRANSFORM_NAME)
GDB_AC_TRANSFORM(readelf, READELF_TRANSFORM_NAME)
GDB_AC_TRANSFORM(as, GAS_TRANSFORM_NAME)
GDB_AC_TRANSFORM(nm, NM_TRANSFORM_NAME)
AC_CONFIG_FILES([testsuite/lib/pdtrace], [chmod +x testsuite/lib/pdtrace])
AC_CONFIG_FILES([testsuite/Makefile])
AC_OUTPUT

View File

@@ -105,7 +105,7 @@ case "${targ}" in
*-*-freebsd* | *-*-kfreebsd*-gnu)
os_obs="fbsd-tdep.o solib-svr4.o";;
*-*-netbsd* | *-*-knetbsd*-gnu)
os_obs="nbsd-tdep.o solib-svr4.o";;
os_obs="netbsd-tdep.o solib-svr4.o";;
*-*-openbsd*)
os_obs="obsd-tdep.o solib-svr4.o";;
esac
@@ -146,7 +146,7 @@ alpha*-*-netbsd* | alpha*-*-knetbsd*-gnu)
alpha*-*-openbsd*)
# Target: OpenBSD/alpha
gdb_target_obs="alpha-mdebug-tdep.o alpha-bsd-tdep.o \
alpha-netbsd-tdep.o alpha-obsd-tdep.o nbsd-tdep.o"
alpha-netbsd-tdep.o alpha-obsd-tdep.o netbsd-tdep.o"
;;
am33_2.0*-*-linux*)
@@ -632,14 +632,14 @@ sparc64-*-netbsd* | sparc64-*-knetbsd*-gnu)
sparc-*-openbsd*)
# Target: OpenBSD/sparc
gdb_target_obs="sparc-tdep.o sparc-netbsd-tdep.o sparc-obsd-tdep.o \
nbsd-tdep.o bsd-uthread.o \
netbsd-tdep.o bsd-uthread.o \
ravenscar-thread.o sparc-ravenscar-thread.o"
;;
sparc64-*-openbsd*)
# Target: OpenBSD/sparc64
gdb_target_obs="sparc64-tdep.o sparc64-netbsd-tdep.o sparc64-obsd-tdep.o \
sparc-tdep.o sparc-netbsd-tdep.o sparc-obsd-tdep.o \
nbsd-tdep.o bsd-uthread.o \
netbsd-tdep.o bsd-uthread.o \
ravenscar-thread.o sparc-ravenscar-thread.o"
;;
sparc-*-solaris2* | sparcv9-*-solaris2* | sparc64-*-solaris2*)
@@ -761,6 +761,10 @@ xtensa*-*-*linux*)
# Target: GNU/Linux Xtensa
gdb_target_obs="xtensa-linux-tdep.o symfile-mem.o linux-tdep.o"
;;
z80*)
# Target: Z80
gdb_target_obs="z80-tdep.o"
;;
esac

View File

@@ -428,7 +428,8 @@ core_target_open (const char *arg, int from_tty)
}
gdb::unique_xmalloc_ptr<char> filename (tilde_expand (arg));
if (!IS_ABSOLUTE_PATH (filename.get ()))
if (strlen (filename.get ()) != 0
&& !IS_ABSOLUTE_PATH (filename.get ()))
filename = gdb_abspath (filename.get ());
flags = O_BINARY | O_LARGEFILE;

View File

@@ -38,6 +38,8 @@
#include "gdbsupport/byte-vector.h"
#include "gdbarch.h"
#include "cli/cli-style.h"
#include "gdbsupport/selftest.h"
#include "selftest-arch.h"
static struct obstack dont_print_vb_obstack;
static struct obstack dont_print_statmem_obstack;
@@ -715,11 +717,77 @@ cp_print_class_member (const gdb_byte *valaddr, struct type *type,
fprintf_filtered (stream, "%ld", (long) val);
}
#if GDB_SELF_TEST
/* Test printing of TYPE_CODE_STRUCT values. */
static void
test_print_fields (gdbarch *arch)
{
struct field *f;
type *uint8_type = builtin_type (arch)->builtin_uint8;
type *bool_type = builtin_type (arch)->builtin_bool;
type *the_struct = arch_composite_type (arch, NULL, TYPE_CODE_STRUCT);
TYPE_LENGTH (the_struct) = 4;
/* Value: 1110 1001
Fields: C-BB B-A- */
if (gdbarch_byte_order (arch) == BFD_ENDIAN_LITTLE)
{
f = append_composite_type_field_raw (the_struct, "A", bool_type);
SET_FIELD_BITPOS (*f, 1);
FIELD_BITSIZE (*f) = 1;
f = append_composite_type_field_raw (the_struct, "B", uint8_type);
SET_FIELD_BITPOS (*f, 3);
FIELD_BITSIZE (*f) = 3;
f = append_composite_type_field_raw (the_struct, "C", bool_type);
SET_FIELD_BITPOS (*f, 7);
FIELD_BITSIZE (*f) = 1;
}
/* According to the logic commented in "make_gdb_type_struct ()" of
* target-descriptions.c, bit positions are numbered differently for
* little and big endians. */
else
{
f = append_composite_type_field_raw (the_struct, "A", bool_type);
SET_FIELD_BITPOS (*f, 30);
FIELD_BITSIZE (*f) = 1;
f = append_composite_type_field_raw (the_struct, "B", uint8_type);
SET_FIELD_BITPOS (*f, 26);
FIELD_BITSIZE (*f) = 3;
f = append_composite_type_field_raw (the_struct, "C", bool_type);
SET_FIELD_BITPOS (*f, 24);
FIELD_BITSIZE (*f) = 1;
}
value *val = allocate_value (the_struct);
gdb_byte *contents = value_contents_writeable (val);
store_unsigned_integer (contents, TYPE_LENGTH (value_enclosing_type (val)),
gdbarch_byte_order (arch), 0xe9);
string_file out;
struct value_print_options opts;
get_no_prettyformat_print_options (&opts);
cp_print_value_fields(val, &out, 0, &opts, NULL, 0);
SELF_CHECK (out.string () == "{A = false, B = 5, C = true}");
out.clear();
opts.format = 'x';
cp_print_value_fields(val, &out, 0, &opts, NULL, 0);
SELF_CHECK (out.string () == "{A = 0x0, B = 0x5, C = 0x1}");
}
#endif
void _initialize_cp_valprint ();
void
_initialize_cp_valprint ()
{
#if GDB_SELF_TEST
selftests::register_test_foreach_arch ("print-fields", test_print_fields);
#endif
obstack_begin (&dont_print_stat_array_obstack,
32 * sizeof (struct type *));
obstack_begin (&dont_print_statmem_obstack,

View File

@@ -1,3 +1,13 @@
2021-08-12 Tom Tromey <tromey@adacore.com>
* gdb.texinfo (Output Styling): Mention Pygments.
2021-07-26 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
PR gdb/28076
* gdb.texinfo (GDB/MI Breakpoint Commands): Mention clearing
the condition in the -break-condition command.
2021-07-02 Pedro Alves <pedro@palves.net>
* gdb.texinfo (TUI): <TUI Mouse Support>: New node/section.

View File

@@ -26033,10 +26033,16 @@ Show the current state of styling.
@item set style sources @samp{on|off}
Enable or disable source code styling. This affects whether source
code, such as the output of the @code{list} command, is styled. Note
that source styling only works if styling in general is enabled, and
if @value{GDBN} was linked with the GNU Source Highlight library. The
default is @samp{on}.
code, such as the output of the @code{list} command, is styled. The
default is @samp{on}. Note that source styling only works if styling
in general is enabled, and if a source highlighting library is
available to @value{GDBN}.
There are two ways that highlighting can be done. First, if
@value{GDBN} was linked with the GNU Source Highlight library, then it
is used. Otherwise, if @value{GDBN} was configured with Python
scripting support, and if the Python Pygments package is available,
then it will be used.
@item show style sources
Show the current state of source code styling.
@@ -30565,7 +30571,7 @@ times="0"@}
@subsubheading Synopsis
@smallexample
-break-condition [ --force ] @var{number} @var{expr}
-break-condition [ --force ] @var{number} [ @var{expr} ]
@end smallexample
Breakpoint @var{number} will stop the program only if the condition in
@@ -30573,7 +30579,8 @@ Breakpoint @var{number} will stop the program only if the condition in
@samp{-break-list} output (see the description of the @samp{-break-list}
command below). If the @samp{--force} flag is passed, the condition
is forcibly defined even when it is invalid for all locations of
breakpoint @var{number}.
breakpoint @var{number}. If the @var{expr} argument is omitted,
breakpoint @var{number} becomes unconditional.
@subsubheading @value{GDBN} Command

View File

@@ -1639,6 +1639,73 @@ line_header_eq_voidp (const void *item_lhs, const void *item_rhs)
/* An iterator for all_comp_units that is based on index. This
approach makes it possible to iterate over all_comp_units safely,
when some caller in the loop may add new units. */
class all_comp_units_iterator
{
public:
all_comp_units_iterator (dwarf2_per_bfd *per_bfd, bool start)
: m_per_bfd (per_bfd),
m_index (start ? 0 : per_bfd->all_comp_units.size ())
{
}
all_comp_units_iterator &operator++ ()
{
++m_index;
return *this;
}
dwarf2_per_cu_data *operator* () const
{
return m_per_bfd->get_cu (m_index);
}
bool operator== (const all_comp_units_iterator &other) const
{
return m_index == other.m_index;
}
bool operator!= (const all_comp_units_iterator &other) const
{
return m_index != other.m_index;
}
private:
dwarf2_per_bfd *m_per_bfd;
size_t m_index;
};
/* A range adapter for the all_comp_units_iterator. */
class all_comp_units_range
{
public:
all_comp_units_range (dwarf2_per_bfd *per_bfd)
: m_per_bfd (per_bfd)
{
}
all_comp_units_iterator begin ()
{
return all_comp_units_iterator (m_per_bfd, true);
}
all_comp_units_iterator end ()
{
return all_comp_units_iterator (m_per_bfd, false);
}
private:
dwarf2_per_bfd *m_per_bfd;
};
/* See declaration. */
dwarf2_per_bfd::dwarf2_per_bfd (bfd *obfd, const dwarf2_debug_sections *names,
@@ -1703,9 +1770,9 @@ private:
bool
dwarf2_per_objfile::symtab_set_p (const dwarf2_per_cu_data *per_cu) const
{
gdb_assert (per_cu->index < this->m_symtabs.size ());
return this->m_symtabs[per_cu->index] != nullptr;
if (per_cu->index < this->m_symtabs.size ())
return this->m_symtabs[per_cu->index] != nullptr;
return false;
}
/* See read.h. */
@@ -1713,9 +1780,9 @@ dwarf2_per_objfile::symtab_set_p (const dwarf2_per_cu_data *per_cu) const
compunit_symtab *
dwarf2_per_objfile::get_symtab (const dwarf2_per_cu_data *per_cu) const
{
gdb_assert (per_cu->index < this->m_symtabs.size ());
return this->m_symtabs[per_cu->index];
if (per_cu->index < this->m_symtabs.size ())
return this->m_symtabs[per_cu->index];
return nullptr;
}
/* See read.h. */
@@ -1724,9 +1791,9 @@ void
dwarf2_per_objfile::set_symtab (const dwarf2_per_cu_data *per_cu,
compunit_symtab *symtab)
{
gdb_assert (per_cu->index < this->m_symtabs.size ());
if (per_cu->index >= this->m_symtabs.size ())
this->m_symtabs.resize (per_cu->index + 1);
gdb_assert (this->m_symtabs[per_cu->index] == nullptr);
this->m_symtabs[per_cu->index] = symtab;
}
@@ -4321,11 +4388,12 @@ dwarf2_gdb_index::expand_symtabs_matching
if (symbol_matcher == NULL && lookup_name == NULL)
{
for (const auto &per_cu : per_objfile->per_bfd->all_comp_units)
for (dwarf2_per_cu_data *per_cu
: all_comp_units_range (per_objfile->per_bfd))
{
QUIT;
if (!dw2_expand_symtabs_matching_one (per_cu.get (), per_objfile,
if (!dw2_expand_symtabs_matching_one (per_cu, per_objfile,
file_matcher,
expansion_notify))
return false;
@@ -4437,14 +4505,14 @@ dwarf2_base_index_functions::map_symbol_filenames
}
}
for (const auto &per_cu : per_objfile->per_bfd->all_comp_units)
for (dwarf2_per_cu_data *per_cu
: all_comp_units_range (per_objfile->per_bfd))
{
/* We only need to look at symtabs not already expanded. */
if (per_objfile->symtab_set_p (per_cu.get ()))
if (per_cu->is_debug_types || per_objfile->symtab_set_p (per_cu))
continue;
quick_file_names *file_data = dw2_get_file_names (per_cu.get (),
per_objfile);
quick_file_names *file_data = dw2_get_file_names (per_cu, per_objfile);
if (file_data == nullptr
|| qfn_cache.find (file_data) != qfn_cache.end ())
continue;
@@ -5309,11 +5377,12 @@ dwarf2_debug_names_index::expand_symtabs_matching
if (symbol_matcher == NULL && lookup_name == NULL)
{
for (const auto &per_cu : per_objfile->per_bfd->all_comp_units)
for (dwarf2_per_cu_data *per_cu
: all_comp_units_range (per_objfile->per_bfd))
{
QUIT;
if (!dw2_expand_symtabs_matching_one (per_cu.get (), per_objfile,
if (!dw2_expand_symtabs_matching_one (per_cu, per_objfile,
file_matcher,
expansion_notify))
return false;
@@ -5421,7 +5490,6 @@ dwarf2_initialize_objfile (struct objfile *objfile)
if (per_bfd->using_index)
{
dwarf_read_debug_printf ("using_index already set");
per_objfile->resize_symtabs ();
objfile->qf.push_front (make_dwarf_gdb_index ());
return;
}
@@ -5430,7 +5498,6 @@ dwarf2_initialize_objfile (struct objfile *objfile)
create_all_comp_units (per_objfile);
per_bfd->quick_file_names_table
= create_quick_file_names_table (per_bfd->all_comp_units.size ());
per_objfile->resize_symtabs ();
for (int i = 0; i < per_bfd->all_comp_units.size (); ++i)
{
@@ -5452,7 +5519,6 @@ dwarf2_initialize_objfile (struct objfile *objfile)
if (per_bfd->debug_names_table != nullptr)
{
dwarf_read_debug_printf ("re-using shared debug names table");
per_objfile->resize_symtabs ();
objfile->qf.push_front (make_dwarf_debug_names ());
return;
}
@@ -5462,7 +5528,6 @@ dwarf2_initialize_objfile (struct objfile *objfile)
if (per_bfd->index_table != nullptr)
{
dwarf_read_debug_printf ("re-using shared index table");
per_objfile->resize_symtabs ();
objfile->qf.push_front (make_dwarf_gdb_index ());
return;
}
@@ -5482,7 +5547,6 @@ dwarf2_initialize_objfile (struct objfile *objfile)
if (dwarf2_read_debug_names (per_objfile))
{
dwarf_read_debug_printf ("found debug names");
per_objfile->resize_symtabs ();
objfile->qf.push_front (make_dwarf_debug_names ());
return;
}
@@ -5492,7 +5556,6 @@ dwarf2_initialize_objfile (struct objfile *objfile)
get_gdb_index_contents_from_section<dwz_file>))
{
dwarf_read_debug_printf ("found gdb index from file");
per_objfile->resize_symtabs ();
objfile->qf.push_front (make_dwarf_gdb_index ());
return;
}
@@ -5504,7 +5567,6 @@ dwarf2_initialize_objfile (struct objfile *objfile)
{
dwarf_read_debug_printf ("found gdb index from cache");
global_index_cache.hit ();
per_objfile->resize_symtabs ();
objfile->qf.push_front (make_dwarf_gdb_index ());
return;
}
@@ -5534,7 +5596,6 @@ dwarf2_build_psymtabs (struct objfile *objfile, psymbol_functions *psf)
}
else
psf->set_partial_symtabs (per_bfd->partial_symtabs);
per_objfile->resize_symtabs ();
return;
}
@@ -5561,8 +5622,6 @@ dwarf2_build_psymtabs (struct objfile *objfile, psymbol_functions *psf)
dwarf2_build_psymtabs_hard (per_objfile);
psymtabs.keep ();
per_objfile->resize_symtabs ();
/* (maybe) store an index in the cache. */
global_index_cache.store (per_objfile);
}
@@ -5904,8 +5963,6 @@ add_type_unit (dwarf2_per_objfile *per_objfile, ULONGEST sig, void **slot)
= per_objfile->per_bfd->allocate_signatured_type (sig);
signatured_type *sig_type = sig_type_holder.get ();
per_objfile->resize_symtabs ();
per_objfile->per_bfd->all_comp_units.emplace_back
(sig_type_holder.release ());
if (per_objfile->per_bfd->using_index)
@@ -13608,7 +13665,6 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu,
/* Base address selection entry. */
gdb::optional<CORE_ADDR> base;
const gdb_byte *buffer;
CORE_ADDR baseaddr;
bool overflow = false;
ULONGEST addr_index;
struct dwarf2_section_info *rnglists_section;
@@ -13625,8 +13681,6 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu,
}
buffer = rnglists_section->buffer + offset;
baseaddr = objfile->text_section_offset ();
while (1)
{
/* Initialize it due to a false compiler warning. */
@@ -13768,7 +13822,7 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu,
/* A not-uncommon case of bad debug info.
Don't pollute the addrmap with bad data. */
if (range_beginning + baseaddr == 0
if (range_beginning == 0
&& !per_objfile->per_bfd->has_section_at_zero)
{
complaint (_(".debug_rnglists entry has start address of zero"
@@ -13810,7 +13864,6 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag,
gdb::optional<CORE_ADDR> base;
unsigned int dummy;
const gdb_byte *buffer;
CORE_ADDR baseaddr;
if (cu_header->version >= 5)
return dwarf2_rnglists_process (offset, cu, tag, callback);
@@ -13826,8 +13879,6 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag,
}
buffer = per_objfile->per_bfd->ranges.buffer + offset;
baseaddr = objfile->text_section_offset ();
while (1)
{
CORE_ADDR range_beginning, range_end;
@@ -13878,7 +13929,7 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag,
/* A not-uncommon case of bad debug info.
Don't pollute the addrmap with bad data. */
if (range_beginning + baseaddr == 0
if (range_beginning == 0
&& !per_objfile->per_bfd->has_section_at_zero)
{
complaint (_(".debug_ranges entry has start address of zero"
@@ -18231,7 +18282,22 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
baton->locexpr.per_cu = cu->per_cu;
baton->locexpr.per_objfile = per_objfile;
struct dwarf_block *block = attr->as_block ();
struct dwarf_block *block;
if (attr->form == DW_FORM_data16)
{
size_t data_size = 16;
block = XOBNEW (obstack, struct dwarf_block);
block->size = (data_size
+ 2 /* Extra bytes for DW_OP and arg. */);
gdb_byte *data = XOBNEWVEC (obstack, gdb_byte, block->size);
data[0] = DW_OP_implicit_value;
data[1] = data_size;
memcpy (&data[2], attr->as_block ()->data, data_size);
block->data = data;
}
else
block = attr->as_block ();
baton->locexpr.size = block->size;
baton->locexpr.data = block->data;
switch (attr->name)

View File

@@ -514,16 +514,6 @@ struct dwarf2_per_objfile
const struct comp_unit_head *cu_header,
unsigned int *bytes_read_ptr);
/* Resize the M_SYMTABS vector to the needed size (the number of partial
symtabs allocated by the per-bfd). */
void resize_symtabs ()
{
/* The symtabs vector should only grow, not shrink. */
gdb_assert (per_bfd->all_comp_units.size () >= m_symtabs.size ());
m_symtabs.resize (per_bfd->all_comp_units.size ());
}
/* Return true if the symtab corresponding to PER_CU has been set,
false otherwise. */
bool symtab_set_p (const dwarf2_per_cu_data *per_cu) const;

View File

@@ -453,9 +453,8 @@ exec_file_attach (const char *filename, int from_tty)
if (!current_program_space->exec_bfd ())
{
error (_("\"%ps\": could not open as an executable file: %s."),
styled_string (file_name_style.style (), scratch_pathname),
bfd_errmsg (bfd_get_error ()));
error (_("\"%s\": could not open as an executable file: %s."),
scratch_pathname, bfd_errmsg (bfd_get_error ()));
}
/* gdb_realpath_keepfile resolves symlinks on the local
@@ -475,8 +474,7 @@ exec_file_attach (const char *filename, int from_tty)
/* Make sure to close exec_bfd, or else "run" might try to use
it. */
current_program_space->exec_close ();
error (_("\"%ps\": not in executable format: %s"),
styled_string (file_name_style.style (), scratch_pathname),
error (_("\"%s\": not in executable format: %s"), scratch_pathname,
gdb_bfd_errmsg (bfd_get_error (), matching).c_str ());
}

View File

@@ -365,7 +365,7 @@ fbsd_nat_target::info_proc (const char *args, enum info_proc_what what)
printf_filtered ("Parent process: %d\n", kp.ki_ppid);
printf_filtered ("Process group: %d\n", kp.ki_pgid);
printf_filtered ("Session id: %d\n", kp.ki_sid);
printf_filtered ("TTY: %ju\n", (uintmax_t) kp.ki_tdev);
printf_filtered ("TTY: %s\n", pulongest (kp.ki_tdev));
printf_filtered ("TTY owner process group: %d\n", kp.ki_tpgid);
printf_filtered ("User IDs (real, effective, saved): %d %d %d\n",
kp.ki_ruid, kp.ki_uid, kp.ki_svuid);
@@ -383,34 +383,35 @@ fbsd_nat_target::info_proc (const char *args, enum info_proc_what what)
kp.ki_rusage.ru_majflt);
printf_filtered ("Major faults, children: %ld\n",
kp.ki_rusage_ch.ru_majflt);
printf_filtered ("utime: %jd.%06ld\n",
(intmax_t) kp.ki_rusage.ru_utime.tv_sec,
printf_filtered ("utime: %s.%06ld\n",
plongest (kp.ki_rusage.ru_utime.tv_sec),
kp.ki_rusage.ru_utime.tv_usec);
printf_filtered ("stime: %jd.%06ld\n",
(intmax_t) kp.ki_rusage.ru_stime.tv_sec,
printf_filtered ("stime: %s.%06ld\n",
plongest (kp.ki_rusage.ru_stime.tv_sec),
kp.ki_rusage.ru_stime.tv_usec);
printf_filtered ("utime, children: %jd.%06ld\n",
(intmax_t) kp.ki_rusage_ch.ru_utime.tv_sec,
printf_filtered ("utime, children: %s.%06ld\n",
plongest (kp.ki_rusage_ch.ru_utime.tv_sec),
kp.ki_rusage_ch.ru_utime.tv_usec);
printf_filtered ("stime, children: %jd.%06ld\n",
(intmax_t) kp.ki_rusage_ch.ru_stime.tv_sec,
printf_filtered ("stime, children: %s.%06ld\n",
plongest (kp.ki_rusage_ch.ru_stime.tv_sec),
kp.ki_rusage_ch.ru_stime.tv_usec);
printf_filtered ("'nice' value: %d\n", kp.ki_nice);
printf_filtered ("Start time: %jd.%06ld\n", kp.ki_start.tv_sec,
printf_filtered ("Start time: %s.%06ld\n",
plongest (kp.ki_start.tv_sec),
kp.ki_start.tv_usec);
pgtok = getpagesize () / 1024;
printf_filtered ("Virtual memory size: %ju kB\n",
(uintmax_t) kp.ki_size / 1024);
printf_filtered ("Data size: %ju kB\n",
(uintmax_t) kp.ki_dsize * pgtok);
printf_filtered ("Stack size: %ju kB\n",
(uintmax_t) kp.ki_ssize * pgtok);
printf_filtered ("Text size: %ju kB\n",
(uintmax_t) kp.ki_tsize * pgtok);
printf_filtered ("Resident set size: %ju kB\n",
(uintmax_t) kp.ki_rssize * pgtok);
printf_filtered ("Maximum RSS: %ju kB\n",
(uintmax_t) kp.ki_rusage.ru_maxrss);
printf_filtered ("Virtual memory size: %s kB\n",
pulongest (kp.ki_size / 1024));
printf_filtered ("Data size: %s kB\n",
pulongest (kp.ki_dsize * pgtok));
printf_filtered ("Stack size: %s kB\n",
pulongest (kp.ki_ssize * pgtok));
printf_filtered ("Text size: %s kB\n",
pulongest (kp.ki_tsize * pgtok));
printf_filtered ("Resident set size: %s kB\n",
pulongest (kp.ki_rssize * pgtok));
printf_filtered ("Maximum RSS: %s kB\n",
pulongest (kp.ki_rusage.ru_maxrss));
printf_filtered ("Pending Signals: ");
for (int i = 0; i < _SIG_WORDS; i++)
printf_filtered ("%08x ", kp.ki_siglist.__bits[i]);

View File

@@ -170,7 +170,8 @@ XMLTOC = \
s390x-tevx-linux64.xml \
s390x-vx-linux64.xml \
s390-gs-linux64.xml \
s390x-gs-linux64.xml
s390x-gs-linux64.xml \
z80.xml
TDESC_CFILES = $(patsubst %.xml,%.c,$(XMLTOC))
GDB = false

33
gdb/features/z80-cpu.xml Normal file
View File

@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<!-- Copyright (C) 2020 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. -->
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.z80.cpu">
<flags id="af_flags" size="2">
<field name="C" start="0" end="0"/>
<field name="N" start="1" end="1"/>
<field name="P/V" start="2" end="2"/>
<field name="F3" start="3" end="3"/>
<field name="H" start="4" end="4"/>
<field name="F5" start="5" end="5"/>
<field name="Z" start="6" end="6"/>
<field name="S" start="7" end="7"/>
</flags>
<reg name="af" bitsize="16" type="af_flags"/>
<reg name="bc" bitsize="16" type="uint16"/>
<reg name="de" bitsize="16" type="data_ptr"/>
<reg name="hl" bitsize="16" type="data_ptr"/>
<reg name="sp" bitsize="16" type="data_ptr" />
<reg name="pc" bitsize="32" type="code_ptr" />
<reg name="ix" bitsize="16" type="data_ptr"/>
<reg name="iy" bitsize="16" type="data_ptr"/>
<reg name="af'" bitsize="16" type="af_flags"/>
<reg name="bc'" bitsize="16" type="uint16"/>
<reg name="de'" bitsize="16" type="data_ptr"/>
<reg name="hl'" bitsize="16" type="data_ptr"/>
<reg name="ir" bitsize="16" type="uint16"/>
</feature>

44
gdb/features/z80.c Normal file
View File

@@ -0,0 +1,44 @@
/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
Original: z80.xml */
#include "defs.h"
#include "osabi.h"
#include "target-descriptions.h"
struct target_desc *tdesc_z80;
static void
initialize_tdesc_z80 (void)
{
target_desc_up result = allocate_target_description ();
set_tdesc_architecture (result.get (), bfd_scan_arch ("z80"));
struct tdesc_feature *feature;
feature = tdesc_create_feature (result.get (), "org.gnu.gdb.z80.cpu");
tdesc_type_with_fields *type_with_fields;
type_with_fields = tdesc_create_flags (feature, "af_flags", 2);
tdesc_add_flag (type_with_fields, 0, "C");
tdesc_add_flag (type_with_fields, 1, "N");
tdesc_add_flag (type_with_fields, 2, "P/V");
tdesc_add_flag (type_with_fields, 3, "F3");
tdesc_add_flag (type_with_fields, 4, "H");
tdesc_add_flag (type_with_fields, 5, "F5");
tdesc_add_flag (type_with_fields, 6, "Z");
tdesc_add_flag (type_with_fields, 7, "S");
tdesc_create_reg (feature, "af", 0, 1, NULL, 16, "af_flags");
tdesc_create_reg (feature, "bc", 1, 1, NULL, 16, "uint16");
tdesc_create_reg (feature, "de", 2, 1, NULL, 16, "data_ptr");
tdesc_create_reg (feature, "hl", 3, 1, NULL, 16, "data_ptr");
tdesc_create_reg (feature, "sp", 4, 1, NULL, 16, "data_ptr");
tdesc_create_reg (feature, "pc", 5, 1, NULL, 32, "code_ptr");
tdesc_create_reg (feature, "ix", 6, 1, NULL, 16, "data_ptr");
tdesc_create_reg (feature, "iy", 7, 1, NULL, 16, "data_ptr");
tdesc_create_reg (feature, "af'", 8, 1, NULL, 16, "af_flags");
tdesc_create_reg (feature, "bc'", 9, 1, NULL, 16, "uint16");
tdesc_create_reg (feature, "de'", 10, 1, NULL, 16, "data_ptr");
tdesc_create_reg (feature, "hl'", 11, 1, NULL, 16, "data_ptr");
tdesc_create_reg (feature, "ir", 12, 1, NULL, 16, "uint16");
tdesc_z80 = result.release ();
}

12
gdb/features/z80.xml Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!-- Copyright (C) 2020 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. -->
<!DOCTYPE target SYSTEM "gdb-target.dtd">
<target>
<architecture>z80</architecture>
<xi:include href="z80-cpu.xml"/>
</target>

View File

@@ -423,6 +423,15 @@ gdb_bfd_iovec_fileio_pread (struct bfd *abfd, void *stream, void *buf,
return pos;
}
/* Warn that it wasn't possible to close a bfd for file NAME, because
of REASON. */
static void
gdb_bfd_close_warning (const char *name, const char *reason)
{
warning (_("cannot close \"%s\": %s"), name, reason);
}
/* Wrapper for target_fileio_close suitable for passing as the
CLOSE_FUNC argument to gdb_bfd_openr_iovec. */
@@ -436,7 +445,16 @@ gdb_bfd_iovec_fileio_close (struct bfd *abfd, void *stream)
/* Ignore errors on close. These may happen with remote
targets if the connection has already been torn down. */
target_fileio_close (fd, &target_errno);
try
{
target_fileio_close (fd, &target_errno);
}
catch (const gdb_exception &ex)
{
/* Also avoid crossing exceptions over bfd. */
gdb_bfd_close_warning (bfd_get_filename (abfd),
ex.message->c_str ());
}
/* Zero means success. */
return 0;
@@ -626,8 +644,8 @@ gdb_bfd_close_or_warn (struct bfd *abfd)
ret = bfd_close (abfd);
if (!ret)
warning (_("cannot close \"%s\": %s"),
name, bfd_errmsg (bfd_get_error ()));
gdb_bfd_close_warning (name,
bfd_errmsg (bfd_get_error ()));
return ret;
}

View File

@@ -730,7 +730,8 @@ typedef std::string (gdbarch_memtag_to_string_ftype) (struct gdbarch *gdbarch, s
extern std::string gdbarch_memtag_to_string (struct gdbarch *gdbarch, struct value *tag);
extern void set_gdbarch_memtag_to_string (struct gdbarch *gdbarch, gdbarch_memtag_to_string_ftype *memtag_to_string);
/* Return true if ADDRESS contains a tag and false otherwise. */
/* Return true if ADDRESS contains a tag and false otherwise. ADDRESS
must be either a pointer or a reference type. */
typedef bool (gdbarch_tagged_address_p_ftype) (struct gdbarch *gdbarch, struct value *address);
extern bool gdbarch_tagged_address_p (struct gdbarch *gdbarch, struct value *address);

View File

@@ -608,7 +608,8 @@ v;int;significant_addr_bit;;;;;;0
# Return a string representation of the memory tag TAG.
m;std::string;memtag_to_string;struct value *tag;tag;;default_memtag_to_string;;0
# Return true if ADDRESS contains a tag and false otherwise.
# Return true if ADDRESS contains a tag and false otherwise. ADDRESS
# must be either a pointer or a reference type.
m;bool;tagged_address_p;struct value *address;address;;default_tagged_address_p;;0
# Return true if the tag from ADDRESS matches the memory tag for that

View File

@@ -6093,7 +6093,7 @@ gdbtypes_post_init (struct gdbarch *gdbarch)
builtin_type->builtin_string
= arch_type (gdbarch, TYPE_CODE_STRING, TARGET_CHAR_BIT, "string");
builtin_type->builtin_bool
= arch_type (gdbarch, TYPE_CODE_BOOL, TARGET_CHAR_BIT, "bool");
= arch_boolean_type (gdbarch, TARGET_CHAR_BIT, 1, "bool");
/* The following three are about decimal floating point types, which
are 32-bits, 64-bits and 128-bits respectively. */

View File

@@ -825,8 +825,8 @@ public:
int parser (struct parser_state *ps) const override
{
/* No parsing is done, just claim success. */
return 1;
error (_("expression parsing not implemented for language \"%s\""),
natural_name ());
}
/* See language.h. */

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env sh
#!/bin/sh
# Copyright (C) 2013-2021 Free Software Foundation, Inc.
#

View File

@@ -423,20 +423,19 @@ mi_cmd_break_condition (const char *command, char **argv, int argc)
}
}
/* There must be at least two more args: a bpnum and a condition
expression. */
if (oind + 1 >= argc)
error (_("-break-condition: Missing the <number> and/or <expr> "
"argument"));
/* There must be at least one more arg: a bpnum. */
if (oind >= argc)
error (_("-break-condition: Missing the <number> argument"));
int bpnum = atoi (argv[oind]);
/* The rest form the condition expr. */
std::string expr (argv[oind + 1]);
for (int i = oind + 2; i < argc; ++i)
std::string expr = "";
for (int i = oind + 1; i < argc; ++i)
{
expr += " ";
expr += argv[i];
if (i + 1 < argc)
expr += " ";
}
set_breakpoint_condition (bpnum, expr.c_str (), 0 /* from_tty */,

View File

@@ -383,6 +383,9 @@ mi_cmd_exec_interrupt (const char *command, char **argv, int argc)
{
struct inferior *inf = find_inferior_id (current_context->thread_group);
scoped_disable_commit_resumed disable_commit_resumed
("interrupting all threads of thread group");
iterate_over_threads (interrupt_thread_callback, &inf->pid);
}
else

View File

@@ -520,7 +520,7 @@ nbsd_get_siginfo_type (struct gdbarch *gdbarch)
return siginfo_type;
}
/* See nbsd-tdep.h. */
/* See netbsd-tdep.h. */
void
nbsd_info_proc_mappings_header (int addr_bit)
@@ -607,7 +607,7 @@ nbsd_get_syscall_number (struct gdbarch *gdbarch, thread_info *thread)
internal_error (__FILE__, __LINE__, _("nbsd_get_sycall_number called"));
}
/* See nbsd-tdep.h. */
/* See netbsd-tdep.h. */
void
nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)

View File

@@ -1266,19 +1266,26 @@ print_value (value *val, const value_print_options &opts)
static bool
should_validate_memtags (struct value *value)
{
if (target_supports_memory_tagging ()
&& gdbarch_tagged_address_p (target_gdbarch (), value))
{
gdb_assert (value != nullptr && value_type (value) != nullptr);
gdb_assert (value != nullptr && value_type (value) != nullptr);
enum type_code code = value_type (value)->code ();
if (!target_supports_memory_tagging ())
return false;
return (code == TYPE_CODE_PTR
|| code == TYPE_CODE_REF
|| code == TYPE_CODE_METHODPTR
|| code == TYPE_CODE_MEMBERPTR);
}
return false;
enum type_code code = value_type (value)->code ();
/* Skip non-address values. */
if (code != TYPE_CODE_PTR
&& !TYPE_IS_REFERENCE (value_type (value)))
return false;
/* OK, we have an address value. Check we have a complete value we
can extract. */
if (value_optimized_out (value)
|| !value_entirely_available (value))
return false;
/* We do. Check whether it includes any tags. */
return gdbarch_tagged_address_p (target_gdbarch (), value);
}
/* Helper for parsing arguments for print_command_1. */
@@ -1321,26 +1328,42 @@ print_command_1 (const char *args, int voidprint)
value_type (val)->code () != TYPE_CODE_VOID))
{
/* If memory tagging validation is on, check if the tag is valid. */
if (print_opts.memory_tag_violations && should_validate_memtags (val)
&& !gdbarch_memtag_matches_p (target_gdbarch (), val))
if (print_opts.memory_tag_violations)
{
/* Fetch the logical tag. */
struct value *tag
= gdbarch_get_memtag (target_gdbarch (), val,
memtag_type::logical);
std::string ltag
= gdbarch_memtag_to_string (target_gdbarch (), tag);
try
{
if (should_validate_memtags (val)
&& !gdbarch_memtag_matches_p (target_gdbarch (), val))
{
/* Fetch the logical tag. */
struct value *tag
= gdbarch_get_memtag (target_gdbarch (), val,
memtag_type::logical);
std::string ltag
= gdbarch_memtag_to_string (target_gdbarch (), tag);
/* Fetch the allocation tag. */
tag = gdbarch_get_memtag (target_gdbarch (), val,
memtag_type::allocation);
std::string atag
= gdbarch_memtag_to_string (target_gdbarch (), tag);
/* Fetch the allocation tag. */
tag = gdbarch_get_memtag (target_gdbarch (), val,
memtag_type::allocation);
std::string atag
= gdbarch_memtag_to_string (target_gdbarch (), tag);
printf_filtered (_("Logical tag (%s) does not match the "
"allocation tag (%s).\n"),
ltag.c_str (), atag.c_str ());
printf_filtered (_("Logical tag (%s) does not match the "
"allocation tag (%s).\n"),
ltag.c_str (), atag.c_str ());
}
}
catch (gdb_exception_error &ex)
{
if (ex.error == TARGET_CLOSE_ERROR)
throw;
fprintf_filtered (gdb_stderr,
_("Could not validate memory tag: %s\n"),
ex.message->c_str ());
}
}
print_value (val, print_opts);
}
}

View File

@@ -5624,6 +5624,15 @@ remote_unpush_target (remote_target *target)
pop_all_targets_at_and_above (process_stratum);
generic_mourn_inferior ();
}
/* Don't rely on target_close doing this when the target is popped
from the last remote inferior above, because something may be
holding a reference to the target higher up on the stack, meaning
target_close won't be called yet. We lost the connection to the
target, so clear these now, otherwise we may later throw
TARGET_CLOSE_ERROR while trying to tell the remote target to
close the file. */
fileio_handles_invalidate_target (target);
}
static void

View File

@@ -1120,7 +1120,7 @@ s390_linux_init_abi_any (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->s390_syscall_record = s390_linux_syscall_record;
linux_init_abi (info, gdbarch, 0);
linux_init_abi (info, gdbarch, 1);
/* Register handling. */
set_gdbarch_core_read_description (gdbarch, s390_core_read_description);

View File

@@ -7050,10 +7050,6 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_displaced_step_copy_insn (gdbarch,
s390_displaced_step_copy_insn);
set_gdbarch_displaced_step_fixup (gdbarch, s390_displaced_step_fixup);
set_gdbarch_displaced_step_prepare (gdbarch, linux_displaced_step_prepare);
set_gdbarch_displaced_step_finish (gdbarch, linux_displaced_step_finish);
set_gdbarch_displaced_step_restore_all_in_ptid
(gdbarch, linux_displaced_step_restore_all_in_ptid);
set_gdbarch_displaced_step_hw_singlestep (gdbarch, s390_displaced_step_hw_singlestep);
set_gdbarch_software_single_step (gdbarch, s390_software_single_step);
set_gdbarch_max_insn_length (gdbarch, S390_MAX_INSTR_SIZE);

View File

@@ -504,6 +504,10 @@ darwin_solib_read_all_image_info_addr (struct darwin_info *info)
static void
darwin_solib_create_inferior_hook (int from_tty)
{
/* Everything below only makes sense if we have a running inferior. */
if (!target_has_execution ())
return;
struct darwin_info *info = get_darwin_info ();
CORE_ADDR load_addr;

View File

@@ -245,7 +245,7 @@ extern int sparc_is_annulled_branch_insn (CORE_ADDR pc);
extern const struct sparc_gregmap sparc32_sol2_gregmap;
extern const struct sparc_fpregmap sparc32_sol2_fpregmap;
/* Functions and variables exported from sparcnbsd-tdep.c. */
/* Functions and variables exported from sparc-netbsd-tdep.c. */
/* Register offsets for NetBSD. */
extern const struct sparc_gregmap sparc32nbsd_gregmap;

View File

@@ -1,3 +1,7 @@
2021-07-17 Sergey Belyashov <Sergey.Belyashov@gmail.com>
* z80-stub.c: New file.
2020-04-28 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* ia64vms-stub.c: Fix typo in comment (thead -> thread).

1355
gdb/stubs/z80-stub.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4242,6 +4242,8 @@ info_sources_filter::matches (const char *fullname) const
case match_on::FULLNAME:
to_match = fullname;
break;
default:
gdb_assert_not_reached ("bad m_match_type");
}
if (m_c_regexp->exec (to_match, 0, NULL, 0) != 0)

View File

@@ -105,6 +105,7 @@
<syscall name="compat_43_osethostname" number="88"/>
<syscall name="compat_43_ogetdtablesize" number="89"/>
<syscall name="dup2" number="90"/>
<syscall name="getrandom" number="91"/>
<syscall name="fcntl" number="92"/>
<syscall name="compat_50_select" number="93"/>
<syscall name="fsync" number="95"/>
@@ -171,6 +172,9 @@
<syscall name="compat_09_osetdomainname" number="163"/>
<syscall name="compat_09_ouname" number="164"/>
<syscall name="sysarch" number="165"/>
<syscall name="__futex" number="166"/>
<syscall name="__futex_set_robust_list" number="167"/>
<syscall name="__futex_get_robust_list" number="168"/>
<syscall name="compat_10_osemsys" number="169"/>
<syscall name="compat_10_omsgsys" number="170"/>
<syscall name="compat_10_oshmsys" number="171"/>
@@ -310,7 +314,6 @@
<syscall name="_lwp_setname" number="323"/>
<syscall name="_lwp_getname" number="324"/>
<syscall name="_lwp_ctl" number="325"/>
<syscall name="_lwp_gettid" number="326"/>
<syscall name="compat_60_sa_register" number="330"/>
<syscall name="compat_60_sa_stacks" number="331"/>
<syscall name="compat_60_sa_enable" number="332"/>
@@ -458,4 +461,17 @@
<syscall name="__statvfs190" number="484"/>
<syscall name="__fstatvfs190" number="485"/>
<syscall name="__fhstatvfs190" number="486"/>
<syscall name="__acl_get_link" number="487"/>
<syscall name="__acl_set_link" number="488"/>
<syscall name="__acl_delete_link" number="489"/>
<syscall name="__acl_aclcheck_link" number="490"/>
<syscall name="__acl_get_file" number="491"/>
<syscall name="__acl_set_file" number="492"/>
<syscall name="__acl_get_fd" number="493"/>
<syscall name="__acl_set_fd" number="494"/>
<syscall name="__acl_delete_file" number="495"/>
<syscall name="__acl_delete_fd" number="496"/>
<syscall name="__acl_aclcheck_file" number="497"/>
<syscall name="__acl_aclcheck_fd" number="498"/>
<syscall name="lpathconf" number="499"/>
</syscalls_info>

View File

@@ -3121,13 +3121,9 @@ static std::vector<fileio_fh_t> fileio_fhandles;
list each time a new file is opened. */
static int lowest_closed_fd;
/* Invalidate the target associated with open handles that were open
on target TARG, since we're about to close (and maybe destroy) the
target. The handles remain open from the client's perspective, but
trying to do anything with them other than closing them will fail
with EIO. */
/* See target.h. */
static void
void
fileio_handles_invalidate_target (target_ops *targ)
{
for (fileio_fh_t &fh : fileio_fhandles)

View File

@@ -2230,6 +2230,12 @@ extern LONGEST target_fileio_read_alloc (struct inferior *inf,
extern gdb::unique_xmalloc_ptr<char> target_fileio_read_stralloc
(struct inferior *inf, const char *filename);
/* Invalidate the target associated with open handles that were open
on target TARG, since we're about to close (and maybe destroy) the
target. The handles remain open from the client's perspective, but
trying to do anything with them other than closing them will fail
with EIO. */
extern void fileio_handles_invalidate_target (target_ops *targ);
/* Tracepoint-related operations. */

View File

@@ -1,3 +1,171 @@
2021-09-10 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (gdb_compile_test): Handle unrecognized command line
option.
2021-09-09 Tom de Vries <tdevries@suse.de>
* gdb.base/coredump-filter-build-id.exp: Handle older eu-unstrip.
2021-09-09 Tom de Vries <tdevries@suse.de>
* gdb.mi/mi-sym-info.exp: Fix regexps. Add missing message argument
to mi_gdb_test. Factor out regexps for functions and variables.
2021-09-04 Tom de Vries <tdevries@suse.de>
PR testsuite/26950
* gdb/testsuite/gdb.arch/i386-avx.c (main): Remove call to have_avx.
(have_avx): Move ...
* gdb/testsuite/lib/gdb.exp (have_avx): ... here. New proc.
* gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp: Use have_avx.
* gdb/testsuite/gdb.arch/i386-avx.exp: Same.
2021-09-03 Tom de Vries <tdevries@suse.de>
* gdb.gdb/complaints.exp: Use untested if clear_complaints cannot
be found.
2021-09-03 Tom de Vries <tdevries@suse.de>
* lib/selftest-support.exp: Emit untested when not being able to set
breakpoint.
2021-09-01 Tom de Vries <tdevries@suse.de>
PR testsuite/28298
* gdb.dwarf2/fission-base.S: Use DWO instead of XSTR(DWO).
* gdb.dwarf2/fission-loclists-pie.S: Same.
* gdb.dwarf2/fission-loclists.S: Same.
* gdb.dwarf2/fission-reread.S: Same.
* gdb.dwarf2/fission-base.exp: Use additional_flags=-DDWO=\"$dwo\".
* gdb.dwarf2/fission-loclists-pie.exp: Same.
* gdb.dwarf2/fission-loclists.exp: Same.
* gdb.dwarf2/fission-reread.exp: Same.
2021-09-01 Tom de Vries <tdevries@suse.de>
* gdb.fortran/call-no-debug.exp: Avoid shared lib symbols for
find_mangled_name calls.
2021-08-30 Tom de Vries <tdevries@suse.de>
PR cli/28290
* gdb.base/batch-exit-status.exp: Add gdb '' and gdb '' '' tests.
2021-08-23 Tom de Vries <tdevries@suse.de>
PR gdb/26880
* gdb.base/non-executable.exp: New file.
2021-08-06 Simon Marchi <simon.marchi@polymtl.ca>
Tom de Vries <tdevries@suse.de>
PR symtab/28004
* gdb.dwarf2/dw2-zero-range-shlib.c: New test.
* gdb.dwarf2/dw2-zero-range.c: New test.
* gdb.dwarf2/dw2-zero-range.exp: New file.
2021-08-02 Tom Tromey <tromey@adacore.com>
PR varobj/28131
* gdb.python/py-mi-var-info-path-expression.exp: Add regression
test.
2021-07-26 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
PR gdb/28076
* gdb.mi/mi-break.exp: Add more tests to check clearing the
breakpoint condition.
2021-07-22 Tom de Vries <tdevries@suse.de>
* gdb.ada/formatted_ref.exp: Add xfail for PR gcc/101575.
* gdb.ada/iwide.exp: Same.
* gdb.ada/pkd_arr_elem.exp: Same.
2021-07-22 Tom de Vries <tdevries@suse.de>
* gdb.cp/step-and-next-inline.cc (tree_check, get_alias_set, main):
Tag closing brace with comment.
* gdb.cp/step-and-next-inline.h: Update to keep identical with
step-and-next-inline.cc.
* gdb.cp/step-and-next-inline.exp: Issue extra next when required.
2021-07-21 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (gcc_major_version): New proc.
* gdb.base/ptype-offsets.cc: Define static member static_member::Empty.
* gdb.cp/templates.exp: Define static member using -DGCC_BUG.
* gdb.cp/m-static.exp: Add
additional_flags=-fno-eliminate-unused-debug-types.
* gdb.cp/pr-574.exp: Same.
* gdb.cp/pr9167.exp: Same.
2021-07-21 Tom de Vries <tdevries@suse.de>
* gdb.ada/arrayptr.exp: Add KFAILs for PR20991 and PR28115.
* gdb.ada/exprs.exp: Add KFAILs for PR20991.
* gdb.ada/packed_array_assign.exp: Same.
2021-07-19 Tom Tromey <tromey@adacore.com>
PR gdb/28093
* gdb.base/langs.exp: Add tests.
2021-07-14 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (have_index): New proc.
* gdb.base/gold-gdb-index.exp: Use have_index.
2021-07-13 Pedro Alves <pedro@palves.net>
PR gdb/28080
* gdb.base/detach-sysroot-target.exp: New.
* gdb.base/detach-sysroot-target.c: New.
2021-07-13 Tom de Vries <tdevries@suse.de>
PR testsuite/27690
* gdb.threads/check-libthread-db.exp: Update patterns for glibc 2.33.
2021-07-13 Simon Marchi <simon.marchi@polymtl.ca>
* gdb.mi/interrupt-thread-group.c: New.
* gdb.mi/interrupt-thread-group.exp: New.
2021-07-12 Tom de Vries <tdevries@suse.de>
PR testsuite/28057
* gdb.btrace/tsx.exp: Add pattern for system with tsx disabled in
microcode.
2021-07-12 Tom de Vries <tdevries@suse.de>
* lib/mi-support.exp (mi_readnow): New proc.
* gdb.mi/mi-info-sources.exp: Use nosharedlibrary. Update patterns.
Skip tests for readnow. Use "maint expand-symtabs".
2021-07-08 Tom de Vries <tdevries@suse.de>
* gdb.guile/scm-breakpoint.exp: Make additional "ERROR: " prefix in
exception printing optional.
2021-07-06 Simon Marchi <simon.marchi@polymtl.ca>
* configure.ac: Restore.
* configure: Re-generate.
* aclocal.m4: Re-generate.
* Makefile.in (distclean): Add config.status.
(Makefile): Adjust paths.
(lib/pdtrace): Adjust paths.
(config.status): Add.
2021-07-06 Tom de Vries <tdevries@suse.de>
* gdb.fortran/ptype-on-functions.exp: Allow both $integer8 and
$integer4 for size of string length.
2021-07-01 Pedro Alves <pedro@palves.net>
PR mi/15729

View File

@@ -348,14 +348,17 @@ clean mostlyclean:
distclean maintainer-clean realclean: clean
-rm -f *~ core
-rm -f Makefile *-init.exp
-rm -f Makefile config.status *-init.exp
-rm -fr *.log summary detail *.plog *.sum *.psum site.*
Makefile : Makefile.in ../config.status $(host_makefile_frag)
cd .. && $(SHELL) ./config.status testsuite/Makefile
Makefile : Makefile.in config.status $(host_makefile_frag)
$(SHELL) config.status Makefile
lib/pdtrace: pdtrace.in ../config.status
cd .. && $(SHELL) ./config.status testsuite/lib/pdtrace
lib/pdtrace: pdtrace.in config.status
$(SHELL) config.status lib/pdtrace
config.status: configure
$(SHELL) config.status --recheck
TAGS: force
find $(srcdir) -name '*.exp' -print | \

37
gdb/testsuite/aclocal.m4 vendored Normal file
View File

@@ -0,0 +1,37 @@
m4_include(../../config/acx.m4)
m4_include(../../config/override.m4)
m4_include(../../config/enable.m4)
m4_include(../transform.m4)
# AM_CONDITIONAL -*- Autoconf -*-
# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 7
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
# -------------------------------------
# Define a conditional.
AC_DEFUN([AM_CONDITIONAL],
[AC_PREREQ(2.52)dnl
ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
AC_SUBST([$1_TRUE])
AC_SUBST([$1_FALSE])
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi
AC_CONFIG_COMMANDS_PRE(
[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
AC_MSG_ERROR([[conditional "$1" was never defined.
Usually this means the macro was only invoked conditionally.]])
fi])])

4806
gdb/testsuite/configure vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,99 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
# Copyright 2002-2021 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AC_INIT
AC_CONFIG_SRCDIR([gdb.base])
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
ACX_NONCANONICAL_TARGET
# Enable gdbtk.
AC_ARG_ENABLE(gdbtk,
[ --enable-gtk enable gdbtk graphical user interface (GUI)],,
[if test -d $srcdir/../gdbtk && test -d $srcdir/gdb.gdbtk; then
enable_gdbtk=yes
else
enable_gdbtk=no
fi])
# We unconditionally disable gdbtk tests on selected platforms.
case $host_os in
go32* | windows*)
enable_gdbtk=no ;;
esac
# Add gdbtk tests when appropriate.
if test $enable_gdbtk = yes; then
AC_CONFIG_SUBDIRS(gdb.gdbtk)
fi
GCC_ENABLE([libctf], [yes], [], [Handle .ctf type-info sections])
AC_SUBST(enable_libctf)
# Enable shared libraries.
AC_ARG_ENABLE(shared,
[ --enable-shared build shared libraries [deault=yes]],,
enable_shared=yes)
# If we have shared libraries, try to set RPATH_ENVVAR reasonably,
# such that we can find the shared libraries in the build tree.
if test $enable_shared = no; then
# The variable `RPATH_ENVVAR' itself is not likely to be used on any
# platform.
RPATH_ENVVAR=RPATH_ENVVAR
else
# The variable `LD_LIBRARY_PATH' is used on most platforms.
RPATH_ENVVAR=LD_LIBRARY_PATH
# The following exceptions are taken from Libtool 1.4.3.
case $host_os in
aix*)
if test $host_cpu != ia64; then
RPATH_ENVVAR=LIBPATH
fi ;;
darwin* | rhapsody*)
RPATH_ENVVAR=DYLD_LIBRARY_PATH ;;
esac
fi
AC_SUBST(RPATH_ENVVAR)
AC_CHECK_HEADERS(pthread.h)
AC_EXEEXT
if test "${build}" = "${host}" -a "${host}" = "${target}"; then
case "${host}" in
*gnu*)
EXTRA_RULES=read1
;;
esac
fi
AC_SUBST(EXTRA_RULES)
# Transform the name of some programs and generate the lib/pdtrace
# test tool.
AC_ARG_PROGRAM
GDB_AC_TRANSFORM(strip, STRIP_TRANSFORM_NAME)
GDB_AC_TRANSFORM(readelf, READELF_TRANSFORM_NAME)
GDB_AC_TRANSFORM(as, GAS_TRANSFORM_NAME)
GDB_AC_TRANSFORM(nm, NM_TRANSFORM_NAME)
AC_CONFIG_FILES([lib/pdtrace], [chmod +x lib/pdtrace])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

View File

@@ -19,6 +19,29 @@ if { [skip_ada_tests] } { return -1 }
standard_ada_testfile p
if [get_compiler_info] {
return -1
}
set old_gcc [expr [test_compiler_info {gcc-[0-7]-*}]]
proc gdb_test_with_xfail { cmd re re_xfail msg } {
global scenario old_gcc
set have_xfail [expr $old_gcc && [string equal "$scenario" "minimal"]]
gdb_test_multiple $cmd $msg {
-re -wrap $re {
pass $gdb_test_name
}
-re -wrap $re_xfail {
if { $have_xfail } {
# gcc/101633
setup_xfail *-*-*
}
fail $gdb_test_name
}
}
}
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
@@ -32,17 +55,23 @@ foreach_with_prefix scenario {all minimal} {
runto "p.adb:$bp_location"
set v1 "(tag => object, values => (2, 2, 2, 2, 2))"
set v1_xfail "(tag => object, values => ())"
set v2 "(tag => unused)"
gdb_test "print objects" \
[string_to_regexp " = ($v1, $v2)"] \
"print entire array"
gdb_test "print objects(1)" \
[string_to_regexp " = $v1"] \
set re [string_to_regexp " = ($v1, $v2)"]
set re_xfail [string_to_regexp " = ($v1_xfail, $v2)"]
gdb_test_with_xfail "print objects" $re $re_xfail "print entire array"
set re [string_to_regexp " = $v1"]
set re_xfail [string_to_regexp " = $v1_xfail"]
gdb_test_with_xfail "print objects(1)" $re $re_xfail \
"print first array element"
gdb_test "print objects(1 .. 1)" \
[string_to_regexp " = ($v1)"] \
set re [string_to_regexp " = ($v1)"]
set re_xfail [string_to_regexp " = ($v1_xfail)"]
gdb_test_with_xfail "print objects(1 .. 1)" $re $re_xfail \
"print first array slice"
gdb_test "print objects(2)" \
[string_to_regexp " = $v2"] \
"print second array element"

View File

@@ -49,10 +49,38 @@ foreach_with_prefix scenario {all minimal} {
gdb_test "ptype string_access" "= access array \\(<>\\) of character"
gdb_test "print pa_ptr.all" \
" = \\(10, 20, 30, 40, 50, 60, 62, 63, -23, 42\\)"
set kfail_int128support_re \
"That operation is not available on integers of more than 8 bytes\\."
set kfail_packed_array_range_re \
"cannot subscript or call something of type `foo__packed_array_ptr'"
gdb_test "print pa_ptr(3)" " = 30"
gdb_test_multiple "print pa_ptr.all" "" {
-re -wrap " = \\(10, 20, 30, 40, 50, 60, 62, 63, -23, 42\\)" {
pass $gdb_test_name
}
-re -wrap $kfail_int128support_re {
kfail gdb/20991 $gdb_test_name
}
}
gdb_test "print pa_ptr.all(3)" " = 30"
gdb_test_multiple "print pa_ptr(3)" "" {
-re -wrap " = 30" {
pass $gdb_test_name
}
-re -wrap $kfail_int128support_re {
kfail gdb/20991 $gdb_test_name
}
-re -wrap $kfail_packed_array_range_re {
kfail gdb/28115 $gdb_test_name
}
}
gdb_test_multiple "print pa_ptr.all(3)" "" {
-re -wrap " = 30" {
pass $gdb_test_name
}
-re -wrap $kfail_int128support_re {
kfail gdb/20991 $gdb_test_name
}
}
}

View File

@@ -19,6 +19,11 @@ if { [skip_ada_tests] } { return -1 }
standard_ada_testfile foo_ra24_010
if [get_compiler_info] {
return -1
}
set old_gcc [expr [test_compiler_info {gcc-[0-8]-*}]]
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
@@ -34,6 +39,20 @@ foreach_with_prefix scenario {all minimal} {
gdb_test "print good" \
"= \\(false <repeats 196 times>\\)" \
gdb_test "print bad" \
"= \\(false <repeats 196 times>\\)"
set have_xfail [expr $old_gcc && [string equal "$scenario" "minimal"]]
set re "= \\(false <repeats 196 times>\\)"
set re_xfail "= \\(0 => 0 <repeats 25 times>\\)"
gdb_test_multiple "print bad" "" {
-re -wrap $re {
pass $gdb_test_name
}
-re -wrap $re_xfail {
if { $have_xfail } {
# gcc/101643
setup_xfail *-*-*
}
fail $gdb_test_name
}
}
}

View File

@@ -28,14 +28,34 @@ clean_restart ${testfile}
set bp_location [gdb_get_line_number "START" ${testdir}/p.adb]
runto "p.adb:$bp_location"
gdb_test "print X ** Y = Z" \
"= true" \
"Long_Long_Integer ** Y"
set kfail_int128support_re \
"That operation is not available on integers of more than 8 bytes\\."
gdb_test "print long_float'min (long_float (X), 8.0)" \
"= 7.0" \
"long_float'min"
gdb_test_multiple "print X ** Y = Z" "Long_Long_Integer ** Y" {
-re -wrap "= true" {
pass $gdb_test_name
}
-re -wrap $kfail_int128support_re {
kfail gdb/20991 $gdb_test_name
}
}
gdb_test "print long_float'max (long_float (X), 8.0)" \
"= 8.0" \
"long_float'max"
set cmd "print long_float'min (long_float (X), 8.0)"
gdb_test_multiple $cmd "long_float'min" {
-re -wrap "= 7.0" {
pass $gdb_test_name
}
-re -wrap $kfail_int128support_re {
kfail gdb/20991 $gdb_test_name
}
}
set cmd "print long_float'max (long_float (X), 8.0)"
gdb_test_multiple $cmd "long_float'max" {
-re -wrap "= 8.0" {
pass $gdb_test_name
}
-re -wrap $kfail_int128support_re {
kfail gdb/20991 $gdb_test_name
}
}

View File

@@ -90,7 +90,30 @@ proc test_p_op1_equals_op2 {op1 op2} {
clean_restart ${testfile}
runto defs.adb:[gdb_get_line_number "marker here" ${testdir}/defs.adb ]
set bp_location \
defs.adb:[gdb_get_line_number "marker here" ${testdir}/defs.adb]
# Workaround gcc PR101575.
#runto $bp_location
gdb_breakpoint "$bp_location"
gdb_run_cmd
set re "Breakpoint $decimal, defs.f1 \\(.*\\) at .*:$decimal.*"
set re_xfail "Breakpoint $decimal, defs__struct1IP \\(\\) at .*:$decimal.*"
set ok 1
gdb_test_multiple "" "Runto to $bp_location" {
-re -wrap $re {
if { $ok } {
pass $gdb_test_name
} else {
xfail $gdb_test_name
}
}
-re -wrap $re_xfail {
set ok 0
send_gdb "continue\n"
exp_continue
}
}
set s1_address [get_address "s1"]

View File

@@ -25,8 +25,29 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional
clean_restart ${testfile}
set bp_location [gdb_get_line_number "BREAK" ${testdir}/p.adb]
runto "p.adb:$bp_location"
set bp_location p.adb:[gdb_get_line_number "BREAK" ${testdir}/p.adb]
# Workaround gcc PR101575.
#runto "$bp_location"
gdb_breakpoint "$bp_location"
gdb_run_cmd
set re "Breakpoint $decimal, p \\(\\) at .*:$decimal.*"
set re_xfail "Breakpoint $decimal, p__P5b.0 \\(\\) at .*:$decimal.*"
set ok 1
gdb_test_multiple "" "Runto to $bp_location" {
-re -wrap $re {
if { $ok } {
pass $gdb_test_name
} else {
xfail $gdb_test_name
}
}
-re -wrap $re_xfail {
set ok 0
send_gdb "continue\n"
exp_continue
}
}
gdb_test "print My_Drawable" \
"= \\(center => \\(x => 1, y => 2\\), radius => 3\\)"

View File

@@ -27,15 +27,72 @@ clean_restart ${testfile}
runto "aggregates.run_test"
gdb_test \
"print pra := ((packed_array_assign_x => 2, packed_array_assign_y => 0, packed_array_assign_w => 17), pr, (packed_array_assign_x => 7, packed_array_assign_y => 1, packed_array_assign_w => 23))" \
" = \\(\\(packed_array_assign_w => 17, packed_array_assign_x => 2, packed_array_assign_y => 0\\), \\(packed_array_assign_w => 104, packed_array_assign_x => 2, packed_array_assign_y => 3\\), \\(packed_array_assign_w => 23, packed_array_assign_x => 7, packed_array_assign_y => 1\\)\\)" \
"value of pra"
set kfail_int128support_re \
"That operation is not available on integers of more than 8 bytes\\."
gdb_test "print pra(1) := pr" \
" = \\(packed_array_assign_w => 104, packed_array_assign_x => 2, packed_array_assign_y => 3\\)"
gdb_test "print pra(1)" \
" = \\(packed_array_assign_w => 104, packed_array_assign_x => 2, packed_array_assign_y => 3\\)"
set cmd \
[list \
"print pra := " \
"((packed_array_assign_x => 2," \
"packed_array_assign_y => 0," \
"packed_array_assign_w => 17)," \
"pr," \
"(packed_array_assign_x => 7," \
"packed_array_assign_y => 1," \
"packed_array_assign_w => 23))"]
set cmd [join $cmd]
set re \
[list \
" = \\(\\(packed_array_assign_w => 17," \
"packed_array_assign_x => 2," \
"packed_array_assign_y => 0\\)," \
"\\(packed_array_assign_w => 104," \
"packed_array_assign_x => 2," \
"packed_array_assign_y => 3\\)," \
"\\(packed_array_assign_w => 23," \
"packed_array_assign_x => 7," \
"packed_array_assign_y => 1\\)\\)"]
set re [join $re]
gdb_test_multiple $cmd "value of pra" {
-re -wrap $re {
pass $gdb_test_name
}
-re -wrap $kfail_int128support_re {
kfail gdb/20991 $gdb_test_name
}
}
set cmd "print pra(1) := pr"
set re \
[list \
" = \\(packed_array_assign_w => 104," \
"packed_array_assign_x => 2," \
"packed_array_assign_y => 3\\)"]
set re [join $re]
gdb_test_multiple $cmd "" {
-re -wrap $re {
pass $gdb_test_name
}
-re -wrap $kfail_int128support_re {
kfail gdb/20991 $gdb_test_name
}
}
set cmd "print pra(1)"
set re \
[list \
" = \\(packed_array_assign_w => 104," \
"packed_array_assign_x => 2," \
"packed_array_assign_y => 3\\)"]
set re [join $re]
gdb_test_multiple $cmd "" {
-re -wrap $re {
pass $gdb_test_name
}
-re -wrap $kfail_int128support_re {
kfail gdb/20991 $gdb_test_name
}
}
gdb_test "print npr := (q000 => 3, r000 => (packed_array_assign_x => 6, packed_array_assign_y => 1, packed_array_assign_w => 117))" \
" = \\(q000 => 3, r000 => \\(packed_array_assign_w => 117, packed_array_assign_x => 6, packed_array_assign_y => 1\\)\\)" \

View File

@@ -25,8 +25,30 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
clean_restart ${testfile}
set bp_location [gdb_get_line_number "START" ${testdir}/failure.adb]
runto "failure.adb:$bp_location"
set bp_location \
failure.adb:[gdb_get_line_number "START" ${testdir}/failure.adb]
# Workaround gcc PR101575.
#runto "$bp_location"
gdb_breakpoint "$bp_location"
gdb_run_cmd
set re "Breakpoint $decimal, failure \\(\\) at .*:$decimal.*"
set re_xfail "Breakpoint $decimal, failure__bounded_funny_stringIP.0 \\(\\) at .*:$decimal.*"
set ok 1
gdb_test_multiple "" "Runto to $bp_location" {
-re -wrap $re {
if { $ok } {
pass $gdb_test_name
} else {
xfail $gdb_test_name
}
}
-re -wrap $re_xfail {
set ok 0
send_gdb "continue\n"
exp_continue
}
}
# Print Test. The order of the components depends on which version of
# the compiler being used, as newer version can re-order the order

View File

@@ -23,6 +23,11 @@ if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
return
}
if { ![have_avx] } {
verbose "Skipping x86_64 displaced stepping tests."
return
}
standard_testfile .S
set options [list debug \

View File

@@ -48,81 +48,64 @@ v8sf_t data[] =
};
int
have_avx (void)
{
unsigned int eax, ebx, ecx, edx;
if (!x86_cpuid (1, &eax, &ebx, &ecx, &edx))
return 0;
if ((ecx & (bit_AVX | bit_OSXSAVE)) == (bit_AVX | bit_OSXSAVE))
return 1;
else
return 0;
}
int
main (int argc, char **argv)
{
if (have_avx ())
{
asm ("vmovaps 0(%0), %%ymm0\n\t"
"vmovaps 32(%0), %%ymm1\n\t"
"vmovaps 64(%0), %%ymm2\n\t"
"vmovaps 96(%0), %%ymm3\n\t"
"vmovaps 128(%0), %%ymm4\n\t"
"vmovaps 160(%0), %%ymm5\n\t"
"vmovaps 192(%0), %%ymm6\n\t"
"vmovaps 224(%0), %%ymm7\n\t"
: /* no output operands */
: "r" (data)
: "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7");
asm ("vmovaps 0(%0), %%ymm0\n\t"
"vmovaps 32(%0), %%ymm1\n\t"
"vmovaps 64(%0), %%ymm2\n\t"
"vmovaps 96(%0), %%ymm3\n\t"
"vmovaps 128(%0), %%ymm4\n\t"
"vmovaps 160(%0), %%ymm5\n\t"
"vmovaps 192(%0), %%ymm6\n\t"
"vmovaps 224(%0), %%ymm7\n\t"
: /* no output operands */
: "r" (data)
: "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7");
#ifdef __x86_64__
asm ("vmovaps 256(%0), %%ymm8\n\t"
"vmovaps 288(%0), %%ymm9\n\t"
"vmovaps 320(%0), %%ymm10\n\t"
"vmovaps 352(%0), %%ymm11\n\t"
"vmovaps 384(%0), %%ymm12\n\t"
"vmovaps 416(%0), %%ymm13\n\t"
"vmovaps 448(%0), %%ymm14\n\t"
"vmovaps 480(%0), %%ymm15\n\t"
: /* no output operands */
: "r" (data)
: "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15");
asm ("vmovaps 256(%0), %%ymm8\n\t"
"vmovaps 288(%0), %%ymm9\n\t"
"vmovaps 320(%0), %%ymm10\n\t"
"vmovaps 352(%0), %%ymm11\n\t"
"vmovaps 384(%0), %%ymm12\n\t"
"vmovaps 416(%0), %%ymm13\n\t"
"vmovaps 448(%0), %%ymm14\n\t"
"vmovaps 480(%0), %%ymm15\n\t"
: /* no output operands */
: "r" (data)
: "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15");
#endif
asm ("nop"); /* first breakpoint here */
asm ("nop"); /* first breakpoint here */
asm (
"vmovaps %%ymm0, 0(%0)\n\t"
"vmovaps %%ymm1, 32(%0)\n\t"
"vmovaps %%ymm2, 64(%0)\n\t"
"vmovaps %%ymm3, 96(%0)\n\t"
"vmovaps %%ymm4, 128(%0)\n\t"
"vmovaps %%ymm5, 160(%0)\n\t"
"vmovaps %%ymm6, 192(%0)\n\t"
"vmovaps %%ymm7, 224(%0)\n\t"
: /* no output operands */
: "r" (data)
: "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7");
asm (
"vmovaps %%ymm0, 0(%0)\n\t"
"vmovaps %%ymm1, 32(%0)\n\t"
"vmovaps %%ymm2, 64(%0)\n\t"
"vmovaps %%ymm3, 96(%0)\n\t"
"vmovaps %%ymm4, 128(%0)\n\t"
"vmovaps %%ymm5, 160(%0)\n\t"
"vmovaps %%ymm6, 192(%0)\n\t"
"vmovaps %%ymm7, 224(%0)\n\t"
: /* no output operands */
: "r" (data)
: "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7");
#ifdef __x86_64__
asm (
"vmovaps %%ymm8, 256(%0)\n\t"
"vmovaps %%ymm9, 288(%0)\n\t"
"vmovaps %%ymm10, 320(%0)\n\t"
"vmovaps %%ymm11, 352(%0)\n\t"
"vmovaps %%ymm12, 384(%0)\n\t"
"vmovaps %%ymm13, 416(%0)\n\t"
"vmovaps %%ymm14, 448(%0)\n\t"
"vmovaps %%ymm15, 480(%0)\n\t"
: /* no output operands */
: "r" (data)
: "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15");
asm (
"vmovaps %%ymm8, 256(%0)\n\t"
"vmovaps %%ymm9, 288(%0)\n\t"
"vmovaps %%ymm10, 320(%0)\n\t"
"vmovaps %%ymm11, 352(%0)\n\t"
"vmovaps %%ymm12, 384(%0)\n\t"
"vmovaps %%ymm13, 416(%0)\n\t"
"vmovaps %%ymm14, 448(%0)\n\t"
"vmovaps %%ymm15, 480(%0)\n\t"
: /* no output operands */
: "r" (data)
: "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15");
#endif
puts ("Bye!"); /* second breakpoint here */
}
puts ("Bye!"); /* second breakpoint here */
return 0;
}

View File

@@ -24,6 +24,11 @@ if { ![istarget i?86-*-*] && ![istarget x86_64-*-* ] } {
return
}
if { ![have_avx] } {
verbose "Skipping x86 AVX tests."
return
}
standard_testfile .c
if [get_compiler_info] {
@@ -47,23 +52,6 @@ if ![runto_main] then {
return 0
}
send_gdb "print have_avx ()\r"
gdb_expect {
-re ".. = 1\r\n$gdb_prompt " {
pass "check whether processor supports AVX"
}
-re ".. = 0\r\n$gdb_prompt " {
verbose "processor does not support AVX; skipping AVX tests"
return
}
-re ".*$gdb_prompt $" {
fail "check whether processor supports AVX"
}
timeout {
fail "check whether processor supports AVX (timeout)"
}
}
gdb_test "break [gdb_get_line_number "first breakpoint here"]" \
"Breakpoint .* at .*i386-avx.c.*" \
"set first breakpoint in main"

View File

@@ -76,3 +76,7 @@ test_exit_status 1 "-batch -x $good_commands -x $bad_commands" \
"-batch -x good-commands -x bad-commands"
test_exit_status 1 "-batch -x $good_commands -ex \"set not-a-thing 4\"" \
"-batch -x good-commands -ex \"set not-a-thing 4\""
set no_such_re ": No such file or directory\\."
test_exit_status 1 "-batch \"\"" $no_such_re
test_exit_status 1 "-batch \"\" \"\"" [multi_line $no_such_re $no_such_re]

View File

@@ -58,7 +58,8 @@ if { [catch "exec [gdb_find_eu-unstrip] -n --core $corefilename" output] == 0 }
verbose -log "First line of eu-unstrip: $line"
if { [regexp "^${hex}\\+${hex} \[a-f0-9\]+@${hex}.*[string_to_regexp $binfile]$" $line] } {
set binfile_re (?:[string_to_regexp $binfile]|\\\[(?:exe|pie)\\\])
if { [regexp "^${hex}\\+${hex} \[a-f0-9\]+@${hex}.*$binfile_re$" $line] } {
pass "$test"
} else {
fail "$test"

View File

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

View File

@@ -0,0 +1,59 @@
# Copyright 2021 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. */
# Test running a program from the GDB prompt and then detaching it,
# with "set sysroot target:". Regression test for PR gdb/28080.
#
# It is assumed that it is only safe to tweak the sysroot on the
# current board if it is currently either empty or already "target:".
# If set to anything else, we skip the test.
standard_testfile
if {[prepare_for_testing "failed to prepare" ${binfile} ${srcfile}]} {
return
}
gdb_test_multiple "show sysroot" "" {
-wrap -re "The current system root is \"\"\\." {
pass $gdb_test_name
# Explicitly set target: sysroot.
gdb_test_no_output "set sysroot target:"
}
-wrap -re "The current system root is \"target:\"\\." {
pass $gdb_test_name
# Nothing else to do.
}
-re "$gdb_prompt $" {
pass $gdb_test_name
# If testing with any other sysroot, we probably should not
# mess with it.
unsupported "sysroot is set"
return
}
}
if ![runto_main] {
fail "couldn't run to main"
return
}
# With PR gdb/28080, this would crash GDB when testing with "target
# remote".
set escapedbinfile [string_to_regexp ${binfile}]
gdb_test "detach" "Detaching from program: .*$escapedbinfile, .*"

View File

@@ -28,7 +28,7 @@ if {[prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" \
return -1
}
if { [readnow] } {
if { [have_index $binfile] != "gdb_index" } {
return -1
}

View File

@@ -111,6 +111,12 @@ if [runto csub] then {
"set lang to minimal"
gdb_test "print x" " = 5000" "print parameter value"
# Ensure this at least does not crash.
gdb_test_no_output "set language unknown"
gdb_test "print x" \
"expression parsing not implemented for language .Unknown." \
"expression parsing does not crash for unknown"
}
set timeout $oldtimeout

View File

@@ -0,0 +1,32 @@
# Copyright 2021 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Check that loading an existing but non-executable file
# results in the correct error message.
set binfile "$srcdir/$subdir/$gdb_test_file_name.exp"
clean_restart
set re \
[list \
"\"[string_to_regexp $binfile]\"" \
"not in executable format" \
"file format not recognized"]
set re [join $re ": "]
# Using gdb_load will generate a dejagnu ERROR, so use
# plain file command instead.
gdb_test "file $binfile" $re "error message"

View File

@@ -185,6 +185,9 @@ struct static_member
int abc;
};
/* Work around PR gcc/101452. */
static_member static_member::Empty;
struct empty_member
{
struct { } empty;

View File

@@ -59,6 +59,11 @@ set abort_2 [multi_line \
"\[0-9\]*\t 0x\[0-9a-f\]+ <test\\+\[0-9\]+>:\tmov\[^\\\r\\\n\]*" \
"\[0-9\]*\t 0x\[0-9a-f\]+ <test\\+\[0-9\]+>:\tret\[^\\\r\\\n\]*" \
]
set abort_3 \
[multi_line \
"$decimal\t $hex <main\\+$decimal>:\t\[^\\\r\\\n\]*" \
"$decimal\t $hex <test\\+$decimal>:\tmov\[^\\\r\\\n\]*" \
"$decimal\t $hex <test\\+$decimal>:\tret\[^\\\r\\\n\]*"]
set test "speculation indication"
gdb_test_multiple "record instruction-history" $test {
@@ -68,6 +73,9 @@ gdb_test_multiple "record instruction-history" $test {
-re "$abort_2.*$gdb_prompt $" {
pass $test
}
-re -wrap "$abort_3.*" {
pass $gdb_test_name
}
-re "$begin_to_end.*$gdb_prompt $" {
pass $test
}

View File

@@ -31,8 +31,14 @@ if [get_compiler_info] {
return -1
}
set flags [list debug c++]
if { [test_compiler_info gcc-*] && [gcc_major_version] >= 10 } {
# Work around PR gcc/101452.
lappend flags additional_flags=-fno-eliminate-unused-debug-types
}
if {[prepare_for_testing "failed to prepare" $testfile \
[list $srcfile $srcfile2] {debug c++}]} {
[list $srcfile $srcfile2] $flags]} {
return -1
}

View File

@@ -32,7 +32,13 @@ if [get_compiler_info "c++"] {
return -1
}
if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
set flags [list debug c++]
if { [test_compiler_info gcc-*] && [gcc_major_version] >= 10 } {
# Work around PR gcc/101452.
lappend flags additional_flags=-fno-eliminate-unused-debug-types
}
if {[prepare_for_testing "failed to prepare" $testfile $srcfile $flags]} {
return -1
}

View File

@@ -15,7 +15,13 @@
standard_testfile .cc
if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
set flags [list debug c++]
if { [test_compiler_info gcc-*] && [gcc_major_version] >= 10 } {
# Work around PR gcc/101452.
lappend flags additional_flags=-fno-eliminate-unused-debug-types
}
if {[prepare_for_testing "failed to prepare" $testfile $srcfile $flags]} {
return -1
}

View File

@@ -41,7 +41,7 @@ tree_check (tree *t, int i)
abort();
tree *x = t;
return x;
}
} // tree-check
#endif /* USE_NEXT_INLINE_H */
@@ -54,7 +54,7 @@ get_alias_set (tree *t)
&& TREE_TYPE (t).z != 3)
return 0;
return 1;
}
} // get_alias_set
tree xx;
@@ -63,4 +63,4 @@ main()
{
get_alias_set (&xx);
return 0;
}
} // main

View File

@@ -67,29 +67,100 @@ proc do_test { use_header } {
gdb_test "step" ".*" "step into get_alias_set"
gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
"not in inline 1"
# It's possible that this first failure (when not using a header
# file) is GCC's fault, though the remaining failures would best
# be fixed by adding location views support (though it could be
# that some easier heuristic could be figured out). Still, it is
# not certain that the first failure wouldn't also be fixed by
# having location view support, so for now it is tagged as such.
if {[test_compiler_info gcc*] && !$use_header} {
setup_kfail "*-*-*" symtab/25507
set have_kfail [expr [test_compiler_info gcc*] && !$use_header]
set ok 1
gdb_test_multiple "next" "next step 1" {
-re -wrap "if \\(t->x != i\\)" {
set ok 0
send_gdb "next\n"
exp_continue
}
-re -wrap ".*TREE_TYPE.* != 1" {
if { $ok } {
pass $gdb_test_name
} else {
if { $have_kfail } {
setup_kfail "*-*-*" symtab/25507
}
fail $gdb_test_name
}
}
}
gdb_test "next" ".*TREE_TYPE.*" "next step 1"
gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
"not in inline 2"
gdb_test "next" ".*TREE_TYPE.*" "next step 2"
set ok 1
gdb_test_multiple "next" "next step 2" {
-re -wrap "return x;" {
set ok 0
send_gdb "next\n"
exp_continue
}
-re -wrap ".*TREE_TYPE.* != 2" {
if { $ok } {
pass $gdb_test_name
} else {
if { $have_kfail } {
setup_kfail "*-*-*" symtab/25507
}
fail $gdb_test_name
}
}
}
gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
"not in inline 3"
if {[test_compiler_info gcc*] && !$use_header} {
setup_kfail "*-*-*" symtab/25507
set ok 1
gdb_test_multiple "next" "next step 3" {
-re -wrap "return x;" {
set ok 0
send_gdb "next\n"
exp_continue
}
-re -wrap ".*TREE_TYPE.* != 3\\)" {
if { $ok } {
pass $gdb_test_name
} else {
if { $have_kfail } {
setup_kfail "*-*-*" symtab/25507
}
fail $gdb_test_name
}
}
}
gdb_test "next" ".*TREE_TYPE.*" "next step 3"
gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
"not in inline 4"
if {!$use_header} { setup_kfail "*-*-*" symtab/25507 }
gdb_test "next" "return 0.*" "next step 4"
set ok 1
gdb_test_multiple "next" "next step 4" {
-re -wrap "(if \\(t != NULL|\} // get_alias_set)" {
send_gdb "next\n"
exp_continue
}
-re -wrap "return x;" {
set ok 0
send_gdb "next\n"
exp_continue
}
-re -wrap "return 0.*" {
if { $ok } {
pass $gdb_test_name
} else {
if { $have_kfail } {
setup_kfail "*-*-*" symtab/25507
}
fail $gdb_test_name
}
}
}
gdb_test "bt" \
"\\s*\\#0\\s+(main|get_alias_set)\[^\r\]*${srcfile}:.*" \
"not in inline 5"

View File

@@ -35,4 +35,4 @@ tree_check (tree *t, int i)
abort();
tree *x = t;
return x;
}
} // tree_check

View File

@@ -27,7 +27,13 @@ if [get_compiler_info "c++"] {
return -1
}
if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
set flags [list debug c++]
if { [test_compiler_info gcc-*] && [gcc_major_version] >= 10 } {
# Work around PR gcc/101452.
lappend flags additional_flags=-DGCC_BUG
}
if {[prepare_for_testing "failed to prepare" $testfile $srcfile $flags]} {
return -1
}

View File

@@ -0,0 +1,21 @@
/*
Copyright 2021 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
void
foo (void)
{
asm ("foo_label: .globl foo_label");
}

View File

@@ -0,0 +1,24 @@
/*
Copyright 2021 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
extern void foo (void);
int
main (void)
{
asm ("main_label: .globl main_label");
foo ();
}

View File

@@ -0,0 +1,185 @@
# Copyright 2021 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Check that the ".debug_ranges entry has start address of zero" complaint
# is triggered for a loaded shared lib.
load_lib dwarf.exp
# This test can only be run on targets which support DWARF-2 and use gas.
if {![dwarf2_support]} {
verbose "Skipping $gdb_test_file_name."
return 0
}
if {[skip_shlib_tests]} {
return 0
}
standard_testfile .c -shlib.c -dw.S
# Test with both a .debug_ranges section (DWARF 4) and a .debug_rnglists
# section (DWARF 5).
foreach_with_prefix ranges_sect {ranges rnglists} {
set asm_file [standard_output_file ${ranges_sect}-$srcfile3]
if { $ranges_sect == "ranges" } {
Dwarf::assemble $asm_file {
global srcdir subdir srcfile2
declare_labels ranges_label
cu {} {
compile_unit {
{language @DW_LANG_C}
{name $srcfile2}
{ranges ${ranges_label} DW_FORM_sec_offset}
} {
subprogram {
{external 1 flag}
{name foo}
}
}
}
ranges {is_64 [is_64_target]} {
ranges_label: sequence {
base 0
range 0 1
}
}
}
} elseif { $ranges_sect == "rnglists" } {
Dwarf::assemble $asm_file {
global srcdir subdir srcfile2
declare_labels rnglists_label
cu {
version 5
} {
compile_unit {
{language @DW_LANG_C}
{name $srcfile2}
{ranges ${rnglists_label} DW_FORM_sec_offset}
} {
subprogram {
{external 1 flag}
{name foo}
}
}
}
rnglists {
table {
rnglists_label: list_ {
start_end 0 1
}
}
}
}
} else {
error "invalid ranges section kind"
}
set lib1 [standard_output_file shr1.sl]
set lib_opts "nodebug"
set sources [list ${srcdir}/${subdir}/$srcfile2 $asm_file]
if { [gdb_compile_shlib $sources ${lib1} $lib_opts] != "" } {
untested "failed to compile"
return -1
}
set exec_opts [list debug shlib=${lib1}]
set sources ${srcdir}/${subdir}/${srcfile}
if { [gdb_compile $sources ${binfile} executable \
$exec_opts] != ""} {
untested "failed to compile"
return -1
}
clean_restart $binfile
set readnow_p [readnow]
# Don't load the symbols for $lib1 during runto_main.
# Instead, we do this afterwards using "sharedlibrary $lib1".
gdb_test_no_output "set auto-solib-add off"
if { ![runto_main] } {
fail "cannot run to main."
return -1
}
set complaint_re ".debug_${ranges_sect} entry has start address of zero"
set re \
"During symbol reading: $complaint_re \\\[in module \[^\r\n\]*\\\]"
# Test for presence of complaint, with lib1 relocated.
with_complaints 1 {
set test "Zero address complaint - relocated - psymtab"
set have_complaint 0
gdb_test_multiple "sharedlibrary $lib1" $test {
-re -wrap $re {
set have_complaint 1
}
-re -wrap "" {
}
}
if { $have_complaint } {
pass $test
} else {
set index [have_index $lib1]
if { $index == "gdb_index" } {
kfail symtab/28159 $test
} else {
fail $test
}
}
}
if { ! $readnow_p } {
with_complaints 1 {
gdb_test "maint expand-symtabs $srcfile2" $re \
"Zero address complaint - relocated - symtab"
}
}
clean_restart
# Test for presence of complaint, with lib1 unrelocated.
with_complaints 1 {
gdb_load $lib1
set test "Zero address complaint - unrelocated - psymtab"
set have_complaint [regexp $re.* $gdb_file_cmd_msg]
if { $have_complaint } {
pass $test
} else {
set index [have_index $lib1]
if { $index == "gdb_index" } {
kfail symtab/28159 $test
} else {
fail $test
}
}
}
if { ! $readnow_p } {
with_complaints 1 {
gdb_test "maint expand-symtabs $srcfile2" $re \
"Zero address complaint - unrelocated - symtab"
}
}
}

View File

@@ -20,9 +20,6 @@
and then massaging the output.
*/
#define XSTR(s) STR(s)
#define STR(s) #s
.file "fission-base.c"
.text
@@ -146,7 +143,7 @@ main:
.8byte .Letext0-.Ltext0 # DW_AT_high_pc
.4byte .Ldebug_line0 # DW_AT_stmt_list
.ascii "/tmp/src/gdb/testsuite\0" # DW_AT_comp_dir
.asciz XSTR(DWO) # DW_AT_GNU_dwo_name
.asciz DWO # DW_AT_GNU_dwo_name
.4byte .Ldebug_pubnames0 # DW_AT_GNU_pubnames
.4byte .Ldebug_pubtypes0 # DW_AT_GNU_pubtypes
.4byte .Ldebug_addr0_begin # DW_AT_GNU_addr_base

View File

@@ -36,7 +36,7 @@ set obj [standard_output_file "${testfile}.o"]
set dwo [standard_output_file "${testfile}.dwo"]
if [build_executable_and_dwo_files "$testfile.exp" "${binfile}" {nodebug} \
[list $srcfile \
[list nodebug split-dwo additional_flags=-DDWO=$dwo] \
[list nodebug split-dwo additional_flags=-DDWO=\"$dwo\"] \
$obj]] {
return -1
}

View File

@@ -33,8 +33,6 @@
return init (&argc);
}
*/
#define XSTR(s) STR(s)
#define STR(s) #s
.file "fission-loclists-pie.c"
.text
@@ -463,7 +461,7 @@ main:
.LASF1:
.string "/tmp/19999/obj64/gdb/testsuite"
.LASF0:
.string XSTR(DWO)
.string DWO
.section .debug_str_offsets.dwo,"e",@progbits
.long 0 # indexed string 0x0: argv
.long 0x5 # indexed string 0x1: argc

View File

@@ -41,7 +41,7 @@ set obj [standard_output_file "${testfile}.o"]
set dwo [standard_output_file "${testfile}.dwo"]
if [build_executable_and_dwo_files "$testfile.exp" "${binfile}" \
{nodebug ldflags=-pie} \
[list $srcfile [list nodebug split-dwo additional_flags=-DDWO=$dwo] \
[list $srcfile [list nodebug split-dwo additional_flags=-DDWO=\"$dwo\"] \
$obj]] {
return -1
}

View File

@@ -33,9 +33,6 @@
}
*/
#define XSTR(s) STR(s)
#define STR(s) #s
.file "fission-loclists.c"
.text
.Ltext0:
@@ -243,7 +240,7 @@ main:
.byte 0x5
.4byte .Ldebug_ranges0 # DW_AT_GNU_ranges_base
.ascii "/tmp/src/gdb/testsuite\0" # DW_AT_comp_dir
.asciz XSTR(DWO) # DW_AT_GNU_dwo_name
.asciz DWO # DW_AT_GNU_dwo_name
.4byte .Ldebug_pubnames0 # DW_AT_GNU_pubnames
.4byte .Ldebug_pubtypes0 # DW_AT_GNU_pubtypes
.4byte .Ldebug_addr0 # DW_AT_GNU_addr_base

View File

@@ -36,7 +36,7 @@ set obj [standard_output_file "${testfile}.o"]
set dwo [standard_output_file "${testfile}.dwo"]
if [build_executable_and_dwo_files "$testfile.exp" "${binfile}" {nodebug} \
[list $srcfile \
[list nodebug split-dwo additional_flags=-DDWO=$dwo] \
[list nodebug split-dwo additional_flags=-DDWO=\"$dwo\"] \
$obj]] {
return -1
}

View File

@@ -47,9 +47,6 @@
# define SYMBOL(str) str
#endif
#define XSTR(s) STR(s)
#define STR(s) #s
.file "fission-reread.cc"
.globl SYMBOL(baz)
@@ -146,7 +143,7 @@ SYMBOL(main):
.4byte 0 /* Offset to Type DIE */
.uleb128 0x2 /* (DIE (0) DW_TAG_type_unit) */
.ascii "/tmp/src/gdb/testsuite\0" /* DW_AT_comp_dir */
.asciz XSTR(DWO) /* DW_AT_GNU_dwo_name */
.asciz DWO /* DW_AT_GNU_dwo_name */
.4byte .Ldebug_pubnames0 /* DW_AT_GNU_pubnames */
.4byte .Ldebug_pubtypes0 /* DW_AT_GNU_pubtypes */
.4byte .Ldebug_addr0 /* DW_AT_GNU_addr_base */
@@ -217,7 +214,7 @@ SYMBOL(main):
.4byte .Letext0-.Ltext0 /* DW_AT_high_pc */
.4byte .Ldebug_line0 /* DW_AT_stmt_list */
.ascii "/tmp/src/gdb/testsuite\0" /* DW_AT_comp_dir */
.asciz XSTR(DWO) /* DW_AT_GNU_dwo_name */
.asciz DWO /* DW_AT_GNU_dwo_name */
.4byte .Ldebug_pubnames0 /* DW_AT_GNU_pubnames */
.4byte .Ldebug_pubtypes0 /* DW_AT_GNU_pubtypes */
.4byte .Ldebug_addr0 /* DW_AT_GNU_addr_base */

View File

@@ -40,7 +40,7 @@ if { $additional_flags != "" } {
set dwo_options $options
lappend dwo_options split-dwo
lappend dwo_options additional_flags=-DDWO=$dwo
lappend dwo_options additional_flags=-DDWO=\"$dwo\"
if [build_executable_and_dwo_files "$testfile.exp" "${binfile}" $options \
[list $srcfile $dwo_options $obj]] {

View File

@@ -28,11 +28,6 @@ if {[prepare_for_testing_full "failed to prepare" \
return -1
}
if ![fortran_runto_main] {
untested "could not run to main"
return -1
}
# Find a possibly mangled version of NAME, a function we want to call
# that has no debug information available. We hope that the mangled
# version of NAME contains the pattern NAME, and so we use 'info
@@ -67,12 +62,22 @@ proc find_mangled_name { name } {
return $symbol_name
}
# Sample before before starting the exec, in order to avoid picking up symbols
# from shared libs.
set some_func [find_mangled_name "some_func"]
set string_func [find_mangled_name "string_func"]
if ![fortran_runto_main] {
untested "could not run to main"
return -1
}
# Call the function SOME_FUNC, that takes a single integer and returns
# an integer. As the function has no debug information then we have
# to pass the integer argument as '&1' so that GDB will send the
# address of an integer '1' (as Fortran arguments are pass by
# reference).
set symbol_name [find_mangled_name "some_func"]
set symbol_name $some_func
if { $symbol_name == "" } {
untested "couldn't find suitable name for 'some_func'"
} else {
@@ -91,7 +96,7 @@ if { $symbol_name == "" } {
# The compiled program is expecting the address of the string, so we
# prefix that argument with '&', but the artificial length parameter
# is pass by value, so there's no need for '&' in that case.
set symbol_name [find_mangled_name "string_func"]
set symbol_name $string_func
if { $symbol_name == "" } {
untested "couldn't find suitable name for 'string_func'"
} else {

View File

@@ -33,6 +33,13 @@ set integer4 [fortran_int4]
set logical4 [fortran_logical4]
set integer8 [fortran_int8]
# A fortran string parameter is passed as a char *, and an additional
# argument str_ for the string length. The type used for the string length
# argument is size_t, but for gcc 7 and earlier, the actual type is int
# instead ( see
# https://gcc.gnu.org/onlinedocs/gfortran/Argument-passing-conventions.html ).
set stringlen ($integer8|$integer4)
if {[test_compiler_info {clang-*}]} {
set some_module_class_type "Type number"
set some_module_aux_info ", $integer8 \\(10\\)"
@@ -62,7 +69,7 @@ gdb_test "ptype fun_ptr" \
"type = PTR TO -> \\( $integer4 \\(\\) \\(${fun_ptr_arg}\\) \\)"
gdb_test "ptype say_string" \
"type = void \\(character\[^,\]+, $integer8\\)"
"type = void \\(character\[^,\]+, $stringlen\\)"
set say_array_artificial_first_arg ""
if {[test_compiler_info {clang-*}]} {

View File

@@ -104,6 +104,26 @@ proc test_empty_complaint { cmd msg } {
}
proc test_empty_complaints { } {
global decimal
set re [multi_line \
"All functions matching regular expression \[^:\]*:" \
"" \
"File \[^\r\n\]*/complaints\\.c:" \
"$decimal:\tvoid clear_complaints\\(\\);"]
set found 0
gdb_test_multiple "info function ^clear_complaints()$" "" {
-re -wrap $re {
set found 1
}
-re -wrap "" {
}
}
if { ! $found } {
untested "Cannot find clear_complaints, skipping test"
return 0
}
test_empty_complaint "call clear_complaints()" \
"clear complaints"

View File

@@ -260,10 +260,10 @@ proc_with_prefix test_watchpoints { } {
"test watchpoint write"
gdb_test "guile (define wp2 (make-breakpoint \"result\" #:wp-class WP_WRITE #:type 999))" \
"ERROR: In procedure gdbscm_make_breakpoint: Out of range: invalid breakpoint type in position 5: 999\r\n.*" \
"(ERROR: )?In procedure gdbscm_make_breakpoint: Out of range: invalid breakpoint type in position 5: 999\r\n.*" \
"create a breakpoint with an invalid type number"
gdb_test "guile (define wp2 (make-breakpoint \"result\" #:wp-class WP_WRITE #:type BP_NONE))" \
"ERROR: In procedure gdbscm_make_breakpoint: unsupported breakpoint type in position 5: \"BP_NONE\"\r\n.*" \
"(ERROR: )?In procedure gdbscm_make_breakpoint: unsupported breakpoint type in position 5: \"BP_NONE\"\r\n.*" \
"create a breakpoint with an unsupported type"
}
@@ -533,7 +533,7 @@ proc_with_prefix test_catchpoints {} {
# Try to create a catchpoint, currently this isn't supported via
# the guile api.
gdb_test "guile (define cp (make-breakpoint \"syscall\" #:type BP_CATCHPOINT))" \
"ERROR: In procedure gdbscm_make_breakpoint: unsupported breakpoint type in position 3: \"BP_CATCHPOINT\"\r\n.*" \
"(ERROR: )?In procedure gdbscm_make_breakpoint: unsupported breakpoint type in position 3: \"BP_CATCHPOINT\"\r\n.*" \
"create a catchpoint via the api"
# Setup a catchpoint.

View File

@@ -0,0 +1,65 @@
/* This testcase is part of GDB, the GNU debugger.
Copyright 2021 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <unistd.h>
#include <pthread.h>
#include <assert.h>
#define NUM_THREADS 4
static pthread_barrier_t barrier;
static void *
thread_function (void *arg)
{
pthread_barrier_wait (&barrier);
for (int i = 0; i < 30; i++)
sleep (1);
return NULL;
}
static void
all_threads_started (void)
{}
int
main (void)
{
pthread_t threads[NUM_THREADS];
pthread_barrier_init (&barrier, NULL, NUM_THREADS + 1);
for (int i = 0; i < NUM_THREADS; i++)
{
int res = pthread_create (&threads[i], NULL, thread_function, NULL);
assert (res == 0);
}
pthread_barrier_wait (&barrier);
all_threads_started ();
for (int i = 0; i < NUM_THREADS; i++)
{
int res = pthread_join (threads[i], NULL);
assert (res == 0);
}
return 0;
}

View File

@@ -0,0 +1,130 @@
# Copyright 2021 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Test --exec-interrupt with thread-group.
#
# Run two inferiors, try interrupting them both with --exec-interrupt +
# --thread-group.
load_lib mi-support.exp
set MIFLAGS "-i=mi"
standard_testfile .c
if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile \
executable debug] != "" } {
return -1
}
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set non-stop on\" -ex \"set mi-async\""
mi_clean_restart $binfile
}
mi_detect_async
# Create breakpoint by hand instead of using mi_runto, since we'll need it for
# both inferiors.
mi_create_breakpoint "all_threads_started" \
"set breakpoint on all_threads_started"
# Run first inferior to all_threads_started (to ensure all threads are started)
# and resume it.
if { [mi_run_cmd] < 0 } {
return
}
mi_expect_stop "breakpoint-hit" "all_threads_started" ".*" ".*" ".*" {"" "disp=\"keep\""} \
"inferior i1 stops at all_threads_started"
mi_send_resuming_command "exec-continue --thread-group i1" \
"continue inferior 1"
# We can't run a second inferior on stub targets. We can still test with one
# inferior and ensure that the command has the desired effect.
set use_second_inferior [expr {![use_gdb_stub]}]
if { $use_second_inferior } {
# The inferior created by the -add-inferior MI command does not inherit the
# target connection of the first inferior. If debugging through an
# extended-remote connection, that means we can't run that second inferior
# on the remote connection. Use the add-inferior CLI command as a stop-gap.
if { [mi_is_target_remote] } {
mi_gdb_test "add-inferior" \
"\\^done" \
"add inferior 2"
} else {
mi_gdb_test "-add-inferior" \
"\\^done,inferior=\"i2\"" \
"add inferior 2"
}
mi_gdb_test "-file-exec-and-symbols --thread-group i2 $::binfile" \
"\\^done" \
"set executable of inferior 2"
# Run second inferior to all_threads_started (to ensure all threads are
# started) and resume it.
mi_gdb_test "-exec-run --thread-group i2" \
"\\^running.*" \
"run inferior 2"
mi_expect_stop "breakpoint-hit" "all_threads_started" ".*" ".*" ".*" {"" "disp=\"keep\""} \
"inferior i2 stops at all_threads_started"
mi_send_resuming_command "exec-continue --thread-group i2" \
"continue inferior 2"
mi_check_thread_states {
"running" "running" "running" "running" "running"
"running" "running" "running" "running" "running"
} "before interrupting"
} else {
mi_check_thread_states {
"running" "running" "running" "running" "running"
} "before interrupting"
}
# Interrupt inferior 1, wait for events.
mi_gdb_test "-exec-interrupt --thread-group i1" \
"\\^done" \
"interrupt inferior 1"
for {set i 0} {$i < 5} {incr i} {
mi_expect_interrupt "inferior 1, interrupt $i"
}
if { $use_second_inferior } {
mi_check_thread_states {
"stopped" "stopped" "stopped" "stopped" "stopped"
"running" "running" "running" "running" "running"
} "after interrupting inferior 1"
# Interrupt inferior 2, wait for events.
mi_gdb_test "-exec-interrupt --thread-group i2" \
"\\^done" \
"interrupt inferior 2"
for {set i 0} {$i < 5} {incr i} {
mi_expect_interrupt "inferior 2, interrupt $i"
}
mi_check_thread_states {
"stopped" "stopped" "stopped" "stopped" "stopped"
"stopped" "stopped" "stopped" "stopped" "stopped"
} "after interrupting inferior 2"
} else {
mi_check_thread_states {
"stopped" "stopped" "stopped" "stopped" "stopped"
} "after interrupting inferior 1"
}

View File

@@ -435,6 +435,28 @@ proc_with_prefix test_forced_conditions {} {
mi_gdb_test "-break-info 16" \
"\\^done,[mi_make_breakpoint_table [list $bp]]" \
"invalid condition is defined"
# No cond argument should clear the condition.
mi_gdb_test "-break-condition 16" \
"~\"Breakpoint 16's condition is now valid at location 1, enabling.*\\^done" \
"clear the condition"
set bp [mi_make_breakpoint -number 16]
mi_gdb_test "-break-info 16" \
"\\^done,[mi_make_breakpoint_table [list $bp]]" \
"condition is cleared"
# Zero-argument is an error.
mi_gdb_test "-break-condition" \
"\\^error,msg=\"-break-condition: Missing the <number> argument\"" \
"no arguments to -break-condition"
# Passing --force with no condition should not crash or raise an error.
mi_gdb_test "-break-condition --force 16" \
"\\^done" \
"clear the condition with --force"
mi_gdb_test "-break-condition --force" \
"\\^error,msg=\"-break-condition: Missing the <number> argument\"" \
"no arguments with --force"
}
proc test_break {mi_mode} {

View File

@@ -28,8 +28,14 @@ if {[prepare_for_testing $testfile.exp $testfile \
mi_clean_restart $binfile
set readnow_p [mi_readnow]
mi_runto_main
# Unload symbols for shared libraries to prevent
# 'ERROR: internal buffer is full'.
mi_gdb_test "nosharedlibrary" ".*\\^done" "nosharedlibrary"
# Helper to build expected MI output pattern for a list. NAME is the
# name of the list (which can be the empty string) and args is one
# or more strings representing the fields of the list, which will be
@@ -108,27 +114,45 @@ proc check_info_sources { debug_fully_read } {
with_test_prefix "debug_read=${debug_fully_read}" {
if { $debug_fully_read } {
set p [mi_list "files" \
[mi_tuple "" \
[mi_field "file" "\[^\"\]+/mi-info-sources-base\\.c"] \
[mi_field "fullname" "\[^\"\]+/mi-info-sources-base\\.c"] \
[mi_field "debug-fully-read" "${debug_fully_read}"]] \
[mi_tuple "" \
[mi_field "file" "\[^\"\]+/mi-info-sources\\.c"] \
[mi_field "fullname" "\[^\"\]+/mi-info-sources\\.c"] \
[mi_field "debug-fully-read" "true"]]]
set p1 \
[mi_list "files" \
".*" \
[mi_tuple "" \
[mi_field "file" "\[^\"\]+/mi-info-sources-base\\.c"] \
[mi_field "fullname" "\[^\"\]+/mi-info-sources-base\\.c"] \
[mi_field "debug-fully-read" "${debug_fully_read}"]] \
".*"]
set p2 \
[mi_list "files" \
".*" \
[mi_tuple "" \
[mi_field "file" "\[^\"\]+/mi-info-sources\\.c"] \
[mi_field "fullname" "\[^\"\]+/mi-info-sources\\.c"] \
[mi_field "debug-fully-read" "true"]] \
".*"]
} else {
set p [mi_list "files" \
[mi_tuple "" \
[mi_field "file" "\[^\"\]+/mi-info-sources\\.c"] \
[mi_field "fullname" "\[^\"\]+/mi-info-sources\\.c"] \
[mi_field "debug-fully-read" "true"]] \
[mi_tuple "" \
[mi_field "file" "\[^\"\]+/mi-info-sources-base\\.c"] \
[mi_field "fullname" "\[^\"\]+/mi-info-sources-base\\.c"] \
[mi_field "debug-fully-read" "${debug_fully_read}"]]]
set p1 \
[mi_list "files" \
".*" \
[mi_tuple "" \
[mi_field "file" "\[^\"\]+/mi-info-sources\\.c"] \
[mi_field "fullname" "\[^\"\]+/mi-info-sources\\.c"] \
[mi_field "debug-fully-read" "true"]] \
".*"]
set p2 \
[mi_list "files" \
".*" \
[mi_tuple "" \
[mi_field "file" "\[^\"\]+/mi-info-sources-base\\.c"] \
[mi_field "fullname" "\[^\"\]+/mi-info-sources-base\\.c"] \
[mi_field "debug-fully-read" "${debug_fully_read}"]] \
".*"]
}
mi_gdb_test "-file-list-exec-source-files" ".*\\^done,${p}" "-file-list-exec-source-files"
mi_gdb_test "-file-list-exec-source-files" ".*\\^done,${p1}" \
"-file-list-exec-source-files, src1"
mi_gdb_test "-file-list-exec-source-files" ".*\\^done,${p2}" \
"-file-list-exec-source-files, src2"
set p [mi_list "files" \
[mi_tuple "" \
@@ -147,7 +171,7 @@ proc check_info_sources { debug_fully_read } {
set p [mi_list "files" \
[mi_tuple "" \
[mi_field "filename" "\[^\"\]+/mi-info-sources"] \
[mi_field "filename" "\[^\"\]+/mi-info-sources(\.debug)?"] \
[mi_field "debug-info" "${debug_info}"] \
[mi_list "sources" \
".*" \
@@ -162,7 +186,7 @@ proc check_info_sources { debug_fully_read } {
set p [mi_list "files" \
[mi_tuple "" \
[mi_field "filename" "\[^\"\]+/mi-info-sources"] \
[mi_field "filename" "\[^\"\]+/mi-info-sources(\.debug)?"] \
[mi_field "debug-info" "${debug_info}"] \
[mi_list "sources" \
".*" \
@@ -177,8 +201,13 @@ proc check_info_sources { debug_fully_read } {
}
}
check_info_sources "false"
if { ! $readnow_p } {
check_info_sources "false"
}
mi_continue_to "some_other_func"
# Force "fully-read".
mi_gdb_test "maint expand-symtabs"
check_info_sources "true"

View File

@@ -189,34 +189,58 @@ with_timeout_factor 4 {
}
}
set f2_re \
"\{line=\"33\",name=\"f2\",type=\"float \\(another_float_t\\)\",description=\"float f2\\(another_float_t\\);\"\}"
set f3_re \
"\{line=\"39\",name=\"f3\",type=\"int \\(another_int_t\\)\",description=\"int f3\\(another_int_t\\);\"\}"
set f4_re \
"\{line=\"36\",name=\"f4\",type=\"void \\(int \\*\\)\",description=\"void f4\\(int \\*\\);\"\}"
set global_i1_re \
"\{line=\"18\",name=\"global_i1\",type=\"int\",description=\"static int global_i1;\"\}"
set global_f2_re \
"\{line=\"21\",name=\"global_f2\",type=\"int\",description=\"int global_f2;\"\}"
set global_i2_re \
"\{line=\"20\",name=\"global_i2\",type=\"int\",description=\"int global_i2;\"\}"
set global_f1_s1_re \
"\{line=\"25\",name=\"global_f1\",type=\"float\",description=\"static float global_f1;\"\}"
set global_f1_s2_re \
"\{line=\"19\",name=\"global_f1\",type=\"float\",description=\"static float global_f1;\"\}"
set another_int_re "\{line=\"23\",name=\"another_int_t\"\}"
set my_int_re "\{line=\"27\",name=\"my_int_t\"\}"
set another_char_re "\{line=\"44\",name=\"another_char_t\"\}"
set another_float_re "\{line=\"24\",name=\"another_float_t\"\}"
set another_short_re "\{line=\"45\",name=\"another_short_t\"\}"
# Filter functions by name and type.
set lineno [gdb_get_line_number "f3 (another_int_t arg)" ${srcfile2}]
mi_gdb_test "116-symbol-info-functions --name ^f3$" \
"116\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[\{line=\"39\",name=\"f3\",type=\"int \\(another_int_t\\)\",description=\"int f3\\(another_int_t\\);\"\}\\\]\}\\\]\}" \
"116\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[$f3_re\\\]\}\\\]\}" \
"List all functions matching pattern f3"
set lineno [gdb_get_line_number "f4 (int *arg)" ${srcfile}]
mi_gdb_test "117-symbol-info-functions --type void --name ^f4$" \
"117\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile\",fullname=\"\[^\"\]+$srcfile\",symbols=\\\[\{line=\"36\",name=\"f4\",type=\"void \\(int \\*\\)\",description=\"void f4\\(int \\*\\);\"\}\\\]\}\\\]\}" \
"117\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile\",fullname=\"\[^\"\]+$srcfile\",symbols=\\\[$f4_re\\\]\}\\\]\}" \
"List all functions matching type void"
# Filter variables by name and type.
set lineno [gdb_get_line_number "int global_f2;" ${srcfile2}]
mi_gdb_test "118-symbol-info-variables --name global_f2" \
"118\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[\{line=\"21\",name=\"global_f2\",type=\"int\",description=\"int global_f2;\"\}\\\]\}\\\]\}" \
"118\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[$global_f2_re\\\]\}\\\]\}" \
"List all variables matching pattern global_f2"
set lineno1 [gdb_get_line_number "static float __attribute__ ((used)) global_f1;" ${srcfile}]
set lineno2 [gdb_get_line_number "static float __attribute__ ((used)) global_f1;" ${srcfile2}]
mi_gdb_test "119-symbol-info-variables --type float --name ^global_" \
"119\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile\",fullname=\"\[^\"\]+$srcfile\",symbols=\\\[\{line=\"25\",name=\"global_f1\",type=\"float\",description=\"static float global_f1;\"\}\\\]\},\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[\{line=\"19\",name=\"global_f1\",type=\"float\",description=\"static float global_f1;\"\}\\\]\}\\\]\}" \
"119\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile\",fullname=\"\[^\"\]+$srcfile\",symbols=\\\[$global_f1_s1_re\\\]\},\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[$global_f1_s2_re\\\]\}\\\]\}" \
"List all variables matching type float"
# Fetch types, filtering by name.
set lineno1 [gdb_get_line_number "typedef int my_int_t;" ${srcfile}]
set lineno2 [gdb_get_line_number "typedef int another_int_t;" ${srcfile2}]
mi_gdb_test "120-symbol-info-types --name _int_" \
"120\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile\",fullname=\"\[^\"\]+$srcfile\",symbols=\\\[\{line=\"27\",name=\"my_int_t\"\}\\\]\},\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[\{line=\"23\",name=\"another_int_t\"\}\\\]\}\\\]\}" \
"120\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile\",fullname=\"\[^\"\]+$srcfile\",symbols=\\\[$my_int_re\\\]\},\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[$another_int_re\\\]\}\\\]\}" \
"List all types matching _int_"
# Test the --max-results parameter.
@@ -225,20 +249,17 @@ mi_gdb_test "121-symbol-info-functions --max-results 0" \
"-symbol-info-functions --max-results 0"
mi_gdb_test "122-symbol-info-functions --max-results 1 --name ^\[^_\]" \
"122\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[\{line=\"39\",name=\"f3\",type=\"int \\(another_int_t\\)\",description=\"int f3\\(another_int_t\\);\"\}\\\]\}\\\]\}" \
"122\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[(?:$f2_re|$f3_re)\\\]\}\\\]\}" \
"-symbol-info-functions --max-results 1"
mi_gdb_test "123-symbol-info-functions --max-results 2 --name ^\[^_\]" \
"123\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[\{line=\"33\",name=\"f2\",type=\"float \\(another_float_t\\)\",description=\"float f2\\(another_float_t\\);\"\},\{line=\"39\",name=\"f3\",type=\"int \\(another_int_t\\)\",description=\"int f3\\(another_int_t\\);\"\}\\\]\}\\\]\}" \
"123\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[$f2_re,$f3_re\\\]\}\\\]\}" \
"-symbol-info-functions --max-results 2"
mi_gdb_test "124-symbol-info-variables --max-results 3 --name ^\[^_\]" \
"124\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[\{line=\"21\",name=\"global_f2\",type=\"int\",description=\"int global_f2;\"\},\{line=\"20\",name=\"global_i2\",type=\"int\",description=\"int global_i2;\"\},\{line=\"19\",name=\"global_f1\",type=\"float\",description=\"static float global_f1;\"\}\\\]\}\\\]\}" \
"124\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[$global_f2_re,$global_i2_re,(?:$global_i1_re|$global_f1_s2_re)\\\]\}\\\]\}" \
"-symbol-info-types --max-results 3"
set s1 "\{line=\"44\",name=\"another_char_t\"\}"
set s2 "\{line=\"24\",name=\"another_float_t\"\}"
set s3 "\{line=\"23\",name=\"another_int_t\"\}"
set s4 "\{line=\"45\",name=\"another_short_t\"\}"
mi_gdb_test "125-symbol-info-types --max-results 4 --name another_" \
"125\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[$s1,$s2,$s3,$s4\\\]\}\\\]\}" \
"125\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[$another_char_re,$another_float_re,$another_int_re,$another_short_re\\\]\}\\\]\}" \
"-symbol-info-types --max-results 4"

View File

@@ -85,3 +85,15 @@ mi_gdb_test "-var-list-children c1.car.atom" \
mi_gdb_test "-var-info-path-expression c1.car.atom.ival" \
"\\^error,msg=\".*\"" \
"-var-info-path-expression c1.car.atom.ival"
# Regression test for a crasher that would occur when deleting a
# varobj that held an iterator that hadn't yet been completed.
# See PR varobj/28131.
mi_gdb_test "-var-create c1_again * &c1" \
"\\^done.*" \
"-var-create c1_again * &c1"
mi_gdb_test "-var-list-children c1_again 0 1" \
"\\^done,numchild=\"1\",children=.child=\{name=\"c1_again.car\".*" \
"-var-list-children c1_again"
mi_delete_varobj c1_again "delete c1_again"

View File

@@ -32,6 +32,13 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
return -1
}
# Case 1: libthread_db fakes a single thread with th_unique == NULL.
set thread_re1 "0 => $decimal => 0"
# Case 2: libthread_db already initialized.
set thread_re2 "$hex => $decimal => ${hex}(; errno = 0)?"
# Match either of the two cases.
set initial_thread_re "($thread_re1|$thread_re2)"
with_test_prefix "user-initiated check" {
# User-initiated check with libthread_db not loaded.
@@ -49,18 +56,16 @@ with_test_prefix "user-initiated check" {
"No libthread_db loaded" \
"no libpthread.so loaded"
# User-initiated check with NPTL uninitialized.
# libthread_db should fake a single thread with th_unique == NULL.
# User-initiated check with NPTL possibly uninitialized.
gdb_test "continue" \
".*Stopped due to shared library event.*Inferior loaded .*libpthread.*"
gdb_test_sequence "maint check libthread-db" \
"libpthread.so not initialized" {
"\[\r\n\]+Running libthread_db integrity checks:"
"\[\r\n\]+\[ \]+Got thread 0x0 => \[0-9\]+ => 0x0 ... OK"
"\[\r\n\]+libthread_db integrity checks passed."
}
"libpthread.so possibly not initialized" \
[list \
"\[\r\n\]+Running libthread_db integrity checks:" \
"\[\r\n\]+\[ \]+Got thread $initial_thread_re ... OK" \
"\[\r\n\]+libthread_db integrity checks passed."]
# User-initiated check with NPTL fully operational.
gdb_test_no_output "set stop-on-solib-events 0"
@@ -78,8 +83,8 @@ with_test_prefix "user-initiated check" {
with_test_prefix "automated load-time check" {
# Automated load-time check with NPTL uninitialized.
with_test_prefix "libpthread.so not initialized" {
# Automated load-time check with NPTL possibly uninitialized.
with_test_prefix "libpthread.so possibly not initialized" {
clean_restart ${binfile}
gdb_test_no_output "maint set check-libthread-db 1"
@@ -88,12 +93,12 @@ with_test_prefix "automated load-time check" {
gdb_run_cmd
gdb_test_sequence "" \
"check debug libthread-db output" {
"\[\r\n\]+Running libthread_db integrity checks:"
"\[\r\n\]+\[ \]+Got thread 0x0 => \[0-9\]+ => 0x0 ... OK"
"\[\r\n\]+libthread_db integrity checks passed."
"\[\r\n\]+[Thread debugging using libthread_db enabled]"
}
"check debug libthread-db output" \
[list \
"\[\r\n\]+Running libthread_db integrity checks:" \
"\[\r\n\]+\[ \]+Got thread $initial_thread_re ... OK" \
"\[\r\n\]+libthread_db integrity checks passed." \
"\[\r\n\]+\\\[Thread debugging using libthread_db enabled\\\]"]
}
# Automated load-time check with NPTL fully operational.

Some files were not shown because too many files have changed in this diff Show More