Add new API for systems with native kernel support for dumping
a process on demand. Wire it into the gdb's gcore functionality.
gdb/ChangeLog:
* target.h (supports_dumpcore, dumpcore): New
function declarations.
* target.c (supports_dumpcore, dumpcore): New
functions.
* target-delegates.c: Rebuild.
* gcore.c (gcore_command): Use target_supports_dumpcore ()
and target_dumpcore ().
Store query information in user_data struct instead of global variables.
gdb/ChangeLog:
* debuginfod-support.c: Replace global variables with user_data.
There is a bit of a situation in the ARM sim with regards to the handling
of argv. sim_open () gets a const char **argv, but ARM's sim_open gets
clever and decides to modify argv in place via sim_target_parse_command_line.
I'm not sure why.
In any case, here's a fix that makes the code modify a copy of argv instead.
sim/arm/ChangeLog:
2020-08-13 Luis Machado <luis.machado@linaro.org>
PR sim/26365
* wrapper.c (sim_target_parse_command_line): Free discarded argv
entries.
(sim_open): Use a duplicate of argv instead of the original argv.
I found myself wanting to run a few specific selftests while developing.
I thought it would be nice to be able to provide multiple test names
when running `maintenant selftests`. The arguments to that command is
currently interpreted as a single filter (not split by spaces), it now
becomes a list a filters, split by spaces. A test is executed when it
matches at least one filter.
Here's an example of the result in GDB:
(gdb) maintenance selftest xml
Running selftest xml_escape_text.
Running selftest xml_escape_text_append.
Ran 2 unit tests, 0 failed
(gdb) maintenance selftest xml unord
Running selftest unordered_remove.
Running selftest xml_escape_text.
Running selftest xml_escape_text_append.
Ran 3 unit tests, 0 failed
(gdb) maintenance selftest xml unord foobar
Running selftest unordered_remove.
Running selftest xml_escape_text.
Running selftest xml_escape_text_append.
Ran 3 unit tests, 0 failed
Since the selftest machinery is also shared with gdbserver, I also
adapted gdbserver. It accepts a `--selftest` switch, which accepts an
optional filter argument. I made it so you can now pass `--selftest`
multiple time to add filters.
It's not so useful right now though: there's only a single selftest
right now in GDB and it's for an architecture I can't compile. So I
tested by adding dummy tests, here's an example of the result:
$ ./gdbserver --selftest=foo
Running selftest foo.
foo
Running selftest foobar.
foobar
Ran 2 unit tests, 0 failed
$ ./gdbserver --selftest=foo --selftest=bar
Running selftest bar.
bar
Running selftest foo.
foo
Running selftest foobar.
foobar
Ran 3 unit tests, 0 failed
gdbsupport/ChangeLog:
* selftest.h (run_tests): Change parameter to array_view.
* selftest.c (run_tests): Change parameter to array_view and use
it.
gdb/ChangeLog:
* maint.c (maintenance_selftest): Split args and pass array_view
to run_tests.
gdbserver/ChangeLog:
* server.cc (captured_main): Accept multiple `--selftest=`
options. Pass all `--selftest=` arguments to run_tests.
Change-Id: I422bd49f08ea8095ae174c5d66a2dd502a59613a
This new option effectively ignores R_PPC64_PCREL_OPT, disabling the
optimization of instructions marked by that relocation. The patch
also disables GOT indirect to GOT/TOC pointer relative code editing
when --no-toc-optimize.
bfd/
* elf64-ppc.h (struct ppc64_elf_params): Add no_pcrel_opt.
* elf64-ppc.c (ppc64_elf_relocate_section): Disable GOT reloc
optimizations when --no-toc-optimize. Disable R_PPC64_PCREL_OPT
optimization when --no-pcrel-optimize.
ld/
* emultempl/ppc64elf.em (params): Init new field.
(enum ppc64_opt): Add OPTION_NO_PCREL_OPT.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS),
(PARSE_AND_LIST_ARGS_CASES): Support --no-pcrel-optimize.
This adds a few more sanity checks on ELF objects, and a BFD flag to
disable objcopy and strip when fuzzed input files belong in the "too
hard" basket.
bfd/
PR 26348
* bfd.c (struct bfd): Add read_only.
* elfcode.h (elf_swap_shdr_in): Test both sh_offset and sh_size.
Set read_only on warning.
(elf_object_p): Sanity check program header alignment. Set
read_only on warning.
* bfd-in2.h: Regenerate.
binutils/
PR 26348
* objcopy.c (copy_object): Report file name with endian error.
Error and return on abfd->read_only.
During debugging of PR26362, it was noticed that the malloc size check
in check_type_length_before_alloc wasn't detecting an allocation attempt
of a huge amount of bytes, making GDB run into an internal error.
This happens because we're using an int to store a type's length. When the
type length is large enough, the int will overflow and the max_value_size
check won't work anymore.
The following patch fixes this by making the length variable a ULONGEST.
Printing statements were also updated to show the correct number of bytes.
gdb/ChangeLog:
2020-08-12 Luis Machado <luis.machado@linaro.org>
* value.c (check_type_length_before_alloc): Use ULONGEST to store a
type's length.
Use %s and pulongest to print the length.
Simon noticed that I managed to put this in the "Changes in GDB 9"
section by mistake instead of in the "Changes since GDB 9" section
where it belongs.
gdb/ChangeLog:
* NEWS: Move "Multi-target debugging support" item to the
"Changes since GDB 9" section.
gdb.base/corefile.exp is showing an unexpected failure and an
unresolved testcase when testing against unix/-m32:
(gdb) PASS: gdb.base/corefile.exp: attach: sanity check we see the core file
attach 15741
gdb/dwarf2-frame.c:1009: internal-error: dwarf2_frame_cache* dwarf2_frame_cache(frame_info*, void**): Assertion `fde != NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) FAIL: gdb.base/corefile.exp: attach: with core (GDB internal error)
Resyncing due to internal error.
This regressed with:
From 5b6d1e4fa4 Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Fri, 10 Jan 2020 20:06:08 +0000
Subject: [PATCH] Multi-target support
The assertion is here:
#0 internal_error (file=0xbffffccb0 <error: Cannot access memory at address 0xbffffccb0>, line=0, fmt=0x555556327320 "en_US.UTF-8") at sr
c/gdbsupport/errors.cc:51
#1 0x00005555557d4e45 in dwarf2_frame_cache (this_frame=0x55555672f950, this_cache=0x55555672f968) at src/gdb/dwarf2/frame.c:1013
#2 0x00005555557d5886 in dwarf2_frame_this_id (this_frame=0x55555672f950, this_cache=0x55555672f968, this_id=0x55555672f9b0) at src/gdb/d
warf2/frame.c:1226
#3 0x00005555558b184e in compute_frame_id (fi=0x55555672f950) at src/gdb/frame.c:558
#4 0x00005555558b19b2 in get_frame_id (fi=0x55555672f950) at src/gdb/frame.c:588
#5 0x0000555555bda338 in scoped_restore_current_thread::scoped_restore_current_thread (this=0x7fffffffd0d8) at src/gdb/thread.c:1458
#6 0x00005555556ce41f in scoped_restore_current_pspace_and_thread::scoped_restore_current_pspace_and_thread (During symbol reading: .debug_line address at offset 0x1db2d3
is 0 [in module /home/pedro/gdb/cascais-builds/binutils-gdb/gdb/gdb]
this=0x7fffffffd0d0) at src/gdb/progspace-and-thread.h:29
#7 0x0000555555898ea6 in remove_target_sections (owner=0x555556935550) at src/gdb/exec.c:798
#8 0x0000555555b700b6 in symfile_free_objfile (objfile=0x555556935550) at src/gdb/symfile.c:3742
#9 0x000055555565050e in std::_Function_handler<void (objfile*), void (*)(objfile*)>::_M_invoke(std::_Any_data const&, objfile*&&) (__functor=..., __args#0=@0x7fffffffd190
: 0x555556935550) at /usr/include/c++/9/bits/std_function.h:300
#10 0x0000555555a3053d in std::function<void (objfile*)>::operator()(objfile*) const (this=0x555556752a20, __args#0=0x555556935550) at /usr/include/c++/9/bits/std_function.
h:688
#11 0x0000555555a2ff01 in gdb::observers::observable<objfile*>::notify (this=0x5555562eaa80 <gdb::observers::free_objfile>, args#0=0x555556935550) at /net/cascais.nfs/gdb/b
inutils-gdb/src/gdb/../gdbsupport/observable.h:106
#12 0x0000555555a2c56a in objfile::~objfile (this=0x555556935550, __in_chrg=<optimized out>) at src/gdb/objfiles.c:521
#13 0x0000555555a31d46 in std::_Sp_counted_ptr<objfile*, (__gnu_cxx::_Lock_policy)2>::_M_dispose (this=0x555556c1f6f0) at /usr/include/c++/9/bits/shared_ptr_base.h:377
#14 0x00005555556d3444 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x555556c1f6f0) at /usr/include/c++/9/bits/shared_ptr_base.h:155
#15 0x00005555556cec77 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (this=0x555556b99ee8, __in_chrg=<optimized out>) at /usr/include/c++/9/bits/shared_ptr_base.h:730
#16 0x0000555555a2f8da in std::__shared_ptr<objfile, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr (this=0x555556b99ee0, __in_chrg=<optimized out>) at /usr/include/c++/9/bits/shared_ptr_base.h:1169
#17 0x0000555555a2f8fa in std::shared_ptr<objfile>::~shared_ptr (this=0x555556b99ee0, __in_chrg=<optimized out>) at /usr/include/c++/9/bits/shared_ptr.h:103
#18 0x0000555555a63fba in __gnu_cxx::new_allocator<std::_List_node<std::shared_ptr<objfile> > >::destroy<std::shared_ptr<objfile> > (this=0x55555679f0c0, __p=0x555556b99ee0) at /usr/include/c++/9/ext/new_allocator.h:153
#19 0x0000555555a638fb in std::allocator_traits<std::allocator<std::_List_node<std::shared_ptr<objfile> > > >::destroy<std::shared_ptr<objfile> > (__a=..., __p=0x555556b99ee0) at /usr/include/c++/9/bits/alloc_traits.h:497
#20 0x0000555555a6351c in std::__cxx11::list<std::shared_ptr<objfile>, std::allocator<std::shared_ptr<objfile> > >::_M_erase (this=0x55555679f0c0, __position=std::shared_ptr<objfile> (expired, weak count 1) = {get() = 0x555556935550}) at /usr/include/c++/9/bits/stl_list.h:1921
#21 0x0000555555a62dab in std::__cxx11::list<std::shared_ptr<objfile>, std::allocator<std::shared_ptr<objfile> > >::erase (this=0x55555679f0c0, __position=std::shared_ptr<objfile> (expired, weak count 1) = {get() = 0x555556935550}) at /usr/include/c++/9/bits/list.tcc:158
#22 0x0000555555a614dd in program_space::remove_objfile (this=0x55555679f080, objfile=0x555556935550) at src/gdb/progspace.c:207
#23 0x0000555555a2c4dc in objfile::unlink (this=0x555556935550) at src/gdb/objfiles.c:497
#24 0x0000555555a2da65 in objfile_purge_solibs () at src/gdb/objfiles.c:904
#25 0x0000555555b3af74 in no_shared_libraries (ignored=0x0, from_tty=1) at src/gdb/solib.c:1236
#26 0x0000555555bbafc7 in target_pre_inferior (from_tty=1) at src/gdb/target.c:1900
#27 0x0000555555940afb in attach_command (args=0x5555563277c7 "15741", from_tty=1) at src/gdb/infcmd.c:2582
...
The problem is that the multi-target commit added a
scoped_restore_current_thread to remove_target_sections (frame #7
above). scoped_restore_current_thread's ctor fetches the selected
frame's frame id. If the frame had not had its frame id computed yet,
it is computed then (frame #4 above). Because it has been determined
earlier that the frame's unwinder is the DWARF unwinder, we end up
here:
static struct dwarf2_frame_cache *
dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
{
...
/* Find the correct FDE. */
fde = dwarf2_frame_find_fde (&pc1, &cache->per_objfile);
gdb_assert (fde != NULL);
And, that assertion fails. The assertion is reasonable, because the
DWARF unwinder only claims the frame if it managed to find the FDE
earlier (in dwarf2_frame_sniffer).
(unix/-m32 is thus really a red herring here -- it's just that on
x86_64 -m64, the frame is not claimed by the DWARF unwinder.)
The reason the assertion is failing, is because the objfile that
contains the FDE has been removed from the objfiles list already when
we get here (frame #22 above). This suggests that the fix should be
to invalidate DWARF frames when their objfile is removed. Or to keep
it simple and safe, invalidate the frame cache when an objfile is
removed. That is what this commit does.
OOC, I checked why is it that when you unload a file with plain "(gdb)
file", we don't hit the assertion. It must be because we're already
flushing the frame cache somewhere else in that case. And indeed, we
flush the frame cache here:
(gdb) bt
#0 reinit_frame_cache () at src/gdb/frame.c:1857
#1 0x0000555555ad1ad6 in registers_changed_ptid (target=0x0, ptid=...) at src/gdb/regcache.c:470
#2 0x0000555555ad1b58 in registers_changed () at src/gdb/regcache.c:485
#3 0x00005555558d095e in set_target_gdbarch (new_gdbarch=0x555556d5f5b0) at src/gdb/gdbarch.c:5528
#4 0x0000555555677175 in set_gdbarch_from_file (abfd=0x0) at src/gdb/arch-utils.c:601
#5 0x0000555555897c6b in exec_file_attach (filename=0x0, from_tty=1) at src/gdb/exec.c:409
#6 0x000055555589852d in exec_file_command (args=0x0, from_tty=1) at src/gdb/exec.c:571
#7 0x00005555558985a1 in file_command (arg=0x0, from_tty=1) at src/gdb/exec.c:583
#8 0x000055555572b55f in do_const_cfunc (c=0x55555672e200, args=0x0, from_tty=1) at src/gdb/cli/cli-decode.c:95
#9 0x000055555572f3d3 in cmd_func (cmd=0x55555672e200, args=0x0, from_tty=1) at src/gdb/cli/cli-decode.c:2181
#10 0x0000555555be1ecc in execute_command (p=0x555556327804 "", from_tty=1) at src/gdb/top.c:668
#11 0x0000555555895427 in command_handler (command=0x555556327800 "file") at src/gdb/event-top.c:588
#12 0x00005555558958af in command_line_handler (rl=...) at src/gdb/event-top.c:773
#13 0x0000555555894b3e in gdb_rl_callback_handler (rl=0x55555a09e240 "file") at src/gdb/event-top.c:219
#14 0x0000555555ccfeec in rl_callback_read_char () at src/readline/readline/callback.c:281
#15 0x000055555589495a in gdb_rl_callback_read_char_wrapper_noexcept () at src/gdb/event-top.c:177
#16 0x0000555555894a08 in gdb_rl_callback_read_char_wrapper (client_data=0x555556327520) at src/gdb/event-top.c:194
#17 0x00005555558952a5 in stdin_event_handler (error=0, client_data=0x555556327520) at src/gdb/event-top.c:516
#18 0x0000555555e027d6 in handle_file_event (file_ptr=0x555558d20840, ready_mask=1) at src/gdbsupport/event-loop.cc:548
#19 0x0000555555e02d88 in gdb_wait_for_event (block=1) at src/gdbsupport/event-loop.cc:673
#20 0x0000555555e01c42 in gdb_do_one_event () at src/gdbsupport/event-loop.cc:215
#21 0x00005555559c47c2 in start_event_loop () at src/gdb/main.c:356
#22 0x00005555559c490d in captured_command_loop () at src/gdb/main.c:416
#23 0x00005555559c6217 in captured_main (data=0x7fffffffdc00) at src/gdb/main.c:1253
#24 0x00005555559c6289 in gdb_main (args=0x7fffffffdc00) at src/gdb/main.c:1268
#25 0x0000555555621756 in main (argc=3, argv=0x7fffffffdd18) at src/gdb/gdb.c:32
gdb/ChangeLog:
PR gdb/26336
* progspace.c (program_space::remove_objfile): Invalidate the
frame cache.
* config/tc-arm.c (do_neon_cvt_1): Parse vcvtne as vcvt-ne for
NS_FD shape when MVE is present
* testsuite/gas/arm/mve-vcvtne-it-bad.d: New test.
* testsuite/gas/arm/mve-vcvtne-it-bad.l: New test.
* testsuite/gas/arm/mve-vcvtne-it-bad.s: New test.
* testsuite/gas/arm/mve-vcvtne-it.d: New test.
* testsuite/gas/arm/mve-vcvtne-it.s: New test.
bfd/ChangeLog:
2020-08-12 Jon Turney <jon.turney@dronecode.org.uk>
* elf.c (elfcore_grok_win32pstatus): Use unsigned int for
win32pstatus note type to avoid signedness comparison warning.
This fixes a couple of small problems in dwarf-mode.el.
First, I noticed that for an attribute like:
<2><136c>: Abbrev Number: 11 (DW_TAG_member)
<136d> DW_AT_name : t
... the "t" would not be font-locked using the function name face.
The problem here is that the regexp assumed the indirect string
format, like:
<12ac> DW_AT_name : (indirect string, offset: 0x1b40): whatever
Here the fix is to adjust the regexp to match both formats.
Second, when following a DIE reference, point could end up on an
attribute instead. This happens when there is a zero-length attribute
with the same "offset" as the following DIE, like:
<12c5> DW_AT_GNU_all_call_sites: 1
<2><12c5>: Abbrev Number: 5 (DW_TAG_formal_parameter)
Here the fix is to search for the DIE by looking for the depth ("<2>"
in the example) as well.
I've bumped the internal version number to make it simpler to install
this using the Emacs package facility.
binutils/ChangeLog
2020-08-12 Tom Tromey <tromey@adacore.com>
* dwarf-mode.el (Version): Now 1.6.
(dwarf-die-button-action): Tighten DIE reference regexp.
(dwarf-font-lock-keywords): Update name regexp.
bfd/ChangeLog:
2020-07-21 Jon Turney <jon.turney@dronecode.org.uk>
* elf.c (elfcore_grok_win32pstatus): Warn on malformed
win32pstatus notes, and return TRUE so we continue rather than
stopping as if it was an error.
Don't reject any win32pstatus notes smaller than minimum size for a
NOTE_INFO_THREAD.
This only happens to work because the Cygwin dumper tool currently
writes all these notes as the largest size of the union, (which wastes
lots of space in the core dump).
Instead, apply the appropriate size constraint for each win32pstatus
note type.
bfd/ChangeLog:
2020-07-11 Jon Turney <jon.turney@dronecode.org.uk>
* elf.c (elfcore_grok_win32pstatus): Don't apply size constraint
for NOTE_INFO_THREAD to all win32pstatus ELF notes, instead apply
appropriate size constraint for each win32pstatus note type.
Don't hardcode the size of the Win32 API thread CONTEXT type read from a
NOTE_INFO_THREAD win32pstatus note (since it's different on different
architectures).
bfd/ChangeLog:
2020-07-01 Jon Turney <jon.turney@dronecode.org.uk>
* elf.c (elfcore_grok_win32pstatus): Don't hardcode the size of
the Win32 API thread CONTEXT type read from a NOTE_INFO_THREAD
win32pstatus note.
Define constants for win32pstatus ELF notes, as they were prior to
4a6636fb, and say what specifies them.
bfd/ChangeLog:
2020-07-11 Jon Turney <jon.turney@dronecode.org.uk>
* elf.c (NOTE_INFO{_PROCESS,_THREAD,_MODULE}): Define.
(elfcore_grok_win32pstatus): Use.
Fix the offset used to read the tid from a win32pstatus ELF note.
This probably meant that registers were only being correctly recovered
from the core dump for the current thread.
It looks like this has beeen incorrect since 4a6636fb.
Also fix offsets used in NOTE_INFO_PROCESS (which is not actually
generated by the Cygwin dumper tool).
Also improve comment.
bfd/ChangeLog:
2020-07-01 Jon Turney <jon.turney@dronecode.org.uk>
* elf.c (elfcore_grok_win32pstatus): Fix the offset used to read
the tid from a win32pstatus NOTE_INFO_THREAD ELF note. Fix
offsets used to read NOTE_INFO_PROCESS.
gdb.dwarf2/dw2-op-out-param.S contained a duplicate label, and failed
to build with clang with the following error:
gdb compile failed, /gdbtest/src/gdb/testsuite/gdb.dwarf2/dw2-op-out-param.S:163:1:
error: invalid symbol redefinition
.Ltext5:
^
This commit renames the two labels as .Ltext5a and .Ltext5b, and
updates all references appropriately.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/dw2-op-out-param.S (.Ltext5): Fix duplicate label.
This patch adds support for the system registers introduced in the
Armv8-A MPAM extension.
See https://developer.arm.com/documentation/ddi0598/latest for the
Arm ARM supplement documenting this extension.
gas/ChangeLog:
* testsuite/gas/aarch64/mpam-bad.d: New test.
* testsuite/gas/aarch64/mpam-bad.l: Error output.
* testsuite/gas/aarch64/mpam-bad.s: Input.
* testsuite/gas/aarch64/mpam.d: New test.
* testsuite/gas/aarch64/mpam.s: Input.
opcodes/ChangeLog:
* aarch64-opc.c (aarch64_sys_regs): Add MPAM registers.
PR binutils/26331
* readelf.c (do_demangle): New option flag.
(print_symbol): If do_demangle is enabled, demangle the symbol.
(enum long_option_values): New enum to hold long option values.
(options): Add demangle, no-demangle, recursion-limit and
no-recursion-limit options. Alpha sort the table.
(usage): Describe the new options.
(parse_args): Handle the new options.
* NEWS: Mention the new feature.
* doc/binutils.texi: Document the new feature.
* testsuite/binutils-all/readelf.exp: Test the new feature.
* testsuite/binutils-all/mangled.s: New file - assembler source.
* testsuite/binutils-all/readelf.demangled: New file - expected
output from readelf.
When running gdb/gdb_mbuild.sh, we run into:
...
ms1-elf ...
... src/configure --target=ms1-elf --enable-gdb-build-warnings=,-Werror \
--enable-sim-build-warnings=,-Werror
... make -k -j 5 ms1-elf
ms1-elf: compile failed
...
In mbuild/ms1-elf/Build.log we find:
...
*** Configuration mt-unknown-elf is obsolete.
*** Support has been REMOVED.
make: *** [Makefile:10995: configure-gdb] Error 1
...
The support for ms1-elf, aka mt-elf, has been removed since commit dc71152484
"Remove mt port" in Jan 2018. Make this official in the MAINTAINERS file.
Tested using gdb/gdb_mbuild.sh.
gdb/ChangeLog:
2020-08-11 Tom de Vries <tdevries@suse.de>
* MAINTAINERS: Mark ms1 as deleted.
This patch fixes an assertion failure on long system register operands
in the AArch64 backend. See the new testcase for an input which
reproduces the issue.
gas/ChangeLog:
* config/tc-aarch64.c (parse_sys_reg): Don't assert when parsing
a long system register.
(parse_sys_ins_reg): Likewise.
(sysreg_hash_insert): New.
(md_begin): Use sysreg_hash_insert() to ensure all system
registers are no longer than the maximum length at startup.
* testsuite/gas/aarch64/invalid-sysreg-assert.d: New test.
* testsuite/gas/aarch64/invalid-sysreg-assert.l: Error output.
* testsuite/gas/aarch64/invalid-sysreg-assert.s: Input.
include/ChangeLog:
* opcode/aarch64.h (AARCH64_MAX_SYSREG_NAME_LEN): New.
When running gdb/gdb_mbuild.sh, I run into:
...
src/sim/aarch64/../common/sim-cpu.c: In function 'sim_cpu_free':
src/sim/aarch64/../common/sim-cpu.c:64:3: error: implicit declaration of \
function 'free' [-Werror=implicit-function-declaration]
free (cpu);
^~~~
src/sim/aarch64/../common/sim-cpu.c:64:3: error: incompatible implicit \
declaration of built-in function 'free' [-Werror]
src/sim/aarch64/../common/sim-cpu.c:64:3: note: include '<stdlib.h>' or \
provide a declaration of 'free'
...
Fix this by adding "#include <stdlib.h>".
Tested by gdb/gdb_mbuild.sh -e aarch64-elf.
sim/common/ChangeLog:
2020-08-10 Tom de Vries <tdevries@suse.de>
* sim-cpu.c: Include stdlib.h for free.
I initially noticed the problem with the addition of
gdb.dwarf2/dw2-line-number-zero.exp. The following failures showed up:
FAIL: gdb.dwarf2/dw2-line-number-zero.exp: continue to breakpoint: bar1
FAIL: gdb.dwarf2/dw2-line-number-zero.exp: bar1, 1st next
FAIL: gdb.dwarf2/dw2-line-number-zero.exp: bar1, 2nd next
FAIL: gdb.dwarf2/dw2-line-number-zero.exp: continue to breakpoint: bar2
FAIL: gdb.dwarf2/dw2-line-number-zero.exp: bar2, 1st next
FAIL: gdb.dwarf2/dw2-line-number-zero.exp: bar2, 2nd next
They happen because AArch64's prologue analyzer skips too many instructions
and ends up indicating a stopping point further into user code.
Dump of assembler code for function bar1:
0x00000000000006f8 <+0>: stp x29, x30, [sp, #-16]!
0x00000000000006fc <+4>: mov x29, sp
0x0000000000000700 <+8>: mov w0, #0x1 // #1
0x0000000000000704 <+12>: bl 0x6e4 <foo>
0x0000000000000708 <+16>: mov w0, #0x2 // #2
We should've stopped at 0x700, but the analyzer actually skips
that instruction and stops at 0x704. Then GDB ends up adjusting
the address further, and pushes the stopping point to 0x708 based on the
SAL information.
I'm not sure if this adjustment to 0x708 is correct though, as it ends up
skipping past a branch. But I'm leaving that aside for now.
One other complicating factor is that GCC seems to be hoisting up instructions
from user code, mixing them up with prologue instructions.
The following patch adjusts the heuristics a little bit, and tracks when the
SP and FP get used. If we notice an instruction that is not supposed to be
in the prologue, and this happens *after* SP/FP adjustments and saving of
registers, we stop the analysis.
This means, for PR26310, that we will now stop at 0x700.
I've also added a few more unit tests to make sure the updated behavior is
validated.
gdb/ChangeLog:
2020-08-10 Luis Machado <luis.machado@linaro.org>
PR gdb/26310
* aarch64-tdep.c (aarch64_analyze_prologue): Track use of SP/FP and
act accordingly.
(aarch64_analyze_prologue_test): Add more unit tests to exercise
movz/str/stur/stp skipping behavior.
The kernel has fixed this here:
https://lore.kernel.org/patchwork/patch/1029011/
We should do the same for GDB, which is still carrying an incorrect
definition of the macro. As stated in the kernel patch thread, this doesn't
actually change things because, luckily, the structs are of the same size.
gdb/ChangeLog:
2020-08-10 Luis Machado <luis.machado@linaro.org>
* nat/aarch64-sve-linux-sigcontext.h (SVE_PT_REGS_OFFSET): Use
struct user_sve_header instead of struct sve_context.
Replace the function pointer + `void *` parameters of
dwarf2_fetch_die_loc_sect_off and dwarf2_fetch_die_loc_cu_off with a
function_view parameter. Change call sites to use a lambda function.
This improves type-safety, so reduces the chances of errors.
gdb/ChangeLog:
* read.h (dwarf2_fetch_die_loc_sect_off,
dwarf2_fetch_die_loc_cu_off): Replace function pointer +
`void *` parameter with function_view.
* read.c (dwarf2_fetch_die_loc_sect_off,
dwarf2_fetch_die_loc_cu_off): Likewise.
* loc.c (get_frame_pc_for_per_cu_dwarf_call): Remove.
(per_cu_dwarf_call): Adjust.
(get_frame_address_in_block_wrapper): Remove.
(indirect_synthetic_pointer): Adjust.
(get_ax_pc): Remove.
(dwarf2_compile_expr_to_ax): Adjust.
Change-Id: Ic9b6ced0c4128f2b75ca62e0ed638b0962a22859
When building gdb on x86_64-linux with --enable-targets riscv64-suse-linux, I
run into:
...
src/gdb/arch/riscv.c:112:45: required from here
/usr/include/c++/4.8/bits/hashtable_policy.h:195:39: error: no matching \
function for call to 'std::pair<const riscv_gdbarch_features, const \
std::unique_ptr<target_desc, target_desc_deleter> >::pair(const \
riscv_gdbarch_features&, target_desc*&)'
: _M_v(std::forward<_Args>(__args)...) { }
^
...
for this code in riscv_lookup_target_description:
...
/* Add to the cache. */
riscv_tdesc_cache.emplace (features, tdesc);
...
Work around this compiler problem (filed as PR gcc/96537), similar to how that
was done in commit 6d0cf4464e "Fix build with gcc-4.8.x":
...
- riscv_tdesc_cache.emplace (features, tdesc);
+ riscv_tdesc_cache.emplace (features, target_desc_up (tdesc));
...
That is, call the target_desc_up constructor explictly instead of implicitly.
Also, work around a similar issue in get_thread_arch_aspace_regcache.
Build on x86_64-linux with --enable-targets riscv64-suse-linux, and
reg-tested.
gdb/ChangeLog:
2020-08-08 Tom de Vries <tdevries@suse.de>
PR build/26344
* arch/riscv.c (riscv_lookup_target_description): Use an explicit
constructor.
* regcache.c (get_thread_arch_aspace_regcache): Same.