Commit Graph

106221 Commits

Author SHA1 Message Date
Alan Modra
4863cddb50 PR27858, global-buffer-overflow
PR 27858
	* elf32-sh.c (sh_elf_info_to_howto): Correct check for last valid
	reloc howto.
2021-05-13 10:18:44 +09:30
GDB Administrator
3e5fac0797 Automatic date update in version.in 2021-05-13 00:00:34 +00:00
Simon Marchi
4b8cb9dd9e gdb: make gdbpy_parse_command_name return a unique_xmalloc_ptr
This avoids some manual memory management.

cmdpy_init correctly transfers ownership of the name to the
cmd_list_element, as it sets the name_allocated flag.  However,
cmdpy_init (and add_setshow_generic) doesn't, it looks like the name is
just leaked.  This is a bit tricky, because it actually creates two
commands (one set and one show), it would take a bit of refactoring of
the command code to give each their own allocated copy.  For now, just
keep doing what the current code does but in a more explicit fashion,
with an explicit release.

gdb/ChangeLog:

	* python/python-internal.h (gdbpy_parse_command_name): Return
	gdb::unique_xmalloc_ptr.
	* python/py-cmd.c (gdbpy_parse_command_name): Likewise.
	(cmdpy_init): Adjust.
	* python/py-param.c (parmpy_init): Adjust.
	(add_setshow_generic): Take gdb::unique_xmalloc_ptr, release it
	when done.

Change-Id: Iae5bc21fe2b22f12d5f954057b0aca7ca4cd3f0d
2021-05-12 13:50:09 -04:00
Tom de Vries
3db19b2d72 Revert "[gdb/symtab] Fix infinite recursion in dwarf2_cu::get_builder()"
This reverts commit 4cf88725da.

It causes the following regression:
...
$ cat shadow.cc
namespace A {}

int
main()
{
  using namespace A;
  return 0;
}
$ g++-10 -g shadow.cc -flto -o shadow
$ ./gdb -q -batch ./shadow  -ex "b main"
Aborted (core dumped)
...
2021-05-12 16:03:02 +02:00
Alan Modra
a7077ce760 Ensure data pointer kept within bounds
* dwarf.c (process_extended_line_op): Don't bump data pointer past
	end when strnlen doesn't find string terminator.
	(decode_location_expression): Remove dead code.
	(skip_attr_bytes): Remove const from end param.  Ensure data
	pointer doesn't pass end.
	(get_type_signedness): Remove const from end param.
	(read_and_display_attr_value): Ensure data pointer doesn't pass end.
	(display_debug_lines_raw, display_debug_lines_decoded): Likewise.
	(display_debug_pubnames_worker): Likewise.
	(display_debug_pubnames_worker): Use SAFE_BYTE_GET_AND INC rather
	than blindly incrementing data pointer.
	(display_debug_addr, display_debug_str_offsets): Likewise.  Don't
	compare pointers, compare lengths.
2021-05-12 21:29:25 +09:30
Alan Modra
6d1ad6f783 SAFE_BYTE_GET
This rearranges SAFE_BYTE_GET* macros, eliminating some duplication,
and making sure that the _INC variants never increment their PTR arg
past END.  I've added an assertion that should show us places where we
use them improperly with user derived PTR args, which I'm sure the
fuzzers will find for us.

	* dwarf.c (SAFE_BYTE_GET_INTERNAL): Define.
	(SAFE_BYTE_GET, SAFE_BYTE_GET_AND_INC): Define using the above.
	(SAFE_SIGNED_BYTE_GET, SAFE_SIGNED_BYTE_GET_AND_INC): Likewise.
	(display_discr_list): Use SAFE_BYTE_GET_AND_INC rather than
	SAFE_BYTE_GET followed by increment.
	(process_debug_info): Likewise, and test bytes remaining before
	incrementing section_begin rather than using pointer comparison.
	(display_debug_names): Pass lvalue as SAFE_BYTE_GET PTR.
	(process_cu_tu_index): Likewise for SAFE_BYTE_GET_AND_INC.
2021-05-12 21:17:35 +09:30
Alan Modra
af2ddf69ab SAFE_BYTE_GET64
Functions dealing with lack of a 64-bit integer type can disappear now
that we require C99.  Printing using dwarf_vmatoa is better too.

binutils/
	* dwarf.c (dwarf_vmatoa64, SAFE_BYTE_GET64, add64): Delete.
	(skip_attr_bytes): Replace use of SAFE_BYTE_GET64 with
	SAFE_BYTE_GET_AND_INC.
	(read_and_display_attr_value): Likewise.  Print using dwarf_vmatoa.
	(process_debug_info, process_cu_tu_index): Likewise.
	* elfcomm.c (byte_put, byte_put_little_endian, byte_put_big_endian),
	(byte_get, byte_get_little_endian, byte_get_big_endian),
	(byte_get_signed): Make size param unsigned.  Remove code dealing
	with 4-byte elf_vma.
	(byte_get_64): Delete.
	* elfcomm.h  (byte_put, byte_put_little_endian, byte_put_big_endian),
	(byte_get, byte_get_little_endian, byte_get_big_endian),
	(byte_get_signed): Update prototypes.
	(byte_get_64): Delete.
gas/
	* testsuite/gas/elf/dwarf-5-file0.d: Update.
	* testsuite/gas/i386/dwarf5-line-1.d: Update.
2021-05-12 21:10:33 +09:30
Alan Modra
0d872fca02 PR27836, readelf -w pointer comparison UB
PR 27836
	* dwarf.c (display_debug_frames): Don't compare pointers derived
	from user input.  Test offset against bounds instead.
2021-05-12 21:10:33 +09:30
George Barrett
ee35ce8200 Guile: add value-const-value
The Guile API doesn't currently have an equivalent to the Python API's
gdb.Value.const_value(). This commit adds a procedure with equivalent
semantics to the Guile API.

gdb/ChangeLog:

	* NEWS (Guile API): Note the addition of the new procedure.
	* guile/scm-value.c (gdbscm_value_const_value): Add
	implementation of value-const-value procedure.
	(value_functions): Add value-const-value procedure.

gdb/doc/ChangeLog:

	* guile.texi (Values From Inferior In Guile): Add documentation
	for value-const-value.

gdb/testsuite/ChangeLog:

	* gdb.guile/scm-value.exp (test_value_in_inferior): Add test for
	value-const-value.
2021-05-12 12:35:36 +01:00
George Barrett
9d4fc61d41 Guile: add value-{rvalue-,}reference-value
The Guile API doesn't currently have an equivalent to the Python API's
Value.reference_value() or Value.rvalue_reference_value(). This commit
adds a procedure with equivalent semantics to the Guile API.

gdb/ChangeLog:

	* NEWS (Guile API): Note the addition of new procedures.
	* guile/scm-value.c (gdbscm_reference_value): Add helper function
	for reference value creation.
	(gdbscm_value_reference_value): Add implementation of
	value-reference-value procedure.
	(gdbscm_value_rvalue_reference_value): Add implementation of
	value-rvalue-reference-value procedure.
	(value_functions): Add value-reference-value procedure.  Add
	value-rvalue-reference-value procedure.

gdb/doc/ChangeLog:

	* guile.texi (Values From Inferior In Guile): Add documentation
	for value-reference-value.  Add documentation for
	value-rvalue-reference-value.

gdb/testsuite/ChangeLog:

	* gdb.guile/scm-value.exp (test_value_in_inferior): Add test for
	value-reference-value.  Add test for value-rvalue-reference-value.
2021-05-12 12:35:36 +01:00
George Barrett
97cef6b7b7 Guile: improved rvalue reference support
Adds a couple of missing bits to the Guile API to make C++11 rvalue
reference values and types usable from Guile scripts.

gdb/ChangeLog:

	* guile/scm-type.c (type_integer_constants): Add binding for
	TYPE_CODE_RVALUE_REF.
	* guile/scm-value.c (gdbscm_value_referenced_value): Handle
	dereferencing of rvalue references.
	* NEWS (Guile API): Note improvements in rvalue reference support.

gdb/doc/ChangeLog:

	* guile.texi (Types In Guile): Add documentation for
	TYPE_CODE_RVALUE_REF.
2021-05-12 12:35:36 +01:00
Richard Earnshaw
84139c5864 arm: fix fallout from recent thumb2 detection patch
The recent change to correct the detection of thumb2 object files
resulted in a ld test for veneering starting to fail.  The problem was
the test itself, which was incorrectly expecting thumb1 type far-call
veneers instead of the thumb2 flavour.  We already have a dump file of
the expected form, so the fix is to change the expected output
accordingly.

ld/

	* testsuite/ld-arm/arm-elf.exp (farcall test for v8-m.mainline):
	Correct expected output.
2021-05-12 11:43:59 +01:00
Marco Barisione
2f822da535 gdb: generate the prefix name for prefix commands on demand
Previously, the prefixname field of struct cmd_list_element was manually
set for prefix commands.  This seems verbose and error prone as it
required every single call to functions adding prefix commands to
specify the prefix name while the same information can be easily
generated.

Historically, this was not possible as the prefix field was null for
many commands, but this was fixed in commit
3f4d92ebdf by Philippe Waroquiers, so
we can rely on the prefix field being set when generating the prefix
name.

This commit also fixes a use after free in this scenario:
* A command gets created via Python (using the gdb.Command class).
  The prefix name member is dynamically allocated.
* An alias to the new command is created. The alias's prefixname is set
  to point to the prefixname for the original command with a direct
  assignment.
* A new command with the same name as the Python command is created.
* The object for the original Python command gets freed and its
  prefixname gets freed as well.
* The alias is updated to point to the new command, but its prefixname
  is not updated so it keeps pointing to the freed one.

gdb/ChangeLog:

	* command.h (add_prefix_cmd): Remove the prefixname argument as
	it can now be generated automatically.  Update all callers.
	(add_basic_prefix_cmd): Ditto.
	(add_show_prefix_cmd): Ditto.
	(add_prefix_cmd_suppress_notification): Ditto.
	(add_abbrev_prefix_cmd): Ditto.
	* cli/cli-decode.c (add_prefix_cmd): Ditto.
	(add_basic_prefix_cmd): Ditto.
	(add_show_prefix_cmd): Ditto.
	(add_prefix_cmd_suppress_notification): Ditto.
	(add_prefix_cmd_suppress_notification): Ditto.
	(add_abbrev_prefix_cmd): Ditto.
	* cli/cli-decode.h (struct cmd_list_element): Replace the
	prefixname member variable with a method which generates the
	prefix name at runtime.  Update all code reading the prefix
	name to use the method, and remove all code setting it.
	* python/py-cmd.c (cmdpy_destroyer): Remove code to free the
	prefixname member as it's now a method.
	(cmdpy_function): Determine if the command is a prefix by
	looking at prefixlist, not prefixname.
2021-05-12 11:19:22 +01:00
Luis Machado
f0bbe8bab8 Add MTE register set support for core files
* elf-bfd.h (elfcore_write_aarch_mte): New prototype.
	* elf.c (elfcore_grok_aarch_mte, elfcore_write_aarch_mte): New
	functions.
	(elfcore_grok_note): Handle notes of type NT_ARM_TAGGED_ADDR_CTRL.
	(elfcore_write_register_note): Handle MTE notes.
2021-05-12 11:03:17 +01:00
Markus Metzger
d51344c909 gdb, btrace, pt: ignore status update enable events
Future versions of libipt report enable/disable status updates on PSB+.
Ignore them.
2021-05-12 10:39:41 +02:00
Alan Modra
55b26492bb PR27853, Infinite loop in dwarf.c
Not quite infinite but much longer than it need be.  The problem is
triggered by read_and_display_attr_value incrementing "data" past
"end".  read_and_display_attr_value shouldn't do that, but be
defensive.

	PR 27853
	* dwarf.c (display_formatted_table): Test for data >= end rather
	than data == end.
	(process_extended_line_op): Likewise.
	(display_debug_lines_raw): Likewise.
	(display_debug_lines_decoded): Likewise.
2021-05-12 15:41:10 +09:30
Alan Modra
5ab3907543 PR27849, heap-buffer-overflow on readelf -w
PR 27849
	* dwarf.c (fetch_indexed_string): Correct length sanity checks.
	Sanity check section size for version and padding too.  Correct
	index sanity check.  Handle multiple tables in .debug_str_offsets.
2021-05-12 15:41:10 +09:30
Mike Frysinger
425b0b1a98 sim: clean up explicit environment build calls
This was enabled by default for all targets, but a few ports still
include an explicit call.  Clean that up, and update the docs.
2021-05-12 00:47:49 -04:00
Luis Machado
e7e40cedbb Fix build failure in d10v sim
While building all targets on Ubuntu 20.04/aarch64, I ran into the following
build error:

In file included from /usr/include/string.h:495,
                 from ../../bfd/bfd.h:48,
                 from ../../../../repos/binutils-gdb/sim/d10v/interp.c:4:
In function memset,
    inlined from sim_create_inferior at ../../../../repos/binutils-gdb/sim/d10v/interp.c:1146:3:
/usr/include/aarch64-linux-gnu/bits/string_fortified.h:71:10: error: __builtin_memset offset [33, 616] from the object at State is out of the bounds of referenced subobject regs with type reg_t[16] {aka short unsigned int[16]} at offset 0 [-Werror=array-bounds]
   71 |   return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[3]: *** [Makefile:558: interp.o] Error 1

The following patch fixes this.

sim/ChangeLog:

2021-05-12  Luis Machado  <luis.machado@linaro.org>

	* d10v/interp.c (sim_create_inferior): Fix memset call.
2021-05-12 00:57:46 -03:00
Roland McGrath
4a1ad5c9e4 x86-64/ELF: Fix "clear src_mask for all reloc types" test case
ld/
	* testsuite/ld-x86-64/rela.d: Fix regexp not to presume a specific
	address layout, so it works for e.g. --target=x86-64-elf.
2021-05-11 17:00:51 -07:00
GDB Administrator
ad9e0d9c8b Automatic date update in version.in 2021-05-12 00:00:36 +00:00
Simon Marchi
f2a883a81e gdb: fix indentation in arm_record_data_proc_misc_ld_str
The scopes under this "if" are over-indented, fix that.

gdb/ChangeLog:

	* arm-tdep.c (arm_record_data_proc_misc_ld_str): Fix
	indentation.

Change-Id: I84a551793207ca95d0bc4f122e336555c8179c0e
2021-05-11 17:32:38 -04:00
Simon Marchi
64f30eb0f8 gdb: fix indentation of cmd_list_element
This structure declaration is over-indented, fix that.

gdb/ChangeLog:

	* cli/cli-decode.h (struct cmd_list_element): Fix indentation.

Change-Id: I17c9cd739a233239b3add72f4fce7947c20907cd
2021-05-11 16:08:49 -04:00
Richard Earnshaw
d8147d7053 arm: correctly decode Tag_THUMB_ISA_use=3 for thumb2 features
This was detected when a user accidentally tried to build a shared
library using armv8-m.main objects.  The resulting error was "warning:
thumb-1 mode PLT generation not currently supported".  Something was
clearly wrong because v8-m.main is a thumb-2 variant.

It turns out that the code to detect thumb-2 in object files hadn't
been updated for the extended definition of Tag_THUMB_ISA_use to
support the value 3, meaning 'work it out for yourself from the
architecture tag'; something that is now necessary given that the line
between thumb-1 and thumb-2 has become blurred over time.

Another problem with the function doing this calculation was that the
absence of this tag (implying a default value 0) should mean use of
thumb code was NOT permitted.  However, the code went on to look at
the architecture flags and decide that it could ignore this if the
architecture flags said that thumb2 features were available, thus
completely ignoring the intended meaning.

bfd/

	* elf32-arm.c (using_thumb2): Correctly handle Tag_THUMB_ISA_use
	values 0 and 3.
2021-05-11 16:18:25 +01:00
Hans-Peter Nilsson
d30182b51e dwarf.c (process_abbrev_set): Properly parenthesize, fix fallout
Building as ILP32 shows:

 gcc -m32 -DHAVE_CONFIG_H -I. -I/checkout/binutils  -I. -I/checkout/binutils -I../bfd -I/checkout/binutils/../bfd -I/checkout/binutils/../include -DLOCALEDIR="\"/usr/local/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation  -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Werror -I/checkout/binutils/../zlib -g -O2   -MT dwarf.o -MD -MP -MF $depbase.Tpo -c -o dwarf.o /checkout/binutils/dwarf.c &&\
 mv -f $depbase.Tpo $depbase.Po
 In file included from /checkout/binutils/sysdep.h:101:0,
                  from /checkout/binutils/dwarf.c:21:
 /checkout/binutils/dwarf.c: In function 'process_abbrev_set':
 /checkout/binutils/dwarf.c:1072:15: error: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'dwarf_vma {aka long long unsigned int}' [-Werror=format=]
        warn (_("Debug info is corrupted, abbrev size (%lx) is larger than "
                ^
 /checkout/binutils/dwarf.c:1072:13: note: in expansion of macro '_'
        warn (_("Debug info is corrupted, abbrev size (%lx) is larger than "
              ^
 cc1: all warnings being treated as errors
 Makefile:1101: recipe for target 'dwarf.o' failed

The recent commit, casting one of the terms, has an obvious
typo.  To wit, the (non-cast) term abbrev_size is a
dwarf_vma and causes the whole expression to (still) be 64
bits.

binutils:
	* dwarf.c (process_abbrev_set): Properly parenthesize before
	casting to unsigned long.
2021-05-11 16:26:30 +02:00
Tom de Vries
5048549af9 [gdb/testsuite] Update infrun regexp in gdb.base/watch_thread_num.exp
The test-case gdb.base/watch_thread_num.exp contains an infrun regexp:
...
       -re "infrun:" {
...
which doesn't trigger because:
- the test-case doesn't contain "set debug infrun 1", and
- if we hack the test-case to add this, the regexp doesn't match
  because "[infrun] " is printed instead.

Make the test pass with "set debug infrun 1" and add the setting commented
out.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-05-11  Tom de Vries  <tdevries@suse.de>

	* gdb.base/watch_thread_num.exp: Fix "set debug infrun 1" FAILs.
	Add "set debug infrun 1" commented out.
2021-05-11 14:22:11 +02:00
Tom de Vries
2302f96354 [gdb/testsuite] Fix read1 timeout in gdb.base/gdb-sigterm.exp
When running check-read1, I run into a timeout in test-case
gdb.base/gdb-sigterm.exp:
...
  [infrun] handle_inferior_event: status->kind = stopped, \
    signal = GDB_SIGNAL_TRAP^M
  [infrun] start_step_over: enter^M
    [infrun] start_step_overFAIL: gdb.base/gdb-sigterm.exp: \
      expect eof #0 (timeout)
gdb.base/gdb-sigterm.exp: expect eof #0: stepped 0 times
FAIL: gdb.base/gdb-sigterm.exp: 50 SIGTERM passes
...

The corresponding gdb_test_multiple has an exp_continue clause, but it doesn't
trigger because the regexp greps for 'infrun: ' instead of '[infrun] '.

Fix the timeout by fixing the infrun regexp.

Tested on x86_64-linux, with check and check-read1.

gdb/testsuite/ChangeLog:

2021-05-11  Tom de Vries  <tdevries@suse.de>

	* gdb.base/gdb-sigterm.exp: Fix exp_continue regexp.
2021-05-11 14:22:11 +02:00
Bhuvanendra Kumar N
abb894a470 gdb/fortran: Breakpoint location is modified.
Breakpoint location is modified to "return" statement which is
outside the DO loop. Because the label 100 of DO loop should get
executed for each iteration as shared in this external link:
http://www-pnp.physics.ox.ac.uk/~gronbech/intfor/node18.html.
flang compiler is following this fortran standard, whereas gfortran
compiler is not following, hence the test case is passing with
gfortran and failing with flang. but to correct this gfortran
behavior, bug has been filed in bugzilla
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99816). As reported in
the bug, with gfortran, label 100 of DO loop is reached only after
the completion of the entire DO loop. Hence at label 100, all the
array elements are set and printing of array element a(2) succeeds.
whereas with flang, when we are at label 100 for first time, array
element a(2) is not yet set, only a(1) is set, hence moving the
breakpoint location to outside the DO loop, so that once we are
outside the DO loop, we can print any of the array elements. This
change in test case is done irrespective of any fortran compiler.

gdb/testsuite/ChangeLog:
        * gdb.fortran/array-element.exp: Breakpoint location is modified.
2021-05-11 17:50:00 +05:30
Alan Modra
8ca5537ba5 PR27844, Unstable symbol name in objdump outputs
Special care for fuzzers.

	PR 27844
	* pdp11.c (aout_get_external_symbols): Clear first four bytes of
	strings array, not just the first byte.
	* aoutx.h (aout_get_external_symbols): Likewise.
2021-05-11 21:38:39 +09:30
Nick Clifton
a680affc63 Fix an illegal memory access when attempting to disassemble a corrupt TIC30 binary.
PR 27840
	* tic30-dis.c (print_insn_tic30): Prevent attempts to read beyond
	the end of the code buffer.
2021-05-11 11:29:58 +01:00
Nick Clifton
22604fe675 Prevent libdel.dll.a from being installed on Windows based systems.
PR 27113
	* Makefile.am (install-data-local): Also delete libdep.dll.a if it
	is present.
	* Makefile.in: Regenerate.
2021-05-11 11:06:53 +01:00
Sergey Belyashov
cfe7a19169 Report illegal Z80 load instructions.
PR 27823
	* config/tc-z80.c (emit_ld_r_m): Report an illegal load
	instruction.
	* testsuite/gas/z80/ill_ops.s: New test source file.
	* testsuite/gas/z80/ill_ops.d: New test driver.
	* testsuite/gas/z80/ill_ops.l: New test error output.
2021-05-11 10:57:04 +01:00
Alan Modra
f2f9554bf0 PR27845, readelf heap-buffer-overflow
PR 27845
	* dwarf.c (process_abbrev_set): Replace start and end parameters
	with section, abbrev_base, abbrev_size, abbrev_offset.  Update
	all callers.  Sanity check parameters correctly and emit warnings
	here rather than..
	(process_debug_info): ..here.
2021-05-11 19:07:02 +09:30
GDB Administrator
2005aa0281 Automatic date update in version.in 2021-05-11 00:00:36 +00:00
Lancelot SIX
db1f6cd692 [PR gdb/27614] gdb-add-index fails on symlinks.
PR 27614 shows that gdb-add-index fails to generate the index when its
argument is a symlink.

The following one liner illustrates the reported problem:

        $ echo 'int main(){}'|gcc -g -x c -;ln -s a.out symlink;gdb-add-index symlink
        gdb-add-index: No index was created for symlink
        gdb-add-index: [Was there no debuginfo? Was there already an index?]
        $ ls -l
        -rwxr-xr-x 1 25712 Mar 19 23:05 a.out*
        -rw------- 1  8277 Mar 19 23:05 a.out.gdb-index
        lrwxrwxrwx 1     5 Mar 19 23:05 symlink -> a.out*

GDB generates the .gdb-index file with a name that matches the name of
the actual program (a.out.gdb-index here), not the symlink that
references it.  The remaining of the script is looking for a file named
after the provided argument (would be 'symlink.gdb-index' in our
example).

gdb/ChangeLog:

	PR gdb/27614
	* contrib/gdb-add-index.sh: Fix when called with a symlink as an
	argument.

gdb/testsuite/ChangeLog:

	PR gdb/27614
	* gdb.dwarf2/gdb-add-index-symlink.exp: New test.
2021-05-10 23:14:41 +01:00
H.J. Lu
b397aef4cd Remove strayed fprintf in commit 23182ac0d8
PR binutils/27839
	* simple.c (bfd_simple_get_relocated_section_contents): Remove
	strayed fprintf.
2021-05-10 12:50:33 -07:00
Andrew Burgess
9344937b04 gdb/testsuite: don't use source tree as temporary HOME directory
In this commit:

  commit 1845e25464
  Date:   Wed May 5 16:50:17 2021 +0100

      gdb/guile: perform tilde expansion when sourcing guile scripts

A test was added that tries to source a guile script from the users
HOME directory.  In order to achieve this the test (temporarily)
modifies $HOME to point into the binutils-gdb source tree.

The problem with this is that sourcing a guile script can cause the
guile script to be byte compiled and written into a .cache/ directory,
which is stored .... in the $HOME directory.

The result was that the test added in the above commit would cause a
.cache/ directory to be added into the binutils-gdb source tree.

In this commit the test is updated to create a new directory in the
build tree, the file we want to source is copied over, and $HOME is
set to point at the location in the build tree.  Now when the test is
run the .cache/ directory is created in the build tree, leaving the
source tree untouched.

gdb/testsuite/ChangeLog:

	* gdb.guile/guile.exp: Don't use the source directory as a
	temporary HOME directory.
2021-05-10 17:56:16 +01:00
Simon Marchi
0709cf686d gdb/testsuite: use proc parameters in gdb.arch/amd64-osabi.exp
This test has a little oversight: the test procedure doesn't actually
use its parameters, the commands and expected patterns are hard-coded,
so we always test with i386:x86-64, instead of with the three arches.
Fix that.

gdb/testsuite/ChangeLog:

	* gdb.arch/amd64-osabi.exp (test_osabi_none): Use the
	parameters.

Change-Id: Iee2c32963d09e502ae791d5df2b6c04a1f49a57a
2021-05-10 12:43:07 -04:00
Simon Marchi
31aceaef1c gdb, gdbserver: make status_to_str display the signal name
I was looking at some "set debug lin-lwp" logs, and saw that a thread
received the "Child exited" signal.  It took me a moment to realize that
this was SIGCHLD.  I then thought that it would be nice for
status_to_str to show the signal name (SIGCHLD) in addition to the
description "Child exited", since people are much more used to referring
to signals using their names.

Fortunately, libiberty contains a handy function to get the signal name
from the signal number, strsigno, use that.

The output of "set debug lin-lwp" now looks like:

    [linux-nat] linux_nat_wait_1: waitpid 1209631 received SIGTRAP - Trace/breakpoint trap (stopped)

gdb/ChangeLog:

	* nat/linux-waitpid.c (status_to_str): Show signal name.

Change-Id: I8ad9b1e744dd64461fd87b08d5c29f9ef97c4691
2021-05-10 12:13:36 -04:00
Nick Clifton
23182ac0d8 Fix an indirection via uninitialised memory when parsing a corrupt input file.
PR 27839
	* simple.c (simple_dummy_add_to_set): New function.
	(simple_dummy_constructor): New function.
	(simple_dummy_multiple_common): New function.
	(bfd_simple_get_relocated_section_contents): Zero out the
	callbacks structure, and then set the add_to_set, constructor and
	multiple_common fields.
2021-05-10 14:44:31 +01:00
Dimitar Dimitrov
5b45e89f56 Enable linker garbage collection for the PRU target.
bfd	* elf32-pru.c (elf_backend_can_gc_sections): Define as 1.

ld	* testsuite/ld-elf/group8a.d: Remove pru from XFAIL list.
	* testsuite/ld-elf/group8b.d: Ditto.
	* testsuite/ld-elf/group9a.d: Ditto.
	* testsuite/ld-elf/group9b.d: Ditto.
	* testsuite/ld-elf/pr12851.d: Ditto.
	* testsuite/ld-elf/pr22677.d: Ditto.
	* testsuite/lib/ld-lib.exp (check_gc_sections_available): Remove
	pru from list.
2021-05-10 14:00:00 +01:00
Dimitar Dimitrov
261980de18 PRU: Add alignment for resource table, and allow sizes of memory regions to be set from the command line.
ld	* scripttempl/pru.sc (.resource_table): Add ALIGN directive.
	Use symbols for memory sizes.
2021-05-10 13:58:17 +01:00
Sergey Belyashov
e4b1ab2062 Add support for 8-bit and 24-bit shifts in the z80 assembler.
PR 27415
	* config/tc-z80.c (emit_data_val): Add support for 8-bit and
	24-bit shifts.
	* testsuite/gas/z80/z80_reloc.a: Update tests.
	* testsuite/gas/z80/z80_reloc.d: Update expected disassembly.
2021-05-10 13:36:08 +01:00
Thomas Wolff
749c700282 Restore old behaviour of windres so that options containing spaces are not enclosed in double quotes.
PR 4356
	PR 26865
	PR 27594
	* windres.c (quot): Revert previous delta.  Do not use double
	quotes when spaces are detected in options.
	* doc/binutils.texi (windres): Remove suggestion that the
	--preprocessor option can take arguments.
2021-05-10 11:28:15 +01:00
Andrew Burgess
802021d46d gdb/doc: reword a sentence
Change this:

  The available watchpoint types represented by constants are defined
  in the gdb module:

to this:

  The available watchpoint types are represented by constants defined
  in the gdb module:

The new version matches a similar line a few lines up the document
which reads:

  The available types are represented by constants defined in the gdb
  module:

gdb/doc/ChangeLog:

	* guile.texinfo (Breakpoints In Guile): Reword sentence.
	* python.texinfo (Breakpoints In Python): Reword sentence.
2021-05-10 10:09:33 +01:00
Alan Modra
2d4b49864e Avoid possible pointer wrap
PTR supplied to these macros can be read from user input, END is an
end of buffer pointer.  It's safer to do arithmetic on END than on PTR.

	* dwarf.c (SAFE_BYTE_GET): Check bounds by subtracting amount from
	END rather than adding amount to PTR.
	(SAFE_SIGNED_BYTE_GET, SAFE_BYTE_GET64): Likewise.
2021-05-10 10:03:00 +09:30
GDB Administrator
400f0c9b88 Automatic date update in version.in 2021-05-10 00:00:37 +00:00
Andrew Burgess
9dffa1aa8e gdb/doc: document 'set debug py-unwind'
When the 'set debug py-unwind' flag was added, it was never documented
in the manual.  This commit adds some text for this command to the
manual.

gdb/doc/ChangeLog:

	* python.texinfo (Python Commands): Document 'set debug
	py-unwind' and 'show debug py-unwind'.
2021-05-09 16:50:16 +01:00
Andrew Burgess
75140e3b75 gdb/py: add some debugging to py-breakpoint.c
Adds some new debugging to python/py-breakpoint.c.

gdb/ChangeLog:

	* python/py-breakpoint.c (pybp_debug): New static global.
	(show_pybp_debug): New function.
	(pybp_debug_printf): Define.
	(PYBP_SCOPED_DEBUG_ENTER_EXIT): Define.
	(gdbpy_breakpoint_created): Add some debugging.
	(gdbpy_breakpoint_deleted): Likewise.
	(gdbpy_breakpoint_modified): Likewise.
	(_initialize_py_breakpoint): New function.

gdb/doc/ChangeLog:

	* python.texinfo (Python Commands): Document 'set debug
	py-breakpoint' and 'show debug py-breakpoint'.
2021-05-09 16:50:16 +01:00
Andrew Burgess
1ef40c1362 gdb/py: convert debug logging in py-unwind to use new scheme
Converts the debug print out in python/py-unwind.c to use the new
debug printing scheme.  I have also modified what is printed in a few
places, for example, rather than printing frame pointers, I now print
the frame level, this matches what we do in the general 'set debug
frame' tracing, and is usually more helpful (I think).

I also added a couple of ENTER/EXIT scope printers.

gdb/ChangeLog:

	* python/py-unwind.c (pyuw_debug): Convert to bool.
	(show_pyuw_debug): New function.
	(pyuw_debug_printf): Define.
	(PYUW_SCOPED_DEBUG_ENTER_EXIT): Define.
	(pyuw_this_id): Convert to new debug print macros.
	(pyuw_prev_register): Likewise.
	(pyuw_sniffer): Likewise.
	(pyuw_dealloc_cache): Likewise.
	(_initialize_py_unwind): Update now pyuw_debug is a bool, and add
	show function when registering.
2021-05-09 16:50:15 +01:00