Commit Graph

42476 Commits

Author SHA1 Message Date
Tom Tromey 3d6e9d2336 Make exceptions use std::string and be self-managing
This changes the exception's "message" member to be a shared_ptr
wrapping a std::string.  This allows removing the stack of exception
messages, because now exceptions will self-destruct when needed.  This
also adds a noexcept copy constructor and operator= to gdb_exception,
plus a "what" method.

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

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

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

	* server.c (handle_btrace_general_set, handle_qxfer_btrace)
	(handle_qxfer_btrace_conf, detach_or_kill_for_exit_cleanup)
	(captured_main, main): Update.
	* gdbreplay.c (main): Update.
2019-04-08 09:05:38 -06:00
Tom Tromey c5c1011821 Simplify exception handling
Now that cleanups have been removed, TRY/CATCH can't be SJLJ-based any
more.  This patch simplifies the exception handling code, by removing
the non-working variants.

Note that the "pure" C++ exception handling code is removed as well; I
think the route forward must be to change exceptions to be
self-destructing, so that try_scope_depth can simply be removed.

Some longjmp-based code remains, as it is needed to throw an exception
through readline.

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

	* common/common-exceptions.h (GDB_XCPT_SJMP, GDB_XCPT_TRY)
	(GDB_XCPT_RAW_TRY, GDB_XCPT): Remove.
	(TRY, CATCH, END_CATCH): Remove some definitions.
	* common/common-exceptions.c: Don't use GDB_XCPT.
	(catcher_list_size): Remove.
	(throw_exception, throw_it): Simplify.
2019-04-08 09:05:37 -06:00
Tom Tromey 48ab418ec7 Make "all" depend on "info"
I've broken "make info" a couple of times now, because I sometimes
forget to run "make info" after modifying a Texinfo file.

I don't know why gdb's "make all" doesn't build the info pages.  I
suspect this was some Cygnus-local oddity back in the day.

This patch changes doc/Makefile.in so that the info pages are built by
"make all".  As a point of reference, Automake has essentially always
worked this way.  According to the Automake manual (I didn't
double-check) this is required by the GNU coding standards.

The first time I sent this patch, I mentioned that I wanted to look
into some existing bugs in bugzilla about missing "makeinfo".
However, today I tried and I discovered that BFD requires makeinfo,
and builds its info file as part of "all".  So, I think this change
doesn't worsen the situation for users in any way, and can simply go
in.

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

	* Makefile.in (all): Depend on "info".
2019-04-07 17:01:18 -06:00
Tom Tromey 4de283e4b5 Revert the header-sorting patch
Andreas Schwab and John Baldwin pointed out some bugs in the header
sorting patch; and I noticed that the output was not correct when
limited to a subset of files (a bug in my script).

So, I'm reverting the patch.  I may try again after fixing the issues
pointed out.

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

	Revert the header-sorting patch.
	* ft32-tdep.c: Revert.
	* frv-tdep.c: Revert.
	* frv-linux-tdep.c: Revert.
	* frame.c: Revert.
	* frame-unwind.c: Revert.
	* frame-base.c: Revert.
	* fork-child.c: Revert.
	* findvar.c: Revert.
	* findcmd.c: Revert.
	* filesystem.c: Revert.
	* filename-seen-cache.h: Revert.
	* filename-seen-cache.c: Revert.
	* fbsd-tdep.c: Revert.
	* fbsd-nat.h: Revert.
	* fbsd-nat.c: Revert.
	* f-valprint.c: Revert.
	* f-typeprint.c: Revert.
	* f-lang.c: Revert.
	* extension.h: Revert.
	* extension.c: Revert.
	* extension-priv.h: Revert.
	* expprint.c: Revert.
	* exec.h: Revert.
	* exec.c: Revert.
	* exceptions.c: Revert.
	* event-top.c: Revert.
	* event-loop.c: Revert.
	* eval.c: Revert.
	* elfread.c: Revert.
	* dwarf2read.h: Revert.
	* dwarf2read.c: Revert.
	* dwarf2loc.c: Revert.
	* dwarf2expr.h: Revert.
	* dwarf2expr.c: Revert.
	* dwarf2-frame.c: Revert.
	* dwarf2-frame-tailcall.c: Revert.
	* dwarf-index-write.h: Revert.
	* dwarf-index-write.c: Revert.
	* dwarf-index-common.c: Revert.
	* dwarf-index-cache.h: Revert.
	* dwarf-index-cache.c: Revert.
	* dummy-frame.c: Revert.
	* dtrace-probe.c: Revert.
	* disasm.h: Revert.
	* disasm.c: Revert.
	* disasm-selftests.c: Revert.
	* dictionary.c: Revert.
	* dicos-tdep.c: Revert.
	* demangle.c: Revert.
	* dcache.h: Revert.
	* dcache.c: Revert.
	* darwin-nat.h: Revert.
	* darwin-nat.c: Revert.
	* darwin-nat-info.c: Revert.
	* d-valprint.c: Revert.
	* d-namespace.c: Revert.
	* d-lang.c: Revert.
	* ctf.c: Revert.
	* csky-tdep.c: Revert.
	* csky-linux-tdep.c: Revert.
	* cris-tdep.c: Revert.
	* cris-linux-tdep.c: Revert.
	* cp-valprint.c: Revert.
	* cp-support.c: Revert.
	* cp-namespace.c: Revert.
	* cp-abi.c: Revert.
	* corelow.c: Revert.
	* corefile.c: Revert.
	* continuations.c: Revert.
	* completer.h: Revert.
	* completer.c: Revert.
	* complaints.c: Revert.
	* coffread.c: Revert.
	* coff-pe-read.c: Revert.
	* cli-out.h: Revert.
	* cli-out.c: Revert.
	* charset.c: Revert.
	* c-varobj.c: Revert.
	* c-valprint.c: Revert.
	* c-typeprint.c: Revert.
	* c-lang.c: Revert.
	* buildsym.c: Revert.
	* buildsym-legacy.c: Revert.
	* build-id.h: Revert.
	* build-id.c: Revert.
	* btrace.c: Revert.
	* bsd-uthread.c: Revert.
	* breakpoint.h: Revert.
	* breakpoint.c: Revert.
	* break-catch-throw.c: Revert.
	* break-catch-syscall.c: Revert.
	* break-catch-sig.c: Revert.
	* blockframe.c: Revert.
	* block.c: Revert.
	* bfin-tdep.c: Revert.
	* bfin-linux-tdep.c: Revert.
	* bfd-target.c: Revert.
	* bcache.c: Revert.
	* ax-general.c: Revert.
	* ax-gdb.h: Revert.
	* ax-gdb.c: Revert.
	* avr-tdep.c: Revert.
	* auxv.c: Revert.
	* auto-load.c: Revert.
	* arm-wince-tdep.c: Revert.
	* arm-tdep.c: Revert.
	* arm-symbian-tdep.c: Revert.
	* arm-pikeos-tdep.c: Revert.
	* arm-obsd-tdep.c: Revert.
	* arm-nbsd-tdep.c: Revert.
	* arm-nbsd-nat.c: Revert.
	* arm-linux-tdep.c: Revert.
	* arm-linux-nat.c: Revert.
	* arm-fbsd-tdep.c: Revert.
	* arm-fbsd-nat.c: Revert.
	* arm-bsd-tdep.c: Revert.
	* arch-utils.c: Revert.
	* arc-tdep.c: Revert.
	* arc-newlib-tdep.c: Revert.
	* annotate.h: Revert.
	* annotate.c: Revert.
	* amd64-windows-tdep.c: Revert.
	* amd64-windows-nat.c: Revert.
	* amd64-tdep.c: Revert.
	* amd64-sol2-tdep.c: Revert.
	* amd64-obsd-tdep.c: Revert.
	* amd64-obsd-nat.c: Revert.
	* amd64-nbsd-tdep.c: Revert.
	* amd64-nbsd-nat.c: Revert.
	* amd64-nat.c: Revert.
	* amd64-linux-tdep.c: Revert.
	* amd64-linux-nat.c: Revert.
	* amd64-fbsd-tdep.c: Revert.
	* amd64-fbsd-nat.c: Revert.
	* amd64-dicos-tdep.c: Revert.
	* amd64-darwin-tdep.c: Revert.
	* amd64-bsd-nat.c: Revert.
	* alpha-tdep.c: Revert.
	* alpha-obsd-tdep.c: Revert.
	* alpha-nbsd-tdep.c: Revert.
	* alpha-mdebug-tdep.c: Revert.
	* alpha-linux-tdep.c: Revert.
	* alpha-linux-nat.c: Revert.
	* alpha-bsd-tdep.c: Revert.
	* alpha-bsd-nat.c: Revert.
	* aix-thread.c: Revert.
	* agent.c: Revert.
	* addrmap.c: Revert.
	* ada-varobj.c: Revert.
	* ada-valprint.c: Revert.
	* ada-typeprint.c: Revert.
	* ada-tasks.c: Revert.
	* ada-lang.c: Revert.
	* aarch64-tdep.c: Revert.
	* aarch64-ravenscar-thread.c: Revert.
	* aarch64-newlib-tdep.c: Revert.
	* aarch64-linux-tdep.c: Revert.
	* aarch64-linux-nat.c: Revert.
	* aarch64-fbsd-tdep.c: Revert.
	* aarch64-fbsd-nat.c: Revert.
	* aarch32-linux-nat.c: Revert.
2019-04-06 13:47:34 -06:00
Tom Tromey d55e5aa6b2 Sort includes for files gdb/[a-f]*.[chyl].
This patch sorts the include files for the files [a-f]*.[chyl].
The patch was written by a script.

Tested by the buildbot.

I will follow up with patches to sort the remaining files, by sorting
a subset, testing them, and then checking them in.

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

	* ft32-tdep.c: Sort headers.
	* frv-tdep.c: Sort headers.
	* frv-linux-tdep.c: Sort headers.
	* frame.c: Sort headers.
	* frame-unwind.c: Sort headers.
	* frame-base.c: Sort headers.
	* fork-child.c: Sort headers.
	* findvar.c: Sort headers.
	* findcmd.c: Sort headers.
	* filesystem.c: Sort headers.
	* filename-seen-cache.h: Sort headers.
	* filename-seen-cache.c: Sort headers.
	* fbsd-tdep.c: Sort headers.
	* fbsd-nat.h: Sort headers.
	* fbsd-nat.c: Sort headers.
	* f-valprint.c: Sort headers.
	* f-typeprint.c: Sort headers.
	* f-lang.c: Sort headers.
	* extension.h: Sort headers.
	* extension.c: Sort headers.
	* extension-priv.h: Sort headers.
	* expprint.c: Sort headers.
	* exec.h: Sort headers.
	* exec.c: Sort headers.
	* exceptions.c: Sort headers.
	* event-top.c: Sort headers.
	* event-loop.c: Sort headers.
	* eval.c: Sort headers.
	* elfread.c: Sort headers.
	* dwarf2read.h: Sort headers.
	* dwarf2read.c: Sort headers.
	* dwarf2loc.c: Sort headers.
	* dwarf2expr.h: Sort headers.
	* dwarf2expr.c: Sort headers.
	* dwarf2-frame.c: Sort headers.
	* dwarf2-frame-tailcall.c: Sort headers.
	* dwarf-index-write.h: Sort headers.
	* dwarf-index-write.c: Sort headers.
	* dwarf-index-common.c: Sort headers.
	* dwarf-index-cache.h: Sort headers.
	* dwarf-index-cache.c: Sort headers.
	* dummy-frame.c: Sort headers.
	* dtrace-probe.c: Sort headers.
	* disasm.h: Sort headers.
	* disasm.c: Sort headers.
	* disasm-selftests.c: Sort headers.
	* dictionary.c: Sort headers.
	* dicos-tdep.c: Sort headers.
	* demangle.c: Sort headers.
	* dcache.h: Sort headers.
	* dcache.c: Sort headers.
	* darwin-nat.h: Sort headers.
	* darwin-nat.c: Sort headers.
	* darwin-nat-info.c: Sort headers.
	* d-valprint.c: Sort headers.
	* d-namespace.c: Sort headers.
	* d-lang.c: Sort headers.
	* ctf.c: Sort headers.
	* csky-tdep.c: Sort headers.
	* csky-linux-tdep.c: Sort headers.
	* cris-tdep.c: Sort headers.
	* cris-linux-tdep.c: Sort headers.
	* cp-valprint.c: Sort headers.
	* cp-support.c: Sort headers.
	* cp-namespace.c: Sort headers.
	* cp-abi.c: Sort headers.
	* corelow.c: Sort headers.
	* corefile.c: Sort headers.
	* continuations.c: Sort headers.
	* completer.h: Sort headers.
	* completer.c: Sort headers.
	* complaints.c: Sort headers.
	* coffread.c: Sort headers.
	* coff-pe-read.c: Sort headers.
	* cli-out.h: Sort headers.
	* cli-out.c: Sort headers.
	* charset.c: Sort headers.
	* c-varobj.c: Sort headers.
	* c-valprint.c: Sort headers.
	* c-typeprint.c: Sort headers.
	* c-lang.c: Sort headers.
	* buildsym.c: Sort headers.
	* buildsym-legacy.c: Sort headers.
	* build-id.h: Sort headers.
	* build-id.c: Sort headers.
	* btrace.c: Sort headers.
	* bsd-uthread.c: Sort headers.
	* breakpoint.h: Sort headers.
	* breakpoint.c: Sort headers.
	* break-catch-throw.c: Sort headers.
	* break-catch-syscall.c: Sort headers.
	* break-catch-sig.c: Sort headers.
	* blockframe.c: Sort headers.
	* block.c: Sort headers.
	* bfin-tdep.c: Sort headers.
	* bfin-linux-tdep.c: Sort headers.
	* bfd-target.c: Sort headers.
	* bcache.c: Sort headers.
	* ax-general.c: Sort headers.
	* ax-gdb.h: Sort headers.
	* ax-gdb.c: Sort headers.
	* avr-tdep.c: Sort headers.
	* auxv.c: Sort headers.
	* auto-load.c: Sort headers.
	* arm-wince-tdep.c: Sort headers.
	* arm-tdep.c: Sort headers.
	* arm-symbian-tdep.c: Sort headers.
	* arm-pikeos-tdep.c: Sort headers.
	* arm-obsd-tdep.c: Sort headers.
	* arm-nbsd-tdep.c: Sort headers.
	* arm-nbsd-nat.c: Sort headers.
	* arm-linux-tdep.c: Sort headers.
	* arm-linux-nat.c: Sort headers.
	* arm-fbsd-tdep.c: Sort headers.
	* arm-fbsd-nat.c: Sort headers.
	* arm-bsd-tdep.c: Sort headers.
	* arch-utils.c: Sort headers.
	* arc-tdep.c: Sort headers.
	* arc-newlib-tdep.c: Sort headers.
	* annotate.h: Sort headers.
	* annotate.c: Sort headers.
	* amd64-windows-tdep.c: Sort headers.
	* amd64-windows-nat.c: Sort headers.
	* amd64-tdep.c: Sort headers.
	* amd64-sol2-tdep.c: Sort headers.
	* amd64-obsd-tdep.c: Sort headers.
	* amd64-obsd-nat.c: Sort headers.
	* amd64-nbsd-tdep.c: Sort headers.
	* amd64-nbsd-nat.c: Sort headers.
	* amd64-nat.c: Sort headers.
	* amd64-linux-tdep.c: Sort headers.
	* amd64-linux-nat.c: Sort headers.
	* amd64-fbsd-tdep.c: Sort headers.
	* amd64-fbsd-nat.c: Sort headers.
	* amd64-dicos-tdep.c: Sort headers.
	* amd64-darwin-tdep.c: Sort headers.
	* amd64-bsd-nat.c: Sort headers.
	* alpha-tdep.c: Sort headers.
	* alpha-obsd-tdep.c: Sort headers.
	* alpha-nbsd-tdep.c: Sort headers.
	* alpha-mdebug-tdep.c: Sort headers.
	* alpha-linux-tdep.c: Sort headers.
	* alpha-linux-nat.c: Sort headers.
	* alpha-bsd-tdep.c: Sort headers.
	* alpha-bsd-nat.c: Sort headers.
	* aix-thread.c: Sort headers.
	* agent.c: Sort headers.
	* addrmap.c: Sort headers.
	* ada-varobj.c: Sort headers.
	* ada-valprint.c: Sort headers.
	* ada-typeprint.c: Sort headers.
	* ada-tasks.c: Sort headers.
	* ada-lang.c: Sort headers.
	* aarch64-tdep.c: Sort headers.
	* aarch64-ravenscar-thread.c: Sort headers.
	* aarch64-newlib-tdep.c: Sort headers.
	* aarch64-linux-tdep.c: Sort headers.
	* aarch64-linux-nat.c: Sort headers.
	* aarch64-fbsd-tdep.c: Sort headers.
	* aarch64-fbsd-nat.c: Sort headers.
	* aarch32-linux-nat.c: Sort headers.
2019-04-05 19:09:35 -06:00
Pedro Franco de Carvalho 0570503dd3 Use linux_get_auxv to get AT_PHDR in the PPC stub
This patch fixes a build error due to a call to ppc_get_auxv that was
left over after linux_get_hwcap and linux_get_hwcap2 were introduced
in:

974c89e088 gdbserver: Add
linux_get_hwcap

Because the missing call fetched AT_PHDR and not AT_HWCAP,
linux_get_auxv is now visible.

This use also required ppc_get_auxv to return a status variable
indicating that the AT_PHDR entry was not found separately from the
actual value of of the auxv entry.  Therefore, the new linux_get_auxv
function is changed to return a status variable and write the entry
value to a pointer passed as an argument.

Note that linux_get_hwcap and linux_get_hwcap2 still use the return
value as both an indicator of that the entry wasn't found and as the
actual value of the entry.

gdb/gdbserver/ChangeLog:
2019-04-05  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* linux-low.c (linux_get_auxv): Remove static.  Return auxv entry
	value in argument pointer, return 1 if the entry is found and 0
	otherwise.  Move comment.
	(linux_get_hwcap, linux_get_hwcap2): Use modified linux_get_auxv.
	* linux-low.h (linux_get_auxv): Declare.
	* linux-ppc-low.c (is_elfv2_inferior): Use linux_get_auxv.
2019-04-05 14:19:08 -03:00
Tom Tromey 227a9e65b9 Use upper-case for metasyntactic in gdbserver help
I noticed that "gdbserver --help" contains a few metasyntactic
variables that aren't in upper-case.  This patch fixes them to conform
to the GNU standard.

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

	* server.c (gdbserver_usage): Use upper-case for metasyntactic
	variables.
2019-04-05 07:29:24 -06:00
Tom Tromey 699bd4cfa8 Move innermost_block_tracker global to parse_state
This changes the parsing API so that callers that are interested in
tracking the innermost block must instantiate an
innermost_block_tracker and pass it in.  Then, a pointer to this
object is stored in the parser_state.

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

	* varobj.c (varobj_create): Update.
	* rust-exp.y (struct rust_parser) <update_innermost_block,
	lookup_symbol>: New methods.
	(rust_parser::update_innermost_block, rust_parser::lookup_symbol):
	Rename.
	(rust_parser::rust_lookup_type)
	(rust_parser::convert_ast_to_expression, rust_lex_tests): Update.
	* printcmd.c (display_command, do_one_display): Update.
	* parser-defs.h (struct parser_state) <parser_state>: Add
	"tracker" parameter.
	(block_tracker): New member.
	(class innermost_block_tracker) <innermost_block_tracker>: Add
	"types" parameter.
	<reset>: Remove method.
	(innermost_block): Don't declare.
	(null_post_parser): Update.
	* parse.c (innermost_block): Remove global.
	(write_dollar_variable): Update.
	(parse_exp_1, parse_exp_in_context): Add "tracker" parameter.
	Remove "tracker_types" parameter.
	(parse_expression): Add "tracker" parameter.
	(parse_expression_for_completion): Update.
	(null_post_parser): Add "tracker" parameter.
	* p-exp.y: Update rules.
	* m2-exp.y: Update rules.
	* language.h (struct language_defn) <la_post_parser>: Add
	"tracker" parameter.
	* go-exp.y: Update rules.
	* f-exp.y: Update rules.
	* expression.h (parse_expression, parse_exp_1): Add "tracker"
	parameter.
	* d-exp.y: Update rules.
	* c-exp.y: Update rules.
	* breakpoint.c (set_breakpoint_condition): Create an
	innermost_block_tracker.
	(watch_command_1): Likewise.
	* ada-lang.c (resolve): Add "tracker" parameter.
	(resolve_subexp): Likewise.
	* ada-exp.y (write_var_from_sym): Update.
2019-04-04 19:55:11 -06:00
Tom Tromey dac43e327d Move type stack handling to a new class
This introduces a new "type_stack" class, and moves all the parser
type stack handling to this class.  Parsers that wish to use this
facility must now instantiate this class somehow.  I chose this
approach because a minority of the existing parsers require this.

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

	* type-stack.h: New file.
	* type-stack.c: New file.
	* parser-defs.h (enum type_pieces, union type_stack_elt): Move to
	type-stack.h.
	(insert_into_type_stack, insert_type, push_type, push_type_int)
	(insert_type_address_space, pop_type, pop_type_int)
	(pop_typelist, pop_type_stack, append_type_stack)
	(push_type_stack, get_type_stack, push_typelist)
	(follow_type_instance_flags, follow_types): Don't declare.
	* parse.c (type_stack): Remove global.
	(parse_exp_in_context): Update.
	(insert_into_type_stack, insert_type, push_type, push_type_int)
	(insert_type_address_space, pop_type, pop_type_int)
	(pop_typelist, pop_type_stack, append_type_stack)
	(push_type_stack, get_type_stack, push_typelist)
	(follow_type_instance_flags, follow_types): Remove (moved to
	type-stack.c).
	* f-exp.y (type_stack): New global.
	Update rules.
	(push_kind_type, f_parse): Update.
	* d-exp.y (type_stack): New global.
	Update rules.
	(d_parse): Update.
	* c-exp.y (struct c_parse_state) <type_stack>: New member.
	Update rules.
	* Makefile.in (COMMON_SFILES): Add type-stack.c.
	(HFILES_NO_SRCDIR): Add type-stack.h.
2019-04-04 19:55:11 -06:00
Tom Tromey 2a61252965 Move completion parsing to parser_state
This moves the globals and functions related to parsing for completion
to parser_state.  A new structure is introduced in order to return
completion results from the parse back to
parse_expression_for_completion.

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

	* rust-exp.y (rust_parser::lex_identifier, rustyylex)
	(rust_parser::convert_ast_to_expression, rust_parse)
	(rust_lex_test_completion, rust_lex_tests): Update.
	* parser-defs.h (struct expr_completion_state): New.
	(struct parser_state) <parser_state>: Add completion parameter.
	<mark_struct_expression, mark_completion_tag>: New methods.
	<parse_completion, m_completion_state>: New members.
	(prefixify_expression, null_post_parser): Update.
	(mark_struct_expression, mark_completion_tag): Don't declare.
	* parse.c (parse_completion, expout_last_struct)
	(expout_tag_completion_type, expout_completion_name): Remove
	globals.
	(parser_state::mark_struct_expression)
	(parser_state::mark_completion_tag): Now methods.
	(prefixify_expression): Add last_struct parameter.
	(prefixify_subexp): Likewise.
	(parse_exp_1): Update.
	(parse_exp_in_context): Add cstate parameter.  Update.
	(parse_expression_for_completion): Create an
	expr_completion_state.
	(null_post_parser): Add "completion" parameter.
	* p-exp.y: Update rules.
	(yylex): Update.
	* language.h (struct language_defn) <la_post_parser>: Add
	"completing" parameter.
	* go-exp.y: Update rules.
	(lex_one_token): Update.
	* expression.h (parse_completion): Don't declare.
	* d-exp.y: Update rules.
	(lex_one_token): Update rules.
	* c-exp.y: Update rules.
	(lex_one_token): Update.
	* ada-lang.c (resolve): Add "parse_completion" parameter.
	(resolve_subexp): Likewise.
	(ada_resolve_function): Likewise.
2019-04-04 19:55:11 -06:00
Tom Tromey 43476f0b1b Move arglist_len et al to parser_state
This moves arglist_len, start_arglist, and end_arglist to
parser_state.

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

	* parser-defs.h (struct parser_state) <start_arglist,
	end_arglist>: New methods.
	<arglist_len, m_funcall_chain>: New members.
	(arglist_len, start_arglist, end_arglist): Don't declare.
	* parse.c (arglist_len, funcall_chain): Remove global.
	(start_arglist, end_arglist): Remove functions.
	(parse_exp_in_context): Update.
	* p-exp.y: Update rules.
	* m2-exp.y: Update rules.
	* go-exp.y: Update rules.
	* f-exp.y: Update rules.
	* d-exp.y: Update rules.
	* c-exp.y: Update rules.
2019-04-04 19:55:11 -06:00
Tom Tromey 5776fca307 Move lexptr and prev_lexptr to parser_state
This removes the lexptr and prev_lexptr globals, in favor of members
of parser_state.  prev_lexptr could be isolated to each parser, but
since every parser uses it, that did not seem necessary.

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

	* rust-exp.y (struct rust_parser) <lex_hex, lex_escape,
	lex_operator, push_back>: New methods.
	Update all rules.
	(rust_parser::lex_hex, lex_escape): Rename and update.
	(rust_parser::lex_string, rust_parser::lex_identifier): Update.
	(rust_parser::lex_operator): Rename and update.
	(rust_parser::lex_number, rustyylex, rustyyerror)
	(rust_lex_test_init, rust_lex_test_sequence)
	(rust_lex_test_push_back, rust_lex_tests): Update.
	* parser-defs.h (struct parser_state) <parser_state>: Add "input"
	parameter.
	<lexptr, prev_lexptr>: New members.
	(lexptr, prev_lexptr): Don't declare.
	* parse.c (lexptr, prev_lexptr): Remove globals.
	(parse_exp_in_context): Update.
	* p-exp.y (yylex, yyerror): Update.
	* m2-exp.y (parse_number, yylex, yyerror): Update.
	* go-exp.y (lex_one_token, yyerror): Update.
	* f-exp.y (match_string_literal, yylex, yyerror): Update.
	* d-exp.y (lex_one_token, yyerror): Update.
	* c-exp.y (scan_macro_expansion, finished_macro_expansion)
	(lex_one_token, yyerror): Update.
	* ada-lex.l (YY_INPUT): Update.
	(rewind_to_char): Update.
	* ada-exp.y (yyerror): Update.
2019-04-04 19:55:11 -06:00
Tom Tromey 8621b685bf Move comma_terminates global to parser_state
This moves the comma_terminates global to parser_state.

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

	* rust-exp.y (rustyylex, rust_lex_tests): Update.
	* parser-defs.h (struct parser_state) <parser_state>: Add new
	parameter.
	<comma_terminates>: New member.
	(comma_terminates): Don't declare global.
	* parse.c (comma_terminates): Remove global.
	(parse_exp_in_context): Update.
	* p-exp.y (yylex): Update.
	* m2-exp.y (yylex): Update.
	* go-exp.y (lex_one_token): Update.
	* f-exp.y (yylex): Update.
	* d-exp.y (lex_one_token): Update.
	* c-exp.y (lex_one_token): Update.
	* ada-lex.l: Update.
2019-04-04 19:55:11 -06:00
Tom Tromey 28aaf3fdf9 Remove paren_depth global
This removes the "paren_depth" global.  In most cases, it is made into
a static global in a given parser.  I consider this a slight
improvement, because it makes it clear that the variable isn't used
for communication between different modules of gdb.  The one exception
is the Rust parser, which already incorporates all local state into a
transient object; in this case the parser depth is now a member.

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

	* rust-exp.y (struct rust_parser) <paren_depth>: New member.
	(rustyylex, rust_lex_test_init, rust_lex_test_one)
	(rust_lex_test_sequence, rust_lex_test_push_back): Update.
	* parser-defs.h (paren_depth): Don't declare.
	* parse.c (paren_depth): Remove global.
	(parse_exp_in_context): Update.
	* p-exp.y (paren_depth): New global.
	(pascal_parse): Initialize it.
	* m2-exp.y (paren_depth): New global.
	(m2_parse): Initialize it.
	* go-exp.y (paren_depth): New global.
	(go_parse): Initialize it.
	* f-exp.y (paren_depth): New global.
	(f_parse): Initialize it.
	* d-exp.y (paren_depth): New global.
	(d_parse): Initialize it.
	* c-exp.y (paren_depth): New global.
	(c_parse): Initialize it.
	* ada-lex.l (paren_depth): New global.
	(lexer_init): Initialize it.
2019-04-04 19:55:10 -06:00
Tom Tromey 1e58a4a4db Move expression_context_* globals to parser_state
This moves the expression_context_block and expression_context_pc
globals to be members of parser_state and updates the parsers.

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

	* rust-exp.y (rust_parser::crate_name, rust_parser::super_name)
	(rust_parser::convert_ast_to_type)
	(rust_parser::convert_ast_to_expression, rust_lex_tests): Update.
	* parser-defs.h (struct parser_state) <parser_state>: Add
	parameters.  Initialize new members.
	<expression_context_block, expression_context_pc>: New members.
	* parse.c (expression_context_block, expression_context_pc):
	Remove globals.
	(parse_exp_in_context): Update.
	* p-exp.y: Update all rules.
	(yylex): Update.
	* m2-exp.y: Update all rules.
	(yylex): Update.
	* go-exp.y (yylex): Update.
	* f-exp.y (yylex): Update.
	* d-exp.y: Update all rules.
	(yylex): Update.
	* c-exp.y: Update all rules.
	(lex_one_token, classify_name, yylex, c_parse): Update.
	* ada-exp.y (write_var_or_type, write_name_assoc): Update.
2019-04-04 19:55:10 -06:00
Tom Tromey 37eedb3982 Make base class for parser_state
This makes a new base class, expr_builder, for parser_state.  This
separates the state needed to construct an expression from the state
needed by the parsers.

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

	* gdbarch.h, gdbarch.c: Rebuild.
	* gdbarch.sh (dtrace_parse_probe_argument): Change type.
	* stap-probe.h:
	(struct stap_parse_info): Replace "parser_state" with
	"expr_builder".
	* parser-defs.h (struct expr_builder): Rename from "parser_state".
	(parser_state): New class.
	* parse.c (expr_builder): Rename.
	(expr_builder::release): Rename.
	(write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym)
	(write_exp_elt_msym, write_exp_elt_block, write_exp_elt_objfile)
	(write_exp_elt_longcst, write_exp_elt_floatcst)
	(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)
	(insert_type_address_space, increase_expout_size): Replace
	"parser_state" with "expr_builder".
	* dtrace-probe.c: Replace "parser_state" with "expr_builder".
	* amd64-linux-tdep.c (amd64_dtrace_parse_probe_argument): Replace
	"parser_state" with "expr_builder".
2019-04-04 19:55:10 -06:00
Tom Tromey 73923d7eed Turn parse_language into a method
This changes parse_language into a method of parser_state.  This patch
was written by a script.

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

	* rust-exp.y: Replace "parse_language" with method call.
	* p-exp.y:
	(yylex): Replace "parse_language" with method call.
	* m2-exp.y:
	(yylex): Replace "parse_language" with method call.
	* go-exp.y (classify_name): Replace "parse_language" with method
	call.
	* f-exp.y (yylex): Replace "parse_language" with method call.
	* d-exp.y (lex_one_token): Replace "parse_language" with method
	call.
	* c-exp.y:
	(lex_one_token, classify_name, yylex): Replace "parse_language"
	with method call.
	* ada-exp.y (find_primitive_type, type_char)
	(type_system_address): Replace "parse_language" with method call.
2019-04-04 19:55:10 -06:00
Tom Tromey fa9f5be683 Turn parse_gdbarch into a method
This changes parse_gdbarch into a method of parser_state.  This patch
was written by a script.

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

	* rust-exp.y: Replace "parse_gdbarch" with method call.
	* parse.c (write_dollar_variable, insert_type_address_space):
	Replace "parse_gdbarch" with method call.
	* p-exp.y (parse_type, yylex): Replace "parse_gdbarch" with method
	call.
	* objc-lang.c (end_msglist): Replace "parse_gdbarch" with method
	call.
	* m2-exp.y (parse_type, parse_m2_type, yylex): Replace
	"parse_gdbarch" with method call.
	* go-exp.y (parse_type, classify_name): Replace "parse_gdbarch"
	with method call.
	* f-exp.y (parse_type, parse_f_type, yylex): Replace
	"parse_gdbarch" with method call.
	* d-exp.y (parse_type, parse_d_type, lex_one_token): Replace
	"parse_gdbarch" with method call.
	* c-exp.y (parse_type, parse_number, classify_name): Replace
	"parse_gdbarch" with method call.
	* ada-lex.l: Replace "parse_gdbarch" with method call.
	* ada-exp.y (parse_type, find_primitive_type, type_char)
	(type_system_address): Replace "parse_gdbarch" with method call.
2019-04-04 19:55:10 -06:00
Tom Tromey 1201a264c8 Remove parser_state "initial_size" parameter
All the real (not test) uses of parser_state pass 10 as the
"initial_size" parameter, and it seems to me that there's no real
reason to require callers to set this.  This patch removes this
parameter.

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

	* dtrace-probe.c (dtrace_probe::build_arg_exprs): Update.
	* stap-probe.c (stap_parse_argument): Update.
	* stap-probe.h (struct stap_parse_info) <stap_parse_info>: Remove
	initial_size parameter.
	* rust-exp.y (rust_lex_tests): Update.
	* parse.c (parser_state): Update.
	(parse_exp_in_context): Update.
	* parser-defs.h (struct parser_state) <parser_state>: Remove
	"initial_size" parameter.
2019-04-04 19:55:10 -06:00
Tom Tromey e3980ce2a9 Make increase_expout_size static
increase_expout_size is only called from parse.c, and probably only
should be.  This makes it "static".  Tested by rebuilding.

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

	* parser-defs.h (increase_expout_size): Don't declare.
	* parse.c (increase_expout_size): Now static.
2019-04-04 19:55:10 -06:00
Thomas Schwinge e9f8e3f109 [GDB, Hurd] Fix build; 'target_waitstatus_to_string' call
Recent commit c29705b71a removed an incomplete
local implementation in favor of 'target_waitstatus_to_string' (thanks!), but
introduced a small typing error:

    In file included from [...]/gdb/gnu-nat.c:24:0:
    [...]/gdb/gnu-nat.c: In member function 'virtual ptid_t gnu_nat_target::wait(ptid_t, target_waitstatus*, int)':
    [...]/gdb/gnu-nat.c:1652:43: error: cannot convert 'target_waitstatus**' to 'const target_waitstatus*' for argument '1' to 'std::__cxx11::string target_waitstatus_to_string(const target_waitstatus*)'
           target_waitstatus_to_string (&status).c_str ());
                                               ^
    [...]/gdb/gnu-nat.h:119:32: note: in definition of macro 'debug'
            __FILE__ , __LINE__ , ##args); } while (0)
                                    ^~~~
    [...]/gdb/gnu-nat.c:1650:3: note: in expansion of macro 'inf_debug'
       inf_debug (inf, "returning ptid = %s, %s",
       ^~~~~~~~~

	gdb/
	* gnu-nat.c (gnu_nat_target::wait): Fix
	target_waitstatus_to_string call.
2019-04-04 11:20:12 +02:00
Andrew Burgess d7df654955 gdb/fortran: Handle internal function calls
If an convenience function is defined in python (or guile), then
currently this will not work in Fortran, instead the user is given
this message:

  (gdb) set language fortran
  (gdb) p $myfunc (3)
  Cannot perform substring on this type

Compare this to C:

  (gdb) set language c
  (gdb) p $myfunc (3)
  $1 = 1

After this patch we see the same behaviour in both C and Fortran.
I've extended the test to check that all languages can call the
convenience functions - only Fortran was broken.

When calling convenience functions in Fortran we don't need to perform
the same value preparation (passing by pointer) that we would for
calling a native function - passing the real value is fine.

gdb/ChangeLog:

	* eval.c (evaluate_subexp_standard): Handle internal functions
	during Fortran function call handling.

gdb/testsuite/ChangeLog:

	* gdb.python/py-function.exp: Check calling helper function from
	all languages.
	* lib/gdb.exp (gdb_supported_languages): New proc.
2019-04-01 21:41:51 +01:00
Andrew Burgess 8bdc16587e gdb: Add $_cimag and $_creal internal functions
Add two new internal functions $_cimag and $_creal that extract the
imaginary and real parts of a complex value.

These internal functions can take a complex value of any type 'float
complex', 'double complex', or 'long double complex' and return a
suitable floating point value 'float', 'double', or 'long double'.
So we can now do this:

    (gdb) p z1
    $1 = 1.5 + 4.5 * I
    (gdb) p $_cimag (z1)
    $4 = 4.5
    (gdb) p $_creal (z1)
    $4 = 1.5

The components of a complex value are not strictly named types in
DWARF, as the complex type is itself the base type.  However, once we
are able to extract the components it makes sense to be able to ask
what the type of these components is and get a sensible answer back,
rather than the error we would currently get.  Currently GDB says:

    (gdb) ptype z1
    type = complex double
    (gdb) p $_cimag (z1)
    $4 = 4.5
    (gdb) ptype $
    type = <invalid type code 9>

With the changes in dwarf2read.c, GDB now says:

    (gdb) ptype z1
    type = complex double
    (gdb) p $_cimag (z1)
    $4 = 4.5
    (gdb) ptype $
    type = double

Which seems to make more sense.

gdb/ChangeLog:

	* NEWS: Mention new internal functions.
	* dwarf2read.c (dwarf2_init_complex_target_type): New function.
	(read_base_type): Use dwarf2_init_complex_target_type.
	* value.c (creal_internal_fn): New function.
	(cimag_internal_fn): New function.
	(_initialize_values): Register new internal functions.

gdb/doc/ChangeLog:

	* gdb.texinfo (Convenience Funs): Document '$_creal' and
	'$_cimag'.

gdb/testsuite/ChangeLog:

	* gdb.base/complex-parts.c: New file.
	* gdb.base/complex-parts.exp: New file.
2019-04-01 21:41:49 +01:00
Philippe Waroquiers c29705b71a Fix internal error and improve 'set debug infrun 1'/target wait kind trace
The test  gdb.threads/watchthreads-reorder.exp verifies that the
'set debug infrun 1' debug output does not crash GDB.

Under high load, the test can still cause a GDB internal error (see details
below).

This patch fixes this crash, and improves/factorises some wait kind traces.

Tested on debian/amd64 + run one test with 'set debug infrun 1'.

Changes compared to the first version:
  * Handles the suggestions of Kevin to trace the relevant elements
    of the wait status (this is done by calling target_waitstatus_to_string).
  * Some other changes to factorise wait status tracing.

Note that using target_waitstatus_to_string instead of the 'locally printed'
status kind strings means that debug trace that was using strings such as:
   "EXITED" or "TARGET_WAITKIND_EXITED"
will now use what is printed by target_waitstatus_to_string e.g.
   "exited".

gdb/ChangeLog
2019-04-01  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* infrun.c (stop_all_threads): If debug_infrun, always
	trace the wait status after wait_one, using
	target_waitstatus_to_string and target_pid_to_str.
	(handle_inferior_event): Replace various trace of
	wait status kind by a single trace.
	* gdb/gnu-nat.c (gnu_nat_target::wait): Replace local
	wait status kind image by target_waitstatus_to_string.
	* target/waitstatus.c (target_waitstatus_to_string): Fix
	obsolete comment.

  (top-gdb) bt
  #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
  #1  0x00007f3d54a0642a in __GI_abort () at abort.c:89
  #2  0x0000555c24c60e66 in dump_core () at ../../fixleaks/gdb/utils.c:201
  #3  0x0000555c24c63d49 in internal_vproblem(internal_problem *, const char *, int, const char *, typedef __va_list_tag __va_list_tag *) (problem=problem@entry=0x555c25338d40 <internal_error_problem>, file=<optimized out>, line=287,
      fmt=<optimized out>, ap=<optimized out>) at ../../fixleaks/gdb/utils.c:411
  #4  0x0000555c24c63eab in internal_verror (file=<optimized out>, line=<optimized out>, fmt=<optimized out>,
      ap=<optimized out>) at ../../fixleaks/gdb/utils.c:436
  #5  0x0000555c249e8c22 in internal_error (file=file@entry=0x555c24e0f2ad "../../fixleaks/gdb/inferior.c",
      line=line@entry=287, fmt=<optimized out>) at ../../fixleaks/gdb/common/errors.c:55
  #6  0x0000555c247d3f5c in find_inferior_pid (pid=<optimized out>) at ../../fixleaks/gdb/inferior.c:287
  #7  0x0000555c24ad2248 in find_inferior_pid (pid=<optimized out>) at ../../fixleaks/gdb/inferior.c:302
  #8  find_inferior_ptid (ptid=...) at ../../fixleaks/gdb/inferior.c:301
  #9  0x0000555c24c35f25 in find_thread_ptid (ptid=...) at ../../fixleaks/gdb/thread.c:522
  #10 0x0000555c24b0ab4d in thread_db_target::pid_to_str[abi:cxx11](ptid_t) (
      this=0x555c2532e3e0 <the_thread_db_target>, ptid=...) at ../../fixleaks/gdb/linux-thread-db.c:1637
  #11 0x0000555c24c2f420 in target_pid_to_str[abi:cxx11](ptid_t) (ptid=...) at ../../fixleaks/gdb/target.c:2083
  #12 0x0000555c24ad9cab in stop_all_threads () at ../../fixleaks/gdb/infrun.c:4373
  #13 0x0000555c24ada00f in stop_waiting (ecs=<optimized out>) at ../../fixleaks/gdb/infrun.c:7464
  #14 0x0000555c24adc401 in process_event_stop_test (ecs=ecs@entry=0x7ffc9402d9d0) at ../../fixleaks/gdb/infrun.c:6181
  ...
  (top-gdb) fr 12
  #12 0x0000555c24ad9cab in stop_all_threads () at ../../fixleaks/gdb/infrun.c:4373
  (top-gdb) p event_ptid
  $5 = {m_pid = 25419, m_lwp = 25427, m_tid = 0}
  (top-gdb) p ptid
  $6 = {m_pid = 0, m_lwp = 0, m_tid = 0}
  (top-gdb) p ws
  $7 = {kind = TARGET_WAITKIND_THREAD_EXITED, value = {integer = 0, sig = GDB_SIGNAL_0, related_pid = {m_pid = 0,
        m_lwp = 0, m_tid = 0}, execd_pathname = 0x0, syscall_number = 0}}
  (top-gdb)

The gdb.log corresponding to the above crash is:
  (gdb) PASS: gdb.threads/watchthreads-reorder.exp: reorder1: set debug infrun 1
  continue
  Continuing.
  infrun: clear_proceed_status_thread (Thread 0x7ffff7fcfb40 (LWP 25419))
  infrun: clear_proceed_status_thread (Thread 0x7ffff7310700 (LWP 25427))
  infrun: clear_proceed_status_thread (Thread 0x7ffff6b0f700 (LWP 25428))
  infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
  infrun: proceed: resuming Thread 0x7ffff7fcfb40 (LWP 25419)
  infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 0x7ffff7fcfb40 (LWP 25419)] at 0x7ffff7344317
  infrun: infrun_async(1)
  infrun: prepare_to_wait
  infrun: proceed: resuming Thread 0x7ffff7310700 (LWP 25427)
  infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 0x7ffff7310700 (LWP 25427)] at 0x5555555553d7
  infrun: prepare_to_wait
  infrun: proceed: resuming Thread 0x7ffff6b0f700 (LWP 25428)
  infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 0x7ffff6b0f700 (LWP 25428)] at 0x5555555554c8
  infrun: prepare_to_wait
  infrun: target_wait (-1.0.0, status) =
  infrun:   -1.0.0 [process -1],
  infrun:   status->kind = ignore
  infrun: TARGET_WAITKIND_IGNORE
  infrun: prepare_to_wait
  Joining the threads.
  [Thread 0x7ffff6b0f700 (LWP 25428) exited]
  infrun: target_wait (-1.0.0, status) =
  infrun:   -1.0.0 [process -1],
  infrun:   status->kind = ignore
  infrun: TARGET_WAITKIND_IGNORE
  infrun: prepare_to_wait
  infrun: target_wait (-1.0.0, status) =
  infrun:   25419.25419.0 [Thread 0x7ffff7fcfb40 (LWP 25419)],
  infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
  infrun: TARGET_WAITKIND_STOPPED
  infrun: stop_pc = 0x555555555e50
  infrun: context switch
  infrun: Switching context from Thread 0x7ffff6b0f700 (LWP 25428) to Thread 0x7ffff7fcfb40 (LWP 25419)
  infrun: BPSTAT_WHAT_STOP_NOISY
  infrun: stop_waiting
  infrun: stop_all_threads
  infrun: stop_all_threads, pass=0, iterations=0
  infrun:   Thread 0x7ffff7fcfb40 (LWP 25419) not executing
  infrun:   Thread 0x7ffff7310700 (LWP 25427) executing, need stop
  [Thread 0x7ffff7310700 (LWP 25427) exited]
  infrun: target_wait (-1.0.0, status) =
  infrun:   25419.25427.0 [LWP 25427],
  infrun:   status->kind = thread exited, status = 0
  infrun: infrun_async(0)
  ../../fixleaks/gdb/inferior.c:287: internal-error: inferior* find_inferior_pid(int): Assertion `pid != 0' failed.
  A problem internal to GDB has been detected,
  further debugging may prove unreliable.
  Quit this debugging session? (y or n) FAIL: gdb.threads/watchthreads-reorder.exp: reorder1: continue to breakpoint: break-at-exit (GDB internal error)
  Resyncing due to internal error.
  n
  infrun: infrun_async(1)

  This is a bug, please report it.  For instructions, see:
  <http://www.gnu.org/software/gdb/bugs/>.

  infrun: infrun_async(0)
  ../../fixleaks/gdb/inferior.c:287: internal-error: inferior* find_inferior_pid(int): Assertion `pid != 0' failed.
  A problem internal to GDB has been detected,
  further debugging may prove unreliable.
  Create a core file of GDB? (y or n) y
2019-04-01 20:51:59 +02:00
Tom Tromey 05caa1d236 Handle DW_AT_ranges when reading partial symtabs
add_partial_subprogram does not handle DW_AT_ranges, while the full
symtab reader does.  This can lead to discrepancies where a function
is not put into a partial symtab, and so is not available to "break"
and the like -- but is available if the full symtab has somehow been
read.

This patch fixes the bug by arranging to read DW_AT_ranges when
reading partial DIEs.

This is PR symtab/23331.

The new test case is derived from dw2-ranges-func.exp, which is why I
kept the copyright dates.

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

	PR symtab/23331:
	* dwarf2read.c (partial_die_info::read): Handle DW_AT_ranges.

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

	PR symtab/23331:
	* gdb.dwarf2/dw2-ranges-main.c: New file.
	* gdb.dwarf2/dw2-ranges-psym.c: New file.
	* gdb.dwarf2/dw2-ranges-psym.exp: New file.
2019-04-01 10:36:58 -06:00
Sergio Durigan Junior 9d1447e09d Destroy allocated values when exiting GDB
When the user exits GDB, we might still have some allocated values in
the chain, which, in specific scenarios, can cause problems when GDB
attempts to destroy them in "quit_force".  For example, see the bug
reported at:

  https://bugzilla.redhat.com/show_bug.cgi?id=1690120

And the thread starting at:

  https://sourceware.org/ml/gdb-patches/2019-03/msg00475.html
  Message-ID: <87r2azkhmq.fsf@redhat.com>

In order to avoid that, and to be more aware of our allocated
resources, this commit implements a new function "finalize_values" and
calls it from inside "quit_force".

Tested by the BuildBot.

2019-04-01  Sergio Durigan Junior  <sergiodj@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	* top.c (quit_force): Call 'finalize_values'.
	* value.c (finalize_values): New function.
	* value.h (finalize_values): Declare.
2019-04-01 10:58:12 -04:00
Marco Barisione 52093e1b93 Add gdb.Value.format_string ()
The str () function, called on a gdb.Value instance, produces a string
representation similar to what can be achieved with the print command,
but it doesn't allow to specify additional formatting settings, for
instance disabling pretty printers.

This patch introduces a new format_string () method to gdb.Value which
allows specifying more formatting options, thus giving access to more
features provided by the internal C function common_val_print ().

gdb/ChangeLog:

2019-04-01  Marco Barisione  <mbarisione@undo.io>

	Add gdb.Value.format_string ().
	* python/py-value.c (copy_py_bool_obj):
	(valpy_format_string): Add gdb.Value.format_string ().
	* NEWS: Document the addition of gdb.Value.format_string ().

gdb/doc/ChangeLog:

2019-04-01  Marco Barisione  <mbarisione@undo.io>

	* python.texi (Values From Inferior): Document
	gdb.Value.format_string ().

gdb/testsuite/ChangeLog:

2019-04-01  Marco Barisione  <mbarisione@undo.io>

	Test gdb.Value.format_string ().
	* gdb.python/py-format-string.exp: New test.
	* gdb.python/py-format-string.c: New file.
	* gdb.python/py-format-string.py: New file.
2019-04-01 10:00:04 +02:00
Marco Barisione 8828efdb24 Add myself to gdb/MAINTAINERS
gdb/ChangeLog:

2019-04-01  Marco Barisione  <mbarisione@undo.io>

	* MAINTAINERS (Write After Approval): Add Marco Barisione.
2019-04-01 09:44:51 +02:00
Eli Zaretskii 7734102d6d Introduce new convenience variables $_gdb_major and $_gdb_minor
gdb/ChangeLog:
2019-03-30  Eli Zaretskii  <eliz@gnu.org>

	* NEWS: Announce $_gdb_major and $_gdb_minor.

	* top.c (init_gdb_version_vars): New function.
	(gdb_init): Call init_gdb_version_vars.

gdb/testsuite/ChangeLog:
2019-03-30  Simon Marchi <simark@simark.ca>

	* gdb.base/default.exp: Add values for $_gdb_major and
	$_gdb_minor.

gdb/doc/ChangeLog:
2019-03-30  Eli Zaretskii  <eliz@gnu.org>

	* gdb.texinfo (Convenience Vars): Document $_gdb_major and
	$_gdb_minor.
2019-03-30 12:58:33 +03:00
Tom Tromey 188e1fa9ac Add usage for commands in printcmd.c
I noticed that the help for "info addr" did not include a "usage"
line; and when adding it I went through and fixed a few minor issues
in printcmd.c:

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

Regression tested on x86-64 Fedora 29.

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

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

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

	* gdb.base/help.exp: Tighten apropos regexp.
2019-03-29 14:05:30 -06:00
Keith Seitz 2880242dd0 Allow really large fortran array bounds: fortran type/value printers
This is the fortran part of the patch, including tests, which
are essentially unchanged from Siddhesh's original 2012 submission:

  https://sourceware.org/ml/gdb-patches/2012-08/msg00562.html

There is, however, one large departure.  In the above thread,
Jan pointed out problems with GCC debuginfo for -m32 builds
(filed usptream as gcc/54934).  After investigating the issue,
I am dropping the hand-tweaked assembler source file to workaround
this case.

While I would normally do something to accommodate this, in
this case, given the ubiquity of 64-bit systems today (where
the tests pass) and the apparent lack of urgency on the compiler
side (by users), I don't think the additional complexity and
maintenance costs are worth it. It will be very routinely tested
on 64-bit systems. [For example, at Red Hat, we always
test -m64 and -m32 configurations for all GDB releases.]

gdb/ChangeLog:

	From Siddhesh Poyarekar:
	* f-lang.h (f77_get_upperbound): Return LONGEST.
	(f77_get_lowerbound): Likewise.
	* f-typeprint.c (f_type_print_varspec_suffix): Expand
	UPPER_BOUND and LOWER_BOUND to LONGEST.  Use plongest to format
	print them.
	(f_type_print_base): Expand UPPER_BOUND to LONGEST.  Use
	plongest to format print it.
	* f-valprint.c (f77_get_lowerbound): Return LONGEST.
	(f77_get_upperbound): Likewise.
	(f77_get_dynamic_length_of_aggregate): Expand UPPER_BOUND,
	LOWER_BOUND to LONGEST.
	(f77_create_arrayprint_offset_tbl): Likewise.

gdb/testsuite/ChangeLog:

	* gdb.fortran/array-bounds.exp: New file.
	* gdb.fortran/array-bounds.f90: New file.
2019-03-29 10:35:19 -07:00
Keith Seitz cc1defb1dc Allow really large fortran array bounds: TYPE_LENGTH to ULONGEST
This series is revisit of Siddhesh Poyarekar's patch from back in
2012. The last status on the patch is in the following gdb-patches
thread:

  https://sourceware.org/ml/gdb-patches/2012-08/msg00562.html

It appears that Tom approved the patch, but Jan had some issues
with a compiler error that made the test fail on -m32 test runs.
He wrote up a hand-tweaked .S file to deal with it. Siddesh said
he would update tests. Then nothing.

Siddesh and Jan have both moved on since.

The patch originally required a large precursor patch to work.
I have whittled this down to/rewritten the bare minimum, and this
first patch is the result, changing the type of TYPE_LENGTH
to ULONGEST from unsigned int.

The majority of the changes involve changing printf format
strings to use %s and pulongest instead of %d.

gdb/ChangeLog:

	* ada-lang.c (ada_template_to_fixed_record_type_1): Use
	%s/pulongest for TYPE_LENGTH instead of %d in format
	strings.
	* ada-typerint.c (ada_print_type): Likewise.
	* amd64-windows-tdep.c (amd64_windows_store_arg_in_reg): Likewise.
	* compile/compile-c-support.c (generate_register_struct): Likewise.
	* gdbtypes.c (recursive_dump_type): Likewise.
	* gdbtypes.h (struct type) <length>: Change type to ULONGEST.
	* m2-typeprint.c (m2_array):  Use %s/pulongest for TYPE_LENGTH
	instead of %d in format strings.
	* riscv-tdep.c (riscv_type_alignment): Cast second argument
	to std::min to ULONGEST.
	* symmisc.c (print_symbol): Use %s/pulongest for TYPE_LENGTH
	instead of %d in format strings.
	* tracepoint.c (info_scope_command): Likewise.
	* typeprint.c (print_offset_data::update)
	(print_offset_data::finish): Likewise.
	* xtensa-tdep.c (xtensa_store_return_value)
	(xtensa_push_dummy_call): Likewise.
2019-03-29 10:15:38 -07:00
Jon Turney e432ccf1cb Fix format specification in display_selector() (again)
DWORD type is not a long on 64-bit Cygwin, because that it is LP64.
Explicitly cast DWORD values to unsigned long and use an appropriate
format.

gdb/ChangeLog:

2019-03-28  Jon Turney  <jon.turney@dronecode.org.uk>

	* windows-nat.c (display_selector): Fixed format specifications
	for 64-bit Cygwin.
2019-03-28 17:10:45 -04:00
Philippe Waroquiers 077cad8ec1 Fix gdb.multi/multi-term-settings.exp blocking under high load/slow gdb
Similarly to multi-arch-exec.exp, increase the alarm timer to avoid
test blocking under high load or with a slow gdb.

2019-03-28  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* gdb.multi/multi-term-settings.c (main): Increase alarm timer.
2019-03-28 21:15:59 +01:00
Philippe Waroquiers 80047cfc27 Fix gdb.multi/multi-arch-exec.exp blocking under high load/slow gdb
When running multi-arch-exec.exp under valgrind, the test succeeds
when the machine is not loaded, but blocks when the machine is highly
loaded (e.g. when running the testsuite with valgrind with -j X
where X is one more than the nr of available cores).

The problem is that the hello program dies too early due to the alarm (30).

So, increase the alarm timer.
Note that this does not make the test take longer (it takes about
3.5 seconds on my system).  As I understand, the alarm is just there
to avoid hello staying there forever in case of another problem.

2019-03-28  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* gdb.multi/hello.c (main): Increase alarm timer.
2019-03-28 21:15:20 +01:00
Philippe Waroquiers 65d2b333a8 Fix GDB being suspended SIGTTOU when running gdb.multi/multi-arch-exec.exp
When running under valgrind, multi-arch-exec.exp blocks forever.
Some (painful) investigation shows this is due to valgrind slowing
down GDB, and GDB has to output some messages at a different time,
when GDB does not have the terminal for output.

To reproduce the problem, you need to slow down GDB.
It can be reproduced by:
cd gdb/testsuite/outputs/gdb.multi/multi-arch-exec/
../../../../gdb -ex 'set debug lin-lwp 1' -ex 'break all_started' -ex 'run' ./2-multi-arch-exec

The above stops at a breakpoint.  Do continue.
GDB is then suspended because of SIGTTOU.
The stacktrace that leads to the hanging GDB is:
(top-gdb) bt
    at ../../binutils-gdb/gdb/exceptions.c:130
....

Alternatively, the same happens when doing
strace -o s.out ../../../../gdb  -ex 'break all_started' -ex 'run' ./2-multi-arch-exec

And of course, valgrind is also sufficiently slowing down GDB to
reproduce this :).

Fix this by calling target_terminal::ours_for_output ();
at the beginning of follow_exec.

Note that all this terminal handling is not very clear to me:
  * Some code takes the terminal, and then takes care to give it back to the inferior
    if the terminal was belonging to the inferior.
    (e.g. annotate_breakpoints_invalid).
  * some code takes the terminal, but does not give it back
    (e.g. update_inserted_breakpoint_locations).
  * some code takes it, and unconditionally gives it back
    (e.g. handle_jit_event)
  * here and there, we also find
    gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
    before a (sometimes optional) call to ours_for_output.
    And such calls to ours_for_output is sometimes protected by:
       if (target_supports_terminal_ours ())
    (e.g. exceptions.c: print_flush).
    but most of the code calls it without checking if the target supports it.
  * some code is outputting some errors, but only takes the terminal
    after. E.g. infcmd.c: prepare_one_step

gdb/ChangeLog
2019-03-28  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* infrun.c (follow_exec): Call target_terminal::ours_for_output.
2019-03-28 21:14:14 +01:00
Sandra Loosemore f489207efd Fix stepping past unwritable kernel helper on nios2-linux-gnu.
This patch fixes a problem on nios2-linux-gnu with stepping past the
kernel helper __kuser_cmpxchg, which was exposed by the testcase
gdb.threads/watchpoint-fork.exp.  The kernel maps this function into
user space on an unwritable page.  In this testcase, the cmpxchg
helper is invoked indirectly from the setbuf call in the test program.
Since this target lacks hardware breakpoint/watchpoint support, GDB
tries to single-step through the program by setting software
breakpoints, and was just giving an error when it reached the function
on the unwritable page.

The solution here is to always step over the call instead of stepping
into it; cmpxchg is supposed to be an atomic operation so this
behavior seems reasonable.  The hook in nios2_get_next_pc is somewhat
generic, but at present cmpxchg is the only helper provided by the
Linux kernel that is invoked by an ordinary function call.  (Signal
return trampolines also go through the unwritable page but not by a
function call.)

Fixing this issue also revealed that the testcase needs a much larger
timeout factor when software single-stepping is used.  That has also
been fixed in this patch.

gdb/ChangeLog

2019-03-28  Sandra Loosemore  <sandra@codesourcery.com>

        * nios2-tdep.h (struct gdbarch_tdep): Add is_kernel_helper.
        * nios2-tdep.c (nios2_get_next_pc): Skip over kernel helpers.
        * nios2-linux-tdep.c (nios2_linux_is_kernel_helper): New.
        (nios2_linux_init_abi): Install it.

gdb/testsuite/ChangeLog

2019-03-28  Sandra Loosemore  <sandra@codesourcery.com>

        * gdb.threads/watchpoint-fork.exp (test): Use large timeout
        factor when no hardware watchpoint support.
2019-03-28 09:29:22 -07:00
Alan Hayward c92df149c2 Testsuite: set sysroot when using gdbserver
When testing using native-gdbserver and native-extended-gdbserver, the sysroot
is not set.  This results in a warning from GDB and files are sent via the
remote protocol, which can be slow.

On Ubuntu 18.04 (unlike most distros) the debug versions of the standard
libraries are included by default in /usr/lib/debug/.

These file reads are causing a complete native-gdbserver run on the AArch64
buildbot slave to timeout after 2.5 hours.  This is also causing the builds
to back up on the slave.

The solution is to ensure the sysroot is set to / for all local boards.

This drastically reduces the time of a test. For example, gdb.base/sigall.exp
drops from 23 seconds to 4 seconds.
A full native-gdbserver run on the AArch64 slave now takes 8 minutes.

gdb/testsuite/ChangeLog:

	* boards/local-board.exp: set sysroot to /.
2019-03-28 15:00:30 +00:00
Alan Hayward bffa1015cd AArch64: View the pseudo V registers as vectors
When SVE is enabled, the V registers become pseudo registers based
on the Z registers.  They should look the same as they do when
there is no SVE.

The existing code viewed them as single value registers. Switch
this to a vector.

gdb/ChangeLog:

	* aarch64-tdep.c (aarch64_vnv_type): Use vector types.
2019-03-28 12:27:30 +00:00
Alan Hayward fc96163a3e AArch64: 128bit views for SVE registers
SVE can view Z registers as 128bit values using .q prefix.

Add this view to the SVE feature.

gdb/ChangeLog:

	* features/aarch64-sve.c (create_feature_aarch64_sve): Add q view.
2019-03-28 12:14:09 +00:00
Alan Hayward 69f4c9cc03 gdbserver: Ensure AT_HWCAP2 is defined
When using older compilers, AT_HWCAP2 may not be be defined.
It is defined in elf/common.h, however including this in
gdbserver/linux-low.c causes conflicts.

Manually add the define if it does not exist.

gdb/gdbserver/ChangeLog:

	* linux-low.c (AT_HWCAP2): Add define if not already included.
2019-03-28 11:45:06 +00:00
Philippe Waroquiers 20dc7e9b05 Fix buffer overflow regression due to minsym malloc-ed instead of obstack-ed.
Valgrind detects the following error in a bunch of tests,
e.g. in gdb.base/foll-fork.exp.

==15155== VALGRIND_GDB_ERROR_BEGIN
==15155== Invalid read of size 8
==15155==    at 0x55BE04: minimal_symbol_upper_bound(bound_minimal_symbol) (minsyms.c:1504)
==15155==    by 0x3B2E9C: find_pc_partial_function(unsigned long, char const**, unsigned long*, unsigned long*, block const**) (blockframe.c:340)
==15155==    by 0x3B3135: find_function_entry_range_from_pc(unsigned long, char const**, unsigned long*, unsigned long*) (blockframe.c:385)
==15155==    by 0x4F5597: fill_in_stop_func(gdbarch*, execution_control_state*) [clone .part.16] (infrun.c:4124)
==15155==    by 0x4FBE01: fill_in_stop_func (infrun.c:7636)
==15155==    by 0x4FBE01: process_event_stop_test(execution_control_state*) (infrun.c:6279)
...
==15155==  Address 0x715bec8 is 0 bytes after a block of size 2,952 alloc'd
==15155==    at 0x4C2E2B3: realloc (vg_replace_malloc.c:836)
==15155==    by 0x405F2C: xrealloc (common-utils.c:62)
==15155==    by 0x55BA4E: xresizevec<minimal_symbol> (poison.h:170)
==15155==    by 0x55BA4E: minimal_symbol_reader::install() (minsyms.c:1399)
==15155==    by 0x4981C7: elf_read_minimal_symbols (elfread.c:1165)
...

This seems to be a regression created by:
    commit 042d75e42c
    Author:     Tom Tromey <tom@tromey.com>
    AuthorDate: Sat Mar 2 12:29:48 2019 -0700
    Commit:     Tom Tromey <tom@tromey.com>
    CommitDate: Fri Mar 15 16:02:10 2019 -0600

        Allocate minimal symbols with malloc

Before this commit, the array of 'struct minimal_symbol'
contained a last element that was a "null symbol".  The comment in
minimal_symbol_reader::install was:
      /* We also terminate the minimal symbol table with a "null symbol",
         which is *not* included in the size of the table.  This makes it
         easier to find the end of the table when we are handed a pointer
         to some symbol in the middle of it.  Zero out the fields in the
         "null symbol" allocated at the end of the array.  Note that the
         symbol count does *not* include this null symbol, which is why it
         is indexed by mcount and not mcount-1.  */

      memset (&msymbols[mcount], 0, sizeof (struct minimal_symbol));

However, minimal_symbol_upper_bound was still based on the assumption
that the array of minsym is terminated by a minsym with a null symbol:
it is looping with:
  for (i = 1; MSYMBOL_LINKAGE_NAME (msymbol + i) != NULL; i++)

Replace this NULL comparison by a logic that calculates how
many msymbol are following the msymbols from which we are starting from.

(Re-)tested on debian/amd64, natively and under valgrind.

gdb/ChangeLog
2019-03-24  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
	    Tom Tromey  <tromey@adacore.com>

	* minsyms.c (minimal_symbol_upper_bound): Fix buffer overflow.
2019-03-27 09:41:33 -06:00
Alan Hayward 933aebfae6 Testsuite: Ensure interrupt-daemon-attach doesn't run forever
Looking at the AArch64 buildbot, I noticed about two dozen old instances of
interrupt-daemon-attach taking up a full 100% cpu each.

If the test fails then the test binary relies on an alarm to ensure it dies
after 60 seconds.

As per the Linux man page for alarm:
  Alarms created by alarm() ... are not inherited by children created via fork.

Update the test to add an alarm in the child and also put a sleep in the
child loop so it does not constantly consume cpu.

Note I haven't managed to re-create why the test failed.  This fix will just
stop it hanging and consuming cpu when it does.

gdb/testsuite/ChangeLog:

	* gdb.base/interrupt-daemon-attach.c (main): Add alarm and sleep
	in child.
2019-03-27 11:51:15 +00:00
Joel Brobecker 7f5331a885 gdb-gdb.py.in: Fix error when printing range type
I noticed that trying to print the contents of a struct main_type
would fail when the type was a TYPE_CODE_RANGE:

    (gdb) p *type.main_type
    $1 = Python Exception <class 'gdb.error'> There is no member named low_undefined.:

And indeed, Python is right, fields "low_undefined" has been removed
from struct range_bounds back in ... 2014! It was done when we introduced
dynamic bounds handling. This patch fixes gdb-gdb.py.in according to
the new structure.

gdb/ChangeLog:

	* gdb-gdb.py.in (StructMainTypePrettyPrinter.bound_img): New method.
	(StructMainTypePrettyPrinter.bounds_img): Use new "bound_img"
	method to compute the bounds of range types. Also print "[evaluated]"
	if the bounds' values come from a dynamic evaluation.
2019-03-26 18:30:21 -04:00
Andrew Burgess 9f9aa85206 gdb: Make python display_hint None handling defined behaviour
The documentation say that the display_hint method must return a
string to serve as a display hint, and then goes on to list some
acceptable strings.

However, if we don't supply the display_hint method then we get a
default display style behaviour and there's currently no way (in the
python api) to force this default behaviour.

The guile api allows #f to be used in order to force the default
display style behaviour, and this is documented.

Currently, using None in the python api also forces the default
display behaviour.

This commit extends the documentation to make returning None from the
display_hint method an official mechanism by which the user can get
the default display style.

I've extended one of the existing tests to cover this case.

gdb/doc/ChangeLog:

	* python.texi (Pretty Printing API): Document use of None for the
	display_hint.

gdb/testsuite/ChangeLog:

	* gdb.python/py-prettyprint.c (struct container) <is_map_p>: New
	field.
	(make_container): Initialise new field.
	* gdb.python/py-prettyprint.exp: Add new tests.
	* gdb.python/py-prettyprint.py (class ContainerPrinter)
	<display_hint>: New method.
2019-03-26 18:25:10 +00:00
Andrew Burgess 3714a195e0 gdb/testsuite: Make test names unique in gdb.python/py-prettyprint.exp
This makes the test names unique in gdb.python/py-prettyprint.exp, it
also switches to use gdb_breakpoint and gdb_continue_to_breakpoint
more so that we avoid test names with the source line number in - this
is bad if the test source ever changes as the test names will then
change.

One final change is to switch from using gdb_py_test_silent_cmd to use
gdb_test_no_output, the former should be used for running python
commands and can catch any thrown exception.  However, in this case
the command being run is not a python command, its just a normal GDB
CLI command that produces no output, so lets use the appropriate
wrapper function.

gdb/testsuite/ChangeLog:

	* gdb.python/py-prettyprint.exp: Use gdb_breakpoint and
	gdb_continue_to_breakpoint more throughout this test.
	(run_lang_tests) Supply unique test names, and use
	gdb_test_no_output.
2019-03-26 18:23:50 +00:00
Andrew Burgess 18c77628b1 gdb: Avoid trailing whitespace when pretty printing
While writing a new test for 'set print pretty on' I spotted that GDB
will sometimes add a trailing whitespace character when pretty
printing.  This commit removes the trailing whitespace and updates the
expected results in one tests where this was an issue.

I've added an extra test for 'set print pretty on' as it doesn't seem
to have much testing.

gdb/ChangeLog:

	* cp-valprint.c (cp_print_value_fields): Don't print trailing
	whitespace when pretty printing is on.

gdb/testsuite/ChangeLog:

	* gdb.base/finish-pretty.exp: Update expected results.
	* gdb.base/pretty-print.c: New file.
	* gdb.base/pretty-print.exp: New file.
2019-03-26 18:23:49 +00:00
Alan Hayward 53c973f200 Fix Powerpc build
gdb/ChangeLog:

        * ppc-linux-nat.c: Add include.
2019-03-26 17:18:27 +00:00
Alan Hayward d851aa7170 Add AArch64 Pointer Authentication to the NEWS file
gdb/ChangeLog:

        * NEWS: Mention AArch64 Pointer Authentication.
2019-03-26 17:09:00 +00:00
Alan Hayward 974c89e088 gdbserver: Add linux_get_hwcap
In gdbserver, Tidy up calls to read HWCAP (and HWCAP2) by adding common
functions, removing the Arm, AArch64, PPC and S390 specific versions.

No functionality differences.

gdb/gdbserver/ChangeLog:

	* linux-aarch64-low.c (aarch64_get_hwcap): Remove function.
	(aarch64_arch_setup): Call linux_get_hwcap.
	* linux-arm-low.c (arm_get_hwcap): Remove function.
	(arm_read_description): Call linux_get_hwcap.
	* linux-low.c (linux_get_auxv): New function.
	(linux_get_hwcap): Likewise.
	(linux_get_hwcap2): Likewise.
	* linux-low.h (linux_get_hwcap): New declaration.
	(linux_get_hwcap2): Likewise.
	* linux-ppc-low.c (ppc_get_auxv): Remove function.
	(ppc_arch_setup): Call linux_get_hwcap.
	* linux-s390-low.c (s390_get_hwcap): Remove function.
	(s390_arch_setup): Call linux_get_hwcap.
2019-03-26 16:27:43 +00:00