binutils-gdb.git
7 years agoSimplify floatformat_from_type
Ulrich Weigand [Wed, 27 Sep 2017 17:03:36 +0000 (19:03 +0200)]
Simplify floatformat_from_type

For historical reasons, the TYPE_FLOATFORMAT element is still set to hold
an array of two floatformat structs, one for big-endian and the other for
little-endian.  When accessing the element via floatformat_from_type,
the code would check the type's byte order and return the appropriate
floatformat.

However, these days this is quite unnecessary, since the type's byte order
is already known at the time the type is allocated and the floatformat is
installed into TYPE_FLOATFORMAT.  Therefore, we can just install the correct
version here.

Also, moves the (now trivially simple) floatformat_from_type accessor to
gdbtypes.{c,h}, since it doesn't really need to be in doublest.c now.

gdb/ChangeLog
2017-09-27  Ulrich Weigand  <uweigand@de.ibm.com>

* doublest.h (floatformat_from_type): Move to gdbtypes.h.
* doublest.c (floatformat_from_type): Move to gdbtypes.c.

* gdbtypes.h (union type_specific): Make field floatformat hold
just a single struct floatformat, not an array.
(floatformat_from_type): Move here.
* gdbtypes.c (floatformat_from_type): Move here.  Update to
changed TYPE_FLOATFORMAT definition.
(verify_floatformat): Update to changed TYPE_FLOATFORMAT.
(recursive_dump_type): Likewise.
(init_float_type): Install correct floatformat for byte order.
(arch_float_type): Likewise.

7 years agoMake init_type/arch_type take a size in bits
Ulrich Weigand [Wed, 27 Sep 2017 17:02:00 +0000 (19:02 +0200)]
Make init_type/arch_type take a size in bits

This changes the interfaces to init_type and arch_type to take the
type length in bits as input (instead of as bytes).  The routines
assert that the length is a multiple of TARGET_CHAR_BIT.

For consistency, arch_flags_type is changed likewise, so that now
all type creation interfaces always use length in bits.

All callers are updated in the straightforward manner.

The assert actually found a bug in read_range_type, where the
init_integer_type routine was called with a wrong argument (probably
a bug introduced with the conversion to use init_integer_type).

gdb/ChangeLog
2017-09-27  Ulrich Weigand  <uweigand@de.ibm.com>

* gdbtypes.c (init_type): Change incoming argument from
length-in-bytes to length-in-bits.  Assert length is a
multiple of TARGET_CHAR_BITS.
(arch_type, arch_flags_type): Likewise.
(init_integer_type): Update call to init_type.
(init_character_type): Likewise.
(init_boolean_type): Likewise.
(init_float_type): Likewise.
(init_decfloat_type): Likewise.
(init_complex_type): Likewise.
(init_pointer_type): Likewise.
(objfile_type): Likewise.
(arch_integer_type): Update call to arch_type.
(arch_character_type): Likewise.
(arch_boolean_type): Likewise.
(arch_float_type): Likewise.
(arch_decfloat_type): Likewise.
(arch_complex_type): Likewise.
(arch_pointer_type): Likewise.
(gdbtypes_post_init): Likewise.

* dwarf2read.c (dwarf2_init_float_type): Update call to init_type.
(read_base_type): Likewise.
* mdebugread.c (basic_type): Likewise.
* stabsread.c (dbx_init_float_type): Likewise.
(rs6000_builtin_type): Likewise.
(read_range_type): Likewise.  Also, fix call to init_integer_type
with erroneous length argument.

* ada-lang.c (ada_language_arch_info): Update call to arch_type.
* d-lang.c (build_d_types): Likewise.
* f-lang.c (build_fortran_types): Likewise.
* go-lang.c (build_go_types): Likewise.
* opencl-lang.c (build_opencl_types): Likewise.
* jit.c (finalize_symtab): Likewise.
* gnu-v3-abi.c (build_gdb_vtable_type): Likewise.
(build_std_type_info_type): Likewise.
* target-descriptions.c (tdesc_gdb_type): Likewise.  Also,
update call to arch_flags_type.

* linux-tdep.c (linux_get_siginfo_type_with_fields): Update call to
arch_type.
* fbsd-tdep.c (fbsd_get_siginfo_type): Likewise.
* windows-tdep.c (windows_get_tlb_type): Likewise.

* avr-tdep.c (avr_gdbarch_init): Update call to arch_type.
* ft32-tdep.c (ft32_gdbarch_init): Likewise.
* m32c-tdep.c (make_types): Likewise.
* rl78-tdep.c (rl78_gdbarch_init): Likewise.
(rl78_psw_type): Update call to arch_flags_type.
* m68k-tdep.c (m68k_ps_type): Update call to arch_flags_type.
* rx-tdep.c (rx_psw_type): Likewise.
(rx_fpsw_type): Likewise.
* sparc-tdep.c (sparc_psr_type): Likewise.
(sparc_fsr_type): Likewise.
* sparc64-tdep.c (sparc64_pstate_type): Likewise.
(sparc64_ccr_type): Likewise.
(sparc64_fsr_type): Likewise.
(sparc64_fprs_type): Likewise.

7 years agoAdd support for the new names of the RISC-V fmv.x.s and fmv.s.x instructions, vis...
Nick Clifton [Wed, 27 Sep 2017 15:21:36 +0000 (16:21 +0100)]
Add support for the new names of the RISC-V fmv.x.s and fmv.s.x instructions, vis: fmv.x.w and fmv.w.x.

PR 22179
opcodes * riscv-opc.c (riscv_opcodes): Add fmv.x.w and fmv.w.x as the new
names for the fmv.x.s and fmv.s.x instructions respectively.

gas * testsuite/gas/riscv/fmv.x.s: New file: Tests the support for the
renamed fmv.x.s and fmv.s.x instructions.
* testsuite/gas/riscv/fmv.x.d: New file: Test driver.

7 years agoConstify find_command
Tom Tromey [Wed, 13 Sep 2017 03:33:48 +0000 (21:33 -0600)]
Constify find_command

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* findcmd.c (find_command): Constify.

7 years agoConstify some commands in ada-tasks.c
Tom Tromey [Wed, 13 Sep 2017 03:33:21 +0000 (21:33 -0600)]
Constify some commands in ada-tasks.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* ada-tasks.c (task_command_1, task_command): Constify.

7 years agoConstify some commands in symtab.c
Tom Tromey [Wed, 13 Sep 2017 03:32:30 +0000 (21:32 -0600)]
Constify some commands in symtab.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* symtab.c (maintenance_print_symbol_cache)
(maintenance_flush_symbol_cache)
(maintenance_print_symbol_cache_statistics): Constify.

7 years agoConstify some commands in inferior.c
Tom Tromey [Wed, 13 Sep 2017 03:32:18 +0000 (21:32 -0600)]
Constify some commands in inferior.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* inferior.c (detach_inferior_command, kill_inferior_command)
(inferior_command): Constify.

7 years agoConstify some commands in regcache.c
Tom Tromey [Wed, 13 Sep 2017 03:31:41 +0000 (21:31 -0600)]
Constify some commands in regcache.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* regcache.c (regcache_print, maintenance_print_registers)
(maintenance_print_raw_registers)
(maintenance_print_cooked_registers)
(maintenance_print_register_groups)
(maintenance_print_remote_registers): Constify.

7 years agoConstify some commands in printcmd.c
Tom Tromey [Wed, 13 Sep 2017 03:30:50 +0000 (21:30 -0600)]
Constify some commands in printcmd.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* printcmd.c (map_display_numbers, undisplay_command)
(enable_disable_display_command, enable_display_command)
(disable_display_command): Constify.

7 years agoConstify some commands in breakpoint.c
Tom Tromey [Wed, 13 Sep 2017 03:25:07 +0000 (21:25 -0600)]
Constify some commands in breakpoint.c

This also makes delete_command static; but now I wonder if it is used
in Insight and should not be touched.

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* breakpoint.h (delete_command): Don't declare.
* breakpoint.c (delete_command, enable_once_command)
(enable_count_command, enable_delete_command, breakpoint_1)
(maintenance_info_breakpoints, stopin_command, stopat_command)
(delete_command, delete_trace_command, save_breakpoints)
(save_breakpoints_command, save_tracepoints_command): Constify.

7 years agoConstify some commands in macrocmd.c
Tom Tromey [Wed, 13 Sep 2017 03:22:55 +0000 (21:22 -0600)]
Constify some commands in macrocmd.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* macrocmd.c (macro_expand_command, macro_expand_once_command)
(skip_ws, extract_identifier, macro_define_command)
(macro_undef_command, macro_list_command): Constify.

7 years agoConstify some commands in infcmd.c
Tom Tromey [Wed, 13 Sep 2017 03:20:36 +0000 (21:20 -0600)]
Constify some commands in infcmd.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* infcmd.c (environment_info, set_environment_command)
(unset_environment_command, path_info, info_proc_cmd_1)
(info_proc_cmd_mappings, info_proc_cmd_stat)
(info_proc_cmd_status, info_proc_cmd_cwd, info_proc_cmd_cmdline)
(info_proc_cmd_exe, info_proc_cmd_all): Constify.

7 years agoConstify some commands in i386-tdep.c
Tom Tromey [Wed, 13 Sep 2017 03:17:26 +0000 (21:17 -0600)]
Constify some commands in i386-tdep.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* i386-tdep.c (i386_mpx_info_bounds, i386_mpx_set_bounds):
Constify.

7 years agoConstify add_symbol_file_from_memory_command
Tom Tromey [Wed, 13 Sep 2017 03:17:01 +0000 (21:17 -0600)]
Constify add_symbol_file_from_memory_command

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* symfile-mem.c (add_symbol_file_from_memory_command): Constify.

7 years agoConstify demangle_command
Tom Tromey [Wed, 13 Sep 2017 03:16:47 +0000 (21:16 -0600)]
Constify demangle_command

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* demangle.c (demangle_command): Constify.

7 years agoConstify maintenance_info_program_spaces_command
Tom Tromey [Wed, 13 Sep 2017 03:15:46 +0000 (21:15 -0600)]
Constify maintenance_info_program_spaces_command

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* progspace.c (maintenance_info_program_spaces_command):
Constify.

7 years agoConstify some commands in compile.c
Tom Tromey [Wed, 13 Sep 2017 03:14:41 +0000 (21:14 -0600)]
Constify some commands in compile.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* compile/compile.c (check_raw_argument, compile_file_command)
(compile_code_command, compile_print_command): Constify.

7 years agoConstify maintenance_print_reggroups
Tom Tromey [Wed, 13 Sep 2017 03:13:51 +0000 (21:13 -0600)]
Constify maintenance_print_reggroups

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* reggroups.c (maintenance_print_reggroups): Constify.

7 years agoConstify save_gdb_index_command
Tom Tromey [Wed, 13 Sep 2017 03:13:40 +0000 (21:13 -0600)]
Constify save_gdb_index_command

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* dwarf2read.c (save_gdb_index_command): Constify.

7 years agoConstify info_probes_stap_command
Tom Tromey [Wed, 13 Sep 2017 03:13:21 +0000 (21:13 -0600)]
Constify info_probes_stap_command

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* stap-probe.c (info_probes_stap_command): Constify.

7 years agoConstify unset_exec_wrapper_command
Tom Tromey [Wed, 13 Sep 2017 03:13:03 +0000 (21:13 -0600)]
Constify unset_exec_wrapper_command

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* fork-child.c (unset_exec_wrapper_command): Constify.

7 years agoConstify some commands in btrace.c
Tom Tromey [Wed, 13 Sep 2017 03:12:42 +0000 (21:12 -0600)]
Constify some commands in btrace.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* btrace.c (get_uint, get_context_size, no_chunk)
(maint_btrace_packet_history_cmd)
(maint_btrace_clear_packet_history_cmd, maint_btrace_clear_cmd)
(maint_info_btrace_cmd): Constify.

7 years agoConstify delete_bookmark_command
Tom Tromey [Wed, 13 Sep 2017 03:09:47 +0000 (21:09 -0600)]
Constify delete_bookmark_command

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* reverse.c (delete_bookmark_command): Constify.

7 years agoConstify some commands in remote.c
Tom Tromey [Wed, 13 Sep 2017 03:09:35 +0000 (21:09 -0600)]
Constify some commands in remote.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* remote.c (set_memory_packet_size)
(set_memory_write_packet_size, show_memory_write_packet_size)
(set_memory_read_packet_size, show_memory_read_packet_size)
(compare_sections_command, packet_command, remote_put_command)
(remote_get_command, remote_delete_command): Constify.

7 years agoConstify some commands in mips-tdep.c
Tom Tromey [Wed, 13 Sep 2017 03:05:40 +0000 (21:05 -0600)]
Constify some commands in mips-tdep.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* mips-tdep.c (show_mipsfpu_command, set_mipsfpu_single_command)
(set_mipsfpu_double_command, set_mipsfpu_none_command)
(set_mipsfpu_auto_command): Constify.

7 years agoConstify cd_command
Tom Tromey [Wed, 13 Sep 2017 03:02:08 +0000 (21:02 -0600)]
Constify cd_command

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* cli/cli-cmds.h (cd_command): Constify.
* cli/cli-cmds.c (cd_command): Constify.

7 years agoConstify some commands in thread.c
Tom Tromey [Wed, 13 Sep 2017 02:45:21 +0000 (20:45 -0600)]
Constify some commands in thread.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* thread.c (thread_name_command, thread_find_command): Constify.

7 years agoConstify some commands in probes.c
Tom Tromey [Wed, 13 Sep 2017 02:42:32 +0000 (20:42 -0600)]
Constify some commands in probes.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* probe.c (enable_probes_command, disable_probes_command):
Constify.

7 years agoConstify some commands in exec.c, plus symbol_file_command
Tom Tromey [Wed, 13 Sep 2017 00:39:07 +0000 (18:39 -0600)]
Constify some commands in exec.c, plus symbol_file_command

Note that this commit also changes deprecated_file_changed_hook -- not
used in the tree, but Insight will require a (presumably minor)
change.

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* symfile.c (symbol_file_command): Constify.
* gdbcore.h (deprecated_file_changed_hook): Constify.
* exec.c (deprecated_file_changed_hook, exec_file_command)
(file_command): Constify.
* defs.h (symbol_file_command): Constify.

7 years agoConstify some commands in remote-fileio.c
Tom Tromey [Wed, 13 Sep 2017 00:38:19 +0000 (18:38 -0600)]
Constify some commands in remote-fileio.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* remote-fileio.c (set_system_call_allowed)
(show_system_call_allowed): Constify.

7 years agoConstify some commands in tracepoint.c
Tom Tromey [Wed, 13 Sep 2017 00:37:46 +0000 (18:37 -0600)]
Constify some commands in tracepoint.c

In addition to the constification, this fixes a command-repeat bug.

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* tracepoint.c (delete_trace_variable_command)
(tfind_end_command, tfind_start_command, tfind_pc_command)
(tfind_tracepoint_command, tfind_line_command)
(tfind_range_command, tfind_outside_command): Constify.

7 years agoConstify some commands in ax-gdb.c
Tom Tromey [Tue, 12 Sep 2017 21:00:06 +0000 (15:00 -0600)]
Constify some commands in ax-gdb.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* ax-gdb.c (maint_agent_printf_command, agent_command)
(agent_eval_command): Constify.

7 years agoConstify some linespec functions
Tom Tromey [Wed, 13 Sep 2017 00:32:41 +0000 (18:32 -0600)]
Constify some linespec functions

This changes a few linespec functions to work on "const char *" and
then fixes up all the callers.  This allows further constification
elsewhere.

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* tracepoint.c (info_scope_command): Constify.
* python/python.c (gdbpy_decode_line): Constify.
* python/py-breakpoint.c (bppy_init): Constify.
* mi/mi-cmd-break.c (mi_cmd_break_insert_1): Constify.
* location.h: (new_linespec_location)
(string_to_event_location_basic, string_to_event_location):
Constify.
* location.c (new_linespec_location)
(string_to_event_location_basic, string_to_event_location):
Constify.
* linespec.h (decode_line_with_current_source)
(decode_line_with_last_displayed, linespec_lex_to_end): Constify.
* linespec.c (linespec_lex_to_end)
(decode_line_with_current_source)
(decode_line_with_last_displayed): Constify.
* guile/scm-breakpoint.c (gdbscm_register_breakpoint_x):
Constify.
* cli/cli-cmds.c (edit_command, list_command): Constify.
* breakpoint.h (until_break_command, watch_command_wrapper)
(awatch_command_wrapper, rwatch_command_wrapper)
(init_ada_exception_breakpoint): Constify.
* breakpoint.c (break_command_1, dprintf_command)
(break_range_command, watch_command_wrapper)
(rwatch_command_wrapper, awatch_command_wrapper)
(until_break_command, init_ada_exception_breakpoint)
(strace_marker_create_sals_from_location, trace_command)
(ftrace_command, strace_command, struct tracepoint): Constify.
* ax-gdb.c (agent_command_1): Constify.
* ada-lang.c (ada_exception_sal): Constify.

7 years agoConstify some commands in record.c
Tom Tromey [Tue, 12 Sep 2017 20:56:48 +0000 (14:56 -0600)]
Constify some commands in record.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* record.c (cmd_record_delete, cmd_record_stop, cmd_record_save)
(cmd_record_goto_begin, cmd_record_goto_end, get_insn_number)
(get_context_size, no_chunk, get_insn_history_modifiers)
(cmd_record_insn_history, get_call_history_modifiers)
(cmd_record_call_history): Constify.

7 years agoConstify some commands in source.c
Tom Tromey [Tue, 12 Sep 2017 20:45:14 +0000 (14:45 -0600)]
Constify some commands in source.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* source.c (show_substitute_path_command)
(unset_substitute_path_command, set_substitute_path_command):
Constify.

7 years agoConstify commands maint.c, plus maintenance_print_type
Tom Tromey [Tue, 12 Sep 2017 20:40:43 +0000 (14:40 -0600)]
Constify commands maint.c, plus maintenance_print_type

In addition to the constification, this fixes a command-repeat bug.

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* typeprint.c (maintenance_print_type): Constify.
* maint.c (maintenance_dump_me, maintenance_demangle)
(maintenance_time_display, maintenance_info_sections)
(maintenance_print_statistics, maintenance_deprecate)
(maintenance_undeprecate): Constify.
(maintenance_do_deprecate): Constify.  Use std::string.
(maintenance_selftest): Constify.
* gdbtypes.h (maintenance_print_type): Constify.

7 years agoConstify unwind_command
Tom Tromey [Sun, 10 Sep 2017 03:52:56 +0000 (21:52 -0600)]
Constify unwind_command

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* hppa-tdep.c (unwind_command): Constify.

7 years agoConstify some commands in target-descriptions.c
Tom Tromey [Sun, 10 Sep 2017 03:52:05 +0000 (21:52 -0600)]
Constify some commands in target-descriptions.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* target-descriptions.c (unset_tdesc_filename_cmd)
(maint_print_c_tdesc_cmd, maintenance_check_xml_descriptions):
Constify.

7 years agoConstify maintenance_print_dummy_frames
Tom Tromey [Sun, 10 Sep 2017 03:51:39 +0000 (21:51 -0600)]
Constify maintenance_print_dummy_frames

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* dummy-frame.c (maintenance_print_dummy_frames): Constify.

7 years agoConstify some commands in tui.c
Tom Tromey [Sun, 10 Sep 2017 03:51:21 +0000 (21:51 -0600)]
Constify some commands in tui.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* tui/tui.c (tui_enable_command, tui_disable_command): Constify.

7 years agoConstify tui_reg_command
Tom Tromey [Sun, 10 Sep 2017 03:51:10 +0000 (21:51 -0600)]
Constify tui_reg_command

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* tui/tui-regs.c (tui_reg_command): Constify.

7 years agoConstify some commands in skip.c
Tom Tromey [Sun, 10 Sep 2017 03:50:56 +0000 (21:50 -0600)]
Constify some commands in skip.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* skip.c (skip_file_command, skip_function_command)
(skip_enable_command, skip_disable_command, skip_delete_command):
Constify.

7 years agoConstify some commands in record-btrace.c
Tom Tromey [Sun, 10 Sep 2017 03:46:34 +0000 (21:46 -0600)]
Constify some commands in record-btrace.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* record-btrace.c (cmd_record_btrace_bts_start)
(cmd_record_btrace_pt_start): Constify.

7 years agoConstify some commands in symmisc.c
Tom Tromey [Sun, 10 Sep 2017 03:45:47 +0000 (21:45 -0600)]
Constify some commands in symmisc.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* symmisc.c (maintenance_print_symbols)
(maintenance_print_msymbols, maintenance_print_objfiles)
(maintenance_info_symtabs, maintenance_check_symtabs)
(maintenance_expand_symtabs, maintenance_info_line_tables):
Constify.

7 years agoConstify new_ui_command
Tom Tromey [Sun, 10 Sep 2017 03:44:55 +0000 (21:44 -0600)]
Constify new_ui_command

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* top.c (new_ui_command): Constify.

7 years agoConstify some commands in symfile.c
Tom Tromey [Sun, 10 Sep 2017 03:44:31 +0000 (21:44 -0600)]
Constify some commands in symfile.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* symfile.c (add_symbol_file_command)
(remove_symbol_file_command, list_overlays_command)
(map_overlay_command, unmap_overlay_command)
(overlay_auto_command, overlay_manual_command)
(overlay_off_command, overlay_load_command): Constify.

7 years agoConstify some commands in spu-tdep.c
Tom Tromey [Sun, 10 Sep 2017 03:41:50 +0000 (21:41 -0600)]
Constify some commands in spu-tdep.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* spu-tdep.c (info_spu_event_command, info_spu_signal_command)
(info_spu_mailbox_command, info_spu_dma_command)
(info_spu_proxydma_command): Constify.

7 years agoConstify some commands in cli-logging.c
Tom Tromey [Sun, 10 Sep 2017 03:40:53 +0000 (21:40 -0600)]
Constify some commands in cli-logging.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* cli/cli-logging.c (set_logging_on, set_logging_off): Constify.

7 years agoConstify user_defined_command
Tom Tromey [Sun, 10 Sep 2017 03:40:16 +0000 (21:40 -0600)]
Constify user_defined_command

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* cli/cli-script.c (user_defined_command): Constify.

7 years agoConstify commands in cli-dump.c
Tom Tromey [Sun, 10 Sep 2017 03:39:18 +0000 (21:39 -0600)]
Constify commands in cli-dump.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* cli/cli-dump.c (dump_memory_command, dump_value_command)
(dump_srec_memory, dump_srec_value, dump_ihex_memory)
(dump_ihex_value, dump_verilog_memory, dump_verilog_value)
(dump_tekhex_memory, dump_tekhex_value, dump_binary_memory)
(dump_binary_value, append_binary_memory, append_binary_value):
Constify.
(struct dump_context) <func>: Constify.
(add_dump_command): Update.

7 years agoConstify some commands in cli-cmds.c
Tom Tromey [Sun, 10 Sep 2017 03:37:20 +0000 (21:37 -0600)]
Constify some commands in  cli-cmds.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* cli/cli-cmds.c (show_version, show_configuration)
(source_command, show_user): Constify.

7 years agoConstify maintenance_print_target_stack
Tom Tromey [Sun, 10 Sep 2017 03:34:29 +0000 (21:34 -0600)]
Constify maintenance_print_target_stack

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* target.c (maintenance_print_target_stack): Constify.

7 years agoConstify interpreter_exec_cmd
Tom Tromey [Sun, 10 Sep 2017 03:32:11 +0000 (21:32 -0600)]
Constify interpreter_exec_cmd

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* interps.c (interpreter_exec_cmd): Constify.

7 years agoConstify cmd_record_full_restore
Tom Tromey [Sun, 10 Sep 2017 03:31:57 +0000 (21:31 -0600)]
Constify cmd_record_full_restore

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* record-full.c (cmd_record_full_restore): Constify.

7 years agoConstify some functions in memattr.c
Tom Tromey [Sun, 10 Sep 2017 03:30:40 +0000 (21:30 -0600)]
Constify some functions in memattr.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* memattr.c (enable_mem_command, disable_mem_command)
(delete_mem_command): Constify.

7 years agoConstify show_convenience
Tom Tromey [Sun, 10 Sep 2017 03:29:57 +0000 (21:29 -0600)]
Constify show_convenience

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* value.c (show_convenience): Constify.

7 years agoConstify core_file_command
Tom Tromey [Sun, 10 Sep 2017 03:25:44 +0000 (21:25 -0600)]
Constify core_file_command

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* gdbcore.h (core_file_command): Update.
* corefile.c (core_file_command): Constify.

7 years agoConstify maintenance_print_user_registers
Tom Tromey [Sun, 10 Sep 2017 03:24:08 +0000 (21:24 -0600)]
Constify maintenance_print_user_registers

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* user-regs.c (maintenance_print_user_registers): Constify.

7 years agoConstify maintenance_cplus_namespace
Tom Tromey [Sun, 10 Sep 2017 03:23:03 +0000 (21:23 -0600)]
Constify maintenance_cplus_namespace

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* cp-namespace.c (maintenance_cplus_namespace): Constify.

7 years agoConstify first_component_command
Tom Tromey [Sun, 10 Sep 2017 03:22:52 +0000 (21:22 -0600)]
Constify first_component_command

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* cp-support.c (first_component_command): Constify.

7 years agoConstify some functions in psymtab.c
Tom Tromey [Sun, 10 Sep 2017 03:22:28 +0000 (21:22 -0600)]
Constify some functions in psymtab.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* psymtab.c (maintenance_print_psymbols)
(maintenance_info_psymtabs, maintenance_check_psymtabs):
Constify.

7 years agoConstify display_tib
Tom Tromey [Sun, 10 Sep 2017 03:22:05 +0000 (21:22 -0600)]
Constify display_tib

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* windows-tdep.c (display_tib): Constify.

7 years agoConstify two functions in linux-fork.c
Tom Tromey [Sun, 10 Sep 2017 03:00:26 +0000 (21:00 -0600)]
Constify two functions in linux-fork.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* linux-fork.c (delete_checkpoint_command)
(detach_checkpoint_command): Constify.

7 years agoConstify two functions in cp-abi.c
Tom Tromey [Sun, 10 Sep 2017 02:59:50 +0000 (20:59 -0600)]
Constify two functions in cp-abi.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* cp-abi.c (set_cp_abi_cmd, show_cp_abi_cmd): Constify.

7 years agoConstify dump_arc_instruction_command
Tom Tromey [Sun, 10 Sep 2017 02:59:14 +0000 (20:59 -0600)]
Constify dump_arc_instruction_command

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* arc-tdep.c (dump_arc_instruction_command): Constify.

7 years agoConstify two functions in valprint.c
Tom Tromey [Sun, 10 Sep 2017 02:58:42 +0000 (20:58 -0600)]
Constify two functions in valprint.c

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* valprint.c (set_radix, show_radix): Constify.

7 years agoConstify info_probes_dtrace_command
Tom Tromey [Sun, 10 Sep 2017 02:57:56 +0000 (20:57 -0600)]
Constify info_probes_dtrace_command

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* dtrace-probe.c (info_probes_dtrace_command): Constify.

7 years agoConstify not_just_help_class_command
Tom Tromey [Sun, 10 Sep 2017 02:57:10 +0000 (20:57 -0600)]
Constify not_just_help_class_command

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* command.h (not_just_help_class_command): Update.
* cli/cli-decode.h (not_just_help_class_command): Update.
* cli/cli-decode.c (not_just_help_class_command): Constify.

7 years agoConstify add_cmd gdb_bfd.c
Tom Tromey [Sun, 10 Sep 2017 02:55:20 +0000 (20:55 -0600)]
Constify add_cmd gdb_bfd.c

This constifies a command function in gdb_bfd.c.

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* gdb_bfd.c (maintenance_info_bfds): Constify.

7 years agoAdd add_cmd function overloads
Tom Tromey [Sun, 10 Sep 2017 02:51:33 +0000 (20:51 -0600)]
Add add_cmd function overloads

This adds two add_cmd overloads: one whose callback takes a const char *,
and one that doesn't accept a function at all.  The no-function overload
was introduced to avoid ambiguity when NULL was passed as the function.

Long term the goal is for all commands to take const arguments, and
for the non-const variants to be removed entirely.

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* cli/cli-decode.c (add_cmd, set_cmd_cfunc): New function
overloads.
(do_add_cmd): Rename from add_cmd.  Don't call set_cmd_cfunc.
(do_const_cfunc): New function.
(cmd_cfunc_eq): New overload.
(cli_user_command_p): Check do_const_cfunc.
* cli/cli-decode.h (struct cmd_list_element) <function>: New field
const_cfunc.
* command.h (add_cmd): Add const overload and no-function
overload.
(set_cmd_cfunc): Add const overload.
(cmd_const_cfunc_ftype): Declare.
(cmd_cfunc_eq): Add const overload.
* breakpoint.c, cli-cmds.c, cli-dump.c, guile/scm-cmd.c,
python/py-cmd.c, target.c, tracepoint.c: Use no-function add_cmd
overload.

7 years agoAdd support for __VA_OPT__
Tom Tromey [Mon, 18 Sep 2017 02:36:41 +0000 (20:36 -0600)]
Add support for __VA_OPT__

C++2a adds a "__VA_OPT__" feature that can be used to control the
pesky "," emission when the final (variable) argument of a variadic
macro is empty.  This patch implements this feature for gdb.  (A patch
to implement it for gcc is pending.)

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* macroexp.c (get_next_token_for_substitution): New function.
(substitute_args): Call it.  Check for __VA_OPT__.

gdb/testsuite/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

* gdb.base/macscp.exp: Add __VA_OPT__ tests.

7 years agoPrevent an infinite loop in the DWARF parsing code when encountering a CU structure...
Nick Clifton [Wed, 27 Sep 2017 09:42:51 +0000 (10:42 +0100)]
Prevent an infinite loop in the DWARF parsing code when encountering a CU structure with a small negative size.

PR 22219
* dwarf.c (process_debug_info): Add a check for a negative
cu_length field.

7 years agoPR22216, infinite loop in readelf process_symbol_table
Alan Modra [Wed, 27 Sep 2017 05:44:00 +0000 (15:14 +0930)]
PR22216, infinite loop in readelf process_symbol_table

This should make readelf bombproof given a fuzzed DT_HASH.  Also
removes a bogus check that would have resulted in wrong histograms.

PR 22216
* readelf.c (process_symbol_table): Check that DT_HASH symbol
chains are only visited once, and report an error if not.  Display
invalid symbol index if chain is out of range.  Use the same logic
when calculating histograms rather than the PR 17531 fix.  Delete
bogus check that chained index is less than number of buckets.

7 years agonds32: Fix a tautological comparison.
Kuan-Lin Chen [Wed, 27 Sep 2017 05:04:35 +0000 (13:04 +0800)]
nds32: Fix a tautological comparison.

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 27 Sep 2017 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agox86-64: Don't pass output_bfd to info->callbacks->minfo
H.J. Lu [Tue, 26 Sep 2017 21:41:22 +0000 (14:41 -0700)]
x86-64: Don't pass output_bfd to info->callbacks->minfo

Don't pass output_bfd to info->callbacks->minfo when dumping local IFUNC
functions in the map file.

PR ld/22199
* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Don't pass
output_bfd to info->callbacks->minfo.

7 years agodwarf2read: Restrict ICC workaround to ICC<14
Walfred Tedeschi [Tue, 26 Sep 2017 17:26:41 +0000 (18:26 +0100)]
dwarf2read: Restrict ICC workaround to ICC<14

GDB has a workaround for DWARF output by ICC, related to missing
DW_AT_declaration on incomplete types.  The bug was fixed in ICC 14,
so this commit adjusts GDB accordingly.

For the version check, this adds a new parser function for the ICC
producer string.  While at it, it also adds unit tests for the
producer parsing covering the new function and preexisting parsers.

gdb/ChangeLog:
2017-09-26  Walfred Tedeschi  <walfred.tedeschi@intel.com>
    Pedro Alves <palves@redhat.com>

* dwarf2read.c (dwarf2_cu): Remove field producer_is_icc and add
producer_is_icc_lt_14.
(producer_is_icc_lt_14): New function.
(check_producer): Add code for checking version of ICC.
(producer_is_icc): Move to producer.c.
(read_structure_type): Restrict ICC workaround to ICC<14.
* producer.c: Include selftest.h.
(producer_is_icc, producer_parsing_tests, _initialize_producer):
New functions.
* producer.h (producer_is_icc): New declaration.

7 years agoMove GDB producer parsing routines to a separate file
Walfred Tedeschi [Tue, 26 Sep 2017 17:26:41 +0000 (18:26 +0100)]
Move GDB producer parsing routines to a separate file

gdb/ChangeLog:
2017-09-26  Walfred Tedeschi  <walfred.tedeschi@intel.com>

* Makefile.in (SFILES): Add producer.c.
(COMMON_OBS): Add producer.o
* amd64-tdep.c (producer.h): Add new include.
* dwarf2read.c (producer.h): Add new include.
* producer.c: New file.
* producer.h: New file.
* utils.c (producer_is_gcc, producer_is_gcc_ge_4): Move to
producer.c.
* utils.h (producer_is_gcc, producer_is_gcc_ge_4): Move to
producer.h.

7 years agoUse "switch_to_thread" more thoroughly on gdbserver
Sergio Durigan Junior [Fri, 15 Sep 2017 04:27:53 +0000 (00:27 -0400)]
Use "switch_to_thread" more thoroughly on gdbserver

This is a technical debt that I left when I ported "switch_to_thread"
to gdbserver.  It's a simple patch that converts occurences of:

  current_thread = find_thread_ptid (ptid);

to:

  switch_to_thread (ptid);

This patch also converts a simple "if" to a "gdb_assert" on
gdbserver's version of "switch_to_thread":

  gdb_assert (ptid != minus_one_ptid);

This change makes the code more similar to what GDB already does.

Regtested on BuildBot.

gdb/gdbserver/ChangeLog:
2017-09-26  Sergio Durigan Junior  <sergiodj@redhat.com>

* gdbthread.h: Include "common-gdbthread.h".
* inferiors.c (switch_to_thread): Use "gdb_assert" instead of
"if" when validating the ptid.
* remote-utils.c: Include "gdbthread.h".
(prepare_resume_reply): Use "switch_to_thread".
* target.c (done_accessing_memory): Likewise.

7 years agoAllow linking GDB with ncursesw
Matthias Klose [Tue, 26 Sep 2017 15:23:19 +0000 (16:23 +0100)]
Allow linking GDB with ncursesw

Triggered by https://launchpad.net/bugs/1275210, to be able to cope
with UTF-8 characters in gdbtui.

Reference:
  https://sourceware.org/ml/gdb-patches/2017-09/msg00356.html

gdb/ChangeLog:
2017-09-26  Matthias Klose  <doko@ubuntu.com>

* configure.ac: Search ncursesw before ncurses.
Check ncursesw/ncurses.h before ncurses/ncurses.h.
* gdb_curses.h: Include <ncursesw/ncurses.h>
* config.in, configure: Regenerate.

7 years agoFix an assertion failure when parsing a fuzzed x86_64 ELF binary.
Nick Clifton [Tue, 26 Sep 2017 15:03:10 +0000 (16:03 +0100)]
Fix an assertion failure when parsing a fuzzed x86_64 ELF binary.

PR 22172
* elf64-x86-64.c (elf_x86_64_info_to_howto): Do not trigger an
assertion failure if elf_x86_64_rtype_to_howto has already issued
an error message.

7 years agoFix incorrect register mask.
Cary Coutant [Tue, 26 Sep 2017 14:33:04 +0000 (07:33 -0700)]
Fix incorrect register mask.

PR gold/22213
* sparc.cc (Target_sparc): Fix incorrect register mask.

7 years agoTidy reading data in read_formatted_entries
Alan Modra [Tue, 26 Sep 2017 13:50:06 +0000 (23:20 +0930)]
Tidy reading data in read_formatted_entries

Using read_attribute_value accomplishes two things: It checks for
unexpected formats, and ensures the buffer pointer always increments.

PR 22210
* dwarf2.c (read_formatted_entries): Use read_attribute_value to
read data.

7 years agoAvoid needless resource usage when processing a corrupt DWARF directory or file name...
Nick Clifton [Tue, 26 Sep 2017 13:37:47 +0000 (14:37 +0100)]
Avoid needless resource usage when processing a corrupt DWARF directory or file name table.

PR 22210
* dwarf2.c (read_formatted_entries): Fail early if we know that
the loop parsing data entries will overflow the end of the
section.

7 years agoRemove support for Solaris < 10 (PR gdb/22185)
Rainer Orth [Tue, 26 Sep 2017 13:19:10 +0000 (15:19 +0200)]
Remove support for Solaris < 10 (PR gdb/22185)

Given that GCC has obsoleted/removed support for Solaris 9 in GCC 4.9/5 in 2013:

    https://gcc.gnu.org/gcc-4.9/changes.html
    https://gcc.gnu.org/ml/gcc-patches/2013-05/msg00728.html

and the last gdb version that can be compiled with gcc 4.9 is 7.12.1 only when
configured with --disable-build-with-cxx, it's time to obsolete/remove support
for Solaris < 10.

This patch does this, simplifying configure.nat along the way (only a single
sol2 configuration with variants for i386 and sparc).

Some configure checks for older Solaris versions can go, too, and the check
for libthread_db.so.1 removed:

* Since Solaris 10, dlopen has moved to libc and libdl.so is just a
  filter on ld.so.1, so no need to check.

* $RDYNAMIC is already handled above (and is a no-op with Solaris ld
  anyway).

Both proc-service.c and sol-thread.c lose support for (Solaris-only)
PROC_SERVICE_IS_OLD.

The attached revised patch has been tested on sparcv9-sun-solaris2.10,
sparcv9-sun-solaris2.11.4, amd64-pc-solaris2.10, amd64-pc-solaris2.11.4,
and x86_64-pc-linux-gnu.

I've also started an i386-pc-solaris2.9 build to check that it really
stops as expected.

PR gdb/22185
* configure.host <*-*-solaris2.[01], *-*-solaris2.[2-9]*>: Mark as
obsolete.
Use gdb_host sol2 for i[34567]86-*-solaris2*, x86_64-*-solaris2*.
Remove i386sol2 support.
* configure.nat <i386sol2>: Remove.
<sol2-64>: Fold into ...
<sol2>: ... this.
Move common settings to default section.
Add sol-thread.o.
* configure.tgt <i[34567]86-*-solaris2.1[0-9]*,
x86_64-*-solaris2.1[0-9]*>: Rename to ...
<i[34567]86-*-solaris2*, x86_64-*-solaris2*>: ... this.
<i[34567]86-*-solaris*>: Remove.
<sparc-*-solaris2.[0-6], sparc-*-solaris2.[0-6].*>: Remove.

* configure.ac: Remove wctype in libw check.
(_MSE_INT_H): Don't define on Solaris 7-9.
<solaris*>: Remove libthread_db.so.1 check.
* configure: Regenerate.
* config.in: Regenerate.

* proc-service.c: Remove PROC_SERVICE_IS_OLD handling.
(gdb_ps_prochandle_t, gdb_ps_read_buf_t, gdb_ps_write_buf_t)
(gdb_ps_size_t): Remove.
Use base types in users.
* sol-thread.c: Likewise, also for gdb_ps_addr_t.

* NEWS (Changes since GDB 8.0): Document Solaris 2.0-9 removal.

7 years agoFix gdb 8.1 Solaris/SPARC compilation (PR build/22206)
Rainer Orth [Tue, 26 Sep 2017 12:58:53 +0000 (14:58 +0200)]
Fix gdb 8.1 Solaris/SPARC compilation (PR build/22206)

When testing my Solaris < 10 removal patch on Solaris/SPARC, I found
that gdb mainline is currently broken there due to the recent SPARC M7
ADI patches:

/vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c:1876:0: error: "PSR_ICC" redefined [-Werror]
 #define PSR_ICC  0x00f00000
 ^
In file included from /usr/include/v7/sys/privregs.h:24:0,
                 from /usr/include/sys/regset.h:420,
                 from /usr/include/sys/ucontext.h:21,
                 from /usr/include/sys/signal.h:231,
                 from /usr/include/sys/procset.h:23,
                 from /usr/include/sys/wait.h:25,
                 from /usr/include/stdlib.h:21,
                 from build-gnulib/import/stdlib.h:36,
                 from /vol/src/gnu/gdb/gdb/local/gdb/common/common-defs.h:53,
                 from /vol/src/gnu/gdb/gdb/local/gdb/defs.h:28,
                 from /vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c:20:
/usr/include/v7/sys/psr.h:35:0: note: this is the location of the previous definition
 #define PSR_ICC  0x00F00000 /* integer condition codes */
 ^
/vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c:1878:0: error: "PSR_IMPL" redefined [-Werror]
 #define PSR_IMPL 0xf0000000
 ^
In file included from /usr/include/v7/sys/privregs.h:24:0,
                 from /usr/include/sys/regset.h:420,
                 from /usr/include/sys/ucontext.h:21,
                 from /usr/include/sys/signal.h:231,
                 from /usr/include/sys/procset.h:23,
                 from /usr/include/sys/wait.h:25,
                 from /usr/include/stdlib.h:21,
                 from build-gnulib/import/stdlib.h:36,
                 from /vol/src/gnu/gdb/gdb/local/gdb/common/common-defs.h:53,
                 from /vol/src/gnu/gdb/gdb/local/gdb/defs.h:28,
                 from /vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c:20:
/usr/include/v7/sys/psr.h:41:0: note: this is the location of the previous definition
 #define PSR_IMPL 0xF0000000 /* implementation */
 ^

Comparing Solaris 11.4 <v7/sys/psr.h> and sparc64-tdep.c, there are more
inconsistencies:

<v7/sys/psr.h>:

#define PSR_S 0x00000080 /* supervisor mode */
#define PSR_ICC 0x00F00000 /* integer condition codes */
#define PSR_VER 0x0F000000 /* mask version */
#define PSR_IMPL 0xF0000000 /* implementation */
#define PSR_RSV 0x000FC000 /* reserved */

sparc64-tdep.c:

#define PSR_S 0x00000080
#define PSR_ICC 0x00f00000
#define PSR_VERS 0x0f000000
#define PSR_IMPL 0xf0000000
#define PSR_V8PLUS 0xff000000
#define PSR_XCC 0x000f0000

Apart from the capitalization differences that trip g++, the names
differ (PSR_VER vs. PSR_VERS), PSR_XCC is included in Solaris' PSR_RSV,
and there's no PSR_V8PLUS on Solaris either.

/vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c: In function `int adi_tag_fd()':
/vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c:296:63: error: format `%d' expects argument of type `int', but argument 4 has type `pid_t {aka long int}' [-Werror=format=]
   snprintf (cl_name, sizeof(cl_name), "/proc/%d/adi/tags", pid);
                                                               ^
/vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c: In function `bool adi_is_addr_mapped(CORE_ADDR, std::size_t)':
/vol/src/gnu/gdb/gdb/local/gdb/sparc64-tdep.c:314:64: error: format `%d' expects argument of type `int', but argument 4 has type `pid_t {aka long int}' [-Werror=format=]
   snprintf (filename, sizeof filename, "/proc/%d/adi/maps", pid);
                                                                ^

You cannot always print a pid_t, which can be either int or long on
Solaris, as an int.

Obviously, the ADI patch which modifies code shared between all SPARC
targets, hasn't been tested on anything but Linux/SPARC.

The patch below includes the minimal fixes necessary to unbreak the
Solaris/SPARC build.

However, as detailed in the PR, there's more breakage here: apart from
not bothering to implement ADI support on Solaris, the code contains
several more changes to shared/common SPARC code that are simply wrong
on anything but Linux/SPARC.

The patch was tested on sparcv9-sun-solaris2.10 and
sparcv9-sun-solaris2.11.4 (build and gdb/gdb gdb/gdb smoke test only).

PR build/22206
* sparc64-tdep.c (adi_tag_fd): Print pid as long.
(adi_is_addr_mapped): Likewise.
(PSR_ICC): Don't redefine.
(PSR_IMPL): Likewise.

7 years agoPR22209, invalid memory read in find_abstract_instance_name
Alan Modra [Tue, 26 Sep 2017 12:17:24 +0000 (21:47 +0930)]
PR22209, invalid memory read in find_abstract_instance_name

This patch adds bounds checking for DW_FORM_ref_addr die refs, and
calculates them relative to the first .debug_info section.  See the
big comment for why calculating relative to the current .debug_info
section was wrong for relocatable object files.

PR 22209
* dwarf2.c (struct comp_unit): Delete sec_info_ptr field.
(find_abstract_instance_name): Calculate DW_FORM_ref_addr relative
to stash->info_ptr_memory, and check die_ref is within that memory.
Set info_ptr_end correctly when another CU is refd.  Check die_ref
for DW_FORM_ref4 etc. is within CU.

7 years agoFix address violations when parsing a corrupt DWARF linenumber table.
Nick Clifton [Tue, 26 Sep 2017 11:14:42 +0000 (12:14 +0100)]
Fix address violations when parsing a corrupt DWARF linenumber table.

PR 22154
* dwarf.c (get_line_filename_and_dirname): Add extra checks for
buffer overruns.

7 years agoLD/testsuite: Fix undefined symbol tests for MIPS and S+core targets
Maciej W. Rozycki [Tue, 26 Sep 2017 11:09:50 +0000 (12:09 +0100)]
LD/testsuite: Fix undefined symbol tests for MIPS and S+core targets

Fix commit 647d4de92e06 ("Test undefined symbols in shared libraries")
and remove "undefined symbols in shared lib (dyn reloc)" test failures
for MIPS and S+core targets.

This test assumes 3 dynamic relocation entries, however the respective
psABIs define an extra single dummy *_NONE relocation at the beginning
of the dynamic relocation table, which results in test output like the
following for MIPS:

Relocation section '.rel.dyn' at offset 0x33c contains 4 entries:
 Offset     Info    Type            Sym.Value  Sym. Name
00000000  00000000 R_MIPS_NONE
00010364  00000903 R_MIPS_REL32      00000000   undef_pfun
00010360  00000a03 R_MIPS_REL32      00000000   undef_data
00010368  00000b03 R_MIPS_REL32      00000000   undef_notype

and S+core:

Relocation section '.rel.dyn' at offset 0x274 contains 4 entries:
 Offset     Info    Type            Sym.Value  Sym. Name
00000000  00000000 R_SCORE_NONE
5ffe0464  00000e12 R_SCORE_REL32     00000000   undef_notype
5ffe045c  00000f12 R_SCORE_REL32     00000000   undef_data
5ffe0460  00001012 R_SCORE_REL32     00000000   undef_pfun

targets respectively, and also n64 MIPS targets pad relocation triplets
they use with extra *_NONE relocations, resulting in output like this:

Relocation section '.rel.dyn' at offset 0x4c0 contains 4 entries:
  Offset          Info           Type           Sym. Value    Sym. Name
000000000000  000000000000 R_MIPS_NONE
                    Type2: R_MIPS_NONE
                    Type3: R_MIPS_NONE
000000010508  000900001203 R_MIPS_REL32      0000000000000000 undef_pfun
                    Type2: R_MIPS_64
                    Type3: R_MIPS_NONE
000000010500  000a00001203 R_MIPS_REL32      0000000000000000 undef_data
                    Type2: R_MIPS_64
                    Type3: R_MIPS_NONE
000000010510  000b00001203 R_MIPS_REL32      0000000000000000 undef_notype
                    Type2: R_MIPS_64
                    Type3: R_MIPS_NONE

Expect the right number of *_NONE relocations then, and adjust the total
number of relocations expected accordingly.

ld/
* testsuite/ld-undefined/undefined.exp: Correct the dyn reloc
test for MIPS and S+core targets.

7 years agoAllow the macw and macl instructions to be used on CPUs that have emacs support.
Nick Clifton [Tue, 26 Sep 2017 09:33:32 +0000 (10:33 +0100)]
Allow the macw and macl instructions to be used on CPUs that have emacs support.

From PR 22123:

  The common opcodes of emac and mac seem to be only implemented for mac.

  To reproduce:

    echo "macw %d3l,%a0l" > /tmp/dummy.S
    m68k-unknown-elf-as -m5208  /tmp/dummy.S

  Outputs something like:
    /tmp/dummy.S: Assembler messages:
    /tmp/dummy.S:1: Error: operands mismatch -- statement `macw %d3l,%a0l' ignored

  This behavior occurs only if the CPU supports only emac but not explicitly mac (but emac is a superset of mac).

7 years agoAdd README file for creating binutils releases
Nick Clifton [Tue, 26 Sep 2017 09:07:23 +0000 (10:07 +0100)]
Add README file for creating binutils releases

7 years agoFix FAILs in compare-sections.exp
Thomas Preud'homme [Tue, 26 Sep 2017 08:57:18 +0000 (09:57 +0100)]
Fix FAILs in compare-sections.exp

compare-sections.exp has two cases that are not handled appropriately:
1) value read with msb set
2) error while patching that section

This patch adapts the "get value of read-only section" test to print
the value as an unsigned integer to fix 1) and test for the error
message to not set the written variable if read-only section cannot
be written to so as to solve 2).

2017-09-26  Thomas Preud'homme  <thomas.preudhomme@arm.com>
    Pedro Alves  <palves@redhat.com>

gdb/testsuite/
* gdb.base/compare-sections.exp (get value of read-only section): Read
as unsigned value.
(corrupt read-only section): Likewise and don't set written if patching
failed.

7 years agoPR21732, String-concatenated message can not be translated
Alan Modra [Tue, 26 Sep 2017 01:58:04 +0000 (11:28 +0930)]
PR21732, String-concatenated message can not be translated

Preprocessor tokens like DWARF_VMA_FMT and BFD_VMA_FMT are not
understood by gettext, and cause the translation string to be
truncated.  Even if it were not truncated, we wouldn't want a value
that changes depending on host or configure options to be put in a
translation string.

PR 21732
* dwarf.c (READ_ULEB): Don't use DWARF_VMA_FMT in translated string.
(READ_SLEB): Likewise.
* readelf.c (bfd_vmatoa): New function.
(get_data, get_dynamic_data): Use it for printing error messages.

7 years agoRemove the last cleanup from regcache.c
Tom Tromey [Sat, 23 Sep 2017 21:54:36 +0000 (15:54 -0600)]
Remove the last cleanup from regcache.c

This removes the last cleanup from regcache.c by changing one function
to use std::string.

gdb/ChangeLog
2017-09-25  Tom Tromey  <tom@tromey.com>

* regcache.c (regcache::dump): Use string_printf.

7 years agoRemove make_cleanup_regcache_invalidate
Tom Tromey [Sat, 23 Sep 2017 21:53:30 +0000 (15:53 -0600)]
Remove make_cleanup_regcache_invalidate

This removes make_cleanup_regcache_invalidate in favor of a simple
RAII class that handles register invalidation.

gdb/ChangeLog
2017-09-25  Tom Tromey  <tom@tromey.com>

* regcache.c (class regcache_invalidator): New.
(struct register_to_invalidate): Remove.
(make_cleanup_regcache_invalidate): Remove.
(regcache::raw_write): Use regcache_invalidator.

7 years agoRemove make_cleanup_regcache_xfree
Tom Tromey [Sat, 23 Sep 2017 21:34:30 +0000 (15:34 -0600)]
Remove make_cleanup_regcache_xfree

This removes make_cleanup_regcache_xfree in favor of using
std::unique_ptr as the return type of frame_save_as_regcache.

gdb/ChangeLog
2017-09-25  Tom Tromey  <tom@tromey.com>

* spu-tdep.c (spu2ppu_sniffer): Update.
* regcache.h (make_cleanup_regcache_xfree): Don't declare.
* regcache.c (do_regcache_xfree, make_cleanup_regcache_xfree):
Remove.
* ppc-linux-tdep.c (ppu2spu_sniffer): Update.
* mi/mi-main.c (mi_cmd_data_list_changed_registers): Update.
* frame.h (frame_save_as_regcache): Return std::unique_ptr.
* frame.c (frame_save_as_regcache): Return std::unique_ptr.
(frame_pop): Update.

7 years agoRemove regcache_xfree
Tom Tromey [Sat, 23 Sep 2017 20:41:07 +0000 (14:41 -0600)]
Remove regcache_xfree

This removes regcache_xfree in favor of plain "delete".

gdb/ChangeLog
2017-09-25  Tom Tromey  <tom@tromey.com>

* spu-tdep.c (spu2ppu_dealloc_cache): Use delete.
* regcache.h (regcache_xfree): Don't declare.
* regcache.c (regcache_xfree): Remove.
(do_regcache_xfree): Use delete.
* ppc-linux-tdep.c (ppu2spu_dealloc_cache): Use delete.
* linux-fork.c (free_fork): Use delete.
(fork_save_infrun_state): Likewise.
* jit.c (jit_dealloc_cache): Use delete.
* infrun.c (discard_infcall_suspend_state): Use delete.

7 years agoRemove regcache_xmalloc
Tom Tromey [Sat, 23 Sep 2017 20:39:56 +0000 (14:39 -0600)]
Remove regcache_xmalloc

This patch removes regcache_xmalloc in favor of plain "new".

gdb/ChangeLog
2017-09-25  Tom Tromey  <tom@tromey.com>

* regcache.h (regcache_xmalloc): Don't declare.
(regcache_raw_set_cached_value): Update comment.
* regcache.c (regcache_xmalloc): Remove.
* ppc-linux-tdep.c (ppu2spu_sniffer): Use new.
* jit.c (jit_frame_sniffer): Use new.
* frame.c (frame_save_as_regcache): Use new.

7 years agoPR22205, .debug_line file table NULL filename
Alan Modra [Tue, 26 Sep 2017 00:08:26 +0000 (09:38 +0930)]
PR22205, .debug_line file table NULL filename

The PR22200 fuzzer testcase found one way to put NULLs into .debug_line
file tables.  PR22205 finds another.  This patch gives up on trying to
prevent NULL files in the file table and instead just copes with them.
Arguably, this is better than giving up and showing no info from
.debug_line.  I've also fixed a case where the fairly recent DWARF5
support in handling broken DWARG could result in uninitialized memory
reads, and made a small tidy.

PR 22205
* dwarf2.c (concat_filename): Return "<unknown>" on NULL filename.
(read_formatted_entries): Init "fe".
(decode_line_info <DW_LNE_define_file>): Use line_info_add_file_name.

7 years agoPR22204, Lack of DW_LNE_end_sequence causes "infinite" loop
Alan Modra [Tue, 26 Sep 2017 00:02:18 +0000 (09:32 +0930)]
PR22204, Lack of DW_LNE_end_sequence causes "infinite" loop

PR 22204
* dwarf2.c (decode_line_info): Ensure line_ptr stays within
bounds in inner loop.