Commit Graph

110762 Commits

Author SHA1 Message Date
GDB Administrator
73d9afb778 Automatic date update in version.in 2022-07-20 00:00:20 +00:00
H.J. Lu
f638657759 x86: Disallow invalid relocations against protected symbols
Since glibc 2.36 will issue warnings for copy relocation against
protected symbols and non-canonical reference to canonical protected
functions, change the linker to always disallow such relocations.

bfd/

	* elf32-i386.c (elf_i386_scan_relocs): Remove check for
	elf_has_indirect_extern_access.
	* elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise.
	(elf_x86_64_relocate_section): Remove check for
	elf_has_no_copy_on_protected.
	* elfxx-x86.c (elf_x86_allocate_dynrelocs): Check for building
	executable instead of elf_has_no_copy_on_protected.
	(_bfd_x86_elf_adjust_dynamic_symbol): Disallow copy relocation
	against non-copyable protected symbol.
	* elfxx-x86.h (SYMBOL_NO_COPYRELOC): Remove check for
	elf_has_no_copy_on_protected.

ld/

	* testsuite/ld-i386/i386.exp: Expect linker error for PR ld/17709
	test.
	* testsuite/ld-i386/pr17709.rd: Removed.
	* testsuite/ld-i386/pr17709.err: New file.
	* testsuite/ld-x86-64/pr17709.rd: Removed.
	* testsuite/ld-x86-64/pr17709.err: New file.
	* testsuite/ld-x86-64/pr28875-func.err: Updated.
	* testsuite/ld-x86-64/x86-64.exp: Expect linker error for PR
	ld/17709 test.  Add tests for function pointer against protected
	function.
2022-07-19 08:41:52 -07:00
Fangrui Song
d19a265487 x86: Make protected symbols local for -shared
Call _bfd_elf_symbol_refs_local_p with local_protected==true.  This has
2 noticeable effects for -shared:

* GOT-generating relocations referencing a protected data symbol no
  longer lead to a GLOB_DAT (similar to a hidden symbol).
* Direct access relocations (e.g. R_X86_64_PC32) no longer has the
  confusing diagnostic below.

    __attribute__((visibility("protected"))) void *foo() {
      return (void *)foo;
    }

    // gcc -fpic -shared -fuse-ld=bfd
    relocation R_X86_64_PC32 against protected symbol `foo' can not be used when making a shared object

The new behavior matches arm, aarch64 (commit
83c325007c), and powerpc ports, and other
linkers: gold and ld.lld.

Note: if some code tries to use direct access relocations to take the
address of foo, the pointer equality will break, but the error should be
reported on the executable link, not on the innocent shared object link.
glibc 2.36 will give a warning at relocation resolving time.

With this change, `#define elf_backend_extern_protected_data 1` is no
longer effective.  Just remove it.

Remove the test "Run protected-func-1 without PIE" since -fno-pic
address taken operation in the executable doesn't work with protected
symbol in a shared object by default.  Similarly, remove
protected-data-1a and protected-data-1b.  protected-data-1b can be made
working by removing HAVE_LD_PIE_COPYRELOC from GCC
(https://sourceware.org/pipermail/gcc-patches/2022-June/596678.html).
2022-07-19 08:41:52 -07:00
Luis Machado
e9061058b4 Reformat gdbarch-components.py to fix deviations
Reformat to make sure we have a clean file with no deviations
from the expected python code format.
2022-07-19 16:07:55 +01:00
Luis Machado
68cffbbd44 [AArch64] MTE corefile support
Teach GDB how to dump memory tags for AArch64 when using the gcore command
and how to read memory tag data back from a core file generated by GDB
(via gcore) or by the Linux kernel.

The format is documented in the Linux Kernel documentation [1].

Each tagged memory range (listed in /proc/<pid>/smaps) gets dumped to its
own PT_AARCH64_MEMTAG_MTE segment. A section named ".memtag" is created for each
of those segments when reading the core file back.

To save a little bit of space, given MTE tags only take 4 bits, the memory tags
are stored packed as 2 tags per byte.

When reading the data back, the tags are unpacked.

I've added a new testcase to exercise the feature.

Build-tested with --enable-targets=all and regression tested on aarch64-linux
Ubuntu 20.04.

[1] Documentation/arm64/memory-tagging-extension.rst (Core Dump Support)
2022-07-19 15:24:31 +01:00
Luis Machado
d0ff5ca959 [AArch64] Support AArch64 MTE memory tag dumps in core files
The Linux kernel can dump memory tag segments to a core file, one segment
per mapped range. The format and documentation can be found in the Linux
kernel tree [1].

The following patch adjusts bfd and binutils so they can handle this new
segment type and display it accordingly. It also adds code required so GDB
can properly read/dump core file data containing memory tags.

Upon reading, each segment that contains memory tags gets mapped to a
section named "memtag". These sections will be used by GDB to lookup the tag
data. There can be multiple such sections with the same name, and they are not
numbered to simplify GDB's handling and lookup.

There is another patch for GDB that enables both reading
and dumping of memory tag segments.

Tested on aarch64-linux Ubuntu 20.04.

[1] Documentation/arm64/memory-tagging-extension.rst (Core Dump Support)
2022-07-19 15:24:27 +01:00
Luis Machado
3c539d41b4 [AArch64] Fix testcase compilation failure
Newer distros carry newer headers that contains MTE definitions.  Account
for that fact in the MTE testcases (gdb.arch/aarch64-mte.exp) and define
constants conditionally to prevent compilation failures.
2022-07-19 14:24:00 +01:00
H.J. Lu
76e4fa70e7 ld: Pass -nostdlib to compiler with -r
Pass -nostdlib to compiler with -r to avoid unnecessary .o file and
libraries.

	PR ld/29377
	* testsuite/ld-elf/linux-x86.exp: Pass -nostdlib with -r.
2022-07-18 18:54:20 -07:00
H.J. Lu
bd0736124c x86: Properly check invalid relocation against protected symbol
Only check invalid relocation against protected symbol defined in shared
object.

bfd/

	PR ld/29377
	* elf32-i386.c (elf_i386_scan_relocs): Only check invalid
	relocation against protected symbol defined in shared object.
	* elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise.

ld/

	PR ld/29377
	* testsuite/ld-elf/linux-x86.exp: Run PR ld/29377 tests.
	* testsuite/ld-elf/pr29377a.c: New file.
	* testsuite/ld-elf/pr29377b.c: Likewise.
2022-07-18 18:15:39 -07:00
GDB Administrator
b87062aade Automatic date update in version.in 2022-07-19 00:00:25 +00:00
Vladimir Mezentsev
b8283575ae gprofng: link libgprofng.so against -lpthread
gprofng/ChangeLog
2022-07-15  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	PR gprofng/29364
	* src/Makefile.am (libgprofng_la_LIBADD): Add -lpthread.
	* src/Makefile.in: Rebuild.
2022-07-18 10:42:02 -07:00
Vladimir Mezentsev
e4d04cb306 gprofng: fix regression in build and a race condition in autoreconf
gprofng/ChangeLog
2022-07-14  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	PR gprofng/29338
	* libcollector/configure.ac (AC_CONFIG_HEADERS): Fix a race condition.
	* libcollector/configure: Rebuild.
	* libcollector/Makefile.in: Rebuild.
	* common/config.h.in: Rebuild.
	* common/lib-config.h.in: Created by autoreconf.
2022-07-18 10:41:10 -07:00
Tom Tromey
0b4fe76f95 Add gdb.free_objfile event registry
Currently, Python code can use event registries to detect when gdb
loads a new objfile, and when gdb clears the objfile list.  However,
there's no way to detect the removal of an objfile, say when the
inferior calls dlclose.

This patch adds a gdb.free_objfile event registry and arranges for an
event to be emitted in this case.
2022-07-18 11:25:34 -06:00
Pedro Alves
23948f5602 Put gdb.base/bt-on-fatal-signal.exp GDB cores in output dir
I noticed that gdb.base/bt-on-fatal-signal.exp was contributing four
core files to the count of unexpected core files:

 $ make check TESTS="gdb.base/bt-on-fatal-signal.exp"

		 === gdb Summary ===

 # of unexpected core files      4
 # of expected passes            21

These are GDB core dumps.  They are expected, however, because the
whole point of the testcase is to crash GDB with a signal.

Make GDB change its current directory to the output dir just before
crashing, so that the core files end up there.  The result is now:

		 === gdb Summary ===

 # of expected passes            25

and:

 $ find . -name "core.*"
 ./testsuite/outputs/gdb.base/bt-on-fatal-signal/core.gdb.1676506.nelson.1657727692
 ./testsuite/outputs/gdb.base/bt-on-fatal-signal/core.gdb.1672585.nelson.1657727671
 ./testsuite/outputs/gdb.base/bt-on-fatal-signal/core.gdb.1674833.nelson.1657727683
 ./testsuite/outputs/gdb.base/bt-on-fatal-signal/core.gdb.1673709.nelson.1657727676

(Note the test is skipped at the top if on a remote host.)

Change-Id: I79e4fb2e91330279c7a509930b1952194a72e85a
2022-07-18 17:29:15 +01:00
Tom Tromey
6a40c6e437 Remove array typedef assumption for Ada
Currently the Ada code assumes that it can distinguish between a
multi-dimensional array and an array of arrays by looking for an
intervening typedef -- that is, for an array of arrays, there will be
a typedef wrapping the innermost array type.

A recent compiler change removes this typedef, which causes a gdb
failure in the internal AdaCore test suite.

This patch handles this case by checking whether the array type in
question has a name.
2022-07-18 09:57:04 -06:00
Tom Tromey
083aca0c83 Remove manual lifetime management from cli_interp
cli_interp manually manages its cli_out object.  This patch changes it
to use a unique_ptr, and also changes cli_uiout to be a private
member.
2022-07-18 08:49:55 -06:00
Tom Tromey
66fd2c678e Remove cli_out_new
cli_out_new is just a small wrapper around 'new'.  This patch removes
it, replacing it with uses of 'new' instead.
2022-07-18 08:49:55 -06:00
Tom Tromey
efd3baf0dc Replace input_interactive_p with a method
This replaces the global input_interactive_p function with a new
method ui::input_interactive_p.
2022-07-18 08:49:55 -06:00
Tom Tromey
8f7f9b3a91 Remove ui_register_input_event_handler
This patch removes ui_register_input_event_handler and
ui_unregister_input_event_handler, replacing them with methods on
'ui'.  It also changes gdb to use these methods everywhere, rather
than sometimes reaching in to the ui to manage the file descriptor
directly.
2022-07-18 08:49:55 -06:00
Claudiu Zissulescu
bbcab3366b opcodes/arc: Implement style support in the disassembler
Update the ARC disassembler to supply style information to the
disassembler output. The output formatting remains unchanged.

opcodes/ChangeLog:
	* disassemble.c (disassemble_init_for_target): Set
	created_styled_output for ARC based targets.
	* arc-dis.c (find_format_from_table): Use fprintf_styled_ftype
	instead of fprintf_ftype throughout.
	(find_format): Likewise.
	(print_flags): Likewise.
	(print_insn_arc): Likewise.

Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
2022-07-18 14:25:31 +03:00
Claudiu Zissulescu
5154216259 arc: Update missing cipher.
The ciphers 5,7, and 9 are missing when parsing an assembly
instruction leading to errors when those ciphers are
used.

gas/config
	* tc-arc.c (md_assembly): Update strspn string with the
          missing ciphers.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2022-07-18 14:25:31 +03:00
Tom de Vries
9a14143c59 [gdb/testsuite] Remove duplicate of supports_gnuc
In commit 9d9dd861e9 ("[gdb/testsuite] Fix regression in
step-indirect-call-thunk.exp with gcc 7") I accidentally committed a duplicate
of supports_gnuc, which caused:
...
DUPLICATE: gdb.base/gdb-caching-proc.exp: supports_gnuc: consistency
...

Fix this by removing the duplicate.

Tested on x86_64-linux.
2022-07-18 12:48:39 +02:00
Andrew Burgess
602d2b520d gdb/python: look for python, then python 3 at configure time
It is possible that a system might have a python3 executable, but no
python executable.  For example, on my Fedora system the python2
package provides /usr/bin/python2, the python3 package provides
/usr/bin/python3, and the python-unversioned-command package provides
/usr/bin/python, which picks between python2 and python3.

It is quite possible to only have python3 available on a system.

Currently, when GDB configures, it looks for a 'python' executable.
If non is found then GDB will be built without python support.  Or the
user needs to configure using --with-python=/usr/bin/python3.

This commit updates GDB's configure.ac script to first look for
'python', and then 'python3'.  Now, on a system that only has a
python3 executable, GDB will automatically find, and use that in order
to provide python support, no user supplied configure arguments are
needed.

I've tested this on my local machine by removing the
python-unversioned-command package, confirming that there is no longer
a 'python' executable in my $PATH, and then rebuilding GDB from
scratch.  GDB with this patch has python support.
2022-07-18 11:32:40 +01:00
Jan Beulich
7e864bf71d x86: correct VMOVSH attributes
Both forms were missing VexW0 (thus allowing Evex.W=1 to be encoded by
suitable means, which would cause #UD). The memory operand form further
was using the wrong Masking value, thus allowing zeroing-masking to be
encoded for the store form (which would again cause #UD).
2022-07-18 11:20:44 +02:00
Jan Beulich
37cea58867 x86: re-order insn template fields
This saves quite a number of shift instructions: The "operands" field
can now be retrieved by just masking (no shift), and extracting the
"extension_opcode" field now only requires a (signed) right shift, with
no prereq left one. (Of course there may be architectures where, in a
cross build, there might be no difference at all, e.g. when there are
suitable bitfield extraction insns.)
2022-07-18 11:19:58 +02:00
Tom de Vries
4319180c81 [gdbsupport] Improve thread scheduling in parallel_for_each
When running a task using parallel_for_each, we get the following
distribution:
...
Parallel for: n_elements: 7271
Parallel for: minimum elements per thread: 10
Parallel for: elts_per_thread: 1817
Parallel for: elements on worker thread 0       : 1817
Parallel for: elements on worker thread 1       : 1817
Parallel for: elements on worker thread 2       : 1817
Parallel for: elements on worker thread 3       : 0
Parallel for: elements on main thread           : 1820
...

Note that there are 4 active threads, and scheduling elts_per_thread on each
of those handles 4 * 1817 == 7268, leaving 3 "left over" elements.

These leftovers are currently handled in the main thread.

That doesn't seem to matter much for this example, but for say 10 threads and
99 elements, you'd have 9 threads handling 9 elements and 1 thread handling 18
elements.

Instead, distribute the left over elements over the worker threads, such that
we have:
...
Parallel for: elements on worker thread 0       : 1818
Parallel for: elements on worker thread 1       : 1818
Parallel for: elements on worker thread 2       : 1818
Parallel for: elements on worker thread 3       : 0
Parallel for: elements on main thread           : 1817
...

Tested on x86_64-linux.
2022-07-18 08:34:06 +02:00
Tom de Vries
c3d3b64b34 [gdb/testsuite] Allow override of ASAN_OPTIONS in lib/gdb.exp
Use set_sanitizer_default for ASAN_OPTIONS in lib/gdb.exp.

This allows us to override the default detect_leaks=0 setting, by manually
doing:
...
$ export ASAN_OPTIONS=detect_leaks=1
$ make check
...

Tested on x86_64-linux, by building with -fsanitize=address and running
test-case gdb.dwarf2/gdb-add-index.exp with and without
"export ASAN_OPTIONS=detect_leaks=1".
2022-07-18 06:20:38 +02:00
Tom de Vries
9d9dd861e9 [gdb/testsuite] Fix regression in step-indirect-call-thunk.exp with gcc 7
Since commit 43127ae571 ("Fix gdb.base/step-indirect-call-thunk.exp") I run
into:
...
gdb compile failed, gcc: error: unrecognized command line option \
  '-fcf-protection=none'; did you mean '-flto-partition=none'?
UNTESTED: gdb.base/step-indirect-call-thunk.exp: failed to prepare
...

The problem is that -fcf-protection is supported starting gcc 8, but I'm using
system gcc 7.5.0.

Fix this by only adding -fcf-protection=none for gcc 8 and later.

Tested on x86_64-linux, with gcc 7.5.0, 8.2.1 and 12.1.1.
2022-07-18 06:13:45 +02:00
Tom de Vries
68a5118c48 [gdb/testsuite] Fix gdb.arch/i386-mpx.exp
Since commit c4a3dbaf11 ("Expose current 'print' settings to Python") we
have:
...
(gdb) print /x $bnd0 = {0x10, 0x20}^M
$22 = {lbound = 0x10, ubound = 0x20} : size 0x11^M
(gdb) FAIL: gdb.arch/i386-mpx.exp: verify size for bnd0
...

The regexp in the test-case expects "size 17".

Fix this by updating the regexp.

Tested on x86_64-linux.
2022-07-18 05:54:14 +02:00
Tom de Vries
53944a3bf5 [gdbsupport] Add parallel_for_each_debug
Add a parallel_for_each_debug variable, set to false by default.

With an a.out compiled from hello world, we get with
parallel_for_each_debug == true:
...
$ gdb -q -batch a.out -ex start
  ...
Parallel for: n_elements: 7271
Parallel for: minimum elements per thread: 10
Parallel for: elts_per_thread: 1817
Parallel for: elements on worker thread 0       : 1817
Parallel for: elements on worker thread 1       : 1817
Parallel for: elements on worker thread 2       : 1817
Parallel for: elements on worker thread 3       : 0
Parallel for: elements on main thread           : 1820

Temporary breakpoint 1, main () at /home/vries/hello.c:6
6         printf ("hello\n");
...

Tested on x86_64-linux.
2022-07-18 05:34:01 +02:00
GDB Administrator
38733fdc8c Automatic date update in version.in 2022-07-18 00:00:20 +00:00
GDB Administrator
f39cc214d5 Automatic date update in version.in 2022-07-17 00:00:12 +00:00
GDB Administrator
c3359b8b95 Automatic date update in version.in 2022-07-16 00:00:14 +00:00
Aaron Merey
92b0a182fe gdb-add-index always generates an error when libdebuginfod wasn't compiled in
gdb-add-index runs gdb with -iex 'set debuginfod enabled off'.  If gdb
is not compiled against libdebuginfod this causes an unnecessary error
message to be printed to stderr indicating that gdb was not built with
debuginfod support.

Fix this by changing the 'set debuginfod enabled off' command to a
no-op when gdb isn't built with libdebuginfod.
2022-07-15 17:11:23 -04:00
Bruno Larsen
13c3e10f98 gdb/testsuite: modernize gdb.base/maint.exp
gdb.base/maint.exp was using several gdb_expect statements, probably
because this test case predates the existance of gdb_test_multiple. This
commit updates the test case to use gdb_test_multiple, making it more
resilient to internal errors and such.

The only gdb_expect left in the testcase is one that specifically looks
for an internal error being triggered as a PASS.
2022-07-15 14:19:25 -03:00
Tom Tromey
3028a2dbbf Add 'nibbles' to gdb.print_options
When I rebased and updated the print_options patch, I forgot to update
print_options to add the new 'nibbles' feature to the result.  This
patch fixes the oversight.  I'm checking this in.
2022-07-15 09:42:39 -06:00
Carl Love
ebbac1687d PowerPC: Add support for IEEE 128-bit format.
The test gdb.base/infcall-nested-structs-c.exp fails on a gdb assert
in function ppc64_sysv_abi_return_value in file gdb/ppc-sysv-tdep.c.  The
assert is due to the missing IEEE 128-bit support in file
gdb/ppc-sysv-tdep.c.

The IBM long double was the initial float 128-bit support added by IBM
The IEEE 128-bit support, which is similar IBM long double support, was
made the default starting with GCC 12.  The floating point format
differences include the number of bits used to encode the exponent
and significand.  Also, IBM long double values are passed in a pair of
floating point registers.  The  IEEE 128-bit value is passed in a single
vector register.

This patch fixes the gdb_assert (ok); in function
ppc64_sysv_abi_return_value in gdb/ppc-sysv-tdep.c by adding IEEE FLOAT
128-bit type support for PowerPC.

The patch has been tested on Power 10, ELFv2.  It fixes the following list
of regression failures on Power 10:

gdb.base/infcall-nested-structs-c.exp      192
gdb.base/infcall-nested-structs-c++.exp     76
gdb.base/structs.exp                         9

The patch has been tested on Power 8 BE which is ELFv1.
2022-07-15 15:30:43 +00:00
Tom Tromey
72be9d6be7 Add 'summary' mode to Value.format_string
This adds a 'summary' mode to Value.format_string and to
gdb.print_options.  For the former, it lets Python code format values
using this mode.  For the latter, it lets a printer potentially detect
if it is being called in a backtrace with 'set print frame-arguments'
set to 'scalars'.

I considered adding a new mode here to let a pretty-printer see
whether it was being called in a 'backtrace' context at all, but I'm
not sure if this is really desirable.
2022-07-15 09:26:54 -06:00
Tom Tromey
c4a3dbaf11 Expose current 'print' settings to Python
PR python/17291 asks for access to the current print options.  While I
think this need is largely satisfied by the existence of
Value.format_string, it seemed to me that a bit more could be done.

First, while Value.format_string uses the user's settings, it does not
react to temporary settings such as "print/x".  This patch changes
this.

Second, there is no good way to examine the current settings (in
particular the temporary ones in effect for just a single "print").
This patch adds this as well.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17291
2022-07-15 09:25:33 -06:00
Carl Love
aa63b0a77e PowerPC: fix for gdb.base/eh_return.exp
Disable the Traceback Table generation on PowerPC for this test.  The
Traceback Table consists of a series of bit fields to indicate things like
the Traceback Table version, language, and specific information about the
function.  The Traceback Table is generated following the end of the code
for every function by default.  The Traceback Table is defined in the
PowerPC ELF ABI and is intended to support debuggers and exception
handlers.  The Traceback Table is displayed in the disassembly of functions
by default and is part of the function length.  The table is typically
interpreted by the disassembler as data represented by .long xxx entries.

Generation of the Traceback Table is disabled in this test using the
PowerPC specific gcc compiler option -mtraceback=no, the xlc option
additional_flags-qtable=none and the clang optons
 -mllvm -xcoff-traceback-table=false.  Disabling the Traceback Table
generation in this test results in the gdb_test_multiple statement
correctly locating the address of the bclr instruction before the statement
"End of assembler dump." in the disassembly output.
2022-07-15 15:17:34 +00:00
Tom Tromey
bf4d777d39 Run 'black' on gdb
Running 'black' on gdb fixed a couple of small issues.  This patch is
the result.
2022-07-15 07:55:32 -06:00
GDB Administrator
9afca381e2 Automatic date update in version.in 2022-07-15 00:00:29 +00:00
Tom de Vries
7d1a572d6b [gdb/symtab] Fix data race in cooked_index_functions::expand_symtabs_matching
When building gdb with -fsanitize-threads and running test-case
gdb.ada/char_enum_unicode.exp, I run into:
...
WARNING: ThreadSanitizer: data race (pid=21301)^M
  Write of size 8 at 0x7b2000008080 by main thread:^M
    #0 free <null> (libtsan.so.2+0x4c5e2)^M
    #1 _dl_close_worker <null> (ld-linux-x86-64.so.2+0x4b7b)^M
    #2 convert_between_encodings() charset.c:584^M
  ...
    #21 cooked_index_functions::expand_symtabs_matching() read.c:18606
...

This is fixed by making cooked_index_functions::expand_symtabs_matching wait
for the cooked index finalization to be done.

Tested on x86_64-linux.

https://sourceware.org/bugzilla/show_bug.cgi?id=29311
https://sourceware.org/bugzilla/show_bug.cgi?id=29286
2022-07-14 20:47:54 +02:00
Tom de Vries
18a5766d09 [gdbsupport] Add sequential_for_each
Add a sequential_for_each alongside the parallel_for_each, which can be used
as a drop-in replacement.

This can be useful when debugging multi-threading behaviour, and you want to
limit multi-threading in a fine-grained way.

Tested on x86_64-linux, by using it instead of the parallel_for_each in
dwarf2_build_psymtabs_hard.
2022-07-14 17:01:52 +02:00
Tiezhu Yang
e24500cbab gdb: Document floating-point support for LoongArch
Update NEWS and gdb.texinfo to document floating-point support
for LoongArch.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-07-14 22:44:04 +08:00
Tom de Vries
2df41bda2f [gdb/build] Fix gdb build with gcc 4.8.5
When building gdb with gcc 4.8.5, we run into:
...
In file included from /usr/include/c++/4.8/future:43:0,
                 from gdbsupport/thread-pool.h:30,
                 from gdb/dwarf2/cooked-index.h:33,
                 from gdb/dwarf2/read.h:26,
                 from gdb/dwarf2/abbrev-cache.c:21:
/usr/include/c++/4.8/atomic: In instantiation of \
  ‘_Tp std::atomic<_Tp>::load(std::memory_order) const [with _Tp = \
  packed<dwarf_unit_type, 1ul>; std::memory_order = std::memory_order]’:
gdb/dwarf2/read.h:332:44:   required from here
/usr/include/c++/4.8/atomic:208:13: error: no matching function for call to \
  ‘packed<dwarf_unit_type, 1ul>::packed()’
         _Tp tmp;
             ^
...

Fix this by adding the default constructor for packed.

Tested on x86_64-linux, with gdb build with gcc 4.8.5.
2022-07-14 10:20:16 +02:00
Tom de Vries
14dd1080c6 [gdb/symtab] Make per_cu->m_lang atomic
When building gdb with -fsanitize=thread and running test-case
gdb.dwarf2/inlined_subroutine-inheritance.exp, we run into a data race
between:
...
  Read of size 1 at 0x7b2000003010 by thread T4:
    #0 packed<language, 1ul>::operator language() const packed.h:54
    #1 dwarf2_per_cu_data::set_lang(language) read.h:363
...
and:
...
  Previous write of size 1 at 0x7b2000003010 by main thread:
    #0 dwarf2_per_cu_data::set_lang(language) read.h:365
...

Fix this by making per_cu->m_lang atomic.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29286
2022-07-14 08:19:00 +02:00
Tom de Vries
b35bd7d552 [gdb/symtab] Make per_cu->unit_type atomic
With gdb with -fsanitize=thread and test-case gdb.ada/array_bounds.exp, I run
into a data race between:
...
  Read of size 1 at 0x7b2000025f0f by main thread:
    #0 packed<dwarf_unit_type, 1ul>::operator dwarf_unit_type() const packed.h:54
    #1 dwarf2_per_cu_data::set_unit_type(dwarf_unit_type) read.h:339
...
and:
...
  Previous write of size 1 at 0x7b2000025f0f by thread T3:
    #0 dwarf2_per_cu_data::set_unit_type(dwarf_unit_type) read.h:341
...

Fix this by making per_cu->unit_type atomic.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29286
2022-07-14 08:19:00 +02:00
Tom de Vries
4f92e10cda [gdb/symtab] Fix data race in ~charset_vector
When doing:
...
$ gdb ./outputs/gdb.ada/char_enum_unicode/foo -batch -ex "break foo.adb:26"
...
with a gdb build with -fsanitize=thread I run into a data race:
...
WARNING: ThreadSanitizer: data race (pid=30917)
  Write of size 8 at 0x7b0400004070 by main thread:
    #0 free <null> (libtsan.so.2+0x4c5e2)
    #1 xfree<char> gdbsupport/gdb-xfree.h:37 (gdb+0x650f17)
    #2 charset_vector::clear() gdb/charset.c:703 (gdb+0x651354)
    #3 charset_vector::~charset_vector() gdb/charset.c:697 (gdb+0x6512d3)
    #4 <null> <null> (libtsan.so.2+0x32643)
    #5 captured_main_1 gdb/main.c:1310 (gdb+0xa3975a)
...

The problem is that we're freeing the charset_vector elements in the destructor,
which may still be used by a worker thread.

Fix this by not freeing the charset_vector elements in the destructor.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29311
2022-07-14 08:19:00 +02:00
Alan Modra
5f6c92298a Re: PowerPC: implement md_operand to parse register names
I meant to make this change before committing, to let compilers know
the code on the false branch of md_parse_name is dead.

	* config/tc-ppc.c (ppc_parse_name): Return void.
	* config/tc-ppc.h (md_parse_name): Always true.
	(ppc_parse_name): Update prototype.
2022-07-14 15:25:18 +09:30