When running test-case gdb.base/async.exp with gcc-8, we run into:
...
FAIL: gdb.base/async.exp: stepi&
...
The problem is that with gcc-8, the instruction address is no longer printed:
...
stepi&
-(gdb) 0x00000000004004b2 9 x = 5; x = 5; x = 5;
+(gdb) 9 x = 5; x = 5; x = 5;
completed.
-PASS: gdb.base/async.exp: stepi&
+FAIL: gdb.base/async.exp: stepi&
...
This is due to the fact that gcc-8 contains more precise line info, making the
address being stepped to a "recommended breakpoint location", and consequently
gdb doesn't print the address prefix anymore.
Given that:
- we step through statements on the same line, and
- there's no addres prefix anymore,
this gives the impression of lack of progress, which could be improved upon,
filed as enhancement PR25911 - "Show column when stepping through line".
Fix the FAIL by checking in the test-case whether addresses are at
"recommended breakpoint location" or not.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-05-04 Tom de Vries <tdevries@suse.de>
* gdb.base/async.exp: Check whether instruction addresses are a
"recommended breakpoint location".
I looked at all the calls to add_prefix_cmd, and replaced them with
calls to add_basic_prefix_cmd or add_show_prefix_cmd when appropriate.
This makes gdb's command language a bit more regular. I don't think
there's a significant downside.
Note that this patch removes a couple of tests. The removed ones are
completely redundant.
gdb/ChangeLog
2020-05-03 Tom Tromey <tom@tromey.com>
* breakpoint.c (catch_command, tcatch_command): Remove.
(_initialize_breakpoint): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
(set_breakpoint_cmd, show_breakpoint_cmd): Remove
* utils.c (set_internal_problem_cmd, show_internal_problem_cmd):
Remove.
(add_internal_problem_command): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* mips-tdep.c (set_mipsfpu_command): Remove.
(_initialize_mips_tdep): Use add_basic_prefix_cmd.
* dwarf2/index-cache.c (set_index_cache_command): Remove.
(_initialize_index_cache): Use add_basic_prefix_cmd.
* memattr.c (dummy_cmd): Remove.
(_initialize_mem): Use add_basic_prefix_cmd, add_show_prefix_cmd.
* tui/tui-win.c (set_tui_cmd, show_tui_cmd): Remove.
(_initialize_tui_win): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* cli/cli-logging.c (set_logging_command): Remove.
(_initialize_cli_logging): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
(show_logging_command): Remove.
* target.c (target_command): Remove.
(add_target): Use add_basic_prefix_cmd.
gdb/testsuite/ChangeLog
2020-05-03 Tom Tromey <tom@tromey.com>
* gdb.base/sepdebug.exp: Remove "catch" test.
* gdb.base/break.exp: Remove "catch" test.
* gdb.base/default.exp: Update expected output.
Since GCC 10 defaults to -fno-common, add -fcommon to common tests to
force common behavior.
PR gold/25904
* testsuite/Makefile.am (COMMON_TEST_C_CFLAGS): New.
(common_test_1.o): New rule.
(common_test_2.o): Likewise.
(common_test_3.o): Likewise.
(plugin_common_test_1.o): Likewise.
(plugin_common_test_2.o): Likewise.
(common_test_1_v1.o): Likewise.
(common_test_1_v2.o): Likewise.
(common_test_2_pic.o): Compile with $(COMMON_TEST_C_CFLAGS).
(common_test_3_pic.o): Likewise.
* testsuite/Makefile.in: Regenerated.
When running test-case gdb.arch/i386-mpx.exp with gcc-10, we get:
...
Running src/gdb/testsuite/gdb.arch/i386-mpx.exp ...
gdb compile failed, xgcc: warning: switch '-mmpx' is no longer supported
xgcc: warning: switch '-fcheck-pointer-bounds' is no longer supported
...
The test-case uses a combination of options, -mmpx and -fcheck-pointer-bounds.
The -fcheck-pointer-bounds option requires the -mmpx option:
...
$ gcc -fcheck-pointer-bounds ~/hello.c
hello.c:1:0: warning: Pointer Checker requires MPX support on this target. \
Use -mmpx options to enable MPX.
#include <stdio.h>
cc1: error: ‘-fcheck-pointer-bounds’ is not supported for this target
...
Both options is no longer supported in gcc-9.
Fix the warnings by testing if the option combination is supported.
Tested on x86_64-linux, with gcc-7.5.0 and gcc-10.0.1.
gdb/testsuite/ChangeLog:
2020-05-02 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (supports_mpx_check_pointer_bounds): New proc.
* gdb.arch/i386-mpx-call.exp: Use supports_mpx_check_pointer_bounds.
* gdb.arch/i386-mpx-map.exp: Same.
* gdb.arch/i386-mpx-sigsegv.exp: Same.
* gdb.arch/i386-mpx-simple_segv.exp: Same.
* gdb.arch/i386-mpx.exp: Same.
When running test-case gdb.base/psym-external-decl.exp with gcc-10, we have:
...
(gdb) print aaa^M
'aaa' has unknown type; cast it to its declared type^M
(gdb) FAIL: gdb.base/psym-external-decl.exp: print aaa
...
With an an earlier version, gcc still emits the debug info for the
declaration of aaa:
...
<0><d2>: Abbrev Number: 1 (DW_TAG_compile_unit)
<d8> DW_AT_name : psym-external-decl.c
<1><f4>: Abbrev Number: 2 (DW_TAG_variable)
<f5> DW_AT_name : aaa
<ff> DW_AT_external : 1
<ff> DW_AT_declaration : 1
...
but with gcc-10 that's no longer the case.
Fix the test-case by adding a use of aaa in psym-external-decl.c.
That still doesn't work for clang, so skip test in that case.
Tested with x86_64-linux, with gcc 7.5.0, gcc 10.0.0 and clang 5.0.2.
Also tested by reverting corresponding fix and ensuring test-case still
fails.
gdb/testsuite/ChangeLog:
2020-05-02 Tom de Vries <tdevries@suse.de>
* gdb.base/psym-external-decl.c (main): Add use of variable aaa.
GCC 9 generates the same function size for Ordering::operator() in
odr_violation1.cc and odr_violation2.cc on x32:
134: 00000000 31 FUNC WEAK DEFAULT 64 _ZN8OrderingclEii
40: 00000000 31 FUNC GLOBAL DEFAULT 10 _ZN8OrderingclEii
This patch makes Ordering::operator() even more complex
134: 00000000 31 FUNC WEAK DEFAULT 64 _ZN8OrderingclEii
42: 00000000 35 FUNC GLOBAL DEFAULT 11 _ZN8OrderingclEii
* testsuite/odr_violation2.cc (Ordering::operator()): Make
expression even more complex.
Handle local IFUNC symbol for APLT like global IFUNC symbol.
PR gold/25872
* x86_64.cc (Output_data_plt_x86_64_bnd::do_address_for_local):
Handle local IFUNC symbol.
(Output_data_plt_x86_64_ibt::do_address_for_local): Likewise.
When running test-case gdb.ada/operator_bp.exp with gcc-10, I run into:
...
FAIL: gdb.ada/operator_bp.exp: break "+"
FAIL: gdb.ada/operator_bp.exp: break "-"
FAIL: gdb.ada/operator_bp.exp: break "<"
FAIL: gdb.ada/operator_bp.exp: break "<="
FAIL: gdb.ada/operator_bp.exp: break ">"
FAIL: gdb.ada/operator_bp.exp: break ">="
FAIL: gdb.ada/operator_bp.exp: break "="
FAIL: gdb.ada/operator_bp.exp: break "and"
FAIL: gdb.ada/operator_bp.exp: break "or"
FAIL: gdb.ada/operator_bp.exp: break "xor"
FAIL: gdb.ada/operator_bp.exp: break "not"
...
The first FAIL is because two breakpoint locations are expected, but there are
more than 2:
...
(gdb) break "+"
Breakpoint 2 at 0x402c3c: "+". (6 locations)
(gdb) info break
Num Type Disp Enb Address What
2 breakpoint keep y <MULTIPLE>
2.1 y 0x0000000000402c3c in ops."+"
at operator_bp/ops.adb:25
2.2 y 0x0000000000402e5b in ops."+"
at operator_bp/ops.adb:119
2.3 y 0x0000000000414207 in
system.storage_elements."+" at s-stoele.adb:82
2.4 y 0x0000000000414404 in
system.storage_elements."+" at s-stoele.adb:87
2.5 y 0x0000000000414413 in
system.storage_elements."+" at s-stoele.adb:87
2.6 y 0x0000000000414430 in
system.storage_elements."+" at s-stoele.adb:81
...
This can be traced back to a extra debug info in the executable:
...
$ readelf -w ops_test | grep system__storage_elements__Oadd
<28104> DW_AT_name : system__storage_elements__Oadd__2
<2812e> DW_AT_name : system__storage_elements__Oadd
...
Fix the FAILs by allowing more than the required amount of breakpoint
locations.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-05-01 Tom de Vries <tdevries@suse.de>
* gdb.ada/operator_bp.exp: Allow more than required amount of
breakpoint.
The function info_command has disappeared, so this breakpoint does not
work anymore.
"info_command" was a function for the prefix command "info",
giving the list of "info" subcommands.
It is not very clear what the removed breakpoint and its associated
command list was supposed to do.
Removed and pushed as obvious, after discussion with Tom.
My recent change regarding size calculation of arrays of stubbed types
didn't take array strides and associated/allocated type properties into
account, which basically broke fortran arrays.
Fixed by refactoring the array size calculation of
create_array_type_with_stride into a new function, and also use it for
the stubbed array size recalculation.
gdb/ChangeLog:
2020-05-01 Hannes Domani <ssbssa@yahoo.de>
* gdbtypes.c (update_static_array_size): New function.
(create_array_type_with_stride): Use update_static_array_size.
(check_typedef): Likewise.
When running test-case gdb.reverse/until-reverse.exp or
gdb.reverse/until-precsave.exp with gcc-10, we run into a Wunused-result
warning:
...
gdb compile failed, gdb.reverse/until-reverse.c: In function 'main':
gdb.reverse/until-reverse.c:40:14: warning: ignoring return value of \
'malloc' declared with attribute 'warn_unused_result' [-Wunused-result]
40 | (void) malloc (1);
| ^~~~~~~~~~
...
Fix this by using the result of malloc as argument to a free call.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-05-01 Tom de Vries <tdevries@suse.de>
* gdb.reverse/until-reverse.c (main): Fix Wunused-result warning.
PR 25900
* elfnn-riscv.c (_bfd_riscv_relax_section): Check root.type before
accessing root.u.def of symbols. Also check root.u.def.section
is non-NULL. Reverse tests so as to make the logic positive.
The zero scan is silly when the result isn't used.
* objdump.c (disassemble_bytes): Don't scan for zeros when
disassembling zeros. Translate "resuming at file offset" message.
Formatting. Replace some signed variables with unsigned.
This allows backend merge_private_bfd_data to examine shared library
e_flags and/or .gnu.attributes. ARM and PowerPC have done so when
using ld.gold for a long time.
(The tic6x change below is dead code due to the earlier FIXME,
but this is probably one of the changes needed there.)
PR 25882
bfd/
* elf32-tic6x.c (elf32_tic6x_merge_attributes): Don't transfer
Tag_ABI_PIC or Tag_ABI_PID from dynamic objects to the output.
ld/
* ldlang.c (lang_check): Call bfd_merge_private_bfd_data for
shared libraries.
Code in the linker, present before the addition of .gnu.attributes
support, results in shared libraries not being considered by BFD when
merging e_flags and .gnu.attributes from input files to the output.
That doesn't seem correct to me, but I don't know enough about all the
various ABIs to change the behaviour with any confidence. So this
patch merely punts on dynamic objects in merge_private_bfd_data target
functions, with a FIXME for maintainer attention.
I haven't excluded shared libraries from being considered where the
target merge_private_bfd_data (a) already has code dealing with shared
libraries, or (b) where that function just sets the output to the most
constraining arch/mach combination and other fairly trivial merges, or
(c) when the target has no shared library linker support.
In (a) are: arc, arm, aarch64, riscv, sparc.
In (b) are: bpf, cris, csky, m32r, m68k, mn10300, nios2, tilegx,
tilepro, vax, visium, xtensa.
In (c) are: bpf, cr16, h8300, iq2000, m32c, m68hc11, m68hc12, mcore,
mep, msp430, mt, rl78, rx, v850.
PR 25882
* elf32-bfin.c (elf32_bfin_merge_private_bfd_data): Add FIXME.
* elf32-frv.c (frv_elf_merge_private_bfd_data): Likewise.
* elfxx-mips.c (_bfd_mips_elf_merge_private_bfd_data): Likewise.
* elf32-nds32.c (nds32_elf_merge_private_bfd_data): Likewise.
* elf32-score.c (s3_elf32_score_merge_private_bfd_data): Likewise.
* elf32-score7.c (s7_elf32_score_merge_private_bfd_data): Likewise.
* elf32-sh.c (sh_elf_merge_private_data): Likewise.
* elf32-tic6x.c (elf32_tic6x_merge_attributes): Likewise.
* elf64-ia64-vms.c (elf64_ia64_merge_private_bfd_data): Likewise.
* elfnn-ia64.c (elfNN_ia64_merge_private_bfd_data): Likewise.
EF_PPC_RELOCATABLE and similar flags, if present in an input shared
library, don't have any relevance as far as the output file is
concerned.
Currently, dynamic objects aren't seen in merge_private_bfd_data.
This patch is in preparation for a change to that.
PR 25882
* elf32-ppc.c (ppc_elf_merge_private_bfd_data): Ignore e_flags
from shared libraries.
Report LWP CREATE and LWP EXIT events and setup this on post_attach()
and post_startup_inferior().
Stop reinitializing the list of recognized threads in update_thread_list().
Handle LWP CREATE and EXIT events in nbsd_nat_target::wait().
gdb/ChangeLog:
* nbsd-nat.c (nbsd_enable_proc_events)
(nbsd_nat_target::post_startup_inferior): Add.
(nbsd_nat_target::post_attach): Call `nbsd_enable_proc_events'.
(nbsd_nat_target::update_thread_list): Rewrite.
(nbsd_nat_target::wait): Handle "PTRACE_LWP_EXIT" and
"PTRACE_LWP_CREATE".
* nbsd-nat.h (nbsd_nat_target::post_startup_inferior): Add.
This reverts commit 84ed7a4725.
The problem that the commit attempts to address has already been fixed in
commit 770479f223 "gdb: Fix toplevel types with -fdebug-types-section".
The commit itself is superfluous because it sets list_in_scope at a point that
it's already set (by start_symtab).
"frame" and "f" are created twice by stack.c _initialize_stack.
Remove the second creation.
Regression tested on amd64/Debian.
2020-04-30 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* stack.c (_initialize_stack): Remove duplicated creation
of "frame" command and "f" alias.
Sizes of stubbed types are calculated on demand in check_typedef, so the
same must also be done for arrays of stubbed types.
A stubbed type is usually a structure that has only been forward declared,
but can also happen if the structure has a virtual function that's not
inline in the class definition.
For these stubbed types, the size must be recalculated once the full
definition is available.
gdb/ChangeLog:
2020-04-30 Hannes Domani <ssbssa@yahoo.de>
PR gdb/18706
* gdbtypes.c (check_typedef): Calculate size of array of
stubbed type.
gdb/testsuite/ChangeLog:
2020-04-30 Hannes Domani <ssbssa@yahoo.de>
PR gdb/18706
* gdb.cp/stub-array-size.cc: New test.
* gdb.cp/stub-array-size.exp: New file.
* gdb.cp/stub-array-size.h: New test.
* gdb.cp/stub-array-size2.cc: New test.
gdb/testsuite/ChangeLog:
2020-04-30 Hannes Domani <ssbssa@yahoo.de>
* gdb.python/py-format-string.exp: Adjust pretty_arrays expected
output to the new format.
Non-static member functions for Windows 32bit programs need the thiscall
calling convention, so the 'this' pointer needs to be passed in ECX.
gdb/ChangeLog:
2020-04-30 Hannes Domani <ssbssa@yahoo.de>
PR gdb/15559
* i386-tdep.c (i386_push_dummy_call): Call
i386_thiscall_push_dummy_call.
(i386_thiscall_push_dummy_call): New function.
* i386-tdep.h (i386_thiscall_push_dummy_call): Declare.
* i386-windows-tdep.c (i386_windows_push_dummy_call): New function.
(i386_windows_init_abi): Call set_gdbarch_push_dummy_call.
Fields marked with XTENSA_NDIFF relocations are not negated, they only
have sign bits removed. Don't negate their values when relaxation is
performed. Don't add sign bits when the value is zero. Report overflow
when the result has negative sign but all significant bits are zero.
2020-04-29 Max Filippov <jcmvbkbc@gmail.com>
bfd/
* elf32-xtensa.c (relax_section): Don't negate diff_value for
XTENSA_NDIFF relocations. Don't add sign bits whe diff_value
equals 0. Report overflow when the result has negative sign but
all significant bits are zero.
ld/
* testsuite/ld-xtensa/relax-diff1.d: New test definition.
* testsuite/ld-xtensa/relax-diff1.s: New test source.
* testsuite/ld-xtensa/relax-ndiff.d: New test definition.
* testsuite/ld-xtensa/relax-ndiff.s: New test source.
* testsuite/ld-xtensa/xtensa.exp: (relax-diff1)
(relax-ndiff): New tests.
Starting with RH.0 release Xtensa ISA adds immediate parameter to
simcall opcode. For assembly source compatibility treat "simcall"
instruction without parameter as "simcall 0" when parameter is required.
2020-04-29 Max Filippov <jcmvbkbc@gmail.com>
gas/
* config/tc-xtensa.c (XTENSA_MARCH_EARLIEST): Define macro as 0
if it's not defined.
(microarch_earliest): New static variable.
(xg_translate_idioms): Translate "simcall" to "simcall 0" when
simcall opcode has mandatory parameter.
(xg_init_global_config): Initialize microarch_earliest.
shellcheck reports:
In gdbarch.sh line 53:
while IFS='' read line
^--^ SC2162: read without -r will mangle backslashes.
See the rationale at [1]. In our case, we actually want the backslashes
to be interpreted and removed. Silence the warning using a directive.
[1] https://github.com/koalaman/shellcheck/wiki/SC2162
gdb/ChangeLog:
* gdbarch.sh (do_read): Add shellcheck disable directive for
warning SC2162.
Fix all instances of this kind of warning:
In gdbarch.sh line 96:
m ) staticdefault="${predefault}" ;;
^-----------^ SC2154: predefault is referenced but not assigned.
These warnings appear because we are doing something a bit funky when reading
the gdbarch fields. These variables are not assigned explicitly, but
using some `eval` commands.
I don't think there is so much we can fix about those warnings. To
silence them, I've changed `${foo}` to `${foo:-}`. This tells the shell
to substitute with an empty string if `foo` is not defined. This
retains the current behavior, but the warnings go away.
gdb/ChangeLog:
* gdbarch.sh: Use ${foo:-} where shellcheck would report a
"referenced but not assigned" warning.
shellcheck reports:
In gdbarch.sh line 139:
fallbackdefault="0"
^-------------^ SC2034: fallbackdefault appears unused. Verify use (or export if used externally).
Indeed, the `fallbackdefault` variable appears to be unused, remove the
code that sets it.
gdb/ChangeLog:
* gdbarch.sh: Remove code that sets fallbackdefault.
Fix all warnings of this type:
In gdbarch.sh line 1238:
if [ "x${invalid_p}" = "x0" -a -n "${postdefault}" ]
^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
See the rationale here [1].
[1] https://github.com/koalaman/shellcheck/wiki/SC2166
gdb/ChangeLog:
* gdbarch.sh: Use shell operators && and || instead of
-a and -o.
Fix all instances of:
In gdbarch.sh line 2195:
printf " `echo "$function" | sed -e 's/./ /g'` %s %s)\n" "$returntype" "$function"
^-- SC2006: Use $(...) notation instead of legacy backticked `...`.
Did you mean:
printf " $(echo "$function" | sed -e 's/./ /g') %s %s)\n" "$returntype" "$function"
See here [1] for the rationale.
[1] https://github.com/koalaman/shellcheck/wiki/SC2006
gdb/ChangeLog:
* gdbarch.sh: Use $(...) instead of `...`.
Fix all instances of:
In gdbarch.sh line 31:
if test ! -r ${file}
^-----^ SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
if test ! -r "${file}"
Note that some instances of these are in text that is eval'ed. I'm
pretty sure that things could go wrong during the eval too, but that's
not something shellcheck can check.
gdb/ChangeLog:
* gdbarch.sh: Use double quotes around variables.
Fix all instances of this:
In gdbarch.sh line 2182:
printf " gdb_assert (!(${invalid_p}));\n"
^-- SC2059: Don't use variables in the printf format string. Use printf "..%s.." "$foo".
... by doing exactly as the message suggests.
The rationale explained here [1] makes sense, if there happens to be a
format specifier in text substituted for the variable, the printf won't
do what we expect.
[1] https://github.com/koalaman/shellcheck/wiki/SC2059
gdb/ChangeLog:
* gdbarch.sh: Use %s with printf, instead of variables in the
format string.