Commit Graph

43171 Commits

Author SHA1 Message Date
Frank Ch. Eigler 404f29021a [PR build/24886] disable glibc mcheck support
This patch drops gdb's configury support for glibc's mcheck function.
It has been observed to cause false abort()s, because it is
thread-unsafe yet interposes every malloc/free operation.  So if any
library transitively used by gdb also uses threads, then these
functions can easily corrupt their own checking data.  These days, gcc
ASAN and valgrind provide high quality checking, and mcheck is
apparently itself being slowly deprecated.

So, let's stop linking to it.  Attached patch drops the
autoconf/Makefile machinery for both gdb and gdbserver.  No
testsuite-visible impact.  IMHO not worth mentioning in NEWS.

See also: https://sourceware.org/bugzilla/show_bug.cgi?id=9939

gdb/ChangeLog

        PR build/24886
        * configure.ac: Drop enable-libmcheck support.
        * configure, config.in: Rebuild.
        * libmcheck.m4: Remove.
        * acinclude.m4: Don't include it.
        * Makefile.in: Don't distribute it.
        * top.c (print_gdb_configuration): Don't mention it.

gdb/gdbserver/ChangeLog

        PR build/24886
        * configure.ac: Drop enable-libmcheck support.
        * configure, config.in: Rebuild.
        * acinclude.m4: Don't include it.
2019-08-06 15:09:53 -04:00
Tom Tromey 046bebe1c0 Add more styling to "disassemble"
This adds more styling to the disassemble command.  In particular,
addresses and function names in the disassembly are now styled.

This required fixing a small latent bug in set_output_style.  This
function always passed NULL to emit_style_escape; but when writing to
a file other than gdb_stdout, it should emit the style escape
directly.  (FWIW this is another argument for better integrating the
pager with ui_file and getting rid of this entire layer.)

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

	* utils.c (set_output_style): Sometimes pass stream to
	emit_style_escape.
	* ui-out.h (class ui_out) <can_emit_style_escape>: Declare.
	* record-btrace.c (btrace_insn_history): Update.
	* mi/mi-out.h (class mi_ui_out) <can_emit_style_escape>: New
	method.
	* disasm.h (gdb_pretty_print_disassembler): Add uiout parameter.
	Update initializers.
	<m_uiout>: New field.
	<m_di>: Move lower.
	* disasm.c (gdb_pretty_print_disassembler::pretty_print_insn):
	Remove "uiout" parameter.
	(dump_insns): Update.
	* cli-out.h (class cli_ui_out) <can_emit_style_escape>: Declare.
	* cli-out.c (cli_ui_out::can_emit_style_escape): New method.

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

	* gdb.base/style.exp: Add disassemble test.
	* gdb.base/style.c (some_called_function): New function.
	(main): Use it.
2019-08-06 11:37:51 -06:00
Christian Biesinger ddbcedf5de Replace int with enum block_enum where appropriate.
For better readability and type safety.

gdb/ChangeLog:

2019-08-06  Christian Biesinger  <cbiesinger@google.com>

	* symtab.c (symbol_cache_lookup): Change int to enum block_enum.
	(error_in_psymtab_expansion): Likewise.
	(lookup_symbol_via_quick_fns): Likewise.
	(basic_lookup_transparent_type_quick): Likewise.
	(basic_lookup_transparent_type_1): Likewise.
2019-08-06 11:50:52 -05:00
Tom Tromey b08b16c839 Clean up source file error reporting
print_source_lines_base reopens the source file every time that a
source line is to be printed.  However, there's no need to do this so
frequently -- it's enough to do it when switching source files, and
otherwise rely on the cache.

The code seems to try to avoid these multiple opens; at a guess I'd
say something just got confused along the way.

This patch fixes the problem by reorganizing the code both to make it
more clear, and to ensure that reopens only occur when the "last
source visited" changes.

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

	* source.c (last_source_error): Now bool.
	(print_source_lines_base): Make "noprint" bool.  Only open
	source file when last_source_visited changes.
2019-08-06 08:04:33 -06:00
Tom Tromey cb44333d99 Add file offsets to the source cache
Currently, gdb stores the number of lines and an array of file offsets
for the start of each line in struct symtab.  This patch moves this
information to the source cache.  This has two benefits.

First, it allows gdb to read a source file less frequently.
Currently, a source file may be read multiple times: once when
computing the file offsets, once when highlighting, and then pieces
may be read again while printing source lines.  With this change, the
file is read once for its source text and file offsets; and then
perhaps read again if it is evicted from the cache.

Second, if multiple symtabs cover the same source file, then this will
share the file offsets between them.  I'm not sure whether this
happens in practice.

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

	* annotate.c (annotate_source_line): Use g_source_cache.
	* source-cache.c (source_cache::get_plain_source_lines): Change
	parameters.  Populate m_offset_cache.
	(source_cache::ensure): New method.
	(source_cache::get_line_charpos): New method.
	(extract_lines): Move lower.  Change parameters.
	(source_cache::get_source_lines): Move lower.
	* source-cache.h (class source_cache): Update comment.
	<get_line_charpos>: New method.
	<get_source_lines>: Update comment.
	<clear>: Clear m_offset_cache.
	<get_plain_source_lines>: Change parameters.
	<ensure>: New method
	<m_offset_cache>: New member.
	* source.c (forget_cached_source_info_for_objfile): Update.
	(info_source_command): Use g_source_cache.
	(find_source_lines, open_source_file_with_line_charpos): Remove.
	(print_source_lines_base, search_command_helper): Use g_source_cache.
	* source.h (open_source_file_with_line_charpos): Don't declare.
	* symtab.h (struct symtab) <nlines, line_charpos>: Remove.
	* tui/tui-source.c (tui_source_window::do_scroll_vertical):
	Use g_source_cache.
2019-08-06 08:04:33 -06:00
Tom Tromey 872dceaaff Save plain text in the source cache
Currently the source cache will only store highlighted text.  However,
there's no reason it could not also store plain text, when styling is
turned off.

This patch makes this change.  This also simplifies the source cache
code somewhat.

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

	* source-cache.c (source_cache::get_plain_source_lines):
	Remove "first_line" and "last_line" parameters.
	(source_cache::get_source_lines): Cache plain text.
	* source-cache.h (class source_cache)
	<get_plain_source_lines>: Update.
2019-08-06 08:04:33 -06:00
Tom Tromey 269249d940 Fix latent bug in source cache
The source cache was not returning the final \n of the requested range
of lines.  This caused regressions with later patches in this series,
so this patch pre-emptively fixes the bug.

This adds a self-test of "extract_lines" to the source cache code.  To
make it simpler to test, I changed extract_lines to be a static
function, and changed it's API a bit.

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

	* source-cache.c (extract_lines): No longer a method.
	Changed type of parameter.  Include final newline.
	(selftests::extract_lines_test): New function.
	(_initialize_source_cache): Likewise.
	* source-cache.h (class source_cache)
	<extract_lines>: Don't declare.
2019-08-06 08:04:33 -06:00
Tom Tromey c0e8dcd871 Change breakpoint::filter to be a unique_xmalloc_ptr
This changes breakpoint::filter to be a unique_xmalloc_ptr, removing
an explicit xfree, as well as a use of a "release" method.

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

	* breakpoint.c (init_breakpoint_sal): Update.
	(breakpoint): Update.
	* breakpoint.h (struct breakpoint) <filter>: Now a
	unique_xmalloc_ptr.
2019-08-06 08:01:21 -06:00
Christian Biesinger 0b27c27d0d Add block['var'] accessor
Currently we support iteration on blocks; this patch extends that to make
subscript access work as well.

gdb/ChangeLog:

2019-08-05  Christian Biesinger  <cbiesinger@google.com>

	* NEWS: Mention dictionary access on blocks.
	* python/py-block.c (blpy_getitem): New function.
	(block_object_as_mapping): New struct.
	(block_object_type): Use new struct for tp_as_mapping field.

gdb/doc/ChangeLog:

2019-08-05  Christian Biesinger  <cbiesinger@google.com>

	* python.texi (Blocks In Python): Document dictionary access on blocks.

gdb/testsuite/ChangeLog:

2019-08-05  Christian Biesinger  <cbiesinger@google.com>

	* gdb.python/py-block.exp: Test dictionary access on blocks.
2019-08-05 13:06:18 -05:00
Christian Biesinger 4ee94178af Add a comment briefly explaining partial symbols
Based on an explanation by tromey on IRC.

gdb/ChangeLog:

2019-08-05  Christian Biesinger  <cbiesinger@google.com>

	* objfiles.h (objfile): Add a comment describing partial symbols.
2019-08-05 10:35:35 -05:00
Simon Marchi 580f1034d1 Increase timeout in gdb.mi/list-thread-groups-available.exp
Running

    make check-read1 TESTS="gdb.mi/list-thread-groups-available.exp"

on my machine results in timeout failures.  Running it while having
`tail -F testsuite/gdb.log` on the side shows that the test is never
really blocked, it is just slow at consuming the large output generated
by `-list-thread-groups --available` (which lists all the processes on
the system).

If I increase the timeout to a large value, the test passes in ~30
seconds (compared to under 1 second normally).

Increase the timeout for the particular mi_gdb_test that is long to
execute under read1.  The new timeout value is a bit arbitrary.  The
default timeout is 10 seconds, so I set the new timeout to be
"old-timeout * 10", so 100 seconds in the typical case.

gdb/testsuite/ChangeLog:

	PR gdb/24863
	* gdb.mi/list-thread-groups-available.exp: Increase timeout for
	-list-thread-groups --available test when running under
	check-read1.
2019-08-05 10:21:48 -04:00
Tom de Vries d86bd7cba1 [gdb/testsuite] Run read1 timeout tests with with_read1_timeout_factor
When running tests with check-read1, we run into some timeouts where the tests
are not easy to rewrite using gdb_test_sequence:
...
FAIL: gdb.base/help.exp: help data (timeout)
FAIL: gdb.base/help.exp: help files (timeout)
FAIL: gdb.base/help.exp: help internals (timeout)
FAIL: gdb.base/help.exp: help user-defined (timeout)
FAIL: gdb.base/help.exp: help breakpoint "b" abbreviation (timeout)
FAIL: gdb.base/help.exp: help breakpoint "br" abbreviation (timeout)
FAIL: gdb.base/help.exp: help breakpoint "bre" abbreviation (timeout)
FAIL: gdb.base/info-macros.exp: info macros 2 (timeout)
FAIL: gdb.base/info-macros.exp: next (timeout)
FAIL: gdb.base/info-macros.exp: info macros 3 (timeout)
FAIL: gdb.base/info-macros.exp: next (timeout)
FAIL: gdb.base/info-macros.exp: next (timeout)
FAIL: gdb.base/info-macros.exp: info macros (timeout)
FAIL: gdb.base/info-macros.exp: next (timeout)
FAIL: gdb.base/info-macros.exp: next (timeout)
FAIL: gdb.base/info-macros.exp: info macros 7 (timeout)
FAIL: gdb.cp/nested-types.exp: ptype S10 (limit = -1) // parse failed (timeout)
FAIL: gdb.cp/nested-types.exp: set print type nested-type-limit 1 (timeout)
...

Fix these by increasing the timeout by a factor 10.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-08-05  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24863
	* lib/gdb.exp (with_read1_timeout_factor): New proc.
	* gdb.base/help.exp: Use with_read1_timeout_factor.
	* gdb.base/info-macros.exp: Same.
	* gdb.cp/nested-types.exp: Same.
2019-08-05 15:41:04 +02:00
Tom Tromey 8abfcabcb4 Use _() in calls to build_help
Currently some code in gdb uses build_help with N_(), like:

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

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

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

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

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

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

	* compile/compile.c (_initialize_compile): Use _(), not N_().
	* thread.c (_initialize_thread): Use _(), not N_().
	* stack.c (_initialize_stack): Use _(), not N_().
	* printcmd.c (_initialize_printcmd): Use _(), not N_().
2019-08-05 07:36:28 -06:00
Tom de Vries a80cf5d88e [gdb/testsuite] Fail in gdb_compile if pie results in non-PIE executable
When running gdb.base/break-idempotent.exp with
--target_board=unix/-fno-PIE/-no-pie, we get:
...
nr of expected passes            140
...

The test-case is compiled once with nopie and once with pie, but in both cases
we end up with a non-PIE executable.  The "-fno-PIE -no-pie" options specified
using the target_board are interpreted by dejagnu as multilib_flags, and end up
overriding the pie flags.

Fix this by checking in gdb_compile if the resulting exec is non-PIE despite of
a pie setting, and if so return an error:
...
Running gdb/testsuite/gdb.base/break-idempotent.exp ...
gdb compile failed, pie failed to generate PIE executable

                === gdb Summary ===

nr of expected passes            70
nr of untested testcases         1
...

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-08-05  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (version_at_least): Factor out of ...
	(tcl_version_at_least): ... here.
	(gdb_compile): Fail if pie results in non-PIE executable.
	(readelf_version, readelf_prints_pie): New proc.
	(exec_is_pie): Return -1 if unknown.
2019-08-05 12:51:58 +02:00
Tom de Vries d096283854 [gdb/testsuite] Fix typo in tcl_version_at_least
In tcl_version_at_least we compare a minor against a major version number:
...
    } elseif { $tcl_version_major == $major \
                  && $tcl_version_major >= $minor } {
...

Fix this by using $tcl_version_minor in the comparison instead.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-08-05  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (tcl_version_at_least): Fix typo.
2019-08-05 12:51:58 +02:00
Simon Marchi 2b79f3761c Remove some variables in favor of using gdb::optional
While reading that code, I noticed that some variables essentially meant
whether to consider some other variable or not.  I think using
gdb::optional (which was not available when this code was written) is
clearer, as it embeds the used/not used predicate directly in the type
of the variable, making it harder to miss.

gdb/ChangeLog:

	* dwarf2read.c (struct dw2_symtab_iterator):
	<want_specific_block>: Remove.
	<block_index>: Change type to gdb::optional.
	(dw2_symtab_iter_init): Remove WANT_SPECIFIC_BLOCK parameter,
	change type of BLOCK_INDEX parameter to gdb::optional.
	(dw2_symtab_iter_next): Re-write in function of gdb::optional.
	(dw2_lookup_symbol): Don't pass argument for
	WANT_SPECIFIC_BLOCK.
	(dw2_expand_symtabs_for_function): Don't pass argument for
	WANT_SPECIFIC_BLOCK, pass empty optional for BLOCK_INDEX.
	(class dw2_debug_names_iterator)
	<dw2_debug_names_iterator>: Remove WANT_SPECIFIC_BLOCK
	parameter, change BLOCK_INDEX type to gdb::optional.
	<m_want_specific_block>: Remove.
	<m_block_index>: Change type to gdb::optional.
	(dw2_debug_names_iterator::next): Change type of IS_STATIC to
	gdb::optional.  Re-write in function of gdb::optional.
	(dw2_debug_names_lookup_symbol): Don't pass argument for
	WANT_SPECIFIC_BLOCK.
	(dw2_debug_names_expand_symtabs_for_function): Don't pass
	argument for WANT_SPECIFIC_BLOCK, pass empty optional for
	BLOCK_INDEX.
2019-08-04 22:44:05 -04:00
Sandra Loosemore 2252ff3d90 Skip GDB test reconnect-ctrl-c.exp if nointerrupts is set.
2019-08-04  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/testsuite/
	* gdb.server/reconnect-ctrl-c.exp: Skip if nointerrupts.
2019-08-04 14:34:31 -07:00
Sandra Loosemore 26655f5306 Add check for readline support to more GDB tab-completion tests.
2019-08-04  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/testsuite/
	* lib/completion-support.exp (test_gdb_complete_none): Skip
	tab completion tests if no readline support.
	(test_gdb_complete_unique_re): Likewise.
	(test_gdb_complete_multiple): Likewise.
2019-08-04 14:26:39 -07:00
Philippe Waroquiers ae60f04e08 NEWS and documentation for info sources [-dirname | -basename] [--] [REGEXP].
gdb/ChangeLog
2019-08-03  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

        * NEWS: Mention changes to "info sources" command.

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

        * gdb.texinfo (Symbols): Document new args -dirname and -basename
        of "info sources" command.
2019-08-03 21:27:51 +02:00
Philippe Waroquiers db4dc13eeb New test for 'info sources [-dirname | -basename] [--] [REGEXP]'.
This patch introduces a test for the 'info sources' command
and its new arguments [-dirname | -basename] [--] [REGEXP].

gdb/testsuite/ChangeLog

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

	* gdb.base/info_sources.exp: New file.
	* gdb.base/info_sources.c: New file.
	* gdb.base/info_sources_base.c: New file.
2019-08-03 21:27:06 +02:00
Philippe Waroquiers 28cd9371e8 New "info sources" args [-dirname | -basename] [--] [REGEXP]
gdb/ChangeLog

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

	* symtab.c (filename_partial_match_opts): New struct type.
	(struct output_source_filename_data): New members
	regexp, c_regexp, partial_match.
	(output_source_filename): Use new members to decide to print file.
	(info_sources_option_defs): New variable.
	(make_info_sources_options_def_group, print_info_sources_header,
	info_sources_command_completer):
	New functions.
	(info_sources_command): Read new optional arguments.
	(_initialize_symtab): Update info sources help.
2019-08-03 21:26:37 +02:00
Alexandre Oliva ca683e3a86 support Ada EH ABI v1
A new pair of hooks used by Ada exception handlers, for correct
release of reraised exception occurrences, involves the introduction
of new v1 symbols that GDB should use when available.  The older, v0
ABI remains available in newer runtimes for bootstrapping purposes
only.


for  gdb/ChangeLog

	* ada-lang.c (exception_support_info_v0): Renamed from...
	(default_exception_support_info): ... this.  Create new
	definition for v1.
	(ada_has_this_exception_support): Look up catch_handlers_sym.
	(ada_exception_support_info_sniffer): Try v0 after default.
2019-08-02 15:40:32 -03:00
Pedro Franco de Carvalho 0eba165a74 Remove directory names from gdb.base/batch-exit-status.exp
Adjust gdb.base/batch-exit-status.exp so that test prefixes don't show
directory names for the source scripts passed with -x, to make test
results from different build directories comparable.

gdb/testsuite/ChangeLog:
2019-08-01  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* gdb.base/batch-exit-status.exp: Call test_exit_status with
	prefix argument.
	(test_exit_status): Add prefix argument.
2019-08-01 16:51:44 -03:00
Tom Tromey f126416240 Fix the ia64 libunwind build
This fixes the ia64 libunwind build.

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

	* ia64-libunwind-tdep.h (struct libunwind_descr): Include
	gdbarch.h.
2019-08-01 12:14:07 -06:00
Christian Biesinger 0a7b24850e Include s12z-opc.h using ../opcodes.
This file exists in binutils-gdb/opcodes, and nothing in Makefile.in adds this
to the include path.  Default builds work because in-tree readline adds
binutils-gdb/ to the include path (!). However, this is broken when compiling
with system readline.

Other files already use this way to include files in opcodes:
./gdb/lm32-tdep.c:#include "../opcodes/lm32-desc.h"
./gdb/or1k-tdep.h:#include "../opcodes/or1k-desc.h"
./gdb/mep-tdep.c:#include "../opcodes/mep-desc.h"

etc.

gdb/ChangeLog:

2019-08-01  Christian Biesinger  <cbiesinger@google.com>

	* s12z-tdep.c: Fix include path for s12z-opc.h.
2019-08-01 12:40:49 -05:00
Alan Hayward c6bdbeb7c4 Require GNU make 3.82
Gdbserver has failed to build with GNU make 3.81 since commit 08f10e02be.

Update the NEWS file to state that versions earlier than 3.82 are not
supported.

3.82 was released in 2010, 3.81 was released 2006. A quick investigation
of the default GNU make version provided across various distros found the
earliest provided version to be 3.82:
*RHEL 7, Centos 6 - make 3.82
*Fedora 27 - make 4.2.1
*OpenSuse 42.2, SLES11 - make 4.2.1
*Ubuntu 16.04/18.04 - make 4.1
*Debian Jessie - make 4.0

Note that Glibc requires at least 4.0, whereas GCC still allows 3.81.

gdb/ChangeLog:

	* NEWS: Require GNU make 3.82.
2019-08-01 17:07:43 +01:00
Tom de Vries 59bd512b9c [gdb/testsuite] Fix gdb.threads/fork-plus-threads.exp timeout with check-run1
With gdb.threads/fork-plus-threads.exp and check-run1 we get:
...
FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: \
  inferior 1 exited (timeout)
...

Fix this by calling exp_continue for new thread and thread exited messages.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-08-01  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24863
	* gdb.threads/fork-plus-threads.exp: Fix check-run1 timeout by
	calling exp_continue for new thread and thread exited messages.
2019-08-01 10:48:11 +02:00
Tom de Vries 2a3ad588e0 [gdb/testsuite] Fix gdb.base/structs.exp timeout with check-read1
With gdb.base/structs.exp and check-read1 we get:
...
FAIL: gdb.base/structs.exp: p chartest (timeout)
...

Fix this by using gdb_test_sequence.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-08-01  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24863
	* gdb.base/structs.exp: Fix check-read1 timeout using
	gdb_test_sequence.
	* lib/gdb.exp (tcl_version_at_least, lrepeat): New proc.
2019-08-01 10:48:11 +02:00
Tom de Vries 117eb59422 [gdb/testsuite] Fix gdb.base/break-interp.exp timeout with check-read1
With gdb.base/break-interp.exp and check-read1, we run get:
...
FAIL: gdb.base/break-interp.exp: LDprelinkNOdebugNO: \
  BINprelinkNOdebugNOpieNO: symbol-less: info files (timeout)
FAIL: gdb.base/break-interp.exp: LDprelinkNOdebugNO: \
  BINprelinkNOdebugNOpieYES: symbol-less: info files (timeout)
FAIL: gdb.base/break-interp.exp: LDprelinkNOdebugIN: \
  BINprelinkNOdebugNOpieNO: symbol-less: info files (timeout)
FAIL: gdb.base/break-interp.exp: LDprelinkNOdebugIN: \
  BINprelinkNOdebugNOpieYES: symbol-less: info files (timeout)
...

Fix this by calling exp_continue after each "info files" line.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-08-01  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24863
	* gdb.base/break-interp.exp: Use exp_continue after each "info files"
	line.
2019-08-01 10:48:11 +02:00
Tom de Vries ed5913402b [gdb/testsuite] Fix gdb.base/signals.exp timeout with check-read1
With gdb.base/signals.exp and check-read1 we get:
...
FAIL: gdb.base/signals.exp: info signals (timeout)
...

Fix this by using gdb_test_sequence.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-08-01  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24863
	* gdb.base/signals.exp: Fix check-read1 timeout using gdb_test_sequence.
2019-08-01 10:48:11 +02:00
Tom Tromey a2bd7b82ee Don't declare tui_copy_win or tui_box_win
tui_copy_win and tui_box_win are not implemented, so don't declare
them.

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

	* tui/tui-wingeneral.h (tui_copy_win, tui_box_win): Don't
	declare.
2019-07-30 16:19:59 -06:00
Tom Tromey aa3b653351 Allow nested function displays
In Ada, it's possible to have nested functions.  However,
block.c:contained_in does not recognize this.  Normally, this is no
problem, but if gdb is stopped inside a nested function, then you can
end up in the unexpected situation that "print" of an expression will
work, whereas "display" of the same expression will not -- because
contained_in returns 0.

This patch simply removes the BLOCK_FUNCTION check from contained_in.
The rationale here is that in languages without nested functions, this
will not cause any issues.

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

	* block.c (contained_in): Remove BLOCK_FUNCTION check.

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

	* gdb.ada/display_nested.exp: New file.
	* gdb.ada/display_nested/foo.adb: New file.
	* gdb.ada/display_nested/pack.adb: New file.
	* gdb.ada/display_nested/pack.ads: New file.
2019-07-30 12:34:51 -06:00
Kevin Buettner a1530dc731 Allow display of negative offsets in print_address_symbolic()
When examining addresses associated with blocks with non-contiguous
address ranges, it's not uncommon to see large positive offsets which,
for some address width, actually represent a smaller negative offset.
Here's an example taken from the test case (using the
dw2-ranges-func-lo-cold executable):

    (gdb) x/5i foo_cold
       0x40110d <foo+4294967277>:	push   %rbp
       0x40110e <foo+4294967278>:	mov    %rsp,%rbp
       0x401111 <foo+4294967281>:	callq  0x401106 <baz>
       0x401116 <foo+4294967286>:	nop
       0x401117 <foo+4294967287>:	pop    %rbp

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

(gdb) x/5i foo_cold
   0x40110d <foo_cold>:	push   %rbp
   0x40110e <foo-18>:	mov    %rsp,%rbp
   0x401111 <foo-15>:	callq  0x401106 <baz>
   0x401116 <foo-10>:	nop
   0x401117 <foo-9>:	pop    %rbp

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

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

Before:

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

After:

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

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

gdb/ChangeLog:

	* printcmd.c (print_address_symbolic): Print negative offsets.
	(build_address_symbolic): Force signed arithmetic when computing
	offset.
2019-07-30 09:19:13 -07:00
Christian Biesinger 2906593ffe [PR/24474] Add gdb.lookup_static_symbol to the python API
Similar to lookup_global_symbol, except that it checks the
STATIC_SCOPE.

gdb/ChangeLog:

2019-07-30  Christian Biesinger  <cbiesinger@google.com>

	PR/24474: Add a function to lookup static variables.
	* NEWS: Mention this new function.
	* python/py-symbol.c (gdbpy_lookup_static_symbol): New function.
	* python/python-internal.h (gdbpy_lookup_static_symbol): New function.
	* python/python.c (python_GdbMethods): Add new function.

gdb/doc/ChangeLog:

2019-07-30  Christian Biesinger  <cbiesinger@google.com>

	* python.texi (Symbols In Python): Document new function
	gdb.lookup_static_symbol.

gdb/testsuite/ChangeLog:

2019-07-30  Christian Biesinger  <cbiesinger@google.com>

	* gdb.python/py-symbol.c: Add a static variable and one in an anonymous
	namespace.
	* gdb.python/py-symbol.exp: Test gdb.lookup_static_symbol.
2019-07-30 11:04:37 -05:00
Christian Biesinger 5c4dde850c Add missing changelog entry
I forgot to commit the change before pushing commit
25ec892484
2019-07-30 10:41:32 -05:00
Tom de Vries 0f575925b6 [gdb/testsuite] Work around tcl bug in libsegfault.exp with check-read1
When running libsegfault.exp with check-read1, I get:
...
Running gdb/testsuite/gdb.base/libsegfault.exp ...
ERROR: tcl error sourcing gdb/testsuite/gdb.base/libsegfault.exp.
ERROR: no such variable
    (read trace on "env(LD_PRELOAD)")
    invoked from within
"set env(LD_PRELOAD)"
    ("uplevel" body line 1)
    invoked from within
"uplevel 1 [list set $var]"
    invoked from within
"if [uplevel 1 [list array exists $var]] {
                set saved_arrays($var) [uplevel 1 [list array get $var]]
            } else {
                set saved_scalars($var) [uplevel ..."
    invoked from within
"if [uplevel 1 [list info exists $var]] {
            if [uplevel 1 [list array exists $var]] {
                set saved_arrays($var) [uplevel 1 [list array get $var]]
          ..."
    (procedure "save_vars" line 11)
    invoked from within
"save_vars { env(LD_PRELOAD) } {
        if { ![info exists env(LD_PRELOAD) ]
             || $env(LD_PRELOAD) == "" } {
            set env(LD_PRELOAD) "$lib"
        } else {
         ..."
    (procedure "gdb_spawn_with_ld_preload" line 4)
    invoked from within
"gdb_spawn_with_ld_preload $libsegfault """
...

There are several things here interacting with environment variable
LD_PRELOAD:
- the expect "binary" build/gdb/testsuite/expect-read1 with does
  export LD_PRELOAD=build/gdb/testsuite/read1.so before calling native expect
- read1.so which does unsetenv ("LD_PRELOAD") upon first call to read
- the test-case, which wants to set or append libSegFault.so to LD_PRELOAD

The error occurs when accessing $env(LD_PRELOAD), in a branch where
"info exists env(LD_PRELOAD)" returns true. AFAIU, this is
https://core.tcl-lang.org/tcl/tktview?name=67fd4f973a "incorrect results of
'info exists' when unset env var in one interp and check for existence from
another interp".

Work around the tcl bug by not unsetting the variable, but setting it to ""
instead:
...
-      unsetenv ("LD_PRELOAD");
+      setenv ("LD_PRELOAD", "", 1);
...

Verified that reverting commit de28a3b72e "[gdb/testsuite, 2/2] Fix
gdb.linespec/explicit.exp with check-read1" reintroduced the check-read1
failure in gdb.linespec/explicit.exp.

This fixes a similar error in attach-slow-waitpid.exp, which also sets
LD_PRELOAD.

Tested on x86_64-linux with check-read1.

gdb/testsuite/ChangeLog:

2019-07-30  Tom de Vries  <tdevries@suse.de>

	* lib/read1.c (read): Don't use unsetenv (v), use setenv (v, "", 1)
	instead.
2019-07-30 16:15:46 +02:00
Tom de Vries b13057d9ce [gdb/testsuite] Fail in gdb_compile if nopie results in PIE executable
When running gdb.base/dump.exp with --target_board=unix/-fPIE/-pie, we get:
...
Running gdb/testsuite/gdb.base/dump.exp ...
FAIL: gdb.base/dump.exp: dump array as value, intel hex
...

The FAIL happens because although the test specifies nopie, the exec is
in fact compiled as PIE.  The "-fPIE -pie" options specified using the
target_board are interpreted by dejagnu as multilib_flags, and end up
overriding the nopie flags.

Fix this by checking in gdb_compile if the resulting exec is PIE despite of
a nopie setting, and if so return an error:
...
Running gdb/testsuite/gdb.base/dump.exp ...
gdb compile failed, nopie failed to prevent PIE executable

                === gdb Summary ===

nr of untested testcases         1
...

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-30  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24834
	* lib/gdb.exp (gdb_compile): Fail if nopie results in PIE executable.
	(exec_is_pie): New proc.
2019-07-30 09:42:07 +02:00
Christian Biesinger 25ec892484 Fix misspelling (nonexistant -> nonexistent)
gdb/testsuite/ChangeLog:

2019-07-29  Christian Biesinger  <cbiesinger@google.com>

	* gdb.python/py-objfile.exp: Fix misspelling (nonexistant -> nonexistent)
2019-07-29 21:01:13 -05:00
Christian Biesinger c620ed8866 Add Objfile.lookup_{global,static}_symbol functions
This is essentially the inverse of Symbol.objfile. This allows
handling different symbols with the same name (but from different
objfiles) and can also be faster if the objfile is known.

gdb/ChangeLog:

2019-07-29  Christian Biesinger  <cbiesinger@google.com>

	* NEWS: Mention new functions Objfile.lookup_{global,static}_symbol.
	* python/py-objfile.c (objfpy_lookup_global_symbol): New function.
	(objfpy_lookup_static_symbol): New function.
	(objfile_object_methods): Add new functions.

gdb/doc/ChangeLog:

2019-07-29  Christian Biesinger  <cbiesinger@google.com>

	* python.texi (Objfiles In Python): Document new functions
	  Objfile.lookup_{global,static}_symbol.

gdb/testsuite/ChangeLog:

2019-07-29  Christian Biesinger  <cbiesinger@google.com>

	* gdb.python/py-objfile.c: Add global and static vars.
	* gdb.python/py-objfile.exp: Test new functions Objfile.
	  lookup_global_symbol and lookup_static_symbol.
2019-07-29 20:44:08 -05:00
Tom Tromey 3d2357068b Two fixes for test suite's terminal
Exactly which escape sequences are emitted by gdb in TUI mode are
determined largely by the curses implementation.  Testing my latest
(as yet unsubmitted) series to refactor the TUI showed a couple of
failures that I tracked to the test suite's terminal implementation.

In particular, the CSI "@" sequence was not implemented; and the CSI
"X" sequence was implemented incorrectly.

This patch fixes both of these problems.  Tested on x86-64 Fedora 28.

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

	* lib/tuiterm.exp (Term::_csi_@): New proc.
	(Term::_csi_X): Don't move cursor.
2019-07-29 16:06:58 -06:00
Philippe Waroquiers bc4268a5d9 Document 'set print frame-info|frame-arguments presence'.
gdb/ChangeLog
2019-06-19  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* NEWS: Mention 'set|show print frame-info'.  Mention new
	'presence' value for 'frame-arguments'.  Mention new '-frame-info'
	backtrace argument.  Mention that python frame filtering code
	is now consistent with what 'backtrace' command prints.

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

	* gdb.texinfo (Backtrace): Document the new '-frame-info'
	backtrace option.  Reference 'set print frame-info'.
	(Print Settings): Document 'set|show print frame-info'.
	Document new 'presence' value for 'set print frame-arguments.
2019-07-29 21:43:08 +02:00
Philippe Waroquiers c7e4c0a648 Test 'set print frame-info|frame-arguments presence'.
Updated tests to test the new options and new values.
Test the default for print_what in python frame filtering.
Updated the tests impacted by the default in python frame filtering
which is now consistent with the backtrace command.

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

	* gdb.base/options.exp: Update backtrace - completion to
	new option -frame-info.
	* gdb.base/frame-args.exp: Test new 'frame-arguments presence'.
	Test new 'set print frame-info'.  Test backtrace -frame-info
	overriding 'set print frame-info'.
	* gdb.python/py-framefilter.exp: Test new 'frame-arguments presence'.
	Test new 'set print frame-info'.
	Verify consistency of backtrace with and without filters, with and
	without -no-filters.
	* gdb.python/py-framefilter-invalidarg.exp: Update to new print_what
	default.
2019-07-29 21:42:52 +02:00
Philippe Waroquiers 4b5e8d19af Implement 'set print frame-info|frame-arguments presence'.
New settings allow to better control what frame information is printed.

'set print frame-info' allows to override the default frame information
printed when a GDB command prints a frame.
The backtrace command has a new option -frame-info to override
this global setting.

It is now possible to have very short frame information by using the
new 'set print frame-arguments presence' and
'set print frame-info short-location'.

Combined with 'set print address off', a backtrace will only show
the essential information to see the function call chain, e.g.:
  (gdb) set print address off
  (gdb) set print frame-arguments presence
  (gdb) set print frame-info short-location
  (gdb) bt
  #0  break_me ()
  #1  call_me (...)
  #2  main ()
  (gdb)

This is handy in particular for big backtraces with functions having
many arguments.

Python frame filter printing logic has been updated to respect the new
setting in non MI mode.

Also, the default frame information printed was inconsistent when
backtrace was printing the frame information itself, or when the python
frame filtering code was printing the frame information.
This patch changes the default of python frame filtering to have a
consistent behaviour regarding printed frame-information, whatever
the presence/activity/matches of python filters.

2019-07-29  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* frame.h (enum print_what): New value 'SHORT_LOCATION', update
	comments.
	(print_frame_info_auto, print_frame_info_source_line,
	print_frame_info_location, print_frame_info_source_and_location,
	print_frame_info_location_and_address, print_frame_info_short_location):
	New declarations.
	(struct frame_print_options): New member print_frame_info.
	* extension.h (enum ext_lang_frame_args): New value CLI_PRESENCE.
	* stack.h (get_user_print_what_frame_info): New declaration.
	(frame_show_address): New declaration.
	* stack.c (print_frame_arguments_choices): New value 'presence'.
	(print_frame_info_auto, print_frame_info_source_line,
	print_frame_info_location, print_frame_info_source_and_location,
	print_frame_info_location_and_address, print_frame_info_short_location,
	print_frame_info_choices, print_frame_info_print_what): New definitions.
	(print_frame_args): Only print dots for args if print frame-arguments
	is 'presence'.
	(frame_print_option_defs): New element for "frame-info".
	(get_user_print_what_frame_info): New function.
	(frame_show_address): Make non static.  Move comment to stack.h.
	(print_frame_info_to_print_what): New function.
	(print_frame_info): Update comment.  Use fp_opts.print_frame_info
	to decide what to print.
	(backtrace_command_1): Handle the new print_frame_arguments_presence
	value.
	(_initialize_stack): Call add_setshow_enum_cmd for frame-info.
	* python/py-framefilter.c (py_print_args): Handle CLI_PRESENCE.
	(py_print_frame): In non-mi mode, use LOCATION as default for
	print_what, similarly to frame information printed directly by
	backtrace command. Handle frame-info user option in non MI mode.
2019-07-29 21:42:29 +02:00
Tom de Vries de28a3b72e [gdb/testsuite, 2/2] Fix gdb.linespec/explicit.exp with check-read1
When running gdb.linespec/explicit.exp with check-read1, we get:
...
(gdb) PASS: gdb.linespec/explicit.exp: set max-completions unlimited
break 
-function
  ...
top
(gdb) PASS: gdb.linespec/explicit.exp: complete with no arguments
break
-function
 ...
top
(gdb) FAIL: gdb.linespec/explicit.exp: complete with no arguments (clearing input line)
...

The problem is that the send_gdb "\t\t" triggers completion twice:
...
        set tst "complete with no arguments"
        send_gdb "break \t"
        gdb_test_multiple "" $tst {
            "break \\\x07" {
                send_gdb "\t\t"
                gdb_test_multiple "" $tst {
	...
	}
	clear_input_line $tst
...
but the following gdb_test_multiple only parses it once, so the second
completion is left for clear_input_line, which fails.

Fix this by triggering completion only once.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-29  Tom de Vries  <tdevries@suse.de>

	* gdb.linespec/explicit.exp: Fix completion trigger for "complete with
	no arguments".
2019-07-29 16:24:57 +02:00
Tom de Vries 507dd60e28 [gdb/testsuite, 1/2] Fix gdb.linespec/explicit.exp with check-read1
When running gdb.linespec/explicit.exp with check-read1, we get:
...
(gdb) PASS: gdb.linespec/explicit.exp: complete unique file name: break -source "3explicit.c"
break -source exp^Glicit^G^M
explicit.c   explicit2.c  ^M
(gdb) FAIL: gdb.linespec/explicit.exp: complete non-unique file name
...

The problem is that we have a gdb_test_multiple where we match two regexps:
...
        set tst "complete non-unique file name"
        send_gdb "break -source exp\t"
        gdb_test_multiple "" $tst {
            -re "break -source exp\\\x07licit" {
                ...
            }

            -re "break -source exp\\\x07l" {
                # This pattern may occur when glibc debuginfo is installed.
		...
            }
        }
...
but since second is a substring of the first, we'll usually match the first,
but with check-read1 we'll match the second.

Fix this by using a single regexp and merging the related code.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-29  Tom de Vries  <tdevries@suse.de>

	* gdb.linespec/explicit.exp: Fix gdb_test_multiple regexps where second
	is a substring of the first for "complete non-unique file name".
2019-07-29 16:24:57 +02:00
Tom de Vries 5beafce944 [gdb/testsuite] Fix python.exp with check-read1
when running python/python.exp with check-read1, we get:
...
(gdb) PASS: gdb.python/python.exp: prompt substitution readline - end
python gdb.prompt_hook = error_prompt^M
Python Exception <type 'exceptions.RuntimeError'> Python exception calledPASS: gdb.python/python.exp: set hook
: ^M
(gdb) PASS: gdb.python/python.exp: set the hook to default
python gdb.prompt_hook = None^M
(gdb) PASS: gdb.python/python.exp: set print-stack full for prompt error test
set python print-stack full^M
(gdb) FAIL: gdb.python/python.exp: set the hook
python gdb.prompt_hook = error_prompt^M
Traceback (most recent call last):^M
  File "<string>", line 3, in error_prompt^M
RuntimeError: Python exception called^M
(gdb) FAIL: gdb.python/python.exp: set the hook to default
...

The problem is that gdb_test_multiple here:
...
gdb_test_multiple "python gdb.prompt_hook = error_prompt" "set the hook" {
    -re "Python Exception (exceptions.RuntimeError|<(type 'exceptions.|class ')RuntimeError'>) Python excepti
on called.*" {
       pass "set hook"
    }
}
...
specifies a regexp that ends with ".*" but doesn't specify the expected
$gdb_prompt.

Consequently, due to check-read1, the ".*" is matched to "" and the remaining
$gdb_prompt  is read by the the following gdb_py_test_silent_cmd, which has
its own $gdb_prompt read by the following gdb_py_test_silent_cmd, which has
its own $gdb_prompt causing a mismatch for the following gdb_test_multiple:
...
gdb_test_multiple "python gdb.prompt_hook = error_prompt" "set the hook" {
    -re "Traceback.*File.*line.*RuntimeError.*Python exception called.*" {
        pass "set hook"
    }
}
...
which causes both FAILs.

The second gdb_test_multiple has the same problem as the first, but it happens
not to cause a FAIL because it's followed by a gdb_py_test_silent_cmd and a
clean_restart.

Fix the regexps in both gdb_test_multiple calls.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-29  Tom de Vries  <tdevries@suse.de>

	* gdb.python/python.exp: Don't terminate gdb_test_multiple regexp
	with ".*".
2019-07-29 15:07:47 +02:00
Tom de Vries 2d274232f3 [gdb/testsuite] Fix mi-catch-cpp-exceptions.exp and mi-nonstop.exp with check-read1
With check-read1 we get:
...
FAIL: gdb.mi/mi-catch-cpp-exceptions.exp: check for stap probe in libstdc++
FAIL: gdb.mi/mi-nonstop.exp: probe for target remote
...

In both cases this is due to using gdb_test_multiple (which expects $gdb_prompt
by default) in combination with gdb using $gdb_mi_prompt, similar to the
problem fixed by commit d17725d72f "Don't expect gdb_prompt in
mi_skip_python_test".

Fix this by adding the $prompt_regexp argument to the gdb_test_multiple calls.

gdb/testsuite/ChangeLog:

2019-07-29  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (skip_libstdcxx_probe_tests_prompt, gdb_is_target_1):
	Pass prompt_regexp parameter to gdb_test_multiple calls.
2019-07-29 14:11:13 +02:00
Tom de Vries 9197cd8b52 [gdb/testsuite] Fix gdb.base/maint.exp with check-read1
With gdb.base/maint.exp and check-read1, we get:
...
FAIL: gdb.base/maint.exp: maint print registers
...

Using this patch:
...
diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
index a7675ea215..b81d7ec660 100644
--- a/gdb/testsuite/gdb.base/maint.exp
+++ b/gdb/testsuite/gdb.base/maint.exp
@@ -81,7 +81,9 @@ gdb_test_multiple $test $test {
         exp_continue
     }
     -re "$gdb_prompt $" {
-        gdb_assert { $saw_registers && $saw_headers } $test
+       gdb_assert { $saw_headers } "$test: saw headers"
+       gdb_assert { $saw_registers } "$test: saw registers"
+       pass "$test: got prompt"
     }
 }
...

We get more information:
...
PASS: gdb.base/maint.exp: maint print registers: saw headers
FAIL: gdb.base/maint.exp: maint print registers: saw registers
PASS: gdb.base/maint.exp: maint print registers: got prompt
...

The problem is that when matching:
...
(gdb) maint print registers^M
 Name         Nr  Rel Offset    Size  Type            ^M
 rax           0    0      0       8 int64_t         ^M
...
the regexp for $saw_headers ends in "\[\r\n\]+", which
allows it to match only the "\r".  The remaining "\n" then start the next line
to be matched, which doesn't match for the $saw_registers regexp since it
starts with "^\[^\r\n\]+".

Fix this by ending the regexps with "\r\n".

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-29  Tom de Vries  <tdevries@suse.de>

	* gdb.base/maint.exp: Use "\r\n" instead of "\[\r\n\]+" in "maint
          print registers" regexps.
2019-07-29 11:24:04 +02:00
Tom de Vries b528dae095 [gdb/testsuite] Fix gdb.base/define.exp with check-read1
When running gdb.base/define.exp with check-read1, we get:
...
show prompt^M
Gdb's prompt is "(gdb) ".^M
(gdb) PASS: gdb.base/define.exp: save gdb_prompt
set prompt \(blah\) ^M
(blah) PASS: gdb.base/define.exp: set gdb_prompt
set prompt (gdb) PASS: gdb.base/define.exp: reset gdb_prompt
^M
(gdb) FAIL: gdb.base/define.exp: define do-define
...

The problem is that the "$gdb_prompt $" regexp here:
...
gdb_test_multiple "set prompt $prior_prompt " "reset gdb_prompt" {
    -re "$gdb_prompt $" {
        pass "reset gdb_prompt"
    }
}
...
triggers for the echoing of the command "set prompt $prior_prompt " rather
than for the prompt after the command has executed.

Fix this by changing the regexp to "\r\n$gdb_prompt $".

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-29  Tom de Vries  <tdevries@suse.de>

	* gdb.base/define.exp: Add "\r\n" to "reset gdb_prompt" regexp.
2019-07-29 11:24:04 +02:00
Tom de Vries d17725d72f [gdb/testsuite] Don't expect gdb_prompt in mi_skip_python_test
When running gdb.python/py-mi-events.exp with make check-read1, we get:
...
(gdb) ^M
python print ('test')^M
&"python print ('test')\n"^M
~"test\n"^M
^done^M
(gdb) FAIL: gdb.python/py-mi-events.exp: verify python support
^M
python print (sys.version_info[0])^M
&"python print (sys.version_info[0])\n"^M
~"2\n"^M
^done^M
(gdb) FAIL: gdb.python/py-mi-events.exp: check if python 3
^M
...

The FAILs happen as follows.

On one hand, skip_python_tests_prompt uses the prompt_regexp parameter for the
user_code argument of gdb_test_multiple:
...
proc skip_python_tests_prompt { prompt_regexp } {
    global gdb_py_is_py3k

    gdb_test_multiple "python print ('test')" "verify python support" {
	-re "not supported.*$prompt_regexp" {
	    unsupported "Python support is disabled."
	    return 1
	}
	-re "$prompt_regexp" {}
    }

    gdb_test_multiple "python print (sys.version_info\[0\])" "check if python 3" {
	-re "3.*$prompt_regexp" {
            set gdb_py_is_py3k 1
        }
	-re ".*$prompt_regexp" {
            set gdb_py_is_py3k 0
        }
    }
...

On the other hand, gdb_test_multiple itself uses $gdb_prompt:
...
         -re "\r\n$gdb_prompt $" {
            if ![string match "" $message] then {
                fail "$message"
            }
            set result 1
        }
...

So when mi_skip_python_test calls skip_python_tests_prompt with prompt_regexp
set to $mi_gdb_prompt:
...
proc mi_skip_python_tests {} {
    global mi_gdb_prompt
    return [skip_python_tests_prompt "$mi_gdb_prompt$"]
}
...
and expect reads "(gdb) " and tries to match it (due to the READ1=1 setting),
the user_code regexps using $prompt_regexp (set to $mi_gdb_prompt) don't match,
but the $gdb_prompt regexp in gdb_test_multiple does match.

Fix this by adding a prompt_regexp parameter to gdb_test_multiple, and using the
parameter in skip_python_tests_prompt.

Tested gdb.python/py-mi-events.exp with make check READ1=1 x86_64-linux.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-29  Tom de Vries  <tdevries@suse.de>

	PR gdb/24855
	* lib/gdb.exp (gdb_test_multiple): Add prompt_regexp parameter.
	(skip_python_tests_prompt): Add prompt_regexp argument to
	gdb_test_multiple calls.
2019-07-29 11:24:04 +02:00