Commit Graph

90 Commits

Author SHA1 Message Date
Tom Tromey 426a9c18dd Remove val_print
We can finally remove val_print and various helper functions that are
no longer needed.

gdb/ChangeLog
2020-03-13  Tom Tromey  <tom@tromey.com>

	* value.h (val_print): Don't declare.
	* valprint.h (val_print_array_elements)
	(val_print_scalar_formatted, generic_val_print): Don't declare.
	* valprint.c (generic_val_print_array): Take a struct value.
	(generic_val_print_ptr, generic_val_print_memberptr)
	(generic_val_print_bool, generic_val_print_int)
	(generic_val_print_char, generic_val_print_complex)
	(generic_val_print): Remove.
	(generic_value_print): Update.
	(do_val_print): Remove unused parameters.  Don't call
	la_val_print.
	(val_print): Remove.
	(common_val_print): Update.  Don't call value_check_printable.
	(val_print_scalar_formatted, val_print_array_elements): Remove.
	* rust-lang.c (rust_val_print): Remove.
	(rust_language_defn): Update.
	* p-valprint.c (pascal_val_print): Remove.
	(pascal_value_print_inner): Update.
	(pascal_object_print_val_fields, pascal_object_print_val):
	Remove.
	(pascal_object_print_static_field): Update.
	* p-lang.h (pascal_val_print): Don't declare.
	* p-lang.c (pascal_language_defn): Update.
	* opencl-lang.c (opencl_language_defn): Update.
	* objc-lang.c (objc_language_defn): Update.
	* m2-valprint.c (m2_print_unbounded_array, m2_val_print): Remove.
	* m2-lang.h (m2_val_print): Don't declare.
	* m2-lang.c (m2_language_defn): Update.
	* language.h (struct language_defn) <la_val_print>: Remove.
	* language.c (unk_lang_value_print_inner): Rename.  Change
	argument types.
	(unknown_language_defn, auto_language_defn): Update.
	* go-valprint.c (go_val_print): Remove.
	* go-lang.h (go_val_print): Don't declare.
	* go-lang.c (go_language_defn): Update.
	* f-valprint.c (f_val_print): Remove.
	* f-lang.h (f_value_print): Don't declare.
	* f-lang.c (f_language_defn): Update.
	* d-valprint.c (d_val_print): Remove.
	* d-lang.h (d_value_print): Don't declare.
	* d-lang.c (d_language_defn): Update.
	* cp-valprint.c (cp_print_value_fields)
	(cp_print_value_fields_rtti, cp_print_value): Remove.
	(cp_print_static_field): Update.
	* c-valprint.c (c_val_print_array, c_val_print_ptr)
	(c_val_print_struct, c_val_print_union, c_val_print_int)
	(c_val_print_memberptr, c_val_print): Remove.
	* c-lang.h (c_val_print_array, cp_print_value_fields)
	(cp_print_value_fields_rtti): Don't declare.
	* c-lang.c (c_language_defn, cplus_language_defn)
	(asm_language_defn, minimal_language_defn): Update.
	* ada-valprint.c (ada_val_print_ptr, ada_val_print_num): Remove.
	(ada_val_print_enum): Take a struct value.
	(ada_val_print_flt, ada_val_print_array, ada_val_print_1)
	(ada_val_print): Remove.
	(ada_value_print_1): Update.
	(printable_val_type): Remove.
	* ada-lang.h (ada_val_print): Don't declare.
	* ada-lang.c (ada_language_defn): Update.
2020-03-13 18:03:42 -06:00
Tom Tromey d121c6ce89 Introduce value_print_array_elements
This introduces value_print_array_elements, which is an analogue of
val_print_array_elements that uses the value API.

gdb/ChangeLog
2020-03-13  Tom Tromey  <tom@tromey.com>

	* valprint.c (value_print_array_elements): New function.
	* valprint.h (value_print_array_elements): Declare.
2020-03-13 18:03:40 -06:00
Tom Tromey 4f9ae81013 Introduce value_print_scalar_formatted
This introduces a value_print_scalar_formatted, which is an analogue
of val_print_scalar_formatted that uses the value API.

gdb/ChangeLog
2020-03-13  Tom Tromey  <tom@tromey.com>

	* valprint.h (value_print_scalar_formatted): Declare.
	* valprint.c (value_print_scalar_formatted): New function.
2020-03-13 18:03:40 -06:00
Tom Tromey 156bfec999 Introduce generic_value_print
This introduces generic_value_print, which is a value-based analogue
to generic_val_print.  For now this is unused and simply calls
generic_val_print, but subsequent patches will both change this
function to work using the value API directly, and convert callers of
generic_val_print to call this instead.

gdb/ChangeLog
2020-03-13  Tom Tromey  <tom@tromey.com>

	* valprint.h (generic_value_print): Declare.
	* valprint.c (generic_value_print): New function.
2020-03-13 18:03:40 -06:00
Tom Tromey c2a44efee1 Introduce common_val_print_checked
A (much) later patch will remove the call to value_check_printable
from common_val_print.  This will needed to preserve some details of
how optimized-out structures are printed.

However, doing this will also break dw2-op-out-param.exp.  Making the
change causes "bt" to print:

However, the test wants to see:

... operand2=<optimized out>

That is, a wholly-optimized out structure should not print its fields.

So, this patch introduces a new common_val_print_checked, which calls
value_check_printable first, and then arranges to use it in the one
spot that affects the test suite.

I was not completely sure if it would be preferable to change the
test.  However, I reasoned that, assuming this output was intentional
in the first place, in a backtrace space is at a premium and so this
is a reasonable approach.  In other spots calling common_val_print,
this behavior is probably unintended, or at least a "don't care".

gdb/ChangeLog
2020-03-13  Tom Tromey  <tom@tromey.com>

	* valprint.h (common_val_print_checked): Declare.
	* valprint.c (common_val_print_checked): New function.
	* stack.c (print_frame_arg): Use common_val_print_checked.
2020-03-13 18:03:39 -06:00
Joel Brobecker b811d2c292 Update copyright year range in all GDB files.
gdb/ChangeLog:

        Update copyright year range in all GDB files.
2020-01-01 10:20:53 +04:00
Tom de Vries 30baf67b65 [gdb] Fix more typos in comments (2)
Fix typos in comments.  NFC.

Tested on x86_64-linux.

gdb/ChangeLog:

2019-10-26  Tom de Vries  <tdevries@suse.de>

	* aarch64-linux-tdep.c: Fix typos in comments.
	* aarch64-tdep.c: Same.
	* ada-lang.c: Same.
	* amd64-nat.c: Same.
	* arc-tdep.c: Same.
	* arch/aarch64-insn.c: Same.
	* block.c: Same.
	* breakpoint.h: Same.
	* btrace.h: Same.
	* c-varobj.c: Same.
	* cli/cli-decode.c: Same.
	* cli/cli-script.c: Same.
	* cli/cli-utils.h: Same.
	* coff-pe-read.c: Same.
	* coffread.c: Same.
	* compile/compile-cplus-symbols.c: Same.
	* compile/compile-object-run.c: Same.
	* completer.c: Same.
	* corelow.c: Same.
	* cp-support.c: Same.
	* demangle.c: Same.
	* dwarf-index-write.c: Same.
	* dwarf2-frame.c: Same.
	* dwarf2-frame.h: Same.
	* eval.c: Same.
	* frame-base.h: Same.
	* frame.h: Same.
	* gdbcmd.h: Same.
	* gdbtypes.h: Same.
	* gnu-nat.c: Same.
	* guile/scm-objfile.c: Same.
	* i386-tdep.c: Same.
	* i386-tdep.h: Same.
	* infcall.c: Same.
	* infcall.h: Same.
	* linux-nat.c: Same.
	* m68k-tdep.c: Same.
	* macroexp.c: Same.
	* memattr.c: Same.
	* mi/mi-cmd-disas.c: Same.
	* mi/mi-getopt.h: Same.
	* mi/mi-main.c: Same.
	* minsyms.c: Same.
	* nat/aarch64-sve-linux-sigcontext.h: Same.
	* objfiles.h: Same.
	* ppc-linux-nat.c: Same.
	* ppc-linux-tdep.c: Same.
	* ppc-tdep.h: Same.
	* progspace.h: Same.
	* prologue-value.h: Same.
	* python/py-evtregistry.c: Same.
	* python/py-instruction.h: Same.
	* record-btrace.c: Same.
	* record-full.c: Same.
	* remote.c: Same.
	* rs6000-tdep.c: Same.
	* ser-tcp.c: Same.
	* sol-thread.c: Same.
	* sparc-sol2-tdep.c: Same.
	* sparc64-tdep.c: Same.
	* stabsread.c: Same.
	* symfile.c: Same.
	* symtab.h: Same.
	* target.c: Same.
	* tracepoint.c: Same.
	* tui/tui-data.h: Same.
	* tui/tui-io.c: Same.
	* tui/tui-win.c: Same.
	* tui/tui.c: Same.
	* unittests/rsp-low-selftests.c: Same.
	* user-regs.h: Same.
	* utils.c: Same.
	* utils.h: Same.
	* valarith.c: Same.
	* valops.c: Same.
	* valprint.c: Same.
	* valprint.h: Same.
	* value.c: Same.
	* value.h: Same.
	* varobj.c: Same.
	* x86-nat.h: Same.
	* xtensa-tdep.c: Same.

gdb/gdbserver/ChangeLog:

2019-10-26  Tom de Vries  <tdevries@suse.de>

	* linux-aarch64-low.c: Fix typos in comments.
	* linux-arm-low.c: Same.
	* linux-low.c: Same.
	* linux-ppc-low.c: Same.
	* proc-service.c: Same.
	* regcache.h: Same.
	* server.c: Same.
	* tracepoint.c: Same.
	* win32-low.c: Same.

gdb/stubs/ChangeLog:

2019-10-26  Tom de Vries  <tdevries@suse.de>

	* ia64vms-stub.c: Fix typos in comments.
	* m32r-stub.c: Same.
	* m68k-stub.c: Same.
	* sh-stub.c: Same.

gdb/testsuite/ChangeLog:

2019-10-26  Tom de Vries  <tdevries@suse.de>

	* gdb.base/bigcore.c: Fix typos in comments.
	* gdb.base/ctf-ptype.c: Same.
	* gdb.base/long_long.c: Same.
	* gdb.dwarf2/dw2-op-out-param.S: Same.
	* gdb.python/py-evthreads.c: Same.
	* gdb.reverse/i387-stack-reverse.c: Same.
	* gdb.trace/tfile.c: Same.
	* lib/compiler.c: Same.
	* lib/compiler.cc: Same.

Change-Id: I8573d84a577894270179ae30f46c48d806fc1beb
2019-10-26 09:55:32 +02:00
Christian Biesinger 491144b5e2 Change boolean options to bool instead of int
This is for add_setshow_boolean_cmd as well as the gdb::option interface.

gdb/ChangeLog:

2019-09-17  Christian Biesinger  <cbiesinger@google.com>

	* ada-lang.c (ada_ignore_descriptive_types_p): Change to bool.
	(print_signatures): Likewise.
	(trust_pad_over_xvs): Likewise.
	* arch/aarch64-insn.c (aarch64_debug): Likewise.
	* arch/aarch64-insn.h (aarch64_debug): Likewise.
	* arm-linux-nat.c (arm_apcs_32): Likewise.
	* arm-linux-tdep.c (arm_apcs_32): Likewise.
	* arm-nbsd-nat.c (arm_apcs_32): Likewise.
	* arm-tdep.c (arm_debug): Likewise.
	(arm_apcs_32): Likewise.
	* auto-load.c (debug_auto_load): Likewise.
	(auto_load_gdb_scripts): Likewise.
	(global_auto_load): Likewise.
	(auto_load_local_gdbinit): Likewise.
	(auto_load_local_gdbinit_loaded): Likewise.
	* auto-load.h (global_auto_load): Likewise.
	(auto_load_local_gdbinit): Likewise.
	(auto_load_local_gdbinit_loaded): Likewise.
	* breakpoint.c (disconnected_dprintf): Likewise.
	(breakpoint_proceeded): Likewise.
	(automatic_hardware_breakpoints): Likewise.
	(always_inserted_mode): Likewise.
	(target_exact_watchpoints): Likewise.
	(_initialize_breakpoint): Update.
	* breakpoint.h (target_exact_watchpoints): Change to bool.
	* btrace.c (maint_btrace_pt_skip_pad): Likewise.
	* cli/cli-cmds.c (trace_commands): Likewise.
	* cli/cli-cmds.h (trace_commands): Likewise.
	* cli/cli-decode.c (add_setshow_boolean_cmd): Change int* argument
	to bool*.
	* cli/cli-logging.c (logging_overwrite): Change to bool.
	(logging_redirect): Likewise.
	(debug_redirect): Likewise.
	* cli/cli-option.h (option_def) <boolean>: Change return type to bool*.
	(struct boolean_option_def) <get_var_address_cb_>: Change return type
	to bool.
	<boolean_option_def>: Update.
	(struct flag_option_def): Change default type of Context to bool
	from int.
	<flag_option_def>: Change return type of var_address_cb_ to bool*.
	* cli/cli-setshow.c (do_set_command): Cast to bool* instead of int*.
	(get_setshow_command_value_string): Likewise.
	* cli/cli-style.c (cli_styling): Change to bool.
	(source_styling): Likewise.
	* cli/cli-style.h (source_styling): Likewise.
	(cli_styling): Likewise.
	* cli/cli-utils.h (struct qcs_flags) <quiet, cont, silent>: Change
	to bool.
	* command.h (var_types): Update comment.
	(add_setshow_boolean_cmd): Change int* var argument to bool*.
	* compile/compile-cplus-types.c (debug_compile_cplus_types): Change to
	bool.
	(debug_compile_cplus_scopes): Likewise.
	* compile/compile-internal.h (compile_debug): Likewise.
	* compile/compile.c (compile_debug): Likewise.
	(struct compile_options) <raw>: Likewise.
	* cp-support.c (catch_demangler_crashes): Likewise.
	* cris-tdep.c (usr_cmd_cris_version_valid): Likewise.
	(usr_cmd_cris_dwarf2_cfi): Likewise.
	* csky-tdep.c (csky_debug): Likewise.
	* darwin-nat.c (enable_mach_exceptions): Likewise.
	* dcache.c (dcache_enabled_p): Likewise.
	* defs.h (info_verbose): Likewise.
	* demangle.c (demangle): Likewise.
	(asm_demangle): Likewise.
	* dwarf-index-cache.c (debug_index_cache): Likewise.
	* dwarf2-frame.c (dwarf2_frame_unwinders_enabled_p): Likewise.
	* dwarf2-frame.h (dwarf2_frame_unwinders_enabled_p): Likewise.
	* dwarf2read.c (check_physname): Likewise.
	(use_deprecated_index_sections): Likewise.
	(dwarf_always_disassemble): Likewise.
	* eval.c (overload_resolution): Likewise.
	* event-top.c (set_editing_cmd_var): Likewise.
	(exec_done_display_p): Likewise.
	* event-top.h (set_editing_cmd_var): Likewise.
	(exec_done_display_p): Likewise.
	* exec.c (write_files): Likewise.
	* fbsd-nat.c (debug_fbsd_lwp): Likewise
	(debug_fbsd_nat): Likewise.
	* frame.h (struct frame_print_options) <print_raw_frame_arguments>:
	Likewise.
	(struct set_backtrace_options) <backtrace_past_main>: Likewise.
	<backtrace_past_entry> Likewise.
	* gdb-demangle.h (demangle): Likewise.
	(asm_demangle): Likewise.
	* gdb_bfd.c (bfd_sharing): Likewise.
	* gdbcore.h (write_files): Likewise.
	* gdbsupport/common-debug.c (show_debug_regs): Likewise.
	* gdbsupport/common-debug.h (show_debug_regs): Likewise.
	* gdbthread.h (print_thread_events): Likewise.
	* gdbtypes.c (opaque_type_resolution): Likewise.
	(strict_type_checking): Likewise.
	* gnu-nat.c (gnu_debug_flag): Likewise.
	* guile/scm-auto-load.c (auto_load_guile_scripts): Likewise.
	* guile/scm-param.c (pascm_variable): Add boolval.
	(add_setshow_generic): Update.
	(pascm_param_value): Update.
	(pascm_set_param_value_x): Update.
	* hppa-tdep.c (hppa_debug): Change to bool..
	* infcall.c (may_call_functions_p): Likewise.
	(coerce_float_to_double_p): Likewise.
	(unwind_on_signal_p): Likewise.
	(unwind_on_terminating_exception_p): Likewise.
	* infcmd.c (startup_with_shell): Likewise.
	* inferior.c (print_inferior_events): Likewise.
	* inferior.h (startup_with_shell): Likewise.
	(print_inferior_events): Likewise.
	* infrun.c (step_stop_if_no_debug): Likewise.
	(detach_fork): Likewise.
	(debug_displaced): Likewise.
	(disable_randomization): Likewise.
	(non_stop): Likewise.
	(non_stop_1): Likewise.
	(observer_mode): Likewise.
	(observer_mode_1): Likewise.
	(set_observer_mode): Update.
	(sched_multi): Change to bool.
	* infrun.h (debug_displaced): Likewise.
	(sched_multi): Likewise.
	(step_stop_if_no_debug): Likewise.
	(non_stop): Likewise.
	(disable_randomization): Likewise.
	* linux-tdep.c (use_coredump_filter): Likewise.
	(dump_excluded_mappings): Likewise.
	* linux-thread-db.c (auto_load_thread_db): Likewise.
	(check_thread_db_on_load): Likewise.
	* main.c (captured_main_1): Update.
	* maint-test-options.c (struct test_options_opts) <flag_opt, xx1_opt,
	xx2_opt, boolean_opt>: Change to bool.
	* maint-test-settings.c (maintenance_test_settings_boolean): Likewise.
	* maint.c (maintenance_profile_p): Likewise.
	(per_command_time): Likewise.
	(per_command_space): Likewise.
	(per_command_symtab): Likewise.
	* memattr.c (inaccessible_by_default): Likewise.
	* mi/mi-main.c (mi_async): Likewise.
	(mi_async_1): Likewise.
	* mips-tdep.c (mips64_transfers_32bit_regs_p): Likewise.
	* nat/fork-inferior.h (startup_with_shell): Likewise.
	* nat/linux-namespaces.c (debug_linux_namespaces): Likewise.
	* nat/linux-namespaces.h (debug_linux_namespaces): Likewise.
	* nios2-tdep.c (nios2_debug): Likewise.
	* or1k-tdep.c (or1k_debug): Likewise.
	* parse.c (parser_debug): Likewise.
	* parser-defs.h (parser_debug): Likewise.
	* printcmd.c (print_symbol_filename): Likewise.
	* proc-api.c (procfs_trace): Likewise.
	* python/py-auto-load.c (auto_load_python_scripts): Likewise.
	* python/py-param.c (union parmpy_variable): Add "bool boolval" field.
	(set_parameter_value): Update.
	(add_setshow_generic): Update.
	* python/py-value.c (copy_py_bool_obj): Change argument from int*
	to bool*.
	* python/python.c (gdbpy_parameter_value): Cast to bool* instead of
	int*.
	* ravenscar-thread.c (ravenscar_task_support): Change to bool.
	* record-btrace.c (record_btrace_target::store_registers): Update.
	* record-full.c (record_full_memory_query): Change to bool.
	(record_full_stop_at_limit): Likewise.
	* record-full.h (record_full_memory_query): Likewise.
	* remote-notif.c (notif_debug): Likewise.
	* remote-notif.h (notif_debug): Likewise.
	* remote.c (use_range_stepping): Likewise.
	(interrupt_on_connect): Likewise.
	(remote_break): Likewise.
	* ser-tcp.c (tcp_auto_retry): Likewise.
	* ser-unix.c (serial_hwflow): Likewise.
	* skip.c (debug_skip): Likewise.
	* solib-aix.c (solib_aix_debug): Likewise.
	* spu-tdep.c (spu_stop_on_load_p): Likewise.
	(spu_auto_flush_cache_p): Likewise.
	* stack.c (struct backtrace_cmd_options) <full, no_filters, hide>:
	Likewise.
	(struct info_print_options) <quiet>: Likewise.
	* symfile-debug.c (debug_symfile): Likewise.
	* symfile.c (auto_solib_add): Likewise.
	(separate_debug_file_debug): Likewise.
	* symfile.h (auto_solib_add): Likewise.
	(separate_debug_file_debug): Likewise.
	* symtab.c (basenames_may_differ): Likewise.
	(struct filename_partial_match_opts) <dirname, basename>: Likewise.
	(struct info_print_options) <quiet, exclude_minsyms>: Likewise.
	(struct info_types_options) <quiet>: Likewise.
	* symtab.h (demangle): Likewise.
	(basenames_may_differ): Likewise.
	* target-dcache.c (stack_cache_enabled_1): Likewise.
	(code_cache_enabled_1): Likewise.
	* target.c (trust_readonly): Likewise.
	(may_write_registers): Likewise.
	(may_write_memory): Likewise.
	(may_insert_breakpoints): Likewise.
	(may_insert_tracepoints): Likewise.
	(may_insert_fast_tracepoints): Likewise.
	(may_stop): Likewise.
	(auto_connect_native_target): Likewise.
	(target_stop_and_wait): Update.
	(target_async_permitted): Change to bool.
	(target_async_permitted_1): Likewise.
	(may_write_registers_1): Likewise.
	(may_write_memory_1): Likewise.
	(may_insert_breakpoints_1): Likewise.
	(may_insert_tracepoints_1): Likewise.
	(may_insert_fast_tracepoints_1): Likewise.
	(may_stop_1): Likewise.
	* target.h (target_async_permitted): Likewise.
	(may_write_registers): Likewise.
	(may_write_memory): Likewise.
	(may_insert_breakpoints): Likewise.
	(may_insert_tracepoints): Likewise.
	(may_insert_fast_tracepoints): Likewise.
	(may_stop): Likewise.
	* thread.c (struct info_threads_opts) <show_global_ids>: Likewise.
	(make_thread_apply_all_options_def_group): Change argument from int*
	to bool*.
	(thread_apply_all_command): Update.
	(print_thread_events): Change to bool.
	* top.c (confirm): Likewise.
	(command_editing_p): Likewise.
	(history_expansion_p): Likewise.
	(write_history_p): Likewise.
	(info_verbose): Likewise.
	* top.h (confirm): Likewise.
	(history_expansion_p): Likewise.
	* tracepoint.c (disconnected_tracing): Likewise.
	(circular_trace_buffer): Likewise.
	* typeprint.c (print_methods): Likewise.
	(print_typedefs): Likewise.
	* utils.c (debug_timestamp): Likewise.
	(sevenbit_strings): Likewise.
	(pagination_enabled): Likewise.
	* utils.h (sevenbit_strings): Likewise.
	(pagination_enabled): Likewise.
	* valops.c (overload_resolution): Likewise.
	* valprint.h (struct value_print_options) <prettyformat_arrays,
	prettyformat_structs, vtblprint, unionprint, addressprint, objectprint,
	stop_print_at_null, print_array_indexes, deref_ref, static_field_print,
	pascal_static_field_print, raw, summary, symbol_print, finish_print>:
	Likewise.
	* windows-nat.c (new_console): Likewise.
	(cygwin_exceptions): Likewise.
	(new_group): Likewise.
	(debug_exec): Likewise.
	(debug_events): Likewise.
	(debug_memory): Likewise.
	(debug_exceptions): Likewise.
	(useshell): Likewise.
	* windows-tdep.c (maint_display_all_tib): Likewise.
	* xml-support.c (debug_xml): Likewise.
2019-09-18 09:35:12 +09:00
Kevin Buettner 2dc80cf8a5 Restrict use of minsym names when printing addresses in disassembled code
build_address_symbolic contains some code which causes it to
prefer the minsym over the the function symbol in certain cases.
The cases where this occurs are the same as the "certain pathological
cases" that used to exist in find_frame_funname().

This commit largely disables that code; it will only prefer the
minsym when the address of minsym is identical to that of the address
under consideration AND the function address for the symbtab sym is
not the same as the address under consideration.

So, without this change, when using the dw2-ranges-func-lo-cold
executable from the gdb.dwarf2/dw2-ranges-func.exp test, GDB exhibits
the following behavior:

(gdb) x/5i foo_cold
   0x40110d <foo+4294967277>:	push   %rbp
   0x40110e <foo+4294967278>:	mov    %rsp,%rbp
   0x401111 <foo+4294967281>:	callq  0x401106 <baz>
   0x401116 <foo+4294967286>:	nop
   0x401117 <foo+4294967287>:	pop    %rbp

On the other hand, still without this change, using the
dw2-ranges-func-hi-cold executable from the same test, GDB
does this instead:

(gdb) x/5i foo_cold
   0x401128 <foo_cold>:	push   %rbp
   0x401129 <foo_cold+1>:	mov    %rsp,%rbp
   0x40112c <foo_cold+4>:	callq  0x401134 <baz>
   0x401131 <foo_cold+9>:	nop
   0x401132 <foo_cold+10>:	pop    %rbp

This is inconsistent behavior.  When foo_cold is at a lower
address than the function's entry point, the symtab symbol (foo)
is displayed along with a large positive offset which would wrap
around the address space if the address space were only 32 bits wide.
(A later patch fixes this problem by displaying negative offsets.)

This commit makes the behavior uniform for both the "lo-cold" and
"hi-cold" cases:

lo-cold:

(gdb) x/5i foo_cold
   0x40110d <foo_cold>:	push   %rbp
   0x40110e <foo-18>:	mov    %rsp,%rbp
   0x401111 <foo-15>:	callq  0x401106 <baz>
   0x401116 <foo-10>:	nop
   0x401117 <foo-9>:	pop    %rbp

hi-cold:

(gdb) x/5i foo_cold
   0x401128 <foo_cold>:	push   %rbp
   0x401129 <foo+35>:	mov    %rsp,%rbp
   0x40112c <foo+38>:	callq  0x401134 <baz>
   0x401131 <foo+43>:	nop
   0x401132 <foo+44>:	pop    %rbp

In both cases, the symbol shown for the address at which foo_cold
resides is shown as <foo_cold>.  Subsequent offsets are shown as
either negative or positive offsets from the entry pc for foo.

When disassembling a function, care must be taken to NOT display
<+0> as the offset for the second range.  For this reason, I found
it necessary to add the "prefer_sym_over_minsym" parameter to
build_address_symbolic.  The type of this flag is a bool; do_demangle
ought to be a bool also, so I made this change at the same time.

gdb/ChangeLog:

	* valprint.h (build_address_symbolic): Add "prefer_sym_over_minsym"
	parameter.  Change type of "do_demangle" to bool.
	* disasm.c (gdb_pretty_print_disassembler::pretty_print_insn):
	Pass suitable "prefer_sym_over_minsym" flag to
	build_address_symbolic().  Don't output "+" for negative offsets.
	* printcmd.c (print_address_symbolic): Update invocation of
	build_address_symbolic to include a "prefer_sym_over_minsym"
	flag.
	(build_address_symbolic): Add "prefer_sym_over_minsym" parameter.
	Restrict cases in which use of minimal symbol is preferred to that
	of a found symbol.  Update comments.
2019-07-27 13:28:56 -07:00
Pedro Alves 7d8062de98 Make "print" and "compile print" support -OPT options
This patch adds support for "print -option optval --", etc.
Likewise for "compile print".

We'll get:

~~~~~~
(gdb) help print
Print value of expression EXP.
Usage: print [[OPTION]... --] [/FMT] [EXP]

Options:
  -address [on|off]
    Set printing of addresses.

  -array [on|off]
    Set pretty formatting of arrays.

  -array-indexes [on|off]
    Set printing of array indexes.

  -elements NUMBER|unlimited
    Set limit on string chars or array elements to print.
    "unlimited" causes there to be no limit.

  -max-depth NUMBER|unlimited
    Set maximum print depth for nested structures, unions and arrays.
    When structures, unions, or arrays are nested beyond this depth then they
    will be replaced with either '{...}' or '(...)' depending on the language.
    Use "unlimited" to print the complete structure.

  -null-stop [on|off]
    Set printing of char arrays to stop at first null char.

  -object [on|off]
    Set printing of C++ virtual function tables.

  -pretty [on|off]
    Set pretty formatting of structures.

  -repeats NUMBER|unlimited
    Set threshold for repeated print elements.
    "unlimited" causes all elements to be individually printed.

  -static-members [on|off]
    Set printing of C++ static members.

  -symbol [on|off]
    Set printing of symbol names when printing pointers.

  -union [on|off]
    Set printing of unions interior to structures.

  -vtbl [on|off]
    Set printing of C++ virtual function tables.

Note: because this command accepts arbitrary expressions, if you
specify any command option, you must use a double dash ("--")
to mark the end of option processing.  E.g.: "print -o -- myobj".
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I want to highlight the comment above about "--".

At first, I thought we could make the print command parse the options,
and if the option wasn't recognized, fallback to parsing as an
expression.  Then, if the user wanted to disambiguate, he'd use the
"--" option delimiter.  For example, if you had a variable called
"object" and you wanted to print its negative, you'd have to do:

  (gdb) print -- -object

After getting that working, I saw that gdb.pascal/floats.exp
regressed, in these tests:

 gdb_test "print -r" " = -1\\.2(499.*|5|500.*)"
 gdb_test "print -(r)" " = -1.2(499.*|5|500.*)"
 gdb_test "print -(r + s)" " = -3\\.4(499.*|5|500.*)"

It's the first one that I found most concerning.  It regressed because
"-r" is the abbreviation of "-raw".  I realized then that the behavior
change was a bit risker than I'd like, considering scripts, wrappers
around gdb, etc., and even user expectation.  So instead, I made the
print command _require_ the "--" options delimiter if you want to
specify any option.  So:

  (gdb) print -r

is parsed as an expression, and

  (gdb) print -r --

is parsed as an option.

I noticed that that's also what lldb's expr (the equivalent of print)
does to handle the same problem.

Going back the options themselves, note that:

 - you can shorten option names, as long as unambiguous.
 - For boolean options, 0/1 stand for off/on.
 - For boolean options, "true" is implied.

So these are all equivalent:

 (gdb) print -object on -static-members off -pretty on -- foo
 (gdb) print -object -static-members off -pretty -- foo
 (gdb) print -object -static-members 0 -pretty -- foo
 (gdb) print -o -st 0 -p -- foo

TAB completion is fully supported:

  (gdb) p -[TAB]
  -address         -elements        -pretty          -symbol
  -array           -null-stop       -repeats         -union
  -array-indexes   -object          -static-members  -vtbl

Note that the code is organized such that some of the options and the
"set/show" commands code is shared.  In particular, the "print"
options and the corresponding "set print" commands are defined with
the same structures.  The commands are installed with the
gdb::option::add_setshow_cmds_for_options function.

gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* compile/compile.c: Include "cli/cli-option.h".
	(compile_print_value): Scope data pointer is now a
	value_print_options pointer; adjust.
	(compile_print_command): Process options.  Scope data pointer is
	now a value_print_options pointer; adjust.
	(_initialize_compile): Update "compile print"'s help to include
	supported options.  Install a completer for "compile print".
	* cp-valprint.c (show_vtblprint, show_objectprint)
	(show_static_field_print): Delete.
	(_initialize_cp_valprint): Don't install "set print
	static-members", "set print vtbl", "set print object" here.
	* printcmd.c: Include "cli/cli-option.h" and
	"common/gdb_optional.h".
	(print_command_parse_format): Rework to fill in a
	value_print_options instead of a format_data.
	(print_value): Change parameter type from format_data pointer to
	value_print_options reference.  Adjust.
	(print_command_1): Process options.  Adjust to pass down a
	value_print_options.
	(print_command_completer): New.
	(_initialize_printcmd): Install print_command_completer as
	handle_brkchars completer for the "print" command.  Update
	"print"'s help to include supported options.
	* valprint.c: Include "cli/cli-option.h".
	(show_vtblprint, show_objectprint, show_static_field_print): Moved
	here from cp-valprint.c.
	(boolean_option_def, uinteger_option_def)
	(value_print_option_defs, make_value_print_options_def_group):
	New.  Use gdb::option::add_setshow_cmds_for_options to install
	"set print elements", "set print null-stop", "set print repeats",
	"set print pretty", "set print union", "set print array", "set
	print address", "set print symbol", "set print array-indexes".
	* valprint.h: Include <string> and "cli/cli-option.h".
	(make_value_print_options_def_group): Declare.
	(print_value): Change parameter type from format_data pointer to
	value_print_options reference.
	(print_command_completer): Declare.

gdb/testsuite/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* gdb.base/options.exp: Build executable.
	(test-print): New procedure.
	(top level): Call it, once for "print" and another for "compile
	print".
2019-06-13 00:18:24 +01:00
Tom Tromey 000439d528 Add "set print finish"
A user wanted to be able to disable the display of the value when
using "finish" -- but still have the value entered into the value
history in case it was useful later on.  Part of the rationale here is
that sometimes the value might be quite large, or expensive to display
(in their case this was compounded by a rogue pretty-printer).

This patch implements this idea.

gdb/ChangeLog
2019-05-29  Tom Tromey  <tromey@adacore.com>

	* NEWS: Add entry.
	* infcmd.c (print_return_value_1): Handle finish_print
	option.
	(show_print_finish): New function.
	(_initialize_infcmd): Add "set/show print finish" commands.
	* valprint.c (user_print_options): Initialize new member.
	* valprint.h (struct value_print_options) <finish_print>: New
	member.

gdb/doc/ChangeLog
2019-05-29  Tom Tromey  <tromey@adacore.com>

	* gdb.texinfo (Continuing and Stepping): Document new
	commands.

gdb/testsuite/ChangeLog
2019-05-29  Tom Tromey  <tromey@adacore.com>

	* gdb.base/finish.exp (finish_no_print): New proc.
	(finish_tests): Call it.
2019-05-29 08:25:38 -06:00
Andrew Burgess 2e62ab400f gdb: Introduce 'print max-depth' feature
Introduce a new print setting max-depth which can be set with 'set
print max-depth DEPTH'.  The default value of DEPTH is 20, but this
can also be set to unlimited.

When GDB is printing a value containing nested structures GDB will
stop descending at depth DEPTH.  Here is a small example:

    typedef struct s1 { int a; } s1;
    typedef struct s2 { s1 b; } s2;
    typedef struct s3 { s2 c; } s3;
    typedef struct s4 { s3 d; } s4;

    s4 var = { { { { 3 } } } };

The following table shows how various depth settings affect printing
of 'var':

    | Depth Setting | Result of 'p var'              |
    |---------------+--------------------------------|
    |     Unlimited | $1 = {d = {c = {b = {a = 3}}}} |
    |             4 | $1 = {d = {c = {b = {a = 3}}}} |
    |             3 | $1 = {d = {c = {b = {...}}}}   |
    |             2 | $1 = {d = {c = {...}}}         |
    |             1 | $1 = {d = {...}}               |
    |             0 | $1 = {...}                     |

Only structures, unions, and arrays are replaced in this way, scalars
and strings are not replaced.

The replacement is counted from the level at which you print, not from
the top level of the structure.  So, consider the above example and
this GDB session:

    (gdb) set print max-depth 2
    (gdb) p var
    $1 = {d = {c = {...}}}
    (gdb) p var.d
    $2 = {c = {b = {...}}}
    (gdb) p var.d.c
    $3 = {b = {a = 3}}

Setting the max-depth to 2 doesn't prevent the user from exploring
deeper into 'var' by asking for specific sub-fields to be printed.

The motivation behind this feature is to try and give the user more
control over how much is printed when examining large, complex data
structures.

The default max-depth of 20 means that there is a change in GDB's
default behaviour.  Someone printing a data structure with 20 levels
of nesting will now see '{...}' instead of their data, they would need
to adjust the max depth, or call print again naming a specific field
in order to dig deeper into their data structure.  If this is
considered a problem then we could increase the default, or even make
the default unlimited.

This commit relies on the previous commit, which added a new field to
the language structure, this new field was a string that contained the
pattern that should be used when a structure/union/array is replaced
in the output, this allows languages to use a syntax that is more
appropriate, mostly this will be selecting the correct types of
bracket '(...)' or '{...}', both of which are currently in use.

This commit should have no impact on MI output, expressions are
printed through the MI using -var-create and then -var-list-children.
As each use of -var-list-children only ever displays a single level of
an expression then the max-depth setting will have no impact.

This commit also adds the max-depth mechanism to the scripting
language pretty printers following basically the same rules as for the
built in value printing.

One quirk is that when printing a value using the display hint 'map',
if the keys of the map are structs then GDB will hide the keys one
depth level after it hides the values, this ensures that GDB produces
output like this:

  $1 = map_object = {[{key1}] = {...}, [{key2}] = {...}}

Instead of this less helpful output:

  $1 = map_object = {[{...}] = {...}, [{...}] = {...}}

This is covered by the new tests in gdb.python/py-nested-maps.exp.

gdb/ChangeLog:

	* cp-valprint.c (cp_print_value_fields): Allow an additional level
	of depth when printing anonymous structs or unions.
	* guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer):
	Don't print either the top-level value, or the children if the
	max-depth is exceeded.
	(ppscm_print_children): When printing the key of a map, allow one
	extra level of depth.
	* python/py-prettyprint.c (gdbpy_apply_val_pretty_printer): Don't
	print either the top-level value, or the children if the max-depth
	is exceeded.
	(print_children): When printing the key of a map, allow one extra
	level of depth.
	* python/py-value.c (valpy_format_string): Add max_depth keyword.
	* valprint.c: (PRINT_MAX_DEPTH_DEFAULT): Define.
	(user_print_options): Initialise max_depth field.
	(val_print_scalar_or_string_type_p): New function.
	(val_print): Check to see if the max depth has been reached.
	(val_print_check_max_depth): Define new function.
	(show_print_max_depth): New function.
	(_initialize_valprint): Add 'print max-depth' option.
	* valprint.h (struct value_print_options) <max_depth>: New field.
	(val_print_check_max_depth): Declare new function.
	* NEWS: Document new feature.

gdb/doc/ChangeLog:

	* gdb.texinfo (Print Settings): Document 'print max-depth'.
	* guile.texi (Guile Pretty Printing API): Document that 'print
	max-depth' can effect the display of a values children.
	* python.texi (Pretty Printing API): Likewise.
	(Values From Inferior): Document max_depth keyword.

gdb/testsuite/ChangeLog:

	* gdb.base/max-depth.c: New file.
	* gdb.base/max-depth.exp: New file.
	* gdb.python/py-nested-maps.c: New file.
	* gdb.python/py-nested-maps.exp: New file.
	* gdb.python/py-nested-maps.py: New file.
	* gdb.python/py-format-string.exp (test_max_depth): New proc.
	(test_all_common): Call test_max_depth.
	* gdb.fortran/max-depth.exp: New file.
	* gdb.fortran/max-depth.f90: New file.
	* gdb.go/max-depth.exp: New file.
	* gdb.go/max-depth.go: New file.
	* gdb.modula2/max-depth.exp: New file.
	* gdb.modula2/max-depth.c: New file.
	* lib/gdb.exp (get_print_expr_at_depths): New proc.
2019-04-29 22:01:09 +01:00
Joel Brobecker 42a4f53d2b Update copyright year range in all GDB files.
This commit applies all changes made after running the gdb/copyright.py
script.

Note that one file was flagged by the script, due to an invalid
copyright header
(gdb/unittests/basic_string_view/element_access/char/empty.cc).
As the file was copied from GCC's libstdc++-v3 testsuite, this commit
leaves this file untouched for the time being; a patch to fix the header
was sent to gcc-patches first.

gdb/ChangeLog:

	Update copyright year range in all GDB files.
2019-01-01 10:01:51 +04:00
Tom Tromey b4be9fadea Use unique_xmalloc_ptr for read_string
This changes read_string's "buffer" out-parameter to be a
unique_xmalloc_ptr, then updates the users.  This allows for the
removal of some cleanups.

I chose unique_xmalloc_ptr rather than byte_vector here due to the way
Guile unwinding seems to work.

Tested by the buildbot.

gdb/ChangeLog
2018-06-18  Tom Tromey  <tom@tromey.com>

	* valprint.h (read_string): Update.
	* valprint.c (read_string): Change type of "buffer".
	(val_print_string): Update.
	* python/py-value.c (valpy_string): Update.
	* language.h (struct language_defn) <la_get_string>: Change
	type of "buffer".
	(default_get_string, c_get_string): Update.
	* language.c (default_get_string): Change type of "buffer".
	* guile/scm-value.c (gdbscm_value_to_string): Update.
	* c-lang.c (c_get_string): Change type of "buffer".
2018-06-18 12:51:02 -06:00
Tom Tromey c7110220be Change build_address_symbolic to return std::string
This changes two out parameters of build_address_symbolic to be
std::string, and updates the callers.  This allows removing some
cleanups.

This patch also moves the declaration of build_address_symbolic out of
defs.h.  I think that many things in defs.h should be elsewhere
instead.  In this case, I moved the declaration to valprint.h, becuase
there is no "printcmd.h" -- but perhaps it would be better to
introduce that instead.

Tested by the buildbot.

gdb/ChangeLog
2018-06-07  Tom Tromey  <tom@tromey.com>

	* valprint.h (build_address_symbolic): Declare.
	* printcmd.c (print_address_symbolic): Update.
	(build_address_symbolic): Change "name" and "filename" to
	std::string.
	* disasm.c (gdb_pretty_print_disassembler::pretty_print_insn):
	Update.
	* defs.h (build_address_symbolic): Remove declaration.
2018-06-07 06:38:18 -06:00
Tom Tromey 122b53ea6a Remove output_command_const
I happened to notice that output_command_const still exists, but is
not needed any more -- commands are always const-correct now.  This
patch removes this leftover.

2018-05-21  Tom Tromey  <tom@tromey.com>

	* printcmd.c (output_command): Remove.
	(output_command_const): Rename to output_command.
	* valprint.h (output_command): Rename from output_command_const.
	* tracepoint.c (trace_dump_actions): Call output_command.
2018-05-21 13:29:10 -06:00
Joel Brobecker e2882c8578 Update copyright year range in all GDB files
gdb/ChangeLog:

        Update copyright year range in all GDB files
2018-01-02 07:38:06 +04:00
Tom Tromey f12f6bad7d Remove val_print_type_code_int
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-12 15:04:58 -06:00
Tom Tromey 4ac0cb1cf0 Let print_decimal_chars handle signed values
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-12 15:04:57 -06:00
Tom Tromey 30a254669b Don't always zero pad in print_*_chars
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-06-12 15:04:56 -06:00
Joel Brobecker 61baf725ec update copyright year range in GDB files
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.
2017-01-01 10:52:34 +04:00
Yao Qi e8b24d9ff5 Remove parameter valaddr from la_val_print
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-11-08 16:02:42 +00:00
Tom Tromey 9c37b5aed9 Remove Java support
This patch removes the Java support from gdb.  gcj has not seen much
development or use for years now, and was recently removed from GCC.
This patch changes gdb to follow; in the unlikely event that there are
still users using gcj, they can continue to use an older gdb to debug.
Or, they can debug in C++ mode.

Built and regtested on x86-64 Fedora 24.

2016-10-06  Tom Tromey  <tom@tromey.com>

	* MAINTAINERS: Remove Java test maintainer.
	* varobj.h (java_varobj_ops): Don't declare.
	* valprint.h (struct value_print_options)
	<pascal_static_field_print>: Update comment.
	* utils.c (producer_is_gcc): Remove java reference.
	* symtab.h (struct general_symbol_info): Remove java references.
	(SYMBOL_SEARCH_NAME): Likewise.
	* objfiles.c (allocate_objfile): Update comment.
	* linespec.c (find_linespec_symbols): Remove java references.
	* gnu-v3-abi.c (gnuv3_rtti_type, gnuv3_baseclass_offset): Remove
	java references.
	* gdbtypes.h (struct cplus_struct_type) <is_java>: Remove.
	(TYPE_CPLUS_REALLY_JAVA): Remove.
	* c-varobj.c (enum vsections): Update comment.
	* symtab.c (symbol_set_language, symbol_set_names)
	(symbol_natural_name, symbol_demangled_name)
	(demangle_for_lookup, symbol_matches_domain)
	(default_make_symbol_completion_list_break_on_1): Remove java
	references.
	(JAVA_PREFIX, JAVA_PREFIX_LEN): Remove.
	* psymtab.c (match_partial_symbol, psymtab_search_name)
	(lookup_partial_symbol): Remove java references.
	* dwarf2read.c (find_slot_in_mapped_hash): Remove java references.
	(add_partial_symbol, dwarf2_compute_name, dwarf2_physname)
	(dwarf2_add_member_fn, is_vtable_name, read_structure_type)
	(process_structure_scope, read_subroutine_type)
	(read_subrange_type, load_partial_dies)
	(new_symbol_full, determine_prefix, typename_concat)
	(dwarf2_name): Remove java references.
	(set_cu_language): Treat Java as C++.
	* c-typeprint.c (c_type_print_args): Remove java reference.
	* defs.h (enum language) <language_java>: Remove.
	* Makefile.in (SFILES, HFILES_NO_SRCDIR, COMMON_OBS, YYFILES)
	(YYOBJ, local-maintainer-clean): Don't mention java files.
	* jv-exp.y, jv-lang.c, jv-lang.h, jv-typeprint.c, jv-valprint.c,
	jv-varobj.c: Remove.

2016-10-06  Tom Tromey  <tom@tromey.com>

	* guile.texi (Types In Guile): Remove Java mentions.
	* python.texi (Types In Python): Remove Java mentions.
	* gdb.texinfo (Address Locations, Supported Languages)
	(Index Section Format): Remove Java mentions.

2016-10-06  Tom Tromey  <tom@tromey.com>

	* gdb.compile/compile.exp: Change java tests to rust.
	* gdb.base/setshow.exp: Change java tests to rust.
	* gdb.base/default.exp: Remove java from language list.
	* README (Examples): Update language example.
	* gdb.python/py-lookup-type.exp (test_lookup_type): Remove java
	test.
	* lib/gdb.exp (skip_java_tests): Remove.
	* lib/java.exp: Remove.
	* gdb.java: Remove.
2016-10-06 10:10:40 -06:00
David Taylor 6b8505468e Support structure offsets that are 512K or larger.
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-06-24 21:02:36 -04:00
Tom Tromey 00272ec4b0 Add array start and end strings to generic_val_print_decorations
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-05-17 12:02:00 -06:00
Doug Evans 8151645076 Extend flags to support multibit and enum bitfields.
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-03-15 14:37:29 -07:00
Joel Brobecker 618f726fcb GDB copyright headers update after running GDB's copyright.py script.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2016-01-01 08:43:22 +04:00
Jan Kratochvil 1c88ceb1be Code cleanup: Make parts of print_command_1 public
The later 'compile print' command should share its behavior with the existing
'print' command.  Make the needed existing parts of print_command_1 public.

gdb/ChangeLog
2015-05-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* printcmd.c (struct format_data): Move it to valprint.h.
	(print_command_parse_format, print_value): New functions from ...
	(print_command_1): ... here.  Call them.
	* valprint.h (struct format_data): Move it here from printcmd.c.
	(print_command_parse_format, print_value): New declarations.
2015-05-16 14:26:06 +02:00
Joel Brobecker 32d0add0a6 Update year range in copyright notice of all files owned by the GDB project.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2015-01-01 13:32:14 +04:00
Joel Brobecker ecd75fc8ee Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
Pedro Alves 782d47dfbd Fix "info frame" in the outermost frame.
Doing "info frame" in the outermost frame, when that was indicated by
the next frame saying the unwound PC is undefined/not saved, results
in error and incomplete output:

 (gdb) bt
 #0  thread_function0 (arg=0x0) at threads.c:63
 #1  0x00000034cf407d14 in start_thread (arg=0x7ffff7fcb700) at pthread_create.c:309
 #2  0x000000323d4f168d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115

 (gdb) frame 2
 #2  0x000000323d4f168d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115
 115             call    *%rax

 (gdb) info frame
 Stack level 2, frame at 0x0:
  rip = 0x323d4f168d in clone (../sysdeps/unix/sysv/linux/x86_64/clone.S:115); saved rip Register 16 was not saved
 (gdb)

Not saved register values are treated as optimized out values
internally throughout.  stack.c:frame_info is handing unvailable
values, but not optimized out ones.  The patch deletes the
frame_unwind_caller_pc_if_available wrapper function and instead lets
errors propagate to frame_info (it's only user).

As frame_unwind_pc now needs to be able to handle and cache two
different error scenarios, the prev_pc.p variable is replaced with an
enumeration.

(FWIW, I looked into making gdbarch_unwind_pc or a variant return
struct value's instead, but it results in lots of boxing and unboxing
for no real gain -- e.g., the mips and arm implementations need to do
computation on the unboxed PC value.  Might as well throw an error on
first attempt to get at invalid contents.)

After the patch, we get:

 (gdb) info frame
 Stack level 2, frame at 0x0:
  rip = 0x323d4f168d in clone (../sysdeps/unix/sysv/linux/x86_64/clone.S:115); saved rip = <not saved>
  Outermost frame: outermost
  caller of frame at 0x7ffff7fcafc0
  source language asm.
  Arglist at 0x7ffff7fcafb8, args:
  Locals at 0x7ffff7fcafb8, Previous frame's sp is 0x7ffff7fcafc8
 (gdb)

A new test is added.  It's based off dw2-reg-undefined.exp, and tweaked to
mark the return address (rip) of "stop_frame" as undefined.

Tested on x86_64 Fedora 17.

gdb/
2013-12-06  Pedro Alves  <palves@redhat.com>

	* frame.c (enum cached_copy_status): New enum.
	(struct frame_info) <prev_pc.p>: Change type to enum
	cached_copy_status.
	(fprint_frame): Handle not saved and unavailable prev_pc values.
	(frame_unwind_pc_if_available): Delete and merge contents into ...
	(frame_unwind_pc): ... here.  Handle OPTIMIZED_OUT_ERROR.  Adjust
	to use enum cached_copy_status.
	(frame_unwind_caller_pc_if_available): Delete.
	(create_new_frame): Adjust.
	* frame.h (frame_unwind_caller_pc_if_available): Delete
	declaration.
	* stack.c (frame_info): Use frame_unwind_caller_pc instead of
	frame_unwind_caller_pc_if_available, and handle
	NOT_AVAILABLE_ERROR and OPTIMIZED_OUT_ERROR errors.
	* valprint.c (val_print_optimized_out): Use val_print_not_saved.
	(val_print_not_saved): New function.
	* valprint.h (val_print_not_saved): Declare.

gdb/testsuite/
2013-12-06  Pedro Alves  <palves@redhat.com>

	* gdb.dwarf2/dw2-undefined-ret-addr.S: New file.
	* gdb.dwarf2/dw2-undefined-ret-addr.c: New file.
	* gdb.dwarf2/dw2-undefined-ret-addr.exp: New file.
2013-12-06 19:50:10 +00:00
Pedro Alves 901461f8eb Print registers not saved in the frame as "<not saved>" instead of "<optimized out>".
Currently, in some scenarios, GDB prints <optimized out> when printing
outer frame registers.  An <optimized out> register is a confusing
concept.  What this really means is that the register is
call-clobbered, or IOW, not saved by the callee.  This patch makes GDB
say that instead.

Before patch:

 (gdb) p/x $rax $1 = <optimized out>
 (gdb) info registers rax
 rax            <optimized out>

After patch:

 (gdb) p/x $rax
 $1 = <not saved>
 (gdb) info registers rax
 rax            <not saved>

However, if for some reason the debug info describes a variable as
being in such a register (**), we still want to print <optimized out>
when printing the variable.  IOW, <not saved> is reserved for
inspecting registers at the machine level.  The patch uses
lval_register+optimized_out to encode the not saved registers, and
makes it so that optimized out variables always end up in
!lval_register values.

** See <https://sourceware.org/ml/gdb-patches/2012-08/msg00787.html>.
Current/recent enough GCC doesn't mark variables/arguments as being in
call-clobbered registers in the ranges corresponding to function
calls, while older GCCs did.  Newer GCCs will just not say where the
variable is, so GDB will end up realizing the variable is optimized
out.

frame_unwind_got_optimized creates not_lval optimized out registers,
so by default, in most cases, we'll see <optimized out>.

value_of_register is the function eval.c uses for evaluating
OP_REGISTER (again, $pc, etc.), and related bits.  It isn't used for
anything else.  This function makes sure to return lval_register
values.  The patch makes "info registers" and the MI equivalent use it
too.  I think it just makes a lot of sense, as this makes it so that
when printing machine registers ($pc, etc.), we go through a central
function.

We're likely to need a different encoding at some point, if/when we
support partially saved registers.  Even then, I think
value_of_register will still be the spot to tag the intention to print
machine register values differently.

value_from_register however may also return optimized out
lval_register values, so at a couple places where we're computing a
variable's location from a dwarf expression, we convert the resulting
value away from lval_register to a regular optimized out value.

Tested on x86_64 Fedora 17

gdb/
2013-10-02  Pedro Alves  <palves@redhat.com>

	* cp-valprint.c (cp_print_value_fields): Adjust calls to
	val_print_optimized_out.
	* jv-valprint.c (java_print_value_fields): Likewise.
	* p-valprint.c (pascal_object_print_value_fields): Likewise.
	* dwarf2loc.c (dwarf2_evaluate_loc_desc_full)
	<DWARF_VALUE_REGISTER>: If the register was not saved, return a
	new optimized out value.
	* findvar.c (address_from_register): Likewise.
	* frame.c (put_frame_register): Tweak error string to say the
	register was not saved, rather than optimized out.
	* infcmd.c (default_print_one_register_info): Adjust call to
	val_print_optimized_out.  Use value_of_register instead of
	get_frame_register_value.
	* mi/mi-main.c (output_register): Use value_of_register instead of
	get_frame_register_value.
	* valprint.c (valprint_check_validity): Likewise.
	(val_print_optimized_out): New value parameter.  If the value is
	lval_register, print <not saved> instead.
	(value_check_printable, val_print_scalar_formatted): Adjust calls
	to val_print_optimized_out.
	* valprint.h (val_print_optimized_out): New value parameter.
	* value.c (struct value) <optimized_out>: Extend comment.
	(error_value_optimized_out): New function.
	(require_not_optimized_out): Use it.  Use a different string for
	lval_register values.
	* value.h (error_value_optimized_out): New declaration.
	* NEWS: Mention <not saved>.

gdb/testsuite/
2013-10-02  Pedro Alves  <palves@redhat.com>

	* gdb.dwarf2/dw2-reg-undefined.exp <pattern_rax_rbx_rcx_print,
	pattern_rax_rbx_rcx_info>: Set to "<not saved>".
	* gdb.mi/mi-reg-undefined.exp (opt_out_pattern): Delete.
	(not_saved_pattern): New.
	Replace use of the former with the latter.

gdb/doc/
2013-10-02  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Registers): Expand description of saved registers
	in frames.  Explain <not saved>.
2013-10-02 16:15:46 +00:00
Yao Qi 6211c335ec Add options to skip unavailable locals
This is the patch to add new option '--skip-unavailable' to MI
commands '-stack-list-{locals, arguments, variables}'.  This patch
extends list_args_or_locals to add a new parameter 'skip_unavailable',
and don't list locals or arguments if values are unavailable and
'skip_unavailable' is true.

This is inspecting a trace frame (tfind mode), where only a few
locals have been collected.

-stack-list-locals, no switch vs new switch:

 -stack-list-locals --simple-values
 ^done,locals=[{name="array",type="unsigned char [2]"},{name="i",type="int",value="<unavailable>"}]
 -stack-list-locals --skip-unavailable --simple-values
 ^done,locals=[{name="array",type="unsigned char [2]"}]

-stack-list-arguments, no switch vs new switch:

 -stack-list-arguments --simple-values
 ^done,stack-args=[frame={level="0",args=[{name="j",type="int",value="4"},{name="s",type="char *",value="<unavailable>"}]},frame={level="1",args=[]}]
 -stack-list-arguments --skip-unavailable --simple-values
 ^done,stack-args=[frame={level="0",args=[{name="j",type="int",value="4"}]},frame={level="1",args=[]}]

-stack-list-variables, no switch vs new switch:

 -stack-list-variables --simple-values
 ^done,variables=[{name="j",arg="1",type="int",value="4"},{name="s",arg="1",type="char *",value="<unavailable>"},{name="array",type="unsigned char [2]"},{name="i",type="int",value="<unavailable>"}]
 -stack-list-variables --skip-unavailable --simple-values
 ^done,variables=[{name="j",arg="1",type="int",value="4"},{name="array",type="unsigned char [2]"}]

tests are added to test these new options.

gdb:

2013-08-27  Pedro Alves  <pedro@codesourcery.com>
	    Yao Qi  <yao@codesourcery.com>

	* mi/mi-cmd-stack.c (list_args_or_locals): Adjust prototype.
	(parse_no_frames_option): Remove.
	(mi_cmd_stack_list_locals): Handle --skip-unavailable.
	(mi_cmd_stack_list_args): Adjust.
	(mi_cmd_stack_list_variables): Handle --skip-unavailable.
	(list_arg_or_local): Add new parameter 'skip_unavailable'.  Return
	early if SKIP_UNAVAILABLE is true and ARG->val is unavailable.
	Caller update.
	(list_args_or_locals): New parameter 'skip_unavailable'.
	Handle it.
	* valprint.c (scalar_type_p): Rename to ...
	(val_print_scalar_type_p): ... this.  Make extern.
	(val_print, value_check_printable): Adjust.
	* valprint.h (val_print_scalar_type_p): Declare.
	* value.c (value_entirely_unavailable): New function.
	* value.h (value_entirely_unavailable): Declare.

	* NEWS: Mention the new option "--skip-unavailable" to MI
	commands '-stack-list-locals', '-stack-list-arguments' and
	'-stack-list-variables'.

gdb/doc:

2013-08-27  Pedro Alves  <pedro@codesourcery.com>
	    Yao Qi  <yao@codesourcery.com>

	* gdb.texinfo (GDB/MI Stack Manipulation) <-stack-list-locals>:
	Document new --skip-unavailable option.
	<-stack-list-variables>: Document new --skip-unavailable option.

gdb/testsuite:

2013-08-27  Yao Qi  <yao@codesourcery.com>

	* gdb.trace/entry-values.exp: Test unavailable entry value is
	not shown when option '--skip-unavailable' is specified.
	* gdb.trace/mi-trace-unavailable.exp (test_trace_unavailable):
	Add tests for new option '--skip-unavailable'.
2013-08-27 05:20:57 +00:00
Doug Evans e704570352 * NEWS: Mention "set print raw frame-arguments".
* gdbcmd.h (setprintrawlist, showprintrawlist): Declare.
	* stack.c (print_raw_frame_arguments): New static global.
	(print_frame_arg): Set opts.raw from print_raw_frame_arguments.
	(_initialize_stack): New command "set/show print raw frame-arguments".
	* valprint.c (setprintrawlist, showprintrawlist): New globals.
	(set_print_raw, show_print_raw): New functions.
	(_initialize_valprint): New prefix command "set/show print raw".
	* valprint.h (value_print_options): Improve comments.

	doc/
	* gdb.texinfo (Print Settings): Document "print raw frame-arguments".

	testsuite/
	* gdb.python/py-frame-args.c: New file.
	* gdb.python/py-frame-args.py: New file.
	* gdb.python/py-frame-args.exp New file.
2013-07-17 20:35:11 +00:00
Doug Evans 2a998fc037 * defs.h (enum val_prettyformat): Renamed from val_prettyprint.
Enum values rename as well.  All uses updated.
	* valprint.h (value_print_options): Rename member pretty to
	pretty format.  Rename member prettyprint_arrays to
	prettyformat_arrays.  Rename member prettyprint_structs to
	prettyformat_structs.  All uses updated.
	(get_no_prettyformat_print_options): Renamed from
	get_raw_print_options.
	* valprint.c (get_no_prettyformat_print_options): Renamed from
	get_raw_print_options.  All callers updated.
	(show_prettyformat_structs): Renamed from show_prettyprint_structs.
	All callers updated.
	(show_prettyformat_arrays): Renamed from show_prettyprint_arrays.
	All callers updated.
	(_initialize_valprint): Improve help text for "set print pretty" and
	"set print arrays".

	testsuite/
	* gdb.base/default.exp: Update expected output of "show print array"
	and "show print pretty".
2013-07-09 16:57:09 +00:00
Pedro Alves 6f937416b9 Constify strings in tracepoint.c, lookup_cmd and the completers.
This is sort of a continuation of Keith's parse_exp_1 constification
patch.  It started out by undoing these bits:

  @@ -754,9 +754,12 @@ validate_actionline (char **line, struct
   	  tmp_p = p;
   	  for (loc = t->base.loc; loc; loc = loc->next)
   	    {
  -	      p = tmp_p;
  -	      exp = parse_exp_1 (&p, loc->address,
  +	      const char *q;
  +
  +	      q = tmp_p;
  +	      exp = parse_exp_1 (&q, loc->address,
   				 block_for_pc (loc->address), 1);
  +	      p = (char *) q;

and progressively making more things const upwards, fixing fallout,
rinse repeat, until GDB built again (--enable-targets=all).

That ended up constifying lookup_cmd/add_cmd and (lots of) friends,
and the completers.

I didn't try to constify the command hooks themselves, because I know
upfront there are commands that write to the command string argument,
and I think I managed to stop at a nice non-hacky split point already.

I think the only non-really-super-obvious changes are
tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions.

The rest is just mostly about 'char *' => 'const char *', 'char **'=>
'const char **', and the occasional (e.g., deprecated_cmd_warning)
case of 'char **'=> 'const char *', where/when I noticed that nothing
actually cares about the pointer to pointer output.

Tested on x86_64 Fedora 17, native and gdbserver.

gdb/
2013-03-13  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (struct add_partial_datum) <text, text0, word>: Make
	fields const.
	(ada_make_symbol_completion_list): Make "text0" parameter const.
	* ax-gdb.c (agent_eval_command_one): Make "exp" parameter const.
	* breakpoint.c (condition_completer): Make "text" and "word"
	parameters const.  Adjust.
	(check_tracepoint_command): Adjust to validate_actionline
	prototype change.
	(catch_syscall_completer): Make "text" and "word" parameters
	const.
	* cli/cli-cmds.c (show_user): Make "comname" local const.
	(valid_command_p): Make "command" parameter const.
	(alias_command): Make "alias_prefix" and "command_prefix" locals
	const.
	* cli/cli-decode.c (add_cmd): Make "name" parameter const.
	(add_alias_cmd): Make "name" and "oldname" parameters const.
	Adjust.  No longer make copy of OLDNAME.
	(add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd)
	(add_setshow_cmd_full, 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_unlimited_cmd, add_setshow_zuinteger_cmd)
	(delete_cmd, add_info, add_info_alias, add_com, add_com_alias):
	Make "name" parameter const.
	(help_cmd): Rename "command" parameter to "arg".  New const local
	"command".
	(find_cmd): Make "command" parameter const.
	(lookup_cmd_1): Make "text" parameter pointer to const.  Adjust to
	deprecated_cmd_warning prototype change.
	(undef_cmd_error): Make "cmdtype" parameter const.
	(lookup_cmd): Make "line" parameter const.
	(deprecated_cmd_warning): Change type of "text" parameter to
	pointer to const char, from pointer to pointer to char.  Adjust.
	(lookup_cmd_composition): Make "text" parameter const.
	(complete_on_cmdlist, complete_on_enum): Make "text" and "word"
	parameters const.
	* cli/cli-decode.h (struct cmd_list_element) <name>: Make field
	const.
	* cli/cli-script.c (validate_comname): Make "tem" local const.
	(define_command): New const local "tem_c".  Use it in calls to
	lookup_cmd.
	(document_command): Make "tem" and "comfull" locals const.
	(show_user_1): Make "prefix" and "name" parameters const.
	* cli-script.h (show_user_1): Make "prefix" and "name" parameters
	const.
	* command.h (add_cmd, add_alias_cmd, add_prefix_cmd)
	(add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1)
	(deprecated_cmd_warning, lookup_cmd_composition, add_com)
	(add_com_alias, add_info, add_info_alias, complete_on_cmdlist)
	(complete_on_enum, 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):
	Change prototypes, constifying strings.
	* completer.c (noop_completer, filename_completer): Make "text"
	and "prefix" parameters const.
	(location_completer, expression_completer)
	(complete_line_internal): Make "text" and "prefix" parameters
	const and adjust.
	(command_completer, signal_completer): Make "text" and "prefix"
	parameters const.
	* completer.h (noop_completer, filename_completer)
	(expression_completer, location_completer, command_completer)
	(signal_completer): Change prototypes.
	* corefile.c (complete_set_gnutarget): Make "text" and "word"
	parameters const.
	* cp-abi.c (cp_abi_completer): Likewise.
	* expression.h (parse_expression_for_completion): Change
	prototype.
	* f-lang.c (f_make_symbol_completion_list): Make "text" and "word"
	parameters const.
	* infcmd.c (_initialize_infcmd): Make "cmd_name" local const.
	* infrun.c (handle_completer): Make "text" and "word" parameters
	const.
	* interps.c (interpreter_completer): Make "text" and "word"
	parameters const.
	* language.h (struct language_defn)
	<la_make_symbol_completion_list>: Make "text" and "word"
	parameters const.
	* parse.c (parse_exp_1): Move const hack to parse_exp_in_context.
	(parse_exp_in_context): Rename to ...
	(parse_exp_in_context_1): ... this.
	(parse_exp_in_context): Reimplement, with const hack from
	parse_exp_1.
	(parse_expression_for_completion): Make "string" parameter const.
	* printcmd.c (decode_format): Make "string_ptr" parameter pointer
	to pointer to const char.  Adjust.
	(print_command_1): Make "exp" parameter const.
	(output_command): Rename to ...
	(output_command_const): ... this.  Make "exp" parameter const.
	(output_command): Reimplement.
	(x_command): Adjust.
	(display_command): Rename "exp" parameter to "arg".  New "exp"
	local, const version of "arg".
	* python/py-auto-load.c (gdbpy_initialize_auto_load): Make
	"cmd_name" local const.
	* python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree
	call.
	(cmdpy_completer): Make "text" and "word" parameters const.
	(gdbpy_parse_command_name): Make "prefix_text2" local const.
	* python/py-param.c (add_setshow_generic): Make "tmp_name" local
	const.
	* remote.c (_initialize_remote): Make "cmd_name" local const.
	* symtab.c (language_search_unquoted_string): Make "text" and "p"
	parameters const.  Adjust.
	(completion_list_add_fields): Make "sym_text", "text" and "word"
	parameters const.
	(struct add_name_data) <sym_text, text, word>: Make fields const.
	(default_make_symbol_completion_list_break_on): Make "text" and
	"word" parameters const.  Adjust locals.
	(default_make_symbol_completion_list)
	(make_symbol_completion_list, make_symbol_completion_type)
	(make_symbol_completion_list_fn): Make "text" and "word"
	parameters const.
	(make_file_symbol_completion_list): Make "text", "word" and
	"srcfile" parameters const.  Adjust locals.
	(add_filename_to_list): Make "text" and "word" parameters const.
	(struct add_partial_filename_data) <text, word>: Make fields
	const.
	(make_source_files_completion_list): Make "text" and "word"
	parameters const.
	* symtab.h (default_make_symbol_completion_list_break_on)
	(default_make_symbol_completion_list, make_symbol_completion_list)
	(make_symbol_completion_type enum type_code)
	(make_symbol_completion_list_fn make_file_symbol_completion_list)
	(make_source_files_completion_list): Change prototype.
	* top.c (execute_command): Adjust to pass pointer to pointer to
	const char to lookup_cmd, and to deprecated_cmd_warning prototype
	change.
	(set_verbose): Make "cmdname" local const.
	* tracepoint.c (decode_agent_options): Make "exp" parameter const,
	and adjust.
	(validate_actionline): Make "line" parameter a pointer to const
	char, and adjust.
	(encode_actions_1): Make "action_exp" local const, and adjust.
	(encode_actions): Adjust.
	(replace_comma): Delete.
	(trace_dump_actions): Make "action_exp" and "next_comma" locals
	const, and adjust.  Don't frob the action string while splitting
	it at commas.  Instead, make a copy of each split substring in
	turn.
	(trace_dump_command): Adjust to validate_actionline prototype
	change.
	* tracepoint.h (decode_agent_options, decode_agent_options)
	(encode_actions, validate_actionline): Change prototypes.
	* valprint.h (output_command): Delete declaration.
	(output_command_const): Declare.
	* value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 18:34:55 +00:00
Hui Zhu 03cdf6804a 2013-01-08 Hui Zhu <hui_zhu@mentor.com>
* printcmd.c: Remove define of function output_command.
	* tracepoint.c: Remove extern of function output_command.
	* valprint.h: (output_command): New extern.
2013-01-08 02:00:34 +00:00
Tom Tromey e93a877490 PR cli/7719:
* NEWS: Update.
	* ada-valprint.c (printstr, print_field_values): Remove
	"inspect_it" code.
	* cp-valprint.c (cp_print_value_fields): Remove "inspect_it"
	code.
	* jv-valprint.c (java_print_value_fields): Remove "inspect_it"
	code.
	* m2-lang.c (m2_printstr): Remove "inspect_it" code.
	* main.c (captured_main): Remove "epoch" argument.
	* objc-lang.c (objc_printstr): Remove "inspect_it" code.
	* p-lang.c (pascal_printstr): Remove "inspect_it" code.
	* p-valprint.c (pascal_object_print_value_fields): Remove
	"inspect_it" code.
	* printcmd.c (print_command_1): Remove 'inspect' argument.
	(print_command, call_command): Update.
	(inspect_command): Remove.
	(_initialize_printcmd): Make "inspect" an alias for "print".
	* top.c (epoch_interface): Remove.
	* top.h (epoch_interface): Remove.
	* valprint.c (user_print_options): Update.
	(print_converted_chars_to_obstack): Remove "inspect_it" code.
	* valprint.h (struct value_print_options) <inspect_it>: Remove
	field.
doc
	* gdb.texinfo (Mode Options): Don't mention -epoch.
	(Data, Emacs): Remove obsolete comments.
2013-01-07 16:40:39 +00:00
Joel Brobecker 8acc9f485b Update years in copyright notice for the GDB files.
Two modifications:
  1. The addition of 2013 to the copyright year range for every file;
  2. The use of a single year range, instead of potentially multiple
     year ranges, as approved by the FSF.
2013-01-01 06:41:43 +00:00
Tom Tromey 9cb709b6ba PR exp/13907:
* valprint.h (struct value_print_options) <symbol_print>: New
	field.
	* valprint.c (user_print_options): Add default for symbol_print.
	(show_symbol_print): New function.
	(generic_val_print): Respect symbol_print.
	(_initialize_valprint): Add "print symbol" setting.
	* f-valprint.c (f_val_print): Respect symbol_print.
	* c-valprint.c (c_val_print): Respect symbol_print.
	* NEWS: Update.
	* printcmd.c (print_address_symbolic): Return int.  Ignore some
	zero-size symbols.
	(print_address_demangle): Return int.
	* defs.h: (print_address_symbolic): Return int.
	* value.h (print_address_demangle): Return int.
doc
	* gdb.texinfo (Print Settings): Document 'set print symbol'.
testsuite
	* gdb.mi/mi-var-cmd.exp: Update.
	* gdb.objc/basicclass.exp (do_objc_tests): Update.
	* gdb.cp/virtbase.exp: Update.
	* gdb.cp/classes.exp (test_static_members): Update.
	* gdb.cp/casts.exp: Update.
	* gdb.base/pointers.exp: Update.
	* gdb.base/funcargs.exp (pointer_args): Update.
	(structs_by_reference): Update.
	* gdb.base/find.exp: Update.
	* gdb.base/call-strs.exp: Send "set print symbol off".
	* gdb.base/call-ar-st.exp: Update.
	* gdb.ada/fun_addr.exp: Update.
	* gdb.base/printcmds.exp (test_print_symbol): New proc.
	Call it.
	(test_print_repeats_10, test_print_strings)
	(test_print_char_arrays): Update.
2012-05-18 15:31:42 +00:00
Tom Tromey edf0c1b7ca * printcmd.c (print_address_demangle): Add 'opts' argument.
* p-valprint.c (pascal_val_print): Update.
	* jv-valprint.c (java_val_print): Update.
	* value.h: Update.
	* valprint.c (generic_val_print): Update.
	(print_function_pointer_address): Add 'options' argument.  Remove
	'addressprint' argument.  Update.
	* m2-valprint.c (print_unpacked_pointer): Update.
	* gnu-v3-abi.c (print_one_vtable): Update.
	(gnuv3_print_method_ptr): Update.
	* f-valprint.c (f_val_print): Update.
	* cp-valprint.c (cp_print_value_fields): Update.
	* valprint.h (print_function_pointer_address): Update.
	* c-valprint.c (c_val_print): Update.
2012-05-18 15:27:25 +00:00
Tom Tromey e88acd9618 * valprint.h (struct generic_val_print_decorations): New.
(generic_val_print): Declare.
	* valprint.c (generic_val_print): New function.
	* p-valprint.c (p_decorations): New global.
	(pascal_val_print) <TYPE_CODE_REF, TYPE_CODE_ENUM,
	TYPE_CODE_FLAGS, TYPE_CODE_FUNC, TYPE_CODE_RANGE, TYPE_CODE_INT,
	TYPE_CODE_FLT, TYPE_CODE_VOID, TYPE_CODE_ERROR, TYPE_CODE_UNDEF,
	TYPE_CODE_BOOL, TYPE_CODE_CHAR>: Call generic_val_print.
	* m2-valprint.c (m2_decorations): New global.
	(m2_val_print) <TYPE_CODE_REF, TYPE_CODE_ENUM, TYPE_CODE_FUNC,
	TYPE_CODE_BOOL, TYPE_CODE_RANGE, TYPE_CODE_INT, TYPE_CODE_CHAR,
	TYPE_CODE_FLT, TYPE_CODE_METHOD, TYPE_CODE_VOID, TYPE_CODE_UNDEF,
	TYPE_CODE_ERROR>: Call generic_val_print.
	* f-valprint.c (f_decorations): New global.
	(f_val_print): Use print_function_pointer_address.
	<TYPE_CODE_REF, TYPE_CODE_FUNC, TYPE_CODE_CHAR, TYPE_CODE_FLAGS,
	TYPE_CODE_FLT, TYPE_CODE_VOID, TYPE_CODE_ENUM, TYPE_CODE_RANGE,
	TYPE_CODE_BOOL, TYPE_CODE_COMPLEX, TYPE_CODE_UNDEF>: Call
	generic_val_print.
	* c-valprint.c (c_decorations): New global.
	(c_val_print) <TYPE_CODE_MEMBERPTR, TYPE_CODE_REF, TYPE_CODE_ENUM,
	TYPE_CODE_FLAGS, TYPE_CODE_FUNC, TYPE_CODE_METHOD, TYPE_CODE_BOOL,
	TYPE_CODE_RANGE, TYPE_CODE_CHAR, TYPE_CODE_FLT,
	TYPE_CODE_DECFLOAT, TYPE_CODE_VOID, TYPE_CODE_ERROR,
	TYPE_CODE_UNDEF, TYPE_CODE_COMPLEX>: Call generic_val_print.
	* ada-valprint.c (ada_val_print_1) <TYPE_CODE_FLAGS>: Remove
	case.
2012-03-01 19:27:18 +00:00
Tom Tromey 132c57b477 * c-valprint.c (print_function_pointer_address): Move...
* valprint.c: ... here.  Make non-static.
	* m2-valprint.c (print_function_pointer_address): Remove.
	* valprint.h (print_function_pointer_address): Declare.
2012-03-01 18:25:19 +00:00
Joel Brobecker c5a5708100 Copyright year update in most files of the GDB Project.
gdb/ChangeLog:

        Copyright year update in most files of the GDB Project.
2012-01-04 08:28:28 +00:00
Tom Tromey 3b2b8feaf4 gdb
PR fortran/10036:
	* valprint.h (generic_emit_char, generic_printstr): Declare.
	* valprint.c (wchar_printable, append_string_as_wide)
	(print_wchar): Move from c-lang.c.
	(generic_emit_char): New function; mostly taken from c_emit_char.
	(generic_printstr): New function; mostly taken from c_printstr.
	* f-valprint.c (f_val_print) <TYPE_CODE_ARRAY>: Handle strings
	represented as arrays.
	<TYPE_CODE_CHAR>: Treat as TYPE_CODE_INT; recognize as character
	type.
	* f-typeprint.c (f_type_print_base) <TYPE_CODE_CHAR>: Treat
	identically to TYPE_CODE_INT.
	* f-lang.c (f_get_encoding): New function.
	(f_emit_char): Use generic_emit_char.
	(f_printchar): Replace comment.
	(f_printstr): Use generic_printstr.
	* dwarf2read.c (read_base_type) <DW_ATE_unsigned>: Handle Fortran
	"character" types specially.
	<DW_ATE_signed_char, DW_ATE_unsigned_char>: Make TYPE_CODE_CHAR
	for Fortran.
	* c-lang.c (wchar_printable, append_string_as_wide, print_wchar):
	Move to valprint.c
	(c_emit_char): Call generic_emit_char.
	(c_printstr): Call generic_printstr.
gdb/testsuite
	* gdb.fortran/charset.exp: New file.
	* gdb.fortran/charset.f90: New file.
2011-06-29 15:32:40 +00:00
Pedro Alves 8af8e3bc81 gdb/
* exceptions.h (NOT_AVAILABLE_ERROR): New error.
	* value.c: Include "exceptions.h".
	(require_available): Throw NOT_AVAILABLE_ERROR instead of a
	generic error.
	* cp-abi.c: Include gdb_assert.h.
	(baseclass_offset): Add `embedded_offset' and `val' parameters.
	Assert the method is implemented.  Wrap NOT_AVAILABLE_ERROR
	errors.
	* cp-abi.h (baseclass_offset): Add `embedded_offset' and `val'
	parameters.  No longer returns -1 on error.
	(struct cp_abi_ops) <baseclass_offset>: Add `embedded_offset' and
	`val' parameters.
	* cp-valprint.c: Include exceptions.h.
	(cp_print_value): Handle NOT_AVAILABLE_ERROR errors when fetching
	the baseclass_offset.  Handle unavailable base classes.  Use
	val_print_invalid_address.
	* p-valprint.c: Include exceptions.h.
	(pascal_object_print_value): Handle NOT_AVAILABLE_ERROR errors
	when fetching the baseclass_offset.  No longer expect
	baseclass_offset returning -1.  Handle unavailable base classes.
	Use val_print_invalid_address.
	* valops.c (dynamic_cast_check_1): Rename `contents' parameter to
	`valaddr' parameter, and change its type to gdb_byte pointer.  Add
	`embedded_offset' and `val' parameters.  Adjust.
	(dynamic_cast_check_2): Rename `contents' parameter to `valaddr'
	parameter, and change its type to gdb_byte pointer.  Add
	`embedded_offset' and `val' parameters.  Adjust.  No longer expect
	baseclass_offset returning -1.
	(value_dynamic_cast): Use value_contents_for_printing rather than
	value_contents.  Adjust.
	(search_struct_field): No longer expect baseclass_offset returning
	-1.
	(search_struct_method): If reading memory from the target is
	necessary, wrap it in a new value to pass to baseclass_offset.  No
	longer expect baseclass_offset returning -1.
	(find_method_list): No longer expect baseclass_offset returning
	-1.  Use value_contents_for_printing rather than value_contents.
	* valprint.c (val_print_invalid_address): New function.
	* valprint.h (val_print_invalid_address): Declare.
	* gdbtypes.c (is_unique_ancestor_worker): New `embedded_offset'
	and `val' parameters.  No longer expect baseclass_offset returning
	-1.  Adjust.
	* gnu-v2-abi.c: Include "exceptions.h".
	(gnuv2_baseclass_offset): Add `embedded_offset' and `val'
	parameters.  Handle unavailable memory.  Recurse through
	gnuv2_baseclass_offset directly, rather than through
	baseclass_offset.  No longer returns -1 on not found, instead
	throw an error.
	* gnu-v3-abi.c (gnuv3_baseclass_offset): Add `embedded_offset' and
	`val' parameters.  Adjust.

	gdb/testsuite/
	* gdb.trace/unavailable.cc (class Base, class Middle, class
	Derived): New types.
	(derived_unavail, derived_partial, derived_whole): New globals.
	(virtual_partial): New global.
	(virtualp): Point at virtual_partial.
	* gdb.trace/unavailable.exp (gdb_collect_globals_test): Add tests
	related to unavailable vptr.
2011-02-14 11:35:45 +00:00
Pedro Alves 4e07d55ffb Base support for <unavailable> value contents.
gdb/
	* value.h (value_bytes_available): Declare.
	(mark_value_bytes_unavailable): Declare.
	* value.c (struct range): New struct.
	(range_s): New typedef.
	(ranges_overlap): New function.
	(range_lessthan): New function.
	(ranges_contain_p): New function.
	(struct value) <unavailable>: New field.
	(value_bytes_available): New function.
	(mark_value_bytes_unavailable): New function.
	(require_not_optimized_out): Constify parameter.
	(require_available): New function.
	(value_contents_all, value_contents): Require all bytes be
	available.
	(value_free): Free `unavailable'.
	(value_copy): Copy `unavailable'.
	* valprint.h (val_print_unavailable): Declare.
	* valprint.c (valprint_check_validity): Rename `offset' parameter
	to `embedded_offset'.  If printing a scalar, check whether the
	value chunk is available.
	(val_print_unavailable): New.
	(val_print_scalar_formatted): Check whether the value is
	available.
	* python/py-prettyprint.c (apply_val_pretty_printer): Refuse
	pretty-printing unavailable values.
2011-02-14 11:10:53 +00:00
Pedro Alves ab2188aa2a * printcmd.c (print_formatted): Use val_print_scalar_formatted
instead of print_scalar_formatted.
	(print_scalar_formatted): Don't handle 's' format strings here,
	and add an assertion that we never see such format here.
	* valprint.h (val_print_scalar_formatted): Declare.
	* valprint.c (val_print_scalar_formatted): New.
	* c-valprint.c (c_val_print): Use val_print_scalar_formatted
	instead of print_scalar_formatted.
	* jv-valprint.c (java_val_print): Ditto.
	* p-valprint.c (pascal_val_print): Ditto.
	* ada-valprint.c (ada_val_print_1): Ditto.
	* f-valprint.c (f_val_print): Ditto.
	* infcmd.c (registers_info): Ditto.
	* m2-valprint.c (m2_val_print): Ditto.
2011-01-25 17:59:00 +00:00
Pedro Alves 585fdaa106 Centralize printing "<optimized out>".
gdb/
	* valprint.h (val_print_optimized_out): Declare.
	* cp-valprint.c (cp_print_value_fields): Use
	val_print_optimized_out.
	* jv-valprint.c (java_print_value_fields): Ditto.
	* p-valprint.c (pascal_object_print_value_fields): Ditto.
	* printcmd.c (print_formatted): Ditto.
	* valprint.c (valprint_check_validity): Ditto.
	(value_check_printable): Ditto.
	(val_print_optimized_out): New.

	gdb/doc/
	* gdb.texinfo: s/value optimized out/optimized out/g

	gdb/testsuite/
	* gdb.base/frame-args.exp: Adjust.
	* gdb.dwarf2/dw2-noloc.exp: Adjust.
	* gdb.dwarf2/dw2-inline-param.exp: Adjust.
	* gdb.dwarf2/pieces.exp: Adjust.
	* gdb.opt/clobbered-registers-O2.exp: Adjust.
	* gdb.opt/inline-locals.exp: Adjust.
	* gdb.threads/fork-child-threads.exp: Adjust.
2011-01-25 16:26:23 +00:00
Pedro Alves 490f124f09 2011-01-24 Pedro Alves <pedro@codesourcery.com>
Don't lose embedded_offset in printing routines throughout.

	gdb/
	* valprint.h (val_print_array_elements): Change prototype.
	* valprint.c (val_print_array_elements): Add `embedded_offset'
	parameter, and adjust to pass it down to val_print, while passing
	`valaddr' or `address' unmodified.  Take embedded_offset into
	account when checking repetitions.
	* c-valprint.c (c_val_print): Pass embedded_offset to
	val_print_array_elements instead of adjusting `valaddr' and
	`address'.
	* m2-valprint.c (m2_print_array_contents, m2_val_print): Pass
	embedded_offset to val_print_array_elements instead of adjusting
	`valaddr'.
	* p-lang.h (pascal_object_print_value_fields): Adjust prototype.
	* p-valprint.c (pascal_val_print): Pass embedded_offset to
	val_print_array_elements and pascal_object_print_value_fields
	instead of adjusting `valaddr'.
	(pascal_object_print_value_fields): Add `offset' parameter, and
	adjust to use it.
	(pascal_object_print_value): Add `offset' parameter, and adjust to
	use it.
	(pascal_object_print_static_field): Use
	value_contents_for_printing/value_embedded_offset, rather than
	value_contents.
	* ada-valprint.c (val_print_packed_array_elements): Add `offset'
	parameter, and adjust to use it.  Use
	value_contents_for_printing/value_embedded_offset, rather than
	value_contents.
	(ada_val_print): Rename `valaddr0' parameter to `valaddr'.
	(ada_val_print_array): Add `offset' parameter, and adjust to use
	it.
	(ada_val_print_1): Rename `valaddr0' parameter to `valaddr', and
	`embedded_offset' to `offset'.  Don't re-adjust `valaddr'.
	Instead work with offsets.  Use
	value_contents_for_printing/value_embedded_offset, rather than
	value_contents.  Change `defer_val_int' local type to CORE_ADDR,
	and use value_from_pointer to extract a target pointer, rather
	than value_from_longest.
	(print_variant_part): Add `offset' parameter.  Replace
	`outer_valaddr' parameter by a new `outer_offset' parameter.
	Don't re-adjust `valaddr'.  Instead pass down adjusted offsets.
	(ada_value_print): Use
	value_contents_for_printing/value_embedded_offset, rather than
	value_contents.
	(print_record): Add `offset' parameter, and adjust to pass it
	down.
	(print_field_values): Add `offset' parameter.  Replace
	`outer_valaddr' parameter by a new `outer_offset' parameter.
	Don't re-adjust `valaddr'.  Instead pass down adjusted offsets.
	Use value_contents_for_printing/value_embedded_offset, rather than
	value_contents.
	* d-valprint.c (dynamic_array_type): Use
	value_contents_for_printing/value_embedded_offset, rather than
	value_contents.
	* jv-valprint.c (java_print_value_fields): Add `offset' parameter.
	Don't re-adjust `valaddr'.  Instead pass down adjusted offsets.
	(java_print_value_fields): Take `offset' into account.  Don't
	re-adjust `valaddr'.  Instead pass down adjusted offsets.
	(java_val_print): Take `embedded_offset' into account.  Pass it to
	java_print_value_fields.
	* f-valprint.c (f77_print_array_1): Add `embedded_offset'
	parameter.  Don't re-adjust `valaddr' or `address'.  Instead pass
	down adjusted offsets.
	(f77_print_array): Add `embedded_offset' parameter.  Pass it down.
	(f_val_print): Take `embedded_offset' into account.

	gdb/testsuite/
	* gdb.base/printcmds.c (some_struct): New struct and instance.
	* gdb.base/printcmds.exp (test_print_repeats_embedded_array): New
	procedure.
	<global scope>: Call it.
2011-01-24 18:54:17 +00:00