external/binutils.git
9 years agoPR remote/17946: Fix wrong comparison of pointer against char
Sergio Durigan Junior [Mon, 9 Feb 2015 23:58:12 +0000 (18:58 -0500)]
PR remote/17946: Fix wrong comparison of pointer against char

We were comparing a pointer against a char on remote.c.  'dcb' filed a
bug to inform us about that.  I pushed the following patch under the
obvious rule.

gdb/ChangeLog:
2015-02-09  Sergio Durigan Junior  <sergiodj@redhat.com>

PR remote/17946
* gdb/remote.c (remote_parse_stop_reply): Fix wrong comparison
of pointer against char.

9 years agoAutomatic date update in version.in
GDB Administrator [Tue, 10 Feb 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoAvoid incrementing uninitialized variable
Ed Maste [Mon, 9 Feb 2015 21:55:34 +0000 (13:55 -0800)]
Avoid incrementing uninitialized variable

* elf32-i386.c (elf_i386_get_plt_sym_val): Avoid incrementing
uninitialized and unused variable.
* elf64-x86-64.c (elf_x86_64_get_plt_sym_val): Likewise.

9 years agoGCC5/DWARFv5 Handle DW_TAG_atomic_type for C11 _Atomic type qualifier.
Mark Wielaard [Mon, 9 Feb 2015 13:58:25 +0000 (14:58 +0100)]
GCC5/DWARFv5 Handle DW_TAG_atomic_type for C11 _Atomic type qualifier.

gdb/ChangeLog

* c-typeprint.c (cp_type_print_method_args): Handle '_Atomic'.
(c_type_print_modifier): Likewise.
* dwarf2read.c (read_tag_atomic_type): New function.
(read_type_die_1): Handle DW_TAG_atomic_type.
* gdbtypes.c (make_atomic_type): New function.
(recursive_dump_type): Handle TYPE_ATOMIC.
* gdbtypes.h (enum type_flag_values): Renumber.
(enum type_instance_flag_value): Add TYPE_INSTANCE_FLAG_ATOMIC.
(TYPE_ATOMIC): New macro.
(make_atomic_type): Declare.

gdb/testsuite/ChangeLog

* gdb.dwarf2/atomic.c: New file.
* gdb.dwarf2/atomic-type.exp: Likewise.

include/ChangeLog

* dwarf2.def: Add DW_TAG_atomic_type.

9 years agoReplace two_file_shared_2.so with two_file_shared_1.so
H.J. Lu [Mon, 9 Feb 2015 13:33:19 +0000 (05:33 -0800)]
Replace two_file_shared_2.so with two_file_shared_1.so

There are

two_file_shared_2_pic_1_test_LDADD = two_file_test_2_pic.o two_file_shared_1.so

There should be two_file_shared_1.so, not two_file_shared_2.so in
two_file_shared_2_pic_1_test_DEPENDENCIES.

* testsuite/Makefile.am (two_file_shared_2_pic_1_test_DEPENDENCIES):
Replace two_file_shared_2.so with two_file_shared_1.so.
* testsuite/Makefile.in: Regenerated.

9 years ago[ARM][gas] Use as_tsktsk instead of as_warn for deprecation messages.
Kyrylo Tkachov [Mon, 9 Feb 2015 11:20:30 +0000 (11:20 +0000)]
[ARM][gas] Use as_tsktsk instead of as_warn for deprecation messages.

* config/tc-arm.c (warn_deprecated_sp): Use as_tsktsk instead
of as_warn for deprecation messages.
(encode_arm_addr_mode_2): Likewise.
(check_obsolete): Likewise.
(do_rd_rm_rn): Likewise.
(do_co_reg): Likewise.
(do_setend): Likewise.
(do_t_mov_cmp): Likewise.
(do_neon_ldr_str): Likewise.
(opcode_lookup): Likewise.
(if_fsm_post_encode): Likewise.
(md_assemble): Likewise.

* gas/arm/armv1.l: Remove 'Warning: ' from expected messages
for deprecations.
* gas/arm/armv8-a-bad.l: Likewise.
* gas/arm/armv8-a-it-bad.l: Likewise.
* gas/arm/depr-swp.l: Likewise.
* gas/arm/ldsgeb.l: Likewise.
* gas/arm/ldsgeh.l: Likewise.
* gas/arm/thumb2_bad_reg.l: Likewise.
* gas/arm/thumb32.l: Likewise.
* gas/arm/udf.l: Likewise.
* gas/arm/vstr-arm-bad.l: Likewise.

9 years agorecord-btrace: indicate gaps
Markus Metzger [Thu, 30 Jan 2014 08:51:10 +0000 (09:51 +0100)]
record-btrace: indicate gaps

Indicate gaps in the trace due to decode errors.  Internally, a gap is
represented as a btrace function segment without instructions and with a
non-zero format-specific error code.

Show the gap when traversing the instruction or function call history.
Also indicate gaps in "info record".

It looks like this:

  (gdb) info record
  Active record target: record-btrace
  Recording format: Branch Trace Store.
  Buffer size: 64KB.
  Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182).
  (gdb) record function-call-history /cli
  1 fib inst 1,9 at src/fib.c:9,14
  2   fib inst 10,20 at src/fib.c:6,14
  3 [decode error (1): instruction overflow]
  4 fib inst 21,28 at src/fib.c:11,14
  5   fib inst 29,33 at src/fib.c:6,9
  (gdb) record instruction-history 20,22
  20    0x000000000040062f <fib+47>: sub    $0x1,%rax
  [decode error (1): instruction overflow]
  21    0x0000000000400613 <fib+19>: add    $0x1,%rax
  22    0x0000000000400617 <fib+23>: mov    %rax,0x200a3a(%rip)
  (gdb)

Gaps are ignored during reverse execution and replay.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

* btrace.c (ftrace_find_call): Skip gaps.
(ftrace_new_function): Initialize level.
(ftrace_new_call, ftrace_new_tailcall, ftrace_new_return)
(ftrace_new_switch): Update
level computation.
(ftrace_new_gap): New.
(ftrace_update_function): Create new function after gap.
(btrace_compute_ftrace_bts): Create gap on error.
(btrace_stitch_bts): Update parameters.  Clear trace if it
becomes empty.
(btrace_stitch_trace): Update parameters.  Update callers.
(btrace_clear): Reset the number of gaps.
(btrace_insn_get): Return NULL if the iterator points to a gap.
(btrace_insn_number): Return zero if the iterator points to a gap.
(btrace_insn_end): Allow gaps at the end.
(btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps.
(btrace_find_insn_by_number): Assert that the found iterator does
not point to a gap.
(btrace_call_next, btrace_call_prev): Assert that the last function
is not a gap.
* btrace.h (btrace_bts_error): New.
(btrace_function): Update comment.
(btrace_function) <insn, insn_offset, number>: Update comment.
(btrace_function) <errcode>: New.
(btrace_thread_info) <ngaps>: New.
(btrace_thread_info) <replay>: Update comment.
(btrace_insn_get): Update comment.
* record-btrace.c (btrace_ui_out_decode_error): New.
(record_btrace_info): Print number of gaps.
(btrace_insn_history, btrace_call_history): Call
btrace_ui_out_decode_error for gaps.
(record_btrace_step_thread, record_btrace_start_replaying): Skip gaps.

testsuite/
* gdb.btrace/buffer-size.exp: Update "info record" output.
* gdb.btrace/delta.exp: Update "info record" output.
* gdb.btrace/enable.exp: Update "info record" output.
* gdb.btrace/finish.exp: Update "info record" output.
* gdb.btrace/instruction_history.exp: Update "info record" output.
* gdb.btrace/next.exp: Update "info record" output.
* gdb.btrace/nexti.exp: Update "info record" output.
* gdb.btrace/step.exp: Update "info record" output.
* gdb.btrace/stepi.exp: Update "info record" output.
* gdb.btrace/nohist.exp: Update "info record" output.

9 years agobtrace: identify cpu
Markus Metzger [Fri, 14 Feb 2014 08:25:40 +0000 (09:25 +0100)]
btrace: identify cpu

Add a struct for identifying a processor and use it in linux-btrace.c when
identifying the processor we're running on.

We will need this feature for the new btrace format.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

* common/btrace-common.h (btrace_cpu_vendor, btrace_cpu): New.
* nat/linux-btrace.c: (btrace_this_cpu): New.
(cpu_supports_bts): Call btrace_this_cpu.
(intel_supports_bts): Add cpu parameter.

9 years agobtrace: extend struct btrace_insn
Markus Metzger [Wed, 29 Jan 2014 11:56:09 +0000 (12:56 +0100)]
btrace: extend struct btrace_insn

Add the instruction's size as well as a coarse classification to struct
btrace_insn.  Use the information in ftrace_update_function and
ftrace_find_call.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

* btrace.h (btrace_insn_class): New.
(btrace_insn) <size, iclass>: New.
* btrace.c (ftrace_find_call): Update parameters.  Update users.
Use instruction classification.
(ftrace_new_return): Update parameters.  Update users.
(ftrace_update_function): Update parameters.  Update users.  Use
instruction classification.
(ftrace_update_insns): Update parameters.  Update users.
(ftrace_classify_insn): New.
(btrace_compute_ftrace_bts): Fill in new btrace_insn fields.  Add
TRY_CATCH around call to gdb_insn_length.

9 years agobtrace: update btrace_compute_ftrace parameters
Markus Metzger [Wed, 29 Jan 2014 10:12:06 +0000 (11:12 +0100)]
btrace: update btrace_compute_ftrace parameters

Pass thread_info instead of btrace_thread_info to btrace_compute_ftrace.
We will need the thread_info in subsequent patches.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

* btrace.c (btrace_compute_ftrace_bts, btrace_compute_ftrace):
Update parameters.  Update users.

9 years agorecord-btrace: add bts buffer size configuration option
Markus Metzger [Thu, 28 Nov 2013 15:39:12 +0000 (16:39 +0100)]
record-btrace: add bts buffer size configuration option

Allow the size of the branch trace ring buffer to be defined by the
user.  The specified buffer size will be used when BTS tracing is
enabled for new threads.

The obtained buffer size may differ from the requested size.  The
actual buffer size for the current thread is shown in the "info record"
command.

Bigger buffers mean longer traces, but also longer processing time.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

* btrace.c (parse_xml_btrace_conf_bts): Add size.
(btrace_conf_bts_attributes): New.
(btrace_conf_children): Add attributes.
* common/btrace-common.h (btrace_config_bts): New.
(btrace_config)<bts>: New.
(btrace_config): Update comment.
* nat/linux-btrace.c (linux_enable_btrace, linux_enable_bts):
Use config.
* features/btrace-conf.dtd: Increment version.  Add size
attribute to bts element.
* record-btrace.c (set_record_btrace_bts_cmdlist,
show_record_btrace_bts_cmdlist): New.
(record_btrace_adjust_size, record_btrace_print_bts_conf,
record_btrace_print_conf, cmd_set_record_btrace_bts,
cmd_show_record_btrace_bts): New.
(record_btrace_info): Call record_btrace_print_conf.
(_initialize_record_btrace): Add commands.
* remote.c: Add PACKET_Qbtrace_conf_bts_size enum.
(remote_protocol_features): Add Qbtrace-conf:bts:size packet.
(btrace_sync_conf): Synchronize bts size.
(_initialize_remote): Add Qbtrace-conf:bts:size packet.
* NEWS: Announce new commands and new packets.

doc/
* gdb.texinfo (Branch Trace Configuration Format): Add size.
(Process Record and Replay): Describe new set|show commands.
(General Query Packets): Describe Qbtrace-conf:bts:size packet.

testsuite/
* gdb.btrace/buffer-size: New.

gdbserver/
* linux-low.c (linux_low_btrace_conf): Print size.
* server.c (handle_btrace_conf_general_set): New.
(hanle_general_set): Call handle_btrace_conf_general_set.
(handle_query): Report Qbtrace-conf:bts:size as supported.

9 years agorecord btrace: add configuration struct
Markus Metzger [Thu, 28 Nov 2013 14:44:13 +0000 (15:44 +0100)]
record btrace: add configuration struct

Add a struct to describe the branch trace configuration and use it for
enabling branch tracing.

The user will be able to set configuration fields for each tracing format
to be used for new threads.

The actual configuration that is active for a given thread will be shown
in the "info record" command.

At the moment, the configuration struct only contains a format field
that is set to the only available format.

The format is the only configuration option that can not be set via set
commands.  It is given as argument to the "record btrace" command when
starting recording.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

* Makefile.in (XMLFILES): Add btrace-conf.dtd.
* x86-linux-nat.c (x86_linux_enable_btrace): Update parameters.
(x86_linux_btrace_conf): New.
(x86_linux_create_target): Initialize to_btrace_conf.
* nat/linux-btrace.c (linux_enable_btrace): Update parameters.
Check format.  Split into this and ...
(linux_enable_bts): ... this.
(linux_btrace_conf): New.
(perf_event_skip_record): Renamed into ...
(perf_event_skip_bts_record): ... this.  Updated users.
(linux_disable_btrace): Split into this and ...
(linux_disable_bts): ... this.
(linux_read_btrace): Check format.
* nat/linux-btrace.h (linux_enable_btrace): Update parameters.
(linux_btrace_conf): New.
(btrace_target_info)<ptid>: Moved.
(btrace_target_info)<conf>: New.
(btrace_target_info): Split into this and ...
(btrace_tinfo_bts): ... this.  Updated users.
* btrace.c (btrace_enable): Update parameters.
(btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf)
(btrace_conf_children, btrace_conf_attributes)
(btrace_conf_elements): New.
* btrace.h (btrace_enable): Update parameters.
(btrace_conf, parse_xml_btrace_conf): New.
* common/btrace-common.h (btrace_config): New.
* feature/btrace-conf.dtd: New.
* record-btrace.c (record_btrace_conf): New.
(record_btrace_cmdlist): New.
(record_btrace_enable_warn, record_btrace_open): Pass
&record_btrace_conf.
(record_btrace_info): Print recording format.
(cmd_record_btrace_bts_start): New.
(cmd_record_btrace_start): Call cmd_record_btrace_bts_start.
(_initialize_record_btrace): Add "record btrace bts" subcommand.
Add "record bts" alias command.
* remote.c (remote_state)<btrace_config>: New.
(remote_btrace_reset, PACKET_qXfer_btrace_conf): New.
(remote_protocol_features): Add qXfer:btrace-conf:read.
(remote_open_1): Call remote_btrace_reset.
(remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF.
(btrace_target_info)<conf>: New.
(btrace_sync_conf, btrace_read_config): New.
(remote_enable_btrace): Update parameters.  Call btrace_sync_conf and
btrace_read_conf.
(remote_btrace_conf): New.
(init_remote_ops): Initialize to_btrace_conf.
(_initialize_remote): Add qXfer:btrace-conf packet.
* target.c (target_enable_btrace): Update parameters.
(target_btrace_conf): New.
* target.h (target_enable_btrace): Update parameters.
(target_btrace_conf): New.
(target_object)<TARGET_OBJECT_BTRACE_CONF>: New.
(target_ops)<to_enable_btrace>: Update parameters and comment.
(target_ops)<to_btrace_conf>: New.
* target-delegates: Regenerate.
* target-debug.h (target_debug_print_const_struct_btrace_config_p)
(target_debug_print_const_struct_btrace_target_info_p): New.
NEWS: Announce new command and new packet.

doc/
* gdb.texinfo (Process Record and Replay): Describe the "record
btrace bts" command.
(General Query Packets): Describe qXfer:btrace-conf:read packet.
(Branch Trace Configuration Format): New.

gdbserver/
* linux-low.c (linux_low_enable_btrace): Update parameters.
(linux_low_btrace_conf): New.
(linux_target_ops)<to_btrace_conf>: Initialize.
* server.c (current_btrace_conf): New.
(handle_btrace_enable): Rename to ...
(handle_btrace_enable_bts): ... this.  Pass &current_btrace_conf
to target_enable_btrace.  Update comment.  Update users.
(handle_qxfer_btrace_conf): New.
    (qxfer_packets): Add btrace-conf entry.
(handle_query): Report qXfer:btrace-conf:read as supported packet.
* target.h (target_ops)<enable_btrace>: Update parameters and comment.
(target_ops)<read_btrace_conf>: New.
(target_enable_btrace): Update parameters.
(target_read_btrace_conf): New.

testsuite/
* gdb.btrace/delta.exp: Update "info record" output.
* gdb.btrace/enable.exp: Update "info record" output.
* gdb.btrace/finish.exp: Update "info record" output.
* gdb.btrace/instruction_history.exp: Update "info record" output.
* gdb.btrace/next.exp: Update "info record" output.
* gdb.btrace/nexti.exp: Update "info record" output.
* gdb.btrace/step.exp: Update "info record" output.
* gdb.btrace/stepi.exp: Update "info record" output.
* gdb.btrace/nohist.exp: Update "info record" output.

9 years agobtrace, linux: add perf event buffer abstraction
Markus Metzger [Fri, 17 Jan 2014 13:40:02 +0000 (14:40 +0100)]
btrace, linux: add perf event buffer abstraction

Collect perf event buffer related fields from btrace_target_info into
a new struct perf_event_buffer.  Update functions that operated on the
buffer to take a struct perf_event_buffer pointer rather than a
btrace_target_info pointer.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

* nat/linux-btrace.h (perf_event_buffer): New.
(btrace_target_info) <buffer, size, data_head>: Replace with ...
<bts>: ... this.
* nat/linux-btrace.c (perf_event_header, perf_event_mmap_size)
(perf_event_buffer_size, perf_event_buffer_begin)
(perf_event_buffer_end, linux_btrace_has_changed): Removed.
Updated users.
(perf_event_new_data): New.

9 years agobtrace: add format argument to supports_btrace
Markus Metzger [Fri, 17 Jan 2014 12:29:19 +0000 (13:29 +0100)]
btrace: add format argument to supports_btrace

Add a format argument to the various supports_btrace functions to check
for support of a specific btrace format.  This is to prepare for a new
format.

Removed two redundant calls.  The check will be made in the subsequent
btrace_enable call.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

* btrace.c (btrace_enable): Pass BTRACE_FORMAT_BTS.
* record-btrace.c (record_btrace_open): Remove call to
target_supports_btrace.
* remote.c (remote_supports_btrace): Update parameters.
* target.c (target_supports_btrace): Update parameters.
* target.h (to_supports_btrace, target_supports_btrace): Update
parameters.
* target-delegates.c: Regenerate.
* target-debug.h (target_debug_print_enum_btrace_format): New.
* nat/linux-btrace.c
(kernel_supports_btrace): Rename into ...
(kernel_supports_bts): ... this.  Update users.  Update warning text.
(intel_supports_btrace): Rename into ...
(intel_supports_bts): ... this.  Update users.
(cpu_supports_btrace): Rename into ...
(cpu_supports_bts): ... this.  Update users.
(linux_supports_btrace): Update parameters.  Split into this and ...
(linux_supports_bts): ... this.
* nat/linux-btrace.h (linux_supports_btrace): Update parameters.

gdbserver/
* server.c (handle_btrace_general_set): Remove call to
target_supports_btrace.
(supported_btrace_packets): New.
(handle_query): Call supported_btrace_packets.
* target.h: include btrace-common.h.
(btrace_target_info): Removed.
(supports_btrace, target_supports_btrace): Update parameters.

9 years agobtrace: add struct btrace_data
Markus Metzger [Wed, 13 Nov 2013 14:31:07 +0000 (15:31 +0100)]
btrace: add struct btrace_data

Add a structure to hold the branch trace data and an enum to describe
the format of that data.  So far, only BTS is supported.  Also added
a NONE format to indicate that no branch trace data is available.

This will make it easier to support different branch trace formats in
the future.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

* Makefile.in (SFILES): Add common/btrace-common.c.
(COMMON_OBS): Add common/btrace-common.o.
(btrace-common.o): Add build rules.
* btrace.c (parse_xml_btrace): Update parameters.
(parse_xml_btrace_block): Set format field.
(btrace_add_pc, btrace_fetch): Use struct btrace_data.
(do_btrace_data_cleanup, make_cleanup_btrace_data): New.
(btrace_compute_ftrace): Split into this and...
(btrace_compute_ftrace_bts): ...this.
(btrace_stitch_trace): Split into this and...
(btrace_stitch_bts): ...this.
* btrace.h (parse_xml_btrace): Update parameters.
(make_cleanup_btrace_data): New.
* common/btrace-common.c: New.
* common/btrace-common.h: Include common-defs.h.
(btrace_block_s): Update comment.
(btrace_format): New.
(btrace_format_string): New.
(btrace_data_bts): New.
(btrace_data): New.
(btrace_data_init, btrace_data_fini, btrace_data_empty): New.
* remote.c (remote_read_btrace): Update parameters.
* target.c (target_read_btrace): Update parameters.
* target.h (target_read_btrace): Update parameters.
(target_ops)<to_read_btrace>: Update parameters.
* x86-linux-nat.c (x86_linux_read_btrace): Update parameters.
* target-delegates.c: Regenerate.
* target-debug (target_debug_print_struct_btrace_data_p): New.
* nat/linux-btrace.c (linux_read_btrace): Split into this and...
(linux_read_bts): ...this.
* nat/linux-btrace.h (linux_read_btrace): Update parameters.

gdbserver/
* Makefile.in (SFILES): Add common/btrace-common.c.
(OBS): Add common/btrace-common.o.
(btrace-common.o): Add build rules.
* linux-low: Include btrace-common.h.
(linux_low_read_btrace): Use struct btrace_data.  Call
btrace_data_init and btrace_data_fini.

9 years agoDon't segfault or assert on NULL tls_sec
Alan Modra [Thu, 29 Jan 2015 09:08:28 +0000 (19:38 +1030)]
Don't segfault or assert on NULL tls_sec

Real code won't hit these, but it's possible to contrive a testcase..

* elf32-ppc.c (ppc_elf_relocate_section): Don't segfault on NULL
tls_sec.
* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
* elflink.c (elf_link_output_extsym): Don't assert on NULL tls_sec.

9 years agoelflink.c whitespace, formatting and a plugin symbol tweak
Alan Modra [Thu, 5 Feb 2015 07:00:57 +0000 (17:30 +1030)]
elflink.c whitespace, formatting and a plugin symbol tweak

* elflink.c: Whitespace, formatting fixes.
(elf_link_input_bfd): Clarify comment.
(elf_link_output_extsym): Exclude symbols in linker created
sections when testing for plugin symbols.

9 years agoGold testsuite make clean
Alan Modra [Fri, 6 Feb 2015 07:50:49 +0000 (18:20 +1030)]
Gold testsuite make clean

* testsuite/Makefile.am (MOSTLYCLEANFILES): Add libweak_undef_2.a,
plugin_test_thin.a and defsym_test.
* testsuite/Makefile.in: Regenerate.

9 years agoAutomatic date update in version.in
GDB Administrator [Mon, 9 Feb 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoDon't bfd_check_format if not needed
H.J. Lu [Sun, 8 Feb 2015 23:00:34 +0000 (15:00 -0800)]
Don't bfd_check_format if not needed

When plugin isn't active or there is no thing more to claim, we don't
need to call bfd_check_format.

* ldfile.c (ldfile_try_open_bfd): Don't call bfd_check_format
if plugin isn't active or there is no thing more to claim.

9 years agoCheck format against bfd_object directly
H.J. Lu [Sun, 8 Feb 2015 16:45:23 +0000 (08:45 -0800)]
Check format against bfd_object directly

There is no need to call bfd_check_format.  We should just check format
against bfd_object directly.

* plugin.c (plugin_maybe_claim): Check format against bfd_object
directly.

9 years agoAutomatic date update in version.in
GDB Administrator [Sun, 8 Feb 2015 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoReplace entry->the_bfd with ibfd
H.J. Lu [Sat, 7 Feb 2015 20:50:17 +0000 (12:50 -0800)]
Replace entry->the_bfd with ibfd

* plugin.c (plugin_maybe_claim): Replace entry->the_bfd with
ibfd.

9 years agoUpdate plugin_maybe_claim
H.J. Lu [Sat, 7 Feb 2015 19:01:22 +0000 (11:01 -0800)]
Update plugin_maybe_claim

This patch removes the argument of pointer to struct ld_plugin_input_file.
This is the first step to extract a plugin_object_p out of
plugin_maybe_claim for BFD.

* plugin.c: Include "libbfd.h".
(plugin_strdup): New.
(plugin_maybe_claim): Remove the argument of pointer to struct
ld_plugin_input_file.  Open and handle input entry.
* plugin.h (plugin_maybe_claim): Updated.
* ldfile.c (ldfile_try_open_bfd): Call plugin_maybe_claim directly
without passing a pointer to struct ld_plugin_input_file.
* ldmain.c: Don't include "libbfd.h".
(add_archive_element): Call plugin_maybe_claim directly without
passing a pointer to struct ld_plugin_input_file.

9 years agoIssue relocation in RO section warning for -z text
H.J. Lu [Sat, 7 Feb 2015 13:28:06 +0000 (05:28 -0800)]
Issue relocation in RO section warning for -z text

This patch changes linker to issue a warning for relocation in readonly
section for -z text.

bfd/

PR ld/17935
* elf32-i386.c (elf_i386_readonly_dynrelocs): Also issue a
warning for relocation in readonly section for -z text.
(elf_i386_size_dynamic_sections): Likewise.
* elf64-x86-64.c (elf_x86_64_readonly_dynrelocs): Likewise.
(elf_x86_64_size_dynamic_sections): Likewise.

ld/testsuite/

PR ld/17935
* ld-i386/i386.exp: Run pr17935-1 and pr17935-2.
* ld-x86-64/x86-64.exp: Likewise.

* ld-i386/pr17935-1.d: New file.
* ld-i386/pr17935-1.s: Likewise.
* ld-i386/pr17935-2.d: Likewise.
* ld-i386/pr17935-2.s: Likewise.
* ld-x86-64/pr17935-1.d: Likewise.
* ld-x86-64/pr17935-1.s: Likewise.
* ld-x86-64/pr17935-2.d: Likewise.
* ld-x86-64/pr17935-2.s: Likewise.

9 years agoAutomatic date update in version.in
GDB Administrator [Sat, 7 Feb 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoremote-m32r-sdi.c: Include symfile.h.
Doug Evans [Fri, 6 Feb 2015 20:17:21 +0000 (12:17 -0800)]
remote-m32r-sdi.c: Include symfile.h.

gdb/ChangeLog:

* remote-m32r-sdi.c: Include symfile.h.

9 years agoMove clear_symtab_users, deduce_language_from_filename decls to better place.
Doug Evans [Fri, 6 Feb 2015 19:32:01 +0000 (11:32 -0800)]
Move clear_symtab_users, deduce_language_from_filename decls to better place.

gdb/ChangeLog:

* symtab.h (clear_symtab_users, deduce_language_from_filename): Move
* symfile.h (clear_symtab_users, deduce_language_from_filename): ...
to here.

9 years agoDocument -z text, -z notext and -z textoff
H.J. Lu [Fri, 6 Feb 2015 18:01:35 +0000 (10:01 -0800)]
Document -z text, -z notext and -z textoff

* ld.texinfo: Document -z text, -z notext and -z textoff.
* emultempl/elf32.em (gld${EMULATION_NAME}_list_options): Add
-z text, -z notext and -z textoff.

9 years agoUse mmap and cache the view buffer for get_view
H.J. Lu [Fri, 6 Feb 2015 17:05:35 +0000 (09:05 -0800)]
Use mmap and cache the view buffer for get_view

This patch uses mmap if it is available and works.  It also caches the
view buffer for get_view.

* configure.ac: Add AC_FUNC_MMAP.
* config.in: Regenerated.
* configure: Likewise.
* plugin.c: Include <sys/mman.h>.
(MAP_FAILED): New.  Defined if not defined.
(PROT_READ): Likewise.
(MAP_PRIVATE): Likewise.
(view_buffer_t): New.
(plugin_input_file_t): Add view_buffer.
(get_view): Try mmap and cache the view buffer.
(plugin_maybe_claim): Initialize view_buffer.

9 years agolibthread_db: attaching to terminated/joined threads, debug output
Pedro Alves [Mon, 26 Jan 2015 17:52:25 +0000 (17:52 +0000)]
libthread_db: attaching to terminated/joined threads, debug output

Add a bit of debug output that made things a bit easier for me before.

gdb/
2015-02-06  Pedro Alves  <palves@redhat.com>

* linux-thread-db.c (find_new_threads_callback): Add debug output.

gdb/gdbserver/
2015-02-06  Pedro Alves  <palves@redhat.com>

* thread-db.c (find_new_threads_callback): Add debug output.

9 years ago"enable count" user input error handling (PR gdb/15678)
Simon Marchi [Mon, 2 Feb 2015 19:57:31 +0000 (14:57 -0500)]
"enable count" user input error handling (PR gdb/15678)

Typing "enable count" by itself crashes GDB. Also, if you omit the
breakpoint number/range, the error message is not very clear:

(gdb) enable count 2
warning: bad breakpoint number at or near ''
(gdb) enable count
Segmentation fault (core dumped)

With this patch, the error messages are slightly more helpful:

(gdb) enable count 2
Argument required (one or more breakpoint numbers).
(gdb) enable count
Argument required (hit count).

gdb/ChangeLog:

PR gdb/15678
* breakpoint.c (map_breakpoint_numbers): Check for empty args
string.
(enable_count_command): Check args for NULL value.

gdb/testsuite/ChangeLog:

PR gdb/15678
* gdb.base/ena-dis-br.exp: Test "enable count" for bad user input.

9 years agoFix an invalid memory access triggered by running readelf on a fuzzed binary.
Nick Clifton [Fri, 6 Feb 2015 12:59:25 +0000 (12:59 +0000)]
Fix an invalid memory access triggered by running readelf on a fuzzed binary.

PR binutils/17531
* readelf.c (process_mips_specific): Fail if an option has an
invalid size.

9 years agoProperly mark the plugin symbol undefined
H.J. Lu [Fri, 6 Feb 2015 12:25:36 +0000 (04:25 -0800)]
Properly mark the plugin symbol undefined

Mark the unused plugin defined symbol in elf_link_input_bfd instead of
_bfd_elf_fix_symbol_flags.  Limit the PR ld/12365 test to x86 targets.

bfd/

PR ld/12365
PR ld/14272
* elflink.c (_bfd_elf_fix_symbol_flags): Revert the last change.
(elf_link_input_bfd): Mark the plugin symbol undefined if it is
referenced from a non-IR file.

ld/testsuite/

PR ld/12365
PR ld/14272
* ld-plugin/lto.exp: Run the PR ld/12365 test only for x86 targets.
* ld-plugin/plugin-7.d: Updated.
* ld-plugin/plugin-8.d: Likewise.

9 years agoImprove gdb.threads/attach-many-short-lived-threads.exp timeout handling
Pedro Alves [Fri, 6 Feb 2015 12:24:32 +0000 (13:24 +0100)]
Improve gdb.threads/attach-many-short-lived-threads.exp timeout handling

The buildbot shows that this test is still racy, and occasionally
fails with time outs on some machines.  I'd like to get major issues
with load out of the way.

The test currently exits after 180s, which is just a random number,
that has no relation to what the .exp file considers a time out.  This
commit makes the program wait a bit longer than what the .exp file
considers a time out, and, resets the timer for each iteration.

Tested on x86_64 Fedora 20, native and extended-remote gdbserver.

gdb/testsuite/
2015-02-06  Pedro Alves  <palves@redhat.com>

* gdb.threads/attach-many-short-lived-threads.c (SECONDS): New
macro.
(seconds_left, again): New globals.
(main): Wait seconds_left in a 1-second sleep loop instead of
sleeping 180 seconds.  If 'again' is set, reset the seconds
counter.
* gdb.threads/attach-many-short-lived-threads.exp (test): Set
'again' in the inferior before detaching.  Print the seconds left.
(options): New global.
(top level): Build program with -DTIMEOUT=$timeout.

9 years agoFix memory access violations triggered by processing fuzzed binaries with a 32-bit...
Nick Clifton [Fri, 6 Feb 2015 12:19:20 +0000 (12:19 +0000)]
Fix memory access violations triggered by processing fuzzed binaries with a 32-bit version of readelf, compiled on a 64-bit host.

PR binutils/17531
* dwarf.c (xcmalloc): Fail if the arguments are too big.
(xcrealloc): Likewise.
(xcalloc2): Likewise.

9 years agoFixes illegal memory accesses triggereb by running a 32-bit binary version of objdump...
Nick Clifton [Fri, 6 Feb 2015 11:12:02 +0000 (11:12 +0000)]
Fixes illegal memory accesses triggereb by running a 32-bit binary version of objdump compiled on a 64-bit host.

PR binutils/17512
* dwarf.c (display_debug_frames): Fix range checks to work on
32-bit binaries complied on a 64-bit host.

* peXXigen.c (rsrc_print_resource_entries): Add range check for
addresses that wrap around the address space.
(rsrc_parse_entry): Likewise.

9 years agogdb.base/gdb-sigterm.exp: Fix spurious FAILs
Pedro Alves [Fri, 6 Feb 2015 10:09:42 +0000 (11:09 +0100)]
gdb.base/gdb-sigterm.exp: Fix spurious FAILs

The buildbot shows that some machines FAIL this test frequently.
E.g.: https://sourceware.org/ml/gdb-testers/2015-q1/msg00997.html

If I stress my machine, I can sometimes see it fail too.

Bumping the 200 limit and tweaking the test to show the step count, I
get:

     ...
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 12 times
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 8 times
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 13 times
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 7 times
-->  FAIL: gdb.base/gdb-sigterm.exp: SIGTERM stepped 228 times <--
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 11 times
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 13 times
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 12 times
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 8 times
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 9 times
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 7 times
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 11 times
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 8 times
     ...

Thinking that this might be a problem of SIGTERM reaching GDB, but
then the event loop taking too long to handle it, I hacked GDB to
print a debug log whenever the SIGTERM handler was called, and,
whenever the event loop finally calls the async SIGTERM handler.
Here's what I see:

     infrun:   30011 [Thread 30011],
     infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
     infrun: TARGET_WAITKIND_STOPPED
     infrun: stop_pc = 0x4005de
-->  infrun: got SIGTERM                                       <--
     infrun: stepping inside range [0x4005de-0x4005e0]
     infrun: resume (step=1, signal=GDB_SIGNAL_0), ...
     infrun: prepare_to_wait
-->  infrun: handling async SIGTERM                            <--
     Cannot execute this command while the target is running.
     Use the "interrupt" command to stop the target
     and then try again.
     gdb.base/gdb-sigterm.exp: expect eof #27
     FAIL: gdb.base/gdb-sigterm.exp: SIGTERM stepped 228 times

So, no delay on the GDB side.  It just happens that occasionally it
takes more than 200 single-steps before SIGTERM even reaches GDB.
This just looks like a kernel/scheduling issue --- some extra usage
spike in the system (e.g., an I/O spike) might cause it for me.  For
the build slaves, I'm guessing they're frequently busy enough to trip
on this often.  Particularly more so now that we're having them run
tests in parallel mode.

The fix is to detect failure by timeout instead of counting single
steps.  This should be more reliable.  Indeed for me, after this
commit, I couldn't trigger a FAIL anymore, even after letting the test
run for an hour.

By timeout is also nicer in that a board file for a slow host/target
can increase it (like, e.g., an embedded GNU/Linux board).

Tested on x86_64 Fedora 20, native, gdbserver, and extended-remote
gdbserver.

gdb/testsuite/
2015-02-06  Pedro Alves  <palves@redhat.com>

* gdb.base/gdb-sigterm.c (main): Use the TIMEOUT define to
determine how many seconds to pass to 'alarm'.
* gdb.base/gdb-sigterm.exp (top level): Build program with
-DTIMEOUT=$timeout.
(do_test): Return success/failure indication.  Add more verbose
logging.  Don't fail if 200 single steps are seen.  Instead, fail
when the test times out.
(passes): New global.
(top level): Break the testing loop if testing fails on any
iteration.  Use gdb_assert.

9 years agogas: fix a few omissions in .cfi_label handling
Jan Beulich [Fri, 6 Feb 2015 08:11:09 +0000 (09:11 +0100)]
gas: fix a few omissions in .cfi_label handling

While actually starting to use that new directive, I noticed a few
oversights of the original commit.

gas/
2015-02-06  Jan Beulich  <jbeulich@suse.com>

* dw2gencfi.c (select_cie_for_fde): Also bail on CFI_label.
(cfi_change_reg_numbers): Also do nothing for CFI_label.
(cfi_pseudo_table): Also handle .cfi_label when not supporting
CFI directives.

9 years agoguile/scm-frame.c: Fix spelling errors in a comment.
Doug Evans [Fri, 6 Feb 2015 07:31:05 +0000 (23:31 -0800)]
guile/scm-frame.c: Fix spelling errors in a comment.

gdb/ChangeLog:

* guile/scm-frame.c: Fix spelling errors in a comment.

9 years agoClose fd only if fd != -1
H.J. Lu [Fri, 6 Feb 2015 00:57:09 +0000 (16:57 -0800)]
Close fd only if fd != -1

This patch closes fd only if fd != -1.

* plugin.c (release_input_file): Set fd to -1 after closing it.
(plugin_maybe_claim): Close fd only if fd != -1.

9 years agoAutomatic date update in version.in
GDB Administrator [Fri, 6 Feb 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoAdd plugin_input_file_t
H.J. Lu [Thu, 5 Feb 2015 13:00:52 +0000 (05:00 -0800)]
Add plugin_input_file_t

This patchs adds plugin_input_file_t to implement get_input_file, get_view
and release_input_file.  The maximum memeory overhead per IR input file
are about 40 bytes for plugin_input_file_t plus the memory to store input
IR filename.  According to

http://gcc.gnu.org/wiki/whopr/driver

RELEASE_INPUT_FILE: Function pointer to the linker interface that
releases a file descriptor for a claimed input file. The plug-in library
must call this interface for each file descriptor obtained by the "get
input file" interface. It must release all such file descriptors before
returning from the WPA phase.

However, GCC plug-in library doesn't use the "get input file" interface.
It processed the IR input in the claim file handler.  Since the the file
descriptor opened for the IR input was unused after the claim file
handler returns and GCC plug-in library before GCC 5 doesn't call the
RELEASE_INPUT_FILE function pointer, ld closed the file descriptor to
avoid leaking file descriptor.  But this approach doesn't work with
other plug-in libraries which uses the "get input file", "get view" and
"release input file" interfaces.  To avoid file descriptor leak with
GCC prior to GCC 5 and support other plug-in libraries at the same time,
we close the file descriptor only if the input IR file is a bfd_object
file.  This scheme doesn't work when a plug-in library needs the file
descriptor and its IR is stored in bfd_object file.

PR ld/17878
* plugin.c: Include <errno.h>.
(errno): New.  Declare if needed.
(plugin_input_file_t): New.
(get_input_file): Implemented.
(get_view): Likewise.
(release_input_file): Likewise.
(add_symbols): Updated.
(get_symbols): Likewise.
(plugin_maybe_claim): Allocate a plugin_input_file_t.  Close fd
only for a bfd_object input.

9 years agoDon't refer to optarg in dwarf.c function
Alan Modra [Thu, 5 Feb 2015 06:50:38 +0000 (17:20 +1030)]
Don't refer to optarg in dwarf.c function

This one is passed in optarg as its argument.

PR binutils/17926
* dwarf.c (dwarf_select_sections_by_letters): Don't refer to optarg.

9 years agoAutomatic date update in version.in
GDB Administrator [Thu, 5 Feb 2015 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoFix msp430 build with gcc-5
Alan Modra [Wed, 4 Feb 2015 22:44:56 +0000 (09:14 +1030)]
Fix msp430 build with gcc-5

gcc-5 correctly complains "loop exit may only be reached after
undefined behavior".  I was going to correct this by checking the
index before dereferencing the array rather than the other way around,
but then I noticed it is possible for extract_cmd to write the
terminating zero one past the end of "cmd".  Fixing that means no
index check is needed in md_assemble.

* config/tc-msp430.c (md_assemble): Correct size passed to
extract_cmd.  Remove index check.

9 years agoCombine loop epilogue into main loop body to reduce duplication.
Rafael Ávila de Espíndola [Wed, 4 Feb 2015 22:37:05 +0000 (17:37 -0500)]
Combine loop epilogue into main loop body to reduce duplication.

9 years agoClean up System V IPC objects allocated by test.
Don Breazeal [Wed, 4 Feb 2015 21:15:06 +0000 (13:15 -0800)]
Clean up System V IPC objects allocated by test.

This commit modifies the test program gdb.base/info-os.c so that
it cleans up all allocated System V IPC objects when a fatal
error occurs.  Without this, it was possible for the program
to leave IPC objects on the system, and such objects persist
until they are manually deleted or the system reboots.

I looked at changing the SysV IPC key for allocating the IPC objects to
IPC_PRIVATE.  That would prevent errors due to namespace conflicts with the
key.  However, the test needs to read the actual key number from the 'info
os' command output, and IPC_PRIVATE won't work for that.

gdb/testsuite/ChangeLog:
2015-02-04  Don Breazeal  <donb@codesourcery.com>

        * gdb.base/info-os.c (shmid, semid, msqid): Make variables static
        and initialize them.
        (ipc_cleanup): New function.
        (main): Don't declare shmid, semid, and msqid.  Add a call to
        atexit so that we call ipc_cleanup on exit.

9 years agoFix Python 3 build error on 32-bit hosts
Jan Kratochvil [Wed, 4 Feb 2015 19:31:17 +0000 (20:31 +0100)]
Fix Python 3 build error on 32-bit hosts

on Fedora Rawhide (==22) i686 using --with-python=/usr/bin/python3 one gets:

./python/py-value.c:1696:3: error: initialization from incompatible pointer type [-Werror]
   valpy_hash,            /*tp_hash*/
   ^
./python/py-value.c:1696:3: error: (near initialization for ‘value_object_type.tp_hash’) [-Werror]
cc1: all warnings being treated as errors
Makefile:2628: recipe for target 'py-value.o' failed

This is because in Python 2 tp_hash was:
typedef long (*hashfunc)(PyObject *);
while in Python 3 tp_hash is:
typedef Py_hash_t (*hashfunc)(PyObject *);

Py_hash_t is int for 32-bit hosts and long for 64-bit hosts.  While on 32-bit
hosts sizeof(long)==sizeof(int) still the hashfunc type is formally
incompatible.  As this patch should have no compiled code change it is not
really necessary for gdb-7.9, it would fix there just this non-fatal
compilation warning:
./python/py-value.c:1696:3: warning: initialization from incompatible pointer type
   valpy_hash,            /*tp_hash*/
   ^
./python/py-value.c:1696:3: warning: (near initialization for ‘value_object_type.tp_hash’)

gdb/ChangeLog
2015-02-04  Jan Kratochvil  <jan.kratochvil@redhat.com>

* python/python-internal.h (Py_hash_t): Define it for Python <3.2.
* python/py-value.c (valpy_fetch_lazy): Use it.  Remove cast to the
return type.

9 years ago[AArch64] Add support for Cortex-A72
Jiong Wang [Wed, 4 Feb 2015 19:17:12 +0000 (19:17 +0000)]
[AArch64] Add support for Cortex-A72

2015-02-04  Matthew Wahab  <matthew.wahab@arm.com>

* config/tc-aarch64.c (aarch64_cpus): Add support for Cortex-A72.
* doc/c-aarch64.texi (-mcpu=): Add "cortex-a72".

9 years agoAdd missing ChangeLog entry.
Cary Coutant [Wed, 4 Feb 2015 18:36:07 +0000 (10:36 -0800)]
Add missing ChangeLog entry.

9 years agoLinux: don't resume new LWPs until we've pulled all events out of the kernel
Pedro Alves [Wed, 4 Feb 2015 18:13:28 +0000 (19:13 +0100)]
Linux: don't resume new LWPs until we've pulled all events out of the kernel

Since the starvation avoidance series
(https://sourceware.org/ml/gdb-patches/2014-12/msg00631.html), both
GDB and GDBserver pull all events out of ptrace before deciding which
event to process.

There's one problem with that though.  Because we resume new threads
immediately when we see a PTRACE_EVENT_CLONE event, if the program
constantly spawns threads fast enough, new threads can spawn threads
faster we can pull events out of the kernel, and thus we'd get stuck
in an infinite loop, never returning any event to the core to process.
I occasionally see this happen with the
attach-many-short-lived-threads.exp test against gdbserver.

The fix is to delay resuming new threads until we've pulled out all
events out of the kernel.

On native, we already have the resume_stopped_resumed_lwps function
that knows to resume LWPs that are stopped with no event to report to
the core.  So the patch just adds another use.  GDBserver didn't have
the equivalent yet, so the patch adds one.

Tested on x86_64 Fedora 20, native and gdbserver (remote and
extended-remote).

gdb/gdbserver/ChangeLog:
2015-02-04  Pedro Alves  <palves@redhat.com>

* linux-low.c (handle_extended_wait): Don't resume LWPs here.
(resume_stopped_resumed_lwps): New function.
(linux_wait_for_event_filtered): Use it.

gdb/ChangeLog:
2015-02-04  Pedro Alves  <palves@redhat.com>

* linux-nat.c (handle_extended_wait): Don't resume LWPs here.
(wait_lwp): Don't call wait_lwp if linux_handle_extended_wait
returns true.
(resume_stopped_resumed_lwps): Don't check whether the thread is
marked as executing.
(linux_nat_wait_1): Use resume_stopped_resumed_lwps.

9 years agoResolve forwarding symbols in plugins.
Peter Collingbourne [Wed, 4 Feb 2015 17:47:28 +0000 (09:47 -0800)]
Resolve forwarding symbols in plugins.

2015-02-04  Peter Collingbourne  <pcc@google.com>

* plugin.cc (Pluginobj::get_symbol_resolution_info): Resolve
forwarding symbols when computing symbol resolution info for plugins.

9 years agoFix '--target_board=native-extended-gdbserver/-m32'
Pedro Alves [Wed, 4 Feb 2015 13:53:24 +0000 (14:53 +0100)]
Fix '--target_board=native-extended-gdbserver/-m32'

Running the testsuite with the native-extended-gdbserver.exp board and
passing a variant spec, like

  make check RUNTESTFLAGS="--target_board=native-extended-gdbserver/-m32"

results in dejagnu trying to open a rsh connection to
"native-extended-gdbserver", which of course is wrong.  The point of
this board is running things locally.

The issue is that the native-extended-gdbserver board does not clear
the "isremote" flag properly.

Reported by Sergio at:
  https://sourceware.org/ml/gdb-patches/2015-02/msg00067.html

testsuite/
2015-02-04  Pedro Alves  <palves@redhat.com>

* boards/native-extended-gdbserver.exp: Remove any target variant
specifications from the board name before clearing the isremote
flag from board_info.

9 years agoWarn if core file register section is larger than expected
Andreas Arnez [Thu, 15 Jan 2015 10:20:45 +0000 (10:20 +0000)]
Warn if core file register section is larger than expected

When reading a core file register section which is larger than
expected, emit a warning.  Assume that a register section usually has
exactly the size specified by the regset section iterator.  In some
special cases this assumption is wrong, or at least does not match the
regset supply function's logic.  Thus also add a way to suppress the
warning in those cases, using a new flag REGSET_VARIABLE_SIZE.

gdb/ChangeLog:

* regset.h (struct regset): Add flags field.
(REGSET_VARIABLE_SIZE): New value for a regset's flags field.
* corelow.c (get_core_register_section): Add warning if the size
exceeds the requested size and the regset does not have the
REGSET_VARIABLE_SIZE flag set.
* alphanbsd-tdep.c (alphanbsd_gregset): Add REGSET_VARIABLE_SIZE
flag.
* armbsd-tdep.c (armbsd_gregset): Likewise.
* hppa-hpux-tdep.c (hppa_hpux_regset): Likewise.
* hppaobsd-tdep.c (hppaobsd_gregset): Likewise.
* m68kbsd-tdep.c (m68kbsd_gregset): Likewise.
* mipsnbsd-tdep.c (mipsnbsd_gregset): Likewise.

9 years agox86: Use correct .reg-xstate section size
Andreas Arnez [Wed, 14 Jan 2015 17:53:23 +0000 (17:53 +0000)]
x86: Use correct .reg-xstate section size

When reading the XSAVE extended state from an i386 or AMD64 core file,
the respective regset iterator requests a minimum section size of
zero.  Since the respective regset supply function does not check the
size either, this may lead to accessing data out of range if the
section is too short.

In write mode, the iterator always uses the maximum supported size for
the XSAVE extended state.

This is now changed such that the iterator always requests the
expected size of this section based on xcr0, both for reading and
writing.

gdb/ChangeLog:

* amd64-linux-tdep.c (amd64_linux_iterate_over_regset_sections):
For ".reg-xstate", explicitly specify the requested section size
via X86_XSTATE_SIZE instead of just 0 on input and
X86_XSTATE_MAX_SIZE on output.
* i386-linux-tdep.c (i386_linux_iterate_over_regset_sections):
Likewise.

9 years agoFix internal error when core file section is too big
Andreas Arnez [Wed, 14 Jan 2015 12:01:38 +0000 (12:01 +0000)]
Fix internal error when core file section is too big

As reported in PR 17808, a test case with a forged (invalid) core file
can crash GDB with an assertion failure.  In that particular case the
prstatus of an i386 core file looks like that from an AMD64 core file.
Consequently the respective regset supply function i386_supply_gregset
is invoked with a larger buffer than usual.  But i386_supply_gregset
asserts a specific buffer size, and this assertion fails.

The patch relaxes all buffer size assertions in regset supply
functions such that they merely check for a sufficiently large buffer.
For consistency the regset collect functions are adjusted as well.

gdb/ChangeLog:

PR corefiles/17808:
* gdbarch.sh (iterate_over_regset_sections_cb): Document this
function type, particularly its SIZE parameter.
* gdbarch.h: Regenerate.
* amd64-tdep.c (amd64_supply_fpregset): In gdb_assert, compare
actual against required size using ">=" instead of "==".
(amd64_collect_fpregset): Likewise.
* i386-tdep.c (i386_supply_gregset): Likewise.
(i386_collect_gregset): Likewise.
(i386_supply_fpregset): Likewise.
(i386_collect_fpregset): Likewise.
* mips-linux-tdep.c (mips_supply_gregset_wrapper): Likewise.
(mips_fill_gregset_wrapper): Likewise.
(mips_supply_fpregset_wrapper): Likewise.
(mips_fill_fpregset_wrapper): Likewise.
(mips64_supply_gregset_wrapper): Likewise.
(mips64_fill_gregset_wrapper): Likewise.
(mips64_supply_fpregset_wrapper): Likewise.
(mips64_fill_fpregset_wrapper): Likewise.
* mn10300-linux-tdep.c (am33_supply_gregset_method): Likewise.
(am33_supply_fpregset_method): Likewise.
(am33_collect_gregset_method): Likewise.
(am33_collect_fpregset_method): Likewise.

9 years agoPass -flto-partition=none to the PR ld/12365 test
H.J. Lu [Wed, 4 Feb 2015 12:34:11 +0000 (04:34 -0800)]
Pass -flto-partition=none to the PR ld/12365 test

*  ld-plugin/lto.exp: Pass -flto-partition=none to the PR
ld/12365 test.

9 years agoFix encoding of "addw ax, [hl]" and "subw ax, [hl]".
Nick Clifton [Wed, 4 Feb 2015 12:00:58 +0000 (12:00 +0000)]
Fix encoding of "addw ax, [hl]" and "subw ax, [hl]".

* config/rl78-parse.y (addsubw): Fix encoding of [HL] variant of
these instructions.

9 years agoSpeed up GDB's TUI output
Doug Evans [Wed, 4 Feb 2015 11:27:28 +0000 (12:27 +0100)]
Speed up GDB's TUI output

In the TUI mode, we call wrefresh after outputting every single
character.  This results in the I/O becoming very slow.  Fix this by
delaying refreshing the console window until an explicit flush of
gdb_stdout is requested, or a write to any other (unbuffered) file is
done.

2015-02-04  Doug Evans  <dje@google.com>
    Pedro Alves  <palves@redhat.com>
    Eli Zaretskii  <eliz@gnu.org>

PR tui/17810
* tui/tui-command.c (tui_refresh_cmd_win): New function.
* tui/tui-command.c (tui_refresh_cmd_win): Declare.
* tui/tui-file.c: #include tui/tui-command.h.
(tui_file_fputs): Refresh command window if stream is not gdb_stdout.
(tui_file_flush): Refresh command window if stream is gdb_stdout.
* tui/tui-io.c (tui_puts): Remove calls to wrefresh, fflush.

9 years agoMore fixes for memory access violations triggered by running readelf on fuzzed binaries.
Nick Clifton [Wed, 4 Feb 2015 10:40:05 +0000 (10:40 +0000)]
More fixes for memory access violations triggered by running readelf on fuzzed binaries.

PR binutils/17531
* dwarf.c (read_and_display_attr_value): Test for a block length
being so long that it wraps around to before the start of the block.
(process_debug_info): Test for section_begin wrapping around to
before the start of the section.
(display_gdb_index): Test for num_cus being so large that the end
address wraps around to before the start of the section.
(process_cu_tu_index): Test for j being so large that the section
index pool wraps around to before the start of the section.

9 years agoFix build breakage due to event loop simplification
Pedro Alves [Wed, 4 Feb 2015 10:05:58 +0000 (11:05 +0100)]
Fix build breakage due to event loop simplification

commit 70b66289 (Simplify event-loop core, remove two-step event
processing) causes a build failure when compiling GDB with gcc/-O2:

 gdb/event-loop.c: In function ‘gdb_do_one_event’:
 gdb/event-loop.c:296:10: error: ‘res’ may be used uninitialized in this function
 [-Werror=maybe-uninitialized]
if (res > 0)
   ^

GCC isn't realizing that event_source_head can never be > 2 and that
therefore 'res' is always initialized in all possible paths.  Adding a
default case that internal_error's makes GCC realize that.

Tested on x86_64 Fedora 20.

gdb/ChangeLog:
2015-02-04  Pedro Alves  <palves@redhat.com>

Fix build breakage.
* event-loop.c (gdb_do_one_event): Add default switch case.

9 years agoAdd missing ChangeLog entries.
Cary Coutant [Wed, 4 Feb 2015 04:18:25 +0000 (20:18 -0800)]
Add missing ChangeLog entries.

9 years agoFix a file descriptor leak in gold.
Cary Coutant [Wed, 4 Feb 2015 03:54:57 +0000 (19:54 -0800)]
Fix a file descriptor leak in gold.

When an LTO linker plugin claims an external member of a thin archive, gold
does not properly unlock the file and make its file descriptor available for
reuse. This patch fixes the problem by modifying Archive::include_member to
unlock the object file via an RAII class instance, ensuring that it will be
unlocked no matter what path is taken through the function.

gold/
PR gold/15660
* archive.cc (Thin_archive_object_unlocker): New class.
(Archive::include_member): Unlock external members of thin archives.
* testsuite/Makefile.am (plugin_test_1): Rename .syms files.
(plugin_test_2): Likewise.
(plugin_test_3): Likewise.
(plugin_test_4): Likewise.
(plugin_test_5): Likewise.
(plugin_test_6): Likewise.
(plugin_test_7): Likewise.
(plugin_test_8): Likewise.
(plugin_test_9): Likewise.
(plugin_test_10): Likewise.
(plugin_test_11): New test case.
* testsuite/Makefile.in: Regenerate.
* testsuite/plugin_test.c (claim_file_hook): Check for parallel .syms
file to decide whether to claim file.
(all_symbols_read_hook): Likewise.
* testsuite/plugin_test_1.sh: Adjust expected output.
* testsuite/plugin_test_2.sh: Likewise.
* testsuite/plugin_test_3.sh: Likewise.
* testsuite/plugin_test_6.sh: Likewise.
* testsuite/plugin_test_tls.sh: Likewise.
* testsuite/plugin_test_11.sh: New testcase.

9 years agoAdd extra debugging output for files and descriptors.
Cary Coutant [Mon, 2 Feb 2015 19:47:58 +0000 (11:47 -0800)]
Add extra debugging output for files and descriptors.

gold/
* descriptors.cc (Descriptors::open): Set artificially-low limit for
file descriptors when debugging enabled. Add debug output.
(Descriptors::release): Add debug output.
(Descriptors::close_some_descriptor): Likewise.
(Descriptors::close_all): Likewise.
* fileread.cc (File_read::lock): Likewise.
(File_read::unlock): Likewise.

9 years agoAutomatic date update in version.in
GDB Administrator [Wed, 4 Feb 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoFix memory access violations triggered by running readelf on fuzzed binaries.
Nick Clifton [Tue, 3 Feb 2015 20:42:36 +0000 (20:42 +0000)]
Fix memory access violations triggered by running readelf on fuzzed binaries.

PR binutils/17531
* dwarf.c (process_debug_info): Add range check.
(display_debug_pubnames_worker): Likewise.
(display_gdb_index): Fix range check.
(process_cu_tu_index): Add range check.
* readelf.c (get_data): Change parameter types from size_t to
bfd_size_type.  Add checks for loss of accuracy when casting from
bfd_size_type to size_t.
(get_dynamic_data): Likewise.
(process_section_groups): Limit number of error messages.

9 years agocompile: Filter out -fpreprocessed
Jan Kratochvil [Tue, 3 Feb 2015 17:17:02 +0000 (18:17 +0100)]
compile: Filter out -fpreprocessed

With global system gcc-5.0 if one also installs ccache (needing a different
patch
https://bugzilla.samba.org/show_bug.cgi?id=11060
for -fplugin=libcc1plugin) it breaks as GDB will read from inferior
DW_AT_producer containing -fpreprocessed (due to ccache used to compile the
inferior).
    <c>   DW_AT_producer    : (indirect string, offset: 0x52): GNU C11 5.0.0 20150114 (Red Hat 5.0.0-0.1) -fpreprocessed -mtune=generic -
march=x86-64 -g

It is wrong that gcc puts -fpreprocessed into DW_AT_producer - fixed it in
trunk GCCs:
https://gcc.gnu.org/ml/gcc-patches/2015-01/msg01495.html
But even with that fix there are already built inferiors out there which GDB
could be compatible (for the 'compile' mode) with.

gdb/ChangeLog
2015-02-03  Jan Kratochvil  <jan.kratochvil@redhat.com>

Filter out inferior gcc option -fpreprocessed.
* compile/compile.c (filter_args): New function.
(get_args): Use it.

9 years agoMark the plugin symbol undefined
H.J. Lu [Tue, 3 Feb 2015 17:03:23 +0000 (09:03 -0800)]
Mark the plugin symbol undefined

LTO may optimize out a plugin symbol, which is also referenced by a
non-IR file.  When that happens, we should mark the plugin symbol
undefined.  It isn't the problem since LTO already determined the
symbols in the non-IR file aren't used.

bfd/

PR ld/12365
PR ld/14272
* elflink.c (_bfd_elf_fix_symbol_flags): Mark the plugin symbol
undefined if it is referenced from a non-IR file.

ld/testsuite/

PR ld/12365
* ld-plugin/pr12365a.c: New file.
* ld-plugin/pr12365b.c: Likewise.
* ld-plugin/pr12365c.c: Likewise.

* ld-plugin/lto.exp (lto_link_tests): Prepare for the PR ld/12365
test.
Run the PR ld/12365 test.

9 years agoAdd a testcase for PR ld/14918
H.J. Lu [Tue, 3 Feb 2015 16:24:50 +0000 (08:24 -0800)]
Add a testcase for PR ld/14918

PR ld/14918
* ld-plugin/lto.exp (lto_link_elf_tests): Add PR ld/14918 test.

* ld-plugin/pr14918.c: New file.
* ld-plugin/pr14918.d: Likewise.

9 years agoFix typo in previous delta for mach-o.c.
Nick Clifton [Tue, 3 Feb 2015 15:34:50 +0000 (15:34 +0000)]
Fix typo in previous delta for mach-o.c.

9 years agoSimplify event-loop core, remove two-step event processing
Pedro Alves [Tue, 3 Feb 2015 15:07:54 +0000 (16:07 +0100)]
Simplify event-loop core, remove two-step event processing

Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail.  The problem is that the event
loop's event handling processing is done in two steps:

 #1 - poll all event sources, and push new event objects to the event
  queue, until all event sources are drained.

 #2 - go through the event queue, processing each event object at a
  time.  For each event, call the associated callback, and deletes the
  event object from the queue.

and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet.  To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag.  However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...

One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting.  But then I couldn't find any good reason for the
two-step process in the first place.  It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.

Tested on x86-64 Fedora 20, native and gdbserver.

gdb/
2015-02-03  Pedro Alves  <palves@redhat.com>

* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype.  Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking.  Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int.  Run
event handlers directly instead of queueing events.  Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.

9 years agoWhen disabling target async, remove all target event sources from the event loop
Pedro Alves [Tue, 3 Feb 2015 15:07:54 +0000 (16:07 +0100)]
When disabling target async, remove all target event sources from the event loop

The sigall-reverse.exp test occasionally fails with something like this:

 (gdb) PASS: gdb.reverse/sigall-reverse.exp: send signal TERM
 continue
 Continuing.
 The next instruction is syscall exit_group.  It will make the program exit.  Do you want to stop the program?([y] or n) FAIL: gdb.reverse/sigall-reverse.exp: continue to signal exit (timeout)
 FAIL: gdb.reverse/sigall-reverse.exp: reverse to handler of TERM (timeout)
 FAIL: gdb.reverse/sigall-reverse.exp: reverse to gen_TERM (timeout)

This is another event-loop/async related problem exposed by the patch
that made 'query' use gdb_readline_wrapper (588dcc3edbde19f9).

The problem is that even though gdb_readline_wrapper disables
target-async while the secondary prompt is in progress, the record
target's async event source is left marked.  So when
gdb_readline_wrapper nests an event loop to process input, it may
happen that that event loop ends up processing a target event while
GDB is not really ready for it.  Here's the relevant part of the
backtrace showing the root issue in action:

...
 #14 0x000000000061cb48 in fetch_inferior_event (client_data=0x0) at src/gdb/infrun.c:4158
 #15 0x0000000000642917 in inferior_event_handler (event_type=INF_REG_EVENT, client_data=0x0) at src/gdb/inf-loop.c:57
 #16 0x000000000077ca5c in record_full_async_inferior_event_handler (data=0x0) at src/gdb/record-full.c:791
 #17 0x0000000000640fdf in invoke_async_event_handler (data=...) at src/gdb/event-loop.c:1067
 #18 0x000000000063fb01 in process_event () at src/gdb/event-loop.c:339
 #19 0x000000000063fb2a in gdb_do_one_event () at src/gdb/event-loop.c:360
 #20 0x000000000074d607 in gdb_readline_wrapper (prompt=0x3588f40 "The next instruction is syscall exit_group.  It will make the program exit.  Do you want to stop the program?([y] or n) ") at src/gdb/top.c:842
 #21 0x0000000000750bd9 in defaulted_query (ctlstr=0x8c6588 "The next instruction is syscall exit_group.  It will make the program exit.  Do you want to stop the program?", defchar=121 'y', args=0x7fff70524410) at src/gdb/utils.c:1279
 #22 0x0000000000750e4c in yquery (ctlstr=0x8c6588 "The next instruction is syscall exit_group.  It will make the program exit.  Do you want to stop the program?") at src/gdb/utils.c:1358
 #23 0x00000000004b020e in record_linux_system_call (syscall=gdb_sys_exit_group, regcache=0x3529450, tdep=0xd6c840 <amd64_linux_record_tdep>) at src/gdb/linux-record.c:1933

With my all-stop-on-top-of-non-stop series, I'm also seeing
gdb.server/ext-attach.exp fail occasionally due to the same issue.

The first part of the fix is for target_async implementations to make
sure to remove/unmark all target-related event sources from the event
loop.

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/
2015-02-03  Pedro Alves  <palves@redhat.com>

* event-loop.c (clear_async_event_handler): New function.
* event-loop.h (clear_async_event_handler): New declaration.
* record-btrace.c (record_btrace_async): New function.
(init_record_btrace_ops): Install record_btrace_async.
* record-full.c (record_full_async): New function.
(record_full_resume): Don't mark the async event source here.
(init_record_full_ops): Install record_full_async.
(record_full_core_resume): Don't mark the async event source here.
(init_record_full_core_ops): Install record_full_async.
* remote.c (remote_async): Mark and clear the async stop reply
queue event-loop token as appropriate.

9 years agoFix up some target is-async vs can-async confusions
Pedro Alves [Tue, 3 Feb 2015 15:07:53 +0000 (16:07 +0100)]
Fix up some target is-async vs can-async confusions

In all these cases we're interested in whether the target is currently
async, with its event sources installed in the event loop, not whether
it can async if needed.  Also, I'm not seeing the point of the
target_async call from within linux_nat_wait.  That's normally done on
resume instead, which this target already does.

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/
2015-02-03  Pedro Alves  <palves@redhat.com>

* linux-nat.c (linux_child_follow_fork, linux_nat_wait_1): Use
target_is_async_p instead of target_can_async.
(linux_nat_wait): Use target_is_async_p instead of
target_can_async.  Don't enable async here.
* remote.c (interrupt_query, remote_wait, putpkt_binary): Use
target_is_async_p instead of target_can_async.

9 years agoMore fixes for illegal memory accesses triggered by running objdump on fuzzed binaries.
Nick Clifton [Tue, 3 Feb 2015 14:34:54 +0000 (14:34 +0000)]
More fixes for illegal memory accesses triggered by running objdump on fuzzed binaries.

PR binutils/17512
* objdump.c (display_any_bfd): Fail if archives nest too deeply.

* ecoff.c: Use bfd_alloc2 to allocate space for structure arrays.
(_bfd_ecoff_slurp_symbol_table): Check for a negative symbol
index or an out of range fdr index.
* elf-m10300.c (mn10300_info_to_howto): Fix typo in error message.
* elf32-arc.c (arc_info_to_howto_rel): Likewise.
* elf32-avr.c (avr_info_to_howto_rela): Likewise.
* elf32-cr16.c (elf_cr16_info_to_howto): Likewise.
* elf32-cr16c.c (elf_cr16c_info_to_howto_rel): Likewise.
* elf32-cris.c (cris_info_to_howto_rela): Likewise.
* elf32-crx.c (elf_crx_info_to_howto): Likewise.
* elf32-d10v.c (d10v_info_to_howto_rel): Likewise.
* elf32-d30v.c (d30v_info_to_howto_rel): Likewise.
* elf32-epiphany.c (epiphany_info_to_howto_rela): Likewise.
* elf32-fr30.c (fr30_info_to_howto_rela): Likewise.
* elf32-frv.c (frv_info_to_howto_rela): Likewise.
* elf32-i370.c (i370_elf_info_to_howto): Likewise.
* elf32-i960.c (elf32_i960_info_to_howto_rel): Likewise.
* elf32-ip2k.c (ip2k_info_to_howto_rela): Likewise.
* elf32-iq2000.c (iq2000_info_to_howto_rela): Likewise.
* elf32-lm32.c (lm32_info_to_howto_rela): Likewise.
* elf32-m32c.c (m32c_info_to_howto_rela): Likewise.
* elf32-m32r.c (m32r_info_to_howto_rel): Likewise.
* elf32-m68hc11.c (m68hc11_info_to_howto_rel): Likewise.
* elf32-m68hc12.c (m68hc11_info_to_howto_rel): Likewise.
* elf32-mcore.c (mcore_elf_info_to_howto): Likewise.
* elf32-mep.c (mep_info_to_howto_rela): Likewise.
* elf32-metag.c (metag_info_to_howto_rela): Likewise.
* elf32-microblaze.c (microblaze_elf_info_to_howto): Likewise.
* elf32-moxie.c (moxie_info_to_howto_rela): Likewise.
* elf32-msp430.c (msp430_info_to_howto_rela): Likewise.
* elf32-mt.c (mt_info_to_howto_rela): Likewise.
* elf32-nds32.c (nds32_info_to_howto_rel): Likewise.
* elf32-or1k.c (or1k_info_to_howto_rela): Likewise.
* elf32-pj.c (pj_elf_info_to_howto): Likewise.
* elf32-ppc.c (ppc_elf_info_to_howto): Likewise.
* elf32-rl78.c (rl78_info_to_howto_rela): Likewise.
* elf32-rx.c (rx_info_to_howto_rela): Likewise.
* elf32-sh.c (sh_elf_info_to_howto): Likewise.
* elf32-spu.c (spu_elf_info_to_howto): Likewise.
* elf32-v850.c (v850_elf_perform_relocation): Likewise.
* elf32-vax.c (rtype_to_howto): Likewise.
* elf32-visium.c (visium_info_to_howto_rela): Likewise.
* elf32-xgate.c (xgate_info_to_howto_rel): Likewise.
* elf32-xtensa.c (elf_xtensa_info_to_howto_rela): Likewise.
* elf64-alpha.c (elf64_alpha_info_to_howto): Likewise.
* elf64-mmix.c (mmix_info_to_howto_rela): Likewise.
* mach-o.c: Use bfd_alloc2 to allocate space for structure arrays.
(bfd_mach_o_canonicalize_one_reloc): Fix check on out
of range symbol indicies.
(bfd_mach_o_canonicalize_relocs): Check for out of range alloc.
(bfd_mach_o_canonicalize_dynamic_reloc): Likewise.
(bfd_mach_o_build_dysymtab): Likewise.
(bfd_mach_o_write_symtab_content): Set the string table size to
zero upon error.
(bfd_mach_o_read_symtab_symbols): Reset the nsyms value if the
read fails.
* peXXigen.c (pe_print_edata):  Check for numeric overflow in edt
fields.
* tekhex.c (first_phase): Check for src pointer reaching end of
buffer.

9 years agobfd/elfnn-aarch64.c: Set st_value to zero for undefined symbols
Will Newton [Wed, 28 Jan 2015 10:39:21 +0000 (10:39 +0000)]
bfd/elfnn-aarch64.c: Set st_value to zero for undefined symbols

Unless pointer_equality_needed is set then set st_value to be zero
for undefined symbols.

bfd/ChangeLog:

2015-02-03  Will Newton  <will.newton@linaro.org>

* elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol):
Set st_value to zero for undefined symbols if the reference
is weak or pointer_equality_needed is FALSE.

9 years agobfd/elf32-arm.c: Improve comment in elf32_arm_finish_dynamic_symbol
Will Newton [Tue, 3 Feb 2015 12:51:14 +0000 (12:51 +0000)]
bfd/elf32-arm.c: Improve comment in elf32_arm_finish_dynamic_symbol

Improve the comment discussing why we clear st_value for some
symbols.

bfd/ChangeLog:

2015-02-03  Will Newton  <will.newton@linaro.org>

* elf32-arm.c (elf32_arm_finish_dynamic_symbol): Improve
  comment discussing why we clear st_value for some symbols.

9 years ago[AARCH64] Document .arch and .arch_extension directive
Jiong Wang [Tue, 3 Feb 2015 14:02:24 +0000 (14:02 +0000)]
[AARCH64] Document .arch and .arch_extension directive

2015-02-03  Renlin Li  <renlin.li@arm.com>

  gas/
    * doc/c-aarch64.texi (.arch): Document the directive.
    (.arch_extension): Likewise.

9 years agoFix use of uninitialised memory by the RL78 port of GAS.
Nick Clifton [Tue, 3 Feb 2015 10:10:51 +0000 (10:10 +0000)]
Fix use of uninitialised memory by the RL78 port of GAS.

* config/tc-rl78.h (TC_PARSE_CONS_EXPRESSION): Define.

9 years agoAutomatic date update in version.in
GDB Administrator [Tue, 3 Feb 2015 00:00:13 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agosim: Be sure of calling freeargv() after successfully call buildargv().
Chen Gang [Fri, 30 Jan 2015 22:13:39 +0000 (06:13 +0800)]
sim: Be sure of calling freeargv() after successfully call buildargv().

Or there will be memory leak.

2015-02-02  Chen Gang <gang.chen.5i5j@gmail.com>

* microblaze/interp.c (sim_do_command): Call freeargv() before
return.

9 years agosim: Be sure of calling freeargv() after successfully call buildargv().
Chen Gang [Fri, 30 Jan 2015 22:06:38 +0000 (06:06 +0800)]
sim: Be sure of calling freeargv() after successfully call buildargv().

Or there will be memory leak.

2015-02-02  Chen Gang <gang.chen.5i5j@gmail.com>

* mcore/interp.c (sim_do_command): Call freeargv() before return.

9 years agosim: Call freeargv() when failure occurs
Chen Gang [Fri, 30 Jan 2015 21:58:51 +0000 (05:58 +0800)]
sim: Call freeargv() when failure occurs

After successfully call buildargv(), the code need to be sure of calling
freeargv() in any cases.

2015-02-02  Chen Gang <gang.chen.5i5j@gmail.com>

       * common/sim-options.c (sim_args_command): Call freeargv() when
       failure occurs.

9 years agoFix bug with previous patch for unresolved TLS symbol.
Cary Coutant [Mon, 2 Feb 2015 19:46:45 +0000 (11:46 -0800)]
Fix bug with previous patch for unresolved TLS symbol.

We need to check that the output is executable before assuming that we
can replace the reference with zero.

2015-02-02  Cary Coutant  <ccoutant@google.com>

gold/
* x86_64.cc (Target_x86_64::Relocate::relocate_tls): Check for
executable output file.

9 years agoMention which return values need to be freed in lang_varobj_ops
Simon Marchi [Mon, 2 Feb 2015 18:17:08 +0000 (13:17 -0500)]
Mention which return values need to be freed in lang_varobj_ops

This is the result of a little bit of investigation of the C and Ada
languages, as well as some common sense.

gdb/ChangeLog:

* varobj.h (lang_varobj_ops): Mention which return values need
to be freed.

9 years agoxlc -z relro toc section fixes
Alan Modra [Mon, 2 Feb 2015 11:18:46 +0000 (21:48 +1030)]
xlc -z relro toc section fixes

Moving .toc out of .got caused us to lose toc sorting and multi-toc
support.

* emultempl/ppc64elf.em (toc_section_name): New var.
(ppc_after_open): Set it.
(ppc_before_allocation): Use it.
(gld${EMULATION_NAME}_after_allocation): Here too.

9 years agoNDS32/bfd: Add one more argument to control contents cache.
Kuan-Lin Chen [Mon, 2 Feb 2015 05:42:51 +0000 (13:42 +0800)]
NDS32/bfd: Add one more argument to control contents cache.

The hook bfd_elf32_bfd_get_relocated_section_contents frees contents in
gdb, and it make contents pointer mismatched.

9 years agoAdd missing i18n marker in dwarf2_evaluate_property warning message.
Joel Brobecker [Mon, 2 Feb 2015 03:54:02 +0000 (07:54 +0400)]
Add missing i18n marker in dwarf2_evaluate_property warning message.

gdb/ChangeLog:

        * dwarf2loc.c (dwarf2_evaluate_property): Add i18n marker.

9 years ago[Ada] Do not re-cache symbol-lookup result found from cache lookup.
Joel Brobecker [Mon, 2 Feb 2015 03:28:12 +0000 (07:28 +0400)]
[Ada] Do not re-cache symbol-lookup result found from cache lookup.

When ada-lang.c:ada_lookup_symbol_list_worker finds a match in
the symbol cache, it caches the result again, which is unecessary.
This patch fixes the code to avoid that.

gdb/ChangeLog:

        PR gdb/17856:
        * ada-lang.c (ada_lookup_symbol_list_worker): Do not re-cache
        results found in the cache.

Tested on x86_64-linux, no regression.

9 years ago[Ada] pspace_data->sym_cache is always NULL
Joel Brobecker [Mon, 2 Feb 2015 03:20:58 +0000 (07:20 +0400)]
[Ada] pspace_data->sym_cache is always NULL

The Ada symbol cache has been designed to have one instance of that
of that cache per program space, and for each instance to be created
on-demand. ada_get_symbol_cache is the function responsible for both
lookup and creation on demand.

Unfortunately, ada_get_symbol_cache forgot to store the reference
to newly created caches, thus causing it to:
  - Leak old caches;
  - Allocate a new cache each time the cache is being searched or
    a new entry is to be inserted.

This patch fixes the issue by avoiding the use of the local variable,
which indirectly allowed the bug to happen. We manipulate the reference
in the program-space data instead.

gdb/ChangeLog:

        PR gdb/17854:
        * ada-lang.c (ada_get_symbol_cache): Set pspace_data->sym_cache
        when allocating a new one.

9 years agoAutomatic date update in version.in
GDB Administrator [Mon, 2 Feb 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoremove myself from MAINTAINERS
Tom Tromey [Sun, 1 Feb 2015 18:59:27 +0000 (11:59 -0700)]
remove myself from MAINTAINERS

2015-02-01  Tom Tromey  <tom@tromey.com>

* MAINTAINERS: Remove myself.

9 years agoMove vptr_{fieldno,basetype} out of main_type, and update everything accordingly.
Doug Evans [Sun, 1 Feb 2015 05:40:57 +0000 (21:40 -0800)]
Move vptr_{fieldno,basetype} out of main_type, and update everything accordingly.

Every type has to pay the price in memory usage for their presence.
The proper place for them is in the type_specific field which exists
for this purpose.

gdb/ChangeLog:

* dwarf2read.c (process_structure_scope): Update setting of
TYPE_VPTR_BASETYPE, TYPE_VPTR_FIELDNO.
* gdbtypes.c (internal_type_vptr_fieldno): New function.
(set_type_vptr_fieldno): New function.
(internal_type_vptr_basetype): New function.
(set_type_vptr_basetype): New function.
(get_vptr_fieldno): Update setting of TYPE_VPTR_FIELDNO,
TYPE_VPTR_BASETYPE.
(allocate_cplus_struct_type): Initialize vptr_fieldno.
(recursive_dump_type): Printing of vptr_fieldno, vptr_basetype ...
(print_cplus_stuff): ... moved here.
(copy_type_recursive): Don't copy TYPE_VPTR_BASETYPE.
* gdbtypes.h (struct main_type): Members vptr_fieldno, vptr_basetype
moved to ...
(struct cplus_struct_type): ... here.  All uses updated.
(TYPE_VPTR_FIELDNO, TYPE_VPTR_BASETYPE): Rewrite.
(internal_type_vptr_fieldno, set_type_vptr_fieldno): Declare.
(internal_type_vptr_basetype, set_type_vptr_basetype): Declare.
* stabsread.c (read_tilde_fields): Update setting of
TYPE_VPTR_FIELDNO, TYPE_VPTR_BASETYPE.

gdb/testsuite/ChangeLog:

* gdb.base/maint.exp <maint print type argc>: Update expected output.

9 years agoMove TYPE_SELF_TYPE into new field type_specific.
Doug Evans [Sun, 1 Feb 2015 05:21:01 +0000 (21:21 -0800)]
Move TYPE_SELF_TYPE into new field type_specific.

This patch moves TYPE_SELF_TYPE into new field type_specific.self_type
for MEMBERPTR,METHODPTR types, and into type_specific.func_stuff
for METHODs, and then updates everything to use that.
TYPE_CODE_METHOD could share some things with TYPE_CODE_FUNC
(e.g. TYPE_NO_RETURN) and it seemed simplest to keep them together.

Moving TYPE_SELF_TYPE into type_specific.func_stuff for TYPE_CODE_METHOD
is also nice because when we allocate space for function types we assume
they're TYPE_CODE_FUNCs. If TYPE_CODE_METHODs don't need or use that
space then that space would be wasted, and cleaning that up would involve
more invasive changes.

In order to catch errant uses I've added accessor functions
that do some checking.

One can no longer assign to TYPE_SELF_TYPE like this:

  TYPE_SELF_TYPE (foo) = bar;

One instead has to do:

  set_type_self_type (foo, bar);

But I've left reading of the type to the macro:

  bar = TYPE_SELF_TYPE (foo);

In order to discourage bypassing the TYPE_SELF_TYPE macro
I've named the underlying function that implements it
internal_type_self_type.

While testing this I found the stabs reader leaving methods
as TYPE_CODE_FUNCs, hitting my newly added asserts.
Since the dwarf reader smashes functions to methods (via
smash_to_method) I've done a similar thing for stabs.

gdb/ChangeLog:

* cp-valprint.c (cp_find_class_member): Rename parameter domain_p
to self_p.
(cp_print_class_member): Rename local domain to self_type.
* dwarf2read.c (quirk_gcc_member_function_pointer): Rename local
domain_type to self_type.
(set_die_type) <need_gnat_info>: Handle
TYPE_CODE_METHODPTR, TYPE_CODE_MEMBERPTR, TYPE_CODE_METHOD.
* gdb-gdb.py (StructMainTypePrettyPrinter): Handle
TYPE_SPECIFIC_SELF_TYPE.
* gdbtypes.c (internal_type_self_type): New function.
(set_type_self_type): New function.
(smash_to_memberptr_type): Rename parameter domain to self_type.
Update setting of TYPE_SELF_TYPE.
(smash_to_methodptr_type): Update setting of TYPE_SELF_TYPE.
(smash_to_method_type): Rename parameter domain to self_type.
Update setting of TYPE_SELF_TYPE.
(check_stub_method): Call smash_to_method_type.
(recursive_dump_type): Handle TYPE_SPECIFIC_SELF_TYPE.
(copy_type_recursive): Ditto.
* gdbtypes.h (enum type_specific_kind): New value
TYPE_SPECIFIC_SELF_TYPE.
(struct main_type) <type_specific>: New member self_type.
(struct cplus_struct_type) <fn_field.type>: Update comment.
(TYPE_SELF_TYPE): Rewrite.
(internal_type_self_type, set_type_self_type): Declare.
* gnu-v3-abi.c (gnuv3_print_method_ptr): Rename local domain to
self_type.
(gnuv3_method_ptr_to_value): Rename local domain_type to self_type.
* m2-typeprint.c (m2_range): Replace TYPE_SELF_TYPE with
TYPE_TARGET_TYPE.
* stabsread.c (read_member_functions): Mark methods with
TYPE_CODE_METHOD, not TYPE_CODE_FUNC.  Update setting of
TYPE_SELF_TYPE.

9 years agogdbtypes.h (TYPE_SELF_TYPE): Renamed from TYPE_DOMAIN_TYPE.
Doug Evans [Sun, 1 Feb 2015 05:17:05 +0000 (21:17 -0800)]
gdbtypes.h (TYPE_SELF_TYPE): Renamed from TYPE_DOMAIN_TYPE.

gdb/ChangeLog:

* gdbtypes.h (TYPE_SELF_TYPE): Renamed from TYPE_DOMAIN_TYPE.
All uses updated.

9 years agoBe more strict about what kinds of types can be passed.
Doug Evans [Sun, 1 Feb 2015 05:14:17 +0000 (21:14 -0800)]
Be more strict about what kinds of types can be passed.

gdb/ChangeLog:

* gnu-v3-abi.c (gnuv3_dynamic_class): Assert only passed structs
or unions.  Return zero if union.
(gnuv3_get_vtable): Call check_typedef.  Assert only passed structs.
(gnuv3_rtti_type): Pass already-check_typedef'd value to
gnuv3_get_vtable.
(compute_vtable_size): Assert only passed structs.
(gnuv3_print_vtable): Don't call gnuv3_get_vtable for non-structs.

9 years agogdbtypes.c (copy_type_recursive): Handle all TYPE_SPECIFIC_FIELD kinds.
Doug Evans [Sun, 1 Feb 2015 05:13:02 +0000 (21:13 -0800)]
gdbtypes.c (copy_type_recursive): Handle all TYPE_SPECIFIC_FIELD kinds.

gdb/ChangeLog:

* gdbtypes.c (copy_type_recursive): Handle all TYPE_SPECIFIC_FIELD
kinds.

9 years agoAutomatic date update in version.in
GDB Administrator [Sun, 1 Feb 2015 00:00:13 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoChangeLog entries for max-completions patch.
Gary Benson [Sat, 31 Jan 2015 23:24:26 +0000 (15:24 -0800)]
ChangeLog entries for max-completions patch.

gdb/ChangeLog:

PR cli/9007
PR cli/11920
PR cli/15548
* cli/cli-cmds.c (complete_command): Notify user if max-completions
reached.
* common/common-exceptions.h (enum errors)
<MAX_COMPLETIONS_REACHED_ERROR>: New value.
* completer.h (get_max_completions_reached_message): New declaration.
(max_completions): Likewise.
(completion_tracker_t): New typedef.
(new_completion_tracker): New declaration.
(make_cleanup_free_completion_tracker): Likewise.
(maybe_add_completion_enum): New enum.
(maybe_add_completion): New declaration.
(throw_max_completions_reached_error): Likewise.
* completer.c (max_completions): New global variable.
(new_completion_tracker): New function.
(free_completion_tracker): Likewise.
(make_cleanup_free_completion_tracker): Likewise.
(maybe_add_completions): Likewise.
(throw_max_completions_reached_error): Likewise.
(complete_line): Remove duplicates and limit result to max_completions
entries.
(get_max_completions_reached_message): New function.
(gdb_display_match_list): Handle max_completions.
(_initialize_completer): New declaration and function.
* symtab.c: Include completer.h.
(completion_tracker): New static variable.
(completion_list_add_name): Call maybe_add_completion.
(default_make_symbol_completion_list_break_on_1): Renamed from
default_make_symbol_completion_list_break_on.  Maintain
completion_tracker across calls to completion_list_add_name.
(default_make_symbol_completion_list_break_on): New function.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: Include completer.h.
(tui_old_rl_display_matches_hook): New static global.
(tui_rl_display_match_list): Notify user if max-completions reached.
(tui_setup_io): Save/restore rl_completion_display_matches_hook.
* NEWS (New Options): Mention set/show max-completions.

gdb/doc/ChangeLog:

* gdb.texinfo (Command Completion): Document new
"set/show max-completions" option.

gdb/testsuite/ChangeLog:

* gdb.base/completion.exp: Disable completion limiting for
existing tests.  Add new tests to check completion limiting.
* gdb.linespec/ls-errs.exp: Disable completion limiting.

9 years agoAdd max-completions parameter, and implement tab-completion limiting.
Gary Benson [Sat, 31 Jan 2015 23:07:22 +0000 (15:07 -0800)]
Add max-completions parameter, and implement tab-completion limiting.

This commit adds a new exception, MAX_COMPLETIONS_REACHED_ERROR, to be
thrown whenever the completer has generated too many candidates to
be useful.  A new user-settable variable, "max_completions", is added
to control this behaviour.  A top-level completion limit is added to
complete_line_internal, as the final check to ensure the user never
sees too many completions.  An additional limit is added to
default_make_symbol_completion_list_break_on, to halt time-consuming
symbol table expansions.

gdb/ChangeLog:

PR cli/9007
PR cli/11920
PR cli/15548
* cli/cli-cmds.c (complete_command): Notify user if max-completions
reached.
* common/common-exceptions.h (enum errors)
<MAX_COMPLETIONS_REACHED_ERROR>: New value.
* completer.h (get_max_completions_reached_message): New declaration.
(max_completions): Likewise.
(completion_tracker_t): New typedef.
(new_completion_tracker): New declaration.
(make_cleanup_free_completion_tracker): Likewise.
(maybe_add_completion_enum): New enum.
(maybe_add_completion): New declaration.
(throw_max_completions_reached_error): Likewise.
* completer.c (max_completions): New global variable.
(new_completion_tracker): New function.
(free_completion_tracker): Likewise.
(make_cleanup_free_completion_tracker): Likewise.
(maybe_add_completions): Likewise.
(throw_max_completions_reached_error): Likewise.
(complete_line): Remove duplicates and limit result to max_completions
entries.
(get_max_completions_reached_message): New function.
(gdb_display_match_list): Handle max_completions.
(_initialize_completer): New declaration and function.
* symtab.c: Include completer.h.
(completion_tracker): New static variable.
(completion_list_add_name): Call maybe_add_completion.
(default_make_symbol_completion_list_break_on_1): Renamed from
default_make_symbol_completion_list_break_on.  Maintain
completion_tracker across calls to completion_list_add_name.
(default_make_symbol_completion_list_break_on): New function.
* top.c (init_main): Set rl_completion_display_matches_hook.
* tui/tui-io.c: Include completer.h.
(tui_old_rl_display_matches_hook): New static global.
(tui_rl_display_match_list): Notify user if max-completions reached.
(tui_setup_io): Save/restore rl_completion_display_matches_hook.
* NEWS (New Options): Mention set/show max-completions.

gdb/doc/ChangeLog:

* gdb.texinfo (Command Completion): Document new
"set/show max-completions" option.

gdb/testsuite/ChangeLog:

* gdb.base/completion.exp: Disable completion limiting for
existing tests.  Add new tests to check completion limiting.
* gdb.linespec/ls-errs.exp: Disable completion limiting.