Simon Marchi [Thu, 13 May 2021 19:28:42 +0000 (15:28 -0400)]
gdb: maybe unpush target from old inferior in inf_child_target::follow_exec
I realized that with "follow-exec-mode == new", the process target
stayed pushed in the original inferior. This can cause a small
incoherence:
$ ./gdb -q -nx --data-directory=data-directory -ex "set follow-exec-mode new" --args execer args-for-execer
Reading symbols from execer...
(gdb) r
Starting program: /home/smarchi/build/binutils-gdb/gdb/execer args-for-execer
I am execer and my argv[1] is: args-for-execer
process
3562426 is executing new program: /home/smarchi/build/binutils-gdb/gdb/execee
[New inferior 2]
[New process
3562426]
I am execee and my argv[1] is: arg-for-execee
[Inferior 2 (process
3562426) exited normally]
(gdb) info inferiors
Num Description Connection Executable
1 <null> 1 (native) /home/smarchi/build/binutils-gdb/gdb/execer
* 2 <null> /home/smarchi/build/binutils-gdb/gdb/execee
(gdb) maintenance print target-stack
The current target stack is:
- exec (Local exec file)
- None (None)
(gdb) inferior 1
[Switching to inferior 1 [<null>] (/home/smarchi/build/binutils-gdb/gdb/execer)]
(gdb) maintenance print target-stack
The current target stack is:
- native (Native process)
- exec (Local exec file)
- None (None)
On exec, when execution continues into inferior 2, the native target
isn't unpushed from inferior 1. When inferior 2's execution finishes
normally, inf_child_target::mourn_inferior unpushes the native target,
because the native target has been implicitly opened.
I think that if the native target was implicitly opened, it should be
unpushed from inferior 1, just like it is unpushed from an inferior
whose execution terminate. This patch implements that.
gdb/ChangeLog:
* inf-child.h (inf_child_target) <follow_exec>: New.
* inf-child.c (inf_child_target::follow_exec): New.
Change-Id: I782cc08d73d93a990f4e53611107f68b2cb58af1
Simon Marchi [Thu, 13 May 2021 19:28:20 +0000 (15:28 -0400)]
gdb: on exec, delegate pushing / unpushing target and adding thread to target_ops::follow_exec
On "exec", some targets need to unpush themselves from the inferior,
and do some bookkeeping, like forgetting the data associated to the
exec'ing inferior.
One such example is the thread-db target. It does so in
a special case in thread_db_target::wait, just before returning the
TARGET_WAITKIND_EXECD event to its caller.
We have another such case in the context of rocm-gdb [1], where the
"rocm" target is pushed on top of the linux-nat target. When an exec
happens, we want to unpush the rocm target from the exec'ing inferior to
close some file descriptors that refer to the pre-exec address space and
forget about that inferior. We then want to push the target on the
inferior in which execution continues, to open the file descriptors for
the post-exec address space.
I think that a good way to address this cleanly is to do all this in the
target_ops::follow_exec implementations. Make the
process_stratum_target::follow_exec implementation have the default
behavior of pushing itself to the new inferior's target stack (if
execution continues in a new inferior) and add the initial thread.
remote_target::follow_exec is an example of process target that wants to
do a bit more than the default behavior. So it calls
process_stratum_target::follow_exec first and does the extra work
second.
linux-thread-db (a non-process target) implements follow_exec to do some
bookeeping (forget about that process' data), before handing down the
event down to the process target (which hits
process_stratum_target::follow_exec).
gdb/ChangeLog:
* target.h (struct target_ops) <follow_exec>: Add ptid_t
parameter.
(target_follow_exec): Likewise.
* target.c (target_follow_exec): Add ptid_t parameter.
* infrun.c (follow_exec): Adjust call to target_follow_exec,
don't push target nor create thread.
* linux-thread-db.c (class thread_db_target) <follow_exec>: New.
(thread_db_target::wait): Just return on TARGET_WAITKIND_EXECD.
(thread_db_target::follow_exec): New.
* remote.c (class remote_target) <follow_exec>: Add ptid_t parameter.
(remote_target::follow_exec): Call
process_stratum_target::follow_exec.
* target-delegates.c: Re-generate.
Change-Id: I3f96d0ba3ea0dde6540b7e1b4d5cdb01635088c8
Simon Marchi [Thu, 13 May 2021 19:27:55 +0000 (15:27 -0400)]
gdb: call target_follow_exec when "set follow-exec-mode" is "same"
target_follow_exec is currently only called in the "follow-exec-mode ==
new" branch of follow_exec, not the "follow-exec-mode == same" branch.
I think it would make sense to call it regardless of the mode to let
targets do some necessary handling.
This is needed in the context of rocm-gdb [1], where a target is pushed
on top of the linux-nat target. On exec, it needs to do some
bookkeeping, close some file descriptors / handles that were related to
the process pre-exec and open some new ones for the process post-exec.
However, by looking at the only in-tree implementation of
target_ops::follow_exec, remote_target::follow_exec, I found that it
would be useful for the extended-remote target too, to align its
behavior with native debugging (although I think that behavior is not
very user-friendly, see PR 27745 [2]).
Using two programs, one (let's call it "execer") that execs the other
(let's call it "execee"), with native:
$ ./gdb -q -nx --data-directory=data-directory ./execer
Reading symbols from ./execer...
(gdb) r
Starting program: /home/simark/build/binutils-gdb/gdb/execer
I am execer
process
1495622 is executing new program: /home/simark/build/binutils-gdb/gdb/execee
I am execee
[Inferior 1 (process
1495622) exited normally]
(gdb) r
Starting program: /home/simark/build/binutils-gdb/gdb/execee
I am execee
[Inferior 1 (process
1495626) exited normally]
And now with gdbserver (some irrelevant output lines removed for brevity):
$ ./gdbserver --once --multi :1234
...
$ ./gdb -q -nx --data-directory=data-directory ./execer -ex "set remote exec-file /home/simark/build/binutils-gdb/gdb/execer" -ex "tar ext :1234"
Reading symbols from ./execer...
Remote debugging using :1234
(gdb) r
Starting program: /home/simark/build/binutils-gdb/gdb/execer
process
1495724 is executing new program: /home/simark/build/binutils-gdb/gdb/execee
[Inferior 1 (process
1495724) exited normally]
(gdb) r
`target:/home/simark/build/binutils-gdb/gdb/execee' has disappeared; keeping its symbols.
Starting program: target:/home/simark/build/binutils-gdb/gdb/execee
warning: Build ID mismatch between current exec-file target:/home/simark/build/binutils-gdb/gdb/execee
and automatically determined exec-file target:/home/simark/build/binutils-gdb/gdb/execer
exec-file-mismatch handling is currently "ask"
Reading /home/simark/build/binutils-gdb/gdb/execer from remote target...
Load new symbol table from "target:/home/simark/build/binutils-gdb/gdb/execer"? (y or n)
When handling the exec, GDB updates the exec-file of the inferior to be
the execee. This means that a subsequent "run" will run the execee, not
the original executable (execer).
remote_target::follow_exec is meant to update the "remote exec-file",
which is the file on the remote system that will be executed if you
"run" the inferior, to the execee as well. However, this is not called
when follow-exec-mode is same, because target_follow_exec is not called
in this branch. As a result, GDB thinks the inferior is executing
execee but the remote side is really executing execer, hence the
mismatch message.
By calling target_follow_exec in the "same" branch of the follow_exec
function, we ensure that everybody agrees, and we get the same behavior
with the extended-remote target as we get with the native target, the
execee is executed on the second run:
$ ./gdbserver --once --multi :1234
...
$ ./gdb -q -nx --data-directory=data-directory ./execer -ex "set remote exec-file /home/simark/build/binutils-gdb/gdb/execer" -ex "tar ext :1234"
Reading symbols from ./execer...
Remote debugging using :1234
(gdb) r
Starting program: /home/simark/build/binutils-gdb/gdb/execer
process
1501445 is executing new program: /home/simark/build/binutils-gdb/gdb/execee
[Inferior 1 (process
1501445) exited normally]
(gdb) r
`target:/home/simark/build/binutils-gdb/gdb/execee' has disappeared; keeping its symbols.
Starting program: target:/home/simark/build/binutils-gdb/gdb/execee
[Inferior 1 (process
1501447) exited normally]
(gdb)
This scenario is tested in gdb.base/foll-exec-mode.exp, and in fact this
patch fixes the test for me when using
--target_board=native-extended-gdbserver.
gdb/ChangeLog:
* infrun.c (follow_exec): Call target_follow_fork when
follow-exec-mode is same.
* target.h (target_follow_fork): Improve doc.
[1] https://github.com/ROCm-Developer-Tools/ROCgdb
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=27745
Change-Id: I4ee84a875e39bf3f8eaf3e6789a4bfe23a2a430e
Andrew Burgess [Thu, 13 May 2021 16:58:49 +0000 (17:58 +0100)]
gdb/testsuite: fix dates in last 3 ChangeLog entries
Incorrect dates in last 3 ChangeLog entries for gdb/testsuite/ChangeLog.
Andrew Burgess [Thu, 13 May 2021 16:04:35 +0000 (17:04 +0100)]
gdb/testsuite: resolve remaining duplicate tests in gdb.guile/
The remaining duplicates are resolved by adding a with_test_prefix and
reindenting a proc. I also added a couple of additional test names to
some of the tests.
gdb/testsuite/ChangeLog:
* gdb.guile/scm-pretty-print.exp (run_lang_tests): Give some tests
unique names, also wrap proc body in with_test_prefix.
Andrew Burgess [Thu, 13 May 2021 15:56:03 +0000 (16:56 +0100)]
gdb/testsuite: resolve duplicate test names in gdb.guile/*.exp
This commit resolves almost all of the remaining duplicate test names
in gdb.guile/*.exp. This is done by either:
- Making use of with_test_prefix,
- Giving tests a unique name,
- Extending the existing name to make it unique,
- Not printing PASS lines for simple setup commands (e.g. loading
support modules, or adjusting GDB internal settings not relating to
guile).
gdb/testsuite/ChangeLog:
* gdb.guile/scm-frame-args.exp: Add with_test_prefix to resolve
duplicate test names.
* gdb.guile/scm-parameter.exp: Provide test names to avoid
duplicate names based on the command being run.
* gdb.guile/scm-symbol.exp: Extend test name to make it unique.
* gdb.guile/scm-type.exp (restart_gdb): Don't print PASS line when
loading a support module.
(test_equality): Update test name to match the actual test, making
the name unique in the process.
* gdb.guile/scm-value.exp (test_value_in_inferior): Add test names
to resolve duplicate tests.
(test_inferior_function_call): Likewise.
(test_subscript_regression): Likewise.
Andrew Burgess [Thu, 13 May 2021 15:50:28 +0000 (16:50 +0100)]
gdb/testsuite: remove some duplicate test names from guile tests
The guile support library has some "tests" that are actually being
used to setup GDB ready for the real guile tests, e.g. we load some
support modules, and define some helper functions.
As this setup is done every time we call gdb_guile_runto_main, which
could be called multiple times in a single test script, this can lead
to duplicate PASS lines.
As this setup is all pretty basic, and isn't the actual focus of the
real tests, then in this commit I pass an empty test name through to
the gdb_test_no_output calls, the result of this is that the PASS
lines are no longer printed. This removes some duplicate tests from
the gdb.guile/*.exp set of tests.
gdb/testsuite/ChangeLog:
* lib/guile.exp (gdb_scm_load_file): Use empty test name to
silence PASS lines.
(gdb_install_guile_module): Likewise.
Simon Marchi [Thu, 13 May 2021 14:13:48 +0000 (10:13 -0400)]
gdb: remove cmd_list_element::pre_show_hook
This is unused, remove it.
gdb/ChangeLog:
* cli/cli-decode.h (struct cmd_list_element) <pre_show_hook>:
Remove.
* cli/cli-setshow.c (do_show_command): Adjust.
Change-Id: Ib9cd79d842550392b062309e1e5c079ad5d7571a
Nick Clifton [Thu, 13 May 2021 13:33:39 +0000 (14:33 +0100)]
revert previous delta
Nick Clifton [Thu, 13 May 2021 13:31:09 +0000 (14:31 +0100)]
Fix an infinite loop in the DWARF decoder when parsing a corrupt string table.
PR 27861
* dwarf.c (display_debug_str_offsets): Warn if the length field is
larger than the amount of data remaining in the section.
Alan Modra [Thu, 13 May 2021 13:16:36 +0000 (22:46 +0930)]
PR27861, Infinite loop in dwarf.c:7507-7526
PR 27861
* dwarf.c (display_debug_str_offsets): Sanity check dwarf5
header length.
Alan Modra [Thu, 13 May 2021 12:52:45 +0000 (22:22 +0930)]
PR27860, Segmentation fault on readelf -w
Well it didn't take long for the SAFE_BYTE_GET assert to trigger.
PR 27860
* dwarf.c (display_debug_frames): Sanity check cie_off before
attempting to read cie.
Luis Machado [Thu, 29 Apr 2021 18:10:06 +0000 (15:10 -0300)]
[AArch64] Fix off-by-one when calculating tag granules.
When we want to fetch tags from a memory range, the last address in that
range is not included.
There is a off-by-one error in aarch64_mte_get_tag_granules, which this
patch fixes.
gdb/ChangeLog:
2021-05-13 Luis Machado <luis.machado@linaro.org>
* arch/aarch64-mte-linux.c (aarch64_mte_get_tag_granules): Don't
include the last address in the range.
Nelson Chu [Thu, 13 May 2021 03:48:26 +0000 (11:48 +0800)]
RISC-V: Record implicit subsets in a table, to avoid repeated codes.
Add a new table, riscv_implicit_subsets, to record all implicit information.
So that we add all implicit subsets according to the table, to avoid too
many repeated codes in the riscv_parse_add_implicit_subsets. Besides, the
check_func is used to check whether we should add this implicit subset.
For example, check_implicit_for_i checks the version of i, and we only add
zicsr and zifencei implicitly only when the version less than 2.1.
bfd/
* elfxx-riscv.c (check_implicit_always): The check_func, always add
the implicit subset without checking.
(check_implicit_for_i): The check_func for i, only add zicsr and
zifencei when the version of i less than 2.1.
(struct riscv_implicit_subset): Record the subsets and their
corresponding implicit subsets.
(riscv_implicit_subsets): Table records all implicit informations.
(riscv_parse_add_implicit_subsets): Updated and add implicit subsets
according to riscv_implicit_subsets. Remove the redundant codes.
Fangrui Song [Wed, 12 May 2021 06:10:45 +0000 (23:10 -0700)]
ld: Add -Bno-symbolic
PR 27834
* ldlex.h (enum option_values): Add OPTION_NO_SYMBOLIC.
* lexsup.c (ld_options): Add -Bno-symbolic.
(parse_args): Handle -Bno-symbolic.
* ld.texi: Document -Bno-symbolic.
* NEWS: Mention -Bno-symbolic.
* testsuite/ld-elf/shared.exp: Add a test.
Alan Modra [Thu, 13 May 2021 00:41:20 +0000 (10:11 +0930)]
PR27858, global-buffer-overflow
PR 27858
* elf32-sh.c (sh_elf_info_to_howto): Correct check for last valid
reloc howto.
GDB Administrator [Thu, 13 May 2021 00:00:34 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Wed, 12 May 2021 17:50:05 +0000 (13:50 -0400)]
gdb: make gdbpy_parse_command_name return a unique_xmalloc_ptr
This avoids some manual memory management.
cmdpy_init correctly transfers ownership of the name to the
cmd_list_element, as it sets the name_allocated flag. However,
cmdpy_init (and add_setshow_generic) doesn't, it looks like the name is
just leaked. This is a bit tricky, because it actually creates two
commands (one set and one show), it would take a bit of refactoring of
the command code to give each their own allocated copy. For now, just
keep doing what the current code does but in a more explicit fashion,
with an explicit release.
gdb/ChangeLog:
* python/python-internal.h (gdbpy_parse_command_name): Return
gdb::unique_xmalloc_ptr.
* python/py-cmd.c (gdbpy_parse_command_name): Likewise.
(cmdpy_init): Adjust.
* python/py-param.c (parmpy_init): Adjust.
(add_setshow_generic): Take gdb::unique_xmalloc_ptr, release it
when done.
Change-Id: Iae5bc21fe2b22f12d5f954057b0aca7ca4cd3f0d
Tom de Vries [Wed, 12 May 2021 14:03:02 +0000 (16:03 +0200)]
Revert "[gdb/symtab] Fix infinite recursion in dwarf2_cu::get_builder()"
This reverts commit
4cf88725da1cb503be04d3237354105ec170bc86.
It causes the following regression:
...
$ cat shadow.cc
namespace A {}
int
main()
{
using namespace A;
return 0;
}
$ g++-10 -g shadow.cc -flto -o shadow
$ ./gdb -q -batch ./shadow -ex "b main"
Aborted (core dumped)
...
Alan Modra [Wed, 12 May 2021 07:57:34 +0000 (17:27 +0930)]
Ensure data pointer kept within bounds
* dwarf.c (process_extended_line_op): Don't bump data pointer past
end when strnlen doesn't find string terminator.
(decode_location_expression): Remove dead code.
(skip_attr_bytes): Remove const from end param. Ensure data
pointer doesn't pass end.
(get_type_signedness): Remove const from end param.
(read_and_display_attr_value): Ensure data pointer doesn't pass end.
(display_debug_lines_raw, display_debug_lines_decoded): Likewise.
(display_debug_pubnames_worker): Likewise.
(display_debug_pubnames_worker): Use SAFE_BYTE_GET_AND INC rather
than blindly incrementing data pointer.
(display_debug_addr, display_debug_str_offsets): Likewise. Don't
compare pointers, compare lengths.
Alan Modra [Wed, 12 May 2021 03:21:52 +0000 (12:51 +0930)]
SAFE_BYTE_GET
This rearranges SAFE_BYTE_GET* macros, eliminating some duplication,
and making sure that the _INC variants never increment their PTR arg
past END. I've added an assertion that should show us places where we
use them improperly with user derived PTR args, which I'm sure the
fuzzers will find for us.
* dwarf.c (SAFE_BYTE_GET_INTERNAL): Define.
(SAFE_BYTE_GET, SAFE_BYTE_GET_AND_INC): Define using the above.
(SAFE_SIGNED_BYTE_GET, SAFE_SIGNED_BYTE_GET_AND_INC): Likewise.
(display_discr_list): Use SAFE_BYTE_GET_AND_INC rather than
SAFE_BYTE_GET followed by increment.
(process_debug_info): Likewise, and test bytes remaining before
incrementing section_begin rather than using pointer comparison.
(display_debug_names): Pass lvalue as SAFE_BYTE_GET PTR.
(process_cu_tu_index): Likewise for SAFE_BYTE_GET_AND_INC.
Alan Modra [Wed, 12 May 2021 08:18:13 +0000 (17:48 +0930)]
SAFE_BYTE_GET64
Functions dealing with lack of a 64-bit integer type can disappear now
that we require C99. Printing using dwarf_vmatoa is better too.
binutils/
* dwarf.c (dwarf_vmatoa64, SAFE_BYTE_GET64, add64): Delete.
(skip_attr_bytes): Replace use of SAFE_BYTE_GET64 with
SAFE_BYTE_GET_AND_INC.
(read_and_display_attr_value): Likewise. Print using dwarf_vmatoa.
(process_debug_info, process_cu_tu_index): Likewise.
* elfcomm.c (byte_put, byte_put_little_endian, byte_put_big_endian),
(byte_get, byte_get_little_endian, byte_get_big_endian),
(byte_get_signed): Make size param unsigned. Remove code dealing
with 4-byte elf_vma.
(byte_get_64): Delete.
* elfcomm.h (byte_put, byte_put_little_endian, byte_put_big_endian),
(byte_get, byte_get_little_endian, byte_get_big_endian),
(byte_get_signed): Update prototypes.
(byte_get_64): Delete.
gas/
* testsuite/gas/elf/dwarf-5-file0.d: Update.
* testsuite/gas/i386/dwarf5-line-1.d: Update.
Alan Modra [Tue, 11 May 2021 08:27:04 +0000 (17:57 +0930)]
PR27836, readelf -w pointer comparison UB
PR 27836
* dwarf.c (display_debug_frames): Don't compare pointers derived
from user input. Test offset against bounds instead.
George Barrett [Wed, 28 Apr 2021 17:32:56 +0000 (03:32 +1000)]
Guile: add value-const-value
The Guile API doesn't currently have an equivalent to the Python API's
gdb.Value.const_value(). This commit adds a procedure with equivalent
semantics to the Guile API.
gdb/ChangeLog:
* NEWS (Guile API): Note the addition of the new procedure.
* guile/scm-value.c (gdbscm_value_const_value): Add
implementation of value-const-value procedure.
(value_functions): Add value-const-value procedure.
gdb/doc/ChangeLog:
* guile.texi (Values From Inferior In Guile): Add documentation
for value-const-value.
gdb/testsuite/ChangeLog:
* gdb.guile/scm-value.exp (test_value_in_inferior): Add test for
value-const-value.
George Barrett [Wed, 28 Apr 2021 17:32:47 +0000 (03:32 +1000)]
Guile: add value-{rvalue-,}reference-value
The Guile API doesn't currently have an equivalent to the Python API's
Value.reference_value() or Value.rvalue_reference_value(). This commit
adds a procedure with equivalent semantics to the Guile API.
gdb/ChangeLog:
* NEWS (Guile API): Note the addition of new procedures.
* guile/scm-value.c (gdbscm_reference_value): Add helper function
for reference value creation.
(gdbscm_value_reference_value): Add implementation of
value-reference-value procedure.
(gdbscm_value_rvalue_reference_value): Add implementation of
value-rvalue-reference-value procedure.
(value_functions): Add value-reference-value procedure. Add
value-rvalue-reference-value procedure.
gdb/doc/ChangeLog:
* guile.texi (Values From Inferior In Guile): Add documentation
for value-reference-value. Add documentation for
value-rvalue-reference-value.
gdb/testsuite/ChangeLog:
* gdb.guile/scm-value.exp (test_value_in_inferior): Add test for
value-reference-value. Add test for value-rvalue-reference-value.
George Barrett [Wed, 28 Apr 2021 17:32:37 +0000 (03:32 +1000)]
Guile: improved rvalue reference support
Adds a couple of missing bits to the Guile API to make C++11 rvalue
reference values and types usable from Guile scripts.
gdb/ChangeLog:
* guile/scm-type.c (type_integer_constants): Add binding for
TYPE_CODE_RVALUE_REF.
* guile/scm-value.c (gdbscm_value_referenced_value): Handle
dereferencing of rvalue references.
* NEWS (Guile API): Note improvements in rvalue reference support.
gdb/doc/ChangeLog:
* guile.texi (Types In Guile): Add documentation for
TYPE_CODE_RVALUE_REF.
Richard Earnshaw [Wed, 12 May 2021 10:43:59 +0000 (11:43 +0100)]
arm: fix fallout from recent thumb2 detection patch
The recent change to correct the detection of thumb2 object files
resulted in a ld test for veneering starting to fail. The problem was
the test itself, which was incorrectly expecting thumb1 type far-call
veneers instead of the thumb2 flavour. We already have a dump file of
the expected form, so the fix is to change the expected output
accordingly.
ld/
* testsuite/ld-arm/arm-elf.exp (farcall test for v8-m.mainline):
Correct expected output.
Marco Barisione [Wed, 12 May 2021 10:19:22 +0000 (11:19 +0100)]
gdb: generate the prefix name for prefix commands on demand
Previously, the prefixname field of struct cmd_list_element was manually
set for prefix commands. This seems verbose and error prone as it
required every single call to functions adding prefix commands to
specify the prefix name while the same information can be easily
generated.
Historically, this was not possible as the prefix field was null for
many commands, but this was fixed in commit
3f4d92ebdf7f848b5ccc9e8d8e8514c64fde1183 by Philippe Waroquiers, so
we can rely on the prefix field being set when generating the prefix
name.
This commit also fixes a use after free in this scenario:
* A command gets created via Python (using the gdb.Command class).
The prefix name member is dynamically allocated.
* An alias to the new command is created. The alias's prefixname is set
to point to the prefixname for the original command with a direct
assignment.
* A new command with the same name as the Python command is created.
* The object for the original Python command gets freed and its
prefixname gets freed as well.
* The alias is updated to point to the new command, but its prefixname
is not updated so it keeps pointing to the freed one.
gdb/ChangeLog:
* command.h (add_prefix_cmd): Remove the prefixname argument as
it can now be generated automatically. Update all callers.
(add_basic_prefix_cmd): Ditto.
(add_show_prefix_cmd): Ditto.
(add_prefix_cmd_suppress_notification): Ditto.
(add_abbrev_prefix_cmd): Ditto.
* cli/cli-decode.c (add_prefix_cmd): Ditto.
(add_basic_prefix_cmd): Ditto.
(add_show_prefix_cmd): Ditto.
(add_prefix_cmd_suppress_notification): Ditto.
(add_prefix_cmd_suppress_notification): Ditto.
(add_abbrev_prefix_cmd): Ditto.
* cli/cli-decode.h (struct cmd_list_element): Replace the
prefixname member variable with a method which generates the
prefix name at runtime. Update all code reading the prefix
name to use the method, and remove all code setting it.
* python/py-cmd.c (cmdpy_destroyer): Remove code to free the
prefixname member as it's now a method.
(cmdpy_function): Determine if the command is a prefix by
looking at prefixlist, not prefixname.
Luis Machado [Wed, 12 May 2021 10:03:17 +0000 (11:03 +0100)]
Add MTE register set support for core files
* elf-bfd.h (elfcore_write_aarch_mte): New prototype.
* elf.c (elfcore_grok_aarch_mte, elfcore_write_aarch_mte): New
functions.
(elfcore_grok_note): Handle notes of type NT_ARM_TAGGED_ADDR_CTRL.
(elfcore_write_register_note): Handle MTE notes.
Markus Metzger [Fri, 30 Apr 2021 15:09:47 +0000 (17:09 +0200)]
gdb, btrace, pt: ignore status update enable events
Future versions of libipt report enable/disable status updates on PSB+.
Ignore them.
Alan Modra [Wed, 12 May 2021 05:41:43 +0000 (15:11 +0930)]
PR27853, Infinite loop in dwarf.c
Not quite infinite but much longer than it need be. The problem is
triggered by read_and_display_attr_value incrementing "data" past
"end". read_and_display_attr_value shouldn't do that, but be
defensive.
PR 27853
* dwarf.c (display_formatted_table): Test for data >= end rather
than data == end.
(process_extended_line_op): Likewise.
(display_debug_lines_raw): Likewise.
(display_debug_lines_decoded): Likewise.
Alan Modra [Tue, 11 May 2021 23:21:22 +0000 (08:51 +0930)]
PR27849, heap-buffer-overflow on readelf -w
PR 27849
* dwarf.c (fetch_indexed_string): Correct length sanity checks.
Sanity check section size for version and padding too. Correct
index sanity check. Handle multiple tables in .debug_str_offsets.
Mike Frysinger [Wed, 12 May 2021 04:46:19 +0000 (00:46 -0400)]
sim: clean up explicit environment build calls
This was enabled by default for all targets, but a few ports still
include an explicit call. Clean that up, and update the docs.
Luis Machado [Mon, 10 May 2021 19:06:50 +0000 (16:06 -0300)]
Fix build failure in d10v sim
While building all targets on Ubuntu 20.04/aarch64, I ran into the following
build error:
In file included from /usr/include/string.h:495,
from ../../bfd/bfd.h:48,
from ../../../../repos/binutils-gdb/sim/d10v/interp.c:4:
In function memset,
inlined from sim_create_inferior at ../../../../repos/binutils-gdb/sim/d10v/interp.c:1146:3:
/usr/include/aarch64-linux-gnu/bits/string_fortified.h:71:10: error: __builtin_memset offset [33, 616] from the object at State is out of the bounds of referenced subobject regs with type reg_t[16] {aka short unsigned int[16]} at offset 0 [-Werror=array-bounds]
71 | return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[3]: *** [Makefile:558: interp.o] Error 1
The following patch fixes this.
sim/ChangeLog:
2021-05-12 Luis Machado <luis.machado@linaro.org>
* d10v/interp.c (sim_create_inferior): Fix memset call.
Roland McGrath [Wed, 12 May 2021 00:00:30 +0000 (17:00 -0700)]
x86-64/ELF: Fix "clear src_mask for all reloc types" test case
ld/
* testsuite/ld-x86-64/rela.d: Fix regexp not to presume a specific
address layout, so it works for e.g. --target=x86-64-elf.
GDB Administrator [Wed, 12 May 2021 00:00:36 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Tue, 11 May 2021 21:32:28 +0000 (17:32 -0400)]
gdb: fix indentation in arm_record_data_proc_misc_ld_str
The scopes under this "if" are over-indented, fix that.
gdb/ChangeLog:
* arm-tdep.c (arm_record_data_proc_misc_ld_str): Fix
indentation.
Change-Id: I84a551793207ca95d0bc4f122e336555c8179c0e
Simon Marchi [Tue, 11 May 2021 20:08:16 +0000 (16:08 -0400)]
gdb: fix indentation of cmd_list_element
This structure declaration is over-indented, fix that.
gdb/ChangeLog:
* cli/cli-decode.h (struct cmd_list_element): Fix indentation.
Change-Id: I17c9cd739a233239b3add72f4fce7947c20907cd
Richard Earnshaw [Tue, 11 May 2021 15:18:25 +0000 (16:18 +0100)]
arm: correctly decode Tag_THUMB_ISA_use=3 for thumb2 features
This was detected when a user accidentally tried to build a shared
library using armv8-m.main objects. The resulting error was "warning:
thumb-1 mode PLT generation not currently supported". Something was
clearly wrong because v8-m.main is a thumb-2 variant.
It turns out that the code to detect thumb-2 in object files hadn't
been updated for the extended definition of Tag_THUMB_ISA_use to
support the value 3, meaning 'work it out for yourself from the
architecture tag'; something that is now necessary given that the line
between thumb-1 and thumb-2 has become blurred over time.
Another problem with the function doing this calculation was that the
absence of this tag (implying a default value 0) should mean use of
thumb code was NOT permitted. However, the code went on to look at
the architecture flags and decide that it could ignore this if the
architecture flags said that thumb2 features were available, thus
completely ignoring the intended meaning.
bfd/
* elf32-arm.c (using_thumb2): Correctly handle Tag_THUMB_ISA_use
values 0 and 3.
Hans-Peter Nilsson [Tue, 11 May 2021 14:12:24 +0000 (16:12 +0200)]
dwarf.c (process_abbrev_set): Properly parenthesize, fix fallout
Building as ILP32 shows:
gcc -m32 -DHAVE_CONFIG_H -I. -I/checkout/binutils -I. -I/checkout/binutils -I../bfd -I/checkout/binutils/../bfd -I/checkout/binutils/../include -DLOCALEDIR="\"/usr/local/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Werror -I/checkout/binutils/../zlib -g -O2 -MT dwarf.o -MD -MP -MF $depbase.Tpo -c -o dwarf.o /checkout/binutils/dwarf.c &&\
mv -f $depbase.Tpo $depbase.Po
In file included from /checkout/binutils/sysdep.h:101:0,
from /checkout/binutils/dwarf.c:21:
/checkout/binutils/dwarf.c: In function 'process_abbrev_set':
/checkout/binutils/dwarf.c:1072:15: error: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'dwarf_vma {aka long long unsigned int}' [-Werror=format=]
warn (_("Debug info is corrupted, abbrev size (%lx) is larger than "
^
/checkout/binutils/dwarf.c:1072:13: note: in expansion of macro '_'
warn (_("Debug info is corrupted, abbrev size (%lx) is larger than "
^
cc1: all warnings being treated as errors
Makefile:1101: recipe for target 'dwarf.o' failed
The recent commit, casting one of the terms, has an obvious
typo. To wit, the (non-cast) term abbrev_size is a
dwarf_vma and causes the whole expression to (still) be 64
bits.
binutils:
* dwarf.c (process_abbrev_set): Properly parenthesize before
casting to unsigned long.
Tom de Vries [Tue, 11 May 2021 12:22:11 +0000 (14:22 +0200)]
[gdb/testsuite] Update infrun regexp in gdb.base/watch_thread_num.exp
The test-case gdb.base/watch_thread_num.exp contains an infrun regexp:
...
-re "infrun:" {
...
which doesn't trigger because:
- the test-case doesn't contain "set debug infrun 1", and
- if we hack the test-case to add this, the regexp doesn't match
because "[infrun] " is printed instead.
Make the test pass with "set debug infrun 1" and add the setting commented
out.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2021-05-11 Tom de Vries <tdevries@suse.de>
* gdb.base/watch_thread_num.exp: Fix "set debug infrun 1" FAILs.
Add "set debug infrun 1" commented out.
Tom de Vries [Tue, 11 May 2021 12:22:11 +0000 (14:22 +0200)]
[gdb/testsuite] Fix read1 timeout in gdb.base/gdb-sigterm.exp
When running check-read1, I run into a timeout in test-case
gdb.base/gdb-sigterm.exp:
...
[infrun] handle_inferior_event: status->kind = stopped, \
signal = GDB_SIGNAL_TRAP^M
[infrun] start_step_over: enter^M
[infrun] start_step_overFAIL: gdb.base/gdb-sigterm.exp: \
expect eof #0 (timeout)
gdb.base/gdb-sigterm.exp: expect eof #0: stepped 0 times
FAIL: gdb.base/gdb-sigterm.exp: 50 SIGTERM passes
...
The corresponding gdb_test_multiple has an exp_continue clause, but it doesn't
trigger because the regexp greps for 'infrun: ' instead of '[infrun] '.
Fix the timeout by fixing the infrun regexp.
Tested on x86_64-linux, with check and check-read1.
gdb/testsuite/ChangeLog:
2021-05-11 Tom de Vries <tdevries@suse.de>
* gdb.base/gdb-sigterm.exp: Fix exp_continue regexp.
Bhuvanendra Kumar N [Tue, 11 May 2021 11:56:46 +0000 (17:26 +0530)]
gdb/fortran: Breakpoint location is modified.
Breakpoint location is modified to "return" statement which is
outside the DO loop. Because the label 100 of DO loop should get
executed for each iteration as shared in this external link:
http://www-pnp.physics.ox.ac.uk/~gronbech/intfor/node18.html.
flang compiler is following this fortran standard, whereas gfortran
compiler is not following, hence the test case is passing with
gfortran and failing with flang. but to correct this gfortran
behavior, bug has been filed in bugzilla
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99816). As reported in
the bug, with gfortran, label 100 of DO loop is reached only after
the completion of the entire DO loop. Hence at label 100, all the
array elements are set and printing of array element a(2) succeeds.
whereas with flang, when we are at label 100 for first time, array
element a(2) is not yet set, only a(1) is set, hence moving the
breakpoint location to outside the DO loop, so that once we are
outside the DO loop, we can print any of the array elements. This
change in test case is done irrespective of any fortran compiler.
gdb/testsuite/ChangeLog:
* gdb.fortran/array-element.exp: Breakpoint location is modified.
Alan Modra [Tue, 11 May 2021 12:00:14 +0000 (21:30 +0930)]
PR27844, Unstable symbol name in objdump outputs
Special care for fuzzers.
PR 27844
* pdp11.c (aout_get_external_symbols): Clear first four bytes of
strings array, not just the first byte.
* aoutx.h (aout_get_external_symbols): Likewise.
Nick Clifton [Tue, 11 May 2021 10:29:58 +0000 (11:29 +0100)]
Fix an illegal memory access when attempting to disassemble a corrupt TIC30 binary.
PR 27840
* tic30-dis.c (print_insn_tic30): Prevent attempts to read beyond
the end of the code buffer.
Nick Clifton [Tue, 11 May 2021 10:06:53 +0000 (11:06 +0100)]
Prevent libdel.dll.a from being installed on Windows based systems.
PR 27113
* Makefile.am (install-data-local): Also delete libdep.dll.a if it
is present.
* Makefile.in: Regenerate.
Sergey Belyashov [Tue, 11 May 2021 09:57:04 +0000 (10:57 +0100)]
Report illegal Z80 load instructions.
PR 27823
* config/tc-z80.c (emit_ld_r_m): Report an illegal load
instruction.
* testsuite/gas/z80/ill_ops.s: New test source file.
* testsuite/gas/z80/ill_ops.d: New test driver.
* testsuite/gas/z80/ill_ops.l: New test error output.
Alan Modra [Tue, 11 May 2021 08:27:59 +0000 (17:57 +0930)]
PR27845, readelf heap-buffer-overflow
PR 27845
* dwarf.c (process_abbrev_set): Replace start and end parameters
with section, abbrev_base, abbrev_size, abbrev_offset. Update
all callers. Sanity check parameters correctly and emit warnings
here rather than..
(process_debug_info): ..here.
GDB Administrator [Tue, 11 May 2021 00:00:36 +0000 (00:00 +0000)]
Automatic date update in version.in
Lancelot SIX [Wed, 24 Mar 2021 23:55:25 +0000 (23:55 +0000)]
[PR gdb/27614] gdb-add-index fails on symlinks.
PR 27614 shows that gdb-add-index fails to generate the index when its
argument is a symlink.
The following one liner illustrates the reported problem:
$ echo 'int main(){}'|gcc -g -x c -;ln -s a.out symlink;gdb-add-index symlink
gdb-add-index: No index was created for symlink
gdb-add-index: [Was there no debuginfo? Was there already an index?]
$ ls -l
-rwxr-xr-x 1 25712 Mar 19 23:05 a.out*
-rw------- 1 8277 Mar 19 23:05 a.out.gdb-index
lrwxrwxrwx 1 5 Mar 19 23:05 symlink -> a.out*
GDB generates the .gdb-index file with a name that matches the name of
the actual program (a.out.gdb-index here), not the symlink that
references it. The remaining of the script is looking for a file named
after the provided argument (would be 'symlink.gdb-index' in our
example).
gdb/ChangeLog:
PR gdb/27614
* contrib/gdb-add-index.sh: Fix when called with a symlink as an
argument.
gdb/testsuite/ChangeLog:
PR gdb/27614
* gdb.dwarf2/gdb-add-index-symlink.exp: New test.
H.J. Lu [Mon, 10 May 2021 19:50:22 +0000 (12:50 -0700)]
Remove strayed fprintf in commit
23182ac0d83
PR binutils/27839
* simple.c (bfd_simple_get_relocated_section_contents): Remove
strayed fprintf.
Andrew Burgess [Mon, 10 May 2021 15:49:56 +0000 (16:49 +0100)]
gdb/testsuite: don't use source tree as temporary HOME directory
In this commit:
commit
1845e254645efbc02248345ccdb557d265dd8ae1
Date: Wed May 5 16:50:17 2021 +0100
gdb/guile: perform tilde expansion when sourcing guile scripts
A test was added that tries to source a guile script from the users
HOME directory. In order to achieve this the test (temporarily)
modifies $HOME to point into the binutils-gdb source tree.
The problem with this is that sourcing a guile script can cause the
guile script to be byte compiled and written into a .cache/ directory,
which is stored .... in the $HOME directory.
The result was that the test added in the above commit would cause a
.cache/ directory to be added into the binutils-gdb source tree.
In this commit the test is updated to create a new directory in the
build tree, the file we want to source is copied over, and $HOME is
set to point at the location in the build tree. Now when the test is
run the .cache/ directory is created in the build tree, leaving the
source tree untouched.
gdb/testsuite/ChangeLog:
* gdb.guile/guile.exp: Don't use the source directory as a
temporary HOME directory.
Simon Marchi [Mon, 10 May 2021 16:43:06 +0000 (12:43 -0400)]
gdb/testsuite: use proc parameters in gdb.arch/amd64-osabi.exp
This test has a little oversight: the test procedure doesn't actually
use its parameters, the commands and expected patterns are hard-coded,
so we always test with i386:x86-64, instead of with the three arches.
Fix that.
gdb/testsuite/ChangeLog:
* gdb.arch/amd64-osabi.exp (test_osabi_none): Use the
parameters.
Change-Id: Iee2c32963d09e502ae791d5df2b6c04a1f49a57a
Simon Marchi [Mon, 10 May 2021 16:13:36 +0000 (12:13 -0400)]
gdb, gdbserver: make status_to_str display the signal name
I was looking at some "set debug lin-lwp" logs, and saw that a thread
received the "Child exited" signal. It took me a moment to realize that
this was SIGCHLD. I then thought that it would be nice for
status_to_str to show the signal name (SIGCHLD) in addition to the
description "Child exited", since people are much more used to referring
to signals using their names.
Fortunately, libiberty contains a handy function to get the signal name
from the signal number, strsigno, use that.
The output of "set debug lin-lwp" now looks like:
[linux-nat] linux_nat_wait_1: waitpid
1209631 received SIGTRAP - Trace/breakpoint trap (stopped)
gdb/ChangeLog:
* nat/linux-waitpid.c (status_to_str): Show signal name.
Change-Id: I8ad9b1e744dd64461fd87b08d5c29f9ef97c4691
Nick Clifton [Mon, 10 May 2021 13:44:31 +0000 (14:44 +0100)]
Fix an indirection via uninitialised memory when parsing a corrupt input file.
PR 27839
* simple.c (simple_dummy_add_to_set): New function.
(simple_dummy_constructor): New function.
(simple_dummy_multiple_common): New function.
(bfd_simple_get_relocated_section_contents): Zero out the
callbacks structure, and then set the add_to_set, constructor and
multiple_common fields.
Dimitar Dimitrov [Mon, 10 May 2021 13:00:00 +0000 (14:00 +0100)]
Enable linker garbage collection for the PRU target.
bfd * elf32-pru.c (elf_backend_can_gc_sections): Define as 1.
ld * testsuite/ld-elf/group8a.d: Remove pru from XFAIL list.
* testsuite/ld-elf/group8b.d: Ditto.
* testsuite/ld-elf/group9a.d: Ditto.
* testsuite/ld-elf/group9b.d: Ditto.
* testsuite/ld-elf/pr12851.d: Ditto.
* testsuite/ld-elf/pr22677.d: Ditto.
* testsuite/lib/ld-lib.exp (check_gc_sections_available): Remove
pru from list.
Dimitar Dimitrov [Mon, 10 May 2021 12:58:17 +0000 (13:58 +0100)]
PRU: Add alignment for resource table, and allow sizes of memory regions to be set from the command line.
ld * scripttempl/pru.sc (.resource_table): Add ALIGN directive.
Use symbols for memory sizes.
Sergey Belyashov [Mon, 10 May 2021 12:36:08 +0000 (13:36 +0100)]
Add support for 8-bit and 24-bit shifts in the z80 assembler.
PR 27415
* config/tc-z80.c (emit_data_val): Add support for 8-bit and
24-bit shifts.
* testsuite/gas/z80/z80_reloc.a: Update tests.
* testsuite/gas/z80/z80_reloc.d: Update expected disassembly.
Thomas Wolff [Mon, 10 May 2021 10:28:15 +0000 (11:28 +0100)]
Restore old behaviour of windres so that options containing spaces are not enclosed in double quotes.
PR 4356
PR 26865
PR 27594
* windres.c (quot): Revert previous delta. Do not use double
quotes when spaces are detected in options.
* doc/binutils.texi (windres): Remove suggestion that the
--preprocessor option can take arguments.
Andrew Burgess [Sun, 9 May 2021 16:26:53 +0000 (17:26 +0100)]
gdb/doc: reword a sentence
Change this:
The available watchpoint types represented by constants are defined
in the gdb module:
to this:
The available watchpoint types are represented by constants defined
in the gdb module:
The new version matches a similar line a few lines up the document
which reads:
The available types are represented by constants defined in the gdb
module:
gdb/doc/ChangeLog:
* guile.texinfo (Breakpoints In Guile): Reword sentence.
* python.texinfo (Breakpoints In Python): Reword sentence.
Alan Modra [Mon, 10 May 2021 00:26:43 +0000 (09:56 +0930)]
Avoid possible pointer wrap
PTR supplied to these macros can be read from user input, END is an
end of buffer pointer. It's safer to do arithmetic on END than on PTR.
* dwarf.c (SAFE_BYTE_GET): Check bounds by subtracting amount from
END rather than adding amount to PTR.
(SAFE_SIGNED_BYTE_GET, SAFE_BYTE_GET64): Likewise.
GDB Administrator [Mon, 10 May 2021 00:00:37 +0000 (00:00 +0000)]
Automatic date update in version.in
Andrew Burgess [Sat, 8 May 2021 17:02:36 +0000 (18:02 +0100)]
gdb/doc: document 'set debug py-unwind'
When the 'set debug py-unwind' flag was added, it was never documented
in the manual. This commit adds some text for this command to the
manual.
gdb/doc/ChangeLog:
* python.texinfo (Python Commands): Document 'set debug
py-unwind' and 'show debug py-unwind'.
Andrew Burgess [Wed, 5 May 2021 12:46:36 +0000 (13:46 +0100)]
gdb/py: add some debugging to py-breakpoint.c
Adds some new debugging to python/py-breakpoint.c.
gdb/ChangeLog:
* python/py-breakpoint.c (pybp_debug): New static global.
(show_pybp_debug): New function.
(pybp_debug_printf): Define.
(PYBP_SCOPED_DEBUG_ENTER_EXIT): Define.
(gdbpy_breakpoint_created): Add some debugging.
(gdbpy_breakpoint_deleted): Likewise.
(gdbpy_breakpoint_modified): Likewise.
(_initialize_py_breakpoint): New function.
gdb/doc/ChangeLog:
* python.texinfo (Python Commands): Document 'set debug
py-breakpoint' and 'show debug py-breakpoint'.
Andrew Burgess [Sat, 8 May 2021 15:28:41 +0000 (16:28 +0100)]
gdb/py: convert debug logging in py-unwind to use new scheme
Converts the debug print out in python/py-unwind.c to use the new
debug printing scheme. I have also modified what is printed in a few
places, for example, rather than printing frame pointers, I now print
the frame level, this matches what we do in the general 'set debug
frame' tracing, and is usually more helpful (I think).
I also added a couple of ENTER/EXIT scope printers.
gdb/ChangeLog:
* python/py-unwind.c (pyuw_debug): Convert to bool.
(show_pyuw_debug): New function.
(pyuw_debug_printf): Define.
(PYUW_SCOPED_DEBUG_ENTER_EXIT): Define.
(pyuw_this_id): Convert to new debug print macros.
(pyuw_prev_register): Likewise.
(pyuw_sniffer): Likewise.
(pyuw_dealloc_cache): Likewise.
(_initialize_py_unwind): Update now pyuw_debug is a bool, and add
show function when registering.
Andrew Burgess [Sat, 8 May 2021 14:43:56 +0000 (15:43 +0100)]
gdb: replace fprint_frame_id
Replace fprint_frame_id with a member function frame_id::to_string
that returns a std::string. Convert all of the previous users of
fprint_frame_id to use the new member function. This means that
instead of writing things like this:
fprintf_unfiltered (file, " id=");
fprint_frame_id (file, s->id.id);
We can write this:
fprintf_unfiltered (file, " id=%s", s->id.id.to_string ().c_str ());
There should be no user visible changes after this commit.
gdb/ChangeLog:
* dummy-frame.c (fprint_dummy_frames): Convert use of
fprint_frame_id to use frame_id::to_string.
* frame.c (fprint_field): Delete.
(fprint_frame_id): Moved to...
(frame_id::to_string): ...this, rewritten to return a string.
(fprint_frame): Convert use of fprint_frame_id to use
frame_id::to_string.
(compute_frame_id): Likewise.
(frame_id_p): Likewise.
(frame_id_eq): Likewise.
(frame_id_inner): Likewise.
* frame.h (struct frame_id) <to_string>: New member function.
(fprint_frame_id): Delete declaration.
* guile/scm-frame.c (frscm_print_frame_smob): Convert use of
fprint_frame_id to use frame_id::to_string.
* python/py-frame.c (frame_object_to_frame_info): Likewise.
* python/py-unwind.c (unwind_infopy_str): Likewise.
(pyuw_this_id): Likewise.
Alan Modra [Sun, 9 May 2021 02:58:32 +0000 (12:28 +0930)]
Use htab_eq_string in libctf
* ctf-impl.h (ctf_dynset_eq_string): Don't declare.
* ctf-hash.c (ctf_dynset_eq_string): Delete function.
* ctf-dedup.c (make_set_element): Use htab_eq_string.
(ctf_dedup_atoms_init, ADD_CITER, ctf_dedup_init): Likewise.
(ctf_dedup_conflictify_unshared): Likewise.
(ctf_dedup_walk_output_mapping): Likewise.
Alan Modra [Sun, 9 May 2021 02:58:18 +0000 (12:28 +0930)]
Use htab_eq_string in binutils
A quick check says this is the only place in all of bfd, opcodes,
binutils, gas, ld, gprof that duplicates the new libiberty
htab_eq_string.
* objcopy.c (eq_string): Delete.
(create_symbol_htab): Use htab_eq_string.
Simon Marchi [Sun, 9 May 2021 01:27:49 +0000 (21:27 -0400)]
gdbsupport: re-generate configure & friends
I get these changes when re-generating the autoconf stuff in gdbsupport,
fallouts from
4655f8509fd4 ("Don't run personality syscall at configure
time; don't check it at all").
gdbsupport/ChangeLog:
* Makefile.in: Re-generate.
* config.in: Re-generate.
* configure: Re-generate.
Change-Id: Ie1876ee58d6f4f1cf25fa14900eecf4c85a744c1
Simon Marchi [Sun, 9 May 2021 01:06:41 +0000 (21:06 -0400)]
gdb, gdbserver: make status_to_str return std::string
Instead of using a static buffer. This is safer, and we don't really
mind about any extra dynamic allocation here, since it's only used for
debug purposes.
gdb/ChangeLog:
* nat/linux-waitpid.c (status_to_str): Return std::string.
* nat/linux-waitpid.h (status_to_str): Likewise.
* linux-nat.c (linux_nat_post_attach_wait): Adjust.
(linux_nat_target::attach): Adjust.
(linux_handle_extended_wait): Adjust.
(wait_lwp): Adjust.
(stop_wait_callback): Adjust.
(linux_nat_filter_event): Adjust.
(linux_nat_wait_1): Adjust.
* nat/linux-waitpid.c (status_to_str): Adjust.
* nat/linux-waitpid.h (status_to_str): Adjust.
gdbserver/ChangeLog:
* linux-low.cc (linux_process_target::wait_for_event_filtered):
Adjust to status_to_str returning std::string.
Change-Id: Ia8aead70270438a5690f243e6faafff6c38ff757
Simon Marchi [Sun, 9 May 2021 00:37:27 +0000 (20:37 -0400)]
gdb: add missing space in infrun_debug_printf
gdb/ChangeLog:
* infrun.h (infrun_debug_printf): Add missing space.
Change-Id: I476096a098451ff2019ab38caa41ebfef0e04a1c
GDB Administrator [Sun, 9 May 2021 00:00:37 +0000 (00:00 +0000)]
Automatic date update in version.in
Mike Frysinger [Sat, 8 May 2021 16:41:04 +0000 (12:41 -0400)]
sim: h8300: clean up various warnings
A random grab bag of minor fixes to enable -Werror for this port.
Disable h8_set_macS for now as it's unused.
Initialize trace & intMask before using them.
Mark local set_h8300h function static.
Mike Frysinger [Sat, 8 May 2021 16:34:03 +0000 (12:34 -0400)]
sim: touch modules target
If there are no updates to the file, touch the result so we don't
keep trying to regenerate it.
Mike Frysinger [Sun, 2 May 2021 02:29:50 +0000 (22:29 -0400)]
sim: cgen: tweak trace format
Fixes build warnings when the address size isn't an integer.
Mike Frysinger [Sun, 2 May 2021 02:11:41 +0000 (22:11 -0400)]
sim: cgen: namespace mode_names a bit
These are exported in the library linkage, so add a cgen_ prefix.
Mike Frysinger [Sun, 2 May 2021 02:05:25 +0000 (22:05 -0400)]
sim: cgen: tweak cgen_rtx_error to fix warnings
The function was missing a prototype, and passing a constant string
as the format string instead of going through a %s format.
Mike Frysinger [Sun, 2 May 2021 02:03:05 +0000 (22:03 -0400)]
sim: cgen: tweak initializers to avoid warnings
Use {} instead of {0} to avoid warnings:
common/cgen-utils.c:59:1: warning: missing braces around initializer [-Wmissing-braces]
59 | {
| ^
60 | {
61 | VIRTUAL_INSN_X_INVALID, "--invalid--", NULL, 0, { V, { 0 } }
| {{}}
Generated code should be the same.
Mike Frysinger [Sun, 2 May 2021 16:58:11 +0000 (12:58 -0400)]
binutils: update release docs process
Now that we generate multiple html & pdf forms, update the release
process to show how they get updated.
Mike Frysinger [Sun, 2 May 2021 16:50:39 +0000 (12:50 -0400)]
support generating multi-html pages in parallel
Use the pattern from other projects where we generate the html pages
in a dir named the same as the project. So now we have:
gas/doc/gas.html - single html page
gas/doc/gas/ - multiple html pages
This works for projects that have a doc/ subdir already, but gprof &
ld require a little tweaking since they generate their docs in their
respective toplevels.
Mike Frysinger [Sun, 2 May 2021 16:09:00 +0000 (12:09 -0400)]
generate single html manual page by default
This better matches other GNU projects like autoconf/automake where
the html manual is the single page form. We'll support the multi-page
form in a follow up change.
Mike Frysinger [Sat, 8 May 2021 15:53:37 +0000 (11:53 -0400)]
sim: add html & pdf stubs
We stub out the info targets already since we don't provide any.
Tom Tromey [Sat, 8 May 2021 13:50:47 +0000 (07:50 -0600)]
sim: use htab_eq_string
This changes the sim to use htab_eq_string from libiberty.
sim/common/ChangeLog
2021-05-08 Tom Tromey <tom@tromey.com>
* sim-options.c (compare_strings): Remove.
(dup_arg_p): Use htab_eq_string.
Pedro Alves [Wed, 28 Apr 2021 22:05:15 +0000 (23:05 +0100)]
Don't run personality syscall at configure time; don't check it at all
Currently, in order to tell whether support for disabling address
space randomization on Linux is available, GDB checks if the
personality syscall works, at configure time. I.e., it does a run
test, instead of a compile/link test:
AC_RUN_IFELSE([PERSONALITY_TEST],
[have_personality=true],
[have_personality=false],
This is a bit bogus, because the machine the build is done on may not
(and is when you consider distro gdbs) be the machine that eventually
runs gdb. It would be better if this were a compile/link test
instead, and then at runtime, GDB coped with the personality syscall
failing. Actually, GDB already copes.
One environment where this is problematic is building GDB in a Docker
container -- by default, Docker runs the container with seccomp, with
a profile that disables the personality syscall. You can tell Docker
to use a less restricted seccomp profile, but I think we should just
fix it in GDB.
"man 2 personality" says:
This system call first appeared in Linux 1.1.20 (and thus first
in a stable kernel release with Linux 1.2.0); library support
was added in glibc 2.3.
...
ADDR_NO_RANDOMIZE (since Linux 2.6.12)
With this flag set, disable address-space-layout randomization.
glibc 2.3 was released in 2002.
Linux 2.6.12 was released in 2005.
The original patch that added the configure checks was submitted in
2008. The first version of the patch that was submitted to the list
called personality from common code:
https://sourceware.org/pipermail/gdb-patches/2008-June/058204.html
and then was moved to Linux-specific code:
https://sourceware.org/pipermail/gdb-patches/2008-June/058209.html
Since HAVE_PERSONALITY is only checked in Linux code, and
ADDR_NO_RANDOMIZE exists for over 15 years, I propose just completely
removing the configure checks.
If for some odd reason, some remotely modern system still needs a
configure check, then we can revert this commit but drop the
AC_RUN_IFELSE in favor of always doing the AC_LINK_IFELSE
cross-compile fallback.
gdb/ChangeLog:
* linux-nat.c (linux_nat_target::supports_disable_randomization):
Remove references to HAVE_PERSONALITY.
* nat/linux-personality.c: Remove references to HAVE_PERSONALITY.
(maybe_disable_address_space_randomization)
(~maybe_disable_address_space_randomizatio): Remove references to
HAVE_PERSONALITY.
* config.in, configure: Regenerate.
gdbserver/ChangeLog:
* linux-low.cc:
(linux_process_target::supports_disable_randomization): Remove
reference to HAVE_PERSONALITY.
* config.in, configure: Regenerate.
gdbsupport/ChangeLog:
* common.m4 (personality test): Remove.
Pedro Alves [Sat, 8 May 2021 11:54:43 +0000 (12:54 +0100)]
Don't include sys/personality.h in linux-low.cc anymore
Lancelot pointed out that since the refactor at:
https://sourceware.org/pipermail/gdb-patches/2015-January/120503.html
the sys/personality.h include is not needed in linux-low.cc anymore,
as it does not call personality directly itself anymore.
gdbserver/ChangeLog:
* linux-low.cc: Don't include sys/personality.h or define
ADDR_NO_RANDOMIZE.
Mike Frysinger [Sat, 8 May 2021 01:53:25 +0000 (21:53 -0400)]
sim: m68hc11: fix up cycle buffer printing
Make sure the local static buffer is large enough, and simplify the
sprintf for merging the fields all into one. This fixes compiler
warnings from buf possibly being overflowed.
GDB Administrator [Sat, 8 May 2021 00:00:38 +0000 (00:00 +0000)]
Automatic date update in version.in
Andrew Burgess [Wed, 5 May 2021 15:50:17 +0000 (16:50 +0100)]
gdb/guile: perform tilde expansion when sourcing guile scripts
Before this patch:
(gdb) source ~/script.scm
ERROR: In procedure apply-smob/1:
ERROR: In procedure primitive-load-path: Unable to find file "~/script.scm" in load path
Error while executing Scheme code.
(gdb)
This is because the path is not tilde expanded. In contrast, when
sourcing a .py or .gdb script the path is tilde expanded.
This commit fixes this oversight, and allows the above source command
to work as expected.
The tilde expansion is done in the generic GDB code before we call the
sourcer function for any particular extension language.
gdb/ChangeLog:
* cli/cli-cmds.c: Add 'gdbsupport/gdb_tilde_expand.h'
include.
(source_script_with_search): Perform tilde expansion.
gdb/testsuite/ChangeLog:
* gdb.guile/guile.exp: Add an extra test.
Andrew Burgess [Fri, 7 May 2021 21:14:27 +0000 (22:14 +0100)]
gdb/testsuite: use gdb_test_no_output instead of send_gdb
I noticed gdb.base/ptype-offsets.exp failing occasionally, this was
due to lines like this in the test script:
send_gdb "set print type hex on\n"
As this does not match the '(gdb)' prompt that is produced, the prompt
would sometimes be matched against the next test, causing the next
test to think its output was missing and fail.
Fix this by switching to:
gdb_test_no_output "set print type hex on"
gdb/testsuite/ChangeLog:
* gdb.base/ptype-offsets.exp: Replace use of send_gdb with
gdb_test_no_output.
Simon Marchi [Fri, 7 May 2021 20:28:56 +0000 (16:28 -0400)]
gdb: make target_desc_info::filename an std::string
To make the management of memory automatic.
As to why I chose to make this an std::string and not an
std::unique_xmalloc_ptr<char>: some parts of the code consider both a
NULL value and an empty string value to mean "no filename".
target_desc_info_from_user_p, however, doesn't check for a non-NULL but
empty string value. So it seems like having two ways of denoting "no
filename" can lead to these kinds of inconsistencies. Using
std::string, "no filename" is only represented by an empty value.
As a bonus, using an std::string lets us copy target_desc_info objects
using the default assignment operator.
gdb/ChangeLog:
* target-descriptions.c (struct target_desc_info) <filename>:
Make std::string.
(copy_inferior_target_desc_info): Adjust.
(target_desc_info_free): Adjust.
(target_find_description): Adjust.
(set_tdesc_filename_cmd): Adjust.
(show_tdesc_filename_cmd): Adjust.
(unset_tdesc_filename_cmd): Adjust.
(maint_print_c_tdesc_cmd): Adjust.
Change-Id: I4e3a6ad8ccda2b88c202471d4f54249753cad127
Simon Marchi [Fri, 7 May 2021 20:28:56 +0000 (16:28 -0400)]
gdb: (de-)allocate target_desc_info with new/delete
In preparation for using non-POD types in the struct.
gdb/ChangeLog:
* target-descriptions.c (struct target_desc_info): Initialize
fields.
(get_tdesc_info): Use new.
(target_desc_info_free): Use delete.
Change-Id: I10fdaeeae7cdbd7930ae7adeeb13f7f363c67c7a
Simon Marchi [Fri, 7 May 2021 20:28:56 +0000 (16:28 -0400)]
gdb: change target_desc_info::fetched to bool
gdb/ChangeLog:
* target-descriptions.c (struct target_desc_info) <fetched>:
bool.
(target_find_description): Adjust.
(target_clear_description): Adjust.
Change-Id: Ib69e097b38cf270e674f1249105d535a312954e1
Simon Marchi [Fri, 7 May 2021 20:28:56 +0000 (16:28 -0400)]
gdb: remove target description macros
In my opinion, the target_desc_fetched, current_target_desc and
target_description_filename macros in target-descriptions.c are not very
useful. I don't think it's useful to hide that they operate on the
current inferior, as everything currently works under the assumption
that the various tdesc commands operate on the current inferior, and I
don't see that changing in the foreseeable future.
This change also avoids having multiple unnecessary calls to
current_inferior and get_tdesc_info per function.
gdb/ChangeLog:
* target-descriptions.c (struct target_desc_info) <tdesc>:
Adjust doc.
(target_desc_fetched): Remove.
(current_target_desc): Remove.
(target_description_filename): Remove.
(target_find_description): Adjust.
(target_clear_description): Adjust.
(target_current_description): Adjust.
(set_tdesc_filename_cmd): Adjust.
(show_tdesc_filename_cmd): Adjust.
(unset_tdesc_filename_cmd): Adjust.
(maint_print_c_tdesc_cmd): Adjust.
(maint_print_xml_tdesc_cmd): Adjust.
Change-Id: Ibfb581490e949c16d59924e2cac633ede5c26c5b
Dimitar Dimitrov [Mon, 5 Apr 2021 16:21:35 +0000 (19:21 +0300)]
sim: Add bfd include path for common testsuite tools
On a host without installed libbfd, this patch fixes the following
"make check-sim" errors for both pru cross target, and native x86_64:
In file included from ../../../binutils/sim/common/sim-basics.h:131,
from testsuite/common/bits32m0.c:13:../../../binutils/sim/../include/gdb/callback.h:55:10: fatal error: bfd.h: No such file or directory
55 | #include "bfd.h"
| ^~~~~~~
Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
Nick Clifton [Fri, 7 May 2021 16:07:41 +0000 (17:07 +0100)]
Add a generic .bss directive for ELF based targets.
PR 3136
* config/obj-elf.c (elf_pseudo_table): Add entry for .bss.
(obj_elf_bss): New function. Change to the .bss section.
Support an optional subsection number.
(obj_elf_change_section): Call obj_elf_section_change_hook.
(obj_elf_section): Likewise.
(obj_elf_data): Likewise.
(obj_elf_text): Likewise.
(obj_elf_struct): Likewise.
(obj_elf_subsection): Likewise.
(obj_elf_previous): Likewise.
* config/obj-elf.h (obj_elf_bss): Prototype.
* doc/as.texi (Bss): New node.
Andrew Burgess [Fri, 7 May 2021 15:49:24 +0000 (16:49 +0100)]
gdb: some int to bool conversion
Change int parameter to bool in remote_notice_new_inferior (remote.c)
and notice_new_inferior (infcmd.c), and update the callers.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* infcmd.c (notice_new_inferior): Change parameter type.
* inferior.h (notice_new_inferior): Change parameter type.
* remote.c (remote_notice_new_inferior): Change parameter type to
bool. Also update type of local variable to bool.
(remote_target::update_thread_list): Change type of local variable
to bool.
(remote_target::process_stop_reply): Pass bool instead of int to
remote_notice_new_inferior.
Simon Marchi [Fri, 7 May 2021 15:52:51 +0000 (11:52 -0400)]
gdb: remove reference to current inferior in target_stack::unpush
target_stack::unpush needs to get the target beneath the target being
unpushed to update the m_top field (which keeps the stratum of the
top-most target). It currently does so using target_ops::beneath, which
uses the target stack of the current inferior. The target stack of the
current inferior is the same as the `this` in the unpush method.
Avoid this detour and remove this reference to the current inferior by
calling target_ops::find_beneath and passing `this` to find the target
beneath `t` in the target stack that is `this`.
gdb/ChangeLog:
* target.c (target_stack::unpush): Call target_ops::find_beneath
to get the target beneath `t`.
Change-Id: If9d9661567c5c16f655d270bd2ec9f1b3aa6dadc
Simon Marchi [Fri, 7 May 2021 15:51:19 +0000 (11:51 -0400)]
gdb: make target_close check that the target isn't pushed in all inferiors
The target_close function currently checks that the target to be closed
isn't pushed in the current inferior:
gdb_assert (!current_inferior ()->target_is_pushed (targ));
Normally, a target is closed when its refcount has dropped to 0, due to
not being used in any inferior anymore. I think it would make sense to
change that assert to not only check in the current inferior, but to
check in all inferiors. It would be quite bad (and a bug) to close a
target while it's still pushed in one of the non-current inferiors.
gdb/ChangeLog:
* target.c (target_close): Check in all inferiors that the
target is not pushed.
Change-Id: I6e37fc3f3476a0593da1e476604642b2de90f1d5
Aaron Merey [Fri, 7 May 2021 15:37:16 +0000 (11:37 -0400)]
debuginfod-support.c: Use long-lived debuginfod_client
Instead of initializing a new debuginfod_client for each query, store
the first initialized client for the remainder of the GDB session and
use it for every debuginfod query.
In conjunction with upcoming changes to libdebuginfod, using one client
for all queries will avoid latency caused by unneccesarily setting up
TCP connections multiple times.
Tested on Fedora 33 x86_64.
gdb/ChangeLog:
* debuginfod-support.c (debuginfod_init): Remove.
(get_debuginfod_client): New function.
Tom Tromey [Fri, 7 May 2021 15:18:18 +0000 (09:18 -0600)]
Remove streq_hash in favor of htab_eq_string
Now that libiberty includes htab_eq_string, we can remove the
identical function from gdb.
gdb/ChangeLog
2021-05-07 Tom Tromey <tom@tromey.com>
* breakpoint.c (ambiguous_names_p): Use htab_eq_string.
* utils.c (streq_hash): Remove.
* utils.h (streq_hash): Don't declare.
* completer.c (completion_tracker::discard_completions): Update
comment.
* ada-lang.c (_initialize_ada_language): Use htab_eq_string.