summaryrefslogtreecommitdiff
path: root/gdb/valprint.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-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-06Target FP: Add string routines to target-float.{c,h}Ulrich Weigand
This adds target_float_to_string and target_float_from_string, which dispatch to the corresponding floatformat_ or decimal_ routines. Existing users of those routines are changed to use the new target-float routines instead (most of those places already handle both binary and decimal FP). In addition, two other places are changes to use target_float_from_string: - define_symbol in stabsread.c, when parsing a floating-point literal from stabs debug info - gdbarch-selftest.c when initializing a target format values (to eliminate use of DOUBLEST there). gdb/ChangeLog: 2017-11-06 Ulrich Weigand <uweigand@de.ibm.com> * target-float.c (target_float_to_string): New function. (target_float_from_string): New function. * target-float.h (target_float_to_string): Add prototype. (target_float_from_string): Add prototype. * valprint.c: Include "target-float.h". Do not include "doublest.h" and "dfp.h". (print_floating): Use target_float_to_string. * printcmd.c: Include "target-float.h". Do not include "dfp.h". (printf_floating): Use target_float_to_string. * i387-tdep.c: Include "target-float.h". Do not include "doublest.h". (print_i387_value): Use target_float_to_string. * mips-tdep.c: Include "target-float.h". (mips_print_fp_register): Use target_float_to_string. * sh64-tdep.c: Include "target-float.h". (sh64_do_fp_register): Use target_float_to_string. * parse.c: Include "target-float.h". Do not include "doublest.h" and "dfp.h". (parse_float): Use target_float_from_string. * stabsread.c: Include "target-float.h". Do not include "doublest.h". (define_symbol): Use target_float_from_string. * gdbarch-selftests.c: Include "target-float.h". (register_to_value_test): Use target_float_from_string.
2017-10-24Target FP printing: Simplify and fix print_floatingUlrich Weigand
The print_floating routine currently makes a lot of assumptions about host and target floating point formats. This patch cleans up many of those. One problem is that print_floating may currently be called with types that are not actually floating-point types, and it tries hard to output those as floating-point values anyway. However, there is only one single caller of print_floating where this can ever happen: print_scalar_formatted. And in fact, it is much simpler to handle the case where the value to be printed is not already of floating-point type right there. So this patch changes print_scalar_formatted to handle the 'f' format as follows: - If the value to be printed is already of floating-point type, just call print_floating on it. - Otherwise, if there is a standard target floating-point type of the same size as the value, call print_floating using that type. - Otherwise, just print the value as if the 'f' format had not been specified at all. This has the overall effect to printing everything the same way as the old code did, but is overall a lot simpler. (Also, it would allow us to change the above strategy more easily, if that might be a more intuitive user interface. For example, in the third case above, maybe an error would be more appropriate?) Given that change, print_floating can become much simpler. In particular, we now always have a floating-point format that we can consult. This means we can use the floating-point format to programmatically determine the number of digits necessary to print the value. The current code uses a hard-coded value of 9, 17, or 35 digits. Note that this matches the DECIMAL_DIG values for IEEE-32, IEEE-64, and IEEE-128. (Actually, for IEEE-128 the correct value is 36 -- the 35 seems to be an oversight.) The DECIMAL_DIG value is defined to be the smallest number so that any number in the target format, when printed to this number of digits and then scanned back into a binary floating-point number, will result in the original value. Now that we always have a FP format, we can just compute the DECIMAL_DIG value using the formula from the C standard. This will be correct for *all* FP formats, not just the above list, and it will be correct (as opposed to current code) if the target formats differ from the host ones. The patch moves the new logic to a new floatformat_to_string routine (analogous to the existing decimal_to_string). The print_floating routine now calls floatformat_to_string or decimal_to_string, making the separate print_decimal_floating and generic_val_print_decfloat routines unnecessary. gdb/ChangeLog: 2017-10-24 Ulrich Weigand <uweigand@de.ibm.com> * doublest.c (floatformat_precision): New routine. (floatformat_to_string): Likewise. * doublest.c (floatformat_to_string): Add prototype. * printcmd.c (print_scalar_formatted): Only call print_floating on floating-point types. * valprint.c: Do not include "floatformat.h". (generic_val_print_decfloat): Remove. (generic_val_print): Call generic_val_print_float for both TYPE_CODE_FLT and TYPE_CODE_DECFLOAT. (print_floating): Use floatformat_to_string. Handle decimal float. (print_decimal_floating): Remove, merge into floatformat_to_string. * value.h (print_decimal_floating): Remove. * Makefile.in: Do not build doublest.c with -Wformat-nonliteral.
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-09-27Constify two functions in valprint.cTom Tromey
gdb/ChangeLog 2017-09-27 Tom Tromey <tom@tromey.com> * valprint.c (set_radix, show_radix): 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-09-03Return std::string from memory_error_messageTom Tromey
This changes memory_error_message to return a std::string and fixes up the callers. This removes some cleanups. ChangeLog 2017-09-03 Tom Tromey <tom@tromey.com> * valprint.c (val_print_string): Update. * gdbcore.h (memory_error_message): Return std::string. * corefile.c (memory_error_message): Return std::string. (memory_error): Update. * breakpoint.c (insert_bp_location): Update.
2017-08-14Remove BITS_IN_BYTES defineTom Tromey
While working on the previous patch, I noticed that BITS_IN_BYTES can be replaced by HOST_CHAR_BIT, which is used more widely in gdb. ChangeLog 2017-08-14 Tom Tromey <tom@tromey.com> * valprint.c (print_octal_chars): Use HOST_CHAR_BIT. (print_binary_chars): Likewise. (BITS_IN_BYTES): Remove.
2017-08-14Fix two regressions in scalar printingTom Tromey
PR gdb/21675 points out a few regressions in scalar printing. One type of regression is due to not carrying over the old handling of floating point printing -- where a format like "/d" causes a floating point number to first be cast to a signed integer. This patch restores this behavior. The other regression is a longstanding bug in print_octal_chars: one of the constants was wrong. This patch fixes the constant and adds static asserts to help catch this sort of error. ChangeLog 2017-08-14 Tom Tromey <tom@tromey.com> PR gdb/21675 * valprint.c (LOW_ZERO): Change value to 034. (print_octal_chars): Add static_asserts for octal constants. * printcmd.c (print_scalar_formatted): Add 'd' case. testsuite/ChangeLog 2017-08-14 Tom Tromey <tom@tromey.com> PR gdb/21675: * gdb.base/printcmds.exp (test_radices): New function. * gdb.dwarf2/var-access.exp: Use p/u, not p/d. * gdb.base/sizeof.exp (check_valueof): Use p/d. * lib/gdb.exp (get_integer_valueof): Use p/d.
2017-06-27Eliminate make_cleanup_obstack_free, introduce auto_obstackPedro Alves
This commit eliminates make_cleanup_obstack_free, replacing it with a new auto_obstack type that inherits obstack to add cdtors. These changes in the parsers may not be obvious: - obstack_init (&name_obstack); - make_cleanup_obstack_free (&name_obstack); + name_obstack.clear (); Here, the 'name_obstack' variable is a global. The change means that the obstack's contents from a previous parse will stay around until the next parsing starts. I.e., memory won't be reclaimed until then. I don't think that's a problem, these objects don't really grow much at all. The other option I tried was to add a separate type that is like auto_obstack but manages an external obstack, just for those cases. I like the current approach better as that other approach adds more boilerplate and yet another type to learn. gdb/ChangeLog: 2017-06-27 Pedro Alves <palves@redhat.com> * c-exp.y (name_obstack): Now an auto_obstack. (yylex): Use auto_obstack::clear. (c_parse): Use auto_obstack::clear instead of reinitializing and freeing the obstack. * c-lang.c (evaluate_subexp_c): Use auto_obstack. * d-exp.y (name_obstack): Now an auto_obstack. (yylex): Use auto_obstack::clear. (d_parse): Use auto_obstack::clear instead of reinitializing and freeing the obstack. * dwarf2loc.c (fetch_const_value_from_synthetic_pointer): Use auto_obstack. * dwarf2read.c (create_addrmap_from_index) (dwarf2_build_psymtabs_hard) (update_enumeration_type_from_children): Likewise. * gdb_obstack.h (auto_obstack): New type. * go-exp.y (name_obstack): Now an auto_obstack. (build_packaged_name): Use auto_obstack::clear. (go_parse): Use auto_obstack::clear instead of reinitializing and freeing the obstack. * linux-tdep.c (linux_make_mappings_corefile_notes): Use auto_obstack. * printcmd.c (printf_wide_c_string, ui_printf): Use auto_obstack. * rust-exp.y (work_obstack): Now an auto_obstack. (rust_parse, rust_lex_tests): Use auto_obstack::clear instead of reinitializing and freeing the obstack. * utils.c (do_obstack_free, make_cleanup_obstack_free): Delete. (host_char_to_target): Use auto_obstack. * utils.h (make_cleanup_obstack_free): Delete declaration. * valprint.c (generic_emit_char, generic_printstr): Use auto_obstack.
2017-06-14Introduce gdb::byte_vector, add allocator that default-initializesPedro Alves
In some cases we've been replacing heap-allocated gdb_byte buffers managed with xmalloc/make_cleanup(xfree) with gdb::vector<gdb_byte>. That usually pessimizes the code a little bit because std::vector value-initializes elements (which for gdb_byte means zero-initialization), while if you're creating a temporary buffer, you're most certaintly going to fill it in with some data. An alternative is to use unique_ptr<gdb_byte[]> buf (new gdb_byte[size]); but it looks like that's not very popular. Recently, a use of obstacks in dwarf2read.c was replaced with std::vector<gdb_byte> and that as well introduced a pessimization for always memsetting the buffer when it's garanteed that the zeros will be overwritten immediately. (see dwarf2read.c change in this patch to find it.) So here's a different take at addressing this issue "by design": #1 - Introduce default_init_allocator<T> I.e., a custom allocator that does default construction using default initialization, meaning, no more zero initialization. That's the default_init_allocation<T> class added in this patch. See "Notes" at <http://en.cppreference.com/w/cpp/container/vector/resize>. #2 - Introduce def_vector<T> I.e., a convenience typedef, because typing the allocator is annoying: using def_vector<T> = std::vector<T, gdb::default_init_allocator<T>>; #3 - Introduce byte_vector Because gdb_byte vectors will be the common thing, add a convenience "byte_vector" typedef: using byte_vector = def_vector<gdb_byte>; which is really the same as: std::vector<gdb_byte, gdb::default_init_allocator<gdb_byte>>; The intent then is to make "gdb::byte_vector" be the go-to for dynamic byte buffers. So the less friction, the better. #4 - Adjust current code to use it. To set the example going forward. Replace std::vector uses and also unique_ptr<byte[]> uses. One nice thing is that with this allocator, for changes like these: -std::unique_ptr<byte[]> buf (new gdb_byte[some_size]); +gdb::byte_vector buf (some_size); fill_with_data (buf.data (), buf.size ()); the generated code is the same as before. I.e., the compiler de-structures the vector and gets rid of the unused "reserved vs size" related fields. The other nice thing is that it's easier to write gdb::byte_vector buf (size); than std::unique_ptr<gdb_byte[]> buf (new gdb_byte[size]); or even (C++14): auto buf = std::make_unique<gdb_byte[]> (size); // zero-initializes... #5 - Suggest s/std::vector<gdb_byte>/gdb::byte_vector/ going forward. Note that this commit actually fixes a couple of bugs where the current code is incorrectly using "std::vector::reserve(new_size)" and then accessing the vector's internal buffer beyond the vector's size: see dwarf2loc.c and charset.c. That's undefined behavior and may trigger debug mode assertion failures. With default_init_allocator, "resize()" behaves like "reserve()" performance wise, in that it leaves new elements with unspecified values, but, it does that safely without triggering undefined behavior when you access those values. gdb/ChangeLog: 2017-06-14 Pedro Alves <palves@redhat.com> * ada-lang.c: Include "common/byte-vector.h". (ada_value_primitive_packed_val): Use gdb::byte_vector. * charset.c (wchar_iterator::iterate): Resize the vector instead of reserving it. * common/byte-vector.h: Include "common/def-vector.h". (wchar_iterator::m_out): Now a gdb::def_vector<gdb_wchar_t>. * cli/cli-dump.c: Include "common/byte-vector.h". (dump_memory_to_file, restore_binary_file): Use gdb::byte_vector. * common/byte-vector.h: New file. * common/def-vector.h: New file. * common/default-init-alloc.h: New file. * dwarf2loc.c: Include "common/byte-vector.h". (rw_pieced_value): Use gdb::byte_vector, and resize the vector instead of reserving it. * dwarf2read.c: Include "common/byte-vector.h". (data_buf::m_vec): Now a gdb::byte_vector. * gdb_regex.c: Include "common/def-vector.h". (compiled_regex::compiled_regex): Use gdb::def_vector<char>. * mi/mi-main.c: Include "common/byte-vector.h". (mi_cmd_data_read_memory): Use gdb::byte_vector. * printcmd.c: Include "common/byte-vector.h". (print_scalar_formatted): Use gdb::byte_vector. * valprint.c: Include "common/byte-vector.h". (maybe_negate_by_bytes, print_decimal_chars): Use gdb::byte_vector.
2017-06-12Remove val_print_type_code_intTom Tromey
Now that print_scalar_formatted is more capable, there's no need for val_print_type_code_int. This patch removes it in favor of val_print_scalar_formatted. 2017-06-12 Tom Tromey <tom@tromey.com> * valprint.h (val_print_type_code_int): Remove. * valprint.c (generic_val_print_int): Always call val_print_scalar_formatted. (val_print_type_code_int): Remove. * printcmd.c (print_scalar_formatted): Handle options->format==0. * f-valprint.c (f_val_print): Use val_print_scalar_formatted. * c-valprint.c (c_val_print_int): Use val_print_scalar_formatted. * ada-valprint.c (ada_val_print_num): Use val_print_scalar_formatted.
2017-06-12Let print_decimal_chars handle signed valuesTom Tromey
This changes print_decimal_chars to handle signed values. gdb/ChangeLog 2017-06-12 Tom Tromey <tom@tromey.com> PR exp/16225: * valprint.h (print_decimal_chars): Update. * valprint.c (maybe_negate_by_bytes): New function. (print_decimal_chars): Add "is_signed" argument. * printcmd.c (print_scalar_formatted): Update.
2017-06-12Don't always zero pad in print_*_charsTom Tromey
This changes print_octal_chars and print_decimal_chars to never zero pad, and changes print_binary_chars and print_hex_chars to only optionally zero-pad, based on a flag. ChangeLog 2017-06-12 Tom Tromey <tom@tromey.com> PR exp/16225: * valprint.h (print_binary_chars, print_hex_chars): Update. * valprint.c (val_print_type_code_int): Update. (print_binary_chars): Add "zero_pad" argument. (emit_octal_digit): New function. (print_octal_chars): Don't zero-pad. (print_decimal_chars): Likewise. (print_hex_chars): Add "zero_pad" argument. * sh64-tdep.c (sh64_do_fp_register): Update. * regcache.c (regcache::dump): Update. * printcmd.c (print_scalar_formatted): Update. * infcmd.c (default_print_one_register_info): Update. 2017-06-12 Tom Tromey <tom@tromey.com> PR exp/16225: * gdb.reverse/i386-sse-reverse.exp: Update tests. * gdb.arch/vsx-regs.exp: Update tests. * gdb.arch/s390-vregs.exp (hex128): New proc. Update test. * gdb.arch/altivec-regs.exp: Update tests.
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-03-03Fetch lazy value before calling val_printYao Qi
As reported in PR 21165, (gdb) info locals^M gv = /home/yao/SourceCode/gnu/gdb/git/gdb/value.c:372: internal-error: int value_bits_any_optimized_out(const value*, int, int): Assertion `!value->lazy' failed.^M A problem internal to GDB has been detected,^M further debugging may prove unreliable.^M Quit this debugging session? (y or n) FAIL: gdb.ada/info_locals_renaming.exp: info locals (GDB internal error) Resyncing due to internal error. This internal error is caused by e8b24d9 (Remove parameter valaddr from la_val_print). Commit e8b24d9 removes some calls to value_contents_for_printing, but value_fetch_lazy is not called, so the internal error above is triggered. This patch adds value_fetch_lazy call before val_print. gdb: 2017-03-03 Yao Qi <yao.qi@linaro.org> PR gdb/21165 * ada-valprint.c (ada_val_print_ref): Call value_fetch_lazy if value is lazy. * valprint.c (common_val_print): 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-11-11Remove apply_val_pretty_printer parameter valaddrYao Qi
This patch removes the parameter valaddr of extension_language_ops::apply_val_pretty_printer and remove const from "struct value *val". valaddr can be got in each extension language's implementation of apply_val_pretty_printer. gdb: 2016-11-11 Yao Qi <yao.qi@linaro.org> * cp-valprint.c (cp_print_value): Remove local base_valaddr. * extension-priv.h (struct extension_language_ops) <apply_val_pretty_printer>: Remove the second parameter. Remove const from "struct value *". Callers updated. * extension.c (apply_ext_lang_val_pretty_printer): Update comments. Remove parameter valaddr. Remove const from "struct value *". * extension.h (apply_ext_lang_val_pretty_printer): Update declaration. * guile/guile-internal.h (gdbscm_apply_val_pretty_printer): Update declaration. * guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer): Remove parameter valaddr. Remove const from "struct value *". * python/py-prettyprint.c (gdbpy_apply_val_pretty_printer): Likewise. * python/python-internal.h (gdbpy_apply_val_pretty_printer): Update declaration.
2016-11-08Remove parameter valaddr from la_val_printYao Qi
Nowadays, we pass both val and return value of value_contents_for_printing (val) to la_val_print. The latter is unnecessary. This patch removes the second parameter of la_val_print, and get valaddr in each language's implementation by calling value_contents_for_printing. Since value_contents_for_printing calls value_fetch_lazy, I also make VAL non-const. Note that - I don't clean up the valaddr usages in each language's routines, - I don't remove valaddr from apply_ext_lang_val_pretty_printer, and extension language ops apply_val_pretty_printer. They can be done in followup patches. gdb: 2016-11-08 Yao Qi <yao.qi@linaro.org> * ada-lang.h (ada_val_print): Remove second parameter. Remove const from "struct value *". * ada-valprint.c (print_field_values): Remove const from "struct value *". (val_print_packed_array_elements): Likewise. (print_variant_part): Likewise. (ada_val_print_string): Likewise. (ada_val_print_gnat_array): Likewise. (ada_val_print_ptr): Likewise. (ada_val_print_num): Likewise. (ada_val_print_enum): Likewise. (ada_val_print_flt): Likewise. (ada_val_print_union): Likewise. (ada_val_print_struct_union): Likewise. (ada_val_print_ref): Likewise. (ada_val_print_1): Remove second parameter. Remove const from "struct value *". (ada_val_print): Likewise. * c-lang.h (c_val_print): Likewise. * c-valprint.c (c_val_print_array): Remove const from "struct value *". (c_val_print_ptr): Likewise. (c_val_print_struct): Likewise. (c_val_print_union): Likewise. (c_val_print_int): Likewise. (c_val_print_memberptr): Likewise. (c_val_print): Remove second parameter. Remove const from "struct value *". All callers updated. * cp-valprint.c (cp_print_value): Remove const from "struct value *". (cp_print_value_fields): Likewise. (c_val_print_value): Likewise. * d-lang.h (d_val_print): Remove second parameter. Remove const from "struct value *". * d-valprint.c (dynamic_array_type): Likewise. (d_val_print): Likewise. * f-lang.h (f_val_print): Likewise. * f-valprint.c (f_val_print): Likewise. * go-lang.h (go_val_print): Likewise. * go-valprint.c (print_go_string): Likewise. (go_val_print): Likewise. * language.c (unk_lang_val_print): Likewise. * language.h (struct language_defn) <la_val_print>: Likewise. Update comments. (LA_VAL_PRINT): Remove. * m2-lang.h (m2_val_print): Remove const from "struct value *". * m2-valprint.c (m2_print_array_contents): Likewise. (m2_val_print): Likewise. * p-lang.h (pascal_val_print): Remove second parameter. Remove const from "struct value *". (pascal_object_print_value_fields): Likewise. * p-valprint.c (pascal_val_print): Likewise. (pascal_object_print_value_fields): Likewise. (pascal_object_print_value): Likewise. * rust-lang.c (rust_get_disr_info): Likewise. (val_print_struct): Likewise. (rust_val_print): Likewise. * valprint.c (generic_val_print_array): Likewise. (generic_val_print_ptr): Likewise. (generic_val_print_memberptr): Likewise. (generic_val_print_ref): Likewise. (generic_val_print_enum): Likewise. (generic_val_print_flags): Likewise. (generic_val_print_func): 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. (generic_val_print): Likewise. (val_print): Likewise. (common_val_print): Likewise. (val_print_type_code_flags): Likewise. (val_print_scalar_formatted): Likewise. (val_print_array_elements): Likewise. * valprint.h (val_print_array_elements): Update declaration. (val_print_scalar_formatted): Likewise. (generic_val_print): Likewise. * value.h (val_print): Likewise.
2016-10-12Turn wchar iterator into a classTom Tromey
This changes wchar_iterator from charset.c into a real C++ class, then updates the users to use the class. This lets us remove some cleanups in favor of the class' destructor. 2016-10-12 Tom Tromey <tom@tromey.com> * valprint.c (generic_emit_char, count_next_character) (generic_printstr): Update. * charset.c (struct wchar_iterator): Move to charset.h. (wchar_iterator::wchar_iterator): Rename from make_wchar_iterator, turn into a constructor. (wchar_iterator::~wchar_iterator): Rename from do_cleanup_iterator, turn into a destructor. (make_cleanup_wchar_iterator): Remove. (wchar_iterator::iterate): Rename from wchar_iterate. Remove "iter" argument. Update. * charset.h: Include <vector>. (class wchar_iterator): New class, from old struct wchar_iterator. (make_wchar_iterator, make_cleanup_wchar_iterator): Don't declare.
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-09-06Remove obsolete TYPE_FLAG_... valuesUlrich Weigand
Now that init_type no longer takes a FLAGS argument, there is no user of the TYPE_FLAGS_... enum values left. This commit removes them (and all references to them in comments as well). This is mostly a no-op, except for a change to the Python type printer, which attempted to use them before. (As best as I can tell, this wasn't really needed anyway, since it was only used to pretty-print type *instance* flags, which only use the instance flags.) gdb/ChangeLog: * gdbtypes.h (enum type_flag_value): Remove. Remove references to TYPE_FLAG_... in comments throughout. * gdbtypes.c (recursive_dump_type): Do not print TYPE_FLAG_... flags, print the corresponding TYPE_... access macro names. Remove references to TYPE_FLAG_... in comments throughout. * infcall.c: Remove references to TYPE_FLAG_... in comments. * valprint.c: Likewise. * gdb-gdb.py (class TypeFlag): No longer consider TYPE_FLAG_... values, only TYPE_INSTANCE_FLAG_... values. (class TypeFlagsPrinter): Likewise. gdb/testsuite/ChangeLog: * gdb.cp/hang.exp: Remove reference to TYPE_FLAG_STUB in comment. Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
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-31[PR gdb/19893] Fix handling of synthetic C++ referencesMartin Galvan
https://sourceware.org/bugzilla/show_bug.cgi?id=19893 I've traced the main source of the problem to pieced_value_funcs.coerce_ref not being implemented. Since gdb always assumes references are implemented as pointers, this causes it to think that it's dealing with a NULL pointer, thus breaking any operations involving synthetic references. What I did here was implementing pieced_value_funcs.coerce_ref using some of the synthetic pointer handling code from indirect_pieced_value, as Pedro suggested. I also made a few adjustments to the reference printing code so that it correctly shows either the address of the referenced value or (if it's non-addressable) the "<synthetic pointer>" string. I also wrote some unit tests based on Dwarf::assemble; these took a while to make because in most cases I needed a synthetic reference to a physical variable. Additionally, I started working on a unit test for classes that have a vtable, but ran into a few issues so that'll probably go in a future patch. One thing that should definitely be fixed is that proc function_range (called for MACRO_AT_func) will always try to compile/link using gcc with the default options instead of g++, thus breaking C++ compilations that require e.g. libstdc++. gdb/ChangeLog: * dwarf2loc.c (coerce_pieced_ref, indirect_synthetic_pointer, fetch_const_value_from_synthetic_pointer): New functions. (indirect_pieced_value): Move lower half to indirect_synthetic_pointer. (pieced_value_funcs): Implement coerce_ref. * valops.c (value_addr): Call coerce_ref for synthetic references. * valprint.c (valprint_check_validity): Return true for synthetic references. Also, don't show "<synthetic pointer>" if they reference addressable values. (generic_val_print_ref): Handle synthetic references. Also move some code to print_ref_address. (print_ref_address, get_value_addr_contents): New functions. gdb/testsuite/ChangeLog: * gdb.dwarf2/implref.exp: Rename to... * gdb.dwarf2/implref-const.exp: ...this. Also add more test statements. * gdb.dwarf2/implref-array.c: New file. * gdb.dwarf2/implref-array.exp: Likewise. * gdb.dwarf2/implref-global.c: Likewise. * gdb.dwarf2/implref-global.exp: Likewise. * gdb.dwarf2/implref-struct.c: Likewise. * gdb.dwarf2/implref-struct.exp: Likewise.
2016-05-17Add array start and end strings to generic_val_print_decorationsTom Tromey
For Rust value-printing, I wanted to use generic_val_print_array, but I also wanted to control the starting and ending strings. This patch adds new strings to generic_val_print_decorations, updates generic_val_print_array to use them, and updates all the existing instances of generic_val_print_decorations. 2016-05-17 Tom Tromey <tom@tromey.com> * valprint.h (struct generic_val_print_array) <array_start, array_end>: New fields. * valprint.c (generic_val_print_array): Add "decorations" parameter. Use "array_start", "array_end". (generic_val_print) <TYPE_CODE_ARRAY>: Update. * p-valprint.c (p_decorations): Update. * m2-valprint.c (m2_decorations): Update. * f-valprint.c (f_decorations): Update. * c-valprint.c (c_decorations): Update.
2016-03-15Extend flags to support multibit and enum bitfields.Doug Evans
gdb/ChangeLog: Extend flags to support multibit and enum bitfields. NEWS: Document new features. * c-typeprint.c (c_type_print_varspec_prefix): Handle TYPE_CODE_FLAGS. (c_type_print_varspec_suffix, c_type_print_base): Ditto. * gdbtypes.c (arch_flags_type): Don't assume all fields are one bit. (append_flags_type_field): New function. (append_flags_type_flag): Call it. * gdbtypes.h (append_flags_type_field): Declare. * target-descriptions.c (struct tdesc_type_flag): Delete. (enum tdesc_type_kind) <TDESC_TYPE_BOOL>: New enum value. (enum tdesc_type_kind) <TDESC_TYPE_ENUM>: Ditto. (struct tdesc_type) <u.f>: Delete. (tdesc_predefined_types): Add "bool". (tdesc_predefined_type): New function. (tdesc_gdb_type): Handle TDESC_TYPE_BOOL, TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS support. (tdesc_free_type): Handle TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS. (tdesc_create_flags): Update. (tdesc_create_enum): New function. (tdesc_add_field): Initialize start,end to -1. (tdesc_add_typed_bitfield): New function. (tdesc_add_bitfield): Call it. (tdesc_add_flag): Allow TDESC_TYPE_STRUCT. Update. (tdesc_add_enum_value): New function. (maint_print_c_tdesc_cmd): Fold TDESC_TYPE_FLAGS support into TDESC_TYPE_STRUCT. Handle TDESC_TYPE_ENUM. * target-descriptions.h (tdesc_create_enum): Declare. (tdesc_add_typed_bitfield, tdesc_add_enum_value): Declare. * valprint.c (generic_val_print_enum_1): New function. (generic_val_print_enum): Call it. (val_print_type_code_flags): Make static. Handle multibit bitfields and enum bitfields. * valprint.h (val_print_type_code_flags): Delete. * xml-tdesc.c (struct tdesc_parsing_data) <current_type_is_flags>: Delete. All uses removed. (tdesc_start_enum): New function. (tdesc_start_field): Handle multibit and enum bitfields. (tdesc_start_enum_value): New function. (enum_value_attributes, enum_children, enum_attributes): New static globals. (feature_children): Add "enum". * features/gdb-target.dtd (enum, evalue): New elements. gdb/doc/ChangeLog: * gdb.texinfo (Target Descriptions): New menu item "Enum Target Types". (Target Description Format): Mention enum types. Update docs on flags types. (Predefined Target Types): Add "bool". (Enum Target Types): New node. gdb/testsuite/ChangeLog: * gdb.xml/extra-regs.xml: Add enum, mixed_flags values. * gdb.xml/tdesc-regs.exp (load_description): New arg xml_file. All callers updated. Add tests for enums, mixed flags register.
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-11-18[C++] Add casts to obstack_base callsSimon Marchi
The recent libiberty import of upstream obstack.h (314dee8ea9be) makes obstack_base return a 'void *', with the consequence that a few places in gdb need a (char *) cast. gdb/ChangeLog: 2015-11-18 Simon Marchi <simon.marchi@ericsson.com> Pedro Alves <palves@redhat.com> * break-catch-sig.c (signal_catchpoint_print_one): Add cast. * c-exp.y (parse_string_or_char, yylex): Add casts. * c-lang.c (evaluate_subexp_c): Add casts. * d-exp.y (parse_string_or_char, yylex): Add casts. * go-exp.y (parse_string_or_char, build_packaged_name): Add casts. * p-valprint.c (pascal_object_print_value_fields): Add casts. * valprint.c (generic_emit_char, generic_printstr): Add casts.
2015-10-27target_read_memory&co: no longer return target_xfer_statusPedro Alves
Years ago, these functions used to return errno/EIO. Later, through a series of changes that intended to remove native/remote differences, they ended up returning a target_xfer_status in disguise. Unlike target_xfer_partial&co, the point of target_read_memory&co is to either fully succeed or fail. On error, they always return TARGET_XFER_E_IO. So there's no real point in casting the return of target_read_memory to a target_xfer_status to pass it to memory_error. Instead, it results in clearer code to simply decouple target_read_memory&co's return from target_xfer_status. This fixes build errors like this in C++ mode: ../../src/gdb/corefile.c: In function ‘void read_stack(CORE_ADDR, gdb_byte*, ssize_t)’: ../../src/gdb/corefile.c:276:34: error: invalid conversion from ‘int’ to ‘target_xfer_status’ [-fpermissive] memory_error (status, memaddr); ^ ../../src/gdb/corefile.c:216:1: error: initializing argument 1 of ‘void memory_error(target_xfer_status, CORE_ADDR)’ [-fpermissive] gdb/ChangeLog: 2015-10-27 Pedro Alves <palves@redhat.com> * alpha-tdep.c (alpha_read_insn): Always pass TARGET_XFER_E_IO to memory_error. Rename local 'status' to 'res'. * c-lang.c (c_get_string): Always pass TARGET_XFER_E_IO to memory_error. * corefile.c (read_stack, read_code, write_memory): Always pass TARGET_XFER_E_IO to memory_error. * disasm.c (dis_asm_memory_error): Always pass TARGET_XFER_E_IO to memory_error. Rename parameter 'status' to 'err'. (dump_insns): Rename local 'status' to 'err'. * mips-tdep.c (mips_fetch_instruction): Rename parameter 'statusp' to 'errp'. Rename local 'status' to 'err'. Always pass TARGET_XFER_E_IO to memory_error. (mips_breakpoint_from_pc): Rename local 'status' to 'err'. * target.c (target_read_memory, target_read_raw_memory) (target_read_stack, target_read_code, target_write_memory) (target_write_raw_memory): Return -1 on error instead of TARGET_XFER_E_IO. * valprint.c (val_print_string): Rename local 'errcode' to 'err'. Always pass TARGET_XFER_E_IO to memory_error. Update comment.
2015-10-21fort_dyn_array: add basic fortran dyn array supportKeven Boell
Fortran provide types whose values may be dynamically allocated or associated with a variable under explicit program control. The purpose of this commit is: * to read allocated/associated DWARF tags and store them in the dynamic property list of main_type. * enable GDB to print the value of a dynamic array in Fortran in case the type is allocated or associated (pointer to dynamic array). Examples: (gdb) p vla_not_allocated $1 = <not allocated> (gdb) p vla_allocated $1 = (1, 2, 3) (gdb) p vla_ptr_not_associated $1 = <not associated> (gdb) p vla_ptr_associated $1 = (1, 2, 3) Add basic test coverage for most dynamic array use-cases in Fortran. The commit contains the following tests: * Ensure that values of Fortran dynamic arrays can be evaluated correctly in various ways and states. * Ensure that Fortran primitives can be evaluated correctly when used as a dynamic array. * Dynamic arrays passed to subroutines and handled in different ways inside the routine. * Ensure that the ptype of dynamic arrays in Fortran can be printed in GDB correctly. * Ensure that dynamic arrays in different states (allocated/associated) can be evaluated. * Dynamic arrays passed to functions and returned from functions. * History values of dynamic arrays can be accessed and printed again with the correct values. * Dynamic array evaluations using MI protocol. * Sizeof output of dynamic arrays in various states. The patch was tested using the test suite on Ubuntu 12.04 64bit. gdb/ChangeLog: * dwarf2read.c (set_die_type): Add read of DW_AT_allocated and DW_AT_associated. * f-typeprint.c: New include of typeprint.h (f_print_type): Add check for allocated/associated status of type. (f_type_print_varspec_suffix): Add check for allocated/associated status of type. * gdbtypes.c (create_array_type_with_stride): Add check for valid data location of type in case allocated or associated attributes are set. Length of an array should be only calculated if allocated or associated is resolved as true. (is_dynamic_type_internal): Add check for allocated/ associated. (resolve_dynamic_array): Evaluate allocated/associated properties. * gdbtypes.h (enum dynamic_prop_node_kind): <DYN_PROP_ALLOCATED> <DYN_PROP_ASSOCIATED>: New enums. (TYPE_ALLOCATED_PROP, TYPE_ASSOCIATED_PROP): New macros. (type_not_allocated): New function. (type_not_associated): New function. * valarith.c (value_subscripted_rvalue): Add check for allocated/associated. * valprint.c: New include of typeprint.h. (valprint_check_validity): Add check for allocated/associated. (value_check_printable): Add check for allocated/ associated. * typeprint.h (val_print_not_allocated): New function. (val_print_not_associated): New function. * typeprint.c (val_print_not_allocated): New function. (val_print_not_associated): New function. gdb/testsuite/ChangeLog: * gdb.fortran/vla-alloc-assoc.exp: New file. * gdb.fortran/vla-datatypes.exp: New file. * gdb.fortran/vla-datatypes.f90: New file. * gdb.fortran/vla-history.exp: New file. * gdb.fortran/vla-ptype-sub.exp: New file. * gdb.fortran/vla-ptype.exp: New file. * gdb.fortran/vla-sizeof.exp: New file. * gdb.fortran/vla-sub.f90: New file. * gdb.fortran/vla-value-sub-arbitrary.exp: New file. * gdb.fortran/vla-value-sub-finish.exp: New file. * gdb.fortran/vla-value-sub.exp: New file. * gdb.fortran/vla-value.exp: New file. * gdb.fortran/vla-ptr-info.exp: New file. * gdb.mi/mi-vla-fortran.exp: New file. * gdb.mi/vla.f90: New file.
2015-09-25Add casts to memory allocation related callsSimon Marchi
Most allocation functions (if not all) return a void* pointing to the allocated memory. In C++, we need to add an explicit cast when assigning the result to a pointer to another type (which is the case more often than not). The content of this patch is taken from Pedro's branch, from commit "(mostly) auto-generated patch to insert casts needed for C++". I validated that the changes make sense and manually reflowed the code to make it respect the coding style. I also found multiple places where I could use XNEW/XNEWVEC/XRESIZEVEC/etc. Thanks a lot to whoever did that automated script to insert casts, doing it completely by hand would have taken a ridiculous amount of time. Only files built on x86 with --enable-targets=all are modified. This means that all other -nat.c files are untouched and will have to be dealt with later by using appropiate compilers. Or maybe we can try to build them with a regular g++ just to know where to add casts, I don't know. I built-tested this with --enable-targets=all and reg-tested. Here's the changelog entry, which was not too bad to make despite the size, thanks to David Malcom's script. I fixed some bits by hand, but there might be some wrong parts left (hopefully not). gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast to allocation result assignment. * ada-exp.y (write_object_renaming): Likewise. (write_ambiguous_var): Likewise. (ada_nget_field_index): Likewise. (write_var_or_type): Likewise. * ada-lang.c (ada_decode_symbol): Likewise. (ada_value_assign): Likewise. (value_pointer): Likewise. (cache_symbol): Likewise. (add_nonlocal_symbols): Likewise. (ada_name_for_lookup): Likewise. (symbol_completion_add): Likewise. (ada_to_fixed_type_1): Likewise. (ada_get_next_arg): Likewise. (defns_collected): Likewise. * ada-lex.l (processId): Likewise. (processString): Likewise. * ada-tasks.c (read_known_tasks_array): Likewise. (read_known_tasks_list): Likewise. * ada-typeprint.c (decoded_type_name): Likewise. * addrmap.c (addrmap_mutable_create_fixed): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_displaced_step_copy_insn): Likewise. (amd64_classify_insn_at): Likewise. (amd64_relocate_instruction): Likewise. * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise. * arch-utils.c (simple_displaced_step_copy_insn): Likewise. (initialize_current_architecture): Likewise. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise. * arm-tdep.c (arm_exidx_new_objfile): Likewise. (arm_push_dummy_call): Likewise. (extend_buffer_earlier): Likewise. (arm_adjust_breakpoint_address): Likewise. (arm_skip_stub): Likewise. * auto-load.c (filename_is_in_pattern): Likewise. (maybe_add_script_file): Likewise. (maybe_add_script_text): Likewise. (auto_load_objfile_script_1): Likewise. * auxv.c (ld_so_xfer_auxv): Likewise. * ax-general.c (new_agent_expr): Likewise. (grow_expr): Likewise. (ax_reg_mask): Likewise. * bcache.c (bcache_full): Likewise. * breakpoint.c (program_breakpoint_here_p): Likewise. * btrace.c (parse_xml_raw): Likewise. * build-id.c (build_id_to_debug_bfd): Likewise. * buildsym.c (end_symtab_with_blockvector): Likewise. * c-exp.y (string_exp): Likewise. (qualified_name): Likewise. (write_destructor_name): Likewise. (operator_stoken): Likewise. (parse_number): Likewise. (scan_macro_expansion): Likewise. (yylex): Likewise. (c_print_token): Likewise. * c-lang.c (c_get_string): Likewise. (emit_numeric_character): Likewise. * charset.c (wchar_iterate): Likewise. * cli/cli-cmds.c (complete_command): Likewise. (make_command): Likewise. * cli/cli-dump.c (restore_section_callback): Likewise. (restore_binary_file): Likewise. * cli/cli-interp.c (cli_interpreter_exec): Likewise. * cli/cli-script.c (execute_control_command): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. (read_pe_exported_syms): Likewise. * coffread.c (coff_read_struct_type): Likewise. (coff_read_enum_type): Likewise. * common/btrace-common.c (btrace_data_append): Likewise. * common/buffer.c (buffer_grow): Likewise. * common/filestuff.c (gdb_fopen_cloexec): Likewise. * common/format.c (parse_format_string): Likewise. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. * common/xml-utils.c (xml_escape_text): Likewise. * compile/compile-object-load.c (copy_sections): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * completer.c (filename_completer): Likewise. * corefile.c (read_memory_typed_address): Likewise. (write_memory_unsigned_integer): Likewise. (write_memory_signed_integer): Likewise. (complete_set_gnutarget): Likewise. * corelow.c (get_core_register_section): Likewise. * cp-name-parser.y (d_grab): Likewise. (allocate_info): Likewise. (cp_new_demangle_parse_info): Likewise. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise. (cp_lookup_symbol_in_namespace): Likewise. (lookup_namespace_scope): Likewise. (find_symbol_in_baseclass): Likewise. (cp_lookup_nested_symbol): Likewise. (cp_lookup_transparent_type_loop): Likewise. * cp-support.c (copy_string_to_obstack): Likewise. (make_symbol_overload_list): Likewise. (make_symbol_overload_list_namespace): Likewise. (make_symbol_overload_list_adl_namespace): Likewise. (first_component_command): Likewise. * cp-valprint.c (cp_print_value): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * d-exp.y (StringExp): Likewise. * d-namespace.c (d_lookup_symbol_in_module): Likewise. (lookup_module_scope): Likewise. (find_symbol_in_baseclass): Likewise. (d_lookup_nested_symbol): Likewise. * dbxread.c (find_stab_function_addr): Likewise. (read_dbx_symtab): Likewise. (dbx_end_psymtab): Likewise. (cp_set_block_scope): Likewise. * dcache.c (dcache_alloc): Likewise. * demangle.c (_initialize_demangler): Likewise. * dicos-tdep.c (dicos_load_module_p): Likewise. * dictionary.c (dict_create_hashed_expandable): Likewise. (dict_create_linear_expandable): Likewise. (expand_hashtable): Likewise. (add_symbol_linear_expandable): Likewise. * dwarf2-frame.c (add_cie): Likewise. (add_fde): Likewise. (dwarf2_build_frame_info): Likewise. * dwarf2expr.c (dwarf_expr_grow_stack): Likewise. (dwarf_expr_fetch_address): Likewise. (add_piece): Likewise. (execute_stack_op): Likewise. * dwarf2loc.c (chain_candidate): Likewise. (dwarf_entry_parameter_to_value): Likewise. (read_pieced_value): Likewise. (write_pieced_value): Likewise. * dwarf2read.c (dwarf2_read_section): Likewise. (add_type_unit): Likewise. (read_comp_units_from_section): Likewise. (fixup_go_packaging): Likewise. (dwarf2_compute_name): Likewise. (dwarf2_physname): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_attach_fields_to_type): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (read_common_block): Likewise. (abbrev_table_read_table): Likewise. (guess_partial_die_structure_name): Likewise. (fixup_partial_die): Likewise. (add_file_name): Likewise. (dwarf2_const_value_data): Likewise. (dwarf2_const_value_attr): Likewise. (build_error_marker_type): Likewise. (guess_full_die_structure_name): Likewise. (anonymous_struct_prefix): Likewise. (typename_concat): Likewise. (dwarf2_canonicalize_name): Likewise. (dwarf2_name): Likewise. (write_constant_as_bytes): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (copy_string): Likewise. (parse_macro_definition): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_rel_plt_read): Likewise. (elf_gnu_ifunc_resolve_by_cache): Likewise. (elf_gnu_ifunc_resolve_by_got): Likewise. (elf_read_minimal_symbols): Likewise. (elf_gnu_ifunc_record_cache): Likewise. * event-top.c (top_level_prompt): Likewise. (command_line_handler): Likewise. * exec.c (resize_section_table): Likewise. * expprint.c (print_subexp_standard): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * findcmd.c (parse_find_args): Likewise. * findvar.c (address_from_register): Likewise. * frame.c (get_prev_frame_always): Likewise. * gdb_bfd.c (gdb_bfd_ref): Likewise. (get_section_descriptor): Likewise. * gdb_obstack.c (obconcat): Likewise. (obstack_strdup): Likewise. * gdbtypes.c (lookup_function_type_with_arguments): Likewise. (create_set_type): Likewise. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (resolve_dynamic_union): Likewise. (resolve_dynamic_struct): Likewise. (add_dyn_prop): Likewise. (copy_dynamic_prop_list): Likewise. (arch_flags_type): Likewise. (append_composite_type_field_raw): Likewise. * gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise. * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. * go-exp.y (string_exp): Likewise. * go-lang.c (go_demangle): Likewise. * guile/guile.c (compute_scheme_string): Likewise. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. (gdbscm_canonicalize_command_name): Likewise. * guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise. (ioscm_init_memory_port): Likewise. (ioscm_reinit_memory_port): Likewise. * guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise. (gdbscm_gc_dup_argv): Likewise. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (internalize_unwinds): Likewise. (read_unwind_info): Likewise. * i386-cygwin-tdep.c (core_process_module_section): Likewise. (windows_core_xfer_shared_libraries): Likewise. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise. * inf-child.c (inf_child_fileio_readlink): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_store_register): Likewise. * infrun.c (follow_exec): Likewise. (displaced_step_prepare_throw): Likewise. (save_stop_context): Likewise. (save_infcall_suspend_state): Likewise. * jit.c (jit_read_descriptor): Likewise. (jit_read_code_entry): Likewise. (jit_symtab_line_mapping_add_impl): Likewise. (finalize_symtab): Likewise. (jit_unwind_reg_get_impl): Likewise. * jv-exp.y (QualifiedName): Likewise. * jv-lang.c (get_java_utf8_name): Likewise. (type_from_class): Likewise. (java_demangle_type_signature): Likewise. (java_class_name_from_physname): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_value_print): Likewise. * language.c (add_language): Likewise. * linespec.c (add_sal_to_sals_basic): Likewise. (add_sal_to_sals): Likewise. (decode_objc): Likewise. (find_linespec_symbols): Likewise. * linux-fork.c (fork_save_infrun_state): Likewise. * linux-nat.c (linux_nat_detach): Likewise. (linux_nat_fileio_readlink): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (Do): Likewise. * linux-tdep.c (linux_core_info_proc_mappings): Likewise. (linux_collect_regset_section_cb): Likewise. (linux_get_siginfo_data): Likewise. * linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise. (try_thread_db_load_from_dir): Likewise. (thread_db_load_search): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise. (m32c_m16c_pointer_to_address): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise. * m68k-tdep.c (m68k_get_longjmp_target): Likewise. * machoread.c (macho_check_dsym): Likewise. * macroexp.c (resize_buffer): Likewise. (gather_arguments): Likewise. (maybe_expand): Likewise. * macrotab.c (new_macro_key): Likewise. (new_source_file): Likewise. (new_macro_definition): Likewise. * mdebugread.c (parse_symbol): Likewise. (parse_type): Likewise. (parse_partial_symbols): Likewise. (psymtab_to_symtab_1): Likewise. * mem-break.c (default_memory_insert_breakpoint): Likewise. * mi/mi-cmd-break.c (mi_argv_to_format): Likewise. * mi/mi-main.c (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_data_write_memory_bytes): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. (mi_parse): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. * mips-tdep.c (mips_read_fp_register_single): Likewise. (mips_print_fp_register): Likewise. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise. * mipsread.c (read_alphacoff_dynamic_symtab): Likewise. * mt-tdep.c (mt_register_name): Likewise. (mt_registers_info): Likewise. (mt_push_dummy_call): Likewise. * namespace.c (add_using_directive): Likewise. * nat/linux-btrace.c (perf_event_read): Likewise. (linux_enable_bts): Likewise. * nat/linux-osdata.c (linux_common_core_of_thread): Likewise. * nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_parse_redirection): Likewise. * objc-lang.c (objc_demangle): Likewise. (find_methods): Likewise. * objfiles.c (get_objfile_bfd_data): Likewise. (set_objfile_main_name): Likewise. (allocate_objfile): Likewise. (objfile_relocate): Likewise. (update_section_map): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * p-exp.y (exp): Likewise. (yylex): Likewise. * p-valprint.c (pascal_object_print_value): Likewise. * parse.c (initialize_expout): Likewise. (mark_completion_tag): Likewise. (copy_name): Likewise. (parse_float): Likewise. (type_stack_reserve): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. (ppu2spu_prev_register): Likewise. * ppc-ravenscar-thread.c (supply_register_at_address): Likewise. * printcmd.c (printf_wide_c_string): Likewise. (printf_pointer): Likewise. * probe.c (parse_probes): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. (cmdpy_init): Likewise. * python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise. * python/py-symtab.c (set_sal): Likewise. * python/py-unwind.c (pyuw_sniffer): Likewise. * python/python.c (python_interactive_command): Likewise. (compute_python_string): Likewise. * ravenscar-thread.c (get_running_thread_id): Likewise. * record-full.c (record_full_exec_insn): Likewise. (record_full_core_open_1): Likewise. * regcache.c (regcache_raw_read_signed): Likewise. (regcache_raw_read_unsigned): Likewise. (regcache_cooked_read_signed): Likewise. (regcache_cooked_read_unsigned): Likewise. * remote-fileio.c (remote_fileio_func_open): Likewise. (remote_fileio_func_rename): Likewise. (remote_fileio_func_unlink): Likewise. (remote_fileio_func_stat): Likewise. (remote_fileio_func_system): Likewise. * remote-mips.c (mips_xfer_memory): Likewise. (mips_load_srec): Likewise. (pmon_end_download): Likewise. * remote.c (new_remote_state): Likewise. (map_regcache_remote_table): Likewise. (remote_register_number_and_offset): Likewise. (init_remote_state): Likewise. (get_memory_packet_size): Likewise. (remote_pass_signals): Likewise. (remote_program_signals): Likewise. (remote_start_remote): Likewise. (remote_check_symbols): Likewise. (remote_query_supported): Likewise. (extended_remote_attach): Likewise. (process_g_packet): Likewise. (store_registers_using_G): Likewise. (putpkt_binary): Likewise. (read_frame): Likewise. (compare_sections_command): Likewise. (remote_hostio_pread): Likewise. (remote_hostio_readlink): Likewise. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_pid_to_exec_file): Likewise. (_initialize_remote): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise. (bfd_uses_spe_extensions): Likewise. * s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise. * score-tdep.c (score7_malloc_and_get_memblock): Likewise. * solib-dsbt.c (decode_loadmap): Likewise. (fetch_loadmap): Likewise. (scan_dyntag): Likewise. (enable_break): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (fetch_loadmap): Likewise. (enable_break2): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_relocate_main_executable): Likewise. (spu_bfd_open): Likewise. * solib-svr4.c (lm_info_read): Likewise. (read_program_header): Likewise. (find_program_interpreter): Likewise. (scan_dyntag): Likewise. (elf_locate_base): Likewise. (open_symbol_file_object): Likewise. (read_program_headers_from_bfd): Likewise. (svr4_relocate_main_executable): Likewise. * solib-target.c (solib_target_relocate_section_addresses): Likewise. * solib.c (solib_find_1): Likewise. (exec_file_find): Likewise. (solib_find): Likewise. * source.c (openp): Likewise. (print_source_lines_base): Likewise. (forward_search_command): Likewise. * sparc-ravenscar-thread.c (supply_register_at_address): Likewise. * spu-tdep.c (spu2ppu_prev_register): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (patch_block_stabs): Likewise. (define_symbol): Likewise. (again:): Likewise. (read_member_functions): Likewise. (read_one_struct_field): Likewise. (read_enum_type): Likewise. (common_block_start): Likewise. * stack.c (read_frame_arg): Likewise. (backtrace_command): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. * symfile.c (syms_from_objfile_1): Likewise. (find_separate_debug_file): Likewise. (load_command): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (reread_symbols): Likewise. (add_filename_language): Likewise. (allocate_compunit_symtab): Likewise. (read_target_long_array): Likewise. (simple_read_overlay_table): Likewise. * symtab.c (symbol_set_names): Likewise. (resize_symbol_cache): Likewise. (rbreak_command): Likewise. (completion_list_add_name): Likewise. (completion_list_objc_symbol): Likewise. (add_filename_to_list): Likewise. * target-descriptions.c (maint_print_c_tdesc_cmd): Likewise. * target-memory.c (target_write_memory_blocks): Likewise. * target.c (target_read_string): Likewise. (read_whatever_is_readable): Likewise. (target_read_alloc_1): Likewise. (simple_search_memory): Likewise. (target_fileio_read_alloc_1): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * top.c (command_line_input): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (tracefile_fetch_registers): Likewise. * tracepoint.c (add_memrange): Likewise. (init_collection_list): Likewise. (add_aexpr): Likewise. (trace_dump_actions): Likewise. (parse_trace_status): Likewise. (parse_tracepoint_definition): Likewise. (parse_tsv_definition): Likewise. (parse_static_tracepoint_marker_definition): Likewise. * tui/tui-file.c (tui_sfileopen): Likewise. (tui_file_adjust_strbuf): Likewise. * tui/tui-io.c (tui_expand_tabs): Likewise. * tui/tui-source.c (tui_set_source_content): Likewise. * typeprint.c (find_global_typedef): Likewise. * ui-file.c (do_ui_file_xstrdup): Likewise. (ui_file_obsavestring): Likewise. (mem_file_write): Likewise. * utils.c (make_hex_string): Likewise. (get_regcomp_error): Likewise. (puts_filtered_tabular): Likewise. (gdb_realpath_keepfile): Likewise. (ldirname): Likewise. (gdb_bfd_errmsg): Likewise. (substitute_path_component): Likewise. * valops.c (search_struct_method): Likewise. (find_oload_champ_namespace_loop): Likewise. * valprint.c (print_decimal_chars): Likewise. (read_string): Likewise. (generic_emit_char): Likewise. * varobj.c (varobj_delete): Likewise. (varobj_value_get_print_value): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise. * windows-tdep.c (display_one_tib): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. (process_xcoff_symbol): Likewise. (swap_sym): Likewise. (scan_xcoff_symtab): Likewise. (xcoff_initial_scan): Likewise. * xml-support.c (gdb_xml_end_element): Likewise. (xml_process_xincludes): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (xml_list_of_syscalls): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Add cast to allocation result assignment. (gdb_unparse_agent_expr): Likewise. * hostio.c (require_data): Likewise. (handle_pread): Likewise. * linux-low.c (disable_regset): Likewise. (fetch_register): Likewise. (store_register): Likewise. (get_dynamic): Likewise. (linux_qxfer_libraries_svr4): Likewise. * mem-break.c (delete_fast_tracepoint_jump): Likewise. (set_fast_tracepoint_jump): Likewise. (uninsert_fast_tracepoint_jumps_at): Likewise. (reinsert_fast_tracepoint_jumps_at): Likewise. (validate_inserted_breakpoint): Likewise. (clone_agent_expr): Likewise. * regcache.c (init_register_cache): Likewise. * remote-utils.c (putpkt_binary_1): Likewise. (decode_M_packet): Likewise. (decode_X_packet): Likewise. (look_up_one_symbol): Likewise. (relocate_instruction): Likewise. (monitor_output): Likewise. * server.c (handle_search_memory): Likewise. (handle_qxfer_exec_file): Likewise. (handle_qxfer_libraries): Likewise. (handle_qxfer): Likewise. (handle_query): Likewise. (handle_v_cont): Likewise. (handle_v_run): Likewise. (captured_main): Likewise. * target.c (write_inferior_memory): Likewise. * thread-db.c (try_thread_db_load_from_dir): Likewise. * tracepoint.c (init_trace_buffer): Likewise. (add_tracepoint_action): Likewise. (add_traceframe): Likewise. (add_traceframe_block): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtdv): Likewise. (cmd_qtstatus): Likewise. (response_source): Likewise. (response_tsv): Likewise. (cmd_qtnotes): Likewise. (gdb_collect): Likewise. (initialize_tracepoint): 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-27Factor out complex printing code from generic_val_printSimon Marchi
gdb/ChangeLog: * valprint.c (generic_val_print): Factor out complex printing code to ... (generic_val_print_complex): ... this new function.
2015-07-27Factor out decfloat printing code from generic_val_printSimon Marchi
gdb/ChangeLog: * valprint.c (generic_val_print): Factor out decfloat printing code to ... (generic_val_print_decfloat): ... this new function.
2015-07-27Factor out float printing code from generic_val_printSimon Marchi
gdb/ChangeLog: * valprint.c (generic_val_print): Factor out float printing code to ... (generic_val_print_float): ... this new function.
2015-07-27Factor out char printing code from generic_val_printSimon Marchi
gdb/ChangeLog: * valprint.c (generic_val_print): Factor out char printing code to ... (generic_val_print_char): ... this new function.
2015-07-27Factor out int printing code from generic_val_printSimon Marchi
gdb/ChangeLog: * valprint.c (generic_val_print): Factor out integer printing code to ... (generic_val_print_int): ... this new function.
2015-07-27Factor out bool printing code from generic_val_printSimon Marchi
gdb/ChangeLog: * valprint.c (generic_val_print): Factor out bool printing code to ... (generic_val_print_bool): ... this new function.
2015-07-27Factor out function/method printing code from generic_val_printSimon Marchi
gdb/ChangeLog: * valprint.c (generic_val_print): Factor out function/method printing code to ... (generic_val_print_func): ... this new function.
2015-07-27Factor out flags printing code from generic_val_printSimon Marchi
gdb/ChangeLog: * valprint.c (generic_val_print): Factor out flags printing code to ... (generic_val_print_flags): ... this new function.
2015-07-27Factor out enum printing code from generic_val_printSimon Marchi
gdb/ChangeLog: * valprint.c (generic_val_print): Factor out enum printing code to ... (generic_val_print_enum): ... this new function.
2015-07-27Factor out reference printing code from generic_val_printSimon Marchi
gdb/ChangeLog: * valprint.c (generic_val_print): Factor out reference printing code to ... (generic_val_print_ref): ... this new function.
2015-07-27Factor out memberptr printing code from generic_val_printSimon Marchi
gdb/ChangeLog: * valprint.c (generic_val_print): Factor out memberptr printing code to ... (generic_val_print_memberptr): ... this new function.
2015-07-27Factor out pointer printing code from generic_val_printSimon Marchi
gdb/ChangeLog: * valprint.c (generic_val_print): Factor out pointer printing code to ... (generic_val_print_ptr): ... this new function.
2015-07-27Factor out array printing code from generic_val_printSimon Marchi
gdb/ChangeLog: * valprint.c (generic_val_print): Factor out array printing code to ... (generic_val_print_array): ... this new function.
2015-07-27Factor out print_unpacked_pointer from generic_val_printSimon Marchi
gdb/ChangeLog: * valprint.c (generic_val_print): Factor out print_unpacked_pointer code to ... (print_unpacked_pointer): ... this new function.
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-05-15Array indexed by non-contiguous enumeration typesJerome Guitton
In Ada, index types of arrays can be enumeration types, and enumeration types can be non-contiguous. In which case the address of elements is not given by the value of the index, but by its position in the enumeration type. In other words, in this example: type Color is (Blue, Red); for Color use (Blue => 8, Red => 12, Green => 16); type A is array (Color) of Integer; type B is array (1 .. 3) of Integer; Arrays of type A and B will have the same layout in memory, even if the enumeration Color has a hole in its set of integer value. Since recently support for such a feature was in ada-lang.c, where the array was casted to a regular continuous index range. We were losing the information of index type. And this was not quite working for subranges in variable-length fields; their bounds are expressed using the integer value of the bounds, not its position in the enumeration, and there was some confusion all over ada-lang.c as to whether we had the position or the integer value was used for indexes. The idea behind this patch is to clean this up by keeping the real representation of these array index types and bounds when representing the value, and only use the position when accessing the elements or computing the length. This first patch fixes the printing of such an array. To the best of my knowledge, this feature only exists in Ada so it should only affect this language. gdb/ChangeLog: Jerome Guitton <guitton@adacore.com>: * ada-lang.c (ada_value_ptr_subscript): Use enum position of index to get element instead of enum value. (ada_value_slice_from_ptr, ada_value_slice): Use enum position of index to compute length, but enum values to compute bounds. (ada_array_length): Use enum position of index instead of enum value. (pos_atr): Move position computation to... (ada_evaluate_subexp): Use enum values to compute bounds. * gdbtypes.c (discrete_position): ...this new function. * gdbtypes.h (discrete_position): New function declaration. * valprint.c (val_print_array_elements): Call discrete_position to handle array indexed by non-contiguous enumeration types. gdb/testsuite/ChangeLog: * gdb.ada/arr_enum_with_gap: New testcase.