Commit Graph

31 Commits

Author SHA1 Message Date
Joel Brobecker b811d2c292 Update copyright year range in all GDB files.
gdb/ChangeLog:

        Update copyright year range in all GDB files.
2020-01-01 10:20:53 +04:00
Tom Tromey 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 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
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
Joel Brobecker e2882c8578 Update copyright year range in all GDB files
gdb/ChangeLog:

        Update copyright year range in all GDB files
2018-01-02 07:38:06 +04:00
Simon Marchi b89641bab5 python: Add qualified parameter to gdb.Breakpoint
This patch adds the possibility to pass a qualified=True|False parameter
when creating a breakpoint in Python.  It is equivalent to using
-qualified in a linespec.  The parameter actually accepts any Python
value, and converts it to boolean using Python's standard rules for
that (https://docs.python.org/3/library/stdtypes.html#truth).

Unlike the -source/-line/-function/-label parameters, it is possible to
use -qualified with a "normal" (non-explicit) linespec.  Therefore, it
is possible (unlike these other parameters) to use this new parameter
along with the spec parameter.

I updated the py-breakpoint.exp test.  To be able to test multiple
locations using a namespace, I had to switch the test case to compile as
C++.  If we really wanted to, we could run it as both C and C++, but
omit the C++-specific parts when running it as C.

gdb/ChangeLog:

	* location.h (string_to_event_location): Add match_type
	parameter.
	* location.c (string_to_event_location): Likewise.
	* python/py-breakpoint.c (bppy_init): Handle qualified
	parameter.

gdb/doc/ChangeLog:

	* python.texi (Manipulating breakpoints using Python): Document
	qualified parameter to gdb.Breakpoint.

gdb/testsuite/ChangeLog:

	* gdb.python/py-breakpoint.c (foo_ns::multiply): New function.
	* gdb.python/py-breakpoint.exp: Compile the test case as c++,
	call test_bkpt_qualified.
	(test_bkpt_qualified): New proc.
2017-12-13 11:44:28 -05:00
Keith Seitz fa6eb693cf Validate explicit locations with early termination
breakpoints/22569 involves an internal error generated by the rather
innocent looking command:

(gdb) break -source test.cpp main
.../linespec.c:3302: internal-error: void decode_line_full(...):
Assertion `result.size () == 1 || canonical->pre_expanded' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)

The input string is tokenized into "-source", "test.cpp", and "main"
(input parsing breaks on whitespace). create_breakpoint is then called with
the explicit location (containing only the source file name) and "main" as
the extra_string argument.

No SaLs are created for this underspecified explicit location, and the
"result.size () == 1" evaluates false (as does the pre_expanded condition).
This triggers the assertion.

Normally string_to_explicit_location validates the input string.  However,
the presence of the string "main" causes the parser to exit early:

   802        else
   803          {
   804            /* End of the explicit location specification.
   805               Stop parsing and return whatever explicit location was
   806               parsed.  */
   807            *argp = start;
   808            return location;
   809          }

This bypasses the validation that is done a few lines down in this function
which would have emitted the expected error.  This patch fixes that.

Additionally, this patch also fixes an inconsistency with error reporting
in this use case:

(gdb) b -source foo
Source filename requires function, label, or line offset.
(gdb) b -source foo main
No source file named foo.

These two commands should have elicited the same error message.

gdb/ChangeLog:

	PR breakpoints/22569
	* location.c (string_to_explicit_location): When terminating
	parsing early, break out of enclosing loop instead of returning.

gdb/testsuite/ChangeLog:

	PR breakpoints/22569
	* gdb.linespec/ls-errs.exp: Change expected result of "break
	-source this file has spaces.c -line 3".
	Check that an explicit source file followed by whitespace is
	identified as an invalid explicit location.
2017-12-07 15:27:35 -08:00
Pedro Alves a20714ff39 Make "break foo" find "A::foo", A::B::foo", etc. [C++ and wild matching]
This patch teaches GDB about setting breakpoints in all scopes
(namespaces and classes) by default.

Here's a contrived example:

  (gdb) b func<tab>
  (anonymous namespace)::A::function()            Bn::(anonymous namespace)::B::function()        function(int, int)
  (anonymous namespace)::B::function()            Bn::(anonymous namespace)::function()           gdb::(anonymous namespace)::A::function()
  (anonymous namespace)::B::function() const      Bn::(anonymous namespace)::function(int, int)   gdb::(anonymous namespace)::function()
  (anonymous namespace)::function()               Bn::B::func()                                   gdb::(anonymous namespace)::function(int, int)
  (anonymous namespace)::function(int, int)       Bn::B::function()                               gdb::A::func()
  A::func()                                       Bn::func()                                      gdb::A::function()
  A::function()                                   Bn::function()                                  gdb::func()
  B::func()                                       Bn::function(int, int)                          gdb::function()
  B::function()                                   Bn::function(long)                              gdb::function(int, int)
  B::function() const                             func()                                          gdb::function(long)
  B::function_const() const                       function()
  (gdb) b function
  Breakpoint 1 at 0x4005ce: function. (26 locations)

  (gdb) b B::function<tab>
  (anonymous namespace)::B::function()        B::function() const                         Bn::B::function()
  (anonymous namespace)::B::function() const  B::function_const() const
  B::function()                               Bn::(anonymous namespace)::B::function()
  (gdb) b B::function
  Breakpoint 1 at 0x40072c: B::function. (6 locations)

To get back the original behavior of interpreting the function name as
a fully-qualified name, you can use the new "-qualified" (or "-q")
option/flag (added by this commit).  For example:

 (gdb) b B::function
 (anonymous namespace)::B::function()        B::function() const                         Bn::B::function()
 (anonymous namespace)::B::function() const  B::function_const() const
 B::function()                               Bn::(anonymous namespace)::B::function()

vs:

 (gdb) b -qualified B::function
 B::function()              B::function() const        B::function_const() const

I've chosen "-qualified" / "-q" because "-f" (for "full" or
"fully-qualified") is already taken for "-function".

Note: the "-qualified" option works with both linespecs and explicit
locations.  I.e., these are equivalent:

 (gdb) b -q func
 (gdb) b -q -f func

and so are these:

 (gdb) b -q filename.cc:func
 (gdb) b -q -s filename.cc -f func
 (gdb) b -s filename.cc -q -f func
 (gdb) b -s filename.cc -f func -q

To better understand why I consider wild matching the better default,
consider what happens when we get to the point when _all_ of GDB is
wrapped under "namespace gdb {}".  I have a patch series that does
that, and when I started debugging that GDB, I immediately became
frustrated.  You'd have to write "b gdb::internal_error", "b
gdb::foo", "b gdb::bar", etc. etc., which gets annoying pretty
quickly.  OTOH, consider how this makes it very easy to set
breakpoints in classes wrapped in anonymous namespaces.  You just
don't think of them, GDB finds the symbols for you automatically.

(At the Cauldron a couple months ago, several people told me that they
run into a similar issue when debugging other C++ projects.  One
example was when debugging LLVM, which puts all its code under the
"llvm" namespace.)

Implementation-wise, what the patch does is:

  - makes C++ symbol name hashing only consider the last component of
    a symbol name. (so that we can look up symbol names by
    last-component name only).

  - adds a C++ symbol name matcher for symbol_name_match_type::WILD,
    which ignores missing leading specifiers / components.

  - adjusts a few preexisting testsuite tests to use "-qualified" when
    they mean it.

  - adds new testsuite tests.

  - adds unit tests.

Grows the gdb.linespec/ tests like this:

  -# of expected passes           7823
  +# of expected passes           8977

gdb/ChangeLog:
2017-11-29  Pedro Alves  <palves@redhat.com>

	* NEWS: Mention that breakpoints on C++ functions are now set on
	on all namespaces/classes by default, and mention "break
	-qualified".
	* ax-gdb.c (agent_command_1): Adjust to pass a
	symbol_name_match_type to new_linespec_location.
	* breakpoint.c (parse_breakpoint_sals): Adjust to
	get_linespec_location's return type change.
	(strace_marker_create_sals_from_location): Adjust to pass a
	symbol_name_match_type to new_linespec_location.
	(strace_marker_decode_location): Adjust to get_linespec_location's
	return type change.
	(strace_command): Adjust to pass a symbol_name_match_type to
	new_linespec_location.
	(LOCATION_HELP_STRING): Add paragraph about wildmatching, and
	mention "-qualified".
	* c-lang.c (cplus_language_defn): Install cp_search_name_hash.
	* completer.c (explicit_location_match_type::MATCH_QUALIFIED): New
	enumerator.
	(complete_address_and_linespec_locations): New parameter
	'match_type'.  Pass it down.
	(explicit_options): Add "-qualified".
	(collect_explicit_location_matches): Pass the requested match type
	to the linespec completers.  Handle MATCH_QUALIFIED.
	(location_completer): Handle "-qualified" combined with linespecs.
	* cp-support.c (cp_search_name_hash): New.
	(cp_symbol_name_matches_1): Implement wild matching for C++.
	(cp_fq_symbol_name_matches): Reimplement.
	(cp_get_symbol_name_matcher): Return different matchers depending
	on the lookup name's match type.
	(selftests::test_cp_symbol_name_matches): Add wild matching tests.
	* cp-support.h (cp_search_name_hash): New declaration.
	* dwarf2read.c
	(selftests::dw2_expand_symtabs_matching::test_symbols): Add
	symbols.
	(test_dw2_expand_symtabs_matching_symbol): Add wild matching
	tests.
	* guile/scm-breakpoint.c (gdbscm_register_breakpoint_x): Adjust to
	pass a symbol_name_match_type to new_linespec_location.
	* linespec.c (linespec_parse_basic): Lookup function symbols using
	the parser's symbol name match type.
	(convert_explicit_location_to_linespec): New
	symbol_name_match_type parameter.  Pass it down to
	find_linespec_symbols.
	(convert_explicit_location_to_sals): Pass the location's name
	match type to convert_explicit_location_to_linespec.
	(parse_linespec): New match_type parameter.  Save it in the
	parser.
	(linespec_parser_new): Default to symbol_name_match_type::WILD.
	(linespec_complete_function): New symbol_name_match_type
	parameter.  Use it.
	(complete_linespec_component): Pass down the parser's recorded
	name match type.
	(linespec_complete_label): New symbol_name_match_type parameter.
	Use it.
	(linespec_complete): New symbol_name_match_type parameter.  Save
	it in the parser and pass it down.  Adjust to
	get_linespec_location's prototype change.
	(find_function_symbols, find_linespec_symbols): New
	symbol_name_match_type parameter.  Pass it down instead of
	assuming symbol_name_match_type::WILD.
	* linespec.h (linespec_complete, linespec_complete_function)
	(linespec_complete_label): New symbol_name_match_type parameter.
	* location.c (event_location::linespec_location): Now a struct
	linespec_location.
	(EL_LINESPEC): Adjust.
	(initialize_explicit_location): Default to
	symbol_name_match_type::WILD.
	(new_linespec_location): New symbol_name_match_type parameter.
	Record it in the location.
	(get_linespec_location): Now returns a struct linespec_location.
	(new_explicit_location): Also copy func_name_match_type.
	(explicit_to_string_internal)
	(string_to_explicit_location): Handle "-qualified".
	(copy_event_location): Adjust to LINESPEC_LOCATION type change.
	Copy symbol_name_match_type fields.
	(event_location_deleter::operator()): Adjust to LINESPEC_LOCATION
	type change.
	(event_location_to_string): Adjust to LINESPEC_LOCATION type
	change.  Handle "-qualfied".
	(string_to_explicit_location): Handle "-qualified".
	(string_to_event_location_basic): New symbol_name_match_type
	parameter.  Pass it down.
	(string_to_event_location): Handle "-qualified".
	* location.h (struct linespec_location): New.
	(explicit_location::func_name_match_type): New field.
	(new_linespec_location): Now returns a const linespec_location *.
	(string_to_event_location_basic): New symbol_name_match_type
	parameter.
	(explicit_completion_info::saw_explicit_location_option): New
	field.
	* mi/mi-cmd-break.c (mi_cmd_break_insert_1): Adjust to pass a
	symbol_name_match_type to new_linespec_location.
	* python/py-breakpoint.c (bppy_init): Likewise.
	* python/python.c (gdbpy_decode_line): Likewise.

gdb/testsuite/ChangeLog:
2017-11-29  Pedro Alves  <palves@redhat.com>

	* gdb.base/langs.exp: Use -qualified.
	* gdb.cp/meth-typedefs.exp: Use -qualified, and add tests without
	it.
	* gdb.cp/namespace.exp: Use -qualified.
	* gdb.linespec/cpcompletion.exp (overload-2, fqn, fqn-2)
	(overload-3, template-overload, template-ret-type, const-overload)
	(const-overload-quoted, anon-ns, ambiguous-prefix): New
	procedures.
	(test_driver): Call them.
	* gdb.cp/save-bp-qualified.cc: New.
	* gdb.cp/save-bp-qualified.exp: New.
	* gdb.linespec/explicit.exp: Test -qualified.
	* lib/completion-support.exp (completion::explicit_opts_list): Add
	"-qualified".
	* lib/gdb.exp (gdb_breakpoint): Handle "qualified".

gdb/doc/ChangeLog:
2017-11-29  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Linespec Locations): Document how "function" is
	interpreted in C++ and Ada.  Document "-qualified".
	(Explicit Locations): Document how "-function" is interpreted in
	C++ and Ada.  Document "-qualified".
2017-11-29 19:43:48 +00:00
Sergio Durigan Junior 935676c92f Convert generic probe interface to C++ (and perform some cleanups)
This patch converts the generic probe interface (gdb/probe.[ch]) to
C++, and also performs some cleanups that were on my TODO list for a
while.

The main changes were the conversion of 'struct probe' to 'class
probe', and 'struct probe_ops' to 'class static_probe_ops'.  The
former now contains all the "dynamic", generic methods that act on a
probe + the generic data related to it; the latter encapsulates a
bunch of "static" methods that relate to the probe type, but not to a
specific probe itself.

I've had to do a few renamings (e.g., on 'struct bound_probe' the
field is called 'probe *prob' now, instead of 'struct probe *probe')
because GCC was complaining about naming the field using the same name
as the class.  Nothing major, though.  Generally speaking, the logic
behind and the design behind the code are the same.

Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies.  But it
should be easier to review in separate logical units.

I've regtested this patch on BuildBot, no regressions found.

gdb/ChangeLog:
2017-11-22  Sergio Durigan Junior  <sergiodj@redhat.com>

	* break-catch-throw.c (fetch_probe_arguments): Use
	'probe.prob' instead of 'probe.probe'.
	* breakpoint.c (create_longjmp_master_breakpoint): Call
	'can_evaluate_arguments' and 'get_relocated_address' methods
	from probe.
	(create_exception_master_breakpoint): Likewise.
	(add_location_to_breakpoint): Use 'sal->prob' instead of
	'sal->probe'.
	(bkpt_probe_insert_location): Call 'set_semaphore' method from
	probe.
	(bkpt_probe_remove_location): Likewise, for 'clear_semaphore'.
	* elfread.c (elf_get_probes): Use 'static_probe_ops' instead
	of 'probe_ops'.
	(probe_key_free): Call 'delete' on probe.
	(check_exception_resume): Use 'probe.prob' instead of
	'probe.probe'.
	* location.c (string_to_event_location_basic): Call
	'probe_linespec_to_static_ops'.
	* probe.c (class any_static_probe_ops): New class.
	(any_static_probe_ops any_static_probe_ops): New variable.
	(parse_probes_in_pspace): Receive 'static_probe_ops' as
	argument.  Adjust code to reflect change.
	(parse_probes): Use 'static_probe_ops' instead of
	'probe_ops'.  Adjust code to reflect change.
	(find_probes_in_objfile): Call methods to get name and
	provider from probe.
	(find_probe_by_pc): Use 'result.prob' instead of
	'result.probe'.  Call 'get_relocated_address' method from
	probe.
	(collect_probes): Adjust comment and argument list to receive
	'static_probe_ops' instead of 'probe_ops'.  Adjust code to
	reflect change.  Call necessary methods from probe.
	(compare_probes): Call methods to get name and provider from
	probes.
	(gen_ui_out_table_header_info): Receive 'static_probe_ops'
	instead of 'probe_ops'.  Use 'std::vector' instead of VEC,
	adjust code accordingly.
	(print_ui_out_not_applicables): Likewise.
	(info_probes_for_ops): Rename to...
	(info_probes_for_spops): ...this.  Receive 'static_probe_ops'
	as argument instead of 'probe_ops'.  Adjust code.  Call
	necessary methods from probe.
	(info_probes_command): Use 'info_probes_for_spops'.
	(enable_probes_command): Pass correct argument to
	'collect_probes'.  Call methods from probe.
	(disable_probes_command): Likewise.
	(get_probe_address): Move to 'any_static_probe_ops::get_address'.
	(get_probe_argument_count): Move to
	'any_static_probe_ops::get_argument_count'.
	(can_evaluate_probe_arguments): Move to
	'any_static_probe_ops::can_evaluate_arguments'.
	(evaluate_probe_argument): Move to
	'any_static_probe_ops::evaluate_argument'.
	(probe_safe_evaluate_at_pc): Use 'probe.prob' instead of
	'probe.probe'.
	(probe_linespec_to_ops): Rename to...
	(probe_linespec_to_static_ops): ...this.  Adjust code.
	(probe_any_is_linespec): Rename to...
	(any_static_probe_ops::is_linespec): ...this.
	(probe_any_get_probes): Rename to...
	(any_static_probe_ops::get_probes): ...this.
	(any_static_probe_ops::type_name): New method.
	(any_static_probe_ops::gen_info_probes_table_header): New
	method.
	(compute_probe_arg): Use 'pc_probe.prob' instead of
	'pc_probe.probe'.  Call methods from probe.
	(compile_probe_arg): Likewise.
	(std::vector<const probe_ops *> all_probe_ops): Delete.
	(std::vector<const static_probe_ops *> all_static_probe_ops):
	New variable.
	(_initialize_probe): Use 'all_static_probe_ops' instead of
	'all_probe_ops'.
	* probe.h (struct info_probe_column) <field_name>: Delete
	extraneous newline
	(info_probe_column_s): Delete type and VEC.
	(struct probe_ops): Delete.  Replace with...
	(class static_probe_ops): ...this and...
	(clas probe): ...this.
	(struct bound_probe) <bound_probe>: Delete extraneous
	newline.  Adjust constructor to receive 'probe' instead of
	'struct probe'.
	<probe>: Rename to...
	<prob>: ...this.  Delete extraneous newline.
	<objfile>: Delete extraneous newline.
	(register_probe_ops): Delete unused prototype.
	(info_probes_for_ops): Rename to...
	(info_probes_for_spops): ...this.  Adjust comment.
	(get_probe_address): Move to 'probe::get_address'.
	(get_probe_argument_count): Move to
	'probe::get_argument_count'.
	(can_evaluate_probe_arguments): Move to
	'probe::can_evaluate_arguments'.
	(evaluate_probe_argument): Move to 'probe::evaluate_argument'.
	* solib-svr4.c (struct svr4_info): Adjust comment.
	(struct probe_and_action) <probe>: Rename to...
	<prob>: ...this.
	(register_solib_event_probe): Receive 'probe' instead of
	'struct probe' as argument.  Use 'prob' instead of 'probe'
	when applicable.
	(solib_event_probe_action): Call 'get_argument_count' method
	from probe.  Adjust comment.
	(svr4_handle_solib_event): Adjust comment.  Call
	'evaluate_argument' method from probe.
	(svr4_create_probe_breakpoints): Call 'get_relocated_address'
	from probe.
	(svr4_create_solib_event_breakpoints): Use 'probe' instead of
	'struct probe'.  Call 'can_evaluate_arguments' from probe.
	* symfile.h: Forward declare 'class probe' instead of 'struct
	probe'.
	* symtab.h: Likewise.
	(struct symtab_and_line) <probe>: Rename to...
	<prob>: ...this.
	* tracepoint.c (start_tracing): Use 'prob' when applicable.
	Call probe methods.
	(stop_tracing): Likewise.
2017-11-22 19:13:44 -05:00
Tom Tromey f2fc30156c Constify some linespec functions
This changes a few linespec functions to work on "const char *" and
then fixes up all the callers.  This allows further constification
elsewhere.

gdb/ChangeLog
2017-09-27  Tom Tromey  <tom@tromey.com>

	* tracepoint.c (info_scope_command): Constify.
	* python/python.c (gdbpy_decode_line): Constify.
	* python/py-breakpoint.c (bppy_init): Constify.
	* mi/mi-cmd-break.c (mi_cmd_break_insert_1): Constify.
	* location.h: (new_linespec_location)
	(string_to_event_location_basic, string_to_event_location):
	Constify.
	* location.c (new_linespec_location)
	(string_to_event_location_basic, string_to_event_location):
	Constify.
	* linespec.h (decode_line_with_current_source)
	(decode_line_with_last_displayed, linespec_lex_to_end): Constify.
	* linespec.c (linespec_lex_to_end)
	(decode_line_with_current_source)
	(decode_line_with_last_displayed): Constify.
	* guile/scm-breakpoint.c (gdbscm_register_breakpoint_x):
	Constify.
	* cli/cli-cmds.c (edit_command, list_command): Constify.
	* breakpoint.h (until_break_command, watch_command_wrapper)
	(awatch_command_wrapper, rwatch_command_wrapper)
	(init_ada_exception_breakpoint): Constify.
	* breakpoint.c (break_command_1, dprintf_command)
	(break_range_command, watch_command_wrapper)
	(rwatch_command_wrapper, awatch_command_wrapper)
	(until_break_command, init_ada_exception_breakpoint)
	(strace_marker_create_sals_from_location, trace_command)
	(ftrace_command, strace_command, struct tracepoint): Constify.
	* ax-gdb.c (agent_command_1): Constify.
	* ada-lang.c (ada_exception_sal): Constify.
2017-09-27 08:44:45 -06:00
Tom Tromey f1735a53a6 Rename _const functions to use overloading instead
This renames a few functions -- skip_spaces_const,
skip_to_space_const, get_number_const, extract_arg_const -- to drop
the "_const" suffix and instead rely on overloading.

This makes future const fixes simpler by reducing the number of lines
that must be changed.  I think it is also not any less clear, as all
these functions have the same interface as their non-const versions by
design.  Furthermore there's an example of using an overload in-tree
already, namely check_for_argument.

This patch was largely created using some perl one-liners; then a few
fixes were applied by hand.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

	* common/common-utils.h (skip_to_space): Remove macro, redeclare
	as function.
	(skip_to_space): Rename from skip_to_space_const.
	* common/common-utils.c (skip_to_space): New function.
	(skip_to_space): Rename from skip_to_space_const.
	* cli/cli-utils.h (get_number): Rename from get_number_const.
	(extract_arg): Rename from extract_arg_const.
	* cli/cli-utils.c (get_number): Rename from get_number_const.
	(extract_arg): Rename from extract_arg_const.
	(number_or_range_parser::get_number): Use ::get_number.
	* aarch64-linux-tdep.c, ada-lang.c, arm-linux-tdep.c, ax-gdb.c,
	break-catch-throw.c, breakpoint.c, cli/cli-cmds.c, cli/cli-dump.c,
	cli/cli-script.c, cli/cli-setshow.c, compile/compile.c,
	completer.c, demangle.c, disasm.c, findcmd.c, linespec.c,
	linux-tdep.c, linux-thread-db.c, location.c, mi/mi-parse.c,
	minsyms.c, nat/linux-procfs.c, printcmd.c, probe.c,
	python/py-breakpoint.c, record.c, rust-exp.y, serial.c, stack.c,
	stap-probe.c, tid-parse.c, tracepoint.c: Update all callers.
2017-09-11 15:46:12 -06:00
Pedro Alves c6756f62e0 Rewrite/enhance explicit locations completer, parse left->right
One of the most annoying (to me) things about GDB's completion is when
you have overloads in your program, and you want to set a breakpoint
in one of them:

 void function(int);  // set breakpoint here.
 void function(long);

 (gdb) b -f func[TAB]
 (gdb) b -f function(       # ok, gdb completed as much as possible.
 (gdb) b -f function([TAB]  # show me the overloads, please.
 <_all_ symbols in the program are shown...>

E.g., when debugging GDB, that'd be:

 (gdb) b -f function([TAB]
 (anonymous namespace)::get_global()::global  pt_insn_get_offset@plt                       scm_new_port_table_entry
 asprintf                                     pt_pkt_alloc_decoder                         scm_new_port_table_entry@plt
 asprintf@plt                                 pt_pkt_alloc_decoder@plt                     scm_out_of_range
 bt_ctf_get_char_array                        pt_pkt_sync_forward                          scm_out_of_range@plt
 bt_ctf_get_char_array@plt                    pt_pkt_sync_forward@plt                      scm_putc
 bt_ctf_get_uint64                            pwrite                                       scm_putc@plt
 bt_ctf_get_uint64@plt                        pwrite@plt                                   scm_reverse_x
 bt_ctf_iter_read_event                       PyErr_Restore                                scm_reverse_x@plt
 bt_ctf_iter_read_event@plt                   PyErr_Restore@plt                            scm_set_port_filename_x
 <snip...>

Now that's a load of completely useless completions.

The reason GDB offers those is that the completer relies on readline
figuring out the completion word point in the input line based on the
language's word break characters, which include "(".  So readline
tells the completer to complete on "", the string that is after '('.
Likewise, if you type "function(i[TAB]" to try to complete to "int",
you're out of luck.  GDB shows you all the symbols in the program that
start with "i"...  This makes sense for the expression completer, as
what you'd want to type is e.g., a global variable, say:

(gdb) print function(i[TAB]

but, it makes no sense when specifying a function name for a
breakpoint location.

To get around that limitation, users need to quote the function name,
like:

 (gdb) b -f 'function([TAB]
 function(int)      function(long)
 (gdb) b 'function(i[TAB]
 (gdb) b 'function(int)' # now completes correctly!

Note that the quoting is only necessary for completion.  Creating the
breakpoint does not require the quoting:

 (gdb) b -f function(int) [RET]
 Breakpoint 1 at ....

This patch removes this limitation.

(
Actually, it's a necessary patch, though not sufficient.  That'll
start working correctly by the end of the series.  With this patch, if try it,
you'll see:

 (gdb) b -f function(i[TAB]
 (gdb) b -f function

i.e., gdb strips everything after the "(".  That's caused by some code
in symtab.c that'll be eliminated further down the series.  These
patches are all unfortunately interrelated, which is also the reason
new tests only appear much later in the series.
But let's ignore that reality for the remainder of the description.
)

So... this patch gets rid of the need for quoting.

It does that by adding a way for a completer to control the exact
completion word point that readline should start the completion
request for, instead of letting readline try to figure it out using
the current language's word break chars array, and often failing.

In the case above, we want the completer to figure out that it's
completing a function name that starts with "function(i".  It now
does.

It took me a while to figure out a way to ask readline to "use this
exact word point", and for a while I feared that it'd be impossible
with current readline (and having to rely on master readline for core
functionality is something I'd like to avoid very much).  Eventually,
after several different attempts, I came up with what is described in
the comment above gdb_custom_word_point_brkchars in the patch.

With this patch, the handle_brkchars phase of the explicit location
completer advances the expected word point as it parses the input line
left to right, until it figures out exactly what we're completing,
instead of expecting readline to break the string using the word break
characters, and then having the completer heuristically fix up a bad
decision by parsing the input string backwards.  This allows correctly
knowning that we're completing a symbol name after -function, complete
functions without quoting, etc.

Later, we'll make use of this same mechanims to implement a proper
linespec completer that avoids need for quoting too.

gdb/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (ada_collect_symbol_completion_matches): Add
	complete_symbol_mode parameter.
	* cli/cli-cmds.c (complete_command): Get the completion result out
	of the handle_brkchars tracker if used a custom word point.
	* completer.c: Include "linespec.h".
	(enum explicit_location_match_type) <MATCH_LINE>: New enumerator.
	(advance_to_expression_complete_word_point): New.
	(completion_tracker::completes_to_completion_word): New.
	(complete_files_symbols): Pass down
	complete_symbol_mode::EXPRESSION.
	(explicit_options, probe_options): New.
	(collect_explicit_location_matches): Complete on the
	explictit_loc->foo instead of word.  Use
	linespec_complete_function.  Handle MATCH_LINE.  Handle offering
	keyword and options completions.
	(backup_text_ptr): Delete.
	(skip_keyword): New.
	(complete_explicit_location): Remove 'word' parameter.  Add
	language, quoted_arg_start and quoted_arg_end parameters.
	Rewrite, parsing left to right.
	(location_completer): Rewrite.
	(location_completer_handle_brkchars): New function.
	(symbol_completer): Pass down complete_symbol_mode::EXPRESSION.
	(enum complete_line_internal_reason): Adjust comments.
	(completion_tracker::discard_completions): New.
	(completer_handle_brkchars_func_for_completer): Handle
	location_completer.
	(gdb_custom_word_point_brkchars)
	(gdb_org_rl_basic_quote_characters): New.
	(gdb_completion_word_break_characters_throw)
	(completion_find_completion_word): Handle trackers that use a
	custom word point.
	(completion_tracker::advance_custom_word_point_by): New.
	(completion_tracker::build_completion_result): Don't rely on
	readline appending the quote char.
	(gdb_rl_attempted_completion_function_throw): Handle trackers that
	use a custom word point.
	(gdb_rl_attempted_completion_function): Restore
	rl_basic_quote_characters.
	* completer.h (class completion_tracker): Extend intro comment.
	(completion_tracker::set_quote_char)
	(completion_tracker::quote_char)
	(completion_tracker::set_use_custom_word_point)
	(completion_tracker::use_custom_word_point)
	(completion_tracker::custom_word_point)
	(completion_tracker::set_custom_word_point)
	(completion_tracker::advance_custom_word_point_by)
	(completion_tracker::completes_to_completion_word)
	(completion_tracker::discard_completions): New methods.
	(completion_tracker::m_quote_char)
	(completion_tracker::m_use_custom_word_point)
	(completion_tracker::m_custom_word_point): New fields.
	(advance_to_expression_complete_word_point): Declare.
	* f-lang.c (f_collect_symbol_completion_matches): Add
	complete_symbol_mode parameter.
	* language.h (struct language_defn)
	<la_collect_symbol_completion_matches>: Add complete_symbol_mode
	parameter.
	* linespec.c (linespec_keywords): Add NULL terminator.  Make extern.
	(linespec_complete_function): New function.
	(linespec_lexer_lex_keyword): Adjust.
	* linespec.h (linespec_keywords, linespec_complete_function): New
	declarations.
	* location.c (find_end_quote): New function.
	(explicit_location_lex_one): Add explicit_completion_info
	parameter.  Save quoting info.  Don't throw if being called for
	completion.  Don't handle Ada operators here.
	(is_cp_operator, skip_op_false_positives, first_of)
	(explicit_location_lex_one_function): New function.
	(string_to_explicit_location): Replace 'dont_throw' parameter with
	an explicit_completion_info pointer parameter.  Handle it.  Don't
	use explicit_location_lex_one to lex function names.  Use
	explicit_location_lex_one_function instead.
	* location.h (struct explicit_completion_info): New.
	(string_to_explicit_location): Replace 'dont_throw' parameter with
	an explicit_completion_info pointer parameter.
	* symtab.c (default_collect_symbol_completion_matches_break_on):
	Add complete_symbol_mode parameter.  Handle LINESPEC mode.
	(default_collect_symbol_completion_matches)
	(collect_symbol_completion_matches): Add complete_symbol_mode
	parameter.
	(collect_symbol_completion_matches_type): Pass down
	complete_symbol_mode::EXPRESSION.
	(collect_file_symbol_completion_matches): Add complete_symbol_mode
	parameter.  Handle LINESPEC mode.
	* symtab.h (complete_symbol_mode): New.
	(default_collect_symbol_completion_matches_break_on)
	(default_collect_symbol_completion_matches)
	(collect_symbol_completion_matches)
	(collect_file_symbol_completion_matches): Add complete_symbol_mode
	parameter.

gdb/testsuite/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

	* gdb.linespec/ls-errs.exp (do_test): Adjust expected output.
2017-07-17 20:21:33 +01:00
Pedro Alves 8090b426b5 Introduce CP_OPERATOR_STR/CP_OPERATOR_LEN and use throughout
Move LENGTH_OF_OPERATOR from cp-support.c to cp-support.h so we can
use it elsewhere.  Since there's already
CP_ANONYMOUS_NAMESPACE_STR/CP_ANONYMOUS_NAMESPACE_LEN there, follow
the same naming pattern for the new symbols.

gdb/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

	* c-exp.y (operator_stoken): Use CP_OPERATOR_LEN and
	CP_OPERATOR_STR.
	* c-typeprint.c (is_type_conversion_operator): Use
	CP_OPERATOR_STR.
	* cp-support.c (LENGTH_OF_OPERATOR): Delete.
	(cp_find_first_component_aux): Use CP_OPERATOR_STR and
	CP_OPERATOR_LEN.
	* cp-support.h (CP_OPERATOR_STR, CP_OPERATOR_LEN): New.
	* gnu-v2-abi.c (gnuv2_is_operator_name): Use CP_OPERATOR_STR.
	* gnu-v3-abi.c (gnuv3_is_operator_name): Use CP_OPERATOR_STR.
	* linespec.c (linespec_lexer_lex_string): Use CP_OPERATOR_LEN and
	CP_OPERATOR_STR.
	* location.c: Include "cp-support.h".
	(explicit_location_lex_one): Use CP_OPERATOR_LEN and
	CP_OPERATOR_STR.
	* symtab.c (operator_chars): Use CP_OPERATOR_STR and
	CP_OPERATOR_LEN.
2017-07-17 15:51:55 +01:00
Tom Tromey 8e9e35b180 Change linespec_result::location to be an event_location_up
This is a follow-up to another patch.  It changes
linespec_result::location to be an event_location_up.

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

	* probe.c (parse_probes): Update.
	* location.h (delete_event_location): Don't declare.
	(event_location_deleter::operator()): Update.
	* location.c (event_location_deleter::operator()): Rename from
	delete_event_location.
	* linespec.h (linespec_result) <location>: Change type to
	event_location_up.
	* linespec.c (canonicalize_linespec, event_location_to_sals)
	(decode_objc): Update.
	(linespec_result): Don't call delete_event_location.
	* breakpoint.c (create_breakpoints_sal)
	(bkpt_probe_create_sals_from_location)
	(strace_marker_create_sals_from_location): Update.
2017-04-12 11:16:19 -06:00
Tom Tromey 4b217cc72b Remove some cleanups from location.c
This removes some more cleanups from location.c by using
unique_xmalloc_ptr.

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

	* location.c (explicit_location_lex_one): Return a
	unique_xmalloc_ptr.
	(string_to_explicit_location): Update.  Remove cleanups.
2017-04-12 11:16:18 -06:00
Tom Tromey ffc2605c41 Introduce event_location_up
This removes make_cleanup_delete_event_location and instead changes
the various location functions to return an event_location_up, a new
unique_ptr typedef.

This is largely straightforward, but be sure to examine the
init_breakpoint_sal change.  I believe the code I deleted there is
dead, because "location != NULL" can never be true in that branch; but
you should double-check.

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

	* tracepoint.c (scope_info): Update.
	* spu-tdep.c (spu_catch_start): Update.
	* python/python.c (gdbpy_decode_line): Update.
	* python/py-finishbreakpoint.c (bpfinishpy_init): Update.
	* python/py-breakpoint.c (bppy_init): Update.
	* probe.c (parse_probes): Update.
	* mi/mi-cmd-break.c (mi_cmd_break_insert_1): Update.
	* location.h (event_location_deleter): New struct.
	(event_location_up): New typedef.
	(new_linespec_location, new_address_location, new_probe_location)
	(new_explicit_location, copy_event_location)
	(string_to_event_location, string_to_event_location_basic)
	(string_to_explicit_location): Update return type.
	(make_cleanup_delete_event_location): Remove.
	* location.c (new_linespec_location, new_address_location)
	(new_probe_location, new_explicit_location, copy_event_location):
	Return event_location_up.
	(delete_event_location_cleanup)
	(make_cleanup_delete_event_location): Remove.
	(string_to_explicit_location, string_to_event_location_basic)
	(string_to_event_location): Return event_location_up.
	* linespec.c (canonicalize_linespec, event_location_to_sals)
	(decode_line_with_current_source)
	(decode_line_with_last_displayed, decode_objc): Update.
	* guile/scm-breakpoint.c (gdbscm_register_breakpoint_x): Update.
	* completer.c (location_completer): Update.
	* cli/cli-cmds.c (edit_command, list_command): Update.
	* breakpoint.c (create_overlay_event_breakpoint)
	(create_longjmp_master_breakpoint)
	(create_std_terminate_master_breakpoint)
	(create_exception_master_breakpoint)
	(create_thread_event_breakpoint): Update.
	(init_breakpoint_sal): Update.  Remove some dead code.
	(create_breakpoint_sal): Change type of "location".  Update.
	(create_breakpoints_sal, create_breakpoint, break_command_1)
	(dprintf_command, break_range_command, until_break_command)
	(init_ada_exception_breakpoint)
	(strace_marker_create_sals_from_location)
	(update_static_tracepoint, trace_command, ftrace_command)
	(strace_command, create_tracepoint_from_upload): Update.
	* break-catch-throw.c (re_set_exception_catchpoint): Update.
	* ax-gdb.c (agent_command_1): Update.
2017-04-12 11:16:17 -06:00
Pedro Alves d7e747318f Eliminate make_cleanup_ui_file_delete / make ui_file a class hierarchy
This patch starts from the desire to eliminate
make_cleanup_ui_file_delete, but then goes beyond.  It makes ui_file &
friends a real C++ class hierarchy, and switches temporary
ui_file-like objects to stack-based allocation.

- mem_fileopen -> string_file

mem_fileopen is replaced with a new string_file class that is treated
as a value class created on the stack.  This alone eliminates most
make_cleanup_ui_file_delete calls, and, simplifies code a whole lot
(diffstat shows around 1k loc dropped.)

string_file's internal buffer is a std::string, thus the "string" in
the name.  This simplifies the implementation much, compared to
mem_fileopen, which managed growing its internal buffer manually.

- ui_file_as_string, ui_file_strdup, ui_file_obsavestring all gone

The new string_file class has a string() method that provides direct
writable access to the internal std::string buffer.  This replaced
ui_file_as_string, which forced a copy of the same data the stream had
inside.  With direct access via a writable reference, we can instead
move the string out of the string_stream, avoiding deep string
copying.

Related, ui_file_xstrdup calls are replaced with xstrdup'ping the
stream's string, and ui_file_obsavestring is replaced by
obstack_copy0.

With all those out of the way, getting rid of the weird ui_file_put
mechanism was possible.

- New ui_file::printf, ui_file::puts, etc. methods

These simplify / clarify client code.  I considered splitting
client-code changes, like these, e.g.:

  -  stb = mem_fileopen ();
  -  fprintf_unfiltered (stb, "%s%s%s",
  -		      _("The valid values are:\n"),
  -		      regdesc,
  -		      _("The default is \"std\"."));
  +  string_file stb;
  +  stb.printf ("%s%s%s",
  +	      _("The valid values are:\n"),
  +	      regdesc,
  +	      _("The default is \"std\"."));

In two steps, with the first step leaving fprintf_unfiltered (etc.)
calls in place, and only afterwards do a pass to change all those to
call stb.printf etc..  I didn't do that split, because (when I tried),
it turned out to be pointless make-work: the first pass would have to
touch the fprintf_unfiltered line anyway, to replace "stb" with
"&stb".

- gdb_fopen replaced with stack-based objects

This avoids the need for cleanups or unique_ptr's.  I.e., this:

      struct ui_file *file = gdb_fopen (filename, "w");
      if (filename == NULL)
 	perror_with_name (filename);
      cleanups = make_cleanup_ui_file_delete (file);
      // use file.
      do_cleanups (cleanups);

is replaced with this:

      stdio_file file;
      if (!file.open (filename, "w"))
 	perror_with_name (filename);
      // use file.

- odd contorsions in null_file_write / null_file_fputs around when to
  call to_fputs / to_write eliminated.

- Global null_stream object

A few places that were allocating a ui_file in order to print to
"nowhere" are adjusted to instead refer to a new 'null_stream' global
stream.

- TUI's tui_sfileopen eliminated.  TUI's ui_file much simplified

The TUI's ui_file was serving a dual purpose.  It supported being used
as string buffer, and supported being backed by a stdio FILE.  The
string buffer part is gone, replaced by using of string_file.  The
'FILE *' support is now much simplified, by making the TUI's ui_file
inherit from stdio_file.

gdb/ChangeLog:
2017-02-02  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (type_as_string): Use string_file.
	* ada-valprint.c (ada_print_floating): Use string_file.
	* ada-varobj.c (ada_varobj_scalar_image)
	(ada_varobj_get_value_image): Use string_file.
	* aix-thread.c (aix_thread_extra_thread_info): Use string_file.
	* arm-tdep.c (_initialize_arm_tdep): Use string_printf.
	* breakpoint.c (update_inserted_breakpoint_locations)
	(insert_breakpoint_locations, reattach_breakpoints)
	(print_breakpoint_location, print_one_detail_ranged_breakpoint)
	(print_it_watchpoint): Use string_file.
	(save_breakpoints): Use stdio_file.
	* c-exp.y (oper): Use string_file.
	* cli/cli-logging.c (set_logging_redirect): Use ui_file_up and
	tee_file.
	(pop_output_files): Use delete.
	(handle_redirections): Use stdio_file and tee_file.
	* cli/cli-setshow.c (do_show_command): Use string_file.
	* compile/compile-c-support.c (c_compute_program): Use
	string_file.
	* compile/compile-c-symbols.c (generate_vla_size): Take a
	'string_file &' instead of a 'ui_file *'.
	(generate_c_for_for_one_variable): Take a 'string_file &' instead
	of a 'ui_file *'.  Use string_file.
	(generate_c_for_variable_locations): Take a 'string_file &'
	instead of a 'ui_file *'.
	* compile/compile-internal.h (generate_c_for_for_one_variable):
	Take a 'string_file &' instead of a 'ui_file *'.
	* compile/compile-loc2c.c (push, pushf, unary, binary)
	(print_label, pushf_register_address, pushf_register)
	(do_compile_dwarf_expr_to_c): Take a 'string_file &' instead of a
	'ui_file *'.  Adjust.
	* compile/compile.c (compile_to_object): Use string_file.
	* compile/compile.h (compile_dwarf_expr_to_c)
	(compile_dwarf_bounds_to_c): Take a 'string_file &' instead of a
	'ui_file *'.
	* cp-support.c (inspect_type): Use string_file and obstack_copy0.
	(replace_typedefs_qualified_name): Use string_file and
	obstack_copy0.
	* disasm.c (gdb_pretty_print_insn): Use string_file.
	(gdb_disassembly): Adjust reference the null_stream global.
	(do_ui_file_delete): Delete.
	(gdb_insn_length): Use null_stream.
	* dummy-frame.c (maintenance_print_dummy_frames): Use stdio_file.
	* dwarf2loc.c (dwarf2_compile_property_to_c)
	(locexpr_generate_c_location, loclist_generate_c_location): Take a
	'string_file &' instead of a 'ui_file *'.
	* dwarf2loc.h (dwarf2_compile_property_to_c): Likewise.
	* dwarf2read.c (do_ui_file_peek_last): Delete.
	(dwarf2_compute_name): Use string_file.
	* event-top.c (gdb_setup_readline): Use stdio_file.
	* gdbarch.sh (verify_gdbarch): Use string_file.
	* gdbtypes.c (safe_parse_type): Use null_stream.
	* guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Use
	string_file.
	* guile/scm-disasm.c (gdbscm_print_insn_from_port): Take a
	'string_file *' instead of a 'ui_file *'.
	(gdbscm_arch_disassemble): Use string_file.
	* guile/scm-frame.c (frscm_print_frame_smob): Use string_file.
	* guile/scm-ports.c (class ioscm_file_port): Now a class that
	inherits from ui_file.
	(ioscm_file_port_delete, ioscm_file_port_rewind)
	(ioscm_file_port_put): Delete.
	(ioscm_file_port_write): Rename to ...
	(ioscm_file_port::write): ... this.  Remove file_port_magic
	checks.
	(ioscm_file_port_new): Delete.
	(ioscm_with_output_to_port_worker): Use ioscm_file_port and
	ui_file_up.
	* guile/scm-type.c (tyscm_type_name): Use string_file.
	* guile/scm-value.c (vlscm_print_value_smob, gdbscm_value_print):
	Use string_file.
	* infcmd.c (print_return_value_1): Use string_file.
	* infrun.c (print_target_wait_results): Use string_file.
	* language.c (add_language): Use string_file.
	* location.c (explicit_to_string_internal): Use string_file.
	* main.c (captured_main_1): Use null_file.
	* maint.c (maintenance_print_architecture): Use stdio_file.
	* mi/mi-cmd-stack.c (list_arg_or_local): Use string_file.
	* mi/mi-common.h (struct mi_interp) <out, err, log, targ,
	event_channel>: Change type to mi_console_file pointer.
	* mi/mi-console.c (mi_console_file_fputs, mi_console_file_flush)
	(mi_console_file_delete): Delete.
	(struct mi_console_file): Delete.
	(mi_console_file_magic): Delete.
	(mi_console_file_new): Delete.
	(mi_console_file::mi_console_file): New.
	(mi_console_file_delete): Delete.
	(mi_console_file_fputs): Delete.
	(mi_console_file::write): New.
	(mi_console_raw_packet): Delete.
	(mi_console_file::flush): New.
	(mi_console_file_flush): Delete.
	(mi_console_set_raw): Rename to ...
	(mi_console_file::set_raw): ... this.
	* mi/mi-console.h (class mi_console_file): New class.
	(mi_console_file_new, mi_console_set_raw): Delete.
	* mi/mi-interp.c (mi_interpreter_init): Use mi_console_file.
	(mi_set_logging): Use delete and tee_file.  Adjust.
	* mi/mi-main.c (output_register): Use string_file.
	(mi_cmd_data_evaluate_expression): Use string_file.
	(mi_cmd_data_read_memory): Use string_file.
	(mi_cmd_execute, print_variable_or_computed): Use string_file.
	* mi/mi-out.c (mi_ui_out::main_stream): New.
	(mi_ui_out::rewind): Use main_stream and
	string_file.
	(mi_ui_out::put): Use main_stream and string_file.
	(mi_ui_out::mi_ui_out): Remove 'stream' parameter.
	Allocate a 'string_file' instead.
	(mi_out_new): Don't allocate a mem_fileopen stream here.
	* mi/mi-out.h (mi_ui_out::mi_ui_out): Remove 'stream' parameter.
	(mi_ui_out::main_stream): Declare method.
	* printcmd.c (eval_command): Use string_file.
	* psymtab.c (maintenance_print_psymbols): Use stdio_file.
	* python/py-arch.c (archpy_disassemble): Use string_file.
	* python/py-breakpoint.c (bppy_get_commands): Use string_file.
	* python/py-frame.c (frapy_str): Use string_file.
	* python/py-framefilter.c (py_print_type, py_print_single_arg):
	Use string_file.
	* python/py-type.c (typy_str): Use string_file.
	* python/py-unwind.c (unwind_infopy_str): Use string_file.
	* python/py-value.c (valpy_str): Use string_file.
	* record-btrace.c (btrace_insn_history): Use string_file.
	* regcache.c (regcache_print): Use stdio_file.
	* reggroups.c (maintenance_print_reggroups): Use stdio_file.
	* remote.c (escape_buffer): Use string_file.
	* rust-lang.c (rust_get_disr_info): Use string_file.
	* serial.c (serial_open_ops_1): Use stdio_file.
	(do_serial_close): Use delete.
	* stack.c (print_frame_arg): Use string_file.
	(print_frame_args): Remove local mem_fileopen stream, not used.
	(print_frame): Use string_file.
	* symmisc.c (maintenance_print_symbols): Use stdio_file.
	* symtab.h (struct symbol_computed_ops) <generate_c_location>:
	Take a 'string_file *' instead of a 'ui_file *'.
	* top.c (new_ui): Use stdio_file and stderr_file.
	(free_ui): Use delete.
	(execute_command_to_string): Use string_file.
	(quit_confirm): Use string_file.
	* tracepoint.c (collection_list::append_exp): Use string_file.
	* tui/tui-disasm.c (tui_disassemble): Use string_file.
	* tui/tui-file.c: Don't include "ui-file.h".
	(enum streamtype, struct tui_stream): Delete.
	(tui_file_new, tui_file_delete, tui_fileopen, tui_sfileopen)
	(tui_file_isatty, tui_file_rewind, tui_file_put): Delete.
	(tui_file::tui_file): New method.
	(tui_file_fputs): Delete.
	(tui_file_get_strbuf): Delete.
	(tui_file::puts): New method.
	(tui_file_adjust_strbuf): Delete.
	(tui_file_flush): Delete.
	(tui_file::flush): New method.
	* tui/tui-file.h: Tweak intro comment.
	Include ui-file.h.
	(tui_fileopen, tui_sfileopen, tui_file_get_strbuf)
	(tui_file_adjust_strbuf): Delete declarations.
	(class tui_file): New class.
	* tui/tui-io.c (tui_initialize_io): Use tui_file.
	* tui/tui-regs.c (tui_restore_gdbout): Use delete.
	(tui_register_format): Use string_stream.
	* tui/tui-stack.c (tui_make_status_line): Use string_file.
	(tui_get_function_from_frame): Use string_file.
	* typeprint.c (type_to_string): Use string_file.
	* ui-file.c (struct ui_file, ui_file_magic, ui_file_new): Delete.
	(null_stream): New global.
	(ui_file_delete): Delete.
	(ui_file::ui_file): New.
	(null_file_isatty): Delete.
	(ui_file::~ui_file): New.
	(null_file_rewind): Delete.
	(ui_file::printf): New.
	(null_file_put): Delete.
	(null_file_flush): Delete.
	(ui_file::putstr): New.
	(null_file_write): Delete.
	(ui_file::putstrn): New.
	(null_file_read): Delete.
	(ui_file::putc): New.
	(null_file_fputs): Delete.
	(null_file_write_async_safe): Delete.
	(ui_file::vprintf): New.
	(null_file_delete): Delete.
	(null_file::write): New.
	(null_file_fseek): Delete.
	(null_file::puts): New.
	(ui_file_data): Delete.
	(null_file::write_async_safe): New.
	(gdb_flush, ui_file_isatty): Adjust.
	(ui_file_put, ui_file_rewind): Delete.
	(ui_file_write): Adjust.
	(ui_file_write_for_put): Delete.
	(ui_file_write_async_safe, ui_file_read): Adjust.
	(ui_file_fseek): Delete.
	(fputs_unfiltered): Adjust.
	(set_ui_file_flush, set_ui_file_isatty, set_ui_file_rewind)
	(set_ui_file_put, set_ui_file_write, set_ui_file_write_async_safe)
	(set_ui_file_read, set_ui_file_fputs, set_ui_file_fseek)
	(set_ui_file_data): Delete.
	(string_file::~string_file, string_file::write)
	(struct accumulated_ui_file, do_ui_file_xstrdup, ui_file_xstrdup)
	(do_ui_file_as_string, ui_file_as_string): Delete.
	(do_ui_file_obsavestring, ui_file_obsavestring): Delete.
	(struct mem_file): Delete.
	(mem_file_new): Delete.
	(stdio_file::stdio_file): New.
	(mem_file_delete): Delete.
	(stdio_file::stdio_file): New.
	(mem_fileopen): Delete.
	(stdio_file::~stdio_file): New.
	(mem_file_rewind): Delete.
	(stdio_file::set_stream): New.
	(mem_file_put): Delete.
	(stdio_file::open): New.
	(mem_file_write): Delete.
	(stdio_file_magic, struct stdio_file): Delete.
	(stdio_file_new, stdio_file_delete, stdio_file_flush): Delete.
	(stdio_file::flush): New.
	(stdio_file_read): Rename to ...
	(stdio_file::read): ... this.  Adjust.
	(stdio_file_write): Rename to ...
	(stdio_file::write): ... this.  Adjust.
	(stdio_file_write_async_safe): Rename to ...
	(stdio_file::write_async_safe) ... this.  Adjust.
	(stdio_file_fputs): Rename to ...
	(stdio_file::puts) ... this.  Adjust.
	(stdio_file_isatty): Delete.
	(stdio_file_fseek): Delete.
	(stdio_file::isatty): New.
	(stderr_file_write): Rename to ...
	(stderr_file::write) ... this.  Adjust.
	(stderr_file_fputs): Rename to ...
	(stderr_file::puts) ... this.  Adjust.
	(stderr_fileopen, stdio_fileopen, gdb_fopen): Delete.
	(stderr_file::stderr_file): New.
	(tee_file_magic): Delete.
	(struct tee_file): Delete.
	(tee_file::tee_file): New.
	(tee_file_new): Delete.
	(tee_file::~tee_file): New.
	(tee_file_delete): Delete.
	(tee_file_flush): Rename to ...
	(tee_file::flush): ... this.  Adjust.
	(tee_file_write): Rename to ...
	(tee_file::write): ... this.  Adjust.
	(tee_file::write_async_safe): New.
	(tee_file_fputs): Rename to ...
	(tee_file::puts): ... this.  Adjust.
	(tee_file_isatty): Rename to ...
	(tee_file::isatty): ... this.  Adjust.
	* ui-file.h (struct obstack, struct ui_file): Don't
	forward-declare.
	(ui_file_new, ui_file_flush_ftype, set_ui_file_flush)
	(ui_file_write_ftype)
	(set_ui_file_write, ui_file_fputs_ftype, set_ui_file_fputs)
	(ui_file_write_async_safe_ftype, set_ui_file_write_async_safe)
	(ui_file_read_ftype, set_ui_file_read, ui_file_isatty_ftype)
	(set_ui_file_isatty, ui_file_rewind_ftype, set_ui_file_rewind)
	(ui_file_put_method_ftype, ui_file_put_ftype, set_ui_file_put)
	(ui_file_delete_ftype, set_ui_file_data, ui_file_fseek_ftype)
	(set_ui_file_fseek): Delete.
	(ui_file_data, ui_file_delete, ui_file_rewind)
	(struct ui_file): New.
	(ui_file_up): New.
	(class null_file): New.
	(null_stream): Declare.
	(ui_file_write_for_put, ui_file_put): Delete.
	(ui_file_xstrdup, ui_file_as_string, ui_file_obsavestring):
	Delete.
	(ui_file_fseek, mem_fileopen, stdio_fileopen, stderr_fileopen)
	(gdb_fopen, tee_file_new): Delete.
	(struct string_file): New.
	(struct stdio_file): New.
	(stdio_file_up): New.
	(struct stderr_file): New.
	(class tee_file): New.
	* ui-out.c (ui_out::field_stream): Take a 'string_file &' instead
	of a 'ui_file *'.  Adjust.
	* ui-out.h (class ui_out) <field_stream>: Likewise.
	* utils.c (do_ui_file_delete, make_cleanup_ui_file_delete)
	(null_stream): Delete.
	(error_stream): Take a 'string_file &' instead of a 'ui_file *'.
	Adjust.
	* utils.h (struct ui_file): Delete forward declaration..
	(make_cleanup_ui_file_delete, null_stream): Delete declarations.
	(error_stream): Take a 'string_file &' instead of a
	'ui_file *'.
	* varobj.c (varobj_value_get_print_value): Use string_file.
	* xtensa-tdep.c (xtensa_verify_config): Use string_file.
	* gdbarch.c: Regenerate.
2017-02-02 11:11:47 +00:00
Joel Brobecker 61baf725ec update copyright year range in GDB files
This applies the second part of GDB's End of Year Procedure, which
updates the copyright year range in all of GDB's files.

gdb/ChangeLog:

        Update copyright year range in all GDB files.
2017-01-01 10:52:34 +04:00
Tom Tromey e742d386c4 PR gdb/20653 - small cleanup in string_to_explicit_location
This bug points out that string_to_explicit_location compares a char*
against '\0'; whereas comparing against NULL is more normal.

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

	PR breakpoints/20653:
	* location.c (string_to_explicit_location): Use NULL, not '\0'.
2016-10-05 10:31:34 -06:00
Yao Qi b31f947818 Fix heap-buffer-overflow in explicit_location_lex_one
I build GDB with -fsanitize=address, and see the error in tests,

(gdb) PASS: gdb.linespec/ls-errs.exp: lang=C++: break 3 foo
break -line 3 foo^M
=================================================================^M
==4401==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000047487 at pc 0x819d8e bp 0x7fff4e4e6bb0 sp 0x7fff4e4e6ba8^M
READ of size 1 at 0x603000047487 thread T0^[[1m^[[0m^M
    #0 0x819d8d in explicit_location_lex_one /home/yao/SourceCode/gnu/gdb/git/gdb/location.c:502^M
    #1 0x81a185 in string_to_explicit_location(char const**, language_defn const*, int) /home/yao/SourceCode/gnu/gdb/git/gdb/location.c:556^M
    #2 0x81ac10 in string_to_event_location(char**, language_defn const*) /home/yao/SourceCode/gnu/gdb/git/gdb/location.c:687^

the code in question is:

>         /* Special case: C++ operator,.  */
>         if (language->la_language == language_cplus
>             && strncmp (*inp, "operator", 8)  <--- [1]
>             && (*inp)[9] == ',')
>           (*inp) += 9;
>         ++(*inp);

The error is caused by the access to (*inp)[9] if 9 is out of its bounds.
However [1] looks odd to me, because if strncmp returns true (non-zero),
the following check "(*inp)[9] == ','" makes no sense any more.  I
suspect it was a typo in the code we meant to "strncmp () == 0".  Another
problem in the code above is that if *inp is "operator,", we first
increment *inp by 9, and then increment it by one again, which is wrong
to me.  We should only increment *inp by 8 to skip "operator", and go
back to the loop header to decide where we stop.

gdb:

2016-08-15  Yao Qi  <yao.qi@linaro.org>

	* location.c (explicit_location_lex_one): Compare the return
	value of strncmp with zero.  Don't check (*inp)[9].  Increment
	*inp by 8.
2016-08-15 12:28:56 +01:00
Trevor Saunders 870f88f755 remove trivialy unused variables
gdb/ChangeLog:

2016-05-07  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

	* aarch64-linux-tdep.c (aarch64_linux_sigframe_init): Remove unused
	variables.
	* aarch64-tdep.c (aarch64_skip_prologue): Likewise.
	(aarch64_scan_prologue): Likewise.
	(aarch64_prologue_prev_register): Likewise.
	(aarch64_dwarf2_prev_register): Likewise.
	(pass_in_v): Likewise.
	(aarch64_push_dummy_call): Likewise.
	(aarch64_breakpoint_from_pc): Likewise.
	(aarch64_return_in_memory): Likewise.
	(aarch64_return_value): Likewise.
	(aarch64_displaced_step_b_cond): Likewise.
	(aarch64_displaced_step_cb): Likewise.
	(aarch64_displaced_step_tb): Likewise.
	(aarch64_gdbarch_init): Likewise.
	(aarch64_process_record): Likewise.
	* alpha-mdebug-tdep.c (alpha_mdebug_init_abi): Likewise.
	* alpha-tdep.c (_initialize_alpha_tdep): Likewise.
	* amd64-dicos-tdep.c (amd64_dicos_init_abi): Likewise.
	* amd64-linux-tdep.c (amd64_dtrace_parse_probe_argument): Likewise.
	* amd64-tdep.c (fixup_riprel): Likewise.
	* amd64-windows-tdep.c (amd64_windows_frame_decode_epilogue): Likewise.
	(amd64_windows_frame_decode_insns): Likewise.
	(amd64_windows_frame_cache): Likewise.
	(amd64_windows_frame_prev_register): Likewise.
	(amd64_windows_frame_this_id): Likewise.
	(amd64_windows_init_abi): Likewise.
	* arm-linux-tdep.c (arm_linux_get_syscall_number): Likewise.
	(arm_linux_get_next_pcs_syscall_next_pc): Likewise.
	* arm-symbian-tdep.c (arm_symbian_init_abi): Likewise.
	* arm-tdep.c (arm_make_epilogue_frame_cache): Likewise.
	(arm_epilogue_frame_prev_register): Likewise.
	(arm_record_vdata_transfer_insn): Likewise.
	(arm_record_exreg_ld_st_insn): Likewise.
	* auto-load.c (execute_script_contents): Likewise.
	(print_scripts): Likewise.
	* avr-tdep.c (avr_frame_prev_register): Likewise.
	(avr_push_dummy_call): Likewise.
	* bfin-linux-tdep.c (bfin_linux_sigframe_init): Likewise.
	* bfin-tdep.c (bfin_gdbarch_init): Likewise.
	* blockframe.c (find_pc_partial_function_gnu_ifunc): Likewise.
	* break-catch-throw.c (fetch_probe_arguments): Likewise.
	* breakpoint.c (breakpoint_xfer_memory): Likewise.
	(breakpoint_init_inferior): Likewise.
	(breakpoint_inserted_here_p): Likewise.
	(software_breakpoint_inserted_here_p): Likewise.
	(hardware_breakpoint_inserted_here_p): Likewise.
	(bpstat_what): Likewise.
	(break_range_command): Likewise.
	(save_breakpoints): Likewise.
	* coffread.c (coff_symfile_read): Likewise.
	* cris-tdep.c (cris_push_dummy_call): Likewise.
	(cris_scan_prologue): Likewise.
	(cris_register_size): Likewise.
	(_initialize_cris_tdep): Likewise.
	* d-exp.y: Likewise.
	* dbxread.c (dbx_read_symtab): Likewise.
	(process_one_symbol): Likewise.
	(coffstab_build_psymtabs): Likewise.
	(elfstab_build_psymtabs): Likewise.
	* dicos-tdep.c (dicos_init_abi): Likewise.
	* disasm.c (do_mixed_source_and_assembly): Likewise.
	(gdb_disassembly): Likewise.
	* dtrace-probe.c (dtrace_process_dof): Likewise.
	* dwarf2read.c (error_check_comp_unit_head): Likewise.
	(build_type_psymtabs_1): Likewise.
	(skip_one_die): Likewise.
	(process_imported_unit_die): Likewise.
	(dwarf2_physname): Likewise.
	(read_file_scope): Likewise.
	(setup_type_unit_groups): Likewise.
	(create_dwo_cu_reader): Likewise.
	(create_dwo_cu): Likewise.
	(create_dwo_unit_in_dwp_v1): Likewise.
	(create_dwo_unit_in_dwp_v2): Likewise.
	(lookup_dwo_unit_in_dwp): Likewise.
	(free_dwo_file): Likewise.
	(check_producer): Likewise.
	(dwarf2_add_typedef): Likewise.
	(dwarf2_add_member_fn): Likewise.
	(read_unsigned_leb128): Likewise.
	(read_signed_leb128): Likewise.
	(dwarf2_const_value): Likewise.
	(follow_die_sig_1): Likewise.
	(dwarf_decode_macro_bytes): Likewise.
	* extension.c (restore_active_ext_lang): Likewise.
	* frv-linux-tdep.c (frv_linux_sigtramp_frame_cache): Likewise.
	* ft32-tdep.c (ft32_analyze_prologue): Likewise.
	* gdbtypes.c (lookup_typename): Likewise.
	(resolve_dynamic_range): Likewise.
	(check_typedef): Likewise.
	* h8300-tdep.c (h8300_is_argument_spill): Likewise.
	(h8300_gdbarch_init): Likewise.
	* hppa-tdep.c (hppa32_push_dummy_call): Likewise.
	(hppa_frame_this_id): Likewise.
	(_initialize_hppa_tdep): Likewise.
	* hppanbsd-tdep.c (hppanbsd_sigtramp_cache_init): Likewise.
	* hppaobsd-tdep.c (hppaobsd_supply_fpregset): Likewise.
	* i386-dicos-tdep.c (i386_dicos_init_abi): Likewise.
	* i386-tdep.c (i386_bnd_type): Likewise.
	(i386_gdbarch_init): Likewise.
	(i386_mpx_bd_base): Likewise.
	* i386nbsd-tdep.c (i386nbsd_sigtramp_cache_init): Likewise.
	* i386obsd-tdep.c (i386obsd_elf_init_abi): Likewise.
	* ia64-tdep.c (examine_prologue): Likewise.
	(ia64_frame_cache): Likewise.
	(ia64_push_dummy_call): Likewise.
	* infcmd.c (finish_command_fsm_async_reply_reason): Likewise.
	(default_print_one_register_info): Likewise.
	* infrun.c (infrun_thread_ptid_changed): Likewise.
	(thread_still_needs_step_over): Likewise.
	(stop_all_threads): Likewise.
	(restart_threads): Likewise.
	(keep_going_stepped_thread): Likewise.
	* iq2000-tdep.c (iq2000_scan_prologue): Likewise.
	* language.c (language_init_primitive_type_symbols): Likewise.
	* linespec.c (add_sal_to_sals): Likewise.
	* linux-nat.c (status_callback): Likewise.
	(kill_unfollowed_fork_children): Likewise.
	(linux_nat_kill): Likewise.
	* linux-tdep.c (linux_fill_prpsinfo): Likewise.
	* linux-thread-db.c (thread_db_notice_clone): Likewise.
	(record_thread): Likewise.
	* location.c (string_to_event_location_basic): Likewise.
	* m32c-tdep.c (m32c_prev_register): Likewise.
	* m32r-linux-tdep.c (m32r_linux_init_abi): Likewise.
	* m32r-tdep.c (decode_prologue): Likewise.
	* m68klinux-tdep.c (m68k_linux_sigtramp_frame_cache): Likewise.
	* machoread.c (macho_symtab_read): Likewise.
	(macho_symfile_read): Likewise.
	(macho_symfile_offsets): Likewise.
	* maint.c (set_per_command_cmd): Likewise.
	* mi/mi-cmd-stack.c (mi_cmd_stack_list_locals): Likewise.
	(mi_cmd_stack_list_variables): Likewise.
	* mi/mi-main.c (mi_cmd_exec_run): Likewise.
	(output_register): Likewise.
	(mi_cmd_execute): Likewise.
	(mi_cmd_trace_define_variable): Likewise.
	(print_variable_or_computed): Likewise.
	* minsyms.c (prim_record_minimal_symbol_full): Likewise.
	* mn10300-tdep.c (mn10300_frame_prev_register): Likewise.
	* msp430-tdep.c (msp430_pseudo_register_write): Likewise.
	* mt-tdep.c (mt_registers_info): Likewise.
	* nios2-tdep.c (nios2_analyze_prologue): Likewise.
	(nios2_push_dummy_call): Likewise.
	(nios2_frame_unwind_cache): Likewise.
	(nios2_stub_frame_cache): Likewise.
	(nios2_stub_frame_sniffer): Likewise.
	(nios2_gdbarch_init): Likewise.
	* ppc-ravenscar-thread.c: Likewise.
	* ppcfbsd-tdep.c (ppcfbsd_sigtramp_frame_cache): Likewise.
	* python/py-evts.c (add_new_registry): Likewise.
	* python/py-finishbreakpoint.c (bpfinishpy_init): Likewise.
	(bpfinishpy_detect_out_scope_cb): Likewise.
	* python/py-framefilter.c (py_print_value): Likewise.
	* python/py-inferior.c (infpy_write_memory): Likewise.
	* python/py-infevents.c (create_inferior_call_event_object): Likewise.
	* python/py-infthread.c (thpy_get_ptid): Likewise.
	* python/py-linetable.c (ltpy_get_pcs_for_line): Likewise.
	(ltpy_get_all_source_lines): Likewise.
	(ltpy_is_valid): Likewise.
	(ltpy_iternext): Likewise.
	* python/py-symtab.c (symtab_and_line_to_sal_object): Likewise.
	* python/py-unwind.c (pyuw_object_attribute_to_pointer): Likewise.
	(unwind_infopy_str): Likewise.
	* python/py-varobj.c (py_varobj_get_iterator): Likewise.
	* ravenscar-thread.c (ravenscar_inferior_created): Likewise.
	* rs6000-aix-tdep.c (rs6000_push_dummy_call): Likewise.
	* rs6000-lynx178-tdep.c (rs6000_lynx178_push_dummy_call): Likewise.
	* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Likewise.
	* s390-linux-tdep.c (s390_supply_tdb_regset): Likewise.
	(s390_frame_prev_register): Likewise.
	(s390_dwarf2_frame_init_reg): Likewise.
	(s390_record_vr): Likewise.
	(s390_process_record): Likewise.
	* score-tdep.c (score_push_dummy_call): Likewise.
	(score3_analyze_prologue): Likewise.
	* sh-tdep.c (sh_extract_return_value_nofpu): Likewise.
	* sh64-tdep.c (sh64_analyze_prologue): Likewise.
	(sh64_push_dummy_call): Likewise.
	(sh64_extract_return_value): Likewise.
	(sh64_do_fp_register): Likewise.
	* solib-aix.c (solib_aix_get_section_offsets): Likewise.
	* solib-darwin.c (darwin_read_exec_load_addr_from_dyld): Likewise.
	(darwin_solib_read_all_image_info_addr): Likewise.
	* solib-dsbt.c (enable_break): Likewise.
	* solib-frv.c (enable_break2): Likewise.
	(frv_fdpic_find_canonical_descriptor): Likewise.
	* solib-svr4.c (svr4_handle_solib_event): Likewise.
	* sparc-tdep.c (sparc_skip_stack_check): Likewise.
	* sparc64-linux-tdep.c (sparc64_linux_get_longjmp_target): Likewise.
	* sparcobsd-tdep.c (sparc32obsd_init_abi): Likewise.
	* spu-tdep.c (info_spu_dma_cmdlist): Likewise.
	* stack.c (read_frame_local): Likewise.
	* symfile.c (symbol_file_add_separate): Likewise.
	(remove_symbol_file_command): Likewise.
	* symmisc.c (maintenance_print_one_line_table): Likewise.
	* symtab.c (symbol_cache_flush): Likewise.
	(basic_lookup_transparent_type): Likewise.
	(sort_search_symbols_remove_dups): Likewise.
	* target.c (target_memory_map): Likewise.
	(target_detach): Likewise.
	(target_resume): Likewise.
	(acquire_fileio_fd): Likewise.
	(target_store_registers): Likewise.
	* thread.c (print_thread_info_1): Likewise.
	* tic6x-tdep.c (tic6x_analyze_prologue): Likewise.
	* tilegx-linux-tdep.c (tilegx_linux_sigframe_init): Likewise.
	* tilegx-tdep.c (tilegx_push_dummy_call): Likewise.
	(tilegx_analyze_prologue): Likewise.
	(tilegx_stack_frame_destroyed_p): Likewise.
	(tilegx_frame_cache): Likewise.
	* tracefile.c (trace_save): Likewise.
	* tracepoint.c (encode_actions_and_make_cleanup): Likewise.
	(start_tracing): Likewise.
	(print_one_static_tracepoint_marker): Likewise.
	* tui/tui.c (tui_enable): Likewise.
	* valops.c (value_struct_elt_bitpos): Likewise.
	(find_overload_match): Likewise.
	(find_oload_champ): Likewise.
	* value.c (value_contents_copy_raw): Likewise.
	* windows-tdep.c (windows_get_tlb_type): Likewise.
	* x86-linux-nat.c (x86_linux_enable_btrace): Likewise.
	* xcoffread.c (record_minimal_symbol): Likewise.
	(scan_xcoff_symtab): Likewise.
	* xtensa-tdep.c (execute_code): Likewise.
	(xtensa_gdbarch_init): Likewise.
	(_initialize_xtensa_tdep): Likewise.
2016-05-07 20:12:53 -04:00
Keith Seitz eeb1af437c Refactor string_to_event_location for legacy linespec support.
This patch refactors string_to_event_location, breaking it into two
separate functions:

1) string_to_event_location_basic
A "basic" string parser that implements support for "legacy" linespecs
(linespec, address, and probe locations).  This function is intended to
be used by any UI wishing/needing to support this legacy behavior.

2) string_to_event_location
This is now intended as a CLI-only function which adds explicit location
parsing in a CLI-appropriate manner (in the form of traditional option/value
pairs).

Together these patches serve to simplify string-to-event location parsing
for all existing non-CLI interfaces (MI, guile, and python).

gdb/ChangeLog

	* location.c (string_to_explicit_location): Note that "-p" is
	reserved for probe locations and return NULL for any input
	that starts with that.
	(string_to_event_location): Move "legacy" linespec code to ...
	(string_to_event_location_basic): ... here.
	* location.h (string_to_event_location): Update comment.
	(string_to_event_location_basic): New function.
2016-02-09 10:02:53 -08:00
Joel Brobecker 305e13e67f Fix regression introduced in "break *<EXPR>" by explicit location patches.
A relatively recent patch support for explicit locations, and part
of that patch cleaned up the way we parse breakpoint locations.
Unfortunatly, a small regression crept in for "*<EXPR>" breakpoint
locations. In particular, on PIE programs, one can see the issue by
doing the following, with any program:

    (gdb) b *main
    Breakpoint 1 at 0x51a: file hello.c, line 3.
    (gdb) run
    Starting program: /[...]/hello
    Error in re-setting breakpoint 1: Warning:
    Cannot insert breakpoint 1.
    Cannot access memory at address 0x51a

    Warning:
    Cannot insert breakpoint 1.
    Cannot access memory at address 0x51a

Just for the record, this regression was introduced by:

    commit a06efdd6ef
    Date:   Tue Aug 11 17:09:35 2015 -0700
    Subject: Explicit locations: introduce address locations

What happens is that the patch makes the implicit assumption that
the address computed the first time is static, as if it was designed
to only support litteral expressions (Eg. "*0x1234"). This allows
the shortcut of not re-computing the breakpoint location's address
when re-setting breakpoints.

However, this does not work in general, as demonstrated in the example
above.

This patch plugs that hole simply by saving the original expression
used to compute the address as part of the address location, so as
to then re-evaluate that expression during breakpoint re-set.

gdb/ChangeLog:

        * location.h (new_address_location): Add new parameters
        "addr_string" and "addr_string_len".
        (get_address_string_location): Add declaration.
        * location.c (new_address_location): Add new parameters
        "addr_string" and "addr_string_len".  If not NULL, store
        a copy of the addr_string in the new location as well.
        (get_address_string_location): New function.
        (string_to_event_location): Update call to new_address_location.
        * linespec.c (event_location_to_sals) <ADDRESS_LOCATION>:
        Save the event location in the parser's state before
        passing it to convert_address_location_to_sals.
        * breakpoint.c (create_thread_event_breakpoint): Update call
        to new_address_location.
        (init_breakpoint_sal): Get the event location's string, if any,
        and use it to update call to new_address_location.
        * python/py-finishbreakpoint.c (bpfinishpy_init):
        Update call to new_address_location.
        * spu-tdep.c (spu_catch_start): Likewise.

        * config/djgpp/fnchange.lst: Add entries for
        gdb/testsuite/gdb.base/break-fun-addr1.c and
        gdb/testsuite/gdb.base/break-fun-addr2.c.

gdb/testsuite/ChangeLog:

        * gdb.base/break-fun-addr.exp: New file.
        * gdb.base/break-fun-addr1.c: New file.
        * gdb.base/break-fun-addr2.c: New file.
2016-01-21 14:23:15 +04:00
Joel Brobecker 618f726fcb GDB copyright headers update after running GDB's copyright.py script.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2016-01-01 08:43:22 +04:00
Keith Seitz ebdad8fc7f Rename location accessor macro parameters to silence ARI
The locations patch I recently committed contains macro definitions
such as:

This causes an ARI error to be emitted by the server ("Do not use PTR, ISO C
90 implies `void *'").  While this ARI error is bogus in this context,
it is just easiest to squash the error completely by renaming the macro
parameters.

gdb/ChangeLog

	* location.c (EL_TYPE, EL_LINESPEC, EL_PROBE, EL_ADDRESS)
	(EL_EXPLICIT, EL_STRING): Change macro parameter to "P" to
	silence ARI errors.
2015-08-14 15:04:58 -07:00
Keith Seitz 6799407467 Mass rename `explicit' -> `explicit_loc'.
BuildBot reminded me that "explicit" is a reserved keyword in C++.
This patch simply renames all the (illegal) uses of "explicit". This should
fix the build errors with --enable-build-with-cxx bots.

gdb/ChangeLog

	* break-catch-throw.c (re_set_exception_catchpoint) Rename
	reserved C++ keyword "explicit" to "explicit_loc".
	* breakpoint.c (create_overlay_event_breakpoint)
	(create_longjmp_master_breakpoint)
	(create_std_terminate_master_breakpoint)
	(create_exception_master_breakpoint, update_static_tracepoint):
	Rename reserved C++ keyword "explicit" to "explicit_loc".
	* completer.c (collect_explicit_location_matches)
	(explicit_location_completer): Rename reserved C++ keyword
	"explicit" to "explicit_loc".
	* linespec.c (struct linespec) <explicit>: Rename to "explicit_loc".
	(canonicalize_linespec, create_sals_line_offset)
	(convert_linespec_to_sals, convert_explicit_location_to_sals)
	(event_location_to_sals, decode_objc): Rename reserved C++ keyword
	"explicit" to "explicit_loc".
	* location.c (struct event_location) <explicit>: Rename to
	"explicit_loc".
	(initialize_explicit_location, new_explicit_location)
	(explicit_location_to_string_internal, explicit_location_to_linespec):
	Rename reserved C++ keyword "explicit" to "explicit_loc".
	* location.h (explicit_location_to_string)
	(explicit_location_to_linespec, initialize_explicit_location)
	(new_explicit_location): Rename reserved C++ keyword "explicit"
	to "explicit_loc".
	* mi/mi-cmd-break.c (mi_cmd_break_insert_1): Rename reserved C++
	keyword "explicit" to "explicit_loc".
2015-08-13 09:48:12 -07:00
Keith Seitz 87f0e72047 Explicit locations: add UI features for CLI
This patch exposes explicit locations to the CLI user.  This enables
users to "explicitly" specify attributes of the breakpoint location
to avoid any ambiguity that might otherwise exist with linespecs.

The general syntax of explicit locations is:
-source SOURCE_FILENAME -line {+-}LINE -function FUNCTION_NAME
-label LABEL_NAME

Option names may be abbreviated, e.g., "-s SOURCE_FILENAME -li 3" and users
may use the completer with either options or values.

gdb/ChangeLog:

	* completer.c: Include location.h.
	(enum match_type): New enum.
	(location_completer): Rename to ...
	(linespec_completer): ... this.
	(collect_explicit_location_matches, backup_text_ptr)
	(explicit_location_completer): New functions.
	(location_completer): "New" function; handle linespec
	and explicit location completions.
	(complete_line_internal): Remove all location completer-specific
	handling.
	* linespec.c (linespec_lexer_lex_keyword, is_ada_operator)
	(find_toplevel_char): Export.
	(linespec_parse_line_offset): Export.
	Issue error if STRING is not numerical.
	(gdb_get_linespec_parser_quote_characters): New function.
	* linespec.h (linespec_parse_line_offset): Declare.
	(get_gdb_linespec_parser_quote_characters): Declare.
	(is_ada_operator): Declare.
	(find_toplevel_char): Declare.
	(linespec_lexer_lex_keyword): Declare.
	* location.c (explicit_to_event_location): New function.
	(explicit_location_lex_one): New function.
	(string_to_explicit_location): New function.
	(string_to_event_location): Handle explicit locations.
	* location.h (explicit_to_event_location): Declare.
	(string_to_explicit_location): Declare.

gdb/testsuite/ChangeLog:

	* gdb.linespec/3explicit.c: New file.
	* gdb.linespec/cpexplicit.cc: New file.
	* gdb.linespec/cpexplicit.exp: New file.
	* gdb.linespec/explicit.c: New file.
	* gdb.linespec/explicit.exp: New file.
	* gdb.linespec/explicit2.c: New file.
	* gdb.linespec/ls-errs.exp: Add explicit location tests.
	* lib/gdb.exp (capture_command_output): Regexp-escape `command'
	before using in the matching pattern.
	Clarify that `prefix' is a regular expression.
2015-08-11 17:09:36 -07:00
Keith Seitz 00e52e5376 Explicit locations: introduce explicit locations
This patch add support for explicit locations and switches many linespec
locations to this new location type.  This patch also converts all
linespec locations entered by the user to an explicit representation
internally (thus bypassing the linespec parser when resetting the
breakpoint).

This patch does not introduce any user-visible changes.


gdb/ChangeLog:

	* break-catch-throw.c (re_set_exception_catchpoint): Convert
	linespec into explicit location.
	* breakpoint.c (create_overlay_breakpoint)
	(create_longjmp_master_breakpoint)
	(create_std_terminate_master_breakpoint)
	(create_exception_master_breakpoint): Convert linespec into explicit
	location.
	(update_static_tracepoint): Convert linespec into explicit location.
	* linespec.c (enum offset_relative_sign, struct line_offset): Move
	location.h.
	(struct linespec) <expression, expr_pc, source_filename>
	<function_name, label_name, line_offset>: Replace with ...
	<explicit>: ... this.
	<is_linespec>: New member.
	(PARSER_EXPLICIT): New accessor macro.
	(undefined_label_error): New function.
	(source_file_not_found_error): New function.
	(linespec_parse_basic): The parser result is now an explicit location.
	Use PARSER_EXPLICIT to access it.
	Use undefined_label_error.
	(canonicalize_linespec): Convert canonical linespec into explicit
	location.
	Move string representation of location to explicit_location_to_linespec
	and use it and explicit_location_to_string to save string
	representations of the canonical location.
	(create_sals_line_offset, convert_linespec_to_sals): `ls' contains an
	explicit location.  Update all references.
	(convert_explicit_location_to_sals): New function.
	(parse_linespec): Use PARSER_EXPLICIT to access the parser
	result's explicit location.
	(linespec_state_constructor): Initialize is_linespec.
	Use PARSER_EXPLICIT.
	(linespec_parser_delete): Use PARSER_EXPLICIT to access the parser's
	result.
	(event_location_to_sals): For linespec locations, set is_linespec.
	Handle explicit locations.
	(decode_objc): 'ls' contains an explicit location now. Update all
	references.
	(symtabs_from_filename): Use source_file_not_found_error.
	* location.c (struct event_location.u) <explicit>: New member.
	(initialize_explicit_location): New function.
	(initialize_event_location): Initialize explicit locations.
	(new_explicit_location, get_explicit_location)
	(get_explicit_location_const): New functions.
	(explicit_to_string_internal): New function; most of contents moved
	from canonicalize_linespec.
	(explicit_location_to_string): New function.
	(explicit_location_to_linespec): New function.
	(copy_event_location, delete_event_location)
	(event_location_to_string_const, event_location_empty_p): Handle
	explicit locations.
	* location.h (enum offset_relative_sign, struct line_offset): Move
	here from linespec.h.
	(enum event_location_type): Add EXPLICIT_LOCATION.
	(struct explicit_location): New structure.
	(explicit_location_to_string): Declare.
	(explicit_location_to_linespec): Declare.
	(new_explicit_location, get_explicit_locationp
	(get_explicit_location_const, initialize_explicit_location): Declare.
2015-08-11 17:09:35 -07:00
Keith Seitz 5b56227bdc Explicit locations: introduce probe locations
This patch adds support for probe locations and converts existing
probe linespec locations to the new location type.

gdb/ChangeLog:

	* break-catch-throw.c (re_set_exception_catchpoint): Convert
	linespec for stap probe to probe location.
	* breakpoint.c (create_longjmp_master_breakpoint)
	(create_exception_master_breakpoint): Likewise.
	(break_command_1): Remove local variable `arg_cp'.
	Check location type to set appropriate breakpoint ops methods.
	(trace_command): Likewise.
	* linespec.c (event_location_to_sals): Assert on probe locations.
	* location.c (EL_PROBE): Add macro definition.
	(new_probe_location, get_probe_location): New functions.
	(copy_event_location, delete_event_location, event_location_to_string)
	(string_to_event_location, event_location_empty_p): Handle probe
	locations.
	* location.h (enum event_location_type): Add PROBE_LOCATION.
	(new_probe_location, get_probe_location): Declare.
	* probe.c (parse_probes): Assert that LOCATION is a probe location.
	Convert linespec into probe location.
2015-08-11 17:09:35 -07:00
Keith Seitz a06efdd6ef Explicit locations: introduce address locations
This patch adds support for address locations, of the form "*ADDR".
[Support for address linespecs has been removed/replaced by this "new"
location type.] This patch also converts any existing address locations
from its previous linespec type.

gdb/ChangeLog:

	* breakpoint.c (create_thread_event_breakpoint, init_breakpoint_sal):
	Convert linespec to address location.
	* linespec.c (canonicalize_linespec): Do not handle address
	locations here.
	(convert_address_location_to_sals): New function; contents moved
	from ...
	(convert_linespc_to_sals): ... here.
	(parse_linespec): Remove address locations from linespec grammar.
	Remove handling of address locations.
	(linespec_lex_to_end): Remove handling of address linespecs.
	(event_location_to_sals): Handle ADDRESS_LOCATION.
	(linespec_expression_to_pc): Export.
	* linespec.h (linespec_expression_to_pc): Add declaration.
	* location.c (struct event_location.u) <address>: New member.
	(new_address_location, get_address_location): New functions.
	(copy_event_location, delete_event_location, event_location_to_string)
	(string_to_event_location, event_location_empty_p): Handle address
	locations.
	* location.h (enum event_location_type): Add ADDRESS_LOCATION.
	(new_address_location, get_address_location): Declare.
	* python/py-finishbreakpoint.c (bpfinishpy_init): Convert linespec
	to address location.
	* spu-tdep.c (spu_catch_start): Likewise.
2015-08-11 17:09:35 -07:00
Keith Seitz c7c1b3e998 Explicit locations: introduce new struct event_location-based API
This patch introduces the new breakpoint/"linespec" API based on
a new struct event_location.  This API currently only supports
traditional linespecs, maintaining the status quo of the code base.
Future patches will add additional functionality for other location
types such as address locations.

gdb/ChangeLog:

	* Makefile.in (SFILES): Add location.c.
	(HFILES_NO_SRCDIR): Add location.h.
	(COMMON_OBS): Add location.o.
	* linespec.c (linespec_lex_to_end): New function.
	* linespec.h (linespec_lex_to_end): Declare.
	* location.c: New file.
	* location.h: New file.
2015-08-11 17:09:35 -07:00