Commit Graph

97870 Commits

Author SHA1 Message Date
Andrew Burgess 93cb9841d6 gdb/testsuite: Improve detection of bug gdb/24541
In bug gdb/24686 a testsuite failure was reported, this failure was
actually just another instance of bug gdb/24541, however, due to the
non-deterministic nature of bug gdb/24541 the testsuite pattern that
was intended to catch this bug failed.

This commit adds a second pattern to help detect gdb/24541, which
should change the FAIL reported in gdb/24686 into a KFAIL.

gdb/testsuite/ChangeLog:

	PR gdb/24686
	* gdb.mi/mi-catch-cpp-exceptions.exp: Add an extra pattern to
	improve detection of bug gdb/24541.
2019-06-16 16:27:14 +01:00
Tom Tromey 730ead81df Remove some NULL checks from the TUI
I found a few spots in the TUI that were NULL-checking the result of
XNEW.  This cannot return NULL, so this patch removes the checks.

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

	* tui/tui-data.c (tui_alloc_generic_win_info)
	(tui_alloc_win_info, tui_add_content_elements): Remove NULL
	checks.
2019-06-16 09:15:04 -06:00
Simon Marchi e79be6e5f3 Fix some whitespace issues in gdb ChangeLogs 2019-06-16 10:02:50 -04:00
Simon Marchi 399aaebd1a Make gdb.base/index-cache.exp work with readnow board (PR 24669)
The gdb.base/index-cache.exp test fails with the readnow board:

  $ make check TESTS="gdb.base/index-cache.exp" RUNTESTFLAGS="--target_board=readnow"
  FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: at least one file was created
  FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: expected file is there
  FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: check index-cache stats
  FAIL: gdb.base/index-cache.exp: test_cache_enabled_hit: check index-cache stats

The problem is similar to what was fixed in

  5a56d6a65f ("[gdb/testsuite] Fix index-cache.exp with cc-with-{gdb-index,debug-names}")

In that commit, gdb.base/index-cache.exp was modified to account for the
fact that the index cache is not used when the binary already has an
embedded index.

The same situation happens when GDB is started with the -readnow flag:
it bypasses indices and partial symbols.  So this patch updates the test
to also expect the index cache not to be used if -readnow is present in
$GDBFLAGS,

gdb/testsuite/ChangeLog:

	PR gdb/24669
	* gdb.base/index-cache.exp (uses_readnow,
	expecting_index_cache_use): Define global variable.
	(test_cache_enabled_miss, test_cache_enabled_hit): Use
	expecting_index_cache_use.
2019-06-16 09:07:17 -04:00
GDB Administrator 6ac6a19371 Automatic date update in version.in 2019-06-16 00:01:04 +00:00
Andrew Burgess 584a927c5a gdb/fortran: Show the type for non allocated / associated types
Show the type of not-allocated and/or not-associated types.  For array
types and pointer to array types we are going to print the number of
ranks.

Consider this Fortran program:

  program test
    integer, allocatable :: vla (:)
    logical l
    allocate (vla(5:12))
    l = allocated (vla)
  end program test

And this GDB session with current HEAD:

  (gdb) start
  ...
  2	  integer, allocatable :: vla (:)
  (gdb) n
  4	  allocate (vla(5:12))
  (gdb) ptype vla
  type = <not allocated>
  (gdb) p vla
  $1 = <not allocated>
  (gdb)

And the same session with this patch applied:

  (gdb) start
  ...
  2	  integer, allocatable :: vla (:)
  (gdb) n
  4	  allocate (vla(5:12))
  (gdb) ptype vla
  type = integer(kind=4), allocatable (:)
  (gdb) p vla
  $1 = <not allocated>
  (gdb)

The type of 'vla' is now printed correctly, while the value itself
still shows as '<not allocated>'.  How GDB prints the type of
associated pointers has changed in a similar way.

gdb/ChangeLog:

	* f-typeprint.c (f_print_type): Don't return early for not
	associated or not allocated types.
	(f_type_print_varspec_suffix): Add print_rank parameter and print
	ranks of array types in case they dangling.
	(f_type_print_base): Add print_rank parameter.

gdb/testsuite/ChangeLog:

	* gdb.fortran/pointers.f90: New file.
	* gdb.fortran/print_type.exp: New file.
	* gdb.fortran/vla-ptype.exp: Adapt expected results.
	* gdb.fortran/vla-type.exp: Likewise.
	* gdb.fortran/vla-value.exp: Likewise.
	* gdb.mi/mi-vla-fortran.exp: Likewise.
2019-06-16 00:29:35 +01:00
Andrew Burgess 30056ea04a gdb/mi: New commands to catch C++ exceptions
Adds some MI commands to catch C++ exceptions.  The new commands are
-catch-throw, -catch-rethrow, and -catch-catch, these all correspond
to the CLI commands 'catch throw', 'catch rethrow', and 'catch catch'.

Each MI command takes two optional arguments, '-t' has the effect of
calling 'tcatch' instead of 'catch', for example:

   (gdb)
   -catch-throw -t

Is the same as:

   (gdb) tcatch throw

There is also a '-r REGEXP' argument that can supply a regexp to match
against the exception type, so:

   (gdb)
   -catch-catch -r PATTERN

Is the same as:

   (gdb) catch catch PATTERN

The change in print_mention_exception_catchpoint might seem a little
strange; changing the output from using ui_out::field_int and
ui_out::text to using  ui_out::message.

The print_mention_exception_catchpoint is used as the 'print_mention'
method for the exception catchpoint breakpoint object.  Most of the
other 'print_mention' methods (see breakpoint.c) use either
printf_filtered, of ui_out::message.  Using field_int was causing an
unexpected field to be added to the MI output.  Here's the output
without the change in print_mention_exception_catchpoint:

    (gdb)
    -catch-throw
    ^done,bkptno="1",bkpt={number="1",type="breakpoint",disp="keep",
                           enabled="y",addr="0x00000000004006c0",
                           what="exception throw",catch-type="throw",
                           thread-groups=["i1"],times="0"}

Notice the breakpoint number appears in both the 'bkptno' field, and
the 'number' field within the 'bkpt' tuple.  Here's the output with
the change in print_mention_exception_catchpoint:

    (gdb)
    -catch-throw
    ^done,bkpt={number="1",type="breakpoint",disp="keep",
                enabled="y",addr="0x00000000004006c0",
                what="exception throw",catch-type="throw",
                thread-groups=["i1"],times="0"}

gdb/ChangeLog:

	* NEWS: Mention new MI commands.
	* break-catch-throw.c (enum exception_event_kind): Move to
	breakpoint.h.
	(print_mention_exception_catchpoint): Output text as a single
	message.
	(catch_exception_command_1): Rename to...
	(catch_exception_event): ...this, make non-static, update header
	command, and change some parameter types.
	(catch_catch_command): Update for changes to
	catch_exception_command_1.
	(catch_throw_command): Likewise.
	(catch_rethrow_command): Likewise.
	* breakpoint.c (enum exception_event_kind): Delete.
	* breakpoint.h (enum exception_event_kind): Moved here from
	break-catch-throw.c.
	(catch_exception_event): Declare.
	* mi/mi-cmd-catch.c (mi_cmd_catch_exception_event): New function.
	(mi_cmd_catch_throw): New function.
	(mi_cmd_catch_rethrow): New function.
	(mi_cmd_catch_catch): New function.
	* mi/mi-cmds.c (mi_cmds): Add 'catch-throw', 'catch-rethrow', and
	'catch-catch' entries.
	* mi/mi-cmds.h (mi_cmd_catch_throw): Declare.
	(mi_cmd_catch_rethrow): Declare.
	(mi_cmd_catch_catch): Declare.

gdb/doc/ChangeLog:

	* gdb.texinfo (GDB/MI Catchpoint Commands): Add menu entry to new
	node.
	(C++ Exception GDB/MI Catchpoint Commands): New node to describe
	new MI commands.

gdb/testsuite/ChangeLog:

	* gdb.mi/mi-catch-cpp-exceptions.cc: New file.
	* gdb.mi/mi-catch-cpp-exceptions.exp: New file.
	* lib/mi-support.exp (mi_expect_stop): Handle 'exception-caught'
	as a stop reason.
2019-06-15 23:22:22 +01:00
Andrew Burgess ec8e2b6d30 gdb: Don't allow annotations to influence what else GDB prints
The annotations should be additional information printed by GDB to be
consumed by users (GUIs), but GDB shouldn't reduce what it prints
based on whether annotations are on or not.  However, this is what
happens for annotate_source_line.

This commit makes annotate_source_line a void function that simply
outputs the annotation information, GDB will then print the contents
of the source line to the terminal in the normal way.

Some tests needed to be updated after this commit.

gdb/ChangeLog:

	* annotate.c (annotate_source_line): Change return type to void,
	update implementation to match.
	* annotate.h (annotate_source_line): Change return type to void,
	update header comment.
	* stack.c (print_frame_info): Don't change what frame information
	is printed based on whether annotations are on or not.

gdb/testsuite/ChangeLog:

	* gdb.base/annota1.exp: Update expected results.
	* gdb.cp/annota2.exp: Likewise.
	* gdb.cp/annota3.exp: Likewise.
2019-06-15 21:39:06 +01:00
Andrew Burgess 0d3abd8cc9 gdb: Remove an update of current_source_line and current_source_symtab
While reviewing some of the annotation code I noticed that
identify_source_line (in source.c) sets current_source_line,
current_source_symtab, and also calls clear_lines_listed_range.  This
seems a little strange, identify_source_line is really a wrapper
around annotate_source, and is only called when annotation_level is
greater than 0 (so annotations are turned on).

It seems weird (to me) that when annotations are on we update GDB's
idea of the "current" line/symtab, but when they are off we don't,
given that annotations are really about communicating GDB's state to a
user (GUI) and surely shouldn't be changing GDB's behaviour.

This commit removes from identify_source_line all of the setting of
current line/symtab and the call to clear_lines_listed_range, after
doing this GDB still passes all tests, so I don't believe these lines
were actually required.

With this code removed identify_source_line is only a wrapper around
annotate_source, so I moved identify_source_line to annotate.c and
renamed it to annotate_source_line.

gdb/ChangeLog:

	* annotate.c: Add 'source.h' and 'objfiles.h' includes.
	(annotate_source): Make static.
	(annotate_source_line): Moved from source.c and renamed from
	identify_source_line.  Update the return type.
	* annotate.h (annotate_source): Delete declaration.
	(annotate_source_line): Declaration moved from source.h, and
	renamed from identify_source_line.  Return type updated.
	* source.c (identify_source_line): Moved to annotate.c and renamed
	to annotate_source_line.
	(info_line_command): Remove check of annotation_level.
	* source.h (identify_source_line): Move declaration to annotate.h
	and rename to annotate_source_line.
	* stack.c: Add 'annotate.h' include.
	(print_frame_info): Remove check of annotation_level before
	calling annotate_source_line.
2019-06-15 21:39:05 +01:00
Andrew Burgess 00df30ae1e gdb: New function to open source file and compute line charpos data
Every place that a symtab's line_charpos data is loaded always follows
the same pattern, so create a new function to contain this logic and
make use of it throughout GDB.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* source-cache.c (source_cache::get_plain_source_lines): Use
	open_source_file_with_line_charpos instead of just
	open_source_file, remove call to find_source_lines.
	(source_cache::get_source_lines): Likewise.
	* source.c (find_source_lines): Make static.
	(get_filename_and_charpos): Renamed into...
	(open_source_file_with_line_charpos): ..this along with changes to
	return a scoped_fd, and some other minor clean ups.
	(identify_source_line): Use open_source_file_with_line_charpos.
	(search_command_helper): Use open_source_file_with_line_charpos
	instead of just open_source_file, remove call to
	find_source_lines.
	* source.h (open_source_file_with_line_charpos): Declare new
	function.
	(find_source_lines): Delete declaration.
2019-06-15 21:39:04 +01:00
Andrew Burgess afda45a206 gdb: Remove unused parameter
The parameter 'fullname' is always passed as NULL to the function
get_filename_and_charpos in source.c, so lets remove the parameter.
There should be no user visible changes after this commit.

gdb/ChangeLog:

	* source.c (get_filename_and_charpos): Remove fullname
	parameter.
	(identify_source_line): Update call to get_filename_and_charpos.
2019-06-15 21:39:03 +01:00
Andrew Burgess 09e4c4e1f1 gdb: Remove file path from test name
Having paths in test names makes comparing sum files difficult, rename
a test to avoid paths in test names.

gdb/testsuite/ChangeLog:

	* gdb.base/style-logging.exp: Remove path from test name.
2019-06-15 21:31:04 +01:00
GDB Administrator 49455d8bbd Automatic date update in version.in 2019-06-15 00:00:41 +00:00
Tom Tromey 0735b091ab Do not emit style escape sequences to log file
PR gdb/24502 requests that the "set logging" log file not contain
style escape sequences emitted by gdb.

This seemed like a reasonable request to me, so this patch implements
filtering for the log file.

This also updates a comment in ui-style.h that I noticed while writing
the patch.

Tested on x86-64 Fedora 29.

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

	PR gdb/24502:
	* ui-style.h (skip_ansi_escape): Update comment.
	* ui-file.h (class no_terminal_escape_file): New class.
	* ui-file.c (no_terminal_escape_file::write)
	(no_terminal_escape_file::puts): New methods.
	* cli/cli-logging.c (handle_redirections): Use
	no_terminal_escape_file.

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

	PR gdb/24502:
	* gdb.base/style-logging.exp: New file.
2019-06-14 14:13:29 -06:00
Tom Tromey 52ce35e289 Minor NEWS rearrangement
I noticed that a NEWS item about Python scripting changes appeared
between an item about a convenience function and an item about a
convenience variable.  I think it's better for the latter to be next
to each other.

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

	* NEWS: Move convenience variable news above Python news.
2019-06-14 13:03:18 -06:00
Tom Tromey 73cc72729a Move gnulib to top level
This patch moves the gdb/gnulib subdirectory to the top level.

It adjusts the top-level build system to build gnulib when necessary,
and changes gdb to use this.  However, gdbserver still builds its own
copy of gnulib, just from the new source location.

A small hack was needed to ensure that gnulib is only built when gdb
is enabled.  The Makefile only provides an ordering -- the directory
must be mentioned in configdirs to actually be compiled at all.

Most of the patch is just a "git mv" of gnulib, though a few minor
path adjustments were needed in some files there.

Tested by the buildbot.

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

	* MAINTAINERS: Add gnulib.
	* gnulib: New directory, move from gdb/gnulib.
	* configure.ac (host_libs): Add gnulib.
	* configure: Rebuild.
	* Makefile.def (host_modules, dependencies): Add gnulib.
	* Makefile.in: Rebuild.

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

	* gnulib: Move directory to top-level.
	* configure.ac: Don't configure gnulib.
	* configure: Rebuild.
	* common/common-defs.h: Use new path to gnulib.
	* Makefile.in (GNULIB_BUILDDIR): Now ../gnulib.
	(GNULIB_H): Remove.
	(INCGNU): Look in new gnulib location.
	(HFILES_NO_SRCDIR): Remove gnulib files.
	(SUBDIR, REQUIRED_SUBDIRS): Remove gnulib.
	(generated_files): Remove GNULIB_H.
	($(LIBGNU), all-lib): Remove targets.
	(distclean): Don't mention GNULIB_BUILDDIR.
	($(GNULIB_BUILDDIR)/Makefile): Remove target.

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

	* configure.ac: Use new path to gnulib.
	* configure: Rebuild.
	* Makefile.in (INCGNU, $(GNULIB_BUILDDIR)/Makefile): Use new path
	to gnulib.

gnulib/ChangeLog
2019-06-14  Tom Tromey  <tom@tromey.com>

	* update-gnulib.sh: Adjust paths.
	* Makefile.in: Adjust paths.
	* configure.ac: Adjust paths.  Use ACX_LARGEFILE.
	* configure: Rebuild.
2019-06-14 12:40:02 -06:00
Tom Tromey f568655424 Warn if add-symbol-file does not provide any symbols
A user suggested that add-symbol-file ought to warn if the file does
not in fact provide any symbols.  This seemed like a decent idea, so
this patch implements this idea.

Tested on x86-64 Fedora 29.

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

	* symfile.c (add_symbol_file_command): Remove obsolete comment.
	Warn if symbol file does not provide any symbols.

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

	* gdb.base/symfile-warn.exp: New file.
	* gdb.base/symfile-warn.c: New file.
2019-06-14 12:38:15 -06:00
Tom Tromey a0c1ffedcf Only compute realpath when basenames_may_differ is set
A user noted that, when sources are symlinked, gdb annotations will
print the real path, rather than the name of the symlink.

It seems to me that it is better to print the name of the file that
was actually used in the build, unless there is some reason not to.

This patch implements this, with the caveat that it will not work when
basenames-may-differ is enabled.  The way this mode is currently
implemented, returning the symbolic (not real) path is not possible.

While I think it would be good to redo the source file name cache and
perhaps integrate it with class source_cache, I haven't done so here.

Regression tested on x86-64 Fedora 29.

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

	* source.c (find_and_open_source): Respect basenames_may_differ.

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

	* gdb.base/annotate-symlink.exp: New file.
2019-06-14 08:34:24 -06:00
Andrew Burgess 7c39e397aa gdb: Use scoped_restore_terminal_state in annotate.c
In a couple of places in annotate.c we are manually backing up and
restoring the terminal ownership, we could instead make use of
scoped_restore_terminal_state.

gdb/ChangeLog:

	* annotate.c (annotate_breakpoints_invalid): Make use of
	scoped_restore_terminal_state.
	(annotate_frames_invalid): Likewise.
2019-06-14 15:27:34 +01:00
Tom Tromey f411722cbc Allow re-assigning to convenience variables
In Ada mode, re-assigning an array of a different size to a
convenience variable will cause an error:

    (gdb) set lang ada
    (gdb) set $v := "abc"
    (gdb) set $v := "abcd"
    cannot assign arrays of different length

However, this does not really make sense -- instead, it should always
be possible to overwrite a convenience variable.

This patch fixes this bug.

This was reviewed off-list by Joel.  I'm checking it in.

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

	* ada-lang.c (ada_evaluate_subexp) <case BINOP_ASSIGN>: Always
	allow assignment to an internalvar.

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

	* gdb.ada/set_wstr.exp: Add reassignment test.
2019-06-14 08:06:16 -06:00
Tom Tromey 4268ec187d Recognize _ in attribute names
Ada attribute names can contain "_", but the lexer currently does not
allow this -- even though the "attributes" array lists some attributes
spelled this way.

This patch fixes the bug and adds test cases for the existing
attributes.

This was reviewed off-list by Joel.  I'm checking it in.

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

	* ada-lex.l: Allow "_" in attribute names.

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

	* gdb.ada/formatted_ref.exp (test_p_x_addr): Check
	'unchecked_access and 'unrestricted_access as well.
2019-06-14 08:02:20 -06:00
Tom Tromey abdb711e08 Remove alloca(0) calls
PR gdb/24653 points out that a gcc snapshot will complain about the
calls to alloca(0) in gdb.

These calls are only needed when using the C alloca.  I'm inclined to
think that no current platform needs this, so this patch removes the
calls.

Let me know what you think.

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

	PR gdb/24653:
	* regcache.c (registers_changed): Don't call alloca.
	* top.c (execute_command): Don't call alloca.
2019-06-14 07:00:27 -06:00
Tom Tromey 9a9e394b05 Fix gdb.ada/vla.exp
PR ada/24539 concerns a test failure in gdb.ada/vla.exp.

The problem here is that different versions of Gnat emit the
structure's fields in different orders -- with the order currently
failing actually being the correct one.

Joel pointed out that this can be fixed by simply adding the
No_Component_Reordering pragma to the type in question, which is what
this patch does.

I've reported a Gnat compiler bug internally in hopes of getting the
underlying problem fixed.

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

	PR ada/24539:
	* gdb.ada/vla.exp: Update tests.
	* gdb.ada/vla/vla.adb (Record_Type): Use No_Component_Reordering
	pragma.
2019-06-14 06:53:24 -06:00
Szabolcs Nagy e30d1fa1bf Add R_AARCH64_P32_MOVW_PREL_* ELF32 relocs
These ilp32 relocations were missing for some reason.

bfd/ChangeLog:

	* elfnn-aarch64.c: Enable MOVW_PREL relocs for ELF32.

include/ChangeLog:

	* elf/aarch64.h (R_AARCH64_P32_MOVW_PREL_G0): Define.
	(R_AARCH64_P32_MOVW_PREL_G0_NC): Define.
	(R_AARCH64_P32_MOVW_PREL_G1): Define.

ld/ChangeLog:

	* testsuite/ld-aarch64/aarch64-elf.exp: Add emit-relocs-22 and -23.
	* testsuite/ld-aarch64/emit-relocs-22.d: New test.
	* testsuite/ld-aarch64/emit-relocs-22.s: New test.
	* testsuite/ld-aarch64/emit-relocs-23.d: New test.
	* testsuite/ld-aarch64/emit-relocs-23.s: New test.
2019-06-14 12:02:19 +01:00
Nick Clifton bcc5a6eb66 Updated French translation for the opcodes subdirectory.
* po/fr.po; Updated French translation.
2019-06-14 11:43:53 +01:00
Alan Modra 3a3a077c4a Regenerate with approved autotools version
bfd/
	* Makefile.in: Regenerate.
	* configure: Regenerate.
binutils/
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* doc/Makefile.in: Regenerate.
gas/
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* doc/Makefile.in: Regenerate.
ld/
	* Makefile.in: Regenerate.
	* configure: Regenerate.
libctf/
	* configure: Regenerate.
2019-06-14 10:30:35 +09:30
Alan Modra e3fa7860f4 Fix alpha testsuite regression
readelf st_other display improved for alpha.

	PR 24662
	* testsuite/ld-alpha/tlsbin.rd: Update.
	* testsuite/ld-alpha/tlsbinr.rd: Update.
	* testsuite/ld-alpha/tlspic.rd: Update.
2019-06-14 10:23:20 +09:30
Alan Modra d4b87b1eb6 PowerPC comment fixes
"paddi rt,sym@pcrel" as an abbreviation for "paddi rt,0,sym@pcrel,1"
is invalid, so replace with "pla rt,sym@pcrel" which is a valid form
of "pla rt,sym@pcrel(0),1".

	* elf64-ppc.c: Fix comments involving paddi.
2019-06-14 10:22:49 +09:30
GDB Administrator f8164777cd Automatic date update in version.in 2019-06-14 00:00:18 +00:00
Pedro Alves 4c04873103 Fix "set integer-command unlimited junk"
With integer commands that support "unlimited", we currently fail to
notice junk after "unlimited":

 (gdb) show print elements
 Limit on string chars or array elements to print is 200.
 (gdb) set print elements unlimited foo
 (gdb) show print elements
 Limit on string chars or array elements to print is unlimited.

This commit fixes that.  After, we get:

 (gdb) set print elements unlimited foo
 Junk after "unlimited": foo

gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* cli/cli-setshow.c (cli/cli-setshow.c): New parameter
	'expression'.  When parsing an expression, error out if there's
	junk after "unlimited".
	(parse_cli_var_uinteger, parse_cli_var_zuinteger_unlimited)
	(do_set_command): Adjust calls to is_unlimited_literal.

gdb/testsuite/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* gdb.base/settings.exp (test-integer): Test junk after
	"unlimited".
2019-06-13 15:22:44 +01:00
Stafford Horne 57a63d27dc sim/testsuite/or1k: Add tests for unordered compares
Add tests for 32-bit and 64-bit unordered compare instructions.

sim/testsuite/sim/or1k/ChangeLog:

yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>

	* fpu-unordered.S: New file.
	* fpu64a32-unordered.S: New file.
2019-06-13 21:27:10 +09:00
Stafford Horne 3c83b496d4 sim/testsuite/or1k: Add test case for l.adrp instruction
This is a simple test to ensure that the l.adrp instruction can be assembled and
simulated correctly.

sim/testsuite/sim/or1k/ChangeLog:

yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>

	* adrp.S: New file.
2019-06-13 21:27:10 +09:00
Stafford Horne b4f9e00346 sim/testsuite/or1k: Add test for 64-bit fpu operations
This is a very basic test but it ensure the machine is wired up
correctly and that the assembler works.

sim/testsuite/sim/or1k/ChangeLog:

yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>

	* fpu64a32.S: New file.
2019-06-13 21:27:10 +09:00
Stafford Horne f1cc84f594 sim/common: wire up new unordered comparisons
Define and wire up unordered floating point comparison operations for cgen
targets.  This patch depends on my posted cgen patches[0].

[0] https://www.sourceware.org/ml/cgen/2019-q2/msg00013.html

sim/common/ChangeLog:

yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>

	* cgen-accfp.c (unorderedsf, unordereddf): New functions.
	(cgen_init_accurate_fpu): Wire up unorderedsf and unordereddf.
	* cgen-fpu.h (cgen_fp_ops): Define fields unorderedsf and unordereddf.
2019-06-13 21:27:10 +09:00
Stafford Horne 688cea90bc sim/common: Wire in df/di conversion
Up until now these have not been used in any CGEN targets, add them as
they are now used by OpenRISC.

sim/common/ChangeLog:

	* cgen-accfp.c (floatdidf, fixdfdi): New functions.
	(cgen_init_accurate_fpu): Add floatdidf and fixdfdi.
2019-06-13 21:27:10 +09:00
Stafford Horne 7ccbb4437a sim/or1k: Regenerate sim
This picks up changes for:

 - new orfpx64a32 spec
 - new unordered instructions
 - documentation and symbol updates

sim/ChangeLog:

	* or1k/cpu.c: Regenerate.
	* or1k/cpu.h: Regenerate.
	* or1k/decode.c: Regenerate.
	* or1k/decode.h: Regenerate.
	* or1k/model.c: Regenerate.
	* or1k/sem-switch.c: Regenerate.
	* or1k/sem.c: Regenerate.
2019-06-13 21:27:09 +09:00
Pedro Alves 66eb1ed388 Fix gdb build with -std=gnu++11
The options framework series broken the build with gcc 4.8, or any
other compiler were we end up forcing -std=gnu++11, causing errors
like these:

 ../../binutils-gdb/gdb/compile/compile.c: In function gdb::option::option_def_group make_compile_options_def_group(compile_options*):
 ../../binutils-gdb/gdb/compile/compile.c:266:44: error: could not convert (const gdb::option::option_def*)(& compile_command_option_defs) from const gdb::option::option_def* to gdb::array_view<const gdb::option::option_def>
    return {compile_command_option_defs, opts};
					     ^
   CXX    copying.o
 ../../binutils-gdb/gdb/compile/compile.c:267:1: error: control reaches end of non-void function [-Werror=return-type]
  }
  ^

This is a C++11 vs C++14 difference -- C++14 relaxed the rules for
eliding braces.

This commit fixes it by adding the missing (in C++11) braces.  Tested
with g++ 4.8.

gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* compile/compile.c (make_compile_options_def_group): Add braces
	around array_view initializer.
	* thread.c (make_thread_apply_all_options_def_group)
	(make_thread_apply_all_options_def_group): Likewise.
2019-06-13 08:58:54 +01:00
GDB Administrator e41d1c49a1 Automatic date update in version.in 2019-06-13 00:00:38 +00:00
Pedro Alves 3345721af1 NEWS and manual changes for command options changes
gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* NEWS (New commands): Mention "maint test-options
	require-delimiter", "maint test-options unknown-is-error", "maint
	test-options unknown-is-operand" and "maint show
	test-options-completion-result".
	(New command options, command completion): New section.
	(Completion improvements): New section.
	Mention that you can abbreviate "unlimited".

gdb/doc/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Command Completion): Mention command options too.
	(Command Options): New node.
	(Threads): Add anchors.  Extend descriptions of the "taas" and
	"tfaas" commands.
	(Backtrace): Describe new options of the "backtrace" command.  Add
	anchors.
	(Frame Apply): Describe new options of the "frame apply" and
	"faas" commands.  Add anchors.
	(Data): Describe new options of the "print" command.  Add anchors.
	(Compiling and Injecting Code): Mention options of the "compile
	print" command.
	(Maintenance Commands): Mention "maint test-options" subcommands
	and the "maint show test-options-completion-result" command.
2019-06-13 00:25:06 +01:00
Pedro Alves 6206060d9b Delete parse_flags/parse_flags_qcs
Now that "thread/frame apply" have been converted to the gdb::option
framework, these functions are no longer used.

For a while, I thought about keeping the unit tests, by making a local
version of parse_flags_qcs in the unit tests file.  But all that would
really test that is used by GDB itself, is the validate_flags_qcs
function.  So in the end, I went through all the unit tests, and
converted any that wasn't already covered to gdb.base/options.exp
tests.  And those have all already been added in previous patches.

gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* cli/cli-utils.c (parse_flags, parse_flags_qcs): Delete.
	* cli/cli-utils.h (parse_flags, parse_flags_qcs): Delete.
	* unittests/cli-utils-selftests.c (test_parse_flags)
	(test_parse_flags_qcs): Delete.
	(test_cli_utils): Don't call deleted functions.
2019-06-13 00:24:17 +01:00
Pedro Alves 6665660a41 Make "thread apply" use the gdb::option framework
Similarly to the "frame apply" patch, this makes the "thread apply"
family of commands -- "thread apply TID", "thread apply all" and
"taas" use the gdb::option framework for '-'-style options.

No new options are added, but there are some user-visible changes:

- Can now abbreviate and complete "-ascending"

- We now have a completer for "thread apply" commands

  Can now complete options ("thread apply all -[TAB]"), and also,
  'thread apply all COMMAND[TAB]' now does what you'd expect, by
  making use of the new complete_command routine.

- "help" output tweaked with auto-generated option descriptions:

   ~~~
   Usage: thread apply all [OPTION]... COMMAND
   Prints per-inferior thread number and target system's thread id
   followed by COMMAND output.

   By default, an error raised during the execution of COMMAND
   aborts "thread apply".

   Options:
     -ascending
       Call COMMAND for all threads in ascending order.
       The default is descending order.

     -q
       Disables printing the thread information.

     -c
       Print any error raised by COMMAND and continue.

     -s
       Silently ignore any errors or empty output produced by COMMAND.
   ~~~

  The "By default ..." sentence is new as well.

gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* thread.c: Include "cli/cli-option.h".
	(tp_array_compar_ascending): Global.
	(tp_array_compar): Delete function.
	(tp_array_compar_ascending, tp_array_compar_descending): New
	functions.
	(ascending_option_def, qcs_flag_option_def)
	(thr_qcs_flags_option_defs)
	(make_thread_apply_all_options_def_group)
	(make_thread_apply_options_def_group): New.
	(thread_apply_all_command): Use gdb::option::process_options.
	(thread_apply_command_completer)
	(thread_apply_all_command_completer): New.
	(thread_apply_command): Use gdb::option::process_options.
	(_initialize_thread): Delete THREAD_APPLY_FLAGS_HELP, replace it
	with a new THREAD_APPLY_OPTION_HELP.  Use gdb::option::build_help
	to generate help text of "thread apply".  Adjust "taas"'s help.
	* tid-parse.c (tid_range_parser::in_thread_range): New method.
	* tid-parse.h (tid_range_parser::in_thread_range): New method.

gdb/testsuite/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* gdb.base/options.exp (test-thread-apply): New.
	(top level): Call it.
2019-06-13 00:23:25 +01:00
Pedro Alves f7e13587ea "thread apply 1 -- -" vs "frame apply level 0 -- -"
With the following patch, we'll be able to explicitly tell "thread
apply" where options end, using the "--" delimiter.  A test added by
that patch caught a pre-existing inconsistency:

 (gdb) thread apply 1 -- -
 Invalid thread ID: -

 (gdb) frame apply level 0 -- -
 #0  main () at threads.c:55
 Cannot enable the TUI when output is not a terminal

Above, "thread apply" did not try to run the command, while "frame
apply level" did.  ("-" is a valid TUI command.)

That "-" is past "--", so it should have not been confused with an
invalid TID, in the "thread apply" case.

That error actually doesn't come from the TID parser, but instead from
thread_apply_command directly.

So that error/check needs tweaking.  The next question is what to
tweak it to.

"-" is actually a valid TUI command:

 (gdb) help -
 Scroll window backward.
 Usage: - [WIN] [N]

(gdb) frame apply level 0 -- -
#0  main () at threads.c:55
Cannot enable the TUI when output is not a terminal

While I don't imagine it being useful to use that "-" command with
"thread apply" or "frame apply level", the fact is that you can use it
with "frame apply level", but not with "thread apply".  And since it's
an actual command, pedantically it seems right to allow it.

That's what this commit does.

Note: simply removing the "isalpha" check regresses
gdb.multi/tids.exp -- see related commit 3f5b759880.

gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* thread.c (thread_apply_command): Check for invalid TID with
	isdigit instead of !isalpha.
2019-06-13 00:22:53 +01:00
Pedro Alves 5d7071341d Make "frame apply" support -OPT options
This adds support for '-'-style options to the "frame apply" family of
commands -- "frame apply COUNT", "frame apply level", "frame apply
all", "faas" and "tfaas".

The -q/-c/-s flags were already supported, -past-main/-past-entry is
new:

~~~
(gdb) help frame apply all
Apply a command to all frames.

Usage: frame apply all [OPTION]... COMMAND
Prints the frame location information followed by COMMAND output.

By default, an error raised during the execution of COMMAND
aborts "frame apply".

Options:
  -q
    Disables printing the frame location information.

  -c
    Print any error raised by COMMAND and continue.

  -s
    Silently ignore any errors or empty output produced by COMMAND.

  -past-main [on|off]
    Set whether backtraces should continue past "main".
    Normally the caller of "main" is not of interest, so GDB will terminate
    the backtrace at "main".  Set this if you need to see the rest
    of the stack trace.

  -past-entry [on|off]
    Set whether backtraces should continue past the entry point of a program.
    Normally there are no callers beyond the entry point of a program, so GDB
    will terminate the backtrace there.  Set this if you need to see
    the rest of the stack trace.
~~~

TAB completion of options is now supported.  Also, TAB completion of
COMMAND in "frame apply all COMMAND" does the right thing now, making
use of complete_command, added by the previous patch.  E.g.:

 (gdb) thread apply all -ascending frame apply all -past-main print -[TAB]
 -address         -elements        -pretty          -symbol
 -array           -null-stop       -repeats         -union
 -array-indexes   -object          -static-members  -vtbl
 (gdb) thread apply all -ascending frame apply all -past-main print glo[TAB]
 global1         global2

The change to tfaas_command is necessary because otherwise you get
this:

 (gdb) tfaas --
 Unrecognized option at: frame apply all -s --

That's because the above is equivalent to:

 (gdb) thread apply all -s frame apply all -s --

and the "--" instructs "thread apply" to consider everything up to
"--" as its command options.  And from that view, "frame" is an
invalid option.

The change makes tfaas be equivalent to:

 (gdb) thread apply all -s -- frame apply all -s --

gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* cli/cli-utils.c (parse_flags_qcs): Use validate_flags_qcs.
	(validate_flags_qcs): New.
	* cli/cli-utils.h (struct qcs_flags): Change field types to int.
	(validate_flags_qcs): Declare.
	* stack.c (qcs_flag_option_def, fr_qcs_flags_option_defs): New.
	(make_frame_apply_options_def_group): New.
	(frame_apply_command_count): Process options with
	gdb::option::process_options.
	(frame_apply_completer): New.
	(frame_apply_level_completer, frame_apply_all_completer)
	(frame_apply_completer): New.
	(_initialize_stack): Update help of "frame apply", "frame apply
	level", "frame apply all" and "faas" to mention supported options
	and install command completers.
	* stack.h (frame_apply_all_completer): Declare.
	* thread.c: Include "stack.h".
	(tfaas_command): Add "--".
	(_initialize_thread): Update help "tfaas" to mention supported
	options and install command completer.

gdb/testsuite/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* gdb.base/options.exp (test-frame-apply): New.
	(top level): Test print commands with different "frame apply"
	prefixes.
2019-06-13 00:22:07 +01:00
Pedro Alves 272d459434 Introduce complete_nested_command_line
This adds a completion helper routine that makes it possible for a
command that takes another command as argument, such as "frame apply
all COMMAND" as "thread apply all COMMAND", to complete on COMMAND,
and have the completion machinery recurse and complete COMMAND as if
you tried to complete "(gdb) COMMAND".  I.e., we'll be able to
complete like this, for example:

 (gdb) thread apply all -[TAB]
 -c           -ascending   -q           -s
 (gdb) thread apply all -ascending frame apply all -[TAB]
 -c           -limit       -past-entry  -past-main   -q           -s
 (gdb) thread apply all -ascending frame apply all -past-main print -[TAB]
 -address         -elements        -pretty          -symbol
 -array           -null-stop       -repeats         -union
 -array-indexes   -object          -static-members  -vtbl
 (gdb) thread apply all -ascending frame apply all -past-main print glo[TAB]
 global1         global2

Above, the completer function understands that "thread apply all" is a
command, and then parses "-ascending" successfully and understand that
the rest of the string is "thread apply all"'s operand.  And then, the
process repeats for the "frame apply" command, and on and on.

gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* completer.c (complete_nested_command_line): New.
	(gdb_completion_word_break_characters_throw): Add assertion.
	* completer.h (complete_nested_command_line): Declare.
2019-06-13 00:21:29 +01:00
Pedro Alves e2a689da55 lib/completion-support.exp: Add test_gdb_completion_offers_commands
This adds a procedure to the collection of completion-testing
routines, that allows checking whether completion offers all commands
as completion candidates.  This will be used for testing completing
"frame apply all [TAB]", "thread apply all [TAB]", etc.

gdb/testsuite/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

        * lib/completion-support.exp (test_gdb_complete_tab_multiple)
	(test_gdb_complete_cmd_multiple, test_gdb_complete_multiple): Add
	'max_completions' parameter and handle it.
	(test_gdb_completion_offers_commands): New.
2019-06-13 00:20:59 +01:00
Pedro Alves 90a1ef8762 "backtrace full/no-filters/hide" completer
"backtrace"'s completer now completes on command options:

 (gdb) bt -[TAB]
 -entry-values         -full                 -no-filters           -past-main
 -frame-arguments      -hide                 -past-entry           -raw-frame-arguments

But it doesn't know how to complete on qualifiers:

 (gdb) bt fu[TAB]
 funlockfile       futimens          futimes.c
 funlockfile.c     futimens.c        futimesat
 futex-internal.h  futimes           futimesat.c

This commit fixes that:

 (gdb) bt fu[TAB]ll
 (gdb) bt n[TAB]o-filters
 (gdb) bt h[TAB]ide

I considered teaching the gdb::option framework to handle non-'-'
options, but decided it wasn't worth it for this special case, and I'd
rather not make it easy to add new qualifier-like options.

gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* stack.c (parse_backtrace_qualifiers): New.
	(backtrace_command): Use it.
	(backtrace_command_completer): Complete on qualifiers.

gdb/testsuite/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* gdb.base/options.exp (test-backtrace): Test completing qualifiers.
2019-06-13 00:20:08 +01:00
Pedro Alves d4c16835ca Make "backtrace" support -OPT options
This adds support for comand options to the "backtrace" command.  We'll get:

  (gdb) bt -
  -entry-values         -hide                 -past-main
  -frame-arguments      -no-filters           -raw-frame-arguments
  -full                 -past-entry

~~~~
(gdb) help backtrace
Print backtrace of all stack frames, or innermost COUNT frames.
Usage: backtrace [OPTION]... [QUALIFIER]... [COUNT | -COUNT]

Options:
  -entry-values no|only|preferred|if-needed|both|compact|default
    Set printing of function arguments at function entry
    GDB can sometimes determine the values of function arguments at entry,
    in addition to their current values.  This option tells GDB whether
    to print the current value, the value at entry (marked as val@entry),
    or both.  Note that one or both of these values may be <optimized out>.

  -frame-arguments all|scalars|none
    Set printing of non-scalar frame arguments

  -raw-frame-arguments [on|off]
    Set whether to print frame arguments in raw form.
    If set, frame arguments are printed in raw form, bypassing any
    pretty-printers for that value.

  -past-main [on|off]
    Set whether backtraces should continue past "main".
    Normally the caller of "main" is not of interest, so GDB will terminate
    the backtrace at "main".  Set this if you need to see the rest
    of the stack trace.

  -past-entry [on|off]
    Set whether backtraces should continue past the entry point of a program.
    Normally there are no callers beyond the entry point of a program, so GDB
    will terminate the backtrace there.  Set this if you need to see
    the rest of the stack trace.

  -full
    Print values of local variables.

  -no-filters
    Prohibit frame filters from executing on a backtrace.

  -hide
    Causes Python frame filter elided frames to not be printed.

For backward compatibility, the following qualifiers are supported:

   full       - same as -full option.
   no-filters - same as -no-filters option.
   hide       - same as -hide.

With a negative COUNT, print outermost -COUNT frames.
~~~~

Implementation wise, this:

- Moves relevant options/settings globals to structures.
- Tweaks a number of functions to pass down references to such structures.
- Adds option_def structures describing the options/settings.
- Makes backtrace_command parse the options, with gdb::option::process_options.
- Tweaks "backtrace"'s help to describe the new options.
- Adds testcases.

Note that backtrace is a PROCESS_OPTIONS_UNKNOWN_IS_OPERAND command,
because of the "-COUNT" argument.

The COUNT/-COUNT argument is currently parsed as an expression.  I
considered whether it would be prudent here to require "--", but
concluded that the risk of causing a significant breakage here is much
lower compared to "print", since printing the expression is not the
whole point of the "backtrace" command.  Seems OK to me to require
typing "backtrace -past-main -- -p" if the user truly wants to refer
to the negative of a backtrace count stored in an inferior variable
called "p".

gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* frame.c: Include "cli/cli-option.h.
	(user_set_backtrace_options): New.
	(backtrace_past_main, backtrace_past_entry, backtrace_limit):
	Delete.
	(get_prev_frame): Adjust.
	(boolean_option_def, uinteger_option_def)
	(set_backtrace_option_defs): New.
	(_initialize_frame): Adjust and use
	gdb::option::add_setshow_cmds_for_options to install "set
	backtrace past-main" and "set backtrace past-entry".
	* frame.h: Include "cli/cli-option.h".
	(struct frame_print_options): Forward declare.
	(print_frame_arguments_all, print_frame_arguments_scalars)
	(print_frame_arguments_none): Declare.
	(print_entry_values): Delete declaration.
	(struct frame_print_options, user_frame_print_options): New.
	(struct set_backtrace_options): New.
	(set_backtrace_option_defs, user_set_backtrace_options): Declare.
	* mi/mi-cmd-stack.c (mi_cmd_stack_list_frames)
	(mi_cmd_stack_list_locals, mi_cmd_stack_list_args)
	(mi_cmd_stack_list_variables): Pass down USER_FRAME_PRINT_OPTIONS.
	(list_args_or_locals): Add frame_print_options parameter.
	(mi_cmd_stack_info_frame): Pass down USER_FRAME_PRINT_OPTIONS.
	* python/py-framefilter.c (enumerate_args): Pass down
	USER_FRAME_PRINT_OPTIONS.
	* stack.c: Include "cli/cli-option.h".
	(print_frame_arguments_all, print_frame_arguments_scalars)
	(print_frame_arguments_none): Declare.
	(print_raw_frame_arguments, print_entry_values): Delete.
	(user_frame_print_options): New.
	(boolean_option_def, enum_option_def, frame_print_option_defs):
	New.
	(struct backtrace_cmd_options): New.
	(bt_flag_option_def): New.
	(backtrace_command_option_defs): New.
	(print_stack_frame): Pass down USER_FRAME_PRINT_OPTIONS.
	(print_frame_arg, read_frame_arg, print_frame_args)
	(print_frame_info, print_frame): Add frame_print_options parameter
	and use it.
	(info_frame_command_core): Pass down USER_FRAME_PRINT_OPTIONS.
	(backtrace_command_1): Add frame_print_options and
	backtrace_cmd_options parameters and use them.
	(make_backtrace_options_def_group): New.
	(backtrace_command): Process command options with
	gdb::option::process_options.
	(backtrace_command_completer): New.
	(_initialize_stack): Extend "backtrace"'s help to mention
	supported options.  Install completer for "backtrace".
	Install some settings commands with add_setshow_cmds_for_options.

gdb/testsuite/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* gdb.base/options.exp (test-backtrace): New.
	(top level): Call it.
2019-06-13 00:19:14 +01:00
Pedro Alves 2daf894ed0 "set print raw frame-arguments" -> "set print raw-frame-arguments"
A following patch will introduce options for the "backtrace" command,
based on some "set print" and "set backtrace" settings.  There's one
setting in particular that is a bit annoying if we want to describe
the backtrace options and the settings commands using the same data
structures:

  "set print raw frame-arguments"

The problem is that space between "raw" and "frame-arguments".

Calling the option

  "bt -raw frame-arguments"

would be odd.  So I'm calling the option

  "bt -raw-frame-arguments"

instead.

And for consistency, this patch renames the set/show commands to:

 "set print raw-frame-arguments"
 "show print raw-frame-arguments"

I.e., dash instead of space.  The old commands are left in place, but
marked deprecated.

We need to adjust a couple testcases, because the relevant tests use
gdb_test_no_output and the old commands are no longer silent:

  (gdb) set print raw frame-arguments on
  Warning: command 'set print raw frame-arguments' is deprecated.
  Use 'set print raw-frame-arguments'.

gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* NEWS (Changed commands): Mention set/show print raw-frame-arguments,
	and that "set/show print raw frame-arguments" are now deprecated.

	* cli/cli-decode.c (add_setshow_boolean_cmd): Now returns the
	command.
	* command.h (add_setshow_boolean_cmd): Return cmd_list_element *.
	* stack.c (_initialize_stack): Install "set/show print
	raw-frame-arguments", and deprecate "set/show print raw
	frame-arguments".
	* valprint.c (_initialize_valprint): Deprecate "set/show print
	raw".

gdb/doc/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Print Settings): Document "set/show print
	raw-frame-arguments" instead of "set/show print raw
	frame-arguments".

gdb/testsuite/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* gdb.guile/scm-frame-args.exp: Use "set print
	raw-frame-arguments" instead of "set print raw frame-arguments".
	* gdb.python/py-frame-args.exp: Likewise.
2019-06-13 00:18:41 +01:00
Pedro Alves e6ed716cd5 Migrate rest of compile commands to new options framework
As I was in the neighbourhood, I converted the other "compile"
subcommands to the new options framework too.  Specifically, "compile
code" and "compile file".

The user-visible changes are:

  - All abbreviations of "-raw" are accepted now, instead of just -r.
    Obviously that means "-ra" is now accepted.

  - Option completion now works.

  - "compile file" did not have a completer yet, and now it knows to
    complete on filenames.

  - You couldn't use "compile file" with a file named "-something".
    You can now, with "compile file -- -something".

gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* compile/compile.c (struct compile_options): New.
	(compile_flag_option_def, compile_command_option_defs)
	(make_compile_options_def_group): New.
	(compile_file_command): Handle options with
	gdb::option::process_options.
	(compile_file_command_completer): New function.
	(compile_code_command): Handle options with
	gdb::option::process_options.
	(compile_code_command_completer): New function.
	(_initialize_compiler): Install completers for "compile code" and
	"compile file".  Mention available options in "compile code" and
	"compile code"'s help.
	* completer.c (advance_to_completion_word): New, factored out from
	...
	(advance_to_expression_complete_word_point): ... this.
	(advance_to_filename_complete_word_point): New.
	* completer.h (advance_to_filename_complete_word_point): New
	declaration.

gdb/testsuite/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* gdb.compile/compile.exp: Adjust expected output to option
	processing changes.
2019-06-13 00:18:33 +01:00
Pedro Alves 7d8062de98 Make "print" and "compile print" support -OPT options
This patch adds support for "print -option optval --", etc.
Likewise for "compile print".

We'll get:

~~~~~~
(gdb) help print
Print value of expression EXP.
Usage: print [[OPTION]... --] [/FMT] [EXP]

Options:
  -address [on|off]
    Set printing of addresses.

  -array [on|off]
    Set pretty formatting of arrays.

  -array-indexes [on|off]
    Set printing of array indexes.

  -elements NUMBER|unlimited
    Set limit on string chars or array elements to print.
    "unlimited" causes there to be no limit.

  -max-depth NUMBER|unlimited
    Set maximum print depth for nested structures, unions and arrays.
    When structures, unions, or arrays are nested beyond this depth then they
    will be replaced with either '{...}' or '(...)' depending on the language.
    Use "unlimited" to print the complete structure.

  -null-stop [on|off]
    Set printing of char arrays to stop at first null char.

  -object [on|off]
    Set printing of C++ virtual function tables.

  -pretty [on|off]
    Set pretty formatting of structures.

  -repeats NUMBER|unlimited
    Set threshold for repeated print elements.
    "unlimited" causes all elements to be individually printed.

  -static-members [on|off]
    Set printing of C++ static members.

  -symbol [on|off]
    Set printing of symbol names when printing pointers.

  -union [on|off]
    Set printing of unions interior to structures.

  -vtbl [on|off]
    Set printing of C++ virtual function tables.

Note: because this command accepts arbitrary expressions, if you
specify any command option, you must use a double dash ("--")
to mark the end of option processing.  E.g.: "print -o -- myobj".
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I want to highlight the comment above about "--".

At first, I thought we could make the print command parse the options,
and if the option wasn't recognized, fallback to parsing as an
expression.  Then, if the user wanted to disambiguate, he'd use the
"--" option delimiter.  For example, if you had a variable called
"object" and you wanted to print its negative, you'd have to do:

  (gdb) print -- -object

After getting that working, I saw that gdb.pascal/floats.exp
regressed, in these tests:

 gdb_test "print -r" " = -1\\.2(499.*|5|500.*)"
 gdb_test "print -(r)" " = -1.2(499.*|5|500.*)"
 gdb_test "print -(r + s)" " = -3\\.4(499.*|5|500.*)"

It's the first one that I found most concerning.  It regressed because
"-r" is the abbreviation of "-raw".  I realized then that the behavior
change was a bit risker than I'd like, considering scripts, wrappers
around gdb, etc., and even user expectation.  So instead, I made the
print command _require_ the "--" options delimiter if you want to
specify any option.  So:

  (gdb) print -r

is parsed as an expression, and

  (gdb) print -r --

is parsed as an option.

I noticed that that's also what lldb's expr (the equivalent of print)
does to handle the same problem.

Going back the options themselves, note that:

 - you can shorten option names, as long as unambiguous.
 - For boolean options, 0/1 stand for off/on.
 - For boolean options, "true" is implied.

So these are all equivalent:

 (gdb) print -object on -static-members off -pretty on -- foo
 (gdb) print -object -static-members off -pretty -- foo
 (gdb) print -object -static-members 0 -pretty -- foo
 (gdb) print -o -st 0 -p -- foo

TAB completion is fully supported:

  (gdb) p -[TAB]
  -address         -elements        -pretty          -symbol
  -array           -null-stop       -repeats         -union
  -array-indexes   -object          -static-members  -vtbl

Note that the code is organized such that some of the options and the
"set/show" commands code is shared.  In particular, the "print"
options and the corresponding "set print" commands are defined with
the same structures.  The commands are installed with the
gdb::option::add_setshow_cmds_for_options function.

gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* compile/compile.c: Include "cli/cli-option.h".
	(compile_print_value): Scope data pointer is now a
	value_print_options pointer; adjust.
	(compile_print_command): Process options.  Scope data pointer is
	now a value_print_options pointer; adjust.
	(_initialize_compile): Update "compile print"'s help to include
	supported options.  Install a completer for "compile print".
	* cp-valprint.c (show_vtblprint, show_objectprint)
	(show_static_field_print): Delete.
	(_initialize_cp_valprint): Don't install "set print
	static-members", "set print vtbl", "set print object" here.
	* printcmd.c: Include "cli/cli-option.h" and
	"common/gdb_optional.h".
	(print_command_parse_format): Rework to fill in a
	value_print_options instead of a format_data.
	(print_value): Change parameter type from format_data pointer to
	value_print_options reference.  Adjust.
	(print_command_1): Process options.  Adjust to pass down a
	value_print_options.
	(print_command_completer): New.
	(_initialize_printcmd): Install print_command_completer as
	handle_brkchars completer for the "print" command.  Update
	"print"'s help to include supported options.
	* valprint.c: Include "cli/cli-option.h".
	(show_vtblprint, show_objectprint, show_static_field_print): Moved
	here from cp-valprint.c.
	(boolean_option_def, uinteger_option_def)
	(value_print_option_defs, make_value_print_options_def_group):
	New.  Use gdb::option::add_setshow_cmds_for_options to install
	"set print elements", "set print null-stop", "set print repeats",
	"set print pretty", "set print union", "set print array", "set
	print address", "set print symbol", "set print array-indexes".
	* valprint.h: Include <string> and "cli/cli-option.h".
	(make_value_print_options_def_group): Declare.
	(print_value): Change parameter type from format_data pointer to
	value_print_options reference.
	(print_command_completer): Declare.

gdb/testsuite/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

	* gdb.base/options.exp: Build executable.
	(test-print): New procedure.
	(top level): Call it, once for "print" and another for "compile
	print".
2019-06-13 00:18:24 +01:00