Pedro Alves [Wed, 12 Jun 2019 23:06:53 +0000 (00:06 +0100)]
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.
Pedro Alves [Wed, 12 Jun 2019 23:06:53 +0000 (00:06 +0100)]
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.
Pedro Alves [Wed, 12 Jun 2019 23:06:53 +0000 (00:06 +0100)]
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.
Pedro Alves [Wed, 12 Jun 2019 23:06:53 +0000 (00:06 +0100)]
"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.
Pedro Alves [Wed, 12 Jun 2019 23:06:53 +0000 (00:06 +0100)]
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.
Pedro Alves [Wed, 12 Jun 2019 23:06:53 +0000 (00:06 +0100)]
"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.
Pedro Alves [Wed, 12 Jun 2019 23:06:53 +0000 (00:06 +0100)]
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.
Pedro Alves [Wed, 12 Jun 2019 23:06:53 +0000 (00:06 +0100)]
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".
Pedro Alves [Wed, 12 Jun 2019 23:06:53 +0000 (00:06 +0100)]
Introduce generic command options framework
This commit adds a generic command options framework, that makes it
easy enough to add '-'-style options to commands in a uniform way,
instead of each command implementing option parsing in its own way.
Options are defined in arrays of option_def objects (for option
definition), and the same options definitions are used for supporting
TAB completion, and also for generating the relevant help fragment of
the "help" command. See the gdb::options::build_help function, which
returns a string with the result of replacing %OPTIONS% in a template
string with an auto-generated "help" string fragment for all the
passed-in options.
Since most options in GDB are in the form of "-OPT", with a single
dash, this is the format that the framework supports.
I like to think of gdb's "-OPT" as the equivalent to getopt's long
options format ("--OPT"), and gdb's "/" as the equivalent to getopt's
short options format. getopt's short options format allows mixing
several one-character options, like "ls -als", kind of similar to
gdb's "x /FMT" and "disassemble /MOD", etc. While with gdb's "-"
options, the option is expected to have a full name, and to be
abbreviatable. E.g., "watch -location", "break -function main", etc.
This patch only deals with "-" options. The above comment serves more
to disclose why I don't think we should support mixing several
unrelated options in a single "-" option invocation, like "thread
apply -qcs" instead of "thread apply -q -c -s".
The following patches will add uses of the infrastructure to several
key commands. Most notably, "print", "compile print", "backtrace",
"frame apply" and "thread apply". I tried to add options to several
commands in order to make sure the framework didn't leave that many
open holes open.
Options use the same type as set commands -- enum var_types. So
boolean options are var_boolean, enum options are var_enum, etc. The
idea is to share code between settings commands and command options.
The "print" options will be based on the "set print" commands, and
their names will be the same. Actually, their definitions will be the
same too. There is a function to create "set/show" commands from an
array for option definitions:
/* Install set/show commands for options defined in OPTIONS. DATA is
a pointer to the structure that holds the data associated with the
OPTIONS array. */
extern void add_setshow_cmds_for_options (command_class cmd_class, void *data,
gdb::array_view<const option_def> options,
struct cmd_list_element **set_list,
struct cmd_list_element **show_list);
That will be used by several following patches.
Other features:
- You can use the "--" delimiter to explicitly indicate end of
options. Several existing commands use this token sequence for
this effect already, so this just standardizes it.
- You can shorten option names, as long as unambiguous. Currently,
some commands allow this (e.g., break -function), while others do
not (thread apply all -ascending). As GDB allows abbreviating
command names and other things, it feels more GDB-ish to allow
abbreviating option names too, to me.
- For boolean options, 0/1 stands for off/on, just like with boolean
"set" commands.
- For boolean options, "true" is implied, just like with boolean "set
commands.
These are the option types supported, with a few examples:
- boolean options (var_boolean). The option's argument is optional.
(gdb) print -pretty on -- *obj
(gdb) print -pretty off -- *obj
(gdb) print -p -- *obj
(gdb) print -p 0 -- *obj
- flag options (like var_boolean, but no option argument (on/off))
(gdb) thread apply all -s COMMAND
- enum options (var_enum)
(gdb) bt -entry-values compact
(gdb) bt -e c
- uinteger options (var_uinteger)
(gdb) print -elements 100 -- *obj
(gdb) print -e 100 -- *obj
(gdb) print -elements unlimited -- *obj
(gdb) print -e u -- *obj
- zuinteger-unlimited options (var_zuinteger_unlimited)
(gdb) print -max-depth 100 -- obj
(gdb) print -max-depth -1 -- obj
(gdb) print -max-depth unlimited -- obj
Other var_types could be supported, of course. These were just the
types that I needed for the commands that I ported over, in the
following patches.
It was interesting (and unfortunate) to find that we need at least 3
different modes to cover the existing commands:
- Commands that require ending options with "--" if you specify any
option: "print" and "compile print".
- Commands that do not want to require "--", and want to error out if
you specify an unknown option (i.e., an unknown argument that starts
with '-'): "compile code" / "compile file".
- Commands that do not want to require "--", and want to process
unknown options themselves: "bt", because of "bt -COUNT",
"thread/frame apply", because "-" is a valid command.
The different behavior is encoded in the process_options_mode enum,
passed to process_options/complete_options.
For testing, this patch adds one representative maintenance command
for each of the process_options_mode values, that are used by the
testsuite to exercise the options framework:
(gdb) maint test-options require-delimiter
(gdb) maint test-options unknown-is-error
(gdb) maint test-options unknown-is-operand
and adds another command to help with TAB-completion testing:
(gdb) maint show test-options-completion-result
See their description at the top of the maint-test-options.c file.
Docs/NEWS are in a patch later in the series.
gdb/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* Makefile.in (SUBDIR_CLI_SRCS): Add cli/cli-option.c.
(COMMON_SFILES): Add maint-test-settings.c.
* cli/cli-decode.c (boolean_enums): New global, factored out from
...
(add_setshow_boolean_cmd): ... here.
* cli/cli-decode.h (boolean_enums): Declare.
* cli/cli-option.c: New file.
* cli/cli-option.h: New file.
* cli/cli-setshow.c (parse_cli_boolean_value(const char **)): New,
factored out from ...
(parse_cli_boolean_value(const char *)): ... this.
(is_unlimited_literal): Change parameter type to pointer to
pointer. Adjust and advance ARG pointer.
(parse_cli_var_uinteger, parse_cli_var_zuinteger_unlimited)
(parse_cli_var_enum): New, factored out from ...
(do_set_command): ... this. Adjust.
* cli/cli-setshow.h (parse_cli_boolean_value)
(parse_cli_var_uinteger, parse_cli_var_zuinteger_unlimited)
(parse_cli_var_enum): Declare.
* cli/cli-utils.c: Include "cli/cli-option.h".
(get_ulongest): New.
* cli/cli-utils.h (get_ulongest): Declare.
(check_for_argument): New overloads.
* maint-test-options.c: New file.
gdb/testsuite/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* gdb.base/options.c: New file.
* gdb.base/options.exp: New file.
Pedro Alves [Wed, 12 Jun 2019 23:06:53 +0000 (00:06 +0100)]
number_or_range_parser::get_number, don't treat "1 -" as a range
While adding -OPT options to "frame apply level", I noticed that:
(gdb) frame apply level 0 -[TAB]
wasn't completing on the supported options. This commit fixes it.
We'll get instead:
(gdb) frame apply level 0 -
-c -past-entry -past-main -q -s
I added the isspace check because this case:
(gdb) frame apply level 0-
can't be an option.
Tests for this will be in a new gdb.base/options.exp file, in a
following patch. It will exercise all of:
(gdb) frame apply level 0-
(gdb) frame apply level 0 -
(gdb) frame apply level 0 --
(gdb) frame apply level 0 -- -
gdb/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* cli/cli-utils.c (number_or_range_parser::get_number): Do not
parse a range if "-" is at the end of the string.
Pedro Alves [Wed, 12 Jun 2019 23:06:52 +0000 (00:06 +0100)]
boolean/auto-boolean commands, make "o" ambiguous
We currently accept "o" with boolean/auto-boolean commands, taking it
to mean "on". But "o" is ambiguous, between "on" and "off". I can't
imagine why assuming the user wanted to type "on" is a good idea, it
might have been a typo.
This commit makes gdb error out. We now get:
(gdb) maint test-settings set boolean o
"on" or "off" expected.
(gdb) maint test-settings set auto-boolean o
"on", "off" or "auto" expected.
gdb/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* cli/cli-setshow.c (parse_auto_binary_operation)
(parse_cli_boolean_value): Don't allow "o".
gdb/testsuite/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* gdb.base/settings.exp (test-boolean, test-auto-boolean): Check
that "o" is ambiguous.
Pedro Alves [Wed, 12 Jun 2019 23:06:52 +0000 (00:06 +0100)]
New set/show testing framework (gdb.base/settings.exp)
This commit adds new representative commands for all types of settings
commands supported by gdb (enum var_types), and then uses them to
exercise settings parsing and completion.
(gdb) maint test-settings s[TAB]
set show
(gdb) maint test-settings set [TAB]
auto-boolean integer uinteger
boolean optional-filename zinteger
enum string zuinteger
filename string-noescape zuinteger-unlimited
(gdb) maint test-settings set enum [TAB]
xxx yyy zzz
etc.
This is basically unit testing, except that it goes fully via GDB. It
must be done this way in order to exercise TAB completion properly,
which must go via readline.
gdb/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* Makefile.in (COMMON_SFILES): Add maint-test-settings.c.
* NEWS: Mention maint test-settings KIND.
* maint-test-settings.c: New file.
gdb/doc/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Maintenance Commands): Document "maint
test-settings" commands.
gdb/testsuite/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* gdb.base/settings.c: New file.
* gdb.base/settings.exp: New file.
Pedro Alves [Wed, 12 Jun 2019 23:06:52 +0000 (00:06 +0100)]
gdb.base/completion.exp: Fix comment typo
Noticed this while writing the following patch. We cd to $srcdir, not $objdir.
gdb/testsuite/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* gdb.base/completion.exp: Fix comment typo.
Pedro Alves [Wed, 12 Jun 2019 23:06:52 +0000 (00:06 +0100)]
Remove "show" command completers, "set" command completers for string commands
The default command completer is symbol_completer, but it makes no
sense for a "show" command to complete on symbols, or anything else,
really.
I wonder whether we should instead make the default be no completer.
That seems like a much larger/complicated audit/change, so I'd like to
move forward with this version, as it'll be covered by tests. I
noticed this because a following patch will add a new
gdb.base/settings.exp testcase that exercises all sorts of details of
settings commands, including completing the show commands, using new
representative "maint test-settings <type or settings command>"
commands.
Also remove the completer for var_string and var_string_noescape
commands. No point in completing symbols when GDB is expecting a
string.
gdb/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* cli/cli-decode.c (add_setshow_cmd_full): Remove "show"
completer.
(add_setshow_string_cmd, add_setshow_string_noescape_cmd): Remove
"set" completers.
Pedro Alves [Wed, 12 Jun 2019 23:06:52 +0000 (00:06 +0100)]
Fix "set enum-command value junk"
With enum commands, we currently fail to notice junk after the value.
Currently:
(gdb) set print entry-values compact foo
(gdb) show print entry-values foo
Printing of function arguments at function entry is "compact".
After this fix:
(gdb) set print entry-values compact foo
Junk after item "compact": foo
gdb/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* cli/cli-setshow.c (do_set_command) <var_enum>: Detect junk
after item.
Pedro Alves [Wed, 12 Jun 2019 23:06:52 +0000 (00:06 +0100)]
Allow "unlimited" abbreviations
Currently we can abbreviate "on/off/enable/disable/yes/no" in boolean
settings,
(gdb) set non-stop of
(gdb) set non-stop en
we can abbreviate the items of enumeration commands,
(gdb) set print frame-arguments scal
(gdb) set scheduler-locking rep
but we cannot abbreviate "unlimited" in integer commands.
(gdb) set print elements u
No symbol "u" in current context.
This commit fixes that.
Testcases will be in gdb.base/settings.exp and gdb.base/options.exp,
in following patches.
gdb/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* cli/cli-setshow.c (is_unlimited_literal): Allow abbreviations.
Pedro Alves [Wed, 12 Jun 2019 23:06:52 +0000 (00:06 +0100)]
Make check_for_argument skip whitespace after arg itself
Basically every caller of check_for_argument needs to skip space after
the argument. This patch makes check_for_argument do it itself.
Suggested by Philippe Waroquiers.
gdb/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* ax-gdb.c (agent_command_1): Remove skip_spaces call.
* breakpoint.c (watch_maybe_just_location): Remove skip_spaces
call.
* cli/cli-cmds.c (apropos_command): Remove skip_spaces call.
* cli/cli-utils.c (extract_info_print_args): Remove skip_spaces
calls.
(check_for_argument): Skip spaces after argument.
Pedro Alves [Wed, 12 Jun 2019 23:06:52 +0000 (00:06 +0100)]
Fix TID parser bug
I noticed this inconsistency in the error messages below:
(gdb) print --1
Left operand of assignment is not an lvalue.
(gdb) thread apply 1 print --1
Thread 1 (Thread 0x7ffff7fb6740 (LWP 17805)):
inverted range
The "inverted range" error happens because get_number_trailer returns
0 to indicate error, but number_or_range_parser::get_number is not
checking for that. I tried detected the error there, but that doesn't
work because number_of_range_parser is used in places that _do_ want
to legitimately handle 0. IMO we should fix get_number_trailer's
interface or use something else when we want to parse 0 too.
I've decided to fix it in a different way, similarly to how
number_or_range_parser::finished was changed in commit
529c08b25ec7
("Add helper functions parse_flags and parse_flags_qcs").
Seems like a good change, even if we tweaked
number_or_range_parser::get_number, as it simplifies
thread_apply_command and makes them consistent with
number_or_range_parser::finished().
We now get the same error message in both cases:
(gdb) print --1
Left operand of assignment is not an lvalue.
(gdb) thread apply 1 print --1
Thread 1 (Thread 0x7ffff7fb6740 (LWP 17805)):
Left operand of assignment is not an lvalue.
gdb/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* thread.c (thread_apply_command): Adjust TID parsing.
* tid-parse.c (tid_range_parser::finished): Ensure parsing end is
detected before end of string.
(tid_is_in_list): Error out if LIST is invalid.
gdb/testsuite/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* gdb.multi/tids.exp: Adjust expected output. Add "thread apply 1
foo --1" test.
Pedro Alves [Wed, 12 Jun 2019 23:06:52 +0000 (00:06 +0100)]
Fix latent bug with custom word point completers
Completion routines that use a custom word point, and that then
recurse into complete_line (e.g., if we make "thread apply" a custom
word point completer, and complete on the command passed as argument),
we stumble on this latent bug:
(gdb) thread apply all pri[TAB]
(gdb) thread apply all priprint
The problem is that there's a spot in complete_line_internal_1 that
rewinds the completion word but does not reflect that change in the
custom word point in the tracker. This patch fixes it.
gdb/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* completer.c (complete_line_internal_1): Rewind completion word
point.
(completion_tracker::advance_custom_word_point_by): Change
parameter type to int.
* completer.h (completion_tracker::advance_custom_word_point_by):
Likewise.
Pedro Alves [Wed, 12 Jun 2019 23:06:52 +0000 (00:06 +0100)]
Fix latent bug in custom word point completion handling
Without this fix, if we switch the "print" completer to custom word
point handling, we regress gdb.base/completion.exp like this:
(gdb) p "break1.c FAIL: gdb.base/completion.exp: complete 'p "break1' (timeout)
The problem is that completing an expression that starts with double
quotes, and resolves to a filename, like this:
(gdb) p "break1[TAB]
would change from this, with current master:
(gdb) p "break1.c"|
^^^^^^^^^^|
\- cursor here
to this:
(gdb) p "break1.c |
^^^^^^^^^^|
\- quote replaced by space
The issue is that completer.c:advance_to_completion_word misses
telling the completion tracker to emulate readline's handling of
completing a string when rl_find_completion_word returns a delimiter.
This commit fixes the latent bug.
gdb/ChangeLog:
2019-06-13 Pedro Alves <palves@redhat.com>
* completer.c (advance_to_completion_word): Handle delimiters.
Stafford Horne [Wed, 12 Jun 2019 21:16:19 +0000 (06:16 +0900)]
opcodes/or1k: Regenerate opcodes
This picks up changes for:
- new orfpx64a32 spec additions
- new unordered instructions
- symbol and documentation updates
opcodes/ChangeLog:
* or1k-asm.c: Regenerated.
* or1k-desc.c: Regenerated.
* or1k-desc.h: Regenerated.
* or1k-dis.c: Regenerated.
* or1k-ibld.c: Regenerated.
* or1k-opc.c: Regenerated.
* or1k-opc.h: Regenerated.
* or1k-opinst.c: Regenerated.
Stafford Horne [Wed, 12 Jun 2019 21:16:19 +0000 (06:16 +0900)]
cpu/or1k: Update fpu compare symbols to imply set flag
The fpu compare symbols where not including 'sf' in the mnemonic. So
instead of `lf-sfeq` (implying set flag if operands are equal) we were
having `lf-eq`. This patch adds the 'sf'. This helps with making the
generated CGEN documentation consistent and ordered correctly.
cpu/ChangeLog:
yyyy-mm-dd Stafford Horne <shorne@gmail.com>
* or1korfpx.cpu (float-setflag-insn-base): Add 'sf' to symbol.
Stafford Horne [Wed, 12 Jun 2019 21:16:19 +0000 (06:16 +0900)]
cpu/or1k: Document no branch delay slot architectures and l.adrp
The 'nd' architectures did not mention what the 'nd' stands for.
Document that these mean 'no brach delay slot'.
cpu/ChangeLog:
yyyy-mm-dd Stafford Horne <shorne@gmail.com>
* or1k.cpu (or64nd, or32nd, or1200nd): Update comment.a
(l-adrp): Improve comment.
Stafford Horne [Wed, 12 Jun 2019 21:16:19 +0000 (06:16 +0900)]
cpu/or1k: Define unordered comparisons
Add support for new floating point unordered comparisons. These have been
defined in OpenRISC architecture proposal 7[0] and are now included in the
architecture specification 1.3.
These new instructions provide the ability for floating point comparisons to
detect NaNs.
[0] https://openrisc.io/proposals/lfsf
cpu/ChangeLog:
yyyy-mm-dd Stafford Horne <shorne@gmail.com>
* or1korfpx.cpu (insn-opcode-float-regreg): Add SFUEQ_S, SFUNE_S,
SFUGT_S, SFUGE_S, SFULT_S, SFULE_S, SFUN_S, SFUEQ_D, SFUNE_D, SFUGT_D,
SFUGE_D, SFULT_D, SFULE_D, SFUN_D opcodes.
(float-setflag-insn-base): New pmacro based on float-setflag-insn.
(float-setflag-symantics, float-setflag-unordered-cmp-symantics,
float-setflag-unordered-symantics): New pmacro for instruction
symantics.
(float-setflag-insn): Update to use float-setflag-insn-base.
(float-setflag-unordered-insn): New pmacro for generating instructions.
Stafford Horne [Wed, 12 Jun 2019 21:16:18 +0000 (06:16 +0900)]
cpu/or1k: Add support for orfp64a32 spec
This patch adds support for OpenRISC 64-bit FPU operations on 32-bit cores by
using register pairs. The functionality has been added to OpenRISC architecture
specification version 1.3 as per architecture proposal 14[0].
For supporting assembly of both 64-bit and 32-bit precision instructions we have
defined CGEN_VALIDATE_INSN_SUPPORTED. This allows cgen to use 64-bit bit
architecture assembly parsing on 64-bit toolchains and 32-bit architecture
assembly parsing on 32-bit toolchains. Without this the assembler has issues
parsing register pairs.
This patch also contains a few fixes to the symantics for existing OpenRISC
single and double precision FPU operations.
[0] https://openrisc.io/proposals/orfpx64a32
cpu/ChangeLog:
yyyy-mm-dd Andrey Bacherov <avbacherov@opencores.org>
Stafford Horne <shorne@gmail.com>
* or1k.cpu (ORFPX64A32-MACHS): New pmacro.
(ORFPX-MACHS): Removed pmacro.
* or1k.opc (or1k_cgen_insn_supported): New function.
(CGEN_VALIDATE_INSN_SUPPORTED): Define macro.
(parse_regpair, print_regpair): New functions.
* or1kcommon.cpu (h-spr, spr-shift, spr-address, h-gpr): Reorder
and add comments.
(h-fdr): Update comment to indicate or64.
(reg-pair-reg-lo, reg-pair-reg-hi): New pmacros for register pairs.
(h-fd32r): New hardware for 64-bit fpu registers.
(h-i64r): New hardware for 64-bit int registers.
* or1korbis.cpu (f-resv-8-1): New field.
* or1korfpx.cpu (rDSF, rASF, rBSF): Update attribute to ORFPX32-MACHS.
(rDDF, rADF, rBDF): Update operand comment to indicate or64.
(f-rdoff-10-1, f-raoff-9-1, f-rboff-8-1): New fields.
(h-roff1): New hardware.
(double-field-and-ops mnemonic): New pmacro to generate operations
rDD32F, rAD32F, rBD32F, rDDI and rADI.
(float-regreg-insn): Update single precision generator to MACH
ORFPX32-MACHS. Add generator for or32 64-bit instructions.
(float-setflag-insn): Update single precision generator to MACH
ORFPX32-MACHS. Fix double instructions from single to double
precision. Add generator for or32 64-bit instructions.
(float-cust-insn cust-num): Update single precision generator to MACH
ORFPX32-MACHS. Add generator for or32 64-bit instructions.
(lf-rem-s, lf-itof-s, lf-ftoi-s, lf-madd-s): Update MACH to
ORFPX32-MACHS.
(lf-rem-d): Fix operation from mod to rem.
(lf-rem-d32, lf-itof-d32, lf-ftoi-d32, lf-madd-d32): New instruction.
(lf-itof-d): Fix operands from single to double.
(lf-ftoi-d): Update operand mode from DI to WI.
Peter Bergner [Wed, 12 Jun 2019 20:51:01 +0000 (15:51 -0500)]
Add missing ChangeLog entries
Peter Bergner [Wed, 12 Jun 2019 20:48:53 +0000 (15:48 -0500)]
Remove the ldmx mnemonic that never made it into POWER9.
opcodes/
* ppc-opc.c (powerpc_opcodes) <ldmx>: Delete mnemonic.
gas/
* testsuite/gas/ppc/power9.d: Delete ldmx tests.
* testsuite/gas/ppc/power9.s: Likewise.
Adam Lackorzymski [Wed, 12 Jun 2019 14:05:21 +0000 (15:05 +0100)]
Prevent a seg-fault from objdup when disassembling binaries which do not contain a symbol table.
PR 24643
* elf32-arm.c (arm_elf_find_function): Fail if the symol table is
absent, or the bfd is not in the ELF formart.
* elfnn-aarch64.c (aarch64_elf_find_function): Likewise.
Christos Zoulas [Wed, 12 Jun 2019 13:51:17 +0000 (14:51 +0100)]
Add support for NetBSD PaX notes to readelf.
PR 24663
* readelf.c (process_netbsd_elf_note): Add support for
NT_NETBSD_PAX.
(process_note): Add support for PaX notes.
Christos Zoulas [Wed, 12 Jun 2019 13:35:04 +0000 (14:35 +0100)]
Add support for NetBSD/sh3 core reg sections to readelf.
PR 24665
* readelf.c (get_netbsd_elfcore_note_type): Add support for SH
core notes.
Christos Zoulas [Wed, 12 Jun 2019 12:52:04 +0000 (13:52 +0100)]
Add support to readelf to display NetBSD auxv notes in core files.
PR 24664
* readelf.c (get_netbsd_elfcore_note_type): Add support for NetBSD
auxv notes.
GDB Administrator [Wed, 12 Jun 2019 00:00:16 +0000 (00:00 +0000)]
Automatic date update in version.in
Pedro Alves [Tue, 11 Jun 2019 19:37:09 +0000 (20:37 +0100)]
Dwarf: Don't add nameless modules to partial symbol table (ChangeLogs)
Add missing ChangeLog entries for previous commit.
gdb/ChangeLog:
2019-06-11 Bernhard Heckel <bernhard.heckel@intel.com>
* dwarf2read.c (add_partial_symbol): Skip nameless modules.
gdb/testsuite/Changelog:
2019-06-11 Bernhard Heckel <bernhard.heckel@intel.com>
* gdb.fortran/block-data.f: New.
* gdb.fortran/block-data.exp: New.
Bernhard Heckel [Wed, 27 Feb 2019 14:21:12 +0000 (15:21 +0100)]
Dwarf: Don't add nameless modules to partial symbol table
A name for BLOCK DATA in Fortran is optional. If no name has been
assigned, GDB crashes during read-in of DWARF when BLOCK DATA is
represented via DW_TAG_module. BLOCK DATA is used for one-time
initialization of non-pointer variables in named common blocks.
As of now there is no issue when gfortran is used as DW_TAG_module is
not emitted. However, with Intel ifort the nameless DW_TAG_module is
present and has the following form:
...
<1><dd>: Abbrev Number: 7 (DW_TAG_module)
<de> DW_AT_decl_line : 46
<df> DW_AT_decl_file : 1
<e0> DW_AT_description : (indirect string, offset: 0x110): block
data
<e4> DW_AT_high_pc : 0x402bb7
<ec> DW_AT_low_pc : 0x402bb7
...
The missing name leads to a crash in add_partial_symbol, during length
calculation.
gdb/ChangeLog:
2019-06-11 Bernhard Heckel <bernhard.heckel@intel.com>
* dwarf2read.c (add_partial_symbol): Skip nameless modules.
gdb/testsuite/Changelog:
2019-06-11 Bernhard Heckel <bernhard.heckel@intel.com>
* gdb.fortran/block-data.f: New.
* gdb.fortran/block-data.exp: New.
Christos Zoulas [Tue, 11 Jun 2019 15:43:25 +0000 (16:43 +0100)]
Add support for reporting Alpha and Vax symbol visibility in readelf.
PR 24662
* readelf.c (get_alpha_symbol_other): New function.
(get_symbol_other): Use for Alpha symbols.
(is_32bit_pcrel_reloc): Add R_VAX_PCREL32.
Tom Tromey [Wed, 29 May 2019 21:49:10 +0000 (15:49 -0600)]
Move gdb's xmalloc and friends to new file
When "common" becomes a library, linking will cause a symbol clash,
because "xmalloc" and some related symbols are defined in that
library, libiberty, and readline.
To work around this problem, this patch moves the clashing symbols to
a new file, which is then compiled separately for both gdb and
gdbserver.
gdb/ChangeLog
2019-06-11 Tom Tromey <tom@tromey.com>
* common/common-utils.c (xmalloc, xrealloc, xcalloc)
(xmalloc_failed): Move to alloc.c.
* alloc.c: New file.
* Makefile.in (COMMON_SFILES): Add alloc.c.
gdb/gdbserver/ChangeLog
2019-06-11 Tom Tromey <tom@tromey.com>
* Makefile.in (SFILES): Add alloc.c.
(OBS): Add alloc.o.
(IPA_OBJS): Add alloc-ipa.o.
(alloc-ipa.o): New target.
(%.o: ../%.c): New pattern rule.
Tom Tromey [Mon, 6 May 2019 00:28:13 +0000 (18:28 -0600)]
Remove linux-waitpid.c debugging code
The debugging code in linux-waitpid.c is one of the few remaining
spots that depends on the gdb/gdbserver difference.
My first thought was that this code is not extremely useful, so this
patch removes this code. (However, if it is actually useful to
someone, we could make it work by introducing a new abstraction.)
gdb/ChangeLog
2019-06-11 Tom Tromey <tom@tromey.com>
* nat/linux-waitpid.c: Don't include server.h.
(linux_debug): Remove.
(my_waitpid): Update.
Christos Zoulas [Tue, 11 Jun 2019 13:36:47 +0000 (14:36 +0100)]
Fix an unitinitalised local variable in decode_arm_unwind().
PR 24661
* readelf.c (decode_arm_unwind): Ensure that the local variable
'addr' is always initialised.
Tom Tromey [Tue, 4 Jun 2019 12:17:09 +0000 (06:17 -0600)]
Remove trailing newlines from help text
I noticed recently that some command had a trailing newline in its
"help" output. So, I temporarily hacked cli-decode.c to print
something when a new command was installed that had a trailing newline
in its help message, and wrote this patch, which removes all the ones
I could find this way. (There could still be a few more in *-nat
files.)
Tested on x86-64 Fedora 29.
gdb/ChangeLog
2019-06-11 Tom Tromey <tromey@adacore.com>
* infcall.c (_initialize_infcall): Remove trailing newline from
help.
* user-regs.c (_initialize_user_regs): Remove trailing newline
from help.
* typeprint.c (_initialize_typeprint): Remove trailing newline
from help.
* reverse.c (_initialize_reverse): Remove trailing newlines from
help.
* tracepoint.c (_initialize_tracepoint): Remove trailing newlines
from help.
* language.c (add_set_language_command): Remove trailing newline
from help.
* infcmd.c (_initialize_infcmd): Remove trailing newlines from
help.
* disasm.c (_initialize_disasm): Remove trailing newline from
help.
* top.c (init_main): Remove trailing newline from help.
* interps.c (_initialize_interpreter): Remove trailing newline
from help.
* btrace.c (_initialize_btrace): Remove trailing newlines from
help.
* breakpoint.c (_initialize_breakpoint): Remove trailing newline
from help.
* python/python.c (_initialize_python): Remove trailing newline
from help.
* spu-tdep.c (_initialize_spu_tdep): Remove trailing newlines from
help.
* tui/tui-win.c (_initialize_tui_win): Remove trailing newlines
from help. Reformat some text.
* tui/tui-stack.c (_initialize_tui_stack): Remove trailing newline
from help.
* tui/tui-layout.c (_initialize_tui_layout): Remove trailing
newline from help.
Tom de Vries [Tue, 11 Jun 2019 11:54:10 +0000 (13:54 +0200)]
[gdb/testsuite] Fix remove-inferiors.exp FAIL with readnow board
We see this failure with the readnow board:
...
FAIL: gdb.multi/remove-inferiors.exp: load binary
...
When running with board readnow, an extra message "Expanding full symbols" is
emitted after the "Reading symbols" message, and the regexp corresponding to
the FAIL only allows the first message.
Fix this by allowing the extra message in the regexp.
gdb/testsuite/ChangeLog:
2019-06-11 Tom de Vries <tdevries@suse.de>
PR testsuite/24521
* gdb.multi/remove-inferiors.exp: Allow "Expanding full symbols"
message.
Tom Tromey [Mon, 10 Jun 2019 20:49:04 +0000 (22:49 +0200)]
Remove shadowing from darwin-nat.c
Building on Darwin with gcc showed that darwin-nat.c had some
shadowing variable declarations. This removes them.
gdb/ChangeLog
2019-06-11 Tom Tromey <tromey@adacore.com>
* darwin-nat.c (darwin_decode_exception_message)
(darwin_decode_message, darwin_nat_target::kill): Fix shadowing.
Tom de Vries [Tue, 11 Jun 2019 11:22:27 +0000 (13:22 +0200)]
[gdb/testsuite] Fix main high_pc in nonvar-access.exp
When running gdb.dwarf2/nonvar-access.exp with board readnow, we have:
...
FAIL: gdb.dwarf2/nonvar-access.exp: print/x def_implicit_s
...
and 12 more similar failures.
I've tracked this down to the range of main being hardcoded to
[_main, _main+0x10000) in the dwarf assembly:
...
DW_TAG_subprogram {
{name main}
{DW_AT_external 1 flag}
{low_pc [gdb_target_symbol main] DW_FORM_addr}
{high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr}
} {
...
which overlaps with the .debug_info for the elf-init.c CU (containing
__libc_csu_init and __libc_csu_fini).
Fix this by using function_range to find the actual range of main.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2019-06-11 Tom de Vries <tdevries@suse.de>
PR testsuite/24521
* gdb.dwarf2/nonvar-access.exp: Fix main high_pc.
Tom de Vries [Tue, 11 Jun 2019 07:42:56 +0000 (09:42 +0200)]
[gdb/testsuite] Add readnow.exp
Add a target board to test -readnow.
gdb/testsuite/ChangeLog:
2019-06-11 Tom de Vries <tdevries@suse.de>
* boards/readnow.exp: New file.
GDB Administrator [Tue, 11 Jun 2019 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in
Andrew Burgess [Thu, 23 May 2019 18:49:41 +0000 (19:49 +0100)]
gdb: Check for not allocated/associated values during array slicing
When extracting an array slice we should give up if the array is
not-allocated or not-associated. For Fortran, at least in gfortran
compiled code, the upper and lower bounds are undefined if the array
is not allocated or not associated, in which case performing checks
against these bounds will result in undefined behaviour.
Better then to throw an error if we try to slice such an array. This
changes the error message that the user will receive in these
cases (if they got an error message before). Previously they may have
gotten "slice out of range" now they'll get "array not allocated" or
"array not associated".
gdb/ChangeLog:
* valops.c (value_slice): Check for not allocated or not
associated values.
gdb/testsuite/ChangeLog:
* gdb.fortran/vla-sizeof.exp: Update expected results.
Tom de Vries [Mon, 10 Jun 2019 18:27:09 +0000 (20:27 +0200)]
[gdb] Fix heap-buffer-overflow in cp_find_first_component_aux
When compiling gdb with '-lasan -fsanitizer=address' and running tests with:
- export ASAN_OPTIONS="detect_leaks=0:alloc_dealloc_mismatch=0",
- target board cc-with-gdb-index,
- the "[gdb/testsuite] Fix gdb.base/break-probes.exp with native-gdbserver"
commit reverted to avoid running into PR24617,
we get with gdb.arch/amd64-init-x87-values.exp:
...
==31229==ERROR: AddressSanitizer: heap-buffer-overflow on address \
0x62500098c93c at pc 0x000000bcc748 bp 0x7ffe39487660 sp 0x7ffe39487658
READ of size 1 at 0x62500098c93c thread T0
#0 0xbcc747 in cp_find_first_component_aux src/gdb/cp-support.c:999
#1 0xbcc6e9 in cp_find_first_component(char const*) \
src/gdb/cp-support.c:977
#2 0xcc2cf3 in mapped_index_base::build_name_components() \
src/gdb/dwarf2read.c:4499
#3 0xcc3322 in dw2_expand_symtabs_matching_symbol src/gdb/dwarf2read.c:4552
#4 0xcc817f in dw2_expand_symtabs_matching src/gdb/dwarf2read.c:5228
#5 0xfe8f48 in iterate_over_all_matching_symtabs src/gdb/linespec.c:1147
#6 0x1003506 in add_matching_symbols_to_info src/gdb/linespec.c:4413
#7 0xffe21b in find_function_symbols src/gdb/linespec.c:3886
#8 0xffe4a2 in find_linespec_symbols src/gdb/linespec.c:3914
#9 0xfee3ad in linespec_parse_basic src/gdb/linespec.c:1865
#10 0xff5128 in parse_linespec src/gdb/linespec.c:2655
#11 0xff8872 in event_location_to_sals src/gdb/linespec.c:3150
#12 0xff90a8 in decode_line_full(event_location const*, int, \
program_space*, symtab*, int, linespec_result*, \
char const*, char const*) src/gdb/linespec.c:3230
#13 0x9ce449 in parse_breakpoint_sals src/gdb/breakpoint.c:9057
#14 0x9ea022 in create_sals_from_location_default src/gdb/breakpoint.c:13708
#15 0x9e2c1f in bkpt_create_sals_from_location src/gdb/breakpoint.c:12514
#16 0x9cff06 in create_breakpoint(gdbarch*, event_location const*, \
char const*, int, char const*, int, int, bptype, int, \
auto_boolean, breakpoint_ops const*, int, int, int, \
unsigned int) src/gdb/breakpoint.c:9238
#17 0x9d114a in break_command_1 src/gdb/breakpoint.c:9402
#18 0x9d1b60 in break_command(char const*, int) src/gdb/breakpoint.c:9473
#19 0xac96aa in do_const_cfunc src/gdb/cli/cli-decode.c:106
#20 0xad0e5a in cmd_func(cmd_list_element*, char const*, int) \
src/gdb/cli/cli-decode.c:1892
#21 0x15226f6 in execute_command(char const*, int) src/gdb/top.c:630
#22 0xddde37 in command_handler(char const*) src/gdb/event-top.c:586
#23 0xdde7c1 in command_line_handler(std::unique_ptr<char, \
gdb::xfree_deleter<char> >&&) src/gdb/event-top.c:773
#24 0xddc9e8 in gdb_rl_callback_handler src/gdb/event-top.c:217
#25 0x16f2198 in rl_callback_read_char src/readline/callback.c:220
#26 0xddc5a1 in gdb_rl_callback_read_char_wrapper_noexcept \
src/gdb/event-top.c:175
#27 0xddc773 in gdb_rl_callback_read_char_wrapper src/gdb/event-top.c:192
#28 0xddd9f5 in stdin_event_handler(int, void*) src/gdb/event-top.c:514
#29 0xdd7d8f in handle_file_event src/gdb/event-loop.c:731
#30 0xdd8607 in gdb_wait_for_event src/gdb/event-loop.c:857
#31 0xdd629c in gdb_do_one_event() src/gdb/event-loop.c:321
#32 0xdd6344 in start_event_loop() src/gdb/event-loop.c:370
#33 0x10a7715 in captured_command_loop src/gdb/main.c:331
#34 0x10aa548 in captured_main src/gdb/main.c:1173
#35 0x10aa5d8 in gdb_main(captured_main_args*) src/gdb/main.c:1188
#36 0x87bd35 in main src/gdb/gdb.c:32
#37 0x7f16e1434f89 in __libc_start_main (/lib64/libc.so.6+0x20f89)
#38 0x87bb49 in _start (build/gdb/gdb+0x87bb49)
0x62500098c93c is located 0 bytes to the right of 8252-byte region \
[0x62500098a900,0x62500098c93c)
allocated by thread T0 here:
#0 0x7f16e359a600 in malloc (/usr/lib64/libasan.so.5+0xeb600)
#1 0x1742ddf in bfd_malloc src/bfd/libbfd.c:275
#2 0x1738824 in bfd_get_full_section_contents src/bfd/compress.c:253
#3 0xe30044 in gdb_bfd_map_section(bfd_section*, unsigned long*) \
src/gdb/gdb_bfd.c:704
#4 0xcb56bf in dwarf2_read_section(objfile*, dwarf2_section_info*) \
src/gdb/dwarf2read.c:2539
#5 0xd5bcd0 in get_gdb_index_contents_from_section<dwarf2_per_objfile> \
src/gdb/dwarf2read.c:6217
#6 0xd7fc7d in gdb::function_view<gdb::array_view<unsigned char const> \
(...) const src/gdb/common/function-view.h:284
#7 0xd7fddd in gdb::function_view<gdb::array_view<unsigned char const> \
(...) src/gdb/common/function-view.h:278
#8 0xd730cf in gdb::function_view<gdb::array_view<unsigned char const> \
(...) const src/gdb/common/function-view.h:247
#9 0xcbc7ee in dwarf2_read_gdb_index src/gdb/dwarf2read.c:3582
#10 0xcce731 in dwarf2_initialize_objfile(objfile*, dw_index_kind*) \
src/gdb/dwarf2read.c:6297
#11 0xdb88c4 in elf_symfile_read src/gdb/elfread.c:1256
#12 0x141262a in read_symbols src/gdb/symfile.c:798
#13 0x14140a7 in syms_from_objfile_1 src/gdb/symfile.c:1000
#14 0x1414393 in syms_from_objfile src/gdb/symfile.c:1017
#15 0x1414fb7 in symbol_file_add_with_addrs src/gdb/symfile.c:1124
#16 0x14159b7 in symbol_file_add_from_bfd(bfd*, char const*, \
enum_flags<symfile_add_flag>, std::vector<other_sections, \
std::allocator<other_sections> >*, \
enum_flags<objfile_flag>, objfile*) src/gdb/symfile.c:1203
#17 0x1415b6c in symbol_file_add(char const*,
enum_flags<symfile_add_flag>, std::vector<other_sections, \
std::allocator<other_sections> >*, \
enum_flags<objfile_flag>) src/gdb/symfile.c:1216
#18 0x1415f2f in symbol_file_add_main_1 src/gdb/symfile.c:1240
#19 0x1418599 in symbol_file_command(char const*, int) \
src/gdb/symfile.c:1675
#20 0xde2fa6 in file_command src/gdb/exec.c:433
#21 0xac96aa in do_const_cfunc src/gdb/cli/cli-decode.c:106
#22 0xad0e5a in cmd_func(cmd_list_element*, char const*, int) \
src/gdb/cli/cli-decode.c:1892
#23 0x15226f6 in execute_command(char const*, int) src/gdb/top.c:630
#24 0xddde37 in command_handler(char const*) src/gdb/event-top.c:586
#25 0xdde7c1 in command_line_handler(std::unique_ptr<char, \
gdb::xfree_deleter<char> >&&) src/gdb/event-top.c:773
#26 0xddc9e8 in gdb_rl_callback_handler src/gdb/event-top.c:217
#27 0x16f2198 in rl_callback_read_char src/readline/callback.c:220
#28 0xddc5a1 in gdb_rl_callback_read_char_wrapper_noexcept \
src/gdb/event-top.c:175
#29 0xddc773 in gdb_rl_callback_read_char_wrapper src/gdb/event-top.c:192
SUMMARY: AddressSanitizer: heap-buffer-overflow src/gdb/cp-support.c:999 in \
cp_find_first_component_aux
Shadow bytes around the buggy address:
0x0c4a801298d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c4a801298e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c4a801298f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c4a80129900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c4a80129910: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c4a80129920: 00 00 00 00 00 00 00[04]fa fa fa fa fa fa fa fa
0x0c4a80129930: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c4a80129940: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c4a80129950: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c4a80129960: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c4a80129970: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==31229==ABORTING
...
The problem happens as follows.
The executable amd64-init-x87-values gets an index (due to target board
cc-with-gdb-index), which looks as follows:
...
Hex dump of section '.gdb_index':
0x00000000
08000000 18000000 28000000 28000000 ........(...(...
0x00000010
3c000000 3c200000 00000000 00000000 <...< ..........
0x00000020
2e000000 00000000 d4004000 00000000 ..........@.....
0x00000030
db004000 00000000 00000000 00000000 ..@.............
0x00000040
00000000 00000000 00000000 00000000 ................
0x00000050
00000000 00000000 00000000 00000000 ................
... more zeroes ...
0x00002010
00000000 00000000 00000000 00000000 ................
0x00002020
00000000 00000000 00000000 00000000 ................
0x00002030
00000000 00000000 00000000 ............
...
The structure of this index is:
...
header : [0x0, 0x18) : size 0x18
culist : [0x18 ,0x28) : size 0x10
typesculist : [0x28, 0x28) : size 0x0
adress area : [0x28, 0x3c) : size 0x14
symbol table : [0x3c, 0x203c) : size 0x2000
constant pool: [0x203c, 0x203c): size 0x0
EOF : 0x203c
...
Note that the symbol table consists entirely of empty slots (where an empty
slot is a pair of 32-bit zeroes), and that the constant pool is empty.
The problem happens here in mapped_index_base::build_name_components:
...
auto count = this->symbol_name_count ();
for (offset_type idx = 0; idx < count; idx++)
{
if (this->symbol_name_slot_invalid (idx))
continue;
const char *name = this->symbol_name_at (idx);
...
when accessing the slot at idx == 0 in the symbol table,
symbol_name_slot_invalid returns false so we calculate name, which is
calculated using 'constant_pool + symbol_table[idx].name', which means we get
name == constant_pool. And given that the constant pool is empty, name now
points past the memory allocated for the index, and when we access name[0] for
the first time in cp_find_first_component_aux, we run into the
heap-buffer-overflow.
Fix this by fixing the definition of symbol_name_slot_invalid:
...
- return bucket.name == 0 && bucket.vec;
+ return bucket.name == 0 && bucket.vec == 0;
...
Tested on x86_64-linux.
gdb/ChangeLog:
2019-06-10 Tom de Vries <tdevries@suse.de>
PR gdb/24618
* dwarf2read.c (struct mapped_index::symbol_name_slot_invalid): Make
sure an empty slot (defined by a 32-bit zero pair) is recognized as
invalid.
Tom de Vries [Mon, 10 Jun 2019 18:17:14 +0000 (20:17 +0200)]
[gdb] Fix dynamic-stack-buffer-overflow in linespec_lexer_lex_string
When compiling gdb with '-lasan -fsanitizer=address' and running tests with
'export ASAN_OPTIONS="detect_leaks=0:alloc_dealloc_mismatch=0"', I run into:
...
ERROR: GDB process no longer exists
UNRESOLVED: gdb.linespec/cpls-abi-tag.exp: \
test_abi_tag: completion: at tag: tab complete "b test_abi_tag_function[abi:"
...
In more detail:
...
==3637==ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address \
0x7fff5952bbdd at pc 0x000000fe5c57 bp 0x7fff5952af30 sp 0x7fff5952af28
READ of size 1 at 0x7fff5952bbdd thread T0
#0 0xfe5c56 in linespec_lexer_lex_string src/gdb/linespec.c:727
#1 0xfe7473 in linespec_lexer_lex_one src/gdb/linespec.c:946
#2 0xfe799d in linespec_lexer_consume_token src/gdb/linespec.c:982
#3 0xff446d in parse_linespec src/gdb/linespec.c:2564
#4 0xff78be in linespec_complete(completion_tracker&, char const*, \
symbol_name_match_type) src/gdb/linespec.c:2961
#5 0xb9299c in complete_address_and_linespec_locations \
src/gdb/completer.c:573
#6 0xb93e90 in location_completer(cmd_list_element*, completion_tracker&, \
char const*, char const*) src/gdb/completer.c:919
#7 0xb940c5 in location_completer_handle_brkchars src/gdb/completer.c:956
#8 0xb957ec in complete_line_internal_normal_command \
src/gdb/completer.c:1208
#9 0xb96507 in complete_line_internal_1 src/gdb/completer.c:1430
#10 0xb965c2 in complete_line_internal src/gdb/completer.c:1449
#11 0xb98630 in gdb_completion_word_break_characters_throw \
src/gdb/completer.c:1862
#12 0xb98838 in gdb_completion_word_break_characters() \
src/gdb/completer.c:1897
#13 0x16c6362 in _rl_find_completion_word src/readline/complete.c:943
#14 0x16ca8d0 in rl_complete_internal src/readline/complete.c:1843
#15 0x16c460c in rl_complete src/readline/complete.c:408
#16 0x16b3368 in _rl_dispatch_subseq src/readline/readline.c:774
#17 0x16b3092 in _rl_dispatch src/readline/readline.c:724
#18 0x16b2939 in readline_internal_char src/readline/readline.c:552
#19 0x16f1fb0 in rl_callback_read_char src/readline/callback.c:201
#20 0xddc5a1 in gdb_rl_callback_read_char_wrapper_noexcept \
src/gdb/event-top.c:175
#21 0xddc773 in gdb_rl_callback_read_char_wrapper src/gdb/event-top.c:192
#22 0xddd9f5 in stdin_event_handler(int, void*) src/gdb/event-top.c:514
#23 0xdd7d8f in handle_file_event src/gdb/event-loop.c:731
#24 0xdd8607 in gdb_wait_for_event src/gdb/event-loop.c:857
#25 0xdd629c in gdb_do_one_event() src/gdb/event-loop.c:321
#26 0xdd6344 in start_event_loop() src/gdb/event-loop.c:370
#27 0x10a7715 in captured_command_loop src/gdb/main.c:331
#28 0x10aa548 in captured_main src/gdb/main.c:1173
#29 0x10aa5d8 in gdb_main(captured_main_args*) src/gdb/main.c:1188
#30 0x87bd35 in main src/gdb/gdb.c:32
#31 0x7fb0364c6f89 in __libc_start_main (/lib64/libc.so.6+0x20f89)
#32 0x87bb49 in _start (build/gdb/gdb+0x87bb49)
Address 0x7fff5952bbdd is located in stack of thread T0 at offset 557 in frame
#0 0xb93702 in location_completer(cmd_list_element*, completion_tracker&, \
char const*, char const*) src/gdb/completer.c:831
This frame has 4 object(s):
[32, 40) 'copy'
[96, 104) 'location'
[160, 168) 'text'
[224, 256) 'completion_info' <== Memory access at offset 557 overflows \
this variable
HINT: this may be a false positive if your program uses some custom stack \
unwind mechanism or swapcontext
(longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: dynamic-stack-buffer-overflow \
src/gdb/linespec.c:727 in linespec_lexer_lex_string
Shadow bytes around the buggy address:
0x10006b29d720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10006b29d730: 00 00 00 00 00 00 f1 f1 f1 f1 00 f2 f2 f2 f2 f2
0x10006b29d740: f2 f2 00 f2 f2 f2 f2 f2 f2 f2 00 f2 f2 f2 f2 f2
0x10006b29d750: f2 f2 00 00 00 00 f3 f3 f3 f3 00 00 00 00 00 00
0x10006b29d760: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x10006b29d770: 00 00 00 00 ca ca ca ca 00 00 00[05]cb cb cb cb
0x10006b29d780: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
0x10006b29d790: 00 f2 f2 f2 f2 f2 f2 f2 00 f2 f2 f2 f3 f3 f3 f3
0x10006b29d7a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10006b29d7b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10006b29d7c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==3637==ABORTING
...
The problem happens in linespec_lexer_lex_string when lexing
"b test_abi_tag_function[abi:\0" (using a notation where we make the implicit
terminating \0 explicit).
We arrrive here with (PARSER_STREAM (parser)) == ":\0":
...
/* Do not tokenize ABI tags such as "[abi:cxx11]". */
else if (PARSER_STREAM (parser) - start > 4
&& startswith (PARSER_STREAM (parser) - 4, "[abi"))
++(PARSER_STREAM (parser));
...
and consume ':', after which we end up here and consume '\0':
...
/* Advance the stream. */
++(PARSER_STREAM (parser));
...
after which (PARSER_STREAM (parser)) points past the end of the string.
Fix this by removing the first "++(PARSER_STREAM (parser))", and add an assert
to the second one to detect moving past the end-of-string.
Build and tested on x86_64-linux.
gdb/ChangeLog:
2019-06-10 Tom de Vries <tdevries@suse.de>
PR gdb/24611
* linespec.c (linespec_lexer_lex_string): Remove incorrect
"++(PARSER_STREAM (parser))" for "[abi"-prefixed colon. Add assert.
Tom de Vries [Mon, 10 Jun 2019 18:05:04 +0000 (20:05 +0200)]
[gdb/symtab] Fix symbol loading performance regression
The commit "[gdb/symtab] Fix language of duplicate static minimal symbol"
introduces a performance regression, when loading a cc1 executable build with
-O0 -g and gcc 7.4.0. The performance regression, measured in 'real' time is
about 175%.
The slower execution comes from the fact that the fix in symbol_set_names
makes the call to symbol_find_demangled_name unconditional.
Fix this by reverting the commit, and redoing the fix as follows.
Recapturing the original problem, the first time symbol_set_names is called
with gsymbol.language == lang_auto and linkage_name == "_ZL3foov", the name is
not present in the per_bfd->demangled_names_hash hash table, so
symbol_find_demangled_name is called to demangle the name, after which the
mangled/demangled pair is added to the hashtable. The call to
symbol_find_demangled_name also sets gsymbol.language to lang_cplus.
The second time symbol_set_names is called with gsymbol.language == lang_auto
and linkage_name == "_ZL3foov", the name is present in the hash table, so the
demangled name from the hash table is used. However, the language of the
symbol remains lang_auto.
Fix this by adding a field language in struct demangled_name_entry, and using
the field in symbol_set_names to set the language of gsymbol, if necessary.
Tested on x86_64-linux.
gdb/ChangeLog:
2019-06-10 Tom de Vries <tdevries@suse.de>
PR symtab/24545
* symtab.c (struct demangled_name_entry): Add language field.
(symbol_set_names): Revert "[gdb/symtab] Fix language of duplicate
static minimal symbol". Set and use language field.
Nick Clifton [Mon, 10 Jun 2019 14:30:02 +0000 (15:30 +0100)]
Fix printing large decimal values in strings.
PR 24651
* strings.c (print_strings): Use %u to print unsigned values in
decimal.
Tom Tromey [Mon, 3 Jun 2019 15:25:39 +0000 (09:25 -0600)]
Update help text in ada-lang.c
I noticed that the "catch assert" help text erroneously claimed to
accept an argument, and while fixing this I went ahead and added
"Usage" text and made other minor updates to the commands in
ada-lang.c.
Tested on x86-64 Fedora 29.
gdb/ChangeLog
2019-06-10 Tom Tromey <tromey@adacore.com>
* ada-lang.c (_initialize_ada_language): Update help text.
Tom Tromey [Mon, 3 Jun 2019 14:07:29 +0000 (08:07 -0600)]
Remove newlines from warnings
ARI pointed out that a recent patch introduced a call to "warning"
with a string that ended in a newline:
https://sourceware.org/ml/gdb-patches/2019-06/msg00000.html
This is generally forbidden, I believe, because warning adds its own
newline.
This patch removes all of the trailing newlines I was able to find. I
searched for 'warning (.*\\n"' and then fixed the ones where the
newline appeared at the end of the string (some had internal
newlines).
Tested on x86-64 Fedora 29.
gdb/ChangeLog
2019-06-10 Tom Tromey <tromey@adacore.com>
* m32c-tdep.c (m32c_m16c_address_to_pointer): Don't end warning
with a newline.
* guile/guile.c (handle_boot_error): Don't end warning with a
newline.
* cli/cli-cmds.c (exit_status_set_internal_vars): Don't end
warning with a newline.
* s12z-tdep.c (s12z_skip_prologue): Don't end warning with a
newline.
(s12z_frame_cache): Likewise.
* dwarf-index-cache.c (index_cache::store): Don't end warning with
a newline.
* solib-svr4.c (disable_probes_interface): Don't end warning with
a newline.
* nat/fork-inferior.c (fork_inferior): Don't end warning with a
newline.
* python/python.c (do_finish_initialization): Don't end warning
with a newline.
gdb/gdbserver/ChangeLog
2019-06-10 Tom Tromey <tromey@adacore.com>
* remote-utils.c (look_up_one_symbol, relocate_instruction): Don't
end warning with a newline.
* linux-s390-low.c (s390_get_wordsize): Don't end warning with a
newline.
* thread-db.c (attach_thread): Don't end warning with a newline.
(thread_db_notice_clone): Likewise.
* tracepoint.c (gdb_agent_helper_thread): Don't end warning with a
newline.
* linux-x86-low.c (x86_get_min_fast_tracepoint_insn_len): Don't
end warning with a newline.
Christos Zoulas [Mon, 10 Jun 2019 13:41:35 +0000 (14:41 +0100)]
Add support for NetBSD/sh3 core file sections. Merge multiple copies of auxv section creation into one function.
PR 24650
* elf.c (elfcore_make_auxv_note_section): New function.
(elfcore_grok_note): Use it.
(elfcore_grok_freebsd_note): Likewise.
(elfcore_grok_openbsd_note): Likewise.
(elfcore_grok_netbsd_note): Likewise. Plus add support for
NT_NETBSDCORE_AUXV notes.
Tom Tromey [Fri, 7 Jun 2019 22:08:47 +0000 (16:08 -0600)]
Use gdbpy_enter in py-breakpoint.c
A few spots in py-breakpoint.c acquire the GIL manually. However,
because these spots generate events, and because events are expected
to be arbitrary gdb-flavored Python code, it's important to use
gdbpy_enter instead, in order to ensure that the other gdb-related
Python globals are set correctly.
This patch makes this change. Tested on x86-64 Fedora 29.
gdb/ChangeLog
2019-06-10 Tom Tromey <tom@tromey.com>
* python/py-breakpoint.c (gdbpy_breakpoint_created)
(gdbpy_breakpoint_deleted, gdbpy_breakpoint_modified): Use
gdbpy_enter.
Tom Tromey [Fri, 7 Jun 2019 21:01:50 +0000 (15:01 -0600)]
Delay allocation of dbx_symfile_info
I noticed that elfread.c always allocates a dbx_symfile_info, even
though this is only ever needed in the unusual case of reading stabs
in ELF.
This patch moves the allocation into dbxread.c, and applies the same
treatment to similar code in coffread.c.
Regression tested on x86-64 Fedora 29.
gdb/ChangeLog
2019-06-10 Tom Tromey <tromey@adacore.com>
* elfread.c (elf_read_minimal_symbols): Don't set the dbx objfile
data.
(elf_new_init): Don't call stabsread_new_init.
* dbxread.c (coffstab_build_psymtabs): Set dbx objfile data.
(elfstab_build_psymtabs): Likewise. Call stabsread_new_init.
* coffread.c (coff_symfile_init): Don't set the dbx objfile data.
Christos Zoulas [Mon, 10 Jun 2019 12:15:23 +0000 (13:15 +0100)]
Tidy up ar_open by using asprintf to replace xmalloc and sprintf.
PR 24649
* arsup.c (ar_open): Use asprintf in place of xmalloc and
sprintf.
Martin Liska [Fri, 7 Jun 2019 05:36:52 +0000 (07:36 +0200)]
Fix a missing include of <string>
gold/ChangeLog:
2019-06-07 Martin Liska <mliska@suse.cz>
* errors.h: Include string.
Tom de Vries [Mon, 10 Jun 2019 07:28:30 +0000 (09:28 +0200)]
[gdb/symtab] Support DW_AT_main_subprogram with -readnow.
DW_AT_main_subprogram is supported in normal mode in read_partial_die, but not
in -readnow mode.
Fix this by adding support for DW_AT_main_subprogram in read_func_scope.
Tested on x86_64-linux with native and RFC target board readnow (
https://sourceware.org/ml/gdb-patches/2019-05/msg00073.html ).
gdb/ChangeLog:
2019-06-10 Tom de Vries <tdevries@suse.de>
PR symtab/16264
PR symtab/24517
* dwarf2read.c (read_func_scope): Handle DW_AT_main_subprogram.
GDB Administrator [Mon, 10 Jun 2019 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 9 Jun 2019 00:01:03 +0000 (00:01 +0000)]
Automatic date update in version.in
GDB Administrator [Sat, 8 Jun 2019 00:00:34 +0000 (00:00 +0000)]
Automatic date update in version.in
Maciej W. Rozycki [Fri, 7 Jun 2019 18:25:21 +0000 (19:25 +0100)]
LD/doc: Clarify `-rpath' option's semantics WRT link-time dependencies
Mention in the description of the `-rpath' LD option the restrictions
the option has with respect to searching link-time dependencies of
shared objects referred in the link. Previously these restrictions were
only documented along with the `-rpath-link' option, which may not be
the place one would consider when looking for the semantics of `-rpath'.
Copy the relevant part of the `-rpath-link' option description then,
splitting the now overlong paragraph into three, for legibility.
ld/
* ld.texi (Options): Also document `-rpath' option restrictions
in the description of the option itself.
Nick Alcock [Thu, 6 Jun 2019 13:10:08 +0000 (14:10 +0100)]
libctf: avoid strndup
Not all platforms have it. Use libiberty xstrndup() instead.
(The include of libiberty.h happens in an unusual place due to the
requirements of synchronization of most source files between this
project and another that does not use libiberty. It serves to pull
libiberty.h in for all source files in libctf/, which does the trick.)
Tested on x86_64-pc-linux-gnu, x86_64-unknown-freebsd12.0,
sparc-sun-solaris2.11, i686-pc-cygwin, i686-w64-mingw32.
libctf/
* ctf-decls.h: Include <libiberty.h>.
* ctf-lookup.c (ctf_lookup_by_name): Call xstrndup(), not strndup().
Nick Alcock [Thu, 6 Jun 2019 12:59:56 +0000 (13:59 +0100)]
libctf: explicitly cast more size_t types used in printf()s
Unsigned long will always be adequate (the only cases involving an
ssize_t are cases in which no error can be generated, or in which
negative output would require a seriously corrupted file: the latter has
been rewritten on a branch in any case).
Tested on x86_64-pc-linux-gnu, x86_64-unknown-freebsd12.0,
sparc-sun-solaris2.11, i686-pc-cygwin, i686-w64-mingw32.
libctf/
* ctf-dump.c (ctf_dump_format_type): Cast size_t's used in printf()s.
(ctf_dump_objts): Likewise.
(ctf_dump_funcs): Likewise.
(ctf_dump_member): Likewise.
(ctf_dump_str): Likewise.
Nick Alcock [Thu, 6 Jun 2019 12:59:28 +0000 (13:59 +0100)]
libctf: mark various args as unused in the !HAVE_MMAP case
Tested on x86_64-pc-linux-gnu, x86_64-unknown-freebsd12.0,
sparc-sun-solaris2.11, i686-pc-cygwin, i686-w64-mingw32.
libctf/
* ctf-archive.c (arc_mmap_header): Mark fd as potentially unused.
* ctf-subr.c (ctf_data_protect): Mark both args as potentially unused.
GDB Administrator [Fri, 7 Jun 2019 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in
Руслан Ижбулатов [Thu, 28 Feb 2019 10:25:41 +0000 (10:25 +0000)]
Apply substitute-path to relative filenames as well
When source file path is relative to the build directory (which
is considered a good practice and is enforced in certain buildsystems,
such as meson), gdb only applies substitute-path to the build directory
path. Then gdb appends the source file path to the rewritten build
directory path, and tries to access that.
This fails if either two of the following conditions are true:
a) The user didn't specify substitute-path for the build directory.
This is highly likely, since path substitution for build directories
is not documented anywhere, and since gdb does not tell[0] the user
the path to the build directory, just the source file path.
b) The source file path changed.
This can also easily happen, since a source path that is relative
to the build directory can include any number of directory names
that are not part of the program source tree (starting with the
name of the root directory of the source tree). Gdb will not apply
substitute-path to that relative path, thus there is no way for
the user to tell gdb about these changes.
This commit changes the code to apply substitute-path to all filenames,
both relative and absolute. This way it is possible to do things like:
set substitute-path ../foobar-1.0 /src/my/foobar-1.0
which is completely in line with the user expectations.
This might break unusual cases where build directory path is also
relative (is that even possible?) and happens to match the path
to the source directory (i.e. happens to match a substitution rule).
[0]: There's a "maintenance info symtabs" command that does show the names
of the build directories, but normal users are not required to
know or use that.
gdb/ChangeLog
2019-06-06 Руслан Ижбулатов <lrn1986@gmail.com>
* source.c (find_and_open_source): Also rewrite relative file
names.
Amos Bird [Thu, 6 Jun 2019 17:10:14 +0000 (01:10 +0800)]
Add thread-exit annotation.
gdb/ChangeLog
2019-04-26 Amos Bird <amosbird@gmail.com>
* annotate.c (annotate_thread_exited): Add "thread-exited"
annotation.
gdb/doc/ChangeLog
2019-06-06 Amos Bird <amosbird@gmail.com>
* annotate.texinfo (Multi-threaded Apps): Add entry for thread-exited
annotation.
gdb/testsuite/ChangeLog
2019-06-06 Amos Bird <amosbird@gmail.com>
* gdb.base/annota1.exp (thread_switch): Add test for
thread-exited annotation.
H.J. Lu [Thu, 6 Jun 2019 14:57:52 +0000 (07:57 -0700)]
gas: Add .enqcmd and noenqcmd directives
2019-06-06 Lili Cui <lili.cui@intel.com>
* config/tc-i386.c (cpu_arch): Add .enqcmd.
(cpu_noarch): Add noenqcmd.
* doc/c-i386.texi: Document noenqcmd.
H.J. Lu [Thu, 6 Jun 2019 14:55:40 +0000 (07:55 -0700)]
gas: Correct ChangeLog for commit
5d79adc4b22b0abd
Tom Tromey [Thu, 11 Apr 2019 17:26:02 +0000 (11:26 -0600)]
Add timestamps to "maint time" output
Currently "maint time" will print the amount of time a command took.
Sometimes, though, it's useful to have a timestamp as well -- for
example if one is correlating a gdb log with some other log.
This patch adds a timestamp to the start and end of each command when
this setting is in effect.
This also removes a "//" comment and changes scoped_command_stats to
use DISABLE_COPY_AND_ASSIGN; two minor things I noticed while working
on the patch.
Tested on x86-64 Fedora 29.
gdb/ChangeLog
2019-06-06 Tom Tromey <tromey@adacore.com>
* maint.h (class scoped_command_stats): Use
DISABLE_COPY_AND_ASSIGN.
<print_time>: New method.
* maint.c (scoped_command_stats, ~scoped_command_stats): Call
print_time.
(scoped_command_stats::print_time): New method.
gdb/testsuite/ChangeLog
2019-06-06 Tom Tromey <tromey@adacore.com>
* gdb.base/maint.exp: Expect command started/finished output.
Sudakshina Das [Thu, 6 Jun 2019 11:27:41 +0000 (12:27 +0100)]
[BFD, AArch64] Fix PT_GNU_PROPERTY alignment issue
If the new GNU property section was being created by the linker
(this will happen only if none of the inputs have any GNU property
section but the command line to the linker forces a bti with
--force-bti), the alignment of the section and hence the program
header of PT_GNU_PROPERTY type was not being set correctly. This
patch fixes this issue.
bfd/ChangeLog:
2019-06-06 Sudakshina Das <sudi.das@arm.com>
* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Set
alignment of the new gnu property section.
ld/ChangeLog:
2019-06-06 Sudakshina Das <sudi.das@arm.com>
* testsuite/ld-aarch64/aarch64-elf.exp: Add new tests.
* testsuite/ld-aarch64/property-bti-pac4-a.d: New test.
* testsuite/ld-aarch64/property-bti-pac4-b.d: New test.
* testsuite/ld-aarch64/property-bti-pac4.s: New test.
Sudakshina Das [Thu, 6 Jun 2019 11:21:14 +0000 (12:21 +0100)]
[LD, AArch64] Move ELF options behind -z
This patch moves the current AArch64 ld options of --force-bti
and --pac-plt to -z force-bti and -z pac-plt since these are
ELF specific options.
*** bfd/ChangeLog ***
2019-06-06 Sudakshina Das <sudi.das@arm.com>
* bfd-in.h: Change comment.
* bfd-in2.h: Regenerate.
* elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): Update warning.
* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties):
Likwise.
*** ld/ChangeLog ***
2019-06-06 Sudakshina Das <sudi.das@arm.com>
* NEWS: Update options names.
* emultempl/aarch64elf.em (OPTION_FORCE_BTI, OPTION_PAC_PLT): Remove.
(PARSE_AND_LIST_LONGOPTS): Remove force-bti and pac-plt.
(PARSE_AND_LIST_OPTIONS): Update to -z.
(PARSE_AND_LIST_ARGS_CASE_Z_AARCH64): New.
(PARSE_AND_LIST_ARGS_CASE_Z): Add PARSE_AND_LIST_ARGS_CASE_Z_AARCH64.
(PARSE_AND_LIST_ARGS_CASES): Move cases for these options.
* testsuite/ld-aarch64/bti-pac-plt-1.d: Update option.
* testsuite/ld-aarch64/bti-pac-plt-2.d: Likewise.
* testsuite/ld-aarch64/bti-plt-1.d: Likewise.
* testsuite/ld-aarch64/bti-plt-2.d: Likewise.
* testsuite/ld-aarch64/bti-plt-3.d: Likewise.
* testsuite/ld-aarch64/bti-plt-4.d: Likewise.
* testsuite/ld-aarch64/bti-plt-6.d: Likewise.
* testsuite/ld-aarch64/bti-plt-7.d: Likewise.
* testsuite/ld-aarch64/bti-warn.d: Likewise.
* testsuite/ld-aarch64/pac-plt-1.d: Likewise.
* testsuite/ld-aarch64/pac-plt-2.d: Likewise.
GDB Administrator [Thu, 6 Jun 2019 00:00:21 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Wed, 5 Jun 2019 17:27:08 +0000 (10:27 -0700)]
i386: Check vector length for EVEX vextractfXX and vinsertfXX
Since not all vector lengths are supported by EVEX vextractfXX and
vinsertfXX, decode them only with supported vector lengths.
gas/
PR binutils/24633
* testsuite/gas/i386/disassem.s: Add tests for invalid vector
lengths for EVEX vextractfXX and vinsertfXX.
* testsuite/gas/i386/x86-64-disassem.s: Likewise.
* testsuite/gas/i386/disassem.d: Updated.
* testsuite/gas/i386/x86-64-disassem.d: Likewise.
opcodes/
PR binutils/24633
* i386-dis-evex.h (evex_table): Update EVEX_W_0F3A18_P_2,
EVEX_W_0F3A19_P_2, EVEX_W_0F3A1A_P_2 and EVEX_W_0F3A1B_P_2.
(evex_len_table): EVEX_LEN_0F3A18_P_2_W_0,
EVEX_LEN_0F3A18_P_2_W_1, EVEX_LEN_0F3A19_P_2_W_0,
EVEX_LEN_0F3A19_P_2_W_1, EVEX_LEN_0F3A1A_P_2_W_0,
EVEX_LEN_0F3A1A_P_2_W_1, EVEX_LEN_0F3A1B_P_2_W_0,
EVEX_LEN_0F3A1B_P_2_W_1.
* i386-dis.c (EVEX_LEN_0F3A18_P_2_W_0): New enum.
(EVEX_LEN_0F3A18_P_2_W_1): Likewise.
(EVEX_LEN_0F3A19_P_2_W_0): Likewise.
(EVEX_LEN_0F3A19_P_2_W_1): Likewise.
(EVEX_LEN_0F3A1A_P_2_W_0): Likewise.
(EVEX_LEN_0F3A1A_P_2_W_1): Likewise.
(EVEX_LEN_0F3A1B_P_2_W_0): Likewise.
(EVEX_LEN_0F3A1B_P_2_W_1): Likewise.
Nick Alcock [Wed, 5 Jun 2019 12:34:36 +0000 (13:34 +0100)]
libctf: eschew %zi format specifier
Too many platforms don't support it, and we can always safely use %lu or
%li anyway, because the only uses are in debugging output.
libctf/
* ctf-archive.c (ctf_arc_write): Eschew %zi format specifier.
(ctf_arc_open_by_offset): Likewise.
* ctf-create.c (ctf_add_type): Likewise.
Andrew Burgess [Wed, 5 Jun 2019 09:33:54 +0000 (10:33 +0100)]
gdb/testsuite: Improve comments in recently added test
Remove the use of 'I' within some comments in a recently added test.
gdb/testsuite/ChangeLog:
* gdb.arch/riscv-unwind-long-insn-6.s: Remove use of 'I' in
comment.
* gdb.arch/riscv-unwind-long-insn-8.s: Likewise.
Andrew Burgess [Tue, 4 Jun 2019 09:30:41 +0000 (10:30 +0100)]
gdb/riscv: Don't error when decoding a 6 or 8 byte instruction
If the RISC-V prologue scanner finds a 6 or 8 byte instruction we
currently throw an internal error, which is not great for the user.
A mechanism already exists in the prologue scanner to leave
instructions marked as unknown so that we can stop the prologue scan
without raising an error, this is used for all 2 and 4 byte
instructions that are not part of the small set the prologue scanner
actually understands.
This commit changes GDB so that all 6 and 8 byte instructions are
marked as unknown, rather than causing an error.
gdb/ChangeLog:
* riscv-tdep.c (riscv_insn::decode): Gracefully ignore
instructions of lengths 6 or 8 bytes.
gdb/testsuite/ChangeLog:
* gdb.arch/riscv-unwind-long-insn-6.s: New file.
* gdb.arch/riscv-unwind-long-insn-8.s: New file.
* gdb.arch/riscv-unwind-long-insn.c: New file.
* gdb.arch/riscv-unwind-long-insn.exp: New file.
GDB Administrator [Wed, 5 Jun 2019 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in
Pedro Alves [Tue, 4 Jun 2019 21:40:54 +0000 (22:40 +0100)]
Introduce and use make_unique_xstrdup
Adds an utility function to make it shorter to write the common case
of wrapping an xstrdup with a unique_xmalloc_ptr, and uses it
throughout.
Note: I tried to put this in common/common-utils.h near skip_spaces,
etc. but that is included in common/common-defs.h before
common/gdb_unique_ptr.h is included, so it would fail to compile
because gdb::unique_xmalloc_ptr isn't defined at that point yet. I
tried moving the gdb_unique_ptr.h inclusion before common-utils.h, but
that doesn't work because gdb_unique_ptr.h depends on common-utils.h
for xfree.
gdb/ChangeLog:
2019-06-04 Pedro Alves <palves@redhat.com>
* common/gdb_unique_ptr.h (make_unique_xstrdup): New.
* ada-lang.c (catch_ada_completer): Use make_unique_xstrdup.
* breakpoint.c (condition_completer): Likewise.
* cli/cli-dump.c (scan_expression): Likewise.
* common/filestuff.c (mkdir_recursive): Likewise.
* common/gdb_tilde_expand.c (gdb_tilde_expand_up)
* common/pathstuff.c (gdb_realpath, gdb_realpath_keepfile)
(gdb_abspath): Likewise.
* compile/compile-cplus-types.c
(compile_cplus_instance::decl_name): Likewise.
* completer.c (complete_explicit_location):
(signal_completer, reg_or_group_completer_1): Likewise.
* cp-support.c (cp_remove_params_if_any): Likewise.
* fbsd-tdep.c (fbsd_core_vnode_path): Likewise.
* guile/scm-safe-call.c (gdbscm_safe_eval_string): Likewise.
* infcmd.c (strip_bg_char): Likewise.
* linespec.c (copy_token_string): Likewise.
* mi/mi-main.c (output_cores): Likewise.
* psymtab.c (psymtab_search_name):
* symfile.c (test_set_ext_lang_command): Likewise.
* target.c (target_fileio_read_stralloc): Likewise.
* tui/tui-regs.c (tui_reggroup_completer): Likewise.
* value.c (complete_internalvar): Likewise.
gdb/gdbserver/ChangeLog:
2019-06-04 Pedro Alves <palves@redhat.com>
* server.c (captured_main): Use make_unique_xstrdup.
Pedro Alves [Tue, 4 Jun 2019 21:44:36 +0000 (22:44 +0100)]
Fix paths to ChangeLog files
Tom Tromey [Tue, 4 Jun 2019 18:16:57 +0000 (12:16 -0600)]
Use CHAR_BIT instead of NBBY in libctf
On x86-64 Fedora 29, I tried to build a mingw-hosted gdb that targets
ppc-linux. You can do this with:
../binutils-gdb/configure --host=i686-w64-mingw32 --target=ppc-linux \
--disable-{binutils,gas,gold,gprof,ld}
The build failed with these errors in libctf:
In file included from ../../binutils-gdb/libctf/ctf-create.c:20:
../../binutils-gdb/libctf/ctf-create.c: In function 'ctf_add_encoded':
../../binutils-gdb/libctf/ctf-create.c:803:59: error: 'NBBY' undeclared (first use in this function)
dtd->dtd_data.ctt_size = clp2 (P2ROUNDUP (ep->cte_bits, NBBY) / NBBY);
^~~~
../../binutils-gdb/libctf/ctf-impl.h:254:42: note: in definition of macro 'P2ROUNDUP'
#define P2ROUNDUP(x, align) (-(-(x) & -(align)))
^~~~~
../../binutils-gdb/libctf/ctf-create.c:803:59: note: each undeclared identifier is reported only once for each function it appears in
dtd->dtd_data.ctt_size = clp2 (P2ROUNDUP (ep->cte_bits, NBBY) / NBBY);
^~~~
../../binutils-gdb/libctf/ctf-impl.h:254:42: note: in definition of macro 'P2ROUNDUP'
#define P2ROUNDUP(x, align) (-(-(x) & -(align)))
^~~~~
../../binutils-gdb/libctf/ctf-create.c: In function 'ctf_add_slice':
../../binutils-gdb/libctf/ctf-create.c:862:59: error: 'NBBY' undeclared (first use in this function)
dtd->dtd_data.ctt_size = clp2 (P2ROUNDUP (ep->cte_bits, NBBY) / NBBY);
^~~~
../../binutils-gdb/libctf/ctf-impl.h:254:42: note: in definition of macro 'P2ROUNDUP'
#define P2ROUNDUP(x, align) (-(-(x) & -(align)))
^~~~~
../../binutils-gdb/libctf/ctf-create.c: In function 'ctf_add_member_offset':
../../binutils-gdb/libctf/ctf-create.c:1341:21: error: 'NBBY' undeclared (first use in this function)
off += lsize * NBBY;
^~~~
../../binutils-gdb/libctf/ctf-create.c: In function 'ctf_add_type':
../../binutils-gdb/libctf/ctf-create.c:1822:16: warning: unknown conversion type character 'z' in format [-Wformat=]
ctf_dprintf ("Conflict for type %s against ID %lx: "
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../binutils-gdb/libctf/ctf-create.c:1823:35: note: format string is defined here
"union size differs, old %zi, new %zi\n",
^
../../binutils-gdb/libctf/ctf-create.c:1822:16: warning: unknown conversion type character 'z' in format [-Wformat=]
ctf_dprintf ("Conflict for type %s against ID %lx: "
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../binutils-gdb/libctf/ctf-create.c:1823:44: note: format string is defined here
"union size differs, old %zi, new %zi\n",
^
../../binutils-gdb/libctf/ctf-create.c:1822:16: warning: too many arguments for format [-Wformat-extra-args]
ctf_dprintf ("Conflict for type %s against ID %lx: "
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This patch fixes the actual errors in here. I did not try to fix the
printf warnings, though I think someone ought to.
Ok?
libctf/ChangeLog
2019-06-04 Tom Tromey <tromey@adacore.com>
* ctf-create.c (ctf_add_encoded, ctf_add_slice)
(ctf_add_member_offset): Use CHAR_BIT, not NBBY.
H.J. Lu [Tue, 4 Jun 2019 19:45:20 +0000 (12:45 -0700)]
i386: Check for reserved VEX.vvvv and EVEX.vvvv
If VEX.vvvv and EVEX.vvvv are reserved, they must be all 1s, which are
all 0s in inverted form. Add check for unused VEX.vvvv and EVEX.vvvv
when disassembling VEX and EVEX instructions.
gas/
PR binutils/24626
* testsuite/gas/i386/disassem.s: Add tests for reserved VEX.vvvv
and EVEX.vvvv.
* testsuite/gas/i386/x86-64-disassem.s: Likewise.
* testsuite/gas/i386/disassem.d: Updated.
* testsuite/gas/i386/x86-64-disassem.d: Likewise.
opcodes/
PR binutils/24626
* i386-dis.c (print_insn): Check for unused VEX.vvvv and
EVEX.vvvv when disassembling VEX and EVEX instructions.
(OP_VEX): Set vex.register_specifier to 0 after readding
vex.register_specifier.
(OP_Vex_2src_1): Likewise.
(OP_Vex_2src_2): Likewise.
(OP_LWP_E): Likewise.
(OP_EX_Vex): Don't check vex.register_specifier.
(OP_XMM_Vex): Likewise.
Nick Alcock [Tue, 4 Jun 2019 14:04:49 +0000 (15:04 +0100)]
libctf: work on platforms without O_CLOEXEC.
(Not tested on any such platforms, since I don't have access to any at
the moment. Testing encouraged.)
libctf/
* configure.ac: Check for O_CLOEXEC.
* ctf-decls.h (O_CLOEXEC): Define (to 0), if need be.
* config.h.in: Regenerate.
Nick Alcock [Mon, 3 Jun 2019 13:02:09 +0000 (14:02 +0100)]
libctf: look for BSD versus GNU qsort_r signatures
We cannot just look for any declaration of qsort_r, because some
operating systems have a qsort_r that has a different prototype
but which still has a pair of pointers in the right places (the last two
args are interchanged): so use AC_LINK_IFELSE to check for both
known variants of qsort_r(), and swap their args into a consistent order
in a suitable inline function. (The code for this is taken almost
unchanged from gnulib.)
(Now we are not using AC_LIBOBJ any more, we can use a better name for
the qsort_r replacement as well.)
libctf/
* qsort_r.c: Rename to...
* ctf-qsort_r.c: ... this.
(_quicksort): Define to ctf_qsort_r.
* ctf-decls.h (qsort_r): Remove.
(ctf_qsort_r): Add.
(struct ctf_qsort_arg): New, transport the real ARG and COMPAR.
(ctf_qsort_compar_thunk): Rearrange the arguments to COMPAR.
* Makefile.am (libctf_a_LIBADD): Remove.
(libctf_a_SOURCES): New, add ctf-qsort_r.c.
* ctf-archive.c (ctf_arc_write): Call ctf_qsort_r, not qsort_r.
* ctf-create.c (ctf_update): Likewise.
* configure.ac: Check for BSD versus GNU qsort_r signature.
* Makefile.in: Regenerate.
* config.h.in: Likewise.
* configure: Likewise.
Nick Alcock [Mon, 3 Jun 2019 19:26:02 +0000 (20:26 +0100)]
libctf: fix use-after-free in function dumping
This is actually a free-before-initializing (i.e. a free of garbage).
libctf/
* ctf-dump.c (ctf_dump_funcs): Free in the right place.
Nick Alcock [Mon, 3 Jun 2019 10:38:08 +0000 (11:38 +0100)]
libctf: fix the type of ctf_enum.cte_value
This stops the file format from depending on the size of the host int.
(It does mean that we cannot encode enums with a value > 2^32 on
platforms with an int > 2^32: this will be fixed in the next format
revision.)
include/
* ctf.h (ctf_enum.cte_value): Fix type to int32_t.
H.J. Lu [Tue, 4 Jun 2019 15:58:21 +0000 (08:58 -0700)]
Enable Intel AVX512_VP2INTERSECT insn
This patch enables support for VP2INTERSECT in binutils. Please refer to
https://software.intel.com/sites/default/files/managed/c5/15/architecture-instruction-set-extensions-programming-reference.pdf
for VP2INTERSECT details.
Make check-gas is ok.
gas/
2019-06-04 Igor Tsimbalist <igor.v.tsimbalist@intel.com>
Lili Cui <lili.cui@intel.com>
* config/tc-i386.c (cpu_arch): Add .avx512_vp2intersect.
(cpu_noarch): Likewise.
* doc/c-i386.texi: Document avx512_vp2intersect.
* testsuite/gas/i386/i386.exp: Run vp2intersect tests.
* testsuite/gas/i386/vp2intersect-intel.d: New test.
* testsuite/gas/i386/vp2intersect.d: Likewise.
* testsuite/gas/i386/vp2intersect.s: Likewise.
* testsuite/gas/i386/vp2intersect-inval-bcast.l: Likewise.
* testsuite/gas/i386/vp2intersect-inval-bcast.s: Likewise.
* testsuite/gas/i386/x86-64-vp2intersect-intel.d: Likewise.
* testsuite/gas/i386/x86-64-vp2intersect.d: Likewise.
* testsuite/gas/i386/x86-64-vp2intersect.s: Likewise.
* testsuite/gas/i386/x86-64-vp2intersect-inval-bcast.l: Likewise.
* testsuite/gas/i386/x86-64-vp2intersect-inval-bcast.s: Likewise.
opcodes/
2019-06-04 Igor Tsimbalist <igor.v.tsimbalist@intel.com>
Lili Cui <lili.cui@intel.com>
* i386-dis.c (enum): Add PREFIX_EVEX_0F3868, EVEX_W_0F3868_P_3.
* i386-dis-evex.h (evex_table): Add AVX512_VP2INTERSECT
instructions.
* i386-gen.c (cpu_flag_init): Add CPU_AVX512_VP2INTERSECT_FLAGS,
CPU_ANY_AVX512_VP2INTERSECT_FLAGS.
(cpu_flags): Add CpuAVX512_VP2INTERSECT.
* i386-opc.h (enum): Add CpuAVX512_VP2INTERSECT.
(i386_cpu_flags): Add cpuavx512_vp2intersect.
* i386-opc.tbl: Add AVX512_VP2INTERSECT insns.
* i386-init.h: Regenerated.
* i386-tbl.h: Likewise.
H.J. Lu [Tue, 4 Jun 2019 15:50:10 +0000 (08:50 -0700)]
Add support for Intel ENQCMD[S] instructions
This patch enables support for ENQCMD[S] in binutils. Please refer to
https://software.intel.com/sites/default/files/managed/c5/15/architecture-instruction-set-extensions-programming-reference.pdf
for ENQCMD[S] details.
Make check-gas is ok.
gas/ChangeLog:
2019-06-04 Xuepeng Guo <xuepeng.guo@intel.com>
Lili Cui <lili.cui@intel.com>
* doc/c-i386.texi: Document enqcmd.
* testsuite/gas/i386/enqcmd-intel.d: New file.
* testsuite/gas/i386/enqcmd-inval.l: Likewise.
* testsuite/gas/i386/enqcmd-inval.s: Likewise.
* testsuite/gas/i386/enqcmd.d: Likewise.
* testsuite/gas/i386/enqcmd.s: Likewise.
* testsuite/gas/i386/x86-64-enqcmd-intel.d: Likewise.
* testsuite/gas/i386/x86-64-enqcmd-inval.l: Likewise.
* testsuite/gas/i386/x86-64-enqcmd-inval.s: Likewise.
* testsuite/gas/i386/x86-64-enqcmd.d: Likewise.
* testsuite/gas/i386/x86-64-enqcmd.s: Likewise.
* testsuite/gas/i386/i386.exp: Run enqcmd-intel, enqcmd-inval,
enqcmd, x86-64-enqcmd-intel, x86-64-enqcmd-inval,
and x86-64-enqcmd.
opcodes/ChangeLog:
2019-06-04 Xuepeng Guo <xuepeng.guo@intel.com>
Lili Cui <lili.cui@intel.com>
* i386-dis.c (enum): Add MOD_0F38F8_PREFIX_1 and
MOD_0F38F8_PREFIX_3.
(prefix_table): New instructions (see prefix above).
(mod_table): New instructions (see prefix above).
* i386-gen.c (cpu_flag_init): Add entries for enqcmd.
(cpu_flags): Add a bitfield for enqmcd.
* i386-init.h: Regenerated.
* i386-opc.h (enum): Add CpuENQCMD.
(i386_cpu_flags): Add a bitfield for cpuenqcmd.
* i386-opc.tbl: Add enqcmd and enqcmds instructions.
* i386-init.h: Regenerated.
* i386-tbl.h: Regenerated.
Christian Biesinger via gdb-patches [Thu, 23 May 2019 21:37:29 +0000 (16:37 -0500)]
Add an objfile getter to gdb.Type
This allows users of the Python API to find the objfile where a type
was defined.
gdb/ChangeLog:
gdb/ChangeLog
2019-06-04 Christian Biesinger <cbiesinger@google.com>
Add objfile property to gdb.Type.
* gdb/NEWS: Mention Python API addition.
* gdb/python/py-type.c (typy_get_objfile): New method.
gdb/doc/ChangeLog
2019-06-04 Christian Biesinger <cbiesinger@google.com>
* gdb/doc/python.texi: Document new gdb.Type.objfile property.
gdb/testsuite/ChangeLog
2019-06-04 Christian Biesinger <cbiesinger@google.com>
* gdb/testsuite/gdb.python/py-type.exp: Test for new
gdb.Type.objfile property.
Alan Hayward [Tue, 4 Jun 2019 13:25:08 +0000 (14:25 +0100)]
Remove an unnecessary set of parentheses in the arm-dis.c source file.
* arm-dis.c (is_mve_unpredictable): Remove spurious paranthesis.
GDB Administrator [Tue, 4 Jun 2019 00:00:13 +0000 (00:00 +0000)]
Automatic date update in version.in
Philippe Waroquiers [Mon, 3 Jun 2019 19:51:56 +0000 (21:51 +0200)]
Document in NEWS and gdb.texinfo the "help", "apropos" and "show style" changes.
Philippe Waroquiers [Mon, 3 Jun 2019 19:50:22 +0000 (21:50 +0200)]
Update tests following changes to "help" and "apropos"
Factorizes the testing of the help output, by having a single place
that defines the common help trailer and/or prefix messages.
Philippe Waroquiers [Fri, 31 May 2019 12:00:47 +0000 (14:00 +0200)]
Improve usability and/or readibility of help and apropos output.
The "help" command can output long list of command names or classes.
Use the title style to style the command names or classes to make
the output more readable.
Similarly, change "apropos" command to also style the command names.
It is sometimes unclear why "apropos REGEXP" lists some commands,
and then the user has to manually do 'help command' for all commands
listed by "apropos" to see more details about the matching commands.
=> Add an optional flag -v so that "apropos -v REGEXP":
* outputs the full documentation of matching commands.
* highlights the documentation parts matching REGEXP.
Philippe Waroquiers [Fri, 31 May 2019 11:47:37 +0000 (13:47 +0200)]
Add highlight style, title style, fputs_highlighted. Improve 'show style'
Have 'show style' and its subcommands using a style to style its output.
This allows the GDB user or developer to use 'show style' to visually see
with one command how all the current styles look like.
Add 2 new styles highlight style, title style and fputs_highlighted function.
Highlight style is used by fputs_highlighted to highlight the parts of
its char *STR argument that match a HIGHLIGHT regexp.
This (and the title style) will be used in a following patch.
Nick Clifton [Mon, 3 Jun 2019 15:28:15 +0000 (16:28 +0100)]
Revert patch that disables building libctf for non-ELF based targets.
Revert:
binutls 2019-05-29 Nick Clifton <nickc@redhat.com>
* configure.ac (LIBCTF): Export. Set to empty for non-ELF based
targets.
(HAVE_LIBCTF): Define if libctf support is available.
* Makefile.am (LIBCTF): Set value to @LIBCTF@.
* objdump.c: Make CTF code conditional upon HAVE_LIBCTF being
defined.
* readelf.c: Likewise.
* configure: Regenerate.
* Makefile.in: Regenerate.
* config.in: Regenerate.
top 2019-05-29 Nick Clifton <nickc@redhat.com>
* configure.ac (noconfigdirs): Add libctf if the target does not use
the ELF file format.
* configure: Regenerate.
Alan Modra [Mon, 3 Jun 2019 02:16:04 +0000 (11:46 +0930)]
Don't waste space in prefix_opcd_indices
* ppc-dis.c (prefix_opcd_indices): Correct size.
GDB Administrator [Mon, 3 Jun 2019 00:00:54 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Sat, 1 Jun 2019 15:16:04 +0000 (09:16 -0600)]
Remove fromhex implementation from gdbreplay
gdbreplay had its own implementation of fromhex. This patch changes
it to use the one in common/.
gdb/gdbserver/ChangeLog
2019-06-02 Tom Tromey <tom@tromey.com>
* gdbreplay.c (fromhex): Remove.
* Makefile.in (GDBREPLAY_OBS): Add rsp-low.o.
GDB Administrator [Sun, 2 Jun 2019 00:01:00 +0000 (00:01 +0000)]
Automatic date update in version.in