platform/upstream/binutils.git
6 years agoAarch64: Float register detection for _push_dummy_call
Alan Hayward [Wed, 29 Aug 2018 10:40:05 +0000 (11:40 +0100)]
Aarch64: Float register detection for _push_dummy_call

Use aapcs_is_vfp_call_or_return_candidate to detect float register
args, then pass in registers if there is room.

gdb/
* aarch64-tdep.c
(aapcs_is_vfp_call_or_return_candidate): Make static
(pass_in_v_or_stack): Remove function.
(pass_in_v_vfp_candidate): New function.
(aarch64_push_dummy_call): Check for float register candidates.

6 years agoAarch64: Func to detect args passed in float regs
Alan Hayward [Wed, 29 Aug 2018 10:28:10 +0000 (11:28 +0100)]
Aarch64: Func to detect args passed in float regs

aapcs_is_vfp_call_or_return_candidate is as an eventual replacement
for is_hfa_or_hva.

This function is based on the GCC code
gcc/config/aarch64/aarch64.c:aarch64_vfp_is_call_or_return_candidate ()

gdb/
* aarch64-tdep.c (HA_MAX_NUM_FLDS): New macro.
(aapcs_is_vfp_call_or_return_candidate_1): New function.
(aapcs_is_vfp_call_or_return_candidate): Likewise.

6 years ago[MIPS/LD/testsuite] Skip o32 flags check on mips*-*-irix*
Chenghua Xu [Wed, 29 Aug 2018 09:12:44 +0000 (17:12 +0800)]
[MIPS/LD/testsuite] Skip o32 flags check on mips*-*-irix*

ld/ChangeLog:

* testsuite/ld-mips-elf/mips-elf-flags.exp (good_combination):
Skip o32 flags checking if target is mips*-*-irix*.

6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 29 Aug 2018 00:00:38 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoGet rid of -Wodr warning (PR build/23399)
Simon Marchi [Tue, 28 Aug 2018 17:29:32 +0000 (13:29 -0400)]
Get rid of -Wodr warning (PR build/23399)

The PR reports that building with -Wodr -flto complains about different
versions of struct ipa_sym_addresses, in common/agent.c and
gdbserver/tracepoint.c.  This patch renames the version in common to
ipa_sym_addresses_common to avoid the name clash.  Because the IPA_SYM
assumed the name ipa_sym_addresses, it now requires the includer to
define the IPA_SYM_STRUCT_NAME macro to define the name of the structure
holding the IPA symbol addresses.

gdb/ChangeLog:

PR build/23399
* common/agent.c (IPA_SYM_STRUCT_NAME): Define.
(struct ipa_sym_addresses): Rename to...
(struct ipa_sym_addresses_common): ... this.
* common/agent.h (IPA_SYM): Use IPA_SYM_STRUCT_NAME.

gdb/gdbserver/ChangeLog:

PR build/23399
* tracepoint.c (IPA_SYM_STRUCT_NAME): Define.

6 years agoModify gdb.base/commands.exp to test multi breakpoints command clearing.
Philippe Waroquiers [Thu, 2 Aug 2018 21:15:23 +0000 (23:15 +0200)]
Modify gdb.base/commands.exp to test multi breakpoints command clearing.

gdb/testsuite/ChangeLog
2018-08-26  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* gdb.base/commands.exp: Test multi breakpoints command clearing.

6 years agoFix regression for multi breakpoints command line clearing.
Philippe Waroquiers [Thu, 2 Aug 2018 21:13:22 +0000 (23:13 +0200)]
Fix regression for multi breakpoints command line clearing.

breakpoint.c is modified to fix the regression introduced
when clearing the commands of several breakpoints by giving an empty
list of commands, by just typing "end".
GDB should read an empty list of command once, but it reads
it for each breakpoint, as an empty list of command is NULL,
and NULL is interpreted as 'not having read the command list yet'.

The fix consists in having a boolean set to true once the
command list has been read.

gdb/ChangeLog

2018-08-26  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* breakpoint.c (commands_command_1): New boolean cmd_read
to detect cmd was already read.

6 years agoRemove some uses of VEC from parsers
Tom Tromey [Sun, 22 Jul 2018 16:05:14 +0000 (10:05 -0600)]
Remove some uses of VEC from parsers

This changes some uses of VEC in a few parsers to std::vector instead.

Tested by the buildbot.

gdb/ChangeLog
2018-08-28  Tom Tromey  <tom@tromey.com>

* c-exp.y (struct token_and_value): Remove typedef and DEF_VEC.
(token_fifo): Now a std::vector.
(yylex, c_parse): Update.
* d-exp.y (struct token_and_value): Remove typedef and DEF_VEC.
(token_fifo): Now a std::vector.
(yylex, d_parse): Update.
* go-exp.y (struct token_and_value): Remove typedef and DEF_VEC.
(token_fifo): Now a std::vector.
(yylex, go_parse): Update.

6 years agoImplement struct type_stack with a vector
Simon Marchi [Tue, 28 Aug 2018 15:13:26 +0000 (11:13 -0400)]
Implement struct type_stack with a vector

This patch changes the home-made stack implementation with a vector,
which makes it a bit more concise and readable.

Regtested on the buildbot.

gdb/ChangeLog:

* parser-defs.h (struct type_stack) <elements>: Change type to
std::vector<union type_stack_elt>.
<depth, size>: Remove.
* parse.c (parse_exp_in_context_1): Adjust.
(type_stack_reserve): Remove.
(check_type_stack_depth): Remove.
(insert_into_type_stack): Adjust to std::vector.
(insert_type): Likewise.
(push_type): Likewise.
(push_type_int): Likewise.
(insert_type_address_space): Likewise.
(pop_type): Likewise.
(pop_type_int): Likewise.
(pop_typelist): Likewise.
(pop_type_stack): Likewise.
(append_type_stack): Likewise.
(push_type_stack): Likewise.
(get_type_stack): Likewise.
(type_stack_cleanup): Likewise.
(push_typelist): Likewise.
(follow_types): Likewise.
(_initialize_parse): Likewise.

6 years agoMention csky target in the NEWS.
Hafiz Abid Qadeer [Wed, 25 Jul 2018 09:45:26 +0000 (10:45 +0100)]
Mention csky target in the NEWS.

2018-08-28  Hafiz Abid Qadeer  <abidh@codesourcery.com>

* NEWS: Mention csky target.

6 years agoAdd support for new target 'csky'.
Hafiz Abid Qadeer [Wed, 25 Jul 2018 09:43:22 +0000 (10:43 +0100)]
Add support for new target 'csky'.

2018-08-28  Jiangshuai Li  <jiangshuai_li@c-sky.com>
    Hafiz Abid Qadeer  <abidh@codesourcery.com>
    Don Breazeal  <donb@codesourcery.com>

* csky-linux-tdep.c: New file.
* csky-tdep.c: Likewise.
* csky-tdep.h: Likewise.
* Makefile.in (ALL_TARGET_OBS): Add csky-linux-tdep.o and
csky-tdep.o.
(HFILES_NO_SRCDIR): Add csky-tdep.h.
(ALLDEPFILES): Add csky-linux-tdep.c and csky-tdep.c
* configure.tgt: Add csky support.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 28 Aug 2018 00:00:33 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agox86: Don't mask out the GNU_PROPERTY_X86_UINT32_VALID bit
H.J. Lu [Mon, 27 Aug 2018 22:41:09 +0000 (15:41 -0700)]
x86: Don't mask out the GNU_PROPERTY_X86_UINT32_VALID bit

Since only the GNU_PROPERTY_X86_UINT32_VALID bit may be set in data-only
relocatable objects which don't contain any instructions, linker
shouldn't mask out the GNU_PROPERTY_X86_UINT32_VALID bit when merging
GNU_PROPERTY_X86_XXX bits.  Otherwise, linker output doesn't contain
GNU_PROPERTY_X86_XXX property with any data-only relocatable inputs.
This patch keeps the GNU_PROPERTY_X86_UINT32_VALID bit and updates
readelf to print "<None>" if GNU_PROPERTY_X86_XXX property only has
the GNU_PROPERTY_X86_UINT32_VALID bit.

bfd/

* elfxx-x86.c (_bfd_x86_elf_parse_gnu_properties): Don't mask
out the GNU_PROPERTY_X86_UINT32_VALID bit.

binutils/

* readelf.c (decode_x86_isa): Print <None> if bitmask only
contains the GNU_PROPERTY_X86_UINT32_VALID bit.
(decode_x86_feature_1): Likewise.
(decode_x86_feature_2): Likewise.
(print_gnu_property_note): Don't mask out the
GNU_PROPERTY_X86_UINT32_VALID bit.
* testsuite/binutils-all/i386/pr21231b.d: Updated.
* testsuite/binutils-all/x86-64/pr21231b.d: Likewise.

gas/

* testsuite/gas/i386/i386.exp: Run property-1 and
x86-64-property-1.
* testsuite/gas/i386/property-1.d: New file.
* testsuite/gas/i386/property-1.s: Likewise.
* testsuite/gas/i386/x86-64-property-1.d: Likewise.

ld/

* testsuite/ld-i386/i386.exp: Run property-x86-5.
* testsuite/ld-i386/property-x86-5.d: New file.
* testsuite/ld-x86-64/property-x86-5-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-5.d: Likewise.
* testsuite/ld-x86-64/property-x86-5a.s: Likewise.
* testsuite/ld-x86-64/property-x86-5b.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run property-x86-5 and
property-x86-5-x32.

6 years agoMI: Fix printing of frame architecture with Python frame filters enabled
Jan Vrany [Mon, 27 Aug 2018 20:52:44 +0000 (21:52 +0100)]
MI: Fix printing of frame architecture with Python frame filters enabled

Commit 6d52907e226a (MI: Print frame architecture when printing frames
on an MI channel) added frame's architecture to MI frame output. However
the frame architecture was not correctly printed in the output of
"-stack-list-frames" with frame filters enabled (via "-enable-frame-filters").
This was because with frame filters enabled, the actual frame printing is
done in "py_print_frame" rather than "print_frame". This issue is now fixed.

gdb/Changelog:
2018-08-27  Jan Vrany  <jan.vrany@fit.cvut.cz>

* python/py-framefilter.c (py_print_frame): Print frame architecture
when printing on an MI output.

gdb/testsuite/Changelog:
2018-08-27  Jan Vrany  <jan.vrany@fit.cvut.cz>

* gdb.python/py-framefilter-mi.exp: Update regexp to
check for "arch" field in frame output.

6 years agoreadelf.c: Break multi-statement line
H.J. Lu [Mon, 27 Aug 2018 20:01:08 +0000 (13:01 -0700)]
readelf.c: Break multi-statement line

* readelf.c (decode_x86_compat_isa): Break multi-statement line.
(decode_x86_isa): Likewise.
(decode_x86_feature_2): Likewise.

6 years agoRemove -Wno-narrowing from warnings.m4
Tom Tromey [Tue, 7 Aug 2018 19:14:09 +0000 (13:14 -0600)]
Remove -Wno-narrowing from warnings.m4

This removes -Wno-narrowing from warnings.m4.
This is PR build/23087.

gdb/ChangeLog
2018-08-27  Tom Tromey  <tom@tromey.com>

PR build/23087:
* configure: Rebuild.
* warning.m4 (AM_GDB_WARNINGS): Remove -Wno-narrowing.

gdb/gdbserver/ChangeLog
2018-08-27  Tom Tromey  <tom@tromey.com>

PR build/23087:
* configure: Rebuild.

6 years agoAvoid -Wnarrowing warnings in aarch64-linux-tdep.c
Tom Tromey [Mon, 27 Aug 2018 17:55:39 +0000 (11:55 -0600)]
Avoid -Wnarrowing warnings in aarch64-linux-tdep.c

This avoids -Wnarrowing warnings in
aarch64_linux_iterate_over_regset_sections, by adding some casts to
int.

gdb/ChangeLog
2018-08-27  Tom Tromey  <tom@tromey.com>

* aarch64-linux-tdep.c
(aarch64_linux_iterate_over_regset_sections) <sve_regmap>: Add
casts to int.

6 years agoAvoid -Wnarrowing warnings in gdbserver
Tom Tromey [Tue, 7 Aug 2018 22:33:46 +0000 (16:33 -0600)]
Avoid -Wnarrowing warnings in gdbserver

This avoids -Wnarrowing warnings in gdbserver, by introducing some
casts to unsigned char.

gdb/gdbserver/ChangeLog
2018-08-27  Tom Tromey  <tom@tromey.com>

* linux-s390-low.c (s390_emit_ext, s390_emit_litpool)
(s390_emit_const, s390_emit_reg, s390_emit_zero_ext)
(s390_emit_stack_adjust, s390_emit_set_r2, s390x_emit_ext)
(s390x_emit_const, s390x_emit_reg, s390x_emit_zero_ext)
(s390x_emit_stack_adjust): Add casts to unsigned char.

6 years agoAvoid -Wnarrowing warnings in ppc64-tdep.c
Tom Tromey [Tue, 7 Aug 2018 19:13:58 +0000 (13:13 -0600)]
Avoid -Wnarrowing warnings in ppc64-tdep.c

This avoids -Wnarrowing warnings in ppc64-tdep.c, by adding a few
casts to unsigned.

gdb/ChangeLog
2018-08-27  Tom Tromey  <tom@tromey.com>

* ppc64-tdep.c (insn_d, insn_ds, insn_xfx): Add casts to
unsigned.
(ppc64_standard_linkage1, ppc64_standard_linkage2)
(ppc64_standard_linkage3, ppc64_standard_linkage4)
(ppc64_standard_linkage5, ppc64_standard_linkage6)
(ppc64_standard_linkage7, ppc64_standard_linkage8): Add casts to
unsigned.

6 years agoFix two -Wnarrowing warnings in xtensa-tdep.h
Tom Tromey [Tue, 7 Aug 2018 19:07:21 +0000 (13:07 -0600)]
Fix two -Wnarrowing warnings in xtensa-tdep.h

This fixes a couple of -Wnarrowing warnings in xtensa-tdep.h, by
introducing some casts to unsigned.

gdb/ChangeLog
2018-08-27  Tom Tromey  <tom@tromey.com>

* xtensa-tdep.h (XTREG_END): Add cast to unsigned.
(XTENSA_GDBARCH_TDEP_INSTANTIATE): Likewise.

6 years agoAvoid -Wnarrowing warnings in struct tramp_frame instances
Tom Tromey [Tue, 7 Aug 2018 19:04:05 +0000 (13:04 -0600)]
Avoid -Wnarrowing warnings in struct tramp_frame instances

This avoids -Wnarrowing warnings in struct tramp_frame instances,
replacing uses of -1 with a new ULONGEST_MAX.  It also redefined
TRAMP_SENTINEL_INSN to avoid the same warning.

gdb/ChangeLog
2018-08-27  Tom Tromey  <tom@tromey.com>

* tramp-frame.h (TRAMP_SENTINEL_INSN): Redefine.
* tilegx-linux-tdep.c (tilegx_linux_rt_sigframe): Use
ULONGEST_MAX.
* tic6x-linux-tdep.c (tic6x_linux_rt_sigreturn_tramp_frame): Use
ULONGEST_MAX.
* sparc64-linux-tdep.c (sparc64_linux_rt_sigframe): Use
ULONGEST_MAX.
* sparc-linux-tdep.c (sparc32_linux_sigframe)
(sparc32_linux_rt_sigframe): Use ULONGEST_MAX.
* ppc-nbsd-tdep.c (ppcnbsd_sigtramp, ppcnbsd2_sigtramp): Use
ULONGEST_MAX.
* ppc-linux-tdep.c (ppc32_linux_sigaction_tramp_frame)
(ppc64_linux_sigaction_tramp_frame)
(ppc32_linux_sighandler_tramp_frame)
(ppc64_linux_sighandler_tramp_frame): Use ULONGEST_MAX.
* nios2-linux-tdep.c (nios2_r1_linux_rt_sigreturn_tramp_frame)
(nios2_r2_linux_rt_sigreturn_tramp_frame): Use ULONGEST_MAX.
* mn10300-linux-tdep.c (am33_linux_sigframe)
(am33_linux_rt_sigframe): Use ULONGEST_MAX.
* mips64-obsd-tdep.c (mips64obsd_sigframe): Use ULONGEST_MAX.
* mips-linux-tdep.c (mips_linux_o32_sigframe)
(mips_linux_o32_rt_sigframe, mips_linux_n32_rt_sigframe)
(mips_linux_n64_rt_sigframe, micromips_linux_o32_sigframe)
(micromips_linux_o32_rt_sigframe, micromips_linux_n32_rt_sigframe)
(micromips_linux_n64_rt_sigframe): Use ULONGEST_MAX.
* mips-fbsd-tdep.c (mips_fbsd_sigframe, mipsn32_fbsd_sigframe)
(mips64_fbsd_sigframe): Use ULONGEST_MAX.
* microblaze-linux-tdep.c
(microblaze_linux_sighandler_tramp_frame): Use ULONGEST_MAX.
* i386-nbsd-tdep.c (i386nbsd_sigtramp_sc16, i386nbsd_sigtramp_sc2)
(i386nbsd_sigtramp_si2, i386nbsd_sigtramp_si31)
(i386nbsd_sigtramp_si4): Use ULONGEST_MAX.
* hppa-nbsd-tdep.c (hppanbsd_sigtramp_si4): Use ULONGEST_MAX.
* common/common-types.h (ULONGEST_MAX): New define.
(CORE_ADDR_MAX): Fix formatting.
* bfin-linux-tdep.c (bfin_linux_sigframe): Use ULONGEST_MAX.
* arm-obsd-tdep.c (armobsd_sigframe): Use ULONGEST_MAX.
* arm-linux-tdep.c (arm_linux_sigreturn_tramp_frame)
(arm_linux_rt_sigreturn_tramp_frame)
(arm_eabi_linux_sigreturn_tramp_frame)
(arm_eabi_linux_rt_sigreturn_tramp_frame)
(thumb2_eabi_linux_sigreturn_tramp_frame)
(thumb2_eabi_linux_rt_sigreturn_tramp_frame)
(arm_linux_restart_syscall_tramp_frame)
(arm_kernel_linux_restart_syscall_tramp_frame): Use ULONGEST_MAX.
* arm-fbsd-tdep.c (arm_fbsd_sigframe): Use ULONGEST_MAX.
* aarch64-linux-tdep.c (aarch64_linux_rt_sigframe): Use
ULONGEST_MAX.
* aarch64-fbsd-tdep.c (aarch64_fbsd_sigframe): Use ULONGEST_MAX.

6 years agoUse CORE_ADDR_MAX in various "breaks" arrays
Tom Tromey [Tue, 7 Aug 2018 18:48:47 +0000 (12:48 -0600)]
Use CORE_ADDR_MAX in various "breaks" arrays

Code like this:

  CORE_ADDR breaks[2] = {-1, -1};

... gives a warning with -Wnarrowing.  This patch changes all
instances of this to use CORE_ADDR_MAX instead.

gdb/ChangeLog
2018-08-27  Tom Tromey  <tom@tromey.com>

* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Use
CORE_ADDR_MAX.
* mips-tdep.c (mips_deal_with_atomic_sequence)
(micromips_deal_with_atomic_sequence): Use CORE_ADDR_MAX.
* arch/arm-get-next-pcs.c (thumb_deal_with_atomic_sequence_raw)
(arm_deal_with_atomic_sequence_raw): Use CORE_ADDR_MAX.
* alpha-tdep.c (alpha_deal_with_atomic_sequence): Use
CORE_ADDR_MAX.
* aarch64-tdep.c (aarch64_software_single_step): Use
CORE_ADDR_MAX.

6 years agoAvoid -Wnarrowing warnings from quote_char()
Tom Tromey [Thu, 9 Aug 2018 18:38:39 +0000 (12:38 -0600)]
Avoid -Wnarrowing warnings from quote_char()

This adds a couple of casts to avoid -Wnarrowing warnings coming from
the use of quote_char().

gdb/ChangeLog
2018-08-27  Tom Tromey  <tom@tromey.com>

* linespec.c (complete_linespec_component): Add cast to "char".
* completer.c (completion_tracker::build_completion_result): Add
cast to "char".

6 years agoFix indentation in solist.h
Simon Marchi [Mon, 27 Aug 2018 00:05:48 +0000 (20:05 -0400)]
Fix indentation in solist.h

gdb/ChangeLog:

* solist.h (struct solist, struct target_so_ops): Fix
indentation.

6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 27 Aug 2018 00:01:39 +0000 (00:01 +0000)]
Automatic date update in version.in

6 years agoMake ada_tasks_inferior_data::task_list an std::vector
Simon Marchi [Sun, 26 Aug 2018 15:56:41 +0000 (11:56 -0400)]
Make ada_tasks_inferior_data::task_list an std::vector

This removes a VEC type.  It requires converting ada_tasks_inferior_data
to C++ (initializing fields, allocating with new).  It seems, however,
that the allocated ada_tasks_inferior_data structures are never freed
(that should be fixed separately).

gdb/ChangeLog:

* ada-tasks.c (ada_task_info_s): Remove typedef.
(DEF_VEC_O(ada_task_info_s)): Remove.
(struct ada_tasks_inferior_data): Initialize fields.
<task_list>: Make an std::vector.
(get_ada_tasks_inferior_data): Allocate with new.
(ada_get_task_number): Adjust.
(get_task_number_from_id): Likewise.
(valid_task_id): Likewise.
(ada_get_task_info_from_ptid): Likewise.
(iterate_over_live_ada_tasks): Likewise.
(add_ada_task): Likewise.
(read_known_tasks): Likewise.
(ada_build_task_list): Likewise.
(print_ada_task_info): Likewise.
(info_task): Likewise.
(task_command_1): Likewise.

6 years agoMake ada-lang.c::add_angle_brackets return an std::string
Simon Marchi [Sun, 26 Aug 2018 15:53:47 +0000 (11:53 -0400)]
Make ada-lang.c::add_angle_brackets return an std::string

This removes the need for manual memory management.  It may also be a
bit more efficient, since the returned string can be moved all the way
into the destination, in ada_lookup_name_info::matches.

gdb/ChangeLog:

* ada-lang.c (add_angle_brackets): Return std::string.

6 years agoDelay evaluation of alignment expressions in output sections
Alan Modra [Sun, 26 Aug 2018 04:53:38 +0000 (14:23 +0930)]
Delay evaluation of alignment expressions in output sections

git commit 702d16713 broke expressions using CONSTANT(COMMONPAGESIZE)
in ALIGN or SUBALIGN of output section statements, because these
optional fields were evaluated at script parse time and the patch in
question delayed setting of config.commonpagesize.  The right thing to
do is keep the tree representation of those fields for later
evaluation.

PR 23571
* ldlang.h (section_alignment): Make it an expression tree.
(subsection_alignment): Likewise.
* ldlang.c (topower): Delete.
(output_section_statement_newfunc): Adjust initialization.
(init_os): Evaluate section_alignment.
(lang_size_sections_1): Likewise.
(size_input_section): Evaluate subsection_alignment.
(lang_enter_output_section_statement): Don't evaluate here.
(lang_new_phdr): Use exp_get_vma rather than exp_get_value_int.
* ldexp.h (exp_get_value_int): Delete.
(exp_get_power): Declare.
* ldexp.c (exp_get_value_int): Delete.
(exp_get_power): New function.
* emultempl/pe.em (place_orphan): Build expression for section
alignment.
* emultempl/pep.em (place_orphan): Likewise.
* testsuite/ld-scripts/pr23571.d,
* testsuite/ld-scripts/pr23571.t: New test.
* testsuite/ld-scripts/align.exp: Run it.

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 26 Aug 2018 00:01:07 +0000 (00:01 +0000)]
Automatic date update in version.in

6 years agoInitialize variable in py_get_event_thread
Simon Marchi [Sat, 25 Aug 2018 15:52:24 +0000 (11:52 -0400)]
Initialize variable in py_get_event_thread

The pythread variable could be used without being initialized, fix it by
initializing it to nullptr.

gdb/ChangeLog:

* python/py-threadevent.c (py_get_event_thread): Initialize
pythread.

6 years agoelf: Check for corrupt symbol version info
H.J. Lu [Sat, 25 Aug 2018 13:17:52 +0000 (06:17 -0700)]
elf: Check for corrupt symbol version info

The BFD linker with PR ld/23499 may generate shared libraries with
corrupt symbol version info which leads to linker error when the
corrupt shared library is used:

/usr/bin/ld: bin/libKF5Service.so.5.49.0: _edata: invalid version 21 (max 0)
/usr/bin/ld: bin/libKF5Service.so.5.49.0: error adding symbols: bad value

Add check for corrupt symbol version info to objdump:

00000000000af005 g    D  .data 0000000000000000  <corrupt>   _edata

and readelf:

   728: 00000000000af005     0 NOTYPE  GLOBAL DEFAULT   25 _edata@<corrupt> (5)

bfd/

PR ld/23499
* elf.c (_bfd_elf_get_symbol_version_string): Return
_("<corrupt>") for corrupt symbol version info.

binutils/

PR ld/23499
* readelf.c (get_symbol_version_string): Return _("<corrupt>")
for corrupt symbol version info.

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 25 Aug 2018 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agogdb/python: Use copy-initialization more when possible
Pedro Alves [Fri, 24 Aug 2018 19:09:19 +0000 (20:09 +0100)]
gdb/python: Use copy-initialization more when possible

gdb/ChangeLog:
2018-08-24  Pedro Alves  <palves@redhat.com>

* python/py-bpevent.c (create_breakpoint_event_object): Use
copy-initialization.
* python/py-continueevent.c (emit_continue_event): Use
copy-initialization.
* python/py-exitedevent.c (create_exited_event_object): Return a
gdbpy_ref<>.
(emit_exited_event): Use copy-initialization.
* python/py-inferior.c (python_new_inferior)
(python_inferior_deleted, add_thread_object): Use
copy-initialization.
* python/py-infevents.c (create_inferior_call_event_object)
(create_register_changed_event_object)
(create_memory_changed_event_object): Return a gdbpy_ref<>.
(emit_inferior_call_event, emit_memory_changed_event)
(emit_register_changed_event): Use copy-initialization.
* python/py-newobjfileevent.c (create_new_objfile_event_object):
Return a gdbpy_ref<>.
(emit_new_objfile_event): Use copy-initialization.
(create_clear_objfiles_event_object): Return a gdbpy_ref<>.
(emit_clear_objfiles_event): Use copy-initialization.
* python/py-signalevent.c (create_signal_event_object): Use
copy-initialization.
* python/py-threadevent.c (create_thread_event_object): Use
copy-initialization.

6 years agoFix 8.2 regression in gdb.python/py-evthreads.exp w/ gdbserver (PR gdb/23379)
Pedro Alves [Fri, 24 Aug 2018 21:13:30 +0000 (22:13 +0100)]
Fix 8.2 regression in gdb.python/py-evthreads.exp w/ gdbserver (PR gdb/23379)

This commit fixes a 8.1->8.2 regression exposed by
gdb.python/py-evthreads.exp when testing with
--target_board=native-gdbserver.

gdb.log shows:

  src/gdb/thread.c:93: internal-error: thread_info* inferior_thread(): Assertion `tp' failed.
  A problem internal to GDB has been detected,
  further debugging may prove unreliable.
  Quit this debugging session? (y or n) FAIL: gdb.python/py-evthreads.exp: run to breakpoint 1 (GDB internal error)

A backtrace shows (frames #2 and #10 highlighted) that the assertion
fails when GDB is setting up the connection to the remote target, in
non-stop mode:

  #0  0x0000000000622ff0 in internal_error(char const*, int, char const*, ...) (file=0xc1ad98 "src/gdb/thread.c", line=93, fmt=0xc1ad20 "%s: Assertion `%s' failed.") at src/gdb/common/errors.c:54
  #1  0x000000000089567e in inferior_thread() () at src/gdb/thread.c:93
= #2  0x00000000004da91d in get_event_thread() () at src/gdb/python/py-threadevent.c:38
  #3  0x00000000004da9b7 in create_thread_event_object(_typeobject*, _object*) (py_type=0x11574c0 <continue_event_object_type>, thread=0x0)
      at src/gdb/python/py-threadevent.c:60
  #4  0x00000000004bf6fe in create_continue_event_object() () at src/gdb/python/py-continueevent.c:27
  #5  0x00000000004bf738 in emit_continue_event(ptid_t) (ptid=...) at src/gdb/python/py-continueevent.c:40
  #6  0x00000000004c7d47 in python_on_resume(ptid_t) (ptid=...) at src/gdb/python/py-inferior.c:108
  #7  0x0000000000485bfb in std::_Function_handler<void (ptid_t), void (*)(ptid_t)>::_M_invoke(std::_Any_data const&, ptid_t&&) (__functor=..., __args#0=...) at /usr/include/c++/7/bits/std_function.h:316
  #8  0x000000000089b416 in std::function<void (ptid_t)>::operator()(ptid_t) const (this=0x12aa600, __args#0=...)
      at /usr/include/c++/7/bits/std_function.h:706
  #9  0x000000000089aa0e in gdb::observers::observable<ptid_t>::notify(ptid_t) const (this=0x118a7a0 <gdb::observers::target_resumed>, args#0=...)
      at src/gdb/common/observable.h:106
= #10 0x0000000000896fbe in set_running(ptid_t, int) (ptid=..., running=1) at src/gdb/thread.c:880
  #11 0x00000000007f750f in remote_target::remote_add_thread(ptid_t, bool, bool) (this=0x12c5440, ptid=..., running=true, executing=true) at src/gdb/remote.c:2434
  #12 0x00000000007f779d in remote_target::remote_notice_new_inferior(ptid_t, int) (this=0x12c5440, currthread=..., executing=1)
      at src/gdb/remote.c:2515
  #13 0x00000000007f9c44 in remote_target::update_thread_list() (this=0x12c5440) at src/gdb/remote.c:3831
  #14 0x00000000007fb922 in remote_target::start_remote(int, int) (this=0x12c5440, from_tty=0, extended_p=0)
      at src/gdb/remote.c:4655
  #15 0x00000000007fd102 in remote_target::open_1(char const*, int, int) (name=0x1a4f45e "localhost:2346", from_tty=0, extended_p=0)
      at src/gdb/remote.c:5638
  #16 0x00000000007fbec1 in remote_target::open(char const*, int) (name=0x1a4f45e "localhost:2346", from_tty=0)
      at src/gdb/remote.c:4862

So on frame #10, we're marking a newly-discovered thread as running,
and that causes the Python API to emit a gdb.ContinueEvent.
gdb.ContinueEvent is a gdb.ThreadEvent, and as such includes the event
thread as the "inferior_thread" attribute.  The problem is that when
we get to frame #3/#4, we lost all references to the thread that is
being marked as running.  create_continue_event_object assumes that it
is the current thread, which is not true in this case.

Fix this by passing down the right thread in
create_continue_event_object.  Also remove
create_thread_event_object's default argument and have the only other
caller left pass down the right thread explicitly too.

gdb/ChangeLog:
2018-08-24  Pedro Alves  <palves@redhat.com>
    Simon Marchi  <simon.marchi@ericsson.com>

PR gdb/23379
* python/py-continueevent.c: Include "gdbthread.h".
(create_continue_event_object): Add intro comment.  Add 'ptid'
parameter.  Use it to find thread to pass to
create_thread_event_object.
(emit_continue_event): Pass PTID down to
create_continue_event_object.
* python/py-event.h (py_get_event_thread): Declare.
(create_thread_event_object): Remove default from 'thread'
parameter.
* python/py-stopevent.c (create_stop_event_object): Use
py_get_event_thread.
* python/py-threadevent.c (get_event_thread): Rename to ...
(py_get_event_thread): ... this, make extern, add 'ptid' parameter
and use it to find the thread.
(create_thread_event_object): Assert that THREAD isn't null.
Don't find the event thread here.

6 years ago[PATCH] [MIPS] LD/testsuite: Skip 32bit test if ld not support.
Chenghua Xu [Fri, 24 Aug 2018 13:25:15 +0000 (21:25 +0800)]
[PATCH] [MIPS] LD/testsuite: Skip 32bit test if ld not support.

ld/ChangeLog:

    * testsuite/ld-mips-elf/mips-elf-flags.exp
    (check_ld_support_32bit, check_is_32bit_args): New procedures.
    (good_combination, bad_combination): Skip 32bit test if ld
    not support 32bit emulations.

6 years agox86: Update GNU_PROPERTY_X86_XXX macros
H.J. Lu [Fri, 24 Aug 2018 11:41:50 +0000 (04:41 -0700)]
x86: Update GNU_PROPERTY_X86_XXX macros

This patch updates GNU_PROPERTY_X86_XXX macros:

1. GNU_PROPERTY_X86_UINT32_AND_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in all relocatable inputs:

 #define GNU_PROPERTY_X86_UINT32_AND_LO      0xc0000002
 #define GNU_PROPERTY_X86_UINT32_AND_HI      0xc0007fff

2. GNU_PROPERTY_X86_UINT32_OR_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in any relocatable inputs:

 #define GNU_PROPERTY_X86_UINT32_OR_LO    0xc0008000
 #define GNU_PROPERTY_X86_UINT32_OR_HI    0xc000ffff

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:

 #define GNU_PROPERTY_X86_UINT32_OR_AND_LO   0xc0010000
 #define GNU_PROPERTY_X86_UINT32_OR_AND_HI   0xc0017fff

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.

bfd/

* elfxx-x86.c (_bfd_x86_elf_parse_gnu_properties): Handle
X86_COMPAT_ISA_1_USED, X86_COMPAT_ISA_1_NEEDED,
X86_UINT32_AND_LO, X86_UINT32_AND_HI, X86_UINT32_OR_LO,
X86_UINT32_OR_HI, X86_UINT32_OR_AND_LO and X86_UINT32_OR_AND_HI
instead of X86_ISA_1_USED, X86_ISA_1_NEEDED and X86_FEATURE_1_AND.
(_bfd_x86_elf_merge_gnu_properties): Likewise.
(_bfd_x86_elf_link_setup_gnu_properties): Add X86_FEATURE_2_NEEDED
instead of X86_ISA_1_NEEDED.
(_bfd_x86_elf_link_fixup_gnu_properties): Handle
X86_COMPAT_ISA_1_USED, X86_COMPAT_ISA_1_NEEDED, X86_UINT32_AND_LO,
X86_UINT32_AND_HI, X86_UINT32_OR_LO, X86_UINT32_OR_HI,
X86_UINT32_OR_AND_LO and X86_UINT32_OR_AND_HI instead of
X86_ISA_1_USED, X86_ISA_1_NEEDED and X86_FEATURE_1_AND.

binutils/

* readelf.c (decode_x86_compat_isa): New function.
(decode_x86_feature_2): Likewise.
(decode_x86_isa): Updated for new X86_ISA_1_XXX bits.
(decode_x86_feature): Renamed to ...
(decode_x86_feature_1): This.  Remove the type argument.
(print_gnu_property_note): Handle X86_COMPAT_ISA_1_USED,
X86_COMPAT_ISA_1_NEEDED, X86_UINT32_AND_LO, X86_UINT32_AND_HI,
X86_UINT32_OR_LO, X86_UINT32_OR_HI, X86_UINT32_OR_AND_LO and
X86_UINT32_OR_AND_HI instead of X86_ISA_1_USED, X86_ISA_1_NEEDED
and X86_FEATURE_1_AND.
* testsuite/binutils-all/i386/pr21231b.s: Updated to the current
GNU_PROPERTY_X86_ISA_1_USED and GNU_PROPERTY_X86_ISA_1_NEEDED
values.
* testsuite/binutils-all/x86-64/pr21231b.s: Likewise.
* testsuite/binutils-all/x86-64/pr23494a.s: Likewise.
* testsuite/binutils-all/x86-64/pr23494b.s: Likewise.
* testsuite/binutils-all/x86-64/pr23494c.s: Likewise.
* testsuite/binutils-all/i386/pr21231b.d: Updated.
* testsuite/binutils-all/x86-64/pr21231b.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494a-x32.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494a.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494c-x32.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494c.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494d-x32.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494d.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494e-x32.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494e.d: Likewise.

include/

* elf/common.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_ISA_1_XXX): Renamed to ...
(GNU_PROPERTY_X86_COMPAT_ISA_1_XXX): 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_ISA_1_CMOV): Likewise.
(GNU_PROPERTY_X86_ISA_1_SSE): Likewise.
(GNU_PROPERTY_X86_ISA_1_SSE2): Likewise.
(GNU_PROPERTY_X86_ISA_1_SSE3): Likewise.
(GNU_PROPERTY_X86_ISA_1_SSSE3): Likewise.
(GNU_PROPERTY_X86_ISA_1_SSE4_1): Likewise.
(GNU_PROPERTY_X86_ISA_1_SSE4_2): Likewise.
(GNU_PROPERTY_X86_ISA_1_AVX): Likewise.
(GNU_PROPERTY_X86_ISA_1_AVX2): Likewise.
(GNU_PROPERTY_X86_ISA_1_FMA): Likewise.
(GNU_PROPERTY_X86_ISA_1_AVX512F): Likewise.
(GNU_PROPERTY_X86_ISA_1_AVX512CD): Likewise.
(GNU_PROPERTY_X86_ISA_1_AVX512ER): Likewise.
(GNU_PROPERTY_X86_ISA_1_AVX512PF): Likewise.
(GNU_PROPERTY_X86_ISA_1_AVX512VL): Likewise.
(GNU_PROPERTY_X86_ISA_1_AVX512DQ): Likewise.
(GNU_PROPERTY_X86_ISA_1_AVX512BW): Likewise.
(GNU_PROPERTY_X86_ISA_1_AVX512_4FMAPS): Likewise.
(GNU_PROPERTY_X86_ISA_1_AVX512_4VNNIW): Likewise.
(GNU_PROPERTY_X86_ISA_1_AVX512_BITALG): Likewise.
(GNU_PROPERTY_X86_ISA_1_AVX512_IFMA): Likewise.
(GNU_PROPERTY_X86_ISA_1_AVX512_VBMI): Likewise.
(GNU_PROPERTY_X86_ISA_1_AVX512_VBMI2): Likewise.
(GNU_PROPERTY_X86_ISA_1_AVX512_VNNI): Likewise.
(GNU_PROPERTY_X86_FEATURE_2_X86): Likewise.
(GNU_PROPERTY_X86_FEATURE_2_X87): Likewise.
(GNU_PROPERTY_X86_FEATURE_2_MMX): Likewise.
(GNU_PROPERTY_X86_FEATURE_2_XMM): Likewise.
(GNU_PROPERTY_X86_FEATURE_2_YMM): Likewise.
(GNU_PROPERTY_X86_FEATURE_2_ZMM): Likewise.
(GNU_PROPERTY_X86_FEATURE_2_FXSR): Likewise.
(GNU_PROPERTY_X86_FEATURE_2_XSAVE): Likewise.
(GNU_PROPERTY_X86_FEATURE_2_XSAVEOPT): Likewise.
(GNU_PROPERTY_X86_FEATURE_2_XSAVEC): Likewise.
(GNU_PROPERTY_X86_FEATURE_1_AND): Updated to
(GNU_PROPERTY_X86_UINT32_AND_LO + 0).
(GNU_PROPERTY_X86_ISA_1_NEEDED): Defined to
(GNU_PROPERTY_X86_UINT32_OR_LO + 0).
(GNU_PROPERTY_X86_FEATURE_2_NEEDED): New.  Defined to
(GNU_PROPERTY_X86_UINT32_OR_LO + 1).
(GNU_PROPERTY_X86_ISA_1_USED): Defined to
(GNU_PROPERTY_X86_UINT32_OR_AND_LO + 0).
(GNU_PROPERTY_X86_FEATURE_2_USED): New.  Defined to
(GNU_PROPERTY_X86_UINT32_OR_AND_LO + 1).

ld/

* testsuite/ld-i386/i386.exp: Run pr23372c, pr23372d, pr23486c
and pr23486d.
* testsuite/ld-i386/pr23372a.s: Update comments.
* testsuite/ld-i386/pr23372b.s: Likewise.
* testsuite/ld-i386/pr23372c.s: Likewise.
* testsuite/ld-x86-64/pr23372a.s: Likewise.
* testsuite/ld-x86-64/pr23372b.s: Likewise.
* testsuite/ld-x86-64/pr23372c.s: Likewise.
* testsuite/ld-x86-64/pr23486a.s: Likewise.
* testsuite/ld-x86-64/pr23486b.s: Likewise.
* testsuite/ld-i386/pr23372c.d: New file.
* testsuite/ld-i386/pr23372d.d: Likewise.
* testsuite/ld-i386/pr23486c.d: Likewise.
* testsuite/ld-i386/pr23486d.d: Likewise.
* testsuite/ld-x86-64/pr23372c-x32.d: Likewise.
* testsuite/ld-x86-64/pr23372c.d: Likewise.
* testsuite/ld-x86-64/pr23372d-x32.d: Likewise.
* testsuite/ld-x86-64/pr23372d.d: Likewise.
* testsuite/ld-x86-64/pr23372d.s: Likewise.
* testsuite/ld-x86-64/pr23372e.s: Likewise.
* testsuite/ld-x86-64/pr23372f.s: Likewise.
* testsuite/ld-x86-64/pr23486c-x32.d: Likewise.
* testsuite/ld-x86-64/pr23486c.d: Likewise.
* testsuite/ld-x86-64/pr23486c.s: Likewise.
* testsuite/ld-x86-64/pr23486d-x32.d: Likewise.
* testsuite/ld-x86-64/pr23486d.d: Likewise.
* testsuite/ld-x86-64/pr23486d.s: Likewise.
* testsuite/ld-i386/property-3.r: Updated.
* testsuite/ld-i386/property-4.r: Likewise.
* testsuite/ld-i386/property-5.r: Likewise.
* testsuite/ld-i386/property-x86-3.d: Likewise.
* testsuite/ld-i386/property-x86-ibt3a.d: Likewise.
* testsuite/ld-i386/property-x86-shstk3a.d: Likewise.
* testsuite/ld-i386/property-x86-shstk3b.d: Likewise.
* testsuite/ld-x86-64/property-3.r: Likewise.
* testsuite/ld-x86-64/property-4.r: Likewise.
* testsuite/ld-x86-64/property-5.r: Likewise.
* testsuite/ld-x86-64/property-x86-3-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-3.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise.
* testsuite/ld-i386/property-x86-1.S: Updated to the current
GNU_PROPERTY_X86_ISA_1_USED and GNU_PROPERTY_X86_ISA_1_NEEDED
values.
* testsuite/ld-i386/property-x86-2.S: Likewise.
* testsuite/ld-i386/property-x86-3.s: Likewise.
* testsuite/ld-x86-64/property-x86-1.S: Likewise.
* testsuite/ld-x86-64/property-x86-2.S: Likewise.
* testsuite/ld-x86-64/property-x86-3.s: Likewise.
* ld/testsuite/ld-x86-64/x86-64.exp: Run pr23372c, pr23372c-x32,
pr23372d, pr23372d-x32, pr23486c, pr23486c-x32, pr23486d and
pr23486d-x32.

6 years agox86: Add GNU_PROPERTY_X86_UINT32_VALID
H.J. Lu [Fri, 24 Aug 2018 11:37:45 +0000 (04:37 -0700)]
x86: Add GNU_PROPERTY_X86_UINT32_VALID

The older linker treats .note.gnu.property section as a generic note
and just concatenates all .note.gnu.property sections from the input
to the output.  On CET-enabled OS, the output of the older linker is
marked as CET enabled, but in fact, it is not CET enabled and it crashes
on CET-enabled machines.

This patch defines GNU_PROPERTY_X86_UINT32_VALID.  Linker is updated to
set the GNU_PROPERTY_X86_UINT32_VALID bit in GNU property note for
non-relocatable output to differentiate outputs from the older linker.

bfd/

* elfxx-x86.c (_bfd_x86_elf_parse_gnu_properties): Mask out the
GNU_PROPERTY_X86_UINT32_VALID bit.
(_bfd_x86_elf_link_fixup_gnu_properties): Set the
GNU_PROPERTY_X86_UINT32_VALID bit for non-relocatable output.

binutils/

* readelf.c (print_gnu_property_note): Check the
GNU_PROPERTY_X86_UINT32_VALID bit for invalid GNU property note.

include/

* elf/common.h (GNU_PROPERTY_X86_UINT32_VALID): New.

6 years agoehdr_start twiddles
Alan Modra [Fri, 24 Aug 2018 08:07:53 +0000 (17:37 +0930)]
ehdr_start twiddles

We force __ehdr_start to defined in before_allocation, then restore
the type and a union after dynamic symbols have been allocated.
The union contains a number of structs, all starting with a "next"
pointer, and various fields depending on the symbol type.  The old
code restored the entire union, but it isn't necessary to restore the
"next" pointer, and in fact it could be wrong if __ehdr_start happened
to be last on the list and some symbols were added before restoring.

* emultempl/elf32.em (before_allocation): Don't restore
__ehdr_start u.*.next pointer.

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 24 Aug 2018 00:00:37 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoTest case for functions with non-contiguous ranges
Kevin Buettner [Thu, 23 Aug 2018 23:00:50 +0000 (16:00 -0700)]
Test case for functions with non-contiguous ranges

See comments in the new files for what this is about - I tried to
explain it all there.

gdb/testsuite/ChangeLog:

* gdb.dwarf2/dw2-ranges-func.c: New file.
* gdb.dwarf2/dw2-ranges-func.exp: New file.

6 years agoRelocate block range start and end addresses
Kevin Buettner [Thu, 23 Aug 2018 23:00:50 +0000 (16:00 -0700)]
Relocate block range start and end addresses

gdb/ChangeLog:

* objfiles.c (objfile_relocate1): Relocate start and end addresses
for each range in a block.

6 years agoIntroduce find_function_entry_range_from_pc and use it in infrun.c
Kevin Buettner [Thu, 23 Aug 2018 23:00:49 +0000 (16:00 -0700)]
Introduce find_function_entry_range_from_pc and use it in infrun.c

An earlier version of this patch used the returned block in conjunction
with BLOCK_ENTRY_PC to set stop_func_start in fill_in_stop_func() in
infrun.c.  While I think this was the correct thing to do, changes
to find_inferior_partial_function could potentially end up with
stop_func_end < stop_func_start, which is definitely wrong.  For
this case, we want to set both stop_func_start and stop_func_end
to the start and end of the range containing the function's entry
pc.

I think that this functionality will be useful in many other places
too - it probably ought to be used in all of the various prologue
analyzers in GDB.

The change to infrun.c was simple: the call to
find_pc_partial_function was replaced with a call to
find_function_entry_range_from_pc.  The difference between these two
functions is that find_pc_partial_entry_function will (potentially)
return the start and end address corresponding to the range in which
PC is found, but find_function_entry_range_from_pc will (again,
potentially) return the start and end address of the range containing
the entry pc.  find_pc_partial_function has the property that
*ADDRESS <= PC < *ENDADDR.  This condition does not necessarily hold
for the outputs of find_function_entry_range_from_pc.

It should be noted that for functions which contain only a single
range, the outputs of find_pc_partial_function and
find_function_entry_range_from_pc are identical.

I think it might happen that find_function_entry_range_from_pc will come
to be used in place of many of the calls to find_pc_partial_function
within GDB.  Care must be taken in making this change, however, since
some of this code depends on the *ADDRESS <= PC < *ENDADDR property.

Finally, a note regarding the name: I had initially chosen a different
name with a find_pc_partial_ prefix, but Simon suggested the current
name citing the goal of eventually making naming consistent using
the form find_X_from_Y.  In this case X is "function_entry_range" and
Y is "pc".  Both the name and rationale made sense to me, so that's
how it came to be.

gdb/ChangeLog:

* infrun.c (fill_in_stop_func): Use find_function_entry_range_from_pc
in place of find_pc_partial_function.
* blockframe.c (find_function_entry_range_from_pc): New function.
* symtab.h (find_function_entry_range_from_pc): Declare and document.

6 years agoUse BLOCK_ENTRY_PC in place of most uses of BLOCK_START
Kevin Buettner [Thu, 23 Aug 2018 23:00:49 +0000 (16:00 -0700)]
Use BLOCK_ENTRY_PC in place of most uses of BLOCK_START

This change/patch substitues BLOCK_ENTRY_PC for BLOCK_START in
places where BLOCK_START is used to obtain the address at which
execution should enter the block.  Since blocks can now contain
non-contiguous ranges, the BLOCK_START - which is still be the
very lowest address in the block - might not be the same as
BLOCK_ENTRY_PC.

There is a change to infrun.c which is less obvious and less mechanical.
I'm posting it as a separate patch.

gdb/ChangeLog:

* ax-gdb.c (gen_var_ref): Use BLOCK_ENTRY_PC in place of
BLOCK_START.
* blockframe.c (get_pc_function_start): Likewise.
* compile/compile-c-symbols.c (convert_one_symbol): Likewise.
(gcc_symbol_address): Likewise.
* compile/compile-object-run.c (compile_object_run): Likewise.
* compile/compile.c (get_expr_block_and_pc): Likewise.
* dwarf2loc.c (dwarf2_find_location_expression): Likewise.
(func_addr_to_tail_call_list): Likewise.
* findvar.c (default_read_var_value): Likewise.
* inline-frame.c (inline_frame_this_id): Likewise.
(skip-inline_frames): Likewise.
* infcmd.c (until_next_command): Likewise.
* linespec.c (convert_linespec_to_sals): Likewise.
* parse.c (parse_exp_in_context_1): Likewise.
* printcmd.c (build_address_symbolic): likewise.
(info_address_command): Likewise.
symtab.c (find_function_start_sal): Likewise.
(skip_prologue_sal): Likewise.
(find_function_alias_target): Likewise.
(find_gnu_ifunc): Likewise.
* stack.c (find_frame_funname): Likewise.
* symtab.c (fixup_symbol_section): Likewise.
(find_function_start_sal): Likewise.
(skip_prologue_sal): Likewsie.
(find_function_alias_target): Likewise.
(find_gnu_ifunc): Likewise.
* tracepoint.c (info_scope_command): Likewise.
* value.c (value_fn_field): Likewise.

6 years agoDisassemble blocks with non-contiguous ranges
Kevin Buettner [Thu, 23 Aug 2018 23:00:49 +0000 (16:00 -0700)]
Disassemble blocks with non-contiguous ranges

This patch adds support for disassembly of blocks with non-contiguous
ranges.  These blocks are printed as follows:

(gdb) disassemble foo
Dump of assembler code for function foo:
Address range 0x401136 to 0x401151:
   0x0000000000401136 <+0>:     push   %rbp
   0x0000000000401137 <+1>:     mov    %rsp,%rbp
   0x000000000040113a <+4>:     callq  0x401134 <bar>
   0x000000000040113f <+9>:     mov    0x2eef(%rip),%eax        # 0x404034 <e>
   0x0000000000401145 <+15>:    test   %eax,%eax
   0x0000000000401147 <+17>:    je     0x40114e <foo+24>
   0x0000000000401149 <+19>:    callq  0x401128 <foo+4294967282>
   0x000000000040114e <+24>:    nop
   0x000000000040114f <+25>:    pop    %rbp
   0x0000000000401150 <+26>:    retq
Address range 0x401128 to 0x401134:
   0x0000000000401128 <+-14>:   push   %rbp
   0x0000000000401129 <+-13>:   mov    %rsp,%rbp
   0x000000000040112c <+-10>:   callq  0x401126 <baz>
   0x0000000000401131 <+-5>:    nop
   0x0000000000401132 <+-4>:    pop    %rbp
   0x0000000000401133 <+-3>:    retq
End of assembler dump.

This is an actual dump from the test case that I constructed for
this work.  The ranges are printed in the order encountered in the
debug info. For the above example, note that the second range occupies
lower addresses than the first range.

Functions with contiguous ranges are still printed as follows:

(gdb) disassemble main
Dump of assembler code for function main:
   0x0000000000401151 <+0>:     push   %rbp
   0x0000000000401152 <+1>:     mov    %rsp,%rbp
   0x0000000000401155 <+4>:     callq  0x401136 <foo>
   0x000000000040115a <+9>:     mov    $0x0,%eax
   0x000000000040115f <+14>:    pop    %rbp
   0x0000000000401160 <+15>:    retq
End of assembler dump.

gdb/ChangeLog:

* cli/cli-cmds.c (block.h): Include.
(print_disassembly): Handle printing of non-contiguous blocks.
(disassemble_current_function): Likewise.
(disassemble_command): Likewise.

6 years agoAdd support for non-contiguous blocks to find_pc_partial_function
Kevin Buettner [Thu, 23 Aug 2018 23:00:49 +0000 (16:00 -0700)]
Add support for non-contiguous blocks to find_pc_partial_function

This change adds an optional output parameter BLOCK to
find_pc_partial_function.  If BLOCK is non-null, then *BLOCK will be
set to the address of the block corresponding to the function symbol
if such a symbol was found during lookup.  Otherwise it's set to the
NULL value.  Callers may wish to use the block information to
determine whether the block contains any non-contiguous ranges.  The
caller may also iterate over or examine those ranges.

When I first started looking at the broken stepping behavior associated
with functions w/ non-contiguous ranges, I found that I could "fix"
the problem by disabling the find_pc_partial_function cache.  It would
sometimes happen that the PC passed in would be between the low and
high cache values, but would be in some other function that happens to
be placed in between the ranges for the cached function.  This caused
incorrect values to be returned.

So dealing with this cache turns out to be very important for fixing
this problem.  I explored three different ways of dealing with the
cache.

My first approach was to clear the cache when a block was encountered
with more than one range.  This would cause the non-cache pathway to
be executed on the next call to find_pc_partial_function.

Another approach, which I suspect is slightly faster, checks to see
whether the PC is within one of the ranges associated with the cached
block.  If so, then the cached values can be used.  It falls back to
the original behavior if there is no cached block.

The current approach, suggested by Simon Marchi, is to restrict the
low/high pc values recorded for the cache to the beginning and end of
the range containing the PC value under consideration.  This allows us
to retain the simple (and fast) test for determining whether the
memoized (cached) values apply to the PC passed to
find_pc_partial_function.

Another choice that had to be made regards setting *ADDRESS and
*ENDADDR.  There are three possibilities which might make sense:

1) *ADDRESS and *ENDADDR represent the lowest and highest address
   of the function.
2) *ADDRESS and *ENDADDR are set to the start and end address of
   the range containing the entry pc.
3) *ADDRESS and *ENDADDR are set to the start and end address of
   the range in which PC is found.

An earlier version of this patch implemented option #1.  I found out
that it's not very useful though and, in fact, returns results that
are incorrect when used in the context of determining the start and
end of the function for doing prologue analysis.  While debugging a
function in which the entry pc was in the second range (of a function
containing two non-contiguous ranges), I noticed that
amd64_skip_prologue called find_pc_partial_function - the returned
start address was set to the beginning of the first range.  This is
incorrect for this function.  What was also interesting was that this
first invocation of find_pc_partial_function correctly set the cache
for the PC on which it had been invoked, but a slightly later call
from skip_prologue_using_sal could not use this cached value because
it was now being used to lookup the very lowest address of the
function - which is in a range not containing the entry pc.

Option #2 is attractive as it would provide a desirable result
when used in the context of prologue analysis.  However, many callers,
including some which do prologue analysis want the condition
*ADDRESS <= PC < *ENDADDR to hold.  This will not be the case when
find_pc_partial_function is called on a PC that's in a non-entry-pc
range.  A later patch to this series adds
find_function_entry_range_from_pc as a wrapper of
find_pc_partial_function.

Option #3 causes the *ADDRESS <= PC < *ENDADDR property to hold.  If
find_pc_partial_function is called with a PC that's within entry pc's
range, then it will correctly return the limits of that range.  So, if
the result of a minsym search is passed to find_pc_partial_function
to find the limits, then correct results will be achieved.  Returned
limits (for prologue analysis) won't be correct when PC is within some
other (non-entry-pc) range.  I don't yet know how big of a problem
this might be; I'm guessing that it won't be a serious problem - if a
compiler generates functions which have non-contiguous ranges, then it
also probably generates DWARF2 CFI which makes a lot of the old
prologue analysis moot.

I've implemented option #3 for this version of the patch.  I don't see
any regressions for x86-64.  Moreover, I don't expect to see
regressions for other targets either simply because
find_pc_partial_function behaves the same as it did before for the
contiguous address range case.  That said, there may be some
adjustments needed if GDB encounters a function requiring prologue
analysis which occupies non-contiguous ranges.

gdb/ChangeLog:

* symtab.h (find_pc_partial_function): Add new parameter `block'.
* blockframe.c (cache_pc_function_block): New static global.
(clear_pc_function_cache): Clear cache_pc_function_block.
(find_pc_partial_function): Move comment to symtab.h.  Add
support for non-contiguous blocks.

6 years agoRecord explicit block ranges from dwarf2read.c
Kevin Buettner [Thu, 23 Aug 2018 23:00:49 +0000 (16:00 -0700)]
Record explicit block ranges from dwarf2read.c

This change sets BLOCK_RANGES for the block under consideration by
calling make_blockranges().  This action is performed in
dwarf2_record_block_ranges().

It should be noted that dwarf2_record_block_ranges() already does some
recording of the range via a call to record_block_range().  The ranges
recorded in that fashion end up in the address map associated with the
blockvector for the compilation unit's symtab.  Given an address, the
addrmap provides a fast way of finding the block containing that
address.  The address map does not, however, provide a convenient way
of determining which address ranges make up a particular block.

While reading a set of ranges, a vector of pairs is used to collect
the starting and ending addresses for each range in the block.  Once
all of the ranges for a block have been collected, make_blockranges()
is called to fill in BLOCK_RANGES for the block.

The ranges are stored for the block in the order that they're read
from the debug info.  For DWARF, the starting address of the first
range of the block will be the entry pc in cases where DW_AT_entry_pc
is not present.  (Well, that would ideally be the case.  At the moment
DW_AT_entry_pc is not being handled.)

gdb/ChangeLog:

* dwarf2read.c (dwarf2_record_block_ranges): Fill in BLOCK_RANGES
for block.

6 years agoAdd block range data structure for blocks with non-contiguous address ranges
Kevin Buettner [Thu, 23 Aug 2018 23:00:48 +0000 (16:00 -0700)]
Add block range data structure for blocks with non-contiguous address ranges

This patch does the following:

- Introduces a block range data structure which is accessed via
  a new field in struct block.
- Defines several macros for accessing block ranges.
- Defines a new function, make_blockrange, which is responsible for
  creating the new data structure.

It should be noted that some support for non-contiguous ranges already
existed in GDB in the form of blockvector addrmaps.  This support
allowed GDB to quickly find a block containing a particular address
even when the block consists of non-contiguous addresses.  See
find_block_in_blockvector() in block.c, dwarf2_record_block_ranges()
in dwarf2read.c, and record_block_range() in buildsym.c.

Addrmaps do not provide a convenient way to examine address ranges
associated with a particular block.  This data structure (and its
interface) is set up for quickly finding the value (which in this case
is a block) associated with a particular address.  The interface
does not include a method for doing a reverse mapping from blocks to
addresses.  A linear time mapping might be attempted via use of the
addrmap's foreach method, but this is not as straightforward as it
might first appear due to the fact that blocks corresponding to inline
function instances and lexical blocks w/ variables end up getting
interspersed in in the set of transitions.

Note:  If this approach is deemed to be too expensive in terms of
space, an alternate approach might be to attempt the linear time
mapping noted above.  find_pc_partial_function() needs to be able to
quickly know whether there are discontiguous ranges, so a flag for
this property would have to be added to struct block.  Also integral
to this set of changes is the concept of an "entry pc" which might be
different from the block's start address.  An entry_pc field would
also need to be added to struct block.  This does not result in any
space savings in struct block though since the space for the flag and
entry_pc use more space than the blockranges struct pointer that I've
added.  There would, however, be some space savings due to the fact
that the new data structures that I've added for this patch would not
need to be allocated.  (I happen to like the approach I've come up
with, but I wanted to mention another possibility just in case someone
does not.)

gdb/ChangeLog:

* block.h (blockrange, blockranges): New struct declarations.
(struct block): Add new field named `ranges'.
(BLOCK_RANGES, BLOCK_NRANGES, BLOCK_RANGE, BLOCK_CONTIGUOUS_P)
(BLOCK_RANGE_START, BLOCK_RANGE_END, BLOCK_ENTRY_PC): New
macros for accessing ranges in struct block.
(make_blockranges): New declaration.
block.c (make_blockranges): New function.

6 years agoRISC-V: Reject empty rouding mode and fence operand.
Jim Wilson [Thu, 23 Aug 2018 20:26:48 +0000 (13:26 -0700)]
RISC-V: Reject empty rouding mode and fence operand.

gas/
2018-08-23  Kito Cheng  <kito@andestech.com>
* config/tc-riscv.c (arg_lookup): Checking
length before look up.
* testsuite/gas/riscv/fence-fail.d: New file.
* testsuite/gas/riscv/fence-fail.l: Likewise.
* testsuite/gas/riscv/fence-fail.s: Likewise.
* testsuite/gas/riscv/rouding-fail.d: Likewise.
* testsuite/gas/riscv/rouding-fail.l: Likewise.
* testsuite/gas/riscv/rouding-fail.s: Likewise.

6 years agoAvoid problems with plugins being loaded multiple times.
Zenith423 [Thu, 23 Aug 2018 15:22:56 +0000 (16:22 +0100)]
Avoid problems with plugins being loaded multiple times.

PR 23460
* plugin.c (struct plugin_list_entry): New structure.
(plugin_list): New variable.
(try_load_plugin): Place opened plugins on a list.  Ensure that
the refcount in the dynamic loader is kept at 1.

6 years agoDarwin: fix bad loop incrementation
Xavier Roirand [Thu, 23 Aug 2018 15:17:03 +0000 (11:17 -0400)]
Darwin: fix bad loop incrementation

When reading symbols from the vector of oso files on Mac OS X
Darwin, a previous commit introduce a change in the loop and add
an increment at each loop iteration whereas this incrementation is
not needed since the increment or set of the loop control variable
is already done in the loop.

gdb/ChangeLog:

* machoread.c (macho_symfile_read_all_oso): Remove uneeded
incrementation.

Change-Id: I3a5a6deb4e9d834ee7d4217a62d90c2ffb7241bc

6 years agoPR23566, false uninitialized warning
Alan Modra [Thu, 23 Aug 2018 14:50:05 +0000 (00:20 +0930)]
PR23566, false uninitialized warning

PR 23566
* emultempl/elf32.em (before_allocation): Warning fix.

6 years agoPowerPC64 "call lacks nop"
Alan Modra [Thu, 23 Aug 2018 14:45:35 +0000 (00:15 +0930)]
PowerPC64 "call lacks nop"

The "-fPIC" and "-mcmodel=small" parts of these messages isn't always
true, so lets dispense with that and just report the type of stub
causing trouble.

* elf64-ppc.c (ppc64_elf_relocate_section): Revise "call lacks
nop" error message.

6 years agoPowerPC64 st_other decoding in readelf
Alan Modra [Thu, 23 Aug 2018 08:04:13 +0000 (17:34 +0930)]
PowerPC64 st_other decoding in readelf

localentry:1 is a valid encoding, so display it.  The patch also bails
out of get_ppc64_symbol_other when st_other bits besides the three
used for localentry offsets are set, to avoid hiding any such values.

* readelf.c (get_ppc64_symbol_other): Return NULL if st_other
field contains unrecognised or reserved values.  Handle
localentry:1 value.

6 years agoPrune BFD warnings for unknown GNU properties
H.J. Lu [Thu, 23 Aug 2018 13:12:37 +0000 (06:12 -0700)]
Prune BFD warnings for unknown GNU properties

When glibc is enabled with the new GNU_PROPERTY_X86_XXX bits:

https://groups.google.com/forum/#!topic/x86-64-abi/-D05GQ3kWrA

BFD will issue an unknown GNU property warning like

warning: tmpdir/ld1: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010001

and ignore such GNU properties.  This patch adds prune_warnings_extra to
prune such warnings on release branches and updates prune_warnings to
call prune_warnings_extra.

binutils/

PR ld/23536
* Makefile.am (development.exp): New target.
(EXTRA_DEJAGNU_SITE_CONFIG): New.
(DISTCLEANFILES): Add development.exp.
* Makefile.in: Regenerated.
* testsuite/binutils-all/objcopy.exp (strip_test): Call
prune_warnings to prune BFD output.
(strip_test_with_saving_a_symbol): Likewise.
(objcopy_test_without_global_symbol): Likewise.
* testsuite/lib/binutils-common.exp (prune_warnings_extra):
New proc.
(prune_warnings): Likewise.

gas/

PR ld/23536
* Makefile.am (development.exp): New target.
(EXTRA_DEJAGNU_SITE_CONFIG): New.
(DISTCLEANFILES): Add development.exp.
* Makefile.in: Regenerated.

ld/

PR ld/23536
* Makefile.am (development.exp): New target.
(EXTRA_DEJAGNU_SITE_CONFIG): New.
(DISTCLEANFILES): Add development.exp.
* Makefile.in: Regenerated.
* testsuite/ld-bootstrap/bootstrap.exp: Call prune_warnings to
prune BFD output.
* testsuite/ld-plugin/lto.exp: Likewise.
* testsuite/lib/ld-lib.exp (prune_warnings): Removed.
* testsuite/ld-elf/shared.exp: Allow "\n" in linker warnings.

6 years agoDocument setting experimental on release branch.
H.J. Lu [Thu, 23 Aug 2018 12:56:03 +0000 (05:56 -0700)]
Document setting experimental on release branch.

* README-how-to-make-a-release: Document setting "experimental"
to false.

6 years agoReplace unworkable code in HPPA relocs handelr with an assertion.
Nick Clifton [Thu, 23 Aug 2018 12:34:14 +0000 (13:34 +0100)]
Replace unworkable code in HPPA relocs handelr with an assertion.

* elf64-hppa.c (elf_hppa_final_link_relocate): Replace unworkable
code with an assertion.

6 years agoPrevent illegal memory access when processing COFF auxillary symbol information.
Nick Clifton [Thu, 23 Aug 2018 10:45:38 +0000 (11:45 +0100)]
Prevent illegal memory access when processing COFF auxillary symbol information.

PR 23061
* coffgen.c (coff_pointerize_aux): Add table_end parameter.  Use
it to prevent walking off the end of the table.
(coff_get_normalized_symtab): Pass internal_end pointer to
coff_pointerize_aux.

6 years agoFix "unresolved reloc" error for NOTOC relocs
Alan Modra [Thu, 23 Aug 2018 04:04:29 +0000 (13:34 +0930)]
Fix "unresolved reloc" error for NOTOC relocs

* elf64-ppc.c (ppc64_elf_relocate_section): Don't miss clearing
unresolved_reloc on ppc_stub_plt_call_notoc.

6 years agoAutomatic date update in version.in
GDB Administrator [Thu, 23 Aug 2018 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoMake read_program_headers_from_bfd return a gdb::byte_vector
Simon Marchi [Wed, 22 Aug 2018 18:18:08 +0000 (14:18 -0400)]
Make read_program_headers_from_bfd return a gdb::byte_vector

This patch makes read_program_headers_from_bfd return a gdb::byte_vector
instead of a plain pointer.

gdb/ChangeLog:

* solib-svr4.c (read_program_headers_from_bfd): Return
gdb::optional<gdb::byte_vector>.
(svr4_exec_displacement): Adjust.

6 years agoMake read_program_header return a gdb::byte_vector
Simon Marchi [Wed, 22 Aug 2018 18:17:57 +0000 (14:17 -0400)]
Make read_program_header return a gdb::byte_vector

While reading a recent patch, I found this spot where a gdb::byte_vector
could be used instead of an allocated buffer returned as a plain
pointer.

gdb/ChangeLog:

* solib-svr4.c (read_program_header): Return
gdb::optional<gdb::byte_vector>, remove p_sect_size param.
(find_program_interpreter): Return
gdb::optional<gdb::byte_vector>.
(scan_dyntag_auxv): Adjust.
(enable_break): Adjust.
(svr4_exec_displacement): Adjust.

6 years agoRestore behavior of disabling address randomization by default on GDBserver
Simon Marchi [Wed, 22 Aug 2018 17:37:05 +0000 (13:37 -0400)]
Restore behavior of disabling address randomization by default on GDBserver

Commit

  c12a508 ("Add client_state struct.")

inadvertently changed the default behavior of GDBserver wrt address
randomization.  The old disable_randomization global variable was
initialized to 1, whereas the corresponding field in the client_state
structure is initialized to 0.

This fixes

  make check TESTS="gdb.base/jit-simple.exp" RUNTESTFLAGS="--target_board=native-gdbserver"
  make check TESTS="gdb.base/execl-update-breakpoints.exp" RUNTESTFLAGS="--target_board=native-gdbserver"

Note that the execl-update-breakpoints.exp would only fail on systems
where the toolchain emits position-independent executables by default
(otherwise the main executable position is never randomized, so the
value of disable_randomization didn't matter).

gdb/gdbserver/ChangeLog:

PR gdb/23374
PR gdb/23375
* server.h (struct client_state) <disable_randomization>:
Initialize to 1.

6 years agobfd/development.sh: Add experimental
H.J. Lu [Wed, 22 Aug 2018 17:32:08 +0000 (10:32 -0700)]
bfd/development.sh: Add experimental

Add experimental to indicate whether this is a release branch.

PR ld/23536
* development.sh (experimental): New.

6 years agoFix restoring of inferior terminal settings
Simon Marchi [Wed, 22 Aug 2018 15:09:45 +0000 (11:09 -0400)]
Fix restoring of inferior terminal settings

I noticed that the child_terminal_save_inferior function was not used
since the commit f6ac5f3d63e0 ("Convert struct target_ops to C++").  I
was able to make a little test program to illustrate the problem (see
test case).

I think we're just missing the override of the terminal_save_inferior
method in inf_child_target (along with the other terminal-related
methods).

Instead of creating a new test, I thought that gdb.base/term.exp was a
good candidate for testing that gdb restores properly the inferior's
terminal settings.

gdb/ChangeLog:

* inf-child.h (inf_child_target) <terminal_save_inferior>: New.
* inf-child.c (inf_child_target::terminal_save_inferior): New.

gdb/testsuite/ChangeLog:

* gdb.base/term.exp: Compare terminal settings with values from
the inferior.
* gdb.base/term.c: Get and set terminal settings.

6 years agoReplace xstrvprintf usages with string_vprintf
Simon Marchi [Wed, 22 Aug 2018 14:55:28 +0000 (10:55 -0400)]
Replace xstrvprintf usages with string_vprintf

Most usages of xstrvprintf in GDB can be replaced with string_vprintf,
removing some manual memory management.

gdb/ChangeLog:

* guile/scm-string.c (gdbscm_scm_from_printf): Use
string_vprintf.
* guile/scm-utils.c (gdbscm_printf): Likewise.
* serial.c (serial_printf): Likewise.
* xml-support.c (gdb_xml_parser::vdebug): Likewise.

6 years agoMI: Print frame architecture when printing frames on an MI channel
Jan Vrany [Wed, 22 Aug 2018 09:42:38 +0000 (10:42 +0100)]
MI: Print frame architecture when printing frames on an MI channel

When printing frames on an MI channel also print the frame
architecture like in:

    (gdb)
    -stack-list-frames 3 3
    ^done,stack=
    [frame={level="3",addr="0x000107a4",func="foo",
      file="recursive2.c",fullname="/home/foo/bar/recursive2.c",
      line="14",arch="i386:x86_64"}]
   (gdb)

This is useful for MI clients that need to know the architecture in
order to perform further analysis, for example to use their own
disassembler to analyze machine code.

gdb/Changelog:
2018-08-22  Jan Vrany  <jan.vrany@fit.cvut.cz>

* stack.c (print_frame): Print frame architecture when printing on
        an MI output.
* NEWS: Mention new "arch" attribute in frame output.

gdb/testsuite/Changelog
2018-08-22  Jan Vrany  <jan.vrany@fit.cvut.cz>

* lib/mi-support.exp (mi_expect_stop): Update regexp to
accommodate new "arch" field in frame output.
* gdb.mi/mi-return.exp: Likewise.
* gdb.mi/mi-stack.exp: Likewise.
* gdb.mi/mi-syn-frame.exp: Likewise.
* gdb.mi/user-selected-context-sync.exp: Likewise.

gdb/doc/Changelog
2018-08-22  Jan Vrany  <jan.vrany@fit.cvut.cz>

* gdb.texinfo (The -stack-list-frames Command): Update description
to mention "arch".
Update MI examples throughout the document to contain "arch" in
frame output.

6 years agoUse the correct constants when setting the section type of HPPA unwind sections.
Helge Deller [Wed, 22 Aug 2018 09:32:53 +0000 (10:32 +0100)]
Use the correct constants when setting the section type of HPPA unwind sections.

* elf-hppa.h (elf_hppa_fake_sections): Use SHT_PARISC_UNWIND as
the section type of the .PARISC.unwind section on 64-bit binaries
and SHT_PROGBITS for 32-bit binaries.  Add a comment about it.
Add comment about the sh_entsize value.

6 years agoFix AArch64 stub layout algorithm to allow for the fact that section layut might...
Rafeal Auler [Wed, 22 Aug 2018 09:04:09 +0000 (10:04 +0100)]
Fix AArch64 stub layout algorithm to allow for the fact that section layut might change a stub's target location.

PR 23560
* elfnn-aarch64.c (elfNN_aarch64_size_stubs): Always update the
stub's target, since it may have been changed after the layout.

6 years agoFix typo in changelog entry for handling of undocumnented Z80 SLI instruction.
Nick Clifton [Wed, 22 Aug 2018 08:58:32 +0000 (09:58 +0100)]
Fix typo in changelog entry for handling of undocumnented Z80 SLI instruction.

6 years agoAarch64 SVE VG is Vector Granule
Alan Hayward [Wed, 22 Aug 2018 08:22:12 +0000 (09:22 +0100)]
Aarch64 SVE VG is Vector Granule

...not Vector Gradient.

See: DWARF for the ARMĀ® 64-bit Architecture (AArch64) with SVE support

gdb/
* arch/aarch64.h (aarch64_regnum): Update comment.

6 years agoAdd AArch64 SVE to NEWS and GDB manual
Alan Hayward [Wed, 22 Aug 2018 08:17:24 +0000 (09:17 +0100)]
Add AArch64 SVE to NEWS and GDB manual

gdb/
* NEWS: Add SVE to 8.2 section.

gdb/doc/
* doc/gdb.texinfo (AArch64 SVE): New subsubsection.

6 years agoFix changelog entries
Alan Modra [Wed, 22 Aug 2018 07:07:56 +0000 (16:37 +0930)]
Fix changelog entries

6 years agoRe: Pack reloc_howto_struct
Alan Modra [Wed, 22 Aug 2018 04:41:56 +0000 (14:11 +0930)]
Re: Pack reloc_howto_struct

Fix fallout when using gcc-4.

* dw2gencfi.c (emit_expr_encoded, output_fde): Warning fixes.

6 years agoCorrect readelf e_shstrndx range check
Alan Modra [Wed, 22 Aug 2018 00:34:58 +0000 (10:04 +0930)]
Correct readelf e_shstrndx range check

Fixes a bogus out of range error:
  Number of section headers:         0 (210016)
  Section header string table index: 1 <corrupt: out of range>

Caused due to e_shnum remaining as zero rather than being updated to
the value from section_header[0].sh_info at the point where we range
check e_shstrndx.

* readelf.c (process_file_header): Assign updated values from
section_header[0] fields to e_phnum, e_shnum and e_shstrndx
during printing of header.  Correct e_shstrndx range check.
Remove unnecessary casts and use %u rather than %ld for
unsigned int header fields.  Don't print a random %lx when
reporting an unknown EI_VERSION.

6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 22 Aug 2018 00:00:43 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoS12Z: Rename reloc R_S12Z_UKNWN_3 to R_S12Z_EXT18 and implement according to recently...
John Darrington [Sun, 17 Jun 2018 05:04:11 +0000 (07:04 +0200)]
S12Z: Rename reloc R_S12Z_UKNWN_3 to R_S12Z_EXT18 and implement according to recently inferred information about this reloc.

* bfd/elf32-s12z.c: (opru18_reloc): New function.
* bfd/elf32-s12z.c: (elf_s12z_howto_table): Adjust Howto according to new knowledge.
* include/elf/s12z.h: Rename R_S12Z_UKNWN_3 to R_S12Z_EXT18.

6 years agoDon't throw Scheme exceptions with live std::vector objects
Pedro Alves [Tue, 21 Aug 2018 15:48:30 +0000 (16:48 +0100)]
Don't throw Scheme exceptions with live std::vector objects

A complication with the Guile code is that we have two types of
exceptions to consider: GDB/C++ exceptions, and Guile/SJLJ exceptions.

Because Guile exceptions are SJLJ based, we must make sure to not have
live local variables of types with non-trivial dtors when a Guile
exception is thrown, because the dtors won't be run when a Guile
exceptions is thrown.

gdbscm_parse_function_args currently violates this:

 void
 gdbscm_parse_function_args (const char *func_name,
     int beginning_arg_pos,
     const SCM *keywords,
     const char *format, ...)
 {
 ...
   /* Keep track of malloc'd strings.  We need to free them upon error.  */
   std::vector<char *> allocated_strings;
 ...
   for (char *ptr : allocated_strings)
     xfree (ptr);
   gdbscm_throw (status); /// dtor of "allocated_strings" is not run!
 }

This commit fixes the above making using of gdbscm_wrap.

It would be nice if we had a way to make it impossible to write such
code.  PR guile/23429 has an idea for that, if someone's interested.

gdb/ChangeLog:
2018-08-21  Pedro Alves  <palves@redhat.com>

* guile/scm-utils.c (gdbscm_parse_function_args_1): New, factored
out from gdbscm_parse_function_args.
(gdbscm_parse_function_args): Rework to use gdbscm_wrap and
gdbscm_parse_function_args_1.

6 years agoFix running objcopy on Mach-O binaries.
mephi42 [Tue, 21 Aug 2018 15:34:56 +0000 (16:34 +0100)]
Fix running objcopy on Mach-O binaries.

PR binutils/23315
* mach-o.c (bfd_mach_o_mangle_symbols): Update n_type even if
data is already considered filled.

6 years agoUpdate the documentation of the linker's --hash-style option.
Nick Clifton [Tue, 21 Aug 2018 15:15:36 +0000 (16:15 +0100)]
Update the documentation of the linker's --hash-style option.

PR 23426
* ld.texi (--hash-style): Note that the default is configurable
and that for most Linux based systems it will be "both".

6 years agoFix handling of undocumented SLL instruction for the Z80 target.
Arnold Metselaar [Tue, 21 Aug 2018 14:50:49 +0000 (15:50 +0100)]
Fix handling of undocumented SLL instruction for the Z80 target.

* config/tc-z80.c: Correct treatment of undocumented instruction
sli/sll.
(emit_mr): Add argument unportable.
(emit_bit): Adapt call to emit_mr.
(emit_mr_z80): New function.
(emit_mr_unportable): New function.
(instab[]): Replace emit_mr with emit_mr_z80 or emit_mr_unportable
as appropriate.

6 years agoRemove unnecessary ternary operator in m32c-tdep.c
Simon Marchi [Tue, 21 Aug 2018 14:47:47 +0000 (10:47 -0400)]
Remove unnecessary ternary operator in m32c-tdep.c

Bug 17816 pointed out a useless use of the ternary operator:

  case 0x0: sd.reg = (size == 1 ? &st->r0 : &st->r0); break;

I believe that this is right.  If size is 1, the instruction refers to
part of r0, while if size is 2, the instruction refers to the whole of
r0.

gdb/ChangeLog:

PR gdb/17816
* m32c-tdep.c (m32c_decode_srcdest4): Remove unnecessary ternary
operator.

6 years agoNote that Arnold Metselaar has retired as the z80 maintainer.
Nick Clifton [Tue, 21 Aug 2018 14:41:59 +0000 (15:41 +0100)]
Note that Arnold Metselaar has retired as the z80 maintainer.

6 years agoFix a seg-fault in readelf when parsing corrupt HPPA unwind tables.
L. Simon [Tue, 21 Aug 2018 14:37:06 +0000 (15:37 +0100)]
Fix a seg-fault in readelf when parsing corrupt HPPA unwind tables.

PR 23531
* readelf.c (hppa_process_unwind): Only dump the unwind table if
the data was successfully read in.

6 years agoFix invalid strcpy on unterminated buffer
Andreas Schwab [Mon, 20 Aug 2018 14:55:05 +0000 (16:55 +0200)]
Fix invalid strcpy on unterminated buffer

* read.c (do_repeat_with_expander): Use memmove instead of strcpy
on unterminated string buffer.

6 years agoUse operand->extract to provide defaults for optional PowerPC operands
Alan Modra [Thu, 16 Aug 2018 06:44:12 +0000 (16:14 +0930)]
Use operand->extract to provide defaults for optional PowerPC operands

Most optional operands to powerpc instructions use a default value of
zero, but there are a few exceptions.  Those have been handled by
PPC_OPERAND_OPTIONAL_VALUE and an entry in the powerpc_operands table
for the default value, smuggled in the shift field.  This patch
changes that to using the operand extract function to provide non-zero
defaults.

I've also moved the code determining whether optional operands are
provided or omitted, to the point the first optional operand is seen,
and allowed for the possibility of optional base register operands
in a future patch.

The patch does change the error you get on invalid assembly like

  ld 3,4

You'll now see "missing operand" rather than
"syntax error; end of line, expected `('".

gas/
* config/tc-ppc.c (md_assemble): Delay counting of optional
operands until one is encountered.  Allow for the possibility
of optional base regs, ie. PPC_OPERAND_PARENS.  Call
ppc_optional_operand_value with extra args.
include/
* opcode/ppc.h (struct powerpc_operand): Correct "insert" comment.
Mention use of "extract" function to provide default value.
(PPC_OPERAND_OPTIONAL_VALUE): Delete.
(ppc_optional_operand_value): Rewrite to use extract function.
opcodes/
* ppc-dis.c (operand_value_powerpc): Init "invalid".
(skip_optional_operands): Count optional operands, and update
ppc_optional_operand_value call.
* ppc-opc.c (extract_dxdn): Remove ATTRIBUTE_UNUSED from used arg.
(extract_vlensi): Likewise.
(extract_fxm): Return default value for missing optional operand.
(extract_ls, extract_raq, extract_tbr): Likewise.
(insert_sxl, extract_sxl): New functions.
(insert_esync, extract_esync): Remove Power9 handling and simplify.
(powerpc_operands <FXM4, TBR>): Delete PPC_OPERAND_OPTIONAL_VALUE
flag and extra entry.
(powerpc_operands <SXL>): Likewise, and use insert_sxl and
extract_sxl.

6 years agoPowerPC HOWTOs
Alan Modra [Mon, 20 Aug 2018 05:53:38 +0000 (15:23 +0930)]
PowerPC HOWTOs

These take up far too many lines in the files.  This patch introduces
a replacement for the HOWTO macro that simplifies the relow howto
initialization.  Apart from the two relocs mentioned in the ChangeLog,
no relocation howto is changed.

* elf64-ppc.c (HOW): Define.
(ONES): Delete.
(ppc64_elf_howto_raw): Use HOW to initialize entries.
* elf32-ppc.c (HOW): Define.
(ppc_elf_howto_raw): Use HOW to initialize entries, updating
R_PPC_VLE_REL15 and R_PPC_VLE_REL24 to use bitpos=0.

6 years agoPack reloc_howto_struct
Alan Modra [Tue, 21 Aug 2018 02:24:29 +0000 (11:54 +0930)]
Pack reloc_howto_struct

This patch uses bitfields in reloc_howto_struct, reducing its size
from 80 to 40 bytes on 64-bit hosts and from 52 to 32 bytes on 32-bit
hosts (with a 32-bit bfd_vma).  I've also added a new "negate" field
rather than making the encoded "size" field do double duty as both
a size and a flag.

There was just one use of an encoded size of 8, which according to
bfd_get_reloc_size meant 16 bytes, in vms-alpha.c ALPHA_R_LINKAGE.
See git commit c3d8e071bf adding ALPHA_R_LINKAGE and git commit
8612a388f7 decoding size 8 in bfd_get_reloc_size.  Since no other part
of BFD handles 16 byte relocs, I've removed that encoding and special
cased the ALPHA_R_LINKAGE size in vms-alpha.c.

* reloc.c (reloc_howto_type): Typedef.
(bfd_symbol): Delete forward declaration.
(struct reloc_howto_struct): Add "negate" field.  Make "size",
"bitsize", "rightshift", "bitpos", "complain_on_overflow",
"pc_relative", "partial_inplace", and "pcrel_offset" bitfields.
Rearrange for better packing.  Revise comments.
(HOWTO): Map to rearranged reloc_howto_struct.
(bfd_get_reloc_size): Delete now unused cases.
(read_reloc, write_reloc): Likewise.
(apply_reloc, _bfd_relocate_contents): Test howto->negate
rather than howto->size < 0 for negated relocation values.
* coff-rs6000.c (xcoff_complain_overflow_bitfield_func): Avoid
signed/unsigned warning.
(xcoff_ppc_relocate_section): Delete "condition is always false"
code.
* coff64-rs6000.c (xcoff64_ppc_relocate_section): Likewise.
* cpu-ns32k.c (do_ns32k_reloc): Adjust to suit reloc_howto_struct
changes.
* vms-alpha.c (_bfd_vms_write_etir, alpha_vms_slurp_relocs): Use
size 16 for ALPHA_R_LINKAGE.
(alpha_howto_table <ALPHA_R_LINKAGE>): Set encoded size and
bitsize to zero.
* bfd-in.h (reloc_howto_type): Delete.
* bfd-in2.h: Regenerate.

6 years agoDelete NEWHOWTO and tidy some uses of reloc_howto_struct
Alan Modra [Mon, 20 Aug 2018 10:06:05 +0000 (19:36 +0930)]
Delete NEWHOWTO and tidy some uses of reloc_howto_struct

NEWHOWTO was promised way back in 1991 (git commit e5683622186).
I doubt it's ever going to be implemented.  This patch removes it,
and tidies some reloc howtos.  I was going to make some changes to
reloc_howto_struct, so I think it's important that all relocs howtos
are initialized with HOWTO.

* reloc.c (HOWTO): Revise comment.
(NEWHOWTO, HOWTO_PREPARE): Delete.
* coff-arm.c (coff_arm_reloc_type_lookup): Replace const struc
reloc_howto_struct with reloc_howto_type.
* ns32knetbsd.c (MY_bfd_reloc_type_lookup): Likewise.
* vms-alpha.c (alpha_vms_bfd_reloc_type_lookup): Likewise.
* elf-hppa.h (HOW): Define.
(elf_hppa_howto_table): Use it to simplify this table, correcting
name of R_PARISC_LTOFF16WF, R_PARISC_LTOFF_FPTR64, and
R_PARISC_LTOFF_FPTR16DF.
* elf32-mep.c (MEPREL): Use HOWTO.
* bfd-in2.h: Regenerate.

6 years agoFix s12z test regexps
Alan Modra [Mon, 20 Aug 2018 08:46:34 +0000 (18:16 +0930)]
Fix s12z test regexps

Fixes
ERROR: tcl error sourcing .../gas/testsuite/gas/s12z/s12z.exp.
ERROR: couldn't compile regular expression pattern: quantifier operand invalid

run_dump_test expected output lines are regexps.

* testsuite/gas/s12z/bit-manip-invalid.d: Correct regexps.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 21 Aug 2018 00:00:49 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoFix formatting in solib-svr4.c
Simon Marchi [Mon, 20 Aug 2018 02:03:58 +0000 (22:03 -0400)]
Fix formatting in solib-svr4.c

Fix some formatting issues which I have missed during review.

gdb/ChangeLog:

* solib-svr4.c (svr4_exec_displacement): Fix formatting.

6 years agoDon't init array at run time
Alan Modra [Sun, 19 Aug 2018 23:55:12 +0000 (09:25 +0930)]
Don't init array at run time

When it can be done at compile time.

* mmo.c (valid_mmo_symbol_character_set): Initialize and make
array const.
(mmo_init): Don't init valid_mmo_symbol_character_set.

6 years agoTidy bit twiddling
Alan Modra [Sun, 19 Aug 2018 23:52:28 +0000 (09:22 +0930)]
Tidy bit twiddling

* sh-opc.h (MASK): Simplify.

6 years agoBalance parentheses in expression
Alan Modra [Sun, 19 Aug 2018 23:50:11 +0000 (09:20 +0930)]
Balance parentheses in expression

* rs6000-core.c (CORE_COMMONSZ): Balance parentheses in expression.

6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 20 Aug 2018 00:00:44 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoFix debugging of stripped PIE executables with padded PT_TLS
Michael Spang [Sun, 19 Aug 2018 14:55:58 +0000 (10:55 -0400)]
Fix debugging of stripped PIE executables with padded PT_TLS

Certain PIE executables produced by gold cannot be debugged by gdb after
being stripped. GDB requires program headers of PIE executables to match,
and those checks may fail due to adjustments made during stripping.

One case of this occurs because strip recomputes the memsz of PT_TLS and
does not add alignment, while gold does. This is another variant of PR
11786, so apply the same fix of relaxing the program header matching.

gdb/ChangeLog:

PR gdb/11786
* solib-svr4.c (svr4_exec_displacement): Ignore memsz fields
for PT_TLS segments.

gdb/testsuite/ChangeLog:

PR gdb/11786
* gdb.base/gcore-tls-pie.c: New file.
* gdb.base/gcore-tls-pie.exp: New file.

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 19 Aug 2018 00:01:08 +0000 (00:01 +0000)]
Automatic date update in version.in

6 years agoTest case for DW_OP_GNU_variable_value
Kevin Buettner [Tue, 31 Jul 2018 21:45:20 +0000 (14:45 -0700)]
Test case for DW_OP_GNU_variable_value

gdb/testsuite/ChangeLog:

* gdb.dwarf2/varval.c: New file.
* gdb.dwarf2/varval.exp: New file.

6 years agoAdd support of DW_OP_GNU_variable_value to DWARF assembler
Kevin Buettner [Mon, 30 Jul 2018 23:15:34 +0000 (16:15 -0700)]
Add support of DW_OP_GNU_variable_value to DWARF assembler

gdb/testsuite/ChangeLog:

* lib/dwarf.exp: Add support for DW_OP_GNU_variable_value.

6 years agoAdd support for DW_OP_GNU_variable_value
Kevin Buettner [Mon, 30 Jul 2018 22:41:56 +0000 (15:41 -0700)]
Add support for DW_OP_GNU_variable_value

This patch adds support for DW_OP_GNU_variable_value to GDB.

Jakub Jelinek provides a fairly expansive discussion of this DWARF
expression opcode in his GCC patch...

    https://gcc.gnu.org/ml/gcc-patches/2017-02/msg01499.html

It has also been proposed for addition to the DWARF Standard:

    http://www.dwarfstd.org/ShowIssue.php?issue=161109.2

If compiled with a suitable version of GCC, the test case associated
with GCC Bug 77589 uses DW_OP_GNU_variable_value in a DW_AT_byte_stride
expression.  Here's a link to the bug:

    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77589

This is what the DWARF looks like.  Look at the last line, which has
the DW_AT_byte_stride expression:

 <2><e1>: Abbrev Number: 12 (DW_TAG_variable)
    <e2>   DW_AT_name        : (indirect string, offset: 0x115): span.0
    <e6>   DW_AT_type        : <0x2e>
    <ea>   DW_AT_artificial  : 1
    <ea>   DW_AT_location    : 3 byte block: 91 b0 7f  (DW_OP_fbreg: -80)
 ...
 <2><178>: Abbrev Number: 18 (DW_TAG_subrange_type)
    <179>   DW_AT_lower_bound : 4 byte block: 97 23 20 6  (DW_OP_push_object_address; DW_OP_plus_uconst: 32; DW_OP_deref)
    <17e>   DW_AT_upper_bound : 4 byte block: 97 23 28 6  (DW_OP_push_object_address; DW_OP_plus_uconst: 40; DW_OP_deref)
    <183>   DW_AT_byte_stride : 10 byte block: 97 23 18 6 fd e1 0 0 0 1e  (DW_OP_push_object_address; DW_OP_plus_uconst: 24; DW_OP_deref; DW_OP_GNU_variable_value: <0xe1>; DW_OP_mul)

A patch to readelf, which I'm also submitting, is required to do this
decoding.

I found that GDB gave me the correct answer for "p c40pt(2)" once I
(correctly) implemented DW_OP_GNU_variable_value.

I also have test case (later in this series) which uses the DWARF
assembler and, therefore, do not rely on having a compiler with this
support.

gdb/ChangeLog:

* dwarf2expr.h (struct dwarf_expr_context): Add virtual method
dwarf_variable_value.
* dwarf2-frame.c (class dwarf_expr_executor):
Add override for dwarf_variable_value.
* dwarf2loc.c (class dwarf_evaluate_loc_desc): Likewise.
(class symbol_needs_eval_context): Likewise.
(indirect_synthetic_pointer): Add forward declaration.
(sect_variable_value): New function.
(dwarf2_compile_expr_to_ax): Add case for DW_OP_GNU_variable_value.
* dwarf2expr.c (dwarf_expr_context::execute_stack_op): Add case
for DW_OP_GNU_variable_value.