Commit Graph

116048 Commits

Author SHA1 Message Date
Claudiu Zissulescu
8784b6df88 Revert "arc: Update opcode related include files for ARCv3."
This reverts commit 04414221df.
2023-09-25 17:02:41 +03:00
Claudiu Zissulescu
6ba813bf38 Revert "arc: Update ARC's Gnu Assembler backend with ARCv3 ISA."
This reverts commit f3d38d7d0b.
2023-09-25 17:02:29 +03:00
Claudiu Zissulescu
3b7e24aa56 Revert "arc: Add new opcode functions for ARCv3 ISA."
This reverts commit c99dc76089.
2023-09-25 17:02:19 +03:00
Claudiu Zissulescu
f3594421d7 Revert "arc: New ARCv3 ISA instruction table"
This reverts commit 67036dfacf.
2023-09-25 17:02:08 +03:00
Claudiu Zissulescu
efd35d85fc Revert "arc: Update arc's gas tests"
This reverts commit ef90c0991e.
2023-09-25 17:01:58 +03:00
Claudiu Zissulescu
f14cd06ba4 Revert "arc: Update NEWS files"
This reverts commit a47d304b12.
2023-09-25 17:01:47 +03:00
Claudiu Zissulescu
0a87388b3b Revert "arc: Update bfd arc pattern file to allow enable-targets=all"
This reverts commit 5e5116071b.
2023-09-25 17:01:34 +03:00
Claudiu Zissulescu
5e5116071b arc: Update bfd arc pattern file to allow enable-targets=all
The ARC backend uses a BFD pattern file to generate three ARC targets:
- an BFD ARC target for ARCv1 and ARCv2 CPU families. It also works
for big-endian variants.
- an BFD ARC64 target for ARCv3 64bit machines. It also allows working
with ARCv3 32bit machines.
- an BFD ARC32 target for ARCv4 32bit machines. It also allows working
with ARCv3 64bit machines.

When configuring with `--enable-targets=all` some patterns are defined
multiple times. Fix this issue.

Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
2023-09-25 15:21:42 +03:00
Andreas Schwab
7345d05aaf RISC-V: Protect .got with relro
Move .got before .data so that it can be protected with -zrelro.  Also
separate .got.plt from .got if -znow is not in effect; the first two words
of .got.plt are placed within the relro region.

ld:
	PR ld/30877
	* emulparams/elf32lriscv-defs.sh (DATA_GOT, SEPARATE_GOTPLT):
	Define.
	* emulparams/elf64lriscv-defs.sh (SEPARATE_GOTPLT): Define.
	* testsuite/ld-elf/binutils.exp (binutils_test): Remove riscv*-*-*
	from relro_got expression.
2023-09-25 12:36:58 +02:00
Claudiu Zissulescu
a47d304b12 arc: Update NEWS files
Add ARCv3 support in NEWS files.

Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
2023-09-25 11:33:12 +03:00
Claudiu Zissulescu
ef90c0991e arc: Update arc's gas tests
The disassembler can recognize the alternative register names ILINK1
and ILINK2.  Update tests.

gas/testsuite/gas/arc
xxxx-xx-xx  Claudiu Zissulescu <claziss@synopsys.com>

	* gas/testsuite/gas/arc/adc.d: Update ILINK1/INLINK2 reg names.
	* gas/testsuite/gas/arc/add.d: Likewise.
	* gas/testsuite/gas/arc/and.d: Likewise.
	* gas/testsuite/gas/arc/asl.d: Likewise.
	* gas/testsuite/gas/arc/asr.d: Likewise.
	* gas/testsuite/gas/arc/bic.d: Likewise.
	* gas/testsuite/gas/arc/lsr.d: Likewise.
	* gas/testsuite/gas/arc/nps400-1.d: Likewise.
	* gas/testsuite/gas/arc/or.d: Likewise.
	* gas/testsuite/gas/arc/ror.d: Likewise.
	* gas/testsuite/gas/arc/sbc.d: Likewise.
	* gas/testsuite/gas/arc/sub.d: Likewise.
	* gas/testsuite/gas/arc/textinsn3op.d: Likewise.
	* gas/testsuite/gas/arc/warn.exp: Update predicate.
	* gas/testsuite/gas/arc/arc.exp: Likewise.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2023-09-25 10:55:51 +03:00
Claudiu Zissulescu
67036dfacf arc: New ARCv3 ISA instruction table
opcodes/
xxxx-xx-xx  Claudiu Zissulescu <claziss@synopsys.com>

	* opcodes/arc64-tbl.h: New file.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2023-09-25 10:55:51 +03:00
Claudiu Zissulescu
c99dc76089 arc: Add new opcode functions for ARCv3 ISA.
opcodes/
xxxx-xx-xx  Claudiu Zissulescu <claziss@synopsys.com>
            Cupertino Miranda <cmiranda@synopsys.com>

        * opcodes/Makefile.am: Add ARC64 opcode file.
        * opcodes/Makefile.in: Regenerate.
        * opcodes/arc-opc.c: Move the common functionality to
        arcxx-opc.inc. Keep only ARCv2 ARCv1 specifics.
        * opcodes/arc-ext-tbl.h: Deleted file.
        * opcodes/arcxx-opc.inc: New file.
        * opcodes/arc64-opc.c: Likewise.
        * opcodes/arc-fxi.h (insert_uimm9_a32_11_s): New function.
        (extract_uimm9_a32_11_s): Likewise.
        (insert_uimm10_13_s): Likewise.
        (extract_uimm10_13_s): Likewise.
        * opcodes/configure: Regenerate.
        * opcodes/configure.ac: Add ARC64 target.
        * opcodes/disassemble.c: Likewise.
        * opcodes/arc-dis.c (regmod_t): New type.
        (regmods): New structure.
        (fpnames): New strings with fp-regs name.
        (REG_PCL, REG_LIMM, REG_LIMM_S, REG_U32, REG_S32): New defines.
        (getregname): New function.
        (find_format_from_table): Discriminate between signed and unsigned
        32bit immediates.
        (find_format): Handle extract function for flags.
        (arc_insn_length): Update insn lengths to various architectures.
        (print_insn_arc): Update printing for various ARC architectures.
	* opcodes/arc-flag-classes.def: New file.
	* opcodes/arc-flag.def: New file.
	* opcodes/arc-operands.def: New file.
	* opcodes/arc-regs.h: Changed.

Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
2023-09-25 10:55:51 +03:00
Claudiu Zissulescu
f3d38d7d0b arc: Update ARC's Gnu Assembler backend with ARCv3 ISA.
The new Synopsys ARCv3 ISA has a similar instruction format like
the old ARCv1 and ARCv2 ISA.  Thus, the ARCv3 addition is using
whatever we have for old ARC processors plus some ARCv3 spcific mods.

To distinguish between various ARC variants, we introduced two new
configure defines named TARGET_ARCv3_32 and TARGET_ARCv3_64 which are
set when we choose either an ARC32 (ARCv3/32) ISA toolchain or an
ARC64 (ARCv3/64) ISA toolchain.

gas/
xxxx-xx-xx  Claudiu Zissulescu <claziss@synopsys.com>

	* gas/config/tc-arc.h: Selectively define default target macros.
	* gas/configure.ac: Add ARC64 target.
	* gas/configure.tgt: Likewise.
	* gas/configure: Regenerate
	* gas/config.in: Regenerate.
	* gas/config/tc-arc.c (DEFAULT_ARCH): New macro.
	(default_arch): New variable.
	(md_pseudo_table): Add xword.
	(md_shortopts): Only a few options are recognized by the new ARC64
	assembler.
	(md_longopts): Likewise.
	(ARC_CPU_TYPE_A64x): New define.
	(ARC_CPU_TYPE_A32x): Likewise.
	(cpu_type): New arch field.
	(selected_cpu): Update fields.
	(arc_opcode_hash_entry_iterator_init): Formating.
	(arc_opcode_hash_entry_iterator_next): Likewise.
	(arc_select_cpu): Likewise.
	(arc_option): Likewise.
	(check_cpu_feature): Likewise.
	(debug_exp): Recognize new expression operands.
	(parse_reloc_symbol): Parse new signed/unsigend cases.
	(parse_opcode_flags): Update for the case when the flags needs
	insert/extract functions.
	(find_opcode_match): Match new signed/unsigned 32-bit immediates.
	(autodetect_attributes): PLT34 only available for ARC64.
	(md_assemble): Extend match characters.
	(declare_fp_set): New function.
	(init_default_arch): Likewise.
	(md_begin): Detect and initialize the correct CPU and coresponding
	registers.
	(md_pcrel_from_section): Add new relocs.
	(arc_target_format): New function.
	(md_apply_fix): Add new relocs.
	(md_parse_option): Update options.
	(arc_show_cpu_list): Update with ARC64 cpus.
	(md_show_usage): Update messages.
	(may_relax_expr): Add PLT34 case.
	(assemble_insn): Update for ARC64.
	(arc_make_nops): New function.
	(arc_handle_align): Refurbish this function, use arc_make_nops.
	(tc_arc_fix_adjustable): Update messages.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2023-09-25 10:55:51 +03:00
Claudiu Zissulescu
04414221df arc: Update opcode related include files for ARCv3.
Add new ARCv3 CPUs and required bits to decode/encode ARCv3 ISA
opcodes. Fix 32 bit relocations which were set as signed but should be
bitfield: ARC_32_ME, ARC_GLOB_DAT, ARC_JMP_SLOT, ARC_RELATIVE. Remove
non-ABI relocation ARC_32_ME_S.

include/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>
	    Cupertino Miranda  <cupertinomiranda@gmail.com>
	    Bruno Mauricio <brunoasmauricio@gmail.com>

	* include/elf/arc-cpu.def: Add new HS5x and HS6x CPUs.
	* include/elf/arc-reloc.def: Add new ARC64 relocations.
	* include/elf/arc.h (EF_ARC_CPU_ARC64): New define.
	* include/opcode/arc-attrs.h (FEATURE_LIST_NAME): Update predicate.
	* include/opcode/arc-func.h: Update formating.
	(replace_disp8ls): New function.
	(replace_disp9s): Likewise.
	(replace_disp6s): Likewise.
	(replace_disp7s): Likewise.
	(replace_disp12s): Likewise.
	* include/opcode/arc.h (ARC_OPCODE_ARC64): New define.
	(ARC_OPCODE_ARC32): Likewise.
	(ARC_OPERAND_FP): Likewise.
	(HARD_FIELDF): Likewise.
	(ARC_OPCODE_ARCVx): New macro.
	(arc_flag_class): Update structure to hold new extract/insert
	functions for flags.
	(INSN3OP): Update macro.
	(FP_SIZE, TPOF, DPOF, SOPF, COPF, CONVOPS): New enums.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2023-09-25 10:55:51 +03:00
Claudiu Zissulescu
4deb1ee57f arc: Add new linker emulation and scripts for ARCv3 ISA.
Add ARCv3's linker bits. Remove obsolete tests.

ld/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

	* ld/Makefile.am: Add ARC64 targets.
	* ld/configure.tgt: Likewise.
	* ld/Makefile.in: Regenerate.
	* ld/emulparams/arc64elf32.sh: New file.
	* ld/emulparams/arc64elf64.sh: Likewise.
	* ld/emulparams/arc64linux32.sh: Likewise.
	* ld/emulparams/arc64linux64.sh: Likewise.
	* ld/scripttempl/elfarc.sc: Update stack and heap definitions.
	* ld/testsuite/ld-arc/got-weak.d: Deleted file.
	* ld/testsuite/ld-arc/got-weak.s: Likewise.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2023-09-25 10:55:51 +03:00
Claudiu Zissulescu
06e8d9861d arc: Add new ARCv3 ISA to BFD.
The new Synopsys's ARCv3 ISA is capable to run either 64-bit or
32-bit ISA.  The new 32-bit ISA is not compatible with the old
Synopsys ARCv1/ARCv2 ISA, however, it retains a lot of common
concepts.  Thus, this patch is reusing the old ARC BFD backend and
adds the necessary bits for the new architecture in a similar way as
it is done for RISCV backend.

bfd/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>
	    Cupertino Miranda  <cupertinomiranda@gmail.com>

	* bfd/Makefile.am: Add ARC64 files.
	* bfd/Makefile.in: Regerate.
	* bfd/arc-got.h (TCB_SIZE): Depends on the target architecture.
	(GOT_ENTRY_SIZE): New define.
	(write_in_got): Likewise.
	(read_from_got): Likewise.
	(align_power): Likewise.
	(arc_got_entry_type_for_reloc): Use RELA_SIZE and GOT_ENTRY_SIZE.
	(arc_fill_got_info_for_reloc): Update formating.
	(relocate_fix_got_relocs_for_got_info): Likewise.
	(arc_static_sym_data): Deleted structure.
	(get_static_sym_data): Deleted function.
	(relocate_fix_got_relocs_for_got_info): Use symbol static data.
	(create_got_dynrelocs_for_single_entry): Update formating.
	(create_got_dynrelocs_for_got_info): Likewise.
	* bfd/arc-plt.c: New file.
	* bfd/arc-plt.def: Add ARC64 PLT entry.
	* bfd/arc-plt.h: Clean it up, move functionality to arc-plt.c file.
	* bfd/archures.c: Add ARC64 target.
	* bfd/config.bfd: Likewise.
	* bfd/configure.ac: Likewise.
	* bfd/bfd-in2.h: Regenerate.
	* bfd/configure: Likewise.
	* bfd/libbfd.h: Likewise.
	* bfd/cpu-arc.c: Clean it up.
	* bfd/cpu-arc64.c: New file.
	* bfd/elf32-arc.c: Renamed to elfnn-arc.c.
	* bfd/elfnn-arc.c: New file.
	* bfd/reloc.c: Add new ARC64 relocs.
	* bfd/targets.c: Add ARC64 target.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2023-09-25 10:55:51 +03:00
Claudiu Zissulescu
6e467e9a94 arc: Add new LD tests for ARCv3.
Add new linker tests for ARCv3 ISA. All the new tests are added in a
distinct new folder named arc64.

ld/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

	* ld/testsuite/ld-arc64/arcv3_64-reloc-near-exe.dd: New file.
	* ld/testsuite/ld-arc64/arcv3_64-reloc-near-so.dd: Likewise.
	* ld/testsuite/ld-arc64/arcv3_64-reloc-near.s: Likewise.
	* ld/testsuite/ld-arc64/arcv3_64.exp: Likewise.
	* ld/testsuite/ld-arc64/bl34.dd: Likewise.
	* ld/testsuite/ld-arc64/bl34.s: Likewise.
	* ld/testsuite/ld-arc64/linkscript.ld: Likewise.
	* ld/testsuite/ld-arc64/plt34-got.dd: Likewise.
	* ld/testsuite/ld-arc64/plt34-got.s: Likewise.
	* ld/testsuite/ld-arc64/plt34-reloc.dd: Likewise.
	* ld/testsuite/ld-arc64/plt34-reloc.s: Likewise.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2023-09-25 10:55:51 +03:00
Claudiu Zissulescu
462693a455 arc: Add new GAS tests for ARCv3.
Add new assembler tests for ARCv3 ISA. All the new tests are added in
a distinct folder named arc64.

gas/
xxxx-xx-xx  Claudiu Zissulescu <claziss@synopsys.com>

	* gas/testsuite/gas/arc64/arc64.exp: New file.
	* gas/testsuite/gas/arc64/float01.d: Likewise.
	* gas/testsuite/gas/arc64/float01.s: Likewise.
	* gas/testsuite/gas/arc64/ldd.d: Likewise.
	* gas/testsuite/gas/arc64/ldd.s: Likewise.
	* gas/testsuite/gas/arc64/lddl.d: Likewise.
	* gas/testsuite/gas/arc64/lddl.s: Likewise.
	* gas/testsuite/gas/arc64/load.d: Likewise.
	* gas/testsuite/gas/arc64/load.s: Likewise.
	* gas/testsuite/gas/arc64/st.d: Likewise.
	* gas/testsuite/gas/arc64/st.s: Likewise.
	* gas/testsuite/gas/arc64/std.d: Likewise.
	* gas/testsuite/gas/arc64/std.s: Likewise.
	* gas/testsuite/gas/arc64/stdl.d: Likewise.
	* gas/testsuite/gas/arc64/stdl.s: Likewise.
	* gas/testsuite/gas/arc64/stl.d: Likewise.
	* gas/testsuite/gas/arc64/stl.s: Likewise.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2023-09-25 10:55:51 +03:00
Claudiu Zissulescu
f0a3c3dd52 arc: Update binutils arc predicate for tests.
binutils/testsuite/binutils-all
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

	* binutils/testsuite/binutils-all/arc/objdump.exp: Update predicate.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2023-09-25 10:32:52 +03:00
GDB Administrator
be8e831309 Automatic date update in version.in 2023-09-25 00:00:09 +00:00
GDB Administrator
7a5fa3dbe5 Automatic date update in version.in 2023-09-24 00:00:24 +00:00
GDB Administrator
0f7710ced0 Automatic date update in version.in 2023-09-23 00:00:32 +00:00
Frederic Cambus
9c1e3e4204 Update the NetBSD system call table to add memfd_create(2) and epoll(2).
Generated from sys/sys/syscall.h revision 1.324.
2023-09-22 12:25:07 -07:00
Enze Li
2da39de8df fbsd-nat: Pacify gcc with no functional changes
I see these errors on FreeBSD/aarch64 when using gcc 12 without passing
--disable-werror.

=====================================================================
  CXX    fbsd-nat.o
fbsd-nat.c: In member function 'void fbsd_nat_target::resume_one_process(ptid_t, int, gdb_signal)':
fbsd-nat.c:1208:11: error: unused variable 'request' [-Werror=unused-variable]
 1208 |       int request;
      |           ^~~~~~~
fbsd-nat.c: In member function 'virtual ptid_t fbsd_nat_target::wait(ptid_t, target_waitstatus*, target_wait_flags)':
fbsd-nat.c:1726:22: error: declaration of 'inf' shadows a previous local [-Werror=shadow=compatible-local]
 1726 |       for (inferior *inf : all_non_exited_inferiors (this))
      |                      ^~~
fbsd-nat.c:1697:17: note: shadowed declaration is here
 1697 |       inferior *inf = find_inferior_ptid (this, wptid);
      |                 ^~~
fbsd-nat.c: In member function 'virtual void fbsd_nat_target::detach(inferior*, int)':
fbsd-nat.c:2044:18: error: variable 'wptid' set but not used [-Werror=unused-but-set-variable]
 2044 |           ptid_t wptid = wait_1 (ptid, &ws, 0);
      |                  ^~~~~
cc1plus: all warnings being treated as errors
=====================================================================

This patch includes the following non-functional changes,

1. Remove unused variable "request".
2. Rename inf to inf_p to avoid shadowed declaration warnings.
3. Mark wptid as used when USE_SIGTRAP_SIGINFO is defined.

Tested on FreeBSD/aarch64 by rebuilding.

Approved-By: John Baldwin <jhb@FreeBSD.org>
2023-09-22 12:23:44 -07:00
Tom Tromey
e7bb5090cb Remove keywords from target debug printer names
I recently checked in a patch that removed the use of the "struct"
keyword in some spots.  Doing this pointed out that the target
delegate code preserves this keyword -- but, with C++, it does not
really need to.  This patch changes make-target-delegates.py to remove
these keywords, and updates target-debug.h to follow.  This pointed
out that there was already one redudancy: both
target_debug_print_struct_inferior_p and target_debug_print_inferior_p
existed.

Tested by rebuilding.

Reviewed-by: Kevin Buettner <kevinb@redhat.com>
2023-09-22 07:15:37 -06:00
Vladimir Mezentsev
7434de7ef9 gprofng: 30834 improve disassembly output for call and branch instructions
This patch makes the gprofng disassembler to emit, e.g.
    call   fprintf@plt [ 0x401060, .-0x49c]
instead of
    call   0xfffffffffffffb64

I use bfd_get_synthetic_symtab() to get function names in the .plt section.
I have not yet modified Elf-reader in gprofng to remove parsing of .symtab or
.dynsym sections. But we plan to do it.

gprofng/ChangeLog
2023-09-20  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	PR gprofng/30834
	* src/Disasm.cc: Show the function name in the call instruction
	and the relative address in the branch instruction. Remove unused code.
	* src/Disasm.h (map_PC_to_func, get_funcname_in_plt): New functions.
	* src/Elf.cc: Get function names for the .plt section.
	* src/Elf.h (get_funcname_in_plt, get_bfd_symbols): New functions.
	* src/Stabs.cc: Add pltSym to SymLst. Remove the conversion to uint32_t.
2023-09-21 18:56:30 -07:00
GDB Administrator
b3453e999a Automatic date update in version.in 2023-09-22 00:00:27 +00:00
Thomas Weißschuh
0ad14a8c34 ld: write resolved path to included file to dependency-file
In ldfile_open_command_file_1() name written to the dependency files is
the name as specified passed to the "INCLUDE" directive.
This is before include-path processing so the tracked dependency
location is most likely wrong.

Instead track the opened file at the point where the resolved path is
actually available, in try_open().

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-09-21 08:03:09 +02:00
GDB Administrator
f21e7f44e4 Automatic date update in version.in 2023-09-21 00:01:00 +00:00
Tom Tromey
2bcbfaeadc Remove stray trailing "," from DAP breakpoint.py
The buildbot pointed out that the last DAP series I checked in had an
issue.  Looking into it, it seems there is a stray trailing "," in
breakpoint.py.  This patch removes it.

This seems to point out a test suite deficiency.  I will look into
fixing that.
2023-09-20 17:09:13 -06:00
Tom Tromey
ef0f16ccf8 Remove explanatory comments from includes
I noticed a comment by an include and remembered that I think these
don't really provide much value -- sometimes they are just editorial,
and sometimes they are obsolete.  I think it's better to just remove
them.  Tested by rebuilding.

Approved-By: Andrew Burgess <aburgess@redhat.com>
2023-09-20 11:45:16 -06:00
Gregory Anders
0b7de6d3ee gdb/dap: only include sourceReference if file path does not exist
According to the DAP specification if the "sourceReference" field is
included in a Source object, then the DAP client _must_ make a "source"
request to the debugger to retrieve file contents, even if the Source
object also includes path information.

If the Source's path field is a valid path that the DAP client is able
to read from the filesystem, having to make another request to the
debugger to get the file contents is wasteful and leads to incorrect
results (DAP clients will try to get the contents from the server and
display those contents as a file with the name in "source.path", but
this will conflict with the _acutal_ existing file at "source.path").

Instead, only set "sourceReference" if the source file path does not
exist.

Approved-By: Tom Tromey <tom@tromey.com>
2023-09-20 10:59:47 -06:00
Gregory Anders
61830fcb31 gdb/dap: use breakpoint fullname to resolve source
If the breakpoint has a fullname, use that as the source path when
resolving the breakpoint source information. This is consistent with
other callers of make_source which also use "fullname" if it exists (see
e.g. DAPFrameDecorator which returns the symtab's fullname).

Approved-By: Tom Tromey <tom@tromey.com>
2023-09-20 10:59:43 -06:00
Gregory Anders
d2266b2305 gdb/dap: ignore unused keyword args in step_out
Some DAP clients may send additional parameters in the stepOut command
(e.g. "granularity") which are not used by GDB, but should nonetheless
be accepted without error.

Approved-By: Tom Tromey <tom@tromey.com>
2023-09-20 10:59:38 -06:00
Gregory Anders
155f5df517 gdb/dap: check for breakpoint source before unpacking
Not all breakpoints have a source location. For example, a breakpoint
set on a raw address will have only the "address" field populated, but
"source" will be None, which leads to a RuntimeError when attempting to
unpack the filename and line number.

Before attempting to unpack the filename and line number from the
breakpoint, ensure that the source information is not None. Also
populate the source and line information separately from the
"instructionReference" field, so that breakpoints that include only an
address are still included.

Approved-By: Tom Tromey <tom@tromey.com>
2023-09-20 10:59:32 -06:00
Tom Tromey
4abf53c991 Run 'black' on printing.py
The buildbot pointed out that I neglected to re-run 'black' after
making some changes.  This patch fixes the oversight.
2023-09-20 10:43:04 -06:00
Matthew "strager" Glazar
0f6a699478 gdb/tui: add 'set tui mouse-events off' to restore mouse selection
Rationale:
I use the mouse with my terminal to select and copy text. In gdb, I use
the mouse to select a function name to set a breakpoint, or a variable
name to print, for example.

When gdb is compiled with ncurses mouse support, gdb's TUI mode
intercepts mouse events. Left-clicking and dragging, which would
normally select text, seems to do nothing. This means I cannot select
text using my mouse anymore. This makes it harder to set breakpoints,
print variables, etc.

Solution:
I tried to fix this issue by editing the 'mousemask' call to only enable
buttons 4 and 5. However, this still caused my terminal (gnome-terminal)
to not allow text to be selected. The only way I could make it work is
by calling 'mousemask (0, NULL);'. But doing so disables the mouse code
entirely, which other people might want.

I therefore decided to make a setting in gdb called 'tui mouse-events'.
If enabled (the default), the behavior is as it is now: terminal mouse
events are given to gdb, disabling the terminal's default behavior.
If disabled (opt-in), the behavior is as it was before the year 2020:
terminal mouse events are not given to gdb, therefore the mouse can be
used to select and copy text.

Notes:
I am not attached to the setting name or its description. Feel free to
suggest better wording.

Testing:
I tested this change in gnome-terminal by performing the following steps
manually:

1. Run: gdb --args ./myprogram
2. Enable TUI: press ctrl-x ctrl-a
3. Click and drag text with the mouse. Observe no selection.
4. Input: set tui mouse-events off
5. Click and drag text with the mouse. Observe that selection works now.
6. Input: set tui mouse-events on.
7. Click and drag text with the mouse. Observe no selection.
2023-09-20 16:35:36 +01:00
Tom de Vries
973db6fae3 [gdb/symtab] Error out for .debug_types section in dwz file
There are two methods to factor out type information in a dwarf4 executable:
- use -fdebug-info-types to generate type units in a .debug_types section, and
- use dwz to create partial units.

The dwz method has an extra benefit: it also allows to factor out information
between executables into a newly created .dwz file, pointed to by a
.gnu_debugaltlink section.

There is nothing prohibiting a .gnu_debugaltlink file to contain a
.debug_types section.

It's just not generated by dwz or any other tool atm, and consequently gdb has
no support for it.  Enhancement PR symtab/30838 is open about the lack of
support.

Make the current situation explicit by emitting a dwarf error:
...
(gdb) file struct-with-sig-2^M
Reading symbols from struct-with-sig-2...^M
Dwarf Error: .debug_types section not supported in dwz file^M
...
and add an assert in write_gdbindex:
...
+      /* See enhancement PR symtab/30838.  */
+      gdb_assert (!(per_cu->is_dwz && per_cu->is_debug_types));
...
to clarify why we can use:
...
      data_buf &cu_list = (per_cu->is_debug_types
                           ? types_cu_list
                           : per_cu->is_dwz ? dwz_cu_list : objfile_cu_list);
...

The test-case is a modified copy from gdb.dwarf2/struct-with-sig.exp, so it
keeps the copyright years range.

Tested on x86_64-linux.

Tested-By: Guinevere Larsen <blarsen@redhat.com>

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30838
2023-09-20 16:05:55 +02:00
Song Mengzhi
fbf4b3c9bb PR30870, VMS_DEBUG compilation error
Introduced by 8169954446.

	PR 30870
	* vms-alpha.c (image_write): Remove extraneous parenthesis.
2023-09-20 09:35:53 +09:30
GDB Administrator
39d12f2159 Automatic date update in version.in 2023-09-20 00:00:48 +00:00
Alan Modra
765a0c0a86 readelf.c 'ext' may be used uninitialized
* readelf.c (display_lto_symtab): Init ext.
2023-09-20 08:23:48 +09:30
Alan Modra
a1d1634d00 elf-attrs.c memory allocation fail
Report errors rather than segfaulting.

bfd/
	* elf-attrs.c (elf_new_obj_attr): Return NULL on bfd_alloc fail.
	(bfd_elf_add_obj_attr_int): Handle NULL return from the above,
	and propagate return to callers.
	(elf_add_obj_attr_string, elf_add_obj_attr_int_string): Likewise.
	(bfd_elf_add_obj_attr_string): Similarly.
	(_bfd_elf_copy_obj_attributes): Report error on alloc fails.
	(_bfd_elf_parse_attributes): Likewise.
	* elf-bfd.h (bfd_elf_add_obj_attr_int): Update prototype.
	(bfd_elf_add_obj_attr_string): Likewise.
	(bfd_elf_add_obj_attr_int_string): Likewise.
gas/
	* config/obj-elf.c (obj_elf_vendor_attribute): Report fatal
	error on out of memory from bfd attribute functions.
	* config/tc-arc.c (arc_set_attribute_int): Likewise.
	(arc_set_attribute_string, arc_set_public_attributes): Likewise.
	* config/tc-arm.c (aeabi_set_attribute_int): Likewise.
	(aeabi_set_attribute_string): Likewise.
	* config/tc-mips.c (mips_md_finish): Likewise.
	* config/tc-msp430.c (msp430_md_finish): Likewise.
	* config/tc-riscv.c (riscv_write_out_attrs): Likewise.
	* config/tc-sparc.c (sparc_md_finish): Likewise.
	* config/tc-tic6x.c (tic6x_set_attribute_int): Likewise.
	* config/tc-csky.c (md_begin): Likewise.
	(set_csky_attribute): Return ok status.
2023-09-20 08:23:47 +09:30
Tom Tromey
a56e5dce69 Handle pointers and references correctly in DAP
A user pointed out that the current DAP variable code does not let the
client deference a pointer.  Oops!

Fixing this oversight is simple enough -- adding a new no-op
pretty-printer for pointers and references is quite simple.

However, doing this naive caused a regession in scopes.exp, which
expected there to be no children of a 'const char *' variable.  This
problem was fixed by the preceding patches in the series, which ensure
that a C type of this kind is recognized as a string.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30821
2023-09-19 13:28:42 -06:00
Tom Tromey
76fc0f6213 Give a language to a type
This changes main_type to hold a language, and updates the debug
readers to set this field.  This is done by adding the language to the
type-allocator object.

Note that the non-DWARF readers are changed on a "best effort" basis.

This patch also reimplements type::is_array_like to use the type's
language, and it adds a new type::is_string_like as well.  This in
turn lets us change the Python implementation of these methods to
simply defer to the type.
2023-09-19 13:28:42 -06:00
Tom Tromey
26733fc747 Add is_array_like and to_array to language_defn
This adds new is_array_like and to_array methods to language_defn.
This will be used in a subsequent patch that generalizes the new
Python array- and string-handling code.
2023-09-19 13:28:42 -06:00
Tom Tromey
d948c67c5d Regularize some DWARF type initialization
In one spot, it will be convenient for a subsequent patch if the CU is
passed to a type-creation helper function.  In another spot, remove
the redundant 'objfile' parameter to another such function.
2023-09-19 13:28:42 -06:00
Tom Tromey
d559227272 Pass a type allocator to init_fixed_point_type
init_fixed_point_type currently takes an objfile and creates its own
type allocator.  However, for a later patch it is more convenient if
this function accepts a type allocator.  This patch makes this change.
2023-09-19 13:28:42 -06:00
Tom Tromey
8e032233a0 Use gdb::checked_static_cast for catchpoints
This replaces some casts to various kinds of catchpoint with
checked_static_cast.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-09-19 08:14:01 -06:00
Tom Tromey
6a9196a65f Use gdb::checked_static_cast for code_breakpoint
This replaces some casts to 'code_breakpoint *' with
checked_static_cast.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-09-19 08:14:01 -06:00