Commit Graph

108015 Commits

Author SHA1 Message Date
Mike Frysinger
4f2b181ecb sim: standardize move-if-change rules
Use the srcroot path and make them all silent.
2021-10-31 00:39:40 -04:00
Mike Frysinger
bdcbd1b67f sim: mips/v850: remove redundant variable setup
The common/Make-common.in fragment already provides these variables.
2021-10-31 00:23:36 -04:00
Orgad Shaneh
1352aabb23 sim: fix compilation on mingw64 [PR sim/28476]
...by reordering includes.

1. sim-utils.c

sim/mips/sim-main.h defines UserMode, while there is a struct in winnt.h
which has UserMode as a member. So if sim-main.h is included before winnt.h,
compilation fails.

2. ppc

registers.h defines CR, which is used as a member in winnt.h.

winsock2.h is included by sys/time.h, so sys/time.h has to be included
before registers.h.

Bug: https://sourceware.org/PR28476
2021-10-30 23:50:09 -04:00
Alan Modra
590abc168f Don't include coff/pe.h in coff-x86_64.c
This (and other) code from coffcode.h is broken for x86_64_coff_vec,
and has been ever since support was added in 2006 commit 99ad839030
Here, bfd_coff_aoutsz must match coff_swap_aouthdr_out otherwise we
end up writing garbage.

      /* Note that peicode.h fills in a PEAOUTHDR, not an AOUTHDR.
	 include/coff/pe.h sets AOUTSZ == sizeof (PEAOUTHDR)).  */
      char * buff;
      bfd_size_type amount = bfd_coff_aoutsz (abfd);

      buff = (char *) bfd_malloc (amount);
      if (buff == NULL)
	return false;

      coff_swap_aouthdr_out (abfd, & internal_a, buff);
      amount = bfd_bwrite (buff, amount, abfd);

We have removed support for --target=x86_64-coff, likely because it
never worked properly, but still produce coff-x86_64.o with
--enable-targets=all.  This means objcopy can recognize x86_64 COFF
files but will write garbage to the output file, a fact found by
fuzzers.  I suspect x86_64 COFF is still broken after this fix, and
mention of coff-x86_64.* should be removed from bfd/Makefile.am.

	* coff-x86_64.c: Don't include coff/pe.h.
	(COFF_WITH_pex64): Don't define here.
	* pe-x86_64.c: Include coff/pe.h and other headers.
	(PEI_HEADERS): Define.
2021-10-31 11:42:52 +10:30
Alan Modra
1c5e9d8d8c Re: PR28420, ecoff fuzzing failures
sym_ptr_ptr NULL results in segfaults.

	PR 28420
	* ecoff.c (ecoff_slurp_reloc_table): Don't leave sym_ptr_ptr NULL.
2021-10-31 11:42:08 +10:30
Alan Modra
9216910ed8 ubsan: alpha-vms: undefined shift
* vms-alpha.c (evax_bfd_print_image): Shift left 1u.
2021-10-31 11:41:39 +10:30
Alan Modra
3c8ed65a5d PR28518: signed integer overflow & free on unmalloced address
PR 28518
	* vms-alpha.c (build_module_list): Don't lose malloc buffer address.
	Use unsigned variables.
2021-10-31 10:57:52 +10:30
GDB Administrator
fb9f44d410 Automatic date update in version.in 2021-10-31 00:00:09 +00:00
Simon Marchi
311d36251d gdb: fix gdb.gdb/unittest.exp with C++17 compiler
On a machine with gcc 11, I get:

    FAIL: gdb.gdb/unittest.exp: test_completion: tab complete "maintenance selftest string_v" (second tab) (timeout)
    FAIL: gdb.gdb/unittest.exp: test_completion: tab complete "maintenance selftest string_vie" (timeout)

That's because when compiling with C++ >= 17, we use the standard
version of string_view, and don't have a selftest for it.  So the list
of selftests shown by the tab completion when completing "string_v"
differs.

Change the test to use the copy_* tests instead.

Change-Id: I85f6aa44ee5fc9652b9bd4451e0506b89773526b
2021-10-29 22:17:07 -04:00
Aaron Merey
3ea44f2129 gdb.texinfo: Expand documentation for debuginfod
Add section describing GDB's usage of debuginfod.

Refer to this new section in the description of the '--with-debuginfod'
configure option.

Mention debuginfod in the 'Separate Debug Files' section.
2021-10-29 20:58:21 -04:00
Aaron Merey
7811fa5995 gdb: add set/show commands for managing debuginfod
Add 'set debuginfod' command.  Accepts 'on', 'off' or 'ask' as an
argument.  'on' enables debuginfod for the current session.  'off'
disables debuginfod for the current session.  'ask' will prompt
the user to either enable or disable debuginfod when the next query
is about to be performed:

    This GDB supports auto-downloading debuginfo from the following URLs:
    <URL1> <URL2> ...
    Enable debuginfod for this session? (y or [n]) y
    Debuginfod has been enabled.
    To make this setting permanent, add 'set debuginfod on' to .gdbinit.

For interactive sessions, 'ask' is the default.  For non-interactive
sessions, 'off' is the default.

Add 'show debuginfod status' command.  Displays whether debuginfod
is set to 'on', 'off' or 'ask'.

Add 'set/show debuginfod urls' commands. Accepts a string of
space-separated debuginfod server URLs to be queried.  The default
value is copied from the DEBUGINFOD_URLS environment variable.

Finally add 'set/show debuginfod verbose' commands to control whether
debuginfod-related output is displayed.  Verbose output is enabled
by default.

    (gdb) run
    Starting program: /bin/sleep 5
    Download failed: No route to host.  Continuing without debug info for /lib64/libc.so.6.

If GDB is not built with debuginfod then these commands will just display

    Support for debuginfod is not compiled into GDB.
2021-10-29 20:58:21 -04:00
GDB Administrator
4a3a56c5f3 Automatic date update in version.in 2021-10-30 00:00:26 +00:00
Simon Marchi
51e36a3aaa gdb: remove TYPE_FIELD_DWARF_BLOCK
Remove TYPE_FIELD_DWARF_BLOCK, replace with type::field +
field::loc_dwarf_block.

Change-Id: I10af9410bb5f46d342b8358a7956998c7e804b64
2021-10-29 16:44:45 -04:00
Simon Marchi
e06c3e112e gdb: remove TYPE_FIELD_STATIC_PHYSADDR
Remove TYPE_FIELD_STATIC_PHYSADDR replace with type::field +
field::loc_physaddr.

Change-Id: Ica9bc4a48f34750ec82ec86c298d3ecece81bcbd
2021-10-29 16:44:45 -04:00
Simon Marchi
fcbbbd90f0 gdb: remove TYPE_FIELD_STATIC_PHYSNAME
Remove TYPE_FIELD_STATIC_PHYSNAME, replace with type::field +
field::loc_physname.

Change-Id: Ie35d446b67dd1d02f39998b406001bdb7e6d5abb
2021-10-29 16:44:45 -04:00
Simon Marchi
970db51860 gdb: remove TYPE_FIELD_ENUMVAL
Remove TYPE_FIELD_ENUMVAL, replace with type::field +
field::loc_enumval.

Change-Id: I2ada73e4635aad3363ce2eb22c1dc52698ee2072
2021-10-29 16:44:45 -04:00
Simon Marchi
b610c04548 gdb: remove TYPE_FIELD_BITPOS
Remove TYPE_FIELD_BITPOS, replace its uses with type::field +
field::loc_bitpos.

Change-Id: Iccd8d5a77e5352843a837babaa6bd284162e0320
2021-10-29 16:44:44 -04:00
Simon Marchi
2ad53ea10c gdb: remove TYPE_FIELD_LOC_KIND
Remove TYPE_FIELD_LOC_KIND, replace its uses with type::field +
field::loc_kind.

Change-Id: Ib124a26365df82ac1d23df7962d954192913bd90
2021-10-29 16:44:21 -04:00
Simon Marchi
d8557c3d22 gdb: remove FIELD_DWARF_BLOCK macro
Remove FIELD_DWARF_BLOCK, replace its uses with field::loc_dwarf_block.

Change-Id: I66b7d6a960cb5e341e61e21bd3cc9a6ac26de6a8
2021-10-29 16:44:21 -04:00
Simon Marchi
31a1516a81 gdb: remove FIELD_STATIC_PHYSADDR macro
Remove FIELD_LOC_KIND_PHYSADDR, replace its uses with
field::loc_physaddr.

Change-Id: Ifd8b2bdaad75f42bfb1404ef8c396ffe7e10ac55
2021-10-29 16:44:21 -04:00
Simon Marchi
16654a591a gdb: remove FIELD_STATIC_PHYSNAME macro
Remove FIELD_STATIC_PHYSNAME, replace its uses with field::loc_physname.

Change-Id: Iaa8952410403b4eb5bbd68411feea27e2405d657
2021-10-29 16:44:21 -04:00
Simon Marchi
5d2038e3f5 gdb: remove FIELD_ENUMVAL macro
Remove FIELD_ENUMVAL, replace its uses with field::loc_enumval.

Change-Id: Id4861cee91a8bb583a9836f1aa5da0a320fbf4d9
2021-10-29 16:44:21 -04:00
Simon Marchi
3a543e211e gdb: remove FIELD_BITPOS macro
Remove FIELD_BITPOD, replace its uses with field::loc_bitpos.

Change-Id: Idb99297e0170661254276c206383a7e9bf1a935a
2021-10-29 16:44:21 -04:00
Simon Marchi
8d939e8ea4 gdb: remove FIELD_LOC_KIND macro
Remove FIELD_LOC_KIND, replace its uses with field::loc_kind or
call_site_target::loc_kind.

Change-Id: I0368d8c3ea269d491bb215aa70e32edbdf55f389
2021-10-29 16:44:20 -04:00
Tom Tromey
d3771fe234 Add gdb.Architecture.integer_type Python function
This adds a new Python function, gdb.Architecture.integer_type, which
can be used to look up an integer type of a given size and
signed-ness.  This is useful to avoid dependency on debuginfo when a
particular integer type would be useful.

v2 moves this to be a method on gdb.Architecture and addresses other
review comments.
2021-10-29 07:52:31 -06:00
Tom Tromey
7a72f09da5 Remove ada_value_print_inner
I noticed that the only caller of ada_value_print_inner is
valprint.c:do_val_print (via ada_language::value_print_inner), meaning
that the try/catch logic in this function is redundant.  This patch
removes the wrapper function.

Regression tested on x86-64 Fedora 34.
2021-10-29 07:46:28 -06:00
Tom Tromey
52429bbd71 Document resolve_dynamic_type oddity
Today I re-learned that resolve_dynamic_type can return a type for
which is_dynamic_type returns true.  This can happen for an array
whose elements have dynamic type -- the array is reported as dynamic,
but resolving the elements would be incorrect, because each element
might have a different type after resolution.

You can see the special case in resolve_dynamic_array_or_string:

  if (ary_dim != NULL && ary_dim->code () == TYPE_CODE_ARRAY)
...
  else
...

I looked into having the TYPE_CODE_ARRAY case in
is_dynamic_type_internal follow this same logic, but that breaks down
on the gdb.fortran/dynamic-ptype-whatis.exp test case.  In particular
this code in fortran_undetermined::evaluate:

  value *callee = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
  if (noside == EVAL_AVOID_SIDE_EFFECTS
      && is_dynamic_type (value_type (callee)))
    callee = std::get<0> (m_storage)->evaluate (nullptr, exp, EVAL_NORMAL);

... relies on is_dynamic_type returning true for such an array.

I wasn't really sure of the best way to fix this, so in the meantime I
wrote this patch, which documents the oddity so that I might have a
chance of remembering this in the future.
2021-10-29 07:33:13 -06:00
Tom Tromey
9e6978753d Avoid self-test failures on x86-linux
The disassembly tests in "maint selftest" will fail on x86-linux.
This happens because opcodes rejects an attempt to disassemble for an
arch with a 64-bit address size when bfd_vma is 32-bit.

This patch avoids this problem by avoiding the test in this case.  I
chose to do it this way because this seems to be the only situation
where opcodes checks the size of bfd_vma.

For v2 of this patch, I've also updated memory_error_test to do the
same thing.  This is needed due to the "improve error reporting from
the disassembler" patch.
2021-10-29 07:23:38 -06:00
Tom de Vries
b88e456f7e [gdb/build] Fix build with --disable-unit-tests
A build with --disable-unit-tests currently run into:
...
ld: maint.o: in function \
  `maintenance_selftest_completer(cmd_list_element*, completion_tracker&,
                                  char const*, char const*)':
src/gdb/maint.c:1183: undefined reference to \
  `selftests::for_each_selftest(
    gdb::function_view<
      void (std::__cxx11::basic_string<char,std::char_traits<char>,
                                       std::allocator<char> > const&)>)'
...

Fix this by guarding the call to selftests::for_each_selftest in
maintenance_selftest_completer with GDB_SELF_TEST, such that the "-verbose"
completion still works.

Rebuild on x86_64-linux and ran gdb.gdb/unittest.exp.
2021-10-29 14:11:08 +02:00
Enze Li
91b7c7e522 Document "memory-tag-violations".
* gdb/doc/gdb.texinfo: (Data): Document	'-memory-tag-violations'.
 (Command Options): Update the example.
2021-10-29 13:31:37 +03:00
Tejas Belagod
09854a8870 Support for a new pacbti unwind opcode.
This patch adds readelf support for decoding the exception table
opcode for restoring the RA_AUTH_CODE pseudo register defined by the
EHABI
(https://github.com/ARM-software/abi-aa/releases/download/2021Q1/ehabi32.pdf
Section 10.3).

	* readelf.c (decode_arm_unwind_bytecode): Add support to decode
	restoring RA_AUTH_CODE pseudo register.
2021-10-29 20:37:17 +10:30
Alan Modra
dd6b67bec8 Re: arm: add unwinder encoding support for PACBTI
Move the gas testsuite files to where they belong.
2021-10-29 19:46:18 +10:30
Alan Modra
c45c3dba8c ELF core file size checks
Catch fuzzed segments where p_offset + p_filesz wraps, and limit error
output.

	* elfcore.h (elf_core_file_p): Rewrite segment checks using
	bfd_get_file_size.  Set read_only on file size errors.
	* elfcode.h (elf_swap_shdr_in): Don't repeat error message.
2021-10-29 17:22:32 +10:30
Alan Modra
c82ebeb7e6 obcopy vs. files with silly section alignment
We already ignore stupid segment alignment when rewriting headers,
ignore section alignment too.

	* elf.c (rewrite_elf_program_header): Ignore section alignment
	power greater than 62.
2021-10-29 15:48:22 +10:30
GDB Administrator
208eb58158 Automatic date update in version.in 2021-10-29 00:00:18 +00:00
Stafford Horne
cb22a7c366 gdb: Add OpenRISC gdbserver and native config news
The previous patches added gdbserver and native debugging support
for OpenRISC targets.  This patch documents that in the news.
2021-10-29 05:54:44 +09:00
Stafford Horne
5729359001 gdb: or1k: add single step for linux native debugging
Needed for single stepping in Linux, this adds the or1k implementation
of or1k_software_single_step.  Most of the implementation is borrowed
from the bare metal single step code from or1k_single_step_through_delay
which has been extracted and shared in helper function
or1k_delay_slot_p.
2021-10-29 05:22:13 +09:00
Stafford Horne
a45b1e66c5 gdb: or1k: add native linux support
This patch adds support for running gdb natively on OpenRISC linux.
Debugging support is provided via the linux PTRACE interface which is
mostly handled by GDB genric code.  This patch provides the logic of how
to read and write the ptrace registers between linux and GDB.

Single stepping is privided in a separate patch.
2021-10-29 05:22:12 +09:00
Stafford Horne
d336377196 gdb: or1k: add generated linux descriptor file 2021-10-29 05:22:12 +09:00
Stafford Horne
d786a34732 gdb: or1k: fixup linux regcache comment
The old comment was not properly updated from the RISC-V example used.
Update it to match OpenRISC.
2021-10-29 05:22:12 +09:00
Stafford Horne
4933265c3f gdb: or1k: implement gdb server
This patch adds gdbserver support for OpenRISC.  This has been used for
debugging the glibc port that in being worked on here:

  https://github.com/openrisc/or1k-glibc/tree/or1k-port-2

Hence the comment about registers definitions being inline with glibc.
2021-10-29 05:22:12 +09:00
Christian Biesinger
cf365c10d0 [sim] Include defs.h in ppc/hw_memory.c
To fix this error (seen on cygwin):
/../../sim/ppc/../common ../../../sim/ppc/hw_memory.c
In file included from ../../gnulib/import/stdlib.h:100,
                 from ../../../sim/ppc/hw_memory.c:28:
../../gnulib/import/unistd.h:663:3: error: #error "Please include config.h first."
  663 |  #error "Please include config.h first."
      |   ^~~~~
../../gnulib/import/unistd.h:665:24: error: expected ';' before 'extern'
  665 | _GL_INLINE_HEADER_BEGIN
      |                        ^
      |                        ;
../../gnulib/import/unistd.h:2806:22: error: expected ';' before 'extern'
 2806 | _GL_INLINE_HEADER_END
      |                      ^
      |                      ;
2021-10-28 15:09:00 -04:00
Markus Klein
d6dc01baf7 ARM assembler: Allow up to 32 single precision registers in the VPUSH and VPOP instructions.
PR 28436
	* config/tc-arm.c (do_vfp_nsyn_push_pop_check): New function.
	(do_vfp_nsyn_pop): Use the new function.
	(do_vfp_nsyn_push): Use the new function.
	* testsuite/gas/arm/v8_1m-mve.s: Add new instructions.
	* testsuite/gas/arm/v8_1m-mve.d: Updated expected disassembly.
2021-10-28 17:17:25 +01:00
Simon Marchi
0fab795564 gdb: use ptid_t::to_string in infrun debug messages
In debug messages, I think it would be more helpful to print ptid using
the simple "pid.lwp.tid" notation in infrun debug messages.  I am
currently debugging some fork issues, and find the pid_to_str output not
so useful, as it doesn't tell which process a thread belongs to.

It currently shows up like this:

    [infrun] resume_1: step=1, signal=GDB_SIGNAL_0, trap_expected=0, current thread [Thread 0x7ffff7d95740 (LWP 892942)] at 0x55555555521f

With the patch, it shows up like this:

    [infrun] resume_1: step=1, signal=GDB_SIGNAL_0, trap_expected=1, current thread [894072.894077.0] at 0x5555555551d9

Change-Id: I130796d7dfb0d8e763b8358d8a6002701d80c4ea
2021-10-28 11:25:45 -04:00
Simon Marchi
c0492bea7c gdb: add selftest name completion
After the previous commit, it is easy to add completion for selftest
names.  Again, this is not particularly high value, but I rarely touched
completion, so it served as a simple example to get some practice.

Change the for_each_selftest_ftype parameter to gdb::function_view, so
that we can pass a lambda that captures things.

Change-Id: I87cac299ddca9ca7eb0ffab78342e850a98d954c
2021-10-28 11:17:45 -04:00
Tejas Belagod
8c2999954b arm: add unwinder encoding support for PACBTI
This patch adds support for encoding the Return Address Authentication pseudo
register - '.save {ra_auth_code}' as defined by the DWARF ABI - in the
exception tables where the opcode is defined by the EHABI

gas/Changelog:

	* config/tc-arm.c (arm_reg_type): Add new type REG_TYPE_PSEUDO.
	(reg_expected_msgs): Add message for pseudo reg type.
	(reg_list_els): Add new reg list type REGLIST_PSEUDO.
	(parse_reg_list): Handle new REGLIST_PSEUDO type.
	(s_arm_unwind_save_pseudo): Encode pseudo reg list save in exception
	tables.
	(s_arm_unwind_save): Handle new REG_TYPE_PSEUDO.
	(reg_names): Add ra_auth_code pseudo register.
	* testsuite/gas/arm/unwind-pacbti-m.s: New test.
	* testsuite/gas/arm/unwind-pacbti-m.d: New test.
	* testsuite/gas/arm/unwind-pacbti-m-readelf.d: New test.
2021-10-28 15:56:02 +01:00
Simon Marchi
a1ff87d77c gdb: add "maint set/show selftest verbose" commands and use process_options
I saw the new -verbose switch to "maint selftests" and thought it would
be nice for it to use the option framework.  For example, that makes
having completion easy.  It's not that high value, given this is a
maintenance command, but I had never used the framework myself, so it
was a good way to practice.

This patch also adds the "maint set/show selftest verbose" setting.  It
would be possible to use option framework without adding the setting,
but using the framework makes adding the option almost trivial, so I
thought why not.

Change-Id: I6687faa0713ff3da60b398253211777100094144
2021-10-28 10:48:16 -04:00
Tom de Vries
2e466f72c4 [gdb/testsuite] Update some test-cases to GPLv3
I noticed some files in the test-suite have GPLv2 notices.

Update these to GPLv3.
2021-10-28 16:47:07 +02:00
Simon Marchi
f54bdb6d27 gdb: add add_setshow_prefix_cmd
There's a common pattern to call add_basic_prefix_cmd and
add_show_prefix_cmd to add matching set and show commands.  Add the
add_setshow_prefix_cmd function to factor that out and use it at a few
places.

Change-Id: I6e9e90a30e9efb7b255bf839cac27b85d7069cfd
2021-10-28 10:44:18 -04:00
Tom de Vries
5ad2694b1e [gdb/testsuite] Require python in gdb.server/server-kill-python.exp
I came across this when running test-case gdb.server/server-kill-python.exp
with a gdb configured without python:
...
builtin_spawn gdb -nw -nx -data-directory data-directory -iex set height 0 \
  -iex set width 0 -quiet -iex set height 0 -iex set width 0 \
  -ex source outputs/gdb.server/server-kill-python/file1.py^M
FAIL: gdb.server/server-kill-python.exp: ensure inferior is running
Executing on target: kill -9 28535    (timeout = 300)
builtin_spawn -ignore SIGHUP kill -9 28535^M
file1.py:1: Error in sourced command file:^M
Undefined command: "import".  Try "help".^M
...

Fix this by testing for python support in the test-case.

Tested on aarch64-linux (with python support disabled) and x86_64-linux (with
python support enabled).
2021-10-28 14:18:15 +02:00