Commit Graph

1120 Commits

Author SHA1 Message Date
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 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
Tom Tromey 4ca51187d2 Constify target_ops::follow_exec
I noticed that target_ops::follow_exec took a "char *" parameter,
where "const char *" would be more correct.  This patch changes this
(and related functions) to be constified.

Tested by rebuilding.

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

	* target.c (target_follow_exec): Constify parameter.
	* target-delegates.c: Rebuild.
	* remote.c (remote_target::follow_exec): Constify parameter.
	* infrun.c (follow_exec): Constify parameter.
	* target.h (struct target_ops) <follow_exec>: Constify parameter.
	(target_follow_exec): Likewise.
2019-05-22 15:41:28 -04:00
Tom Tromey 7b4a314f8b Convert remote.c to type-safe registry API
This changes remote.c to use the type-safe registry API.

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

	* remote.c (remote_pspace_data): Change type.
	(remote_pspace_data_cleanup): Remove.
	(get_remote_exec_file, set_pspace_remote_exec_file)
	(_initialize_remote): Update.
2019-05-08 16:01:50 -06:00
Tom Tromey 60fcc1c3d0 Change some remote.c globals to "static"
I noticed a three globals in remote.c that could be static.  This
patch makes this change.

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

	* remote.c (remote_hw_watchpoint_limit)
	(remote_hw_watchpoint_length_limit, remote_hw_breakpoint_limit):
	Now static.
2019-05-08 10:38:02 -06:00
Tom Tromey ed2b7c1703 Move "watchdog" to remote.c
The "watchdog" global is only used in remote.c, so this patch moves it
there and makes it static.

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

	* maint.c (_initialize_maint_cmds): Move initialization code to
	remote.c.
	(watchdog, show_watchdog): Move to remote.c.
	* remote.c (watchdog, show_watchdog): Move from maint.c.  Make
	"watchdog" static.
	(_initialize_remote): Move initialization code from maint.c.
	* defs.h (watchdog): Don't declare.
2019-05-08 10:38:02 -06:00
Tom Tromey 97dfbaddad Use std::list for remote_notif_state::notif_queue
This changes remote_notif_state::notif_queue to be a std::list and
updates all the uses.

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

	* remote.c (remote_target): Use delete.
	* remote-notif.h: Include <list>, not "common/queue.h".
	(notif_client_p): Remove typedef.
	(remote_notif_state): Add constructor, destructor, initializer.
	<notif_queue>: Now a std::list.
	(remote_notif_state_xfree): Don't declare.
	* remote-notif.c (remote_notif_process, handle_notification)
	(remote_notif_state_allocate): Update.
	(~remote_notif_state): Rename from remote_notif_state_xfree.
2019-04-19 14:29:33 -06:00
Tom Tromey 9ab8741a48 Consistently use bool for fake_pid_p
I noticed a few spots where fake_pid_p is handled as an int, whereas
the field in struct inferior has type bool.  This patch changes the
remaining places to use bool as well.

Tested by the buildbot.

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

	* remote.c (remote_target::remote_add_inferior): Change fake_pid_p
	to bool.
	(extended_remote_target::attach): Update.
	(remote_target::remote_notice_new_inferior): Update.
	(remote_target::add_current_inferior_and_thread): Update.
	* inferior.c (exit_inferior_1): Use "false".
	* corelow.c (add_to_thread_list): Make fake_pid_p bool.
2019-04-09 11:59:25 -06:00
Kevin Buettner 3d6c62048d Introduce target_ops method thread_info_to_thread_handle
This patch adds a thread_info_to_thread_handle method to the target_ops
struct.  It also implements this functionality for remote targets and
linux native threads.

gdb/ChangeLog:

	* gdbthread.h (thread_to_thread_handle): Declare.
	* thread.c (gdbtypes.h): Include.
	(thread_to_thread_handle): New function.

	* target.h (struct target_ops): Add thread_info_to_thread_handle.
	(target_thread_info_to_thread_handle): Declare.
	* target.c (target_thread_info_to_thread_handle): New function.
	* target-debug.h (target_debug_print_gdb_byte_vector): Define.
	* target-delegates.c: Regenerate.

	* linux-thread-db.c (class thread_db_target): Add method
	thread_info_to_thread_handle.
	(thread_db_target::thread_info_to_thread_handle): Define.
	* remote.c (class remote_target): Add new method
	thread_info_to_thread_handle.
	(remote_target::thread_info_to_thread_handle): Define.
2019-04-08 20:09:37 -07:00
Tom Tromey eedc3f4f0a Replace throw_exception with throw in some cases
This replaces throw_exception with "throw;" when possible.  This was
written by script.  The rule that is followed is that uses of the
form:

   catch (... &name)
     {
       ...
       throw_exception (name);
     }

... can be rewritten.  This should always be safe, because exceptions
are caught by const reference, and therefore can't be modified in the
body of the catch.

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

	* valops.c (value_rtti_indirect_type): Replace throw_exception
	with throw.
	* tracefile-tfile.c (tfile_target_open): Replace throw_exception
	with throw.
	* thread.c (thr_try_catch_cmd): Replace throw_exception with
	throw.
	* target.c (target_translate_tls_address): Replace throw_exception
	with throw.
	* stack.c (frame_apply_command_count): Replace throw_exception
	with throw.
	* solib-spu.c (append_ocl_sos): Replace throw_exception with
	throw.
	* s390-tdep.c (s390_frame_unwind_cache): Replace throw_exception
	with throw.
	* rs6000-tdep.c (rs6000_frame_cache)
	(rs6000_epilogue_frame_cache): Replace throw_exception with throw.
	* remote.c: Replace throw_exception with throw.
	* record-full.c (record_full_message, record_full_wait_1)
	(record_full_restore): Replace throw_exception with throw.
	* record-btrace.c:
	(get_thread_current_frame_id, record_btrace_start_replaying)
	(cmd_record_btrace_bts_start, cmd_record_btrace_pt_start)
	(cmd_record_btrace_start): Replace throw_exception with throw.
	* parse.c (parse_exp_in_context_1): Replace throw_exception with
	throw.
	* linux-nat.c (detach_one_lwp, linux_resume_one_lwp)
	(resume_stopped_resumed_lwps): Replace throw_exception with throw.
	* linespec.c:
	(find_linespec_symbols): Replace throw_exception with throw.
	* infrun.c (displaced_step_prepare, resume): Replace
	throw_exception with throw.
	* infcmd.c (post_create_inferior): Replace throw_exception with
	throw.
	* inf-loop.c (inferior_event_handler): Replace throw_exception
	with throw.
	* i386-tdep.c (i386_frame_cache, i386_epilogue_frame_cache)
	(i386_sigtramp_frame_cache): Replace throw_exception with throw.
	* frame.c (frame_unwind_pc, get_prev_frame_if_no_cycle)
	(get_prev_frame_always, get_frame_pc_if_available)
	(get_frame_address_in_block_if_available, get_frame_language):
	Replace throw_exception with throw.
	* frame-unwind.c (frame_unwind_try_unwinder): Replace
	throw_exception with throw.
	* eval.c (fetch_subexp_value, evaluate_var_value)
	(evaluate_funcall, evaluate_subexp_standard): Replace
	throw_exception with throw.
	* dwarf2loc.c (call_site_find_chain)
	(dwarf2_evaluate_loc_desc_full, dwarf2_locexpr_baton_eval):
	Replace throw_exception with throw.
	* dwarf2-frame.c (dwarf2_frame_cache): Replace throw_exception
	with throw.
	* darwin-nat.c (darwin_attach_pid): Replace throw_exception with
	throw.
	* cp-abi.c (baseclass_offset): Replace throw_exception with throw.
	* completer.c (complete_line_internal): Replace throw_exception
	with throw.
	* compile/compile-object-run.c (compile_object_run): Replace
	throw_exception with throw.
	* cli/cli-script.c (process_next_line): Replace throw_exception
	with throw.
	* btrace.c (btrace_compute_ftrace_pt, btrace_compute_ftrace)
	(btrace_enable, btrace_maint_update_pt_packets): Replace
	throw_exception with throw.
	* breakpoint.c (create_breakpoint, save_breakpoints): Replace
	throw_exception with throw.
	* break-catch-throw.c (re_set_exception_catchpoint): Replace
	throw_exception with throw.
	* amd64-tdep.c (amd64_frame_cache, amd64_sigtramp_frame_cache)
	(amd64_epilogue_frame_cache): Replace throw_exception with throw.
	* aarch64-tdep.c (aarch64_make_prologue_cache)
	(aarch64_make_stub_cache): Replace throw_exception with throw.

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

	* linux-low.c (linux_detach_one_lwp): Replace throw_exception with
	throw.
	(linux_resume_one_lwp): Likewise.
2019-04-08 09:05:41 -06: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 a068643d69 Change pid_to_str to return std::string
Currently the target pid_to_str method returns a const char *, so many
implementations have a static buffer that they update.  This patch
changes these methods to return a std::string instead.  I think this
is cleaner and avoids possible gotchas when calling pid_to_str on
different ptids in a single statement.  (Though no such calls exist
currently.)

This also updates various helper functions, and the gdbarch pid_to_str
methods.

I also made a best effort to fix all the callers, but I can't build
some of the *-nat.c files.

Tested by the buildbot.

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

	* i386-gnu-nat.c (i386_gnu_nat_target::fetch_registers)
	(i386_gnu_nat_target::store_registers): Update.
	* target-debug.h (target_debug_print_std_string): New macro.
	* x86-linux-nat.c (x86_linux_nat_target::enable_btrace): Update.
	* windows-tdep.c (display_one_tib): Update.
	* tui/tui-stack.c (tui_make_status_line): Update.
	* top.c (print_inferior_quit_action): Update.
	* thread.c (thr_try_catch_cmd): Update.
	(add_thread_with_info): Update.
	(thread_target_id_str): Update.
	(thr_try_catch_cmd): Update.
	(thread_command): Update.
	(thread_find_command): Update.
	* record-btrace.c (record_btrace_target::info_record)
	(record_btrace_resume_thread, record_btrace_target::resume)
	(record_btrace_cancel_resume, record_btrace_step_thread)
	(record_btrace_target::wait, record_btrace_target::wait)
	(record_btrace_target::wait, record_btrace_target::stop): Update.
	* progspace.c (print_program_space): Update.
	* process-stratum-target.c
	(process_stratum_target::thread_address_space): Update.
	* linux-fork.c (linux_fork_mourn_inferior)
	(detach_checkpoint_command, info_checkpoints_command)
	(linux_fork_context): Update.
	(linux_fork_detach): Update.
	(class scoped_switch_fork_info): Update.
	(delete_checkpoint_command): Update.
	* infrun.c (follow_fork_inferior): Update.
	(follow_fork_inferior): Update.
	(proceed_after_vfork_done): Update.
	(handle_vfork_child_exec_or_exit): Update.
	(follow_exec): Update.
	(displaced_step_prepare_throw): Update.
	(displaced_step_restore): Update.
	(start_step_over): Update.
	(resume_1): Update.
	(clear_proceed_status_thread): Update.
	(proceed): Update.
	(print_target_wait_results): Update.
	(do_target_wait): Update.
	(context_switch): Update.
	(stop_all_threads): Update.
	(restart_threads): Update.
	(finish_step_over): Update.
	(handle_signal_stop): Update.
	(switch_back_to_stepped_thread): Update.
	(keep_going_pass_signal): Update.
	(print_exited_reason): Update.
	(normal_stop): Update.
	* inferior.c (inferior_pid_to_str): Change return type.
	(print_selected_inferior): Update.
	(add_inferior): Update.
	(detach_inferior): Update.
	* dummy-frame.c (fprint_dummy_frames): Update.
	* dcache.c (dcache_info_1): Update.
	* btrace.c (btrace_enable, btrace_disable, btrace_teardown)
	(btrace_fetch, btrace_clear): Update.
	* linux-tdep.c (linux_core_pid_to_str): Change return type.
	* i386-cygwin-tdep.c (i386_windows_core_pid_to_str): Change return
	type.
	* fbsd-tdep.c (fbsd_core_pid_to_str): Change return type.
	* sol2-tdep.h (sol2_core_pid_to_str): Change return type.
	* sol2-tdep.c (sol2_core_pid_to_str): Change return type.
	* gdbarch.c, gdbarch.h: Rebuild.
	* gdbarch.sh (core_pid_to_str): Change return type.
	* windows-nat.c (struct windows_nat_target) <pid_to_str>: Change
	return type.
	(windows_nat_target::pid_to_str): Change return type.
	(windows_delete_thread): Update.
	(windows_nat_target::attach): Update.
	(windows_nat_target::files_info): Update.
	* target-delegates.c: Rebuild.
	* sol-thread.c (class sol_thread_target) <pid_to_str>: Change
	return type.
	(sol_thread_target::pid_to_str): Change return type.
	* remote.c (class remote_target) <pid_to_str>: Change return
	type.
	(remote_target::pid_to_str): Change return type.
	(extended_remote_target::attach, remote_target::remote_stop_ns)
	(remote_target::remote_notif_remove_queued_reply)
	(remote_target::push_stop_reply, remote_target::disable_btrace):
	Update.
	(extended_remote_target::attach): Update.
	* remote-sim.c (struct gdbsim_target) <pid_to_str>: Change return
	type.
	(gdbsim_target::pid_to_str): Change return type.
	* ravenscar-thread.c (struct ravenscar_thread_target)
	<pid_to_str>: Change return type.
	(ravenscar_thread_target::pid_to_str): Change return type.
	* procfs.c (class procfs_target) <pid_to_str>: Change return
	type.
	(procfs_target::pid_to_str): Change return type.
	(procfs_target::attach): Update.
	(procfs_target::detach): Update.
	(procfs_target::fetch_registers): Update.
	(procfs_target::store_registers): Update.
	(procfs_target::wait): Update.
	(procfs_target::files_info): Update.
	* obsd-nat.c (obsd_nat_target::pid_to_str): Change return type.
	* nto-procfs.c (struct nto_procfs_target) <pid_to_str>: Change
	return type.
	(nto_procfs_target::pid_to_str): Change return type.
	(nto_procfs_target::files_info, nto_procfs_target::attach): Update.
	* linux-thread-db.c (class thread_db_target) <pid_to_str>: Change
	return type.
	* linux-nat.c (linux_nat_target::pid_to_str): Change return type.
	(exit_lwp): Update.
	(attach_proc_task_lwp_callback, get_detach_signal)
	(detach_one_lwp, resume_lwp, linux_nat_target::resume)
	(linux_nat_target::resume, wait_lwp, stop_callback)
	(maybe_clear_ignore_sigint, stop_wait_callback, status_callback)
	(save_stop_reason, select_event_lwp, linux_nat_filter_event)
	(linux_nat_wait_1, resume_stopped_resumed_lwps)
	(linux_nat_target::wait, linux_nat_stop_lwp): Update.
	* inf-ptrace.c (inf_ptrace_target::pid_to_str): Change return
	type.
	(inf_ptrace_target::attach): Update.
	(inf_ptrace_target::files_info): Update.
	* go32-nat.c (struct go32_nat_target) <pid_to_str>: Change return
	type.
	(go32_nat_target::pid_to_str): Change return type.
	* gnu-nat.c (gnu_nat_target::pid_to_str): Change return type.
	(gnu_nat_target::wait): Update.
	(gnu_nat_target::wait): Update.
	(gnu_nat_target::resume): Update.
	* fbsd-nat.c (fbsd_nat_target::pid_to_str): Change return type.
	(fbsd_nat_target::wait): Update.
	* darwin-nat.c (darwin_nat_target::pid_to_str): Change return
	type.
	(darwin_nat_target::attach): Update.
	* corelow.c (class core_target) <pid_to_str>: Change return type.
	(core_target::pid_to_str): Change return type.
	* target.c (normal_pid_to_str): Change return type.
	(default_pid_to_str): Likewise.
	(target_pid_to_str): Change return type.
	(target_translate_tls_address): Update.
	(target_announce_detach): Update.
	* bsd-uthread.c (struct bsd_uthread_target) <pid_to_str>: Change
	return type.
	(bsd_uthread_target::pid_to_str): Change return type.
	* bsd-kvm.c (class bsd_kvm_target) <pid_to_str>: Change return
	type.
	(bsd_kvm_target::pid_to_str): Change return type.
	* aix-thread.c (class aix_thread_target) <pid_to_str>: Change
	return type.
	(aix_thread_target::pid_to_str): Change return type.
	* target.h (struct target_ops) <pid_to_str>: Change return type.
	(target_pid_to_str, normal_pid_to_str): Likewise.
	* obsd-nat.h (class obsd_nat_target) <pid_to_str>: Change return
	type.
	* linux-nat.h (class linux_nat_target) <pid_to_str>: Change return
	type.
	* inf-ptrace.h (struct inf_ptrace_target) <pid_to_str>: Change
	return type.
	* gnu-nat.h (struct gnu_nat_target) <pid_to_str>: Change return
	type.
	* fbsd-nat.h (class fbsd_nat_target) <pid_to_str>: Change return
	type.
	* darwin-nat.h (class darwin_nat_target) <pid_to_str>: Change
	return type.
2019-03-13 13:50:13 -06:00
Tom Tromey ffdd69cf78 Make remote.c ptid constants "const"
This changes magic_null_ptid, not_sent_ptid, and any_thread_ptid to be
"const".  This is a minor improvement that makes it so these can't be
accidentally modified.

Tested by rebuilding.  I'm checking this in.

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

	* remote.c (magic_null_ptid, not_sent_ptid, any_thread_ptid): Now
	const.  Add initializers.
	(_initialize_remote): Don't initialize ptid globals.
2019-03-12 11:07:43 -06:00
Tom Tromey c6321f19c5 Use unique_xmalloc_ptr in remote.c
This removes a cleanup from remote.c, replacing it with
unique_xmalloc_ptr.

2019-03-06  Tom Tromey  <tom@tromey.com>

	* remote.c (remote_target::remote_parse_stop_reply): Use
	unique_xmalloc_ptr.
2019-03-06 16:04:31 -07:00
Tom Tromey 32603266e5 C++ify remote notification code
This C++ifies the remote notification code -- replacing function
pointers with virtual methods and using unique_ptr.  This allows for
the removal of some cleanups.

2019-03-06  Tom Tromey  <tom@tromey.com>

	* remote.c (struct stop_reply_deleter): Remove.
	(stop_reply_up): Update.
	(struct stop_reply): Derive from notif_event.  Don't typedef.
	<regcache>: Now a std::vector.
	(stop_reply_xfree): Remove.
	(stop_reply::~stop_reply): Rename from stop_reply_dtr.
	(remote_notif_stop_alloc_reply): Return a unique_ptr.  Use new.
	(remote_target::discard_pending_stop_replies): Use delete.
	(remote_target::remote_parse_stop_reply): Update.
	(remote_target::process_stop_reply): Update.
	* remote-notif.h (struct notif_event): Add virtual destructor.
	Remove "dtr" member.
	(struct notif_client) <alloc_event>: Return a unique_ptr.
	(notif_event_xfree): Don't declare.
	(notif_event_up): New typedef.
	* remote-notif.c (remote_notif_ack, remote_notif_parse): Update.
	(notif_event_xfree, do_notif_event_xfree): Remove.
	(remote_notif_state_xfree): Update.
2019-03-06 16:04:31 -07: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 88a774b998 Add ATTRIBUTE_UNUSED_RESULT to scoped_remote_fd::release
This applies ATTRIBUTE_UNUSED_RESULT to scoped_remote_fd::release.

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

	* remote.c (class scoped_remote_fd) <release>: Add
	ATTRIBUTE_UNUSED_RESULT.
2019-03-05 08:48:40 -07:00
Tom Tromey dea57a6263 Add push_target overload
This adds a push_target overload that takes a "target_ops_up &&".
This removes some calls to release a target_ops_up, and makes the
intent here clearer.

gdb/ChangeLog
2019-02-15  Tom Tromey  <tromey@adacore.com>

	* target.h (push_target): Declare new overload.
	* target.c (push_target): New overload, taking an rvalue reference.
	* remote.c (remote_target::open_1): Use push_target overload.
	* corelow.c (core_target_open): Use push_target overload.
2019-02-15 13:53:43 -07:00
Thomas Schwinge b671c7fb21 [gdb, hurd] Avoid using 'PATH_MAX' in 'gdb/remote.c'
..., which is not defined in GNU/Hurd systems, and so commit
94585166df "Extended-remote follow-exec" caused:

    [...]/gdb/remote.c: In member function 'void remote_target::remote_parse_stop_reply(const char*, stop_reply*)':
    [...]/gdb/remote.c:7343:22: error: 'PATH_MAX' was not declared in this scope
            char pathname[PATH_MAX];
                          ^~~~~~~~

	gdb/
	* remote.c (remote_target::remote_parse_stop_reply): Avoid using
	'PATH_MAX'.
2019-02-14 17:40:19 +01: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
Pedro Alves adc6a863a9 target_pass_signals/target_program_signals: Use gdb::array_view
This replaces the pointer and length parameters of target_pass_signals
and target_program_signals with a gdb::array_view parameter, and fixes
the fallout.

In infrun.c, the signal_stop, signal_print, signal_program,
signal_catch, signal_pass globals are currently pointers to
heap-allocated memory.  I see no point in that, so I converted them to
arrays.  This allows simplifying the calls to
target_pass_signals/target_program_signals, since we can pass the
array directly, which can implicitly convert to gdb::array_view.

gdb/ChangeLog:
2019-01-24  Pedro Alves  <palves@redhat.com>

	* infrun.c (signal_stop, signal_print, signal_program)
	(signal_catch, signal_pass): Now arrays instead of pointers.
	(update_signals_program_target, do_target_resume)
	(signal_catch_update, handle_command, _initialize_infrun): Adjust.
	* linux-nat.c (linux_nat_target::pass_signals)
	(linux_nat_target::create_inferior, linux_nat_target::attach):
	Adjust.
	* linux-nat.h (linux_nat_target::pass_signals): Adjust.
	* nto-procfs.c (nto_procfs_target::pass_signals): Adjust.
	* procfs.c (procfs_target::pass_signals): Adjust.
	* record-full.c (record_full_target::resume): Adjust.
	* remote.c (remote_target::pass_signals)
	(remote_target::program_signals): Adjust.
	* target-debug.h (target_debug_print_signals): Now takes a
	gdb::array_view as parameter.  Adjust.
	* target.h (target_ops) <pass_signals, program_signals>: Replace
	pointer and length parameters with gdb::array_view.
	(target_pass_signals, target_program_signals): Likewise.
	* target-delegates.c: Regenerate.
2019-01-24 18:25:06 +00: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 8d64371b6b Remove cleanup from remote.c
This removes the remaining cleanup from remote.c, by changing
remote_state::buf to be a gdb::char_vector, and then fixing up all the
fallout.  The resulting patch is somewhat ugly, but on the other hand,
it eliminates some possibilities for mistakes.

Regression tested using the
Fedora-x86_64-native-extended-gdbserver-m64 builder on the buildbot.

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

	* remote.c (class remote_state) <buf>: Now a char_vector.
	<buf_size>: Remove.
	(remote_target::getpkt): Change type of buf.  Remove sizeof_buf
	parameter.
	(remote_target::getpkt_or_notif_sane_1)
	(remote_target::getpkt_sane)
	(remote_target::getpkt_or_notif_sane): Likewise.
	(class remote_target) <putpkt>: New overload.
	(remote_target::read_frame): Change type of "buf_p".  Remove
	sizeof_p parameter.
	(packet_ok): New overload.
	(packet_check_result): New overload.
	Update all uses.
2019-01-15 15:35:56 -07:00
Tom Tromey bb27775165 Constify some remote-notif functions
This constifies the "buf" arguments to various remote-notif functions
and updates the users.

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

	* remote-notif.c (handle_notification, remote_notif_ack)
	(remote_notif_parse): Make "buf" const.
	* remote-notif.h (struct notif_client) <parse, ack>: Make "buf"
	const.
	(remote_notif_parse, remote_notif_ack, handle_notification):
	Likewise.
	* remote.c (remote_notif_stop_parse): Make "buf" const.
	(remote_target::remote_parse_stop_reply): Make "buf" const.
	(remote_notif_stop_ack): Make "buf" const.
2019-01-14 17:32:24 -07:00
Tom Tromey 05be00a884 Constify remote_console_output
This constifies the parameter to remote_console_output.

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

	* remote.c (remote_console_output): Make parameter const.
2019-01-14 17:32:24 -07:00
Tom Tromey 491adecac4 Constify target_pass_signals and target_program_signals
This constifies the final parameter to target_pass_signals and
target_program_signals and updates the rest of gdb.

Note that I have no way to test the nto-procfs.c change.

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

	* target-debug.h (target_debug_print_signals): Constify.
	* nto-procfs.c (nto_procfs_target::pass_signals): Update.
	* procfs.c (procfs_target::pass_signals): Update.
	* linux-nat.c (linux_nat_target::pass_signals): Update.
	* linux-nat.h (class linux_nat_target) <pass_signals>: Update.
	* target-delegates.c: Rebuild.
	* remote.c (remote_target::program_signals): Update.
	(remote_target::pass_signals): Update.
	* target.c (target_pass_signals): Constify argument.
	(target_program_signals): Likewise.
	* target.h (struct target_ops) <pass_signals, program_signals>:
	Constify argument.
	(target_pass_signals, target_program_signals): Constify argument.
2019-01-14 17:32:24 -07:00
Andrew Burgess 66644cd32b gdb/remote: Remove a cleanup in remote_check_symbols
Convert one of the variables that requires a cleanup from a 'char *'
to a 'gdb::char_vector' in remote_target::remote_check_symbols.

Tested on x86-64/Linux with target_board native-gdbserver and
native-extended-gdbserver.

gdb/ChangeLog:

	* remote.c (remote_target::remote_check_symbols): Convert `msg` to
	gdb::char_vector, remove cleanup, and update uses of `msg`.
2019-01-03 21:24:00 +00: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
Pedro Alves f3d11a9a96 Convert default_child_has_foo functions to process_stratum_target methods
This patch converts the default_child_has_foo functions to
process_stratum_target methods.  This simplifies "regular"
non-inf_child process_stratum targets, since they no longer have to
override the target_ops::has_foo methods to call the default_child_foo
functions.  A couple targets need to override the new defaults
(corelow and tracefiles), but it still seems like a good tradeoff,
since those are expected to be little different (target doesn't run).

gdb/ChangeLog:
2018-11-30  Pedro Alves  <palves@redhat.com>

	* corelow.c (core_target) <has_all_memory, has_execution>: New
	overrides.
	* inf-child.c (inf_child_target::has_all_memory)
	(inf_child_target::has_memory, inf_child_target::has_stack)
	(inf_child_target::has_registers)
	(inf_child_target::has_execution): Delete.
	* inf-child.h (inf_child_target) <has_all_memory, has_memory,
	has_stack, has_registers, has_execution>: Delete.
	* process-stratum-target.c
	(process_stratum_target::has_all_memory)
	(process_stratum_target::has_memory)
	(process_stratum_target::has_stack)
	(process_stratum_target::has_registers)
	(process_stratum_target::has_execution): New.
	* process-stratum-target.h (process_stratum_target)
	<has_all_memory, has_memory, has_stack, has_registers,
	has_execution>: New method overrides.
	* ravenscar-thread.c (ravenscar_thread_target) <has_all_memory,
	has_memory, has_stack, has_registers, has_execution>: Delete.
	* remote-sim.c (gdbsim_target) <has_stack, has_registers,
	has_execution>: Delete.
	* remote.c (remote_target) <has_all_memory, has_memory, has_stack,
	has_registers, has_execution>: Delete.
	* target.c (default_child_has_all_memory)
	(default_child_has_memory, default_child_has_stack)
	(default_child_has_registers, default_child_has_execution):
	Delete.
	* target.h (default_child_has_all_memory)
	(default_child_has_memory, default_child_has_stack)
	(default_child_has_registers, default_child_has_execution):
	Delete.
	* tracefile.h (tracefile_target) <has_execution>: New override.
2018-11-30 16:28:11 +00:00
Pedro Alves 3b3dac9b3f Introduce process_stratum_target
This adds a base class that all process_stratum targets inherit from.

default_thread_address_space/default_thread_architecture only make
sense for process_stratum targets, so they are transformed to
process_stratum_target methods/overrides.

gdb/ChangeLog:
2018-11-30  Pedro Alves  <palves@redhat.com>

	* Makefile.in (COMMON_SFILES): Add process-stratum-target.c.
	* bsd-kvm.c: Include "process-stratum-target.h".
	(bsd_kvm_target): Now inherits from process_stratum_target.
	(bsd_kvm_target::bsd_kvm_target): Default it.
	* corelow.c: Include "process-stratum-target.h".
	(core_target): Now inherits from process_stratum_target.
	(core_target::core_target): Don't set to_stratum here.
	* inf-child.c (inf_child_target::inf_child_target): Delete.
	* inf-child.h: Include "process-stratum-target.h".
	(inf_child_target): Inherit from process_stratum_target.
	(inf_child_target) <inf_child_target>: Default it.
	<can_async_p, supports_non_stop, supports_disable_randomization>:
	Delete overrides.
	* process-stratum-target.c: New file.
	* process-stratum-target.h: New file.
	* remote-sim.c: Include "process-stratum-target.h".
	(gdbsim_target): Inherit from process_stratum_target.
	<gdbsim_target>: Default it.
	* remote.c: Include "process-stratum-target.h".
	(remote_target): Inherit from process_stratum_target.
	<remote_target>: Default it.
	* target.c (default_thread_address_space)
	(default_thread_architecture): Delete.
	* target.h (target_ops) <thread_architecture>: Now returns NULL by
	default.
	<thread_address_space>: Ditto.
	* test-target.h: Include "process-stratum-target.h" instead of
	"target.h".
	(test_target_ops): Inherit from process_stratum_target.
	<test_target_ops>: Default it.
	* tracefile.c (tracefile_target::tracefile_target): Delete.
	* tracefile.h: Include "process-stratum-target.h".
	(tracefile_target): Inherit from process_stratum_target.
	<tracefile_target>: Default it.
	* target-delegates.c: Regenerate.
2018-11-30 16:27:26 +00:00
Pedro Alves 0803633106 Per-inferior thread list, thread ranges/iterators, down with ALL_THREADS, etc.
As preparation for multi-target, this patch makes each inferior have
its own thread list.

This isn't absolutely necessary for multi-target, but simplifies
things.  It originally stemmed from the desire to eliminate the
init_thread_list calls sprinkled around, plus it makes it more
efficient to iterate over threads of a given inferior (no need to
always iterate over threads of all inferiors).

We still need to iterate over threads of all inferiors in a number of
places, which means we'd need adjust the ALL_THREADS /
ALL_NON_EXITED_THREADS macros.  However, naively tweaking those macros
to have an extra for loop, like:

     #define ALL_THREADS (thr, inf) \
       for (inf = inferior_list; inf; inf = inf->next) \
	 for (thr = inf->thread_list; thr; thr = thr->next)

causes problems with code that does "break" or "continue" within the
ALL_THREADS loop body.  Plus, we need to declare the extra "inf" local
variable in order to pass it as temporary variable to ALL_THREADS
(etc.)

It gets even trickier when we consider extending the macros to filter
out threads matching a ptid_t and a target.  The macros become tricker
to read/write.  Been there.

An alternative (which was my next attempt), is to replace the
ALL_THREADS etc. iteration style with for_each_all_threads,
for_each_non_exited_threads, etc. functions which would take a
callback as parameter, which would usually be passed a lambda.
However, I did not find that satisfactory at all, because the
resulting code ends up a little less natural / more noisy to read,
write and debug/step-through (due to use of lambdas), and in many
places where we use "continue;" to skip to the next thread now need to
use "return;".  (I ran into hard to debug bugs caused by a
continue/return confusion.)

I.e., before:

    ALL_NON_EXITED_THREADS (tp)
      {
	if (tp->not_what_I_want)
	  continue;
	// do something
      }

would turn into:

    for_each_non_exited_thread ([&] (thread_info *tp)
      {
	if (tp->not_what_I_want)
	  return;
	// do something
      });

Lastly, the solution I settled with was to replace the ALL_THREADS /
ALL_NON_EXITED_THREADS / ALL_INFERIORS macros with (C++20-like) ranges
and iterators, such that you can instead naturaly iterate over
threads/inferiors using range-for, like e.g,.:

   // all threads, including THREAD_EXITED threads.
   for (thread_info *tp : all_threads ())
     { .... }

   // all non-exited threads.
   for (thread_info *tp : all_non_exited_threads ())
     { .... }

   // all non-exited threads of INF inferior.
   for (thread_info *tp : inf->non_exited_threads ())
     { .... }

The all_non_exited_threads() function takes an optional filter ptid_t as
parameter, which is quite convenient when we need to iterate over
threads matching that filter.  See e.g., how the
set_executing/set_stop_requested/finish_thread_state etc. functions in
thread.c end up being simplified.

Most of the patch thus is about adding the infrustructure for allowing
the above.  Later on when we get to actual multi-target, these
functions/ranges/iterators will gain a "target_ops *" parameter so
that e.g., we can iterate over all threads of a given target that
match a given filter ptid_t.

The only entry points users needs to be aware of are the
all_threads/all_non_exited_threads etc. functions seen above.  Thus,
those functions are declared in gdbthread.h/inferior.h.  The actual
iterators/ranges are mainly "internals" and thus are put out of view
in the new thread-iter.h/thread-iter.c/inferior-iter.h files.  That
keeps the gdbthread.h/inferior.h headers quite a bit more readable.

A common/safe-iterator.h header is added which adds a template that
can be used to build "safe" iterators, which are forward iterators
that can be used to replace the ALL_THREADS_SAFE macro and other
instances of the same idiom in future.

There's a little bit of shuffling of code between
gdbthread.h/thread.c/inferior.h in the patch.  That is necessary in
order to avoid circular dependencies between the
gdbthread.h/inferior.h headers.

As for the init_thread_list calls sprinkled around, they're all
eliminated by this patch, and a new, central call is added to
inferior_appeared.  Note how also related to that, there's a call to
init_wait_for_inferior in remote.c that is eliminated.
init_wait_for_inferior is currently responsible for discarding skipped
inline frames, which had to be moved elsewhere.  Given that nowadays
we always have a thread even for single-threaded processes, the
natural place is to delete a frame's inline frame info when we delete
the thread.  I.e., from clear_thread_inferior_resources.

gdb/ChangeLog:
2018-11-22  Pedro Alves  <palves@redhat.com>

	* Makefile.in (COMMON_SFILES): Add thread-iter.c.
	* breakpoint.c (breakpoints_should_be_inserted_now): Replace
	ALL_NON_EXITED_THREADS with all_non_exited_threads.
	(print_one_breakpoint_location): Replace ALL_INFERIORS with
	all_inferiors.
	* bsd-kvm.c: Include inferior.h.
	* btrace.c (btrace_free_objfile): Replace ALL_NON_EXITED_THREADS
	with all_non_exited_threads.
	* common/filtered-iterator.h: New.
	* common/safe-iterator.h: New.
	* corelow.c (core_target_open): Don't call init_thread_list here.
	* darwin-nat.c (thread_info_from_private_thread_info): Replace
	ALL_THREADS with all_threads.
	* fbsd-nat.c (fbsd_nat_target::resume): Replace
	ALL_NON_EXITED_THREADS with inf->non_exited_threads.
	* fbsd-tdep.c (fbsd_make_corefile_notes): Replace
	ALL_NON_EXITED_THREADS with inf->non_exited_threads.
	* fork-child.c (postfork_hook): Don't call init_thread_list here.
	* gdbarch-selftests.c (register_to_value_test): Adjust.
	* gdbthread.h: Don't include "inferior.h" here.
	(struct inferior): Forward declare.
	(enum step_over_calls_kind): Moved here from inferior.h.
	(thread_info::deletable): Definition moved to thread.c.
	(find_thread_ptid (inferior *, ptid_t)): Declare.
	(ALL_THREADS, ALL_THREADS_BY_INFERIOR, ALL_THREADS_SAFE): Delete.
	Include "thread-iter.h".
	(all_threads, all_non_exited_threads, all_threads_safe): New.
	(any_thread_p): Declare.
	(thread_list): Delete.
	* infcmd.c (signal_command): Replace ALL_NON_EXITED_THREADS with
	all_non_exited_threads.
	(proceed_after_attach_callback): Delete.
	(proceed_after_attach): Take an inferior pointer instead of an
	integer PID.  Adjust to use range-for.
	(attach_post_wait): Pass down inferior pointer instead of pid.
	Use range-for instead of ALL_NON_EXITED_THREADS.
	(detach_command): Remove init_thread_list call.
	* inferior-iter.h: New.
	* inferior.c (struct delete_thread_of_inferior_arg): Delete.
	(delete_thread_of_inferior): Delete.
	(delete_inferior, exit_inferior_1): Use range-for with
	inf->threads_safe() instead of iterate_over_threads.
	(inferior_appeared): Call init_thread_list here.
	(discard_all_inferiors): Use all_non_exited_inferiors.
	(find_inferior_id, find_inferior_pid): Use all_inferiors.
	(iterate_over_inferiors): Use all_inferiors_safe.
	(have_inferiors, number_of_live_inferiors): Use
	all_non_exited_inferiors.
	(number_of_inferiors): Use all_inferiors and std::distance.
	(print_inferior): Use all_inferiors.
	* inferior.h: Include gdbthread.h.
	(enum step_over_calls_kind): Moved to gdbthread.h.
	(struct inferior) <thread_list>: New field.
	<threads, non_exited_threads, threads_safe>: New methods.
	(ALL_INFERIORS): Delete.
	Include "inferior-iter.h".
	(ALL_NON_EXITED_INFERIORS): Delete.
	(all_inferiors_safe, all_inferiors, all_non_exited_inferiors): New
	functions.
	* inflow.c (child_interrupt, child_pass_ctrlc): Replace
	ALL_NON_EXITED_THREADS with all_non_exited_threads.
	* infrun.c (follow_exec): Use all_threads_safe.
	(clear_proceed_status, proceed): Use all_non_exited_threads.
	(init_wait_for_inferior): Don't clear inline frame state here.
	(infrun_thread_stop_requested, for_each_just_stopped_thread): Use
	all_threads instead of ALL_NON_EXITED_THREADS.
	(random_pending_event_thread): Use all_non_exited_threads instead
	of ALL_NON_EXITED_THREADS.  Use a lambda for repeated code.
	(clean_up_just_stopped_threads_fsms): Use all_non_exited_threads
	instead of ALL_NON_EXITED_THREADS.
	(handle_no_resumed): Use all_non_exited_threads instead of
	ALL_NON_EXITED_THREADS.  Use all_inferiors instead of
	ALL_INFERIORS.
	(restart_threads, switch_back_to_stepped_thread): Use
	all_non_exited_threads instead of ALL_NON_EXITED_THREADS.
	* linux-nat.c (check_zombie_leaders): Replace ALL_INFERIORS with
	all_inferiors.
	(kill_unfollowed_fork_children): Use inf->non_exited_threads
	instead of ALL_NON_EXITED_THREADS.
	* linux-tdep.c (linux_make_corefile_notes): Use
	inf->non_exited_threads instead of ALL_NON_EXITED_THREADS.
	* linux-thread-db.c (thread_db_target::update_thread_list):
	Replace ALL_INFERIORS with all_inferiors.
	(thread_db_target::thread_handle_to_thread_info): Use
	inf->non_exited_threads instead of ALL_NON_EXITED_THREADS.
	* mi/mi-interp.c (multiple_inferiors_p): New.
	(mi_on_resume_1): Simplify using all_non_exited_threads and
	multiple_inferiors_p.
	* mi/mi-main.c (mi_cmd_thread_list_ids): Use all_non_exited_threads
	instead of ALL_NON_EXITED_THREADS.
	* nto-procfs.c (nto_procfs_target::open): Don't call
	init_thread_list here.
	* record-btrace.c (record_btrace_target_open)
	(record_btrace_target::stop_recording)
	(record_btrace_target::close)
	(record_btrace_target::record_is_replaying)
	(record_btrace_target::resume, record_btrace_target::wait)
	(record_btrace_target::record_stop_replaying): Use
	all_non_exited_threads instead of ALL_NON_EXITED_THREADS.
	* record-full.c (record_full_wait_1): Use all_non_exited_threads
	instead of ALL_NON_EXITED_THREADS.
	* regcache.c (cooked_read_test): Remove reference to global
	thread_list.
	* remote-sim.c (gdbsim_target::create_inferior): Don't call
	init_thread_list here.
	* remote.c (remote_target::update_thread_list): Use
	all_threads_safe instead of ALL_NON_EXITED_THREADS.
	(remote_target::process_initial_stop_replies): Replace
	ALL_INFERIORS with all_non_exited_inferiors and use
	all_non_exited_threads instead of ALL_NON_EXITED_THREADS.
	(remote_target::open_1): Don't call init_thread_list here.
	(remote_target::append_pending_thread_resumptions)
	(remote_target::remote_resume_with_hc): Use all_non_exited_threads
	instead of ALL_NON_EXITED_THREADS.
	(remote_target::commit_resume)
	(remote_target::remove_new_fork_children): Replace ALL_INFERIORS
	with all_non_exited_inferiors and use all_non_exited_threads
	instead of ALL_NON_EXITED_THREADS.
	(remote_target::kill_new_fork_children): Use
	all_non_exited_threads instead of ALL_NON_EXITED_THREADS.  Remove
	init_thread_list and init_wait_for_inferior calls.
	(remote_target::remote_btrace_maybe_reopen)
	(remote_target::thread_handle_to_thread_info): Use
	all_non_exited_threads instead of ALL_NON_EXITED_THREADS.
	* target.c (target_terminal::restore_inferior)
	(target_terminal_is_ours_kind): Replace ALL_INFERIORS with
	all_non_exited_inferiors.
	* thread-iter.c: New file.
	* thread-iter.h: New file.
	* thread.c: Include "inline-frame.h".
	(thread_list): Delete.
	(clear_thread_inferior_resources): Call clear_inline_frame_state.
	(init_thread_list): Use all_threads_safe instead of
	ALL_THREADS_SAFE.  Adjust to per-inferior thread lists.
	(new_thread): Adjust to per-inferior thread lists.
	(add_thread_silent): Pass inferior to find_thread_ptid.
	(thread_info::deletable): New, moved from the header.
	(delete_thread_1): Adjust to per-inferior thread lists.
	(find_thread_global_id): Use inf->threads().
	(find_thread_ptid): Use find_inferior_ptid and pass inferior to
	find_thread_ptid.
	(find_thread_ptid(inferior*, ptid_t)): New overload.
	(iterate_over_threads): Use all_threads_safe.
	(any_thread_p): New.
	(thread_count): Use all_threads and std::distance.
	(live_threads_count): Use all_non_exited_threads and
	std::distance.
	(valid_global_thread_id): Use all_threads.
	(in_thread_list): Use find_thread_ptid.
	(first_thread_of_inferior): Adjust to per-inferior thread lists.
	(any_thread_of_inferior, any_live_thread_of_inferior): Use
	inf->non_exited_threads().
	(prune_threads, delete_exited_threads): Use all_threads_safe.
	(thread_change_ptid): Pass inferior pointer to find_thread_ptid.
	(set_resumed, set_running): Use all_non_exited_threads.
	(is_thread_state, is_stopped, is_exited, is_running)
	(is_executing): Delete.
	(set_executing, set_stop_requested, finish_thread_state): Use
	all_non_exited_threads.
	(print_thread_info_1): Use all_inferiors and all_threads.
	(thread_apply_all_command): Use all_non_exited_threads.
	(thread_find_command): Use all_threads.
	(update_threads_executing): Use all_non_exited_threads.
	* tid-parse.c (parse_thread_id): Use inf->threads.
	* x86-bsd-nat.c (x86bsd_dr_set): Use inf->non_exited_threads ().
2018-11-22 16:13:23 +00:00
Tom Tromey eefce37f62 Remove a VEC from remote.c
This removes the VEC from remote_g_packet_data, replacing it with a
std::vector.  This is a bit odd in that this object is never
destroyed, and is obstack-allocated.  I believe a gdbarch is never
destroyed, so this seemed ok.

Tested by the buildbot.

gdb/ChangeLog
2018-11-09  Tom Tromey  <tom@tromey.com>

	* remote.c (remote_g_packet_guess_s): Remove typedef and DEF_VEC.
	(struct remote_g_packet_data): Derive from allocate_on_obstack.
	<guesses>: Now a std::vector.
	(remote_g_packet_data_init, register_remote_g_packet_guess):
	Update.
	(remote_read_description_p): Update.  Return bool.
	(remote_target::read_description): Update.
	(struct remote_g_packet_guess): Add constructor.
2018-11-09 16:04:03 -07:00
Gary Benson 33b031ce7a Add missing va_end found by Coverity
This commit adds a missing va_end found by Coverity.

gdb/ChangeLog:

	* remote.c (remote_target::remote_send_printf): Add
	missing va_end found by Coverity.
2018-10-10 15:01:50 +01:00
Tom Tromey b926417afa Simple -Wshadow=local fixes
This fixes all the straightforward -Wshadow=local warnings in gdb.  A
few standard approaches are used here:

* Renaming an inner (or outer, but more commonly inner) variable;
* Lowering a declaration to avoid a clash;
* Moving a declaration into a more inner scope to avoid a clash,
  including the special case of moving a declaration into a loop header.

I did not consider any of the changes in this patch to be particularly
noteworthy, though of course they should all still be examined.

gdb/ChangeLog
2018-10-04  Tom Tromey  <tom@tromey.com>

	* ctf.c (SET_ARRAY_FIELD): Rename "u32".
	* p-valprint.c (pascal_val_print): Split inner "i" variable.
	* xtensa-tdep.c (xtensa_push_dummy_call): Declare "i" in loop
	header.
	* xstormy16-tdep.c (xstormy16_push_dummy_call): Declare "val" in
	more inner scope.
	* xcoffread.c (read_xcoff_symtab): Rename inner "symbol".
	* varobj.c (varobj_update): Rename inner "newobj",
	"type_changed".
	* valprint.c (generic_emit_char): Rename inner "buf".
	* valops.c (find_overload_match): Rename inner "temp".
	(value_struct_elt_for_reference): Declare "v" in more inner
	scope.
	* v850-tdep.c (v850_push_dummy_call): Rename "len".
	* unittests/array-view-selftests.c (run_tests): Rename inner
	"vec".
	* tui/tui-stack.c (tui_show_frame_info): Declare "i" in loop
	header.
	* tracepoint.c (merge_uploaded_trace_state_variables): Declare
	"tsv" in more inner scope.
	(print_one_static_tracepoint_marker): Rename inner
	"tuple_emitter".
	* tic6x-tdep.c (tic6x_analyze_prologue): Declare "inst" lower.
	(tic6x_push_dummy_call): Don't redeclare "addr".
	* target-float.c: Declare "dto" lower.
	* symtab.c (lookup_local_symbol): Rename inner "sym".
	(find_pc_sect_line): Rename inner "pc".
	* stack.c (print_frame): Don't redeclare "gdbarch".
	(return_command): Rename inner "gdbarch".
	* s390-tdep.c (s390_prologue_frame_unwind_cache): Renam inner
	"sp".
	* rust-lang.c (rust_internal_print_type): Declare "i" in loop
	header.
	* rs6000-tdep.c (ppc_process_record): Rename inner "addr".
	* riscv-tdep.c (riscv_push_dummy_call): Declare "info" in inner
	scope.
	* remote.c (remote_target::update_thread_list): Don't redeclare
	"tp".
	(remote_target::process_initial_stop_replies): Rename inner
	"thread".
	(remote_target::remote_parse_stop_reply): Don't redeclare "p".
	(remote_target::wait_as): Don't redeclare "stop_reply".
	(remote_target::get_thread_local_address): Rename inner
	"result".
	(remote_target::get_tib_address): Likewise.
2018-10-04 22:51:45 -06:00
Tom Tromey 65e65158c5 Use GNU style for metasyntactic variables in gdb
I searched for other spots that did not use the GNU style for
metasyntactic syntactic variables.  This patch fixes most of the ones
I found in gdb proper.  There are a few remaining in MI, but I was
unsure whether those should be touched.

gdb/ChangeLog
2018-09-16  Tom Tromey  <tom@tromey.com>

	* top.c (new_ui_command): Use GNU style for metasyntactic
	variables.
	* breakpoint.c (stopat_command): Use GNU style for metasyntactic
	variables.
	* maint.c (maintenance_translate_address): Remove "<>" around
	text.
	* interps.c (interpreter_exec_cmd): Use GNU style for
	metasyntactic variables.
	* nto-procfs.c (nto_procfs_target_info): Use GNU style for
	metasyntactic variables.
	* tracepoint.c (tfind_range_command): Use GNU style for
	metasyntactic variables.
	(tfind_outside_command): Likewise.
	(_initialize_tracepoint): Likewise.
	* remote.c (extended_remote_target::create_inferior): Use GNU
	style for metasyntactic variables.
	* sparc64-tdep.c (adi_examine_command): Use GNU style for
	metasyntactic variables.
	(adi_assign_command): Likewise.

gdb/testsuite/ChangeLog
2018-09-16  Tom Tromey  <tom@tromey.com>

	* gdb.base/new-ui.exp (do_execution_tests): Update.
	* gdb.base/dbx.exp (test_breakpoints): Update.
2018-09-16 06:25:17 -06:00
Szabolcs Nagy ff36536c92 Fix gdb/remote.c build failure
Add const qualifier to fix

/S/gdb/common/gdb_locale.h:35:27: error: deprecated conversion from string constant to 'char*' [-Werror=write-strings]
 # define _(String) (String)
                           ^
/S/gdb/remote.c:12844:19: note: in expansion of macro '_'
   char *err_msg = _("Tracepoint packet too large for target.");
                   ^
gdb/ChangeLog:

	* remote.c (remote_target::download_tracepoint): Change char* to
	const char*.
2018-08-08 11:31:11 +01:00
Simon Marchi a7f25a84f4 Fix compilation failure in remote.c
A recent patch introduced a few of these:

/home/emaisin/src/binutils-gdb/gdb/remote.c:12862:19: error: format not a string literal and no format arguments [-Werror=format-security]
     error (err_msg);
                   ^

Fix them by replacing the call to error with

  error ("%s", err_msg);

gdb/ChangeLog:

	* remote.c (remote_target::download_tracepoint): Fix format
	string errors.
2018-08-06 16:57:24 -04:00
Pedro Franco de Carvalho 3df3a985a4 Use get_remote_packet_size in download_tracepoint
This patch changes the remote target to use the remote packet size to
build QTDP packets, and to check if there is enough room for the
packet.

I changed the function to raise an error if the packet is too small,
instead of aborting gdb (through xsnprintf).  It isn't clear if gdb
will be in a consistent state with respect to the stub after this,
since it's possible that some packets will be sent but not others, and
there could be an incomplete tracepoint on the stub.

The char array used to build the packets is changed to a
gdb::char_vector and sized with the result from
get_remote_packet_size.

When checking if the buffer is large enough to hold the tracepoint
condition agent expression, the length of the expression is multiplied
by two, since it is encoded with two hex digits per expression
byte.  For simplicity, I assume that the result won't overflow, which
can happen for very long condition expressions.

gdb/ChangeLog:
2018-08-06  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* remote.c (remote_target::download_tracepoint): Remove BUF_SIZE.
	Replace array buf with gdb::char_vector buf, of size
	get_remote_packet_size ().  Replace references to buf and
	BUF_SIZE to buf.data () and buf.size ().  Replace strcpy, strcat
	and xsnprintf with snprintf.  Raise errors if the buffer is too
	small.
2018-08-06 16:34:02 -03:00
Pedro Franco de Carvalho aa6f3694ce Remove trailing '-' from the last QTDP action packet
The has_more predicate in remote_target::download_tracepoint always
evaluates to true, so the last action packet will be sent with a
trailing '-'.  This patch changes the predicate to remove the last
trailing '-'.

gdb/ChangeLog:
2018-08-06  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* remote.c (remote_target::download_tracepoint): Fix the has_more
	predicate in the QTDP action list iteration.
2018-08-06 16:30:17 -03:00
Pedro Franco de Carvalho 05abfc39c7 Fix indentation in remote_target::download_tracepoint
gdb/ChangeLog:
2018-08-06  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* remote.c (remote_target::download_tracepoint): Fix indentation
	in for block.
2018-08-06 16:27:47 -03:00
Tom Tromey 1576637036 Unused variable fixes related to conditional compilation
This patch fixes various unused variable warnings that are related to
conditional compilation.  In these cases, either the variable is now
protected by the same #if as its uses, or the declaration is simply
lowered into the conditionally-compiled block.

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

	* windows-nat.c (saved_context): Conditionally define.
	* remote.c (remote_target::remote_btrace_maybe_reopen):
	Conditionally declare "warned".
	* inflow.c (sigquit_ours): Conditionally define.
	(new_tty): Move "tty" declaration inside #if.
	* guile/guile.c (guile_datadir): Conditionally define.
	* charset.c (set_be_le_names): Move some declarations inside #if.
	* btrace.c (parse_xml_btrace): Move "errcode" declaration inside
	#if.
	(parse_xml_btrace_conf): Likewise.
2018-07-22 13:20:02 -06:00
Pedro Alves 4c7333b308 GDB: Work around D;PID handling bug in older GDBservers (PR gdb/23377)
This commit adds a GDB workaround for the GDBserver bug exposed by
commit f2ffa92bbc ("gdb: Eliminate the 'stop_pc' global"), so that
newer GDBs can continue working with older GDBservers.

gdb/ChangeLog:
2018-07-11  Pedro Alves  <palves@redhat.com>

	PR gdb/23377
	* remote.c (remote_target::remote_detach_pid): Call
	set_current_process.
2018-07-11 23:33:19 +01:00
Andrew Burgess 055303e28f gdb: Use add_setshow_zuinteger_unlimited_cmd in remote.c
Switch to use add_setshow_zuinteger_unlimited_cmd for some of the
control variables in remote.c.  The variables
hardware-watchpoint-limit, hardware-breakpoint-limit, and
hardware-watchpoint-length-limit are all changed.  For example, a user
will now see this:

    (gdb) show remote hardware-breakpoint-limit
    The maximum number of target hardware breakpoints is unlimited.

Instead of this:

    (gdb) show remote hardware-breakpoint-limit
    The maximum number of target hardware breakpoints is -1.

And can do this:

    (gdb) set remote hardware-breakpoint-limit unlimited

However, previously any negative value implied "unlimited", now only
-1, or the text "unlimited" can be used for unlimited.  Any other
negative value will give an error about invalid input.  This is a
small change in the user interface, but, hopefully, this will not
cause too many problems.

I've also added show functions for these three variables to allow for
internationalisation.

gdb/ChangeLog:

	* remote.c (show_hardware_watchpoint_limit): New function.
	(show_hardware_watchpoint_length_limit): New function.
	(show_hardware_breakpoint_limit): New function.
	(_initialize_remote): Use add_setshow_zuinteger_unlimited_cmd
	where appropriate, update help text.

gdb/doc/ChangeLog:

	* gdb.texinfo (Remote Configuration): Update descriptions for
	set/show of hardware-watchpoint-limit, hardware-breakpoint-limit,
	and hardware-watchpoint-length-limit variables.
2018-07-09 18:07:01 +01:00
Tom Tromey d7e15655a4 Remove ptid_equal
Remove ptid_equal in favor of using "==".

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

	* common/ptid.c (ptid_equal): Remove.
	* common/ptid.h (ptid_equal): Don't declare.
	* ada-tasks.c: Update.
	* breakpoint.c: Update.
	* common/agent.c: Update.
	* corelow.c: Update.
	* darwin-nat-info.c: Update.
	* darwin-nat.c: Update.
	* dcache.c: Update.
	* dtrace-probe.c: Update.
	* dummy-frame.c: Update.
	* fbsd-nat.c: Update.
	* frame.c: Update.
	* gdbthread.h: Update.
	* gnu-nat.c: Update.
	* go32-nat.c: Update.
	* inf-loop.c: Update.
	* inf-ptrace.c: Update.
	* infcall.c: Update.
	* infcmd.c: Update.
	* inflow.c: Update.
	* infrun.c: Update.
	* linux-fork.c: Update.
	* linux-nat.c: Update.
	* linux-thread-db.c: Update.
	* mi/mi-cmd-var.c: Update.
	* mi/mi-interp.c: Update.
	* mi/mi-main.c: Update.
	* nto-procfs.c: Update.
	* ppc-linux-tdep.c: Update.
	* procfs.c: Update.
	* python/py-inferior.c: Update.
	* python/py-record-btrace.c: Update.
	* python/py-record.c: Update.
	* ravenscar-thread.c: Update.
	* regcache.c: Update.
	* remote-sim.c: Update.
	* remote.c: Update.
	* sol-thread.c: Update.
	* solib.c: Update.
	* target.c: Update.
	* tui/tui-stack.c: Update.
	* varobj.c: Update.
	* windows-nat.c: Update.
	* windows-tdep.c: Update.

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

	* linux-low.c: Update.
	* lynx-low.c: Update.
	* mem-break.c: Update.
	* nto-low.c: Update.
	* remote-utils.c: Update.
	* server.c: Update.
	* spu-low.c: Update.
	* target.c: Update.
	* win32-low.c: Update.
2018-07-03 11:36:46 -06:00
Tom Tromey 26a57c9256 Remove ptid_match
This removes ptid_match in favor of the ptid_t::matches method.

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

	* common/ptid.c (ptid_match): Remove.
	* common/ptid.h (ptid_match): Don't declare.
	* fbsd-nat.c: Update.
	* infcmd.c: Update.
	* infrun.c: Update.
	* linux-nat.c: Update.
	* record-btrace.c: Update.
	* regcache.c: Update.
	* remote.c: Update.

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

	* server.c: Update.
2018-07-03 11:36:45 -06:00
Tom Tromey 0e998d966b Remove ptid_is_pid
This removes ptid_is_pid in favor of the ptid_t::is_pid method.

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

	* common/ptid.c (ptid_is_pid): Remove.
	* common/ptid.h (ptid_is_pid): Don't declare.
	* infrun.c: Update.
	* linux-nat.c: Update.
	* mi/mi-interp.c: Update.
	* remote.c: Update.
	* thread.c: Update.

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

	* linux-low.c: Update.
2018-07-03 11:36:44 -06:00
Tom Tromey e38504b392 Remove ptid_get_lwp
This removes ptid_get_lwp in favor of calling the ptid_t::lwp method.

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

	* common/ptid.c (ptid_get_lwp): Remove.
	* common/ptid.h (ptid_get_lwp): Don't declare.
	* aarch64-linux-nat.c: Update.
	* ada-tasks.c: Update.
	* aix-thread.c: Update.
	* amd64-linux-nat.c: Update.
	* arm-linux-nat.c: Update.
	* corelow.c: Update.
	* fbsd-nat.c: Update.
	* fbsd-tdep.c: Update.
	* gnu-nat.c: Update.
	* i386-cygwin-tdep.c: Update.
	* i386-gnu-nat.c: Update.
	* i386-linux-nat.c: Update.
	* ia64-linux-nat.c: Update.
	* inf-ptrace.c: Update.
	* infrun.c: Update.
	* linux-fork.c: Update.
	* linux-nat.c: Update.
	* linux-tdep.c: Update.
	* linux-thread-db.c: Update.
	* mips-linux-nat.c: Update.
	* nat/aarch64-linux-hw-point.c: Update.
	* nat/aarch64-linux.c: Update.
	* nat/linux-btrace.c: Update.
	* nat/linux-osdata.c: Update.
	* nat/linux-procfs.c: Update.
	* nat/x86-linux-dregs.c: Update.
	* obsd-nat.c: Update.
	* ppc-fbsd-nat.c: Update.
	* ppc-linux-nat.c: Update.
	* procfs.c: Update.
	* python/py-infthread.c: Update.
	* ravenscar-thread.c: Update.
	* remote.c: Update.
	* s390-linux-nat.c: Update.
	* sol-thread.c: Update.
	* sol2-tdep.c: Update.
	* spu-linux-nat.c: Update.
	* x86-linux-nat.c: Update.
	* xtensa-linux-nat.c: Update.

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

	* linux-low.c: Update.
	* linux-mips-low.c: Update.
	* lynx-low.c: Update.
	* nto-low.c: Update.
	* remote-utils.c: Update.
	* server.c: Update.
	* spu-low.c: Update.
	* target.c: Update.
	* thread-db.c: Update.
2018-07-03 11:36:43 -06:00
Tom Tromey e99b03dcf4 Remove ptid_get_pid
This removes ptid_get_pid in favor of calling the ptid_t::pid method.

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

	* common/ptid.c (ptid_get_pid): Remove.
	* common/ptid.h (ptid_get_pid): Don't declare.
	* aarch64-linux-nat.c: Update.
	* ada-lang.c: Update.
	* aix-thread.c: Update.
	* alpha-bsd-nat.c: Update.
	* amd64-fbsd-nat.c: Update.
	* amd64-linux-nat.c: Update.
	* arm-linux-nat.c: Update.
	* arm-nbsd-nat.c: Update.
	* auxv.c: Update.
	* break-catch-syscall.c: Update.
	* breakpoint.c: Update.
	* bsd-uthread.c: Update.
	* corelow.c: Update.
	* ctf.c: Update.
	* darwin-nat.c: Update.
	* fbsd-nat.c: Update.
	* fbsd-tdep.c: Update.
	* gcore.c: Update.
	* gnu-nat.c: Update.
	* hppa-nbsd-nat.c: Update.
	* hppa-obsd-nat.c: Update.
	* i386-fbsd-nat.c: Update.
	* ia64-linux-nat.c: Update.
	* inf-ptrace.c: Update.
	* infcmd.c: Update.
	* inferior.c: Update.
	* inferior.h: Update.
	* inflow.c: Update.
	* infrun.c: Update.
	* linux-fork.c: Update.
	* linux-nat.c: Update.
	* linux-tdep.c: Update.
	* linux-thread-db.c: Update.
	* m68k-bsd-nat.c: Update.
	* mi/mi-interp.c: Update.
	* mi/mi-main.c: Update.
	* mips-linux-nat.c: Update.
	* mips-nbsd-nat.c: Update.
	* mips64-obsd-nat.c: Update.
	* nat/aarch64-linux-hw-point.c: Update.
	* nat/aarch64-linux.c: Update.
	* nat/linux-btrace.c: Update.
	* nat/linux-osdata.c: Update.
	* nat/linux-procfs.c: Update.
	* nat/x86-linux-dregs.c: Update.
	* nto-procfs.c: Update.
	* obsd-nat.c: Update.
	* ppc-linux-nat.c: Update.
	* ppc-nbsd-nat.c: Update.
	* ppc-obsd-nat.c: Update.
	* proc-service.c: Update.
	* procfs.c: Update.
	* python/py-inferior.c: Update.
	* python/py-infthread.c: Update.
	* ravenscar-thread.c: Update.
	* record.c: Update.
	* remote-sim.c: Update.
	* remote.c: Update.
	* rs6000-nat.c: Update.
	* s390-linux-nat.c: Update.
	* sh-nbsd-nat.c: Update.
	* sol-thread.c: Update.
	* sparc-nat.c: Update.
	* sparc64-tdep.c: Update.
	* spu-linux-nat.c: Update.
	* spu-tdep.c: Update.
	* target-debug.h: Update.
	* target.c: Update.
	* thread.c: Update.
	* tid-parse.c: Update.
	* tracefile-tfile.c: Update.
	* vax-bsd-nat.c: Update.
	* windows-nat.c: Update.
	* x86-linux-nat.c: Update.
	* x86-nat.c: Update.

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

	* linux-low.c: Update.
	* linux-mips-low.c: Update.
	* lynx-low.c: Update.
	* mem-break.c: Update.
	* nto-low.c: Update.
	* remote-utils.c: Update.
	* server.c: Update.
	* spu-low.c: Update.
	* target.c: Update.
	* tracepoint.c: Update.
2018-07-03 11:36:42 -06:00