Tom de Vries [Fri, 30 Apr 2021 09:25:47 +0000 (11:25 +0200)]
[gdb/testsuite] Make gdb.mi/mi-sym-info.exp more robust against timeouts
Once in a while, I run into this timeout:
...
FAIL: gdb.mi/mi-sym-info.exp: List all variables from debug information \
only (timeout)
...
I can make the timeout reproducible by setting timeout to 8s (instead of the
default 10s) for the duration of that test.
Make the test-case more stable by fixing all timeouts caused by setting
timeout to 5, either by adding with_timeout_factor, or increasing its factor.
Tested on x86_64-linux. Also tested in parallel with stress -c 5, to simulate
a busy system in another way.
gdb/testsuite/ChangeLog:
2021-04-30 Tom de Vries <tdevries@suse.de>
* gdb.mi/mi-sym-info.exp: Add with_timeout_factor, and increase
existing timeout factors.
Tom de Vries [Fri, 30 Apr 2021 09:25:47 +0000 (11:25 +0200)]
[gdb/testsuite] Fix duplicate test name in gdb.mi/mi-sym-info.exp
Since commit
2d61316c32a "[gdb/testsuite] Fix buffer full errors in
gdb.mi/mi-sym-info.exp", we have a duplicate test name:
...
Running src/gdb/testsuite/gdb.mi/mi-sym-info.exp ...
DUPLICATE: gdb.mi/mi-sym-info.exp: List all variables
...
This is caused by a copy-paste accident: the idea was to copy the test, edit
it, and then remove the old test, but I forgot to remove the old one.
Remove it now.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2021-04-30 Tom de Vries <tdevries@suse.de>
* gdb.mi/mi-sym-info.exp: Remove duplicate test.
GDB Administrator [Fri, 30 Apr 2021 00:00:29 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom de Vries [Thu, 29 Apr 2021 21:32:20 +0000 (23:32 +0200)]
[gdb/testsuite] Fix timeout in gdb.base/valgrind-infcall-2.exp
Since commit
6d5702a5eb3 "Fix test case gdb.base/valgrind-bt.exp" I run into:
...
FAIL: gdb.base/valgrind-infcall-2.exp: target remote for vgdb (timeout)
FAIL: gdb.base/valgrind-infcall-2.exp: monitor v.set gdb_output (timeout)
...
The commit adds this line in proc vgdb_start:
...
set vgdbcmd "set remotetimeout 3"
...
which has no effect given that the value of var vgdbcmd is not used before
it's overwritten. We can fix this by doing instead:
...
set_remotetimeout 3
...
The FAIL I'm observing is fixed by increasing the remotetimeout value to 4.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2021-04-29 Tom de Vries <tdevries@suse.de>
PR testsuite/27786
* lib/valgrind.exp (vgdb_start): Use set_remotetimeout. Increase
remotetimeout to 4.
Simon Marchi [Thu, 29 Apr 2021 20:24:19 +0000 (16:24 -0400)]
gdb: don't use C++17 namespace declaration style
In a review, I suggested to use "namespace gdb::observers" instead of
two separate namespace declarations. I didn't realize that this was a
C++17 feature, which breaks compilers that default to an earlier version
of the language, like g++ 4.8. Change it back to two separate
declarations.
gdb/ChangeLog:
* auto-load.h: Split namespace declaration.
Change-Id: I701537161967fbd9fcc298ff600bd072aab1251d
Nick Clifton [Thu, 29 Apr 2021 16:55:43 +0000 (17:55 +0100)]
Fix an access through a null pointer when parsing a corrupt SOM format fle.
PR 27793
* som.c (som_slurp_symbol_table): Assign symbols without any scope
to the undefined section.
(som_decode_symclass): Check for a missing symbol section.
* syms.c (bfd_decode_symclass): Likewise.
Nick Clifton [Thu, 29 Apr 2021 16:41:43 +0000 (17:41 +0100)]
Fix illegal memory accesses when parsing a corrupt SOM format file.
PR 27792
* som.c (som_slurp_string_table): Place a terminating NUL byte at
the end of the table.
(som_slurp_symbol_table): Check for an over-large offset into the
string string table.
Simon Marchi [Thu, 29 Apr 2021 14:16:28 +0000 (10:16 -0400)]
gdb: move some variables to an inner scope in save_waitstatus
These two variables:
struct regcache *regcache = get_thread_regcache (tp);
const address_space *aspace = regcache->aspace ();
are only needed inside the "if". Getting a thread's regcache is a
somewhat expensive operation, so it's good to avoid it if not necessary.
Move the variable declarations and their initialization to the "if"
scope.
gdb/ChangeLog:
* infrun.c (save_waitstatus): Move variables to inner scope.
Change-Id: Ief1463728755b4dcc142c0a0a76896e9d594ae84
Jan Beulich [Thu, 29 Apr 2021 13:02:25 +0000 (15:02 +0200)]
x86-64: adjust recently added tests
Five of them fail for Cygwin and MingW. Adjust four and move one to the
ELF-only section.
Nick Clifton [Thu, 29 Apr 2021 12:11:29 +0000 (13:11 +0100)]
Correct the text describing windres's --processor option.
PR 27594
* doc/binutils.texi (windres): Correct the description of the
default value of the --preprocessor argument.
Jan Beulich [Thu, 29 Apr 2021 09:45:10 +0000 (11:45 +0200)]
x86: relax when/how @size can be used
Allow a few more expression forms when the entire expression can be
resolved at assembly time. For this, i386_validate_fix() needs to
arrange for all processing of the relocation to be deferred to
tc_gen_reloc().
Jan Beulich [Thu, 29 Apr 2021 09:43:53 +0000 (11:43 +0200)]
x86: allow @size to also (sensibly) apply to sections
So far this (counter-intuitively) produced the size as recorded in the
(section) symbol. Obtain the section's size instead for section symbols.
(I wonder whether STT_SECTION symbols couldn't properly hold the
section's size in their st_size field, which in turn would likely mean
the internal symbol would also have its size properly updated.)
Note that this is not the same as the .sizeof.() pseudo-operator: @size
yields the local file's contribution to a section, while .sizeof.() gets
resolved by the linker to produce the final full section's size.
As to the 3rd each of the expected output lines in the changed testcase:
I can't find justification for zzz to come after yyy despite them being
defined in the opposite order in source. Therefore I think it's better
to permit both possible outcomes.
Andrew Burgess [Thu, 29 Apr 2021 09:29:41 +0000 (10:29 +0100)]
gdb/NEWS: Fix typo and stray full stop
Some errors introduced in commit:
commit
edeaceda7b2f33b2c3bf78c732e67f3188e7f0b9
Date: Thu Aug 27 16:53:13 2020 +0100
gdb: startup commands to control Python extension language
gdb/ChangeLog:
* NEWS: Fix typo and stray full stop.
GDB Administrator [Thu, 29 Apr 2021 00:00:33 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Tue, 27 Apr 2021 13:35:23 +0000 (07:35 -0600)]
Fix Ada overloading with 'null'
Currently, the Ada expression parser treats 'null' as an integer 0.
However, this causes overloading to fail in certain cases.
This patch changes the Ada expression parser to use a special type for
'null'. I chose pointer-to-int0, because I think that's not likely to
be needed for any other Ada expression. Note this works because a
"mod 1" type has an underlying non-zero byte size; the test includes a
check for this.
The output is changed so that "print null", by default, shows "null".
And, ada_type_match is changed both to recognize the special null type
and to remove a bit of weird code related to how pointers are treated
for overload type matching.
Tested on x86-64 Fedora 32. Because this only touches Ada, and Joel
already approved it internally at AdaCore, I am checking it in.
gdb/ChangeLog
2021-04-28 Tom Tromey <tromey@adacore.com>
* ada-exp.y (primary): Use new type for null pointer.
* ada-lang.c (ada_type_match): Remove "may_deref"
parameter. Handle null pointer.
(ada_args_match): Update.
* ada-valprint.c (ada_value_print_ptr, ada_value_print):
Handle null pointer.
gdb/testsuite/ChangeLog
2021-04-28 Tom Tromey <tromey@adacore.com>
* gdb.ada/null_overload.exp: New file.
* gdb.ada/null_overload/foo.adb: New file.
Andrew Burgess [Wed, 28 Apr 2021 09:16:48 +0000 (10:16 +0100)]
gdb/doc: use @env to reference environment variables
Clean up a few places where we are not using @env{...} to reference
environment variables.
gdb/doc/ChangeLog:
* gdb.texinfo (Initialization Files): Use @env when referencing
environment variables.
(Shell Commands): Likewise.
(Starting): Likewise.
(Arguments): Likewise.
(Environment): Likewise.
(Edit): Likewise.
(Compiling and Injecting Code): Likewise.
(Files): Likewise.
(Command History): Likewise.
(Screen Size): Likewise.
(Emacs): Likewise.
Nick Clifton [Wed, 28 Apr 2021 10:49:09 +0000 (11:49 +0100)]
Stop the BFD library from treating annobin symbols as potential function symbols.
bfd * elf.c (_bfd_elf_maybe_function_sym): Do not accept annobin
symbols as potential function symbols.
* elfnn-aarch64.c (elfNN_aarch64_maybe_function_sym): Likewise.
* elf64-ppc.c (ppc64_elf_maybe_function_sym): Likewise.
* elf32-arm.c (elf32_arm_maybe_function_sym): Likewise.
ld * testsuite/ld-elf/anno-sym.s: New test source file.
* testsuite/ld-elf/anno-sym.d: New test driver.
* testsuite/ld-elf/anno-sym.l: New test error output.
Andrew Burgess [Thu, 27 Aug 2020 15:53:13 +0000 (16:53 +0100)]
gdb: startup commands to control Python extension language
Add two new commands to GDB that can be placed into the early
initialization to control how Python starts up. The new options are:
set python ignore-environment on|off
set python dont-write-bytecode auto|on|off
show python ignore-environment
show python dont-write-bytecode
These can be used from GDB's startup file to control how the Python
extension language behaves. These options are equivalent to the -E
and -B flags to python respectively, their descriptions from the
Python man page:
-E Ignore environment variables like PYTHONPATH and PYTHONHOME
that modify the behavior of the interpreter.
-B Don't write .pyc files on import.
gdb/ChangeLog:
* NEWS: Mention new commands.
* python/python.c (python_ignore_environment): New static global.
(show_python_ignore_environment): New function.
(set_python_ignore_environment): New function.
(python_dont_write_bytecode): New static global.
(show_python_dont_write_bytecode): New function.
(set_python_dont_write_bytecode): New function.
(_initialize_python): Register new commands.
gdb/doc/ChangeLog:
* python.texinfo (Python Commands): Mention new commands.
gdb/testsuite/ChangeLog:
* gdb.python/py-startup-opt.exp: New file.
Andrew Burgess [Thu, 22 Apr 2021 17:26:15 +0000 (18:26 +0100)]
gdb: extension languages finish_initialization to initialize
Now that both Python and Guile are fully initialized from their
respective finish_initialization methods, the "finish" in the method
name doesn't really make sense; initialization starts _and_ finishes
with that method.
As such, this commit renames finish_initialization to just initialize.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* extension-priv.h (struct extension_language_ops): Rename
'finish_initialization' to 'initialize'.
* extension.c (finish_ext_lang_initialization): Renamed to...
(ext_lang_initialization): ...this, update comment, and updated
the calls to reflect the change in struct extension_language_ops.
* extension.h (finish_ext_lang_initialization): Renamed to...
(ext_lang_initialization): ...this.
* guile/guile.c (gdbscm_finish_initialization): Renamed to...
(gdbscm_initialize): ...this, update comment at definition.
(guile_extension_ops): Update.
* main.c (captured_main_1): Update call to
finish_ext_lang_initialization.
* python/python.c (gdbpy_finish_initialization): Rename to...
(gdbpy_initialize): ...this, update comment at definition, and
update call to do_finish_initialization.
(python_extension_ops): Update.
(do_finish_initialization): Rename to...
(do_initialize): ...this, and update comment.
Andrew Burgess [Wed, 26 Aug 2020 16:31:12 +0000 (17:31 +0100)]
gdb: initialise extension languages after processing early startup files
Now (thanks to the last few commits) all extension languages are
fully initialised in their finish_initialization method, this commit
delays the call to this method until after the early initialization
files have been processed.
Right now there's no benefit from doing this, but in a later commit I
plan to add new options for Python that will control how Python is
initialized.
With this commit in place, my next commits will allow the user to add
options to their early initialization file and alter how Python starts
up.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* main.c (captured_main_1): Add a call to
finish_ext_lang_initialization.
* top.c (gdb_init): Remove call to finish_ext_lang_initialization.
Andrew Burgess [Thu, 22 Apr 2021 17:17:01 +0000 (18:17 +0100)]
gdb delay guile initialization until gdbscm_finish_initialization
Like with the previous commit, this commit delays the initialisation
of the guile extension language until gdbscm_finish_initialization.
This is mostly about splitting the existing gdbscm_initialize_*
functions in two, all the calls to register_objfile_data_with_cleanup,
gdbarch_data_register_post_init, etc are moved into new _initialize_*
functions, but everything else is left in the gdbscm_initialize_*
functions.
Then the call to code previously in _initialize_guile is moved into
gdbscm_finish_initialization.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* guile/guile.c (gdbscm_set_backtrace): Add declaration.
(gdbscm_finish_initialization): Add code moved from
_initialize_guile.
(_initialize_guile): Move code to gdbscm_finish_initialization.
* guile/scm-arch.c (gdbscm_initialize_arches): Move some code into
_initialize_scm_arch.
(_initialize_scm_arch): New function.
* guile/scm-block.c (gdbscm_initialize_blocks): Move some code
into _initialize_scm_block.
(_initialize_scm_block): New function.
* guile/scm-frame.c (gdbscm_initialize_frames): Move some code
into _initialize_scm_frame.
(_initialize_scm_frame): New function.
* guile/scm-objfile.c (gdbscm_initialize_objfiles): Move some code
into _initialize_scm_objfile.
(_initialize_scm_objfile): New function.
* guile/scm-progspace.c (gdbscm_initialize_pspaces): Move some
code into _initialize_scm_progspace.
(_initialize_scm_progspace): New function.
* guile/scm-symbol.c (gdbscm_initialize_symbols): Move some code
into _initialize_scm_symbol.
(_initialize_scm_symbol): New function.
* guile/scm-symtab.c (gdbscm_initialize_symtabs): Move some code
into _initialize_scm_symtab.
(_initialize_scm_symtab): New function.
* guile/scm-type.c (gdbscm_initialize_types): Move some code into
_initialize_scm_type.
(_initialize_scm_type): New function.
Andrew Burgess [Thu, 22 Apr 2021 16:11:25 +0000 (17:11 +0100)]
gdb: delay python initialisation until gdbpy_finish_initialization
Delay Python initialisation until gdbpy_finish_initialization.
This is mostly about splitting the existing gdbpy_initialize_*
functions in two, all the calls to register_objfile_data_with_cleanup,
gdbarch_data_register_post_init, etc are moved into new _initialize_*
functions, but everything else is left in the gdbpy_initialize_*
functions.
Then the call to do_start_initialization (in python/python.c) is moved
from the _initialize_python function into gdbpy_finish_initialization.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* python/py-arch.c (_initialize_py_arch): New function.
(gdbpy_initialize_arch): Move code to _initialize_py_arch.
* python/py-block.c (_initialize_py_block): New function.
(gdbpy_initialize_blocks): Move code to _initialize_py_block.
* python/py-inferior.c (_initialize_py_inferior): New function.
(gdbpy_initialize_inferior): Move code to _initialize_py_inferior.
* python/py-objfile.c (_initialize_py_objfile): New function.
(gdbpy_initialize_objfile): Move code to _initialize_py_objfile.
* python/py-progspace.c (_initialize_py_progspace): New function.
(gdbpy_initialize_pspace): Move code to _initialize_py_progspace.
* python/py-registers.c (_initialize_py_registers): New function.
(gdbpy_initialize_registers): Move code to
_initialize_py_registers.
* python/py-symbol.c (_initialize_py_symbol): New function.
(gdbpy_initialize_symbols): Move code to _initialize_py_symbol.
* python/py-symtab.c (_initialize_py_symtab): New function.
(gdbpy_initialize_symtabs): Move code to _initialize_py_symtab.
* python/py-type.c (_initialize_py_type): New function.
(gdbpy_initialize_types): Move code to _initialize_py_type.
* python/py-unwind.c (_initialize_py_unwind): New function.
(gdbpy_initialize_unwind): Move code to _initialize_py_unwind.
* python/python.c (_initialize_python): Move call to
do_start_initialization to gdbpy_finish_initialization.
(gdbpy_finish_initialization): Add call to
do_start_initialization.
Andrew Burgess [Thu, 22 Apr 2021 16:05:44 +0000 (17:05 +0100)]
gdb: ensure SIGINT is set to SIG_DFL during initialisation
In order for our SIGINT handling to work correctly with Python we
require that SIGINT be set to SIG_DFL during Python's initialisation.
Currently this is the case, but, in a later commit I plan to delay the
initialisation of Python until after the point where GDB's own SIGINT
handler has been installed.
The consequence of this is that our SIGINT handling would become
broken.
In this commit I propose adding an RAII class that will ensure SIGINT
is set to SIG_DFL during the call to each extension languages
finish_initialization method.
At this point this change should have not effect.
gdb/ChangeLog:
* extension.c (struct scoped_default_signal): New struct.
(scoped_default_sigint): New typedef.
(finish_ext_lang_initialization): Make use of
scoped_default_sigint.
Andrew Burgess [Thu, 22 Apr 2021 15:46:23 +0000 (16:46 +0100)]
gdb: remove unused argument from gdb_init
The argument to gdb_init is not used, remove it.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* main.c (captured_main_1): Don't pass argument to gdb_init.
* top.c (gdb_init): Remove unused argument, and add header
comment.
* top.h (gdb_init): Remove argument.
Jan Beulich [Wed, 28 Apr 2021 08:53:00 +0000 (10:53 +0200)]
x86: honor signedness of PC-relative relocations
PR gas/27763
While the comment in output_jump() was basically correct prior to the
introduction of 64-bit mode, both that and the not-JMP-like behavior of
XBEGIN require adjustments: Branches with 32-bit displacement do not
wrap at 4G in 64-bit mode, and XBEGIN with 16-bit operand size doesn't
wrap at 64k. Similarly %rip-relative addressing doesn't wrap at 4G.
The new testcase points out that for PE/COFF object_64bit didn't get
set so far, preventing in particular the check at the end of
md_convert_frag() to take effect.
For Mach-O the new testcase fails (bogusly), in that only the first two
of the expected errors get raised. Since for Mach-O many testcases
already fail, and since an x86_64-darwin target can't even be configured
for, I didn't think I need to bother.
Note that there are further issues in this area, in particular for
branches with operand size overrides. Such branches, which truncate
%rip / %eip, can't be correctly expressed with ordinary PC-relative
relocations. It's not really clear what to do with them - perhaps the
best we can do is to carry through all associated relocations, leaving
it to the linker (or even loader) to decide (once the final address
layout is known). Same perhaps goes for relocations associated with
32-bit addressing in 64-bit mode.
GDB Administrator [Wed, 28 Apr 2021 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in
Luis Machado [Thu, 1 Apr 2021 20:00:43 +0000 (17:00 -0300)]
Fix timeout with maint print objfiles
I'm seeing timeouts from gdb.rust/traits.exp when we attempt to print
things with "maint print objfiles".
This happens for two reasons:
1 - GDB does not explicitly split each entry into its own line, but rather
relies on the terminal's width to insert line breaks.
2 - When running the GDB testsuite, such width may be unlimited, which will
prevent GDB from inserting any line breaks.
As a result, the output may be too lengthy and will come in big lines. Tweak
the support library to match the patterns line-by-line, which gives us more
time to match things. Also fix GDB's output to print one entry per line,
regardless of the terminal width.
A similar approach was used in another testcase using the same command (commit
eaeaf44cfdc9a4096a0dd52fa0606f29d4bfd48e). With the new line breaks, we don't
need a particular pattern, so clean up that test as well.
gdb/ChangeLog:
2021-04-27 Luis Machado <luis.machado@linaro.org>
* psymtab.c (psymbol_functions::dump): Output newline.
* symmisc.c (dump_objfile): Likewise.
gdb/testsuite/ChangeLog:
2021-04-27 Luis Machado <luis.machado@linaro.org>
* gdb.base/maint.exp: Drop a pattern that is not needed.
* lib/gdb.exp (readnow): Match line-by-line.
Luis Machado [Thu, 1 Apr 2021 17:31:24 +0000 (14:31 -0300)]
Fix timeout for gdb.xml/tdesc-reload.exp
For aarch64, the "info all-registers" output is very verbose. If you run
this test using read1, it will timeout before the command output is done being
read.
Read line-by-line so we don't run into timeouts.
gdb/testsuite/ChangeLog:
2021-04-27 Luis Machado <luis.machado@linaro.org>
* gdb.xml/tdesc-reload.exp: Pass -lbl.
Michael Weghorn [Tue, 27 Apr 2021 14:02:42 +0000 (10:02 -0400)]
gdb: do autoload before notifying Python side in new_objfile event
Without any explicit dependencies specified, the observers attached
to the 'gdb::observers::new_objfile' observable are always notified
in the order in which they have been attached.
The new_objfile observer callback to auto-load scripts is attached in
'_initialize_auto_load'.
The new_objfile observer callback that propagates the new_objfile event
to the Python side is attached in 'gdbpy_initialize_inferior', which is
called via '_initialize_python'.
With '_initialize_python' happening before '_initialize_auto_load',
the consequence was that the new_objfile event was emitted on the Python
side before autoloaded scripts had been executed when a new objfile was
loaded.
As a result, trying to access the objfile's pretty printers (defined in
the autoloaded script) from a handler for the Python-side
'new_objfile' event would fail. Those would only be initialized later on
(when the 'auto_load_new_objfile' callback was called).
To make sure that the objfile passed to the Python event handler
is properly initialized (including its 'pretty_printers' member),
make sure that the 'auto_load_new_objfile' observer is notified
before the 'python_new_objfile' one that propagates the event
to the Python side.
To do this, make use of the mechanism to explicitly specify
dependencies between observers (introduced in a preparatory commit).
Add a corresponding testcase that involves a test library with an autoloaded
Python script and a handler for the Python 'new_objfile' event.
(The real world use case where I came across this issue was in an attempt
to extend handling for GDB pretty printers for dynamically loaded
objfiles in the Qt Creator IDE, s. [1] and [2] for more background.)
[1] https://bugreports.qt.io/browse/QTCREATORBUG-25339
[2] https://codereview.qt-project.org/c/qt-creator/qt-creator/+/333857/1
Tested on x86_64-linux (Debian testing).
gdb/ChangeLog:
* gdb/auto-load.c (_initialize_auto_load): 'Specify token
when attaching the 'auto_load_new_objfile' observer, so
other observers can specify it as a dependency.
* gdb/auto-load.h (struct token): Declare
'auto_load_new_objfile_observer_token' as token to be used
for the 'auto_load_new_objfile' observer.
* gdb/python/py-inferior.c (gdbpy_initialize_inferior): Make
'python_new_objfile' observer depend on 'auto_load_new_objfile'
observer, so it gets notified after the latter.
gdb/testsuite/ChangeLog:
* gdb.python/libpy-autoloaded-pretty-printers-in-newobjfile-event.so-gdb.py: New test.
* gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-lib.cc: New test.
* gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-lib.h: New test.
* gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-main.cc: New test.
* gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.exp: New test.
* gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.py: New test.
Change-Id: I8275b3f4c3bec32e56dd7892f9a59d89544edf89
Michael Weghorn [Tue, 27 Apr 2021 13:55:27 +0000 (09:55 -0400)]
gdbsupport: allow to specify dependencies between observers
Previously, the observers attached to an observable were always notified
in the order in which they had been attached. That order is not easily
controlled, because observers are typically attached in _initialize_*
functions, which are called in an undefined order.
However, an observer may require that another observer attached only
later is called before itself is.
Therefore, extend the 'observable' class to allow explicitly specifying
dependencies when attaching observers, by adding the possibility to
specify tokens for observers that it depends on.
To make sure dependencies are notified before observers depending on
them, the vector holding the observers is sorted in a way that
dependencies come before observers depending on them. The current
implementation for sorting uses the depth-first search algorithm for
topological sorting as described at [1].
Extend the observable unit tests to cover this case as well. Check that
this works for a few different orders in which the observers are
attached.
This newly introduced mechanism to explicitly specify dependencies will
be used in a follow-up commit.
[1] https://en.wikipedia.org/wiki/Topological_sorting#Depth-first_search
Tested on x86_64-linux (Debian testing).
gdb/ChangeLog:
* unittests/observable-selftests.c (dependency_test_counters):
New.
(observer_token0, observer_token1, observer_token2,
observer_token3, observer_token4, observer_token5): New.
(struct dependency_observer_data): New struct.
(observer_dependency_test_callback): New function.
(test_observers): New.
(run_dependency_test): New function.
(test_dependency): New.
(_initialize_observer_selftest): Register dependency test.
gdbsupport/ChangeLog:
* observable.h (class observable): Extend to allow specifying
dependencies between observers, keep vector holding observers
sorted so that dependencies are notified before observers
depending on them.
Change-Id: I5399def1eeb69ca99e28c9f1fdf321d78b530bdb
H.J. Lu [Tue, 27 Apr 2021 15:16:55 +0000 (08:16 -0700)]
x86: Add () to silence GCC 5
Add () to !i.prefix[ADDR_PREFIX] to silence GCC 5:
gas/config/tc-i386.c:4152:31: error: logical not is only applied to the left hand side of comparison [-Werror=logical-not-parentheses]
&& !i.prefix[ADDR_PREFIX] != (flag_code == CODE_32BIT))
^
* config/tc-i386.c (optimize_encoding): Add () to silence GCC 5.
Nick Clifton [Tue, 27 Apr 2021 14:19:41 +0000 (15:19 +0100)]
Reject debuglink sections with no associated filename.
PR 27779
* dwarf.c (parse_gnu_debuglink): Reject empty names.
(parse_gnu_debugaltlink): Likewise.
Mike Frysinger [Tue, 27 Apr 2021 03:28:04 +0000 (23:28 -0400)]
sim: riscv: switch MIN/MAX to common min/max
The common sim-basics.h defines min/max already, so use them.
Mike Frysinger [Sun, 25 Apr 2021 22:11:35 +0000 (18:11 -0400)]
sim: nltvals: unify common syscall tables
Since libgloss provides a default syscall table for arches, use that
to provide the default syscall table for ports. Only the exceptions
need to be enumerated now with the common logic as the default.
Mike Frysinger [Fri, 23 Apr 2021 20:24:27 +0000 (16:24 -0400)]
sim: enable hardware support by default
Force this on for all ports. We have a few common models that can
be used, so make them generally available. If the port doesn't use
any hardware (the default), then behavior is unchanged.
Mike Frysinger [Mon, 19 Apr 2021 01:18:11 +0000 (21:18 -0400)]
bfd: add stdlib.h when using abort
Since this file calls abort() now, we need to include stdlib.h for
its prototype.
GDB Administrator [Tue, 27 Apr 2021 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
Nick Clifton [Mon, 26 Apr 2021 16:16:20 +0000 (17:16 +0100)]
Fix a bug in the ARM emulator which would not allow 4 byte alignment for double word stores.
PR 22790
* armemu.c (Handle_Store_Double): Allow 4 byte alignment when
running in v6 mode.
Tom Tromey [Mon, 26 Apr 2021 15:53:32 +0000 (09:53 -0600)]
Add test case for gdb 10 crash
PR gdb/27743 points out a gdb crash when expanding partial symtabs,
where one of the compilation units uses DW_TAG_imported_unit.
This crash happens for gdb 10, but not git trunk. This patch pulls
over the new test case only.
gdb/testsuite/ChangeLog
2021-04-26 Tom Tromey <tromey@adacore.com>
PR gdb/27743:
* gdb.dwarf2/imported-unit-bp.exp: New file.
* gdb.dwarf2/imported-unit-bp-main.c: New file.
* gdb.dwarf2/imported-unit-bp-alt.c: New file.
Simon Marchi [Mon, 26 Apr 2021 15:27:07 +0000 (11:27 -0400)]
gdb: check result of gdb_fopen_cloexec in dump_binary_file
Bug 27773 shows that passing a filename in a non-existent directory to
the "dump binary" command leads to a gdb crash. This is because the
gdb_fopen_cloexec in dump_binary_file fails (returns nullptr) and the
return value is not checked. Fix that by erroring out if
gdb_fopen_cloexec fails.
gdb/ChangeLog:
PR gdb/27773
* cli/cli-dump.c (dump_binary_file): Check result of
gdb_fopen_cloexec.
gdb/testsuite/ChangeLog:
PR gdb/27773
* gdb.base/dump.exp: Test dump to non-existent dir.
Change-Id: Iea89a3bf9e6b9dcc31142faa5ae17bc855759328
Luis Machado [Thu, 8 Apr 2021 18:32:29 +0000 (15:32 -0300)]
Fix gdb.arch/aarch64-dbreg-contents.exp FAIL
The test checks for a particular ARCH level, but it needs to check for
ARCH levels from a minimum and upwards.
gdb/testsuite/ChangeLog:
2021-04-26 Luis Machado <luis.machado@linaro.org>
* gdb.arch/aarch64-dbreg-contents.c (set_watchpoint): Fix arch level
comparison.
Jan Beulich [Mon, 26 Apr 2021 08:41:35 +0000 (10:41 +0200)]
x86: correct overflow checking for 16-bit PC-relative relocs
The only insn requiring a truly 16-bit PC-relative relocation outside of
16-bit mode is XBEGIN (with an operand size override). For it, the
relocation generated should behave similar to 8- and (for 64-bit) 32-bit
PC-relatives ones, i.e. be checked for a signed value to fit the field.
This same mode is also correct for 16-bit code. Outside of 16-bit code,
branches with operand size overrides act in a truly PC-relative way only
when living in the low 32k of address space, as they truncate rIP to 16
bits. This can't be expressed by a PC-relative relocation.
Putting in place a new testcase, I'd like to note that the two existing
ones (pcrel16 and pcrel16abs) appear to be pretty pointless: They don't
expect any error despite supposedly checking for overflow, and in fact
there can't possibly be any error for the
- former since gas doesn't emit any relocation in the first place there,
- latter because the way the relocation gets expressed by gas doesn't
allow the linker to notice the overflow; it should be detected by gas
if at all, but see above (an error would be reported here for x86-64
afaict, but this test doesn't get re-used there).
Jan Beulich [Mon, 26 Apr 2021 08:39:45 +0000 (10:39 +0200)]
x86: add IS_ELF to check whether to resolve @size reloc
This may not be strictly needed, as BFD_RELOC_SIZE* shouldn't appear
from elsewhere for non-ELF, but let's be on the safe side.
Jan Beulich [Mon, 26 Apr 2021 08:39:11 +0000 (10:39 +0200)]
x86: limit 32-bit @size overflow checks to 64-bit objects
For 32-bit objects the behavior should not be dependent upon the build
being a BFD64 one.
Jan Beulich [Mon, 26 Apr 2021 08:37:30 +0000 (10:37 +0200)]
x86: optimize LEA
Over the years I've seen a number of instances where people used
lea (%reg1), %reg2
or
lea symbol, %reg
despite the same thing being expressable via MOV. Since additionally
LEA often has restrictions towards the ports it can be issued to, while
MOV typically gets dealt with simply by register renaming, transform to
MOV when possible (without growing opcode size and without altering
involved relocation types).
Note that for Mach-O the new 64-bit testcases would fail (for
BFD_RELOC_X86_64_32S not having a representation), and hence get skipped
there.
Jan Beulich [Mon, 26 Apr 2021 08:35:51 +0000 (10:35 +0200)]
x86-64: have value properly checked when resolving fixup
Constants not known at the time an individual insn gets assembled and
going into a sign-extended field still shouldn't be silently truncated
at the time the respective fixup gets resolved.
Sergei Trofimovich [Sun, 25 Apr 2021 19:50:38 +0000 (20:50 +0100)]
gdb: fix sparc build failure of linux-nat
On sparc build failed as:
```
gdb/sparc-linux-nat.c: In member function
'virtual void sparc_linux_nat_target::fetch_registers(regcache*, int)':
gdb/sparc-linux-nat.c:36:37:
error: cannot convert 'regcache*' to 'process_stratum_target*'
36 | { sparc_fetch_inferior_registers (regcache, regnum); }
| ^~~~~~~~
| |
| regcache*
```
The fix adopts gdb/sparc-nat.h API change in
d1e93af64a6
("gdb: set current thread in sparc_{fetch,collect}_inferior_registers").
gdb/ChangeLog:
* sparc-linux-nat.c (sparc_linux_nat_target): fix sparc build
by passing `process_stratum_target*` parameter.
GDB Administrator [Mon, 26 Apr 2021 00:00:16 +0000 (00:00 +0000)]
Automatic date update in version.in
Lancelot SIX [Sat, 17 Apr 2021 11:10:23 +0000 (12:10 +0100)]
[PR gdb/22640] ptype: add option to use hexadecimal notation
This commit adds a flag to the ptype command in order to print the
offsets and sizes of struct members using the hexadecimal notation. The
'x' flag ensures use of the hexadecimal notation while the 'd' flag
ensures use of the decimal notation. The default is to use decimal
notation.
Before this patch, gdb only uses decimal notation, as pointed out in PR
gdb/22640.
Here is an example of this new behavior with hex output turned on:
(gdb) ptype /ox struct type_print_options
/* offset | size */ type = struct type_print_options {
/* 0x0000: 0x0 | 0x0004 */ unsigned int raw : 1;
/* 0x0000: 0x1 | 0x0004 */ unsigned int print_methods : 1;
/* 0x0000: 0x2 | 0x0004 */ unsigned int print_typedefs : 1;
/* 0x0000: 0x3 | 0x0004 */ unsigned int print_offsets : 1;
/* 0x0000: 0x4 | 0x0004 */ unsigned int print_in_hex : 1;
/* XXX 3-bit hole */
/* XXX 3-byte hole */
/* 0x0004 | 0x0004 */ int print_nested_type_limit;
/* 0x0008 | 0x0008 */ typedef_hash_table *local_typedefs;
/* 0x0010 | 0x0008 */ typedef_hash_table *global_typedefs;
/* 0x0018 | 0x0008 */ ext_lang_type_printers *global_printers;
/* total size (bytes): 32 */
}
This patch also adds the 'set print type hex' and 'show print type hex'
commands in order to set and inspect the default behavior regarding the
use of decimal or hexadecimal notation when printing struct sizes and
offsets.
Tested using on x86_64.
gdb/ChangeLog:
PR gdb/22640
* typeprint.h (struct type_print_options): Add print_in_hex
flag.
(struct print_offset_data): Add print_in_hex flag, add a
constructor accepting a type_print_options* argument.
* typeprint.c (type_print_raw_options, default_ptype_flags): Set
default value for print_in_hex.
(print_offset_data::indentation): Allow more horizontal space.
(print_offset_data::print_offset_data): Add ctor.
(print_offset_data::maybe_print_hole, print_offset_data::update):
Handle the print_in_hex flag.
(whatis_exp): Handle 'x' and 'd' flags.
(print_offsets_and_sizes_in_hex): Declare.
(set_print_offsets_and_sizes_in_hex): Create.
(show_print_offsets_and_sizes_in_hex): Create.
(_initialize_typeprint): Update help message for the ptype
command, register the 'set print type hex' and 'show print type
hex' commands.
* c-typeprint.c (c_print_type, c_type_print_base_struct_union)
(c_type_print_base): Construct the print_offset_data
object using the type_print_optons parameter.
* rust-lang.c (rust_language::print_type): Construct the
print_offset_data object using the type_print_optons parameter.
* NEWS: Mention the new flags of the ptype command.
gdb/doc/ChangeLog:
PR gdb/22640
* gdb.texinfo (Symbols): Describe the 'x' and 'd' flags of the
ptype command, describe 'set print type hex' and 'show print
type hex' commands. Update 'ptype/o' examples.
gdb/testsuite/ChangeLog:
PR gdb/22640
* gdb.base/ptype-offsets.exp: Add tests to verify the behavior
of 'ptype/ox' and 'ptype/od'. Check that 'set print type hex'
changes the default behavior of 'ptype/o'. Update to take into
account new horizontal layout.
* gdb.rust/simple.exp: Update ptype test to check new horizontal
layout.
* gdb.rust/union.exp: Same.
Lancelot SIX [Sat, 17 Apr 2021 11:10:23 +0000 (12:10 +0100)]
gdb/typeprint.h: reorder struct declaration
Move the declaration of struct type_print_raw_options before struct
print_offset_data to ease upcoming changes. This is a helper commit
intended to make it easier to build a print_offset_data object from
configurations given by a type_print_raw_options.
gdb/ChangeLog:
* typeprint.h (struct type_print_options): Move before
print_offset_data.
Tom Tromey [Sun, 25 Apr 2021 13:30:03 +0000 (07:30 -0600)]
Add engv32.h to SIM_EXTRA_DEPS in sim/cris
A rebuild showed that an earlier change of mine missed a built header
file -- cris/engv32.h. This patch fixes the problem.
sim/cris/ChangeLog
2021-04-25 Tom Tromey <tom@tromey.com>
* Makefile.in (SIM_EXTRA_DEPS): Add engv32.h.
Tom Tromey [Sat, 24 Apr 2021 20:57:39 +0000 (14:57 -0600)]
Use htab_t in sim-options.c
This changes sim-options.c to use the libiberty hash table, rather
than its own custom hash table.
sim/common/ChangeLog
2021-04-25 Tom Tromey <tom@tromey.com>
* sim-options.c (compare_strings): New function.
(ARG_HASH_SIZE, ARG_HASH): Remove.
(dup_arg_p): Use htab_t.
(sim_parse_args): Remove assert.
Joel Brobecker [Sun, 25 Apr 2021 04:19:04 +0000 (08:19 +0400)]
Document the GDB 10.2 release in gdb/ChangeLog
gdb/ChangeLog:
GDB 10.2 released.
GDB Administrator [Sun, 25 Apr 2021 00:00:17 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Sat, 24 Apr 2021 23:26:05 +0000 (19:26 -0400)]
gdbsupport: add observer_debug_printf, OBSERVER_SCOPED_DEBUG_ENTER_EXIT
Switch observer to use the "new" debug printf mechanism and sprinkle a
few debug prints. Here's a small example of the output with "infrun"
and "observer" debug output enabled:
[infrun] proceed: enter
[observer] notify: start: observable target_resumed notify() called
[observer] notify: start: calling observer mi-interp of observable target_resumed
[observer] notify: end: calling observer mi-interp of observable target_resumed
[observer] notify: start: calling observer py-inferior of observable target_resumed
[observer] notify: end: calling observer py-inferior of observable target_resumed
[observer] notify: end: observable target_resumed notify() called
...
gdbsupport/ChangeLog:
* observable.h (observer_debug_printf,
OBSERVER_SCOPED_DEBUG_START_END): New.
(class observable) <notify, attach>: Use them.
Change-Id: If3ae4b6b65450ca3b7cae56698a87fc526688b86
Simon Marchi [Sat, 24 Apr 2021 23:26:04 +0000 (19:26 -0400)]
gdbsupport: allow passing format string to scoped_debug_start_end
A little thing that bothers me with scoped_debug_start_end is that it's
not possible to pass a format string to add context to the messages: the
start and end messages are fixed.
It was done like this at the time because there's the risk that debug
output is not enabled on entry (when the constructor runs) but is
enabled on exit (when the destructor runs). For example, a user
debugging from a top-gdb may manually enable a debug_foo variable. If
debug output is disabled while the constructor runs, we won't render the
format string (to minimize overhead) so it won't be available in the
destructor.
I think it would be nice to be able to use a format string along with
scoped_debug_start_end, and I think it's unfortunate that such a narrow
use case prevents it. So with this patch, I propose that we allow
passing a format string to scoped_debug_start_end, and if the rare
situation described above happens, then we just show a "sorry, message
not available" kind of message.
The following patch makes use of this.
gdbsupport/ChangeLog:
* common-debug.h (struct scoped_debug_start_end)
<scoped_debug_start_end>: Change start_msg/end_msg for
start_prefix/end_prefix. Add format string parameter and make
variadic.
<~scoped_debug_start_end>: Adjust.
<m_end_msg>: Rename to...
<m_end_prefix>: ... this.
<m_with_format>: New.
<m_msg>: New.
(scoped_debug_start_end): Make variadic.
(scoped_debug_enter_exit): Adjust.
Change-Id: I9427ce8877a246a46694b3a1fec3837dc6954d6e
Simon Marchi [Sat, 24 Apr 2021 23:26:04 +0000 (19:26 -0400)]
gdbsupport, gdb: give names to observers
Give a name to each observer, this will help produce more meaningful
debug message.
gdbsupport/ChangeLog:
* observable.h (class observable) <struct observer> <observer>:
Add name parameter.
<name>: New field.
<attach>: Add name parameter, update all callers.
Change-Id: Ie0cc4664925215b8d2b09e026011b7803549fba0
Simon Marchi [Sat, 24 Apr 2021 23:26:04 +0000 (19:26 -0400)]
gdbsupport: introduce struct observer
Instead of using a pair. This allows keeping more data per observer in
a structured way, and using field names is clearer than first/second.
gdbsupport/ChangeLog:
* observable.h (class observable) <struct observer>: New.
<detach, notify>: Update.
<m_observers>: Change type to vector of observers.
Change-Id: Iadf7d1fa25049cfb089e6b1b429ddebc548825ab
Mike Frysinger [Sat, 24 Apr 2021 04:16:08 +0000 (00:16 -0400)]
sim: dv-cfi: fix printf format
Use the existing PRI constants to select the right format rather than
assume signed_cell is always %u. Fixes building for riscv64.
Mike Frysinger [Sat, 24 Apr 2021 04:10:44 +0000 (00:10 -0400)]
sim: options: increase max option count
As we turn on more modules by default for all ports, the number of
options has been increasing. The sim-options module has a limit on
the number of options it can support, and if it's exceeded, it likes
to go into an infinite loop. Increase the ceiling and add an assert
so we abort right away instead of hanging.
This will be needed to turn on hw support for v850 as it will then
exceed the current limit.
Mike Frysinger [Sat, 24 Apr 2021 01:58:21 +0000 (21:58 -0400)]
sim: simplify hardware m4 macro
Every port using this sets the 1st arg to yes and the 2nd arg to "".
These are the defaults we probably want anyways in order to unify the
codebase, so move them to the macro and only allow ports to declare
extra hardware models.
GDB Administrator [Sat, 24 Apr 2021 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Fri, 23 Apr 2021 20:28:26 +0000 (16:28 -0400)]
gdbsupport, gdb: change observer_debug to bool
gdb/ChangeLog:
* observable.c (observer_debug): Change to bool.
gdbsupport/ChangeLog:
* observable.h (observer_debug): Change to bool.
Change-Id: I58634235a20740a66eacb1c83bae3cf3304ae1fd
H.J. Lu [Fri, 23 Apr 2021 19:36:27 +0000 (12:36 -0700)]
ld: Properly create a symbolic link to tmpdir/ldscripts
Don't create a symbolic link to tmpdir/ldscripts if it exists.
PR ld/27771
* testsuite/ld-bootstrap/bootstrap.exp: Create a symbolic link
to tmpdir/ldscripts only if it doesn't exist.
Simon Marchi [Fri, 23 Apr 2021 18:03:30 +0000 (14:03 -0400)]
gdbsupport: include preprocessor.h in common-debug.h
While doing some changes, some code failed to compile because it used
the scoped_debug_start_end macro, but couldn't find the CONCAT macro.
Fix that by making common-debug.h include preprocessor.h, the header
file that provides CONCAT.
gdbsupport/ChangeLog:
* common-debug.h: Include preprocessor.h.
Change-Id: Ibf863a932a18cba9a57b4bd72df538ef52d39127
Eric Botcazou [Fri, 23 Apr 2021 17:07:59 +0000 (19:07 +0200)]
Fix type of .persistent.bss section
The change implementing the .persistent family of sections broke the
existing support for the .persistent.bss section in the compiler:
int a __attribute__ ((section (".persistent.bss")));
t.s: Assembler messages:
t.s:4: Warning: setting incorrect section type for .persistent.bss
The compiler encodes it as @nobits but the assembler expects @progbits.
The assembler is incorrect and should treat the section like the compiler.
bfd/
* elf.c (special_sections_p): Add .persistent.bss.
gas/
* testsuite/gas/elf/section25.d: Run it everywhere.
* testsuite/gas/elf/section26.d: Likewise.
* testsuite/gas/elf/section26.s: Add test for .persistent.bss.
J?r?me Gardou [Fri, 23 Apr 2021 15:33:47 +0000 (16:33 +0100)]
Allow .seh_pushframe to take an optional [code] parameter
* config/obj-coff-seh.c (obj_coff_seh_pushframe): Allow an
optional "code" argument.
Max Filippov [Fri, 23 Apr 2021 09:03:36 +0000 (02:03 -0700)]
opcodes: xtensa: display loaded literal value
Display literal value loaded with l32r opcode as a part of disassembly.
This significantly simplifies reading of disassembly output.
2020-04-23 Max Filippov <jcmvbkbc@gmail.com>
opcodes/
* xtensa-dis.c (print_xtensa_operand): For PC-relative operand
of l32r fetch and display referenced literal value.
Max Filippov [Wed, 7 Apr 2021 01:44:50 +0000 (18:44 -0700)]
opcodes: xtensa: improve literal output
Output literals as 4-byte words, not as separate bytes.
2021-04-23 Max Filippov <jcmvbkbc@gmail.com>
opcodes/
* xtensa-dis.c (print_insn_xtensa): Set info->bytes_per_chunk
to 4 for literal disassembly.
Andrew Burgess [Mon, 19 Apr 2021 12:14:41 +0000 (13:14 +0100)]
gdb: remove some caching from the dwarf reader
While working on some changes to 'info sources' I ran into a situation
where I was seeing the same source files reported twice in the output
of the 'info sources' command when using either .gdb_index or the
.debug_name index.
I traced the problem back to some caching in
dwarf2_base_index_functions::map_symbol_filenames; when called GDB
caches the set of filenames, but, filesnames are not removed as the
index entries are expanded into full symtabs. As a result we can end
up seeing filenames reported both from a full symtab _and_ from
a (stale) previously cached index entry.
Now, obviously, when seeing a problem like this the "correct" fix is
to remove the stale entries from the cache, however, I ran a few
experiments to see why this wasn't really hitting us anywhere, and, as
far as I can tell, ::map_symbol_filenames is only called from three
places:
1. The mi command -file-list-exec-source-files,
2. The 'info sources' command, and
3. Filename completion
However, the result of this "bug" is that we will see duplicate
filenames, and readline's completion mechanism already removes
duplicates, so for case #3 we will never see any problems.
Cases #1 and #2 are basically the same, and in each case, to see a
problem we need to ensure we craft the test in a particular way, start
up ensuring we have some unexpected symtabs, then run one of the
commands to populate the cache, then expand one of the symtabs, and
list the sources again. At this point you'll see duplicate entries in
the results. Hardly surprising we haven't randomly hit this situation
in testing.
So, considering that use cases #1 and #2 are certainly not "high
performance" code (i.e. I don't think these justify the need for
caching) this leaves use case #3. Does this use justify the need for
caching? Well the psymbol_functions::map_symbol_filenames function
doesn't seem to do any extra caching, and within
dwarf2_base_index_functions::map_symbol_filenames, the only expensive
bit appears to be the call to dw2_get_file_names, and this already
does its own caching via this_cu->v.quick->file_names.
The upshot of all this analysis was that I'm not convinced the need
for the additional caching is justified, and so, I propose that to fix
the bug in GDB, I just remove the extra caching (for now).
If we later find that the caching _was_ useful, then we can
reintroduce it, but add it back such that it doesn't reintroduce this
bug.
As I was changing dwarf2_base_index_functions::map_symbol_filenames I
replaced the use of htab_up with std::unordered_set.
Tested using target_boards cc-with-debug-names and dwarf4-gdb-index.
gdb/ChangeLog:
* dwarf2/read.c: Add 'unordered_set' include.
(dwarf2_base_index_functions::map_symbol_filenames): Replace
'visited' hash table with 'qfn_cache' unordered_set. Remove use
of per_Bfd->filenames_cache cache, and use function local
filenames_cache instead. Reindent.
* dwarf2/read.h (struct dwarf2_per_bfd) <filenames_cache>: Delete.
gdb/testsuite/ChangeLog:
* gdb.base/info_sources.exp: Add new tests.
Jan Beulich [Fri, 23 Apr 2021 07:18:48 +0000 (09:18 +0200)]
x86: TLS desc call relocs target zero-size fields
These are marker relocations, so together with their bit size being zero
their byte size should be zero as well. This is expressed by a value of
3, not 0.
Jan Beulich [Fri, 23 Apr 2021 07:18:06 +0000 (09:18 +0200)]
x86-64: special case LEA when determining signedness of displacement
LEA behavior without a 64-bit destination is independent of address size
- in particular LEA with 32-bit addressing and 64-bit destination is the
same as LEA with 64-bit addressing and 32-bit destination. IOW checking
merely i.prefix[ADDR_PREFIX] is insufficient. This also means wrong
relocation types (R_X86_64_32S when R_X86_64_32 is needed) were used so
far in such cases.
Note that in one case in build_modrm_byte() the 64-bit check came too
early altogether, and hence gets dropped in favor of the one included in
the new helper. This is benign to non-64-bit code from all I can tell,
but the failure to clear disp16 could have been a latent problem.
Jan Beulich [Fri, 23 Apr 2021 07:17:33 +0000 (09:17 +0200)]
x86-64: defer 32-bit signed displacement check
In preparation for extending the conditions here defer this check until
operands have been parsed, as certain further attributes will need to
be known for determinig applicability of this check to be correct to
LEA.
Jan Beulich [Fri, 23 Apr 2021 07:16:57 +0000 (09:16 +0200)]
x86: re-order optimize_disp()
While I can't point out any specific case where things break, it looks
wrong to have the consumer of a flag before its producer. Set .disp32
first, then do the possible conversion to signed 32-bit, and finally
check whether the value fits in a signed long.
Jan Beulich [Fri, 23 Apr 2021 07:15:45 +0000 (09:15 +0200)]
x86: don't truncate values in diagnostics and alike
Truncating an expression's X_add_number to just "long" can result in
confusing output (e.g. an apparently in-range number claimed to be out
of range). Use the abstraction that bfd provides for this.
Take the opportunity and also insert a missing "of".
Simon Marchi [Fri, 23 Apr 2021 02:00:39 +0000 (22:00 -0400)]
gdb: use function_view for iterate_over_bp_locations' callback
Use a function_view instead of function pointer + data. Actually,
nothing uses the data anyway, but that makes iterate_over_bp_locations
more like iterate_over_breakpoints.
gdb/ChangeLog:
* breakpoint.c (iterate_over_bp_locations): Change callback to
function view, remove data parameter.
* breakpoint.h (iterate_over_bp_locations): Likewise.
* record-full.c (record_full_sync_record_breakpoints): Remove
data parameter.
Change-Id: I66cdc94a505f67bc640bcc66865fb535ee939a57
Tom Tromey [Fri, 23 Apr 2021 01:51:54 +0000 (19:51 -0600)]
Do not check for sys/time.h or sys/times.h
This updates the sim so that it unconditionally uses sys/time.h. This
is in agreement with existing code, and a recent change to BFD.
I also think that sys/times.h is never needed by the sim, so this
patch removes the check and the one spot that was conditionally
including it.
sim/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* m4/sim_ac_common.m4 (SIM_AC_COMMON): Don't check for sys/time.h
or sys/times.h.
sim/aarch64/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/arm/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/avr/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/bfin/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/bpf/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/common/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* sim-utils.c: Update includes.
sim/cr16/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* simops.c: Update includes.
* configure, config.in: Rebuild.
sim/cris/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* rvdummy.c: Update includes.
* dv-rv.c: Update includes.
* configure, config.in: Rebuild.
sim/d10v/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/erc32/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/example-synacor/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/frv/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/ft32/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/h8300/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/iq2000/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/lm32/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/m32c/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/m32r/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/m68hc11/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/mcore/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/microblaze/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/mips/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/mn10300/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/moxie/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/msp430/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/or1k/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/ppc/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* mon.c: Update includes.
* emul_unix.c: Update includes.
(do_unix_gettimeofday): Update condition.
sim/pru/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/riscv/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/rl78/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/rx/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
sim/sh/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* interp.c: Update includes.
* configure, config.in: Rebuild.
sim/v850/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
Tom Tromey [Fri, 23 Apr 2021 01:51:54 +0000 (19:51 -0600)]
Remove LIBS from two sim Makefiles
A couple of sim Makefiles define LIBS, but don't use it. This removes
these.
sim/m32c/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (LIBS): Remove
sim/rx/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (LIBS): Remove.
Tom Tromey [Fri, 23 Apr 2021 01:51:54 +0000 (19:51 -0600)]
Remove INCLUDE variable from some sim Makefiles
Some Makefiles in sim define INCLUDE but don't use it. This removes
these instances.
sim/bfin/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (INCLUDE): Remove.
sim/m68hc11/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (INCLUDE): Remove.
sim/mn10300/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (INCLUDE): Remove.
sim/v850/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (INCLUDE): Remove.
Tom Tromey [Fri, 23 Apr 2021 01:51:54 +0000 (19:51 -0600)]
Remove and modernize dependencies in sim
Some spots in the sim build used manual dependencies, and some spots
did a compilation by hand but did not use the automatic dependency
tracking code. This patch fixes these spots.
I didn't touch ppc, because it doesn't use the common Makefile code.
I also didn't touch objects that are for the build machine, because
automatic dependencies don't work for those.
sim/arm/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (armemu26.o, armemu32.o): Use COMPILE and
POSTCOMPILE.
sim/bpf/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (arch.o, cpu.o, sim-if.o, traps.o): Remove.
(mloop-le.o, mloop-be.o, decode-le.o, decode-be.o, sim-le.o)
(sim-be.o): Use COMPILE and POSTCOMPILE.
(SIM_EXTRA_DEPS): Add eng-le.h, eng-be.h.
sim/cr16/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (SIM_EXTRA_DEPS): New variable.
(simops.o): Remove.
sim/cris/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (sim-if.o, dv-cris.o, dv-rv.o, arch.o, traps.o)
(devices.o, crisv10f.o, mloopv10f.o, cpuv10.o, decodev10.o)
(modelv10.o, crisv32f.o, mloopv32f.o, cpuv32.o, decodev32.o)
(modelv32.o): Remove.
(SIM_EXTRA_DEPS): Add engv10.h.
sim/d10v/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (SIM_EXTRA_DEPS): New variable.
(simops.o): Remove.
sim/frv/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (arch.o, devices.o, frv.o, traps.o, pipeline.o)
(interrupts.o, memory.o, cache.o, options.o, reset.o)
(registers.o, profile.o, profile-fr400.o, profile-fr450.o)
(profile-fr500.o, profile-fr550.o, sim-if.o, mloop.o, cpu.o)
(decode.o, sem.o, model.o): Remove.
(SIM_EXTRA_DEPS): Add eng.h.
sim/iq2000/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (sim-if.o): Remove.
(arch.o): Use COMPILE and POSTCOMPILE.
(devices.o, iq2000.o, mloop.o, cpu.o, decode.o, sem.o, model.o):
Remove.
(SIM_EXTRA_DEPS): Add eng.h.
sim/lm32/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (arch.o, traps.o, sim-if.o, lm32.o, mloop.o)
(cpu.o, decode.o, sem.o, model.o): Remove.
(SIM_EXTRA_DEPS): Add eng.h.
sim/m32r/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (sim-if.o, arch.o, traps.o, traps-linux.o)
(devices.o, m32r.o, mloop.o, cpu.o, decode.o, sem.o, model.o)
(m32rx.o, mloopx.o, cpux.o, decodex.o, semx.o, modelx.o)
(m32r2.o, mloop2.o, cpu2.o, decode2.o, sem2.o, model2.o): Remove.
(SIM_EXTRA_DEPS): Add eng.h, engx.h, eng2.h.
sim/m68hc11/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (interp.o): Remove.
sim/mips/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (interp.o, m16run.o, micromipsrun.o, multi-run.o):
Remove.
(SIM_EXTRA_DEPS): New variable.
sim/mn10300/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (interp.o): Remove.
(idecode.o op_utils.o semantics.o): Remove.
sim/or1k/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (mloop.o, arch.o, cpu.o, decode.o, sem.o)
(sem-switch.o, model.o): Remove.
sim/rl78/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (err.o, fpu.o, gdb-if.o, load.o, main.o, mem.o)
(reg.o, rl78.o): Remove.
sim/rx/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (err.o, fpu.o, gdb-if.o, load.o, main.o, mem.o)
(misc.o, reg.o, rx.o, syscalls.o, trace.o): Remove.
sim/sh/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (SIM_EXTRA_DEPS): New variable.
(interp.o): Remove.
sim/v850/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (interp.o, simops.o, semantics.o): Remove.
Tom Tromey [Fri, 23 Apr 2021 01:51:54 +0000 (19:51 -0600)]
Require GNU make
GDB has required GNU make for quite some time, and this patch applies
this approach to the sim as well. Requiring GNU make means that
automatic dependency tracking can be simple and reliable, and it also
makes other refactorings simpler.
sim/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* m4/sim_ac_common.m4 (SIM_AC_COMMON): Don't check for make.
sim/aarch64/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/arm/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/avr/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/bfin/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/common/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Make-common.in: Require GNU make.
sim/cr16/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/cris/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/d10v/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/erc32/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/example-synacor/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/frv/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/ft32/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/h8300/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/iq2000/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/lm32/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/m32c/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/m32r/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/m68hc11/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/mcore/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/microblaze/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/mips/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/mn10300/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/moxie/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/msp430/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/or1k/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/pru/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/riscv/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/rl78/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/rx/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/sh/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
sim/v850/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
Tom Tromey [Fri, 23 Apr 2021 01:51:54 +0000 (19:51 -0600)]
Add stamp files for generated files in sim/ppc
This changes the sim/ppc Makefile to use the stamp file idiom for a
couple of generated files, avoiding extra rebuilds.
sim/ppc/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Makefile.in (stamp-vals, stamp-map): New targets.
(targ-vals.h, targ-map.c): Update.
(clean): Remove files.
Tom Tromey [Fri, 23 Apr 2021 01:51:54 +0000 (19:51 -0600)]
Introduce stamp file for hw-config.h
This adds a stamp file for hw-config.h, to avoid unnecessary rebuilds.
It also arranges to remove hw-config.h in "mostlyclean", because the
file is created by "make".
sim/common/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Make-common.in (stamp-hw): New target.
(hw-config.h): Depend on stamp-hw.
(mostlyclean): Remove stamp-hw and hw-config.h.
Tom Tromey [Fri, 23 Apr 2021 01:51:54 +0000 (19:51 -0600)]
Make mostlyclean an alias for clean
I found out by accident that "mostlyclean" in a sim subdir removes all
the configure artifacts. The usual rule is:
* If the maintainer built it, maintainer-clean should remove it;
* If configure built it, distclean should remove it;
* If make built it, "clean" should remove it;
* If there is a handy subset of "clean" that is "easy" to rebuild,
"mostlyclean" should remove it; otherwise mostlyclean should be an
alias for clean
This patch makes mostlyclean an alias for clean.
sim/common/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* Make-common.in (mostlyclean): Now an alias for clean, not
distclean.
Tom Tromey [Thu, 22 Apr 2021 22:50:32 +0000 (16:50 -0600)]
Fix sim build failure
On x86-64 Fedora 32, the sim was failing to build.
sim_events_schedule was passing a 'dummy' argument to
sim_events_schedule_vtracef, which caused an error because the format
parameter was NULL. However, removing this dummy argument caused an
error because too few arguments were being passed -- catch 22.
This patch fixes the build problem by using sim_events_schedule_tracef
instead.
sim/common/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* sim-events.c (sim_events_schedule): Use
sim_events_schedule_tracef.
Tom Tromey [Fri, 23 Apr 2021 01:39:56 +0000 (19:39 -0600)]
Fix ptype/o bug with "<no data fields>"
I noticed that when using ptype/o, the "<no data fields>" text that
may be emitted is indented incorrectly. This patch fixes the bug and
adds a new test case.
I also removed a stray backslash from ptype-offsets.exp that I noticed
while writing the test. This seemed too trivial to warrant a separate
patch.
gdb/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* c-typeprint.c (c_type_print_base_struct_union): Use
print_spaces_filtered_with_print_options.
gdb/testsuite/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* gdb.base/ptype-offsets.cc (struct empty_member): New.
(main): Use empty_member.
* gdb.base/ptype-offsets.exp: Add new test.
GDB Administrator [Fri, 23 Apr 2021 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Thu, 22 Apr 2021 19:45:34 +0000 (15:45 -0400)]
gdb/testsuite: add Python support check in gdb.python/flexible-array-member.exp
We don't want to execute this test if Python support is not compiled in
GDB, add the necessary check.
gdb/testsuite/ChangeLog:
* gdb.python/flexible-array-member.exp: Add check for Python
support.
Change-Id: I853b937d2a193a0bb216566bef1a35354264b1c5
Simon Marchi [Thu, 22 Apr 2021 19:01:28 +0000 (15:01 -0400)]
gdb: fix getting range of flexible array member in Python
As reported in bug 27757, we get an internal error when doing:
$ cat test.c
struct foo {
int len;
int items[];
};
struct foo *p;
int main() {
return 0;
}
$ gcc test.c -g -O0 -o test
$ ./gdb -q -nx --data-directory=data-directory ./test -ex 'python gdb.parse_and_eval("p").type.target()["items"].type.range()'
Reading symbols from ./test...
/home/simark/src/binutils-gdb/gdb/gdbtypes.h:435: internal-error: LONGEST dynamic_prop::const_val() const: Assertion `m_kind == PROP_CONST' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
This is because the Python code (typy_range) blindly reads the high
bound of the type of `items` as a constant value. Since it is a
flexible array member, it has no high bound, the property is undefined.
Since commit
8c2e4e0689 ("gdb: add accessors to struct dynamic_prop"),
the getters check that you are not getting a property value of the wrong
kind, so this causes a failed assertion.
Fix it by checking if the property is indeed a constant value before
accessing it as such. Otherwise, use 0. This restores the previous GDB
behavior: because the structure was zero-initialized, this is what was
returned before. But now this behavior is explicit and not accidental.
Add a test, gdb.python/flexible-array-member.exp, that is derived from
gdb.base/flexible-array-member.exp. It tests the same things, but
through the Python API. It also specifically tests getting the range
from the various kinds of flexible array member types (AFAIK it wasn't
possible to do the equivalent through the CLI).
gdb/ChangeLog:
PR gdb/27757
* python/py-type.c (typy_range): Check that bounds are constant
before accessing them as such.
* guile/scm-type.c (gdbscm_type_range): Likewise.
gdb/testsuite/ChangeLog:
PR gdb/27757
* gdb.python/flexible-array-member.c: New test.
* gdb.python/flexible-array-member.exp: New test.
* gdb.guile/scm-type.exp (test_range): Add test for flexible
array member.
* gdb.guile/scm-type.c (struct flex_member): New.
(main): Use it.
Change-Id: Ibef92ee5fd871ecb7c791db2a788f203dff2b841
Simon Marchi [Thu, 22 Apr 2021 16:07:14 +0000 (12:07 -0400)]
sim: sprinkle some ATTRIBUTE_PRINTF
Add some ATTRIBUTE_PRINTF attributes to functions that take a format
string, to fix a few -Wformat-nonliteral warnings. Use the
ATTRIBUTE_PRINTF macro like we use in GDB, instead of spelling out
__attribute__((format...)). Use ATTRIBUTE_NULL_PRINTF at one place,
because callers expect to be able to pass NULL.
sim/common/ChangeLog:
* callback.c (os_printf_filtered, os_vprintf_filtered,
os_evprintf_filtered, os_error): Use ATTRIBUTE_PRINTF.
* sim-engine.h (sim_engine_abort, sim_engine_vabort): Likewise.
* sim-events.h (sim_events_schedule_tracef,
sim_events_schedule_vtracef): Use ATTRIBUTE_NULL_PRINTF.
Change-Id: Icd206f7b2c325e8b144f72eb129fb2a6b5af2fa3
Tankut Baris Aktemur [Thu, 22 Apr 2021 15:22:39 +0000 (17:22 +0200)]
gdb/continuations: turn continuation functions into inferior methods
Turn continuations-related functions into methods of the inferior
class. This is a refactoring.
gdb/ChangeLog:
2021-04-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* Makefile.in (COMMON_SFILES): Remove continuations.c.
* inferior.c (inferior::add_continuation): New method, adapted
from 'add_inferior_continuation'.
(inferior::do_all_continuations): New method, adapted from
'do_all_inferior_continuations'.
(inferior::~inferior): Clear the list of continuations directly.
* inferior.h (class inferior) <continuations>: Rename into...
<m_continuations>: ...this and make private.
* continuations.c: Remove.
* continuations.h: Remove.
* event-top.c: Don't include "continuations.h".
Update the users below.
* inf-loop.c (inferior_event_handler)
* infcmd.c (attach_command)
(notice_new_inferior): Update.
Tankut Baris Aktemur [Thu, 22 Apr 2021 15:22:39 +0000 (17:22 +0200)]
gdb/continuations: use lambdas instead of function pointers
Use lambdas and std::list to track inferior continuations. This is a
refactoring.
gdb/ChangeLog:
2021-04-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* inferior.h (class inferior) <continuations>: Change the type
to be an std::list of std::function's.
Update the references and uses below.
* continuations.c (struct continuation): Delete.
(make_continuation): Delete.
(do_my_continuations_1): Delete.
(do_my_continuations): Delete.
(discard_my_continuations_1): Delete.
(discard_my_continuations): Delete.
(add_inferior_continuation): Update.
(do_all_inferior_continuations): Update.
(discard_all_inferior_continuations): Update.
* continuations.h (add_inferior_continuation): Update to take
an std::function as the parameter.
* infcmd.c (struct attach_command_continuation_args): Delete.
(attach_command_continuation): Delete.
(attach_command_continuation_free_args): Delete.
(attach_command): Update.
(notice_new_inferior): Update.
Tankut Baris Aktemur [Thu, 22 Apr 2021 15:22:39 +0000 (17:22 +0200)]
gdb/continuations: do minor cleanup
Inferior continuations are no longer used by the until and finish
command. It is used only by the attach command and the remote target
upon detecting new inferiors. Update the comment accordingly.
Also update another comment about non-existent thread continuations and
remove an unused #include.
gdb/ChangeLog:
2021-04-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* continuations.h: Update the general comment.
* inferior.h (class inferior) <continuations>: Update the comment.
* interps.c: Do not include "continuations.h".
Tankut Baris Aktemur [Thu, 22 Apr 2021 15:22:38 +0000 (17:22 +0200)]
gdb/continuations: remove the 'err' from 'do_all_inferior_continuations'
The 'err' parameter of 'do_all_inferior_continuations' is effectively
unused. There is only one place where the function is called, and
there the argument is a literal 0. So, remove the parameter.
gdb/ChangeLog:
2021-04-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* continuations.h (do_all_inferior_continuations): Remove the 'err'
parameter. Update the references below.
* continuations.c (do_my_continuations_1)
(do_my_continuations)
(do_all_inferior_continuations): Update.
* inf-loop.c (inferior_event_handler): Update.
* infcmd.c (attach_command_continuation): Update.
Tankut Baris Aktemur [Thu, 22 Apr 2021 15:22:38 +0000 (17:22 +0200)]
gdb/infcmd: update the comment for 'attach_post_wait'
gdb/ChangeLog:
2021-04-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* infcmd.c (attach_post_wait): Update the function comment.
Tankut Baris Aktemur [Thu, 22 Apr 2021 15:22:38 +0000 (17:22 +0200)]
gdb/infcmd: remove the unused parameter 'args' in 'attach_post_wait'
The 'arg' parameter of 'attach_post_wait' is unused. Remove it.
gdb/ChangeLog:
2021-04-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* infcmd.c (attach_post_wait): Remove the unused parameter 'args'.
Update the references below.
(struct attach_command_continuation_args)
(attach_command_continuation)
(attach_command_continuation_free_args)
(attach_command)
(notice_new_inferior): Update to remove the reference to 'args'.
Tom de Vries [Thu, 22 Apr 2021 15:01:00 +0000 (17:01 +0200)]
[gdb] Fix assert in remote_async_get_pending_events_handler
Occassionally I run into the following assert:
...
(gdb) PASS: gdb.multi/multi-target-continue.exp: inferior 5
Remote debugging from host ::1, port 49990^M
Process multi-target-continue created; pid = 31241^M
src/gdb/remote-notif.c:113: internal-error: \
void remote_async_get_pending_events_handler(gdb_client_data): \
Assertion `target_is_non_stop_p ()' failed.^M
...
The assert checks target_is_non_stop_p, which is related to the current
target.
Fix this by changing the assert such that it checks non-stopness related to
the event it's handling.
Tested on x86_64-linux.
gdb/ChangeLog:
2021-04-22 Simon Marchi <simon.marchi@polymtl.ca>
Tom de Vries <tdevries@suse.de>
PR remote/27710
* remote.c (remote_target_is_non_stop_p): New function.
* remote.h (remote_target_is_non_stop_p): Declare.
* remote-notif.c (remote_async_get_pending_events_handler): Fix assert
to check non-stopness using notif_state->remote rather current target.
Cl?ment Chigot [Thu, 22 Apr 2021 14:31:02 +0000 (15:31 +0100)]
fix string table generation for XCOFF64 .debug section
bfd * hash.c (struct bfd_strtab_hash): Remove xcoff field.
Add length_field_size field.
(_bfd_stringtab_init): Change prototype.
Adapt to new length_field_size.
(_bfd_xcoff_stringtab_init): Likewise.
(_bfd_stringtab_add): Likewise.
(_bfd_stringtab_emit): Likewise.
* libbfd-in.h (_bfd_xcoff_stringtab_init):
Change prototype.
* libbfd.h: Regenerate.
* xcofflink.c (_bfd_xcoff_bfd_link_hash_table_create):
Call _bfd_xcoff_stringtab_init with isxcoff64 value.
Tom Tromey [Thu, 22 Apr 2021 13:16:36 +0000 (07:16 -0600)]
Improve code coverage of Rust testing
I enabled code coverage and ran the gdb test suite, and noticed that
the new Rust parser was missing testing on a few lines that were easy
to cover. This patch mostly adds tests for certain syntax errors; but
this process also uncovered a couple of real bugs: I must have
cut-and-pasted the 'sizeof' parsing code from some other code, because
it is checking for KW_MUT (the old bison parser did not do this), and
the array length check is actually impossible because a negative
number like '-1' is parsed as two tokens.
gdb/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* rust-parse.c (rust_parser::parse_sizeof): Remove KW_MUT code.
(struct typed_val_int) <val>: Now ULONGEST.
(rust_parser::parse_array_type): Remove negative check.
(rust_lex_int_test): Change 'value' to ULONGEST.
gdb/testsuite/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* gdb.rust/modules.exp: Add checks for syntax errors.
* gdb.rust/expr.exp: Add checks for syntax errors.
* gdb.rust/simple.exp: Add checks for syntax errors.
Cl?ment Chigot [Thu, 22 Apr 2021 11:28:50 +0000 (12:28 +0100)]
Harmonize and improve auxiliary entries support for XCOFF
bfd/ChangeLog:
* coff-rs6000.c (_bfd_xcoff_swap_aux_in): Add errors for
unsupported storage class or auxialiry entries.
Improve and adapt to new aux structures.
Add C_DWARF support.
(_bfd_xcoff_swap_aux_out): Likewise.
* coff64-rs6000.c (_bfd_xcoff64_swap_aux_in): Likewise.
(_bfd_xcoff64_swap_aux_out): Likewise.
binutils/ChangeLog:
* od-xcoff.c (dump_xcoff32_symbols): Adapt to new
aux structures.
include/ChangeLog:
* coff/internal.h (union internal_auxent):
Add x_sect structure.
* coff/rs6000.h (union external_auxent): Rework to
match official documentation.
* coff/rs6k64.h (union external_auxent): Likewise.
(_AUX_SECT): New define.