Commit Graph

110316 Commits

Author SHA1 Message Date
Tom Tromey
f5a0f5b503 Use bool for evregpy_no_listeners_p
I noticed that evregpy_no_listeners_p should return a bool.  This
patch makes this change.  I'm checking it in.
2022-06-03 10:35:30 -06:00
Alan Modra
3dc8d5eada asan: heap buffer overflow in _bfd_mips_elf_section_from_shdr
* elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Sanity check
	intopt.size and remaining bytes in section for reginfo.
2022-06-03 23:32:39 +09:30
Alan Modra
7e6ba6a2a5 Re: ubsan: undefined shift in frag_align_code
This one needs the same fix too.

	* config/tc-i386.h (MAX_MEM_FOR_RS_ALIGN_CODE): Avoid signed
	integer overflow.
2022-06-03 23:32:39 +09:30
Tom de Vries
450afa9497 [gdb] Fix warning in foreach_arch selftests
When running the selftests, I run into:
...
$ gdb -q -batch -ex "maint selftest"
  ...
Running selftest execute_cfa_program::aarch64:ilp32.
warning: A handler for the OS ABI "GNU/Linux" is not built into this
configuration of GDB.  Attempting to continue with the default aarch64:ilp32
settings.
...
and likewise for execute_cfa_program::i8086 and
execute_cfa_program::ia64-elf32.

The warning can easily be reproduced outside the selftests by doing:
...
$ gdb -q -batch -ex "set arch aarch64:ilp32"
...
and can be prevented by first doing "set osabi none".

Fix the warning by setting osabi to none while doing selftests that iterate
over all architectures.

This causes a regression in the print_one_insn selftests for the ARC
architecture.

The problem is pre-existing, and can be demonstrated (already without this
patch) using:
...
$ gdb -q -batch -ex "set osabi none" -ex "maint selftest print_one_insn::A6"
Running selftest print_one_insn::A6.
Self test failed: Cannot access memory at address 0x0
Ran 1 unit tests, 1 failed
$
...

For ARC, we use the generic case in print_one_insn_test, containing this code:
...
       int kind = gdbarch_breakpoint_kind_from_pc (gdbarch, &pc);
       ...
       insn = gdbarch_sw_breakpoint_from_kind (gdbarch, kind, &bplen);
...

The problem is that with osabi linux we trigger:
...
static int
arc_linux_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
{
  return trap_size;
}
...
but with osabi none:
...
arc_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
{
  size_t length_with_limm = gdb_insn_length (gdbarch, *pcptr);
...
which needs access to memory, and will consequently fail.

Fix this in print_one_insn_test, in the default case, by iterating over
supported osabi's to makes sure we trigger arc_linux_breakpoint_kind_from_pc
which will give us a usable instruction to disassemble.

Tested on x86_64-linux.
2022-06-03 15:34:50 +02:00
Tom de Vries
0e02119e65 Revert "[gdb] Fix warning in foreach_arch selftests"
This reverts commit fc18b1c5af ("[gdb] Fix warning in foreach_arch
selftests").

The commit introduced regressions for an --enable-targets=all build:
...
Running selftest print_one_insn::A6.^M
Self test failed: Cannot access memory at address 0x0^M
...
and while investigating those I realized that the commit fc18b1c5af
complicates things by trying to set the current osabi.

So, revert the patch in preparation for a simpler solution.

Tested on x86_64-linux.
2022-06-03 15:34:50 +02:00
Jan Beulich
a98600052e x86: exclude certain ISA extensions from v3/v4 ISA
Like TBM and LWP, XOP and FMA4 also shouldn't be included in v3.

Like AVX512-4VNNIW, AVX512-4FMAPS also shouldn't be included in v4.
2022-06-03 10:17:35 +02:00
Roland McGrath
d9ad47747a gdb: LoongArch: Remove nonportable #include
Don't use gregset.h in *-tdep.c since it's not usable on
hosts that don't have <sys/procfs.h>.  It's not needed by
this file, and should only be needed by *-nat.c files.
2022-06-02 22:59:23 -07:00
Alan Modra
6b8b24bb68 Re: asan: mips_gprel_reloc segfault
Similarly for the elf mips support.

	* elf32-mips.c (mips_elf_final_gp): Don't segfault on symbols
	in any of the bfd_is_const_section sections.
	* elf64-mips.c (mips_elf64_final_gp): Likewise.
	* elfn32-mips.c (mips_elf_final_gp): Likewise.
2022-06-03 13:12:01 +09:30
Alan Modra
679dc6e716 asan: mips_gprel_reloc segfault
Not just the undefined section has a NULL owner, the absolute section
has too.  Which means we can't find output_bfd for __gp.  Also, may as
well test directly for output_bfd == NULL.

	* coff-mips.c (mips_gprel_reloc): Don't segfault on any of
	bfd_is_const_section sections.
2022-06-03 12:32:00 +09:30
GDB Administrator
dcefca4019 Automatic date update in version.in 2022-06-03 00:00:11 +00:00
Tom de Vries
bb785a92a8 [gdb/testsuite] Detect change instead of init in gdb.mi/mi-var-block.exp
On openSUSE Tumbleweed with target board unix/-m32, I run into:
...
PASS: gdb.mi/mi-var-block.exp: step at do_block_test 2
Expecting: ^(-var-update \*[^M
]+)?(\^done,changelist=\[{name="foo",in_scope="true",type_changed="false",has_more="0"},
{name="cb",in_scope="true",type_changed="false",has_more="0"}\][^M
]+[(]gdb[)] ^M
[ ]*)
-var-update *^M
^done,changelist=[{name="foo",in_scope="true",type_changed="false",has_more="0"}]^M
(gdb) ^M
FAIL: gdb.mi/mi-var-block.exp: update all vars: cb foo changed (unexpected output)
...

The problem is that the test-case attempts to detect a change in the cb
variable caused by this initialization:
...
void
do_block_tests ()
{
  int cb = 12;
...
but that only works if the stack location happens to be unequal to 12 before
the initialization.

Fix this by first initializing to 0, and then changing the value to 12:
...
-  int cb = 12;
+  int cb = 0;
+  cb = 12;
...
and detecting that change.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29195
2022-06-02 20:40:06 +02:00
Eli Zaretskii
0c8cd1de90 Rearrange and slightly reword the "Location Specification" section
This rearranges and changes the wording of the "Location
Specification" section of the GDB manual in minor ways.
2022-06-02 19:35:24 +03:00
Tom Tromey
527907e0e6 ODR warning for "main"
"main" is redeclared with a different type in maint.c.  I think this
might have come from my first gdb patch, many many years ago.  While I
wonder if this profiling code is actually useful at all any more, in
the meantime it's simple to fix the declaration.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22395
2022-06-02 09:04:45 -06:00
Tom Tromey
a7f779c12e ODR warnings for "struct coff_symbol"
"struct coff_symbol" is defined in multiple .c files, causing ODR
warnings.  This patch renames just the xcoffread.c type.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22395
2022-06-02 09:04:45 -06:00
Tom Tromey
4748a9be44 ODR warnings for "struct insn_decode_record_t"
"struct insn_decode_record_t" is defined in multiple .c files, causing
ODR warnings.  This patch renames the types, and removes the use of
"typedef" here -- this is a C-ism that's no longer needed.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22395
2022-06-02 09:04:45 -06:00
Tom Tromey
131430937d ODR warnings for "struct insn_info"
"struct insn_info" is defined in multiple .c files, causing ODR
warnings.  This patch renames the type in z80-tdep.c, leaving the
other one alone.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22395
2022-06-02 09:04:45 -06:00
Tom Tromey
c8e41b5f14 ODR warnings from overlay constants
Some overlay-related constants are duplicated in z80-tdep.c, causing
ODR warnings.  This patch renames just the z80-specific ones.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22395
2022-06-02 09:04:45 -06:00
Tom Tromey
cec000ad60 ODR warning for "enum string_repr_result"
"enum string_repr_result" is defined in multiple .c files, causing ODR
warnings.  This patch renames the types.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22395
2022-06-02 09:04:45 -06:00
Tom Tromey
ddfc4ef124 ODR warning for "struct find_targ_sec_arg"
"struct find_targ_sec_arg" is defined in multiple .c files, causing
ODR warnings.  This patch renames the types.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22395
2022-06-02 09:04:45 -06:00
Tom Tromey
0fecb1a784 ODR warning for "struct stack_item"
"struct stack_item" is defined in multiple .c files, causing ODR
warnings.  This patch renames these types.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22395
2022-06-02 09:04:45 -06:00
Tom Tromey
cc55e4ef62 ODR warning for "struct instruction_type"
"struct instruction_type" is defined in multiple .c files, causing an
ODR warning.  This patch renames the types.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22395
2022-06-02 09:04:45 -06:00
Tom Tromey
94e079e76e ODR warning for struct ext_link_map
This renames the solib-dsbt.c copy of "struct ext_link_map" to avoid
an ODR warning.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22395
2022-06-02 09:04:45 -06:00
Tom Tromey
c01e28360d ODR warning for struct field_info
This renames one of the instance of "struct field_info" to avoid an
ODR warning.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22395
2022-06-02 09:04:45 -06:00
Tom Tromey
7e9d9756db ODR warnings for struct nextfield
"struct nextfield" is defined in multiple places in GDB.  This patch
renames just the stabs one, leaving the DWARF one untouched.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22395
2022-06-02 09:04:45 -06:00
Tom Tromey
77845a9ac6 ODR warnings for struct symloc
"struct symloc" is defined in multiple spots in gdb, causing ODR
warnings.  This patch renames these.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22395
2022-06-02 09:04:45 -06:00
Tom Tromey
57ebc99013 Fix ODR warning in observable.h
observable.h triggers an ODR warning because this line:

    extern observable<struct target_ops */* target */> target_changed;

... may be the only declaration of "struct target_ops" in scope
(depending on the particular .c file) -- and this declares it in a
namespace, resulting in confusion.

This patch fixes the problem by adding a forward declaration.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22395
2022-06-02 09:04:44 -06:00
Tiezhu Yang
2e90d02578 gdb: LoongArch: Implement the software_single_step gdbarch method
When execute the following command on LoongArch:

  make check-gdb TESTS="gdb.base/branch-to-self.exp"

there exist the following failed testcases:

  FAIL: gdb.base/branch-to-self.exp: single-step: si (timeout)
  FAIL: gdb.base/branch-to-self.exp: break-cond: side=host: continue to breakpoint: continue to break (timeout)
  FAIL: gdb.base/branch-to-self.exp: break-cond: side=host: p counter (timeout)

Implement the software_single_step gdbarch method to decode the current
branch instruction and determine the address of the next instruction on
LoongArch to fix the above failed testcases.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-06-02 22:43:35 +08:00
Ilya Leoshkevich
625b6eae09 gdb: Do not add empty sections to the section map
From: Ulrich Weigand <ulrich.weigand@de.ibm.com>

build_objfile_section_table () creates four synthetic sections per
objfile, which are collected by update_section_map () and passed to
std::sort ().  When there are a lot of objfiles, for example, when
debugging JITs, the presence of these sections slows down the sorting
significantly.

The output of update_section_map () is used by find_pc_section (),
which can never return any of these sections: their size is 0, so they
cannot be accepted by bsearch_cmp ().

Filter them (and all the other empty sections) out in
insert_section_p (), which is used only by update_section_map ().
2022-06-02 14:20:05 +02:00
Jon Turney
a779012848
Fix a new warning on Cygwin
> ../../gdb/windows-nat.c: In function ‘windows_solib* windows_make_so(const char*, LPVOID)’:
> ../../gdb/windows-nat.c:714:12: error: declaration of ‘char name [512]’ shadows a parameter [-Werror=shadow=compatible-local]
>   714 |       char name[SO_NAME_MAX_PATH_SIZE];
>       |            ^~~~
> ../../gdb/windows-nat.c:655:30: note: shadowed declaration is here
>   655 | windows_make_so (const char *name, LPVOID load_addr)
>       |                  ~~~~~~~~~~~~^~~~
2022-06-02 10:39:49 +01:00
Jon Turney
a115c6d62e
Fix Cygwin build after 85b25bd9
Fix Cygwin build after 85b25bd9 ("Simplify windows-nat.c solib handling").
2022-06-02 10:39:47 +01:00
Jon Turney
1f03fa9921
Fix Cygwin build after 0578e87f
Fix Cygwin build after 0578e87f ("Remove some globals from
nat/windows-nat.c").  Update code under ifdef __CYGWIN__ for globals
moved to members of struct windows_process_info.
2022-06-02 10:39:46 +01:00
Jon Turney
c9c157c765
Fix Cygwin build after fcab5839
Fix Cygwin build after fcab5839 ("Implement pid_to_exec_file for Windows
in gdbserver"). That change moves code from gdb/windows-nat.c to
gdb/nat/windows-nat.c, but doesn't add the required typedefs and
includes for parts of that code under ifdef __CYGWIN__.
2022-06-02 10:39:44 +01:00
Alan Modra
6a031255cf Re: ubsan: signed integer overflow in atof_generic
Oops.

	* atof-generic.c: Include limits.h.
2022-06-02 18:42:01 +09:30
Alan Modra
b038f394a9 ubsan: signed integer overflow in atof_generic
Fix the signed overflows by using unsigned variables and detect
overflow at BUG! comment.

	* atof-generic.c (atof_generic): Avoid signed integer overflow.
	Return ERROR_EXPONENT_OVERFLOW if exponent overflows a long.
2022-06-02 18:28:57 +09:30
Alan Modra
ee6cbff213 asan: uninit write _bfd_ecoff_write_object_contents
* ecoff.c (_bfd_ecoff_write_object_contents): zalloc reloc_buff.
2022-06-02 16:43:48 +09:30
Alan Modra
f66d30a6e5 asan: null deref in coff_write_relocs
* coffcode.h (coff_write_relocs): Don't deref NULL howto.
2022-06-02 16:31:42 +09:30
Alan Modra
e0ad09cfa5 ubsan: undefined shift in frag_align_code
* frags.c (MAX_MEM_FOR_RS_ALIGN_CODE): Avoid signed integer
	overflow.
2022-06-02 16:10:30 +09:30
Alan Modra
53f2b36a54 gas read_a_source_file #APP processing
This fixes some horrible code using do_scrub_chars.  What we had ran
text through do_scrub_chars twice, directly in read_a_source_file and
again via the input_scrub_include_sb call.  That's silly, and since
do_scrub_chars is a state machine, possibly wrong.  More silliness is
evident in the temporary malloc'd buffer for do_scrub_chars output,
which should have been written directly to sbuf.

So, get rid of the do_scrub_chars call and support functions, leaving
scrubbing to input_scrub_include_sb.  I did wonder about #NO_APP
overlapping input_scrub_next_buffer buffers, but that should only
happen if the string starts in one file and finishes in another.

	* read.c (scrub_string, scrub_string_end): Delete.
	(scrub_from_string): Delete.
	(read_a_source_file): Rewrite #APP processing.
2022-06-02 15:54:18 +09:30
Alan Modra
cd826186c8 sb_scrub_and_add_sb not draining input string buffer
It is possible for sb_scrub_and_add_sb to not consume all of the input
string buffer.  If this happens for reasons explained in the comment,
do_scrub_chars can leave pointers to the string buffer for the next
call.  This patch fixes that by ensuring the input is drained.  Note
that the behaviour for an empty string buffer is also changed,
avoiding another do_scrub_chars bug where empty input and single char
sized output buffers could result in a write past the end of the
output.

	sb.c (sb_scrub_and_add_sb): Loop until all of input sb is
	consumed.
2022-06-02 15:54:14 +09:30
Alan Modra
6f87d3fd27 asan: heap buffer overflow in dwarf2_directive_filename
Seen with .file 4294967289 "xxx.c"

	* dwarf2dbg.c (assign_file_to_slot): Catch more cases of integer
	overflow.  Make param i an unsigned int.
2022-06-02 15:54:14 +09:30
Alan Modra
b3abcebcae asan: NULL deref in scan_unit_for_symbols
Since commit b43771b045 it has been possible to look up addresses
that match a unit with errors, since ranges are added to a trie while
the unit is being parsed.  On error, parse_comp_unit leaves
first_child_die_ptr NULL which results in a NULL info_ptr being passed
to scan_unit_for_symbols.  Fix this by setting unit->error.

Also wrap some overlong lines, and fix some formatting errors.

	* dwarf2.c: Formatting.
	(parse_comp_unit): Set unit->error on err_exit path.
2022-06-02 15:54:14 +09:30
GDB Administrator
a115b27934 Automatic date update in version.in 2022-06-02 00:00:18 +00:00
Tom de Vries
fc18b1c5af [gdb] Fix warning in foreach_arch selftests
When running the selftests, I run into:
...
$ gdb -q -batch -ex "maint selftest"
  ...
Running selftest execute_cfa_program::aarch64:ilp32.
warning: A handler for the OS ABI "GNU/Linux" is not built into this
configuration of GDB.  Attempting to continue with the default aarch64:ilp32
settings.
...
and likewise for execute_cfa_program::i8086 and
execute_cfa_program::ia64-elf32.

The warning can easily be reproduced outside the selftests by doing:
...
$ gdb -q -batch -ex "set arch aarch64:ilp32"
...
and can be prevented by first doing "set osabi none".

Fix the warning by setting osabi to none while doing selftests that iterate
over all architectures.

Tested on x86_64-linux.
2022-06-01 19:29:40 +02:00
Tom Tromey
80fa4b2a60 Add gdb.current_language and gdb.Frame.language
This adds the gdb.current_language function, which can be used to find
the current language without (1) ever having the value "auto" or (2)
having to parse the output of "show language".

It also adds the gdb.Frame.language, which can be used to find the
language of a given frame.  This is normally preferable if one has a
Frame object handy.
2022-06-01 06:15:53 -06:00
Yvan Roux
46c7fd95fc [arm] Don't use special treatment for PC
In an exception frame the PC register is extracted from the stack
just like other base registers, so there is no need for a special
treatment.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@st.com>
Signed-off-by: Yvan Roux <yvan.roux@foss.st.com>
2022-06-01 11:14:39 +01:00
Yvan Roux
de76473c2d [arm] Add support for FPU registers in prologue unwinder
The prologue unwinder had support for FPU registers, but only to
calculate the correct offset on the stack, the values were not saved.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@st.com>
Signed-off-by: Yvan Roux <yvan.roux@foss.st.com>
2022-06-01 11:14:36 +01:00
Yvan Roux
39fc7ff66b [arm] d0..d15 are 64-bit each, not 32-bit
When unwinding the stack, the floating point registers d0 to d15
need to be handled as double words, not words.

Only the first 8 registers have been confirmed fixed with this patch
on a STM32F407-DISC0 board, but the upper 8 registers on Cortex-M33
should be handled in the same way.

The test consisted of running a program compiled with float-abi=hard.
In the main function, a function taking a double as an argument was
called. After the function call, a hardware timer was used to
trigger an interrupt.

In the debug session, a breakpoint was set in the function called
from main to verify the content of the registers using "info float"
and another breakpoint in the interrupt handler was used to check
the same registers using "info float" on frame 2 (the frame just
before the dummy frame created for the signal handler in gdb).

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@st.com>
Signed-off-by: Yvan Roux <yvan.roux@foss.st.com>
2022-06-01 11:14:32 +01:00
Yvan Roux
1d2eeb660f [arm] Cleanup: use hex for offsets
Changed offset from decimal to hex to match architecture reference
manual terminology and keep coherency with the rest of the code.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@st.com>
Signed-off-by: Yvan Roux <yvan.roux@foss.st.com>
2022-06-01 11:14:27 +01:00
Jiangshuai Li
68538bbeaa gdb:csky save fpu and vdsp info to struct csky_gdbarch_tdep
First, add three variables fpu_abi, fpu_hardfp and vdsp_version
to csky_gdbarch_tdep. They will be initialized from info.abfd in
cskg_gdbarch_init.

Now, they are just used to find a candidate among the list of pre-declared
architectures

Later, they will be used in gdbarch_return_value and gdbarch_push_dummy_call
for funtions described below:
fpu_abi: to check if the bfd is using VAL_CSKY_FPU_ABI_HARD or
VAL_CSKY_FPU_ABI_SOFT
fpu_hardfp: to check if the bfd is using VAL_CSKY_FPU_HARDFP_SINGLE
or VAL_CSKY_FPU_HARDFP_DOUBLE
vdsp_version: to check if a function is returned with CSKY_VRET_REGNUM
2022-06-01 14:46:01 +08:00
Alan Modra
b0de9ed86f Re: use libiberty xmalloc in bfd/doc/chew.c
We can't use libiberty.a in chew.  libiberty is a host library, chew
a build program.  Partly revert commit 7273d78f3f, instead define
local versions of the libiberty functions.  ansidecl.h also isn't
needed.

	* doc/chew.c: Don't include libiberty.h or ansidecl.h.
	(xmalloc, xrealloc, xstrdup): New functions.
	* doc/local.mk (LIBIBERTY): Don't define or use.
	* Makefile.in: Regenerate.
2022-06-01 10:52:05 +09:30