Alan Hayward [Thu, 4 Jul 2019 10:48:16 +0000 (11:48 +0100)]
i386/AArch64: Remove old xml tests
Both the i386, X86_64 and AArch64 builds of gdbserver include a bunch of legacy
xml files, dat files and auto generated C files, when building for unit test.
These tests exists back from when feature target descriptions were added to
prove that the new target descriptions were identical to the original
older versions. The old files are not used for anything other than these tests.
Now that this has been proven, we are not gaining anything by keeping the
original files and tests. Should new functionality be added, it would break
the tests, unless the functionality was backported to the xml. There is no
requirement that we must match the exact xml from N releases ago. It adds
obfuscation, where as the feature target descriptions were meant to simplify
the code.
In addition, there are a bunch of xml and dat files which are completely unused.
This patch removes the selftests and the target descriptions from gdbserver.
Update the unittest to allow 0 tests (note, this failed on other targets that
never had any tests).
gdb/ChangeLog:
* aarch64-tdep.c: Remove xml self tests.
* amd64-linux-tdep.c: Likewise.
* amd64-tdep.c: Likewise.
* i386-linux-tdep.c: Likewise.
* i386-tdep.c: Likewise.
gdb/gdbserver/ChangeLog:
* configure.srv: Remove legacy xml.
* linux-aarch64-low.c (initialize_low_arch): Remove
initialize_low_tdesc call.
* linux-aarch64-tdesc-selftest.c: Remove file.
* linux-aarch64-tdesc.h (initialize_low_tdesc): Remove.
* linux-x86-low.c (initialize_low_arch): Remove
initialize_low_tdesc call.
* linux-x86-tdesc-selftest.c: Remove file.
* linux-x86-tdesc.h (initialize_low_tdesc): Remove.
gdb/testsuite/ChangeLog:
* gdb.server/unittest.exp: Allow 0 unit tests to run.
Jan Beulich [Thu, 4 Jul 2019 08:36:41 +0000 (10:36 +0200)]
x86: correct "-Q" option handling
For another patch I wanted to use a sufficiently benign option (simply
to be able to specify one, which certain test case invocations require),
and I stumbled across -Q in the --help output. Before realizing that
this is x86-specific anyway, I've tried and and ran into a mysterious
testsuite failure, until I further realized that other than the help
text suggests the option requires an argument. Correct the help text,
and make the implementation actually match what the comment there has
been describing (and what the help text now says).
Jan Beulich [Thu, 4 Jul 2019 08:35:47 +0000 (10:35 +0200)]
gas/ELF: don't accumulate .type settings
Recently a patch was submitted for a Xen Project test harness binary to
override the compiler specified @object to @func (see [1]). In a reply I
suggested we shouldn't make ourselves dependent on currently unspecified
behavior of gas here: It accumulates all requests, and then
bfd/elf.c:swap_out_syms(), in an apparently ad hoc manner, prioritizes
certain flags over others.
Make the behavior predictable: Generally the last .type is what counts.
Exceptions are directives which set multiple bits (TLS, IFUNC, and
UNIQUE): Subsequent directives requesting just the more generic bit
(i.e. FUNC following IFUNC) won't clear the more specific one. Warn
about incompatible changes, except from/to STT_NOTYPE.
Also add a new target hook, which hppa wants to use right away afaict.
In the course of adding the warning I ran into two ld testsuite
failures. I can only assume that it was a copy-and-paste mistake that
lead to the same symbol having its type set twice.
[1] https://lists.xenproject.org/archives/html/xen-devel/2019-05/msg01980.html
GDB Administrator [Thu, 4 Jul 2019 00:00:37 +0000 (00:00 +0000)]
Automatic date update in version.in
Pedro Alves [Wed, 3 Jul 2019 17:05:20 +0000 (18:05 +0100)]
Fix early return in foreach_with_prefix
I noticed that an early return in a foreach_with_prefix block does not
cause the outer scope to return, like:
foreach_with_prefix var {"foo" "bar"} {
return
}
# Control continues here, but it should not.
The problem is that we're missing the usual "return -code" treatment.
This commit fixes it.
gdb/testsuite/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (foreach_with_prefix): Use "catch" and
"return -code".
Pedro Alves [Wed, 3 Jul 2019 15:57:51 +0000 (16:57 +0100)]
pipe command completer
This commit adds a completer for the "pipe" command. It can complete
"pipe"'s options, and the specified GDB command.
To make the completer aware of the "-d" option, this converts the
option processing to use gdb::option.
Tests included.
gdb/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
PR cli/24732
* cli/cli-cmds.c (struct pipe_cmd_opts): New.
(pipe_cmd_option_defs): New.
(make_pipe_cmd_options_def_group): New.
(pipe_command): Use gdb::option::process_options.
(pipe_command_completer): New function.
(_initialize_cli_cmds): Install completer for "pipe" command.
gdb/testsuite/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
PR cli/24732
* gdb.base/shell.exp: Load completion-support.exp.
Adjust expected error output. Add completion tests.
Pedro Alves [Wed, 3 Jul 2019 15:57:50 +0000 (16:57 +0100)]
Fix latent bug in test_gdb_complete_cmd_multiple
A following patch will add the following to a testcase:
test_gdb_completion_offers_commands "| "
And that tripped on a latent testsuite bug:
(gdb) | PASS: gdb.base/shell.exp: tab complete "| "
^CQuit
(gdb) complete |
| !
| +
PASS: gdb.base/shell.exp: cmd complete "| "
| *** List may be truncated, max-completions reached. ***
(gdb) FAIL: gdb.base/shell.exp: set max-completions 200
set max-completions 200
The issue is that "|" ends up as part of a regexp, and "|" in regexps
has a special meaning...
Fix this with string_to_regexp.
gdb/testsuite/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
* lib/completion-support.exp (test_gdb_complete_cmd_multiple): Use
string_to_regexp.
Pedro Alves [Wed, 3 Jul 2019 15:57:49 +0000 (16:57 +0100)]
Teach gdb::option about string options
A following patch will make the "pipe" command use the gdb::option
framework for option processing. However, "pipe"'s only option today
is a string option, "-d DELIM", and gdb::option does not support
string options yet.
This commit adds support for string options, mapped to var_string.
For now, a string is parsed up until the first whitespace. I imagine
that we'll need to add support for quoting so that we could do:
(gdb) cmd -option 'some -string'
without gdb confusing the "-string" for an option.
This doesn't seem important for pipe, so I'm leaving it for another
day.
One thing I'm not happy with, is that the string data is managed as a
raw malloc-allocated char *, which means that we need to xfree it
manually. This is because var_string settings work that way too.
Although with var_string settings we're leaking the strings at gdb
exit, that was never really a problem. For options though, leaking is
undesirable.
I think we should tackle that for both settings and options at the
same time, so for now I'm just managing the malloced data manually.
It's a bit ugly in option_def_and_value, but at least that's hidden
from view.
For testing, this adds a new "-string" option to "maint
test-settings", and then tweaks gdb.base/options.exp to exercise it.
gdb/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
* cli/cli-option.c (union option_value) <string>: New field.
(struct option_def_and_value): Add ctor, move ctor, dtor and
use DISABLE_COPY_AND_ASSIGN.
(option_def_and_value::clear_value): New.
(parse_option, save_option_value_in_ctx, get_val_type_str)
(add_setshow_cmds_for_options): Handle var_string.
* cli-option.h (union option_def::var_address) <string>: New
field.
(struct string_option_def): New.
* maint-test-options.c (struct test_options_opts): Add default
ctor and use DISABLE_COPY_AND_ASSIGN.
<string_opt>: New field.
(test_options_opts::~test_options_opts): New.
(test_options_opts::dump): Also dump "-string".
(test_options_option_defs): Install "string.
gdb/testsuite/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
* gdb.base/options.exp (expect_none, expect_flag, expect_bool)
(expect_integer): Adjust to expect "-string".
(expect_string): New.
(all_options): Expect "-string".
(test-flag, test-boolean): Adjust to expect "-string".
(test-string): New proc.
(top level): Call it.
Pedro Alves [Wed, 3 Jul 2019 15:57:48 +0000 (16:57 +0100)]
Make gdb::option::complete_options save processed arguments too
Currently, gdb::option::complete_options just discards any processed
option argument, because no completer needs that data.
When completing "pipe -d XXX gdbcmd XXX" however, the completer needs
to know about -d's argument (XXX), in order to know where input is
already past the gdb command and the delimiter.
In this commit, the fix for that is the factoring out of the
save_option_value_in_ctx function and calling it in complete_options.
For testing, this makes "maint show test-options-completion-result"
show the processed options too, like what the "maint test-options"
subcommands output when run. Then, of course, gdb.base/options.exp is
adjusted.
Doing this exposed a couple latent bugs, which is what the other gdb
changes in the patch are for:
- in the var_enum case, without the change, we'd end up with a null
enum argument, and print:
"-enum (null)"
- The get_ulongest change is necessary to avoid advancing PP in a
case where we end up throwing an error, e.g., when parsing "11x".
Without the change the operand pointer shown by "maint show
test-options-completion-result" would be left pointing at "x"
instead of "11x".
gdb/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
* cli/cli-option.c (parse_option) <var_enum>: Don't return an
option_value with a null enumeration.
(complete_options): Save the option values in the context.
(save_option_value_in_ctx): New, factored out from ...
(process_options): ... here.
* cli/cli-utils.c (get_ulongest): Don't advance PP until the end
of the function.
* maint-test-options.c (test_options_opts::dump): New, factored
out from ...
(maintenance_test_options_command_mode): ... here.
(maintenance_test_options_command_completion_result): Delete.
(maintenance_test_options_command_completion_text): Update
comment.
(maintenance_show_test_options_completion_result): Change
prototype. Just print
maintenance_test_options_command_completion_text.
(save_completion_result): New.
(maintenance_test_options_completer_mode): Pass options context to
complete_options, and then save a dump.
(_initialize_maint_test_options): Use add_cmd to install "maint
show test-options-completion-result".
gdb/testsuite/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
* gdb.base/options.exp (test-misc, test-flag, test-boolean)
(test-uinteger, test-enum): Adjust res_test_gdb_... calls to pass
the expected output in the success.
Pedro Alves [Wed, 3 Jul 2019 15:57:48 +0000 (16:57 +0100)]
Fix test_gdb_complete_tab_multiple race
Running 'make check-read1 TESTS="gdb.base/options.exp"' revealed a
race in test_gdb_complete_tab_multiple. There's a gdb_test_multiple
call that expects a prompt in the middle of the regexp. That's racy
because gdb_test_multiple includes a built-in FAIL pattern for the
prompt, which may match if gdb is slow enough to produce the rest of
the output after the prompt.
Fix this in the usual way of splitting the matching in two.
gdb/testsuite/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
* lib/completion-support.exp (test_gdb_complete_tab_multiple):
Split one gdb_test_multiple call in two to avoid a race.
Nick Clifton [Wed, 3 Jul 2019 14:26:32 +0000 (15:26 +0100)]
Fix assembler tests to work with toolchains that have been configured with --enable-generate-build-notes.
Pedro Alves [Wed, 3 Jul 2019 12:34:20 +0000 (13:34 +0100)]
Introduce the "with" command
( See original discussion and prototype here:
https://sourceware.org/ml/gdb-patches/2019-05/msg00570.html )
(gdb) help with
Temporarily set SETTING to VALUE, run COMMAND, and restore SETTING.
Usage: with SETTING [VALUE] [-- COMMAND]
Usage: w SETTING [VALUE] [-- COMMAND]
With no COMMAND, repeats the last executed command.
SETTING is any setting you can change with the "set" subcommands.
E.g.:
with language pascal -- print obj
with print elements unlimited -- print obj
As can be seen above, the "with" command is just like "set", but
instead of setting the setting permanently, it sets the setting, runs
a command and then restores the setting.
(gdb) p g_s
$1 = {a = 1, b = 2, c = 3}
(gdb) with language ada -- print g_s
$2 = (a => 1, b => 2, c => 3)
Warning: the current language does not match this frame.
(gdb) show language
The current source language is "auto; currently c".
(gdb) with print elements 100 -- with print object on -- print 1
$3 = 1
You can shorten things a bit though, as long as unambiguous. So this:
(gdb) with print elements 100 -- with print object off -- print 1
is the same as:
(gdb) w p el 100 -- w p o 0 -- p 1
Note that the patch adds a "w" alias for "with", as "w" is not
currently taken:
(gdb) w
Ambiguous command "w": watch, wh, whatis, where, while, while-stepping, winheight, ws.
Let me know if you'd prefer to reserve "w" for one of the other
commands above. IMHO, this command will end up being used frequently
enough that it deserves the "w" shorthand.
A nice feature is that this is fully integrated with TAB-completion:
(gdb) with p[TAB]
pagination print prompt python
(gdb) with print [TAB]
address max-depth static-members
array max-symbolic-offset symbol
array-indexes null-stop symbol-filename
asm-demangle object symbol-loading
demangle pascal_static-members thread-events
elements pretty type
entry-values raw union
frame-arguments repeats vtbl
inferior-events sevenbit-strings
(gdb) with print [TAB]
(gdb) with print elements unlimited -- thread apply all -[TAB]
-ascending -c -q -s
(gdb) with print elements unlimited -- print -[TAB]
-address -max-depth -repeats -vtbl
-array -null-stop -static-members
-array-indexes -object -symbol
-elements -pretty -union
The main advantage of this new command compared to command options,
like the new "print -OPT", is that this command works with any
setting, and, it works nicely when you want to override a setting
while running a user-defined command, like:
(gdb) with print pretty -- usercmd
The disadvantage is that it isn't as compact or easy to type. I think
of command options and this command as complementary. I think that
even with this new command, it makes sense to continue developing the
command options in the direction of exposing most-oft-used settings as
command options.
Inspired by Philippe's "/" command proposal, if no command is
specified, then the last command is re-invoked, under the overridden
setting:
(gdb) p g_s
$1 = {a = 1, b = 2, c = 3}
(gdb) with language ada
$2 = (a => 1, b => 2, c => 3)
Warning: the current language does not match this frame.
Note: "with" requires "--" to separate the setting from the command.
It might be possible to do without that, but, I haven't tried it yet,
and I think that this can go in without it. We can always downgrade
to making "--" optional if we manage to make it work.
On to the patch itself, the implementation of the command is simpler
than one might expect. A few details:
- I factored out a bit from pipe_command into repeat_previous
directly, because otherwise I'd need to copy&paste the same code and
same error message in the with command.
- The parse_cli_var_uinteger / parse_cli_var_zuinteger_unlimited /
do_set_command changes are necessary since we can now pass an empty
string as argument.
- do_show_command was split in two, as a FIXME comment suggests, but
for a different reason: we need to get a string version of a "set"
command's value, and we already had code for that in
do_show_command. That code is now factored out to the new
get_setshow_command_value_string function.
- There's a new "maint with" command added too:
(gdb) help maint with
Like "with", but works with "maintenance set" variables.
Usage: maintenance with SETTING [VALUE] [-- COMMAND]
With no COMMAND, repeats the last executed command.
SETTING is any setting you can change with the "maintenance set"
subcommands.
"with" and "maint with" share 99% of the implementation.
This might be useful on its own, but it's also useful for testing,
since with this, we can use the "maint set/show test-settings"
settings for exercising the "with" machinery with all the command
type variants (all enum var_types). This is done in the new
gdb/base/with.exp testcase.
The documentation bits are originally based on Philippe's docs for the
"/" command, hence the attribution in the ChangeLog.
gdb/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
* NEWS (New commands): Mention "with" and "maint with".
* cli/cli-cmds.c (with_command_1, with_command_completer_1)
(with_command, with_command_completer): New.
(pipe_command): Adjust to new repeat_previous
interface.
(_initialize_cli_cmds): Install the "with" command and its "w"
alias.
* cli/cli-cmds.h (with_command_1, with_command_completer_1): New
declarations.
* cli/cli-setshow.c (parse_cli_var_uinteger)
(parse_cli_var_zuinteger_unlimited, do_set_command): Handle empty
argument strings for all var_types.
(get_setshow_command_value_string): New, factored out from ...
(do_show_command): ... this.
* cli/cli-setshow.h: Include <string>.
(get_setshow_command_value_string): Declare.
* command.h (repeat_previous): Now returns const char *. Adjust
comment.
* maint.c: Include "cli/cli-cmds.h".
(maintenance_with_cmd, maintenance_with_cmd_completer): New.
(_initialize_maint_cmds): Register the "maintenance with" command.
* top.c (repeat_previous): Move bits from pipe_command here:
Return the saved command line, if any; error out if there's no
command to relaunch.
gdb/doc/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.texinfo (Command Settings): New node documenting the general
concept of settings, how to change them, and the new "with"
command.
(Maintenance Commands): Document "maint with".
gdb/testsuite/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
* gdb.base/with.c: New file.
* gdb.base/with.exp: New file.
Pedro Alves [Wed, 3 Jul 2019 12:34:19 +0000 (13:34 +0100)]
"maint test-settings set/show" -> "maint set/show test-settings"
This commit renames "maint test-settings set/show" to "maint set/show
test-settings".
This helps the following patch, which introduce a "maint with" command
what works with all "maint set" settings.
gdb/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
* NEWS (New commands): Mention "maint set/show test-settings"
instead of "maint test-settings".
* maint-test-settings.c (maintenance_test_settings_list): Delete.
(maintenance_test_settings_set_list): Rename to ...
(maintenance_set_test_settings_list): ... this.
(maintenance_test_settings_show_list): Rename to ...
(maintenance_show_test_settings_list): ... this.
(maintenance_test_settings_cmd): Delete.
(maintenance_test_settings_set_cmd): ...
(maintenance_set_test_settings_cmd): ... this.
(maintenance_test_settings_show_cmd): ...
(maintenance_show_test_settings_cmd): ... this.
(maintenance_test_settings_show_value_cmd):
(maintenance_show_test_settings_value_cmd): ... this.
(_initialize_maint_test_settings): No longer install the "maint
test-settings" prefix command. Rename "maint test-settings set"
to "maint set test-settings", and "maint test-settings show" to
"maint show test-settings". Adjust all subcommands.
gdb/doc/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Maintenance Commands): Document "maint set/show
test-settings" instead of "maint test-settings set/show".
gdb/testsuite/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
* gdb.base/settings.exp: Replace all references to "maint
test-settings set" with references to "maint set test-settings",
and all references to "maint test-settings show" with references
to "maint show test-settings".
Pedro Alves [Wed, 3 Jul 2019 12:34:18 +0000 (13:34 +0100)]
Fix a few comments in maint-test-settings.c
Fix the file's intro comment, and s/test-options/test-settings/.
gdb/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
* maint-test-settings.c: Fix file's intro comment. Replace all
references to "test-options" with references to "test-settings",
in comments.
Pedro Alves [Wed, 3 Jul 2019 12:34:17 +0000 (13:34 +0100)]
Fix defaults of some "maint test-settings" subcommands
New tests added later for the incoming "with" command exposed a couple
invalid-default-value bugs in the "maint test-settings" commands:
- var_filename commands don't allow setting the filename to the empty
string (unlike var_optional_filename commands), yet, "maint
test-settings filename"'s control variable was not initialized, so
on startup, "maint test-settings show filename" shows an empty
string.
- "maint test-settings enum"'s control variable was not initialized,
so on startup, "maint test-settings show enum" shows an empty value
instead of a valid enum value.
Both issues are fixed by initializing the control variables.
gdb/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
* maint-test-settings.c (maintenance_test_settings_xxx)
(maintenance_test_settings_yyy, maintenance_test_settings_zzz):
New.
(maintenance_test_settings_enums): Use them.
(maintenance_test_settings_enum): Default to
maintenance_test_settings_xxx.
(_initialize_maint_test_settings): Initialize
MAINTENANCE_TEST_SETTINGS_FILENAME.
gdb/testsuite/ChangeLog:
2019-07-03 Pedro Alves <palves@redhat.com>
* gdb.base/settings.exp (test-string): Adjust expected out when
testing "maint test-settings show filename"
Simon Marchi [Wed, 3 Jul 2019 02:03:09 +0000 (22:03 -0400)]
Remove return value from remove_breakpoints_inf
... since nobody uses it.
gdb/ChangeLog:
* breakpoint.h (remove_breakpoints_inf): Change return type to
void, move function documentation here.
* breakpoint.c (remove_breakpoints_inf): Change return type to
void, move function documentation to header.
GDB Administrator [Wed, 3 Jul 2019 00:00:24 +0000 (00:00 +0000)]
Automatic date update in version.in
Pedro Alves [Tue, 2 Jul 2019 15:34:31 +0000 (16:34 +0100)]
Make "info threads" use the gdb::option framework
This makes "info threads" use the gdb::option framework to process
options. There's only one option today (-gid), and it isn't used much
frequently unless you're looking at matching MI output. Still, this
was in the neighborhood of "thread apply" so I had converted it.
The main advantage is that TAB completion now shows you the available
options, and gives you a hint to what the command accepts as operand
argument, including showing a metasyntactic variable:
(gdb) info threads [TAB]
-gid ID
(gdb) help info threads
Display currently known threads.
Usage: info threads [OPTION]... [ID]...
Options:
-gid
Show global thread IDs.
If ID is given, it is a space-separated list of IDs of threads to display.
Otherwise, all threads are displayed.
(gdb)
gdb/ChangeLog:
2019-07-02 Pedro Alves <palves@redhat.com>
* NEWS (Completion improvements): Mention "info threads".
* thread.c (struct info_threads_opts, info_threads_option_defs)
(make_info_threads_options_def_group): New.
(info_threads_command): Use gdb::option::process_options.
(info_threads_command_completer): New.
(_initialize_thread): Use gdb::option::build_help to build the
help text for "info threads".
gdb/testsuite/ChangeLog:
2019-07-02 Pedro Alves <palves@redhat.com>
* gdb.base/options.exp (test-info-threads): New procedure.
(top level): Call it.
Nick Clifton [Tue, 2 Jul 2019 14:58:29 +0000 (15:58 +0100)]
Stop the BFD library from issuing a warning message when processing allocated sections in debuginfo files that lie outside of any loadable segment.
PR 24717
* elf.c (is_debuginfo_file): New function.
(assign_file_positions_for_non_load_sections): Do not warn about
allocated sections outside of loadable segments if they are found
in a debuginfo file.
* elf-bfd.h (is_debuginfo_file): Prototype.
Simon Marchi [Tue, 2 Jul 2019 14:30:46 +0000 (10:30 -0400)]
Move generic_load declaration to symfile.h
... since the implementation is in symfile.c.
At the same time, add some documentation and make sure the first
parameter's name in the declaration matches the definition.
gdb/ChangeLog:
* defs.h (generic_load): Move from here...
* symfile.h (generic_load): ... to here. Rename name parameter
to args.
* symfile.c (generic_load): Add comment.
Nick Clifton [Tue, 2 Jul 2019 13:14:13 +0000 (14:14 +0100)]
Fix a bug recently introduced to the linker where it would complain about a section being larger than a file, even if the section was artificial.
PR 24753
bfd * compress.c (bfd_get_full_section_contents): Do not complain
about linker created sections that are larger than the file size.
ld * emultempl/aarch64elf.em (_aarch64_add_stub_section): Include the
LINKER_CREATED section flag when creating the stub section.
Barnaby Wilks [Tue, 2 Jul 2019 13:09:52 +0000 (14:09 +0100)]
This patch fixes a bug in the AArch64 assembler where an incorrect structural load/store by element instruction would generate the wrong error message.
For example, when provided with the (incorrect) instruction
st4 {v0.16b-v3.16b}[4],[x0]
currently assembler provides the following error message
"Error: comma expected between operands at operand 2 -- `st4 {v0.16b-v3.16b}[4],[x0]'".
This was due to the assembler consuming the {v0.16b-v3.16b} as the first operand leaving
[4],[x0] as what it believed to be the second operand.
The actual error is that the first operand should be of element type and not
vector type (as provided). The new diagnostic for this error is
"Error: expected element type rather than vector type at operand 1 -- `st4 {v0.16b-v3.16b}[4],[x0]'.
Added testcases to check for the correct diagnostic message as well as checking that
variations of the structural load/store by element instruction also generate the error
when they have the same problem.
* config/tc-aarch64.c (parse_operands): Add error check.
* testsuite/gas/aarch64/diagnostic.l: New test.
* testsuite/gas/aarch64/diagnostic.s: New test.
* testsuite/gas/aarch64/illegal.l: New tests.
* testsuite/gas/aarch64/illegal.s: New tests.
Christophe Lyon [Tue, 2 Jul 2019 13:09:02 +0000 (13:09 +0000)]
PR ld/24709 [arm] linker crash and assertion failure with CMSE
As discussed in the PR, we do not support the case where CMSE stubs
are inserted too far from their destination. This would require an
intermediate long-branch stub, which is tricky in this context.
Instead of crashing, this patch emit an error message and exits.
2019-07-02 Christophe Lyon <christophe.lyon@linaro.org>
* bfd/elf32-arm.c (CMSE_STUB_NAME): New define.
(elf32_arm_get_stub_entry): Do not try to emit long-branch stubs
for CMSE stubs.
(arm_dedicated_stub_output_section_name): Use CMSE_STUB_NAME.
Change-Id: I6d4e1c0fdee6bb9f4b07e5e1b46700b5ba31c62e
Srinath Parvathaneni [Tue, 2 Jul 2019 11:43:59 +0000 (12:43 +0100)]
Ensure that debug information is retained for ARMv8-M security functions.
Consider a file containing only Armv8-M secure entry functions.
This file is compiled and linked with "-march=armv8-m.main -mfloat-abi=hard
-mfpu=fpv5-sp-d16 -mcmse -static --specs=rdimon.specs
-Wl,--section-start,.gnu.sgstubs=0x190000 -ffunction-sections
-fdata-sections
-Wl,--gc-sections -g" options to generate an executable.
The executable generated does not contain any debug information of these
secure entry functions even though it contains secure entry functions in
the .text section. This patch fixes this problem.
Richard Sandiford [Tue, 2 Jul 2019 09:52:16 +0000 (10:52 +0100)]
[AArch64] Allow MOVPRFX to be used with FMOV
The entry for the FMOV alias of FCPY was missing C_SCAN_MOVPRFX.
(The entry for FCPY itself was OK.)
This was the only /m-predicated instruction I could see that was
missing the flag.
2019-07-02 Richard Sandiford <richard.sandiford@arm.com>
opcodes/
* aarch64-tbl.h (aarch64_opcode): Set C_SCAN_MOVPRFX for the
SVE FMOV alias of FCPY.
gas/
* testsuite/gas/aarch64/sve-movprfx_27.s,
* testsuite/gas/aarch64/sve-movprfx_27.d: New test.
Richard Sandiford [Tue, 2 Jul 2019 09:51:09 +0000 (10:51 +0100)]
[AArch64] Add missing C_MAX_ELEM flags for SVE conversions
SVE FCVTZS, FCVTZU, SCVTF and UCVTF need the same treatment as FCVT:
the register size used in a predicated MOVPRFX must be the wider of
the destination and source sizes.
Since I was adding a (supposedly) complete set of tests for converts,
it seemed more consistent to add a complete set of tests for shifts
as well, even though there's no bug to fix there.
2019-07-02 Richard Sandiford <richard.sandiford@arm.com>
opcodes/
* aarch64-tbl.h (aarch64_opcode_table): Add C_MAX_ELEM flags
to SVE fcvtzs, fcvtzu, scvtf and ucvtf entries.
gas/
* testsuite/gas/aarch64/sve-movprfx_26.s: Also test FCVTZS, FCVTZU,
SCVTF, UCVTF, LSR and ASR.
* testsuite/gas/aarch64/sve-movprfx_26.d: Update accordingly.
* testsuite/gas/aarch64/sve-movprfx_26.l: Likewise.
Richard Sandiford [Tue, 2 Jul 2019 09:51:05 +0000 (10:51 +0100)]
[AArch64] Fix bogus MOVPRFX warning for GPR form of CPY
One of the MOVPRFX tests has:
output register of preceding `movprfx' used as input at operand 3 -- `cpy z1.d,p1/m,x1'
But X1 and Z1 are not the same register, so the instruction is
actually OK.
2019-07-02 Richard Sandiford <richard.sandiford@arm.com>
opcodes/
* aarch64-opc.c (verify_constraints): Skip GPRs when scanning the
registers in an instruction prefixed by MOVPRFX.
gas/
* testsuite/gas/aarch64/sve-movprfx_25.s: Allow CPY Z1.D.P1/M,X1
to be prefixed by MOVPRFX.
* testsuite/gas/aarch64/sve-movprfx_25.d: Update accordingly.
* testsuite/gas/aarch64/sve-movprfx_25.l: Likewise.
GDB Administrator [Tue, 2 Jul 2019 00:00:38 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Mon, 1 Jul 2019 15:33:19 +0000 (09:33 -0600)]
Avoid use-after-free in DWARF debug names code
A static analyzer pointed out that find_vec_in_debug_names will use
the contents of a unique_ptr after it has been destroyed. This patch
fixes the bug by hoisting the declaration into the appropriate
enclosing block.
I'm checking this in as obvious.
gdb/ChangeLog
2019-07-01 Tom Tromey <tromey@adacore.com>
* dwarf2read.c
(dw2_debug_names_iterator::find_vec_in_debug_names): Hoist
declaration of without_params. Fix formatting.
Nick Clifton [Mon, 1 Jul 2019 15:19:14 +0000 (16:19 +0100)]
Fix bug when generating REL type relocs for assembler generated build notes.
PR 24748
* write.c (create_note_reloc): Add desc2_offset parameter. Change
name of offset parameter to note_offset. Only use desc2_offset
when placing addend into REL reloc's address space.
(maybe_generate_build_notes): Update parameters passed to
create_note_reloc.
Matthew Malcomson [Mon, 1 Jul 2019 14:17:22 +0000 (15:17 +0100)]
[gas][aarch64][SVE2] Fix pmull{t,b} requirement on SVE2-AES
I had mistakenly given all variants of the new SVE2 instructions
pmull{t,b} a dependency on the feature +sve2-aes.
Only the variant specifying .Q -> .D sizes should have that
restriction.
This patch fixes that mistake and updates the testsuite to have extra
tests (matching the given set of tests per line in aarch64-tbl.h that
the rest of the SVE2 tests follow).
We also add a line in the documentation of the command line to clarify
how to enable `pmull{t,b}` of this larger size. This is needed because
all other instructions gated under the `sve2-aes` architecture extension
are marked in the instruction documentation by an `HaveSVE2AES` check
while pmull{t,b} is gated under the `HaveSVE2PMULL128` check.
Regtested targeting aarch64-linux.
gas/ChangeLog:
2019-07-01 Matthew Malcomson <matthew.malcomson@arm.com>
* testsuite/gas/aarch64/illegal-sve2-aes.d: Update tests.
* testsuite/gas/aarch64/illegal-sve2.l: Update tests.
* doc/c-aarch64.texi: Add special note of pmull{t,b}
instructions under the sve2-aes architecture extension.
* testsuite/gas/aarch64/illegal-sve2.s: Add small size
pmull{t,b} instructions.
* testsuite/gas/aarch64/sve2.d: Add small size pmull{t,b}
disassembly.
* testsuite/gas/aarch64/sve2.s: Add small size pmull{t,b}
instructions.
include/ChangeLog:
2019-07-01 Matthew Malcomson <matthew.malcomson@arm.com>
* opcode/aarch64.h (enum aarch64_insn_class): sve_size_013
renamed to sve_size_13.
opcodes/ChangeLog:
2019-07-01 Matthew Malcomson <matthew.malcomson@arm.com>
* aarch64-asm.c (aarch64_encode_variant_using_iclass): Use new
sve_size_13 icode to account for variant behaviour of
pmull{t,b}.
* aarch64-dis-2.c: Regenerate.
* aarch64-dis.c (aarch64_decode_variant_using_iclass): Use new
sve_size_13 icode to account for variant behaviour of
pmull{t,b}.
* aarch64-tbl.h (OP_SVE_VVV_HD_BS): Add new qualifier.
(OP_SVE_VVV_Q_D): Add new qualifier.
(OP_SVE_VVV_QHD_DBS): Remove now unused qualifier.
(struct aarch64_opcode): Split pmull{t,b} into those requiring
AES and those not.
Tom Tromey [Thu, 27 Jun 2019 15:05:17 +0000 (09:05 -0600)]
Remove is_a_field_of_this from ada_lookup_symbol
All callers of ada_lookup_symbol pass NULL for the
"is_a_field_of_this" parameter, so remove it.
gdb/ChangeLog
2019-07-01 Tom Tromey <tromey@adacore.com>
* ada-exp.y (find_primitive_type): Update.
* ada-lang.h (ada_lookup_symbol): Update.
* ada-lang.c (ada_lookup_symbol): Remove "is_a_field_of_this"
parameter.
(ada_lookup_encoded_symbol, ada_lookup_symbol_nonlocal): Update.
Nick Clifton [Mon, 1 Jul 2019 11:39:09 +0000 (12:39 +0100)]
Document the .value directive supported by the x86 and x86_64 assemblers.
PR 24738
* doc/c-i386.texi (i386-Directives): Add a description of the
Value directive.
Nick Clifton [Mon, 1 Jul 2019 11:24:46 +0000 (12:24 +0100)]
Correct a typo in the description of the Align and P2align directives.
PR 24737
* doc/as.texi (Align): Add missing word to description of
pseudo-op.
(P2align): Likewise.
Nick Clifton [Mon, 1 Jul 2019 10:17:01 +0000 (11:17 +0100)]
Correct the calculation of offsets for ARM exidx relocs when performing a partial link.
PR 23839
bfd * elf32-arm.c (elf32_arm_update_relocs): Do not include the
section VMA in the offset used to update exidx relocs.
ld * testsuite/ld-arm/unwind-4.d: Adjust for corrected calculation of
exidx relocs.
Nick Alcock [Fri, 28 Jun 2019 21:11:14 +0000 (22:11 +0100)]
libctf: fix spurious error when rolling back to the first snapshot
The first ctf_snapshot called after CTF file creation yields a snapshot
handle that always yields a spurious ECTF_OVERROLLBACK error ("Attempt
to roll back past a ctf_update") on ctf_rollback(), even if ctf_update
has never been called.
The fix is to start with a ctf_snapshot value higher than the zero value
that ctf_snapshot_lu ("last update CTF snapshot value") is initialized
to.
libctf/
* ctf-create.c (ctf_create): Fix off-by-one error.
Nick Alcock [Thu, 27 Jun 2019 12:51:10 +0000 (13:51 +0100)]
libctf: deduplicate and sort the string table
ctf.h states:
> [...] the CTF string table does not contain any duplicated strings.
Unfortunately this is entirely untrue: libctf has before now made no
attempt whatsoever to deduplicate the string table. It computes the
string table's length on the fly as it adds new strings to the dynamic
CTF file, and ctf_update() just writes each string to the table and
notes the current write position as it traverses the dynamic CTF file's
data structures and builds the final CTF buffer. There is no global
view of the strings and no deduplication.
Fix this by erasing the ctf_dtvstrlen dead-reckoning length, and adding
a new dynhash table ctf_str_atoms that maps unique strings to a list
of references to those strings: a reference is a simple uint32_t * to
some value somewhere in the under-construction CTF buffer that needs
updating to note the string offset when the strtab is laid out.
Adding a string is now a simple matter of calling ctf_str_add_ref(),
which adds a new atom to the atoms table, if one doesn't already exist,
and adding the location of the reference to this atom to the refs list
attached to the atom: this works reliably as long as one takes care to
only call ctf_str_add_ref() once the final location of the offset is
known (so you can't call it on a temporary structure and then memcpy()
that structure into place in the CTF buffer, because the ref will still
point to the old location: ctf_update() changes accordingly).
Generating the CTF string table is a matter of calling
ctf_str_write_strtab(), which counts the length and number of elements
in the atoms table using the ctf_dynhash_iter() function we just added,
populating an array of pointers into the atoms table and sorting it into
order (to help compressors), then traversing this table and emitting it,
updating the refs to each atom as we go. The only complexity here is
arranging to keep the null string at offset zero, since a lot of code in
libctf depends on being able to leave strtab references at 0 to indicate
'no name'. Once the table is constructed and the refs updated, we know
how long it is, so we can realloc() the partial CTF buffer we allocated
earlier and can copy the table on to the end of it (and purge the refs
because they're not needed any more and have been invalidated by the
realloc() call in any case).
The net effect of all this is a reduction in uncompressed strtab sizes
of about 30% (perhaps a quarter to a half of all strings across the
Linux kernel are eliminated as duplicates). Of course, duplicated
strings are highly redundant, so the space saving after compression is
only about 20%: when the other non-strtab sections are factored in, CTF
sizes shrink by about 10%.
No change in externally-visible API or file format (other than the
reduction in pointless redundancy).
libctf/
* ctf-impl.h: (struct ctf_strs_writable): New, non-const version of
struct ctf_strs.
(struct ctf_dtdef): Note that dtd_data.ctt_name is unpopulated.
(struct ctf_str_atom): New, disambiguated single string.
(struct ctf_str_atom_ref): New, points to some other location that
references this string's offset.
(struct ctf_file): New members ctf_str_atoms and ctf_str_num_refs.
Remove member ctf_dtvstrlen: we no longer track the total strlen
as we add strings.
(ctf_str_create_atoms): Declare new function in ctf-string.c.
(ctf_str_free_atoms): Likewise.
(ctf_str_add): Likewise.
(ctf_str_add_ref): Likewise.
(ctf_str_purge_refs): Likewise.
(ctf_str_write_strtab): Likewise.
(ctf_realloc): Declare new function in ctf-util.c.
* ctf-open.c (ctf_bufopen): Create the atoms table.
(ctf_file_close): Destroy it.
* ctf-create.c (ctf_update): Copy-and-free it on update. No longer
special-case the position of the parname string. Construct the
strtab by calling ctf_str_add_ref and ctf_str_write_strtab after the
rest of each buffer element is constructed, not via open-coding:
realloc the CTF buffer and append the strtab to it. No longer
maintain ctf_dtvstrlen. Sort the variable entry table later, after
strtab construction.
(ctf_copy_membnames): Remove: integrated into ctf_copy_{s,l,e}members.
(ctf_copy_smembers): Drop the string offset: call ctf_str_add_ref
after buffer element construction instead.
(ctf_copy_lmembers): Likewise.
(ctf_copy_emembers): Likewise.
(ctf_create): No longer maintain the ctf_dtvstrlen.
(ctf_dtd_delete): Likewise.
(ctf_dvd_delete): Likewise.
(ctf_add_generic): Likewise.
(ctf_add_enumerator): Likewise.
(ctf_add_member_offset): Likewise.
(ctf_add_variable): Likewise.
(membadd): Likewise.
* ctf-util.c (ctf_realloc): New, wrapper around realloc that aborts
if there are active ctf_str_num_refs.
(ctf_strraw): Move to ctf-string.c.
(ctf_strptr): Likewise.
* ctf-string.c: New file, strtab manipulation.
* Makefile.am (libctf_a_SOURCES): Add it.
* Makefile.in: Regenerate.
Nick Alcock [Thu, 27 Jun 2019 12:30:22 +0000 (13:30 +0100)]
libctf: add hash traversal helpers
There are two, ctf_dynhash_iter and ctf_dynhash_iter_remove: the latter
lets you return a nonzero value to remove the element being iterated
over.
Used in the next commit.
libctf/
* ctf-impl.h (ctf_hash_iter_f): New.
(ctf_dynhash_iter): New declaration.
(ctf_dynhash_iter_remove): New declaration.
* ctf-hash.c (ctf_dynhash_iter): Define.
(ctf_dynhash_iter_remove): Likewise.
(ctf_hashtab_traverse): New.
(ctf_hashtab_traverse_remove): Likewise.
(struct ctf_traverse_cb_arg): Likewise.
(struct ctf_traverse_remove_cb_arg): Likewise.
Nick Alcock [Fri, 28 Jun 2019 20:58:31 +0000 (21:58 +0100)]
libctf: fix hash removal
We must call htab_remove_elt with an element (in this case, a mocked-up
one with only the key populated, since no reasonable hash function will
need the other fields), not with the key alone.
libctf/
* ctf-hash.c (ctf_dynhash_remove): Call with a mocked-up element.
Nick Alcock [Thu, 27 Jun 2019 12:15:37 +0000 (13:15 +0100)]
libctf: disambiguate hex output in dumps
We were sometimes printing hex values without prefixing them with '0x',
leading to confusion about what base the numbers were actually in.
libctf/
* ctf-dump.c (ctf_dump_format_type): Prefix hex strings with 0x.
(ctf_dump_funcs): Likewise.
Nick Clifton [Mon, 1 Jul 2019 09:20:43 +0000 (10:20 +0100)]
Fix spelling error in assembler documentation.
Jan Beulich [Mon, 1 Jul 2019 06:38:50 +0000 (08:38 +0200)]
x86: drop Vec_Imm4
It is pretty wasteful to have a per-operand flag which is used in
exactly 4 cases. It can be relatively easily replaced, and by doing so
I've actually found some dead code to remove at the same time (there's
no case of ImmExt set at the same time as Vec_Imm4).
Jan Beulich [Mon, 1 Jul 2019 06:37:40 +0000 (08:37 +0200)]
x86: limit ImmExt abuse
In quite a few cases ImmExt gets used when there's not really any
immediate, but rather a degenerate ModR/M byte. ENCL{S,U} show how this
case is supposed to be dealt with. Eliminate most abuses, leaving in
place (for now) only ones where process_immext() is involved.
Jan Beulich [Mon, 1 Jul 2019 06:35:08 +0000 (08:35 +0200)]
x86: optimize AND/OR with twice the same register
It seems to be not uncommon for people to use AND or OR in this form for
just setting the status flags. TEST, which doesn't write to any
register other than EFLAGS, ought to be preferred. Make the change only
for -O2 and above though, at least for now.
Jan Beulich [Mon, 1 Jul 2019 06:33:56 +0000 (08:33 +0200)]
x86-64: optimize certain commutative VEX-encoded insns
When they're in the 0F opcode space, swapping their source operands may
allow switching from 3-byte to 2-byte VEX prefix encoding. Note that NaN
behavior precludes us doing so for many packed and scalar floating point
insns; such an optimization would need to be done by the compiler
instead in this case, when it knows that NaN-s have undefined behavior
anyway.
While for explicitly specified AVX/AVX2 insns the optimization (for now
at least) gets done only for -O2 and -Os, it is utilized by default in
SSE2AVX mode, as there we're re-writing the programmer's specified insns
anyway.
Rather than introducing a new attribute flag, the change re-uses one
which so far was meaningful only for EVEX-encoded insns.
Jan Beulich [Mon, 1 Jul 2019 06:31:50 +0000 (08:31 +0200)]
x86: StaticRounding implies SAE
This implication allows to simplify some conditionals, thus slightly
improving performance. This change also paves the way for re-using
StaticRounding for non-EVEX insns.
Jan Beulich [Mon, 1 Jul 2019 06:31:14 +0000 (08:31 +0200)]
x86: optimize EVEX packed integer logical instructions
As long as there's no write mask as well as no broadcast, and as long
as the scaled Disp8 wouldn't result in a shorter EVEX encoding, encode
VPAND{D,Q}, VPANDN{D,Q}, VPOR{D,Q}, and VPXOR{D,Q} acting on only the
lower 16 XMM/YMM registers using their VEX equivalents with -O1.
Also take the opportunity and avoid looping twice over all operands
when dealing with memory-with-displacement ones.
Jan Beulich [Mon, 1 Jul 2019 06:28:58 +0000 (08:28 +0200)]
x86: add missing pseudo ops for VPCLMULQDQ ISA extension
While the ISA extensions doc suggests them to be made available just
like the SDM does for the PCLMULQDQ ISA extension, these weren't added
when supposrt for the new extension was introduced.
Also make sure the 64-bit non-AVX512 test actually tests VEX encodings,
not EVEX ones.
Jan Beulich [Mon, 1 Jul 2019 06:27:38 +0000 (08:27 +0200)]
x86: drop bogus Disp8MemShift attributes
In commit
dc821c5f9a ("x86: replace Reg8, Reg16, Reg32, and Reg64") I
apparently blindly copied the original register/memory templates into
separate ones, in particular without removing the Disp8MemShift which
are applicable to templates with memory operands only.
Jan Beulich [Mon, 1 Jul 2019 06:25:33 +0000 (08:25 +0200)]
x86: use encoding_length() also elsewhere
Jan Beulich [Mon, 1 Jul 2019 06:24:57 +0000 (08:24 +0200)]
x86: warn about insns exceeding the 15-byte limit
Such insns will cause #UD when an attempt to execute them is made.
See also http://www.sandpile.org/x86/opc_enc.htm.
Jan Beulich [Mon, 1 Jul 2019 06:23:41 +0000 (08:23 +0200)]
x86: remove ModRM.mod decoding layer from AVX512F VMOVS{S,D}
Just like their AVX counterparts they can utilize XMVexScalar /
EXdVexScalarS / EXqVexScalarS taking care of dropping the middle operand
for their memory forms.
Jan Beulich [Mon, 1 Jul 2019 06:22:37 +0000 (08:22 +0200)]
x86: drop a few dead macros
GDB Administrator [Mon, 1 Jul 2019 00:00:41 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 30 Jun 2019 00:01:04 +0000 (00:01 +0000)]
Automatic date update in version.in
GDB Administrator [Sat, 29 Jun 2019 00:00:22 +0000 (00:00 +0000)]
Automatic date update in version.in
Sergio Durigan Junior [Wed, 26 Jun 2019 21:34:50 +0000 (17:34 -0400)]
Adjust i386 registers on SystemTap probes' arguments (PR breakpoints/24541)
This bug has been reported on PR breakpoints/24541, but it is possible
to reproduce it easily by running:
make check-gdb TESTS=gdb.base/stap-probe.exp RUNTESTFLAGS='--target_board unix/-m32'
The underlying cause is kind of complex, and involves decisions made
by GCC and the sys/sdt.h header file about how to represent a probe
argument that lives in a register in 32-bit programs. I'll use
Andrew's example on the bug to illustrate the problem.
libstdc++ has a probe named "throw" with two arguments. On i386, the
probe is:
stapsdt 0x00000028 NT_STAPSDT (SystemTap probe descriptors)
Provider: libstdcxx
Name: throw
Location: 0x00072c96, Base: 0x00133d64, Semaphore: 0x00000000
Arguments: 4@%si 4@%di
I.e., the first argument is an unsigned 32-bit value (represented by
the "4@") that lives on %si, and the second argument is an unsigned
32-bit value that lives on %di. Note the discrepancy between the
argument size reported by the probe (32-bit) and the register size
being used to store the value (16-bit).
However, if you take a look at the disassemble of a program that uses
this probe, you will see:
00072c80 <__cxa_throw@@CXXABI_1.3>:
72c80: 57 push %edi
72c81: 56 push %esi
72c82: 53 push %ebx
72c83: 8b 74 24 10 mov 0x10(%esp),%esi
72c87: e8 74 bf ff ff call 6ec00 <__cxa_finalize@plt+0x980>
72c8c: 81 c3 74 e3 10 00 add $0x10e374,%ebx
72c92: 8b 7c 24 14 mov 0x14(%esp),%edi
72c96: 90 nop <----------------- PROBE IS HERE
72c97: e8 d4 a2 ff ff call 6cf70 <__cxa_get_globals@plt>
72c9c: 83 40 04 01 addl $0x1,0x4(%eax)
72ca0: 83 ec 04 sub $0x4,%esp
72ca3: ff 74 24 1c pushl 0x1c(%esp)
72ca7: 57 push %edi
72ca8: 56 push %esi
72ca9: e8 62 a3 ff ff call 6d010 <__cxa_init_primary_exception@plt>
72cae: 8d 70 40 lea 0x40(%eax),%esi
72cb1: c7 00 01 00 00 00 movl $0x1,(%eax)
72cb7: 89 34 24 mov %esi,(%esp)
72cba: e8 61 96 ff ff call 6c320 <_Unwind_RaiseException@plt>
72cbf: 89 34 24 mov %esi,(%esp)
72cc2: e8 c9 84 ff ff call 6b190 <__cxa_begin_catch@plt>
72cc7: e8 d4 b3 ff ff call 6e0a0 <_ZSt9terminatev@plt>
72ccc: 66 90 xchg %ax,%ax
72cce: 66 90 xchg %ax,%ax
Note how the program is actually using %edi, and not %di, to store the
second argument. This is the problem here.
GDB will basically read the probe argument, then read the contents of
%di, and then cast this value to uint32_t, which causes the wrong
value to be obtained. In the gdb.base/stap-probe.exp case, this makes
GDB read the wrong memory location, and not be able to display a test
string. In Andrew's example, this causes GDB to actually stop at a
"catch throw" when it should actually have *not* stopped.
After some discussion with Frank Eigler and Jakub Jelinek, it was
decided that this bug should be fixed on the client side (i.e., the
program that actually reads the probes), and this is why I'm proposing
this patch.
The idea is simple: we will have a gdbarch method, which, for now, is
only used by i386. The generic code that deals with register operands
on gdb/stap-probe.c will call this method if it exists, passing the
current parse information, the register name and its number.
The i386 method will then verify if the register size is greater or
equal than the size reported by the stap probe (the "4@" part). If it
is, we're fine. Otherwise, it will check if we're dealing with any of
the "extendable" registers (like ax, bx, si, di, sp, etc.). If we
are, it will change the register name to include the "e" prefix.
I have tested the patch here in many scenarios, and it fixes Andrew's
bug and also the regressions I mentioned before, on
gdb.base/stap-probe.exp. No regressions where found on other tests.
Comments?
gdb/ChangeLog:
2019-06-27 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/24541
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh: Add 'stap_adjust_register'.
* i386-tdep.c: Include '<unordered_set>'.
(i386_stap_adjust_register): New function.
(i386_elf_init_abi): Register 'i386_stap_adjust_register'.
* stap-probe.c (stap_parse_register_operand): Call
'gdbarch_stap_adjust_register'.
Sergio Durigan Junior [Thu, 27 Jun 2019 17:14:26 +0000 (13:14 -0400)]
Fix crash when using PYTHONMALLOC=debug (PR python/24742)
This bug was originally reported against Fedora GDB:
https://bugzilla.redhat.com/show_bug.cgi?id=1723564
The problem is that GDB will crash in the following scenario:
- PYTHONMALLOC=debug or PYTHONDEVMODE=1 is set.
- The Python debuginfo is installed.
- GDB is used to debug Python.
The crash looks like this:
$ PYTHONMALLOC=debug gdb -args python3 -c pass
GNU gdb (GDB) Fedora 8.3-3.fc30
Reading symbols from python3...
Reading symbols from /usr/lib/debug/usr/bin/python3.7m-3.7.3-3.fc30.x86_64.debug...
(gdb) run
Starting program: /usr/bin/python3 -c pass
Missing separate debuginfos, use: dnf debuginfo-install glibc-2.29-9.fc30.x86_64
Debug memory block at address p=0x5603977bf330: API ''
8098648152243306496 bytes originally requested
The 7 pad bytes at p-7 are not all FORBIDDENBYTE (0xfb):
at p-7: 0x03 *** OUCH
at p-6: 0x00 *** OUCH
at p-5: 0x00 *** OUCH
at p-4: 0x00 *** OUCH
at p-3: 0x00 *** OUCH
at p-2: 0x00 *** OUCH
at p-1: 0x00 *** OUCH
Because memory is corrupted at the start, the count of bytes requested
may be bogus, and checking the trailing pad bytes may segfault.
The 8 pad bytes at tail=0x706483999ad1f330 are Segmentation fault (core dumped)
It's hard to determine what happens, but after doing some
investigation and talking to Victor Stinner I found that GDB should
not use the Python memory allocation functions before the Python
interpreter is initialized (which makes sense). However, we do just
that on python/python.c:do_start_initialization:
...
progsize = strlen (progname.get ());
progname_copy = (wchar_t *) PyMem_Malloc ((progsize + 1) * sizeof (wchar_t));
...
/* Note that Py_SetProgramName expects the string it is passed to
remain alive for the duration of the program's execution, so
it is not freed after this call. */
Py_SetProgramName (progname_copy);
...
Py_Initialize ();
PyEval_InitThreads ();
Upon reading the Python 3 C API documentation, I
found (https://docs.python.org/3.5/c-api/memory.html):
To avoid memory corruption, extension writers should never try to
operate on Python objects with the functions exported by the C
library: malloc(), calloc(), realloc() and free(). This will result in
mixed calls between the C allocator and the Python memory manager with
fatal consequences, because they implement different algorithms and
operate on different heaps. However, one may safely allocate and
release memory blocks with the C library allocator for individual
purposes[...]
And Py_SetProgramName seems like a very simple call that doesn't need
a Python-allocated memory to work on. So I'm proposing this patch,
which simply replaces PyMem_Malloc by xmalloc.
Testing this is more complicated. First, the crash is completely
non-deterministic; I was able to reproduce it 10 times in a row, and
then I wasn't able to reproduce it anymore. I found that if you
completely remove your build directory and rebuild GDB from scratch,
you can reproduce it again confidently. And with my patch, I
confirmed that the bug doesn't manifest even in this situation.
No regressions found.
OK to apply?
gdb/ChangeLog:
2019-06-28 Sergio Durigan Junior <sergiodj@redhat.com>
PR python/24742
https://bugzilla.redhat.com/show_bug.cgi?id=1723564
* python/python.c (do_start_initialization): Use 'xmalloc'
instead of 'PyMem_Malloc'.
Tom Tromey [Thu, 20 Jun 2019 19:50:15 +0000 (13:50 -0600)]
Handle either order of name and linkage name
We discovered that the Ada support in gdb depends on the order of the
DW_AT_name and DW_AT_linkage_name attributes in the DWARF. In
particular, if they are emitted in the "wrong" order for some system
symbols, "catch exception" will not work.
This patch fixes this problem by arranging to always prefer the
linkage name if both exist. This seems to be what the full symbol
reader already does -- that is, this is another bug arising from
having two different DWARF readers.
Another possible issue here is that gdb still doesn't really preserve
mangled names properly. There's a PR open about this. However, this
seems to be somewhat involved to fix, which is why this patch
continues to work around the bigger issue.
gdb/ChangeLog
2019-06-28 Tom Tromey <tromey@adacore.com>
* dwarf2read.c (partial_die_info::read): Prefer the linkage name
for Ada.
gdb/testsuite/ChangeLog
2019-06-28 Tom Tromey <tromey@adacore.com>
* gdb.dwarf2/ada-linkage-name.c: New file.
* gdb.dwarf2/ada-linkage-name.exp: New file.
Nick Clifton [Fri, 28 Jun 2019 14:30:43 +0000 (15:30 +0100)]
Prevent attempts to allocate excessive amounts of memory when parsing corrupt ELF files.
PR 24708
* elf.c (_bfd_elf_slurp_version_tables): Check for an excessively
large version reference section.
* compress.c (bfd_get_full_section_contents): Check for an
uncompressed section whose size is larger than the file size.
Nick Clifton [Fri, 28 Jun 2019 12:30:00 +0000 (13:30 +0100)]
Prevent an attempt to allocate an excessive amount of memory when dumping the symbols in a malformed file.
PR 24707
* objdump.c (slurp_symtab): Fail with a helpful error message if
the symbol table is too large.
Alan Modra [Fri, 28 Jun 2019 00:48:49 +0000 (10:18 +0930)]
Plugin target handling
This patch fixes failures with LTO on mingw32 targets. Since git
commit
7cf7fcc83c all possible targets (minus binary) are matched in
bfd_check_format_matches rather than lower priority targets being
excluded once a higher priority target matches. During linking that
results in the ld/plugin.c plugin_object_p function being called with
the input file xvec set to plugin_vec, which means
plugin_get_ir_dummy_bfd doesn't see the real format of the file
(pe-i386). It defaults to the output format instead, which happens to
be pei-i386, and this wrong choice persists for the dummy bfd.
pei-i386 isn't recognised as a valid linker input file.
So, omit recognizing a plugin object in bfd_check_format_matches when
some other object format matches, and make sure those other object
formats are checked first.
* format.c (bfd_check_format_matches): Don't match plugin target
if another target matches. Expand comment.
* targets.c (_bfd_target_vector): Move plugin_vec after all other
non-corefile targets, outside !SELECT_VECS.
* config.bfd: Don't handle targ=plugin here.
* configure.ac: Don't add plugin to enable_targets or handle in
target loop setting selvecs and other target vars.
* configure: Regenerate.
Alan Modra [Fri, 28 Jun 2019 00:48:03 +0000 (10:18 +0930)]
[GOLD] PowerPC tweak relnum tests
There is a call of relocate() to perform a single relocation. In that
case the "relnum" parameter is -1U and of course it isn't appropriate
to consider any of the PowerPC code sequence optimisations triggered
by a following relocation.
* powerpc.cc (Target_powerpc::Relocate::relocate): Don't look
at next/previous reloc when relnum is -1.
Alan Modra [Fri, 28 Jun 2019 00:47:45 +0000 (10:17 +0930)]
[GOLD] PowerPC linkage table error
This fixes a segfault when attempring to output a "linkage table
error". "object" is only non-NULL in the local symbol case.
* powerpc.cc (Stub_table::plt_error): New function.
(Stub_table::do_write): Use it.
(Output_data_glink::do_write): Don't segfault emitting linkage
table error.
Alan Modra [Fri, 28 Jun 2019 00:47:08 +0000 (10:17 +0930)]
[GOLD] R_PPC64_REL16_HIGH relocs
These relocs have been around for quite a while. It's past time gold
supported them.
elfcpp/
* powerpc.h (R_PPC64_REL16_HIGH, R_PPC64_REL16_HIGHA),
(R_PPC64_REL16_HIGHER, R_PPC64_REL16_HIGHERA),
(R_PPC64_REL16_HIGHEST, R_PPC64_REL16_HIGHESTA): Define.
gold/
* powerpc.cc (Target_powerpc::Scan::get_reference_flags): Handle
REL16_HIGH* relocs.
(Target_powerpc::Scan::local): Likewise.
(Target_powerpc::Scan::global): Likewise.
(Target_powerpc::Relocate::relocate): Likewise.
Alan Modra [Fri, 28 Jun 2019 00:45:57 +0000 (10:15 +0930)]
PowerPC notoc call stub tests
* testsuite/ld-powerpc/callstub-1.d,
* testsuite/ld-powerpc/callstub-1.s: New test.
* testsuite/ld-powerpc/callstub-2.d,
* testsuite/ld-powerpc/callstub-2.s: New test.
* testsuite/ld-powerpc/powerpc.exp: Run them.
GDB Administrator [Fri, 28 Jun 2019 00:00:56 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Thu, 27 Jun 2019 20:39:19 +0000 (13:39 -0700)]
i386: Check vector length for scatter/gather prefetch instructions
Since not all vector lengths are supported by scatter/gather prefetch
instructions, decode them only with supported vector lengths.
gas/
PR binutils/24719
* testsuite/gas/i386/disassem.s: Add test for vgatherpf0dps
with invalid vector length.
* 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/24719
* i386-dis-evex-len.h: Add EVEX_LEN_0F38C6_REG_1_PREFIX_2,
EVEX_LEN_0F38C6_REG_2_PREFIX_2, EVEX_LEN_0F38C6_REG_5_PREFIX_2,
EVEX_LEN_0F38C6_REG_6_PREFIX_2, EVEX_LEN_0F38C7_R_1_P_2_W_0,
EVEX_LEN_0F38C7_R_1_P_2_W_1, EVEX_LEN_0F38C7_R_2_P_2_W_0,
EVEX_LEN_0F38C7_R_2_P_2_W_1, EVEX_LEN_0F38C7_R_5_P_2_W_0,
EVEX_LEN_0F38C7_R_5_P_2_W_1, EVEX_LEN_0F38C7_R_6_P_2_W_0 and
EVEX_LEN_0F38C7_R_6_P_2_W_1.
* i386-dis-evex-prefix.h: Update PREFIX_EVEX_0F38C6_REG_1,
PREFIX_EVEX_0F38C6_REG_2, PREFIX_EVEX_0F38C6_REG_5 and
PREFIX_EVEX_0F38C6_REG_6 entries.
* i386-dis-evex-w.h: Update EVEX_W_0F38C7_R_1_P_2,
EVEX_W_0F38C7_R_2_P_2, EVEX_W_0F38C7_R_5_P_2 and
EVEX_W_0F38C7_R_6_P_2 entries.
* i386-dis.c: Add EVEX_LEN_0F38C6_REG_1_PREFIX_2,
EVEX_LEN_0F38C6_REG_2_PREFIX_2, EVEX_LEN_0F38C6_REG_5_PREFIX_2,
EVEX_LEN_0F38C6_REG_6_PREFIX_2, EVEX_LEN_0F38C7_R_1_P_2_W_0,
EVEX_LEN_0F38C7_R_1_P_2_W_1, EVEX_LEN_0F38C7_R_2_P_2_W_0,
EVEX_LEN_0F38C7_R_2_P_2_W_1, EVEX_LEN_0F38C7_R_5_P_2_W_0,
EVEX_LEN_0F38C7_R_5_P_2_W_1, EVEX_LEN_0F38C7_R_6_P_2_W_0 and
EVEX_LEN_0F38C7_R_6_P_2_W_1 enums.
Tom Tromey [Wed, 26 Jun 2019 17:41:00 +0000 (11:41 -0600)]
Change arm_objfile_data_key to use type-safe registry
After seeing Simon's patch to change arm_per_objfile to use new and
delete, I realized it is now simple to change arm_objfile_data_key to
use the type-safe registry.
gdb/ChangeLog
2019-06-27 Tom Tromey <tromey@adacore.com>
* arm-tdep.c (arm_objfile_data_key): Move lower. Change type to
objfile_key.
(arm_find_mapping_symbol, arm_record_special_symbol)
(_initialize_arm_tdep): Update.
(arm_objfile_data_free): Remove.
Tom Tromey [Tue, 18 Jun 2019 15:37:02 +0000 (09:37 -0600)]
Fix two buglets in cp_print_value_fields patch
Pedro and Tom both pointed out issues in the cp_print_value_fields
patch, aka the fix for PR c++/20020.
This patch addresses both issues. Tested on x86-64 Fedora 29.
gdb/ChangeLog
2019-06-27 Tom Tromey <tromey@adacore.com>
* cp-valprint.c (cp_print_value_fields): Pass opts, not options,
to cp_print_static_field.
gdb/testsuite/ChangeLog
2019-06-27 Tom Tromey <tromey@adacore.com>
* gdb.cp/constexpr-field.exp: Use setup_xfail.
Barnaby Wilk s [Thu, 27 Jun 2019 13:06:02 +0000 (14:06 +0100)]
This fixes a bug in the ARm assembler where an immediate operand larger than 4 bits (0xF) could be passed to the SMC (Secure Monitor Call) instruction.
For example, this code is invalid:
smc #0x6951
The code would previously check for and encode for up to 16 bit immediate values, however
this immediate should instead be only a 4 bit value
(as documented herehttps://static.docs.arm.com/ddi0406/c/DDI0406C_C_arm_architecture_reference_manual.pdf ).
Fixed this by adding range checks in the relevant areas and also removing code that would
encode more than the first 4 bits of the immediate (code that is now redundant, as any immediate operand
larger than 0xF would error now anyway).
gas * config/tc-arm.c (do_smc): Add range check for immediate operand.
(do_t_smc): Add range check for immediate operand. Remove
obsolete immediate encoding.
(md_apply_fix): Fix range check. Remove obsolete immediate encoding.
* testsuite/gas/arm/arch6zk.d: Fix test.
* testsuite/gas/arm/arch6zk.s: Fix test.
* testsuite/gas/arm/smc-bad.d: New test.
* testsuite/gas/arm/smc-bad.l: New test.
* testsuite/gas/arm/smc-bad.s: New test.
* testsuite/gas/arm/thumb32.d: Fix test.
* testsuite/gas/arm/thumb32.s: Fix test.
Jan Beulich [Thu, 27 Jun 2019 10:40:08 +0000 (12:40 +0200)]
x86: add missing test
These files were mistakenly left out of commit
c1dc7af521.
Jan Beulich [Thu, 27 Jun 2019 06:50:28 +0000 (08:50 +0200)]
x86: fold AVX scalar to/from int conversion insns
There's no point doing a separate decode of the VEX.L bit - both decoded
forms are identical.
Jan Beulich [Thu, 27 Jun 2019 06:49:40 +0000 (08:49 +0200)]
x86: allow VEX et al encodings in 16-bit (protected) mode
These encodings aren't valid in real and VM86 modes, but they are very
well usable in 16-bit protected mode.
A few adjustments in the disassembler tables are needed where Ev or Gv
were wrongly used. Additionally an adjustment is needed to avoid
printing "addr32" when that's already recognizable by the use of %eiz.
Furthermore the Iq operand template was wrong for XOP:0Ah encoding
insns: They're having a uniform 32-bit immediate. Drop Iq and introduce
Id instead.
Clone a few existing test cases to exercise assembler and disassembler.
Jim Wilson [Thu, 27 Jun 2019 01:12:55 +0000 (18:12 -0700)]
Fix a few non-dash safe xstormy16 shell scripts.
Noticed by a customer while looking at a tangentially related problem. The
gas testsuite for xstormy16 has two scripts that have a typo on the first
line, they are missing the !. They also use shell syntax that doesn't work
on a system where /bin/sh is dash. So I fixed the typo, changed the shell
to bash, and made them executable, so that they now work when run directly
even if /bin/sh is dash.
gas/
* testsuite/gas/xstormy16/allinsn.sh: Change first line to
#!/bin/bash and make it executable.
* testsuite/gas/xstormy16/gcc.sh: Likewise.
Jim Wilson [Thu, 27 Jun 2019 00:17:09 +0000 (17:17 -0700)]
RISC-V: Make objdump disassembly work right for binary files.
Without the ELF header to set info->endian, it ends up as BFD_UNKNOWN_ENDIAN
which gets printed as big-endian. But RISC-V instructions are always little
endian, so we can set endian_code correctly, and then set display_endian from
that. This is similar to how the aarch64 support works, but without the
support for constant pools, as we don't have that on RISC-V.
opcodes/
PR binutils/24739
* riscv-dis.c (riscv_disasemble_insn): Set info->endian_code.
Set info->display_endian to info->endian_code.
GDB Administrator [Thu, 27 Jun 2019 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
Lili Cui [Wed, 26 Jun 2019 22:12:58 +0000 (15:12 -0700)]
i386: Document memory size reference in assembler
* doc/c-i386.texi: Document x/y/z instruction sufffixes in AT&T
syntax and xmmword/ymmword/zmmword/fword/tbyte/oword ptr in
Intel syntax.
Nick Clifton [Wed, 26 Jun 2019 16:03:32 +0000 (17:03 +0100)]
Ensure that when attempting to process an ARM Mach-O file with unknown relocs, that a suitable error message is displayed.
PR 24703
binutils* bucomm.c (bfd_nonfatal): If no bfd error code has been set then
indicate this in the output.
(bfd_nonfatal_message): Likewise.
bfd * mach-o-arm.c (bfd_mach_o_arm_canonicalize_one_reloc): Add error
messages for failures.
* mach-o.c (bfd_mach_o_canonicalize_relocs): Set an bfd error code
if returning an error value.
Tom Tromey [Wed, 26 Jun 2019 15:48:32 +0000 (09:48 -0600)]
Remove lookup_minimal_symbol_solib_trampoline
lookup_minimal_symbol_solib_trampoline is unused, so this patch
removes it. The last use was apparently removed in
commit
61a12cfa ("Remove HPUX").
gdb/ChangeLog
2019-06-26 Tom Tromey <tromey@adacore.com>
* minsyms.c (lookup_minimal_symbol_solib_trampoline): Remove.
* minsyms.h (lookup_minimal_symbol_solib_trampoline): Don't
declare.
Alan Hayward [Wed, 26 Jun 2019 14:48:12 +0000 (15:48 +0100)]
AArch64: Add missing CPSR flags
Add all the CPSR flags for Armv8.1-A through to Armv8.4-A.
In addition, document all the existing flags, and remove
the superfluous empty spaces.
gdb/ChangeLog:
* features/aarch64-core.c (create_feature_aarch64_core):
Regenerate.
* features/aarch64-core.xml: Add cpsr flags.
Alan Hayward [Wed, 26 Jun 2019 13:10:08 +0000 (14:10 +0100)]
Arm: Allow version strings in the triplet regexp
On Arm, the OS may use the full version string for the arch name when
installing the compiler, for example armv7hl-redhat-linux-gnueabi-gcc.
Implement gdbarch_gnu_triplet_regexp for Arm to allow this to be detected.
Ensure that other Arm targets (eg iwmmxt) are not affected.
This fixes the compile/ set of tests on those systems.
gdb/ChangeLog:
2019-06-26 Alan Hayward <alan.hayward@arm.com>
* arm-tdep.c (arm_gnu_triplet_regexp): New function.
(arm_gdbarch_init): Add arm_gnu_triplet_regexp.
Tom de Vries [Wed, 26 Jun 2019 13:04:05 +0000 (15:04 +0200)]
[gdb/testsuite] Compile varval twice, once without bad DWARF
When we run gdb.dwarf2/varval.exp with board cc-with-dwz, we run into:
...
gdb compile failed, dwz: varval: Couldn't find DIE referenced by \
DW_OP_GNU_variable_value
cc-with-tweaks.sh: dwz did not modify varval.
UNTESTED: gdb.dwarf2/varval.exp: failed to prepare
...
The problem is that varval contains some bad DWARF, which has been added
intentionally to test GDB, but that bad DWARF causes dwz to error out, which
has the consequence that the test-case remains untested with cc-with-dwz,
while the test-case contains also correct DWARF that does not occur in any
other test, and which we would really like to test with board cc-with-dwz.
Fix this by compiling varval twice, once without and once with the bad DWARF,
such that we have at least:
...
PASS: gdb.dwarf2/varval.exp: print varval
PASS: gdb.dwarf2/varval.exp: print varval2
PASS: gdb.dwarf2/varval.exp: print constval
PASS: gdb.dwarf2/varval.exp: print mixedval
PASS: gdb.dwarf2/varval.exp: print pointerval
PASS: gdb.dwarf2/varval.exp: print *pointerval
PASS: gdb.dwarf2/varval.exp: print structval
PASS: gdb.dwarf2/varval.exp: print untypedval
gdb compile failed, dwz: varval: Couldn't find DIE referenced by \
DW_OP_GNU_variable_value
cc-with-tweaks.sh: dwz did not modify varval.
UNTESTED: gdb.dwarf2/varval.exp: failed to prepare
...
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2019-06-26 Tom de Vries <tdevries@suse.de>
* gdb.dwarf2/varval.exp: Compile twice, once without bad DWARF.
Tom de Vries [Wed, 26 Jun 2019 03:52:47 +0000 (05:52 +0200)]
[gdb/testsuite] Add back missing debug for index-cache.exp
The proc prepare_for_testing has "debug" as default argument for the options
parameter.
In the commit
c596f180a1 "[gdb/testsuite] Compile index-cache.c with
-Wl,--build-id", by setting the options argument we've effectively dropped
"debug". This causes index-cache.exp to not contain any debug info anymore on
most systems (though not on openSUSE), which causes index-cache.exp FAILs.
Fix this by adding back the missing "debug" option.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2019-06-26 Tom de Vries <tdevries@suse.de>
* gdb.base/index-cache.exp: Add back missing debug option.
GDB Administrator [Wed, 26 Jun 2019 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Tue, 25 Jun 2019 18:22:30 +0000 (14:22 -0400)]
arm-tdep: sort mapping symbols after parsing all minimal symbols
Somebody on IRC reported a while ago that loading a big ARM program in
GDB was very slow. Their profiling pointed out that a big amount of
time was spent in
VEC_safe_insert (arm_mapping_symbol_s, *map_p, idx, &new_map_sym);
I was able to verify this as well.
ARM mapping symbols are special ELF symbols named $a, $d and $t
indicating that symbols starting at this address up to the next mapping
symbol (in terms of address) are of type "ARM code", "data" and "Thumb
code", respectively. GDB records these symbols in vectors (one for each
section) in arm-tdep.c. These vectors are sorted by symbol address, to
allow for quick lookup. The current approach is to insert new symbols
at the right position to keep the vectors sorted at all time. This is
done based on the assumption that mapping symbols come already almost
sorted from the binary, as explains this comment in
arm_record_special_symbol:
/* Assume that most mapping symbols appear in order of increasing
value. If they were randomly distributed, it would be faster to
always push here and then sort at first use. */
Well, it turns out this is not the case. The original reporter
mentioned that mapping symbols in their binaries are not nearly sorted,
and this is not my experience either (at least in the binary used in the
benchmark below). So if the values don't come nearly sorted, doing
insertions to keep the vectors sorted ends up being of the order of
number_of_mapping_symbols ^ 2.
This patch changes it just like the comment above says, to just append
to the vector in arm_record_special_symbol and sort the vector on first
use.
Benchmark
=========
I have done some benchmarks using an --enable-targets=all GDB, compiled
with -O2, running on x86-64 and parsing file
dce18d22e5c2ecb6a3a57372f4e6ef614130bc.debug from this package:
https://launchpad.net/ubuntu/+source/firefox/66.0.3+build1-0ubuntu1/+build/
16608691/+files/firefox-dbg_66.0.3+build1-0ubuntu1_armhf.deb
This file is the separate debug info for libxul.so (part of firefox) for
ARM.
I have added some traces to measure the execution time of just
elf_symtab_read and ran GDB like this:
./gdb --data-directory=data-directory -nx -batch .../path/to/usr/lib/debug/.build-id/65/
dce18d22e5c2ecb6a3a57372f4e6ef614130bc.debug
Since the new code sorts the vectors on first use, it would be difficult
to benchmark it as-is and be fair, since the "before" version does more
work in elf_symtab_read. So I have actually benchmarked a version of
the patch that did sort all the vectors at the end of elf_symtab_read,
so the sorting would be considered in the measured execution time.
Here's the measured execution time of elf_symtab_read, averaged on 3
runs:
insert sorted (before): 28.678s
sort after (after): 1.760s
And here's the total execution time of the command above (just one run).
The time is now mostly spent in reading DWARF.
insert sorted: 71.12s user 2.71s system 99% cpu 1:14.03 total
sort after: 46.42s user 2.60s system 99% cpu 49.147 total
I tried for fun on my Raspberry Pi 3, the run time of
elf_symtab_read goes from ~259s to ~9s, reading the same file.
gdb/ChangeLog:
* arm-tdep.c (struct arm_per_objfile) <section_maps_sorted>: New
field.
(arm_find_mapping_symbol): Sort mapping symbol vectors on first
use.
(arm_record_special_symbol): Don't insert new symbol in sorted
position, push it at the end.
Simon Marchi [Tue, 25 Jun 2019 18:22:23 +0000 (14:22 -0400)]
arm-tdep: replace arm_mapping_symbol VEC with std::vector
This patch replaces VEC (arm_mapping_symbol) with an std::vector. No
functional changes intended.
gdb/ChangeLog:
* arm-tdep.c (struct arm_mapping_symbol) (operator <): New.
(arm_mapping_symbol_s): Remove.
(DEF_VEC_O(arm_mapping_symbol_s)): Remove.
(arm_mapping_symbol_vec): New typedef.
(struct arm_per_objfile): Add constructor.
<section_maps>: Change type to
std::unique_ptr<arm_mapping_symbol_vec[]>.
(arm_compare_mapping_symbols): Remove.
(arm_find_mapping_symbol): Adjust to section_maps type change.
(arm_objfile_data_free): Call delete on arm_per_objfile.
(arm_record_special_symbol): Adjust to section_maps type change.
Allocate arm_per_objfile with new.
Philippe Waroquiers [Sun, 23 Jun 2019 13:34:15 +0000 (15:34 +0200)]
Fix alias command not detecting non matching prefix & sometimes asserting.
alias_command does not detect that the prefixes of the alias command and the
aliased command are not matching: it is comparing the alias prefix
with itself, instead of comparing it with the aliased command prefix.
This causes either the alias command to silently do nothing,
or to have GDB asserting:
(gdb) alias assigne imprime limite-elements = set print elements
../../binutils-gdb/gdb/cli/cli-cmds.c:1552: internal-error: void alias_command(const char*, int): Assertion `c_command != NULL && c_command != (struct cmd_list_element *) -1' failed.
A problem internal to GDB has been detected,
Fix the logic, and update gdb.base/alias.exp to test these cases.
gdb/ChangeLog
2019-06-25 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* cli/cli-cmds.c (alias_command): Compare the alias prefix
with the command prefix.
gdb/testsuite/ChangeLog
2019-06-25 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.base/alias.exp: Test non matching/non existing prefixes.
Faraz Shahbazker [Wed, 19 Jun 2019 22:55:04 +0000 (15:55 -0700)]
MIPS/gas: Fix order of instructions in LI macro expansion
When MTHC1 instruction is paired with MTC1 to write a value to a
64-bit FPR, the MTC1 must be executed first, because the semantic
definition of MTC1 is not aware that software will be using an MTHC1
to complete the operation, and sets the upper half of the 64-bit FPR
to an UNPREDICTABLE value[1].
Fix the order of MTHC1 and MTC1 instructions in LI macro expansion.
Modify the expansions to exploit moves from $zero directly by-passing
the use of $AT, where ever possible.
[1] "MIPS Architecture for Programmers Volume II-A: The MIPS32
Instruction Set Manual", Wave Computing, Inc., Document
Number: MD00086, Revision 5.04, December 11, 2013, Section 3.2
"Alphabetical List of Instructions", pp. 217.
gas/
* config/tc-mips.c (macro) <M_LI>: Re-order MTHC1 with
respect to MTC1 and use $0 for either part where possible.
* testsuite/gas/mips/li-d.s: Add test cases for non-zero
words in double precision constants.
* testsuite/gas/mips/li-d.d: Update reference output.
* testsuite/gas/mips/micromips@isa-override-1.d: Likewise.
* testsuite/gas/mips/mips32r2@isa-override-1.d: Likewise.
* testsuite/gas/mips/mips64r2@isa-override-1.d: Likewise.
Tom de Vries [Tue, 25 Jun 2019 14:42:46 +0000 (16:42 +0200)]
[gdb/testsuite] Regenerate dw2-restrict.S
When running gdb.dwarf2/dw2-restrict.exp with board cc-with-dwz, we run into:
...
dwz: dw2-restrict: DW_AT_stmt_list not DW_FORM_sec_offset or DW_FORM_data4
...
The problem is that the DW_AT_stmt_list is encoded using DW_FORM_addr, while
DW_FORM_sec_offset or DW_FORM_data4 would be appropriate. The test-case uses
a dw2-restrict.S which was generated using clang 2.9, which contained a bug
( https://bugs.llvm.org/show_bug.cgi?id=9995 ) causing this problem.
Fix this by regenerating using clang 5.0.1.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2019-06-25 Tom de Vries <tdevries@suse.de>
PR testsuite/24727
* gdb.dwarf2/dw2-restrict.S: Regenerate using clang 5.0.1.
Tom Tromey [Sun, 23 Jun 2019 22:38:06 +0000 (16:38 -0600)]
Tidy tui_delete_win
tui_delete_win does its own NULL check, so ~tui_gen_win_info does not
need to do it. Also, tui_delete_win has an extraneous "return".
gdb/ChangeLog
2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui-wingeneral.c (tui_delete_win): Remove "return".
* tui/tui-data.c (~tui_gen_win_info): Remove "if".
Tom Tromey [Sun, 23 Jun 2019 22:34:39 +0000 (16:34 -0600)]
Make tui_gen_win_info constructor protected
Now that all the window types have their own concrete classes, the
tui_gen_win_info constructor can be protected.
gdb/ChangeLog
2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui-layout.c (init_and_make_win): Assert on unrecognized
type.
* tui/tui-data.h (struct tui_gen_win_info): Make constructor
protected.
Tom Tromey [Sun, 23 Jun 2019 22:07:12 +0000 (16:07 -0600)]
Fix latent bug in set_is_exec_point_at
valgrind pointed out that the TUI was using uninitialized memory in
set_is_exec_point_at. The bug is a missing check against LOA_ADDRESS,
causing gdb to examine the uninitialized bits of the "addr" field.
gdb/ChangeLog
2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui-winsource.c
(tui_source_window_base::set_is_exec_point_at): Add check against
LOA_ADDRESS.
Tom Tromey [Sun, 23 Jun 2019 20:28:11 +0000 (14:28 -0600)]
Remove NULL checks before xfree
A couple of spots in the TUI did a NULL check before an xfree. This
isn't necessary, and most other cases were removed from gdb a while
ago.
gdb/ChangeLog
2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui-source.c (tui_set_source_content): Don't check before
xfree.
* tui/tui-disasm.c (tui_disassemble): Don't check before xfree.
Tom Tromey [Sun, 23 Jun 2019 20:27:04 +0000 (14:27 -0600)]
Remove union tui_which_element
This removes union tui_which_element, instead moving the content
directly into tui_source_window_base. This allows for the deletion of
a fair amount of code. Now the TUI window hierarchy is more
type-safe. In particular, there is never any confusion now about
which members are in use by which subtype.
gdb/ChangeLog
2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui-winsource.h (tui_update_source_window_as_is)
(tui_alloc_source_buffer, tui_line_is_displayed)
(tui_addr_is_displayed): Change type of win_info.
* tui/tui-winsource.c (tui_update_source_window_as_is)
(tui_clear_source_content, tui_show_source_line)
(tui_show_source_content, tui_source_window_base::refill)
(tui_source_window_base::set_is_exec_point_at)
(tui_source_window_base::set_is_exec_point_at)
(tui_update_breakpoint_info, tui_set_exec_info_content): Update.
(tui_alloc_source_buffer, tui_line_is_displayed)
(tui_addr_is_displayed): Change type of win_info. Update.
* tui/tui-win.c (tui_resize_all, tui_adjust_win_heights)
(tui_source_window_base::do_make_visible_with_new_height):
Update.
* tui/tui-source.c (tui_set_source_content)
(tui_set_source_content_nil)
(tui_source_window::do_scroll_vertical): Update.
* tui/tui-layout.c (show_layout): Update.
* tui/tui-disasm.c (tui_set_disassem_content)
(tui_disasm_window::do_scroll_vertical): Update.
* tui/tui-data.h (tui_win_content): Remove.
(struct tui_gen_win_info) <content, content_size>: Remove.
(struct tui_source_element): Add initializers and destructor.
(union tui_which_element, struct tui_win_element): Remove.
(struct tui_source_window_base) <content>: New field.
(struct tui_data_window): Remove destructor.
(tui_alloc_content, tui_free_win_content)
(tui_free_all_source_wins_content): Don't declare.
* tui/tui-data.c (tui_initialize_static_data): Update.
(init_content_element, tui_alloc_content): Remove.
(~tui_gen_win_info): Update.
(~tui_data_window, tui_free_all_source_wins_content)
(tui_free_win_content, free_content, free_content_elements):
Remove.
Tom Tromey [Sun, 23 Jun 2019 18:21:34 +0000 (12:21 -0600)]
More type safety for TUI source window functions
A few functions can only operate on a source or disassembly window.
This patch adds a bit more type safety to a few of these functions.
This simplifies a subsequent patch.
gdb/ChangeLog
2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui-winsource.h (tui_clear_source_content)
(tui_erase_source_content, tui_show_source_content): Change type
of win_info.
* tui/tui-winsource.c (tui_clear_source_content)
(tui_erase_source_content, tui_show_source_content): Change type
of win_info.
* tui/tui-win.c (tui_resize_all, tui_adjust_win_heights): Update.
* tui/tui-source.h (tui_set_source_content_nil): Change type of
win_info.
* tui/tui-source.c (tui_set_source_content_nil): Change type of
win_info.
* tui/tui-layout.c (show_source_or_disasm_and_command): Update.
Tom Tromey [Sun, 23 Jun 2019 16:25:03 +0000 (10:25 -0600)]
Use bool for is_exec_point
This changes tui_source_element::is_exec_point to be a bool. I looked
at also changing "has_break", but it turns out that this field is used
inconsistently (sometimes as flags and sometimes as a bool), and so
needs more invesstigation before it can be changed.
gdb/ChangeLog
2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui-winsource.c (tui_clear_source_content)
(tui_source_window_base::set_is_exec_point_at): Update.
* tui/tui-source.c (tui_set_source_content_nil): Update.
* tui/tui-data.h (struct tui_source_element) <is_exec_point>: Now
a bool.
* tui/tui-data.c (init_content_element): Update.
Tom Tromey [Sun, 23 Jun 2019 14:27:55 +0000 (08:27 -0600)]
Fix "auxiliary" typo
The TUI has a function called tui_win_is_auxillary, but the word
should actually be spelled "auxiliary". This fixes the typo.
gdb/ChangeLog
2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui-wingeneral.c (tui_gen_win_info::make_visible): Update.
* tui/tui-win.c (make_invisible_and_set_new_height): Update.
* tui/tui-layout.c (init_and_make_win): Update.
* tui/tui.h (enum tui_win_type): Update.
* tui/tui-data.h (tui_win_is_auxiliary): Rename from
tui_win_is_auxillary.
* tui/tui-data.c (tui_win_is_auxiliary): Rename from
tui_win_is_auxillary.
Tom Tromey [Sat, 22 Jun 2019 18:49:06 +0000 (12:49 -0600)]
Separate out data window
This removes "data_window" from union tui_which_element and updates
the uses. It also changes how tui_data_window refers to the register
data, and changes it not to need the "content" field at all (though as
this is in a base class, it can't yet be removed).
gdb/ChangeLog
2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui-wingeneral.c (tui_data_window::refresh_window): Update.
* tui/tui-windata.c (tui_data_window::first_data_item_displayed)
(tui_delete_data_content_windows, tui_display_all_data)
(tui_data_window::do_scroll_vertical, tui_display_data_from):
Update.
* tui/tui-win.c (tui_data_window::set_new_height): Simplify.
* tui/tui-regs.c (tui_last_regs_line_no)
(tui_line_from_reg_element_no, tui_first_reg_element_no_inline)
(tui_show_registers): Update.
(tui_show_register_group): Return void. Update.
(tui_display_registers_from, tui_display_reg_element_at_line)
(tui_display_registers_from_line, tui_check_register_values):
Update.
* tui/tui-data.h (union tui_which_element) <data_window>: Remove
member.
(struct tui_data_window) <regs_content>: Now a std::vector.
<regs_content_count>: Remove.
(tui_add_content_elements, tui_free_data_content): Don't declare.
* tui/tui-data.c (tui_data_window::clear_detail): Update.
(init_content_element): Remove DATA_WIN case. Add assert.
(tui_add_content_elements): Remove.
(tui_data_window): Update.
(tui_free_data_content): Remove.
(free_content_elements): Remove DATA_WIN case.
Tom Tromey [Sat, 22 Jun 2019 18:07:13 +0000 (12:07 -0600)]
Remove "data_content" and "data_content_count" from TUI data window
The TUI has some stub code for adding data other than registers to the
data window. However, it doesn't do anything, and apparently never
has. This removes the dead code.
gdb/ChangeLog
2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui-data.c (tui_data_item_window): Update.
* tui/tui-windata.h (tui_check_data_values): Don't declare.
* tui/tui-windata.c (tui_display_all_data)
(tui_display_data_from_line): Update.
(tui_check_data_values): Remove.
* tui/tui-regs.c (tui_show_register_group)
(tui_display_reg_element_at_line): Update.
* tui/tui-hooks.c (tui_register_changed)
(tui_refresh_frame_and_register_information): Call
tui_check_register_values.
* tui/tui-data.h (struct tui_data_window) <data_content,
data_content_count, data_type>: Remove.
(enum tui_data_type): Remove.