Commit Graph

115233 Commits

Author SHA1 Message Date
Tom Tromey
a2bbca9fa5 Use std::vector<bool> for agent_expr::reg_mask
agent_expr::reg_mask implements its own packed boolean vector.  This
patch replaces it with a std::vector<bool>, simplifying the code.

Reviewed-by: John Baldwin <jhb@FreeBSD.org>
2023-06-20 11:21:51 -06:00
Tom Tromey
6f96f4854f Use gdb::byte_vector in agent_expr
This changes agent_expr to use gdb::byte_vector rather than manually
reimplementing a vector.

Reviewed-by: John Baldwin <jhb@FreeBSD.org>
2023-06-20 11:00:19 -06:00
Tom Tromey
90db289d0d Remove mem2hex
tracepoint.c has a 'mem2hex' function that is functionally equivalent
to bin2hex.  This patch removes the redundancy.

Reviewed-by: John Baldwin <jhb@FreeBSD.org>
2023-06-20 11:00:19 -06:00
H.J. Lu
c7face1422 x86: Don't check if AVX512 template requires AVX512VL
If the ZMM operand in an AVX12 template also allows XMM or ZMM, this
template must require AVX512VL.  Drop the AVX512VL requirement check
on such AVX512 templates.

	* config/tc-i386.c (check_VecOperands): Don't check if AVX512
	template requires AVX512VL.
2023-06-20 09:43:58 -07:00
Tom Tromey
c65030964b Use std::string in do_set_command
do_set_command manually updates a string, only to copy it to a
std::string and free the working copy.  This patch changes this code
to use std::string for everything, simplifying the code and removing a
copy.

Reviewed-by: John Baldwin <jhb@FreeBSD.org>
2023-06-20 07:52:28 -06:00
Tom Tromey
6b19f38ae3 Use byte_vector in remote.c:readahead_cache
This patch changes the remote.c readahead_cache to use
gdb::byte_vector.  This simplifies the code by removing manual memory
management.

Reviewed-by: John Baldwin <jhb@FreeBSD.org>
2023-06-20 07:52:28 -06:00
Tom Tromey
b68e4ea64e Use std::string in linux-osdata.c
I found some code in linux-osdata that manually managed a string.
Replacing this with std::string simplifies it.

Reviewed-by: John Baldwin <jhb@FreeBSD.org>
2023-06-20 07:52:28 -06:00
Tom Tromey
8ca8b801ed Use unique_xmalloc_ptr for mi_parse::command
This changes mi_parse::command to be a unique_xmalloc_ptr and fixes up
all the uses.  This avoids some manual memory management.  std::string
is not used here due to how the Python API works -- this approach
avoids an extra copy there.

Reviewed-by: Keith Seitz <keiths@redhat.com>
2023-06-20 06:23:30 -06:00
Tom Tromey
550194db38 Use std::string for MI token
This changes the MI "token" to be a std::string, removing some manual
memory management.  It also makes current_token 'const' in order to
support this change.

Reviewed-by: Keith Seitz <keiths@redhat.com>
2023-06-20 06:23:30 -06:00
Alan Modra
75e73c6cad Don't segfault in mips reloc special_functions
A symbol defined in a section from a shared library will have a NULL
section->output_section during linking.

	* elf32-mips.c (gprel32_with_gp): Don't segfault on NULL
	symbol->section->output_section.
	* elf64-mips.c (mips_elf64_gprel32_reloc): Likewise.
	* elfn32-mips.c (mips_elf_gprel16_reloc): Likewise.
	(mips_elf_literal_reloc, mips_elf_gprel32_reloc): Likewise.
	(gprel32_with_gp, mips16_gprel_reloc): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_gprel16_with_gp): Likewise.
	(_bfd_mips_elf_generic_reloc): Likewise.
2023-06-20 10:01:50 +09:30
GDB Administrator
a89e364b45 Automatic date update in version.in 2023-06-20 00:00:13 +00:00
Tom de Vries
e11a2ebb8e Revert "[gdb/testsuite] Clean standard_output_file dir in gdb_init"
This reverts commit b7b77500dc.
2023-06-19 19:09:58 +02:00
Simon Farre
d32d7e918d Fixes 28ab59607e
Python formatting errors fixed, introduced by this commit.
2023-06-19 17:13:05 +02:00
Simon Farre
ce65796b17 Fixes f1a614dc8f
Fixes failure reported by buildbot regarding ill-formatted Python code.
2023-06-19 17:06:05 +02:00
Simon Farre
28ab59607e gdb/Python: Added ThreadExitedEvent
v6:
Fix comments.
Fix copyright
Remove unnecessary test suite stuff. save_var had to stay, as it mutates
some test suite state that otherwise fails.

v5:
Did what Tom Tromey requested in v4; which can be found here: https://pi.simark.ca/gdb-patches/87pmjm0xar.fsf@tromey.com/

v4:
Doc formatting fixed.

v3:
Eli:
Updated docs & NEWS to reflect new changes. Added
a reference from the .ptid attribute of the ThreadExitedEvent
to the ptid attribute of InferiorThread. To do this,
I've added an anchor to that attribute.

Tom:
Tom requested that I should probably just emit the thread object;
I ran into two issues for this, which I could not resolve in this patch;

1 - The Thread Object (the python type) checks it's own validity
by doing a comparison of it's `thread_info* thread` to nullptr. This
means that any access of it's attributes may (probably, since we are
in "async" land) throw Python exceptions because the thread has been
removed from the thread object. Therefore I've decided in v3 of this
patch to just emit most of the same fields that gdb.InferiorThread has, namely
global_num, name, num and ptid (the 3-attribute tuple provided by
gdb.InferiorThread.ptid).

2 - A python user can hold a global reference to an exiting thread. Thus
in order to have a ThreadExit event that can provide attribute access
reliably (both as a global reference, but also inside the thread exit
handler, as we can never guarantee that it's executed _before_ the
thread_info pointer is removed from the gdbpy thread object),
the `thread_info *` thread pointer must not be null. However, this
comes at the cost of gdb.InferiorThread believing it is "valid" - which means,
that if a user holds takes a global reference to that
exiting event thread object, they can some time later do `t.switch()` at which
point GDB will 'explode' so to speak.

v2:
Fixed white space issues and NULL/nullptr stuff,
as requested by Tom Tromey.

v1:
Currently no event is emitted for a thread exit.

This adds this functionality by emitting a new gdb.ThreadExitedEvent.

It currently provides four attributes:
- global_num: The GDB assigned global thread number
- num: the per-inferior thread number
- name: name of the thread or none if not set
- ptid: the PTID of the thread, a 3-attribute tuple, identical to
InferiorThread.ptid attribute

Added info to docs & the NEWS file as well.

Added test to test suite.

Fixed formatting.

Feedback wanted and appreciated.
2023-06-19 16:17:21 +02:00
Simon Farre
f1a614dc8f gdb/dap - Getting thread names
Renamed thread_name according to convention (_ first)

When testing firefox tests, it is apparent that
_get_threads returns threads with name field = None.

I had initially thought that this was due to Firefox setting the names
using /proc/pid/task/tid/comm, by writing directly to the proc fs the
names, but apparently GDB seems to catch this, because I re-wrote
the basic-dap.exp/c to do this specifically and it saw the changes.

So I couldn't determine right now, what operation of name change that
GDB does not pick up, but with this patch, GDB will pick up the thread
names for an applications that set the name of a thread in ways that
aren't obvious.
2023-06-19 16:08:45 +02:00
Nick Clifton
74d39f70cd Fix illegal memory access implementing relocs in a fuzzed x86_64 object file.
PR 30560
  * elf64-x86-64.c (elf_x86_64_relocate_section): Add more checks for a valid relocation offset.
2023-06-19 12:09:11 +01:00
Tom de Vries
319626ca73 [gdb/testsuite] Add shared_gnat_runtime_has_debug_info
Test-case gdb.ada/catch_ex_std.exp passes for me with package
libada7-debuginfo installed, but after removing it I get:
...
(gdb) catch exception some_kind_of_error^M
Your Ada runtime appears to be missing some debugging information.^M
Cannot insert Ada exception catchpoint in this configuration.^M
(gdb) FAIL: gdb.ada/catch_ex_std.exp: catch exception some_kind_of_error
...

The test-case contains a require gnat_runtime_has_debug_info to deal with
this, but the problem is that this checks the static gnat runtime, while this
test-case uses the shared one.

Fix this by introducing shared_gnat_runtime_has_debug_info, and requiring that
one instead.

Tested on x86_64-linux.

PR testsuite/30094
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30094
2023-06-19 11:47:29 +02:00
Tom de Vries
ba769bb0e6 [gdb/tui] Simplify tui_update_variables
Simplify tui_update_variables by using template function
assign_return_if_changed.

Tested on x86_64-linux.
2023-06-19 11:15:56 +02:00
Tom de Vries
2e12e79882 [gdb] Add template functions assign_return/set_if_changed
Add template functions assign_return_if_changed and assign_set_if_changed in
gdb/utils.h:
...
template<typename T> void assign_set_if_changed (T &lval, const T &val, bool &changed)
{ ... }
template<typename T> bool assign_return_if_changed (T &lval, const T &val)
{ ... }
...

This allows us to rewrite code like this:
...
  if (tui_border_attrs != entry->value)
    {
      tui_border_attrs = entry->value;
      need_redraw = true;
    }
...
into this:
...
  need_redraw |= assign_return_if_changed<int> (tui_border_attrs, entry->value);
...
or:
...
  assign_set_if_changed<int> (tui_border_attrs, entry->value, need_redraw);
...

The names are a composition of the functionality.  The functions:
- assign VAL to LVAL, and either
- return true if the assignment changed LVAL, or
- set CHANGED to true if the assignment changed LVAL.

Tested on x86_64-linux.
2023-06-19 11:15:56 +02:00
Andreas Schwab
71a75b51a6 riscv: Use run-time endianess for floating point literals
gas/
	PR binutils/30551
	* config/tc-riscv.c (md_atof): Use target_big_endian instead of
	TARGET_BYTES_BIG_ENDIAN.
	* testsuite/gas/riscv/float-be.d: New file.
	* testsuite/gas/riscv/float-le.d: New file.
	* testsuite/gas/riscv/float.s: New file.
2023-06-19 09:15:14 +02:00
GDB Administrator
39f02ae4ad Automatic date update in version.in 2023-06-19 00:00:12 +00:00
Tom de Vries
b7b77500dc [gdb/testsuite] Clean standard_output_file dir in gdb_init
In commit e2adba909e ("[gdb/testsuite] Clean up before compilation in
gdb.ada/call-no-debug.exp") I added some code in the test-case to remove some
files at the start of the test-case:
...
remote_file host delete [standard_output_file prog.o]
remote_file host delete [standard_output_file prog.ali]
...

Replace this with cleaning up the entire directory instead, for all
test-cases.

Tested on x86_64-linux.

Suggested-By: Tom Tromey <tom@tromey.com>
Reviewed-By: Tom Tromey <tom@tromey.com>
2023-06-18 11:05:31 +02:00
GDB Administrator
2156c51d71 Automatic date update in version.in 2023-06-18 00:00:07 +00:00
Tom de Vries
34a6dcd442 [gdb/testsuite] Remove f-string in gdb.python/py-unwind.py
on openSUSE Leap 42.3, with python 3.4, I run into a
"SyntaxError: invalid syntax" due to usage of an f-string in test-case
gdb.python/py-unwind.py.

Fix this by using string concatenation using '+' instead.

Tested on x86_64-linux.
2023-06-17 12:28:58 +02:00
Tom de Vries
90cce6c055 [gdb/testsuite] Add nopie in a few test-cases
When running test-case gdb.arch/i386-disp-step.exp with target board
unix/-m32/-fPIE/-pie we run into:
...
gdb compile failed, ld: i386-disp-step0.o: warning: relocation in read-only section `.text'
ld: warning: creating DT_TEXTREL in a PIE
...

Fix this by adding nopie in the compilation flags.

Likewise in a few other test-cases.

Tested on x86_64-linux.
2023-06-17 12:28:58 +02:00
Tom de Vries
09ea7c9c49 [gdb/testsuite] Use require in gdb.dwarf2/implptr.exp
In test-case gdb.dwarf2/implptr.exp I noticed:
...
} elseif {![is_x86_like_target]} {
    # This test can only be run on x86 targets.
    unsupported "needs x86-like target"
    return 0
}
...

Use instead "require is_x86_like_target".

Tested on x86_64-linux.
2023-06-17 12:28:58 +02:00
GDB Administrator
6a4058a606 Automatic date update in version.in 2023-06-17 00:00:11 +00:00
Tom de Vries
e2adba909e [gdb/testsuite] Clean up before compilation in gdb.ada/call-no-debug.exp
Running test-case gdb.ada/call-no-debug.exp with target board unix/-m64 works
fine, but if we run it again with target board unix-m32, we run into:
...
gnatlink prog.ali -m32 -g -o prog^M
ld: i386:x86-64 architecture of input file `b~prog.o' is incompatible with \
  i386 output^M
...

This is due to compiling with no-force.

The test-case:
- first compiles pck.adb into pck.o (without debug info), and
- then compiles prog.adb and pck.o into prog (with debug info).

Using no-force in the second compilation make sure that pck.adb is not
compiled again, with debug info.

But it also means it will pick up intermediate files related to prog.adb from
a previous compilation.

Fix this by removing prog.o and prog.ali before compilation.

Tested on x86_64-linux.
2023-06-16 13:32:43 +02:00
Tom de Vries
9fb3860866 [gdb/testsuite] Use %progbits in gdb.arch/thumb*.S
In commit 0f2cd53cf4 ("[gdb/testsuite] Handle missing .note.GNU-stack") I
updated a gdb.arch/arm*.S test-case to use %progbits rather than @progbits,
but failed to do so for gdb.arch/thumb*.S.  Fix this oversight.

Tested on arm-linux-gnueabihf.
2023-06-16 12:56:32 +02:00
mengqinggang
d2fddb6d78 LoongArch: Fix ld "undefined reference" error with --enable-shared
Because _bfd_read_unsigned_leb128 is hidden visibility, so it can't
  be referenced out of shared object.

  The new function loongarch_get_uleb128_length just used to call
  _bfd_read_unsigned_leb128.

bfd/ChangeLog:

	* elfxx-loongarch.c (loongarch_get_uleb128_length): New function.
	* elfxx-loongarch.h (loongarch_get_uleb128_length): New function.

gas/ChangeLog:

	* config/tc-loongarch.c (md_apply_fix): Use
	loongarch_get_uleb128_length.
2023-06-16 17:32:02 +08:00
Andrew Burgess
8203d5e72e gdb: update IRC reference from Freenode to Libera.Chat
It's been some time since the switch from Freenode to Libera.Chat,
however, there's still a reference to Freenode in the 'gdb --help'
output.  Lets update that.
2023-06-16 10:17:40 +01:00
Jan Beulich
b1c7925686 x86: shrink Masking insn attribute to a single bit (boolean)
The logic can actually be expressed with less code that way, utilizing
that there are common patterns of when which form of masking is
permitted. This then also eliminates the large set of open-codings of
BOTH_MASKING in the opcode table.
2023-06-16 09:23:26 +02:00
Alan Modra
2a4da07308 Correct ld-elf/eh5 test for hppa64
Commit 3c0afdb789 regressed this test for hppa64, because the test
had been enabled for hppa64 in the time between the mips changes and
their reversion.  This patch isn't just a simple reapply, I recreated
the testsuite change by hand for hppa64: Two lines in eh5.d might need
further changes for mips.
2023-06-16 12:46:49 +09:30
GDB Administrator
fb0894b2b3 Automatic date update in version.in 2023-06-16 00:00:08 +00:00
Maciej W. Rozycki
9012d7819c binutils/NEWS: Mention Sony Allegrex MIPS CPU support
Mention the addition of Sony Allegrex processor support to the MIPS port.

	binutils/
	* NEWS: Mention Sony Allegrex MIPS CPU support.
2023-06-15 15:17:38 +01:00
Maciej W. Rozycki
2b462da34d MIPS/GAS/testsuite: Fix -modd-spreg'/-mno-odd-spreg' test invocations
Reformat `-modd-spreg'/`-mno-odd-spreg' test invocations in mips.exp to
fit in 79 columns

	gas/
	* testsuite/gas/mips/mips.exp: Reformat
	`-modd-spreg'/`-mno-odd-spreg' test invocations.
2023-06-15 04:45:03 +01:00
David Guillen Fandos
a0176d8d12 Add additional missing Allegrex CPU instructions
Allegrex supports some MIPS32 and MIPS32r2 instructions (albeit with
some encoding differences) such as bit manipulation (ins/ext) and MLA
(madd/msub).  It also features some new instructions like wsbw and
min/max or device-specific ones such as mfic.

Signed-off-by: David Guillen Fandos <david@davidgf.net>
2023-06-15 04:45:03 +01:00
David Guillen Fandos
d29b94fc9f Add rotation instructions to MIPS Allegrex CPU
The Allegrex CPU supports bit rotation instructions as described in the
MIPS32 release 2 CPU (even though it is a MIPS-2 based CPU).

Signed-off-by: David Guillen Fandos <david@davidgf.net>
2023-06-15 04:45:03 +01:00
David Guillen Fandos
df18f71b56 Add MIPS Allegrex CPU as a MIPS2-based CPU
The Allegrex CPU was created by Sony Interactive Entertainment to power
their portable console, the PlayStation Portable.
The pspdev organization maintains all sorts of tools to create software
for said device including documentation.

Signed-off-by: David Guillen Fandos <david@davidgf.net>
2023-06-15 04:45:03 +01:00
Maciej W. Rozycki
011365baca GAS/doc: Correct Tag_GNU_MIPS_ABI_MSA attribute description
Rewrite the paragraph to match the style of Tag_GNU_MIPS_ABI_FP text
immediately above, correcting grammar and formatting at the same time.

	gas/
	* doc/as.texi (MIPS Attributes): Correct Tag_GNU_MIPS_ABI_MSA
	attribute description.
2023-06-15 04:45:03 +01:00
Maciej W. Rozycki
dbec9420c9 Revert "MIPS: gas: alter 64 or 32 for mipsisa triples if march is implicit"
This reverts commit 094025a30b.  It was
applied unapproved.
2023-06-15 04:45:03 +01:00
Maciej W. Rozycki
dbad690493 Revert "MIPS: default r6 if vendor is img"
This reverts commit be0d391f22.  It was
applied unapproved.
2023-06-15 04:45:03 +01:00
Maciej W. Rozycki
13527d85af Revert "MIPS: fix r6 testsuites"
This reverts commit ffc528aed5.  It was
applied unapproved.
2023-06-15 04:45:03 +01:00
Maciej W. Rozycki
3c0afdb789 Revert "MIPS: fix -gnuabi64 testsuite"
This reverts commit cb81e84c72.  It was
applied unapproved.
2023-06-15 04:45:03 +01:00
Maciej W. Rozycki
0b46c1ec2d Revert "MIPS: fix some ld testcases with compiler"
This reverts commit a0631c1501.  It was
applied unapproved.
2023-06-15 04:45:03 +01:00
Maciej W. Rozycki
0c5c669cef Revert "MIPS: add MT ASE support for micromips32"
This reverts commit acce83dacf.  It was
applied unapproved.
2023-06-15 04:45:03 +01:00
Maciej W. Rozycki
9cfee3962c Revert "MIPS: sync oprand char usage between mips and micromips"
This reverts commit 5b207b9194.  It was
applied unapproved.
2023-06-15 04:45:03 +01:00
Alan Modra
0749c73cf8 Re: Add some expected failures for bfin linker tests
After commit 7ade0f1582 I was seeing bfin-elf +XPASS: weak symbols,
and on looking into the bfin targets a little, discovered we have two
bfin-linux targets.  One, bfin-uclinux, is like bfin-elf in that
ld -m elf32bfin is the default, and the other, bfin-linux-uclibc where
ld -m elf32bfinfd is the default.  So putting bfin-*-*linux* in test
xfails or elsewhere is wrong.  We want bfin-*-linux* instead to just
select the fdpic bfin target.

This patch corrects wrong bfin target triples in the ld testsuite,
not just the recent change but others I'd added to xfails too.
It also fixes the bfin-linux-uclibc ld-elf/64ksec fail
2023-06-15 11:45:03 +09:30
Alan Modra
6a28a3c200 vms write_archive memory leaks
This fixes two memory leaks in the vms archive handling.

	* vms-lib.c (_bfd_vms_lib_build_map): Free input symbols.
	(_bfd_vms_lib_write_archive_contents): Free archive map symbols.
2023-06-15 10:11:56 +09:30