Commit Graph

110473 Commits

Author SHA1 Message Date
Andrew Burgess
08b326ee0a gdb/testsuite: make 'c' default language for get/test compiler info
This commit is a minor cleanup for the two functions (in gdb.exp)
get_compiler_info and test_compiler_info.

Instead of using the empty string as the default language, and just
"knowing" that this means the C language.  Make this explicit.  The
language argument now defaults to "c" if not specified, and the if
chain in get_compiler_info that checks the language not explicitly
handles "c" and gives an error for unknown languages.

This is a good thing, now that the API appears to take a language, if
somebody does:

  test_compiler_info "xxxx" "rust"

to check the version of the rust compiler then we will now give an
error rather than just using the C compiler and leaving the user
having to figure out why they are not getting the results they
expect.

After a little grepping, I think the only place we were explicitly
passing the empty string to either get_compiler_info or
test_compiler_info was in gdb_compile_shlib_1, this is now changed to
pass "c" as the default language.

There should be no changes to the test results after this commit.
2022-06-09 14:40:48 +01:00
Andrew Burgess
1562f64fec gdb/testsuite: remove get_compiler_info calls from gdb.exp and dwarf.exp
We don't need to call get_compiler_info before calling
test_compiler_info; test_compiler_info includes a call to
get_compiler_info.

This commit cleans up lib/gdb.exp and lib/dwarf.exp a little by
removing some unneeded calls to get_compiler_info.  We could do the
same cleanup throughout the testsuite, but I'm leaving that for
another day.

There should be no change in the test results after this commit.
2022-06-09 14:40:48 +01:00
Nils-Christian Kempke
61ee7510b3 gdb/testsuite: use test_compiler_info in gcc_major_version
The procedure gcc_major_version was earlier using the global variable
compiler_info to retrieve gcc's major version.  This is discouraged and
(as can be read in a comment in compiler.c) compiler_info should be
local to get_compiler_info and test_compiler_info.

The preferred way of getting the compiler string is via calling
test_compiler_info without arguments.  Gcc_major_version was changed to
do that.
2022-06-09 14:40:48 +01:00
Yvan Roux
8f4141b0ae gdb: add Yvan Roux to gdb/MAINTAINERS 2022-06-09 14:54:28 +02:00
Andrew Burgess
b1054b67df gdb/testsuite: resolve duplicate test names in gdb.threads/tls.exp
While running the gdb.threads/tls.exp test with a GDB configured
without Python, I noticed some duplicate test names.

This is caused by a call to skip_python_tests that is within a proc
that is called multiple times by the test script.  Each call to
skip_python_tests results in a call to 'unsupported', and this causes
the duplicate test names.

After this commit we now call skip_python_tests just once and place
the result into a variable.  Now, instead of calling skip_python_tests
multiple times, we just check the variable.

There should be no change in what is tested after this commit.
2022-06-09 13:40:07 +01:00
Andrew Burgess
417d2514ef gdb/testsuite: resolve duplicate test name in gnu_vector.exp
While testing on AArch64 I spotted a duplicate test name in the
gdb.base/gnu_vector.exp test.

This commit adds a 'with_test_prefix' to resolve the duplicate.

While I was in the area I updated a 'gdb_test_multiple' call to make
use of $gdb_test_name.

There should be no change in what is tested after this commit.
2022-06-09 13:34:57 +01:00
GDB Administrator
d21691eaa7 Automatic date update in version.in 2022-06-09 00:00:17 +00:00
Andrew Burgess
42d77edce1 gdb: make throw_perror_with_name static
The throw_perror_with_name function is not used outside of utils.c
right now.  And as perror_with_name is just a wrapper around
throw_perror_with_name, then any future calls would be to
perror_with_name.

Lets make throw_perror_with_name static.

There should be no user visible changes after this commit.
2022-06-08 20:04:33 +01:00
Andrew Burgess
deb70aa032 gdb: remove trailing '.' from perror_with_name calls
I ran into this error while working on AArch64 GDB:

  Unable to fetch VFP registers.: Invalid argument.

Notice the '.:' in the middle of this error message.

This is because of this call in aarch64-linux-nat.c:

  perror_with_name (_("Unable to fetch VFP registers."));

The perror_with_name function take a string, and adds ': <message>' to
the end the string, so I don't think the string that we pass to
perror_with_name should end in '.'.

This commit removes all of the trailing '.' characters from
perror_with_name calls, which give more readable error messages.

I don't believe that any of these errors are tested in the
testsuite (after a little grepping).
2022-06-08 20:04:33 +01:00
Tom Tromey
5ca5b31d63 Move CU queue to dwarf2_per_objfile
The CU queue is a member of dwarf2_per_bfd, but it is only used when
expanding CUs.  Also, the dwarf2_per_objfile destructor checks the
queue -- however, if the per-BFD object is destroyed first, this will
not work.  This was pointed out Lancelot as fallout from the patch to
rewrite the registry system.

This patch avoids this problem by moving the queue to the per-objfile
object.
2022-06-08 11:04:12 -06:00
Tom Tromey
d09ee622ee Change allocation of m_dwarf2_cus
m_dwarf2_cus manually manages the 'dwarf2_cu' pointers it owns.  This
patch simplifies the code by changing it to use unique_ptr.
2022-06-08 11:04:12 -06:00
Andrew Burgess
2c3b9a9130 libopcodes: extend the styling within the i386 disassembler
The i386 disassembler is pretty complex.  Most disassembly is done
indirectly; operands are built into buffers within a struct instr_info
instance, before finally being printed later in the disassembly
process.

Sometimes the operand buffers are built in a different order to the
order in which they will eventually be printed.

Each operand can contain multiple components, e.g. multiple registers,
immediates, other textual elements (commas, brackets, etc).

When looking for how to apply styling I guess the ideal solution would
be to move away from the operands being a single string that is built
up, and instead have each operand be a list of "parts", where each
part is some text and a style.  Then, when we eventually print the
operand we would loop over the parts and print each part with the
correct style.

But it feels like a huge amount of work to move from where we are
now to that potentially ideal solution.  Plus, the above solution
would be pretty complex.

So, instead I propose a .... different solution here, one that works
with the existing infrastructure.

As each operand is built up, piece be piece, we pass through style
information.  This style information is then encoded into the operand
buffer (see below for details).  After this the code can continue to
operate as it does right now in order to manage the set of operand
buffers.

Then, as each operand is printed we can split the operand buffer into
chunks at the style marker boundaries, with each chunk being printed
with the correct style.

For encoding the style information I use a single character, currently
\002, followed by the style encoded as a single hex digit, followed
again by the \002 character.

This of course relies on there not being more than 16 styles, but that
is currently true, and hopefully will remain true for the foreseeable
future.

The other major concern that has arisen around this work is whether
the escape character could ever be encountered in output naturally
generated by the disassembler.  If this did happen then the escape
characters would be stripped from the output, and the wrong styling
would be applied.

However, I don't believe that this is currently a problem.
Disassembler content comes from a number of sources.  First there's
content that copied directly from the i386-dis.c file, this is things
like register names, and other syntax elements (brackets, commas,
etc).  We can easily check that the i386-dis.c file doesn't contain
our special character.

The next source of content are immediate operands.  The text for these
operands is generated by calls into libc.  By selecting a
non-printable character we can be confident that this is not something
that libc will generate as part of an immediate representation.

The other output that appears to be from the disassembler is operands
that contain addresses and (possibly) symbol names.  It is quite
possible that a symbol name might contain any special character we
could imagine, so is this a problem?

I don't think it is, we don't actually print address and symbol
operands through the disassembler, instead, the disassembler calls
back to the user (objdump, gdb, etc) to print the address and symbol
on its behalf.  This content is printed directly to the output stream,
it does not pass through the i386 disassembler output buffers.  As a
result, we never check this particular output for styling escape
characters.

In some (not very scientific) benchmarking on my machine,
disassembling a reasonably large (142M) shared library, I'm not seeing
any significant slow down in disassembler speed with this change.

Most instructions are now being fully syntax highlighted when I
disassemble using the --disassembler-color=extended-color option.  I'm
sure that there are probably still a few corner cases that need fixing
up, but we can come back to them later I think.

When disassembler syntax highlighting is not being used, then there
should be no user visible changes after this commit.
2022-06-08 16:38:38 +01:00
Carl Love
cb50b0722c Fix gdb.arch/powerpc-power7.exp isel disassembly output.
The following commit changes the output format for the isel instruction on
PowerPC.

   commit dd4832bf3e     Introduces error in test
   Author: Dmitry Selyutin <ghostmansd@gmail.com>
   Date:   Tue May 24 13:46:35 2022 +0000

       opcodes: introduce BC field; fix isel

       Per Power ISA Version 3.1B 3.3.12, isel uses BC field rather than CRB
       field present in binutils sources. Also, per 1.6.2, BC has the same
       semantics as BA and BB fields, so this should keep the same flags and
       mask, only with the different offset.

       opcodes/
               * ppc-opc.c
               (BC): Define new field, with the same definition as CRB field,
               but with the PPC_OPERAND_CR_BIT flag present.
       gas/
               * testsuite/gas/ppc/476.d: Update.
               * testsuite/gas/ppc/a2.d: Update.
               * testsuite/gas/ppc/e500.d: Update.
               * testsuite/gas/ppc/power7.d: Update.
  <snip>
   --- a/gas/testsuite/gas/ppc/476.d
   +++ b/gas/testsuite/gas/ppc/476.d
   @@ -209,7 +209,7 @@ Disassembly of section \.text:
    .*:    (7c 20 07 8c|8c 07 20 7c)       ici     1
    .*:    (7c 03 27 cc|cc 27 03 7c)       icread  r3,r4
    .*:    (50 83 65 36|36 65 83 50)       rlwimi  r3,r4,12,20,27
    -.*:    (7c 43 27 1e|1e 27 43 7c)       isel    r2,r3,r4,28
    +.*:    (7c 43 27 1e|1e 27 43 7c)       isel    r2,r3,r4,4\*cr7\+lt

The above change breaks the gdb regression test gdb.arch/powerpc-power7.exp
on Power 7, Power 8, Power 9 and Power 10.

This patch updates the regression test gdb.arch/powerpc-power7.exp with
the new expected output for the isel instruction.

The patch has been tested on Power 7 and Power 10 to verify the patch fixes
the test.
2022-06-08 14:55:31 +00:00
Pedro Alves
bc2220c89d aarch64: Add fallback if ARM_CC_FOR_TARGET not set
On Aarch64, you can set ARM_CC_FOR_TARGET to point to the 32-bit
compiler to use when testing gdb.multi/multi-arch.exp and
gdb.multi/multi-arch-exec.exp.  If you don't set it, then those
testcases don't run.

I guess that approximately nobody remembers to set ARM_CC_FOR_TARGET.

This commit adds a fallback.  If ARM_CC_FOR_TARGET is not set, and
testing for Linux, try arm-linux-gnueabi-gcc,
arm-none-linux-gnueabi-gcc, arm-linux-gnueabihf-gcc as 32-bit
compilers, making sure that the produced executable runs on the target
machine before claiming that the compiler produces useful executables.

Change-Id: Iefe5865d5fc84b4032eaff7f4c5c61582bf75c39
2022-06-08 14:06:38 +01:00
Alan Modra
57698478b7 Don't encode reloc.size
I expect the encoded reloc.size field originally came from aout
r_length ecoding, but somehow went wrong for 64-bit relocs (which
should have been encoded as 3).  Toss all that out, just use a byte
size instead.  The changes outside of reloc.c in this patch should
make the code independent of how reloc.size is encoded.

	* reloc.c (struct reloc_howto_struct): Increase size field by
	one bit.  Comment.
	(HOWTO_RSIZE): Don't encode size.
	(bfd_get_reloc_size): Adjust, and make it an inline function.
	(read_reloc, write_reloc): Adjust.
	* bfd-in2.h: Regenerate.
	* aout-ns32k.c: Include libbfd.h.
	(put_reloc): Don't use howto->size directly.  Calculate r_length
	using bfd_log2 and bfd_get_reloc_size.
	* aoutx.h (swap_std_reloc_out): Likewise.
	(aout_link_reloc_link_order): Likewise.
	* i386lynx.c (swap_std_reloc_out
	* mach-o-i386.c (bfd_mach_o_i386_swap_reloc_out
	* pdp11.c (aout_link_reloc_link_order
	* coff-arm.c (coff_arm_reloc): Don't use howto->size directly,
	use bfd_get_reloc_size instead and adjust switch cases.
	* coff-i386.c (coff_i386_reloc): Similarly.
	* coff-x86_64.c (coff_amd64_reloc): Likewise.
	* cpu-ns32k.c (do_ns32k_reloc): Likewise.
	* elf32-arc.c (arc_do_relocation): Likewise.
	* elf32-arm.c (elf32_arm_final_link_relocate): Likewise.
	* elf32-bfin.c (bfin_bfd_reloc): Likewise.
	* elf32-cr16.c (cr16_elf_final_link_relocate): Likewise.
	* elf32-cris.c (cris_elf_pcrel_reloc): Likewise.
	* elf32-crx.c (crx_elf_final_link_relocate): Likewise.
	* elf32-csky.c (csky_elf_relocate_section): Likewise.
	* elf32-d10v.c (extract_rel_addend, insert_rel_addend): Likewise.
	* elf32-i386.c (elf_i386_relocate_section): Likewise.
	* elf32-m32r.c (m32r_elf_generic_reloc): Likewise.
	* elf32-nds32.c (nds32_elf_generic_reloc): Likewise.
	* syms.c (_bfd_stab_section_find_nearest_line): Likewise.
	* coff-rs6000.c (xcoff_ppc_relocate_section): Adjust howto.size.
	* coff64-rs6000.c (xcoff64_ppc_relocate_section): Likewise.
2022-06-08 21:33:00 +09:30
Alan Modra
5d2834cc7e bfin reloc offset checks
These all ought to use bfd_reloc_offset_in_range.  In particular, replace
the check using howto->size + 1u.

	* elf32-bfin.c (bfin_pcrel24_reloc): Use bfd_reloc_offset_in_range.
	(bfin_imm16_reloc, bfin_byte4_reloc, bfin_bfd_reloc),
	(bfin_final_link_relocate): Likewise.
2022-06-08 21:33:00 +09:30
Alan Modra
5d0feb989c Revert reloc howto nits
The "HOWTO size encoding" patch put 1 as the HOWTO size arg for
numerous howtos that are unused, describe dynamic relocs, are markers,
or otherwise are special purpose reloc howtos that don't care about
the size.  The idea was to ensure no howto changed by inspecting
object files.  Revert those changes, making them zero size.

	* coff-alpha.c: Give special purpose reloc howtos a size of zero.
	* coff-mcore.c, * elf-hppa.h, * elf-m10300.c, * elf32-arm.c,
	* elf32-csky.c, * elf32-m32c.c, * elf32-m68k.c, * elf32-mep.c,
	* elf32-mips.c, * elf32-ppc.c, * elf32-rx.c, * elf32-s390.c,
	* elf32-spu.c, * elf32-tic6x.c, * elf32-tilepro.c, *elf32-vax.c,
	* elf32-xtensa.c, * elf64-alpha.c, * elf64-mips.c,
	* elf64-mmix.c, * elf64-ppc.c, * elf64-s390.c, * elfn32-mips.c,
	* elfxx-loongarch.c, * elfxx-riscv.c, * elfxx-sparc.c,
	* elfxx-tilegx.c, * som.c, * vms-alpha.c: Likewise.
2022-06-08 21:33:00 +09:30
Alan Modra
c94cb02662 HOWTO size encoding
This changes the HOWTO macro to encode the howto.size field from a
value given in bytes.  This of course requires editing all target
uses of HOWTO, a major pain, but makes it a little nicer to specify
new target HOWTOs.  Object files before/after this patch are
unchanged in .data and .rodata.

bfd/
	* reloc.c (HOWTO_RSIZE): Encode size in bytes.
	(EMPTY_HOWTO): Adjust to keep it all zero.
	* aout-ns32k.c, * aoutx.h, * coff-alpha.c, * coff-arm.c,
	* coff-i386.c, * coff-mcore.c, * coff-mips.c, * coff-rs6000.c,
	* coff-sh.c, * coff-tic30.c, * coff-tic4x.c, * coff-tic54x.c,
	* coff-x86_64.c, * coff-z80.c, * coff-z8k.c, * coff64-rs6000.c,
	* elf-hppa.h, * elf-m10200.c, * elf-m10300.c, * elf32-arc.c,
	* elf32-arm.c, * elf32-avr.c, * elf32-bfin.c, * elf32-cr16.c,
	* elf32-cris.c, * elf32-crx.c, * elf32-csky.c, * elf32-d10v.c,
	* elf32-d30v.c, * elf32-dlx.c, * elf32-epiphany.c,
	* elf32-fr30.c, * elf32-frv.c, * elf32-ft32.c, * elf32-gen.c,
	* elf32-h8300.c, * elf32-i386.c, * elf32-ip2k.c, * elf32-iq2000.c,
	* elf32-lm32.c, * elf32-m32c.c, * elf32-m32r.c, * elf32-m68hc11.c,
	* elf32-m68hc12.c, * elf32-m68k.c, * elf32-mcore.c, * elf32-mep.c,
	* elf32-metag.c, * elf32-microblaze.c, * elf32-mips.c,
	* elf32-moxie.c, * elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c,
	* elf32-nios2.c, * elf32-or1k.c, * elf32-pj.c, * elf32-ppc.c,
	* elf32-pru.c, * elf32-rl78.c, * elf32-rx.c, * elf32-s12z.c,
	* elf32-s390.c, * elf32-score.c, * elf32-score7.c,
	* elf32-sh-relocs.h, * elf32-spu.c, * elf32-tic6x.c,
	* elf32-tilepro.c, * elf32-v850.c, * elf32-vax.c,
	* elf32-visium.c, * elf32-wasm32.c, * elf32-xc16x.c,
	* elf32-xgate.c, * elf32-xstormy16.c, * elf32-xtensa.c,
	* elf32-z80.c, * elf64-alpha.c, * elf64-bpf.c, * elf64-gen.c,
	* elf64-mips.c, * elf64-mmix.c, * elf64-nfp.c, * elf64-ppc.c,
	* elf64-s390.c, * elf64-x86-64.c, * elfn32-mips.c,
	* elfnn-aarch64.c, * elfxx-ia64.c, * elfxx-loongarch.c,
	* elfxx-mips.c, * elfxx-riscv.c, * elfxx-sparc.c,
	* elfxx-tilegx.c, * mach-o-aarch64.c, * mach-o-arm.c,
	* mach-o-i386.c, * mach-o-x86-64.c, * pdp11.c, * reloc.c,
	* som.c, * vms-alpha.c: Adjust all uses of HOWTO.
	* bfd-in2.h: Regenerate.
include/
	* elf/arc-reloc.def: Adjust all uses of HOWTO.
2022-06-08 21:33:00 +09:30
Alan Modra
3418a349c6 HOWTO_RSIZE
Define a helper macro for HOWTO.

       * reloc.c (HOWTO_RSIZE): Define.
       (HOWTO): Use it.
       * bfd-in2.h: Regenerate.
2022-06-08 21:28:48 +09:30
Alan Modra
47be149aca elf64-nfp reloc fix
These are all dummy howtos, there is no reason one of them should
have partial_inplace true.

	* elf64-nfp.c (elf_nfp_howto_table <R_NFP_IMMED_LO16_I_B>): Don't
	set partial_inplace.
2022-06-08 16:40:01 +09:30
Alan Modra
24d34d81ea coff-z80 reloc howto fixes
Mostly cosmetic unless attempting to link coff-z80 into another output
format.

	* coff-z80.c (howto_table <R_IMM24, R_WORD0, R_WORD1>): Correct size.
	(extra_case): Use bfd_{get,put}_24 when applying R_IMM24.
2022-06-08 16:37:16 +09:30
Alan Modra
ff50916f8b NONE reloc fixes
Make them all zero size standard do-nothing howtos.

	* elf32-csky.c (csky_elf_howto_table <R_CKCORE_NONE>): Correct howto.
	* elf32-ft32.c (ft32_elf_howto_table <R_FT32_NONE>): Likewise.
	* elf32-gen.c (dummy): Likewise.
	* elf32-nds32.c (none_howto): Likewise.
	* elf32-nios2.c (elf_nios2_r2_howto_table_rel <R_NIOS2_NONE>):
	Likewise.
	* elf32-pru.c (elf_pru_howto_table_rel <R_PRU_NONE>): Likewise.
	* elf32-v850.c (v800_elf_howto_table <R_V810_NONE>): Likewise.
	* elf64-gen.c (dummy): Likewise.
	* elfn32-mips.c (elf_mips_howto_table_rela <R_MIPS_NONE): Likewise.
	* elfxx-mips.c (none_howto): Likewise.
	* reloc.c (none_howto): Likewise.
2022-06-08 16:22:28 +09:30
Alan Modra
38ef9f36cf asan: double free sb_kill
oss-fuzz hits a flaky crash with a double-free.  I think this is due
to gas static state not being reinitialised between testcases, a bug
with oss-fuzz not gas.  Anyway, this patch should avoid the problem.

	* input-scrub.c (input_scrub_push): Move init of sb_index..
	(input_scrub_reinit): ..to here.
2022-06-08 16:22:15 +09:30
GDB Administrator
bcdbf606bc Automatic date update in version.in 2022-06-08 00:00:11 +00:00
Tom Tromey
20489cca90 Use subclasses of windows_process_info
This changes windows_process_info to use virtual methods for its
callbacks, and then changes the two clients of this code to subclass
this class to implement the methods.

I considered using CRTP here, but that would require making the new
structures visible to the compilation of of nat/windows-nat.c.  This
seemed like a bit of a pain, so I didn't do it.

This change then lets us change all the per-inferior globals to be
members of the new subclass.  Note that there can still only be a
single inferior -- currently there's a single global of the new type.
This is just another step toward possibly implementing multi-inferior
for Windows.

It's possible this could be cleaned up further... ideally I'd like to
move more of the data into the base class.  However, because gdb
supports Cygwin and gdbserver does not, and because I don't have a way
to build or test Cygwin, larger refactorings are difficult.
2022-06-07 11:44:53 -06:00
Tom Tromey
5517650206 Turn some windows-nat.c static functions into methods
This patch turns some windows-nat.c static functions into methods on
windows_nat_target.  This avoids having to reference the
windows_nat_target singleton in some more spots -- a minor code
cleanup.
2022-06-07 11:44:51 -06:00
Tom Tromey
bcb9251f02 Allow ASLR to be disabled on Windows
On Windows, it is possible to disable ASLR when creating a process.
This patch adds code to do this, and hooks it up to gdb's existing
disable-randomization feature.  Because the Windows documentation
cautions that this isn't available on all versions of Windows, the
CreateProcess wrapper function is updated to make the attempt, and
then fall back to the current approach if it fails.
2022-06-07 09:59:41 -06:00
Tom Tromey
8fea1a81c7 Introduce wrapper for CreateProcess
This is a small refactoring that introduces a wrapper for the Windows
CreateProcess function.  This is done to make the next patch a bit
simpler.
2022-06-07 09:59:40 -06:00
Enze Li
265aa48b39 Update my email address in gdb/MAINTAINERS 2022-06-07 22:01:09 +08:00
Tom Tromey
6d08aed3c9 Constify solib_name_from_address
I noticed that solib_name_from_address returned a non-const string,
but it's more appropriate to return const.  This patch implements
this.  Tested by rebuilding.
2022-06-07 07:21:26 -06:00
Tom de Vries
b11f3dbb88 [gdb/rust] Add missing _() for error call
In commit 1390b65a1b ("[gdb/rust] Fix literal truncation") I forgot to add
_() around a string using in an error call.

Fix this by adding the missing _().

Tested on x86_64-linux.
2022-06-07 11:22:56 +02:00
Tom de Vries
e97198fdcd [gdb] Allow frv::fr300 in selftests
In skip_arch in gdb/selftest-arch.c we skip architecture fr300 because of
PR20946, but the PR has been fixed by commit 0ae60c3ef4 ("Prevent an abort in
the FRV disassembler if the target bfd name is unknown.") in Januari 2017.

Remove the skipping of frv::fr300.

Tested on x86_64-linux.
2022-06-07 09:59:54 +02:00
GDB Administrator
f3cdb43624 Automatic date update in version.in 2022-06-07 00:00:10 +00:00
Tom Tromey
691ade38bc Consolidate "Python API" sections in NEWS
I noticed that the gdb NEWS file had two "Python API" sections in
"Changes since GDB 12".  This patch consolidates the two.  I chose to
preserve the second one, first because it is longer, and second
because I felt that user command changes should come before API
changes.
2022-06-06 13:07:37 -06:00
Tom Tromey
a80f2680db Simplify varobj "change" logic
varobj used to store 'print_value' as a C string, where NULL was a
valid value, and so it had logic to handle this situation.  However,
at some point this was changed to be a std::string, and so the code
can be simplified in this spot.
2022-06-06 12:50:34 -06:00
Tom Tromey
c2ebdf6a7d Remove "-break-insert -r" tests
PR mi/14270 points out that mi-break.exp has some tests for an
unimplemented "-r" switch for "-break-insert".  This switch was never
implemented, and is not documented -- though it is mentioned in a
comment in the documentation.  This patch removes the test and the doc
comment.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=14270
2022-06-06 12:42:12 -06:00
Tom de Vries
38015f6710 [gdb] Name arch selftests more clearly
When running some all archs selftest I get:
...
$ gdb -q -batch -ex "maint selftest unpack_field_as_long"
Running selftest unpack_field_as_long::A6.
...

By now I know that A6 is an arc architecture, but for others that's less
clear.

Fix this by using unpack_field_as_long::arc::A6 instead.

This then introduces redundant names like arm::arm, so try to avoid those,
though I'm not entirely convinced that that's worth the trouble.

This introduces the following new names:
...
+Running selftest unpack_field_as_long::am33_2::am33-2.
+Running selftest unpack_field_as_long::arc::A6.
+Running selftest unpack_field_as_long::arc::A7.
+Running selftest unpack_field_as_long::arc::EM.
+Running selftest unpack_field_as_long::arc::HS.
+Running selftest unpack_field_as_long::arm::ep9312.
+Running selftest unpack_field_as_long::arm::iwmmxt.
+Running selftest unpack_field_as_long::arm::iwmmxt2.
+Running selftest unpack_field_as_long::arm::xscale.
+Running selftest unpack_field_as_long::bpf::xbpf.
+Running selftest unpack_field_as_long::frv::fr400.
+Running selftest unpack_field_as_long::frv::fr450.
+Running selftest unpack_field_as_long::frv::fr500.
+Running selftest unpack_field_as_long::frv::fr550.
+Running selftest unpack_field_as_long::frv::simple.
+Running selftest unpack_field_as_long::frv::tomcat.
+Running selftest unpack_field_as_long::iq2000::iq10.
+Running selftest unpack_field_as_long::m32c::m16c.
+Running selftest unpack_field_as_long::mep::c5.
+Running selftest unpack_field_as_long::mep::h1.
+Running selftest unpack_field_as_long::nds32::n1.
+Running selftest unpack_field_as_long::nds32::n1h.
+Running selftest unpack_field_as_long::nds32::n1h_v2.
+Running selftest unpack_field_as_long::nds32::n1h_v3.
+Running selftest unpack_field_as_long::nds32::n1h_v3m.
+Running selftest unpack_field_as_long::z80::ez80-adl.
+Running selftest unpack_field_as_long::z80::ez80-z80.
+Running selftest unpack_field_as_long::z80::gbz80.
+Running selftest unpack_field_as_long::z80::r800.
+Running selftest unpack_field_as_long::z80::z180.
...

Tested on x86_64-linux.
2022-06-06 19:27:46 +02:00
Tom de Vries
4ab19f4c9b [gdb] Enable some more print_one_insn selftests
In print_one_insn_test we have this cluster of skipped tests:
...
    case bfd_arch_ia64:
    case bfd_arch_mep:
    case bfd_arch_mips:
    case bfd_arch_tic6x:
    case bfd_arch_xtensa:
      return;
...

Enable some of these, and document in more detail why they're enabled or
skipped.

Likewise, document bfd_arch_or1k because it's an odd case.

Tested on x86_64-linux.
2022-06-06 19:27:46 +02:00
Tom de Vries
faec7017f0 [gdb] Fix maint selftest -v print_one_insn
When running the print_one_insn selftests with -v, I get:
...
$ gdb -q -batch -ex "maint selftest -v print_one_insn"
Running selftest print_one_insn::A6.
.shor   0x783eRunning selftest print_one_insn::A7.
trap_s  0x1Running selftest print_one_insn::ARC600.
.shor   0x783eRunning selftest print_one_insn::ARC601.
Running selftest print_one_insn::ARC700.
trap_s  0x1Running selftest print_one_insn::ARCv2.
trap_s  0x1Running selftest print_one_insn::EM.
trap_s  0x1Running selftest print_one_insn::HS.
trap_s  0x1Running selftest print_one_insn::Loongarch32.
...

The insn is written to gdb_stdout, and there is code in the selftest to add a
newline after the insn, which writes to stream().

The stream() ui_file points into a string buffer, which the disassembler uses
before writing to gdb_stdout, so writing into it after the disassembler has
finished has no effect.

Fix this by using gdb_stdlog and debug_printf (which is what the unit test
infrastructure itself uses) instead, such that we have:
...
Running selftest print_one_insn::A6.
.shor   0x783e
Running selftest print_one_insn::A7.
trap_s  0x1
Running selftest print_one_insn::ARC600.
.shor   0x783e
Running selftest print_one_insn::ARC601.
Running selftest print_one_insn::ARC700.
trap_s  0x1
Running selftest print_one_insn::ARCv2.
trap_s  0x1
Running selftest print_one_insn::Loongarch32.
...

Note: I've also removed the printing of arch_name, which would give
us otherwise the redundant:
...
Running selftest print_one_insn::A6.
arc .shor       0x783e
Running selftest print_one_insn::A7.
arc trap_s      0x1
...

Tested on x86_64-linux.
2022-06-06 19:27:46 +02:00
Andrew Burgess
772f4c2e98 gdb/testsuite: add missing skip_python_tests call in py-doc-reformat.exp
In commit:

  commit 51e8dbe1fb
  Date:   Mon May 16 19:26:54 2022 +0100

      gdb/python: improve formatting of help text for user defined commands

the test that was added (gdb.python/py-doc-reformat.exp) was missing a
call to skip_python_tests.  As a result, this test would fail for any
GDB built within Python support.

This commit adds a call to skip_python_tests.
2022-06-06 12:34:24 +01:00
GDB Administrator
fdb5b467f9 Automatic date update in version.in 2022-06-06 00:00:10 +00:00
Tom Tromey
ca9aae53bd Remove obsolete Python 2 comment
I found a comment that referred to Python 2, but that is now obsolete
-- the code it refers to is gone.  I'm checking in this patch to
remove the comment.

There's a similar comment elsewhere, but I plan to remove that one in
another patch I'm going to submit shortly.
2022-06-05 10:11:37 -06:00
GDB Administrator
c8eab1d7c9 Automatic date update in version.in 2022-06-05 00:00:14 +00:00
Alan Modra
3ae76967be asan: null dereference in coff_count_linenumbers
* coffgen.c (coff_count_linenumbers): Don't segfault when asymbol
	the_bfd is NULL.
2022-06-04 20:57:36 +09:30
Alan Modra
21aacea42e asan: uninitialised write in bfd_mach_o_write_contents
* mach-o.c (bfd_mach_o_write_contents): Always set
	bfd_mach_o_dyld_info_command *_off fields.
2022-06-04 20:57:36 +09:30
Tom de Vries
ac3afe36d7 [gdb/ada] Fix literal truncation
Make sure we error out on overflow instead of truncating in all cases.

Tested on x86_64-linux, with a build with --enable-targets=all.
2022-06-04 13:17:33 +02:00
Tom de Vries
999f7adc21 [gdb/m2] Fix UB and literal truncation
Rewrite parse_number to use ULONGEST instead of LONGEST, to fix UB errors as
mentioned in PR29163.

Furthermore, make sure we error out on overflow instead of truncating in all
cases.

Tested on x86_64-linux, with a build with --enable-targets=all.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29163
2022-06-04 13:17:33 +02:00
Tom de Vries
1390b65a1b [gdb/rust] Fix literal truncation
Make sure we error out on overflow instead of truncating in all cases.

I've used as overflow string: "Integer literal is too large", based
on what I found at
<rust-lang/rust>/src/test/ui/parser/int-literal-too-large-span.rs
but perhaps someone has a better idea.

Tested on x86_64-linux, with a build with --enable-targets=all.
2022-06-04 13:17:33 +02:00
Tom de Vries
7af9baa9fa [gdb/pascal] Fix literal truncation
Make sure we error out on overflow instead of truncating in all cases.

The current implementation of parse_number contains a comment about PR16377,
but that's related to C-like languages.  In absence of information of whether
the same fix is needed for pascal, take the conservative approach and keep
behaviour for decimals unchanged.

Tested on x86_64-linux, with a build with --enable-targets=all.
2022-06-04 13:17:33 +02:00
Tom de Vries
4c4d769ab7 [gdb/go] Fix literal truncation
Make sure we error out on overflow instead of truncating in all cases.

The current implementation of parse_number contains a comment about PR16377,
but that's related to C-like languages.  In absence of information of whether
the same fix is needed for go, take the conservative approach and keep
behaviour for decimals unchanged.

Tested on x86_64-linux, with a build with --enable-targets=all.
2022-06-04 13:17:33 +02:00