Commit Graph

139 Commits

Author SHA1 Message Date
Tom Tromey f5272a3bb3 Remove read_memory_string
read_memory_string is redundant and only called in a couple of spots.
This patch removes it in favor of target_read_string.

gdb/ChangeLog
2020-06-15  Tom Tromey  <tromey@adacore.com>

	* corefile.c (read_memory_string): Remove.
	* ada-valprint.c (ada_value_print_ptr): Update.
	* ada-lang.h (ada_tag_name): Change return type.
	* ada-lang.c (type_from_tag): Update.
	(ada_tag_name_from_tsd): Change return type.  Use
	target_read_string.
	(ada_tag_name): Likewise.
	* gdbcore.h (read_memory_string): Don't declare.
2020-06-15 06:28:09 -06:00
Joel Brobecker b2188a06e4 update name of several Ada fixed-point type handling functions
The purpose of this patch is to prepare for the future where
fixed point types become described using standard DWARF info,
rather than GNAT encodings. For that, we rename a number of
routines manipulating Ada fixed point types to make it explicit
from their new names that they rely on the GNAT encodings to work.
This will allow us, when we introduce support for fixed point types
from standard DWARF to use names that are not ambiguous with
the functions that do similar work, but only for GNAT encodings.

gdb/ChangeLog:

        * ada-lang.h: (ada_is_gnat_encoded_fixed_point_type): Renames
        ada_is_fixed_point_type.  Update all callers.
        (gnat_encoded_fixed_point_delta): Renames ada_delta.  Update
        all callers.
        * ada-lang.c (gnat_encoded_fixed_type_info): Renames fixed_type_info.
        Update all callers.
        * ada-typeprint.c (print_gnat_encoded_fixed_point_type): Renames
        print_fixed_point_type.  Update all callers.
        * ada-valprint.c (ada_value_print_num): Replace call to
        ada_is_fixed_point_type by ada_is_gnat_encoded_fixed_point_type.
2020-05-15 16:06:42 -04:00
Tom Tromey 5eb68a39a2 Fix Ada value printing on PPC64
The val_print removal patches introduced an Ada regression on PPC64
(probably any big-endian system).

The issue comes because value_field does not understand that Ada
wrapper fields can be bitfields that wrap a non-scalar type.  In this
case the value is already left-justified, so the justification done
there does the wrong thing.

Perhaps it would be good, eventually, to change value_field to
understand this case.  In the meantime this implements an Ada-specific
solution.

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

	* ada-lang.c (ada_value_primitive_field): Now public.
	* ada-lang.h (ada_value_primitive_field): Declare.
	* ada-valprint.c (print_field_values): Use
	ada_value_primitive_field for wrapper fields.
2020-05-11 14:57:49 -06:00
Tom Tromey d8af906814 Change ada_which_variant_applies to value API
While debugging an Ada regression, I noticed that all the callers of
ada_which_variant_applies desconstruct a value, only to have it be
reconstructed by this function.

This patch removes this inefficiency in favor of simply passing in the
value directly.

Tested on x86-64 Fedora 30.

gdb/ChangeLog
2020-03-30  Tom Tromey  <tromey@adacore.com>

	* ada-valprint.c (print_variant_part): Update.
	* ada-lang.h (ada_which_variant_applies): Update.
	* ada-lang.c (ada_which_variant_applies): Remove outer_type and
	outer_valaddr parameters; replace with "outer" value parameter.
	(to_fixed_variant_branch_type): Update.
2020-03-30 11:54:50 -06:00
Tom Tromey 426a9c18dd Remove val_print
We can finally remove val_print and various helper functions that are
no longer needed.

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

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

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

	* ada-valprint.c (ada_value_print_inner): New function.
	* ada-lang.h (ada_value_print_inner): Declare.
	* ada-lang.c (ada_language_defn): Use ada_value_print_inner.
2020-03-13 18:03:40 -06:00
Joel Brobecker b811d2c292 Update copyright year range in all GDB files.
gdb/ChangeLog:

        Update copyright year range in all GDB files.
2020-01-01 10:20:53 +04:00
Simon Marchi de93309a38 Clean up ada-lang.h
This patch cleans up ada-lang.h:

- Some functions just don't exist anymore, remove their declaration
- Some functions are implemented in ada-lang.c and only used there, make
  them static to that file.

I moved some functions higher in the file to avoid having to
forward-declare them, but the implementations are unchanged.

gdb/ChangeLog:

	* ada-lang.h (GROW_VECT): Move to ada-lang.c.
	(grow_vect): Remove declaration.
	(ada_type_of_array): Remove declaration.
	(ada_update_initial_language): Remove declaration.
	(ada_fold_name): Remove declaration.
	(ada_fill_in_ada_prototype): Remove declaration.
	(user_select_syms): Remove declaration.
	(get_selections): Remove declaration.
	(ada_tag_type): Remove declaration.
	(ada_value_tag): Remove declaration.
	(ada_is_others_clause): Remove declaration.
	(ada_in_variant): Remove declaration.
	(ada_value_struct_elt): Remove declaration.
	(ada_attribute_name): Remove declaration.
	(ada_system_address_type): Remove declaration.
	* ada-lang.c (ada_watch_location_expression): Make static.
	(GROW_VECT): Move here from ada-lang.h.
	(grow_vect): Make static.
	(ada_update_initial_language): Make static.
	(ada_fold_name): Make static.
	(ada_type_of_array): Make static.
	(encoded_ordered_before): Move up.
	(sort_choices): Move up.
	(print_signatures): Move up.
	(ada_print_symbol_signature): Move up.
	(get_selections): Move up and make static.
	(user_select_syms): Move up and make static.
	(ada_value_struct_elt): Move up and make static.
	(ada_tag_type): Make static.
	(ada_value_tag): Make static.
	(ada_is_others_clause): Make static.
	(ada_in_variant): Make static.
	(ada_attribute_name): Make static.

Change-Id: If0d46ba87d6585ab674c87244068a19e84718fc9
2019-10-29 17:52:24 -04:00
Andrew Burgess 0dc327459b gdb: Remove vec.{c,h} and update code to not include vec.h
Removes vec.c and vec.h from the source tree, and remove all the
remaining includes of vec.h.  There should be no user visible changes
after this commit.

I did have a few issues rebuilding GDB after applying this patch due
to cached dependencies, I found that running this command in the build
directory resolved my build issues without requiring a 'make clean':

    rm -fr gdb/gdbserver/gdbsupport/.deps/

gdb/ChangeLog:

	* Makefile.in: Remove references to vec.h and vec.c.
	* aarch64-tdep.c: No longer include vec.h.
	* ada-lang.c: Likewise.
	* ada-lang.h: Likewise.
	* arm-tdep.c: Likewise.
	* ax.h: Likewise.
	* breakpoint.h: Likewise.
	* charset.c: Likewise.
	* cp-support.h: Likewise.
	* dtrace-probe.c: Likewise.
	* dwarf2read.c: Likewise.
	* extension.h: Likewise.
	* gdb_bfd.c: Likewise.
	* gdbsupport/gdb_vecs.h: Likewise.
	* gdbsupport/vec.c: Remove.
	* gdbsupport/vec.h: Remove.
	* gdbthread.h: Likewise.
	* guile/scm-type.c: Likewise.
	* inline-frame.c: Likewise.
	* machoread.c: Likewise.
	* memattr.c: Likewise.
	* memrange.h: Likewise.
	* namespace.h: Likewise.
	* nat/linux-btrace.h: Likewise.
	* osdata.c: Likewise.
	* parser-defs.h: Likewise.
	* progspace.h: Likewise.
	* python/py-type.c: Likewise.
	* record-btrace.c: Likewise.
	* rust-exp.y: Likewise.
	* solib-target.c: Likewise.
	* stap-probe.c: Likewise.
	* target-descriptions.c: Likewise.
	* target-memory.c: Likewise.
	* target.h: Likewise.
	* varobj.c: Likewise.
	* varobj.h: Likewise.
	* xml-support.h: Likewise.

gdb/gdbserver/ChangeLog:

	* Makefile.in: Remove references to vec.c.

Change-Id: I0c91d7170bf1b5e992a387fcd9fe4f2abe343bb5
2019-10-15 21:31:55 +01:00
Christian Biesinger f945dedfd3 Make ada_decode not use a static buffer
This makes it safer to use in general, and also allows using it on a
background thread in the future.

Inspired by tromey's patch at:
1226cbdfa4
(however, implemented in a different way)

gdb/ChangeLog:

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

	* ada-exp.y (write_object_remaining): Update.
	* ada-lang.c (ada_decode): Return a std::string instead of a char*
	and eliminate the static buffer.
	(ada_decode_symbol): Update.
	(ada_la_decode): Update.
	(ada_sniff_from_mangled_name): Update.
	(is_valid_name_for_wild_match): Update.
	(ada_lookup_name_info::matches): Update and simplify.
	(name_matches_regex): Update.
	(ada_add_global_exceptions): Update.
	* ada-lang.h (ada_decode): Update signature.
	* ada-varobj.c (ada_varobj_describe_simple_array_child): Update.
	* dwarf-index-write.c (debug_names::insert): Update.
2019-09-23 13:36:34 -05:00
Tom Tromey f06f1252b0 Change Ada catchpoints to be bp_catchpoint
Like Pedro's earlier patches to change catchpoint to be of type
bp_catchpoint, this changes the Ada catchpoints to follow.

Tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-07-10  Tom Tromey  <tromey@adacore.com>

	* ada-lang.h (is_ada_exception_catchpoint): Declare.
	* breakpoint.c (init_ada_exception_breakpoint): Register as
	bp_catchpoint.
	(print_one_breakpoint_location, print_one_breakpoint): Use
	is_ada_exception_catchpoint.
	* ada-lang.c (class ada_catchpoint_location): Pass
	bp_loc_software_breakpoint to bp_location constructor.
	(is_ada_exception_catchpoint): New function.

gdb/testsuite/ChangeLog
2019-07-10  Tom Tromey  <tromey@adacore.com>

	* gdb.ada/mi_ex_cond.exp: Update expected results.
	* gdb.ada/mi_catch_ex_hand.exp: Update expected results.
	* gdb.ada/mi_catch_ex.exp: Update expected results.
	* gdb.ada/mi_catch_assert.exp: Update expected results.
	* gdb.ada/catch_ex.exp (catch_exception_info)
	(catch_exception_entry, catch_assert_entry)
	(catch_unhandled_entry): Update.
	* gdb.ada/catch_assert_if.exp: Update expected results.
2019-07-10 14:48:53 -06: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 65392b3edd Remove is_a_field_of_this from ada_lookup_symbol
All callers of ada_lookup_symbol pass NULL for the
"is_a_field_of_this" parameter, so remove it.

gdb/ChangeLog
2019-07-01  Tom Tromey  <tromey@adacore.com>

	* ada-exp.y (find_primitive_type): Update.
	* ada-lang.h (ada_lookup_symbol): Update.
	* ada-lang.c (ada_lookup_symbol): Remove "is_a_field_of_this"
	parameter.
	(ada_lookup_encoded_symbol, ada_lookup_symbol_nonlocal): Update.
2019-07-01 06:29:04 -06:00
Tom Tromey c0e70c624f Remove find_old_style_renaming_symbol
We found a case where a "bt" was very slow with Ada code.  Profiling
with callgrind showed this to be primarily due to calls to
find_old_style_renaming_symbol.  Because new-style renaming symbols
were implemented in 2007, it seems safe enough to remove this old
code.

A "-batch -ex bt" test on a large Ada program improves from:

    13.23user 0.57system 0:13.82elapsed 99%CPU (0avgtext+0avgdata 571408maxresident)k

to

    4.25user 0.48system 0:04.74elapsed 99%CPU (0avgtext+0avgdata 559844maxresident)k

with this patch.

Tested on x86-64 Fedora 29.  Joel reviewed this internally; and as it
is Ada-specific, I am checking it in.

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

	* ada-lang.c (ada_remove_Xbn_suffix)
	(find_old_style_renaming_symbol)
	(parse_old_style_renaming): Remove.
	(ada_find_renaming_symbol): Don't call
	find_old_style_renaming_symbol.
	(ada_is_renaming_symbol): Rename from
	ada_find_renaming_symbol.  Remove "block" parameter.  Return
	bool.  Now static.
	(ada_read_var_value): Update and simplify.
	* ada-exp.y (write_var_or_type): Remove old code.
2019-05-28 12:39:01 -04:00
Tom Tromey 24c54127c5 Two minor constifications
I noticed a couple of spots where a "char *" was used where a
"const char *" made more sense.  This patch fixes both of them.
Tested by rebuilding.

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

	* thread.c (print_thread_info): Make "requested_threads" const.
	* gdbthread.h (print_thread_info): Make "requested_threads"
	const.
	* ada-tasks.c (print_ada_task_info): Make "taskno_str" const.
	* ada-lang.h (print_ada_task_info): Make "taskno_str" const.
2019-05-10 07:17:48 -06:00
Andrew Burgess fc913e53c3 gdb/ada: Update some predicate functions to return bool
A later commit would like to make use of a pointer to the function
ada_is_string_type, however, this will require the function to return
a bool (so the signature matches).

As the ada_is_string_type is a predicate function, and its return
value is only ever used as either true or false, then this commit
updates the function to return a bool.

As a consequence ada_is_character_type needs to change too.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_is_character_type): Change return type to bool.
	(ada_is_string_type): Likewise.
	* ada-lang.h (ada_is_character_type): Update declaration
	(ada_is_string_type): Likewise.
2019-04-29 22:01:06 +01:00
Tom Tromey 98814c6c11 Minor Ada task cleanups
While working on the Ada task code, I noticed a few things that could
be cleaned up:

* task_list_valid_p was not set in all cases in ada_build_task_list.
  This causes many needless re-fetches of the task list.

* task_list_valid_p can be bool, and various functions can also return
  bool.

* Nothing checks the return value of read_known_tasks, so it can be
  changed to return void.

* The call to ada_build_task_list in
  ravenscar_thread_target::update_thread_list is redundant, because
  this is the first thing done by iterate_over_live_ada_tasks.

Tested using the internal AdaCore test suite against a ravenscar
target.

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

	* ravenscar-thread.c
	(ravenscar_thread_target::update_thread_list): Don't call
	ada_build_task_list.
	* ada-lang.h (ada_build_task_list): Don't declare.
	* ada-tasks.c (struct ada_tasks_inferior_data)
	<task_list_valid_p>: Now bool.
	(read_known_tasks, ada_task_list_changed)
	(ada_tasks_invalidate_inferior_data): Update.
	(read_known_tasks_array): Return bool.
	(read_known_tasks_list): Likewise.
	(read_known_tasks): Return void.
	(ada_build_task_list): Now static.
2019-02-19 12:26:37 -07:00
Tom Tromey 0747795c08 Normalize includes to use common/
This changes all includes to use the form "common/filename.h" rather
than just "filename.h".  This was written by a script.

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

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

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

	* win32-low.c: Fix common/ includes.
	* win32-i386-low.c: Fix common/ includes.
	* tracepoint.c: Fix common/ includes.
	* thread-db.c: Fix common/ includes.
	* target.h: Fix common/ includes.
	* symbol.c: Fix common/ includes.
	* spu-low.c: Fix common/ includes.
	* server.h: Fix common/ includes.
	* server.c: Fix common/ includes.
	* remote-utils.c: Fix common/ includes.
	* regcache.h: Fix common/ includes.
	* regcache.c: Fix common/ includes.
	* nto-x86-low.c: Fix common/ includes.
	* notif.h: Fix common/ includes.
	* mem-break.h: Fix common/ includes.
	* lynx-low.c: Fix common/ includes.
	* lynx-i386-low.c: Fix common/ includes.
	* linux-x86-tdesc-selftest.c: Fix common/ includes.
	* linux-x86-low.c: Fix common/ includes.
	* linux-low.c: Fix common/ includes.
	* inferiors.h: Fix common/ includes.
	* i387-fp.c: Fix common/ includes.
	* hostio.c: Fix common/ includes.
	* hostio-errno.c: Fix common/ includes.
	* gdbthread.h: Fix common/ includes.
	* gdbreplay.c: Fix common/ includes.
	* fork-child.c: Fix common/ includes.
	* event-loop.c: Fix common/ includes.
	* ax.c:
	(enum gdb_agent_op): Fix common/ includes.
2019-01-25 15:28:16 -07:00
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
Xavier Roirand d91e9ea81d (Ada) Cleanup code by using ada_is_access_to_unconstrained_array call.
This patch just avoids code duplication by using a function we
introduced recently (ada_is_access_to_unconstrained_array).

gdb/ChangeLog:

    * ada-lang.c (ada_is_access_to_unconstrained_array): Remove static
    declaration.
    * ada-lang.h: add ada_is_access_to_unconstrained_array prototype.
    * ada-varobj.c (ada_varobj_get_number_of_children,
    ada_varobj_describe_child, ada_value_is_changeable_p): Cleanup code.

Tested on x86_64-linux.
No new testcase provided, as this is just a refactoring.
2018-09-10 11:35:58 -04:00
Pedro Alves 00431a78b2 Use thread_info and inferior pointers more throughout
This is more preparation bits for multi-target support.

In a multi-target scenario, we need to address the case of different
processes/threads running on different targets that happen to have the
same PID/PTID.  E.g., we can have both process 123 in target 1, and
process 123 in target 2, while they're in reality different processes
running on different machines.  Or maybe we've loaded multiple
instances of the same core file.  Etc.

To address this, in my WIP multi-target branch, threads and processes
are uniquely identified by the (process_stratum target_ops *, ptid_t)
and (process_stratum target_ops *, pid) tuples respectively.  I.e.,
each process_stratum instance has its own thread/process number space.

As you can imagine, that requires passing around target_ops * pointers
in a number of functions where we're currently passing only a ptid_t
or an int.  E.g., when we look up a thread_info object by ptid_t in
find_thread_ptid, the ptid_t alone isn't sufficient.

In many cases though, we already have the thread_info or inferior
pointer handy, but we "lose" it somewhere along the call stack, only
to look it up again by ptid_t/pid.  Since thread_info or inferior
objects know their parent target, if we pass around thread_info or
inferior pointers when possible, we avoid having to add extra
target_ops parameters to many functions, and also, we eliminate a
number of by ptid_t/int lookups.

So that's what this patch does.  In a bit more detail:

- Changes a number of functions and methods to take a thread_info or
  inferior pointer instead of a ptid_t or int parameter.

- Changes a number of structure fields from ptid_t/int to inferior or
  thread_info pointers.

- Uses the inferior_thread() function whenever possible instead of
  inferior_ptid.

- Uses thread_info pointers directly when possible instead of the
  is_running/is_stopped etc. routines that require a lookup.

- A number of functions are eliminated along the way, such as:

  int valid_gdb_inferior_id (int num);
  int pid_to_gdb_inferior_id (int pid);
  int gdb_inferior_id_to_pid (int num);
  int in_inferior_list (int pid);

- A few structures and places hold a thread_info pointer across
  inferior execution, so now they take a strong reference to the
  (refcounted) thread_info object to avoid the thread_info pointer
  getting stale.  This is done in enable_thread_stack_temporaries and
  in the infcall.c code.

- Related, there's a spot in infcall.c where using a RAII object to
  handle the refcount would be handy, so a gdb::ref_ptr specialization
  for thread_info is added (thread_info_ref, in gdbthread.h), along
  with a gdb_ref_ptr policy that works for all refcounted_object types
  (in common/refcounted-object.h).

gdb/ChangeLog:
2018-06-21  Pedro Alves  <palves@redhat.com>

	* ada-lang.h (ada_get_task_number): Take a thread_info pointer
	instead of a ptid_t.  All callers adjusted.
	* ada-tasks.c (ada_get_task_number): Likewise.  All callers
	adjusted.
	(print_ada_task_info, display_current_task_id, task_command_1):
	Adjust.
	* breakpoint.c (watchpoint_in_thread_scope): Adjust to use
	inferior_thread.
	(breakpoint_kind): Adjust.
	(remove_breakpoints_pid): Rename to ...
	(remove_breakpoints_inf): ... this.  Adjust to take an inferior
	pointer.  All callers adjusted.
	(bpstat_clear_actions): Use inferior_thread.
	(get_bpstat_thread): New.
	(bpstat_do_actions): Use it.
	(bpstat_check_breakpoint_conditions, bpstat_stop_status): Adjust
	to take a thread_info pointer.  All callers adjusted.
	(set_longjmp_breakpoint_for_call_dummy, set_momentary_breakpoint)
	(breakpoint_re_set_thread): Use inferior_thread.
	* breakpoint.h (struct inferior): Forward declare.
	(bpstat_stop_status): Update.
	(remove_breakpoints_pid): Delete.
	(remove_breakpoints_inf): New.
	* bsd-uthread.c (bsd_uthread_target::wait)
	(bsd_uthread_target::update_thread_list): Use find_thread_ptid.
	* btrace.c (btrace_add_pc, btrace_enable, btrace_fetch)
	(maint_btrace_packet_history_cmd)
	(maint_btrace_clear_packet_history_cmd): Adjust.
	(maint_btrace_clear_cmd, maint_info_btrace_cmd): Adjust to use
	inferior_thread.
	* cli/cli-interp.c: Include "inferior.h".
	* common/refcounted-object.h (struct
	refcounted_object_ref_policy): New.
	* compile/compile-object-load.c: Include gdbthread.h.
	(store_regs): Use inferior_thread.
	* corelow.c (core_target::close): Use current_inferior.
	(core_target_open): Adjust to use first_thread_of_inferior and use
	the current inferior.
	* ctf.c (ctf_target::close): Adjust to use current_inferior.
	* dummy-frame.c (dummy_frame_id) <ptid>: Delete, replaced by ...
	<thread>: ... this new field.  All references adjusted.
	(dummy_frame_pop, dummy_frame_discard, register_dummy_frame_dtor):
	Take a thread_info pointer instead of a ptid_t.
	* dummy-frame.h (dummy_frame_push, dummy_frame_pop)
	(dummy_frame_discard, register_dummy_frame_dtor): Take a
	thread_info pointer instead of a ptid_t.
	* elfread.c: Include "inferior.h".
	(elf_gnu_ifunc_resolver_stop, elf_gnu_ifunc_resolver_return_stop):
	Use inferior_thread.
	* eval.c (evaluate_subexp): Likewise.
	* frame.c (frame_pop, has_stack_frames, find_frame_sal): Use
	inferior_thread.
	* gdb_proc_service.h (struct thread_info): Forward declare.
	(struct ps_prochandle) <ptid>: Delete, replaced by ...
	<thread>: ... this new field.  All references adjusted.
	* gdbarch.h, gdbarch.c: Regenerate.
	* gdbarch.sh (get_syscall_number): Replace 'ptid' parameter with a
	'thread' parameter.  All implementations and callers adjusted.
	* gdbthread.h (thread_info) <set_running>: New method.
	(delete_thread, delete_thread_silent): Take a thread_info pointer
	instead of a ptid.
	(global_thread_id_to_ptid, ptid_to_global_thread_id): Delete.
	(first_thread_of_process): Delete, replaced by ...
	(first_thread_of_inferior): ... this new function.  All callers
	adjusted.
	(any_live_thread_of_process): Delete, replaced by ...
	(any_live_thread_of_inferior): ... this new function.  All callers
	adjusted.
	(switch_to_thread, switch_to_no_thread): Declare.
	(is_executing): Delete.
	(enable_thread_stack_temporaries): Update comment.
	<enable_thread_stack_temporaries>: Take a thread_info pointer
	instead of a ptid_t.  Incref the thread.
	<~enable_thread_stack_temporaries>: Decref the thread.
	<m_ptid>: Delete
	<m_thr>: New.
	(thread_stack_temporaries_enabled_p, push_thread_stack_temporary)
	(get_last_thread_stack_temporary)
	(value_in_thread_stack_temporaries, can_access_registers_thread):
	Take a thread_info pointer instead of a ptid_t.  All callers
	adjusted.
	* infcall.c (get_call_return_value): Use inferior_thread.
	(run_inferior_call): Work with thread pointers instead of ptid_t.
	(call_function_by_hand_dummy): Work with thread pointers instead
	of ptid_t.  Use thread_info_ref.
	* infcmd.c (proceed_thread_callback): Access thread's state
	directly.
	(ensure_valid_thread, ensure_not_running): Use inferior_thread,
	access thread's state directly.
	(continue_command): Use inferior_thread.
	(info_program_command): Use find_thread_ptid and access thread
	state directly.
	(proceed_after_attach_callback): Use thread state directly.
	(notice_new_inferior): Take a thread_info pointer instead of a
	ptid_t.  All callers adjusted.
	(exit_inferior): Take an inferior pointer instead of a pid.  All
	callers adjusted.
	(exit_inferior_silent): New.
	(detach_inferior): Delete.
	(valid_gdb_inferior_id, pid_to_gdb_inferior_id)
	(gdb_inferior_id_to_pid, in_inferior_list): Delete.
	(detach_inferior_command, kill_inferior_command): Use
	find_inferior_id instead of valid_gdb_inferior_id and
	gdb_inferior_id_to_pid.
	(inferior_command): Use inferior and thread pointers.
	* inferior.h (struct thread_info): Forward declare.
	(notice_new_inferior): Take a thread_info pointer instead of a
	ptid_t.  All callers adjusted.
	(detach_inferior): Delete declaration.
	(exit_inferior, exit_inferior_silent): Take an inferior pointer
	instead of a pid.  All callers adjusted.
	(gdb_inferior_id_to_pid, pid_to_gdb_inferior_id, in_inferior_list)
	(valid_gdb_inferior_id): Delete.
	* infrun.c (follow_fork_inferior, proceed_after_vfork_done)
	(handle_vfork_child_exec_or_exit, follow_exec): Adjust.
	(struct displaced_step_inferior_state) <pid>: Delete, replaced by
	...
	<inf>: ... this new field.
	<step_ptid>: Delete, replaced by ...
	<step_thread>: ... this new field.
	(get_displaced_stepping_state): Take an inferior pointer instead
	of a pid.  All callers adjusted.
	(displaced_step_in_progress_any_inferior): Adjust.
	(displaced_step_in_progress_thread): Take a thread pointer instead
	of a ptid_t.  All callers adjusted.
	(displaced_step_in_progress, add_displaced_stepping_state): Take
	an inferior pointer instead of a pid.  All callers adjusted.
	(get_displaced_step_closure_by_addr): Adjust.
	(remove_displaced_stepping_state): Take an inferior pointer
	instead of a pid.  All callers adjusted.
	(displaced_step_prepare_throw, displaced_step_prepare)
	(displaced_step_fixup): Take a thread pointer instead of a ptid_t.
	All callers adjusted.
	(start_step_over): Adjust.
	(infrun_thread_ptid_changed): Remove bit updating ptids in the
	displaced step queue.
	(do_target_resume): Adjust.
	(fetch_inferior_event): Use inferior_thread.
	(context_switch, get_inferior_stop_soon): Take an
	execution_control_state pointer instead of a ptid_t.  All callers
	adjusted.
	(switch_to_thread_cleanup): Delete.
	(stop_all_threads): Use scoped_restore_current_thread.
	* inline-frame.c: Include "gdbthread.h".
	(inline_state) <inline_state>: Take a thread pointer instead of a
	ptid_t.  All callers adjusted.
	<ptid>: Delete, replaced by ...
	<thread>: ... this new field.
	(find_inline_frame_state): Take a thread pointer instead of a
	ptid_t.  All callers adjusted.
	(skip_inline_frames, step_into_inline_frame)
	(inline_skipped_frames, inline_skipped_symbol): Take a thread
	pointer instead of a ptid_t.  All callers adjusted.
	* inline-frame.h (skip_inline_frames, step_into_inline_frame)
	(inline_skipped_frames, inline_skipped_symbol): Likewise.
	* linux-fork.c (delete_checkpoint_command): Adjust to use thread
	pointers directly.
	* linux-nat.c (get_detach_signal): Likewise.
	* linux-thread-db.c (thread_from_lwp): New 'stopped' parameter.
	(thread_db_notice_clone): Adjust.
	(thread_db_find_new_threads_silently)
	(thread_db_find_new_threads_2, thread_db_find_new_threads_1): Take
	a thread pointer instead of a ptid_t.  All callers adjusted.
	* mi/mi-cmd-var.c: Include "inferior.h".
	(mi_cmd_var_update_iter): Update to use thread pointers.
	* mi/mi-interp.c (mi_new_thread): Update to use the thread's
	inferior directly.
	(mi_output_running_pid, mi_inferior_count): Delete, bits factored
	out to ...
	(mi_output_running): ... this new function.
	(mi_on_resume_1): Adjust to use it.
	(mi_user_selected_context_changed): Adjust to use inferior_thread.
	* mi/mi-main.c (proceed_thread): Adjust to use thread pointers
	directly.
	(interrupt_thread_callback): : Adjust to use thread and inferior
	pointers.
	* proc-service.c: Include "gdbthread.h".
	(ps_pglobal_lookup): Adjust to use the thread's inferior directly.
	* progspace-and-thread.c: Include "inferior.h".
	* progspace.c: Include "inferior.h".
	* python/py-exitedevent.c (create_exited_event_object): Adjust to
	hold a reference to an inferior_object.
	* python/py-finishbreakpoint.c (bpfinishpy_init): Adjust to use
	inferior_thread.
	* python/py-inferior.c (struct inferior_object): Give the type a
	tag name instead of a typedef.
	(python_on_normal_stop): No need to check if the current thread is
	listed.
	(inferior_to_inferior_object): Change return type to
	inferior_object.  All callers adjusted.
	(find_thread_object): Delete, bits factored out to ...
	(thread_to_thread_object): ... this new function.
	* python/py-infthread.c (create_thread_object): Use
	inferior_to_inferior_object.
	(thpy_is_stopped): Use thread pointer directly.
	(gdbpy_selected_thread): Use inferior_thread.
	* python/py-record-btrace.c (btpy_list_object) <ptid>: Delete
	field, replaced with ...
	<thread>: ... this new field.  All users adjusted.
	(btpy_insn_or_gap_new): Drop const.
	(btpy_list_new): Take a thread pointer instead of a ptid_t.  All
	callers adjusted.
	* python/py-record.c: Include "gdbthread.h".
	(recpy_insn_new, recpy_func_new): Take a thread pointer instead of
	a ptid_t.  All callers adjusted.
	(gdbpy_current_recording): Use inferior_thread.
	* python/py-record.h (recpy_record_object) <ptid>: Delete
	field, replaced with ...
	<thread>: ... this new field.  All users adjusted.
	(recpy_element_object) <ptid>: Delete
	field, replaced with ...
	<thread>: ... this new field.  All users adjusted.
	(recpy_insn_new, recpy_func_new): Take a thread pointer instead of
	a ptid_t.  All callers adjusted.
	* python/py-threadevent.c: Include "gdbthread.h".
	(get_event_thread): Use thread_to_thread_object.
	* python/python-internal.h (struct inferior_object): Forward
	declare.
	(find_thread_object, find_inferior_object): Delete declarations.
	(thread_to_thread_object, inferior_to_inferior_object): New
	declarations.
	* record-btrace.c: Include "inferior.h".
	(require_btrace_thread): Use inferior_thread.
	(record_btrace_frame_sniffer)
	(record_btrace_tailcall_frame_sniffer): Use inferior_thread.
	(get_thread_current_frame): Use scoped_restore_current_thread and
	switch_to_thread.
	(get_thread_current_frame): Use thread pointer directly.
	(record_btrace_replay_at_breakpoint): Use thread's inferior
	pointer directly.
	* record-full.c: Include "inferior.h".
	* regcache.c: Include "gdbthread.h".
	(get_thread_arch_regcache): Use the inferior's address space
	directly.
	(get_thread_regcache, registers_changed_thread): New.
	* regcache.h (get_thread_regcache(thread_info *thread)): New
	overload.
	(registers_changed_thread): New.
	(remote_target) <remote_detach_1>: Swap order of parameters.
	(remote_add_thread): <remote_add_thread>: Return the new thread.
	(get_remote_thread_info(ptid_t)): New overload.
	(remote_target::remote_notice_new_inferior): Use thread pointers
	directly.
	(remote_target::process_initial_stop_replies): Use
	thread_info::set_running.
	(remote_target::remote_detach_1, remote_target::detach)
	(extended_remote_target::detach): Adjust.
	* stack.c (frame_show_address): Use inferior_thread.
	* target-debug.h (target_debug_print_thread_info_pp): New.
	* target-delegates.c: Regenerate.
	* target.c (default_thread_address_space): Delete.
	(memory_xfer_partial_1): Use current_inferior.
	(target_detach): Use current_inferior.
	(target_thread_address_space): Delete.
	(generic_mourn_inferior): Use current_inferior.
	* target.h (struct target_ops) <thread_address_space>: Delete.
	(target_thread_address_space): Delete.
	* thread.c (init_thread_list): Use ALL_THREADS_SAFE.  Use thread
	pointers directly.
	(delete_thread_1, delete_thread, delete_thread_silent): Take a
	thread pointer instead of a ptid_t.  Adjust all callers.
	(ptid_to_global_thread_id, global_thread_id_to_ptid): Delete.
	(first_thread_of_process): Delete, replaced by ...
	(first_thread_of_inferior): ... this new function.  All callers
	adjusted.
	(any_thread_of_process): Rename to ...
	(any_thread_of_inferior): ... this, and take an inferior pointer.
	(any_live_thread_of_process): Rename to ...
	(any_live_thread_of_inferior): ... this, and take an inferior
	pointer.
	(thread_stack_temporaries_enabled_p, push_thread_stack_temporary)
	(value_in_thread_stack_temporaries)
	(get_last_thread_stack_temporary): Take a thread pointer instead
	of a ptid_t.  Adjust all callers.
	(thread_info::set_running): New.
	(validate_registers_access): Use inferior_thread.
	(can_access_registers_ptid): Rename to ...
	(can_access_registers_thread): ... this, and take a thread
	pointer.
	(print_thread_info_1): Adjust to compare thread pointers instead
	of ptids.
	(switch_to_no_thread, switch_to_thread): Make extern.
	(scoped_restore_current_thread::~scoped_restore_current_thread):
	Use m_thread pointer directly.
	(scoped_restore_current_thread::scoped_restore_current_thread):
	Use inferior_thread.
	(thread_command): Use thread pointer directly.
	(thread_num_make_value_helper): Use inferior_thread.
	* top.c (execute_command): Use inferior_thread.
	* tui/tui-interp.c: Include "inferior.h".
	* varobj.c (varobj_create): Use inferior_thread.
	(value_of_root_1): Use find_thread_global_id instead of
	global_thread_id_to_ptid.
2018-06-21 17:09:31 +01:00
Tom Tromey 69d340c684 Remove la_error
While working on the parser code, I noticed that yyerror is exported
from each parser.  It is used by this code in parse.c:

   TRY
     {
       if (lang->la_parser (&ps))
         lang->la_error (NULL);
     }

However, it seems to me that la_error will never be called here,
because in every case, la_parser throws an exception on error -- each
implementation of yyerror just calls error.

So, this patch removes la_error and makes all the yyerror functions
static.  This is handy primarily because it makes it simpler to make
the expression parsers pure.

Tested by the buildbot.

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

	* rust-lang.h (rust_yyerror): Don't declare.
	* rust-lang.c (rust_language_defn): Update.
	* rust-exp.y (yyerror): Now static.
	* parse.c (parse_exp_in_context_1): Update.
	* p-lang.h (p_yyerror): Don't declare.
	* p-lang.c (p_language_defn): Update.
	* p-exp.y (yyerror): Now static.
	* opencl-lang.c (opencl_language_defn): Update.
	* objc-lang.c (objc_language_defn): Update.
	* m2-lang.h (m2_yyerror): Don't declare.
	* m2-lang.c (m2_language_defn): Update.
	* m2-exp.y (yyerror): Now static.
	* language.h (struct language_defn) <la_error>: Remove.
	* language.c (unk_lang_error): Remove.
	(unknown_language_defn, auto_language_defn): Remove.
	* go-lang.h (go_yyerror): Don't declare.
	* go-lang.c (go_language_defn): Update.
	* go-exp.y (yyerror): Now static.
	* f-lang.h (f_yyerror): Don't declare.
	* f-lang.c (f_language_defn): Update.
	* f-exp.y (yyerror): Now static.
	* d-lang.h (d_yyerror): Don't declare.
	* d-lang.c (d_language_defn): Update.
	* d-exp.y (yyerror): Now static.
	* c-lang.h (c_yyerror): Don't declare.
	* c-lang.c (c_language_defn, cplus_language_defn)
	(asm_language_defn, minimal_language_defn): Update.
	* c-exp.y (yyerror): Now static.
	* ada-lang.h (ada_yyerror): Don't declare.
	* ada-lang.c (ada_language_defn): Update.
	* ada-exp.y (yyerror): Now static.
2018-06-18 12:29:15 -06:00
Tom Tromey 54d343a240 Remove last Ada cleanups
This removes the last cleanups from the Ada code by changing
ada_lookup_symbol_list's out parameter to be a std::vector, and then
fixing up the fallout.

This is a relatively shallow change.  Deeper changes are possible, for
example (1) changing various other functions to accept a vector rather
than a pointer, or (2) changing ada_lookup_symbol_list to return the
vector and omitting the length entirely.

Tested by the buildbot, but I'll wait for Joel to test these as well.

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

	* ada-lang.h (ada_lookup_symbol_list): Update.
	* ada-lang.c (resolve_subexp): Update.
	(symbols_are_identical_enums): Change type of syms.  Remove nsyms
	parameter.
	(remove_extra_symbols, remove_irrelevant_renamings): Likewise.
	(ada_lookup_symbol_list_worker, ada_lookup_symbol_list): Change
	results parameter to std::vector.
	(ada_iterate_over_symbols, ada_lookup_symbol, get_var_value):
	Update.
	* ada-exp.y (block_lookup): Update.
	(select_possible_type_sym): Change type of syms.  Remove nsyms
	parameter.
	(write_var_or_type, write_name_assoc): Update.
2018-06-04 15:33:28 -06:00
Tom Tromey bc18fbb575 Change ada_catchpoint::excep_string to be a std::string
This changes ada_catchpoint::excep_string to be a std::string and then
fixes up all t he users.

This found a memory leak in catch_ada_exception_command_split, where
"cond" was copied but never freed.

I changed the type of the "cond_string" argument to
catch_ada_exception_command_split to follow the rule that out
parameters should be pointers and not references.

This patch enables the removal of some cleanups and also the function
ada_get_next_arg.

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

	* mi/mi-cmd-catch.c (mi_cmd_catch_assert)
	(mi_cmd_catch_exception, mi_cmd_catch_handlers): Update.
	* ada-lang.h (create_ada_exception_catchpoint): Update.
	* ada-lang.c (struct ada_catchpoint) <excep_string>: Now a
	std::string.
	(create_excep_cond_exprs, ~ada_catchpoint)
	(should_stop_exception, print_one_exception)
	(print_mention_exception, print_recreate_exception): Update.
	(ada_get_next_arg): Remove.
	(catch_ada_exception_command_split): Use std::string.  Change type
	of "excep_string", "cond_string".
	(catch_ada_exception_command): Update.
	(create_ada_exception_catchpoint): Change type of excep_string.
	(ada_exception_sal): Remove excep_string parameter.
	(~ada_catchpoint): Remove.
2018-05-21 10:01:15 -06:00
Joel Brobecker f98b2e334f Remove references to ada_name_for_lookup (deleted)
This function was deleted on 2017-11-08, but its declaration and
a reference to it in a comment was left behind.  This patch just
removes those.

gdb/ChangeLog:

        * ada-lang.c (name_match_type_from_name): Remove reference to
        ada_name_for_lookup in function's documentation.
        * ada-lang.h (ada_name_for_lookup): Delete declaration.

Tested by rebuilding GDB.
2018-02-14 05:48:48 -05:00
Xavier Roirand 56ecd069f0 (Ada) C++fy conditional string when catching exception.
This commit C++fy the conditional string used when catching Ada exception.

gdb/ChangeLog:

        * ada-lang.c (catch_ada_exception_command_split)
        (create_ada_exception_catchpoint) <cond_string>: Change parameter
        type.  Update code accordingly.
        (catch_ada_exception_command, catch_ada_handlers_command): Use
        C++ string instead of char* for conditional var.
        (catch_ada_assert_command_split) <cond_string>: Change parameter
        type.  Update code accordingly.
        (catch_assert_command): Use C++ string instead of char* for
        conditional var.
        * ada-lang.h (create_ada_exception_catchpoint) <cond_string>:
        Update declaration.
        * mi/mi-cmd-catch.c (mi_cmd_catch_assert, mi_cmd_catch_exception):
        Use std::string instead of char* for condition string.

Tested on x86_64-linux.
2018-01-31 13:42:30 +01:00
Xavier Roirand 9f757bf7fc (Ada) New command to stop at start of exception handler.
When using gdb for debugging Ada source code, there are several catchpoint
types you can define in order to stop upon certain conditions.  Let's
use this small example:

procedure Foo is
begin
   begin
      raise Constraint_Error;
   exception
      when Program_Error =>
         null;
      when Constraint_Error =>
         null;
      when others =>
         null;
   end;
end Foo;

One can stop when the exception is being raised by using the exception
catchpoint like below:

(gdb) catch exception
Catchpoint 1: all Ada exceptions
(gdb)

In that case, when running Foo, gdb will stop at the line where the exception
was raised:

   begin
>>>   raise Constraint_Error;
   exception

This patch introduces new type of catchpoint, when the user wants to stop
at the location of the exception handling.
Imagine we want to stop on any exception handled by the program, we can do:

(gdb) catch handlers
Catchpoint 1: all Ada exceptions handlers
(gdb) r
Starting program: /tmp/foo

By doing so, when running Foo, gdb will stop here:

Catchpoint 1, exception at 0x000000000040255a in foo () at foo.adb:25
25          when Constraint_Error =>
(gdb)

It is also possible to stop when the Constraint_Error exception is being
handled in this program.  With this patch, we can use:

(gdb) catch handlers Constraint_Error
Catchpoint 1: `Constraint_Error' Ada exception handlers
(gdb)

Like for other catchpoint, you can set a condition when adding a catchpoint
on exception handlers.
Here the handlers catchpoint checks Global_Var:

(gdb) catch handlers Constraint_Error if Global_Var /= 0

gdb/ChangeLog:

        * ada-lang.h (ada_exception_catchpoint_kind) <ada_catch_handlers>:
        Add field.
        * ada-lang.c (struct exception_support_info) <catch_handlers_sym>:
        Add field.
        (default_exception_support_info) <catch_handlers_sym>: Add field.
        (exception_support_info_fallback) <catch_handlers_sym>: Add field.
        (ada_exception_name_addr_1): Add "catch handlers" handling.
        (ada_exception_catchpoint_cond_string) <ex>: New parameter.
        Update all callers.
        (create_excep_cond_exprs) <ex>: Add parameter.
        (re_set_exception): Update create_excep_cond_exprs call.
        (print_it_exception, print_one_exception, print_mention_exception)
        (print_recreate_exception): Add "catch handler" handling.
        (allocate_location_catch_handlers, re_set_catch_handlers)
        (check_status_catch_handlers, print_it_catch_handlers)
        (print_one_catch_handlers, print_mention_catch_handlers)
        (print_recreate_catch_handlers): New function.
        (catch_handlers_breakpoint_ops): New variable.
        (catch_ada_exception_command_split) <is_catch_handlers_cmd>:
        Add parameter.  Add "catch handler" handling.
        (ada_exception_sym_name, ada_exception_breakpoint_ops):
        Add "catch handler" handling.
        (ada_exception_catchpoint_cond_string): Add "catch handler"
        handling.
        (create_ada_exception_catchpoint): Update create_excep_cond_exprs
        call.
        (catch_ada_handlers_command): New function.
        (initialize_ada_catchpoint_ops): Initialize "catch handlers"
        operations structure.
        (_initialize_ada_language): Add "catch handlers" command entry.
        * NEWS: Document "catch handlers" feature.

gdb/doc/ChangeLog:

        * gdb.texinfo (Set Catchpoints): Add documentation for new
        "catch handlers" action.

gdb/testsuite/ChangeLog:

        * gdb.ada/excep_handle.exp: New testcase.
        * gdb.ada/excep_handle/foo.adb: New file.
        * gdb.ada/excep_handle/pck.ads: New file.

Tested on x86_64-linux.
2018-01-03 11:02:53 +01: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
Joel Brobecker cf3fbed4a0 problem debugging ravenscar programs if runtime is stripped
Trying to debug a program using a stripped version of the ravenscar
runtime, we can get the following error:

    (gdb) cont
    Continuing.
    Cannot find Ada_Task_Control_Block type. Aborting

This is because the ravenscar-thread layer makes the assumption that
the runtime is built the way we expect it, meaning that the Ada tasking
units we rely on for Ada tasking debugging, are built with debugging
information, and that this debug information has not been stripped from
the runtime.

When this assumption is not true, resuming such a program can trigger
the error above, which then leads GDB a little confused. For instance,
we can see things like:

     (gdb) bt
     Target is executing.

This patch fixes the issue by disabling the ravenscar thread layer
if we detect that the runtime is missing some of the debugging info
we need in order to support Ada task debugging. This is the best
we can do, as the ravenscar-thread layer actually depends on the
ada-tasks layer to implement thread debugging.

gdb/ChangeLog:

        * ada-lang.h (ada_get_tcb_types_info): Add declaration.
        * ada-tasks.c (ada_get_tcb_types_info): Renames get_tcb_types_info.
        Make non-static.  Change return type to char *.  Adjust code
        accordingly.  Rewrite the function's documentation.
        (read_atcb): Adjust call to get_tcb_types_info accordingly.
        * ravenscar-thread.c (ravenscar_inferior_created): Check that
        we have enough debugging information in the runtime to support
        Ada task debugging before we enable the ravenscar-thread layer.
2017-11-21 14:32:48 -08:00
Joel Brobecker 9edcc12f9b Add multiple-CPU support in ravenscar-thread.c
This patch reworks the ravenscar-thread layer to remove the
assumption that the target only has 1 CPU. In particular,
when connected to a QEMU target over the remote protocol,
QEMU reports each CPU as one thread. This patch adapts
the ravenscar-thread layer to this, and adds a large comment
explaining the general design of this unit.

gdb/ChangeLog:

        * ada-lang.h (ada_get_task_info_from_ptid): Add declaration.
        * ada-tasks.c (ada_get_task_info_from_ptid): New function.
        * ravenscar-thread.c: Add into comment.
        (base_magic_null_ptid): Delete.
        (base_ptid): Change documentation.
        (ravenscar_active_task): Renames ravenscar_running_thread.
        All callers updated throughout.
        (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function.
        (ravenscar_task_is_currently_active): Likewise.
        (get_base_thread_from_ravenscar_task): Ditto.
        (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs.
        (ravenscar_runtime_initialized): Likewise.
        (get_running_thread_id): Add new parameter "cpu".  Adjust
        implementation to handle this new parameter.
        (ravenscar_fetch_registers): Small adjustment to use
        is_ravenscar_task and ravenscar_task_is_currently_active in
        order to decide whether to use the target beneath or this
        module's arch_ops.
        (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise.
        (ravenscar_stopped_by_sw_breakpoint): Use
        get_base_thread_from_ravenscar_task to get the underlying
        thread, rather than using base_ptid.
        (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint)
        (ravenscar_stopped_data_address, ravenscar_core_of_thread):
        Likewise.
        (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 14:32:10 -08:00
Joel Brobecker 65d40437e2 Provide the "Base CPU" in output of "info task" (if set by runtime).
At the user level, this patch enhances the debugger to print the ID
of the base CPU a task is running on:

        (gdb) info task 3
        Ada Task: 0x13268
        Name: raven1
        Thread: 0x13280
        LWP: 0
 !!!->  Base CPU: 1
        No parent
        Base Priority: 127
        State: Runnable

This new field is only printed when the base CPU is nonzero or, in
other words, if the base CPU info is being provided by the runtime.
For instance, on native systems, where threads/processes can "jump"
from CPU to CPU, the info is not available, and the output of the
command above then remains unchanged.

At the internal level, the real purpose of this change is to prepare
the way for ravenscar-thread to start handling SMP systems. For that,
we'll need to know which CPU each task is running on...  More info
on that in the commit that actually adds support for it.

gdb/ChangeLog:

        * ada-lang.h (struct ada_task_info) <base_cpu>: New field.
        * ada-lang.c (struct atcb_fieldno) <base_cpu>: New field.
        (get_tcb_types_info): Set fieldnos.base_cpu.
        (read_atcb): Set task_info->base_cpu.
        (info_task): Print "Base CPU" info if set by runtime.
2017-11-21 14:31:32 -08:00
Ulrich Weigand 50eff16b85 Target FP: Perform Ada fixed-point scaling in target format
One of the few still remaining uses of DOUBLEST in GDB is the Ada front-end
code that handles scaling of Ada fixed-point types.  The target format for
those types is some integer format; to convert those values to standard
floating-point representation, that integer needs to be multiplied by a
rational scale factor, given as a pair of numerator and denominator.

To avoid having to deal with long integer arithmetic, the current Ada
front-end code currently performs those scaling operations in host
DOUBLEST arithmetic.  To eliminate this use of DOUBLEST, this patch
changes the front-end to instead perform those operations in the
*target* floating-point format (chosing to use the target "long double").

The implementation is mostly straight-forward, using value_cast and
value_binop to perform the target operations.

Scanning in the scale numerator and denominator is now done into
a host "long long" instead of a DOUBLEST, which should be large
enough to hold all possible values.  (Otherwise, this can be replaced
by target-format target_float_from_string operations as well.)

Printing fixed-point types and values should be completely unchanges,
using target_float_to_string with the same format strings as current code.

gdb/ChangeLog:
2017-11-06  Ulrich Weigand  <uweigand@de.ibm.com>

	* ada-lang.c (cast_to_fixed): Reimplement in target arithmetic.
	(cast_from_fixed): Likewise.
	(ada_scaling_type): New function.
	(ada_delta): Return value instead of DOUBLEST.  Perform target
	arithmetic instead of host arithmetic.
	(scaling_factor): Rename to ...
	(ada_scaling_factor) ... this.  Make non-static.  Return value instead
	of DOUBLEST.  Perform target arithmetic instead of host arithmetic.
	(ada_fixed_to_float): Remove.
	(ada_float_to_fixed): Remove.
	* ada-lang.h (ada_fixed_to_float): Remove.
	(ada_float_to_fixed): Remove.
	(ada_delta): Return value instead of DOUBLEST.
	(ada_scaling_factor): Add prototype.

	* ada-typeprint.c: Include "target-float.h".
	(print_fixed_point_type): Perform target arithmetic instead of
	host arithmetic.
	* ada-valprint.c: Include "target-float.h".
	(ada_val_print_num): Perform target arithmetic instead of
	host arithmetic for fixed-point types.
2017-11-06 16:00:12 +01:00
Pedro Alves cc536b2167 Fix GDB build with G++ 4.8
G++ 4.8 trips on:

  In file included from /opt/gcc-4.8/include/c++/4.8.5/algorithm:62:0,
		   from ../../src/gdb/ada-lang.c:65:
  /opt/gcc-4.8/include/c++/4.8.5/bits/stl_algo.h: In instantiation of ‘_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<ada_exc_info*, std::vector<ada_exc_info> >; _Tp = ada_exc_info]’:
  /opt/gcc-4.8/include/c++/4.8.5/bits/stl_algo.h:2283:70:   required from ‘_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<ada_exc_info*, std::vector<ada_exc_info> >]’
  /opt/gcc-4.8/include/c++/4.8.5/bits/stl_algo.h:2315:54:   required from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<ada_exc_info*, std::vector<ada_exc_info> >; _Size = long int]’
  /opt/gcc-4.8/include/c++/4.8.5/bits/stl_algo.h:5461:36:   required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<ada_exc_info*, std::vector<ada_exc_info> >]’
  ../../src/gdb/ada-lang.c:13153:61:   required from here
  /opt/gcc-4.8/include/c++/4.8.5/bits/stl_algo.h:2245:19: error: passing ‘const ada_exc_info’ as ‘this’ argument of ‘bool ada_exc_info::operator<(const ada_exc_info&)’ discards qualifiers [-fpermissive]
      while (__pivot < *__last)
		     ^

Seems to be a libstdc++ bug meanwhile fixed by:
  https://gcc.gnu.org/ml/libstdc++/2012-04/msg00074.

In any case, there's no reason these methods can't be const.

gdb/ChangeLog:
2017-10-02  Tom Tromey  <tom@tromey.com>
	    Pedro Alves  <palves@redhat.com>

	* ada-lang.h (ada_exc_info::operator<): Make const.
	(ada_exc_info::operator==): Make const.
	* ada-lang.c (ada_exc_info::operator<, ada_exc_info::operator==):
	Make const.
2017-10-02 10:18:30 +01:00
Tom Tromey ab816a2745 Use a std::vector for ada_exceptions_list
Change ada_exceptions_list to return a std::vector and fix up the
users.  This allows removing a cleanup in MI.

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

	* mi/mi-cmd-info.c (mi_cmd_info_ada_exceptions): Update.
	* ada-lang.h (struct ada_exc_info): Remove typedef.  Declare
	operator< and operator==.
	(ada_exceptions_list): Return a std::vector.
	* ada-lang.c (ada_exc_info::operator<): Rename from
	compare_ada_exception_info.
	(ada_exc_info::operator==): New.
	(sort_remove_dups_ada_exceptions_list): Change type of
	"exceptions".
	(ada_add_standard_exceptions, ada_add_exceptions_from_frame)
	(ada_add_global_exceptions): Likewise.
	(ada_exceptions_list_1): Return a std::vector.
	(ada_exceptions_list): Likewise.
2017-09-29 21:12:17 -06:00
Pedro Alves edb0c9cb22 get_int_var_value
I noticed that get_int_var_value's parameters could use some
constification.  And then realized that client code would become
simpler by changing the interface to return the success/failure
indication as actual return value, as it allows getting rid of the
local "boolean" variable.

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

	* ada-lang.c (ada_to_fixed_type_1): Adjust.
	(get_var_value): Constify parameters.
	(get_int_var_value): Change prototype.
	(to_fixed_range_type): Adjust.
	* ada-lang.h (get_int_var_value): Change prototype.
2017-07-20 18:12:19 +01:00
Pedro Alves a121b7c1ac -Wwrite-strings: The Rest
This is the remainder boring constification that all looks more of less
borderline obvious IMO.

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

	* ada-exp.y (yyerror): Constify.
	* ada-lang.c (bound_name, get_selections)
	(ada_variant_discrim_type)
	(ada_variant_discrim_name, ada_value_struct_elt)
	(ada_lookup_struct_elt_type, is_unchecked_variant)
	(ada_which_variant_applies, standard_exc, ada_get_next_arg)
	(catch_ada_exception_command_split)
	(catch_ada_assert_command_split, catch_assert_command)
	(ada_op_name): Constify.
	* ada-lang.h (ada_yyerror, get_selections)
	(ada_variant_discrim_name, ada_value_struct_elt): Constify.
	* arc-tdep.c (arc_print_frame_cache): Constify.
	* arm-tdep.c (arm_skip_stub): Constify.
	* ax-gdb.c (gen_binop, gen_struct_ref_recursive, gen_struct_ref)
	(gen_aggregate_elt_ref): Constify.
	* bcache.c (print_bcache_statistics): Constify.
	* bcache.h (print_bcache_statistics): Constify.
	* break-catch-throw.c (catch_exception_command_1):
	* breakpoint.c (struct ep_type_description::description):
	Constify.
	(add_solib_catchpoint): Constify.
	(catch_fork_command_1): Add cast.
	(add_catch_command): Constify.
	* breakpoint.h (add_catch_command, add_solib_catchpoint):
	Constify.
	* bsd-uthread.c (bsd_uthread_state): Constify.
	* buildsym.c (patch_subfile_names): Constify.
	* buildsym.h (next_symbol_text_func, patch_subfile_names):
	Constify.
	* c-exp.y (yyerror): Constify.
	(token::oper): Constify.
	* c-lang.h (c_yyerror, cp_print_class_member): Constify.
	* c-varobj.c (cplus_describe_child): Constify.
	* charset.c (find_charset_names): Add cast.
	(find_charset_names): Constify array and add const_cast.
	* cli/cli-cmds.c (complete_command, cd_command): Constify.
	(edit_command): Constify.
	* cli/cli-decode.c (lookup_cmd): Constify.
	* cli/cli-dump.c (dump_memory_command, dump_value_command):
	Constify.
	(struct dump_context): Constify.
	(add_dump_command, restore_command): Constify.
	* cli/cli-script.c (get_command_line): Constify.
	* cli/cli-script.h (get_command_line): Constify.
	* cli/cli-utils.c (check_for_argument): Constify.
	* cli/cli-utils.h (check_for_argument): Constify.
	* coff-pe-read.c (struct read_pe_section_data): Constify.
	* command.h (lookup_cmd): Constify.
	* common/print-utils.c (decimal2str): Constify.
	* completer.c (gdb_print_filename): Constify.
	* corefile.c (set_gnutarget): Constify.
	* cp-name-parser.y (yyerror): Constify.
	* cp-valprint.c (cp_print_class_member): Constify.
	* cris-tdep.c (cris_register_name, crisv32_register_name):
	Constify.
	* d-exp.y (yyerror): Constify.
	(struct token::oper): Constify.
	* d-lang.h (d_yyerror): Constify.
	* dbxread.c (struct header_file_location::name): Constify.
	(add_old_header_file, add_new_header_file, last_function_name)
	(dbx_next_symbol_text, add_bincl_to_list)
	(find_corresponding_bincl_psymtab, set_namestring)
	(find_stab_function_addr, read_dbx_symtab, start_psymtab)
	(dbx_end_psymtab, read_ofile_symtab, process_one_symbol):
	* defs.h (command_line_input, print_address_symbolic)
	(deprecated_readline_begin_hook): Constify.
	* dwarf2read.c (anonymous_struct_prefix, dwarf_bool_name):
	Constify.
	* event-top.c (handle_line_of_input): Constify and add cast.
	* exceptions.c (catch_errors): Constify.
	* exceptions.h (catch_errors): Constify.
	* expprint.c (print_subexp_standard, op_string, op_name)
	(op_name_standard, dump_raw_expression, dump_raw_expression):
	* expression.h (op_name, op_string, dump_raw_expression):
	Constify.
	* f-exp.y (yyerror): Constify.
	(struct token::oper): Constify.
	(struct f77_boolean_val::name): Constify.
	* f-lang.c (f_word_break_characters): Constify.
	* f-lang.h (f_yyerror): Constify.
	* fork-child.c (fork_inferior): Add cast.
	* frv-tdep.c (struct gdbarch_tdep::register_names): Constify.
	(new_variant): Constify.
	* gdbarch.sh (pstring_ptr, pstring_list): Constify.
	* gdbarch.c: Regenerate.
	* gdbcore.h (set_gnutarget): Constify.
	* go-exp.y (yyerror): Constify.
	(token::oper): Constify.
	* go-lang.h (go_yyerror): Constify.
	* go32-nat.c (go32_sysinfo): Constify.
	* guile/scm-breakpoint.c (gdbscm_breakpoint_expression): Constify.
	* guile/scm-cmd.c (cmdscm_function): Constify.
	* guile/scm-param.c (pascm_param_value): Constify.
	* h8300-tdep.c (h8300_register_name, h8300s_register_name)
	(h8300sx_register_name): Constify.
	* hppa-tdep.c (hppa32_register_name, hppa64_register_name):
	Constify.
	* ia64-tdep.c (ia64_register_names): Constify.
	* infcmd.c (construct_inferior_arguments): Constify.
	(path_command, attach_post_wait): Constify.
	* language.c (show_range_command, show_case_command)
	(unk_lang_error): Constify.
	* language.h (language_defn::la_error)
	(language_defn::la_name_of_this): Constify.
	* linespec.c (decode_line_2): Constify.
	* linux-thread-db.c (thread_db_err_str): Constify.
	* lm32-tdep.c (lm32_register_name): Constify.
	* m2-exp.y (yyerror): Constify.
	* m2-lang.h (m2_yyerror): Constify.
	* m32r-tdep.c (m32r_register_names): Constify and make static.
	* m68hc11-tdep.c (m68hc11_register_names): Constify.
	* m88k-tdep.c (m88k_register_name): Constify.
	* macroexp.c (appendmem): Constify.
	* mdebugread.c (fdr_name, add_data_symbol, parse_type)
	(upgrade_type, parse_external, parse_partial_symbols)
	(mdebug_next_symbol_text, cross_ref, mylookup_symbol, new_psymtab)
	(new_symbol): Constify.
	* memattr.c (mem_info_command): Constify.
	* mep-tdep.c (register_name_from_keyword): Constify.
	* mi/mi-cmd-env.c (mi_cmd_env_path, _initialize_mi_cmd_env):
	Constify.
	* mi/mi-cmd-stack.c (list_args_or_locals): Constify.
	* mi/mi-cmd-var.c (mi_cmd_var_show_attributes): Constify.
	* mi/mi-main.c (captured_mi_execute_command): Constify and add
	cast.
	(mi_execute_async_cli_command): Constify.
	* mips-tdep.c (mips_register_name): Constify.
	* mn10300-tdep.c (register_name, mn10300_generic_register_name)
	(am33_register_name, am33_2_register_name)
	* moxie-tdep.c (moxie_register_names): Constify.
	* nat/linux-osdata.c (osdata_type): Constify fields.
	* nto-tdep.c (nto_parse_redirection): Constify.
	* objc-lang.c (lookup_struct_typedef, lookup_objc_class)
	(lookup_child_selector): Constify.
	(objc_methcall::name): Constify.
	* objc-lang.h (lookup_objc_class, lookup_child_selector)
	(lookup_struct_typedef): Constify.
	* objfiles.c (pc_in_section): Constify.
	* objfiles.h (pc_in_section): Constify.
	* p-exp.y (struct token::oper): Constify.
	(yyerror): Constify.
	* p-lang.h (pascal_yyerror): Constify.
	* parser-defs.h (op_name_standard): Constify.
	(op_print::string): Constify.
	(exp_descriptor::op_name): Constify.
	* printcmd.c (print_address_symbolic): Constify.
	* psymtab.c (print_partial_symbols): Constify.
	* python/py-breakpoint.c (stop_func): Constify.
	(bppy_get_expression): Constify.
	* python/py-cmd.c (cmdpy_completer::name): Constify.
	(cmdpy_function): Constify.
	* python/py-event.c (evpy_add_attribute)
	(gdbpy_initialize_event_generic): Constify.
	* python/py-event.h (evpy_add_attribute)
	(gdbpy_initialize_event_generic): Constify.
	* python/py-evts.c (add_new_registry): Constify.
	* python/py-finishbreakpoint.c (outofscope_func): Constify.
	* python/py-framefilter.c (get_py_iter_from_func): Constify.
	* python/py-inferior.c (get_buffer): Add cast.
	* python/py-param.c (parm_constant::name): Constify.
	* python/py-unwind.c (fprint_frame_id): Constify.
	* python/python.c (gdbpy_parameter_value): Constify.
	* remote-fileio.c (remote_fio_func_map): Make 'name' const.
	* remote.c (memory_packet_config::name): Constify.
	(show_packet_config_cmd, remote_write_bytes)
	(remote_buffer_add_string):
	* reverse.c (exec_reverse_once): Constify.
	* rs6000-tdep.c (variant::name, variant::description): Constify.
	* rust-exp.y (rustyyerror): Constify.
	* rust-lang.c (rust_op_name): Constify.
	* rust-lang.h (rustyyerror): Constify.
	* serial.h (serial_ops::name): Constify.
	* sh-tdep.c (sh_sh_register_name, sh_sh3_register_name)
	(sh_sh3e_register_name, sh_sh2e_register_name)
	(sh_sh2a_register_name, sh_sh2a_nofpu_register_name)
	(sh_sh_dsp_register_name, sh_sh3_dsp_register_name)
	(sh_sh4_register_name, sh_sh4_nofpu_register_name)
	(sh_sh4al_dsp_register_name): Constify.
	* sh64-tdep.c (sh64_register_name): Constify.
	* solib-darwin.c (lookup_symbol_from_bfd): Constify.
	* spu-tdep.c (spu_register_name, info_spu_dma_cmdlist): Constify.
	* stabsread.c (patch_block_stabs, read_type_number)
	(ref_map::stabs, ref_add, process_reference)
	(symbol_reference_defined, define_symbol, define_symbol)
	(error_type, read_type, read_member_functions, read_cpp_abbrev)
	(read_one_struct_field, read_struct_fields, read_baseclasses)
	(read_tilde_fields, read_struct_type, read_array_type)
	(read_enum_type, read_sun_builtin_type, read_sun_floating_type)
	(read_huge_number, read_range_type, read_args, common_block_start)
	(find_name_end): Constify.
	* stabsread.h (common_block_start, define_symbol)
	(process_one_symbol, symbol_reference_defined, ref_add):
	* symfile.c (get_section_index, add_symbol_file_command):
	* symfile.h (get_section_index): Constify.
	* target-descriptions.c (tdesc_type::name): Constify.
	(tdesc_free_type): Add cast.
	* target.c (find_default_run_target):
	(add_deprecated_target_alias, find_default_run_target)
	(target_announce_detach): Constify.
	(do_option): Constify.
	* target.h (add_deprecated_target_alias): Constify.
	* thread.c (print_thread_info_1): Constify.
	* top.c (deprecated_readline_begin_hook, command_line_input):
	Constify.
	(init_main): Add casts.
	* top.h (handle_line_of_input): Constify.
	* tracefile-tfile.c (tfile_write_uploaded_tsv): Constify.
	* tracepoint.c (tvariables_info_1, trace_status_mi): Constify.
	(tfind_command): Rename to ...
	(tfind_command_1): ... this and constify.
	(tfind_command): New function.
	(tfind_end_command, tfind_start_command): Adjust.
	(encode_source_string): Constify.
	* tracepoint.h (encode_source_string): Constify.
	* tui/tui-data.c (tui_partial_win_by_name): Constify.
	* tui/tui-data.h (tui_partial_win_by_name): Constify.
	* tui/tui-source.c (tui_set_source_content_nil): Constify.
	* tui/tui-source.h (tui_set_source_content_nil): Constify.
	* tui/tui-win.c (parse_scrolling_args): Constify.
	* tui/tui-windata.c (tui_erase_data_content): Constify.
	* tui/tui-windata.h (tui_erase_data_content): Constify.
	* tui/tui-winsource.c (tui_erase_source_content): Constify.
	* tui/tui.c (tui_enable): Add cast.
	* utils.c (defaulted_query): Constify.
	(init_page_info): Add cast.
	(puts_debug, subset_compare): Constify.
	* utils.h (subset_compare): Constify.
	* varobj.c (varobj_format_string): Constify.
	* varobj.h (varobj_format_string): Constify.
	* vax-tdep.c (vax_register_name): Constify.
	* windows-nat.c (windows_detach): Constify.
	* xcoffread.c (process_linenos, xcoff_next_symbol_text): Constify.
	* xml-support.c (gdb_xml_end_element): Constify.
	* xml-tdesc.c (tdesc_start_reg): Constify.
	* xstormy16-tdep.c (xstormy16_register_name): Constify.
	* xtensa-tdep.c (xtensa_find_register_by_name): Constify.
	* xtensa-tdep.h (xtensa_register_t::name): Constify.

gdb/gdbserver/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

	* gdbreplay.c (sync_error): Constify.
	* linux-x86-low.c (push_opcode): Constify.
2017-04-05 19:21:37 +01:00
Joel Brobecker 61baf725ec update copyright year range in GDB files
This applies the second part of GDB's End of Year Procedure, which
updates the copyright year range in all of GDB's files.

gdb/ChangeLog:

        Update copyright year range in all GDB files.
2017-01-01 10:52:34 +04:00
Yao Qi e8b24d9ff5 Remove parameter valaddr from la_val_print
Nowadays, we pass both val and return value of
value_contents_for_printing (val) to la_val_print.  The latter is
unnecessary.  This patch removes the second parameter of la_val_print,
and get valaddr in each language's implementation by calling
value_contents_for_printing.  Since value_contents_for_printing calls
value_fetch_lazy, I also make VAL non-const.

Note that
 - I don't clean up the valaddr usages in each language's routines,
 - I don't remove valaddr from apply_ext_lang_val_pretty_printer, and
   extension language ops apply_val_pretty_printer.

They can be done in followup patches.

gdb:

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

	* ada-lang.h (ada_val_print): Remove second parameter.  Remove
	const from "struct value *".
	* ada-valprint.c (print_field_values): Remove const from
	"struct value *".
	(val_print_packed_array_elements): Likewise.
	(print_variant_part): Likewise.
	(ada_val_print_string): Likewise.
	(ada_val_print_gnat_array): Likewise.
	(ada_val_print_ptr): Likewise.
	(ada_val_print_num): Likewise.
	(ada_val_print_enum): Likewise.
	(ada_val_print_flt): Likewise.
	(ada_val_print_union): Likewise.
	(ada_val_print_struct_union): Likewise.
	(ada_val_print_ref): Likewise.
	(ada_val_print_1): Remove second parameter.  Remove const from
	"struct value *".
	(ada_val_print): Likewise.
	* c-lang.h (c_val_print): Likewise.
	* c-valprint.c (c_val_print_array): Remove const from
	"struct value *".
	(c_val_print_ptr): Likewise.
	(c_val_print_struct): Likewise.
	(c_val_print_union): Likewise.
	(c_val_print_int): Likewise.
	(c_val_print_memberptr): Likewise.
	(c_val_print): Remove second parameter.  Remove const from
	"struct value *".  All callers updated.
	* cp-valprint.c (cp_print_value): Remove const from
	"struct value *".
	(cp_print_value_fields): Likewise.
	(c_val_print_value): Likewise.
	* d-lang.h (d_val_print): Remove second parameter.  Remove const
	from "struct value *".
	* d-valprint.c (dynamic_array_type): Likewise.
	(d_val_print): Likewise.
	* f-lang.h (f_val_print): Likewise.
	* f-valprint.c (f_val_print): Likewise.
	* go-lang.h (go_val_print): Likewise.
	* go-valprint.c (print_go_string): Likewise.
	(go_val_print): Likewise.
	* language.c (unk_lang_val_print): Likewise.
	* language.h (struct language_defn) <la_val_print>: Likewise.
	Update comments.
	(LA_VAL_PRINT): Remove.
	* m2-lang.h (m2_val_print): Remove const from
	"struct value *".
	* m2-valprint.c (m2_print_array_contents): Likewise.
	(m2_val_print): Likewise.
	* p-lang.h (pascal_val_print): Remove second parameter.  Remove
	const from "struct value *".
	(pascal_object_print_value_fields): Likewise.
	* p-valprint.c (pascal_val_print): Likewise.
	(pascal_object_print_value_fields): Likewise.
	(pascal_object_print_value): Likewise.
	* rust-lang.c (rust_get_disr_info): Likewise.
	(val_print_struct): Likewise.
	(rust_val_print): Likewise.
	* valprint.c (generic_val_print_array): Likewise.
	(generic_val_print_ptr): Likewise.
	(generic_val_print_memberptr): Likewise.
	(generic_val_print_ref): Likewise.
	(generic_val_print_enum): Likewise.
	(generic_val_print_flags): Likewise.
	(generic_val_print_func): Likewise.
	(generic_val_print_bool): Likewise.
	(generic_val_print_int): Likewise.
	(generic_val_print_char): Likewise.
	(generic_val_print_float): Likewise.
	(generic_val_print_decfloat): Likewise.
	(generic_val_print_complex): Likewise.
	(generic_val_print): Likewise.
	(val_print): Likewise.
	(common_val_print): Likewise.
	(val_print_type_code_flags): Likewise.
	(val_print_scalar_formatted): Likewise.
	(val_print_array_elements): Likewise.
	* valprint.h (val_print_array_elements): Update declaration.
	(val_print_scalar_formatted): Likewise.
	(generic_val_print): Likewise.
	* value.h (val_print): Likewise.
2016-11-08 16:02:42 +00:00
Pedro Alves 2f408ecb92 Use ui_file_as_string throughout more
This replaces most of the remaining ui_file_xstrdup calls with
ui_file_as_string calls.  Whenever a call was replaced, that led to a
cascade of other necessary adjustments throughout, to make the code
use std::string instead of raw pointers.  And then whenever I added a
std::string as member of a struct, I needed to adjust
allocation/destruction of said struct to use new/delete instead of
xmalloc/xfree.

The stopping point was once gdb built again.  These doesn't seem to be
a way to reasonably split this out further.

Maybe-not-obvious changes:

 - demangle_for_lookup returns a cleanup today.  To get rid of that,
   and avoid unnecessary string dupping/copying, this introduces a
   demangle_result_storage type that the caller instantiates and
   passes to demangle_for_lookup.

 - Many methods returned a "char *" to indicate that the caller owns
   the memory and must free it.  Those are switched to return a
   std::string instead.  Methods that return a "view" into some
   internal string return a "const char *" instead.  I.e., we only
   copy/allocate when necessary.

gdb/ChangeLog:
2016-11-08  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (ada_name_for_lookup, type_as_string): Use and return
	std::string.
	(type_as_string_and_cleanup): Delete.
	(ada_lookup_struct_elt_type): Use type_as_string.
	* ada-lang.h (ada_name_for_lookup): Now returns std::string.
	* ada-varobj.c (ada_varobj_scalar_image): Return a std::string.
	(ada_varobj_describe_child): Make 'child_name' and
	'child_path_expr' parameters std::string pointers.
	(ada_varobj_describe_struct_child, ada_varobj_describe_ptr_child):
	Likewise, and use string_printf.
	(ada_varobj_describe_simple_array_child)
	(ada_varobj_describe_child): Likewise.
	(ada_varobj_get_name_of_child, ada_varobj_get_path_expr_of_child)
	(ada_varobj_get_value_image)
	(ada_varobj_get_value_of_array_variable)
	(ada_varobj_get_value_of_variable, ada_name_of_variable)
	(ada_name_of_child, ada_path_expr_of_child)
	(ada_value_of_variable): Now returns std::string.  Use
	string_printf.
	(ada_value_of_child): Adjust.
	* break-catch-throw.c (check_status_exception_catchpoint): Adjust
	to use std::string.
	* breakpoint.c (watch_command_1): Adjust to use std::string.
	* c-lang.c (c_get_string): Adjust to use std::string.
	* c-typeprint.c (print_name_maybe_canonical): Use std::string.
	* c-varobj.c (varobj_is_anonymous_child): Use ==/!= std::string
	operators.
	(c_name_of_variable): Now returns a std::string.
	(c_describe_child): The 'cname' and 'cfull_expression' output
	parameters are now std::string pointers.  Adjust.
	(c_name_of_child, c_path_expr_of_child, c_value_of_variable)
	(cplus_number_of_children): Adjust to use std::string and
	string_printf.
	(cplus_name_of_variable): Now returns a std::string.
	(cplus_describe_child): The 'cname' and 'cfull_expression' output
	parameters are now std::string pointers.  Adjust.
	(cplus_name_of_child, cplus_path_expr_of_child)
	(cplus_value_of_variable): Now returns a std::string.
	* cp-abi.c (cplus_typename_from_type_info): Return std::string.
	* cp-abi.h (cplus_typename_from_type_info): Return std::string.
	(struct cp_abi_ops) <get_typename_from_type_info>: Return
	std::string.
	* cp-support.c (inspect_type): Use std::string.
	(cp_canonicalize_string_full, cp_canonicalize_string_no_typedefs)
	(cp_canonicalize_string): Return std::string and adjust.
	* cp-support.h (cp_canonicalize_string)
	(cp_canonicalize_string_no_typedefs, cp_canonicalize_string_full):
	Return std::string.
	* dbxread.c (read_dbx_symtab): Use std::string.
	* dwarf2read.c (dwarf2_canonicalize_name): Adjust to use std::string.
	* gdbcmd.h (lookup_struct_elt_type): Adjust to use std::string.
	* gnu-v3-abi.c (gnuv3_get_typeid): Use std::string.
	(gnuv3_get_typename_from_type_info): Return a std::string and
	adjust.
	(gnuv3_get_type_from_type_info): Adjust to use std::string.
	* guile/guile.c (gdbscm_execute_gdb_command): Adjust to use
	std::string.
	* infcmd.c (print_return_value_1): Adjust to use std::string.
	* linespec.c (find_linespec_symbols): Adjust to
	demangle_for_lookup API change.  Use std::string.
	* mi/mi-cmd-var.c (print_varobj, mi_cmd_var_set_format)
	(mi_cmd_var_info_type, mi_cmd_var_info_path_expression)
	(mi_cmd_var_info_expression, mi_cmd_var_evaluate_expression)
	(mi_cmd_var_assign, varobj_update_one): Adjust to use std::string.
	* minsyms.c (lookup_minimal_symbol): Use std::string.
	* python/py-varobj.c (py_varobj_iter_next): Use new instead of
	XNEW.  vitem->name is a std::string now, adjust.
	* rust-exp.y (convert_ast_to_type, convert_name): Adjust to use
	std::string.
	* stabsread.c (define_symbol): Adjust to use std::string.
	* symtab.c (demangle_for_lookup): Now returns 'const char *'.  Add
	a demangle_result_storage parameter.  Use it for storage.
	(lookup_symbol_in_language)
	(lookup_symbol_in_objfile_from_linkage_name): Adjust to new
	demangle_for_lookup API.
	* symtab.h (struct demangle_result_storage): New type.
	(demangle_for_lookup): Now returns 'const char *'.  Add a
	demangle_result_storage parameter.
	* typeprint.c (type_to_string): Return std::string and use
	ui_file_as_string.
	* value.h (type_to_string): Change return type to std::string.
	* varobj-iter.h (struct varobj_item) <name>: Now a std::string.
	(varobj_iter_delete): Use delete instead of xfree.
	* varobj.c (create_child): Return std::string instead of char * in
	output parameter.
	(name_of_variable, name_of_child, my_value_of_variable): Return
	std::string instead of char *.
	(varobj_create, varobj_get_handle): Constify 'objname' parameter.
	Adjust to std::string fields.
	(varobj_get_objname): Return a const char * instead of a char *.
	(varobj_get_expression): Return a std::string.
	(varobj_list_children): Adjust to use std::string.
	(varobj_get_type): Return a std::string.
	(varobj_get_path_expr): Return a const char * instead of a char *.
	Adjust to std::string fields.
	(varobj_get_formatted_value, varobj_get_value): Return a
	std::string.
	(varobj_set_value): Change type of 'expression' parameter to
	std::string.  Use std::string.
	(install_new_value): Use std::string.
	(delete_variable_1): Adjust to use std::string.
	(create_child): Change the 'name' parameter to a std::string
	reference.  Swap it into the new item's name.
	(create_child_with_value): Swap item's name into the new child's
	name.  Use string_printf.
	(new_variable): Use new instead of XNEW.
	(free_variable): Don't xfree fields that are now std::string.
	(name_of_variable, name_of_child): Now returns std::string.
	(value_of_root): Adjust to use std::string.
	(my_value_of_variable, varobj_value_get_print_value): Return
	and use std::string.
	(varobj_value_get_print_value): Adjust to use ui_file_as_string
	and std::string.
	* varobj.h (struct varobj) <name, path_expr, obj_name,
	print_value>: Now std::string's.
	<name_of_variable, name_of_child, path_expr_of_child,
	value_of_variable>: Return std::string.
	(varobj_create, varobj_get_handle): Constify 'objname' parameter.
	(varobj_get_objname): Return a const char * instead of a char *.
	(varobj_get_expression, varobj_get_type): Return a std::string.
	(varobj_get_path_expr): Return a const char * instead of a char *.
	(varobj_get_formatted_value, varobj_get_value): Return a
	std::string.
	(varobj_set_value): Constify 'expression' parameter.
	(varobj_value_get_print_value): Return a std::string.
2016-11-08 15:26:47 +00:00
Pedro Alves b3f11165aa Centralize yacc interface names remapping (yyparse, yylex, yyerror, etc)
This factors out all the yy-variables remapping to a single file,
instead of each parser having to do the same, with different prefixes.

With this, a parser just needs to define the prefix they want and
include yy-remap.h, which does the dirty job.

Note this renames the c_error, ada_error, etc. functions.  Writing the
remapping pattern as:

 #define yyerror GDB_YY_REMAP (error)

instead of:

 #define yyerror GDB_YY_REMAP (yyerror)

would have avoided the renaming.  However, that would be problematic
if we have a macro 'foo' in scope, when we write:

 #define yyfoo GDB_YY_REMAP (foo)

as that would expand 'foo'.

The c_yyerror etc. naming end ups indicating that this is a yacc
related function more clearly, so feels like a good change, anyway.

gdb/ChangeLog:
2016-04-22  Pedro Alves  <palves@redhat.com>

	* ada-exp.y: Remove all yy symbol remappings.
	(GDB_YY_REMAP_PREFIX): Define.
	Include "yy-remap.h".
	* ada-lang.c (ada_language_defn): Adjust.
	* ada-lang.h (ada_error): Rename to ...
	(ada_yyerror): ... this.
	* c-exp.y: Remove all yy symbol remappings.
	(GDB_YY_REMAP_PREFIX): Define.
	Include "yy-remap.h".
	* c-lang.c (c_language_defn, cplus_language_defn)
	(asm_language_defn, minimal_language_defn): Adjust.
	* c-lang.h (c_error): Rename to ...
	(c_yyerror): ... this.
	* d-exp.y: Remove all yy symbol remappings.
	(GDB_YY_REMAP_PREFIX): Define.
	Include "yy-remap.h".
	* d-lang.c (d_language_defn): Adjust.
	* d-lang.h (d_error): Rename to ...
	(d_yyerror): ... this.
	* f-exp.y: Remove all yy symbol remappings.
	(GDB_YY_REMAP_PREFIX): Define.
	Include "yy-remap.h".
	* f-lang.c (f_language_defn): Adjust.
	* f-lang.h (f_error): Rename to ...
	(f_yyerror): ... this.
	* go-exp.y: Remove all yy symbol remappings.
	(GDB_YY_REMAP_PREFIX): Define.
	Include "yy-remap.h".
	* go-lang.c (go_language_defn): Adjust.
	* go-lang.h (go_error): Rename to ...
	(go_yyerror): ... this.
	* jv-exp.y: Remove all yy symbol remappings.
	(GDB_YY_REMAP_PREFIX): Define.
	Include "yy-remap.h".
	* jv-lang.c (java_language_defn): Adjust.
	* jv-lang.h (java_error): Rename to ...
	(java_yyerror): ... this.
	* m2-exp.y: Remove all yy symbol remappings.
	(GDB_YY_REMAP_PREFIX): Define.
	Include "yy-remap.h".
	* m2-lang.c (m2_language_defn): Adjust.
	* m2-lang.h (m2_error): Rename to ...
	(m2_yyerror): ... this.
	* objc-exp.y: Remove all yy symbol remappings.
	(GDB_YY_REMAP_PREFIX): Define.
	Include "yy-remap.h".
	* objc-lang.c (objc_language_defn): Adjust.
	* opencl-lang.c (opencl_language_defn): Adjust.
	* p-exp.y: Remove all yy symbol remappings.
	(GDB_YY_REMAP_PREFIX): Define.
	Include "yy-remap.h".
	* p-lang.c (pascal_language_defn): Adjust.
	* p-lang.h (pascal_error): Rename to ...
	(pascal_yyerror): ... this.
	* yy-remap.h: New file.
2016-04-22 16:40:33 +01: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
Simon Marchi a480de357b ada-lang.h: Add cast in GROW_VECT
The assignment requires a cast in C++.  We only use this macro for
vectors of chars, so adding (char *) diretly will do for now.

gdb/ChangeLog:

	* ada-lang.h (GROW_VECT): Add cast.
2015-10-27 09:27:40 -04:00
Pierre-Marie de Rodat d12307c199 Replace the block_found global with explicit data-flow
As Pedro suggested on gdb-patches@ (see
https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this
change makes symbol lookup functions return a structure that includes
both the symbol found and the block in which it was found.  This makes
it possible to get rid of the block_found global variable and thus makes
block hunting explicit.

gdb/

	* ada-exp.y (write_object_renaming): Replace struct
	ada_symbol_info with struct block_symbol.  Update field
	references accordingly.
	(block_lookup, select_possible_type_sym): Likewise.
	(find_primitive_type): Likewise.  Also update call to
	ada_lookup_symbol to extract the symbol itself.
	(write_var_or_type, write_name_assoc): Likewise.
	* ada-lang.h (struct ada_symbol_info): Remove.
	(ada_lookup_symbol_list): Replace struct ada_symbol_info with
	struct block_symbol.
	(ada_lookup_encoded_symbol, user_select_syms): Likewise.
	(ada_lookup_symbol): Return struct block_symbol instead of a
	mere symbol.
	* ada-lang.c (defns_collected): Replace struct ada_symbol_info
	with struct block_symbol.
	(resolve_subexp, ada_resolve_function, sort_choices,
	user_select_syms, is_nonfunction, add_defn_to_vec,
	num_defns_collected, defns_collected,
	symbols_are_identical_enums, remove_extra_symbols,
	remove_irrelevant_renamings, add_lookup_symbol_list_worker,
	ada_lookup_symbol_list, ada_iterate_over_symbols,
	ada_lookup_encoded_symbol, get_var_value): Likewise.
	(ada_lookup_symbol): Return a block_symbol instead of a mere
	symbol.  Replace struct ada_symbol_info with struct
	block_symbol.
	(ada_lookup_symbol_nonlocal): Likewise.
	(standard_lookup): Make block passing explicit through
	lookup_symbol_in_language.
	* ada-tasks.c (get_tcb_types_info): Update the calls to
	lookup_symbol_in_language to extract the mere symbol out of the
	returned value.
	(ada_tasks_inferior_data_sniffer): Likewise.
	* ax-gdb.c (gen_static_field): Likewise for the call to
	lookup_symbol.
	(gen_maybe_namespace_elt): Deal with struct symbol_in_block from
	lookup functions.
	(gen_expr): Likewise.
	* c-exp.y: Likewise.  Remove uses of block_found.
	(lex_one_token, classify_inner_name, c_print_token): Likewise.
	(classify_name): Likewise.  Rename the "sym" local variable to
	"bsym".
	* c-valprint.c (print_unpacked_pointer): Likewise.
	* compile/compile-c-symbols.c (convert_symbol_sym): Promote the
	"sym" parameter from struct symbol * to struct block_symbol.
	Use it to remove uses of block_found.  Deal with struct
	symbol_in_block from lookup functions.
	(gcc_convert_symbol): Likewise.  Update the call to
	convert_symbol_sym.
	* compile/compile-object-load.c (compile_object_load): Deal with
	struct symbol_in_block from lookup functions.
	* cp-namespace.c (cp_lookup_nested_symbol_1,
	cp_lookup_nested_symbol, cp_lookup_bare_symbol,
	cp_search_static_and_baseclasses,
	cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports,
	cp_lookup_symbol_imports_or_template,
	cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace,
	lookup_namespace_scope, cp_lookup_nonlocal,
	find_symbol_in_baseclass): Return struct symbol_in_block instead
	of mere symbols and deal with struct symbol_in_block from lookup
	functions.
	* cp-support.c (inspect_type, replace_typedefs,
	cp_lookup_rtti_type): Deal with struct symbol_in_block from
	lookup functions.
	* cp-support.h (cp_lookup_symbol_nonlocal,
	cp_lookup_symbol_from_namespace,
	cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol):
	Return struct symbol_in_block instead of mere symbols.
	* d-exp.y (d_type_from_name, d_module_from_name, push_variable,
	push_module_name):
	Deal with struct symbol_in_block from lookup functions.  Remove
	uses of block_found.
	* eval.c (evaluate_subexp_standard): Update call to
	cp_lookup_symbol_namespace.
	* f-exp.y: Deal with struct symbol_in_block from lookup
	functions.  Remove uses of block_found.
	(yylex): Likewise.
	* gdbtypes.c (lookup_typename, lookup_struct, lookup_union,
	lookup_enum, lookup_template_type, check_typedef): Deal with
	struct symbol_in_block from lookup functions.
	* guile/scm-frame.c (gdbscm_frame_read_var): Likewise.
	* guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise.
	(gdbscm_lookup_global_symbol): Likewise.
	* gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise.
	* go-exp.y: Likewise.  Remove uses of block_found.
	(package_name_p, classify_packaged_name, classify_name):
	Likewise.
	* infrun.c (insert_exception_resume_breakpoint): Likewise.
	* jv-exp.y (push_variable): Likewise.
	* jv-lang.c (java_lookup_class, get_java_object_type): Likewise.
	* language.c (language_bool_type): Likewise.
	* language.h (struct language_defn): Update
	la_lookup_symbol_nonlocal to return a struct symbol_in_block
	rather than a mere symbol.
	* linespec.c (find_label_symbols): Deal with struct
	symbol_in_block from lookup functions.
	* m2-exp.y: Likewise.  Remove uses of block_found.
	(yylex): Likewise.
	* mi/mi-cmd-stack.c (list_args_or_locals): Likewise.
	* objc-lang.c (lookup_struct_typedef, find_imps): Likewise.
	* p-exp.y: Likewise.  Remove uses of block_found.
	(yylex): Likewise.
	* p-valprint.c (pascal_val_print): Likewise.
	* parse.c (write_dollar_variable): Likewise.  Remove uses of
	block_found.
	* parser-defs.h (struct symtoken): Turn the SYM field into a
	struct symbol_in_block.
	* printcmd.c (address_info): Deal with struct symbol_in_block
	from lookup functions.
	* python/py-frame.c (frapy_read_var): Likewise.
	* python/py-symbol.c (gdbpy_lookup_symbol,
	gdbpy_lookup_global_symbol): Likewise.
	* skip.c (skip_function_command): Likewise.
	* solib-darwin.c (darwin_lookup_lib_symbol): Return a struct
	symbol_in_block instead of a mere symbol.
	* solib-spu.c (spu_lookup_lib_symbol): Likewise.
	* solib-svr4.c (elf_lookup_lib_symbol): Likewise.
	* solib.c (solib_global_lookup): Likewise.
	* solist.h (solib_global_lookup): Likewise.
	(struct target_so_ops): Update lookup_lib_global_symbol to
	return a struct symbol_in_block rather than a mere symbol.
	* source.c (select_source_symtab): Deal with struct
	symbol_in_block from lookup functions.
	* stack.c (print_frame_args, iterate_over_block_arg_vars):
	Likewise.
	* symfile.c (set_initial_language): Likewise.
	* symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct
	symbol_in_block.
	(SYMBOL_LOOKUP_FAILED_P): New predicate as a macro.
	(struct symbol_cache_slot): Turn the FOUND field into a struct
	symbol_in_block.
	(block_found): Remove.
	(eq_symbol_entry): Update to deal with struct symbol_in_block in
	cache slots.
	(symbol_cache_lookup): Return a struct symbol_in_block rather
	than a mere symbol.
	(symbol_cache_mark_found): Add a BLOCK parameter to fill
	appropriately the cache slots.  Update callers.
	(symbol_cache_dump): Update cache slots handling to the type
	change.
	(lookup_symbol_in_language, lookup_symbol, lookup_language_this,
	lookup_symbol_aux, lookup_local_symbol,
	lookup_symbol_in_objfile, lookup_global_symbol_from_objfile,
	lookup_symbol_in_objfile_symtabs,
	lookup_symbol_in_objfile_from_linkage_name,
	lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal,
	lookup_symbol_in_static_block, lookup_static_symbol,
	lookup_global_symbol):
	Return a struct symbol_in_block rather than a mere symbol.  Deal
	with struct symbol_in_block from other lookup functions.  Remove
	uses of block_found.
	(lookup_symbol_in_block): Remove uses of block_found.
	(struct global_sym_lookup_data): Turn the RESULT field into a
	struct symbol_in_block.
	(lookup_symbol_global_iterator_cb): Update references to the
	RESULT field.
	(search_symbols): Deal with struct symbol_in_block from lookup
	functions.
	* symtab.h (struct symbol_in_block): New structure.
	(block_found): Remove.
	(lookup_symbol_in_language, lookup_symbol,
	basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block,
	looku_static_symbol, lookup_global_symbol,
	lookup_symbol_in_block, lookup_language_this,
	lookup_global_symbol_from_objfile): Return a struct
	symbol_in_block rather than just a mere symbol.  Update comments
	to remove mentions of block_found.
	* valops.c (find_function_in_inferior,
	value_struct_elt_for_reference, value_maybe_namespace_elt,
	value_of_this):  Deal with struct symbol_in_block from lookup
	functions.
	* value.c (value_static_field, value_fn_field): Likewise.
2015-08-01 10:55:44 +02:00
Pedro Alves fe978cb071 C++ keyword cleanliness, mostly auto-generated
This patch renames symbols that happen to have names which are
reserved keywords in C++.

Most of this was generated with Tromey's cxx-conversion.el script.
Some places where later hand massaged a bit, to fix formatting, etc.
And this was rebased several times meanwhile, along with re-running
the script, so re-running the script from scratch probably does not
result in the exact same output.  I don't think that matters anyway.

gdb/
2015-02-27  Tom Tromey  <tromey@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	Rename symbols whose names are reserved C++ keywords throughout.

gdb/gdbserver/
2015-02-27  Tom Tromey  <tromey@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	Rename symbols whose names are reserved C++ keywords throughout.
2015-02-27 16:33:07 +00:00
Joel Brobecker 32d0add0a6 Update year range in copyright notice of all files owned by the GDB project.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2015-01-01 13:32:14 +04:00
Joel Brobecker c1b5a1a6e7 Internal error trying to print uninitialized string.
Trying to print the value of a string whose size is not known at
compile-time before it gets assigned a value can lead to the following
internal error:

    (gdb) p my_str
    $1 =
    /[...]/utils.c:1089: internal-error: virtual memory exhausted.

What happens is that my_str is described as a reference to an array
type whose bounds are dynamic. During the read of that variable's
value (in default_read_var_value), we end up resolving dynamic types
which, for reference types, makes us also resolve the target of that
reference type. This means we resolve our variable to a reference
to an array whose bounds are undefined, and unfortunately very far
appart.

So, when we pass that value to ada-valprint, and in particular to
da_val_print_ref, we eventually try to allocate too large of a buffer
corresponding to the (bogus) size of our array, hence the internal
error.

This patch fixes the problem by adding a size_check before trying
to print the dereferenced value. To perform this check, a function
that was previously specific to ada-lang.c (check_size) gets
exported, and renamed to something less prone to name collisions
(ada_ensure_varsize_limit).

gdb/ChangeLog:

        * ada-lang.h (ada_ensure_varsize_limit): Declare.
        * ada-lang.c (check_size): Remove advance declaration.
        (ada_ensure_varsize_limit): Renames check_size.
        Replace calls to check_size by calls to ada_ensure_varsize_limit
        throughout.
        * ada-valprint.c (ada_val_print_ref): Add call to
        ada_ensure_varsize_limit.  Add comment explaining why.

gdb/testsuite/ChangeLog:

        * gdb.ada/str_uninit: New testcase.
2014-12-13 11:00:24 -05:00
Pedro Alves 32a8097ba5 Delete Tru64 support
This commit does most of the mechanical removal.  IOW, the easy part.

procfs.c isn't touched beyond removing a couple obvious bits that are
guarded by a couple macros defined in config/alpha/nm-osf3.h.  Going
beyond that for procfs.c & co would be a harder excision that
potentially affects Solaris.

Some comments in the generic alpha code ABIs that may still be
relevant and I wouldn't know what to do with them.  That can always be
done on a separate pass, preferably by someone who can test on alpha.

A couple other spots have references to OSF/Tru64 and related files
being removed, but it felt like removing them would make things worse,
not better.  We can revisit those when we next need to touch that
code.

I didn't remove a reference to osf in testsuite/lib/future.exp, as I
believe that code is imported from DejaGNU.

Built and tested on x86_64 Fedora 20, with --enable-targets=all.

Tested that building for --target=alpha-osf3 on x86_64 Fedora 20
fails with:

 checking for default auto-load directory... $debugdir:$datadir/auto-load
 checking for default auto-load safe-path... $debugdir:$datadir/auto-load
 *** Configuration alpha-unknown-osf3 is obsolete.
 *** Support has been REMOVED.
 make[1]: *** [configure-gdb] Error 1
 make[1]: Leaving directory `build-osf'
 make: *** [all] Error 2

gdb/
2014-10-17  Pedro Alves  <palves@redhat.com>

	* Makefile.in (ALL_64_TARGET_OBS): Remove alpha-osf1-tdep.o.
	(HFILES_NO_SRCDIR): Remove config/alpha/nm-osf3.h.
	(ALLDEPFILES): Remove alpha-nat.c, alpha-osf1-tdep.c and
	solib-osf.c.
	* NEWS: Mention that support for alpha*-*-osf* has been removed.
	* ada-lang.h [__alpha__ && __osf__]
	(ADA_KNOWN_RUNTIME_FILE_NAME_PATTERNS): Delete.
	* alpha-nat.c, alpha-osf1-tdep.c: Delete files.
	* alpha-tdep.c (alpha_gdbarch_init): Remove reference to
	GDB_OSABI_OSF1.
	* config/alpha/alpha-osf3.mh, config/alpha/nm-osf3.h: Delete
	files.
	* config/djgpp/fnchange.lst (config/alpha/alpha-osf1.mh)
	(config/alpha/alpha-osf2.mh, config/alpha/alpha-osf3.mh): Delete.
	* configure: Regenerate.
	* configure.ac: Remove references to osf.
	* configure.host: Handle alpha*-*-osf* in the obsolete hosts
	section.  Remove all other references to osf.
	* configure.tgt: Add alpha*-*-osf* to the obsolete targets section.
	Remove all other references to osf.
	* dec-thread.c: Delete file.
	* defs.h (GDB_OSABI_OSF1): Delete.
	* inferior.h (START_INFERIOR_TRAPS_EXPECTED): New unconditionally
	defined.
	* osabi.c (gdb_osabi_names): Delete "OSF/1".
	* procfs.c (procfs_debug_inferior) [PROCFS_DONT_TRACE_FAULTS]:
	Delete code.
	(unconditionally_kill_inferior)
	[PROCFS_NEED_CLEAR_CURSIG_FOR_KILL]: Delete code.
	* solib-osf.c: Delete file.

gdb/testsuite/
2014-10-17  Pedro Alves  <palves@redhat.com>

	* gdb.base/callfuncs.exp: emove references to osf.
	* gdb.base/sigall.exp: Likewise.
	* gdb.gdb/selftest.exp: Likewise.
	* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
	* gdb.mi/non-stop.c: Likewise.
	* gdb.mi/pthreads.c: Likewise.
	* gdb.reverse/sigall-precsave.exp: Likewise.
	* gdb.reverse/sigall-reverse.exp: Likewise.
	* gdb.threads/pthreads.c: Likewise.
	* gdb.threads/pthreads.exp: Likewise.

gdb/doc/
2014-10-17  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Ada Tasks and Core Files): Delete mention of Tru64.
	(SVR4 Process Information): Delete mention of OSF/1.
2014-10-17 11:18:59 +01:00
Sergio Durigan Junior 410a0ff2df Remove `expout*' globals from parser-defs.h
This commit removes the "expout*" globals from our parser code, turning
them into a structure that is passed when an expression needs to be
evaluated.  This is the initial step to make our parser less
"globalized".

This is mostly a mechanical patch, which creates a structure containing
the "expout*" globals and then modify all the functions that handle them
in order to take the structure as argument.  It is big, and has been
reviewed at least 4 times, so I think everything is covered.

Below you can see the message links from the discussions:

- First attempt:

<https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html>
Message-ID: <m3k44s7qej.fsf@gmail.com>

- Second attempt:

<https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html>
Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com>

- Third attempt:

<https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html>
Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com>

- Fourth (last) attempt:

<https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html>
Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com>

gdb/
2014-03-27  Sergio Durigan Junior  <sergiodj@redhat.com>

	Remove some globals from our parser.
	* language.c (unk_lang_parser): Add "struct parser_state"
	argument.
	* language.h (struct language_defn) <la_parser>: Likewise.
	* parse.c (expout, expout_size, expout_ptr): Remove variables.
	(initialize_expout): Add "struct parser_state" argument.
	Rewrite function to use the parser state.
	(reallocate_expout, write_exp_elt, write_exp_elt_opcode,
	write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile,
	write_exp_elt_longcst, write_exp_elt_dblcst,
	write_exp_elt_decfloatcst, write_exp_elt_type,
	write_exp_elt_intern, write_exp_string, write_exp_string_vector,
	write_exp_bitstring, write_exp_msymbol, mark_struct_expression,
	write_dollar_variable): Likewise.
	(parse_exp_in_context_1): Use parser state.
	(insert_type_address_space): Add "struct parser_state" argument.
	Use parser state.
	(increase_expout_size): New function.
	* parser-defs.h: Forward declare "struct language_defn" and
	"struct parser_state".
	(expout, expout_size, expout_ptr): Remove extern declarations.
	(parse_gdbarch, parse_language): Rewrite macro declarations to
	accept the parser state.
	(struct parser_state): New struct.
	(initialize_expout, reallocate_expout, write_exp_elt_opcode,
	write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst,
	write_exp_elt_decfloatcst, write_exp_elt_type,
	write_exp_elt_intern, write_exp_string, write_exp_string_vector,
	write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile,
	write_exp_msymbol, write_dollar_variable,
	mark_struct_expression, insert_type_address_space): Add "struct
	parser_state" argument.
	(increase_expout_size): New function.
	* utils.c (do_clear_parser_state): New function.
	(make_cleanup_clear_parser_state): Likewise.
	* utils.h (make_cleanup_clear_parser_state): New function
	prototype.
	* aarch64-linux-tdep.c (aarch64_stap_parse_special_token):
	Update calls to write_exp* in order to pass the parser state.
	* arm-linux-tdep.c (arm_stap_parse_special_token): Likewise.
	* i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise.
	(i386_stap_parse_special_token_three_arg_disp): Likewise.
	* ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise.
	* stap-probe.c (stap_parse_register_operand): Likewise.
	(stap_parse_single_operand): Likewise.
	(stap_parse_argument_1): Likewise.
	(stap_parse_argument): Use parser state.
	* stap-probe.h: Include "parser-defs.h".
	(struct stap_parse_info) <pstate>: New field.
	* c-exp.y (parse_type): Rewrite to use parser state.
	(yyparse): Redefine to c_parse_internal.
	(pstate): New global variable.
	(parse_number): Add "struct parser_state" argument.
	(write_destructor_name): Likewise.
	(type_exp): Update calls to write_exp* and similars in order to
	use parser state.
	(exp1, exp, variable, qualified_name, space_identifier,
	typename, typebase): Likewise.
	(write_destructor_name, parse_number, lex_one_token,
	classify_name, classify_inner_name, c_parse): Add "struct
	parser_state" argument.  Update function to use parser state.
	* c-lang.h: Forward declare "struct parser_state".
	(c_parse): Add "struct parser_state" argument.
	* ada-exp.y (parse_type): Rewrite macro to use parser state.
	(yyparse): Redefine macro to ada_parse_internal.
	(pstate): New variable.
	(write_int, write_object_renaming, write_var_or_type,
	write_name_assoc, write_exp_op_with_string, write_ambiguous_var,
	type_int, type_long, type_long_long, type_float, type_double,
	type_long_double, type_char, type_boolean, type_system_address):
	Add "struct parser_state" argument.
	(exp1, primary, simple_exp, relation, and_exp, and_then_exp,
	or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix,
	var_or_type, aggregate, aggregate_component_list,
	positional_list, others, component_group,
	component_associations): Update calls to write_exp* and similar
	functions in order to use parser state.
	(ada_parse, write_var_from_sym, write_int,
	write_exp_op_with_string, write_object_renaming,
	find_primitive_type, write_selectors, write_ambiguous_var,
	write_var_or_type, write_name_assoc, type_int, type_long,
	type_long_long, type_float, type_double, type_long_double,
	type_char, type_boolean, type_system_address): Add "struct
	parser_state" argument.  Adjust function to use parser state.
	* ada-lang.c (parse): Likewise.
	* ada-lang.h: Forward declare "struct parser_state".
	(ada_parse): Add "struct parser_state" argument.
	* ada-lex.l (processInt, processReal): Likewise.  Adjust all
	calls to both functions.
	* f-exp.y (parse_type, parse_f_type): Rewrite macros to use
	parser state.
	(yyparse): Redefine macro to f_parse_internal.
	(pstate): New variable.
	(parse_number): Add "struct parser_state" argument.
	(type_exp, exp, subrange, typebase): Update calls to write_exp*
	and similars in order to use parser state.
	(parse_number): Adjust code to use parser state.
	(yylex): Likewise.
	(f_parse): New function.
	* f-lang.h: Forward declare "struct parser_state".
	(f_parse): Add "struct parser_state" argument.
	* jv-exp.y (parse_type, parse_java_type): Rewrite macros to use
	parser state.
	(yyparse): Redefine macro for java_parse_internal.
	(pstate): New variable.
	(push_expression_name, push_expression_name, insert_exp): Add
	"struct parser_state" argument.
	(type_exp, StringLiteral, Literal, PrimitiveType, IntegralType,
	FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess,
	FuncStart, MethodInvocation, ArrayAccess, PostfixExpression,
	PostIncrementExpression, PostDecrementExpression,
	UnaryExpression, PreIncrementExpression, PreDecrementExpression,
	UnaryExpressionNotPlusMinus, CastExpression,
	MultiplicativeExpression, AdditiveExpression, ShiftExpression,
	RelationalExpression, EqualityExpression, AndExpression,
	ExclusiveOrExpression, InclusiveOrExpression,
	ConditionalAndExpression, ConditionalOrExpression,
	ConditionalExpression, Assignment, LeftHandSide): Update
	calls to write_exp* and similars in order to use parser state.
	(parse_number): Ajust code to use parser state.
	(yylex): Likewise.
	(java_parse): New function.
	(push_variable): Add "struct parser_state" argument.  Adjust
	code to user parser state.
	(push_fieldnames, push_qualified_expression_name,
	push_expression_name, insert_exp): Likewise.
	* jv-lang.h: Forward declare "struct parser_state".
	(java_parse): Add "struct parser_state" argument.
	* m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use
	parser state.
	(yyparse): Redefine macro to m2_parse_internal.
	(pstate): New variable.
	(type_exp, exp, fblock, variable, type): Update calls to
	write_exp* and similars to use parser state.
	(yylex): Likewise.
	(m2_parse): New function.
	* m2-lang.h: Forward declare "struct parser_state".
	(m2_parse): Add "struct parser_state" argument.
	* objc-lang.c (end_msglist): Add "struct parser_state" argument.
	* objc-lang.h: Forward declare "struct parser_state".
	(end_msglist): Add "struct parser_state" argument.
	* p-exp.y (parse_type): Rewrite macro to use parser state.
	(yyparse): Redefine macro to pascal_parse_internal.
	(pstate): New variable.
	(parse_number): Add "struct parser_state" argument.
	(type_exp, exp1, exp, qualified_name, variable): Update calls to
	write_exp* and similars in order to use parser state.
	(parse_number, yylex): Adjust code to use parser state.
	(pascal_parse): New function.
	* p-lang.h: Forward declare "struct parser_state".
	(pascal_parse): Add "struct parser_state" argument.
	* go-exp.y (parse_type): Rewrite macro to use parser state.
	(yyparse): Redefine macro to go_parse_internal.
	(pstate): New variable.
	(parse_number): Add "struct parser_state" argument.
	(type_exp, exp1, exp, variable, type): Update calls to
	write_exp* and similars in order to use parser state.
	(parse_number, lex_one_token, classify_name, yylex): Adjust code
	to use parser state.
	(go_parse): Likewise.
	* go-lang.h: Forward declare "struct parser_state".
	(go_parse): Add "struct parser_state" argument.
2014-03-27 19:10:40 -03:00
Joel Brobecker ae56bfb8e7 Delete ada-lang.h::clear_ada_sym_cache (nonexistant function).
I happen to notice this extern function declaration in ada-lang.h
which does not actually exist...

gdb/ChangeLog:

        * ada-lang.h (clear_ada_sym_cache): Delete.
2014-01-31 15:32:00 +04:00
Joel Brobecker ecd75fc8ee Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00