Since we now have mi_runto_main which is like runto_main, eliminate
mi_run_to_main, in favor of a new MI clean_restart counterpart --
mi_clean_restart -- and mi_runto_main.
This makes MI testcases look a bit more like CLI testcases.
gdb/testsuite/ChangeLog:
* lib/mi-support.exp (mi_clean_restart): New.
(mi_run_to_main): Delete.
All callers adjust to use mi_clean_restart / mi_runto_main.
Pedro Alves [Thu, 3 Sep 2020 14:38:12 +0000 (15:38 +0100)]
gdb/testsuite/: Use "-qualified" in explicit "break main", etc.
Similar to the previous patch, but this time add "-q" to tests that do
"break main", "list main", etc. explicitly.
gdb/testsuite/ChangeLog:
* config/monitor.exp: Use "list -q".
* gdb.arch/gdb1558.exp: Use "break -q".
* gdb.arch/i386-permbkpt.exp: Use "break -q".
* gdb.arch/i386-prologue-skip-cf-protection.exp: Use "break -q".
* gdb.base/break.exp: Use "break -q", "list -q" and "tbreak -q".
* gdb.base/commands.exp: Use "break -q".
* gdb.base/condbreak.exp: Use "break -q".
* gdb.base/ctf-ptype.exp: Use "list -q".
* gdb.base/define.exp: Use "break -q".
* gdb.base/del.exp: Use "break -q".
* gdb.base/fullname.exp: Use "break -q".
* gdb.base/hbreak-in-shr-unsupported.exp: Use "hbreak -q".
* gdb.base/hbreak-unmapped.exp: Use "hbreak -q".
* gdb.base/hbreak2.exp: Use "hbreak -q" and "list -q".
* gdb.base/hw-sw-break-same-address.exp: Use "break -q" and
"hbreak -q".
* gdb.base/included.exp: Use "list -q".
* gdb.base/label.exp: Use "break -q".
* gdb.base/lineinc.exp: Use "break -q".
* gdb.base/list.exp: Use "list -q".
* gdb.base/macscp.exp: Use "list -q".
* gdb.base/pending.exp: Use "break -q".
* gdb.base/prologue-include.exp: Use "break -q".
* gdb.base/ptype.exp: Use "list -q".
* gdb.base/sepdebug.exp: Use "break -q", "list -q" and "tbreak -q".
* gdb.base/server-del-break.exp: Use "break -q".
* gdb.base/style.exp: Use "break -q".
* gdb.base/symbol-without-target_section.exp: Use "list -q".
* gdb.base/watchpoint-reuse-slot.exp: Use "hbreak -q".
* gdb.cp/exception.exp: Use "tbreak -q".
* gdb.dwarf2/dw2-error.exp: Use "break -q".
* gdb.dwarf2/fission-mix.exp: Use "break -q".
* gdb.dwarf2/fission-reread.exp: Use "break -q".
* gdb.dwarf2/pr13961.exp: Use "break -q".
* gdb.linespec/explicit.exp: Use "list -q".
* gdb.linespec/linespec.exp: Use "break -q".
* gdb.mi/mi-simplerun.exp: Use "--qualified".
* gdb.python/py-mi-objfile-gdb.py: Use "list -q".
* gdb.server/bkpt-other-inferior.exp: Use "break -q".
* gdb.server/connect-without-multi-process.exp: Use "break -q".
* gdb.trace/change-loc.exp: Use "break -q".
* gdb.trace/pending.exp: Use "break -q".
* gdb.tui/basic.exp: Use "list -q".
* gdb.tui/list-before.exp: Use "list -q".
* gdb.tui/list.exp: Use "list -q".
* lib/gdb.exp (gdb_has_argv0): Use "break -q".
Pedro Alves [Wed, 2 Sep 2020 22:20:45 +0000 (23:20 +0100)]
gdb/testsuite/: Use -qualified in runto_main / mi_runto_main
In some runtimes, there may be a "main" function in some class or
namespace. The breakpoint created by runto_main may therefore have
unexpected locations on some other functions than the actual main.
These breakpoint locations can unexpectedly get hit during tests and
lead to failures.
I saw this while playing with AMD's ROCm toolchain -- I wrote a board
file to run the testsuite against device kernels. There, the runtime
calls a "main" function before the device kernel code is reached:
Thread 4 "bit_extract" hit Breakpoint 1, 0x00007ffeea140960 in lld::elf::LinkerDriver::main(llvm::ArrayRef<char const*>) () from /opt/rocm/lib/libamd_comgr.so.1
(gdb) bt
#0 0x00007ffeea140960 in lld::elf::LinkerDriver::main(llvm::ArrayRef<char const*>) () from /opt/rocm/lib/libamd_comgr.so.1
#1 0x00007ffeea2257a5 in lld::elf::link(llvm::ArrayRef<char const*>, bool, llvm::raw_ostream&, llvm::raw_ostream&) () from /opt/rocm/lib/libamd_comgr.so.1
#2 0x00007ffeea1bc374 in COMGR::linkWithLLD(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&) () from /opt/rocm/lib/libamd_comgr.so.1
#3 0x00007ffeea1bfb09 in COMGR::InProcessDriver::execute(llvm::ArrayRef<char const*>) () from /opt/rocm/lib/libamd_comgr.so.1
#4 0x00007ffeea1c4da9 in COMGR::AMDGPUCompiler::linkToExecutable() () from /opt/rocm/lib/libamd_comgr.so.1
#5 0x00007ffeea1fde20 in dispatchCompilerAction(amd_comgr_action_kind_s, COMGR::DataAction*, COMGR::DataSet*, COMGR::DataSet*, llvm::raw_ostream&) () from /opt/rocm/lib/libamd_comgr.so.1
#6 0x00007ffeea203a87 in amd_comgr_do_action () from /opt/rocm/lib/libamd_comgr.so.1
...
To avoid that, pass "qualified" to runto, in runto_main, so that
gdb_breakpoint ends up creating a breakpoint with -qualified. This
avoids creating breakpoints locations for other unrelated "main"
functions.
Note: I first tried making runto itself use "-qualified", but that
caused regressions in the gdb.ada/ tests, which use runto without
specifying the whole fully-qualified function name (i.e., without the
package). So I end up restricting the -qualified to
runto_main/mi_runto_main.
The gdb.base/ui-redirect.exp change is necessary because that testcase
is looking at what "save breakpoint" generates.
gdb/testsuite/ChangeLog:
* gdb.base/ui-redirect.exp: Expect "break -qualified main" in
saved breakpoints file.
* gdb.guile/scm-breakpoint.exp: Expect "-qualified main" when
inspecting breakpoint list.
* lib/gdb.exp (runto_main): Add "qualified" to options.
* lib/mi-support.exp (mi_runto_helper): Add 'qualified' parameter,
and handle it.
(mi_runto_main): Pass 1 as qualified argument.
Pedro Alves [Wed, 2 Sep 2020 22:06:19 +0000 (23:06 +0100)]
Introduce mi_runto_main
This adds an mi_runto_main routine, very much like the runto_main CLI
counterpart.
Note there's already a mi_run_to_main (extra underscore in "run_to"),
but unlike its intro comment says, that does more than the CLI's
runto_main -- it also starts GDB. I would like to eliminate that
other one by introducing a mi_clean_restart function instead. That is
done later in the series.
gdb/testsuite/ChangeLog:
* lib/mi-support.exp (mi_runto_main): New proc.
(mi_run_to_main): Use it.
* gdb.mi/mi-catch-cpp-exceptions.exp: Likewise.
* gdb.mi/mi-var-cmd.exp: Likewise.
* gdb.mi/mi-var-invalidate.exp: Likewise.
* mi-var-list-children-invalid-grandchild.exp: Likewise.
* gdb.mi/mi2-amd64-entry-value.exp: Likewise.
* gdb.mi/new-ui-mi-sync.exp: Likewise.
* gdb.mi/user-selected-context-sync.exp: Likewise.
* gdb.opt/inline-cmds.exp: Likewise.
* gdb.python/py-framefilter-mi.exp: Likewise.
* gdb.python/py-mi.exp: Likewise.
Simon Marchi [Tue, 13 Oct 2020 16:01:19 +0000 (12:01 -0400)]
gdb: don't pass TARGET_WNOHANG to targets that can't async (PR 26642)
Debugging with "maintenance set target-async off" on Linux has been
broken since 5b6d1e4fa4f ("Multi-target support").
The issue is easy to reproduce:
$ ./gdb -q --data-directory=data-directory -nx ./test
Reading symbols from ./test...
(gdb) maintenance set target-async off
(gdb) start
Temporary breakpoint 1 at 0x1151: file test.c, line 5.
Starting program: /home/simark/build/binutils-gdb/gdb/test
... and it hangs there.
The difference between pre-5b6d1e4fa4f and 5b6d1e4fa4f is that
fetch_inferior_event now calls target_wait with TARGET_WNOHANG for
non-async-capable targets, whereas it didn't before.
For non-async-capable targets, this is how it's expected to work when
resuming execution:
1. we call resume
2. the infrun async handler is marked in prepare_to_wait, to immediately
wake up the event loop when we get back to it
3. fetch_inferior_event calls the target's wait method without
TARGET_WNOHANG, effectively blocking until the target has something
to report
However, since we call the target's wait method with TARGET_WNOHANG,
this happens:
1. we call resume
2. the infrun async handler is marked in prepare_to_wait, to immediately
wake up the event loop when we get back to it
3. fetch_inferior_event calls the target's wait method with
TARGET_WNOHANG, the target has nothing to report yet
4. we go back to blocking on the event loop
5. SIGCHLD finally arrives, but the event loop is not woken up, because
we are not in async mode. Normally, we should have been stuck in
waitpid the SIGCHLD would have unblocked us.
We end up in this situation because these two necessary conditions are
met:
1. GDB uses the TARGET_WNOHANG option with a target that can't do async.
I don't think this makes sense. I mean, it's technically possible,
the doc for TARGET_WNOHANG is:
/* Return immediately if there's no event already queued. If this
options is not requested, target_wait blocks waiting for an
event. */
TARGET_WNOHANG = 1,
... which isn't in itself necessarily incompatible with synchronous
targets. It could be possible for a target to support non-blocking
polls, while not having a way to asynchronously wake up the event
loop, which is also necessary to support async. But as of today,
we don't expect GDB and sync targets to work this way.
2. The linux-nat target, even in the mode where it emulates a
synchronous target (with "maintenance set target-async off") respects
TARGET_WNOHANG. Other non-async targets, such as windows_nat_target,
simply don't check / support TARGET_WNOHANG, so their wait method is
always blocking.
Fix the first issue by avoiding using TARGET_WNOHANG on non-async
targets, in do_target_wait_1. Add an assert in target_wait to verify it
doesn't happen.
The new test gdb.base/maint-target-async-off.exp is a simple test that
just tries running to main and then to the end of the program, with
"maintenance set target-async off".
gdb/ChangeLog:
PR gdb/26642
* infrun.c (do_target_wait_1): Clear TARGET_WNOHANG if the
target can't do async.
* target.c (target_wait): Assert that we don't pass
TARGET_WNOHANG to a target that can't async.
gdb/testsuite/ChangeLog:
PR gdb/26642
* gdb.base/maint-target-async-off.c: New test.
* gdb.base/maint-target-async-off.exp: New test.
H.J. Lu [Tue, 13 Oct 2020 12:22:55 +0000 (05:22 -0700)]
gold: Skip some incremental tests
Skip incremental_test_2, incremental_test_3, incremental_test_4,
incremental_test_5, incremental_copy_test, incremental_common_test_1
and incremental_comdat_test_1 when -fcf-protection is used to compile
gold since gold doesn't properly support -fcf-protection on Intel CET
enabled OS.
Also skip incremental_copy_test and incremental_comdat_test_1 for GCC 9
or later since they failed with GCC 9 or later.
PR gold/23539
* configure.ac: Check for GCC 9 or later and for -fcf-protection.
* configure: Regenerated.
* testsuite/Makefile.am (check_PROGRAMS): Skip incremental_test_2,
incremental_test_3, incremental_test_4, incremental_test_5,
incremental_copy_test, incremental_common_test_1 and
incremental_comdat_test_1 for -fcf-protection. Also Skip
incremental_copy_test and incremental_comdat_test_1 for GCC 9 or
later.
* testsuite/Makefile.in: Regenerated.
3. GNU_PROPERTY_X86_UINT32_OR_AND_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in any relocatable inputs and the property is
present in all relocatable inputs:
4. GNU_PROPERTY_X86_FEATURE_2_NEEDED, GNU_PROPERTY_X86_FEATURE_2_USED
and GNU_PROPERTY_X86_FEATURE_2_XXX bits.
GNU_PROPERTY_X86_FEATURE_1_AND is unchanged. GNU_PROPERTY_X86_ISA_1_USED
and GNU_PROPERTY_X86_ISA_1_NEEDED are updated to better support targeted
processors since GNU_PROPERTY_X86_ISA_1_?86 aren't isn't very useful.
A new set of GNU_PROPERTY_X86_ISA_1_XXX bits are defined. The previous
GNU_PROPERTY_X86_ISA_1_XXX macros are deprecated and renamed to
GNU_PROPERTY_X86_COMPAT_ISA_1_XXX and GNU_PROPERTY_X86_COMPAT_2_ISA_1_XXX.
elfcpp/
* elfcpp.h (GNU_PROPERTY_X86_ISA_1_USED): Renamed to ...
(GNU_PROPERTY_X86_COMPAT_ISA_1_USED): This.
(GNU_PROPERTY_X86_ISA_1_NEEDED): Renamed to ...
(GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED): This.
(GNU_PROPERTY_X86_UINT32_AND_LO): New.
(GNU_PROPERTY_X86_UINT32_AND_HI): Likewise.
(GNU_PROPERTY_X86_UINT32_OR_LO): Likewise.
(GNU_PROPERTY_X86_UINT32_OR_HI): Likewise.
(GNU_PROPERTY_X86_UINT32_OR_AND_LO): Likewise.
(GNU_PROPERTY_X86_UINT32_OR_AND_HI): Likewise.
(GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED): New.
(GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED): Likewise.
(GNU_PROPERTY_X86_FEATURE_1_AND): Updated to
(GNU_PROPERTY_X86_UINT32_AND_LO + 0).
(GNU_PROPERTY_X86_ISA_1_NEEDED): New. Defined to
GNU_PROPERTY_X86_UINT32_OR_LO + 2.
(GNU_PROPERTY_X86_FEATURE_2_NEEDED): New. Defined to
(GNU_PROPERTY_X86_UINT32_OR_LO + 1).
(GNU_PROPERTY_X86_ISA_1_USED): New. Defined to
GNU_PROPERTY_X86_UINT32_OR_AND_LO + 2.
(GNU_PROPERTY_X86_FEATURE_2_USED): New. Defined to
(GNU_PROPERTY_X86_UINT32_OR_AND_LO + 1).
gold/
* x86_64.cc (Target_x86_64::Target_x86_64): Initialize
feature_2_used_, feature_2_needed_ and object_feature_2_used_.
(Target_x86_64::feature_2_used_): New data member.
(Target_x86_64::feature_2_needed_): Likewise.
(Target_x86_64::object_isa_1_used_): Likewise.
(Target_x86_64::record_gnu_property): Support
GNU_PROPERTY_X86_COMPAT_ISA_1_USED,
GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED,
GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED,
GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED,
GNU_PROPERTY_X86_FEATURE_2_USED and
GNU_PROPERTY_X86_FEATURE_2_NEEDED.
(Target_x86_64::merge_gnu_properties): Merge FEATURE_2_USED bits.
Initialize object_feature_2_used_.
(Target_x86_64::do_finalize_gnu_properties): Support
GNU_PROPERTY_X86_FEATURE_2_USED and
GNU_PROPERTY_X86_FEATURE_2_NEEDED.
* testsuite/gnu_property_a.S (GNU_PROPERTY_X86_ISA_1_USED): Set
to 0xc0010002.
(GNU_PROPERTY_X86_ISA_1_NEEDED): Set to 0xc0008002.
* testsuite/gnu_property_b.S (GNU_PROPERTY_X86_ISA_1_USED): Set
to 0xc0010002.
(GNU_PROPERTY_X86_ISA_1_NEEDED): Set to 0xc0008002.
* testsuite/gnu_property_c.S (GNU_PROPERTY_X86_ISA_1_USED): Set
to 0xc0010002.
(GNU_PROPERTY_X86_ISA_1_NEEDED): Set to 0xc0008002.
* testsuite/gnu_property_test.sh: Updated.
H.J. Lu [Tue, 13 Oct 2020 12:18:13 +0000 (05:18 -0700)]
gold: Properly align the NT_GNU_PROPERTY_TYPE_0 note
The NT_GNU_PROPERTY_TYPE_0 note should be aligned to 8 bytes for 64-bit
ELF as specified by gABI. A note section can be only placed in a PT_NOTE
segment with the same alignment.
PR gold/22914
PR gold/23535
* layout.cc (Layout::attach_allocated_section_to_segment): Place
a note section in a PT_NOTE segment with the same alignment. Set
the alignment of the PT_NOTE segment from the alignment of the
note section.
(Layout::create_note): Align the NT_GNU_PROPERTY_TYPE_0 note to 8
bytes for 64-bit ELF.
(Layout::segment_precedes): Place segments with larger alignments
first.
* output.cc (Output_segment::Output_segment): Initialize align_.
* output.h (Output_segment): Add align, set_align and align_.
* testsuite/Makefile.am (gnu_property_test.stdout): Pass -lhSWn
to $(TEST_READELF).
(gnu_property_test): Pass --build-id to ld.
* testsuite/Makefile.in: Regenerated.
* testsuite/gnu_property_test.sh (check_alignment): New.
Use check_alignment to check the NT_GNU_PROPERTY_TYPE_0 note
alignment. Verify that there are 2 PT_NOTE segments.
Improved support for --icf=safe when used with -pie.
we now check opcode with R_X86_64_PC32 relocation, which tell branches
from other instructions. We can enable safe ICF for shared object on
x86-64. Also, global symbols with non-default visibility should be
folded like local symbols.
PR gold/21452
* x86_64.cc (Scan::local_reloc_may_be_function_pointer): Remove
check for shared library.
(Scan::global_reloc_may_be_function_pointer): Remove check for
shared library and symbol visibility.
* testsuite/icf_safe_so_test.cc (bar_static): New function.
(main): Take function address of bar_static and use it.
* testsuite/icf_safe_so_test.sh (arch_specific_safe_fold): Also
check fold on x86-64. Check bar_static isn't folded.
Tom Tromey [Mon, 12 Oct 2020 21:53:16 +0000 (15:53 -0600)]
Change target_section_table to std::vector alias
Because target_section_table only holds a vector, and because it is
used in an "open" way, this patch makes it just be an alias for the
std::vector specialization. This makes the code less wordy. If we do
ever want to add more specialized behavior to this type, it's simple
enough to convert it back to a struct with the few needed methods
implied by this change.
gdb/ChangeLog
2020-10-12 Tom Tromey <tom@tromey.com>
Tom Tromey [Mon, 12 Oct 2020 21:53:16 +0000 (15:53 -0600)]
Remove clear_section_table
The call to clear_section_table in ~program_space is now clearly not
needed -- the section table will clear itself. This patch removes
this call and then inlines the one remaining call to
clear_section_table.
gdb/ChangeLog
2020-10-12 Tom Tromey <tom@tromey.com>
Tom Tromey [Mon, 12 Oct 2020 21:53:16 +0000 (15:53 -0600)]
Simplify add_target_sections_of_objfile
Now that target_section_table uses std::vector,
add_target_sections_of_objfile does not need to loop twice. This
patch simplifies this code to have just a single loop. Also, the
passed-in objfile can never be NULL, so this changes this function to
assert that.
gdb/ChangeLog
2020-10-12 Tom Tromey <tom@tromey.com>
Tom Tromey [Mon, 12 Oct 2020 21:53:16 +0000 (15:53 -0600)]
Use a std::vector in target_section_table
This changes target_section_table to wrap a std::vector. This
simplifies some code, and also enables the simplifications coming in
the subsequent patches.
Note that for solib, I chose to have it use a pointer to a
target_section_table. This is more convoluted than would be ideal,
but I didn't want to convert solib to new/delete as a prerequisite for
this series.
gdb/ChangeLog
2020-10-12 Tom Tromey <tom@tromey.com>
* target.c (target_section_by_addr, memory_xfer_partial_1):
Update.
* target-section.h (struct target_section_table): Use
std::vector.
* symfile.h (build_section_addr_info_from_section_table): Take a
target_section_table.
* symfile.c (build_section_addr_info_from_section_table): Take a
target_section_table.
* solist.h (struct so_list) <sections>: Change type.
<sections_end>: Remove.
* solib.c (solib_map_sections, clear_so, solib_read_symbols)
(solib_contains_address_p): Update.
* solib-svr4.c (scan_dyntag): Update.
* solib-dsbt.c (scan_dyntag): Update.
* remote.c (remote_target::remote_xfer_live_readonly_partial):
Update.
* record-full.c (record_full_core_start, record_full_core_end):
Remove.
(record_full_core_sections): New global.
(record_full_core_open_1, record_full_core_target::xfer_partial):
Update.
* exec.h (build_section_table, section_table_xfer_memory_partial)
(add_target_sections): Take a target_section_table.
* exec.c (exec_file_attach, clear_section_table): Update.
(resize_section_table): Remove.
(build_section_table, add_target_sections): Take a
target_section_table.
(add_target_sections_of_objfile, remove_target_sections)
(exec_on_vfork): Update.
(section_table_available_memory): Take a target_section_table.
(section_table_read_available_memory): Update.
(section_table_xfer_memory_partial): Take a target_section_table.
(print_section_info, set_section_command)
(exec_set_section_address, exec_target::has_memory): Update.
* corelow.c (class core_target) <m_core_section_table,
m_core_file_mappings>: Remove braces.
<~core_target>: Remove.
(core_target::core_target): Update.
(core_target::~core_target): Remove.
(core_target::build_file_mappings)
(core_target::xfer_memory_via_mappings)
(core_target::xfer_partial, core_target::info_proc_mappings):
Update.
* bfd-target.c (target_bfd::xfer_partial): Update.
(target_bfd::target_bfd): Update.
(target_bfd::~target_bfd): Remove.
Tom Tromey [Mon, 12 Oct 2020 21:53:16 +0000 (15:53 -0600)]
Introduce target-section.h
This introduces a new target-section.h file. This makes some of the
later patches in this series a bit cleaner, because new includes of
target.h won't be required. Also I think it's better to have small
header files for each separate data structure.
gdb/ChangeLog
2020-10-12 Tom Tromey <tom@tromey.com>
* target.h (struct target_section, struct target_section_table):
Move to target-section.h.
* target-section.h: New file.
Alan Modra [Mon, 12 Oct 2020 02:27:58 +0000 (12:57 +1030)]
PowerPC testsuite fails and duplicates
binutils commit 5fbec329ec3 changed disassembly of mfvsrd and mtvsrd
to be consistent with the mfvsrwz and mtvsrw/mtvsrwz, which favour
output of the fp/vr extended mnemonic and regs over the vsx form.
This patch fixes the following, and removes some duplicates.
Alan Modra [Mon, 12 Oct 2020 01:02:21 +0000 (11:32 +1030)]
Re: gdb: Improve formatting of 'show architecture' messages
Commit ccb9eba6a25 updated the testsuite for some targets without
running the testsuite on those targets. This patch corrects the
update, in most cases just adding the expected full-stop.
On powerpc64le-linux, fixes these:
FAIL: gdb.arch/powerpc-d128-regs.exp: checking for PPC arch
FAIL: gdb.arch/powerpc-disassembler-options.exp: set architecture powerpc:common64
FAIL: gdb.arch/powerpc-disassembler-options.exp: set architecture rs6000:6000
FAIL: gdb.arch/ppc64-symtab-cordic.exp: show architecture
I also verified that arm-linuxeabi and s390x-linux cross-builds now
pass their disassembler-options.exp tests.
Pedro Alves [Fri, 28 Aug 2020 20:10:59 +0000 (21:10 +0100)]
Reject ambiguous C++ field accesses (PR exp/26602)
The gdb.cp/ambiguous.exp testcase had been disabled for many years,
but recently it was re-enabled. However, it is failing everywhere.
That is because it is testing an old feature that is gone from GDB.
The testcase is expecting to see an ambiguous field warning, like:
# X is derived from A1 and A2; both A1 and A2 have a member 'x'
send_gdb "print x.x\n"
gdb_expect {
-re "warning: x ambiguous; using X::A2::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
pass "print x.x"
}
-re "warning: x ambiguous; using X::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
pass "print x.x"
}
-re ".*$gdb_prompt $" { fail "print x.x" }
timeout { fail "(timeout) print x.x" }
}
However, GDB just accesses one of the candidates without warning or
error:
(The weird number is because the testcase does not initialize the
variables.)
The testcase come in originally with the big HP merge:
+Sun Jan 10 23:44:11 1999 David Taylor <taylor@texas.cygnus.com>
+
+
+ The following files are part of the HP merge; some had longer
+ names at HP, but have been renamed to be no more than 14
+ characters in length.
Looking at the tree back then, we find that warning:
/* Helper function used by value_struct_elt to recurse through baseclasses.
Look for a field NAME in ARG1. Adjust the address of ARG1 by OFFSET bytes,
and search in it assuming it has (class) type TYPE.
If found, return value, else return NULL.
If LOOKING_FOR_BASECLASS, then instead of looking for struct fields,
look for a baseclass named NAME. */
static value_ptr
search_struct_field (name, arg1, offset, type, looking_for_baseclass)
char *name;
register value_ptr arg1;
int offset;
register struct type *type;
int looking_for_baseclass;
{
int found = 0;
char found_class[1024];
value_ptr v;
struct type *vbase = NULL;
found_class[0] = '\000';
v = search_struct_field_aux (name, arg1, offset, type, looking_for_baseclass, &found, found_class, &vbase);
if (found > 1)
warning ("%s ambiguous; using %s::%s. Use a cast to disambiguate.",
name, found_class, name);
return v;
}
However, in current GDB, search_struct_field does not handle the
ambiguous field case, nor is that warning found anywhere. Somehow it
got lost over the years. That seems like a regression, because the
compiler (as per language rules) rejects the ambiguous accesses as
well. E.g.:
gdb.cp/ambiguous.cc:98:5: error: request for member 'x' is ambiguous
98 | x.x = 1;
| ^
gdb.cp/ambiguous.cc:10:7: note: candidates are: 'int A2::x'
10 | int x;
| ^
gdb.cp/ambiguous.cc:4:7: note: 'int A1::x'
4 | int x;
| ^
This patch restores the feature, though implemented differently and
with better user experience, IMHO. An ambiguous access is now an
error instead of a warning, and also GDB shows you all the candidates,
like:
(gdb) print x.x
Request for member 'x' is ambiguous in type 'X'. Candidates are:
'int A1::x' (X -> A1)
'int A2::x' (X -> A2)
(gdb) print j.x
Request for member 'x' is ambiguous in type 'J'. Candidates are:
'int A1::x' (J -> K -> A1)
'int A1::x' (J -> L -> A1)
Users can then fix their commands by casting or by specifying the
baseclass explicitly, like:
(gdb) p x.A1::x
$1 = 1
(gdb) p x.A2::x
$2 = 2
(gdb) p ((A1) x).x
$3 = 1
(gdb) p ((A2) x).x
$4 = 2
(gdb) p j.K::x
$12 = 1
(gdb) p j.L::x
$13 = 2
(gdb) p j.A1::x
base class 'A1' is ambiguous in type 'J'
The last error I've not touched; could be improved to also list the
baseclass candidates.
The showing the class "path" for each candidate was inspired by GCC's
output when you try an ambiguous cast:
gdb.cp/ambiguous.cc:161:8: error: ambiguous conversion from derived class 'const JVA1' to base class 'const A1':
class JVA1 -> class KV -> class A1
class JVA1 -> class A1
(A1) jva1;
^~~~
I did not include the "class" word as it seemed unnecessarily
repetitive, but I can include it if people prefer it:
(gdb) print j.x
Request for member 'x' is ambiguous in type 'J'. Candidates are:
'int A1::x' (class J -> class K -> class A1)
'int A1::x' (class J -> class L -> class A1)
The testcase is adjusted accordingly. I also took the chance to
modernize it at the same time.
Also, as mentioned above, the testcase doesn't currently initialize
the tested variables. This patch inializes them all, giving each
field a distinct value, so that we can be sure that GDB is accessing
the right fields / offsets. The testcase is extended accordingly.
Unfortunately, this exposes a bug, not addressed in this patch. The
bug is around a class that inherits from A1 directly and also inherits
from two other distinct base classes that inherit virtually from A1 in
turn:
(gdb) print /x (KV)jva1
$4 = {<A1> = <invalid address>, _vptr.KV = 0x555555557b88 <vtable for JVA1+24>, i = 0x457}
(gdb) print /x (A1)(KV)jva1
Cannot access memory at address 0x0
Since that's an orthogonal issue, I filed PR c++/26550 and kfailed the
tests that fail because of it.
gdb/ChangeLog:
PR exp/26602
* valops.c (struct struct_field_searcher): New.
(update_search_result): Rename to ...
(struct_field_searcher::update_result): ... this. Simplify
prototype. Record all found fields.
(do_search_struct_field): Rename to ...
(struct_field_searcher::search): ... this. Simplify prototype.
Maintain stack of visited baseclass path. Call update_result for
fields too. Keep searching fields in baseclasses instead of
stopping at the first found field.
(search_struct_field): Use struct_field_searcher. When looking
for fields, report ambiguous access attempts.
gdb/testsuite/ChangeLog:
PR exp/26602
PR c++/26550
* gdb.cp/ambiguous.cc (marker1): Delete.
(main): Initialize all the fields of the locals. Replace marker1
call with a "set breakpoint here" marker.
* gdb.cp/ambiguous.exp: Modernize. Use gdb_continue_to_breakpoint
instead of running to marker1. Add tests printing all the
variables and all the fields of the variables.
(test_ambiguous): New proc, expecting the new GDB output when a
field access is ambiguous. Change all "warning: X ambiguous"
tests to use it.
Gary Benson [Mon, 12 Oct 2020 09:35:23 +0000 (10:35 +0100)]
Fix testcases with required but unreferenced functions and variables
A number of testcases define variables and/or functions which are
referenced by GDB during the test, but which are not referenced from
within the test executable. Clang correctly recognizes that these
variables and functions are unused, and optimizes them out, causing
the testcases in question to fail. This commit adds __attribute__
((used)) in various places to prevent this.
Andrew Burgess [Thu, 8 Oct 2020 11:28:19 +0000 (12:28 +0100)]
gdb: detect main function even when there's no matching msymbol
Currently, GDB will only stop the backtrace at the main function if
there is a minimal symbol with the matching name. In Fortran programs
compiled with gfortran this is not the case. The main function is
present in the DWARF, and as marked as DW_AT_main_subprogram, but
there's no minimal symbol.
This commit extends `inside_main_func` to check the full symbols if no
matching minimal symbol is found.
There's an updated test case that covers this change.
gdb/ChangeLog:
* frame.c (inside_main_func): Check full symbols as well as
minimal symbols.
gdb/testsuite/ChangeLog:
* gdb.fortran/mixed-lang-stack.exp (run_tests): Update expected
output of backtrace.
Tom Tromey [Tue, 6 Oct 2020 14:56:54 +0000 (08:56 -0600)]
Fix bit offset regression
The type-safe attribute patch introduced a regression that can occur
when the DW_AT_bit_offset value is negative. This can happen with
some Ada programs.
This patch fixes the problem. It also fixes a minor oddity in the
existing scalar storage test -- this test was intended to assign a
smaller number of bits to the field.
2020-10-09 Tom Tromey <tromey@adacore.com>
* dwarf2/read.c (dwarf2_add_field): Handle signed offsets.
gdb/testsuite/ChangeLog
2020-10-09 Tom Tromey <tromey@adacore.com>
Alan Modra [Fri, 9 Oct 2020 06:26:33 +0000 (16:56 +1030)]
[GOLD] Power10 segv due to wild r2
Calling non-pcrel functions from pcrel code requires a stub to set up
r2. Gold created the stub, but an "optimisation" made the stub jump
to the function local entry, ie. r2 was not initialised.
This patch fixes that long branch stub problem, and another that might
occur for plt call stubs to local functions.
bfd/
* elf64-ppc.c (write_plt_relocs_for_local_syms): Don't do local
entry offset optimisation.
gold/
* powerpc.cc (Powerpc_relobj::do_relocate_sections): Don't do
local entry offset optimisation for lplt_section.
(Target_powerpc::Branch_info::make_stub): Don't add local
entry offset to long branch dest passed to
add_long_branch_entry. Do pass st_other bits.
(Stub_table::Branch_stub_ent): Add "other_" field.
(Stub_table::add_long_branch_entry): Add "other" param, and
save.
(Stub_table::branch_stub_size): Adjust long branch offset.
(Stub_table::do_write): Likewise.
(Target_powerpc::Relocate::relocate): Likewise.
Alan Modra [Fri, 9 Oct 2020 00:29:33 +0000 (10:59 +1030)]
[GOLD] internal error in relocate, at powerpc.cc:10473
GOT relocations can refer directly to a function in a fixed position
executable, unlike ADDR64 which needs a global entry stub, or branch
relocs, which need PLT stubs.
* powerpc.cc (is_got_reloc): New function.
(Target_powerpc::Relocate::relocate): Use it here, exclude GOT
relocs when looking for stubs.
The previous GNU_PROPERTY_X86_ISA_1_XXX macros are deprecated and renamed
to GNU_PROPERTY_X86_COMPAT_2_ISA_1_XXX.
In addition to EM_X86_64, GNU_PROPERTY_X86_ISA_1_V[234] marker can be used
by ld.so to detect the x86-64-v4 shared library placed in an x86-64-v2
directory by mistake on an x86-64-v2 machine to avoid crashes on x86-64-v4
instructions.
Add -z x86-64-v[234] linker command line option to mark x86-64-v[234]
ISA level as needed.
gdb: Have allocate_target_description return a unique_ptr
There were a few places where we could (should?) have delayed
releasing the target_desc_up until a little later. This commit
catches these cases.
In the case of ARC, the target_desc_up is now exposed right out to
gdbserver, which means making a small change there too.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* arch/aarch32.c (aarch32_create_target_description): Release the
target_desc_up as late as possible.
* arch/aarch64.c (aarch64_create_target_description): Likewise.
* arch/amd64.c (amd64_create_target_description): Likewise.
* arch/arc.c (arc_create_target_description): Return a
target_desc_up, don't release it.
* arch/arc.h (arc_create_target_description): Update declaration.
(arc_lookup_target_description): Move target_desc_up into the
cache, and return a borrowed pointer.
* arch/arm.c (arm_create_target_description): Release the
target_desc_up as late as possible.
* arch/i386.c (i386_create_target_description): Likewise.
* arch/riscv.h (riscv_create_target_description): Update
declaration to match definition.
* arch/tic6x.c (tic6x_create_target_description): Release the
target_desc_up as late as possible.
gdbserver/ChangeLog:
* linux-arc-low.cc (arc_linux_read_description): Release the
unique_ptr returned from arc_create_target_description.
that the solution might be to make use of $(LIB_GETRANDOM), a variable
defined in the gnulib makefile, when linking GDB.
In fact I think the issue is bigger than just LIB_GETRANDOM. When
using the script binutils-gdb/gnulib/update-gnulib.sh to reimport
gnulib there is a lot of output from gnulib's gnulib-tool. Part of
that output is this:
You may need to use the following makefile variables when linking.
Use them in <program>_LDADD when linking a program, or
in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library.
$(FREXPL_LIBM)
$(FREXP_LIBM)
$(INET_NTOP_LIB)
$(LIBTHREAD)
$(LIB_GETLOGIN)
$(LIB_GETRANDOM)
$(LIB_HARD_LOCALE)
$(LIB_MBRTOWC)
$(LIB_SETLOCALE_NULL)
$(LTLIBINTL) when linking with libtool, $(LIBINTL) otherwise
What I think this is telling us is that we should be including the
value of all these variables on the link line for gdb and gdbserver.
The problem though is that these variables are define in gnulib's
makefile, but are not (necessarily) defined in GDB's makefile.
One solution would be to recreate the checks that gnulib performs in
order to recreate these variables in both gdb's and gdbserver's
makefile. Though this shouldn't be too hard, most (if not all) of
these checks are in the form macros defined in m4 files in the gnulib
tree, so we could just reference these as needed. However, in this
commit I propose a different solution.
Currently, in the top level makefile, we give gdb and gdbserver a
dependency on gnulib. Once gnulib has finished building gdb and
gdbserver can start, these projects then have a hard coded (relative)
path to the compiled gnulib library in their makefiles.
In this commit I extend the gnulib configure script to install a new
makefile fragment in the gnulib build directory. This new file will
have the usual variable substitutions applied to it, and so can
include the complete list (see above) of all the extra libraries that
are needed when linking against gnulib.
In fact the new makefile fragment defines three variables, these are:
LIBGNU: The path to the archive containing gnulib. Can be used as a
dependency as when this file changes gdb/gdbserver should be
relinked.
LIBGNU_EXTRA_LIBS: A list of linker -l.... flags that should be
included in the link line of gdb/gdbserver. These are
libraries that $(LIBGNU) depends on. This list is taken from
the output of gnulib-tool, which is run by our
gnulib/update-gnulib.sh script.
INCGNU: A list of -I.... include paths that should be passed to the
compiler, these are where the gnulib headers can be found.
Now both gdb and gdbserver can include the makefile fragment and make
use of these variables.
The makefile fragment relies on the variable GNULIB_BUILDDIR being
defined. This is checked for in the fragment, and was already defined
in the makefiles of gdb and gdbserver.
gdb/ChangeLog:
* Makefile.in: Include Makefile.gnulib.inc. Don't define LIBGNU
or INCGNU. Make use of LIBGNU_EXTRA_LIBS when linking.
gdbserver/ChangeLog:
* Makefile.in: Include Makefile.gnulib.inc. Don't define LIBGNU
or INCGNU. Make use of LIBGNU_EXTRA_LIBS when linking.
gnulib/ChangeLog:
* Makefile.gnulib.inc.in: New file.
* Makefile.in: Regenerate.
* configure: Regenerate.
* configure.ac: Install the new file.
Tom Tromey [Fri, 9 Oct 2020 01:41:45 +0000 (19:41 -0600)]
Style more output of "disassemble" command
I noticed a couple of spots where the "disassemble" could style its
output, but currently does not. This patch adds styling to the
function name at the start of the disassembly, and any addresses
printed there.
gdb/ChangeLog
2020-10-08 Tom Tromey <tom@tromey.com>
* cli/cli-cmds.c (print_disassembly): Style function name and
addresses. Add _() wrappers.
gdb/testsuite/ChangeLog
2020-10-08 Tom Tromey <tom@tromey.com>
* gdb.base/style.exp: Check that "main"'s name is styled.
Andrew Burgess [Mon, 20 Jul 2020 13:18:04 +0000 (14:18 +0100)]
gdb: Have allocate_target_description return a unique_ptr
Update allocate_target_description to return a target_desc_up, a
specialisation of unique_ptr.
This commit does not attempt to make use of the unique_ptr in the
best possible way, in almost all cases we immediately release the
pointer from within the unique_ptr and then continue as before.
There are a few places where it was easy to handle the unique_ptr, and
in these cases I've done that.
Everything under gdb/features/* is auto-regenerated.
There should be no user visible changes after this commit.
Alan Modra [Wed, 7 Oct 2020 23:57:43 +0000 (10:27 +1030)]
[GOLD] Increase --split-stack-adjust-size
For functions with small (< 256 bytes) stack frames, the current x86
do_calls_non_split ignores --split-stack-adjust-size and, in
combination with __morestack_non_split, supplies a non-split-stack
function with at least 0x100000 (1M) available stack. On powerpc64, a
default of 0x4000 is not large enough to reliably work with the golang
testsuite. This increase the default size to the defacto x86 value.
* options.h (split_stack_adjust_size): Default to 0x100000.
Tom Tromey [Wed, 7 Oct 2020 18:07:55 +0000 (12:07 -0600)]
Move simple_search_memory to gdbsupport/search.cc
This moves the simple_search_memory function to a new file,
gdbsupport/search.cc. The API is slightly changed to make it more
general. This generality is useful for wiring it to gdbserver, and
also for unit testing.
gdb/ChangeLog
2020-10-07 Tom Tromey <tromey@adacore.com>
Simon Marchi [Wed, 7 Oct 2020 17:58:57 +0000 (13:58 -0400)]
gdb: put user-supplied CFLAGS at the end
GDB currently doesn't build cleanly with clang (a -Wdeprecated-copy-dtor
error). I configured my clang-based GDB build with
CXXFLAGS="-Wno-error=deprecated-copy-dtor", so I can use it despite that
problem. However, I found that it had no effect. This is because my
-Wno-error=Wdeprecated-copy-dtor switch is followed by -Werror in the
command line, which switches back all warnings to be errors.
If we want the user-supplied C(XX)FLAGS to be able to override flags
added by our configure script, the user-supplied C(XX)FLAGS should
appear after the configure-supplied flags.
This patch moves the user-supplied CXXFLAGS at the very end of the
compilation command line, which fixes the problem described above. This
means moving it out of INTERNAL_CFLAGS and inlining it in the users of
INTERNAL_CFLAGS.
I observed the problem when building GDB, but the same problem could
happen with GDBserver, so the change is done there too.
In GDBserver, INTERNAL_CFLAGS is passed when linking
Add Makefile.in entry for "Add NetBSD/aarch64 gdbserver support"
The support is on par with NetBSD/amd64, thus GPR works,
single step and software breakpoint are operational, and the
SVR4 r_debug integration is functional.
Anton Kolesov [Mon, 30 Jan 2017 15:32:10 +0000 (18:32 +0300)]
arc: Add support for Linux coredump files
With the implemenations in this patch, ARC gdb can handle
coredump related matters. The binutils counter part of
this patch has already been pushed [1].
v2 [2]:
- arc_linux_collect_gregset: Use "reg <= ARC_LAST_REGNUM" instead of
"reg < ARC_LAST_REGNUM" for the condition check of the for-loop.
- arc-linux-tdep.c: Use "ARC_LAST_REGNUM < ARRAY_SIZE (...)" instead of
"ARC_LAST_REGNUM <= ARRAY_SIZE (...)" for the "asserts".
- Use "buf + arc_linux_core_reg_offsets[ARC_ERET_REGNUM]" instead of
"buf + REG_OFF (6)".
- Fix a few typos/indentation.
v3 [3]:
- Use gdb_assert_not_reached(text) instead of gdb_assert (!text).
- Remove unnecessary braces in the for loop.
[1] arc: Add support for ARC HS extra registers in core files
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=2745674244d6aecddcf636475034bdb9c0a6b4a0
[2] First remarks
https://sourceware.org/pipermail/gdb-patches/2020-September/171912.html
[3] Second remarks
https://sourceware.org/pipermail/gdb-patches/2020-October/172302.html
Anton Kolesov [Wed, 6 Jul 2016 17:30:29 +0000 (20:30 +0300)]
gdbserver: Add GNU/Linux support for ARC
This gdbserver implementation supports ARC ABI v3 and v4 (older ARC ABI
versions are not supported by other modern GNU tools or Linux itself).
Gdbserver supports inspection of ARC HS registers R30, R58 and R59 - feature
that has been added to Linux 4.12. Whether gdbserver build will actually
support this feature depends on the version of Linux headers used to build
the server.
v2 [1]:
- Use "this->read_memory ()" instead of "the_target->read_memory ()".
- Remove the unnecessary "arch-arc.o:" target from the "Makefile.in".
- Got rid of "ntohs()" function and added lots of comments about
endianness.
- Clarify why "pc" value is read from and saved to different fields
in user regs struct.
- In function "is_reg_name_available_p()", use a range-based iterator
to loop over the registers.
- Removed mentioning of issue number that was not related to sourceware.
- A few typo's fixed.
Shahab Vahedi [Mon, 5 Oct 2020 15:10:47 +0000 (17:10 +0200)]
arc: Rename "arc_gdbarch_features" struct
"arc_gdbarch_features" is a data structure containing information
about the ARC architecture: ISA version, register size, etc.
This name is misleading, because although it carries the phrase
"gdbarch", it has nothing to do with the type/interface in GDB.
Traditionaly, "gdbarch" structures are only used for that purpose.
To rectify this, this patch changes the name to "arc_arch_features".
In `attach_command`, there is a call to `init_wait_for_inferior`
followed by a call to `clear_proceed_status`. However,
`init_wait_for_inferior` already calls `clear_proceed_status`. Remove
the redundant call.
Regression-tested on X86_64 Linux.
gdb/ChangeLog:
2020-10-07 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* infcmd.c (attach_command): Remove the redundant call to
`clear_proceed_status`.
Add common write_memory and read_memory NetBSD routines
Instead of sharing the native-only code with all BSDs with slightly
different semantics of the kernels, share the NetBSD-only behavior beteen
the NetBSD native and gdbserver setup.
NetBSD does not differentiate the address space I and D in the
operations (contrary to OpenBSD). NetBSD handles EACCES that integrates
with NetBSD specific PaX MPROTECT error handling.
Add a verbose message in the native client that an operation could be
cancelled due to PaX MPROTECT setup.
Add ChangeLog for "Add NetBSD/aarch64 gdbserver support"
The support is on par with NetBSD/amd64, thus GPR works,
single step and software breakpoint are operational, and the
SVR4 r_debug integration is functional.
The support is on par with NetBSD/amd64, thus GPR works,
single step and software breakpoint are operational, and the
SVR4 r_debug integration is functional.
Simon Marchi [Wed, 7 Oct 2020 12:13:44 +0000 (08:13 -0400)]
gdb: make signal_catch_counts a static array
I noticed that signal_catch_counts is a dynamically-allocated array of
constant size, allocated at startup an never freed. This might as well
be a statically-allocated array.
gdb/ChangeLog:
* break-catch-sig.c (signal_catch_counts): Make a static arrray.
(_initialize_break_catch_sig): Don't allocate array.
Michael Forney [Tue, 6 Oct 2020 21:12:57 +0000 (17:12 -0400)]
gdb: Fix installation of gcore.1 on some platforms
gcore is installed on NetBSD, FreeBSD, Solaris (HAVE_NATIVE_GCORE_HOST=1)
and Linux (HAVE_NATIVE_GCORE_TARGET=1). However, even though gcore.1
is installed conditional on those variables, HAVE_NATIVE_GCORE_HOST
was missing from gdb/doc/Makefile.in, so manual installation was
skipped on NetBSD, FreeBSD, and Solaris.
gdb/doc/ChangeLog:
2020-10-06 Michael Forney <mforney@mforney.org>
* Makefile.in (HAVE_NATIVE_GCORE_HOST): Add for gcore.1
install condition.
Shahab Vahedi [Tue, 6 Oct 2020 11:15:32 +0000 (13:15 +0200)]
gdbserver: Remove unused argument in register_data()
The register_data() function in gdbserver/regcache.cc has an
input argument called "fetch". This argument is not used by this
static function at all. Therefore, it is time to get rid of it.
Alex Coplan [Tue, 6 Oct 2020 14:56:44 +0000 (15:56 +0100)]
aarch64: Fix bogus type punning in parse_barrier() [PR26699]
This patch fixes a bogus use of type punning in parse_barrier() which
was causing an assembly failure on big endian LP64 hosts when attempting
to assemble "isb sy" for AArch64.
The type of the entries in aarch64_barrier_opt_hsh is
aarch64_name_value_pair. We were incorrectly casting this to the
locally-defined asm_barrier_opt which has a wider type (on LP64) for the
second member. This happened to work on little-endian hosts but fails on
LP64 big endian.
The fix is to use the correct type in parse_barrier(). This makes the
locally-defined asm_barrier_opt redundant, so remove it.
gas/ChangeLog:
* config/tc-aarch64.c (asm_barrier_opt): Delete.
(parse_barrier): Fix bogus type punning.
* testsuite/gas/aarch64/system.d: Update disassembly.
* testsuite/gas/aarch64/system.s: Add isb sy test.
Gary Benson [Tue, 6 Oct 2020 14:08:37 +0000 (15:08 +0100)]
Fix gdb.base/list.exp with Clang
Two subtests of gdb.base/list.exp failed when built with Clang
because the unused function "unused" was optimized out. This
commit adds __attribute__ ((used)) to both definitions.
Gary Benson [Tue, 6 Oct 2020 14:08:37 +0000 (15:08 +0100)]
Fix gdb.base/list-ambiguous.exp with Clang
The ambiguous variable parts of gdb.base/list-ambiguous.exp failed
when built with Clang because the variable in question was unused
and was optimized out. This commit adds __attribute__ ((used)) to
both definitions.
A small set of code improvements for the Z80 assembler.
PR 26692
* config/tc-z80.c (md_begin): Ensure that xpressions are empty
before using them.
(unify_indexed): Likewise.
(z80_start_line_hook): Improve hash sign handling when SDCC
compatibility mode enabled.
(md_parse_exp_not_indexed): Improve indirect addressing
detection.
(md_pseudo_table): Accept hd64 as an alias of z810.
Andrew Burgess [Mon, 5 Oct 2020 08:53:50 +0000 (09:53 +0100)]
sim: Fix autoreconf errors in sim/ directory
Run autoreconf in sim/ directory and you'll see some errors. The
problem is that autoreconf (a perl script) does not evaluate the value
passed as an argument to AC_CONFIG_AUX_DIR, so something like:
AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/../..)
does not do the right thing inside autoreconf, my understanding is
that changing to something like this is fine:
AC_CONFIG_AUX_DIR(../..)
the generated configure seems to check the value passed, and the value
passed relative to the source directory, so I think we get basically
the same behaviour as before.
Andrew Burgess [Sun, 13 Sep 2020 20:53:26 +0000 (21:53 +0100)]
gdb: handle unmapped overlays in find_pc_line
I configured and built an m32r-elf toolchain, and ran the
gdb.base/overlays.exp test. I saw a couple of errors where GDB would
place a breakpoint in the wrong place when placing a breakpoint using
a function name, for example in this function:
GDB would place the breakpoint on line 2 instead of line 3. The issue
is that GDB was failing to skip the prologue correctly.
The reason for this is that in m32r-tdep.c:m32r_skip_prologue, we
first use find_pc_partial_function to find the functions start and end
addresses, then we use find_pc_line to find the start and end of the
first line of the function.
Currently, if the pc value passed to find_pc_partial_function is in an
unmapped overlay then the function start and end addresses that are
returned are also the unmapped addresses.
However, this is not the case for find_pc_line, here, if the address
passed in is in an unmapped overlay then we still get back a
symtab_and_line describing the mapped location.
What this means is that if a function's mapped location is 0x100 ->
0x120, and its unmapped locations is 0x400 -> 0x420 then we think that
the start/end is 0x400 and 0x420 respectively, but the first line
might run from 0x100 to 0x108.
GDB will then try to scan the prologue starting from 0x400 and ending
at 0x108, this immediately gives up as it thinks we have gone past the
end of the prologue and the breakpoint is placed at 0x400.
In this commit I propose that we change find_pc_line to return
addresses in the unmapped range if the address passed in is already in
the unmapped range. Now the first line will appear to run from 0x400
to 0x408 and the prologue scanner will correctly find the end of the
prologue.
With this commit gdb.base/overlays.exp now completely passes with an
m32r-elf toolchain.
gdb/ChangeLog:
* symtab.c (find_pc_line): Return unmapped addresses when the
requested address is also unmapped.
Andrew Burgess [Sun, 13 Sep 2020 20:53:08 +0000 (21:53 +0100)]
gdb/testsuite: allow gdb.base/overlays.exp to compile for m32r
The gdb.base/overlays.exp test is only currently supported on m32r
baremetal targets, however, when I configure a toolchain for m32r-elf
the test does not compile.
This commit updates the linker script, fixes some TCL errors in the
exp file, and adds some missing includes to the source file so that
the test does compile.
With this test, when run against an m32r-elf toolchain the test mostly
passes, but there are a couple of failures, these are GDB issues and
will be addressed in a later commit.
gdb/testsuite/ChangeLog:
* gdb.base/m32r.ld: Remove SEARCH_DIR line. Add MEMORY regions,
make use of regions throughout.
* gdb.base/overlays.exp: Enclose string with variableds in "..",
not {...}.
* gdb.base/ovlymgr.c: Add 'string.h' and 'stdlib.h' includes.
Simon Marchi [Mon, 5 Oct 2020 16:21:14 +0000 (12:21 -0400)]
gdb: TYPE_VECTOR -> type::is_vector in amd64-windows-tdep.c
I get this build failure:
CXX amd64-windows-tdep.o
cc1plus: warning: command-line option '-Wmissing-prototypes' is valid for C/ObjC but not for C++
/home/smarchi/src/binutils-gdb/gdb/amd64-windows-tdep.c: In function 'return_value_convention amd64_windows_return_value(gdbarch*, value*, type*, regcache*, gdb_byte*, const gdb_byte*)':
/home/smarchi/src/binutils-gdb/gdb/amd64-windows-tdep.c:374:6: error: 'TYPE_VECTOR' was not declared in this scope
374 | if (TYPE_VECTOR (type) && len == 16)
| ^~~~~~~~~~~
TYPE_VECTOR was removed in favor of the type::is_vector method.
gdb/ChangeLog:
* amd64-windows-tdep.c (amd64_windows_return_value): Use
type::is_vector instead of TYPE_VECTOR.
Simon Marchi [Mon, 5 Oct 2020 13:02:42 +0000 (09:02 -0400)]
gdb: avoid unnecessary string copy in auto_load_objfile_script_1
Assigning the result of STRIP_DRIVE_SPEC to an std::string creates an
unnecessary copy of the string. STRIP_DRIVE_SPEC is defined as:
#define STRIP_DRIVE_SPEC(f) ((f) + 2)
So if it is passed a "const char *", it returns a "const char *". We
could use a "const char *" intermediary variable instead of an
std::string, or (as implemented in this patch) just use it directly in
the concatenation right after.
gdb/ChangeLog:
* auto-load.c (auto_load_objfile_script_1): Don't use
debugfile_holder as temporary variable when stripping drive
letter.
Hannes Domani [Tue, 5 May 2020 12:31:26 +0000 (14:31 +0200)]
Fix function argument and return value locations
Fixes these testsuite fails on Windows:
FAIL: gdb.base/callfuncs.exp: p t_float_complex_values(fc1, fc2)
FAIL: gdb.base/callfuncs.exp: p t_float_complex_many_args(fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4)
FAIL: gdb.base/callfuncs.exp: noproto: p t_float_complex_values(fc1, fc2)
FAIL: gdb.base/callfuncs.exp: noproto: p t_float_complex_many_args(fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4)
FAIL: gdb.base/call-sc.exp: p/c fun(); call call-sc-tld
FAIL: gdb.base/call-sc.exp: advance to fun for return; return call-sc-tld
FAIL: gdb.base/call-sc.exp: zed L for return; return call-sc-tld
FAIL: gdb.base/call-sc.exp: return foo; return call-sc-tld
FAIL: gdb.base/call-sc.exp: return foo; synchronize pc to main() for 'call-sc-tld'
FAIL: gdb.base/call-sc.exp: return foo; synchronize pc to main() for 'call-sc-tld'
FAIL: gdb.base/call-sc.exp: advance to fun for finish; return call-sc-tld
FAIL: gdb.base/call-sc.exp: zed L for finish; return call-sc-tld
FAIL: gdb.base/call-sc.exp: finish foo; return call-sc-tld (the program is no longer running)
FAIL: gdb.base/call-sc.exp: value foo finished; return call-sc-tld
For function arguments (callfuncs.exp), only TYPE_CODE_COMPLEX was
missing in the types passed via integer registers.
For return values, there were a lot more issues:
- TYPE_CODE_DECFLOAT is NOT returned via XMM0.
- long double is NOT returned via XMM0.
- but __int128 IS returned via XMM0.
- the comments for TYPE_CODE_FLT state that __m128, __m128i and __m128d are
returned by XMM0, and this is correct, but it doesn't actually check for
them, because they are TYPE_CODE_ARRAY with TYPE_VECTOR
So I had to add TYPE_CODE_DECFLOAT to the arguments passed via XMM register,
but I had to remove it from the values returned via XMM0 register.
gdb/ChangeLog:
2020-10-05 Hannes Domani <ssbssa@yahoo.de>
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Add TYPE_CODE_COMPLEX.
(amd64_windows_return_value): Fix types returned via XMM0.
gdb/testsuite/ChangeLog:
2020-10-05 Hannes Domani <ssbssa@yahoo.de>
* gdb.base/call-sc.c: Fix return struct on stack test case.
* gdb.base/call-sc.exp: Likewise.
H.J. Lu [Mon, 5 Oct 2020 12:27:58 +0000 (05:27 -0700)]
x86-64: Always display suffix for %LQ in 64bit
In 64bit, assembler generates a warning for "sysret":
$ echo sysret | as --64 -o x.o -
{standard input}: Assembler messages:
{standard input}:1: Warning: no instruction mnemonic suffix given and no register operands; using default for `sysret'
Always display suffix for %LQ in 64bit to display "sysretl".
H.J. Lu [Mon, 5 Oct 2020 12:23:29 +0000 (05:23 -0700)]
x86: Clear modrm if not needed
The MODRM byte can be checked to display the instruction name only if the
MODRM byte needed. Clear modrm if the MODRM byte isn't needed so that
modrm field checks in putop like, modrm.mod == N with N != 0, can be done
without checking need_modrm.
Nick Clifton [Mon, 5 Oct 2020 09:40:07 +0000 (10:40 +0100)]
GAS: Update the .section directive so that a numeric section index can be provided when the "o" flag is used.
PR 26253
gas * config/obj-elf.c (obj_elf_section): Accept a numeric value for
the "o" section flag. Interpret it as a section index. Allow an
index of zero.
* doc/as.texi: Document the new behaviour.
* NEWS: Mention the new feature. Tidy entries.
* testsuite/gas/elf/sh-link-zero.s: New test.
* testsuite/gas/elf/sh-link-zero.d: New test driver.
* testsuite/gas/elf/elf.exp: Run the new test.
* testsuite/gas/elf/section21.l: Updated expected assembler
output.
bfd * elf.c (_bfd_elf_setup_sections): Do not complain about an
sh_link value of zero when the SLF_LINK_ORDER flag is set.
(assign_section_numbers): Likewise.