summaryrefslogtreecommitdiff
path: root/gdb/value.c
AgeCommit message (Collapse)Author
2018-01-02Update copyright year range in all GDB filesJoel Brobecker
gdb/ChangeLog: Update copyright year range in all GDB files
2017-11-24Change value_contents_eq return boolYao Qi
This patch changes value_contents_eq return type from int to bool. gdb: 2017-11-24 Yao Qi <yao.qi@linaro.org> * mi/mi-main.c (register_changed_p): Update. * value.c (value_contents_bits_eq): Change return type. (value_contents_eq): Likewise. * value.h: Update comments.
2017-11-07Constify add_setshow_*Tom Tromey
This constifies the add_setshow_* family of functions, and then fixes up the fallout. The bulk of this patch was written by script. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * ada-lang.c (catch_ada_exception_command): Constify. (catch_assert_command): Constify. * break-catch-throw.c (catch_catch_command, catch_throw_command) (catch_rethrow_command): Constify. (catch_exception_command_1): Constify. * breakpoint.h (add_catch_command): Constify. * break-catch-syscall.c (catch_syscall_command_1): Constify. (catch_syscall_split_args): Constify. * break-catch-sig.c (catch_signal_command): Constify. (catch_signal_split_args): Constify. * cli/cli-decode.h (struct cmd_list_element) <function>: Use cmd_const_sfunc_ftype. * cli/cli-decode.c (add_setshow_cmd_full): Constify. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, struct cmd_list_element) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd): Constify. (set_cmd_sfunc): Constify. (empty_sfunc): Constify. * command.h (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Constify. (set_cmd_sfunc): Constify. (cmd_sfunc_ftype): Remove. * compile/compile.c (set_compile_args): Constify. * infrun.c (set_disable_randomization): Constify. * infcmd.c (set_args_command, set_cwd_command): Constify. * breakpoint.c (set_condition_evaluation_mode): Constify. (add_catch_command): Constify. (catch_fork_command_1, catch_exec_command_1) (catch_load_command_1, catch_unload_command_1): Constify. (catch_load_or_unload): Constify. * guile/scm-param.c (pascm_set_func): Constify. (add_setshow_generic): Constify. * python/py-param.c (get_set_value): Constify. * top.h (set_verbose): Constify. * tui/tui-win.c (tui_set_var_cmd): Constify. * mi/mi-main.c (set_mi_async_command): Constify. * cli/cli-logging.c (set_logging_overwrite) (set_logging_redirect): Constify. * value.c (set_max_value_size): Constify. * valprint.c (set_input_radix, set_output_radix): Constify. * utils.c (set_width_command, set_height_command): Constify. * typeprint.c (set_print_type_methods, set_print_type_typedefs): Constify. * tracepoint.c (set_disconnected_tracing) (set_circular_trace_buffer, set_trace_buffer_size) (set_trace_user, set_trace_notes, set_trace_stop_notes): Constify. * top.c (set_history_size_command, set_verbose, set_editing) (set_gdb_datadir, set_history_filename): Constify. * target.c (set_targetdebug, maint_set_target_async_command) (maint_set_target_non_stop_command, set_target_permissions) (set_write_memory_permission): Constify. (open_target): Constify. * target-descriptions.c (set_tdesc_filename_cmd): Constify. * target-dcache.c (set_stack_cache, set_code_cache): Constify. * symtab.c (set_symbol_cache_size_handler): Constify. * symfile.c (set_ext_lang_command): Constify. * symfile-debug.c (set_debug_symfile): Constify. * source.c (set_directories_command): Constify. * solib.c (reload_shared_libraries, gdb_sysroot_changed): Constify. * serial.c (set_parity): Constify. * rs6000-tdep.c (powerpc_set_soft_float, powerpc_set_vector_abi): Constify. * remote.c (set_remote_exec_file, set_remotebreak) (set_remote_protocol_Z_packet_cmd, set_range_stepping): Constify. * record.c (set_record_insn_history_size) (set_record_call_history_size): Constify. * record-full.c (set_record_full_insn_max_num): Constify. * proc-api.c (set_procfs_trace_cmd, set_procfs_file_cmd): Constify. * osabi.c (set_osabi): Constify. * mips-tdep.c (set_mips64_transfers_32bit_regs) (reinit_frame_cache_sfunc, mips_abi_update): Constify. * maint.c (maintenance_set_profile_cmd): Constify. * linux-thread-db.c (set_libthread_db_search_path): Constify. * language.c (set_language_command, set_range_command) (set_case_command): Constify. * infrun.c (set_non_stop, set_observer_mode) (set_stop_on_solib_events, set_schedlock_func) (set_exec_direction_func): Constify. * infcmd.c (set_inferior_tty_command): Constify. * disasm.c (set_disassembler_options_sfunc): Constify. * demangle.c (set_demangling_command): Constify. * dcache.c (set_dcache_size, set_dcache_line_size): Constify. * cris-tdep.c (set_cris_version, set_cris_mode) (set_cris_dwarf2_cfi): Constify. * corefile.c (set_gnutarget_command): Constify. * charset.c (set_host_charset_sfunc, set_target_charset_sfunc) (set_target_wide_charset_sfunc): Constify. * breakpoint.c (update_dprintf_commands): Constify. * auto-load.c (set_auto_load_dir, set_auto_load_safe_path): Constify. * arm-tdep.c (set_fp_model_sfunc, arm_set_abi) (set_disassembly_style_sfunc): Constify. * arch-utils.c (set_endian, set_architecture): Constify. * alpha-tdep.c (reinit_frame_cache_sfunc): Constify. * agent.c (set_can_use_agent): Constify.
2017-11-07Remove cmd_cfunc_ftypeTom Tromey
This removes cmd_cfunc_ftype and the non-const overload of add_cmd; then fixes up the fallout. For the most part this patch is straightforward. There are a few files (go32-nat.c, windows-nat.c, and gnu-nat.c) that I could not compile; so I made a best effort there. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * go32-nat.c (go32_sysinfo, go32_sldt, go32_sgdt, go32_sidt) (go32_pde, go32_pte, go32_pte_for_address): Constify. * gnu-nat.c (_parse_bool_arg, show_thread_default_pause_cmd) (set_thread_default_pause_cmd, set_thread_default_run_cmd) (show_thread_default_run_cmd, set_thread_default_detach_sc_cmd) (parse_int_arg, show_thread_default_detach_sc_cmd) (set_signals_cmd, show_signals_cmd, set_sig_thread_cmd) (show_sig_thread_cmd, set_stopped_cmd, show_stopped_cmd) (set_exceptions_cmd, show_exceptions_cmd, set_task_pause_cmd) (show_task_pause_cmd, set_task_detach_sc_cmd) (show_task_detach_sc_cmd, set_task_exc_port_cmd) (set_noninvasive_cmd, set_thread_pause_cmd) (show_thread_pause_cmd, set_thread_run_cmd, show_thread_run_cmd) (set_thread_detach_sc_cmd, show_thread_detach_sc_cmd) (set_thread_exc_port_cmd, thread_takeover_sc_cmd): Constify. * windows-nat.c (display_selectors): Constify. * cli/cli-decode.h (struct cmd_list_element) <function>: Remove non-const "cfunc". * cli/cli-decode.c (set_cmd_cfunc): Remove non-const overload. (cmd_cfunc_eq): Likewise. (struct cmd_list_element): Likewise. (do_cfunc): Remove. (cli_user_command_p): Update. * command.h (add_cmd): Remove non-const overload. (cmd_cfunc_ftype): Remove typedef. (cmd_cfunc_eq): Remove non-const overload. * value.c (show_values): Constify. * thread.c (thread_apply_all_command): Constify. * symfile.c (load_command): Constify. * source.c (directory_command): Constify. * maint.c (maintenance_internal_error) (maintenance_demangler_warning, maintenance_space_display) (maintenance_print_architecture, maintenance_translate_address) (maintenance_info_selftests, maintenance_internal_warning): Constify. * breakpoint.c (disable_trace_command, enable_trace_command): Constify. * auto-load.c (info_auto_load_local_gdbinit, add_auto_load_dir): Constify. (add_auto_load_safe_path): Constify. * guile/scm-auto-load.c (info_auto_load_guile_scripts): Constify. * top.h (show_commands): Constify. * linux-thread-db.c (info_auto_load_libthread_db): Constify. * sparc64-tdep.c (adi_examine_command): Constify. (adi_assign_command): Constify.
2017-11-07Constify add_comTom Tromey
This changes add_com to take a cmd_const_cfunc_ftype, and then fixes up all the command implementations. In most cases this is trivial. In a couple of places I had to again introduce a temporary non-const overload. These overloads will be removed when add_info is constified. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * solib.h (no_shared_libraries): Constify. * frame.h (return_command): Constify. * cli/cli-cmds.h (quit_command): Constify. * top.h (quit_command, execute_command): Constify. * target.h (flash_erase_command): Constify. * inferior.h (set_inferior_args, attach_command): Constify. * tracepoint.h (start_tracing, stop_tracing): Constify. * breakpoint.h (break_command, tbreak_command) (hbreak_command_wrapper, thbreak_command_wrapper) (rbreak_command_wrapper, watch_command_wrapper) (awatch_command_wrapper, rwatch_command_wrapper) (get_tracepoint_by_number): Constify. * symtab.c (info_variables_command, rbreak_command) (symtab_symbol_info): Constify. (info_variables_command): Add non-const overload. * top.c (dont_repeat_command): Constify. * breakpoint.c (ignore_command, commands_command) (condition_command, tbreak_command, hbreak_command) (thbreak_command, clear_command, break_command) (info_breakpoints_command, watch_command, rwatch_command) (awatch_command, trace_command, ftrace_command, strace_command) (trace_pass_command, break_range_command, dprintf_command) (agent_printf_command, get_tracepoint_by_number) (watch_maybe_just_location, trace_pass_command): Constify. (info_breakpoints_command): Add non-const overload. * tracefile.c (tsave_command): Constify. * infcmd.c (attach_command, disconnect_command, signal_command) (queue_signal_command, stepi_command, nexti_command) (finish_command, next_command, step_command, until_command) (advance_command, jump_command, continue_command, run_command) (start_command, starti_command, interrupt_command) (run_command_1, set_inferior_args, step_1): Constify. * inferior.c (add_inferior_command, remove_inferior_command) (clone_inferior_command): Constify. * linux-fork.c (checkpoint_command, restart_command): Constify. * windows-nat.c (signal_event_command): Constify. * guile/guile.c (guile_repl_command, guile_command): Constify. * printcmd.c (x_command, display_command, printf_command) (output_command, set_command, call_command, print_command) (eval_command): Constify. (non_const_set_command): Remove. (_initialize_printcmd): Update. * source.c (forward_search_command, reverse_search_command): Constify. * jit.c (jit_reader_load_command, jit_reader_unload_command): Constify. * infrun.c (handle_command): Constify. * memattr.c (mem_command): Constify. * stack.c (return_command, up_command, up_silently_command) (down_command, down_silently_command, frame_command) (backtrace_command, func_command, backtrace_command_1): Constify. (backtrace_command): Add non-const overload. * remote-sim.c (simulator_command): Constify. * exec.c (set_section_command): Constify. * tracepoint.c (tdump_command, trace_variable_command) (tstatus_command, tstop_command, tstart_command) (end_actions_pseudocommand, while_stepping_pseudocommand) (collect_pseudocommand, teval_pseudocommand, actions_command) (start_tracing, stop_tracing): Constify. * value.c (init_if_undefined_command): Constify. * tui/tui-stack.c (tui_update_command): Constify. * tui/tui-win.c (tui_refresh_all_command) (tui_set_tab_width_command, tui_set_win_height_command) (tui_set_focus_command, tui_scroll_forward_command) (tui_scroll_backward_command, tui_scroll_left_command) (tui_scroll_right_command, parse_scrolling_args, tui_set_focus) (tui_set_win_height): Constify. * tui/tui-layout.c (tui_layout_command): Constify. * procfs.c (proc_trace_syscalls, proc_trace_sysentry_cmd) (proc_trace_sysexit_cmd, proc_untrace_sysentry_cmd) (proc_untrace_sysexit_cmd): Constify. * remote.c (threadlist_test_cmd, threadinfo_test_cmd) (threadset_test_cmd, threadlist_update_test_cmd) (threadalive_test): Constify. * objc-lang.c (print_object_command): Constify. * command.h (add_com): Constify. * cli/cli-dump.c (restore_command): Constify. * cli/cli-cmds.c (pwd_command, echo_command, quit_command) (help_command, complete_command, shell_command, edit_command) (list_command, disassemble_command, make_command) (apropos_command, alias_command): Constify. * cli/cli-script.c (document_command, define_command) (while_command, if_command, validate_comname): Constify. * cli/cli-decode.c (struct cmd_list_element): Change type of "fun". * target.c (do_monitor_command, flash_erase_command): Constify. * regcache.c (reg_flush_command): Constify. * reverse.c (reverse_step, reverse_next, reverse_stepi) (reverse_nexti, reverse_continue, reverse_finish) (save_bookmark_command, goto_bookmark_command) (exec_reverse_once): Constify. * python/python.c (python_interactive_command, python_command): Constify. * typeprint.c (ptype_command, whatis_command, whatis_exp): Constify. * solib.c (sharedlibrary_command, no_shared_libraries): Constify. * gcore.c (gcore_command): Constify.
2017-11-07Add set_repeat_arguments functionTom Tromey
The "x", "list", and "show commands" commands have special repetition behavior: repeating the command doesn't re-run it with the same arguments This is currently implemented by modifying the passed-in argument; but that won't work properly with const arguments (and seems pretty obscure besides). This patch adds a new "set_repeat_arguments" function and changes the relevant places to call it. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * printcmd.c (x_command): Call set_repeat_arguments. * cli/cli-cmds.c (list_command): Call set_repeat_arguments. * top.c (repeat_arguments): New global. (set_repeat_arguments): New function. (execute_command): Handle repeat_arguments. (show_commands): Calls set_repeat_arguments. * command.h (set_repeat_arguments): Declare.
2017-11-06Target FP: Remove unused floating-point routinesUlrich Weigand
This patch removes the following routines, which now have no remaining users in GDB: - extract_typed_floating - store_typed_floating - convert_typed_floating - decimal_from_doublest - decimal_to_doublest - value_as_double - unpack_double - value_from_double - value_from_decfloat This completes removal of DOUBLEST from all files except doublest.{c,h} and target-float.c. gdb/ChangeLog: 2017-11-06 Ulrich Weigand <uweigand@de.ibm.com> * doublest.c: Do not include "gdbtypes.h". (extract_typed_floating): Remove. (store_typed_floating): Remove. (convert_typed_floating): Remove. * doublest.h (struct type): Remove. (DOUBLEST_PRINT_FORMAT): Remove. (DOUBLEST_SCAN_FORMAT): Remove. (extract_typed_floating): Remove. (store_typed_floating): Remove. (convert_typed_floating): Remove. * dfp.c (decimal_from_doublest): Remove. (decimal_to_doublest): Remove. * dfp.h: Do not include "doublest.h". (decimal_from_doublest): Remove. (decimal_to_doublest): Remove. * value.c: Do not include "doublest.h" and "dfp.h". (value_as_double): Remove. (unpack_double): Remove. (value_from_double): Remove. (value_from_decfloat): Remove. * value.h: Do not include "doublest.h". (value_as_double): Remove. (unpack_double): Remove. (value_from_double): Remove. (value_from_decfloat): Remove.
2017-11-06Target FP: Add conversion routines to target-float.{c,h}Ulrich Weigand
This patch adds the following conversion routines: - target_float_to_longest - target_float_from_longest - target_float_from_ulongest - target_float_convert which call the equivalent decimal_ routines to handle decimal FP, and call helper routines that currently still go via DOUBLEST to handle binary FP. The target_float_convert routine not only handles BFP<->BFP and DFP<->DFP conversions, but also BFP<->DFP, which are implemented by converting to a string and back. These helpers are used in particular to implement conversion from and to FP in value_cast, without going through DOUBLEST there. In order to implement this for the FP<-integer case, the pack_long / pack_unsigned_long routines are extended to support floating-point values as output (thereby allowing use of value_from_[u]longest with a floating-point target type). This latter change also allows simplification of value_one. gdb/ChangeLog: 2017-11-06 Ulrich Weigand <uweigand@de.ibm.com> * target-float.c (floatformat_to_longest): New function. (floatformat_from_longest, floatformat_from_ulongest): Likewise. (floatformat_convert): Likewise. (target_float_to_longest): Likewise. (target_float_from_longest, target_float_from_ulongest): Likewise. (target_float_convert): Likewise. * target-float.h (target_float_to_longest): Add prototype. (target_float_from_longest, target_float_from_ulongest): Likewise. (target_float_convert): Likewise. * value.c (unpack_long): Use target_float_to_longest. (pack_long): Allow FP types. Use target_float_from_longest. (pack_unsigned_long): Likewise using target_float_from_ulongest. * valops.c: Include "target-float.h". Do not include "dfp.h". (value_cast): Handle conversions to FP using target_float_convert, value_from_ulongest, and value_from_longest. (value_one): Use value_from_longest for FP types as well.
2017-11-06Target FP: Introduce target-float.{c,h}Ulrich Weigand
This patch introduces the new set of target floating-point handling routines in target-float.{c,h}. In the end, the intention is that this file will contain support for all operations in target FP format, fully replacing both the current doublest.{c,h} and dfp.{c,h}. To begin with, this patch only adds a target_float_is_zero routine, which handles the equivalent of decimal_is_zero for both binary and decimal FP. For the binary case, to avoid conversion to DOUBLEST, this is implemented using the floatformat_classify routine. However, it turns out that floatformat_classify actually has a bug (it was not used to check for zero before), so this is fixed as well. The new routine is used in both value_logical_not and valpy_nonzero. There is one extra twist: the code previously used value_as_double to convert to DOUBLEST and then compare against zero. That routine performs an extra task: it detects invalid floating-point values and raises an error. In any place where value_as_double is removed in favor of some target-float.c routine, we need to replace that check. To keep this check centralized in one place, I've added a new routine is_floating_value, which returns a boolean determining whether a value's type is floating point (binary or decimal), and if so, also performs the validity check. Since we need to check whether a value is FP before calling any of the target-float routines anyway, this seems a good place to add the check without much code size overhead. In some places where we only want to check for floating-point types and not perform a validity check (e.g. for the *output* of an operation), we can use the new is_floating_type routine (in gdbarch) instead. The validity check itself is done by a new target_float_is_valid routine in target-float, encapsulating floatformat_is_valid. ChangeLog: 2017-11-06 Ulrich Weigand <uweigand@de.ibm.com> * Makefile.c (SFILES): Add target-float.c. (HFILES_NO_SRCDIR): Add target-float.h. (COMMON_OBS): Add target-float.o. * target-float.h: New file. * target-float.c: New file. * doublest.c (floatformat_classify): Fix detection of float_zero. * gdbtypes.c (is_floating_type): New function. * gdbtypes.h (is_floating_type): Add prototype. * value.c: Do not include "floatformat.h". (unpack_double): Use target_float_is_valid. (is_floating_value): New function. * value.h (is_floating_value): Add prototype- * valarith.c: Include "target-float.h". (value_logical_not): Use target_float_is_zero. * python/py-value.c: Include "target-float.h". (valpy_nonzero): Use target_float_is_zero.
2017-10-11Constify add_prefix_cmdTom Tromey
This changes add_prefix_cmd to accept a const-taking function as an argument; then fixes up all the callers. In a couple of spots I had to add a non-const overload of a function, because the function is passed to two different command-adding "constructors". These overloads are temporary; once constification is complete they can be removed. This patch also fixes a typo I happened to notice while constifying. Note that this touches a couple of files (gnu-nat.c and go32-nat.c) that I can't build. So, while I made a best-effort there, I am not certain they will still compile. Tested by rebuilding. gdb/ChangeLog 2017-10-11 Tom Tromey <tom@tromey.com> * gdbthread.h (thread_command): Constify. * inferior.h (detach_command): Constify. * top.h (set_history, show_history): Constify. * arm-tdep.c (set_arm_command, show_arm_command): Constify. * serial.c (serial_set_cmd, serial_show_cmd): Constify. * bsd-kvm.c (bsd_kvm_cmd): Constify. * printcmd.c (set_command): Constify. (non_const_set_command): New function. * dcache.c (set_dcache_command, show_dcache_command): Constify. * breakpoint.c (enable_command, disable_command, delete_command) (catch_command, tcatch_command, set_breakpoint_cmd) (show_breakpoint_cmd): Constify. * macrocmd.c (macro_command): Constify. * infcmd.c (unset_command, kill_command, detach_command) (info_proc_cmd): Constify. * i386-tdep.c (set_mpx_cmd, show_mpx_cmd): Constify. * auto-load.c (show_auto_load_cmd, set_auto_load_cmd) (info_auto_load_cmd): Constify. * target-descriptions.c (set_tdesc_cmd, show_tdesc_cmd) (unset_tdesc_cmd): Constify. * ada-lang.c (set_ada_command, show_ada_command) (maint_set_ada_cmd, maint_show_ada_cmd): Constify. * guile/guile.c (set_guile_command, show_guile_command) (info_guile_command): Constify. * tui/tui-win.c (tui_command, set_tui_cmd, show_tui_cmd): Constify. * skip.c (skip_command): Constify. * compile/compile.c (_initialize_compile): Constify. * dwarf2read.c (set_dwarf_cmd, show_dwarf_cmd): Constify. * btrace.c (maint_btrace_cmd, maint_btrace_set_cmd) (maint_btrace_show_cmd, maint_btrace_pt_set_cmd) (maint_btrace_pt_show_cmd): Constify. * remote.c (set_remote_cmd, show_remote_cmd, remote_command): Constify. * python/python.c (user_show_python, user_set_python): Constify. * mips-tdep.c (set_mips_command, show_mips_command) (set_mipsfpu_command): Constify. * record-btrace.c (cmd_record_btrace_start) (cmd_set_record_btrace, cmd_show_record_btrace) (cmd_set_record_btrace_bts, cmd_show_record_btrace_bts) (cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): Constify. * rs6000-tdep.c (set_powerpc_command, show_powerpc_command): Constify. * symfile.c (overlay_command): Constify. * spu-tdep.c (set_spu_command, show_spu_command): Constify. * cli/cli-logging.c (set_logging_command, show_logging_command): Constify. * cli/cli-dump.c (dump_command, append_command) (srec_dump_command, ihex_dump_command, verilog_dump_command) (tekhex_dump_command, binary_dump_command) (binary_append_command): Constify. * cli/cli-decode.c (struct cmd_list_element): Change type of "fun". * cli/cli-cmds.c (info_command, show_command, set_debug) (show_debug): Constify. (show_command): Add non-const overload. * top.c (set_history, show_history): Constify. * sh-tdep.c (set_sh_command, show_sh_command): Constify. * command.h (add_prefix_cmd): Accept a cmd_const_cfunc_ftype. * target.c (target_command): Constify. * sparc64-tdep.c (info_adi_command): Constify. * record-full.c (cmd_record_full_start): Constify. (set_record_full_command): Constify. Fix typo. (show_record_full_command): Constify. * thread.c (thread_command, thread_apply_command): Constify. * memattr.c (dummy_cmd): Constify. * value.c (function_command): Constify. * frame.c (set_backtrace_cmd, show_backtrace_cmd): Constify. * probe.c (info_probes_command): Constify. * ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Constify. * gnu-nat.c (set_task_cmd, show_task_cmd, set_thread_cmd) (show_thread_cmd, set_thread_default_cmd) (show_thread_default_cmd): Constify. (check_empty): Constify. * tracepoint.c (tfind_command): Constify. * cp-support.c (maint_cplus_command): Constify. * windows-tdep.c (info_w32_command): Constify. * record.c (cmd_record_start, set_record_command) (show_record_command, info_record_command, cmd_record_goto): Constify. * ravenscar-thread.c (set_ravenscar_command) (show_ravenscar_command): Constify. * utils.c (set_internal_problem_cmd, show_internal_problem_cmd): Constify. (add_internal_problem_command): Remove casts. * arc-tdep.c (maintenance_print_arc_command): Constify. * valprint.c (set_print, show_print, set_print_raw) (show_print_raw): Constify. * maint.c (maintenance_command, maintenance_info_command) (maintenance_print_command, maintenance_set_cmd) (maintenance_show_cmd, set_per_command_cmd) (show_per_command_cmd, maintenance_check_command): Constify. * language.c (set_check, show_check): Constify. * typeprint.c (show_print_type, set_print_type): Constify. * go32-nat.c (go32_info_dos_command): Constify.
2017-10-05Clean up some DFP interfacesUlrich Weigand
This cleans up a number of interfaces in dfp.c / dfp.h. Specifically: - The decimal_from_string / decimal_to_string routines are C++-ified to operate on std::string instead of character buffers. In the decimal_from_string, the boolean return value now actually is bool instead of an int. - The decimal_from_integral and decimal_from_doublest routines take an struct value as input. This is not really appropriate at the low level the DFP routines sit, so this replaced them with new routines decimal_from_longest / decimal_from_ulongest / decimal_from_doublest that operate on contents instead. - To mirror the decimal_from_[u]longest, a new decimal_to_longest routine is added as well, which can be used in unpack_long to avoid an unnecessary conversion via DOUBLEST. Note that the decimal_from_longest / decimal_from_ulongest routines are actually more powerful than decimal_from_integral: the old routine would only accept integer *types* of at most four bytes size, while the new routines accept all integer *values* that fit in an [u]int32_t, no matter which type they came from. The DFP tests are updated to allow for this larger range of integers that can be converted. gdb/ChangeLog: 2017-10-05 Ulrich Weigand <uweigand@de.ibm.com> * dfp.h (MAX_DECIMAL_STRING): Move to dfp.c. (decimal_to_string): Return std::string object. (decimal_from_string): Accept std::string object. Return bool. (decimal_from_integral, decimal_from_doublest): Remove. (decimal_from_longest): Add prototype. (decimal_from_ulongest): Likewise. (decimal_to_longest): Likewise. (decimal_from_doublest): Likewise. * dfp.c: Do not include "gdbtypes.h" or "value.h". (MAX_DECIMAL_STRING): Move here. (decimal_to_string): Return std::string object. (decimal_from_string): Accept std::string object. Return bool. (decimal_from_integral): Remove, replace by ... (decimal_from_longest, decimal_from_ulongest): ... these new functions. (decimal_to_longest): New function. (decimal_from_floating): Remove, replace by ... (decimal_from_doublest): ... this new function. (decimal_to_doublest): Update to new decimal_to_string interface. * value.c (unpack_long): Use decimal_to_longest. * valops.c (value_cast): Use decimal_from_doublest instead of decimal_from_floating. Use decimal_from_[u]longest isntead of decimal_from_integral. * valarith.c (value_args_as_decimal): Likewise. * valprint.c (print_decimal_floating): Update to new decimal_to_string interface. * printcmd.c (printf_decfloat): Likewise. * c-exp.y (parse_number): Update to new decimal_from_string interface. gdb/testsuite/ChangeLog: 2017-10-05 Ulrich Weigand <uweigand@de.ibm.com> * gdb.base/dfp-exprs.exp: Update tests to larger range of supported integer-to-dfp conversion. * gdb.base/dfp-test.exp: Likewise.
2017-10-05Clean up includes of doublest.h and floatformat.hUlrich Weigand
As a first small step to getting rid of doublest.h, this patch removes the include of "floatformat.h" in "doublest.h". This is actually not needed for the file itself. A few source files now need to include "floatformat.h" directly, since they got it indirectly via "doublest.h" and still need it. In reviewing which files need it, I found a number of files that include "floatformat.h" directly without actually needing it at all. Similarly, a number of files include "doublest.h" without needing it. I've also removed those unnecessary include statements. gdb/ChangeLog: 2017-10-05 Ulrich Weigand <uweigand@de.ibm.com> * doublest.h: Do not include "floatformat.h". Remove stale comments. * gdbtypes.c: Include "floatformat.h". * value.c: Likewise. * m68k-tdep.c: Likewise. * findvar.c: Do not include "floatformat.h". * amd64-darwin-tdep.c: Likewise. * arm-linux-tdep.c: Likewise. * i386-darwin-tdep.c: Likewise. * i387-tdep.c: Likewise. * m68k-linux-tdep.c: Likewise. * mep-tdep.c: Likewise. * mips-tdep.c: Likewise. * nios2-tdep.c: Likewise. * s390-linux-tdep.c: Likewise. * sparc-obsd-tdep.c: Likewise. * sparc-tdep.c: Likewise. * sparc64-tdep.c: Likewise. * spu-tdep.c: Likewise. * tic6x-tdep.c: Likewise. * tilegx-tdep.c: Likewise. * vax-tdep.c: Likewise. * xstormy16-tdep.c: Likewise. * xtensa-tdep.c: Likewise. * top.c: Do not include "doublest.h". * aarch64-tdep.c: Likewise. * alpha-tdep.c: Likewise. * arm-linux-tdep.c: Likewise. * m68k-linux-tdep.c: Likewise. * tilegx-tdep.c: Likewise. * xstormy16-tdep.c: Likewise.
2017-09-27Constify show_convenienceTom Tromey
gdb/ChangeLog 2017-09-27 Tom Tromey <tom@tromey.com> * value.c (show_convenience): Constify.
2017-09-09Remove unnecessary function prototypes.John Baldwin
These prototypes were required when compiling GDB as C but are not required for C++. gdb/ChangeLog: * aarch64-linux-nat.c: Remove _initialize_aarch64_linux_nat prototype. * aarch64-linux-tdep.c: Remove _initialize_aarch64_linux_tdep prototype. * aarch64-newlib-tdep.c: Remove _initialize_aarch64_newlib_tdep prototype. * aarch64-tdep.c: Remove _initialize_aarch64_tdep prototype. * ada-exp.y: Remove _initialize_ada_exp prototype. * ada-lang.c: Remove _initialize_ada_language prototype. * ada-tasks.c: Remove _initialize_tasks prototype. * addrmap.c: Remove _initialize_addrmap prototype. * agent.c: Remove _initialize_agent prototype. * aix-thread.c: Remove _initialize_aix_thread prototype. * alpha-bsd-nat.c: Remove _initialize_alphabsd_nat prototype. * alpha-linux-nat.c: Remove _initialize_alpha_linux_nat prototype. * alpha-linux-tdep.c: Remove _initialize_alpha_linux_tdep prototype. * alpha-nbsd-tdep.c: Remove _initialize_alphanbsd_tdep prototype. * alpha-obsd-tdep.c: Remove _initialize_alphaobsd_tdep prototype. * alpha-tdep.c: Remove _initialize_alpha_tdep prototype. * amd64-darwin-tdep.c: Remove _initialize_amd64_darwin_tdep prototype. * amd64-dicos-tdep.c: Remove _initialize_amd64_dicos_tdep prototype. * amd64-fbsd-nat.c: Remove _initialize_amd64fbsd_nat prototype. * amd64-fbsd-tdep.c: Remove _initialize_amd64fbsd_tdep prototype. * amd64-linux-nat.c: Remove _initialize_amd64_linux_nat prototype. * amd64-linux-tdep.c: Remove _initialize_amd64_linux_tdep prototype. * amd64-nbsd-nat.c: Remove _initialize_amd64nbsd_nat prototype. * amd64-nbsd-tdep.c: Remove _initialize_amd64nbsd_tdep prototype. * amd64-obsd-nat.c: Remove _initialize_amd64obsd_nat prototype. * amd64-obsd-tdep.c: Remove _initialize_amd64obsd_tdep prototype. * amd64-sol2-tdep.c: Remove _initialize_amd64_sol2_tdep prototype. * amd64-tdep.c: Remove _initialize_amd64_tdep prototype. * amd64-windows-nat.c: Remove _initialize_amd64_windows_nat prototype. * amd64-windows-tdep.c: Remove _initialize_amd64_windows_tdep prototype. * annotate.c: Remove _initialize_annotate prototype. * arc-newlib-tdep.c: Remove _initialize_arc_newlib_tdep prototype. * arc-tdep.c: Remove _initialize_arc_tdep prototype. * arch-utils.c: Remove _initialize_gdbarch_utils prototype. * arm-linux-nat.c: Remove _initialize_arm_linux_nat prototype. * arm-linux-tdep.c: Remove _initialize_arm_linux_tdep prototype. * arm-nbsd-tdep.c: Remove _initialize_arm_netbsd_tdep prototype. * arm-obsd-tdep.c: Remove _initialize_armobsd_tdep prototype. * arm-symbian-tdep.c: Remove _initialize_arm_symbian_tdep prototype. * arm-tdep.c: Remove _initialize_arm_tdep prototype. * arm-wince-tdep.c: Remove _initialize_arm_wince_tdep prototype. * auto-load.c: Remove _initialize_auto_load prototype. * auxv.c: Remove _initialize_auxv prototype. * avr-tdep.c: Remove _initialize_avr_tdep prototype. * ax-gdb.c: Remove _initialize_ax_gdb prototype. * bfin-linux-tdep.c: Remove _initialize_bfin_linux_tdep prototype. * bfin-tdep.c: Remove _initialize_bfin_tdep prototype. * break-catch-sig.c: Remove _initialize_break_catch_sig prototype. * break-catch-syscall.c: Remove _initialize_break_catch_syscall prototype. * break-catch-throw.c: Remove _initialize_break_catch_throw prototype. * breakpoint.c: Remove _initialize_breakpoint prototype. * bsd-uthread.c: Remove _initialize_bsd_uthread prototype. * btrace.c: Remove _initialize_btrace prototype. * charset.c: Remove _initialize_charset prototype. * cli/cli-cmds.c: Remove _initialize_cli_cmds prototype. * cli/cli-dump.c: Remove _initialize_cli_dump prototype. * cli/cli-interp.c: Remove _initialize_cli_interp prototype. * cli/cli-logging.c: Remove _initialize_cli_logging prototype. * cli/cli-script.c: Remove _initialize_cli_script prototype. * coff-pe-read.c: Remove _initialize_coff_pe_read prototype. * coffread.c: Remove _initialize_coffread prototype. * compile/compile.c: Remove _initialize_compile prototype. * complaints.c: Remove _initialize_complaints prototype. * completer.c: Remove _initialize_completer prototype. * copying.awk: Remove _initialize_copying prototype. * copying.c: Regenerate. * core-regset.c: Remove _initialize_core_regset prototype. * corefile.c: Remove _initialize_core prototype. * corelow.c: Remove _initialize_corelow prototype. * cp-abi.c: Remove _initialize_cp_abi prototype. * cp-namespace.c: Remove _initialize_cp_namespace prototype. * cp-support.c: Remove _initialize_cp_support prototype. * cp-valprint.c: Remove _initialize_cp_valprint prototype. * cris-linux-tdep.c: Remove _initialize_cris_linux_tdep prototype. * cris-tdep.c: Remove _initialize_cris_tdep prototype. * ctf.c: Remove _initialize_ctf prototype. * d-lang.c: Remove _initialize_d_language prototype. * darwin-nat-info.c: Remove _initialize_darwin_info_commands prototype. * darwin-nat.c: Remove _initialize_darwin_inferior prototype. * dbxread.c: Remove _initialize_dbxread prototype. * dcache.c: Remove _initialize_dcache prototype. * demangle.c: Remove _initialize_demangler prototype. * disasm-selftests.c: Remove _initialize_disasm_selftests prototype. * disasm.c: Remove _initialize_disasm prototype. * dtrace-probe.c: Remove _initialize_dtrace_probe prototype. * dummy-frame.c: Remove _initialize_dummy_frame prototype. * dwarf2-frame-tailcall.c: Remove _initialize_tailcall_frame prototype. * dwarf2-frame.c: Remove _initialize_dwarf2_frame prototype. * dwarf2expr.c: Remove _initialize_dwarf2expr prototype. * dwarf2loc.c: Remove _initialize_dwarf2loc prototype. * dwarf2read.c: Remove _initialize_dwarf2_read prototype. * elfread.c: Remove _initialize_elfread prototype. * exec.c: Remove _initialize_exec prototype. * extension.c: Remove _initialize_extension prototype. * f-lang.c: Remove _initialize_f_language prototype. * f-valprint.c: Remove _initialize_f_valprint prototype. * fbsd-nat.c: Remove _initialize_fbsd_nat prototype. * fbsd-tdep.c: Remove _initialize_fbsd_tdep prototype. * filesystem.c: Remove _initialize_filesystem prototype. * findcmd.c: Remove _initialize_mem_search prototype. * fork-child.c: Remove _initialize_fork_child prototype. * frame-base.c: Remove _initialize_frame_base prototype. * frame-unwind.c: Remove _initialize_frame_unwind prototype. * frame.c: Remove _initialize_frame prototype. * frv-linux-tdep.c: Remove _initialize_frv_linux_tdep prototype. * frv-tdep.c: Remove _initialize_frv_tdep prototype. * ft32-tdep.c: Remove _initialize_ft32_tdep prototype. * gcore.c: Remove _initialize_gcore prototype. * gdb_bfd.c: Remove _initialize_gdb_bfd prototype. * gdbarch.c: Regenerate. * gdbarch.sh: Remove _initialize_gdbarch prototype. * gdbtypes.c: Remove _initialize_gdbtypes prototype. * gnu-nat.c: Remove _initialize_gnu_nat prototype. * gnu-v2-abi.c: Remove _initialize_gnu_v2_abi prototype. * gnu-v3-abi.c: Remove _initialize_gnu_v3_abi prototype. * go-lang.c: Remove _initialize_go_language prototype. * go32-nat.c: Remove _initialize_go32_nat prototype. * guile/guile.c: Remove _initialize_guile prototype. * h8300-tdep.c: Remove _initialize_h8300_tdep prototype. * hppa-linux-nat.c: Remove _initialize_hppa_linux_nat prototype. * hppa-linux-tdep.c: Remove _initialize_hppa_linux_tdep prototype. * hppa-nbsd-nat.c: Remove _initialize_hppanbsd_nat prototype. * hppa-nbsd-tdep.c: Remove _initialize_hppanbsd_tdep prototype. * hppa-obsd-nat.c: Remove _initialize_hppaobsd_nat prototype. * hppa-obsd-tdep.c: Remove _initialize_hppaobsd_tdep prototype. * hppa-tdep.c: Remove _initialize_hppa_tdep prototype. * i386-bsd-nat.c: Remove _initialize_i386bsd_nat prototype. * i386-cygwin-tdep.c: Remove _initialize_i386_cygwin_tdep prototype. * i386-darwin-tdep.c: Remove _initialize_i386_darwin_tdep prototype. * i386-dicos-tdep.c: Remove _initialize_i386_dicos_tdep prototype. * i386-fbsd-nat.c: Remove _initialize_i386fbsd_nat prototype. * i386-fbsd-tdep.c: Remove _initialize_i386fbsd_tdep prototype. * i386-gnu-nat.c: Remove _initialize_i386gnu_nat prototype. * i386-gnu-tdep.c: Remove _initialize_i386gnu_tdep prototype. * i386-linux-nat.c: Remove _initialize_i386_linux_nat prototype. * i386-linux-tdep.c: Remove _initialize_i386_linux_tdep prototype. * i386-nbsd-nat.c: Remove _initialize_i386nbsd_nat prototype. * i386-nbsd-tdep.c: Remove _initialize_i386nbsd_tdep prototype. * i386-nto-tdep.c: Remove _initialize_i386nto_tdep prototype. * i386-obsd-nat.c: Remove _initialize_i386obsd_nat prototype. * i386-obsd-tdep.c: Remove _initialize_i386obsd_tdep prototype. * i386-sol2-nat.c: Remove _initialize_amd64_sol2_nat prototype. * i386-sol2-tdep.c: Remove _initialize_amd64_sol2_tdep prototype. * i386-tdep.c: Remove _initialize_i386_tdep prototype. * i386-windows-nat.c: Remove _initialize_i386_windows_nat prototype. * ia64-libunwind-tdep.c: Remove _initialize_libunwind_frame prototype. * ia64-linux-nat.c: Remove _initialize_ia64_linux_nat prototype. * ia64-linux-tdep.c: Remove _initialize_ia64_linux_tdep prototype. * ia64-tdep.c: Remove _initialize_ia64_tdep prototype. * ia64-vms-tdep.c: Remove _initialize_ia64_vms_tdep prototype. * infcall.c: Remove _initialize_infcall prototype. * infcmd.c: Remove _initialize_infcmd prototype. * inferior.c: Remove _initialize_inferiors prototype. * inflow.c: Remove _initialize_inflow prototype. * infrun.c: Remove _initialize_infrun prototype. * interps.c: Remove _initialize_interpreter prototype. * iq2000-tdep.c: Remove _initialize_iq2000_tdep prototype. * jit.c: Remove _initialize_jit prototype. * language.c: Remove _initialize_language prototype. * linux-fork.c: Remove _initialize_linux_fork prototype. * linux-nat.c: Remove _initialize_linux_nat prototype. * linux-tdep.c: Remove _initialize_linux_tdep prototype. * linux-thread-db.c: Remove _initialize_thread_db prototype. * lm32-tdep.c: Remove _initialize_lm32_tdep prototype. * m2-lang.c: Remove _initialize_m2_language prototype. * m32c-tdep.c: Remove _initialize_m32c_tdep prototype. * m32r-linux-nat.c: Remove _initialize_m32r_linux_nat prototype. * m32r-linux-tdep.c: Remove _initialize_m32r_linux_tdep prototype. * m32r-tdep.c: Remove _initialize_m32r_tdep prototype. * m68hc11-tdep.c: Remove _initialize_m68hc11_tdep prototype. * m68k-bsd-nat.c: Remove _initialize_m68kbsd_nat prototype. * m68k-bsd-tdep.c: Remove _initialize_m68kbsd_tdep prototype. * m68k-linux-nat.c: Remove _initialize_m68k_linux_tdep prototype. * m68k-linux-tdep.c: Remove _initialize_m68k_linux_tdep prototype. * m68k-tdep.c: Remove _initialize_m68k_tdep prototype. * m88k-bsd-nat.c: Remove _initialize_m68kbsd_nat prototype. * m88k-tdep.c: Remove _initialize_m68kbsd_tdep prototype. * machoread.c: Remove _initialize_machoread prototype. * macrocmd.c: Remove _initialize_macrocmd prototype. * macroscope.c: Remove _initialize_macroscope prototype. * maint.c: Remove _initialize_maint_cmds prototype. * mdebugread.c: Remove _initialize_mdebugread prototype. * memattr.c: Remove _initialize_mem prototype. * mep-tdep.c: Remove _initialize_mep_tdep prototype. * mi/mi-cmd-env.c: Remove _initialize_mi_cmd_env prototype. * mi/mi-cmds.c: Remove _initialize_mi_cmds prototype. * mi/mi-interp.c: Remove _initialize_mi_interp prototype. * mi/mi-main.c: Remove _initialize_mi_main prototype. * microblaze-linux-tdep.c: Remove _initialize_microblaze_linux_tdep prototype. * microblaze-tdep.c: Remove _initialize_microblaze_tdep prototype. * mips-fbsd-nat.c: Remove _initialize_mips_fbsd_nat prototype. * mips-fbsd-tdep.c: Remove _initialize_mips_fbsd_tdep prototype. * mips-linux-nat.c: Remove _initialize_mips_linux_nat prototype. * mips-linux-tdep.c: Remove _initialize_mips_linux_tdep prototype. * mips-nbsd-nat.c: Remove _initialize_mipsnbsd_nat prototype. * mips-nbsd-tdep.c: Remove _initialize_mipsnbsd_tdep prototype. * mips-sde-tdep.c: Remove _initialize_mips_sde_tdep prototype. * mips-tdep.c: Remove _initialize_mips_tdep prototype. * mips64-obsd-nat.c: Remove _initialize_mips64obsd_nat prototype. * mips64-obsd-tdep.c: Remove _initialize_mips64obsd_tdep prototype. * mipsread.c: Remove _initialize_mipsread prototype. * mn10300-linux-tdep.c: Remove _initialize_mn10300_linux_tdep prototype. * mn10300-tdep.c: Remove _initialize_mn10300_tdep prototype. * moxie-tdep.c: Remove _initialize_moxie_tdep prototype. * msp430-tdep.c: Remove _initialize_msp430_tdep prototype. * mt-tdep.c: Remove _initialize_mt_tdep prototype. * nds32-tdep.c: Remove _initialize_nds32_tdep prototype. * nios2-linux-tdep.c: Remove _initialize_nios2_linux_tdep prototype. * nios2-tdep.c: Remove _initialize_nios2_tdep prototype. * nto-procfs.c: Remove _initialize_procfs prototype. * nto-tdep.c: Remove _initialize_nto_tdep prototype. * objc-lang.c: Remove _initialize_objc_language prototype. * objfiles.c: Remove _initialize_objfiles prototype. * observer.c: Remove observer_test_first_notification_function, observer_test_second_notification_function, observer_test_third_notification_function, and _initialize_observer prototypes. * opencl-lang.c: Remove _initialize_opencl_language prototypes. * osabi.c: Remove _initialize_gdb_osabi prototype. * osdata.c: Remove _initialize_osdata prototype. * p-valprint.c: Remove _initialize_pascal_valprint prototype. * parse.c: Remove _initialize_parse prototype. * ppc-fbsd-nat.c: Remove _initialize_ppcfbsd_nat prototype. * ppc-fbsd-tdep.c: Remove _initialize_ppcfbsd_tdep prototype. * ppc-linux-nat.c: Remove _initialize_ppc_linux_nat prototype. * ppc-linux-tdep.c: Remove _initialize_ppc_linux_tdep prototype. * ppc-nbsd-nat.c: Remove _initialize_ppcnbsd_nat prototype. * ppc-nbsd-tdep.c: Remove _initialize_ppcnbsd_tdep prototype. * ppc-obsd-nat.c: Remove _initialize_ppcobsd_nat prototype. * ppc-obsd-tdep.c: Remove _initialize_ppcobsd_tdep prototype. * printcmd.c: Remove _initialize_printcmd prototype. * probe.c: Remove _initialize_probe prototype. * proc-api.c: Remove _initialize_proc_api prototype. * proc-events.c: Remove _initialize_proc_events prototype. * proc-service.c: Remove _initialize_proc_service prototype. * procfs.c: Remove _initialize_procfs prototype. * psymtab.c: Remove _initialize_psymtab prototype. * python/python.c: Remove _initialize_python prototype. * ravenscar-thread.c: Remove _initialize_ravenscar prototype. * record-btrace.c: Remove _initialize_record_btrace prototype. * record-full.c: Remove _initialize_record_full prototype. * record.c: Remove _initialize_record prototype. * regcache.c: Remove _initialize_regcache prototype. * reggroups.c: Remove _initialize_reggroup prototype. * remote-notif.c: Remove _initialize_notif prototype. * remote-sim.c: Remove _initialize_remote_sim prototype. * remote.c: Remove _initialize_remote prototype. * reverse.c: Remove _initialize_reverse prototype. * rl78-tdep.c: Remove _initialize_rl78_tdep prototype. * rs6000-aix-tdep.c: Remove _initialize_rs6000_aix_tdep prototype. * rs6000-lynx178-tdep.c: Remove _initialize_rs6000_lynx178_tdep prototype. * rs6000-nat.c: Remove _initialize_rs6000_nat prototype. * rs6000-tdep.c: Remove _initialize_rs6000_tdep prototype. * rust-exp.y: Remove _initialize_rust_exp prototype. * rx-tdep.c: Remove _initialize_rx_tdep prototype. * s390-linux-nat.c: Remove _initialize_s390_nat prototype. * s390-linux-tdep.c: Remove _initialize_s390_tdep prototype. * score-tdep.c: Remove _initialize_score_tdep prototype. * selftest-arch.c: Remove _initialize_selftests_foreach_arch prototype. * ser-go32.c: Remove _initialize_ser_dos prototype. * ser-mingw.c: Remove _initialize_ser_windows prototype. * ser-pipe.c: Remove _initialize_ser_pipe prototype. * ser-tcp.c: Remove _initialize_ser_tcp prototype. * ser-unix.c: Remove _initialize_ser_hardwire prototype. * serial.c: Remove _initialize_serial prototype. * sh-linux-tdep.c: Remove _initialize_sh_linux_tdep prototype. * sh-nbsd-nat.c: Remove _initialize_shnbsd_nat prototype. * sh-nbsd-tdep.c: Remove _initialize_shnbsd_tdep prototype. * sh-tdep.c: Remove _initialize_sh_tdep prototype. * skip.c: Remove _initialize_step_skip prototype. * sol-thread.c: Remove _initialize_sol_thread prototype. * solib-aix.c: Remove _initialize_solib_aix prototype. * solib-darwin.c: Remove _initialize_darwin_solib prototype. * solib-dsbt.c: Remove _initialize_dsbt_solib prototype. * solib-frv.c: Remove _initialize_frv_solib prototype. * solib-spu.c: Remove _initialize_spu_solib prototype. * solib-svr4.c: Remove _initialize_svr4_solib prototype. * solib-target.c: Remove _initialize_solib_target prototype. * solib.c: Remove _initialize_solib prototype. * source.c: Remove _initialize_source prototype. * sparc-linux-nat.c: Remove _initialize_sparc_linux_nat prototype. * sparc-linux-tdep.c: Remove _initialize_sparc_linux_tdep prototype. * sparc-nat.c: Remove _initialize_sparc_nat prototype. * sparc-nbsd-nat.c: Remove _initialize_sparcnbsd_nat prototype. * sparc-nbsd-tdep.c: Remove _initialize_sparcnbsd_tdep prototype. * sparc-obsd-tdep.c: Remove _initialize_sparc32obsd_tdep prototype. * sparc-sol2-nat.c: Remove _initialize_sparc_sol2_nat prototype. * sparc-sol2-tdep.c: Remove _initialize_sparc_sol2_tdep prototype. * sparc-tdep.c: Remove _initialize_sparc_tdep prototype. * sparc64-fbsd-nat.c: Remove _initialize_sparc64fbsd_nat prototype. * sparc64-fbsd-tdep.c: Remove _initialize_sparc64fbsd_tdep prototype. * sparc64-linux-nat.c: Remove _initialize_sparc64_linux_nat prototype. * sparc64-linux-tdep.c: Remove _initialize_sparc64_linux_tdep prototype. * sparc64-nat.c: Remove _initialize_sparc64_nat prototype. * sparc64-nbsd-nat.c: Remove _initialize_sparc64nbsd_nat prototype. * sparc64-nbsd-tdep.c: Remove _initialize_sparc64nbsd_tdep prototype. * sparc64-obsd-nat.c: Remove _initialize_sparc64obsd_nat prototype. * sparc64-obsd-tdep.c: Remove _initialize_sparc64obsd_tdep prototype. * sparc64-sol2-tdep.c: Remove _initialize_sparc64_sol2_tdep prototype. * spu-linux-nat.c: Remove _initialize_spu_nat prototype. * spu-multiarch.c: Remove _initialize_spu_multiarch prototype. * spu-tdep.c: Remove _initialize_spu_tdep prototype. * stabsread.c: Remove _initialize_stabsread prototype. * stack.c: Remove _initialize_stack prototype. * stap-probe.c: Remove _initialize_stap_probe prototype. * std-regs.c: Remove _initialize_frame_reg prototype. * symfile-debug.c: Remove _initialize_symfile_debug prototype. * symfile-mem.c: Remove _initialize_symfile_mem prototype. * symfile.c: Remove _initialize_symfile prototype. * symmisc.c: Remove _initialize_symmisc prototype. * symtab.c: Remove _initialize_symtab prototype. * target-dcache.c: Remove _initialize_target_dcache prototype. * target-descriptions.c: Remove _initialize_target_descriptions prototype. * thread.c: Remove _initialize_thread prototype. * tic6x-linux-tdep.c: Remove _initialize_tic6x_linux_tdep prototype. * tic6x-tdep.c: Remove _initialize_tic6x_tdep prototype. * tilegx-linux-nat.c: Remove _initialize_tile_linux_nat prototype. * tilegx-linux-tdep.c: Remove _initialize_tilegx_linux_tdep prototype. * tilegx-tdep.c: Remove _initialize_tilegx_tdep prototype. * tracefile-tfile.c: Remove _initialize_tracefile_tfile prototype. * tracefile.c: Remove _initialize_tracefile prototype. * tracepoint.c: Remove _initialize_tracepoint prototype. * tui/tui-hooks.c: Remove _initialize_tui_hooks prototype. * tui/tui-interp.c: Remove _initialize_tui_interp prototype. * tui/tui-layout.c: Remove _initialize_tui_layout prototype. * tui/tui-regs.c: Remove _initialize_tui_regs prototype. * tui/tui-stack.c: Remove _initialize_tui_stack prototype. * tui/tui-win.c: Remove _initialize_tui_win prototype. * tui/tui.c: Remove _initialize_tui prototype. * typeprint.c: Remove _initialize_typeprint prototype. * user-regs.c: Remove _initialize_user_regs prototype. * utils.c: Remove _initialize_utils prototype. * v850-tdep.c: Remove _initialize_v850_tdep prototype. * valarith.c: Remove _initialize_valarith prototype. * valops.c: Remove _initialize_valops prototype. * valprint.c: Remove _initialize_valprint prototype. * value.c: Remove _initialize_values prototype. * varobj.c: Remove _initialize_varobj prototype. * vax-bsd-nat.c: Remove _initialize_vaxbsd_nat prototype. * vax-nbsd-tdep.c: Remove _initialize_vaxnbsd_tdep prototype. * vax-tdep.c: Remove _initialize_vax_tdep prototype. * windows-nat.c: Remove _initialize_windows_nat, _initialize_check_for_gdb_ini, and _initialize_loadable prototypes. * windows-tdep.c: Remove _initialize_windows_tdep prototype. * xcoffread.c: Remove _initialize_xcoffread prototype. * xml-support.c: Remove _initialize_xml_support prototype. * xstormy16-tdep.c: Remove _initialize_xstormy16_tdep prototype. * xtensa-linux-nat.c: Remove _initialize_xtensa_linux_nat prototype. * xtensa-linux-tdep.c: Remove _initialize_xtensa_linux_tdep prototype. * xtensa-tdep.c: Remove _initialize_xtensa_tdep prototype.
2017-07-17Introduce class completion_tracker & rewrite completion<->readline interactionPedro Alves
This patch reworks the whole completion machinery, and prepares it for later enhancements. Adds a new "completion_tracker" class that is meant to hold everything about the state of the current completion operation. This class now has the responsibility of tracking the list of completion matches, and checking whether the max completions limit has been reached. You can look at this as this patch starting out by C++fying the existing "completion_tracker" in symtab.c (it's just an htab_t typedef currently), moving it to completer.h/c, and then making it a class/generalizing/enhancing it. Unlike with the current tracking, completion_tracker now checks whether the limit has been reached on each completion match list insertion. This both simplifies the max-completions handling code (maybe_add_completion_enum is gone, for example), and is a prerequisite for follow up patches. The current completion_tracker is only used for symbol completions, and the symbol code gets at the current instance via globals. This patch cleans that up by adding a completion_tracker reference to the signature of the completion functions, and passing the tracker around everywhere necessary. Then, the patch changes how the completion match list is handed over to readline. Currently, we're using the rl_completion_entry_function readline entry point, and the patch switches to rl_attempted_completion_function. A following patch will want to let GDB itself decide the common completion prefix between all matches (what readline calls the "lowest common denominator"), instead of having readline compute it, and that's not possible with the rl_completion_entry_function entry point. Also, rl_attempted_completion_function lets GDB hand over the match list to readline as an array in one go instead of passing down matches one by one, so from that angle it's a nicer entry point anyway. Lastly, the patch catches exceptions around the readline entry points, because we can't let C++ exceptions cross readline. We handle that in the readline input entry point, but the completion entry point isn't guarded, so GDB can abort if completion throws. E.g., in current master: (gdb) b -function "fun<tab> terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR' Aborted (core dumped) This patch fixes that. This will be exercised in the new tests added later on in the series. gdb/ChangeLog: 2017-07-17 Pedro Alves <palves@redhat.com> * ada-lang.c (symbol_completion_match): Adjust comments. (symbol_completion_add): Replace vector parameter with completion_tracker parameter. Use it. (ada_make_symbol_completion_list): Rename to... (ada_collect_symbol_completion_matches): ... this. Add completion_tracker parameter and use it. (ada_language_defn): Adjust. * break-catch-syscall.c (catch_syscall_completer): Adjust prototype and work with completion_tracker instead of VEC. * breakpoint.c (condition_completer): Adjust prototype and work with completion_tracker instead of VEC. * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Adjust to renames. * cli/cli-cmds.c (complete_command): Rework using completion_tracker. Catch exceptions when completing. * cli/cli-decode.c (integer_unlimited_completer) (complete_on_cmdlist, complete_on_enum): Adjust prototype and work with completion_tracker instead of VEC. * command.h (struct completion_tracker): Forward declare. (completer_ftype, completer_handle_brkchars_ftype): Change types. (complete_on_cmdlist, complete_on_enum): Adjust. * completer.c: Include <algorithm>. (struct gdb_completer_state): New. (current_completion): New global. (readline_line_completion_function): Delete. (noop_completer, filename_completer) (filename_completer_handle_brkchars, complete_files_symbols) (linespec_location_completer): Adjust to work with a completion_tracker instead of a VEC. (string_or_empty): New. (collect_explicit_location_matches): Adjust to work with a completion_tracker instead of a VEC. (explicit_location_completer): Rename to ... (complete_explicit_location): ... this and adjust to work with a completion_tracker instead of a VEC. (location_completer): Adjust to work with a completion_tracker instead of a VEC. (add_struct_fields): Adjust to work with a completion_list instead of VEC. (expression_completer): Rename to ... (complete_expression): ... this and adjust to work with a completion_tracker instead of a VEC. Use complete_files_symbols. (expression_completer): Reimplement on top of complete_expression. (symbol_completer): Adjust to work with a completion_tracker instead of a VEC. (enum complete_line_internal_reason): Add describing comments. (complete_line_internal_normal_command): Adjust to work with a completion_tracker instead of a VEC. (complete_line_internal): Rename to ... (complete_line_internal_1): ... this and adjust to work with a completion_tracker instead of a VEC. Assert TEXT is NULL in the handle_brkchars phase. (new_completion_tracker): Delete. (complete_line_internal): Reimplement as TRY/CATCH wrapper around complete_line_internal_1. (free_completion_tracker): Delete. (INITIAL_COMPLETION_HTAB_SIZE): New. (completion_tracker::completion_tracker) (completion_tracker::~completion_tracker): New. (maybe_add_completion): Delete. (completion_tracker::maybe_add_completion) (completion_tracker::add_completion) (completion_tracker::add_completions): New. (throw_max_completions_reached_error): Delete. (complete_line): Adjust to work with a completion_tracker instead of a VEC. Don't create a completion_tracker_t or check for max completions here. (command_completer, command_completer_handle_brkchars) (signal_completer, reg_or_group_completer_1) (reg_or_group_completer, default_completer_handle_brkchars): Adjust to work with a completion_tracker. (gdb_completion_word_break_characters_throw): New. (gdb_completion_word_break_characters): Reimplement. (line_completion_function): Delete. (completion_tracker::recompute_lowest_common_denominator) (expand_preserving_ws) (completion_tracker::build_completion_result) (completion_result::completion_result) (completion_result::completion_result) (completion_result::~completion_result) (completion_result::completion_result) (completion_result::release_match_list, compare_cstrings) (completion_result::sort_match_list) (completion_result::reset_match_list) (gdb_rl_attempted_completion_function_throw) (gdb_rl_attempted_completion_function): New. * completer.h (completion_list, struct completion_result) (class completion_tracker): New. (complete_line): Add completion_tracker parameter. (readline_line_completion_function): Delete. (gdb_rl_attempted_completion_function): New. (noop_completer, filename_completer, expression_completer) (location_completer, symbol_completer, command_completer) (signal_completer, reg_or_group_completer): Update prototypes. (completion_tracker_t, new_completion_tracker) (make_cleanup_free_completion_tracker): Delete. (enum maybe_add_completion_enum): Delete. (maybe_add_completion): Delete. (throw_max_completions_reached_error): Delete. * corefile.c (complete_set_gnutarget): Adjust to work with a completion_tracker instead of a VEC. * cp-abi.c (cp_abi_completer): Adjust to work with a completion_tracker instead of a VEC. * d-lang.c (d_language_defn): Adjust. * disasm.c (disassembler_options_completer): Adjust to work with a completion_tracker instead of a VEC. * f-lang.c (f_make_symbol_completion_list): Rename to ... (f_collect_symbol_completion_matches): ... this. Adjust to work with a completion_tracker instead of a VEC. (f_language_defn): Adjust. * go-lang.c (go_language_defn): Adjust. * guile/scm-cmd.c (cmdscm_add_completion, cmdscm_completer): Adjust to work with a completion_tracker instead of a VEC. * infrun.c (handle_completer): Likewise. * interps.c (interpreter_completer): Likewise. * interps.h (interpreter_completer): Likewise. * language.c (unknown_language_defn, auto_language_defn) (local_language_defn): Adjust. * language.h (language_defn::la_make_symbol_completion_list): Rename to ... (language_defn::la_collect_symbol_completion_matches): ... this and adjust to work with a completion_tracker instead of a VEC. * m2-lang.c (m2_language_defn): Adjust. * objc-lang.c (objc_language_defn): Adjust. * opencl-lang.c (opencl_language_defn): Adjust. * p-lang.c (pascal_language_defn): Adjust. * python/py-cmd.c (cmdpy_completer_helper): Handle NULL word. (cmdpy_completer_handle_brkchars, cmdpy_completer): Adjust to work with a completion_tracker. * rust-lang.c (rust_language_defn): Adjust. * symtab.c (free_completion_list, do_free_completion_list) (return_val, completion_tracker): Delete. (completion_list_add_name, completion_list_add_symbol) (completion_list_add_msymbol, completion_list_objc_symbol) (completion_list_add_fields, add_symtab_completions): Add completion_tracker parameter and use it. (default_make_symbol_completion_list_break_on_1): Rename to... (default_collect_symbol_completion_matches_break_on): ... this. Add completion_tracker parameter and use it instead of allocating a completion tracker here. (default_make_symbol_completion_list_break_on): Delete old implementation. (default_make_symbol_completion_list): Delete. (default_collect_symbol_completion_matches): New. (make_symbol_completion_list): Delete. (collect_symbol_completion_matches): New. (make_symbol_completion_type): Rename to ... (collect_symbol_completion_matches_type): ... this. Add completion_tracker parameter and use it instead of VEC. (make_file_symbol_completion_list_1): Rename to... (collect_file_symbol_completion_matches): ... this. Add completion_tracker parameter and use it instead of VEC. (make_file_symbol_completion_list): Delete. (add_filename_to_list): Use completion_list instead of a VEC. (add_partial_filename_data::list): Now a completion_list. (make_source_files_completion_list): Work with a completion_list instead of a VEC. * symtab.h: Include "completer.h". (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type, make_file_symbol_completion_list) (make_source_files_completion_list): Delete. (default_collect_symbol_completion_matches_break_on) (default_collect_symbol_completion_matches) (collect_symbol_completion_matches) (collect_symbol_completion_matches_type) (collect_file_symbol_completion_matches) (make_source_files_completion_list): New. * top.c (init_main): Don't install a rl_completion_entry_function hook. Install a rl_attempted_completion_function hook instead. * tui/tui-layout.c (layout_completer): Adjust to work with a completion_tracker. * tui/tui-regs.c (tui_reggroup_completer): * tui/tui-win.c (window_name_completer, focus_completer) (winheight_completer): Adjust to work with a completion_tracker. * value.c: Include "completer.h". (complete_internalvar): Adjust to work with a completion_tracker. * value.h (complete_internalvar): Likewise.
2017-03-20Convert lvalue reference type check to general reference type checkArtemiy Volkov
In almost all contexts (except for overload resolution rules and expression semantics), lvalue and rvalue references are equivalent. That means that in all but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE check and, for switch statements, add a case label for a rvalue reference type next to a case label for an lvalue reference type. This patch does exactly that. gdb/ChangeLog PR gdb/14441 * aarch64-tdep.c (aarch64_type_align) (aarch64_extract_return_value, aarch64_store_return_value): Change lvalue reference type checks to general reference type checks. * amd64-tdep.c (amd64_classify): Likewise. * amd64-windows-tdep.c (amd64_windows_passed_by_integer_register): Likewise. * arm-tdep.c (arm_type_align, arm_extract_return_value) (arm_store_return_value): Likewise. * ax-gdb.c (gen_fetch, gen_cast): Likewise. * c-typeprint.c (c_print_type): Likewise. * c-varobj.c (adjust_value_for_child_access, c_value_of_variable) (cplus_number_of_children, cplus_describe_child): Likewise. * compile/compile-c-symbols.c (generate_vla_size): Likewise. * completer.c (expression_completer): Likewise. * cp-support.c (make_symbol_overload_list_adl_namespace): Likewise. * darwin-nat-info.c (info_mach_region_command): Likewise. * dwarf2loc.c (entry_data_value_coerce_ref) (value_of_dwarf_reg_entry): Likewise. * eval.c (ptrmath_type_p, evaluate_subexp_standard) (evaluate_subexp_for_address, evaluate_subexp_for_sizeof): Likewise. * findvar.c (extract_typed_address, store_typed_address): Likewise. * gdbtypes.c (rank_one_type): Likewise. * hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise. * infcall.c (value_arg_coerce): Likewise. * language.c (pointer_type): Likewise. * m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer): Likewise. * m88k-tdep.c (m88k_integral_or_pointer_p): Likewise. * mn10300-tdep.c (mn10300_type_align): Likewise. * msp430-tdep.c (msp430_push_dummy_call): Likewise. * ppc-sysv-tdep.c (do_ppc_sysv_return_value) (ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value): Likewise. * printcmd.c (print_formatted, x_command): Likewise. * python/py-type.c (typy_get_composite, typy_template_argument): Likewise. * python/py-value.c (valpy_referenced_value) (valpy_get_dynamic_type, value_has_field): Likewise. * s390-linux-tdep.c (s390_function_arg_integer): Likewise. * sparc-tdep.c (sparc_integral_or_pointer_p): Likewise. * sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise. * spu-tdep.c (spu_scalar_value_p): Likewise. * symtab.c (lookup_symbol_aux): Likewise. * typeprint.c (whatis_exp, print_type_scalar): Likewise. * valarith.c (binop_types_user_defined_p, unop_user_defined_p): Likewise. * valops.c (value_cast_pointers, value_cast) (value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp) (value_struct_elt, value_struct_elt_bitpos) (value_find_oload_method_list, find_overload_match) (value_rtti_indirect_type): Likewise. * valprint.c (val_print_scalar_type_p, generic_val_print): Likewise. * value.c (value_actual_type, value_as_address, unpack_long) (pack_long, pack_unsigned_long, coerce_ref_if_computed) (coerce_ref): Likewise. * varobj.c (varobj_get_value_type): Likewise.
2017-01-01update copyright year range in GDB filesJoel Brobecker
This applies the second part of GDB's End of Year Procedure, which updates the copyright year range in all of GDB's files. gdb/ChangeLog: Update copyright year range in all GDB files.
2016-12-06Assert on lval_registerYao Qi
This patch adds asserts where the value's lval must be lval_register. This triggers an error in frame_register_unwind because VALUE_REGNUM is used but value's lval is not lval_register. This also reveals a design issue in frame_register_unwind, that is arguments addrp and realnump are mutually exclusive, we either use addrp (for lval_memory), or use realnump (for lval_register). This can be done in a separate patch. gdb: 2016-12-06 Yao Qi <yao.qi@linaro.org> * frame.c (frame_register_unwind): Set *realnump if *lvalp is lval_register. * value.c (deprecated_value_next_frame_id_hack): Assert value->lval is lval_register. (deprecated_value_regnum_hack): Likewise.
2016-11-28Restrict checking value.lval on using addressYao Qi
With the previous change, value.location.address is only valid for lval_memory. This patch restrict some checking on value.lval on using address. Since we have a check on VALUE_VAL in set_value_address, we need to set VALUE_VAL properly before set_value_address too. gdb: 2016-11-25 Yao Qi <yao.qi@linaro.org> * ada-lang.c (ensure_lval): Call set_value_address after setting VALUE_LVAL. * elfread.c (elf_gnu_ifunc_resolve_addr): Set VALUE_LVAL to lval_memory. (elf_gnu_ifunc_resolver_return_stop): Likewise. * value.c (value_fn_field): Likewise. (value_from_contents_and_address_unresolved): Likewise. (value_from_contents_and_address): Likewise. (value_address): Check value->lval isn't lval_memory. (value_raw_address): Likewise. (set_value_address): Assert value->lval is lval_memory.
2016-11-28Adjust Value.location for lval_registerYao Qi
value.regnum and value.next_frame_id are only used for lval_register, so this patch moves them to union value.location. As a result, when we copy value, only copy location, don't need to copy regnum and next_frame_id. This patch also changes regnum's type to int as there is no space constraint, so update deprecated_value_regnum_hack return type too. gdb: 2016-11-28 Yao Qi <yao.qi@linaro.org> * valops.c (value_slice): Don't set frame id of slice. * value.c (struct value) <regnum, next_frame_id>: Move them to... (struct value) <location>: ... here. Update comments. (allocate_value_lazy): Don't set frame id and regnum. (deprecated_value_next_frame_id_hack): Adjust. (deprecated_value_regnum_hack): Adjust. (value_copy): Don't copy frame id and regnu. (value_primitive_field): Likewise. (value_from_component): Likewise. (deprecated_value_regnum_hack): Return int *. * value.h (deprecated_value_regnum_hack): Update declaration.
2016-11-22Use VALUE_NEXT_FRAME_ID in value_from_componentYao Qi
We renamed VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID recently, https://sourceware.org/ml/gdb-patches/2016-11/msg00018.html and we should use VALUE_NEXT_FRAME_ID in value_from_component too. gdb: 2016-11-22 Yao Qi <yao.qi@linaro.org> * value.c (value_from_component): Use VALUE_NEXT_FRAME_ID instead of VALUE_FROM_ID.
2016-11-21Create subobject value in pretty printerYao Qi
Nowadays, we create a value of subobject in pretty printer with 'address' being used, value = value_from_contents_and_address (type, valaddr + embedded_offset, address + embedded_offset); set_value_component_location (value, val); /* set_value_component_location resets the address, so we may need to set it again. */ if (VALUE_LVAL (value) != lval_internalvar && VALUE_LVAL (value) != lval_internalvar_component && VALUE_LVAL (value) != lval_computed) set_value_address (value, address + embedded_offset); value_from_contents_and_address creates a value from memory, but the value we are pretty-printing may not from memory at all. Instead of using value_from_contents_and_address, we create a value of subobject with the same location as object's but different offset. We avoid using address in this way. As a result, parameter 'address' in apply_val_pretty_printer is no longer needed, we can remove it in next step. We've already had the location of the 'whole' value, so it is safe to assume we can create a value of 'component' or 'suboject' value at the same location but with different offset. gdb: 2016-11-21 Yao Qi <yao.qi@linaro.org> * guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer): Don't call value_from_contents_and_address and set_value_address. Call value_from_component. * python/py-prettyprint.c (gdbpy_apply_val_pretty_printer): Likewise. * value.c (value_from_component): New function. * value.h (value_from_component): Likewise. * valarith.c (value_subscripted_rvalue): Call value_from_component.
2016-11-16Change meaning of VALUE_FRAME_ID; rename to VALUE_NEXT_FRAME_IDKevin Buettner
The VALUE_FRAME_ID macro provides access to a member in struct value that's used to hold the frame id that's used when determining a register's value or when assigning to a register. The underlying member has a long and obscure name. I won't refer to it here, but will simply refer to VALUE_FRAME_ID as if it's the struct value member instead of being a convenient macro. At the moment, without this patch in place, VALUE_FRAME_ID is set in value_of_register_lazy() and several other locations to hold the frame id of the frame passed to those functions. VALUE_FRAME_ID is used in the lval_register case of value_fetch_lazy(). To fetch the register's value, it calls get_frame_register_value() which, in turn, calls frame_unwind_register_value() with frame->next. A python based unwinder may wish to determine the value of a register or evaluate an expression containing a register. When it does this, value_fetch_lazy() will be called under some circumstances. It will attempt to determine the frame id associated with the frame passed to it. In so doing, it will end up back in the frame sniffer of the very same python unwinder that's attempting to learn the value of a register as part of the sniffing operation. This recursion is not desirable. As noted above, when value_fetch_lazy() wants to fetch a register's value, it does so (indirectly) by unwinding from frame->next. With this in mind, a solution suggests itself: Change VALUE_FRAME_ID to hold the frame id associated with the next frame. Then, when it comes time to obtain the value associated with the register, we can simply unwind from the frame corresponding to the frame id stored in VALUE_FRAME_ID. This neatly avoids the python unwinder recursion problem by changing when the "next" operation occurs. Instead of the "next" operation occuring when the register value is fetched, it occurs earlier on when assigning a frame id to VALUE_FRAME_ID. (Thanks to Pedro for this suggestion.) This patch implements this idea. It builds on the patch "Distinguish sentinel frame from null frame". Without that work in place, it's necessary to check for null_id at several places and then obtain the sentinel frame. It also renames most occurences of VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID to reflect the new meaning of this field. There are several uses of VALUE_FRAME_ID which were not changed. In each case, the original meaning of VALUE_FRAME_ID is required to get correct results. In all but one of these uses, either put_frame_register_bytes() or get_frame_register_bytes() is being called with the frame value obtained from VALUE_FRAME_ID. Both of these functions perform some unwinding by performing a "->next" operation on the frame passed to it. If we were to use the new VALUE_NEXT_FRAME_ID macro, this would effectively do two "->next" operations, which is not what we want. The VALUE_FRAME_ID macro has been redefined in terms of VALUE_NEXT_FRAME_ID. It simply fetches the previous frame's id, providing this id as the value of the macro. gdb/ChangeLog: * value.h (VALUE_FRAME_ID): Rename to VALUE_NEXT_FRAME_ID. Update comment. Create new VALUE_FRAME_ID which is defined in terms of VALUE_NEXT_FRAME_ID. (deprecated_value_frame_id_hack): Rename to deprecated_value_next_frame_id_hack. * dwarf2loc.c, findvar.c, frame-unwind.c, sentinel-frame.c, valarith.c, valops.c, value.c: Adjust nearly all occurences of VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID. Add comments for those which did not change. * value.c (struct value): Rename frame_id field to next_frame_id. Update comment. (deprecated_value_frame_id_hack): Rename to deprecated_value_next_frame_id_hack. (value_fetch_lazy): Call frame_unwind_register_value() instead of get_frame_register_value(). * frame.c (get_prev_frame_id_by_id): New function. * frame.h (get_prev_frame_id_by_id): Declare. * dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Make VALUE_NEXT_FRAME_ID refer to the next frame. * findvar.c (value_of_register_lazy): Likewise. (default_value_from_register): Likewise. (value_from_register): Likewise. * frame_unwind.c (frame_unwind_got_optimized): Likewise. * sentinel-frame.c (sentinel_frame_prev_register): Likewise. * value.h (VALUE_FRAME_ID): Update comment describing this macro.
2016-11-08'struct expression *' -> gdb::unique_xmalloc_ptr<expression>Pedro Alves
This patch makes parse_expression and friends return a unique_ptr instead of raw pointer [1]: typedef gdb::unique_malloc_ptr<expression> expression_up; and then adjusts the codebase throughout to stop using cleanups to manage lifetime of expression pointers. Whenever I found a structure owning an expression pointer, I made it store a unique_ptr instead of a raw pointer, which then requires using new/delete of the holding structure, instead of XNEW/xfree. [1] - I'd like to set the rule that types named with an "_up" suffix are unique_ptr typedefs. Note I used gdb::unique_xmalloc_ptr instead of gdb::unique_ptr, simply because we still use xmalloc instead of new to allocate expression objects. Once that's changed, all we need to do is change the expression_up typedef and the smart pointer will then call delete instead of xfree. gdb/ChangeLog: 2016-11-08 Pedro Alves <palves@redhat.com> * ada-lang.c (ada_read_renaming_var_value): Use expression_up. (struct ada_catchpoint_location) <excep_cond_expr>: Now an expression_up. (ada_catchpoint_location_dtor): Reset excep_cond_expr instead of using xfree. (create_excep_cond_exprs): Use expression_up and gdb::move. (allocate_location_exception): Use new instead of XNEW. (should_stop_exception): Likewise. Adjust to use expression_up. (create_ada_exception_catchpoint): Use new instead of XNEW. * ax-gdb.c (agent_eval_command_one): Use expression_up instead of cleanups. (maint_agent_printf_command): Use expression_up. * break-catch-sig.c (create_signal_catchpoint): Use new instead of XNEW. * break-catch-syscall.c (create_syscall_event_catchpoint): Likewise. * break-catch-throw.c (handle_gnu_v3_exceptions): Use new instead of XCNEW. Use gdb::unique_ptr instead of cleanups. * breakpoint.c (set_breakpoint_condition, update_watchpoint) (parse_cmd_to_aexpr, watchpoint_check) (bpstat_check_breakpoint_conditions, watchpoint_locations_match): Adjust to use expression_up. (init_bp_location): Adjust. (free_bp_location): Use delete instead of xfree. (set_raw_breakpoint_without_location, set_raw_breakpoint) (add_solib_catchpoint, create_fork_vfork_event_catchpoint) (new_single_step_breakpoint, create_breakpoint_sal): Use new instead of XNEW. (find_condition_and_thread): Adjust to use expression_up. (create_breakpoint): Use new instead of XNEW. (dtor_watchpoint): Don't xfree expression pointers, they're unique_ptr's now. (insert_watchpoint, remove_watchpoint): Adjust. (watch_command_1): Use expression_up. Use new instead of XCNEW. (catch_exec_command_1): Use new instead of XNEW. (bp_location_dtor): Don't xfree expression pointers, they're unique_ptr's now. (base_breakpoint_allocate_location) (strace_marker_create_breakpoints_sal): Use new instead of XNEW. (delete_breakpoint): Use delete instead of xfree. * breakpoint.h (struct bp_location) <cond>: Now an unique_ptr<expression> instead of a raw pointer. (struct watchpoint) <exp, cond_exp>: Likewise. * cli/cli-script.c (execute_control_command): Use expression_up instead of cleanups. * dtrace-probe.c (dtrace_process_dof_probe): Use expression_up. * eval.c (parse_and_eval_address, parse_and_eval_long) (parse_and_eval, parse_to_comma_and_eval, parse_and_eval_type): Use expression_up instead of cleanups. * expression.h (expression_up): New typedef. (parse_expression, parse_expression_with_language, parse_exp_1): Change return type to expression_up. * mi/mi-main.c (mi_cmd_data_evaluate_expression) (print_variable_or_computed): Use expression_up. * objc-lang.c (print_object_command): Use expression_up instead of cleanups. * parse.c (parse_exp_1, parse_exp_in_context) (parse_exp_in_context_1, parse_expression) (parse_expression_with_language): Return an expression_up instead of a raw pointer. (parse_expression_for_completion): Use expression_up. * printcmd.c (struct display) <exp>: Now an expression_up instead of a raw pointer. (print_command_1, output_command_const, set_command, x_command): Use expression_up instead of cleanups. (display_command): Likewise. Use new instead of XNEW. (free_display): Use delete instead of xfree. (do_one_display): Adjust to use expression_up. * remote.c (remote_download_tracepoint): Likewise. * stack.c (return_command): Likewise. * tracepoint.c (validate_actionline, encode_actions_1): Use expression_up instead of cleanups. * typeprint.c (whatis_exp, maintenance_print_type): Likewise. * value.c (init_if_undefined_command): Likewise. * varobj.c (struct varobj_root) <exp>: Now an expression_up instead of a raw pointer. (varobj_create): Adjust. (varobj_set_value): Use an expression_up instead of cleanups. (new_root_variable): Use new instead of XNEW. (free_variable): Use delete instead of xfree. (value_of_root_1): Use std::swap.
2016-09-16gdb: Use std::min and std::max throughoutPedro Alves
Otherwise including <string> or some other C++ header is broken. E.g.: In file included from /opt/gcc/include/c++/7.0.0/bits/char_traits.h:39:0, from /opt/gcc/include/c++/7.0.0/string:40, from /home/pedro/gdb/mygit/cxx-convertion/src/gdb/infrun.c:68: /opt/gcc/include/c++/7.0.0/bits/stl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2 min(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ /opt/gcc/include/c++/7.0.0/bits/stl_algobase.h:265:56: error: macro "max" passed 3 arguments, but takes just 2 max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ In file included from .../src/gdb/infrun.c:21:0: To the best of my grepping abilities, I believe I adjusted all min/max calls. gdb/ChangeLog: 2016-09-16 Pedro Alves <palves@redhat.com> * defs.h (min, max): Delete. * aarch64-tdep.c: Include <algorithm> and use std::min and std::max throughout. * aarch64-tdep.c: Likewise. * alpha-tdep.c: Likewise. * amd64-tdep.c: Likewise. * amd64-windows-tdep.c: Likewise. * arm-tdep.c: Likewise. * avr-tdep.c: Likewise. * breakpoint.c: Likewise. * btrace.c: Likewise. * ctf.c: Likewise. * disasm.c: Likewise. * doublest.c: Likewise. * dwarf2loc.c: Likewise. * dwarf2read.c: Likewise. * environ.c: Likewise. * exec.c: Likewise. * f-exp.y: Likewise. * findcmd.c: Likewise. * ft32-tdep.c: Likewise. * gcore.c: Likewise. * hppa-tdep.c: Likewise. * i386-darwin-tdep.c: Likewise. * i386-tdep.c: Likewise. * linux-thread-db.c: Likewise. * lm32-tdep.c: Likewise. * m32r-tdep.c: Likewise. * m88k-tdep.c: Likewise. * memrange.c: Likewise. * minidebug.c: Likewise. * mips-tdep.c: Likewise. * moxie-tdep.c: Likewise. * nds32-tdep.c: Likewise. * nios2-tdep.c: Likewise. * nto-procfs.c: Likewise. * parse.c: Likewise. * ppc-sysv-tdep.c: Likewise. * probe.c: Likewise. * record-btrace.c: Likewise. * remote.c: Likewise. * rs6000-tdep.c: Likewise. * rx-tdep.c: Likewise. * s390-linux-nat.c: Likewise. * s390-linux-tdep.c: Likewise. * ser-tcp.c: Likewise. * sh-tdep.c: Likewise. * sh64-tdep.c: Likewise. * source.c: Likewise. * sparc-tdep.c: Likewise. * symfile.c: Likewise. * target-memory.c: Likewise. * target.c: Likewise. * tic6x-tdep.c: Likewise. * tilegx-tdep.c: Likewise. * tracefile-tfile.c: Likewise. * tracepoint.c: Likewise. * valprint.c: Likewise. * value.c: Likewise. * xtensa-tdep.c: Likewise. * cli/cli-cmds.c: Likewise. * compile/compile-object-load.c: Likewise.
2016-08-09Fix PR gdb/20295: GDB segfaults printing bitfield member of optimized out valuePedro Alves
With something like: struct A { int bitfield:4; } var; If 'var' ends up wholly-optimized out, printing 'var.bitfield' crashes gdb here: (top-gdb) bt #0 0x000000000058b89f in extract_unsigned_integer (addr=0x2 <error: Cannot access memory at address 0x2>, len=2, byte_order=BFD_ENDIAN_LITTLE) at /home/pedro/gdb/mygit/src/gdb/findvar.c:109 #1 0x00000000005a187a in unpack_bits_as_long (field_type=0x16cff70, valaddr=0x0, bitpos=16, bitsize=12) at /home/pedro/gdb/mygit/src/gdb/value.c:3347 #2 0x00000000005a1b9d in unpack_value_bitfield (dest_val=0x1b5d9d0, bitpos=16, bitsize=12, valaddr=0x0, embedded_offset=0, val=0x1b5d8d0) at /home/pedro/gdb/mygit/src/gdb/value.c:3441 #3 0x00000000005a2a5f in value_fetch_lazy (val=0x1b5d9d0) at /home/pedro/gdb/mygit/src/gdb/value.c:3958 #4 0x00000000005a10a7 in value_primitive_field (arg1=0x1b5d8d0, offset=0, fieldno=0, arg_type=0x16d04c0) at /home/pedro/gdb/mygit/src/gdb/value.c:3161 #5 0x00000000005b01e5 in do_search_struct_field (name=0x1727c60 "bitfield", arg1=0x1b5d8d0, offset=0, type=0x16d04c0, looking_for_baseclass=0, result_ptr=0x7fffffffcaf8, [...] unpack_value_bitfield is already optimized-out/unavailable -aware: (...) VALADDR points to the contents of VAL. If the VAL's contents required to extract the bitfield from are unavailable/optimized out, DEST_VAL is correspondingly marked unavailable/optimized out. however, it is not considering the case of the value having no contents buffer at all, as can happen through allocate_optimized_out_value. gdb/ChangeLog: 2016-08-09 Pedro Alves <palves@redhat.com> * value.c (unpack_value_bitfield): Skip unpacking if the parent has no contents buffer to begin with. gdb/testsuite/ChangeLog: 2016-08-09 Pedro Alves <palves@redhat.com> * gdb.dwarf2/bitfield-parent-optimized-out.exp: New file.
2016-06-24Support structure offsets that are 512K or larger.David Taylor
GDB computes structure byte offsets using a 32 bit integer. And, first it computes the offset in bits and then converts to bytes. The result is that any offset that if 512K bytes or larger overflows. This patch changes GDB to use LONGEST for such calculations. PR gdb/17520 Structure offset wrong when 1/4 GB or greater. * c-lang.h: Change all parameters, variables, and struct or union members used as struct or union fie3ld offsets from int to LONGEST. * c-valprint.c: Likewise. * cp-abi.c: Likewise. * cp-abi.h: Likewise. * cp-valprint.c: Likewise. * d-valprint.c: Likewise. * dwarf2loc.c: Likewise. * eval.c: Likewise. * extension-priv.h: Likewise. * extension.c: Likewise. * extension.h: Likewise. * findvar.c: Likewise. * gdbtypes.h: Likewise. * gnu-v2-abi.c: Likewise. * gnu-v3-abi.c: Likewise. * go-valprint.c: Likewise. * guile/guile-internal.h: Likewise. * guile/scm-pretty-print.c: Likewise. * jv-valprint.c Likewise. * opencl-lang.c: Likewise. * p-lang.h: Likewise. * python/py-prettyprint.c: Likewise. * python/python-internal.h: Likewise. * spu-tdep.c: Likewise. * typeprint.c: Likewise. * valarith.c: Likewise. * valops.c: Likewise. * valprint.c: Likewise. * valprint.h: Likewise. * value.c: Likewise. * value.h: Likewise. * p-valprint.c: Likewise. * c-typeprint.c (c_type_print_base): When printing offset, use plongest, not %d. * gdbtypes.c (recursive_dump_type): Ditto.
2016-05-07remove trivialy unused variablesTrevor Saunders
gdb/ChangeLog: 2016-05-07 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> * aarch64-linux-tdep.c (aarch64_linux_sigframe_init): Remove unused variables. * aarch64-tdep.c (aarch64_skip_prologue): Likewise. (aarch64_scan_prologue): Likewise. (aarch64_prologue_prev_register): Likewise. (aarch64_dwarf2_prev_register): Likewise. (pass_in_v): Likewise. (aarch64_push_dummy_call): Likewise. (aarch64_breakpoint_from_pc): Likewise. (aarch64_return_in_memory): Likewise. (aarch64_return_value): Likewise. (aarch64_displaced_step_b_cond): Likewise. (aarch64_displaced_step_cb): Likewise. (aarch64_displaced_step_tb): Likewise. (aarch64_gdbarch_init): Likewise. (aarch64_process_record): Likewise. * alpha-mdebug-tdep.c (alpha_mdebug_init_abi): Likewise. * alpha-tdep.c (_initialize_alpha_tdep): Likewise. * amd64-dicos-tdep.c (amd64_dicos_init_abi): Likewise. * amd64-linux-tdep.c (amd64_dtrace_parse_probe_argument): Likewise. * amd64-tdep.c (fixup_riprel): Likewise. * amd64-windows-tdep.c (amd64_windows_frame_decode_epilogue): Likewise. (amd64_windows_frame_decode_insns): Likewise. (amd64_windows_frame_cache): Likewise. (amd64_windows_frame_prev_register): Likewise. (amd64_windows_frame_this_id): Likewise. (amd64_windows_init_abi): Likewise. * arm-linux-tdep.c (arm_linux_get_syscall_number): Likewise. (arm_linux_get_next_pcs_syscall_next_pc): Likewise. * arm-symbian-tdep.c (arm_symbian_init_abi): Likewise. * arm-tdep.c (arm_make_epilogue_frame_cache): Likewise. (arm_epilogue_frame_prev_register): Likewise. (arm_record_vdata_transfer_insn): Likewise. (arm_record_exreg_ld_st_insn): Likewise. * auto-load.c (execute_script_contents): Likewise. (print_scripts): Likewise. * avr-tdep.c (avr_frame_prev_register): Likewise. (avr_push_dummy_call): Likewise. * bfin-linux-tdep.c (bfin_linux_sigframe_init): Likewise. * bfin-tdep.c (bfin_gdbarch_init): Likewise. * blockframe.c (find_pc_partial_function_gnu_ifunc): Likewise. * break-catch-throw.c (fetch_probe_arguments): Likewise. * breakpoint.c (breakpoint_xfer_memory): Likewise. (breakpoint_init_inferior): Likewise. (breakpoint_inserted_here_p): Likewise. (software_breakpoint_inserted_here_p): Likewise. (hardware_breakpoint_inserted_here_p): Likewise. (bpstat_what): Likewise. (break_range_command): Likewise. (save_breakpoints): Likewise. * coffread.c (coff_symfile_read): Likewise. * cris-tdep.c (cris_push_dummy_call): Likewise. (cris_scan_prologue): Likewise. (cris_register_size): Likewise. (_initialize_cris_tdep): Likewise. * d-exp.y: Likewise. * dbxread.c (dbx_read_symtab): Likewise. (process_one_symbol): Likewise. (coffstab_build_psymtabs): Likewise. (elfstab_build_psymtabs): Likewise. * dicos-tdep.c (dicos_init_abi): Likewise. * disasm.c (do_mixed_source_and_assembly): Likewise. (gdb_disassembly): Likewise. * dtrace-probe.c (dtrace_process_dof): Likewise. * dwarf2read.c (error_check_comp_unit_head): Likewise. (build_type_psymtabs_1): Likewise. (skip_one_die): Likewise. (process_imported_unit_die): Likewise. (dwarf2_physname): Likewise. (read_file_scope): Likewise. (setup_type_unit_groups): Likewise. (create_dwo_cu_reader): Likewise. (create_dwo_cu): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (lookup_dwo_unit_in_dwp): Likewise. (free_dwo_file): Likewise. (check_producer): Likewise. (dwarf2_add_typedef): Likewise. (dwarf2_add_member_fn): Likewise. (read_unsigned_leb128): Likewise. (read_signed_leb128): Likewise. (dwarf2_const_value): Likewise. (follow_die_sig_1): Likewise. (dwarf_decode_macro_bytes): Likewise. * extension.c (restore_active_ext_lang): Likewise. * frv-linux-tdep.c (frv_linux_sigtramp_frame_cache): Likewise. * ft32-tdep.c (ft32_analyze_prologue): Likewise. * gdbtypes.c (lookup_typename): Likewise. (resolve_dynamic_range): Likewise. (check_typedef): Likewise. * h8300-tdep.c (h8300_is_argument_spill): Likewise. (h8300_gdbarch_init): Likewise. * hppa-tdep.c (hppa32_push_dummy_call): Likewise. (hppa_frame_this_id): Likewise. (_initialize_hppa_tdep): Likewise. * hppanbsd-tdep.c (hppanbsd_sigtramp_cache_init): Likewise. * hppaobsd-tdep.c (hppaobsd_supply_fpregset): Likewise. * i386-dicos-tdep.c (i386_dicos_init_abi): Likewise. * i386-tdep.c (i386_bnd_type): Likewise. (i386_gdbarch_init): Likewise. (i386_mpx_bd_base): Likewise. * i386nbsd-tdep.c (i386nbsd_sigtramp_cache_init): Likewise. * i386obsd-tdep.c (i386obsd_elf_init_abi): Likewise. * ia64-tdep.c (examine_prologue): Likewise. (ia64_frame_cache): Likewise. (ia64_push_dummy_call): Likewise. * infcmd.c (finish_command_fsm_async_reply_reason): Likewise. (default_print_one_register_info): Likewise. * infrun.c (infrun_thread_ptid_changed): Likewise. (thread_still_needs_step_over): Likewise. (stop_all_threads): Likewise. (restart_threads): Likewise. (keep_going_stepped_thread): Likewise. * iq2000-tdep.c (iq2000_scan_prologue): Likewise. * language.c (language_init_primitive_type_symbols): Likewise. * linespec.c (add_sal_to_sals): Likewise. * linux-nat.c (status_callback): Likewise. (kill_unfollowed_fork_children): Likewise. (linux_nat_kill): Likewise. * linux-tdep.c (linux_fill_prpsinfo): Likewise. * linux-thread-db.c (thread_db_notice_clone): Likewise. (record_thread): Likewise. * location.c (string_to_event_location_basic): Likewise. * m32c-tdep.c (m32c_prev_register): Likewise. * m32r-linux-tdep.c (m32r_linux_init_abi): Likewise. * m32r-tdep.c (decode_prologue): Likewise. * m68klinux-tdep.c (m68k_linux_sigtramp_frame_cache): Likewise. * machoread.c (macho_symtab_read): Likewise. (macho_symfile_read): Likewise. (macho_symfile_offsets): Likewise. * maint.c (set_per_command_cmd): Likewise. * mi/mi-cmd-stack.c (mi_cmd_stack_list_locals): Likewise. (mi_cmd_stack_list_variables): Likewise. * mi/mi-main.c (mi_cmd_exec_run): Likewise. (output_register): Likewise. (mi_cmd_execute): Likewise. (mi_cmd_trace_define_variable): Likewise. (print_variable_or_computed): Likewise. * minsyms.c (prim_record_minimal_symbol_full): Likewise. * mn10300-tdep.c (mn10300_frame_prev_register): Likewise. * msp430-tdep.c (msp430_pseudo_register_write): Likewise. * mt-tdep.c (mt_registers_info): Likewise. * nios2-tdep.c (nios2_analyze_prologue): Likewise. (nios2_push_dummy_call): Likewise. (nios2_frame_unwind_cache): Likewise. (nios2_stub_frame_cache): Likewise. (nios2_stub_frame_sniffer): Likewise. (nios2_gdbarch_init): Likewise. * ppc-ravenscar-thread.c: Likewise. * ppcfbsd-tdep.c (ppcfbsd_sigtramp_frame_cache): Likewise. * python/py-evts.c (add_new_registry): Likewise. * python/py-finishbreakpoint.c (bpfinishpy_init): Likewise. (bpfinishpy_detect_out_scope_cb): Likewise. * python/py-framefilter.c (py_print_value): Likewise. * python/py-inferior.c (infpy_write_memory): Likewise. * python/py-infevents.c (create_inferior_call_event_object): Likewise. * python/py-infthread.c (thpy_get_ptid): Likewise. * python/py-linetable.c (ltpy_get_pcs_for_line): Likewise. (ltpy_get_all_source_lines): Likewise. (ltpy_is_valid): Likewise. (ltpy_iternext): Likewise. * python/py-symtab.c (symtab_and_line_to_sal_object): Likewise. * python/py-unwind.c (pyuw_object_attribute_to_pointer): Likewise. (unwind_infopy_str): Likewise. * python/py-varobj.c (py_varobj_get_iterator): Likewise. * ravenscar-thread.c (ravenscar_inferior_created): Likewise. * rs6000-aix-tdep.c (rs6000_push_dummy_call): Likewise. * rs6000-lynx178-tdep.c (rs6000_lynx178_push_dummy_call): Likewise. * rs6000-tdep.c (ppc_deal_with_atomic_sequence): Likewise. * s390-linux-tdep.c (s390_supply_tdb_regset): Likewise. (s390_frame_prev_register): Likewise. (s390_dwarf2_frame_init_reg): Likewise. (s390_record_vr): Likewise. (s390_process_record): Likewise. * score-tdep.c (score_push_dummy_call): Likewise. (score3_analyze_prologue): Likewise. * sh-tdep.c (sh_extract_return_value_nofpu): Likewise. * sh64-tdep.c (sh64_analyze_prologue): Likewise. (sh64_push_dummy_call): Likewise. (sh64_extract_return_value): Likewise. (sh64_do_fp_register): Likewise. * solib-aix.c (solib_aix_get_section_offsets): Likewise. * solib-darwin.c (darwin_read_exec_load_addr_from_dyld): Likewise. (darwin_solib_read_all_image_info_addr): Likewise. * solib-dsbt.c (enable_break): Likewise. * solib-frv.c (enable_break2): Likewise. (frv_fdpic_find_canonical_descriptor): Likewise. * solib-svr4.c (svr4_handle_solib_event): Likewise. * sparc-tdep.c (sparc_skip_stack_check): Likewise. * sparc64-linux-tdep.c (sparc64_linux_get_longjmp_target): Likewise. * sparcobsd-tdep.c (sparc32obsd_init_abi): Likewise. * spu-tdep.c (info_spu_dma_cmdlist): Likewise. * stack.c (read_frame_local): Likewise. * symfile.c (symbol_file_add_separate): Likewise. (remove_symbol_file_command): Likewise. * symmisc.c (maintenance_print_one_line_table): Likewise. * symtab.c (symbol_cache_flush): Likewise. (basic_lookup_transparent_type): Likewise. (sort_search_symbols_remove_dups): Likewise. * target.c (target_memory_map): Likewise. (target_detach): Likewise. (target_resume): Likewise. (acquire_fileio_fd): Likewise. (target_store_registers): Likewise. * thread.c (print_thread_info_1): Likewise. * tic6x-tdep.c (tic6x_analyze_prologue): Likewise. * tilegx-linux-tdep.c (tilegx_linux_sigframe_init): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. (tilegx_analyze_prologue): Likewise. (tilegx_stack_frame_destroyed_p): Likewise. (tilegx_frame_cache): Likewise. * tracefile.c (trace_save): Likewise. * tracepoint.c (encode_actions_and_make_cleanup): Likewise. (start_tracing): Likewise. (print_one_static_tracepoint_marker): Likewise. * tui/tui.c (tui_enable): Likewise. * valops.c (value_struct_elt_bitpos): Likewise. (find_overload_match): Likewise. (find_oload_champ): Likewise. * value.c (value_contents_copy_raw): Likewise. * windows-tdep.c (windows_get_tlb_type): Likewise. * x86-linux-nat.c (x86_linux_enable_btrace): Likewise. * xcoffread.c (record_minimal_symbol): Likewise. (scan_xcoff_symtab): Likewise. * xtensa-tdep.c (execute_code): Likewise. (xtensa_gdbarch_init): Likewise. (_initialize_xtensa_tdep): Likewise.
2016-04-26fort_dyn_array: Enable dynamic member types inside a structure.Bernhard Heckel
Fortran supports dynamic types for which bounds, size and location can vary during their lifetime. As a result of the dynamic behaviour, they have to be resolved at every query. This patch will resolve the type of a structure field when it is dynamic. 2016-04-26 Bernhard Heckel <bernhard.heckel@intel.com> 2016-04-26 Keven Boell <keven.boell@intel.com> Before: (gdb) print threev%ivla(1) Cannot access memory at address 0x3 (gdb) print threev%ivla(5) no such vector element After: (gdb) print threev%ivla(1) $9 = 1 (gdb) print threev%ivla(5) $10 = 42 gdb/Changelog: * NEWS: Add new supported features for fortran. * gdbtypes.c (remove_dyn_prop): New. (resolve_dynamic_struct): Keep type length for fortran structs. * gdbtypes.h: Forward declaration of new function. * value.c (value_address): Return dynamic resolved location of a value. (set_value_component_location): Adjust the value address for single value prints. (value_primitive_field): Support value types with a dynamic location. (set_internalvar): Remove dynamic location property of internal variables. gdb/testsuite/Changelog: * gdb.fortran/vla-type.f90: New file. * gdb.fortran/vla-type.exp: New file.
2016-04-14Avoid implicit float <-> integer conversion warningsPedro Alves
On: $ uname -a NetBSD gcc70.fsffrance.org 5.1 NetBSD 5.1 (GENERIC) #0: Sat Nov 6 13:19:33 UTC 2010 builds@b6.netbsd.org:/home/builds/ab/netbsd-5-1-RELEASE/amd64/201011061943Z-obj/home/builds/ab/netbsd-5-1-RELEASE/src/sys/arch/amd64/compile/GENERIC amd64 With: $ g++ -v Using built-in specs. Target: x86_64--netbsd Configured with: /usr/src/tools/gcc/../../gnu/dist/gcc4/configure --enable-long-long --disable-multilib --enable-threads --disable-symvers --build=x86_64-unknown-netbsd4.99.72 --host=x86_64--netbsd --target=x86_64--netbsd --enable-__cxa_atexit Thread model: posix gcc version 4.1.3 20080704 prerelease (NetBSD nb2 20081120) I saw: ../../src/gdb/ada-typeprint.c: In function 'void print_fixed_point_type(type*, ui_file*)': ../../src/gdb/ada-typeprint.c:366: warning: passing 'float' for argument 2 to 'DOUBLEST ada_fixed_to_float(type*, LONGEST)' ../../src/gdb/value.c: In function 'LONGEST unpack_long(type*, const gdb_byte*)': ../../src/gdb/value.c:2833: warning: converting to 'LONGEST' from 'DOUBLEST' ../../src/gdb/value.c:2838: warning: converting to 'LONGEST' from 'DOUBLEST' gdb/ChangeLog: 2016-04-14 Pedro Alves <palves@redhat.com> * ada-typeprint.c (print_fixed_point_type): Don't pass float as argument to function expecting LONGEST. * value.c (unpack_long): Add casts to LONGEST.
2016-04-08value: Make accessor methods' parameters const-correctMartin Galvan
I did a quick pass over value.c and value.h and made some of the accessor methods' pass-by-reference parameters const-correct. Besides the obvious benefits, this is required if we want to use them on values that are already declared as const (such as the parameters to lval_funcs). There's probably a lot more stuff that can be made const, here and elsewhere. gdb/ChangeLog: 2016-04-08 Martin Galvan <martin.galvan@tallertechnologies.com> * value.c (value_next): Make pass-by-reference parameters const-correct. (value_parent): Likewise. (value_enclosing_type): Likewise. (value_lazy): Likewise. (value_stack): Likewise. (value_embedded_offset): Likewise. (value_pointed_to_offset): Likewise. (value_raw_address): Likewise. (deprecated_value_modifiable): Likewise. (value_free_to_mark): Likewise. (value_release_to_mark): Likewise. (internalvar_name): Likewise. (readjust_indirect_value_type): Likewise. (value_initialized): Likewise. * value.h (value_next): Likewise. (value_parent): Likewise. (value_enclosing_type): Likewise. (value_lazy): Likewise. (value_stack): Likewise. (value_embedded_offset): Likewise. (value_pointed_to_offset): Likewise. (value_raw_address): Likewise. (deprecated_value_modifiable): Likewise. (value_free_to_mark): Likewise. (value_release_to_mark): Likewise. (internalvar_name): Likewise. (readjust_indirect_value_type): Likewise. (value_initialized): Likewise.
2016-04-06Eliminate -var-create error for optzd ptr to structDon Breazeal
This patch eliminates an error thrown when accessing the value of a pointer to a structure where the pointer has been optimized out and 'set print object' is 'on'. The error shows up as the rather ugly value of the pointer variable in Eclipse. If 'set print object' is 'on', GDB tries to determine the actual (derived) type of the object rather than the declared type, which requires dereferencing the pointer, which in this cases throws an error because the pointer has been optimized out. The fix is to simply ignore the 'print object on' setting for pointers or references to structures when they have been optimized out. This means we just get the declared type instead of the actual type, because in this case that's the best that we can do. To implement the fix, value_optimized_out was modified so that it no longer throws an error when it fails to fetch the specified value. Instead, it just checks value->optimized_out. If we can't definitively say that the value is optimized out, then we assume it is not. gdb/ChangeLog: 2016-04-06 Don Breazeal <donb@codesourcery.com> * value.c (value_actual_type): Don't try to get rtti type of the value if it has been optimized out. (value_optimized_out): If a memory access error occurs, just check vaue->optimized_out.
2016-03-292016-03-29 Don Breazeal <donb@codesourcery.com>Don Breazeal
* gdb/value.c (value_actual_type): Fix formatting issue.
2016-02-01gdb: New set/show max-value-size command.Andrew Burgess
For languages with dynamic types, an incorrect program, or uninitialised variables within a program, could result in an incorrect, overly large type being associated with a value. Currently, attempting to print such a variable will result in gdb trying to allocate an overly large buffer. If this large memory allocation fails then the result can be gdb either terminating, or (due to memory contention) becoming unresponsive for the user. A new user visible variable in gdb helps guard against such problems, two new commands are available: set max-value-size show max-value-size The 'max-value-size' is the maximum size of memory in bytes that gdb will allocate for the contents of a value. Any attempt to allocate a value with a size greater than this will result in an error. The initial default for this limit is set at 64k, this is based on a similar limit that exists within the ada specific code. It is possible for the user to set max-value-size to unlimited, in which case the old behaviour is restored. gdb/ChangeLog: * value.c (max_value_size): New variable. (MIN_VALUE_FOR_MAX_VALUE_SIZE): New define. (show_max_value_size): New function. (check_type_length_before_alloc): New function. (allocate_value_contents): Call check_type_length_before_alloc. (set_value_enclosing_type): Likewise. (_initialize_values): Add set/show handler for max-value-size. * NEWS: Mention new set/show command. gdb/doc/ChangeLog: * gdb.texinfo (Value Sizes): New section. (Data): Add the 'Value Sizes' node to the menu. gdb/testsuite/ChangeLog: * gdb.base/max-value-size.c: New file. * gdb.base/max-value-size.exp: New file. * gdb.base/huge.exp: Disable max-value-size for this test.
2016-01-01GDB copyright headers update after running GDB's copyright.py script.Joel Brobecker
gdb/ChangeLog: Update year range in copyright notice of all files.
2015-08-26Replace some xmalloc-family functions with XNEW-family onesSimon Marchi
This patch is part of the make-gdb-buildable-in-C++ effort. The idea is to change some calls to the xmalloc family of functions to calls to the equivalents in the XNEW family. This avoids adding an explicit cast, so it keeps the code a bit more readable. Some of them also map relatively well to a C++ equivalent (XNEW (struct foo) -> new foo), so it will be possible to do scripted replacements if needed. I only changed calls that were obviously allocating memory for one or multiple "objects". Allocation of variable sizes (such as strings or buffer handling) will be for later (and won't use XNEW). - xmalloc (sizeof (struct foo)) -> XNEW (struct foo) - xmalloc (num * sizeof (struct foo)) -> XNEWVEC (struct foo, num) - xcalloc (1, sizeof (struct foo)) -> XCNEW (struct foo) - xcalloc (num, sizeof (struct foo)) -> XCNEWVEC (struct foo, num) - xrealloc (p, num * sizeof (struct foo) -> XRESIZEVEC (struct foo, p, num) - obstack_alloc (ob, sizeof (struct foo)) -> XOBNEW (ob, struct foo) - obstack_alloc (ob, num * sizeof (struct foo)) -> XOBNEWVEC (ob, struct foo, num) - alloca (sizeof (struct foo)) -> XALLOCA (struct foo) - alloca (num * sizeof (struct foo)) -> XALLOCAVEC (struct foo, num) Some instances of xmalloc followed by memset to zero the buffer were replaced by XCNEW or XCNEWVEC. I regtested on x86-64, Ubuntu 14.04, but the patch touches many architecture-specific files. For those I'll have to rely on the buildbot or people complaining that I broke their gdb. gdb/ChangeLog: * aarch64-linux-nat.c (aarch64_add_process): Likewise. * aarch64-tdep.c (aarch64_gdbarch_init): Likewise. * ada-exp.y (write_ambiguous_var): Likewise. * ada-lang.c (resolve_subexp): Likewise. (user_select_syms): Likewise. (assign_aggregate): Likewise. (ada_evaluate_subexp): Likewise. (cache_symbol): Likewise. * addrmap.c (allocate_key): Likewise. (addrmap_create_mutable): Likewise. * aix-thread.c (sync_threadlists): Likewise. * alpha-tdep.c (alpha_push_dummy_call): Likewise. (alpha_gdbarch_init): Likewise. * amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise. * arm-linux-nat.c (arm_linux_add_process): Likewise. * arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise. * arm-tdep.c (push_stack_item): Likewise. (arm_displaced_step_copy_insn): Likewise. (arm_gdbarch_init): Likewise. (_initialize_arm_tdep): Likewise. * avr-tdep.c (push_stack_item): Likewise. * ax-general.c (new_agent_expr): Likewise. * block.c (block_initialize_namespace): Likewise. * breakpoint.c (alloc_counted_command_line): Likewise. (update_dprintf_command_list): Likewise. (parse_breakpoint_sals): Likewise. (decode_static_tracepoint_spec): Likewise. (until_break_command): Likewise. (clear_command): Likewise. (update_global_location_list): Likewise. (get_breakpoint_objfile_data) Likewise. * btrace.c (ftrace_new_function): Likewise. (btrace_set_insn_history): Likewise. (btrace_set_call_history): Likewise. * buildsym.c (add_symbol_to_list): Likewise. (record_pending_block): Likewise. (start_subfile): Likewise. (start_buildsym_compunit): Likewise. (push_subfile): Likewise. (end_symtab_get_static_block): Likewise. (buildsym_init): Likewise. * cli/cli-cmds.c (source_command): Likewise. * cli/cli-decode.c (add_cmd): Likewise. * cli/cli-script.c (build_command_line): Likewise. (setup_user_args): Likewise. (realloc_body_list): Likewise. (process_next_line): Likewise. (copy_command_lines): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (read_pe_exported_syms): Likewise. * coffread.c (coff_locate_sections): Likewise. (coff_symtab_read): Likewise. (coff_read_struct_type): Likewise. * common/cleanups.c (make_my_cleanup2): Likewise. * common/common-exceptions.c (throw_it): Likewise. * common/filestuff.c (make_cleanup_close): Likewise. * common/format.c (parse_format_string): Likewise. * common/queue.h (DEFINE_QUEUE_P): Likewise. * compile/compile-object-load.c (munmap_list_add): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * compile/compile.c (append_args): Likewise. * corefile.c (specify_exec_file_hook): Likewise. * cp-support.c (make_symbol_overload_list): Likewise. * cris-tdep.c (push_stack_item): Likewise. (cris_gdbarch_init): Likewise. * ctf.c (ctf_trace_file_writer_new): Likewise. * dbxread.c (init_header_files): Likewise. (add_new_header_file): Likewise. (init_bincl_list): Likewise. (dbx_end_psymtab): Likewise. (start_psymtab): Likewise. (dbx_end_psymtab): Likewise. * dcache.c (dcache_init): Likewise. * dictionary.c (dict_create_hashed): Likewise. (dict_create_hashed_expandable): Likewise. (dict_create_linear): Likewise. (dict_create_linear_expandable): Likewise. * dtrace-probe.c (dtrace_process_dof_probe): Likewise. * dummy-frame.c (register_dummy_frame_dtor): Likewise. * dwarf2-frame-tailcall.c (cache_new_ref1): Likewise. * dwarf2-frame.c (dwarf2_build_frame_info): Likewise. (decode_frame_entry_1): Likewise. * dwarf2expr.c (new_dwarf_expr_context): Likewise. * dwarf2loc.c (dwarf2_compile_expr_to_ax): Likewise. * dwarf2read.c (dwarf2_has_info): Likewise. (create_signatured_type_table_from_index): Likewise. (dwarf2_read_index): Likewise. (dw2_get_file_names_reader): Likewise. (create_all_type_units): Likewise. (read_cutu_die_from_dwo): Likewise. (init_tu_and_read_dwo_dies): Likewise. (init_cutu_and_read_dies): Likewise. (create_all_comp_units): Likewise. (queue_comp_unit): Likewise. (inherit_abstract_dies): Likewise. (read_call_site_scope): Likewise. (dwarf2_add_field): Likewise. (dwarf2_add_typedef): Likewise. (dwarf2_add_member_fn): Likewise. (attr_to_dynamic_prop): Likewise. (abbrev_table_alloc_abbrev): Likewise. (abbrev_table_read_table): Likewise. (add_include_dir): Likewise. (add_file_name): Likewise. (dwarf_decode_line_header): Likewise. (dwarf2_const_value_attr): Likewise. (dwarf_alloc_block): Likewise. (parse_macro_definition): Likewise. (set_die_type): Likewise. (write_psymtabs_to_index): Likewise. (create_cus_from_index): Likewise. (dwarf2_create_include_psymtab): Likewise. (process_psymtab_comp_unit_reader): Likewise. (build_type_psymtab_dependencies): Likewise. (read_comp_units_from_section): Likewise. (compute_compunit_symtab_includes): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (load_partial_dies): Likewise. (dwarf2_symbol_mark_computed): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_read_minimal_symbols): Likewise. * environ.c (make_environ): Likewise. * eval.c (evaluate_subexp_standard): Likewise. * event-loop.c (create_file_handler): Likewise. (create_async_signal_handler): Likewise. (create_async_event_handler): Likewise. (create_timer): Likewise. * exec.c (build_section_table): Likewise. * fbsd-nat.c (fbsd_remember_child): Likewise. * fork-child.c (fork_inferior): Likewise. * frv-tdep.c (new_variant): Likewise. * gdbarch.sh (gdbarch_alloc): Likewise. (append_name): Likewise. * gdbtypes.c (rank_function): Likewise. (copy_type_recursive): Likewise. (add_dyn_prop): Likewise. * gnu-nat.c (make_proc): Likewise. (make_inf): Likewise. (gnu_write_inferior): Likewise. * gnu-v3-abi.c (build_gdb_vtable_type): Likewise. (build_std_type_info_type): Likewise. * guile/scm-param.c (compute_enum_list): Likewise. * guile/scm-utils.c (gdbscm_parse_function_args): Likewise. * guile/scm-value.c (gdbscm_value_call): Likewise. * h8300-tdep.c (h8300_gdbarch_init): Likewise. * hppa-tdep.c (hppa_init_objfile_priv_data): Likewise. (read_unwind_info): Likewise. * ia64-tdep.c (ia64_gdbarch_init): Likewise. * infcall.c (dummy_frame_context_saver_setup): Likewise. (call_function_by_hand_dummy): Likewise. * infcmd.c (step_once): Likewise. (finish_forward): Likewise. (attach_command): Likewise. (notice_new_inferior): Likewise. * inferior.c (add_inferior_silent): Likewise. * infrun.c (add_displaced_stepping_state): Likewise. (save_infcall_control_state): Likewise. (save_inferior_ptid): Likewise. (_initialize_infrun): Likewise. * jit.c (bfd_open_from_target_memory): Likewise. (jit_gdbarch_data_init): Likewise. * language.c (add_language): Likewise. * linespec.c (decode_line_2): Likewise. * linux-nat.c (add_to_pid_list): Likewise. (add_initial_lwp): Likewise. * linux-thread-db.c (add_thread_db_info): Likewise. (record_thread): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_gdbarch_init): Likewise. * m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise. * m68k-tdep.c (m68k_gdbarch_init): Likewise. * m88k-tdep.c (m88k_analyze_prologue): Likewise. * macrocmd.c (macro_define_command): Likewise. * macroexp.c (gather_arguments): Likewise. * macroscope.c (sal_macro_scope): Likewise. * macrotab.c (new_macro_table): Likewise. * mdebugread.c (push_parse_stack): Likewise. (parse_partial_symbols): Likewise. (parse_symbol): Likewise. (psymtab_to_symtab_1): Likewise. (new_block): Likewise. (new_psymtab): Likewise. (mdebug_build_psymtabs): Likewise. (add_pending): Likewise. (elfmdebug_build_psymtabs): Likewise. * mep-tdep.c (mep_gdbarch_init): Likewise. * mi/mi-main.c (mi_execute_command): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. * minidebug.c (lzma_open): Likewise. * minsyms.c (terminate_minimal_symbol_table): Likewise. * mips-linux-nat.c (mips_linux_insert_watchpoint): Likewise. * mips-tdep.c (mips_gdbarch_init): Likewise. * mn10300-tdep.c (mn10300_gdbarch_init): Likewise. * msp430-tdep.c (msp430_gdbarch_init): Likewise. * mt-tdep.c (mt_registers_info): Likewise. * nat/aarch64-linux.c (aarch64_linux_new_thread): Likewise. * nat/linux-btrace.c (linux_enable_bts): Likewise. (linux_enable_pt): Likewise. * nat/linux-osdata.c (linux_xfer_osdata_processes): Likewise. (linux_xfer_osdata_processgroups): Likewise. * nios2-tdep.c (nios2_gdbarch_init): Likewise. * nto-procfs.c (procfs_meminfo): Likewise. * objc-lang.c (start_msglist): Likewise. (selectors_info): Likewise. (classes_info): Likewise. (find_methods): Likewise. * objfiles.c (allocate_objfile): Likewise. (update_section_map): Likewise. * osabi.c (gdbarch_register_osabi): Likewise. (gdbarch_register_osabi_sniffer): Likewise. * parse.c (start_arglist): Likewise. * ppc-linux-nat.c (hwdebug_find_thread_points_by_tid): Likewise. (hwdebug_insert_point): Likewise. * printcmd.c (display_command): Likewise. (ui_printf): Likewise. * procfs.c (create_procinfo): Likewise. (load_syscalls): Likewise. (proc_get_LDT_entry): Likewise. (proc_update_threads): Likewise. * prologue-value.c (make_pv_area): Likewise. (pv_area_store): Likewise. * psymtab.c (extend_psymbol_list): Likewise. (init_psymbol_list): Likewise. (allocate_psymtab): Likewise. * python/py-inferior.c (add_thread_object): Likewise. * python/py-param.c (compute_enum_values): Likewise. * python/py-value.c (valpy_call): Likewise. * python/py-varobj.c (py_varobj_iter_next): Likewise. * python/python.c (ensure_python_env): Likewise. * record-btrace.c (record_btrace_start_replaying): Likewise. * record-full.c (record_full_reg_alloc): Likewise. (record_full_mem_alloc): Likewise. (record_full_end_alloc): Likewise. (record_full_core_xfer_partial): Likewise. * regcache.c (get_thread_arch_aspace_regcache): Likewise. * remote-fileio.c (remote_fileio_init_fd_map): Likewise. * remote-notif.c (remote_notif_state_allocate): Likewise. * remote.c (demand_private_info): Likewise. (remote_notif_stop_alloc_reply): Likewise. (remote_enable_btrace): Likewise. * reverse.c (save_bookmark_command): Likewise. * rl78-tdep.c (rl78_gdbarch_init): Likewise. * rx-tdep.c (rx_gdbarch_init): Likewise. * s390-linux-nat.c (s390_insert_watchpoint): Likewise. * ser-go32.c (dos_get_tty_state): Likewise. (dos_copy_tty_state): Likewise. * ser-mingw.c (ser_windows_open): Likewise. (ser_console_wait_handle): Likewise. (ser_console_get_tty_state): Likewise. (make_pipe_state): Likewise. (net_windows_open): Likewise. * ser-unix.c (hardwire_get_tty_state): Likewise. (hardwire_copy_tty_state): Likewise. * solib-aix.c (solib_aix_new_lm_info): Likewise. * solib-dsbt.c (dsbt_current_sos): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (frv_current_sos): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_bfd_fopen): Likewise. * solib-svr4.c (lm_info_read): Likewise. (svr4_copy_library_list): Likewise. (svr4_default_sos): Likewise. * source.c (find_source_lines): Likewise. (line_info): Likewise. (add_substitute_path_rule): Likewise. * spu-linux-nat.c (spu_bfd_open): Likewise. * spu-tdep.c (info_spu_dma_cmdlist): Likewise. * stabsread.c (dbx_lookup_type): Likewise. (read_type): Likewise. (read_member_functions): Likewise. (read_struct_fields): Likewise. (read_baseclasses): Likewise. (read_args): Likewise. (_initialize_stabsread): Likewise. * stack.c (func_command): Likewise. * stap-probe.c (handle_stap_probe): Likewise. * symfile.c (addrs_section_sort): Likewise. (addr_info_make_relative): Likewise. (load_section_callback): Likewise. (add_symbol_file_command): Likewise. (init_filename_language_table): Likewise. * symtab.c (create_filename_seen_cache): Likewise. (sort_search_symbols_remove_dups): Likewise. (search_symbols): Likewise. * target.c (make_cleanup_restore_target_terminal): Likewise. * thread.c (new_thread): Likewise. (enable_thread_stack_temporaries): Likewise. (make_cleanup_restore_current_thread): Likewise. (thread_apply_all_command): Likewise. * tic6x-tdep.c (tic6x_gdbarch_init): Likewise. * top.c (gdb_readline_wrapper): Likewise. * tracefile-tfile.c (tfile_trace_file_writer_new): Likewise. * tracepoint.c (trace_find_line_command): Likewise. (all_tracepoint_actions_and_cleanup): Likewise. (make_cleanup_restore_current_traceframe): Likewise. (get_uploaded_tp): Likewise. (get_uploaded_tsv): Likewise. * tui/tui-data.c (tui_alloc_generic_win_info): Likewise. (tui_alloc_win_info): Likewise. (tui_alloc_content): Likewise. (tui_add_content_elements): Likewise. * tui/tui-disasm.c (tui_find_disassembly_address): Likewise. (tui_set_disassem_content): Likewise. * ui-file.c (ui_file_new): Likewise. (stdio_file_new): Likewise. (tee_file_new): Likewise. * utils.c (make_cleanup_restore_integer): Likewise. (add_internal_problem_command): Likewise. * v850-tdep.c (v850_gdbarch_init): Likewise. * valops.c (find_oload_champ): Likewise. * value.c (allocate_value_lazy): Likewise. (record_latest_value): Likewise. (create_internalvar): Likewise. * varobj.c (install_variable): Likewise. (new_variable): Likewise. (new_root_variable): Likewise. (cppush): Likewise. (_initialize_varobj): Likewise. * windows-nat.c (windows_make_so): Likewise. * x86-nat.c (x86_add_process): Likewise. * xcoffread.c (arrange_linetable): Likewise. (allocate_include_entry): Likewise. (process_linenos): Likewise. (SYMBOL_DUP): Likewise. (xcoff_start_psymtab): Likewise. (xcoff_end_psymtab): Likewise. * xml-support.c (gdb_xml_parse_attr_ulongest): Likewise. * xtensa-tdep.c (xtensa_register_type): Likewise. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Likewise. (compile_bytecodes): Likewise. * dll.c (loaded_dll): Likewise. * event-loop.c (append_callback_event): Likewise. (create_file_handler): Likewise. (create_file_event): Likewise. * hostio.c (handle_open): Likewise. * inferiors.c (add_thread): Likewise. (add_process): Likewise. * linux-aarch64-low.c (aarch64_linux_new_process): Likewise. * linux-arm-low.c (arm_new_process): Likewise. (arm_new_thread): Likewise. * linux-low.c (add_to_pid_list): Likewise. (linux_add_process): Likewise. (handle_extended_wait): Likewise. (add_lwp): Likewise. (enqueue_one_deferred_signal): Likewise. (enqueue_pending_signal): Likewise. (linux_resume_one_lwp_throw): Likewise. (linux_resume_one_thread): Likewise. (linux_read_memory): Likewise. (linux_write_memory): Likewise. * linux-mips-low.c (mips_linux_new_process): Likewise. (mips_linux_new_thread): Likewise. (mips_add_watchpoint): Likewise. * linux-x86-low.c (initialize_low_arch): Likewise. * lynx-low.c (lynx_add_process): Likewise. * mem-break.c (set_raw_breakpoint_at): Likewise. (set_breakpoint): Likewise. (add_condition_to_breakpoint): Likewise. (add_commands_to_breakpoint): Likewise. (clone_agent_expr): Likewise. (clone_one_breakpoint): Likewise. * regcache.c (new_register_cache): Likewise. * remote-utils.c (look_up_one_symbol): Likewise. * server.c (queue_stop_reply): Likewise. (start_inferior): Likewise. (queue_stop_reply_callback): Likewise. (handle_target_event): Likewise. * spu-low.c (fetch_ppc_memory): Likewise. (store_ppc_memory): Likewise. * target.c (set_target_ops): Likewise. * thread-db.c (thread_db_load_search): Likewise. (try_thread_db_load_1): Likewise. * tracepoint.c (add_tracepoint): Likewise. (add_tracepoint_action): Likewise. (create_trace_state_variable): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtro): Likewise. (add_while_stepping_state): Likewise. * win32-low.c (child_add_thread): Likewise. (get_image_name): Likewise.
2015-08-01Replace the block_found global with explicit data-flowPierre-Marie de Rodat
As Pedro suggested on gdb-patches@ (see https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this change makes symbol lookup functions return a structure that includes both the symbol found and the block in which it was found. This makes it possible to get rid of the block_found global variable and thus makes block hunting explicit. gdb/ * ada-exp.y (write_object_renaming): Replace struct ada_symbol_info with struct block_symbol. Update field references accordingly. (block_lookup, select_possible_type_sym): Likewise. (find_primitive_type): Likewise. Also update call to ada_lookup_symbol to extract the symbol itself. (write_var_or_type, write_name_assoc): Likewise. * ada-lang.h (struct ada_symbol_info): Remove. (ada_lookup_symbol_list): Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_encoded_symbol, user_select_syms): Likewise. (ada_lookup_symbol): Return struct block_symbol instead of a mere symbol. * ada-lang.c (defns_collected): Replace struct ada_symbol_info with struct block_symbol. (resolve_subexp, ada_resolve_function, sort_choices, user_select_syms, is_nonfunction, add_defn_to_vec, num_defns_collected, defns_collected, symbols_are_identical_enums, remove_extra_symbols, remove_irrelevant_renamings, add_lookup_symbol_list_worker, ada_lookup_symbol_list, ada_iterate_over_symbols, ada_lookup_encoded_symbol, get_var_value): Likewise. (ada_lookup_symbol): Return a block_symbol instead of a mere symbol. Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_symbol_nonlocal): Likewise. (standard_lookup): Make block passing explicit through lookup_symbol_in_language. * ada-tasks.c (get_tcb_types_info): Update the calls to lookup_symbol_in_language to extract the mere symbol out of the returned value. (ada_tasks_inferior_data_sniffer): Likewise. * ax-gdb.c (gen_static_field): Likewise for the call to lookup_symbol. (gen_maybe_namespace_elt): Deal with struct symbol_in_block from lookup functions. (gen_expr): Likewise. * c-exp.y: Likewise. Remove uses of block_found. (lex_one_token, classify_inner_name, c_print_token): Likewise. (classify_name): Likewise. Rename the "sym" local variable to "bsym". * c-valprint.c (print_unpacked_pointer): Likewise. * compile/compile-c-symbols.c (convert_symbol_sym): Promote the "sym" parameter from struct symbol * to struct block_symbol. Use it to remove uses of block_found. Deal with struct symbol_in_block from lookup functions. (gcc_convert_symbol): Likewise. Update the call to convert_symbol_sym. * compile/compile-object-load.c (compile_object_load): Deal with struct symbol_in_block from lookup functions. * cp-namespace.c (cp_lookup_nested_symbol_1, cp_lookup_nested_symbol, cp_lookup_bare_symbol, cp_search_static_and_baseclasses, cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports, cp_lookup_symbol_imports_or_template, cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace, lookup_namespace_scope, cp_lookup_nonlocal, find_symbol_in_baseclass): Return struct symbol_in_block instead of mere symbols and deal with struct symbol_in_block from lookup functions. * cp-support.c (inspect_type, replace_typedefs, cp_lookup_rtti_type): Deal with struct symbol_in_block from lookup functions. * cp-support.h (cp_lookup_symbol_nonlocal, cp_lookup_symbol_from_namespace, cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol): Return struct symbol_in_block instead of mere symbols. * d-exp.y (d_type_from_name, d_module_from_name, push_variable, push_module_name): Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. * eval.c (evaluate_subexp_standard): Update call to cp_lookup_symbol_namespace. * f-exp.y: Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. (yylex): Likewise. * gdbtypes.c (lookup_typename, lookup_struct, lookup_union, lookup_enum, lookup_template_type, check_typedef): Deal with struct symbol_in_block from lookup functions. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise. (gdbscm_lookup_global_symbol): Likewise. * gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise. * go-exp.y: Likewise. Remove uses of block_found. (package_name_p, classify_packaged_name, classify_name): Likewise. * infrun.c (insert_exception_resume_breakpoint): Likewise. * jv-exp.y (push_variable): Likewise. * jv-lang.c (java_lookup_class, get_java_object_type): Likewise. * language.c (language_bool_type): Likewise. * language.h (struct language_defn): Update la_lookup_symbol_nonlocal to return a struct symbol_in_block rather than a mere symbol. * linespec.c (find_label_symbols): Deal with struct symbol_in_block from lookup functions. * m2-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * mi/mi-cmd-stack.c (list_args_or_locals): Likewise. * objc-lang.c (lookup_struct_typedef, find_imps): Likewise. * p-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * p-valprint.c (pascal_val_print): Likewise. * parse.c (write_dollar_variable): Likewise. Remove uses of block_found. * parser-defs.h (struct symtoken): Turn the SYM field into a struct symbol_in_block. * printcmd.c (address_info): Deal with struct symbol_in_block from lookup functions. * python/py-frame.c (frapy_read_var): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol, gdbpy_lookup_global_symbol): Likewise. * skip.c (skip_function_command): Likewise. * solib-darwin.c (darwin_lookup_lib_symbol): Return a struct symbol_in_block instead of a mere symbol. * solib-spu.c (spu_lookup_lib_symbol): Likewise. * solib-svr4.c (elf_lookup_lib_symbol): Likewise. * solib.c (solib_global_lookup): Likewise. * solist.h (solib_global_lookup): Likewise. (struct target_so_ops): Update lookup_lib_global_symbol to return a struct symbol_in_block rather than a mere symbol. * source.c (select_source_symtab): Deal with struct symbol_in_block from lookup functions. * stack.c (print_frame_args, iterate_over_block_arg_vars): Likewise. * symfile.c (set_initial_language): Likewise. * symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct symbol_in_block. (SYMBOL_LOOKUP_FAILED_P): New predicate as a macro. (struct symbol_cache_slot): Turn the FOUND field into a struct symbol_in_block. (block_found): Remove. (eq_symbol_entry): Update to deal with struct symbol_in_block in cache slots. (symbol_cache_lookup): Return a struct symbol_in_block rather than a mere symbol. (symbol_cache_mark_found): Add a BLOCK parameter to fill appropriately the cache slots. Update callers. (symbol_cache_dump): Update cache slots handling to the type change. (lookup_symbol_in_language, lookup_symbol, lookup_language_this, lookup_symbol_aux, lookup_local_symbol, lookup_symbol_in_objfile, lookup_global_symbol_from_objfile, lookup_symbol_in_objfile_symtabs, lookup_symbol_in_objfile_from_linkage_name, lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, lookup_static_symbol, lookup_global_symbol): Return a struct symbol_in_block rather than a mere symbol. Deal with struct symbol_in_block from other lookup functions. Remove uses of block_found. (lookup_symbol_in_block): Remove uses of block_found. (struct global_sym_lookup_data): Turn the RESULT field into a struct symbol_in_block. (lookup_symbol_global_iterator_cb): Update references to the RESULT field. (search_symbols): Deal with struct symbol_in_block from lookup functions. * symtab.h (struct symbol_in_block): New structure. (block_found): Remove. (lookup_symbol_in_language, lookup_symbol, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, looku_static_symbol, lookup_global_symbol, lookup_symbol_in_block, lookup_language_this, lookup_global_symbol_from_objfile): Return a struct symbol_in_block rather than just a mere symbol. Update comments to remove mentions of block_found. * valops.c (find_function_in_inferior, value_struct_elt_for_reference, value_maybe_namespace_elt, value_of_this): Deal with struct symbol_in_block from lookup functions. * value.c (value_static_field, value_fn_field): Likewise.
2015-07-28Consider addressable memory unit size in various value functionsSimon Marchi
This patch updates various value handling functions to make them consider the addressable memory unit size of the current architecture. This allows to correctly extract and print values on architectures whose addressable memory unit is not 8 bits. The patch doesn't cover all the code that would ideally need to be adjusted, only the code paths that we happen to use, plus a few obvious ones. Specifically, those areas are not covered by this patch: - Management of unavailable bits - Bitfields - C++ stuff Regression-tested on x86-64 Ubuntu 14.04. I saw no related test result change. gdb/ChangeLog: * c-valprint.c (c_val_print_array): Consider addressable memory unit size. (c_val_print_ptr): Likewise. (c_val_print_int): Likewise. * findvar.c (read_frame_register_value): Likewise. * valarith.c (find_size_for_pointer_math): Likewise. (value_ptrdiff): Likewise. (value_subscripted_rvalue): Likewise. * valops.c (read_value_memory): Likewise (and rename variables). (value_assign): Likewise. (value_repeat): Likewise. (value_array): Likewise. (value_slice): Likewise. * valprint.c (generic_val_print_ptr): Likewise. (generic_val_print_enum): Likewise. (generic_val_print_bool): Likewise. (generic_val_print_int): Likewise. (generic_val_print_char): Likewise. (generic_val_print_float): Likewise. (generic_val_print_decfloat): Likewise. (generic_val_print_complex): Likewise. (val_print_scalar_formatted): Likewise. (val_print_array_elements): Likewise. * value.c (set_value_parent): Likewise. (value_contents_copy_raw): Likewise. (set_internalvar_component): Likewise. (value_primitive_field): Likewise. (value_fetch_lazy): Likewise. * value.h (read_value_memory): Update comment.
2015-07-28Introduce get_value_archSimon Marchi
Similar to get_type_arch, used to get the gdbarch associated to a struct value. gdb/ChangeLog: * value.c (get_value_arch): New function. * value.h (get_value_arch): New declaration.
2015-07-28Update comments in struct value for non-8-bits architecturesSimon Marchi
gdb/ChangeLog: * value.c (struct value): Update comments.
2015-07-14Remove CHECK_TYPEDEF, use check_typedef insteadSimon Marchi
I think that the CHECK_TYPEDEF macro is not necessary, and even a bit annoying. It makes unclear the fact that the "type" variables gets overwritten. It has actually bitten me a few times. I think the following, explicit form, is better. type = check_typedef (type); This patches changes all instances of CHECK_TYPEDEF for an equivalent call to check_typedef. The bulk of the change was done with this sed: sed -i 's/CHECK_TYPEDEF (\([^)]*\));/\1 = check_typedef (\1);/' <file>.c The ChangeLog was generated using David Malcom's generate_changelog.py. I manually fixed those places where it gets the wrong function name, hopefully all of them. The patch was built-tested, and I ran a few smoke tests. gdb/ChangeLog: * gdbtypes.h (CHECK_TYPEDEF): Remove. * aarch64-tdep.c (aarch64_return_in_memory): Replace CHECK_TYPEDEF with check_typedef. * ada-lang.c (decode_constrained_packed_array_type): Likewise. (ada_array_length): Likewise. (find_parallel_type_by_descriptive_type): Likewise. (ada_check_typedef): Likewise. * arm-tdep.c (arm_return_in_memory): Likewise. * ax-gdb.c (gen_trace_static_fields): Likewise. (gen_struct_ref_recursive): Likewise. * c-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise. (variable: block COLONCOLON name): Likewise. (qualified_name: TYPENAME COLONCOLON name): Likewise. * c-lang.c (classify_type): Likewise. * c-typeprint.c (c_print_type): Likewise. (c_print_typedef): Likewise. (c_type_print_base): Likewise. * c-valprint.c (c_val_print): Likewise. * compile/compile-c-types.c (convert_type): Likewise. * compile/compile-object-load.c (get_out_value_type): Likewise. * completer.c (add_struct_fields): Likewise. (expression_completer): Likewise. * cp-namespace.c (cp_find_type_baseclass_by_name): Likewise. (cp_lookup_nested_symbol_1): Likewise. (cp_lookup_nested_symbol): Likewise. * cp-valprint.c (cp_print_value_fields): Likewise. (cp_print_static_field): Likewise. * d-valprint.c (d_val_print): Likewise. * eval.c (evaluate_subexp_standard): Likewise. (evaluate_subexp_for_sizeof): Likewise. * f-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise. * f-typeprint.c (f_type_print_base): Likewise. * f-valprint.c (f_val_print): Likewise. * gdbtypes.c (get_discrete_bounds): Likewise. (create_array_type_with_stride): Likewise. (type_name_no_tag_or_error): Likewise. (lookup_struct_elt_type): Likewise. (get_unsigned_type_max): Likewise. (internal_type_vptr_fieldno): Likewise. (set_type_vptr_fieldno): Likewise. (internal_type_vptr_basetype): Likewise. (set_type_vptr_basetype): Likewise. (get_vptr_fieldno): Likewise. (is_integral_type): Likewise. (is_scalar_type): Likewise. (is_scalar_type_recursive): Likewise. (distance_to_ancestor): Likewise. (is_unique_ancestor_worker): Likewise. (check_types_equal): Likewise. * gnu-v2-abi.c (gnuv2_value_rtti_type): Likewise. * gnu-v3-abi.c (gnuv3_dynamic_class): Likewise. (gnuv3_get_vtable): Likewise. (gnuv3_pass_by_reference): Likewise. * go-exp.y (exp : SIZEOF_KEYWORD '(' type ')' %prec UNARY): Likewise. * go-lang.c (gccgo_string_p): Likewise. (go_classify_struct_type): Likewise. * go-typeprint.c (go_print_type): Likewise. * go-valprint.c (go_val_print): Likewise. * guile/scm-math.c (vlscm_binop): Likewise. * guile/scm-value.c (gdbscm_value_dynamic_type): Likewise. (gdbscm_value_to_bytevector): Likewise. (gdbscm_value_to_bool): Likewise. (gdbscm_value_to_integer): Likewise. (gdbscm_value_to_real): Likewise. * infcall.c (call_function_by_hand_dummy): Likewise. * infcmd.c (get_return_value): Likewise. * jv-lang.c (is_object_type): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_print_value_fields): Likewise. (java_val_print): Likewise. * linespec.c (find_methods): Likewise. (collect_one_symbol): Likewise. * m2-typeprint.c (m2_print_type): Likewise. (m2_print_typedef): Likewise. (m2_get_discrete_bounds): Likewise. * m2-valprint.c (m2_print_long_set): Likewise. (m2_print_unbounded_array): Likewise. (m2_print_array_contents): Likewise. (m2_val_print): Likewise. * opencl-lang.c (opencl_print_type): Likewise. * p-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise. * p-typeprint.c (pascal_print_type): Likewise. (pascal_print_typedef): Likewise. (pascal_type_print_base): Likewise. * p-valprint.c (pascal_val_print): Likewise. (pascal_object_print_value_fields): Likewise. (pascal_object_print_static_field): Likewise. * python/py-type.c (typy_fields_items): Likewise. (typy_get_composite): Likewise. * python/py-value.c (valpy_get_dynamic_type): Likewise. (valpy_binop): Likewise. (valpy_long): Likewise. (valpy_float): Likewise. * stack.c (return_command): Likewise. * symtab.c (check_field): Likewise. (lookup_symbol_aux): Likewise. * tic6x-tdep.c (tic6x_return_value): Likewise. * typeprint.c (print_type_scalar): Likewise. * valarith.c (value_vector_widen): Likewise. * valops.c (value_cast): Likewise. (value_assign): Likewise. (do_search_struct_field): Likewise. (search_struct_method): Likewise. (find_method_list): Likewise. * valprint.c (val_print_scalar_type_p): Likewise. (valprint_check_validity): Likewise. (generic_val_print): Likewise. * value.c (unpack_double): Likewise. (value_primitive_field): Likewise. (unpack_bits_as_long): Likewise.
2015-07-06Cleanup value_fetch_lazy's comment and return valueSimon Marchi
The comment for value_fetch_lazy seems outdated. It says that it's only called from the value_contents and value_contents_all (macros!), which is not true. Also, the return value seems useless now, despite what the comment says. gdb/ChangeLog: * value.c (value_fetch_lazy): Update comment, change return value to void. * value.h (value_fetch_lazy): Change return value to void.
2015-05-09[Python] Add methods reference_value and const_value to gdb.Value.Siva Chandra
gdb/ChangeLog: * NEWS (Python Scripting): Mention the new gdb.Value methods. * python/py-value.c (valpy_reference_value): New function. (valpy_const_value): Likewise. (value_object_methods): Add new methods. * value.c (make_cv_value): New function. * value.h (make_cv_value): Declare. gdb/doc/ChangeLog: * python.texi (Values From Inferior): Add descriptions of new methods gdb.Value.reference_value and gdb.Value.const_value. gdb/testsuite/ChangeLog: * gdb.python/py-xmethods.cc: Enhance test case. * gdb.python/py-xmethods.exp: New tests. * gdb.python/py-xmethods.py (A_indexoper): New xmethod worker function. (B_indexoper): Likewise. (global_dm_list) : Add new xmethod worker functions.
2015-05-05Add valaddr support in dynamic property resolution.Joel Brobecker
This is the second part of enhancing the debugger to print the value of arrays of records whose size is variable when only standard DWARF info is available (no GNAT encoding). For instance: subtype Small_Type is Integer range 0 .. 10; type Record_Type (I : Small_Type := 0) is record S : String (1 .. I); end record; type Array_Type is array (Integer range <>) of Record_Type; A1 : Array_Type := (1 => (I => 0, S => <>), 2 => (I => 1, S => "A"), 3 => (I => 2, S => "AB")); Currently, GDB prints the following output: (gdb) p a1 $1 = ( The error happens while the ada-valprint module is trying to print the value of an element of our array. Because of the fact that the array's element (type Record_Type) has a variant size, the DWARF info for our array provide the array's stride: <1><749>: Abbrev Number: 10 (DW_TAG_array_type) <74a> DW_AT_name : (indirect string, offset: 0xb6d): pck__T18s <74e> DW_AT_byte_stride : 16 <74f> DW_AT_type : <0x6ea> And because our array has a stride, ada-valprint treats it the same way as packed arrays (see ada-valprint.c::ada_val_print_array): if (TYPE_FIELD_BITSIZE (type, 0) > 0) val_print_packed_array_elements (type, valaddr, offset_aligned, 0, stream, recurse, original_value, options); The first thing that we should notice in the call above is that the "valaddr" buffer and the associated offset (OFFSET_ALIGNED) is passed, but that the corresponding array's address is not. This can be explained by looking inside val_print_packed_array_elements, where we see that the function unpacks each element of our array from the buffer alone (ada_value_primitive_packed_val), and then prints the resulting artificial value instead: v0 = ada_value_primitive_packed_val (NULL, valaddr + offset, (i0 * bitsize) / HOST_CHAR_BIT, (i0 * bitsize) % HOST_CHAR_BIT, bitsize, elttype); [...] val_print (elttype, value_contents_for_printing (v0), value_embedded_offset (v0), 0, stream, recurse + 1, v0, &opts, current_language); Of particular interest, here, is the fact that we call val_print with a null address, which is OK, since we're providing a buffer instead (value_contents_for_printing). Also, providing an address might not always possible, since packing could place elements at boundaries that are not byte-aligned. Things go south when val_print tries to see if there is a pretty-printer that could be applied. In particular, one of the first things that the Python pretty-printer does is to create a value using our buffer, and the given address, which in this case is null (see call to value_from_contents_and_address in gdbpy_apply_val_pretty_printer). value_from_contents_and_address, in turn immediately tries to resolve the type, using the given address, which is null. But, because our array element is a record containing an array whose bound is the value of one of its elements (the "s" component), the debugging info for the array's upper bound is a reference... <3><71a>: Abbrev Number: 7 (DW_TAG_subrange_type) <71b> DW_AT_type : <0x724> <71f> DW_AT_upper_bound : <0x703> ... to component "i" of our record... <2><703>: Abbrev Number: 5 (DW_TAG_member) <704> DW_AT_name : i <706> DW_AT_decl_file : 2 <707> DW_AT_decl_line : 6 <708> DW_AT_type : <0x6d1> <70c> DW_AT_data_member_location: 0 ... where that component is located at offset 0 of the start of the record. dwarf2_evaluate_property correctly determines the offset where to load the value of the bound from, but then tries to read that value from inferior memory using the address that was given, which is null. See case PROP_ADDR_OFFSET in dwarf2_evaluate_property: val = value_at (baton->offset_info.type, pinfo->addr + baton->offset_info.offset); This triggers a memory error, which then causes the printing to terminate. Since there are going to be situations where providing an address alone is not going to be sufficient (packed arrays where array elements are not stored at byte boundaries), this patch fixes the issue by enhancing the type resolution to take both address and data. This follows the same principle as the val_print module, where both address and buffer ("valaddr") can be passed as arguments. If the data has already been fetched from inferior memory (or provided by the debugging info in some form -- Eg a constant), then use that data instead of reading it from inferior memory. Note that this should also be a good step towards being able to handle dynamic types whose value is stored outside of inferior memory (Eg: in a register). With this patch, GDB isn't able to print all of A1, but does perform a little better: (gdb) p a1 $1 = ((i => 0, s => , (i => 1, s => , (i => 2, s => ) There is another issue which is independent of this one, and will therefore be patched separately. gdb/ChangeLog: * dwarf2loc.h (struct property_addr_info): Add "valaddr" field. * dwarf2loc.c (dwarf2_evaluate_property): Add handling of pinfo->valaddr. * gdbtypes.h (resolve_dynamic_type): Add "valaddr" parameter. * gdbtypes.c (resolve_dynamic_struct): Set pinfo.valaddr. (resolve_dynamic_type_internal): Set pinfo.valaddr. Add handling of addr_stack->valaddr. (resolve_dynamic_type): Add "valaddr" parameter. Set pinfo.valaddr field. * ada-lang.c (ada_discrete_type_high_bound): Update call to resolve_dynamic_type. (ada_discrete_type_low_bound): Likewise. * findvar.c (default_read_var_value): Likewise. * value.c (value_from_contents_and_address): Likewise.
2015-04-29PR python/18285Doug Evans
gdb/ChangeLog: PR python/18285 * NEWS: Document new gdb.XMethodWorker.get_result_type method. * eval.c (evaluate_subexp_standard) <OP_FUNCALL>: Handle EVAL_AVOID_SIDE_EFFECTS for xmethods. * extension-priv.h (struct extension_language_ops) <get_xmethod_result_type>: New member. * extension.c (get_xmethod_result_type): New function. * extension.h (get_xmethod_result_type): Declare. * python/py-xmethods.c (get_result_type_method_name): New static global. (py_get_result_type_method_name): Ditto. (gdbpy_get_xmethod_result_type): New function. (gdbpy_initialize_xmethods): Initialize py_get_result_type_method_name. * python/python-internal.h (gdbpy_get_xmethod_result_type): Declare. * python/python.c (python_extension_ops): Add gdbpy_get_xmethod_result_type. * python/lib/gdb/xmethod.py (XMethodWorker): Add get_result_type. * valarith.c (value_x_binop): Handle EVAL_AVOID_SIDE_EFFECTS for xmethods. (value_x_unop): Ditto. * value.c (result_type_of_xmethod): New function. * value.h (result_type_of_xmethod): Declare. gdb/testsuite/ChangeLog: * gdb.python/py-xmethods.exp: Add ptype tests. * gdb.python/py-xmethods.py (E_method_char_worker): Add get_result_type method. gdb/doc/ChangeLog: * python.texi (Xmethod API) <gdb.XMethodWorker.get_result_type>: Document. (Writing an Xmethod): Add get_result_type to example.
2015-03-07Split TRY_CATCH into TRY + CATCHPedro Alves
This patch splits the TRY_CATCH macro into three, so that we go from this: ~~~ volatile gdb_exception ex; TRY_CATCH (ex, RETURN_MASK_ERROR) { } if (ex.reason < 0) { } ~~~ to this: ~~~ TRY { } CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH ~~~ Thus, we'll be getting rid of the local volatile exception object, and declaring the caught exception in the catch block. This allows reimplementing TRY/CATCH in terms of C++ exceptions when building in C++ mode, while still allowing to build GDB in C mode (using setjmp/longjmp), as a transition step. TBC, after this patch, is it _not_ valid to have code between the TRY and the CATCH blocks, like: TRY { } // some code here. CATCH (ex, RETURN_MASK_ERROR) { } END_CATCH Just like it isn't valid to do that with C++'s native try/catch. By switching to creating the exception object inside the CATCH block scope, we can get rid of all the explicitly allocated volatile exception objects all over the tree, and map the CATCH block more directly to C++'s catch blocks. The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was done with a script, rerun from scratch at every rebase, no manual editing involved. After the mechanical conversion, a few places needed manual intervention, to fix preexisting cases where we were using the exception object outside of the TRY_CATCH block, and cases where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH after this patch]. The result was folded into this patch so that GDB still builds at each incremental step. END_CATCH is necessary for two reasons: First, because we name the exception object in the CATCH block, which requires creating a scope, which in turn must be closed somewhere. Declaring the exception variable in the initializer field of a for block, like: #define CATCH(EXCEPTION, mask) \ for (struct gdb_exception EXCEPTION; \ exceptions_state_mc_catch (&EXCEPTION, MASK); \ EXCEPTION = exception_none) would avoid needing END_CATCH, but alas, in C mode, we build with C90, which doesn't allow mixed declarations and code. Second, because when TRY/CATCH are wired to real C++ try/catch, as long as we need to handle cleanup chains, even if there's no CATCH block that wants to catch the exception, we need for stop at every frame in the unwind chain and run cleanups, then rethrow. That will be done in END_CATCH. After we require C++, we'll still need TRY/CATCH/END_CATCH until cleanups are completely phased out -- TRY/CATCH in C++ mode will save/restore the current cleanup chain, like in C mode, and END_CATCH catches otherwise uncaugh exceptions, runs cleanups and rethrows, so that C++ cleanups and exceptions can coexist. IMO, this still makes the TRY/CATCH code look a bit more like a newcomer would expect, so IMO worth it even if we weren't considering C++. gdb/ChangeLog. 2015-03-07 Pedro Alves <palves@redhat.com> * common/common-exceptions.c (struct catcher) <exception>: No longer a pointer to volatile exception. Now an exception value. <mask>: Delete field. (exceptions_state_mc_init): Remove all parameters. Adjust. (exceptions_state_mc): No longer pop the catcher here. (exceptions_state_mc_catch): New function. (throw_exception): Adjust. * common/common-exceptions.h (exceptions_state_mc_init): Remove all parameters. (exceptions_state_mc_catch): Declare. (TRY_CATCH): Rename to ... (TRY): ... this. Remove EXCEPTION and MASK parameters. (CATCH, END_CATCH): New. All callers adjusted. gdb/gdbserver/ChangeLog: 2015-03-07 Pedro Alves <palves@redhat.com> Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH instead.
2015-02-27Fix struct, union, and enum nesting in C++Tom Tromey
In C, an enum or structure defined inside other structure has global scope just like it had been defined outside the struct in the first place. However, in C++, such a nested structure is given a name that is nested inside the structure. This patch moves such affected structures/enums out to global scope, so that code using them works the same in C++ as it works today in C. gdb/ChangeLog: 2015-02-27 Tom Tromey <tromey@redhat.com> Pedro Alves <palves@redhat.com> * dwarf2-frame.c (enum cfa_how_kind, struct dwarf2_frame_state_reg_info): Move out of struct dwarf2_frame_state. * dwarf2read.c (struct tu_stats): Move out of struct dwarf2_per_objfile. (struct file_entry): Move out of struct line_header. (struct nextfield, struct nextfnfield, struct fnfieldlist, struct typedef_field_list): Move out of struct field_info. * gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data): Move out of struct dynamic_prop. (union type_owner, union field_location, struct field, struct range_bounds, union type_specific): Move out of struct main_type. (struct fn_fieldlist, struct fn_field, struct typedef_field) (VOFFSET_STATIC): Move out of struct cplus_struct_type. (struct call_site_target, union call_site_parameter_u, struct call_site_parameter): Move out of struct call_site. * m32c-tdep.c (enum m32c_prologue_kind): Move out of struct m32c_prologue. (enum srcdest_kind): Move out of struct srcdest. * main.c (enum cmdarg_kind): Move out of struct cmdarg. * prologue-value.h (enum prologue_value_kind): Move out of struct prologue_value. * s390-linux-tdep.c (enum s390_abi_kind): Move out of struct gdbarch_tdep. * stabsread.c (struct nextfield, struct next_fnfieldlist): Move out of struct field_info. * symfile.h (struct other_sections): Move out of struct section_addr_info. * symtab.c (struct symbol_cache_slot): Move out struct block_symbol_cache. * target-descriptions.c (enum tdesc_type_kind): Move out of typedef struct tdesc_type. * tui/tui-data.h (enum tui_line_or_address_kind): Move out of struct tui_line_or_address. * value.c (enum internalvar_kind, union internalvar_data): Move out of struct internalvar. * xtensa-tdep.h (struct ctype_cache): Move out of struct gdbarch_tdep.
2015-02-27C++ keyword cleanliness, mostly auto-generatedPedro Alves
This patch renames symbols that happen to have names which are reserved keywords in C++. Most of this was generated with Tromey's cxx-conversion.el script. Some places where later hand massaged a bit, to fix formatting, etc. And this was rebased several times meanwhile, along with re-running the script, so re-running the script from scratch probably does not result in the exact same output. I don't think that matters anyway. gdb/ 2015-02-27 Tom Tromey <tromey@redhat.com> Pedro Alves <palves@redhat.com> Rename symbols whose names are reserved C++ keywords throughout. gdb/gdbserver/ 2015-02-27 Tom Tromey <tromey@redhat.com> Pedro Alves <palves@redhat.com> Rename symbols whose names are reserved C++ keywords throughout.
2015-01-01Update year range in copyright notice of all files owned by the GDB project.Joel Brobecker
gdb/ChangeLog: Update year range in copyright notice of all files.
2014-11-28Enable chained function calls in C++ expressions.Siva Chandra
gdb/ChangeLog: * eval.c: Include gdbthread.h. (evaluate_subexp): Enable thread stack temporaries before evaluating a complete expression and clean them up after the evaluation is complete. * gdbthread.h: Include common/vec.h. (value_ptr): New typedef. (VEC (value_ptr)): New vector type. (value_vec): New typedef. (struct thread_info): Add new fields stack_temporaries_enabled and stack_temporaries. (enable_thread_stack_temporaries) (thread_stack_temporaries_enabled_p, push_thread_stack_temporary) (get_last_thread_stack_temporary) (value_in_thread_stack_temporaries): Declare. * gdbtypes.c (class_or_union_p): New function. * gdbtypes.h (class_or_union_p): Declare. * infcall.c (call_function_by_hand): Store return values of class type as temporaries on stack. * thread.c (enable_thread_stack_temporaries): New function. (thread_stack_temporaries_enabled_p, push_thread_stack_temporary) (get_last_thread_stack_temporary): Likewise. (value_in_thread_stack_temporaries): Likewise. * value.c (value_force_lval): New function. * value.h (value_force_lval): Declare. gdb/testsuite/ChangeLog: * gdb.cp/chained-calls.cc: New file. * gdb.cp/chained-calls.exp: New file. * gdb.cp/smartp.exp: Remove KFAIL for "p c2->inta".