Tom Tromey [Sun, 3 Nov 2019 21:47:55 +0000 (14:47 -0700)]
Manage objfiles with shared_ptr
This changes objfiles to be managed using a shared_ptr. shared_ptr is
chosen because it enables the use of objfiles in background threads.
The simplest way to do this was to introduce a new iterator that will
return the underlying objfile, rather than a shared_ptr. (I also
tried changing the rest of gdb to use shared_ptr, but this was quite
large; and to using intrusive reference counting, but this also was
tricky.)
gdb/ChangeLog
2019-12-12 Tom Tromey <tom@tromey.com>
* progspace.h (objfile_list): New typedef.
(class unwrapping_objfile_iterator)
(struct unwrapping_objfile_range): Newl
(struct program_space) <objfiles_range>: Change type.
<objfiles>: Change return type.
<add_objfile>: Change type of "objfile" parameter.
<objfiles_list>: Now a list of shared_ptr.
* progspace.c (program_space::add_objfile): Change type of
"objfile". Update.
(program_space::remove_objfile): Update.
* objfiles.h (struct objfile) <~objfile>: Make public.
* objfiles.c (objfile::make): Update.
(objfile::unlink): Don't call delete.
Change-Id: I6fb7fbf06efb7cb7474c525908365863eae27eb3
Tom Tromey [Sat, 2 Nov 2019 03:02:38 +0000 (21:02 -0600)]
Move free_all_objfiles to program_space
This changes free_all_objfiles to be a method on program_space, in
line with the other changes to treat program_space as a container for
objfiles.
gdb/ChangeLog
2019-12-12 Tom Tromey <tom@tromey.com>
* symfile.c (symbol_file_clear): Update.
* progspace.h (struct program_space) <free_all_objfiles>: Declare
method.
* progspace.c (program_space::free_all_objfiles): New method.
* objfiles.h (free_all_objfiles): Don't declare.
* objfiles.c (free_all_objfiles): Move to program_space.
Change-Id: I908b549d2981b6005f7ca181fc0e6d24fc8b7b6f
Tom Tromey [Sun, 10 Mar 2019 12:56:33 +0000 (06:56 -0600)]
Store objfiles on a std::list
This removes objfile::next and changes objfiles to be stored in a
std::list.
gdb/ChangeLog
2019-12-12 Tom Tromey <tom@tromey.com>
* progspace.c (program_space::add_objfile)
(program_space::remove_objfile): Update.
(program_space::multi_objfile_p): Remove.
* objfiles.h (struct objfile) <next>: Remove.
* objfiles.c (objfile::objfile): Update.
(put_objfile_before): Update.
(unlink_objfile): Update.
* progspace.h (object_files): Remove.
(struct program_space) <objfiles_head>: Remove.
<objfiles_list>: New member.
<objfiles_range, objfiles_safe_range>: Change type.
(objfiles): Change return type.
(objfiles_safe): Update.
(multi_objfile_p): Rewrite and inline.
(object_files): Remove macro.
Change-Id: Ib4430e3db6f9a390399924379a5c10426c514853
Tom Tromey [Sun, 3 Nov 2019 17:38:36 +0000 (10:38 -0700)]
Introduce basic_safe_range
This introduces the basic_safe_range class, which can be used to
create a basic_safe_iterator. This also changes basic_safe_iterator
in two ways.
First, it simplifies the constructor. This seemed unnecessarily
complicated to me, and keeping it this way would prevent the second
change...
... which is to add a second constructor for initializing the
one-past-the-end iterator that is stored in basic_safe_iterator.
gdb/ChangeLog
2019-12-12 Tom Tromey <tom@tromey.com>
* gdbsupport/safe-iterator.h (basic_safe_iterator): Simplify. Add
second constructor.
(basic_safe_range): New class.
Change-Id: Ib351ef6fd435129a5053c64e5561877e1459ab37
Tom Tromey [Sun, 20 Jan 2019 04:33:50 +0000 (21:33 -0700)]
Remove MULTI_OBJFILE_P
This removes the MULTI_OBJFILE_P macro in favor of a method on the
program space.
gdb/ChangeLog
2019-12-12 Tom Tromey <tom@tromey.com>
* progspace.c (program_space::multi_objfile_p): New method.
* printcmd.c (info_symbol_command): Update.
* maint.c (maintenance_translate_address): Update.
* objfiles.h (MULTI_OBJFILE_P): Remove.
* progspace.h (struct program_space) <multi_objfile_p>: New
method.
Change-Id: I2779e26ea8909078d63fea8f13bce94cab73948c
Tom Tromey [Fri, 1 Nov 2019 22:42:29 +0000 (16:42 -0600)]
Introduce program_space::remove_objfile
This introduces a new method, program_space::remove_objfile, and
changes the objfile destructor not to unlink an objfile from the
program space's list.
This is cleaner because, like the previous patch, it treats the
program space more like a container for objfiles. Also, this makes it
possible to keep an objfile alive even though it has been unlinked
from the program space's list, which is important for processing in a
worker thread.
gdb/ChangeLog
2019-12-12 Tom Tromey <tom@tromey.com>
* progspace.h (struct program_space) <remove_objfile>: Declare.
* progspace.c (program_space::remove_objfile): New method.
* objfiles.c (unlink_objfile): Remove.
(objfile::unlink): Call remove_objfile.
(objfile): Don't call unlink_objfile.
Change-Id: I22f768827723dce21886fae9b3664532c8349e68
Tom Tromey [Fri, 1 Nov 2019 22:31:28 +0000 (16:31 -0600)]
Introduce program_space::add_objfile
This introduces a new method, program_space::add_objfile, that adds an
objfile to the program space's list of objfiles. It also changes the
obfile's constructor so that linking an objfile into this list is not
done here.
The former is an improvement because it makes more sense to treat the
program space as a container holding objfiles -- so manipulation of
the list belongs there.
The latter is not strictly needed, but seemed better both because it
is removing a global side effect from a constructor, and for symmetry
reasons, as a subsequent patch will remove unlinking from the
destructor.
gdb/ChangeLog
2019-12-12 Tom Tromey <tom@tromey.com>
* progspace.h (struct program_space) <add_objfile>: Declare
method.
* progspace.c (program_space::add_objfile): New method.
* objfiles.c (~objfile): Don't unlink objfile.
(put_objfile_before): Remove.
(add_separate_debug_objfile): Don't call put_objfile_before.
(objfile::make): Call add_objfile. Set new_objfiles_available on
the per-program-space data.
Change-Id: I93e8525dda631cb89dcc2046a5c51c7c9f34ccfd
Tom Tromey [Fri, 1 Nov 2019 22:21:04 +0000 (16:21 -0600)]
Make the objfile destructor private
The idea behind this is that, in the long run, some code will need to
be able to hold onto an objfile after it is unlinked from the program
space. In particular, this is needed for some functionality to be
moved to worker threads -- otherwise the objfile can be deleted while
still in use.
So, this makes ~objfile private, replacing it with an "unlink" method,
making it more obvious which operation is intended at the calling
points.
gdb/ChangeLog
2019-12-12 Tom Tromey <tom@tromey.com>
* symfile.c (syms_from_objfile_1): Use objfile_up.
(syms_from_objfile_1, remove_symbol_file_command): Call unlink
method.
(reread_symbols): Use objfile_up.
* solib.c (update_solib_list, reload_shared_libraries_1): Call
unlink method.
* objfiles.h (struct objfile) <~objfile>: Now private.
<unlink>: New method.
(struct objfile_deleter): New.
(objfile_up): New typedef.
* objfiles.c (objfile::unlink): New method.
(free_objfile_separate_debug, free_all_objfiles)
(objfile_purge_solibs): Use it.
* jit.c (jit_unregister_code): Remove.
(jit_inferior_exit_hook, jit_event_handler): Call unlink on
objfile.
* compile/compile-object-run.c (do_module_cleanup): Call unlink on
objfile.
* compile/compile-object-load.c (compile_object_load): Use
objfile_up.
Change-Id: I934bee70b26b8b24e1735828fb1e60fe8a05714f
Tom Tromey [Fri, 1 Nov 2019 22:10:48 +0000 (16:10 -0600)]
Make add_separate_debug_objfile static
This changes objfile::make to take a "parent" parameter, and makes
add_separate_debug_objfile static.
gdb/ChangeLog
2019-12-12 Tom Tromey <tom@tromey.com>
* symfile.c (symbol_file_add_with_addrs): Pass "parent" to
objfile::make.
* objfiles.h (struct objjfile) <make>: No longer inline.
(add_separate_debug_objfile): Don't declare.
* objfiles.c (add_separate_debug_objfile): Now static.
(objfile::make): Move from objfiles.h. Call
add_separate_debug_objfile. Add "parent" parameter.
Change-Id: I631f43bb71738dea6ae0697317bf8ef4a0db4617
Tom Tromey [Fri, 1 Nov 2019 22:06:37 +0000 (16:06 -0600)]
Make the objfile constructor private
This changes the objfile constructor to be private, changing the
callers to use a factory method. This isn't perhaps strictly needed
for the goal of this series -- changing the container model of
objfiles -- but is a nice symmetry.
gdb/ChangeLog
2019-12-12 Tom Tromey <tom@tromey.com>
* symfile.c (symbol_file_add_with_addrs): Use objfile::make.
* objfiles.h (struct objfile): Make constructor private.
<make>: New static method.
* jit.c (jit_object_close_impl): Update.
Change-Id: I42e07bc80a88cf3322ace94ffe869ae5788bcb29
H.J. Lu [Thu, 12 Dec 2019 20:25:48 +0000 (12:25 -0800)]
i386: Also check R12-R15 registers when optimizing testq to testb
Similar to SP, BP, SI and DI registers, R12-R15 registers must use REX
prefix for the low byte register when optimizing
test $imm7, %r64/%r32/%r16 -> test $imm7, %r8
PR gas/25274
* config/tc-i386.c (optimize_encoding): Also check R12-R15
registers for "test $imm7, %r64/%r32/%r16 -> test $imm7, %r8"
optimization.
* testsuite/gas/i386/x86-64-optimize-3.s: Add tests for test
with r12.
* testsuite/gas/i386/x86-64-optimize-3.d: Updated.
* testsuite/gas/i386/x86-64-optimize-3b.d: Likewise.
H.J. Lu [Thu, 12 Dec 2019 19:58:50 +0000 (11:58 -0800)]
i386: Add tests for -malign-branch-boundary and -malign-branch
Add tests for -malign-branch-boundary, -malign-branch and
-mbranches-within-32B-boundaries.
gas/
* testsuite/gas/i386/align-branch-1.s: New file.
* testsuite/gas/i386/align-branch-1a.d: Likewise.
* testsuite/gas/i386/align-branch-1b.d: Likewise.
* testsuite/gas/i386/align-branch-1c.d: Likewise.
* testsuite/gas/i386/align-branch-1d.d: Likewise.
* testsuite/gas/i386/align-branch-1e.d: Likewise.
* testsuite/gas/i386/align-branch-1f.d: Likewise.
* testsuite/gas/i386/align-branch-1g.d: Likewise.
* testsuite/gas/i386/align-branch-1h.d: Likewise.
* testsuite/gas/i386/align-branch-2.s: Likewise.
* testsuite/gas/i386/align-branch-2a.d: Likewise.
* testsuite/gas/i386/align-branch-2b.d: Likewise.
* testsuite/gas/i386/align-branch-2c.d: Likewise.
* testsuite/gas/i386/align-branch-3.d: Likewise.
* testsuite/gas/i386/align-branch-3.s: Likewise.
* testsuite/gas/i386/align-branch-4.s: Likewise.
* testsuite/gas/i386/align-branch-4a.d: Likewise.
* testsuite/gas/i386/align-branch-4b.d: Likewise.
* testsuite/gas/i386/align-branch-5.d: Likewise.
* testsuite/gas/i386/align-branch-5.s: Likewise.
* testsuite/gas/i386/align-branch-6.d: Likewise.
* testsuite/gas/i386/align-branch-6.s: Likewise.
* testsuite/gas/i386/align-branch-7.d: Likewise.
* testsuite/gas/i386/align-branch-7.s: Likewise.
* testsuite/gas/i386/align-branch-8.d: Likewise.
* testsuite/gas/i386/align-branch-8.s: Likewise.
* testsuite/gas/i386/x86-64-align-branch-1.s: Likewise.
* testsuite/gas/i386/x86-64-align-branch-1a.d: Likewise.
* testsuite/gas/i386/x86-64-align-branch-1b.d: Likewise.
* testsuite/gas/i386/x86-64-align-branch-1c.d: Likewise.
* testsuite/gas/i386/x86-64-align-branch-1d.d: Likewise.
* testsuite/gas/i386/x86-64-align-branch-1e.d: Likewise.
* testsuite/gas/i386/x86-64-align-branch-1f.d: Likewise.
* testsuite/gas/i386/x86-64-align-branch-1g.d: Likewise.
* testsuite/gas/i386/x86-64-align-branch-1h.d: Likewise.
* testsuite/gas/i386/x86-64-align-branch-2.s: Likewise.
* testsuite/gas/i386/x86-64-align-branch-2a.d: Likewise.
* testsuite/gas/i386/x86-64-align-branch-2b.d: Likewise.
* testsuite/gas/i386/x86-64-align-branch-2c.d: Likewise.
* testsuite/gas/i386/x86-64-align-branch-3.d: Likewise.
* testsuite/gas/i386/x86-64-align-branch-3.s: Likewise.
* testsuite/gas/i386/x86-64-align-branch-4.s: Likewise.
* testsuite/gas/i386/x86-64-align-branch-4a.d: Likewise.
* testsuite/gas/i386/x86-64-align-branch-4b.d: Likewise.
* testsuite/gas/i386/x86-64-align-branch-5.d: Likewise.
* testsuite/gas/i386/x86-64-align-branch-6.d: Likewise.
* testsuite/gas/i386/x86-64-align-branch-7.d: Likewise.
* testsuite/gas/i386/x86-64-align-branch-7.s: Likewise.
* testsuite/gas/i386/x86-64-align-branch-8.d: Likewise.
* testsuite/gas/i386/x86-64-align-branch-8.s: Likewise.
* testsuite/gas/i386/i386.exp: Run new tests.
ld/
* testsuite/ld-i386/align-branch-1.d: New file.
* testsuite/ld-i386/align-branch-1.s: Likewise.
* testsuite/ld-x86-64/align-branch-1.d: Likewise.
* testsuite/ld-x86-64/align-branch-1.3: Likewise.
* testsuite/ld-i386/i386.exp: Run the new test.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
H.J. Lu [Thu, 12 Dec 2019 19:57:03 +0000 (11:57 -0800)]
i386: Add -mbranches-within-32B-boundaries
Add -mbranches-within-32B-boundaries to enable
-malign-branch-boundary=32
-malign-branch=jcc+fused+jmp
-malign-branch-prefix-size=5
* config/tc-i386.c (OPTION_MBRANCHES_WITH_32B_BOUNDARIES): New.
(md_longopts): Add -mbranches-within-32B-boundaries.
(md_parse_option): Handle -mbranches-within-32B-boundaries.
(md_show_usage): Add -mbranches-within-32B-boundaries.
H.J. Lu [Thu, 12 Dec 2019 19:56:06 +0000 (11:56 -0800)]
i386: Align branches within a fixed boundary
Add 3 command-line options to align branches within a fixed boundary
with segment prefixes or NOPs:
1. -malign-branch-boundary=NUM aligns branches within NUM byte boundary.
2. -malign-branch=TYPE[+TYPE...] specifies types of branches to align.
The supported branches are:
a. Conditional jump.
b. Fused conditional jump.
c. Unconditional jump.
d. Call.
e. Ret.
f. Indirect jump and call.
3. -malign-branch-prefix-size=NUM aligns branches with NUM segment
prefixes per instruction.
3 new rs_machine_dependent frag types are added:
1. BRANCH_PADDING. The variable size frag to insert NOP before branch.
2. BRANCH_PREFIX. The variable size frag to insert segment prefixes to
an instruction. The choices of prefixes are:
a. Use the existing segment prefix if there is one.
b. Use CS segment prefix in 64-bit mode.
c. In 32-bit mode, use SS segment prefix with ESP/EBP base register
and use DS segment prefix without ESP/EBP base register.
3. FUSED_JCC_PADDING. The variable size frag to insert NOP before fused
conditional jump.
The new rs_machine_dependent frags aren't inserted if the previous item
is a prefix or a constant directive, which may be used to hardcode an
instruction, since there is no clear instruction boundary. Segment
prefixes and NOP padding are disabled before relaxable TLS relocations
and tls_get_addr calls to keep TLS instruction sequence unchanged.
md_estimate_size_before_relax() and i386_generic_table_relax_frag() are
used to handled BRANCH_PADDING, BRANCH_PREFIX and FUSED_JCC_PADDING frags.
i386_generic_table_relax_frag() grows or shrinks sizes of segment prefix
and NOP to align the next branch frag:
1. First try to add segment prefixes to instructions before a branch.
2. If there is no sufficient room to add segment prefixes, NOP will be
inserted before a branch.
* config/tc-i386.c (_i386_insn): Add has_gotpc_tls_reloc.
(tls_get_addr): New.
(last_insn): New.
(align_branch_power): New.
(align_branch_kind): New.
(align_branch_bit): New.
(align_branch): New.
(MAX_FUSED_JCC_PADDING_SIZE): New.
(align_branch_prefix_size): New.
(BRANCH_PADDING): New.
(BRANCH_PREFIX): New.
(FUSED_JCC_PADDING): New.
(i386_generate_nops): Support BRANCH_PADDING and FUSED_JCC_PADDING.
(md_begin): Abort if align_branch_prefix_size <
MAX_FUSED_JCC_PADDING_SIZE.
(md_assemble): Set last_insn.
(maybe_fused_with_jcc_p): New.
(add_fused_jcc_padding_frag_p): New.
(add_branch_prefix_frag_p): New.
(add_branch_padding_frag_p): New.
(output_insn): Generate a BRANCH_PADDING, FUSED_JCC_PADDING or
BRANCH_PREFIX frag and terminate each frag to align branches.
(output_disp): Set i.has_gotpc_tls_reloc to TRUE for GOTPC and
relaxable TLS relocations.
(output_imm): Likewise.
(i386_next_non_empty_frag): New.
(i386_next_jcc_frag): New.
(i386_classify_machine_dependent_frag): New.
(i386_branch_padding_size): New.
(i386_generic_table_relax_frag): New.
(md_estimate_size_before_relax): Handle COND_JUMP_PADDING,
FUSED_JCC_PADDING and COND_JUMP_PREFIX frags.
(md_convert_frag): Handle BRANCH_PADDING, BRANCH_PREFIX and
FUSED_JCC_PADDING frags.
(OPTION_MALIGN_BRANCH_BOUNDARY): New.
(OPTION_MALIGN_BRANCH_PREFIX_SIZE): New.
(OPTION_MALIGN_BRANCH): New.
(md_longopts): Add -malign-branch-boundary=,
-malign-branch-prefix-size= and -malign-branch=.
(md_parse_option): Handle -malign-branch-boundary=,
-malign-branch-prefix-size= and -malign-branch=.
(md_show_usage): Display -malign-branch-boundary=,
-malign-branch-prefix-size= and -malign-branch=.
(i386_target_format): Set tls_get_addr.
(i386_cons_align): New.
* config/tc-i386.h (i386_cons_align): New.
(md_cons_align): New.
(i386_generic_table_relax_frag): New.
(md_generic_table_relax_frag): New.
(i386_tc_frag_data): Add u, padding_address, length,
max_prefix_length, prefix_length, default_prefix, cmp_size,
classified and branch_type.
(TC_FRAG_INIT): Initialize u, padding_address, length,
max_prefix_length, prefix_length, default_prefix, cmp_size,
classified and branch_type.
* doc/c-i386.texi: Document -malign-branch-boundary=,
-malign-branch= and -malign-branch-prefix-size=.
H.J. Lu [Thu, 12 Dec 2019 19:54:31 +0000 (11:54 -0800)]
gas: Add md_generic_table_relax_frag
Add md_generic_table_relax_frag for TC_GENERIC_RELAX_TABLE targets so
that a backend can extend relax_frag beyond TC_GENERIC_RELAX_TABLE.
* write.c (md_generic_table_relax_frag): New. Defined to
relax_frag if not defined.
(relax_segment): Call md_generic_table_relax_frag instead of
relax_frag.
Simon Marchi [Thu, 12 Dec 2019 19:54:47 +0000 (14:54 -0500)]
Replace xmalloc/xfree with vector in jit.c
I'm currently studying that code and noticed this manual memory
management, which could easily be replaced with a vector, so here it is.
gdb/ChangeLog:
* jit.c (jit_reader_try_read_symtab): Replace xmalloc/xfree with
gdb::byte_vector.
Tom Tromey [Tue, 10 Dec 2019 18:19:23 +0000 (11:19 -0700)]
Remove some calls to malloc_failure
I noticed a couple of spots that call malloc_failure, but that don't
need to.
* In xml-support.c, "concat" uses xmalloc, so cannot return NULL.
* In utils.c, "buildargv" also uses xmalloc, so can only return NULL
if the argument is empty.
Tested by the buildbot.
gdb/ChangeLog
2019-12-12 Tom Tromey <tromey@adacore.com>
* xml-support.c (xml_fetch_content_from_file): Don't call
malloc_failure.
* utils.h (class gdb_argv): Remove malloc_failure comment.
* utils.c (gdb_argv::reset): Don't call malloc_failure.
Change-Id: I59483620deb6609ccf2f024d94a29113bb62d1a9
Tom Tromey [Fri, 19 Apr 2019 16:41:40 +0000 (10:41 -0600)]
Ravenscar port for RISC-V
This adds Ravenscar support to gdb for RISC-V targets.
This was tested internally using AdaCore's test suite and qemu.
gdb/ChangeLog
2019-12-12 Tom Tromey <tromey@adacore.com>
* Makefile.in (ALL_TARGET_OBS): Add riscv-ravenscar-thread.o.
(HFILES_NO_SRCDIR): Add riscv-ravenscar-thread.h.
(ALLDEPFILES): Add riscv-ravenscar-thread.c.
* configure.tgt (riscv-*-*): Add riscv-ravenscar-thread.o.
* riscv-ravenscar-thread.c: New file.
* riscv-ravenscar-thread.h: New file.
* riscv-tdep.c (riscv_gdbarch_init): Call
register_riscv_ravenscar_ops.
Change-Id: Ic47a3b3cfbbe80c2c82a5f48d2e0481845cac8b0
Tom Tromey [Thu, 12 Dec 2019 13:09:40 +0000 (06:09 -0700)]
Fix the thread-pool.c compilation
A recent commit removed DIAGNOSTIC_IGNORE_UNUSED_FUNCTION, which was
used in thread-pool.c. This patch changes this code to use
ATTRIBUTE_UNUSED instead.
Tested by rebuilding.
gdb/ChangeLog
2019-12-12 Tom Tromey <tromey@adacore.com>
* gdbsupport/thread-pool.c (set_thread_name): Use
ATTRIBUTE_UNUSED.
Change-Id: I56d46eaac73690565d0e52db1791411567a918dd
Luis Machado [Wed, 11 Dec 2019 14:55:49 +0000 (11:55 -0300)]
Fix unused function error
Attempting to build GDB in Ubuntu 16.04.6 LTS on x86_64, I ran into warnings
that caused the build to fail:
binutils-gdb/gdb/gdbsupport/safe-strerror.c:44:1: error: ‘char* select_strerror_r(char*, char*)’ defined but not used [-Werror=unused-function] select_strerror_r (char *res, char *)
The diagnostic macro DIAGNOSTIC_IGNORE_UNUSED_FUNCTION seems to expand
correctly to its respective pragma, but this doesn't seem to have an effect on
the warning. I tried to use the pragma explicitly and got the same result.
ATTRIBUTE_UNUSED works fine in this case if you put it in both functions,
which should fix warnings for both gdb and gdbserver builds.
The compiler version is gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0
20160609.
This is likely the result of PR64079 in GCC, which was fixed by commit
9e96f1e1b9731c4e1ef4fbbbf0997319973f0537.
To prevent other developers from attempting to use this macro, only to get
confused by it not working as expected, it seems better to not define this
particular macro.
gdb/ChangeLog:
2019-12-12 Luis Machado <luis.machado@linaro.org>
* gdbsupport/safe-strerror.c: Don't include diagnostics.h.
(select_strerror_r): Use ATTRIBUTE_UNUSED instead of the diagnostics
macros.
include/ChangeLog:
2019-12-12 Luis Machado <luis.machado@linaro.org>
* diagnostics.h (DIAGNOSTIC_IGNORE_UNUSED_FUNCTION). Remove
definitions.
Change-Id: Iad6123d61d76d111e3ef8d24aa8c60112304c749
Alan Modra [Wed, 11 Dec 2019 22:59:45 +0000 (09:29 +1030)]
gas signed overflow fixes
* config/tc-aarch64.c (get_aarch64_insn): Avoid signed overflow.
* config/tc-metag.c (parse_dalu): Likewise.
* config/tc-tic4x.c (md_pcrel_from): Likewise.
* config/tc-tic6x.c (tic6x_output_unwinding): Likewise.
* config/tc-csky.c (parse_fexp): Use an unsigned char temp buffer.
Don't use register keyword. Avoid signed overflow and remove now
unneccesary char masks. Formatting.
* config/tc-ia64.c (operand_match): Don't use shifts to sign extend.
* config/tc-mep.c (mep_apply_fix): Likewise.
* config/tc-pru.c (md_apply_fix): Likewise.
* config/tc-riscv.c (load_const): Likewise.
* config/tc-nios2.c (md_apply_fix): Likewise. Don't potentially
truncate fixup before right shift. Tidy BFD_RELOC_NIOS2_HIADJ16
calculation.
Alan Modra [Thu, 12 Dec 2019 06:17:21 +0000 (16:47 +1030)]
obj-evax.c tidy
This started out as fixing decode_16, which used a char to index a 256
byte decodings array. When char is signed that could result in an out
of bounds array access. The rest of the patch is for consistency and
just general cleanup.
* config/obj-evax.c (crc32, encode_32, encode_16, decode_16):
Remove unnecessary prototypes.
(number_of_codings): Delete, use ARRAY_SIZE instead throughout.
(codings, decodings): Make arrays of unsigned char.
(crc32): Use unsigned variables. Delete unnecessary mask.
(encode_32, encode_16): Return unsigned char*, and make static
buffer an unsigned char array.
(decode_16): Make arg an unsigned char*. Remove useless casts.
(shorten_identifier): Use unsigned char crc_chars.
(is_truncated_identifier): Make ptr an unsigned char*.
Alan Modra [Thu, 12 Dec 2019 06:14:24 +0000 (16:44 +1030)]
csky: tidy csky_chars_to_number
* csky-dis.c (csky_chars_to_number): Remove abort and unnecessary
mask.
Alan Modra [Thu, 12 Dec 2019 03:50:07 +0000 (14:20 +1030)]
Remove duplicate cast
* libbfd.c (bfd_get): Don't cast result of bfd_get_8.
* bfd-in2.h: Regenerate.
Tom Tromey [Thu, 12 Dec 2019 02:17:47 +0000 (19:17 -0700)]
Fix TUI test suite regexps
Testing on another TUI series showed that some of the regexps in the
TUI test suite have been incorrect for a while. In particular, "|"
was meant literally in these tests, but was interpreted as pattern
alternation due to lack of quoting.
This patch fixes the bad tests. I am checking this in.
gdb/testsuite/ChangeLog
2019-12-11 Tom Tromey <tom@tromey.com>
* gdb.tui/resize.exp: Fix regexp.
* gdb.tui/regs.exp: Fix regexps.
* gdb.tui/main.exp: Fix regexp.
Change-Id: Ib6661361171ac120bb92f4a8aec7efa4bcaa36b9
GDB Administrator [Thu, 12 Dec 2019 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Sat, 26 Oct 2019 22:37:32 +0000 (16:37 -0600)]
Change "winheight" resizing to use new layout code
The "winheight" command resizes a specified window, resizing the other
windows in the layout to adapt. In the current code, this is done by
examining each possible layout separately. The new layout code has a
more general approach to handling this, and this patch simply removes
the old code in favor of a call into the new layout engine.
gdb/ChangeLog
2019-12-11 Tom Tromey <tom@tromey.com>
* tui/tui-win.c (tui_set_win_height_command): Call
tui_adjust_window_height.
(tui_adjust_win_heights, new_height_ok): Remove.
* tui/tui-layout.h (tui_adjust_window_height): Declare.
* tui/tui-layout.c (tui_adjust_window_height): New function.
Change-Id: I6bb681375a46adc8d29fd06f581deed4e078e78a
Tom Tromey [Thu, 10 Oct 2019 03:18:31 +0000 (21:18 -0600)]
Re-apply the current layout when resizing
The TUI has separate code for each possible layout to handle the case
where the terminal window is resized. With the new layout code, this
can all be replaced with a call to tui_apply_current_layout, which
simply re-applies the current layout.
This results in some small differences in behavior when resizing, so
some tests are updated.
gdb/ChangeLog
2019-12-11 Tom Tromey <tom@tromey.com>
* tui/tui-win.c (tui_resize_all): Remove code, call
tui_apply_current_layout.
gdb/testsuite/ChangeLog
2019-12-11 Tom Tromey <tom@tromey.com>
* gdb.tui/resize.exp: Update.
* gdb.tui/empty.exp (layouts): Update.
Change-Id: I3dc6c02a753d495d9ab5e8213d550a147198ce6f
Tom Tromey [Wed, 9 Oct 2019 22:35:41 +0000 (16:35 -0600)]
First use of tui_layout
This patch introduces the first use of tui_layout, by changing
show_layout to clone and use the appropriate tui_layout.
This resulted in one minor layout change, and also in the unintended
-- but good -- side effect that the title of each boxed window is now
visible.
gdb/ChangeLog
2019-12-11 Tom Tromey <tom@tromey.com>
* tui/tui-layout.h (tui_apply_current_layout): Declare.
* tui/tui-layout.c (standard_layouts, applied_layout): New
globals.
(tui_apply_current_layout): New function.
(show_layout): Set applied_layout. Call
tui_apply_current_layout.
(show_source_command, show_disasm_command)
(show_source_disasm_command, show_data)
(show_source_or_disasm_and_command): Remove.
(initialize_layouts): New function.
(_initialize_tui_layout): Call initialize_layouts.
gdb/testsuite/ChangeLog
2019-12-11 Tom Tromey <tom@tromey.com>
* gdb.tui/regs.exp: Update.
* gdb.tui/empty.exp (layouts): Update.
* gdb.tui/basic.exp: Update.
* lib/tuiterm.exp (_check_box): Don't check bottom border.
Change-Id: If1ee06ee58f4803e8c213f4ab0f5bb59f4650ec2
Tom Tromey [Tue, 8 Oct 2019 00:03:02 +0000 (18:03 -0600)]
Introduce new layout code
This introduces a new approach to window layout for the TUI. The idea
behind this code is that a layout should be specified in a declarative
way, and then be applied by generic code that does not need to know
the specifics of every possible layout.
This patch itself does not change any behavior, because the new layout
engine isn't yet connected to anything. That is, this merely
introduces the implementation.
This generic approach makes the code more maintainable. It also
enables some future changes:
* New window types are simpler to add;
* User-specified layouts are possible; and
* Horizontal layouts are more attainable
gdb/ChangeLog
2019-12-11 Tom Tromey <tom@tromey.com>
* tui/tui-layout.h (class tui_layout_base)
(class tui_layout_window, class tui_layout_split): New.
* tui/tui-layout.c (tui_get_window_by_name)
(tui_layout_window::clone, tui_layout_window::apply)
(tui_layout_window::get_sizes, tui_layout_window::add_split)
(tui_layout_split::add_window, tui_layout_split::clone)
(tui_layout_split::get_sizes)
(tui_layout_split::set_weights_from_heights)
(tui_layout_split::adjust_size, tui_layout_split::apply): New
functions.
(tui_layout_split::add_split, tui_layout_split::add_split)
(tui_layout_split::set_weights_from_heights)
(tui_layout_split::set_weights_from_heights): New functions.
Change-Id: I3a4cae666327b617d862aaa356f8179f945c6a4e
Tom Tromey [Sat, 26 Oct 2019 22:00:01 +0000 (16:00 -0600)]
Remove struct tui_point
struct tui_point does not help very much. It is only used for
storage, and never passed between functions. I think it makes the
code more verbose without any corresponding benefit, so this patch
removes it.
gdb/ChangeLog
2019-12-11 Tom Tromey <tom@tromey.com>
* tui/tui-wingeneral.c (tui_gen_win_info::make_window): Update.
* tui/tui-win.c (tui_adjust_win_heights, tui_resize_all): Update.
* tui/tui-layout.c (tui_gen_win_info::resize): Update.
* tui/tui-data.h (struct tui_point): Remove.
(struct tui_gen_win_info) <origin>: Remove.
<x, y>: New fields.
* tui/tui-command.c (tui_cmd_window::resize): Update.
Change-Id: I3f77920585b9ea9e2b4b189f3f3ae32d4da0c252
Tom Tromey [Mon, 7 Oct 2019 23:36:49 +0000 (17:36 -0600)]
Introduce the tui_gen_win_info::min_height method
This introduces a new method, tui_gen_win_info::min_height, to fetch
the minimum height of a window. This is used in the subsequent
unified layout patch.
gdb/ChangeLog
2019-12-11 Tom Tromey <tom@tromey.com>
* tui/tui-stack.h (struct tui_locator_window) <min_height>:
Implement.
* tui/tui-regs.h (struct tui_data_item_window) <min_height>:
Implement.
* tui/tui-data.h (struct tui_gen_win_info) <min_height>: New
method.
(struct tui_win_info) <min_height>: Implement.
Change-Id: Id33baffdf041fde072e15c1ff89b75f8b8118adb
Tom Tromey [Wed, 6 Nov 2019 00:12:04 +0000 (17:12 -0700)]
Move can_box to tui_gen_win_info
This moves the can_box method to tui_gen_win_info, so that it will be
available on the tui_locator_window class. This will be used in a
subsequent patch.
gdb/ChangeLog
2019-12-11 Tom Tromey <tom@tromey.com>
* tui/tui-data.h (struct tui_gen_win_info) <can_box>: New method.
(struct tui_win_info) <can_box>: Update.
Change-Id: Idfa58af41341607932d3c39415f6a35ee9b5d3dc
Tom Tromey [Mon, 7 Oct 2019 22:59:02 +0000 (16:59 -0600)]
Move max_height method to tui_gen_win_info
This moves the max_height method to tui_gen_win_info and implements it
in the subclasses. This is used by a subsequent patch, which will
normalize window layout across all window types.
gdb/ChangeLog
2019-12-11 Tom Tromey <tom@tromey.com>
* tui/tui-stack.h (struct tui_locator_window) <max_height>: New
method.
* tui/tui-regs.h (struct tui_data_item_window) <max_height>: New
method.
* tui/tui-data.h (struct tui_gen_win_info) <max_height>: New
method.
(struct tui_win_info) <max_height>: Now override.
Change-Id: I4ba3e8899bc4668328d3d78e3c1674c61882450d
Joel Brobecker [Wed, 11 Dec 2019 20:44:47 +0000 (21:44 +0100)]
Update NEWS post GDB 9 branch creation.
gdb/ChangeLog:
* NEWS: Create a new section for the next release branch.
Rename the section of the current branch, now that it has
been cut.
Joel Brobecker [Wed, 11 Dec 2019 20:37:51 +0000 (21:37 +0100)]
Bump version to 10.0.50.DATE-git.
Now that the GDB 9 branch has been created, we can
bump the version number.
gdb/ChangeLog:
GDB 9 branch created (
27f7b2f64062ac9e52afc60509263c2702a9ebd0):
* version.in: Bump version to 10.0.50.DATE-git.
Simon Marchi [Wed, 11 Dec 2019 16:30:15 +0000 (11:30 -0500)]
Fix typo, get_Frame_id -> get_frame_id
gdb/doc/ChangeLog:
* gdb.texinfo (Writing JIT Debug Info Readers): Fix typo.
Andre Vieira [Wed, 11 Dec 2019 15:53:26 +0000 (15:53 +0000)]
[gas][arm] Add -mwarn-restrict-it
Add a -m{no-}warn-restrict-it option to control IT related warnings in
ARMv8-A and ARMv8-R. This is disabled by default.
Committed on behalf of Wilco Dijkstra.
gas/ChangeLog:
2019-12-11 Wilco Dijkstra <wdijkstr@arm.com>
* config/tc-arm.c (warn_on_restrict_it): Add new variable.
(it_fsm_post_encode): Check warn_on_restrict_it.
(arm_option_table): Add -mwarn-restrict-it/-mno-warn-restrict-it.
* testsuite/gas/arm/armv8-2-fp16-scalar-bad.d: Add -mwarn-restrict-it.
* testsuite/gas/arm/armv8-2-fp16-scalar-bad-ext.d: Likewise.
* testsuite/gas/arm/armv8-a-bad.d: Likewise.
* testsuite/gas/arm/armv8-a-it-bad.d: Likewise.
* testsuite/gas/arm/armv8-r-bad.d: Likewise.
* testsuite/gas/arm/armv8-r-it-bad.d: Likewise.
* testsuite/gas/arm/sp-pc-validations-bad-t-v8a.d: Likewise.
* testsuite/gas/arm/udf.d: Likewise.
Tom Tromey [Tue, 10 Dec 2019 21:16:19 +0000 (14:16 -0700)]
Fix build on macOS
PR build/25268 points out that the build fails on macOS, because on
macOS the "pthread_setname_np" function takes a single argument.
This patch fixes the problem, by introducing a new adapter function
that handles both styles of pthread_setname_np.
This change also meant moving the pthread_setname_np call to the
thread function, because macOS only permits setting the name of the
current thread. This means that there can be a brief window when gdb
will see the wrong name; but I think this is a minor concern.
Tested by rebuilding on x86-64 Fedora 30, and on macOS High Sierra.
On Linux I also debugged gdb to ensure that the thread names are still
set correctly.
gdb/ChangeLog
2019-12-11 Tom Tromey <tromey@adacore.com>
PR build/25268:
* gdbsupport/thread-pool.c (set_thread_name): New function.
(thread_pool::set_thread_count): Don't call pthread_setname_np.
(thread_pool::thread_function): Call set_thread_name.
Change-Id: Id7bf28d99ca27a893a9fc87ebb90b15a9c2a9cb4
Tom Tromey [Wed, 11 Dec 2019 14:58:46 +0000 (07:58 -0700)]
Fix the build after bfd_get_signed_8 change
A recent commit changed bfd_get_signed_8 to extend the result to a
bfd_signed_vma. This caused a compiler error in one spot in my
--enable-targets=all gdb build, where the result of bfd_get_signed_8
was passed to printf.
This patch fixes the build. Tested by rebuilding.
gdb/ChangeLog
2019-12-11 Tom Tromey <tromey@adacore.com>
* fbsd-tdep.c (fbsd_core_info_proc_status): Cast result of
bfd_get_signed_8.
Change-Id: Ic015f5fd3d88da6b5da8f7b4e1d11d5c981333db
Alan Modra [Wed, 11 Dec 2019 06:15:14 +0000 (16:45 +1030)]
Remove more shifts for sign/zero extension
cpu/
* epiphany.cpu (f-sdisp11): Don't sign extend with shifts.
* lm32.cpu (f-branch, f-vall): Likewise.
* m32.cpu (f-lab-8-16): Likewise.
opcodes/
* arc-dis.c (BITS): Don't truncate high bits with shifts.
* nios2-dis.c (nios2_print_insn_arg): Don't sign extend with shifts.
* tic54x-dis.c (print_instruction): Likewise.
* tilegx-opc.c (parse_insn_tilegx): Likewise.
* tilepro-opc.c (parse_insn_tilepro): Likewise.
* visium-dis.c (disassem_class0): Likewise.
* pdp11-dis.c (sign_extend): Likewise.
(SIGN_BITS): Delete.
* epiphany-ibld.c: Regenerate.
* lm32-ibld.c: Regenerate.
* m32c-ibld.c: Regenerate.
Alan Modra [Wed, 11 Dec 2019 03:02:25 +0000 (13:32 +1030)]
bfd signed overflow fixes
Aimed at quietening ubsan.
include/
* opcode/mmix.h (PUSHGO_INSN_BYTE): Make unsigned.
(GO_INSN_BYTE, SETL_INSN_BYTE, INCML_INSN_BYTE, INCMH_INSN_BYTE),
(INCH_INSN_BYTE, SWYM_INSN_BYTE, JMP_INSN_BYTE): Likewise.
bfd/
* elf32-rx.c (elf32_rx_relax_section): Avoid signed overflow.
* libaout.h (N_SET_INFO, N_SET_FLAGS): Likewise.
* netbsd.h (write_object_contents): Likewise.
* elf32-arm.c (bfd_elf32_arm_vfp11_erratum_scan): Likewise.
* libhppa.h (HPPA_R_CONSTANT): Don't signed extend with shifts.
(stm32l4xx_create_replacing_stub_vldm): Don't truncate high bits
with shifts.
* elf32-nds32.h (R_NDS32_RELAX_ENTRY_DISABLE_RELAX_FLAG): Define
using 1u shifted left. Ditto for other macros.
* mmo.c (LOP): Make unsigned.
Alan Modra [Wed, 11 Dec 2019 10:36:17 +0000 (21:06 +1030)]
Make bfd_get_8 return a bfd_vma like other bfd_get_* functions
And similarly for bfd_get_signed_8.
bfd/
* libbfd.c (bfd_get_8): Return a bfd_vma.
(bfd_get_signed_8): Return a bfd_signed_vma.
* bfd-in2.h: Regenerate.
binutils/
* od-xcoff.c (dump_dumpx_core): Adjust for bfd_h_get_8 change.
Jan Beulich [Wed, 11 Dec 2019 08:42:29 +0000 (09:42 +0100)]
x86: further refine SSE check (SSE4a, SHA, GFNI)
In ("x86: extend SSE check to PCLMULQDQ, AES, and GFNI insns") I went
both a little too far and not quite far enough:
- GFNI insns also have AVX512 variants, which also shouldn't get
diagnosed,
- SSE4a insns should get diagnosed just like SSE4.x ones,
- SHA insns should get diagnosed just like PCLMULQDQ or AES ones.
Philippe Waroquiers [Wed, 7 Aug 2019 18:50:54 +0000 (20:50 +0200)]
Implement 'print -raw-values' and 'set print raw-values on|off'
The option framework documentation was speaking about a 'print -raw'
option, but this option does not exist.
This patch implements -raw-values option that tells to ignore the
active pretty printers when printing a value.
As we already have -raw-frame-arguments, I thought -raw-values
was more clear, in particular to differentiate
set print raw-values and set print raw-frame-arguments.
gdb/doc/ChangeLog
2019-12-11 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.texinfo (Command Options): Use -p and -pretty in the example,
as -r is ambiguous. Update the print - TAB TAB completion result.
(Data): Document new option -raw-values. Use -p and -pretty in the
example, as -r is ambiguous.
(Print Settings): Document set print raw values.
(Pretty-Printer Commands): Document interaction between enabled
pretty printers and -raw-values/-raw-frame-arguments.
gdb/ChangeLog
2019-12-11 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* NEWS: Document -raw-values option and the related setting commands.
* printcmd.c (print_command_parse_format): Do not set opts->raw off,
only set it on when /r is given.
* valprint.c (value_print_option_defs): New element raw-values.
* Makefile.in: Add the new file.
gdb/testsuite/ChangeLog
2019-12-11 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.base/options.exp: Add -raw-values in the print completion list.
* gdb.python/py-prettyprint.exp: Add tests for -raw-values.
Alan Modra [Wed, 11 Dec 2019 02:41:07 +0000 (13:11 +1030)]
Re: ubsan: ns32k: left shift cannot be represented in type
* ns32k-dis.c (sign_extend): Correct last patch.
Alan Modra [Tue, 10 Dec 2019 22:27:45 +0000 (08:57 +1030)]
ubsan: vax: left shift cannot be represented in type 'int'
* vax-dis.c (NEXTLONG): Avoid signed overflow.
Alan Modra [Tue, 10 Dec 2019 22:23:50 +0000 (08:53 +1030)]
ubsan: v850: left shift cannot be represented in type 'long'
* v850-dis.c (get_operand_value): Use unsigned arithmetic. Don't
sign extend using shifts.
Alan Modra [Tue, 10 Dec 2019 22:22:22 +0000 (08:52 +1030)]
ubsan: tic6x: shift left of int
* tic6x-dis.c (tic6x_extract_32): Avoid signed overflow.
Alan Modra [Tue, 10 Dec 2019 22:17:35 +0000 (08:47 +1030)]
ubsan: tic4x: segv and signed shifts
* tic4x-dis.c (tic4x_print_register): Formatting. Don't segfault
on NULL registertable entry.
(tic4x_hash_opcode): Use unsigned arithmetic.
Alan Modra [Tue, 10 Dec 2019 22:07:53 +0000 (08:37 +1030)]
ubsan: s12z: left shift cannot be represented in type 'int'
* s12z-opc.c (z_decode_signed_value): Avoid signed overflow.
Alan Modra [Tue, 10 Dec 2019 22:04:57 +0000 (08:34 +1030)]
ubsan: ns32k: left shift cannot be represented in type 'int'
* ns32k-dis.c (bit_extract): Use unsigned arithmetic.
(bit_extract_simple, sign_extend): Likewise.
Alan Modra [Tue, 10 Dec 2019 22:02:18 +0000 (08:32 +1030)]
ubsan: nios2: left shift cannot be represented in type 'int'
* nios2-dis.c (nios2_print_insn_arg): Use 1u << 31.
Alan Modra [Tue, 10 Dec 2019 21:56:58 +0000 (08:26 +1030)]
ubsan: moxie: left shift of negative value
* moxie-dis.c (INST2OFFSET): Don't sign extend using shifts.
Alan Modra [Tue, 10 Dec 2019 21:53:33 +0000 (08:23 +1030)]
ubsan: m68k: left shift cannot be represented in type 'int'
* m68k-dis.c (COERCE32): Cast value first.
(NEXTLONG, NEXTULONG): Avoid signed overflow.
Alan Modra [Tue, 10 Dec 2019 13:23:57 +0000 (23:53 +1030)]
ubsan: h8300: left shift cannot be represented in type 'int'
This is
*cst = (data[0] << 24) + (data[1] << 16) + (data[2] << 8) + data[3];
data is unsigned char which promotes to int.
* h8300-dis.c (extract_immediate): Avoid signed overflow.
(bfd_h8_disassemble): Likewise.
Alan Modra [Tue, 10 Dec 2019 13:20:02 +0000 (23:50 +1030)]
ussan: d30v: index out of bounds
* d30v-dis.c (print_insn): Make opind unsigned. Don't access
past end of operands array.
Alan Modra [Tue, 10 Dec 2019 13:07:03 +0000 (23:37 +1030)]
ubsan: csky: left shift cannot be represented in type 'int'
In the following buf is an unsigned char array, so elements are
promoted to int before arithmetic operations.
if (dis_info.info->endian == BFD_ENDIAN_BIG)
while (n--)
val |= buf[n] << (n*8);
else
for (i = 0; i < n; i++)
val |= buf[i] << (i*8);
* csky-dis.c (csky_chars_to_number): Rewrite. Avoid signed
overflow when collecting bytes of a number.
Alan Modra [Tue, 10 Dec 2019 12:52:10 +0000 (23:22 +1030)]
ubsan: cris: signed integer overflow
This was the following in print_with_operands
case 4:
number
= buffer[2] + buffer[3] * 256 + buffer[4] * 65536
+ buffer[5] * 0x1000000;
and buffer[5] * 0x1000000 can indeed overflow. So to fix this we need
to use unsigned arithmetic where overflow semantics are specified.
But number is a long, and the expression is int which will be sign
extended to long. If we make the expression unsigned it will be zero
extended. So make number an int32_t and rearrange a little for some
of the places that need fixing.
* cris-dis.c (print_with_operands): Avoid signed integer
overflow when collecting bytes of a 32-bit integer.
Alan Modra [Tue, 10 Dec 2019 12:32:37 +0000 (23:02 +1030)]
ubsan: cr16: left shift cannot be represented in type 'int'
This was:
unsigned long mask = SBM (instruction->match_bits);
with
#define SBM(offs) ((((1 << (32 - offs)) -1) << (offs)))
Well, there are a couple of problems. Firstly, the expression uses
int values (1 rather than 1u or 1ul) resulting in the ubsan error, and
secondly, a zero offs will result in a 32-bit shift which is undefined
if ints are only 32 bits.
* cr16-dis.c (EXTRACT, SBM): Rewrite.
(cr16_match_opcode): Delete duplicate bcond test.
Alan Modra [Tue, 10 Dec 2019 12:02:06 +0000 (22:32 +1030)]
ubsan: bfin: shift exponent is too large
This was the following in fmtconst_val, x is unsigned int.
x = SIGNEXTEND (x, constant_formats[cf].nbits);
Problem is, the SIGNEXTEND macro assumed its arg was a long and sign
extended by shifting left then shifting right, and didn't cast the
arg. So don't do the silly shift thing. It's not guaranteed to work
anyway according to the C standard. ">>" might do a logical shift
even if its args are signed.
* bfin-dis.c (HOST_LONG_WORD_SIZE, XFIELD): Delete.
(SIGNBIT): New.
(MASKBITS, SIGNEXTEND): Rewrite.
(fmtconst): Don't use ? expression now that SIGNEXTEND uses
unsigned arithmetic, instead assign result of SIGNEXTEND back
to x.
(fmtconst_val): Use 1u in shift expression.
Alan Modra [Tue, 10 Dec 2019 08:39:47 +0000 (19:09 +1030)]
ubsan: arc: shift exponent 32 is too large for 32-bit type 'int'
When operand->bits is 32, the following results in UB.
value = (insn >> operand->shift) & ((1 << operand->bits) - 1);
* arc-dis.c (find_format_from_table): Use ull constant when
shifting by up to 32.
Alan Modra [Tue, 10 Dec 2019 08:34:37 +0000 (19:04 +1030)]
aarch64 disassembler infinite loop
Assembling this to an object and trying to disassemble results in
objdump -d looping forever.
.inst 0x45205120
PR 25270
* aarch64-dis.c (aarch64_decode_variant_using_iclass): Return
false when field is zero for sve_size_tsz_bhs.
Alan Modra [Tue, 10 Dec 2019 08:28:38 +0000 (18:58 +1030)]
ubsan: left shift of cannot be represented in type 'int'
* dis-asm.h (INSN_HAS_RELOC, DISASSEMBLE_DATA),
(USER_SPECIFIED_MACHINE_TYPE, WIDE_OUTPUT): Make unsigned.
* opcode/tic80.h (TIC80_OPERAND_*): Likewise.
Alan Modra [Tue, 10 Dec 2019 07:42:28 +0000 (18:12 +1030)]
ubsan: xtensa: left shift cannot be represented in type 'int'
In Operand_soffsetx4_decode:
soffsetx4_0 = 0x4 + ((((int) offset_0 << 14) >> 14) << 2);
and other places.
Don't sign extend with shifts! This file also has many occurrences of
truncation via shifts, which aren't a problem due to using uint32, but
I dislike on principle enough to fix.
* xtensa-modules.c (Field_* functions): Don't mask using shifts.
(Operand_soffsetx4_decode, Operand_simm4_decode),
(Operand_simm8_decode, Operand_simm8x256_decode),
(Operand_simm12b_decode, Operand_label8_decode),
(Operand_label12_decode, Operand_soffset_decode),
(Operand_xt_wbr15_label_decode, Operand_xt_wbr18_label_decode): Don't
sign extend using shifts.
(Operand_immrx4_decode, Operand_uimm16x4_decode): Avoid UB in
constant.
Alan Modra [Tue, 10 Dec 2019 07:36:09 +0000 (18:06 +1030)]
ubsan: epiphany: left shift of negative value
Two places in epiphany_cgen_extract_operand, "value" is a long.
value = ((((value) << (1))) + (pc));
cpu/
* epiphany.cpu (f-simm8, f-simm24): Use multiply rather than
shift left to avoid UB on left shift of negative values.
opcodes/
* epiphany-ibld.c: Regenerate.
Alan Modra [Tue, 10 Dec 2019 07:27:14 +0000 (17:57 +1030)]
ubsan: ia64: left shift of negative value
Here, since val is signed:
*valuep = (val << scale);
* cpu-ia64-opc.c (ext_imms_scaled): Avoid undefined left shift
of negative values by using unsigned vars.
GDB Administrator [Wed, 11 Dec 2019 00:00:25 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Wed, 20 Nov 2019 23:07:46 +0000 (16:07 -0700)]
Minor fix to gdb.prompt documentation
I noticed that an example in the gdb.prompt documentation used the
wrong kind of quotes -- because it is code, it should use a plain
ASCII quotation mark. I also slightly shortened the sample text here,
so it would more clearly fit on a single line.
gdb/doc/ChangeLog
2019-12-10 Tom Tromey <tom@tromey.com>
* python.texi (gdb.prompt): Use correct quotes in example.
Shorten sample text.
Change-Id: I4153928c0d88001244ad410f3943c952a6ebfeb1
Kevin Buettner [Wed, 20 Sep 2017 22:40:14 +0000 (15:40 -0700)]
OpenMP parallel region scope tests
Add tests which check for accessibility of variables from within
various OpenMP parallel regions.
Tested on Fedora 27, 28, 29, 30, and 31. I also tested with my OpenMP
work on Fedora 30. The test has been annotated with setup_xfail and
setup_kfail statements so that there are no unexpected failures on any
of these platforms when using gcc. Better still, for my own testing
anyway, is that there are also no XPASSes or KPASSes either. So,
regardless of platform, when using gcc, and regardless of whether my
(not yet public) OpenMP work is used, seeing a FAIL indicates a real
problem.
Fedora 27 results:
# of expected passes 85
# of expected failures 65
(Note: I have not retested F27 since v1 of the patch; it's possible
that the numbers will be slightly different for v2.)
Fedora 28, 29, 30 results:
# of expected passes 131
# of expected failures 4
# of known failures 16
Fedora 30, 31 results w/ my OpenMP work:
# of expected passes 151
The above results all use gcc, either the system gcc or a development
gcc (when testing against my OpenMP work in GDB). I've also tested
with clang 9.0.0 and icc 19.0.5.281
20190815 on Fedora 31.
Fedora 31, clang:
FAIL: gdb.threads/omp-par-scope.exp: single_scope: first thread: print s1
FAIL: gdb.threads/omp-par-scope.exp: single_scope: first thread: print s3
FAIL: gdb.threads/omp-par-scope.exp: single_scope: first thread: print i1
FAIL: gdb.threads/omp-par-scope.exp: single_scope: first thread: print i3
FAIL: gdb.threads/omp-par-scope.exp: single_scope: second thread: print s1
FAIL: gdb.threads/omp-par-scope.exp: single_scope: second thread: print s3
FAIL: gdb.threads/omp-par-scope.exp: single_scope: second thread: print i1
FAIL: gdb.threads/omp-par-scope.exp: multi_scope: first thread: print i02
FAIL: gdb.threads/omp-par-scope.exp: multi_scope: first thread: print i11
FAIL: gdb.threads/omp-par-scope.exp: multi_scope: first thread: print i12
FAIL: gdb.threads/omp-par-scope.exp: multi_scope: first thread: print i22
FAIL: gdb.threads/omp-par-scope.exp: multi_scope: first thread: print file_scope_var
FAIL: gdb.threads/omp-par-scope.exp: multi_scope: second thread: print i11
FAIL: gdb.threads/omp-par-scope.exp: multi_scope: second thread: print file_scope_var
FAIL: gdb.threads/omp-par-scope.exp: multi_scope: after parallel: print file_scope_var
FAIL: gdb.threads/omp-par-scope.exp: nested_parallel: inner_threads: 1st stop: print file_scope_var
FAIL: gdb.threads/omp-par-scope.exp: nested_parallel: inner_threads: 1st stop: print num
FAIL: gdb.threads/omp-par-scope.exp: nested_parallel: inner_threads: 1st stop: print l
FAIL: gdb.threads/omp-par-scope.exp: nested_parallel: inner_threads: 1st stop: print k
FAIL: gdb.threads/omp-par-scope.exp: nested_parallel: inner_threads: 2nd stop: print file_scope_var
FAIL: gdb.threads/omp-par-scope.exp: nested_parallel: inner_threads: 2nd stop: print num
FAIL: gdb.threads/omp-par-scope.exp: nested_parallel: inner_threads: 3rd stop: print file_scope_var
FAIL: gdb.threads/omp-par-scope.exp: nested_parallel: inner_threads: 3rd stop: print num
FAIL: gdb.threads/omp-par-scope.exp: nested_parallel: inner_threads: 3rd stop: print l
FAIL: gdb.threads/omp-par-scope.exp: nested_parallel: inner_threads: 3rd stop: print k
FAIL: gdb.threads/omp-par-scope.exp: nested_parallel: inner_threads: 4th stop: print file_scope_var
FAIL: gdb.threads/omp-par-scope.exp: nested_parallel: inner_threads: 4th stop: print num
FAIL: gdb.threads/omp-par-scope.exp: nested_parallel: outer_threads: outer stop: print file_scope_var
FAIL: gdb.threads/omp-par-scope.exp: nested_parallel: outer_threads: outer stop: print i
FAIL: gdb.threads/omp-par-scope.exp: nested_parallel: outer_threads: outer stop: print j
Fedora 31, icc:
FAIL: gdb.threads/omp-par-scope.exp: multi_scope: first thread: print i12
FAIL: gdb.threads/omp-par-scope.exp: multi_scope: first thread: print i22
FAIL: gdb.threads/omp-par-scope.exp: nested_func: 1st call: 1st thread: print s1
FAIL: gdb.threads/omp-par-scope.exp: nested_func: 1st call: 1st thread: print i
FAIL: gdb.threads/omp-par-scope.exp: nested_func: 1st call: 1st thread: print j
FAIL: gdb.threads/omp-par-scope.exp: nested_func: 1st call: 2nd thread: print s1
FAIL: gdb.threads/omp-par-scope.exp: nested_func: 1st call: 2nd thread: print i
FAIL: gdb.threads/omp-par-scope.exp: nested_func: 1st call: 2nd thread: print j
FAIL: gdb.threads/omp-par-scope.exp: nested_func: 1st call: 2nd thread: print k
FAIL: gdb.threads/omp-par-scope.exp: nested_func: 1st call: 2nd thread: print z
FAIL: gdb.threads/omp-par-scope.exp: nested_func: 2nd call: 1st thread: print s1
FAIL: gdb.threads/omp-par-scope.exp: nested_func: 2nd call: 1st thread: print i
FAIL: gdb.threads/omp-par-scope.exp: nested_func: 2nd call: 1st thread: print j
FAIL: gdb.threads/omp-par-scope.exp: nested_func: 2nd call: 2nd thread: print s1
FAIL: gdb.threads/omp-par-scope.exp: nested_func: 2nd call: 2nd thread: print i
FAIL: gdb.threads/omp-par-scope.exp: nested_func: 2nd call: 2nd thread: print j
FAIL: gdb.threads/omp-par-scope.exp: nested_func: 2nd call: 2nd thread: print k
FAIL: gdb.threads/omp-par-scope.exp: nested_func: 2nd call: 2nd thread: print z
FAIL: gdb.threads/omp-par-scope.exp: nested_parallel: inner_threads: 1st stop: print l
FAIL: gdb.threads/omp-par-scope.exp: nested_parallel: inner_threads: 1st stop: print k
FAIL: gdb.threads/omp-par-scope.exp: nested_parallel: inner_threads: 3rd stop: print l
FAIL: gdb.threads/omp-par-scope.exp: nested_parallel: inner_threads: 3rd stop: print k
For both clang and icc, it turns out that there are some problems with
the DWARF that these compilers generate. Of the two, icc does at
least nest the subprogram of the outlined function representing the
parallel region within the function that it's defined, but does not
handle inner scopes if they exist. clang places the subprogram for
the outlined function at the same level as the containing function, so
variables declared within the function aren't visible at all.
I could call setup_xfail to avoid FAILs for clang and icc also, but I don't
want to further complicate the test.
gdb/testsuite/ChangeLog:
* gdb.threads/omp-par-scope.c: New file.
* gdb/threads/omp-par-scope.exp: New file.
Change-Id: Icb9c991730d84ca7509380af817dfcc778e764ea
Kevin Buettner [Sat, 9 Nov 2019 18:09:41 +0000 (11:09 -0700)]
Add gdb_caching_proc support_nested_function_tests to lib/gdb.exp
This commit adds the gdb_caching_proc, support_nested_function_tests,
to lib/gdb.exp. It tests to see whether or not the C compiler has
support for nested function calls.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (support_nested_function_tests): New proc.
Change-Id: Ic2c93bc4cc200e07e104a2398f89a9c0514bdc75
Kevin Buettner [Thu, 22 Aug 2019 02:32:12 +0000 (19:32 -0700)]
Add gdb_compile_openmp to lib/gdb.exp
gdb/testsuite/ChangeLog:
* lib/gdb.exp (gdb_compile_openmp): New proc.
(build_executable_from_specs): Add an "openmp" option.
(gdb_compile_pthreads): Add non-executable case.
Change-Id: I94048b8b0940c707ce0529a6bcfa6e4eace49101
Christian Biesinger [Tue, 10 Dec 2019 19:42:40 +0000 (13:42 -0600)]
Suppress the "unused function" warning for select_strerror_r
We only ever use one of the two overloads, so to avoid breaking -Werror
builds, supress the warning.
gdb/ChangeLog:
2019-12-10 Christian Biesinger <cbiesinger@google.com>
* gdbsupport/safe-strerror.c: Supress the unused function warning
for select_strerror_r.
Change-Id: I344869a382bb36fe181b5b2a31838d1d20f58169
Christian Biesinger [Wed, 6 Nov 2019 19:57:52 +0000 (13:57 -0600)]
Replace the remaining uses of strerror with safe_strerror
To do that, this patch makes IPA compile safe-strerror as well. Because
it doesn't use Gnulib, it calls the Glibc version of strerror_r directly.
Consequently this patch also removes the configure checks for strerror.
gdb/ChangeLog:
2019-12-10 Christian Biesinger <cbiesinger@google.com>
* config.in: Regenerate.
* configure: Regenerate.
* gdbsupport/agent.c (gdb_connect_sync_socket): Call
safe_strerror instead of strerror.
* gdbsupport/common.m4: Don't check for strerror.
* gdbsupport/safe-strerror.c: Support both the glibc version
of strerror_r and the XSI version.
gdb/gdbserver/ChangeLog:
2019-12-10 Christian Biesinger <cbiesinger@google.com>
* Makefile.in: Add safe-strerror.c to gdbreplay and IPA, and change
UNDO_GNULIB_CFLAGS to undo strerror_r instead of strerror.
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac: Don't check for strerror.
* linux-i386-ipa.c (initialize_fast_tracepoint_trampoline_buffer):
Call safe_strerror instead of strerror.
* server.h (strerror): Remove this now-unnecessary declaration.
* tracepoint.c (init_named_socket): Call safe_strerror instead of
strerror.
(gdb_agent_helper_thread): Likewise.
* utils.c (perror_with_name): Likewise.
Change-Id: I74848f072dcde75cb55c435ef9398dc8f958cd73
Andre Vieira [Tue, 10 Dec 2019 16:10:17 +0000 (16:10 +0000)]
[gas][arm] Set context table for '.arch_extension'
This patch fixes .arch_extension behaviour.
Currently, context table for '.arch_extension' is only set while
"-march" processing, but it is not set while .arch processing,
so following code is rejected
.syntax unified
.thumb
.arch armv8.1-m.main
.arch_extension mve.fp
unless -march=armv8.1-m.main is given.
Committing on behalf of Vladimir Murzin
gas/ChangeLog:
2019-12-10 Vladimir Murzin <vladimir.murzin@arm.com>
* config/tc-arm.c (s_arm_arch): Set selected_ctx_ext_table.
* testsuite/gas/arm/mve-arch-ext.s: New.
* testsuite/gas/arm/mve-arch-ext.d: New.
Tom Tromey [Tue, 3 Dec 2019 20:31:21 +0000 (13:31 -0700)]
Normalize Ada ptype to use a single "?"
Sometimes -- notably with unchecked unions -- the Ada "ptype" code
will print a "?" or "??" to indicate something unknown. The choice of
what was printed was somewhat arbitrary, and in one case, Ada would
print an empty string rather than "?".
This patch normalizes the Ada code to use "?" rather than an empty
string or "??". My reasoning here is that a single question mark is
enough to convey unknown-ness.
gdb/ChangeLog
2019-12-10 Tom Tromey <tromey@adacore.com>
* ada-typeprint.c (print_choices): Use a single "?".
(print_variant_part): Print "?" if the discriminant name
is not known.
gdb/testsuite/ChangeLog
2019-12-10 Tom Tromey <tromey@adacore.com>
* gdb.ada/unchecked_union.exp: New file.
* gdb.ada/unchecked_union/pck.adb: New file.
* gdb.ada/unchecked_union/pck.ads: New file.
* gdb.ada/unchecked_union/unchecked_union.adb: New file.
* gdb-utils.exp (string_to_regexp): Also quote "?".
Change-Id: I3403040780a155ffa2c44c8e6a04ba86bc810e29
GDB Administrator [Tue, 10 Dec 2019 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Mon, 9 Dec 2019 10:04:49 +0000 (20:34 +1030)]
PR24960, Memory leak from disassembler
PR 24960
include/
* dis-asm.h (disassemble_free_target): Declare.
opcodes/
* disassemble.c (disassemble_free_target): New function.
binutils/
* objdump.c (disassemble_data): Call disassemble_free_target.
Alan Modra [Mon, 9 Dec 2019 12:16:26 +0000 (22:46 +1030)]
Use disassemble_info.private_data in place of insn_sets
No cgen target uses private_data. This patch removes a
disassemble_info field that is only used by cgen, and instead uses
private_data. It also removes a macro that is no longer used.
include/
* dis-asm.h (struct disassemble_info): Delete insn_sets.
(INIT_DISASSEMBLE_INFO_NO_ARCH): Don't define.
opcodes/
* cgen-dis.in (print_insn_@arch@): Replace insn_sets with private_data.
* disassemble.c (disassemble_init_for_target): Likewise.
* bpf-dis.c: Regenerate.
* epiphany-dis.c: Regenerate.
* fr30-dis.c: Regenerate.
* frv-dis.c: Regenerate.
* ip2k-dis.c: Regenerate.
* iq2000-dis.c: Regenerate.
* lm32-dis.c: Regenerate.
* m32c-dis.c: Regenerate.
* m32r-dis.c: Regenerate.
* mep-dis.c: Regenerate.
* mt-dis.c: Regenerate.
* or1k-dis.c: Regenerate.
* xc16x-dis.c: Regenerate.
* xstormy16-dis.c: Regenerate.
Alan Modra [Mon, 9 Dec 2019 12:27:15 +0000 (22:57 +1030)]
Remove backup ppc struct dis_private.
ppc-dis.c used a global struct whenever malloc failed to provide the
eight bytes of memory necessary for struct dis_private. Which is
quite ridiculous. If that malloc failed there is zero chance some
other malloc won't fail too.
* ppc-dis.c (private): Delete variable.
(get_powerpc_dialect): Don't segfault on NULL info->private_data.
(powerpc_init_dialect): Don't use global private.
Alan Modra [Mon, 9 Dec 2019 10:17:04 +0000 (20:47 +1030)]
Delete duplicate struct objdump_disasm_info field
objdump_disasm_info.sec duplicates disassemble_info.section
* objdump.c (struct objdump_disasm_info): Delete "sec".
(find_symbol_for_address): Use inf->section rather than aux->sec.
(objdump_print_addr, disassemble_bytes): Likewise.
(disassemble_section): Don't set aux->sec.
Alan Modra [Sat, 7 Dec 2019 05:34:33 +0000 (16:04 +1030)]
s12z-opc.c formatting fixes
Wrap overlong lines, whitespace fixes, and for function definitions
start a line with the name of the function.
* s12z-opc.c: Formatting.
George Barrett [Mon, 9 Dec 2019 21:28:39 +0000 (08:28 +1100)]
Fix scripted probe breakpoints
The documentation for make-breakpoint from the Guile API and the `spec'
variant of the gdb.Breakpoint constructor from the Python API state that
the format acceptable for location strings is the same as that accepted
by the break command. However, using the -probe qualifier at the
beginning of the location string causes a GDB internal error as it
attempts to decode a probe location in the wrong code path. Without this
functionality, there doesn't appear to be another way to set breakpoints
on probe points from Python or Guile scripts.
This patch introduces a new helper function that returns a
breakpoint_ops instance appropriate for a parsed location and updates
the Guile and Python bindings to use said function, rather than the
current hard-coded use of bkpt_breakpoint_ops. Since this logic is
duplicated in the handling of the `break' and `trace' commands, those
are also updated to call into the new helper function.
gdb/ChangeLog:
2019-12-10 George Barrett <bob@bob131.so>
Fix scripted probe breakpoints.
* breakpoint.c (tracepoint_probe_breakpoint_ops): Move
declaration forward.
(breakpoint_ops_for_event_location_type)
(breakpoint_ops_for_event_location): Add function definitions.
(break_command_1, trace_command): Use
breakpoint_ops_for_event_location.
* breakpoint.h (breakpoint_ops_for_event_location): Add function
declarations.
* guile/scm-breakpoint.c (gdbscm_register_breakpoint_x): Use
breakpoint_ops_for_event_location.
* python/py-breakpoint.c (bppy_init): Use
breakpoint_ops_for_event_location.
gdb/testsuite/ChangeLog:
2019-12-10 George Barrett <bob@bob131.so>
Test scripted probe breakpoints.
* gdb.guile/scm-breakpoint.c (main): Add probe point.
* gdb.python/py-breakpoint.c (main): Likewise.
* gdb.guile/scm-breakpoint.exp (test_bkpt_probe): Add probe
specifier test.
* gdb.python/py-breakpoint.exp (test_bkpt_probe): Likewise.
Tankut Baris Aktemur [Mon, 9 Dec 2019 16:07:47 +0000 (17:07 +0100)]
gdb: rank an lvalue argument incompatible for an rvalue parameter
Passing an lvalue argument to a function that takes an rvalue parameter
is not allowed per C++ rules. Consider this function:
int g (int &&x) { return x; }
Calling g as in
int i = 5;
int j = g (i);
is illegal. For instance, GCC 9.2.1 yields
~~~
test.cpp: In function ‘int main()’:
test.cpp:6:14: error: cannot bind rvalue reference of type ‘int&&’ to
lvalue of type ‘int’
6 | int j = g (i);
| ^
~~~
GDB currently allows this function call:
~~~
(gdb) print g(i)
$1 = 5
~~~
Fix this by ranking an lvalue argument incompatible with an rvalue
parameter. The behavior after this patch is:
~~~
(gdb) print g(i)
Cannot resolve function g to any overloaded instance
~~~
Tested with GCC 9.2.1.
gdb/ChangeLog:
2019-12-09 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdbtypes.c (rank_one_type): Return INCOMPATIBLE_TYPE_BADNESS
when ranking an lvalue argument for an rvalue parameter.
gdb/testsuite/ChangeLog:
2019-12-09 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.cp/rvalue-ref-overload.cc (g): New function that takes
an rvalue parameter.
* gdb.cp/rvalue-ref-overload.exp: Test calling it with an lvalue
parameter.
Change-Id: I4a6dfc7dac63efa1e3b9f8f391e4b736fbdccdc1
Andrew Burgess [Tue, 3 Dec 2019 20:41:27 +0000 (20:41 +0000)]
gdb/fortran: Improve output pattern in gdb.mi/mi-fortran-modules.exp
Extend the output pattern in mi-fortran-modules.exp to skip some
system modules that appear with versions of GFortran after 7.x.x.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-fortran-modules.exp: Add patterns to skip system
modules.
Change-Id: I64aaa395e554a32e8267ffa096faee53c19c0b9e
Andrew Burgess [Tue, 3 Dec 2019 19:15:06 +0000 (19:15 +0000)]
gdb/testsuite: kfail some tests if using broken gcc
In some cases the Fortran stride information generated by GCC is wrong
with versions of GCC after 7.x.x. This commit adds kfails for the
tests in question with known bad versions of gcc.
The bug has been reported to GCC here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92775
gdb/testsuite/ChangeLog:
* gdb.fortran/derived-type-striding.exp: KFAIL if we are using a
broken version of GCC.
Change-Id: Iaef08e5e2c87ab3d6983b88f749d40e01aea2bc6
Andrew Burgess [Tue, 3 Dec 2019 13:18:43 +0000 (13:18 +0000)]
gdb/testsuite/fortran: Fix info-modules/info-types for gfortran 8+
The gdb.fortran/info-modules.exp and gdb.fortran/info-types.exp tests
are failing on versions of gfortran after 7.3 due to the inclusion of
extra "system" modules and type that were not being matched by the
current test patterns.
Rather than building increasingly complex patterns that would always
be at risk of breaking with future versions of GCC I have instead
added a new library that parses the output of the following commands:
info types
info variables
info functions
info modules
info module functions
info module variables
into a data structure, the test can than run checks against the
contents of this data structure.
The benefit is that we can simply ignore extra results that we don't
care about.
There is a small risk that a bug in GDB might allow us to start
reporting incorrect results in such a way that the new library will
not spot the error. However, I have tried to mitigate this risk by
adding extra procedures into the test library (see check_no_entry) and
we can add more in future if we wanted to be even more defensive.
I tested this test file with gFortran 7.3.1, 8.3.0, and 9.2.0, I now
see 100% pass in all cases.
gdb/testsuite/ChangeLog:
* gdb.fortran/info-modules.exp: Rewrite to make use of new
sym-info-cmds library.
* gdb.fortran/info-types.exp: Likewise.
* lib/sym-info-cmds.exp: New file.
Change-Id: Iff81624f51b5afb6c95393932f3d94472d7c2970
Wataru Ashihara [Sun, 8 Dec 2019 08:00:43 +0000 (17:00 +0900)]
gdb/darwin-nat.c: Fix template argument for scoped_restore_tmpl
This should be the type of startup_with_shell, whose type was changed
from int to bool at commit
80fd28264.
This fixes the build on macOS:
CXX darwin-nat.o
In file included from ../../gdb/darwin-nat.c:22:
In file included from ../../gdb/top.h:25:
In file included from ../../gdb/value.h:23:
In file included from ../../gdb/frame.h:72:
In file included from ../../gdb/language.h:26:
In file included from ../../gdb/symtab.h:33:
../../gdb/gdbsupport/gdb_optional.h:155:19: error: no matching constructor for initialization of 'scoped_restore_tmpl<int>'
new (&m_item) T (std::forward<Args>(args)...);
^ ~~~~~~~~~~~~~~~~~~~~~~~~
../../gdb/darwin-nat.c:1995:31: note: in instantiation of function template specialization 'gdb::optional<scoped_restore_tmpl<int> >::emplace<bool *, int>' requested here
restore_startup_with_shell.emplace (&startup_with_shell, 0);
^
../../gdb/gdbsupport/scoped_restore.h:69:3: note: candidate constructor template not viable: no known conversion from 'bool *' to 'int *' for 1st argument
scoped_restore_tmpl (T *var, T2 value)
^
../../gdb/gdbsupport/scoped_restore.h:57:3: note: candidate constructor not viable: requires single argument 'var', but 2 arguments were provided
scoped_restore_tmpl (T *var)
^
../../gdb/gdbsupport/scoped_restore.h:76:3: note: candidate constructor not viable: requires single argument 'other', but 2 arguments were provided
scoped_restore_tmpl (const scoped_restore_tmpl<T> &other)
^
1 error generated.
gdb/ChangeLog
2019-12-08 Wataru Ashihara <wataash@wataash.com>
* darwin-nat.c (darwin_nat_target::create_inferior): Fix
template argument for scoped_restore_tmpl from bool to int.
Change-Id: Ia0202efd34dbce69b6af5d035fa55ed89215138a
Jan Beulich [Mon, 9 Dec 2019 12:32:11 +0000 (13:32 +0100)]
x86/Intel: fold "xmmword" with "oword"
These are full aliases of one another, so there's no real need to use
distinct O_md* values for them.
Jan Beulich [Mon, 9 Dec 2019 12:31:39 +0000 (13:31 +0100)]
x86/Intel: support "mmword ptr"
This is an alias of "qword ptr", commonly used with MMX insns.
At this occasion also test (alongside the newly supported "mmword")
- "zmmword" used as expression,
- PADDB with "oword ptr" (aliasing "xmmword ptr").
Jan Beulich [Mon, 9 Dec 2019 12:31:07 +0000 (13:31 +0100)]
x86/Intel: fix "near ptr" / "far ptr" handling
Commit
dc2be329b950 ("i386: Only check suffix in instruction mnemonic")
broke rejecting of these for floating point insns. Fix this by setting
the "byte" operand attribute, which will now (again) cause an error.
Furthermore the diagnostic for the "far ptr" case in general and for the
"near ptr" case in the non-float cases became "invalid instruction
suffix" instead of the intended "operand size mismatch". Fix this by
also setting the "tbyte" operand attribute (no insn template accepts
both byte and tbyte operands).
Jan Beulich [Mon, 9 Dec 2019 12:29:44 +0000 (13:29 +0100)]
x86/Intel: drop pointless suffix setting for "tbyte ptr"
There are extremely few insns accepting "tbyte ptr" operand, so the
"tbyte" operand flag checking done by match_operand_size() is already
sufficient; the setting of the suffix has become meaningless anyway
with
dc2be329b950 ("i386: Only check suffix in instruction mnemonic").
Fold the code with that setting the "byte" operand flag to force an
error (no insn at all accepts both "byte ptr" and tbyte ptr" operands,
except for AnySize ones where the two (conflicting) recorded types
don't matter (operand_size_match() doesn't call match_operand_size() in
this case).
Jan Beulich [Mon, 9 Dec 2019 12:29:14 +0000 (13:29 +0100)]
x86/Intel: drop pointless suffix setting for "fword ptr"
No floating point insn accepts an "fword ptr" operand, so the "fword"
operand flag checking done by match_mem_size() is already sufficient;
the setting of the suffix has become meaningless anyway with
dc2be329b950 ("i386: Only check suffix in instruction mnemonic").
Jan Beulich [Mon, 9 Dec 2019 12:28:43 +0000 (13:28 +0100)]
x86/Intel: drop pointless special casing of LxS
LDS et al don't accept "word ptr" operands anyway, as per their insn
templates. Hence there's no need to special case this here; the check
has become dysfunctional anyway by
dc2be329b950 ("i386: Only check
suffix in instruction mnemonic").
GDB Administrator [Mon, 9 Dec 2019 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Sat, 7 Dec 2019 00:55:52 +0000 (11:25 +1030)]
S12Z disassembler memory leak
* s12z-opc.c (exg_sex_discrim): Don't leak memory on invalid
registers.
Alan Modra [Sat, 7 Dec 2019 12:01:43 +0000 (22:31 +1030)]
aarch64*-*-*ilp32 gas tests
The new pac_negate_ra_state test adds yet another failure on aarch64
ipl32 targets. This patch fixes that particular problem and a few
more that are trivial to fix.
* testsuite/gas/aarch64/bfloat16.d: Match 32-bit and 64-bit output.
* testsuite/gas/aarch64/dgh.d: Likewise.
* testsuite/gas/aarch64/f32mm.d: Likewise.
* testsuite/gas/aarch64/f64mm.d: Likewise.
* testsuite/gas/aarch64/i8mm.d: Likewise.
* testsuite/gas/aarch64/pac_ab_key.d: Likewise.
* testsuite/gas/aarch64/pac_negate_ra_state.d: Likewise.
* testsuite/gas/aarch64/reloc-prel_g0.d: Likewise.
* testsuite/gas/aarch64/reloc-prel_g0_nc.d: Likewise.
* testsuite/gas/aarch64/reloc-prel_g1.d: Likewise.
* testsuite/gas/aarch64/sve-bfloat-movprfx.d: Likewise.
* testsuite/gas/aarch64/sve-movprfx-mm.d: Likewise.
* testsuite/gas/aarch64/sve2.d: Likewise.
Alan Modra [Sat, 7 Dec 2019 12:02:52 +0000 (22:32 +1030)]
Optional matching for run_dump_test
This adds an alternative to using #... in dump files, useful where we
only want to allow specific extra output. DW_CFA_nop in CIEs and FDEs
to pad out to required alignment (larger for 64-bit than 32-bit) is
an example where these optional match patterns are useful.
binutils/
* testsuite/lib/binutils-common.exp (regexp_diff): Support #?REGEXP.
ld/
* testsuite/ld-elf/eh4.d: Match optional padding DW_CFA_nop in FDEs.
* testsuite/ld-elf/eh5.d: Likewise, and extra CIEs emitted on
embedded targets.
Tom de Vries [Sun, 8 Dec 2019 10:25:28 +0000 (11:25 +0100)]
Fix inter-CU references using intra-CU form in imported-unit
When running the gdb testsuite with the cc-with-dwz board, I run into:
...
Running gdb/testsuite/gdb.dwarf2/imported-unit.exp ...
gdb compile failed, dwz: gdb.dwarf2/imported-unit/imported-unit: \
Couldn't find DIE referenced by DW_AT_abstract_origin
cc-with-tweaks.sh: dwz did not modify gdb.dwarf2/imported-unit/imported-unit.
...
The problem is that the DW_AT_abstract_origin reference here:
...
<0><d2>: Abbrev Number: 2 (DW_TAG_compile_unit)
<1><e6>: Abbrev Number: 4 (DW_TAG_subprogram)
<e7> DW_AT_abstract_origin: <0x142>
<eb> DW_AT_low_pc : 0x4004b2
<f3> DW_AT_high_pc : 0x4004c8
...
referring to a DIE in another compilation unit here:
...
<0><129>: Abbrev Number: 2 (DW_TAG_compile_unit)
<1><142>: Abbrev Number: 4 (DW_TAG_subprogram)
<143> DW_AT_name : main
<148> DW_AT_type : <0x13b>
<14c> DW_AT_external : 1
...
is encoded using intra-CU reference form DW_FORM_ref4 instead of intra-CU
reference DW_FORM_ref_addr:
...
4 DW_TAG_subprogram [has children]
DW_AT_abstract_origin DW_FORM_ref4
DW_AT_low_pc DW_FORM_addr
DW_AT_high_pc DW_FORM_addr
DW_AT value: 0 DW_FORM value: 0
...
Fix this in the DWARF assembler by making all inter-CU references use the '%'
label prefix.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2019-12-08 Tom de Vries <tdevries@suse.de>
* gdb.dwarf2/imported-unit.exp: Fix inter-CU references.
Change-Id: I690ff18c3943705ed478453531b176ff74700f3c
GDB Administrator [Sun, 8 Dec 2019 00:01:12 +0000 (00:01 +0000)]
Automatic date update in version.in