Commit Graph

442 Commits

Author SHA1 Message Date
Tom Tromey 08feed99cb Change get_objfile_arch to a method on objfile
This changes get_objfile_arch to be a new inline method,
objfile::arch.

To my surprise, this function came up while profiling DWARF psymbol
reading.  Making this change improved performance from 1.986 seconds
to 1.869 seconds.  Both measurements were done by taking the mean of
10 runs on a fixed copy of the gdb executable.

gdb/ChangeLog
2020-04-18  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (enter_line_range, scan_xcoff_symtab): Update.
	* value.c (value_fn_field): Update.
	* valops.c (find_function_in_inferior)
	(value_allocate_space_in_inferior): Update.
	* tui/tui-winsource.c (tui_update_source_windows_with_line):
	Update.
	* tui/tui-source.c (tui_source_window::set_contents): Update.
	* symtab.c (lookup_global_or_static_symbol)
	(find_function_start_sal_1, skip_prologue_sal)
	(print_msymbol_info, find_gnu_ifunc, symbol_arch): Update.
	* symmisc.c (dump_msymbols, dump_symtab_1)
	(maintenance_print_one_line_table): Update.
	* symfile.c (init_entry_point_info, section_is_mapped)
	(list_overlays_command, simple_read_overlay_table)
	(simple_overlay_update_1): Update.
	* stap-probe.c (handle_stap_probe): Update.
	* stabsread.c (dbx_init_float_type, define_symbol)
	(read_one_struct_field, read_enum_type, read_range_type): Update.
	* source.c (info_line_command): Update.
	* python/python.c (gdbpy_source_objfile_script)
	(gdbpy_execute_objfile_script): Update.
	* python/py-type.c (save_objfile_types): Update.
	* python/py-objfile.c (py_free_objfile): Update.
	* python/py-inferior.c (python_new_objfile): Update.
	* psymtab.c (psym_find_pc_sect_compunit_symtab, dump_psymtab)
	(dump_psymtab_addrmap_1, maintenance_info_psymtabs)
	(maintenance_check_psymtabs): Update.
	* printcmd.c (info_address_command): Update.
	* objfiles.h (struct objfile) <arch>: New method, from
	get_objfile_arch.
	(get_objfile_arch): Don't declare.
	* objfiles.c (get_objfile_arch): Remove.
	(filter_overlapping_sections): Update.
	* minsyms.c (msymbol_is_function): Update.
	* mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines)
	(output_nondebug_symbol): Update.
	* mdebugread.c (parse_symbol, basic_type, parse_partial_symbols)
	(mdebug_expand_psymtab): Update.
	* machoread.c (macho_add_oso_symfile): Update.
	* linux-tdep.c (linux_infcall_mmap, linux_infcall_munmap):
	Update.
	* linux-fork.c (checkpoint_command): Update.
	* linespec.c (convert_linespec_to_sals): Update.
	* jit.c (finalize_symtab): Update.
	* infrun.c (insert_exception_resume_from_probe): Update.
	* ia64-tdep.c (ia64_find_unwind_table): Update.
	* hppa-tdep.c (internalize_unwinds): Update.
	* gdbtypes.c (get_type_arch, init_float_type, objfile_type):
	Update.
	* gcore.c (call_target_sbrk): Update.
	* elfread.c (record_minimal_symbol, elf_symtab_read)
	(elf_rel_plt_read, elf_gnu_ifunc_record_cache)
	(elf_gnu_ifunc_resolve_by_got): Update.
	* dwarf2/read.c (create_addrmap_from_index)
	(create_addrmap_from_aranges, dw2_find_pc_sect_compunit_symtab)
	(read_debug_names_from_section)
	(process_psymtab_comp_unit_reader, add_partial_symbol)
	(add_partial_subprogram, process_full_comp_unit)
	(read_file_scope, read_func_scope, read_lexical_block_scope)
	(read_call_site_scope, dwarf2_ranges_read)
	(dwarf2_record_block_ranges, dwarf2_add_field)
	(mark_common_block_symbol_computed, read_tag_pointer_type)
	(read_tag_string_type, dwarf2_init_float_type)
	(dwarf2_init_complex_target_type, read_base_type)
	(partial_die_info::read, partial_die_info::read)
	(read_attribute_value, dwarf_decode_lines_1, new_symbol)
	(dwarf2_fetch_die_loc_sect_off): Update.
	* dwarf2/loc.c (dwarf2_find_location_expression)
	(class dwarf_evaluate_loc_desc, rw_pieced_value)
	(dwarf2_evaluate_loc_desc_full, dwarf2_locexpr_baton_eval)
	(dwarf2_loc_desc_get_symbol_read_needs)
	(locexpr_describe_location_piece, locexpr_describe_location_1)
	(loclist_describe_location): Update.
	* dwarf2/index-write.c (write_debug_names): Update.
	* dwarf2/frame.c (dwarf2_build_frame_info): Update.
	* dtrace-probe.c (dtrace_process_dof): Update.
	* dbxread.c (read_dbx_symtab, dbx_end_psymtab)
	(process_one_symbol): Update.
	* ctfread.c (ctf_init_float_type, read_base_type): Update.
	* coffread.c (coff_symtab_read, enter_linenos, decode_base_type)
	(coff_read_enum_type): Update.
	* cli/cli-cmds.c (edit_command, list_command): Update.
	* buildsym.c (buildsym_compunit::finish_block_internal): Update.
	* breakpoint.c (create_overlay_event_breakpoint)
	(create_longjmp_master_breakpoint)
	(create_std_terminate_master_breakpoint)
	(create_exception_master_breakpoint, get_sal_arch): Update.
	* block.c (block_gdbarch): Update.
	* annotate.c (annotate_source_line): Update.
2020-04-18 08:35:04 -06:00
Tom Tromey 4dba70eee1 Two simple uses of value_print_scalar_formatted
A couple of spots could be easily converted to use
value_print_scalar_formatted.  This patch makes this change.

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

	* printcmd.c (print_formatted): Use value_print_scalar_formatted.
	* mips-tdep.c (mips_print_register): Use
	value_print_scalar_formatted.
2020-03-13 18:03:40 -06:00
Sergio Durigan Junior 7b973adce2 Fix printf of a convenience variable holding an inferior address
Back at:

commit 1f6f6e21fa
Author: Philippe Waroquiers <philippe.waroquiers@skynet.be>
Date:   Mon Jun 10 21:41:51 2019 +0200

    Ensure GDB printf command can print convenience var strings without a target.

GDB was extended in order to allow the printing of convenience
variables that are strings without a target.  However, this introduced
a regression that hasn't been caught by our testsuite (because there
were no tests for it).

The problem happens when we try to print a convenience variable that
holds the address of a string in the inferior.  The following
two-liners can reproduce the issue:

$ echo -e 'int main(){const char a[]="test";return 0;}' | gcc -x c - -O0-g3
$ ./gdb/gdb --data-directory ./gdb/data-directory -q ./a.out -ex 'start' -ex 'set $x = (const char *) (&a[0] + 2)' -ex 'printf "%s\n", $x'

After some investigation, I found that the problem happens on
printcmd.c:printf_c_string.  In the case above, we're taking the first
branch of the 'if' condition, which assumes that there will be a value
to be printed at "value_contents (value)".  There isn't.  We actually
need to obtain the address that the variable points to, and read the
contents from memory.

It seems to me that we should avoid this branch if the TYPE_CODE of
"value_type (value)" is TYPE_CODE_PTR (i.e., a pointer to the
inferior's memory).  This is what this patch does.

I took the liberty to extend the current testcase under
gdb.base/printcmds.exp and create a test that exercises this scenario.

No regressions have been found on Buildbot.

gdb/ChangeLog:
2020-03-03  Sergio Durigan Junior  <sergiodj@redhat.com>

	* printcmd.c (print_c_string): Check also for TYPE_CODE_PTR
	when verifying if dealing with a convenience variable.

gdb/testsuite/ChangeLog:
2020-03-03  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdb.base/printcmds.exp: Add test to verify printf of a
	variable holding an address.
2020-03-03 11:28:09 -05:00
Tom Tromey da5bd37ebc Remove some ui_file_* functions
This removes ui_file_isatty, ui_file_read, ui_file_write,
ui_file_write_async_safe, ui_file_flush, and ui_file_puts, replacing
them with calls to the appropriate method instead.

gdb/ChangeLog
2020-02-11  Tom Tromey  <tromey@adacore.com>

	* remote.c (remote_console_output): Update.
	* printcmd.c (printf_command): Update.
	* event-loop.c (gdb_wait_for_event): Update.
	* linux-nat.c (sigchld_handler): Update.
	* remote-sim.c (gdb_os_write_stdout): Update.
	(gdb_os_flush_stdout): Update.
	(gdb_os_flush_stderr): Update.
	(gdb_os_write_stderr): Update.
	* exceptions.c (print_exception): Update.
	* remote-fileio.c (remote_fileio_func_read): Update.
	(remote_fileio_func_write): Update.
	* tui/tui.c (tui_enable): Update.
	* tui/tui-interp.c (tui_interp::init): Update.
	* utils.c (init_page_info): Update.
	(putchar_unfiltered, fputc_unfiltered): Update.
	(gdb_flush): Update.
	(emit_style_escape): Update.
	(flush_wrap_buffer, fputs_maybe_filtered): Update.
	* ui-file.c (ui_file_isatty, ui_file_read, ui_file_write)
	(ui_file_write_async_safe, ui_file_flush, ui_file_puts): Remove.
	(stderr_file::write): Update.
	(stderr_file::puts): Update.
	* ui-file.h (ui_file_isatty, ui_file_write)
	(ui_file_write_async_safe, ui_file_read, ui_file_flush)
	(ui_file_puts): Don't declare.

Change-Id: I3ca9b36e9107f6adbc41e014f5078b41d6bcec4d
2020-02-11 07:05:28 -07:00
Iain Buclaw faa17681cc Make gdb_flush also flush the wrap buffer
This changes gdb_flush to also flush the internal wrap buffer.  A few
places needed to continue using the previous approach, so this also
introduces ui_file_flush for those.

2020-02-05  Iain Buclaw  <ibuclaw@gdcproject.org>

        * gdb/event-loop.c (gdb_wait_for_event): Update.
        * gdb/printcmd.c (printf_command): Update.
        * gdb/remote-fileio.c (remote_fileio_func_write): Update.
        * gdb/remote-sim.c (gdb_os_flush_stdout): Update.
        (gdb_os_flush_stderr): Update.
        * gdb/remote.c (remote_console_output): Update.
        * gdb/ui-file.c (gdb_flush): Rename to...
        (ui_file_flush): ...this.
        (stderr_file::write): Update.
        (stderr_file::puts): Update.
        * gdb/ui-file.h (gdb_flush): Rename to...
        (ui_file_flush): ...this.
        * gdb/utils.c (gdb_flush): Add function.
        * gdb/utils.h (gdb_flush): Add declaration.

Change-Id: I7ca143d30f03dc39f218f6e880eb9bca9e15af39
2020-02-07 14:06:02 -07:00
Simon Marchi 6c2659886f gdb: add back declarations for _initialize functions
I'd like to enable the -Wmissing-declarations warning.  However, it
warns for every _initialize function, for example:

      CXX    dcache.o
    /home/smarchi/src/binutils-gdb/gdb/dcache.c: In function ‘void _initialize_dcache()’:
    /home/smarchi/src/binutils-gdb/gdb/dcache.c:688:1: error: no previous declaration for ‘void _initialize_dcache()’ [-Werror=missing-declarations]
     _initialize_dcache (void)
     ^~~~~~~~~~~~~~~~~~

The only practical way forward I found is to add back the declarations,
which were removed by this commit:

    commit 481695ed5f
    Author: John Baldwin <jhb@FreeBSD.org>
    Date:   Sat Sep 9 11:02:37 2017 -0700

        Remove unnecessary function prototypes.

I don't think it's a big problem to have the declarations for these
functions, but if anybody has a better solution for this, I'll be happy
to use it.

gdb/ChangeLog:

	* aarch64-fbsd-nat.c (_initialize_aarch64_fbsd_nat): Add declaration.
	* aarch64-fbsd-tdep.c (_initialize_aarch64_fbsd_tdep): Add declaration.
	* aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Add declaration.
	* aarch64-linux-tdep.c (_initialize_aarch64_linux_tdep): Add declaration.
	* aarch64-newlib-tdep.c (_initialize_aarch64_newlib_tdep): Add declaration.
	* aarch64-tdep.c (_initialize_aarch64_tdep): Add declaration.
	* ada-exp.y (_initialize_ada_exp): Add declaration.
	* ada-lang.c (_initialize_ada_language): Add declaration.
	* ada-tasks.c (_initialize_tasks): Add declaration.
	* agent.c (_initialize_agent): Add declaration.
	* aix-thread.c (_initialize_aix_thread): Add declaration.
	* alpha-bsd-nat.c (_initialize_alphabsd_nat): Add declaration.
	* alpha-linux-nat.c (_initialize_alpha_linux_nat): Add declaration.
	* alpha-linux-tdep.c (_initialize_alpha_linux_tdep): Add declaration.
	* alpha-nbsd-tdep.c (_initialize_alphanbsd_tdep): Add declaration.
	* alpha-obsd-tdep.c (_initialize_alphaobsd_tdep): Add declaration.
	* alpha-tdep.c (_initialize_alpha_tdep): Add declaration.
	* amd64-darwin-tdep.c (_initialize_amd64_darwin_tdep): Add declaration.
	* amd64-dicos-tdep.c (_initialize_amd64_dicos_tdep): Add declaration.
	* amd64-fbsd-nat.c (_initialize_amd64fbsd_nat): Add declaration.
	* amd64-fbsd-tdep.c (_initialize_amd64fbsd_tdep): Add declaration.
	* amd64-linux-nat.c (_initialize_amd64_linux_nat): Add declaration.
	* amd64-linux-tdep.c (_initialize_amd64_linux_tdep): Add declaration.
	* amd64-nbsd-nat.c (_initialize_amd64nbsd_nat): Add declaration.
	* amd64-nbsd-tdep.c (_initialize_amd64nbsd_tdep): Add declaration.
	* amd64-obsd-nat.c (_initialize_amd64obsd_nat): Add declaration.
	* amd64-obsd-tdep.c (_initialize_amd64obsd_tdep): Add declaration.
	* amd64-sol2-tdep.c (_initialize_amd64_sol2_tdep): Add declaration.
	* amd64-tdep.c (_initialize_amd64_tdep): Add declaration.
	* amd64-windows-nat.c (_initialize_amd64_windows_nat): Add declaration.
	* amd64-windows-tdep.c (_initialize_amd64_windows_tdep): Add declaration.
	* annotate.c (_initialize_annotate): Add declaration.
	* arc-newlib-tdep.c (_initialize_arc_newlib_tdep): Add declaration.
	* arc-tdep.c (_initialize_arc_tdep): Add declaration.
	* arch-utils.c (_initialize_gdbarch_utils): Add declaration.
	* arm-fbsd-nat.c (_initialize_arm_fbsd_nat): Add declaration.
	* arm-fbsd-tdep.c (_initialize_arm_fbsd_tdep): Add declaration.
	* arm-linux-nat.c (_initialize_arm_linux_nat): Add declaration.
	* arm-linux-tdep.c (_initialize_arm_linux_tdep): Add declaration.
	* arm-nbsd-nat.c (_initialize_arm_netbsd_nat): Add declaration.
	* arm-nbsd-tdep.c (_initialize_arm_netbsd_tdep): Add declaration.
	* arm-obsd-tdep.c (_initialize_armobsd_tdep): Add declaration.
	* arm-pikeos-tdep.c (_initialize_arm_pikeos_tdep): Add declaration.
	* arm-symbian-tdep.c (_initialize_arm_symbian_tdep): Add declaration.
	* arm-tdep.c (_initialize_arm_tdep): Add declaration.
	* arm-wince-tdep.c (_initialize_arm_wince_tdep): Add declaration.
	* auto-load.c (_initialize_auto_load): Add declaration.
	* auxv.c (_initialize_auxv): Add declaration.
	* avr-tdep.c (_initialize_avr_tdep): Add declaration.
	* ax-gdb.c (_initialize_ax_gdb): Add declaration.
	* bfin-linux-tdep.c (_initialize_bfin_linux_tdep): Add declaration.
	* bfin-tdep.c (_initialize_bfin_tdep): Add declaration.
	* break-catch-sig.c (_initialize_break_catch_sig): Add declaration.
	* break-catch-syscall.c (_initialize_break_catch_syscall): Add declaration.
	* break-catch-throw.c (_initialize_break_catch_throw): Add declaration.
	* breakpoint.c (_initialize_breakpoint): Add declaration.
	* bsd-uthread.c (_initialize_bsd_uthread): Add declaration.
	* btrace.c (_initialize_btrace): Add declaration.
	* charset.c (_initialize_charset): Add declaration.
	* cli/cli-cmds.c (_initialize_cli_cmds): Add declaration.
	* cli/cli-dump.c (_initialize_cli_dump): Add declaration.
	* cli/cli-interp.c (_initialize_cli_interp): Add declaration.
	* cli/cli-logging.c (_initialize_cli_logging): Add declaration.
	* cli/cli-script.c (_initialize_cli_script): Add declaration.
	* cli/cli-style.c (_initialize_cli_style): Add declaration.
	* coff-pe-read.c (_initialize_coff_pe_read): Add declaration.
	* coffread.c (_initialize_coffread): Add declaration.
	* compile/compile-cplus-types.c (_initialize_compile_cplus_types): Add declaration.
	* compile/compile.c (_initialize_compile): Add declaration.
	* complaints.c (_initialize_complaints): Add declaration.
	* completer.c (_initialize_completer): Add declaration.
	* copying.c (_initialize_copying): Add declaration.
	* corefile.c (_initialize_core): Add declaration.
	* corelow.c (_initialize_corelow): Add declaration.
	* cp-abi.c (_initialize_cp_abi): Add declaration.
	* cp-namespace.c (_initialize_cp_namespace): Add declaration.
	* cp-support.c (_initialize_cp_support): Add declaration.
	* cp-valprint.c (_initialize_cp_valprint): Add declaration.
	* cris-linux-tdep.c (_initialize_cris_linux_tdep): Add declaration.
	* cris-tdep.c (_initialize_cris_tdep): Add declaration.
	* csky-linux-tdep.c (_initialize_csky_linux_tdep): Add declaration.
	* csky-tdep.c (_initialize_csky_tdep): Add declaration.
	* ctfread.c (_initialize_ctfread): Add declaration.
	* d-lang.c (_initialize_d_language): Add declaration.
	* darwin-nat-info.c (_initialize_darwin_info_commands): Add declaration.
	* darwin-nat.c (_initialize_darwin_nat): Add declaration.
	* dbxread.c (_initialize_dbxread): Add declaration.
	* dcache.c (_initialize_dcache): Add declaration.
	* disasm-selftests.c (_initialize_disasm_selftests): Add declaration.
	* disasm.c (_initialize_disasm): Add declaration.
	* dtrace-probe.c (_initialize_dtrace_probe): Add declaration.
	* dummy-frame.c (_initialize_dummy_frame): Add declaration.
	* dwarf-index-cache.c (_initialize_index_cache): Add declaration.
	* dwarf-index-write.c (_initialize_dwarf_index_write): Add declaration.
	* dwarf2-frame-tailcall.c (_initialize_tailcall_frame): Add declaration.
	* dwarf2-frame.c (_initialize_dwarf2_frame): Add declaration.
	* dwarf2expr.c (_initialize_dwarf2expr): Add declaration.
	* dwarf2loc.c (_initialize_dwarf2loc): Add declaration.
	* dwarf2read.c (_initialize_dwarf2_read): Add declaration.
	* elfread.c (_initialize_elfread): Add declaration.
	* exec.c (_initialize_exec): Add declaration.
	* extension.c (_initialize_extension): Add declaration.
	* f-lang.c (_initialize_f_language): Add declaration.
	* f-valprint.c (_initialize_f_valprint): Add declaration.
	* fbsd-nat.c (_initialize_fbsd_nat): Add declaration.
	* fbsd-tdep.c (_initialize_fbsd_tdep): Add declaration.
	* filesystem.c (_initialize_filesystem): Add declaration.
	* findcmd.c (_initialize_mem_search): Add declaration.
	* findvar.c (_initialize_findvar): Add declaration.
	* fork-child.c (_initialize_fork_child): Add declaration.
	* frame-base.c (_initialize_frame_base): Add declaration.
	* frame-unwind.c (_initialize_frame_unwind): Add declaration.
	* frame.c (_initialize_frame): Add declaration.
	* frv-linux-tdep.c (_initialize_frv_linux_tdep): Add declaration.
	* frv-tdep.c (_initialize_frv_tdep): Add declaration.
	* ft32-tdep.c (_initialize_ft32_tdep): Add declaration.
	* gcore.c (_initialize_gcore): Add declaration.
	* gdb-demangle.c (_initialize_gdb_demangle): Add declaration.
	* gdb_bfd.c (_initialize_gdb_bfd): Add declaration.
	* gdbarch-selftests.c (_initialize_gdbarch_selftests): Add declaration.
	* gdbarch.c (_initialize_gdbarch): Add declaration.
	* gdbtypes.c (_initialize_gdbtypes): Add declaration.
	* gnu-nat.c (_initialize_gnu_nat): Add declaration.
	* gnu-v2-abi.c (_initialize_gnu_v2_abi): Add declaration.
	* gnu-v3-abi.c (_initialize_gnu_v3_abi): Add declaration.
	* go-lang.c (_initialize_go_language): Add declaration.
	* go32-nat.c (_initialize_go32_nat): Add declaration.
	* guile/guile.c (_initialize_guile): Add declaration.
	* h8300-tdep.c (_initialize_h8300_tdep): Add declaration.
	* hppa-linux-nat.c (_initialize_hppa_linux_nat): Add declaration.
	* hppa-linux-tdep.c (_initialize_hppa_linux_tdep): Add declaration.
	* hppa-nbsd-nat.c (_initialize_hppanbsd_nat): Add declaration.
	* hppa-nbsd-tdep.c (_initialize_hppanbsd_tdep): Add declaration.
	* hppa-obsd-nat.c (_initialize_hppaobsd_nat): Add declaration.
	* hppa-obsd-tdep.c (_initialize_hppabsd_tdep): Add declaration.
	* hppa-tdep.c (_initialize_hppa_tdep): Add declaration.
	* i386-bsd-nat.c (_initialize_i386bsd_nat): Add declaration.
	* i386-cygwin-tdep.c (_initialize_i386_cygwin_tdep): Add declaration.
	* i386-darwin-nat.c (_initialize_i386_darwin_nat): Add declaration.
	* i386-darwin-tdep.c (_initialize_i386_darwin_tdep): Add declaration.
	* i386-dicos-tdep.c (_initialize_i386_dicos_tdep): Add declaration.
	* i386-fbsd-nat.c (_initialize_i386fbsd_nat): Add declaration.
	* i386-fbsd-tdep.c (_initialize_i386fbsd_tdep): Add declaration.
	* i386-gnu-nat.c (_initialize_i386gnu_nat): Add declaration.
	* i386-gnu-tdep.c (_initialize_i386gnu_tdep): Add declaration.
	* i386-go32-tdep.c (_initialize_i386_go32_tdep): Add declaration.
	* i386-linux-nat.c (_initialize_i386_linux_nat): Add declaration.
	* i386-linux-tdep.c (_initialize_i386_linux_tdep): Add declaration.
	* i386-nbsd-nat.c (_initialize_i386nbsd_nat): Add declaration.
	* i386-nbsd-tdep.c (_initialize_i386nbsd_tdep): Add declaration.
	* i386-nto-tdep.c (_initialize_i386nto_tdep): Add declaration.
	* i386-obsd-nat.c (_initialize_i386obsd_nat): Add declaration.
	* i386-obsd-tdep.c (_initialize_i386obsd_tdep): Add declaration.
	* i386-sol2-nat.c (_initialize_amd64_sol2_nat): Add declaration.
	* i386-sol2-tdep.c (_initialize_i386_sol2_tdep): Add declaration.
	* i386-tdep.c (_initialize_i386_tdep): Add declaration.
	* i386-windows-nat.c (_initialize_i386_windows_nat): Add declaration.
	* ia64-libunwind-tdep.c (_initialize_libunwind_frame): Add declaration.
	* ia64-linux-nat.c (_initialize_ia64_linux_nat): Add declaration.
	* ia64-linux-tdep.c (_initialize_ia64_linux_tdep): Add declaration.
	* ia64-tdep.c (_initialize_ia64_tdep): Add declaration.
	* ia64-vms-tdep.c (_initialize_ia64_vms_tdep): Add declaration.
	* infcall.c (_initialize_infcall): Add declaration.
	* infcmd.c (_initialize_infcmd): Add declaration.
	* inflow.c (_initialize_inflow): Add declaration.
	* infrun.c (_initialize_infrun): Add declaration.
	* interps.c (_initialize_interpreter): Add declaration.
	* iq2000-tdep.c (_initialize_iq2000_tdep): Add declaration.
	* jit.c (_initialize_jit): Add declaration.
	* language.c (_initialize_language): Add declaration.
	* linux-fork.c (_initialize_linux_fork): Add declaration.
	* linux-nat.c (_initialize_linux_nat): Add declaration.
	* linux-tdep.c (_initialize_linux_tdep): Add declaration.
	* linux-thread-db.c (_initialize_thread_db): Add declaration.
	* lm32-tdep.c (_initialize_lm32_tdep): Add declaration.
	* m2-lang.c (_initialize_m2_language): Add declaration.
	* m32c-tdep.c (_initialize_m32c_tdep): Add declaration.
	* m32r-linux-nat.c (_initialize_m32r_linux_nat): Add declaration.
	* m32r-linux-tdep.c (_initialize_m32r_linux_tdep): Add declaration.
	* m32r-tdep.c (_initialize_m32r_tdep): Add declaration.
	* m68hc11-tdep.c (_initialize_m68hc11_tdep): Add declaration.
	* m68k-bsd-nat.c (_initialize_m68kbsd_nat): Add declaration.
	* m68k-bsd-tdep.c (_initialize_m68kbsd_tdep): Add declaration.
	* m68k-linux-nat.c (_initialize_m68k_linux_nat): Add declaration.
	* m68k-linux-tdep.c (_initialize_m68k_linux_tdep): Add declaration.
	* m68k-tdep.c (_initialize_m68k_tdep): Add declaration.
	* machoread.c (_initialize_machoread): Add declaration.
	* macrocmd.c (_initialize_macrocmd): Add declaration.
	* macroscope.c (_initialize_macroscope): Add declaration.
	* maint-test-options.c (_initialize_maint_test_options): Add declaration.
	* maint-test-settings.c (_initialize_maint_test_settings): Add declaration.
	* maint.c (_initialize_maint_cmds): Add declaration.
	* mdebugread.c (_initialize_mdebugread): Add declaration.
	* memattr.c (_initialize_mem): Add declaration.
	* mep-tdep.c (_initialize_mep_tdep): Add declaration.
	* mi/mi-cmd-env.c (_initialize_mi_cmd_env): Add declaration.
	* mi/mi-cmds.c (_initialize_mi_cmds): Add declaration.
	* mi/mi-interp.c (_initialize_mi_interp): Add declaration.
	* mi/mi-main.c (_initialize_mi_main): Add declaration.
	* microblaze-linux-tdep.c (_initialize_microblaze_linux_tdep): Add declaration.
	* microblaze-tdep.c (_initialize_microblaze_tdep): Add declaration.
	* mips-fbsd-nat.c (_initialize_mips_fbsd_nat): Add declaration.
	* mips-fbsd-tdep.c (_initialize_mips_fbsd_tdep): Add declaration.
	* mips-linux-nat.c (_initialize_mips_linux_nat): Add declaration.
	* mips-linux-tdep.c (_initialize_mips_linux_tdep): Add declaration.
	* mips-nbsd-nat.c (_initialize_mipsnbsd_nat): Add declaration.
	* mips-nbsd-tdep.c (_initialize_mipsnbsd_tdep): Add declaration.
	* mips-sde-tdep.c (_initialize_mips_sde_tdep): Add declaration.
	* mips-tdep.c (_initialize_mips_tdep): Add declaration.
	* mips64-obsd-nat.c (_initialize_mips64obsd_nat): Add declaration.
	* mips64-obsd-tdep.c (_initialize_mips64obsd_tdep): Add declaration.
	* mipsread.c (_initialize_mipsread): Add declaration.
	* mn10300-linux-tdep.c (_initialize_mn10300_linux_tdep): Add declaration.
	* mn10300-tdep.c (_initialize_mn10300_tdep): Add declaration.
	* moxie-tdep.c (_initialize_moxie_tdep): Add declaration.
	* msp430-tdep.c (_initialize_msp430_tdep): Add declaration.
	* nds32-tdep.c (_initialize_nds32_tdep): Add declaration.
	* nios2-linux-tdep.c (_initialize_nios2_linux_tdep): Add declaration.
	* nios2-tdep.c (_initialize_nios2_tdep): Add declaration.
	* nto-procfs.c (_initialize_procfs): Add declaration.
	* objc-lang.c (_initialize_objc_language): Add declaration.
	* observable.c (_initialize_observer): Add declaration.
	* opencl-lang.c (_initialize_opencl_language): Add declaration.
	* or1k-linux-tdep.c (_initialize_or1k_linux_tdep): Add declaration.
	* or1k-tdep.c (_initialize_or1k_tdep): Add declaration.
	* osabi.c (_initialize_gdb_osabi): Add declaration.
	* osdata.c (_initialize_osdata): Add declaration.
	* p-valprint.c (_initialize_pascal_valprint): Add declaration.
	* parse.c (_initialize_parse): Add declaration.
	* ppc-fbsd-nat.c (_initialize_ppcfbsd_nat): Add declaration.
	* ppc-fbsd-tdep.c (_initialize_ppcfbsd_tdep): Add declaration.
	* ppc-linux-nat.c (_initialize_ppc_linux_nat): Add declaration.
	* ppc-linux-tdep.c (_initialize_ppc_linux_tdep): Add declaration.
	* ppc-nbsd-nat.c (_initialize_ppcnbsd_nat): Add declaration.
	* ppc-nbsd-tdep.c (_initialize_ppcnbsd_tdep): Add declaration.
	* ppc-obsd-nat.c (_initialize_ppcobsd_nat): Add declaration.
	* ppc-obsd-tdep.c (_initialize_ppcobsd_tdep): Add declaration.
	* printcmd.c (_initialize_printcmd): Add declaration.
	* probe.c (_initialize_probe): Add declaration.
	* proc-api.c (_initialize_proc_api): Add declaration.
	* proc-events.c (_initialize_proc_events): Add declaration.
	* proc-service.c (_initialize_proc_service): Add declaration.
	* procfs.c (_initialize_procfs): Add declaration.
	* producer.c (_initialize_producer): Add declaration.
	* psymtab.c (_initialize_psymtab): Add declaration.
	* python/python.c (_initialize_python): Add declaration.
	* ravenscar-thread.c (_initialize_ravenscar): Add declaration.
	* record-btrace.c (_initialize_record_btrace): Add declaration.
	* record-full.c (_initialize_record_full): Add declaration.
	* record.c (_initialize_record): Add declaration.
	* regcache-dump.c (_initialize_regcache_dump): Add declaration.
	* regcache.c (_initialize_regcache): Add declaration.
	* reggroups.c (_initialize_reggroup): Add declaration.
	* remote-notif.c (_initialize_notif): Add declaration.
	* remote-sim.c (_initialize_remote_sim): Add declaration.
	* remote.c (_initialize_remote): Add declaration.
	* reverse.c (_initialize_reverse): Add declaration.
	* riscv-fbsd-nat.c (_initialize_riscv_fbsd_nat): Add declaration.
	* riscv-fbsd-tdep.c (_initialize_riscv_fbsd_tdep): Add declaration.
	* riscv-linux-nat.c (_initialize_riscv_linux_nat): Add declaration.
	* riscv-linux-tdep.c (_initialize_riscv_linux_tdep): Add declaration.
	* riscv-tdep.c (_initialize_riscv_tdep): Add declaration.
	* rl78-tdep.c (_initialize_rl78_tdep): Add declaration.
	* rs6000-aix-tdep.c (_initialize_rs6000_aix_tdep): Add declaration.
	* rs6000-lynx178-tdep.c (_initialize_rs6000_lynx178_tdep):
	Add declaration.
	* rs6000-nat.c (_initialize_rs6000_nat): Add declaration.
	* rs6000-tdep.c (_initialize_rs6000_tdep): Add declaration.
	* run-on-main-thread.c (_initialize_run_on_main_thread): Add declaration.
	* rust-exp.y (_initialize_rust_exp): Add declaration.
	* rx-tdep.c (_initialize_rx_tdep): Add declaration.
	* s12z-tdep.c (_initialize_s12z_tdep): Add declaration.
	* s390-linux-nat.c (_initialize_s390_nat): Add declaration.
	* s390-linux-tdep.c (_initialize_s390_linux_tdep): Add declaration.
	* s390-tdep.c (_initialize_s390_tdep): Add declaration.
	* score-tdep.c (_initialize_score_tdep): Add declaration.
	* ser-go32.c (_initialize_ser_dos): Add declaration.
	* ser-mingw.c (_initialize_ser_windows): Add declaration.
	* ser-pipe.c (_initialize_ser_pipe): Add declaration.
	* ser-tcp.c (_initialize_ser_tcp): Add declaration.
	* ser-uds.c (_initialize_ser_socket): Add declaration.
	* ser-unix.c (_initialize_ser_hardwire): Add declaration.
	* serial.c (_initialize_serial): Add declaration.
	* sh-linux-tdep.c (_initialize_sh_linux_tdep): Add declaration.
	* sh-nbsd-nat.c (_initialize_shnbsd_nat): Add declaration.
	* sh-nbsd-tdep.c (_initialize_shnbsd_tdep): Add declaration.
	* sh-tdep.c (_initialize_sh_tdep): Add declaration.
	* skip.c (_initialize_step_skip): Add declaration.
	* sol-thread.c (_initialize_sol_thread): Add declaration.
	* solib-aix.c (_initialize_solib_aix): Add declaration.
	* solib-darwin.c (_initialize_darwin_solib): Add declaration.
	* solib-dsbt.c (_initialize_dsbt_solib): Add declaration.
	* solib-frv.c (_initialize_frv_solib): Add declaration.
	* solib-svr4.c (_initialize_svr4_solib): Add declaration.
	* solib-target.c (_initialize_solib_target): Add declaration.
	* solib.c (_initialize_solib): Add declaration.
	* source-cache.c (_initialize_source_cache): Add declaration.
	* source.c (_initialize_source): Add declaration.
	* sparc-linux-nat.c (_initialize_sparc_linux_nat): Add declaration.
	* sparc-linux-tdep.c (_initialize_sparc_linux_tdep): Add declaration.
	* sparc-nat.c (_initialize_sparc_nat): Add declaration.
	* sparc-nbsd-nat.c (_initialize_sparcnbsd_nat): Add declaration.
	* sparc-nbsd-tdep.c (_initialize_sparcnbsd_tdep): Add declaration.
	* sparc-obsd-tdep.c (_initialize_sparc32obsd_tdep): Add declaration.
	* sparc-sol2-tdep.c (_initialize_sparc_sol2_tdep): Add declaration.
	* sparc-tdep.c (_initialize_sparc_tdep): Add declaration.
	* sparc64-fbsd-nat.c (_initialize_sparc64fbsd_nat): Add declaration.
	* sparc64-fbsd-tdep.c (_initialize_sparc64fbsd_tdep): Add declaration.
	* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Add declaration.
	* sparc64-linux-tdep.c (_initialize_sparc64_linux_tdep): Add declaration.
	* sparc64-nat.c (_initialize_sparc64_nat): Add declaration.
	* sparc64-nbsd-nat.c (_initialize_sparc64nbsd_nat): Add declaration.
	* sparc64-nbsd-tdep.c (_initialize_sparc64nbsd_tdep): Add declaration.
	* sparc64-obsd-nat.c (_initialize_sparc64obsd_nat): Add declaration.
	* sparc64-obsd-tdep.c (_initialize_sparc64obsd_tdep): Add declaration.
	* sparc64-sol2-tdep.c (_initialize_sparc64_sol2_tdep): Add declaration.
	* sparc64-tdep.c (_initialize_sparc64_adi_tdep): Add declaration.
	* stabsread.c (_initialize_stabsread): Add declaration.
	* stack.c (_initialize_stack): Add declaration.
	* stap-probe.c (_initialize_stap_probe): Add declaration.
	* std-regs.c (_initialize_frame_reg): Add declaration.
	* symfile-debug.c (_initialize_symfile_debug): Add declaration.
	* symfile-mem.c (_initialize_symfile_mem): Add declaration.
	* symfile.c (_initialize_symfile): Add declaration.
	* symmisc.c (_initialize_symmisc): Add declaration.
	* symtab.c (_initialize_symtab): Add declaration.
	* target.c (_initialize_target): Add declaration.
	* target-connection.c (_initialize_target_connection): Add
	declaration.
	* target-dcache.c (_initialize_target_dcache): Add declaration.
	* target-descriptions.c (_initialize_target_descriptions): Add declaration.
	* thread.c (_initialize_thread): Add declaration.
	* tic6x-linux-tdep.c (_initialize_tic6x_linux_tdep): Add declaration.
	* tic6x-tdep.c (_initialize_tic6x_tdep): Add declaration.
	* tilegx-linux-nat.c (_initialize_tile_linux_nat): Add declaration.
	* tilegx-linux-tdep.c (_initialize_tilegx_linux_tdep): Add declaration.
	* tilegx-tdep.c (_initialize_tilegx_tdep): Add declaration.
	* tracectf.c (_initialize_ctf): Add declaration.
	* tracefile-tfile.c (_initialize_tracefile_tfile): Add declaration.
	* tracefile.c (_initialize_tracefile): Add declaration.
	* tracepoint.c (_initialize_tracepoint): Add declaration.
	* tui/tui-hooks.c (_initialize_tui_hooks): Add declaration.
	* tui/tui-interp.c (_initialize_tui_interp): Add declaration.
	* tui/tui-layout.c (_initialize_tui_layout): Add declaration.
	* tui/tui-regs.c (_initialize_tui_regs): Add declaration.
	* tui/tui-stack.c (_initialize_tui_stack): Add declaration.
	* tui/tui-win.c (_initialize_tui_win): Add declaration.
	* tui/tui.c (_initialize_tui): Add declaration.
	* typeprint.c (_initialize_typeprint): Add declaration.
	* ui-style.c (_initialize_ui_style): Add declaration.
	* unittests/array-view-selftests.c (_initialize_array_view_selftests): Add declaration.
	* unittests/child-path-selftests.c (_initialize_child_path_selftests): Add declaration.
	* unittests/cli-utils-selftests.c (_initialize_cli_utils_selftests): Add declaration.
	* unittests/common-utils-selftests.c (_initialize_common_utils_selftests): Add declaration.
	* unittests/copy_bitwise-selftests.c (_initialize_copy_bitwise_utils_selftests): Add declaration.
	* unittests/environ-selftests.c (_initialize_environ_selftests): Add declaration.
	* unittests/filtered_iterator-selftests.c
	(_initialize_filtered_iterator_selftests): Add declaration.
	* unittests/format_pieces-selftests.c (_initialize_format_pieces_selftests): Add declaration.
	* unittests/function-view-selftests.c (_initialize_function_view_selftests): Add declaration.
	* unittests/help-doc-selftests.c (_initialize_help_doc_selftests): Add declaration.
	* unittests/lookup_name_info-selftests.c (_initialize_lookup_name_info_selftests): Add declaration.
	* unittests/main-thread-selftests.c
	(_initialize_main_thread_selftests): Add declaration.
	* unittests/memory-map-selftests.c (_initialize_memory_map_selftests): Add declaration.
	* unittests/memrange-selftests.c (_initialize_memrange_selftests): Add declaration.
	* unittests/mkdir-recursive-selftests.c (_initialize_mkdir_recursive_selftests): Add declaration.
	* unittests/observable-selftests.c (_initialize_observer_selftest): Add declaration.
	* unittests/offset-type-selftests.c (_initialize_offset_type_selftests): Add declaration.
	* unittests/optional-selftests.c (_initialize_optional_selftests): Add declaration.
	* unittests/parse-connection-spec-selftests.c (_initialize_parse_connection_spec_selftests): Add declaration.
	* unittests/rsp-low-selftests.c (_initialize_rsp_low_selftests): Add declaration.
	* unittests/scoped_fd-selftests.c (_initialize_scoped_fd_selftests): Add declaration.
	* unittests/scoped_mmap-selftests.c (_initialize_scoped_mmap_selftests): Add declaration.
	* unittests/scoped_restore-selftests.c (_initialize_scoped_restore_selftests): Add declaration.
	* unittests/string_view-selftests.c (_initialize_string_view_selftests): Add declaration.
	* unittests/style-selftests.c (_initialize_style_selftest): Add declaration.
	* unittests/tracepoint-selftests.c (_initialize_tracepoint_selftests): Add declaration.
	* unittests/tui-selftests.c (_initialize_tui_selftest): Add
	declaration.
	* unittests/unpack-selftests.c (_initialize_unpack_selftests): Add declaration.
	* unittests/utils-selftests.c (_initialize_utils_selftests): Add declaration.
	* unittests/vec-utils-selftests.c (_initialize_vec_utils_selftests): Add declaration.
	* unittests/xml-utils-selftests.c (_initialize_xml_utils): Add declaration.
	* user-regs.c (_initialize_user_regs): Add declaration.
	* utils.c (_initialize_utils): Add declaration.
	* v850-tdep.c (_initialize_v850_tdep): Add declaration.
	* valops.c (_initialize_valops): Add declaration.
	* valprint.c (_initialize_valprint): Add declaration.
	* value.c (_initialize_values): Add declaration.
	* varobj.c (_initialize_varobj): Add declaration.
	* vax-bsd-nat.c (_initialize_vaxbsd_nat): Add declaration.
	* vax-nbsd-tdep.c (_initialize_vaxnbsd_tdep): Add declaration.
	* vax-tdep.c (_initialize_vax_tdep): Add declaration.
	* windows-nat.c (_initialize_windows_nat): Add declaration.
	(_initialize_check_for_gdb_ini): Add declaration.
	(_initialize_loadable): Add declaration.
	* windows-tdep.c (_initialize_windows_tdep): Add declaration.
	* x86-bsd-nat.c (_initialize_x86_bsd_nat): Add declaration.
	* x86-linux-nat.c (_initialize_x86_linux_nat): Add declaration.
	* xcoffread.c (_initialize_xcoffread): Add declaration.
	* xml-support.c (_initialize_xml_support): Add declaration.
	* xstormy16-tdep.c (_initialize_xstormy16_tdep): Add declaration.
	* xtensa-linux-nat.c (_initialize_xtensa_linux_nat): Add declaration.
	* xtensa-linux-tdep.c (_initialize_xtensa_linux_tdep): Add declaration.
	* xtensa-tdep.c (_initialize_xtensa_tdep): Add declaration.

Change-Id: I13eec7e0ed2b3c427377a7bdb055cf46da64def9
2020-01-13 14:01:38 -05: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 Tromey deeafabb67 Remove MULTI_OBJFILE_P
This removes the MULTI_OBJFILE_P macro in favor of a method on the
program space.

gdb/ChangeLog
2019-12-12  Tom Tromey  <tom@tromey.com>

	* progspace.c (program_space::multi_objfile_p): New method.
	* printcmd.c (info_symbol_command): Update.
	* maint.c (maintenance_translate_address): Update.
	* objfiles.h (MULTI_OBJFILE_P): Remove.
	* progspace.h (struct program_space) <multi_objfile_p>: New
	method.

Change-Id: I2779e26ea8909078d63fea8f13bce94cab73948c
2019-12-12 15:50:53 -07:00
Philippe Waroquiers d8edc8b768 Implement 'print -raw-values' and 'set print raw-values on|off'
The option framework documentation was speaking about a 'print -raw'
option, but this option does not exist.

This patch implements -raw-values option that tells to ignore the
active pretty printers when printing a value.
As we already have -raw-frame-arguments, I thought -raw-values
was more clear, in particular to differentiate
   set print raw-values and set print raw-frame-arguments.

gdb/doc/ChangeLog
2019-12-11  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* gdb.texinfo (Command Options): Use -p and -pretty in the example,
	as -r is ambiguous.  Update the print - TAB TAB completion result.
	(Data): Document new option -raw-values.  Use -p and -pretty in the
	 example, as -r is ambiguous.
	(Print Settings): Document set print raw values.
	(Pretty-Printer Commands): Document interaction between enabled
	pretty printers and -raw-values/-raw-frame-arguments.

gdb/ChangeLog
2019-12-11  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* NEWS: Document -raw-values option and the related setting commands.
	* printcmd.c (print_command_parse_format): Do not set opts->raw off,
	only set it on when /r is given.
	* valprint.c (value_print_option_defs): New element raw-values.
	* Makefile.in: Add the new file.

gdb/testsuite/ChangeLog
2019-12-11  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* gdb.base/options.exp: Add -raw-values in the print completion list.
	* gdb.python/py-prettyprint.exp: Add tests for -raw-values.
2019-12-11 04:31:05 +01:00
Simon Marchi b858499daf Remove gdbarch parameter of lookup_typename
I noticed that the gdbarch parameter of lookup_typename was unused, so I
removed it (as well as from lookup_signed_typename and
lookup_unsigned_typename) and updated all callers.

Tested by rebuilding.

gdb/ChangeLog:

	* c-exp.y: Update calls to lookup_typename,
	lookup_signed_typename and lookup_unsigned_typename.
	* c-lang.c (evaluate_subexp_c): Likewise.
	* cp-namespace.c (cp_lookup_symbol_imports_or_template):
	Likewise.
	* eval.c (binop_promote): Likewise.
	* gdbtypes.c (lookup_typename): Remove gdbarch parameter.
	(lookup_unsigned_typename): Likewise.
	(lookup_signed_typename): Likewise.
	* gdbtypes.h (lookup_unsigned_typename): Likewise.
	(lookup_signed_typename): Likewise.
	(lookup_typename): Likewise.
	* guile/scm-type.c (tyscm_lookup_typename): Update calls to
	lookup_typename, lookup_signed_typename,
	lookup_unsigned_typename.
	* m2-exp.y: Likewise.
	* printcmd.c (printf_wide_c_string): Likewise.
	(ui_printf): Likewise.
	* python/py-type.c (typy_lookup_typename): Likewise.
	* python/py-xmethods.c (python_xmethod_worker::invoke):
	Likewise.
	* rust-exp.y: Likewise.
2019-12-05 13:44:30 -05:00
Christian Biesinger 987012b89b Replace SYMBOL_*_NAME accessors with member functions
Similar to the MSYMBOL version of this patch, improves readability
and will eventually allow making name private.

gdb/ChangeLog:

2019-11-22  Christian Biesinger  <cbiesinger@google.com>

	* ada-exp.y: Update.
	* ada-lang.c (sort_choices): Update.
	(ada_print_symbol_signature): Update.
	(resolve_subexp): Update.
	(ada_parse_renaming): Update.
	(ada_read_renaming_var_value): Update.
	(lesseq_defined_than): Update.
	(remove_extra_symbols): Update.
	(remove_irrelevant_renamings): Update.
	(ada_add_block_symbols): Update.
	(ada_collect_symbol_completion_matches): Update.
	(ada_is_renaming_symbol): Update.
	(aggregate_assign_from_choices): Update.
	(ada_evaluate_subexp): Update.
	(ada_has_this_exception_support): Update.
	(ada_is_non_standard_exception_sym): Update.
	(ada_add_exceptions_from_frame): Update.
	(ada_add_global_exceptions): Update.
	(ada_print_subexp): Update.
	* ax-gdb.c (gen_var_ref): Update.
	(gen_maybe_namespace_elt): Update.
	(gen_expr_for_cast): Update.
	(gen_expr): Update.
	* block.h: Update.
	* blockframe.c (find_pc_partial_function): Update.
	* breakpoint.c (print_breakpoint_location): Update.
	(update_static_tracepoint): Update.
	* btrace.c (ftrace_print_function_name): Update.
	(ftrace_function_switched): Update.
	* buildsym.c (find_symbol_in_list): Update.
	* c-exp.y: Update.
	* c-typeprint.c (c_print_typedef): Update.
	(c_type_print_template_args): Update.
	* cli/cli-cmds.c (edit_command): Update.
	(list_command): Update.
	(print_sal_location): Update.
	* coffread.c (patch_opaque_types): Update.
	(process_coff_symbol): Update.
	(coff_read_enum_type): Update.
	* compile/compile-c-symbols.c (c_symbol_substitution_name): Update.
	(convert_one_symbol): Update.
	(hash_symname): Update.
	(eq_symname): Update.
	* compile/compile-cplus-symbols.c (convert_one_symbol): Update.
	* compile/compile-cplus-types.c (debug_print_scope): Update.
	* compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update.
	* compile/compile-object-load.c (get_out_value_type): Update.
	* cp-namespace.c (cp_scan_for_anonymous_namespaces): Update.
	(search_symbol_list): Update.
	(cp_lookup_symbol_imports_or_template): Update.
	* cp-support.c (overload_list_add_symbol): Update.
	* ctfread.c (psymtab_to_symtab): Update.
	* dbxread.c (cp_set_block_scope): Update.
	* dictionary.c (iter_match_first_hashed): Update.
	(iter_match_next_hashed): Update.
	(insert_symbol_hashed): Update.
	(iter_match_next_linear): Update.
	* dictionary.h: Update.
	* dwarf2loc.c (func_get_frame_base_dwarf_block): Update.
	(locexpr_describe_location_piece): Update.
	(locexpr_describe_location_1): Update.
	(locexpr_generate_c_location): Update.
	(loclist_describe_location): Update.
	(loclist_generate_c_location): Update.
	* dwarf2read.c (dw2_debug_names_lookup_symbol): Update.
	(read_func_scope): Update.
	(process_enumeration_scope): Update.
	(new_symbol): Update.
	(dwarf2_const_value): Update.
	(dwarf2_symbol_mark_computed): Update.
	* eval.c (evaluate_funcall): Update.
	(evaluate_subexp_standard): Update.
	* expprint.c (print_subexp_standard): Update.
	(dump_subexp_body_standard): Update.
	* f-valprint.c (info_common_command_for_block): Update.
	* findvar.c (get_hosting_frame): Update.
	(default_read_var_value): Update.
	* go-lang.c (go_symbol_package_name): Update.
	* guile/scm-block.c (bkscm_print_block_smob): Update.
	* guile/scm-symbol.c (syscm_print_symbol_smob): Update.
	(gdbscm_symbol_name): Update.
	(gdbscm_symbol_linkage_name): Update.
	(gdbscm_symbol_print_name): Update.
	* infcall.c (get_function_name): Update.
	* infcmd.c (jump_command): Update.
	(finish_command): Update.
	* infrun.c (insert_exception_resume_breakpoint): Update.
	* linespec.c (canonicalize_linespec): Update.
	(create_sals_line_offset): Update.
	(convert_linespec_to_sals): Update.
	(complete_label): Update.
	(find_label_symbols_in_block): Update.
	* m2-typeprint.c (m2_print_typedef): Update.
	* mdebugread.c (mdebug_reg_to_regnum): Update.
	(parse_symbol): Update.
	(mylookup_symbol): Update.
	* mi/mi-cmd-stack.c (list_arg_or_local): Update.
	(list_args_or_locals): Update.
	* objc-lang.c (compare_selectors): Update.
	(info_selectors_command): Update.
	(compare_classes): Update.
	(info_classes_command): Update.
	(find_imps): Update.
	* p-typeprint.c (pascal_print_typedef): Update.
	* printcmd.c (build_address_symbolic): Update.
	(info_address_command): Update.
	(print_variable_and_value): Update.
	* python/py-framefilter.c (extract_sym): Update.
	(py_print_single_arg): Update.
	* python/py-symbol.c (sympy_str): Update.
	(sympy_get_name): Update.
	(sympy_get_linkage_name): Update.
	* python/python.c (gdbpy_rbreak): Update.
	* record-btrace.c (btrace_get_bfun_name): Update.
	(btrace_call_history): Update.
	* rust-lang.c (rust_print_typedef): Update.
	* solib-frv.c (frv_fdpic_find_canonical_descriptor): Update.
	* stabsread.c (stab_reg_to_regnum): Update.
	(define_symbol): Update.
	(read_enum_type): Update.
	(common_block_end): Update.
	(cleanup_undefined_types_1): Update.
	(scan_file_globals): Update.
	* stack.c (print_frame_arg): Update.
	(print_frame_args): Update.
	(find_frame_funname): Update.
	(info_frame_command_core): Update.
	(iterate_over_block_locals): Update.
	(print_block_frame_labels): Update.
	(do_print_variable_and_value): Update.
	(iterate_over_block_arg_vars): Update.
	(return_command): Update.
	* symmisc.c (dump_symtab_1): Update.
	(print_symbol): Update.
	* symtab.c (eq_symbol_entry): Update.
	(symbol_cache_dump): Update.
	(lookup_language_this): Update.
	(find_pc_sect_line): Update.
	(skip_prologue_sal): Update.
	(symbol_search::compare_search_syms): Update.
	(treg_matches_sym_type_name): Update.
	(search_symbols): Update.
	(print_symbol_info): Update.
	(rbreak_command): Update.
	(completion_list_add_symbol): Update.
	(find_gnu_ifunc): Update.
	(get_symbol_address): Update.
	(search_module_symbols): Update.
	(info_module_subcommand): Update.
	* symtab.h (SYMBOL_NATURAL_NAME): Remove.
	(SYMBOL_LINKAGE_NAME): Remove.
	(SYMBOL_DEMANGLED_NAME): Remove.
	(SYMBOL_PRINT_NAME): Remove.
	(SYMBOL_SEARCH_NAME): Remove.
	* tracepoint.c (set_traceframe_context): Update.
	(validate_actionline): Update.
	(collection_list::collect_symbol): Update.
	(encode_actions_1): Update.
	(info_scope_command): Update.
	(print_one_static_tracepoint_marker): Update.
	* typeprint.c (typedef_hash_table::add_template_parameters): Update.
	* valops.c (address_of_variable): Update.
	(find_overload_match): Update.
	(find_oload_champ): Update.

Change-Id: I76bdc8b44eea6876bf03af9d351f8e90cc0154b2
2019-11-22 12:05:14 -06:00
Christian Biesinger c9d95fa3d0 Replace the MSYMBOL_*_NAME macros with member functions
Improves readability. In the future, it will also allow making the name
private, once the name setter functions become member functions.

gdb/ChangeLog:

2019-11-22  Christian Biesinger  <cbiesinger@google.com>

	* ada-lang.c (ada_lookup_simple_minsym): Update.
	(ada_collect_symbol_completion_matches): Update.
	* ada-tasks.c (read_atcb): Update.
	* amd64-windows-tdep.c (amd64_skip_main_prologue): Update.
	(amd64_windows_skip_trampoline_code): Update.
	* arm-tdep.c (skip_prologue_function): Update.
	(arm_skip_stack_protector): Update.
	* arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update.
	(arm_wince_skip_main_prologue): Update.
	* ax-gdb.c (gen_expr): Update.
	* block.c (call_site_for_pc): Update.
	* blockframe.c (find_pc_partial_function): Update.
	* breakpoint.c (set_breakpoint_location_function): Update.
	* btrace.c (ftrace_print_function_name): Update.
	(ftrace_function_switched): Update.
	* c-valprint.c (print_unpacked_pointer): Update.
	* coffread.c (coff_symfile_read): Update.
	* compile/compile-c-symbols.c (convert_symbol_bmsym): Update.
	* compile/compile-cplus-symbols.c (convert_symbol_bmsym): Update.
	* dwarf-index-write.c (write_psymbols): Update.
	* dwarf2loc.c (call_site_to_target_addr): Update.
	(func_verify_no_selftailcall): Update.
	(tailcall_dump): Update.
	(call_site_find_chain_1): Update.
	(dwarf_expr_reg_to_entry_parameter): Update.
	* elfread.c (elf_gnu_ifunc_record_cache): Update.
	* eval.c (evaluate_funcall): Update.
	(evaluate_subexp_standard): Update.
	(evaluate_subexp_for_sizeof): Update.
	* expprint.c (print_subexp_standard): Update.
	(dump_subexp_body_standard): Update.
	* frame.c (get_prev_frame_always_1): Update.
	* frv-tdep.c (frv_skip_main_prologue): Update.
	* gnu-v2-abi.c (gnuv2_value_rtti_type): Update.
	* gnu-v3-abi.c (gnuv3_rtti_type): Update.
	(gnuv3_get_typename_from_type_info): Update.
	(gnuv3_skip_trampoline): Update.
	* hppa-tdep.c (hppa_lookup_stub_minimal_symbol): Update.
	* i386-tdep.c (i386_skip_main_prologue): Update.
	(i386_pe_skip_trampoline_code): Update.
	* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Update.
	* infcall.c (get_function_name): Update.
	* linespec.c (minsym_found): Update.
	* linux-fork.c (info_checkpoints_command): Update.
	* m32c-tdep.c (m32c_m16c_address_to_pointer): Update.
	(m32c_m16c_pointer_to_address): Update.
	* maint.c (maintenance_translate_address): Update.
	* minsyms.c (add_minsym_to_hash_table): Update.
	(add_minsym_to_demangled_hash_table): Update.
	(lookup_minimal_symbol_mangled): Update.
	(lookup_minimal_symbol_demangled): Update.
	(lookup_minimal_symbol_linkage): Update.
	(lookup_minimal_symbol_text): Update.
	(lookup_minimal_symbol_by_pc_name): Update.
	(minimal_symbol_is_less_than): Update.
	(compact_minimal_symbols): Update.
	(build_minimal_symbol_hash_tables): Update.
	(find_solib_trampoline_target): Update.
	* mips-tdep.c (mips_stub_frame_sniffer): Update.
	(mips_skip_pic_trampoline_code): Update.
	* msp430-tdep.c (msp430_skip_trampoline_code): Update.
	* objc-lang.c (info_selectors_command): Update.
	(info_classes_command): Update.
	(find_methods): Update.
	(find_imps): Update.
	* p-valprint.c (pascal_val_print): Update.
	* ppc-linux-tdep.c (powerpc_linux_in_dynsym_resolve_code): Update.
	* ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update.
	* printcmd.c (build_address_symbolic): Update.
	(info_symbol_command): Update.
	* psymtab.c (psymbol_name_matches): Update.
	(match_partial_symbol): Update.
	(lookup_partial_symbol): Update.
	(print_partial_symbols): Update.
	(sort_pst_symbols): Update.
	(maintenance_check_psymtabs): Update.
	* python/py-framefilter.c (py_print_frame): Update.
	* python/python.c (gdbpy_rbreak): Update.
	* record-btrace.c (btrace_get_bfun_name): Update.
	(btrace_call_history): Update.
	* rs6000-tdep.c (rs6000_skip_main_prologue): Update.
	(rs6000_skip_trampoline_code): Update.
	* sol-thread.c (info_cb): Update.
	* stabsread.c (scan_file_globals): Update.
	* stack.c (find_frame_funname): Update.
	(info_frame_command_core): Update.
	* symmisc.c (dump_msymbols): Update.
	* symtab.c (symbol_natural_name): Rename to..,
	(general_symbol_info::natural_name): ...this.
	(symbol_demangled_name): Rename to...
	(general_symbol_info::demangled_name): ...this.
	(symbol_search_name): Rename to...
	(general_symbol_info::search_name): ...this.
	(symbol_matches_search_name): Update.
	(find_pc_sect_line): Update.
	(skip_prologue_sal): Update.
	(search_symbols): Update.
	(print_msymbol_info): Update.
	(rbreak_command): Update.
	(completion_list_add_msymbol): Update.
	(completion_list_objc_symbol): Update.
	(get_msymbol_address): Update.
	* symtab.h (struct general_symbol_info): Add member functions
	natural_name (), linkage_name (), print_name (), demangled_name (),
	and search_name ().
	(SYMBOL_NATURAL_NAME): Update.
	(symbol_natural_name): Move to a member function on general_symbol_info.
	(SYMBOL_DEMANGLED_NAME): Update.
	(symbol_demangled_name): Move to a member function on
	general_symbol_info.
	(SYMBOL_SEARCH_NAME): Update.
	(symbol_search_name): Move to a member function on general_symbol_info.
	(MSYMBOL_NATURAL_NAME): Remove.
	(MSYMBOL_LINKAGE_NAME): Remove.
	(MSYMBOL_PRINT_NAME): Remove.
	(MSYMBOL_DEMANGLED_NAME): Remove.
	(MSYMBOL_SEARCH_NAME): Remove.
	* x86-tdep.c (x86_in_indirect_branch_thunk): Update.

Change-Id: I65aa529843a9903e174ce799037e41f954a9fcee
2019-11-22 12:05:14 -06:00
Peeter Joot 34877895ca Adjust byte order variable display/change if DW_AT_endianity is present.
- Rationale:
It is possible for compilers to indicate the desired byte order
interpretation of scalar variables using the DWARF attribute:
   DW_AT_endianity

A type flagged with this variable would typically use one of:
   DW_END_big
   DW_END_little
which instructs the debugger what the desired byte order interpretation
of the variable should be.

The GCC compiler (as of V6) has a mechanism for setting the desired byte
ordering of the fields within a structure or union.  For, example, on a
little endian target, a structure declared as:
   struct big {
       int v;
       short a[4];
   } __attribute__( ( scalar_storage_order( "big-endian" ) ) );
could be used to ensure all the structure members have a big-endian
interpretation (the compiler would automatically insert byte swap
instructions before and after respective store and load instructions).

- To reproduce
GCC V8 is required to correctly emit DW_AT_endianity DWARF attributes
in all situations when the scalar_storage_order attribute is used.

A fix for (dwarf endianity instrumentation) for GCC V6-V7 can be found
in the URL field of the following PR:
   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82509

- Test-case:
A new test case (testsuite/gdb.base/endianity.*) is included with this
patch.

Manual testing for mixed endianity code has also been done with GCC V8.
See:
   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82509#c4

- Observed vs. expected:

Without this change, using scalar_storage_order that doesn't match the
target, such as

struct otherendian
{
  int v;
} __attribute__( ( scalar_storage_order( "big-endian" ) ) );

would behave like the following on a little endian target:

   Breakpoint 1 at 0x401135: file endianity.c, line 41.
   (gdb) run
   Starting program: /home/pjoot/freeware/t/a.out
   Missing separate debuginfos, use: debuginfo-install glibc-2.17-292.el7.x86_64

   Breakpoint 1, main () at endianity.c:41
   41        struct otherendian o = {3};
   (gdb) n
   43        do_nothing (&o); /* START */
   (gdb) p o
   $1 = {v = 50331648}
   (gdb) p /x
   $2 = {v = 0x3000000}

whereas with this gdb enhancement we can access the variable with the user
specified endianity:

   Breakpoint 1, main () at endianity.c:41
   41        struct otherendian o = {3};
   (gdb) p o
   $1 = {v = 0}
   (gdb) n
   43        do_nothing (&o); /* START */
   (gdb) p o
   $2 = {v = 3}
   (gdb) p o.v = 4
   $3 = 4
   (gdb) p o.v
   $4 = 4
   (gdb) x/4xb &o.v
   0x7fffffffd90c: 0x00    0x00    0x00    0x04

(observe that the 4 byte int variable has a big endian representation in the
 hex dump.)

gdb/ChangeLog
2019-11-21  Peeter Joot  <peeter.joot@lzlabs.com>

	Byte reverse display of variables with DW_END_big, DW_END_little
	(DW_AT_endianity) dwarf attributes if different than the native
	byte order.
	* ada-lang.c (ada_value_binop):
	Use type_byte_order instead of gdbarch_byte_order.
	* ada-valprint.c (printstr):
	(ada_val_print_string):
	* ada-lang.c (value_pointer):
	(ada_value_binop):
	Use type_byte_order instead of gdbarch_byte_order.
	* c-lang.c (c_get_string):
	Use type_byte_order instead of gdbarch_byte_order.
	* c-valprint.c (c_val_print_array):
	Use type_byte_order instead of gdbarch_byte_order.
	* cp-valprint.c (cp_print_class_member):
	Use type_byte_order instead of gdbarch_byte_order.
	* dwarf2loc.c (rw_pieced_value):
	Use type_byte_order instead of gdbarch_byte_order.
	* dwarf2read.c (read_base_type): Handle DW_END_big,
	DW_END_little
	* f-lang.c (f_get_encoding):
	Use type_byte_order instead of gdbarch_byte_order.
	* findvar.c (default_read_var_value):
	Use type_byte_order instead of gdbarch_byte_order.
	* gdbtypes.c (check_types_equal):
	Require matching TYPE_ENDIANITY_NOT_DEFAULT if set.
	(recursive_dump_type): Print TYPE_ENDIANITY_BIG,
	and TYPE_ENDIANITY_LITTLE if set.
	(type_byte_order): new function.
	* gdbtypes.h (TYPE_ENDIANITY_NOT_DEFAULT): New macro.
	(struct main_type) <flag_endianity_not_default>:
	New field.
	(type_byte_order): New function.
	* infcmd.c (default_print_one_register_info):
	Use type_byte_order instead of gdbarch_byte_order.
	* p-lang.c (pascal_printstr):
	Use type_byte_order instead of gdbarch_byte_order.
	* p-valprint.c (pascal_val_print):
	Use type_byte_order instead of gdbarch_byte_order.
	* printcmd.c (print_scalar_formatted):
	Use type_byte_order instead of gdbarch_byte_order.
	* solib-darwin.c (darwin_current_sos):
	Use type_byte_order instead of gdbarch_byte_order.
	* solib-svr4.c (solib_svr4_r_ldsomap):
	Use type_byte_order instead of gdbarch_byte_order.
	* stap-probe.c (stap_modify_semaphore):
	Use type_byte_order instead of gdbarch_byte_order.
	* target-float.c (target_float_same_format_p):
	Use type_byte_order instead of gdbarch_byte_order.
	* valarith.c (scalar_binop):
	(value_bit_index):
	Use type_byte_order instead of gdbarch_byte_order.
	* valops.c (value_cast):
	Use type_byte_order instead of gdbarch_byte_order.
	* valprint.c (generic_emit_char):
	(generic_printstr):
	(val_print_string):
	Use type_byte_order instead of gdbarch_byte_order.
	* value.c (unpack_long):
	(unpack_bits_as_long):
	(unpack_value_bitfield):
	(modify_field):
	(pack_long):
	(pack_unsigned_long):
	Use type_byte_order instead of gdbarch_byte_order.
	* findvar.c (unsigned_pointer_to_address):
	(signed_pointer_to_address):
	(unsigned_address_to_pointer):
	(address_to_signed_pointer):
	(default_read_var_value):
	(default_value_from_register):
	Use type_byte_order instead of gdbarch_byte_order.
	* gnu-v3-abi.c (gnuv3_make_method_ptr):
	Use type_byte_order instead of gdbarch_byte_order.
	* riscv-tdep.c (riscv_print_one_register_info):
	Use type_byte_order instead of gdbarch_byte_order.

gdb/testsuite/ChangeLog
2019-11-21  Peeter Joot  <peeter.joot@lzlabs.com>

	* gdb.base/endianity.c: New test.
	* gdb.base/endianity.exp: New file.

Change-Id: I4bd98c1b4508c2d7c5a5dbb15d7b7b1cb4e667e2
2019-11-21 11:48:59 -07:00
Andrew Burgess e06f3d6eba gdb: Support printf 'z' size modifier
The gdb format mechanism doesn't currently support the 'z' size
modifier, there are a few places in GDB where this is used.  Instead
of removing these uses lets just add support to GDB for using 'z'.

I found this issue when trying to use some of the debug output.
Before this commit:

  (gdb) set debug dwarf-line 9
  (gdb) file test
  Reading symbols from test...
  Unrecognized format specifier 'z' in printf
  (No debugging symbols found in test)
  (gdb)

After this commit:

  (gdb) set debug dwarf-line 9
  (gdb) file test
  Reading symbols from test...
  Adding dir 1: /usr/include
  Adding file 1: test.c
  Adding file 2: stdc-predef.h
  Processing actual line 3: file 1, address 0x4004a0, is_stmt 1, discrim 0
  Processing actual line 4: file 1, address 0x4004a0, is_stmt 1, discrim 0
  .... lots of debug output ...
  Processing actual line 10: file 1, address 0x4003b7, is_stmt 0, discrim 0
  (gdb)

I've added a self test to cover the integer format size modifiers,
including the 'z' modifier.

gdb/ChangeLog:

	* gdbsupport/format.c (format_pieces::format_pieces): Support
	printf 'z' size modifier.
	* gdbsupport/format.h (enum argclass): Add size_t_arg.
	* printcmd.c (ui_printf):  Handle size_t_arg.
	* ui-out.c (ui_out::vmessage): Likewise.
	* unittests/format_pieces-selftests.c (test_format_int_sizes): New
	function.
	(run_tests): Call test_format_int_sizes.

gdb/gdbserver/ChangeLog:

	* ax.c (ax_printf): Handle size_t_arg.

Change-Id: Ib6c44d88aa5bce265d757e4c0698881803dd186f
2019-11-12 23:46:41 +00:00
Tom de Vries 85102364b2 [gdb] Fix more typos in comments
Fix typos in comments.  NFC.

Tested on x86_64-linux.

gdb/ChangeLog:

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

	* aarch64-tdep.c: Fix typos in comments.
	* ada-lang.c: Same.
	* ada-tasks.c: Same.
	* alpha-tdep.c: Same.
	* alpha-tdep.h: Same.
	* amd64-nat.c: Same.
	* amd64-windows-tdep.c: Same.
	* arc-tdep.c: Same.
	* arc-tdep.h: Same.
	* arch-utils.c: Same.
	* arm-nbsd-tdep.c: Same.
	* arm-tdep.c: Same.
	* ax-gdb.c: Same.
	* blockframe.c: Same.
	* btrace.c: Same.
	* c-varobj.c: Same.
	* coff-pe-read.c: Same.
	* coffread.c: Same.
	* cris-tdep.c: Same.
	* darwin-nat.c: Same.
	* dbxread.c: Same.
	* dcache.c: Same.
	* disasm.c: Same.
	* dtrace-probe.c: Same.
	* dwarf-index-write.c: Same.
	* dwarf2-frame-tailcall.c: Same.
	* dwarf2-frame.c: Same.
	* dwarf2read.c: Same.
	* eval.c: Same.
	* exceptions.c: Same.
	* fbsd-tdep.c: Same.
	* findvar.c: Same.
	* frame.c: Same.
	* frv-tdep.c: Same.
	* gnu-v3-abi.c: Same.
	* go32-nat.c: Same.
	* h8300-tdep.c: Same.
	* hppa-tdep.c: Same.
	* i386-linux-tdep.c: Same.
	* i386-tdep.c: Same.
	* ia64-libunwind-tdep.c: Same.
	* ia64-tdep.c: Same.
	* infcmd.c: Same.
	* infrun.c: Same.
	* linespec.c: Same.
	* linux-nat.c: Same.
	* linux-thread-db.c: Same.
	* machoread.c: Same.
	* mdebugread.c: Same.
	* mep-tdep.c: Same.
	* mn10300-tdep.c: Same.
	* namespace.c: Same.
	* objfiles.c: Same.
	* opencl-lang.c: Same.
	* or1k-tdep.c: Same.
	* osabi.c: Same.
	* ppc-linux-nat.c: Same.
	* ppc-linux-tdep.c: Same.
	* ppc-sysv-tdep.c: Same.
	* printcmd.c: Same.
	* procfs.c: Same.
	* record-btrace.c: Same.
	* record-full.c: Same.
	* remote-fileio.c: Same.
	* remote.c: Same.
	* rs6000-tdep.c: Same.
	* s12z-tdep.c: Same.
	* score-tdep.c: Same.
	* ser-base.c: Same.
	* ser-go32.c: Same.
	* skip.c: Same.
	* sol-thread.c: Same.
	* solib-svr4.c: Same.
	* solib.c: Same.
	* source.c: Same.
	* sparc-nat.c: Same.
	* sparc-sol2-tdep.c: Same.
	* sparc-tdep.c: Same.
	* sparc64-tdep.c: Same.
	* stabsread.c: Same.
	* stack.c: Same.
	* symfile.c: Same.
	* symtab.c: Same.
	* target-descriptions.c: Same.
	* target-float.c: Same.
	* thread.c: Same.
	* utils.c: Same.
	* valops.c: Same.
	* valprint.c: Same.
	* value.c: Same.
	* varobj.c: Same.
	* windows-nat.c: Same.
	* xcoffread.c: Same.
	* xstormy16-tdep.c: Same.
	* xtensa-tdep.c: Same.

Change-Id: I5175f1b107bfa4e1cdd4a3361ccb4739e53c75c4
2019-10-18 02:48:08 +02:00
Tom Tromey 7f6aba03b9 Introduce metadata style
This introduces a new "metadata" style and changes many places in gdb
to use it.  The idea here is to let the user distinguish gdb output
from output that (conceptually at least) comes directly from the
inferior.  The newly-styled category includes text that gdb
traditionally surrounds in "<...>", like "<unavailable>".

I only added a single test for this.  In many cases this output is
difficult to test.  Also, while developing this errors in the
implementation of the new printf formats showed up as regressions.

gdb/ChangeLog
2019-10-01  Tom Tromey  <tom@tromey.com>

	* p-lang.c (pascal_printstr): Use metadata style.
	* value.c (show_convenience): Use metadata style.
	* valprint.c (valprint_check_validity, val_print_optimized_out)
	(val_print_not_saved, val_print_unavailable)
	(val_print_invalid_address, generic_val_print, val_print)
	(value_check_printable, val_print_array_elements): Use metadata
	style.
	* ui-out.h (class ui_out) <field_fmt>: New overload.
	<do_field_fmt>: Add style parameter.
	* ui-out.c (ui_out::field_fmt): New overload.
	* typeprint.c (type_print_unknown_return_type)
	(val_print_not_allocated, val_print_not_associated): Use metadata
	style.
	* tui/tui-out.h (class tui_ui_out) <do_field_fmt>: Add style
	parameter.
	* tui/tui-out.c (tui_ui_out::do_field_fmt): Update.
	* tracepoint.c (tvariables_info_1): Use metadata style.
	* stack.c (print_frame_arg, print_frame_info, print_frame)
	(info_frame_command_core): Use metadata style.
	* skip.c (info_skip_command): Use metadata style.
	* rust-lang.c (rust_print_enum): Use metadata style.
	* python/py-prettyprint.c (print_stack_unless_memory_error): Use
	metadata style.
	* python/py-framefilter.c (py_print_single_arg): Use metadata
	style.
	* printcmd.c (do_one_display, print_variable_and_value): Use
	metadata style.
	* p-valprint.c (pascal_val_print)
	(pascal_object_print_value_fields): Use metadata style.
	* p-typeprint.c (pascal_type_print_base): Use metadata style.
	* mi/mi-out.h (class mi_ui_out) <do_field_fmt>: Add style
	parameter.
	* mi/mi-out.c (mi_ui_out::do_field_fmt): Update.
	* m2-valprint.c (m2_print_long_set): Use metadata style.
	* m2-typeprint.c (m2_print_type): Use metadata style.
	* infcmd.c (print_return_value_1): Use metadata style.
	* gnu-v3-abi.c (print_one_vtable): Use metadata style.
	* f-valprint.c (info_common_command_for_block): Use metadata
	style.
	* f-typeprint.c (f_type_print_base): Use metadata style.
	* expprint.c (print_subexp_standard): Use metadata style.
	* cp-valprint.c (cp_print_value_fields): Use metadata style.
	* cli/cli-style.h (class cli_style_option): Add constructor.
	(metadata_style): Declare.
	* cli/cli-style.c (metadata_style): New global.
	(_initialize_cli_style): Register metadata style.
	* cli-out.h (class cli_ui_out) <do_field_fmt>: Add style
	parameter.
	* cli-out.c (cli_ui_out::do_field_fmt): Update.
	* c-typeprint.c (c_type_print_base_struct_union)
	(c_type_print_base_1): Use metadata style.
	* breakpoint.c (watchpoint_value_print)
	(print_one_breakpoint_location): Use metadata style.
	* break-catch-syscall.c (print_one_catch_syscall): Use metadata
	style.
	* break-catch-sig.c (signal_catchpoint_print_one): Use metadata
	style.
	* ada-valprint.c (val_print_packed_array_elements, printstr)
	(print_field_values, ada_val_print_ref, ada_val_print): Use
	metadata style.
	* ada-typeprint.c (print_array_type, ada_print_type): Use metadata
	style.
	* ada-tasks.c (print_ada_task_info, info_task): Use metadata
	style.
	* ada-lang.c (user_select_syms): Use metadata style.

gdb/testsuite/ChangeLog
2019-10-01  Tom Tromey  <tom@tromey.com>

	* lib/gdb-utils.exp (style): Handle "metadata" argument.
	* gdb.base/style.exp: Add metadata style test.
2019-10-01 15:12:40 -06:00
Pedro Alves 6a831f06e1 Use new %p format suffixes in gdb
This changes various spots in gdb to use the new %p format suffixes.

gdb/ChangeLog
2019-10-01  Pedro Alves  <palves@redhat.com>
	    Tom Tromey  <tom@tromey.com>

	* symtab.c (print_symbol_info): Use %ps.
	(print_msymbol_info): Use %ps.
	* symfile.c (symbol_file_add_with_addrs): Use %ps.
	* printcmd.c (print_variable_and_value): Use %ps.
	* macrocmd.c (show_pp_source_pos): Use %ps.
	* infrun.c (print_exited_reason): Use ui_out::message.
	* breakpoint.c (watchpoint_check, print_one_breakpoint_location)
	(describe_other_breakpoints): Use ui_out::message and new
	formats.
	(say_where): Use new formats.
	(bkpt_print_it, tracepoint_print_one_detail): Use ui_out::message
	and new formats.
2019-10-01 15:12:38 -06: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
Tom Tromey 4e962e74e4 Handle biased types
In Ada, the programmer can request that a range type with a non-zero
base be stored in the minimal number of bits required for the range.
This is done by biasing the values; so, for example, a range of -7..-4
may be stored as two bits with a bias of -7.

This patch implements this for gdb.  It is done by adding a bias to
struct range_bounds and then adjusting a few spots to handle this.

The test case is written to use -fgnat-encodings=minimal, but a future
compiler patch will change the compiler to emit DW_AT_GNU_bias with
-fgnat-encodings=gdb.  It seemed good to get the gdb patch in first.

Tested on x86-64 Fedora 29; plus a variety of targets using AdaCore's
internal test suite.

gdb/ChangeLog
2019-09-03  Tom Tromey  <tromey@adacore.com>

	* ada-valprint.c (ada_val_print_num): Don't recurse for range
	types.
	(has_negatives): Unbias a range type bound.
	* dwarf2read.c (read_subrange_type): Handle DW_AT_GNU_bias.
	* gdbtypes.c (operator==): Handle new field.
	(create_range_type): Add "bias" parameter.
	(create_static_range_type, resolve_dynamic_range): Update.
	* gdbtypes.h (struct range_bounds) <bias>: New member.
	(create_range_type): Add bias parameter.
	* printcmd.c (print_scalar_formatted): Unbias range types.
	* value.c (unpack_long): Unbias range types.
	(pack_long): Bias range types.

gdb/testsuite/ChangeLog
2019-09-03  Tom Tromey  <tromey@adacore.com>

	* gdb.ada/bias.exp: New file.
	* gdb.ada/bias/bias.adb: New file.
	* gdb.ada/print_chars.exp: Add regression test.
	* gdb.ada/print_chars/foo.adb (My_Character): New type.
	(MC): New variable.
2019-09-03 10:20:40 -06:00
Tom Tromey f21c2bd7b7 Fix Fortran regression with variables in nested functions
Sergio pointed out that commit commit aa3b6533 ("Allow nested function
displays") regressed a few gdb.fortran tests.  I was able to reproduce
these failures with gcc head.

The bug is that some spots calling contained_in will in fact do the
wrong thing if nested functions are considered as contained.  In the
particular case of the Fortran regression, it was the call in
block_innermost_frame, being called from get_hosting_frame -- in this
case, the caller is specifically trying to avoid the nested case.

This patch fixes the problem by adding an "allow_nested" parameter to
contained_in, essentially reverting the change for most callers.

gdb/ChangeLog
2019-08-19  Tom Tromey  <tromey@adacore.com>

	* printcmd.c (do_one_display, info_display_command): Update.
	* block.h (contained_in): Return bool.  Add allow_nested
	parameter.
	* block.c (contained_in): Return bool.  Add allow_nested
	parameter.
2019-08-19 10:32:03 -06:00
Philippe Waroquiers 590042fc45 Make first and last lines of 'command help documentation' consistent.
With this patch, the help docs now respect 2 invariants:
  * The first line of a command help is terminated by a '.' character.
  * The last character of a command help is not a newline character.

Note that the changes for the last invariant were done by Tom, as part of :
 [PATCH] Remove trailing newlines from help text
 https://sourceware.org/ml/gdb-patches/2019-06/msg00050.html
but some occurrences have been re-introduced since then.

Some help docs had to be rephrased/restructured to respect the above
invariants.

Before this patch, print_doc_line was printing the first line
of a command help documentation, but stopping at the first '.'
or ',' character.

This was giving inconsistent results :
  * The first line of command helps was sometimes '.' terminated,
    sometimes not.
  * The first line of command helps was not always designed to be
    readable/understandable/unambiguous when stopping at the first
    '.' or ',' character.

This e.g. created the following inconsistencies/problems:
< catch exception -- Catch Ada exceptions
< catch handlers -- Catch Ada exceptions
< catch syscall -- Catch system calls by their names
< down-silently -- Same as the `down' command
while the new help is:
> catch exception -- Catch Ada exceptions, when raised.
> catch handlers -- Catch Ada exceptions, when handled.
> catch syscall -- Catch system calls by their names, groups and/or numbers.
> down-silently -- Same as the `down' command, but does not print anything.

Also, the command help doc should not be terminated by a newline
character, but this was not respected by all commands.
The cli-option -OPT framework re-introduced some occurences.
So, the -OPT build help framework was changed to not output newlines at the
end of %OPTIONS% replacement.

This patch changes the help documentations to ensure the 2 invariants
given above.

It implied to slightly rephrase or restructure some help docs.

Based on the above invariants, print_doc_line (called by
'apropos' and 'help' commands to print the first line of a command
help) now outputs the full first line of a command help.

This all results in a lot of small changes in the produced help docs.
There are less code changes than changes in the help docs, as a lot
of docs are produced by some code (e.g. the remote packet usage settings).

gdb/ChangeLog
2019-08-07  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* cli/cli-decode.h (print_doc_line): Add for_value_prefix argument.
	* cli/cli-decode.c (print_doc_line): Likewise.  It now prints
	the full first line, except when FOR_VALUE_PREFIX.  In this case,
	the trailing '.' is not output, and the first character is uppercased.
	(print_help_for_command): Update call to print_doc_line.
	(print_doc_of_command): Likewise.
	* cli/cli-setshow.c (deprecated_show_value_hack): Likewise.
	* cli/cli-option.c (append_indented_doc): Do not append newline.
	(build_help_option): Append newline after first appended_indented_doc
	only if a second call is done.
	(build_help): Append 2 new lines before each option, except the first
	one.
	* compile/compile.c (_initialize_compile): Add new lines after
	%OPTIONS%, when not at the end of the help.
	Change help doc or code
	producing the help doc to respect the invariants.
	* maint-test-options.c (_initialize_maint_test_options): Likewise.
	Also removed the new line after 'Options:', as all other commands
	do not put an empty line between 'Options:' and the first option.
	* printcmd.c (_initialize_printcmd): Likewise.
	* stack.c (_initialize_stack): Likewise.
	* interps.c (interpreter_exec_cmd): Fix "Usage:" line that was
	incorrectly telling COMMAND is optional.
	* ada-lang.c (_initialize_ada_language): Change help doc or code
	producing the help doc to respect the invariants.
	* ada-tasks.c (_initialize_ada_tasks): Likewise.
	* breakpoint.c (_initialize_breakpoint): Likewise.
	* cli/cli-cmds.c (_initialize_cli_cmds): Likewise.
	* cli/cli-logging.c (_initialize_cli_logging): Likewise.
	* cli/cli-setshow.c (_initialize_cli_setshow): Likewise.
	* cli/cli-style.c (cli_style_option::add_setshow_commands,
	_initialize_cli_style): Likewise.
	* corelow.c (core_target_info): Likewise.
	* dwarf-index-cache.c (_initialize_index_cache): Likewise.
	* dwarf2read.c (_initialize_dwarf2_read): Likewise.
	* filesystem.c (_initialize_filesystem): Likewise.
	* frame.c (_initialize_frame): Likewise.
	* gnu-nat.c (add_task_commands): Likewise.
	* infcall.c (_initialize_infcall): Likewise.
	* infcmd.c (_initialize_infcmd): Likewise.
	* interps.c (_initialize_interpreter): Likewise.
	* language.c (_initialize_language): Likewise.
	* linux-fork.c (_initialize_linux_fork): Likewise.
	* maint-test-settings.c (_initialize_maint_test_settings): Likewise.
	* maint.c (_initialize_maint_cmds): Likewise.
	* memattr.c (_initialize_mem): Likewise.
	* printcmd.c (_initialize_printcmd): Likewise.
	* python/lib/gdb/function/strfns.py (_MemEq, _StrLen, _StrEq,
	_RegEx): Likewise.
	* ravenscar-thread.c (_initialize_ravenscar): Likewise.
	* record-btrace.c (_initialize_record_btrace): Likewise.
	* record-full.c (_initialize_record_full): Likewise.
	* record.c (_initialize_record): Likewise.
	* regcache-dump.c (_initialize_regcache_dump): Likewise.
	* regcache.c (_initialize_regcache): Likewise.
	* remote.c (add_packet_config_cmd, init_remote_threadtests,
	_initialize_remote): Likewise.
	* ser-tcp.c (_initialize_ser_tcp): Likewise.
	* serial.c (_initialize_serial): Likewise.
	* skip.c (_initialize_step_skip): Likewise.
	* source.c (_initialize_source): Likewise.
	* stack.c (_initialize_stack): Likewise.
	* symfile.c (_initialize_symfile): Likewise.
	* symtab.c (_initialize_symtab): Likewise.
	* target-descriptions.c (_initialize_target_descriptions): Likewise.
	* top.c (init_main): Likewise.
	* tracefile-tfile.c (tfile_target_info): Likewise.
	* tracepoint.c (_initialize_tracepoint): Likewise.
	* tui/tui-win.c (_initialize_tui_win): Likewise.
	* utils.c (add_internal_problem_command): Likewise.
	* valprint.c (value_print_option_defs): Likewise.

gdb/testsuite/ChangeLog
2019-08-07  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* gdb.base/style.exp: Update tests for help doc new invariants.
	* gdb.base/help.exp: Likewise.
2019-08-07 00:04:33 +02:00
Tom Tromey 8abfcabcb4 Use _() in calls to build_help
Currently some code in gdb uses build_help with N_(), like:

  static const std::string compile_print_help
    = gdb::option::build_help (N_("\

I believe this is incorrect.  The N_ macro is used to mark text that
should end up in the message catalog, but which will be translated by
a later call to gettext.

However, in this case, there is no later call to gettext, so (if gdb
had translations), this text would remain untranslated.

Instead, I think using the ordinary _() macro is correct here.
Translators will have to know to preserve "%OPTIONS%" in the text --
but that seems both unavoidable and fine.

Tested by rebuilding as there's not much else to do.

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

	* compile/compile.c (_initialize_compile): Use _(), not N_().
	* thread.c (_initialize_thread): Use _(), not N_().
	* stack.c (_initialize_stack): Use _(), not N_().
	* printcmd.c (_initialize_printcmd): Use _(), not N_().
2019-08-05 07:36:28 -06:00
Kevin Buettner a1530dc731 Allow display of negative offsets in print_address_symbolic()
When examining addresses associated with blocks with non-contiguous
address ranges, it's not uncommon to see large positive offsets which,
for some address width, actually represent a smaller negative offset.
Here's an example taken from the test case (using the
dw2-ranges-func-lo-cold executable):

    (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

This commit, in conjuction with an earlier patch from this series, causes
cases like the above to be displayed like this (below) instead:

(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

Note that the address of foo_cold is now (due to another patch) being
displayed as <foo_cold> instead of <foo+BigOffset>.  The subsequent
lines are shown as negative offsets from foo.

Disassembly using the "disassemble" command is somewhat affected by
these changes:

Before:

(gdb) disassemble foo_cold
Dump of assembler code for function foo:
Address range 0x401120 to 0x40113b:
   0x0000000000401120 <+0>:	push   %rbp
   0x0000000000401121 <+1>:	mov    %rsp,%rbp
   0x0000000000401124 <+4>:	callq  0x401119 <bar>
   0x0000000000401129 <+9>:	mov    0x2ef1(%rip),%eax        # 0x404020 <e>
   0x000000000040112f <+15>:	test   %eax,%eax
   0x0000000000401131 <+17>:	je     0x401138 <foo+24>
   0x0000000000401133 <+19>:	callq  0x40110d <foo+4294967277>
   0x0000000000401138 <+24>:	nop
   0x0000000000401139 <+25>:	pop    %rbp
   0x000000000040113a <+26>:	retq
Address range 0x40110d to 0x401119:
   0x000000000040110d <+-19>:	push   %rbp
   0x000000000040110e <+-18>:	mov    %rsp,%rbp
   0x0000000000401111 <+-15>:	callq  0x401106 <baz>
   0x0000000000401116 <+-10>:	nop
   0x0000000000401117 <+-9>:	pop    %rbp
   0x0000000000401118 <+-8>:	retq
End of assembler dump.

After:

(gdb) disassemble foo_cold
Dump of assembler code for function foo:
Address range 0x401120 to 0x40113b:
   0x0000000000401120 <+0>:	push   %rbp
   0x0000000000401121 <+1>:	mov    %rsp,%rbp
   0x0000000000401124 <+4>:	callq  0x401119 <bar>
   0x0000000000401129 <+9>:	mov    0x2ef1(%rip),%eax        # 0x404020 <e>
   0x000000000040112f <+15>:	test   %eax,%eax
   0x0000000000401131 <+17>:	je     0x401138 <foo+24>
   0x0000000000401133 <+19>:	callq  0x40110d <foo_cold>
   0x0000000000401138 <+24>:	nop
   0x0000000000401139 <+25>:	pop    %rbp
   0x000000000040113a <+26>:	retq
Address range 0x40110d to 0x401119:
   0x000000000040110d <-19>:	push   %rbp
   0x000000000040110e <-18>:	mov    %rsp,%rbp
   0x0000000000401111 <-15>:	callq  0x401106 <baz>
   0x0000000000401116 <-10>:	nop
   0x0000000000401117 <-9>:	pop    %rbp
   0x0000000000401118 <-8>:	retq
End of assembler dump.

Note that negative offsets are now displayed without the leading "+".
Also, the callq to foo_cold is now displayed as such instead of a callq
to foo with a large positive offset.

gdb/ChangeLog:

	* printcmd.c (print_address_symbolic): Print negative offsets.
	(build_address_symbolic): Force signed arithmetic when computing
	offset.
2019-07-30 09:19:13 -07: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
Tom Tromey 268a13a5a3 Rename common to gdbsupport
This is the next patch in the ongoing series to move gdbsever to the
top level.

This patch just renames the "common" directory.  The idea is to do
this move in two parts: first rename the directory (this patch), then
move the directory to the top.  This approach makes the patches a bit
more tractable.

I chose the name "gdbsupport" for the directory.  However, as this
patch was largely written by sed, we could pick a new name without too
much difficulty.

Tested by the buildbot.

gdb/ChangeLog
2019-07-09  Tom Tromey  <tom@tromey.com>

	* contrib/ari/gdb_ari.sh: Change common to gdbsupport.
	* configure: Rebuild.
	* configure.ac: Change common to gdbsupport.
	* gdbsupport: Rename from common.
	* acinclude.m4: Change common to gdbsupport.
	* Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES)
	(HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to
	gdbsupport.
	* aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c,
	amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c,
	amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c,
	amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c,
	amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c,
	arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c,
	arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c,
	arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c,
	arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c,
	auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h,
	btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c,
	charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c,
	cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c,
	coff-pe-read.c, command.h, compile/compile-c-support.c,
	compile/compile-c.h, compile/compile-cplus-symbols.c,
	compile/compile-cplus-types.c, compile/compile-cplus.h,
	compile/compile-loc2c.c, compile/compile.c, completer.c,
	completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c,
	cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c,
	darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c,
	disasm.h, dtrace-probe.c, dwarf-index-cache.c,
	dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c,
	dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c,
	event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c,
	features/aarch64-core.c, features/aarch64-fpu.c,
	features/aarch64-pauth.c, features/aarch64-sve.c,
	features/i386/32bit-avx.c, features/i386/32bit-avx512.c,
	features/i386/32bit-core.c, features/i386/32bit-linux.c,
	features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c,
	features/i386/32bit-segments.c, features/i386/32bit-sse.c,
	features/i386/64bit-avx.c, features/i386/64bit-avx512.c,
	features/i386/64bit-core.c, features/i386/64bit-linux.c,
	features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c,
	features/i386/64bit-segments.c, features/i386/64bit-sse.c,
	features/i386/x32-core.c, features/riscv/32bit-cpu.c,
	features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c,
	features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c,
	features/riscv/64bit-fpu.c, features/tic6x-c6xp.c,
	features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h,
	findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h,
	gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c,
	gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c,
	go32-nat.c, guile/guile.c, guile/scm-ports.c,
	guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c,
	i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c,
	i386-linux-tdep.c, i386-tdep.c, i387-tdep.c,
	ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c,
	inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h,
	inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h,
	inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c,
	linux-tdep.c, linux-thread-db.c, location.c, machoread.c,
	macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h,
	mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c,
	mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h,
	minsyms.c, mips-linux-tdep.c, namespace.h,
	nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h,
	nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c,
	nat/amd64-linux-siginfo.c, nat/fork-inferior.c,
	nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c,
	nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c,
	nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h,
	nat/linux-waitpid.c, nat/mips-linux-watch.c,
	nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c,
	nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c,
	nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h,
	obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c,
	parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c,
	procfs.c, producer.c, progspace.h, psymtab.h,
	python/py-framefilter.c, python/py-inferior.c, python/py-ref.h,
	python/py-type.c, python/python.c, record-btrace.c, record-full.c,
	record.c, record.h, regcache-dump.c, regcache.c, regcache.h,
	remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c,
	riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c,
	selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c,
	ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c,
	source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c,
	stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h,
	symtab.c, symtab.h, target-descriptions.c, target-descriptions.h,
	target-memory.c, target.c, target.h, target/waitstatus.c,
	target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c,
	top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c,
	tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h,
	unittests/array-view-selftests.c,
	unittests/child-path-selftests.c, unittests/cli-utils-selftests.c,
	unittests/common-utils-selftests.c,
	unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c,
	unittests/format_pieces-selftests.c,
	unittests/function-view-selftests.c,
	unittests/lookup_name_info-selftests.c,
	unittests/memory-map-selftests.c, unittests/memrange-selftests.c,
	unittests/mkdir-recursive-selftests.c,
	unittests/observable-selftests.c,
	unittests/offset-type-selftests.c, unittests/optional-selftests.c,
	unittests/parse-connection-spec-selftests.c,
	unittests/ptid-selftests.c, unittests/rsp-low-selftests.c,
	unittests/scoped_fd-selftests.c,
	unittests/scoped_mmap-selftests.c,
	unittests/scoped_restore-selftests.c,
	unittests/string_view-selftests.c, unittests/style-selftests.c,
	unittests/tracepoint-selftests.c, unittests/unpack-selftests.c,
	unittests/utils-selftests.c, unittests/xml-utils-selftests.c,
	utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c,
	value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c,
	xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c,
	xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport.

gdb/gdbserver/ChangeLog
2019-07-09  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* configure.ac: Change common to gdbsupport.
	* acinclude.m4: Change common to gdbsupport.
	* Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS)
	(version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change
	common to gdbsupport.
	* ax.c, event-loop.c, fork-child.c, gdb_proc_service.h,
	gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c,
	inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c,
	linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c,
	linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c,
	linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h,
	nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c,
	server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h,
	thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change
	common to gdbsupport.
2019-07-09 07:45:38 -06:00
Philippe Waroquiers 1f6f6e21fa Ensure GDB printf command can print convenience var strings without a target.
Without this patch, GDB printf command calls malloc on the target,
writes the convenience var content to the target,
re-reads the content from the target, and then locally printf the string.

This implies inferior calls, and does not work when there is no running
inferior, or when the inferior is a core dump.

With this patch, printf command can printf string convenience variables
without inferior function calls.
Ada string convenience variables can also be printed.

gdb/ChangeLog
2019-07-08  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* NEWS: Mention that GDB printf and eval commands can now print
	C-style and Ada-style convenience var strings without
	calling the inferior.
	* printcmd.c (printf_c_string): Locally print GDB internal var
	instead of transiting via the inferior.
	(printf_wide_c_string): Likewise.

gdb/testsuite/ChangeLog
2019-07-08  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* gdb.base/printcmds.exp: Test printing C string and
	C wide string convenience vars without transiting via the inferior.
	Also make test names unique.
2019-07-08 23:31:54 +02: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 230d2906b9 Rename gdb exception types
This renames the gdb exception types.  The old types were only needed
due to the macros in common-exception.h that are now gone.

The intermediate layer of gdb_exception_RETURN_MASK_ALL did not seem
needed, so this patch removes it entirely.

gdb/ChangeLog
2019-04-08  Tom Tromey  <tom@tromey.com>

	* common/common-exceptions.h (gdb_exception_RETURN_MASK_ALL):
	Remove.
	(gdb_exception_error): Rename from
	gdb_exception_RETURN_MASK_ERROR.
	(gdb_exception_quit): Rename from gdb_exception_RETURN_MASK_QUIT.
	(gdb_quit_bad_alloc): Update.
	* aarch64-tdep.c: Update.
	* ada-lang.c: Update.
	* ada-typeprint.c: Update.
	* ada-valprint.c: Update.
	* amd64-tdep.c: Update.
	* arch-utils.c: Update.
	* break-catch-throw.c: Update.
	* breakpoint.c: Update.
	* btrace.c: Update.
	* c-varobj.c: Update.
	* cli/cli-cmds.c: Update.
	* cli/cli-interp.c: Update.
	* cli/cli-script.c: Update.
	* common/common-exceptions.c: Update.
	* common/new-op.c: Update.
	* common/selftest.c: Update.
	* compile/compile-c-symbols.c: Update.
	* compile/compile-cplus-symbols.c: Update.
	* compile/compile-object-load.c: Update.
	* compile/compile-object-run.c: Update.
	* completer.c: Update.
	* corelow.c: Update.
	* cp-abi.c: Update.
	* cp-support.c: Update.
	* cp-valprint.c: Update.
	* darwin-nat.c: Update.
	* disasm-selftests.c: Update.
	* dtrace-probe.c: Update.
	* dwarf-index-cache.c: Update.
	* dwarf-index-write.c: Update.
	* dwarf2-frame-tailcall.c: Update.
	* dwarf2-frame.c: Update.
	* dwarf2loc.c: Update.
	* dwarf2read.c: Update.
	* eval.c: Update.
	* event-loop.c: Update.
	* event-top.c: Update.
	* exec.c: Update.
	* f-valprint.c: Update.
	* fbsd-tdep.c: Update.
	* frame-unwind.c: Update.
	* frame.c: Update.
	* gdbtypes.c: Update.
	* gnu-v3-abi.c: Update.
	* guile/guile-internal.h: Update.
	* guile/scm-block.c: Update.
	* guile/scm-breakpoint.c: Update.
	* guile/scm-cmd.c: Update.
	* guile/scm-disasm.c: Update.
	* guile/scm-frame.c: Update.
	* guile/scm-lazy-string.c: Update.
	* guile/scm-math.c: Update.
	* guile/scm-param.c: Update.
	* guile/scm-ports.c: Update.
	* guile/scm-pretty-print.c: Update.
	* guile/scm-symbol.c: Update.
	* guile/scm-symtab.c: Update.
	* guile/scm-type.c: Update.
	* guile/scm-value.c: Update.
	* i386-linux-tdep.c: Update.
	* i386-tdep.c: Update.
	* inf-loop.c: Update.
	* infcall.c: Update.
	* infcmd.c: Update.
	* infrun.c: Update.
	* jit.c: Update.
	* language.c: Update.
	* linespec.c: Update.
	* linux-fork.c: Update.
	* linux-nat.c: Update.
	* linux-tdep.c: Update.
	* linux-thread-db.c: Update.
	* main.c: Update.
	* mi/mi-cmd-break.c: Update.
	* mi/mi-cmd-stack.c: Update.
	* mi/mi-interp.c: Update.
	* mi/mi-main.c: Update.
	* objc-lang.c: Update.
	* p-valprint.c: Update.
	* parse.c: Update.
	* ppc-linux-tdep.c: Update.
	* printcmd.c: Update.
	* python/py-arch.c: Update.
	* python/py-breakpoint.c: Update.
	* python/py-cmd.c: Update.
	* python/py-finishbreakpoint.c: Update.
	* python/py-frame.c: Update.
	* python/py-framefilter.c: Update.
	* python/py-gdb-readline.c: Update.
	* python/py-inferior.c: Update.
	* python/py-infthread.c: Update.
	* python/py-lazy-string.c: Update.
	* python/py-linetable.c: Update.
	* python/py-objfile.c: Update.
	* python/py-param.c: Update.
	* python/py-prettyprint.c: Update.
	* python/py-progspace.c: Update.
	* python/py-record-btrace.c: Update.
	* python/py-record.c: Update.
	* python/py-symbol.c: Update.
	* python/py-type.c: Update.
	* python/py-unwind.c: Update.
	* python/py-utils.c: Update.
	* python/py-value.c: Update.
	* python/python.c: Update.
	* record-btrace.c: Update.
	* record-full.c: Update.
	* remote-fileio.c: Update.
	* remote.c: Update.
	* riscv-tdep.c: Update.
	* rs6000-aix-tdep.c: Update.
	* rs6000-tdep.c: Update.
	* rust-exp.y: Update.
	* rust-lang.c: Update.
	* s390-tdep.c: Update.
	* selftest-arch.c: Update.
	* solib-dsbt.c: Update.
	* solib-frv.c: Update.
	* solib-spu.c: Update.
	* solib-svr4.c: Update.
	* solib.c: Update.
	* sparc64-linux-tdep.c: Update.
	* stack.c: Update.
	* symfile-mem.c: Update.
	* symmisc.c: Update.
	* target.c: Update.
	* thread.c: Update.
	* top.c: Update.
	* tracefile-tfile.c: Update.
	* tui/tui.c: Update.
	* typeprint.c: Update.
	* unittests/cli-utils-selftests.c: Update.
	* unittests/parse-connection-spec-selftests.c: Update.
	* valops.c: Update.
	* valprint.c: Update.
	* value.c: Update.
	* varobj.c: Update.
	* windows-nat.c: Update.
	* x86-linux-nat.c: Update.
	* xml-support.c: Update.

gdb/gdbserver/ChangeLog
2019-04-08  Tom Tromey  <tom@tromey.com>

	* gdbreplay.c: Update.
	* linux-low.c: Update.
	* server.c: Update.
2019-04-08 09:05:40 -06:00
Tom Tromey a70b814420 Rewrite TRY/CATCH
This rewrites gdb's TRY/CATCH to plain C++ try/catch.  The patch was
largely written by script, though one change (to a comment in
common-exceptions.h) was reverted by hand.

gdb/ChangeLog
2019-04-08  Tom Tromey  <tom@tromey.com>

	* xml-support.c: Use C++ exception handling.
	* x86-linux-nat.c: Use C++ exception handling.
	* windows-nat.c: Use C++ exception handling.
	* varobj.c: Use C++ exception handling.
	* value.c: Use C++ exception handling.
	* valprint.c: Use C++ exception handling.
	* valops.c: Use C++ exception handling.
	* unittests/parse-connection-spec-selftests.c: Use C++ exception
	handling.
	* unittests/cli-utils-selftests.c: Use C++ exception handling.
	* typeprint.c: Use C++ exception handling.
	* tui/tui.c: Use C++ exception handling.
	* tracefile-tfile.c: Use C++ exception handling.
	* top.c: Use C++ exception handling.
	* thread.c: Use C++ exception handling.
	* target.c: Use C++ exception handling.
	* symmisc.c: Use C++ exception handling.
	* symfile-mem.c: Use C++ exception handling.
	* stack.c: Use C++ exception handling.
	* sparc64-linux-tdep.c: Use C++ exception handling.
	* solib.c: Use C++ exception handling.
	* solib-svr4.c: Use C++ exception handling.
	* solib-spu.c: Use C++ exception handling.
	* solib-frv.c: Use C++ exception handling.
	* solib-dsbt.c: Use C++ exception handling.
	* selftest-arch.c: Use C++ exception handling.
	* s390-tdep.c: Use C++ exception handling.
	* rust-lang.c: Use C++ exception handling.
	* rust-exp.y: Use C++ exception handling.
	* rs6000-tdep.c: Use C++ exception handling.
	* rs6000-aix-tdep.c: Use C++ exception handling.
	* riscv-tdep.c: Use C++ exception handling.
	* remote.c: Use C++ exception handling.
	* remote-fileio.c: Use C++ exception handling.
	* record-full.c: Use C++ exception handling.
	* record-btrace.c: Use C++ exception handling.
	* python/python.c: Use C++ exception handling.
	* python/py-value.c: Use C++ exception handling.
	* python/py-utils.c: Use C++ exception handling.
	* python/py-unwind.c: Use C++ exception handling.
	* python/py-type.c: Use C++ exception handling.
	* python/py-symbol.c: Use C++ exception handling.
	* python/py-record.c: Use C++ exception handling.
	* python/py-record-btrace.c: Use C++ exception handling.
	* python/py-progspace.c: Use C++ exception handling.
	* python/py-prettyprint.c: Use C++ exception handling.
	* python/py-param.c: Use C++ exception handling.
	* python/py-objfile.c: Use C++ exception handling.
	* python/py-linetable.c: Use C++ exception handling.
	* python/py-lazy-string.c: Use C++ exception handling.
	* python/py-infthread.c: Use C++ exception handling.
	* python/py-inferior.c: Use C++ exception handling.
	* python/py-gdb-readline.c: Use C++ exception handling.
	* python/py-framefilter.c: Use C++ exception handling.
	* python/py-frame.c: Use C++ exception handling.
	* python/py-finishbreakpoint.c: Use C++ exception handling.
	* python/py-cmd.c: Use C++ exception handling.
	* python/py-breakpoint.c: Use C++ exception handling.
	* python/py-arch.c: Use C++ exception handling.
	* printcmd.c: Use C++ exception handling.
	* ppc-linux-tdep.c: Use C++ exception handling.
	* parse.c: Use C++ exception handling.
	* p-valprint.c: Use C++ exception handling.
	* objc-lang.c: Use C++ exception handling.
	* mi/mi-main.c: Use C++ exception handling.
	* mi/mi-interp.c: Use C++ exception handling.
	* mi/mi-cmd-stack.c: Use C++ exception handling.
	* mi/mi-cmd-break.c: Use C++ exception handling.
	* main.c: Use C++ exception handling.
	* linux-thread-db.c: Use C++ exception handling.
	* linux-tdep.c: Use C++ exception handling.
	* linux-nat.c: Use C++ exception handling.
	* linux-fork.c: Use C++ exception handling.
	* linespec.c: Use C++ exception handling.
	* language.c: Use C++ exception handling.
	* jit.c: Use C++ exception handling.
	* infrun.c: Use C++ exception handling.
	* infcmd.c: Use C++ exception handling.
	* infcall.c: Use C++ exception handling.
	* inf-loop.c: Use C++ exception handling.
	* i386-tdep.c: Use C++ exception handling.
	* i386-linux-tdep.c: Use C++ exception handling.
	* guile/scm-value.c: Use C++ exception handling.
	* guile/scm-type.c: Use C++ exception handling.
	* guile/scm-symtab.c: Use C++ exception handling.
	* guile/scm-symbol.c: Use C++ exception handling.
	* guile/scm-pretty-print.c: Use C++ exception handling.
	* guile/scm-ports.c: Use C++ exception handling.
	* guile/scm-param.c: Use C++ exception handling.
	* guile/scm-math.c: Use C++ exception handling.
	* guile/scm-lazy-string.c: Use C++ exception handling.
	* guile/scm-frame.c: Use C++ exception handling.
	* guile/scm-disasm.c: Use C++ exception handling.
	* guile/scm-cmd.c: Use C++ exception handling.
	* guile/scm-breakpoint.c: Use C++ exception handling.
	* guile/scm-block.c: Use C++ exception handling.
	* guile/guile-internal.h: Use C++ exception handling.
	* gnu-v3-abi.c: Use C++ exception handling.
	* gdbtypes.c: Use C++ exception handling.
	* frame.c: Use C++ exception handling.
	* frame-unwind.c: Use C++ exception handling.
	* fbsd-tdep.c: Use C++ exception handling.
	* f-valprint.c: Use C++ exception handling.
	* exec.c: Use C++ exception handling.
	* event-top.c: Use C++ exception handling.
	* event-loop.c: Use C++ exception handling.
	* eval.c: Use C++ exception handling.
	* dwarf2read.c: Use C++ exception handling.
	* dwarf2loc.c: Use C++ exception handling.
	* dwarf2-frame.c: Use C++ exception handling.
	* dwarf2-frame-tailcall.c: Use C++ exception handling.
	* dwarf-index-write.c: Use C++ exception handling.
	* dwarf-index-cache.c: Use C++ exception handling.
	* dtrace-probe.c: Use C++ exception handling.
	* disasm-selftests.c: Use C++ exception handling.
	* darwin-nat.c: Use C++ exception handling.
	* cp-valprint.c: Use C++ exception handling.
	* cp-support.c: Use C++ exception handling.
	* cp-abi.c: Use C++ exception handling.
	* corelow.c: Use C++ exception handling.
	* completer.c: Use C++ exception handling.
	* compile/compile-object-run.c: Use C++ exception handling.
	* compile/compile-object-load.c: Use C++ exception handling.
	* compile/compile-cplus-symbols.c: Use C++ exception handling.
	* compile/compile-c-symbols.c: Use C++ exception handling.
	* common/selftest.c: Use C++ exception handling.
	* common/new-op.c: Use C++ exception handling.
	* cli/cli-script.c: Use C++ exception handling.
	* cli/cli-interp.c: Use C++ exception handling.
	* cli/cli-cmds.c: Use C++ exception handling.
	* c-varobj.c: Use C++ exception handling.
	* btrace.c: Use C++ exception handling.
	* breakpoint.c: Use C++ exception handling.
	* break-catch-throw.c: Use C++ exception handling.
	* arch-utils.c: Use C++ exception handling.
	* amd64-tdep.c: Use C++ exception handling.
	* ada-valprint.c: Use C++ exception handling.
	* ada-typeprint.c: Use C++ exception handling.
	* ada-lang.c: Use C++ exception handling.
	* aarch64-tdep.c: Use C++ exception handling.

gdb/gdbserver/ChangeLog
2019-04-08  Tom Tromey  <tom@tromey.com>

	* server.c: Use C++ exception handling.
	* linux-low.c: Use C++ exception handling.
	* gdbreplay.c: Use C++ exception handling.
2019-04-08 09:05:39 -06:00
Tom Tromey 3d6e9d2336 Make exceptions use std::string and be self-managing
This changes the exception's "message" member to be a shared_ptr
wrapping a std::string.  This allows removing the stack of exception
messages, because now exceptions will self-destruct when needed.  This
also adds a noexcept copy constructor and operator= to gdb_exception,
plus a "what" method.

gdb/ChangeLog
2019-04-08  Tom Tromey  <tom@tromey.com>

	* xml-support.c (gdb_xml_parser::parse): Update.
	* x86-linux-nat.c (x86_linux_nat_target::enable_btrace): Update.
	* value.c (show_convenience): Update.
	* unittests/cli-utils-selftests.c (test_number_or_range_parser)
	(test_parse_flags_qcs): Update.
	* thread.c (thr_try_catch_cmd): Update.
	* target.c (target_translate_tls_address): Update.
	* stack.c (print_frame_arg, read_frame_local, read_frame_arg)
	(info_frame_command_core, frame_apply_command_count): Update.
	* rust-exp.y (rust_lex_exception_test): Update.
	* riscv-tdep.c (riscv_print_one_register_info): Update.
	* remote.c (remote_target::enable_btrace): Update.
	* record-btrace.c (record_btrace_enable_warn): Update.
	* python/py-utils.c (gdbpy_convert_exception): Update.
	* printcmd.c (do_one_display, print_variable_and_value): Update.
	* mi/mi-main.c (mi_print_exception): Update.
	* mi/mi-interp.c (mi_cmd_interpreter_exec): Use SCOPE_EXIT.
	* mi/mi-cmd-stack.c (list_arg_or_local): Update.
	* linux-nat.c (linux_nat_target::attach): Update.
	* linux-fork.c (class scoped_switch_fork_info): Update.
	* infrun.c (displaced_step_prepare): Update.
	* infcall.c (call_function_by_hand_dummy): Update.
	* guile/scm-exception.c (gdbscm_scm_from_gdb_exception): Update.
	* gnu-v3-abi.c (print_one_vtable): Update.
	* frame.c (get_prev_frame_always): Update.
	* f-valprint.c (info_common_command_for_block): Update.
	* exec.c (try_open_exec_file): Update.
	* exceptions.c (print_exception, exception_print)
	(exception_fprintf, exception_print_same): Update.
	* dwarf2-frame.c (dwarf2_build_frame_info): Update.
	* dwarf-index-cache.c (index_cache::store)
	(index_cache::lookup_gdb_index): Update.
	* darwin-nat.c (maybe_cache_shell): Update.
	* cp-valprint.c (cp_print_value_fields): Update.
	* compile/compile-cplus-symbols.c (gcc_cplus_convert_symbol)
	(gcc_cplus_symbol_address): Update.
	* compile/compile-c-symbols.c (gcc_convert_symbol)
	(gcc_symbol_address, generate_c_for_for_one_variable): Update.
	* common/selftest.c: Update.
	* common/common-exceptions.h (struct gdb_exception) <message>: Now
	a std::string.
	(exception_try_scope_entry, exception_try_scope_exit): Don't
	declare.
	(struct exception_try_scope): Remove.
	(TRY): Don't use exception_try_scope.
	(struct gdb_exception): Add constructor, operator=.
	<what>: New method.
	(struct gdb_exception_RETURN_MASK_ALL)
	(struct gdb_exception_RETURN_MASK_ERROR)
	(struct gdb_exception_RETURN_MASK_QUIT): Add constructor.
	(struct gdb_quit_bad_alloc): Update.
	* common/common-exceptions.c (exception_none): Change
	initializer.
	(struct catcher) <state, exception>: Initialize inline.
	<prev>: Remove member.
	(current_catcher): Remove.
	(catchers): New global.
	(exceptions_state_mc_init): Simplify.
	(catcher_pop): Remove.
	(exceptions_state_mc, exceptions_state_mc_catch): Update.
	(try_scope_depth, exception_try_scope_entry)
	(exception_try_scope_exit): Remove.
	(throw_exception_sjlj): Update.
	(exception_messages, exception_messages_size): Remove.
	(throw_it): Simplify.
	(gdb_exception_sliced_copy): Remove.
	(throw_exception_cxx): Update.
	* cli/cli-script.c (script_from_file): Update.
	* breakpoint.c (insert_bp_location, update_breakpoint_locations):
	Update.
	* ada-valprint.c (ada_val_print): Update.
	* ada-lang.c (ada_to_fixed_type_1, ada_exception_name_addr)
	(create_excep_cond_exprs): Update.

gdb/gdbserver/ChangeLog
2019-04-08  Tom Tromey  <tom@tromey.com>

	* server.c (handle_btrace_general_set, handle_qxfer_btrace)
	(handle_qxfer_btrace_conf, detach_or_kill_for_exit_cleanup)
	(captured_main, main): Update.
	* gdbreplay.c (main): Update.
2019-04-08 09:05:38 -06:00
Tom Tromey 699bd4cfa8 Move innermost_block_tracker global to parse_state
This changes the parsing API so that callers that are interested in
tracking the innermost block must instantiate an
innermost_block_tracker and pass it in.  Then, a pointer to this
object is stored in the parser_state.

2019-04-04  Tom Tromey  <tom@tromey.com>

	* varobj.c (varobj_create): Update.
	* rust-exp.y (struct rust_parser) <update_innermost_block,
	lookup_symbol>: New methods.
	(rust_parser::update_innermost_block, rust_parser::lookup_symbol):
	Rename.
	(rust_parser::rust_lookup_type)
	(rust_parser::convert_ast_to_expression, rust_lex_tests): Update.
	* printcmd.c (display_command, do_one_display): Update.
	* parser-defs.h (struct parser_state) <parser_state>: Add
	"tracker" parameter.
	(block_tracker): New member.
	(class innermost_block_tracker) <innermost_block_tracker>: Add
	"types" parameter.
	<reset>: Remove method.
	(innermost_block): Don't declare.
	(null_post_parser): Update.
	* parse.c (innermost_block): Remove global.
	(write_dollar_variable): Update.
	(parse_exp_1, parse_exp_in_context): Add "tracker" parameter.
	Remove "tracker_types" parameter.
	(parse_expression): Add "tracker" parameter.
	(parse_expression_for_completion): Update.
	(null_post_parser): Add "tracker" parameter.
	* p-exp.y: Update rules.
	* m2-exp.y: Update rules.
	* language.h (struct language_defn) <la_post_parser>: Add
	"tracker" parameter.
	* go-exp.y: Update rules.
	* f-exp.y: Update rules.
	* expression.h (parse_expression, parse_exp_1): Add "tracker"
	parameter.
	* d-exp.y: Update rules.
	* c-exp.y: Update rules.
	* breakpoint.c (set_breakpoint_condition): Create an
	innermost_block_tracker.
	(watch_command_1): Likewise.
	* ada-lang.c (resolve): Add "tracker" parameter.
	(resolve_subexp): Likewise.
	* ada-exp.y (write_var_from_sym): Update.
2019-04-04 19:55:11 -06:00
Tom Tromey 188e1fa9ac Add usage for commands in printcmd.c
I noticed that the help for "info addr" did not include a "usage"
line; and when adding it I went through and fixed a few minor issues
in printcmd.c:

* Added usage lines to all commands
* Updated the help text for some commands
* Changed some help to use upper case metasyntactic variables
* Removed some dead code

Regression tested on x86-64 Fedora 29.

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

	* printcmd.c (_initialize_printcmd): Add usage lines.  Update some
	help text.  Remove dead code.

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

	* gdb.base/help.exp: Tighten apropos regexp.
2019-03-29 14:05:30 -06:00
Tom Tromey 7ad417dd21 Have parser reset the innermost block tracker
I ran across a comment in symfile.c today:

  /* Clear globals which might have pointed into a removed objfile.
     FIXME: It's not clear which of these are supposed to persist
     between expressions and which ought to be reset each time.  */

It seems to me that this can be clarified: the parser entry points
ought to reset the innermost block tracker (and the expression context
block), and these should not be considered valid for code to use at
arbitrary times -- only immediately after an expression has been
parsed.

This patch implements this idea.  This could be further improved by
removing the parser globals and changing the parser functions to
return this information, but I have not done this.

Tested by the buildbot.

gdb/ChangeLog
2019-03-23  Tom Tromey  <tom@tromey.com>

	* varobj.c (varobj_create): Update.
	* symfile.c (clear_symtab_users): Don't reset innermost_block.
	* printcmd.c (display_command, do_one_display): Don't reset
	innermost_block.
	* parser-defs.h (enum innermost_block_tracker_type): Move to
	expression.h.
	(innermost_block): Update comment.
	* parse.c (parse_exp_1): Add tracker_types parameter.
	(parse_exp_in_context): Rename from parse_exp_in_context_1.  Add
	tracker_types parameter.  Reset innermost_block.
	(parse_exp_in_context): Remove.
	(parse_expression_for_completion): Update.
	* objfiles.c (~objfile): Don't reset expression_context_block or
	innermost_block.
	* expression.h (enum innermost_block_tracker_type): Move from
	parser-defs.h.
	(parse_exp_1): Add tracker_types parameter.
	* breakpoint.c (set_breakpoint_condition, watch_command_1): Don't
	reset innermost_block.
2019-03-23 10:59:10 -06:00
Tom Tromey c119e04082 Remove excess calls to gdb_flush
A customer noticed some mildly odd MI output, where CLI output was
split into multiple MI strings at unusual boundaries, like this:

    ~"$1 = (b => true"
    ~", p => 0x407260"

This is technically correct according to the MI spec, but still
unusual, in that there's no particular reason for the string to be
split where it is.

I tracked this down to a call to gdb_flush in generic_val_print.
Then, I went through all calls to gdb_flush and removed the ones I
thought were superfluous.  In particular:

* Any call in the value-printing code;
* Likewise the type-printing code (just a single call); and
* Any call that immediately followed a printf that obviously
  ended with a newline, my belief being that gdb's standard output
  streams are line buffered (by inheriting the behavior from stdio)

Regression tested on x86-64 Fedora 29.

I didn't add a new test case.  I tend to think we don't necessarily
want to specify this behavior in the tests.  Let me know what you
think of this.

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

	* windows-nat.c (windows_nat_target::attach)
	(windows_nat_target::detach): Don't call gdb_flush.
	* valprint.c (generic_val_print, val_print, val_print_string):
	Don't call gdb_flush.
	* utils.c (defaulted_query): Don't call gdb_flush.
	* typeprint.c (print_type_scalar): Don't call gdb_flush.
	* target.c (target_announce_detach): Don't call gdb_flush.
	* sparc64-tdep.c (adi_print_versions): Don't call gdb_flush.
	* remote.c (extended_remote_target::attach): Don't call
	gdb_flush.
	* procfs.c (procfs_target::detach): Don't call gdb_flush.
	* printcmd.c (do_examine): Don't call gdb_flush.
	(info_display_command): Don't call gdb_flush.
	* p-valprint.c (pascal_val_print): Don't call gdb_flush.
	* nto-procfs.c (nto_procfs_target::attach): Don't call gdb_flush.
	* memattr.c (info_mem_command): Don't call gdb_flush.
	* mdebugread.c (mdebug_build_psymtabs): Don't call gdb_flush.
	* m2-valprint.c (m2_val_print): Don't call gdb_flush.
	* infrun.c (follow_exec, handle_command): Don't call gdb_flush.
	* inf-ptrace.c (inf_ptrace_target::attach): Don't call gdb_flush.
	* hppa-tdep.c (unwind_command): Don't call gdb_flush.
	* gnu-nat.c (gnu_nat_target::attach): Don't call gdb_flush.
	(gnu_nat_target::detach): Don't call gdb_flush.
	* f-valprint.c (f_val_print): Don't call gdb_flush.
	* darwin-nat.c (darwin_nat_target::attach): Don't call gdb_flush.
	* cli/cli-script.c (read_command_lines): Don't call gdb_flush.
	* cli/cli-cmds.c (shell_escape, print_disassembly): Don't call
	gdb_flush.
	* c-valprint.c (c_val_print): Don't call gdb_flush.
	* ada-valprint.c (ada_print_scalar): Don't call gdb_flush.
2019-03-05 08:55:51 -07:00
Tom Tromey 0747795c08 Normalize includes to use common/
This changes all includes to use the form "common/filename.h" rather
than just "filename.h".  This was written by a script.

gdb/ChangeLog
2019-01-25  Tom Tromey  <tom@tromey.com>

	* xtensa-linux-nat.c: Fix common/ includes.
	* xml-support.h: Fix common/ includes.
	* xml-support.c: Fix common/ includes.
	* x86-linux-nat.c: Fix common/ includes.
	* windows-nat.c: Fix common/ includes.
	* varobj.h: Fix common/ includes.
	* varobj.c: Fix common/ includes.
	* value.c: Fix common/ includes.
	* valops.c: Fix common/ includes.
	* utils.c: Fix common/ includes.
	* unittests/xml-utils-selftests.c: Fix common/ includes.
	* unittests/utils-selftests.c: Fix common/ includes.
	* unittests/unpack-selftests.c: Fix common/ includes.
	* unittests/tracepoint-selftests.c: Fix common/ includes.
	* unittests/style-selftests.c: Fix common/ includes.
	* unittests/string_view-selftests.c: Fix common/ includes.
	* unittests/scoped_restore-selftests.c: Fix common/ includes.
	* unittests/scoped_mmap-selftests.c: Fix common/ includes.
	* unittests/scoped_fd-selftests.c: Fix common/ includes.
	* unittests/rsp-low-selftests.c: Fix common/ includes.
	* unittests/parse-connection-spec-selftests.c: Fix common/
	includes.
	* unittests/optional-selftests.c: Fix common/ includes.
	* unittests/offset-type-selftests.c: Fix common/ includes.
	* unittests/observable-selftests.c: Fix common/ includes.
	* unittests/mkdir-recursive-selftests.c: Fix common/ includes.
	* unittests/memrange-selftests.c: Fix common/ includes.
	* unittests/memory-map-selftests.c: Fix common/ includes.
	* unittests/lookup_name_info-selftests.c: Fix common/ includes.
	* unittests/function-view-selftests.c: Fix common/ includes.
	* unittests/environ-selftests.c: Fix common/ includes.
	* unittests/copy_bitwise-selftests.c: Fix common/ includes.
	* unittests/common-utils-selftests.c: Fix common/ includes.
	* unittests/cli-utils-selftests.c: Fix common/ includes.
	* unittests/array-view-selftests.c: Fix common/ includes.
	* ui-file.c: Fix common/ includes.
	* tui/tui-io.c: Fix common/ includes.
	* tracepoint.h: Fix common/ includes.
	* tracepoint.c: Fix common/ includes.
	* tracefile-tfile.c: Fix common/ includes.
	* top.h: Fix common/ includes.
	* top.c: Fix common/ includes.
	* thread.c: Fix common/ includes.
	* target/waitstatus.h: Fix common/ includes.
	* target/waitstatus.c: Fix common/ includes.
	* target.h: Fix common/ includes.
	* target.c: Fix common/ includes.
	* target-memory.c: Fix common/ includes.
	* target-descriptions.c: Fix common/ includes.
	* symtab.h: Fix common/ includes.
	* symfile.c: Fix common/ includes.
	* stap-probe.c: Fix common/ includes.
	* spu-linux-nat.c: Fix common/ includes.
	* sparc-nat.c: Fix common/ includes.
	* source.c: Fix common/ includes.
	* solib.c: Fix common/ includes.
	* solib-target.c: Fix common/ includes.
	* ser-unix.c: Fix common/ includes.
	* ser-tcp.c: Fix common/ includes.
	* ser-pipe.c: Fix common/ includes.
	* ser-base.c: Fix common/ includes.
	* selftest-arch.c: Fix common/ includes.
	* s12z-tdep.c: Fix common/ includes.
	* rust-exp.y: Fix common/ includes.
	* rs6000-aix-tdep.c: Fix common/ includes.
	* riscv-tdep.c: Fix common/ includes.
	* remote.c: Fix common/ includes.
	* remote-notif.h: Fix common/ includes.
	* remote-fileio.h: Fix common/ includes.
	* remote-fileio.c: Fix common/ includes.
	* regcache.h: Fix common/ includes.
	* regcache.c: Fix common/ includes.
	* record-btrace.c: Fix common/ includes.
	* python/python.c: Fix common/ includes.
	* python/py-type.c: Fix common/ includes.
	* python/py-inferior.c: Fix common/ includes.
	* progspace.h: Fix common/ includes.
	* producer.c: Fix common/ includes.
	* procfs.c: Fix common/ includes.
	* proc-api.c: Fix common/ includes.
	* printcmd.c: Fix common/ includes.
	* ppc-linux-nat.c: Fix common/ includes.
	* parser-defs.h: Fix common/ includes.
	* osdata.c: Fix common/ includes.
	* obsd-nat.c: Fix common/ includes.
	* nat/x86-linux.c: Fix common/ includes.
	* nat/x86-linux-dregs.c: Fix common/ includes.
	* nat/x86-dregs.h: Fix common/ includes.
	* nat/x86-dregs.c: Fix common/ includes.
	* nat/ppc-linux.c: Fix common/ includes.
	* nat/mips-linux-watch.h: Fix common/ includes.
	* nat/mips-linux-watch.c: Fix common/ includes.
	* nat/linux-waitpid.c: Fix common/ includes.
	* nat/linux-ptrace.h: Fix common/ includes.
	* nat/linux-ptrace.c: Fix common/ includes.
	* nat/linux-procfs.c: Fix common/ includes.
	* nat/linux-personality.c: Fix common/ includes.
	* nat/linux-osdata.c: Fix common/ includes.
	* nat/linux-namespaces.c: Fix common/ includes.
	* nat/linux-btrace.h: Fix common/ includes.
	* nat/linux-btrace.c: Fix common/ includes.
	* nat/fork-inferior.c: Fix common/ includes.
	* nat/amd64-linux-siginfo.c: Fix common/ includes.
	* nat/aarch64-sve-linux-ptrace.c: Fix common/ includes.
	* nat/aarch64-linux.c: Fix common/ includes.
	* nat/aarch64-linux-hw-point.h: Fix common/ includes.
	* nat/aarch64-linux-hw-point.c: Fix common/ includes.
	* namespace.h: Fix common/ includes.
	* mips-linux-tdep.c: Fix common/ includes.
	* minsyms.c: Fix common/ includes.
	* mi/mi-parse.h: Fix common/ includes.
	* mi/mi-main.c: Fix common/ includes.
	* mi/mi-cmd-env.c: Fix common/ includes.
	* memrange.h: Fix common/ includes.
	* memattr.c: Fix common/ includes.
	* maint.h: Fix common/ includes.
	* maint.c: Fix common/ includes.
	* main.c: Fix common/ includes.
	* machoread.c: Fix common/ includes.
	* location.c: Fix common/ includes.
	* linux-thread-db.c: Fix common/ includes.
	* linux-nat.c: Fix common/ includes.
	* linux-fork.c: Fix common/ includes.
	* inline-frame.c: Fix common/ includes.
	* infrun.c: Fix common/ includes.
	* inflow.c: Fix common/ includes.
	* inferior.h: Fix common/ includes.
	* inferior.c: Fix common/ includes.
	* infcmd.c: Fix common/ includes.
	* inf-ptrace.c: Fix common/ includes.
	* inf-child.c: Fix common/ includes.
	* ia64-linux-nat.c: Fix common/ includes.
	* i387-tdep.c: Fix common/ includes.
	* i386-tdep.c: Fix common/ includes.
	* i386-linux-tdep.c: Fix common/ includes.
	* i386-linux-nat.c: Fix common/ includes.
	* i386-go32-tdep.c: Fix common/ includes.
	* i386-fbsd-tdep.c: Fix common/ includes.
	* i386-fbsd-nat.c: Fix common/ includes.
	* guile/scm-type.c: Fix common/ includes.
	* guile/guile.c: Fix common/ includes.
	* go32-nat.c: Fix common/ includes.
	* gnu-nat.c: Fix common/ includes.
	* gdbthread.h: Fix common/ includes.
	* gdbarch-selftests.c: Fix common/ includes.
	* gdb_usleep.c: Fix common/ includes.
	* gdb_select.h: Fix common/ includes.
	* gdb_bfd.c: Fix common/ includes.
	* gcore.c: Fix common/ includes.
	* fork-child.c: Fix common/ includes.
	* findvar.c: Fix common/ includes.
	* fbsd-nat.c: Fix common/ includes.
	* event-top.c: Fix common/ includes.
	* event-loop.c: Fix common/ includes.
	* dwarf2read.c: Fix common/ includes.
	* dwarf2loc.c: Fix common/ includes.
	* dwarf2-frame.c: Fix common/ includes.
	* dwarf-index-cache.c: Fix common/ includes.
	* dtrace-probe.c: Fix common/ includes.
	* disasm-selftests.c: Fix common/ includes.
	* defs.h: Fix common/ includes.
	* csky-tdep.c: Fix common/ includes.
	* cp-valprint.c: Fix common/ includes.
	* cp-support.h: Fix common/ includes.
	* cp-support.c: Fix common/ includes.
	* corelow.c: Fix common/ includes.
	* completer.h: Fix common/ includes.
	* completer.c: Fix common/ includes.
	* compile/compile.c: Fix common/ includes.
	* compile/compile-loc2c.c: Fix common/ includes.
	* compile/compile-cplus-types.c: Fix common/ includes.
	* compile/compile-cplus-symbols.c: Fix common/ includes.
	* command.h: Fix common/ includes.
	* cli/cli-dump.c: Fix common/ includes.
	* cli/cli-cmds.c: Fix common/ includes.
	* charset.c: Fix common/ includes.
	* build-id.c: Fix common/ includes.
	* btrace.h: Fix common/ includes.
	* btrace.c: Fix common/ includes.
	* breakpoint.h: Fix common/ includes.
	* breakpoint.c: Fix common/ includes.
	* ax.h:
	(enum agent_op): Fix common/ includes.
	* ax-general.c (struct aop_map): Fix common/ includes.
	* ax-gdb.c: Fix common/ includes.
	* auxv.c: Fix common/ includes.
	* auto-load.c: Fix common/ includes.
	* arm-tdep.c: Fix common/ includes.
	* arch/riscv.c: Fix common/ includes.
	* arch/ppc-linux-common.c: Fix common/ includes.
	* arch/i386.c: Fix common/ includes.
	* arch/arm.c: Fix common/ includes.
	* arch/arm-linux.c: Fix common/ includes.
	* arch/arm-get-next-pcs.c: Fix common/ includes.
	* arch/amd64.c: Fix common/ includes.
	* arch/aarch64.c: Fix common/ includes.
	* arch/aarch64-insn.c: Fix common/ includes.
	* arch-utils.c: Fix common/ includes.
	* amd64-windows-tdep.c: Fix common/ includes.
	* amd64-tdep.c: Fix common/ includes.
	* amd64-sol2-tdep.c: Fix common/ includes.
	* amd64-obsd-tdep.c: Fix common/ includes.
	* amd64-nbsd-tdep.c: Fix common/ includes.
	* amd64-linux-tdep.c: Fix common/ includes.
	* amd64-linux-nat.c: Fix common/ includes.
	* amd64-fbsd-tdep.c: Fix common/ includes.
	* amd64-fbsd-nat.c: Fix common/ includes.
	* amd64-dicos-tdep.c: Fix common/ includes.
	* amd64-darwin-tdep.c: Fix common/ includes.
	* agent.c: Fix common/ includes.
	* ada-lang.h: Fix common/ includes.
	* ada-lang.c: Fix common/ includes.
	* aarch64-tdep.c: Fix common/ includes.

gdb/gdbserver/ChangeLog
2019-01-25  Tom Tromey  <tom@tromey.com>

	* win32-low.c: Fix common/ includes.
	* win32-i386-low.c: Fix common/ includes.
	* tracepoint.c: Fix common/ includes.
	* thread-db.c: Fix common/ includes.
	* target.h: Fix common/ includes.
	* symbol.c: Fix common/ includes.
	* spu-low.c: Fix common/ includes.
	* server.h: Fix common/ includes.
	* server.c: Fix common/ includes.
	* remote-utils.c: Fix common/ includes.
	* regcache.h: Fix common/ includes.
	* regcache.c: Fix common/ includes.
	* nto-x86-low.c: Fix common/ includes.
	* notif.h: Fix common/ includes.
	* mem-break.h: Fix common/ includes.
	* lynx-low.c: Fix common/ includes.
	* lynx-i386-low.c: Fix common/ includes.
	* linux-x86-tdesc-selftest.c: Fix common/ includes.
	* linux-x86-low.c: Fix common/ includes.
	* linux-low.c: Fix common/ includes.
	* inferiors.h: Fix common/ includes.
	* i387-fp.c: Fix common/ includes.
	* hostio.c: Fix common/ includes.
	* hostio-errno.c: Fix common/ includes.
	* gdbthread.h: Fix common/ includes.
	* gdbreplay.c: Fix common/ includes.
	* fork-child.c: Fix common/ includes.
	* event-loop.c: Fix common/ includes.
	* ax.c:
	(enum gdb_agent_op): Fix common/ includes.
2019-01-25 15:28:16 -07:00
Tom Tromey be6d4f74c7 Remove duplicate or commented-out #includes
I wrote a little script to detect duplicate or commented-out #includes
and ran it on gdb.  This patch is the result.  Tested by rebuilding.

gdb/ChangeLog
2019-01-21  Tom Tromey  <tom@tromey.com>

	* ui-out.c: Fix includes.
	* tui/tui-source.c: Fix includes.
	* target.c: Fix includes.
	* remote.c: Fix includes.
	* regcache.c: Fix includes.
	* python/py-block.c: Fix includes.
	* printcmd.c: Fix includes.
	* or1k-tdep.c: Fix includes.
	* mi/mi-main.c: Fix includes.
	* m32r-tdep.c: Fix includes.
	* csky-tdep.c: Fix includes.
	* compile/compile-cplus-types.c: Fix includes.
	* cli/cli-interp.c: Fix includes.

gdb/gdbserver/ChangeLog
2019-01-21  Tom Tromey  <tom@tromey.com>

	* tracepoint.c: Fix includes.
	* remote-utils.c: Fix includes.
	* linux-x86-low.c: Fix includes.

gdb/stubs/ChangeLog
2019-01-21  Tom Tromey  <tom@tromey.com>

	* ia64vms-stub.c: Fix includes.
2019-01-21 11:14:07 -07:00
Tom Tromey 2030c07971 Change all_objfiles adapter to be a method on program_space
This changes the all_objfiles range adapter to be a method on the
program space, and fixes up all the users.

gdb/ChangeLog
2019-01-17  Tom Tromey  <tom@tromey.com>

	* progspace.h (program_space) <objfiles_range>: New typedef.
	<objfiles>: New method.
	<objfiles_head>: Rename from objfiles.
	(object_files): Update.
	* guile/scm-progspace.c (gdbscm_progspace_objfiles): Update.
	* guile/scm-pretty-print.c
	(ppscm_find_pretty_printer_from_objfiles): Update.
	* guile/scm-objfile.c (gdbscm_objfiles): Update.
	* python/py-xmethods.c (gdbpy_get_matching_xmethod_workers):
	Update.
	* python/py-progspace.c (pspy_get_objfiles): Update.
	* python/py-prettyprint.c (find_pretty_printer_from_objfiles):
	Update.
	* python/py-objfile.c (objfpy_lookup_objfile_by_name)
	(objfpy_lookup_objfile_by_build_id): Update.
	* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Update.
	* windows-tdep.c (windows_iterate_over_objfiles_in_search_order):
	Update.
	* symtab.c (iterate_over_symtabs, matching_obj_sections)
	(expand_symtab_containing_pc, lookup_objfile_from_block)
	(lookup_static_symbol, basic_lookup_transparent_type)
	(find_pc_sect_compunit_symtab, find_symbol_at_address)
	(find_line_symtab, info_sources_command)
	(default_collect_symbol_completion_matches_break_on)
	(make_source_files_completion_list, find_main_name): Update.
	* symmisc.c (print_symbol_bcache_statistics)
	(print_objfile_statistics, maintenance_print_symbols)
	(maintenance_print_msymbols, maintenance_print_objfiles)
	(maintenance_info_symtabs, maintenance_check_symtabs)
	(maintenance_expand_symtabs, maintenance_info_line_tables):
	Update.
	* symfile.c (remove_symbol_file_command, overlay_invalidate_all)
	(find_pc_overlay, find_pc_mapped_section, list_overlays_command)
	(map_overlay_command, unmap_overlay_command)
	(simple_overlay_update, expand_symtabs_matching)
	(map_symbol_filenames): Update.
	* symfile-debug.c (set_debug_symfile): Update.
	* spu-tdep.c (spu_overlay_update, spu_objfile_from_frame):
	Update.
	* source.c (select_source_symtab, forget_cached_source_info):
	Update.
	* solib.c (solib_read_symbols): Update.
	* solib-spu.c (append_ocl_sos): Update.
	* psymtab.c (maintenance_print_psymbols)
	(maintenance_info_psymtabs, maintenance_check_psymtabs): Update.
	* probe.c (parse_probes_in_pspace, find_probe_by_pc): Update.
	* printcmd.c (info_symbol_command): Update.
	* ppc-linux-tdep.c (ppc_linux_spe_context_inferior_created):
	Update.
	* objfiles.h (class all_objfiles): Remove.
	* objfiles.c (have_partial_symbols, have_full_symbols)
	(have_minimal_symbols, qsort_cmp, update_section_map)
	(shared_objfile_contains_address_p)
	(default_iterate_over_objfiles_in_search_order): Update.
	* objc-lang.c (info_selectors_command, info_classes_command)
	(find_methods): Update.
	* minsyms.c (find_solib_trampoline_target): Update.
	* maint.c (maintenance_info_sections)
	(maintenance_translate_address, count_symtabs_and_blocks):
	Update.
	* main.c (captured_main_1): Update.
	* linux-thread-db.c (try_thread_db_load_from_pdir)
	(has_libpthread): Update.
	* linespec.c (iterate_over_all_matching_symtabs)
	(search_minsyms_for_name): Update.
	* jit.c (jit_find_objf_with_entry_addr): Update.
	* hppa-tdep.c (find_unwind_entry)
	(hppa_lookup_stub_minimal_symbol): Update.
	* gcore.c (gcore_create_callback, objfile_find_memory_regions):
	Update.
	* elfread.c (elf_gnu_ifunc_resolve_by_cache)
	(elf_gnu_ifunc_resolve_by_got): Update.
	* dwarf2-frame.c (dwarf2_frame_find_fde): Update.
	* dwarf-index-write.c (save_gdb_index_command): Update.
	* cp-support.c (add_symbol_overload_list_qualified): Update.
	* breakpoint.c (create_overlay_event_breakpoint)
	(create_longjmp_master_breakpoint)
	(create_std_terminate_master_breakpoint)
	(create_exception_master_breakpoint): Update.
	* blockframe.c (find_pc_partial_function): Update.
	* ada-lang.c (ada_lookup_simple_minsym, add_nonlocal_symbols)
	(ada_collect_symbol_completion_matches)
	(ada_add_global_exceptions): Update.
2019-01-17 15:34:37 -07:00
Tom Tromey 3b9d3ac236 Remove ALL_OBJSECTIONS
This removes the ALL_OBJSECTIONS macro, replacing its uses with ranged
for loops.

The special code in this macro for noticing a "break" from the inner
loop was only needed in a single place; so rather than try to
replicate this, I've simply replaced that use with a "goto".

gdb/ChangeLog
2019-01-09  Tom Tromey  <tom@tromey.com>

	* symfile.c (overlay_invalidate_all, find_pc_overlay)
	(find_pc_mapped_section, list_overlays_command)
	(map_overlay_command, unmap_overlay_command)
	(simple_overlay_update): Use all_objfiles.
	* spu-tdep.c (spu_overlay_update): Use all_objfiles.
	* printcmd.c (info_symbol_command): Use all_objfiles.
	* objfiles.h (ALL_OBJSECTIONS): Remove.
	* maint.c (maintenance_translate_address): Use all_objfiles.
	* gcore.c (gcore_create_callback): Use all_objfiles.
	(objfile_find_memory_regions): Likewise.
2019-01-09 18:28:15 -07: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 35fb8261b9 Style addresses
This changes gdb to style addresses.

gdb/ChangeLog
2018-12-28  Tom Tromey  <tom@tromey.com>

	* ui-out.h (enum class ui_out_style_kind) <ADDRESS>: New
	constant.
	* ui-out.c (ui_out::field_core_addr): Add styling.
	* stack.c (print_frame): Add styling.
	* printcmd.c (print_address): Add styling.
	(print_address_demangle, info_address_command): Likewise.
	* cli/cli-style.h (address_style): Declare.
	* cli/cli-style.c (address_style): New global.
	(_initialize_cli_style): Register new commands.
	* cli-out.c (cli_ui_out::do_field_string): Update.

gdb/testsuite/ChangeLog
2018-12-28  Tom Tromey  <tom@tromey.com>

	* gdb.base/style.exp: Update test to check for address styling.
2018-12-28 12:49:52 -07:00
Tom Tromey af79b68d7f Style print_address_symbolic
print_address_symbolic does not use ui-out, so it did not style
function names.  This patch changes it to use the low-level style code
directly.

gdb/ChangeLog
2018-12-28  Tom Tromey  <tom@tromey.com>

	* printcmd.c (print_address_symbolic): Style function name.

gdb/testsuite/ChangeLog
2018-12-28  Tom Tromey  <tom@tromey.com>

	* gdb.base/style.exp: Add test for print_address_symbolic.
2018-12-28 12:49:51 -07:00
Tom Tromey 80ae204359 Style variable names
This adds style support for variable names.  For the time being, this
is only done in backtraces, not in ptype or print; those places do not
use ui-out and so would need ad hoc changes.

This also adds styling to the names printed for local variables in
"backtrace full".  This code does not use ui-out, so the styling is
done using the low-level API.

gdb/ChangeLog
2018-12-28  Tom Tromey  <tom@tromey.com>

	* ui-out.h (enum class ui_out_style_kind) <VARIABLE>: New global.
	* stack.c (print_frame_arg): Style name.
	* printcmd.c (print_variable_and_value): Style variable name.
	* cli/cli-style.h (variable_name_style): Declare.
	* cli/cli-style.c (variable_name_style): New global.
	(_initialize_cli_style): Update.
	* cli-out.c (cli_ui_out::do_field_string): Update.

gdb/testsuite/ChangeLog
2018-12-28  Tom Tromey  <tom@tromey.com>

	* gdb.base/style.exp: Add test for variable names.
2018-12-28 12:49:50 -07:00
Tom Tromey ef1dfa3644 Reset terminal styles
This adds a function that can be used to reset terminal styles,
regardless of what style the low-level output routines currently think
is applied.

This is used to make "echo" and "printf" work properly when emitting
ANSI terminal escapes -- now gdb will reset the style at the end of
the command.

gdb/ChangeLog
2018-12-28  Tom Tromey  <tom@tromey.com>

	* utils.h (reset_terminal_style): Declare.
	* utils.c (can_emit_style_escape): New function.
	(set_output_style): Use it.
	(reset_terminal_style): New function.
	* printcmd.c (printf_command): Call reset_terminal_style.
	* cli/cli-cmds.c (echo_command): Call reset_terminal_style.
2018-12-28 12:49:49 -07:00
Simon Marchi af39b1c216 Disable -Wformat-nonliteral in parts of printcmd.c
commit 3322c5d9a1 ("Remove unneeded explicit .o targets") broke the
build with clang, because -Wno-format-nonliteral was in fact needed.
This patch fixes the problem by introducing
DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL and using it in printcmd.c.  This
seems preferable to reverting the patch because now the warning
suppression is more targeted.

gdb/ChangeLog
2018-09-05  Simon Marchi  <simon.marchi@ericsson.com>

	* printcmd.c (printf_c_string): Use
	DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL.
	(printf_wide_c_string, printf_pointer, ui_printf): Likewise.

include/ChangeLog
2018-09-05  Simon Marchi  <simon.marchi@ericsson.com>

	* diagnostics.h (DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL): New macro.
2018-09-05 21:47:33 -06:00
Kevin Buettner 2b1ffcfd6f Use BLOCK_ENTRY_PC in place of most uses of BLOCK_START
This change/patch substitues BLOCK_ENTRY_PC for BLOCK_START in
places where BLOCK_START is used to obtain the address at which
execution should enter the block.  Since blocks can now contain
non-contiguous ranges, the BLOCK_START - which is still be the
very lowest address in the block - might not be the same as
BLOCK_ENTRY_PC.

There is a change to infrun.c which is less obvious and less mechanical.
I'm posting it as a separate patch.

gdb/ChangeLog:

	* ax-gdb.c (gen_var_ref): Use BLOCK_ENTRY_PC in place of
	BLOCK_START.
	* blockframe.c (get_pc_function_start): Likewise.
	* compile/compile-c-symbols.c (convert_one_symbol): Likewise.
	(gcc_symbol_address): Likewise.
	* compile/compile-object-run.c (compile_object_run): Likewise.
	* compile/compile.c (get_expr_block_and_pc): Likewise.
	* dwarf2loc.c (dwarf2_find_location_expression): Likewise.
	(func_addr_to_tail_call_list): Likewise.
	* findvar.c (default_read_var_value): Likewise.
	* inline-frame.c (inline_frame_this_id): Likewise.
	(skip-inline_frames): Likewise.
	* infcmd.c (until_next_command): Likewise.
	* linespec.c (convert_linespec_to_sals): Likewise.
	* parse.c (parse_exp_in_context_1): Likewise.
	* printcmd.c (build_address_symbolic): likewise.
	(info_address_command): Likewise.
	symtab.c (find_function_start_sal): Likewise.
	(skip_prologue_sal): Likewise.
	(find_function_alias_target): Likewise.
	(find_gnu_ifunc): Likewise.
	* stack.c (find_frame_funname): Likewise.
	* symtab.c (fixup_symbol_section): Likewise.
	(find_function_start_sal): Likewise.
	(skip_prologue_sal): Likewsie.
	(find_function_alias_target): Likewise.
	(find_gnu_ifunc): Likewise.
	* tracepoint.c (info_scope_command): Likewise.
	* value.c (value_fn_field): Likewise.
2018-08-23 16:19:18 -07:00
Tom Tromey 8d49165d83 Simple unused variable removals
This patch holds all the straightforward unused variable deletions.

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

	* guile/scm-value.c (gdbscm_value_call): Remove unused variables.
	* guile/scm-math.c (vlscm_unop_gdbthrow, vlscm_binop_gdbthrow)
	(vlscm_convert_typed_value_from_scheme): Remove unused variable.
	* buildsym-legacy.c (get_macro_table): Remove unused variable.
	* stack.c (frame_apply_level_command): Remove unused variable.
	* tic6x-tdep.c (tic6x_push_dummy_call): Remove unused variable.
	* sparc64-tdep.c (adi_examine_command): Remove unused variable.
	* rs6000-lynx178-tdep.c (rs6000_lynx178_push_dummy_call): Remove
	unused variable.
	* nios2-tdep.c (nios2_push_dummy_call): Remove unused variable.
	* mep-tdep.c (mep_push_dummy_call): Remove unused variable.
	* ada-lang.c (ada_lookup_symbol_list_worker): Remove unused
	variable.
	* amd64-tdep.c (amd64_supply_xsave): Remove unused variable.
	* arm-tdep.c (arm_record_data_proc_misc_ld_str): Remove unused
	variable.
	* breakpoint.c (check_no_tracepoint_commands, update_watchpoint):
	Remove unused variable.
	* cli/cli-script.c (recurse_read_control_structure): Remove unused
	variable.
	* common/tdesc.c (print_xml_feature::visit): Remove unused
	variable.
	* compile/compile-object-load.c (store_regs): Remove unused
	variables.
	* complaints.c (clear_complaints): Remove unused variable.
	* corelow.c (core_target_open): Remove unused variable.
	* fbsd-tdep.c (fbsd_core_info_proc_status): Remove unused
	variable.
	* guile/scm-frame.c (gdbscm_frame_read_var): Remove unused
	variable.
	* guile/scm-symtab.c (stscm_print_sal_smob): Remove unused
	variable.
	* guile/scm-type.c (gdbscm_field_baseclass_p): Remove unused
	variable.
	* guile/scm-utils.c (gdbscm_parse_function_args): Remove unused
	variable.
	* hppa-tdep.c (hppa_stub_frame_unwind_cache): Remove unused
	variable.
	* ia64-tdep.c (examine_prologue): Remove unused variable.
	* infcall.c (run_inferior_call): Remove unused variable.
	* inferior.c (exit_inferior): Remove unused variable.
	* infrun.c (infrun_thread_ptid_changed): Remove unused variable.
	* linespec.c (decode_line_2): Remove unused variable.
	* linux-nat.c (super_close): Remove.
	* linux-tdep.c (linux_info_proc): Remove unused variable.
	* mi/mi-main.c (mi_execute_command): Remove unused variable.
	* microblaze-linux-tdep.c (microblaze_linux_sigtramp_cache):
	Remove unused variable.
	* parse.c (find_minsym_type_and_address): Remove unused variable.
	* printcmd.c (info_symbol_command, printf_floating): Remove unused
	variable.
	* python/py-breakpoint.c (bppy_set_commands): Remove unused
	variable.
	* python/py-unwind.c (unwind_infopy_dealloc): Remove unused
	variables.
	* record-btrace.c (record_btrace_target::store_registers): Remove
	unused variable.
	(cmd_show_record_btrace_cpu): Remove unused variable.
	* riscv-tdep.c (riscv_register_reggroup_p)
	(riscv_push_dummy_call, riscv_return_value): Remove unused
	variable.
	* rust-exp.y (literal): Remove unused variable.
	* rust-lang.c (rust_evaluate_subexp) <OP_RUST_ARARAY>: Remove
	unused variable.
	<STRUCTOP_ANONYMOUS>: Likewise.
	* s390-linux-tdep.c (s390_linux_init_abi_31)
	(s390_linux_init_abi_64): Remove unused variable.
	* ser-ming2.c (ser_windows_read_prim, pipe_select_thread)
	(file_select_thread, net_windows_open, _initialize_ser_windows):
	Remove unused variables.
	* symtab.c (find_pc_sect_line): Remove unused variable.
	* target-memory.c (compute_garbled_blocks): Remove unused
	variable.
	(target_write_memory_blocks): Remove unused variable.
	* target.c (target_stack::unpush): Remove unused variables.
	* tracepoint.c (start_tracing, all_tracepoint_actions)
	(merge_uploaded_trace_state_variables)
	(print_one_static_tracepoint_marker): Remove unused variable.
	* unittests/basic_string_view/element_access/char/1.cc (test01):
	Remove unused variable.
	* windows-nat.c (windows_continue, windows_add_all_dlls)
	(do_initial_windows_stuff, windows_nat_target::create_inferior):
	Remove unused variables.
2018-07-22 13:20:01 -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
Weimin Pan 64cc34d870 Removing lookup_minimal_symbol_and_objfile
Function lookup_minimal_symbol_and_objfile iterates on all objfiles and
calls lookup_minimal_symbol for each of them, effectively searching in all
objfiles.  lookup_bound_minimal_symbol calls lookup_minimal_symbol with NULL,
which also effectively searches all objfiles.  AFAIK, they do exactly the same
thing, so we can get rid of one (and lookup_minimal_symbol_and_objfile happens
to be the most inefficient because it ends up n^2 on the number of objfiles).

Tested in both aarch64-linux-gnu and amd64-linux-gnu. No regressions.
2018-05-29 22:37:07 +00: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
Tom Tromey 2f433492bd Minor cleanups in printcmd.c
This changes decode_format to use skip_spaces, and changes printcmd.c
not to include tui.h, which apparently is not needed.

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

	* printcmd.c: Don't include tui.h.
	(decode_format): Use skip_spaces.
2018-05-04 12:22:44 -06:00