binutils-gdb.git
3 years agogdb: remove some uses of LA_PRINT_STRING
Andrew Burgess [Thu, 19 Nov 2020 17:52:00 +0000 (17:52 +0000)]
gdb: remove some uses of LA_PRINT_STRING

This commit removes some, but not all, uses of LA_PRINT_STRING.  In
this commit I've removed those uses where there is an obvious language
object on which I can instead call the printstr method.

In the remaining 3 uses it is harder to know if the correct thing is
to call printstr on the current language, or on a specific language.
Currently obviously, we always call on the current language (as that's
what LA_PRINT_STRING does), and clearly this behaviour is good enough
right now, but is it "right"?  I've left them for now and will give
them more thought in the future.

gdb/ChangeLog:

* expprint.c (print_subexp_standard): Replace uses of
LA_PRINT_STRING.
* f-valprint.c (f_language::value_print_inner): Likewise.
* guile/scm-pretty-print.c (ppscm_print_string_repr): Likewise.
* p-valprint.c (pascal_language::value_print_inner): Likewise.
* python/py-prettyprint.c (print_string_repr): Likewise.

3 years agogdb: move rust_language into rust-lang.h
Andrew Burgess [Fri, 30 Oct 2020 15:09:35 +0000 (15:09 +0000)]
gdb: move rust_language into rust-lang.h

Move the rust_language class declaration into the rust-lang.h header
file.  This allows for the function implementations called directly in
rust-lang.c and rust-exp.y without the need for trampoline functions.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* rust-exp.y (rust_parse): Rename to...
(rust_language::parser): ...this.
* rust-lang.c (-rust_printstr): Rename to...
(rust_language::printstr): ...this.
(rust_value_print_inner): Delete declaration.
(val_print_struct): Rename to...
(rust_language::val_print_struct): ...this.  Update calls to
member functions.
(rust_print_enum): Rename to...
(rust_language::print_enum): ...this.  Update calls to member
functions.
(rust_value_print_inner): Rename to...
(rust_language::value_print_inner): ...this.  Update calls to
member functions.
(exp_descriptor_rust): Rename to...
(rust_language::exp_descriptor_tab): ...this.
(class rust_language): Move to rust-lang.h.
(rust_language::language_arch_info): Implementation moved to here
from class declaration.
(rust_language::print_type): Likewise.
(rust_language::emitchar): Likewise.
(rust_language::is_string_type_p): Likewise.
* rust-lang.h: Add 'demangle.h', 'language.h', 'value.h', and
'c-lang.h' includes.
(rust_parse): Delete declaration.
(class rust_language): Class declaration moved here from
rust-lang.c.

3 years agogdb/objc: fix bug in objc_language::opcode_print_table
Andrew Burgess [Fri, 30 Oct 2020 14:35:47 +0000 (14:35 +0000)]
gdb/objc: fix bug in objc_language::opcode_print_table

In this commit:

  commit b7c6e27dbbbbe678b2e2f0bf617605e055e1b378
  Date:   Tue Aug 4 17:07:59 2020 +0100

      gdb: Convert language_data::la_op_print_tab to a method

A bug was introduced, the objc language now returns the wrong op_print
table.  Fixed in this commit.

gdb/ChangeLog:

* objc-lang.c (objc_language::opcode_print_table): Return
objc_op_print_tab.

3 years agogdb: move pascal_language into p-lang.h
Andrew Burgess [Wed, 28 Oct 2020 18:10:01 +0000 (18:10 +0000)]
gdb: move pascal_language into p-lang.h

Move the pascal_language class declaration into the p-lang.h header
file.  This allows for the function implementations to be spread over
the different p-*.c files without the need for global trampoline
functions.

As a consequence of this change many of the Pascal value and type
printing helper functions have become member functions within the
pascal_language class.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* p-exp.y (exp): Update call to pascal_is_string_type.
(pascal_parse): Rename to...
(pascal_language::parser): ...this.
* p-lang.c (is_pascal_string_type): Rename to...
(pascal_is_string_type): ...this.
(pascal_one_char): Rename to...
(pascal_language::print_one_char): ...this.
(pascal_printchar): Rename to...
(pascal_language::printchar): ...this.  Update call to
print_one_char member function.
(pascal_op_print_tab): Rename to...
(pascal_language::op_print_tab): ...this.
(class pascal_language): Moved to p-lang.h.
(pascal_language::language_arch_info): Function implementation
moved out of class declaration.
(pascal_language::printstr): Likewise.
* p-lang.h (pascal_parse): Delete declaration.
(pascal_is_string_type): Declare.
(pascal_print_type): Delete declaration.
(pascal_print_typedef): Delete declaration.
(pascal_value_print_inner): Delete declaration.
(pascal_value_print): Delete declaration.
(pascal_type_print_method_args): Delete declaration.
(is_pascal_string_type): Delete declaration.
(pascal_printchar): Delete declaration.
(pascal_builtin_types): Delete declaration.
(pascal_type_print_base): Delete declaration.
(pascal_type_print_varspec_prefix): Delete declaration.
(class pascal_language): Moved here from p-lang.c.
* p-typeprint.c (pascal_type_print_varspec_suffix): Delete
declaration.
(pascal_type_print_derivation_info): Delete declaration.
(pascal_print_type): Rename to...
(pascal_language::print_type): ...this.  Update calls to member
functions.
(pascal_print_typedef): Rename to...
(pascal_language::print_typedef): ...this.  Update calls to member
functions.
(pascal_type_print_derivation_info): Rename to...
(pascal_language::type_print_derivation_info): ...this.
(pascal_type_print_method_args): Rename to...
(pascal_language::type_print_method_args): ...this.
(pascal_type_print_varspec_prefix): Rename to...
(pascal_language::type_print_varspec_prefix): ...this.  Update
calls to member functions.
(pascal_print_func_args): Rename to...
(pascal_language::print_func_args): ...this.  Update calls to
member functions.
(pascal_type_print_func_varspec_suffix): Rename to...
(pascal_language::type_print_func_varspec_suffix): ...this.
Update calls to member functions.
(pascal_type_print_varspec_suffix): Rename to...
(pascal_language::type_print_varspec_suffix): ...this.  Update
calls to member functions.
(pascal_type_print_base): Rename to...
(pascal_language::type_print_base): ...this.  Update calls to
member functions.
* p-valprint.c (pascal_value_print_inner): Rename to...
(pascal_language::value_print_inner): ...this.  Update calls to
member functions.
(pascal_value_print): Rename to...
(pascal_language::value_print): ...this.  Update calls to member
functions.

3 years agogdb: move go_language class declaration into header file
Andrew Burgess [Tue, 20 Oct 2020 13:03:42 +0000 (14:03 +0100)]
gdb: move go_language class declaration into header file

Move the go_language class into go-lang.h, this allows us to have
member functions implemented directly in the different go-*.c files
instead of having to trampoline out to global functions.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* go-exp.y (go_parse): Rename to...
(go_language::parser): ...this.
* go-lang.c (go_demangle): Rename to...
(go_language::demangle_symbol): ...this.
(go_language::expression_ops): Implementation moved here out of
class declaration.
(go_op_print_tab): Rename to...
(go_language::op_print_tab): ...this, update comment.
(class go_language): Declaration moved to go-lang.h.
(go_language::language_arch_info): Implementation moved here out
of class declaration.
* go-lang.h (go_parse): Delete declaration.
(go_demangle): Delete declaration.
(go_print_type): Delete declaration.
(go_value_print_inner): Delete declaration.
(class go_language): Declaration moved here from go-lang.c.
* go-typeprint.c (go_print_type): Rename to...
(go_language::print_type): ...this.
* go-valprint.c (go_value_print_inner): Rename to...
(go_language::value_print_inner): ...this.
* symtab.c (demangle_for_lookup): Call demangle_symbol method on
the go_language object.

3 years agogdb: remove LA_EMIT_CHAR macro
Andrew Burgess [Tue, 20 Oct 2020 12:41:18 +0000 (13:41 +0100)]
gdb: remove LA_EMIT_CHAR macro

Now that every use of the LA_EMIT_CHAR macro is within a language_defn
member function we can simply call the emitchar member function
directly instead of using the LA_EMIT_CHAR macro.

If we are ever inside a language object, for example, cplus_language,
while current_language points at something other than cplus_language
then this commit will result in a change in behaviour.  However, I
believe if we did have such a difference then this would be a bug in
GDB.  AS such I'm going to claim there _should_ be no user visible
changes from this commit.

gdb/ChangeLog:

* c-lang.c (language_defn::printchar): Call emitchar, not
LA_EMIT_CHAR.
* f-lang.h (f_language::printchar): Likewise.
* language.h (LA_EMIT_CHAR): Delete macro.
* rust-lang.c (rust_language::printchar): Call emitchar, not
LA_EMIT_CHAR.

3 years agogdb: rename c_printchar as language_defn::printchar
Andrew Burgess [Tue, 20 Oct 2020 12:33:36 +0000 (13:33 +0100)]
gdb: rename c_printchar as language_defn::printchar

This commit removes the global function c_printchar and moves the
implementation into language_defn::printchar.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* c-lang.c (c_printchar): Rename to...
(language_defn::printchar): ...this.
* c-lang.h (c_printchar): Delete declaration.
* language.c (language_defn::printchar): Delete this
implementation.  Is now implemented in c-lang.c.

3 years agogdb: avoid accessing global C++ language implementation functions
Andrew Burgess [Tue, 20 Oct 2020 11:38:42 +0000 (12:38 +0100)]
gdb: avoid accessing global C++ language implementation functions

The function c_printchar is called from two places; it provides the
implementation of language_defn::printchar and it is called from
dwarf2_compute_name.

It would be nice to rename c_printchar as language_defn::printchar and
so avoid the trampoline.

To achieve this, instead of calling c_printchar directly from the
DWARF code, I lookup the C++ language object and call the printchar
member function.

In a later commit I can then rename c_printchar.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* dwarf2/read.c (dwarf2_compute_name): Call methods on C++
language object instead of calling global functions directly.

3 years agogdb: delete unused function print_char_chars
Andrew Burgess [Mon, 19 Oct 2020 16:44:15 +0000 (17:44 +0100)]
gdb: delete unused function print_char_chars

Spotted that print_char_chars appears to be unused, delete it.  There
should be no user visible changes after this commit.

gdb/ChangeLog:

* valprint.c (print_char_chars): Delete definition.
* valprint.h (print_char_chars): Delete declaration.

3 years agoAdd myself to gdb/MAINTAINERS
Samuel Thibault [Wed, 23 Dec 2020 17:21:18 +0000 (17:21 +0000)]
Add myself to gdb/MAINTAINERS

gdb/ChangeLog:

* MAINTAINERS (Write After Approval): Add myself.

3 years agohurd: Add changelog for dca11eb872c9
Samuel Thibault [Wed, 23 Dec 2020 17:18:49 +0000 (17:18 +0000)]
hurd: Add changelog for dca11eb872c9

3 years agohurd: Fix getting VM_MIN/MAX_ADDRESS
Samuel Thibault [Mon, 21 Dec 2020 16:01:07 +0000 (16:01 +0000)]
hurd: Fix getting VM_MIN/MAX_ADDRESS

gnu-nat.c was getting the inclusion of vm_param.h only by luck. We need
to explicitly include it to be sure to get the definitions of
VM_MIN/MAX_ADDRESS.

gdb/ChangeLog:

* gnu-nat.c: Include <mach/vm_param.h>.

3 years agoAutomatic date update in version.in
GDB Administrator [Wed, 23 Dec 2020 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agoRemove trailing white spaces in gdb/frame.{c,h}
Shahab Vahedi [Tue, 22 Dec 2020 17:08:41 +0000 (18:08 +0100)]
Remove trailing white spaces in gdb/frame.{c,h}

gdb/ChangeLog:

* frame.c: Remove trailing white spaces.
* frame.h: Likewise.

3 years agoarc: Make variable name in comments uppercase
Shahab Vahedi [Tue, 22 Dec 2020 11:27:00 +0000 (12:27 +0100)]
arc: Make variable name in comments uppercase

The word "regnum" in comments should be uppercase, because it
reflects a variable name in the code.

gdb/ChangeLog

* arc-linux-tdep.c: Replace "regnum" with "REGNUM" in comments.

3 years agogdb: Add native support for ARC in GNU/Linux
Anton Kolesov [Fri, 14 Feb 2014 07:56:23 +0000 (11:56 +0400)]
gdb: Add native support for ARC in GNU/Linux

With this patch in place it is possible to build a GDB that
can run on ARC (GNU/Linux) hosts for debugging ARC targets.

The "arc-linux-nat.c" is a rather small one that mostly deals
with registers and a few thread related hooks.

v2 [1]:
- Remove "void" from the input of "_initialize_arc_linux_nat ()"

[1] Tom's remark after the first patch
https://sourceware.org/pipermail/gdb-patches/2020-November/173223.html

gdb/ChangeLog:

* Makefile.in (ALLDEPFILES): Add arc-linux-nat.c.
* configure.host (host to gdb names): Add arc*-*-linux*.
* configure.nat (gdb_host_cpu): Add arc.
* arc-linux-nat.c: New.

3 years agoarc: Take into account the REGNUM in supply/collect gdb hooks
Shahab Vahedi [Tue, 10 Nov 2020 18:34:57 +0000 (19:34 +0100)]
arc: Take into account the REGNUM in supply/collect gdb hooks

All the arc_linux_supply_*() target operations and the
arc_linux_collect_v2_regset() in arc-linux-tdep.c were
supplying/collecting all the registers in regcache as if the
REGNUM was set to -1.

The more efficient behavior is to examine the REGNUM and act
accordingly.  That is what this patch does.

gdb/ChangeLog:

* arc-linux-tdep.c (supply_register): New.
(arc_linux_supply_gregset, arc_linux_supply_v2_regset,
arc_linux_collect_v2_regset): Consider REGNUM.

3 years agoarc: Add support for signal frames for Linux targets
Anton Kolesov [Thu, 22 Dec 2016 18:52:16 +0000 (21:52 +0300)]
arc: Add support for signal frames for Linux targets

Implement functions needed to unwind signal frames on ARC Linux targets.

gdb/ChangeLog

* arc-linux-tdep.c (arc_linux_sc_reg_offsets): New static variable.
(arc_linux_is_sigtramp): New function.
(arc_linux_sigcontext_addr): Likewise.
(arc_linux_init_osabi): Use them.

3 years agoarc: Add support for signal handlers
Anton Kolesov [Mon, 22 Aug 2016 16:39:46 +0000 (19:39 +0300)]
arc: Add support for signal handlers

This patch adds the necessary infrastructure to handle signal frames for
ARC architecture.  It is fairly similar to what any other architecture
would have.  Linux specific parts will be in a separate patch.

v2 [1]:
- Make the logic of "arc_sigtramp_frame_sniffer ()" simpler.

[1] Tom's remark for the first version
https://sourceware.org/pipermail/gdb-patches/2020-November/173221.html

gdb/ChangeLog:

* arc-tdep.c (arc_make_sigtramp_frame_cache): New function.
(arc_sigtramp_frame_this_id): Likewise.
(arc_sigtramp_frame_prev_register): Likewise.
(arc_sigtramp_frame_sniffer): Likewise.
(arc_siftramp_frame_unwind): New global variable.
(arc_gdbarch_init): Use sigtramp capabilities.
(arc_dump_tdep): Print sigtramp fields.
* arc-tdep.h (gdbarch_tdep): Add sigtramp fields.

3 years agoAutomatic date update in version.in
GDB Administrator [Tue, 22 Dec 2020 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agoMove enum noside earlier in expression.h
Tom Tromey [Sat, 21 Nov 2020 15:49:10 +0000 (08:49 -0700)]
Move enum noside earlier in expression.h

For the expression rewrite series, I needed to move enum noside
earlier in expression.h.  Because this is a pure move, and because it
seems harmless and uncontroversial to move an enum definition earlier
in a file, I'm pushing it in early, to reduce the size of that series.

Tested by rebuilding.

gdb/ChangeLog
2020-12-21  Tom Tromey  <tom@tromey.com>

* expression.h (enum noside): Move earlier.

3 years agoPreserve gdb_std{out, err, log, targ, targerr} across interpreter_exec_cmd
Peter Waller [Mon, 21 Dec 2020 14:38:07 +0000 (09:38 -0500)]
Preserve gdb_std{out, err, log, targ, targerr} across interpreter_exec_cmd

Calls through interpreter_exec_cmd can cause the output state to be modified in
a way which doesn't get back after the execution.

It looks like the intent is that interp::resume should put things back how they
should be, however, mi_interp::resume modifies gdb_stdout and nothing currently
restores it to the previous state.

To see the broken behaviour:

  gdb -ex starti -ex bt -ex 'interpreter-exec mi echo' -ex bt -ex q echo <<<''

Prior to this patch, on a terminal environment, the first backtrace is
coloured, and the second backtrace is not. The reason is that
stdio_file::can_emit_style_escape becomes false, because the gdb_stdout gets
overwritten in mi_interp::resume and not replaced.

gdb/ChangeLog:

* interps.c (interpreter_exec_cmd): Restore streams pointers.

gdb/testsuite/ChangeLog:

* gdb.base/style-interp-exec-mi.exp: New.
* gdb.base/style-interp-exec-mi.c: New.

Signed-off-by: Peter Waller <p@pwaller.net>
Change-Id: Id87423b262d058857ea9dca5866ca6471741e512

3 years agogdb/testsuite: use gdb_test in gdb.base/list.exp
Simon Marchi [Mon, 21 Dec 2020 14:16:28 +0000 (09:16 -0500)]
gdb/testsuite: use gdb_test in gdb.base/list.exp

Use gdb_test instead of send_gdb + gdb_expect.  Use proc_with_prefix to
help with name uniqueness.

gdb/testsuite/ChangeLog:

* gdb.base/list.exp: Replace send_gdb + gdb_expect with
  gdb_test.  Use proc_with_prefix.

Change-Id: Ieee8fb2c80f596f60397fab7633773a7f8c8c879

3 years agotestsuite, gdb.btrace: fix 32-bit PIE false positives
Markus Metzger [Fri, 4 Dec 2020 09:29:06 +0000 (10:29 +0100)]
testsuite, gdb.btrace: fix 32-bit PIE false positives

For 32-bit position independent executables, GCC generates an extra call to

    __x86.get_pc_thunk.<reg>

which appears in the function call history.  It is correct to appear there
but this confuses the tests, which check for an expected sequence of
functions.

Build with nopie to avoid this complication.

gdb/testsuite/ChangeLog:
2020-12-04  Markus Metzger  <markus.t.metzger@intel.com>

* gdb.btrace/exception.exp: Build with nopie.
* gdb.btrace/function_call_history.exp: Likewise.
* gdb.btrace/unknown_functions.exp: Likewise.

3 years agotestsuite, gdb.btrace: skip multi-inferior.exp on gdbserver targets
Markus Metzger [Fri, 11 Dec 2020 08:55:50 +0000 (09:55 +0100)]
testsuite, gdb.btrace: skip multi-inferior.exp on gdbserver targets

The gdb.btrace/multi-inferior.exp test creates multiple inferiors to check
that recording is per-inferior.

When run with the native-gdbserver board, this test hangs when trying to
add the second inferior over the remote connection.  Skip the test.

Note that the test runs fine with the native-extended-gdbserver board file
and we want to keep testing that configuration.

gdb/testsuite/ChangeLog:
2020-12-11  Markus Metzger  <markus.t.metzger@intel.com>

* gdb.btrace/multi-inferior.exp: Skip if use_gdb_stub.

3 years agotestsuite, gdb.python: make py-record-*.exp test names unique
Markus Metzger [Mon, 14 Dec 2020 13:04:33 +0000 (14:04 +0100)]
testsuite, gdb.python: make py-record-*.exp test names unique

gdb/testsuite/ChangeLog:
2020-12-14  Markus Metzger  <markus.t.metzger@intel.com>

* gdb.python/py-record-btrace.exp: Make test names unique.
* gdb.python/py-record-full.exp: Likewise.

3 years agotestsuite, gdb.btrace: make test names unique
Markus Metzger [Fri, 4 Dec 2020 09:01:29 +0000 (10:01 +0100)]
testsuite, gdb.btrace: make test names unique

gdb/testsuite/ChangeLog:
2020-12-04  Markus Metzger  <markus.t.metzger@intel.com>

* gdb.btrace/data.exp: Make test names unique.
* gdb.btrace/delta.exp: Likewise.
* gdb.btrace/enable.exp: Likewise.
* gdb.btrace/function_call_history.exp: Likewise.
* gdb.btrace/nohist.exp: Likewise.
* gdb.btrace/non-stop.exp: Likewise.
* gdb.btrace/rn-dl-bind.exp: Likewise.
* gdb.btrace/step.exp: Likewise.
* gdb.btrace/stepi.exp: Likewise.
* gdb.btrace/tailcall.exp: Likewise.

3 years agogdb, record: rephrase the 'not recording' error message
Markus Metzger [Thu, 3 Dec 2020 16:04:29 +0000 (17:04 +0100)]
gdb, record: rephrase the 'not recording' error message

When trying to use one of the record commands without having enabled
recording first, GDB gives the error message:

    (gdb) record function-call-history
    No record target is currently active.
    Use one of the "target record-<TAB><TAB>" commands first.

In the record help, however, we say:

    (gdb) help record
    record, rec
    Start recording.

    List of record subcommands:

    record btrace, record b -- Start branch trace recording.
    record delete, record del, record d -- Delete the rest of execution log and start recording it anew.
    record full -- Start full execution recording.
    record function-call-history -- Prints the execution history at function granularity.
    record goto -- Restore the program to its state at instruction number N.
    record instruction-history -- Print disassembled instructions stored in the execution log.
    record save -- Save the execution log to a file.
    record stop, record s -- Stop the record/replay target.

Change the above error message to

    (gdb) record function-call-history
    No recording is currently active.
    Use the "record full" or "record btrace" command first.

to align with the help text.

gdb/ChangeLog:
2020-12-03  Markus Metzger  <markus.t.metzger@intel.com>

* record.c (require_record_target): Rephrase error message.
(info_record_command): Likewise.

gdb/testsuite/ChangeLog:
2020-12-03  Markus Metzger  <markus.t.metzger@intel.com>

* gdb.btrace/enable.exp: Update error message.
* gdb.btrace/multi-inferior.exp: Likewise.
* gdb.btrace/reconnect.exp: Likewise.
* gdb.python/py-record-btrace.exp: Likewise.
* gdb.python/py-record-full.exp: Likewise.

3 years agogdb.texinfo: Document GMP as mandatory requirement to build GDB
Joel Brobecker [Mon, 21 Dec 2020 02:21:41 +0000 (06:21 +0400)]
gdb.texinfo: Document GMP as mandatory requirement to build GDB

gdb/doc/ChangeLog

        * gdb.texinfo (Requirements): Add GMP to list of requirements.

3 years agoAutomatic date update in version.in
GDB Administrator [Mon, 21 Dec 2020 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years ago[gdb/testsuite] Add save_target_board_info
Tom de Vries [Sun, 20 Dec 2020 08:35:36 +0000 (09:35 +0100)]
[gdb/testsuite] Add save_target_board_info

Add a proc save_target_board_info, similar to save_vars, such that we can do:
...
save_target_board_info { multilib_flags } {
    global board
    set board [target_info name]
    unset_board_info multilib_flags
    set_board_info multilib_flags "$override_multilib_flags"
    ...
}
...
and use it in gdb_compile_shlib.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-20  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (save_target_board_info): New proc.
(gdb_compile_shlib): Use save_target_board_info.

3 years agoAutomatic date update in version.in
GDB Administrator [Sun, 20 Dec 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agogold: Move sym declaration just before use
H.J. Lu [Sat, 19 Dec 2020 21:30:39 +0000 (13:30 -0800)]
gold: Move sym declaration just before use

Move sym declaration just before use to avoid -Wmaybe-uninitialized
warning from GCC 11.

PR gold/27097
* incremental.cc (Sized_relobj_incr::do_add_symbols): Move sym
declaration just before use.
(Sized_incr_dynobj::do_add_symbols): Likewise.
* plugin.cc (Sized_pluginobj::do_add_symbols): Likewise.

3 years ago[gdb/testsuite] Introduce supports_scalar_storage_order_attribute
Tom de Vries [Sat, 19 Dec 2020 15:43:17 +0000 (16:43 +0100)]
[gdb/testsuite] Introduce supports_scalar_storage_order_attribute

Introduce support test procs:
- supports_scalar_storage_order_attribute, and
- supports_gnuc
and use them in test-case gdb.base/endianity.exp.

Tested on x86_64-linux with gcc-7.5.0, gcc-4.8.5, and clang 10.0.1.

gdb/testsuite/ChangeLog:

2020-12-19  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (supports_scalar_storage_order_attribute)
(supports_gnuc): New proc.
* gdb.base/endianity.exp: Define TEST_SSO.  Eliminate
test_compiler_info calls.  Add unsupported message.
* gdb.base/endianity.c: Use TEST_SSO.

3 years agoDon't compare types of enum fields
Hannes Domani [Mon, 14 Dec 2020 18:06:38 +0000 (19:06 +0100)]
Don't compare types of enum fields

Comparing types of enum fields results in a crash, because they don't
have a type.

It can be reproduced by comparing the types of 2 instances of the same
enum type in different objects:

enum.h:

    enum e
    {
      zero,
      one,
    };

enum-1.c:

    #include <enum.h>
    int func();
    enum e e1;
    int main()
    {
      return e1 + func();
    }

enum-2.c:

    #include <enum.h>
    enum e e2;
    int func()
    {
      return e2;
    }

$ gcc -g -oenum enum-1.c enum-2.c
$ gdb -q enum.exe
Reading symbols from enum.exe...
(gdb) py print(gdb.parse_and_eval("e1").type==gdb.parse_and_eval("e2").type)

Thread 1 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 6184.0x1cc4]
check_typedef (type=0x0) at C:/src/repos/binutils-gdb.git/gdb/gdbtypes.c:2745
2745      while (type->code () == TYPE_CODE_TYPEDEF)

gdb/ChangeLog:

2020-12-19  Hannes Domani  <ssbssa@yahoo.de>

PR exp/27070
* gdbtypes.c (check_types_equal): Don't compare types of enum fields.

gdb/testsuite/ChangeLog:

2020-12-19  Hannes Domani  <ssbssa@yahoo.de>

PR exp/27070
* gdb.python/compare-enum-type-a.c: New test.
* gdb.python/compare-enum-type-b.c: New test.
* gdb.python/compare-enum-type.exp: New file.
* gdb.python/compare-enum-type.h: New test.

3 years agoWarn about static libs vs. source-highlight only when necessary
Bernd Edlinger [Wed, 16 Dec 2020 18:47:18 +0000 (19:47 +0100)]
Warn about static libs vs. source-highlight only when necessary

Avoid the error message when source-highlight is actually available.

2020-12-19  Bernd Edlinger  <bernd.edlinger@hotmail.de>

* configure.ac: Move the static libs vs. source-highlight
error message to a better place.
* configure: Regenerate.

3 years agoAutomatic date update in version.in
GDB Administrator [Sat, 19 Dec 2020 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agoFix name of main_type field type in pretty printer
Hannes Domani [Fri, 18 Dec 2020 17:35:31 +0000 (18:35 +0100)]
Fix name of main_type field type in pretty printer

It was renamed from type to m_type.

gdb/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

* gdb-gdb.py.in: Fix main_type field name.

3 years agoRemove erroneous 'a' in gdb.register_window_type documentation
Hannes Domani [Fri, 18 Dec 2020 17:31:52 +0000 (18:31 +0100)]
Remove erroneous 'a' in gdb.register_window_type documentation

gdb/doc/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

* python.texi (TUI Windows In Python): Remove erroneous 'a'.

3 years agoAdd address keyword to Value.format_string
Hannes Domani [Fri, 18 Dec 2020 16:23:06 +0000 (17:23 +0100)]
Add address keyword to Value.format_string

This makes it possible to disable the address in the result string:

const char *str = "alpha";

(gdb) py print(gdb.parse_and_eval("str").format_string())
0x404000 "alpha"
(gdb) py print(gdb.parse_and_eval("str").format_string(address=False))
"alpha"

gdb/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

* python/py-value.c (valpy_format_string): Implement address keyword.

gdb/doc/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

* python.texi (Values From Inferior): Document the address keyword.

gdb/testsuite/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

* gdb.python/py-format-string.exp: Add tests for address keyword.

3 years agoFix accessing a method's fields from Python
Hannes Domani [Fri, 18 Dec 2020 15:17:46 +0000 (16:17 +0100)]
Fix accessing a method's fields from Python

Considering this example:

struct C
{
  int func() { return 1; }
} c;
int main()
{
  return c.func();
}

Accessing the fields of C::func, when requesting the function by its
type, works:

(gdb) py print(gdb.parse_and_eval('C::func').type.fields()[0].type)
C * const

But when trying to do the same via a class instance, it fails:

(gdb) py print(gdb.parse_and_eval('c')['func'].type.fields()[0].type)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: Type is not a structure, union, enum, or function type.
Error while executing Python code.

The difference is that in the former the function type is TYPE_CODE_FUNC:

(gdb) py print(gdb.parse_and_eval('C::func').type.code == gdb.TYPE_CODE_FUNC)
True

And in the latter the function type is TYPE_CODE_METHOD:

(gdb) py print(gdb.parse_and_eval('c')['func'].type.code == gdb.TYPE_CODE_METHOD)
True

So this adds the functionality for TYPE_CODE_METHOD as well.

gdb/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

* python/py-type.c (typy_get_composite): Add TYPE_CODE_METHOD.

gdb/testsuite/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

* gdb.python/py-type.exp: Add tests for TYPE_CODE_METHOD.

3 years agogdb: define COFF file offsets with file_ptr
Jameson Nash [Fri, 18 Dec 2020 19:08:53 +0000 (14:08 -0500)]
gdb: define COFF file offsets with file_ptr

The arguments to these functions are file_ptr, so these declarations
were accidentally implicitly down-casting them to signed int. This
allows for reading files between 2 and 4 GB in size in my testing (I
don't have a larger dll currently to test). These may not be natively
supported by Windows, but can appear when using split-dwarf information.

This solves a "can't get string table" error resulting from attempting
to pass a negative offset to bfd_seek. I encountered this occuring while
trying to use a debug file for libLLVM.dll, but searching online reveals
at least one other person may have run into a similar problem with
Firefox?

    https://sourceforge.net/p/mingw-w64/mailman/mingw-w64-public/thread/CA+cU71k2bU0azQxjy4-77ynQj1O+TKmgtaTKe59n7Bjub1y7Tg@mail.gmail.com/

With this patch, the debug file appears to load successfully and I can
see debug information in gdb for the library.

gdb/ChangeLog:

* coffread.c (linetab_offset): Change type to file_ptr.
(linetab_size): Likewise.
(enter_linenos): Change parameter type to file_ptr.
(init_lineno): Likewise.
(init_stringtab): Likewise.
(coff_symtab_read): Likewise.
(coff_symfile_read): Change variable types to file_ptr.

Change-Id: I6ae3bf31efc51c826734ade6731ea6b1c32129f3

3 years agoRun fixed_points.exp with -fgnat-encodings=minimal
Tom Tromey [Fri, 18 Dec 2020 15:48:36 +0000 (08:48 -0700)]
Run fixed_points.exp with -fgnat-encodings=minimal

This changes the test case gdb.ada/fixed_points.exp to also be run
with -fgnat-encodings=minimal.  This change pointed out that the test
case had a few incorrect expected outputs; these are fixed as well.

Note that the Overprecise_Object test only uses the non-legacy output
with GCC trunk.

gdb/testsuite/ChangeLog
2020-12-18  Tom Tromey  <tromey@adacore.com>

* gdb.ada/fixed_points.exp: Also run with
-fgnat-encodings=minimal.  Update expected output.

3 years agold: Build and install only unversioned libdep
H.J. Lu [Fri, 18 Dec 2020 12:30:47 +0000 (04:30 -0800)]
ld: Build and install only unversioned libdep

Build only unversioned libdep and remove the installed libdep.la since
only a single libdep.so is needed.

PR ld/27082
* Makefile.am
(libdep_la_LDFLAGS): Add -module -avoid-version.
(libdep_la_LINK): New.
(install-data-local): Depend on $(install-bfdpluginLTLIBRARIES)
and remove libdep.la.

3 years agoelf: Copy elf_gnu_osabi_retain only for relocatable link
H.J. Lu [Fri, 18 Dec 2020 12:24:26 +0000 (04:24 -0800)]
elf: Copy elf_gnu_osabi_retain only for relocatable link

Copy elf_gnu_osabi_retain from input only for relocatable link since
SHF_GNU_RETAIN has no impact on non-relocatable outputs.

bfd/

PR ld/27091
* elflink.c (elf_link_input_bfd): Copy elf_gnu_osabi_retain
from input only for relocatable link.

ld/

PR ld/27091
* testsuite/ld-elf/retain7.s: New file.
* testsuite/ld-elf/retain7a.d: Likewise.
* testsuite/ld-elf/retain7b.d: Likewise.

3 years agoAssorted tidies
Alan Modra [Thu, 17 Dec 2020 23:08:00 +0000 (09:38 +1030)]
Assorted tidies

bfd/
* elf32-microblaze.c (dbg): Delete unused variable.
* elf32-nds32.c (relax_group_section_id_list): Make static.
* som.c (reloc_queue): Make static.
* xtensa-isa.c (xtisa_errno, xtisa_error_msg): Make static.
include/
* xtensa-isa-internal.h (xtisa_errno, xtisa_error_msg): Delete.

3 years agoRemove some static buffers
Alan Modra [Thu, 17 Dec 2020 12:51:11 +0000 (23:21 +1030)]
Remove some static buffers

Fixes possible overflow of a static buffer for powerpc with translated
messages, and on v850 when symbol names are large.

* archive.c (_bfd_ar_spacepad, _bfd_ar_sizepad): Use auto buf.
* coff-mcore.c (coff_mcore_relocate_section): Likewise.
* elf32-ppc.c (ppc_elf_unhandled_reloc): Use asprintf in place
of fixed size and possibly too small buf for translated message.
* elf64-ppc.c (ppc64_elf_unhandled_reloc): Likewise.
* elf32-v850.c (v850_elf_check_relocs): Likewise.
* ecoff.c (ecoff_type_to_string): Pass in return string buff rather
than using static buffer2.  Delete dead code.  Remove unnecessary
parentheses.
(_bfd_ecoff_print_symbol): Pass auto buff to ecoff_type_to_string.
* elf32-rx.c (describe_flags): Pass in return string buf rather
than using static buf.
(rx_elf_merge_private_bfd_data): Pass buf to describe_flags.
(rx_elf_print_private_bfd_data): Likewise.
* mach-o.c (cpusubtype): Pass in return string buffer rather than
using static buffer.
(bfd_mach_o_bfd_print_private_bfd_data): Pass buff to cpusubtype.
* opncls.c (separate_debug_file_exists): Make buffer an auto var.
(bfd_fill_in_gnu_debuglink_section): Likewise.
* peXXigen.c (rsrc_resource_name): Pass in return string buffer
rather than using static buffer.
(rsrc_sort_entries): Pass buff to rsrc_resource_name.
* vms-alpha.c (_bfd_vms_write_emh): Pass tbuf to get_vms_time_string.
* vms-misc.c (get_vms_time_string): Pass in return string tbuf
rather than using static tbuf.
* vms.h (get_vms_time_string): Update prototype.

3 years agoConstify more arrays
Alan Modra [Wed, 16 Dec 2020 22:03:39 +0000 (08:33 +1030)]
Constify more arrays

bfd/
* coff-z80.c (bfd_howto_type): Make typedef const.
* elf32-z80.c (bfd_howto_type): Likewise.
* elf32-m32c.c (EncodingTable): Likewise.
* elf32-csky.c (csky_arch_for_merge): Likewise.
(csky_archs): Use typedef.
* elf32-m68hc11.c (m68hc11_direct_relax_table): Make const.
(find_relaxable_insn, m68hc11_elf_relax_section): Adjust to suit.
* elf32-ppc.c (ppc_alt_plt): Make const.
* elf32-rl78.c (relax_addr16): Likewise.
* targets.c (_bfd_associated_vector): Likewise.
(bfd_target_vector, bfd_associated_vector): Likewise.
* libbfd-in.h (bfd_target_vector, bfd_associated_vector): Likewise.
* libbfd.h: Regenerate.
include/
* opcode/arc-attrs.h (CONFLICT_LIST): Make const.

3 years agoStatically initialise target common sections
Alan Modra [Wed, 16 Dec 2020 21:14:48 +0000 (07:44 +1030)]
Statically initialise target common sections

This tidies initialisation of target common sections, doing so using a
static initialiser rather than via code and deleting unnecessary
symbol_ptr_ptr variables (the one in asection is used instead).

The patch also initialises ecoff.c:bfd_debug_section using
BFD_FAKE_SECTION.  That does change bfd_debug_section slightly,
output_section was NULL now bfd_debug_section, and symbol_ptr_ptr
was NULL now &bfd_debug_section.symbol, but I believe those changes
are safe.

bfd/
* ecoff.c (bfd_debug_section): Init using BFD_FAKE_SECTION.
(ecoff_scom_section, ecoff_scom_symbol): Statically init using
BFD_FAKE_SECTION and GLOBAL_SYM_INIT.  Delete initialisation code.
(ecoff_scom_symbol_ptr): Delete.
* elf32-m32r.c (m32r_elf_scom_section, m32r_elf_scom_symbol),
(m32r_elf_scom_symbol_ptr),
* elf32-score.c (score_elf_scom_section, score_elf_scom_symbol),
(score_elf_scom_symbol_ptr),
* elf32-score7.c (score_elf_scom_section, score_elf_scom_symbol),
(score_elf_scom_symbol_ptr),
* elf32-tic6x.c (tic6x_elf_scom_section, tic6x_elf_scom_symbol),
(tic6x_elf_scom_symbol_ptr),
* elf32-v850.c (v850_elf_scom_section, v850_elf_scom_symbol),
(v850_elf_scom_symbol_ptr),
(v850_elf_tcom_section, v850_elf_tcom_symbol),
(v850_elf_tcom_symbol_ptr),
(v850_elf_zcom_section, v850_elf_zcom_symbol),
(v850_elf_zcom_symbol_ptr),
* elf64-mmix.c (mmix_elf_reg_section, mmix_elf_reg_section_symbol),
(mmix_elf_reg_section_symbol_ptr),
* elfxx-mips.c (mips_elf_scom_section, mips_elf_scom_symbol),
(mips_elf_scom_symbol_ptr): Likewise.
gas/
* ecoff.c (ecoff_frob_symbol): Rename scom_section to
ecoff_scom_section and statically initialise.

3 years agoAutomatic date update in version.in
GDB Administrator [Fri, 18 Dec 2020 00:00:17 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agoRemove a use of n_spaces
Tom Tromey [Thu, 17 Dec 2020 20:37:20 +0000 (13:37 -0700)]
Remove a use of n_spaces

While removing printfi_filtered, I found a spot that used n_spaces
where the now-ordinary "%*s" approach would do.  This patch makes this
change.

Tested on x86-64 Fedora 32.

gdb/ChangeLog
2020-12-17  Tom Tromey  <tromey@adacore.com>

* printcmd.c (print_variable_and_value): Don't use n_spaces.

3 years agoRemove printfi_filtered and fprintfi_filtered
Tom Tromey [Thu, 17 Dec 2020 20:29:38 +0000 (13:29 -0700)]
Remove printfi_filtered and fprintfi_filtered

After seeing Simon's patch, I thought maybe it was finally time to
remove printfi_filtered and fprintfi_filtered, in favor of using the
"%*s" approach to indenting.

In this patch I took the straightforward approach of always adding a
leading "%*s", even when the format already started with "%s", to
avoid the trickier form of:

    printf ("%*s", -indent, string)

Regression tested on x86-64 Fedora 32.
Let me know what you think.

gdb/ChangeLog
2020-12-17  Tom Tromey  <tromey@adacore.com>

* gdbtypes.c (print_args, dump_fn_fieldlists, print_cplus_stuff)
(print_gnat_stuff, print_fixed_point_type_info)
(recursive_dump_type): Update.
* go32-nat.c (go32_sysinfo, display_descriptor): Update.
* c-typeprint.c (c_type_print_base_struct_union)
(c_type_print_base_1): Update.
* rust-lang.c (rust_internal_print_type): Update.
* f-typeprint.c (f_language::f_type_print_base): Update.
* utils.h (fprintfi_filtered, printfi_filtered): Remove.
* m2-typeprint.c (m2_record_fields): Update.
* p-typeprint.c (pascal_type_print_base): Update.
* compile/compile-loc2c.c (push, pushf, unary, binary)
(do_compile_dwarf_expr_to_c): Update.
* utils.c (fprintfi_filtered, printfi_filtered): Remove.

3 years agogdb/doc: fix "show check range" command name
Simon Marchi [Thu, 17 Dec 2020 14:39:33 +0000 (09:39 -0500)]
gdb/doc: fix "show check range" command name

gdb/doc/ChangeLog:

PR gdb/27088
* gdb.texinfo (Range Checking): Fix "show check range" command
name.

Change-Id: I0248ef76d205ac49ed71b813aafe3e630c2ffc2e

3 years agoChange parameters to language_defn::post_parser
Tom Tromey [Wed, 16 Dec 2020 22:49:40 +0000 (15:49 -0700)]
Change parameters to language_defn::post_parser

In the expression rewrite, Ada type resolution will be done at parse
time rather than in a post-parse pass.  At this point,
language_defn::post_parser will be removed.  However, for this to
work, the information available to post_parser must be made available
during the actual parse.

This patch refactors this code slightly to make this possible.  In
particular, "void_context_p" is passed to the parser_state
constructor, and the parser state is then passed to the post_parser
method.

gdb/ChangeLog
2020-12-16  Tom Tromey  <tom@tromey.com>

* rust-exp.y (rust_lex_tests): Update.
* parser-defs.h (parser_state): Add void_p parameter.
<void_context_p>: New member.
* parse.c (parse_exp_in_context): Update.
* language.h (language_defn::post_parser): Remove void_context_p,
completing, tracker parameters.  Add parser state.
* ada-lang.c (ada_language::post_parser): Update.

3 years agoAutomatic date update in version.in
GDB Administrator [Thu, 17 Dec 2020 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agoChange void_context_p to bool
Tom Tromey [Wed, 16 Dec 2020 22:12:55 +0000 (15:12 -0700)]
Change void_context_p to bool

This patch changes void_context_p to bool, as a prerequisite to the
change to post_parser that I submitted here:

https://sourceware.org/pipermail/gdb-patches/2020-December/174080.html

Tested by rebuilding.

Note that nothing in-tree passes true here.  I don't know why this is,
but there is a use of this internally in AdaCore's tree.  I will try
to submit that patch, if it is needed.  (And if not, I will come back
around and remove this.)

gdb/ChangeLog
2020-12-16  Tom Tromey  <tom@tromey.com>

* parse.c (parse_exp_1, parse_expression_for_completion): Update.
(parse_exp_in_context): Change void_context_p to bool.
* language.h (struct language_defn) <post_parser>: Change
void_context_p to bool.
* ada-lang.c (class ada_language) <post_parser>: Update.

3 years agogdb/testsuite: make some tests in gdb.base enable non-stop using GDBFLAGS
Simon Marchi [Wed, 16 Dec 2020 21:43:18 +0000 (16:43 -0500)]
gdb/testsuite: make some tests in gdb.base enable non-stop using GDBFLAGS

For the same reason as explained in commit 7cb2893dfab1 ("gdb/testsuite:
gdb.mi/mi-nonstop-exit.exp: enable non-stop using GDBFLAGS").

Note that the use of

    set GDBFLAGS "$GDBFLAGS ..."

instead of

    append GDBFLAGS "..."

is intentional.  "append" is silent when appending to a non-existent
variable.  So if this code if moved to a proc (as is the case already
for step-sw-breakpoint-adjust-pc.exp) and we forget to add "global
GDBFLAGS", the flag won't be added to the global GDBFLAGS, and we won't
actually enable non-stop, and it might go unnoticed.  Using the "set"
version will turn into an error if we forget the "global".

This makes these test work correctly with native-extended-gdbserver.
Some of them were silently failing because we runto_main is silent when
it fails.

gdb/testsuite/ChangeLog:

* gdb.base/async-shell.exp: Enable non-stop through GDBFLAGS.
* gdb.base/continue-all-already-running.exp: Likewise.
* gdb.base/moribund-step.exp: Likewise.
* gdb.base/step-sw-breakpoint-adjust-pc.exp: Likewise.

Change-Id: I19ef05d07a0ec4a9c9476af2ba6e1ea1159ee437

3 years agold: Skip libdep plugin if not all plugin hooks are available
H.J. Lu [Wed, 16 Dec 2020 21:40:42 +0000 (13:40 -0800)]
ld: Skip libdep plugin if not all plugin hooks are available

Skip plugin if not all required plugin hooks are available.

2020-12-16  Howard Chu <hyc@symas.com>
    H.J. Lu  <hongjiu.lu@intel.com>

PR ld/27081
* libdep_plugin.c (onload): Skip if not all required plugin hooks
are available.
* testsuite/config/default.exp (dep_plug_opt): New.
* testsuite/ld-elf/elf.exp: Pass $dep_plug_opt to nm.
* testsuite/ld-elf/pr26391.fd: New file.

3 years ago[gdb/testsuite] Fix prompt regexp in batch-preserve-term-settings.exp
Tom de Vries [Wed, 16 Dec 2020 20:32:59 +0000 (21:32 +0100)]
[gdb/testsuite] Fix prompt regexp in batch-preserve-term-settings.exp

On openSUSE Leap 15.2, when running test-case
gdb.base/batch-preserve-term-settings.exp I get:
...
spawn /bin/sh^M
PS1="gdb-subshell$ "^M
sh-4.4$ PS1="gdb-subshell$ "^M
gdb-subshell$ PASS: gdb.base/batch-preserve-term-settings.exp: batch run: \
  spawn shell
...
but on Ubuntu 18.04.5, I get instead:
...
spawn /bin/sh^M
PS1="gdb-subshell$ "^M
$ gdb-subshell$ FAIL: gdb.base/batch-preserve-term-settings.exp: batch run: \
  spawn shell (timeout)
...

Fix this by making the regexp recognize the second pattern as well.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-16  Tom de Vries  <tdevries@suse.de>

* gdb.base/batch-preserve-term-settings.exp:

3 years ago[gdb] Print progress for debuginfod
Martin Liska [Wed, 16 Dec 2020 17:18:40 +0000 (18:18 +0100)]
[gdb] Print progress for debuginfod

Prints progress like:

Downloading 4.89 MB separate debug info for /usr/lib64/libgcrypt.so.20.
Downloading 1.10 MB separate debug info for /usr/lib64/liblzma.so.5.
Downloading 1.31 MB separate debug info for /usr/lib64/liblz4.so.1.
Downloading 0.96 MB separate debug info for /usr/lib64/libsmime3.so.
[###                                                                    ]

Tested on x86_64-linux.

ChangeLog:

2020-12-16  Martin Liska  <mliska@suse.cz>
    Tom de Vries  <tdevries@suse.de>

* gdb/debuginfod-support.c (struct user_data): Remove has_printed
field.  Add meter field.
(progressfn): Print progress using meter.

3 years ago[gdb/cli] Add a progress meter
Tom Tromey [Wed, 16 Dec 2020 17:18:40 +0000 (18:18 +0100)]
[gdb/cli] Add a progress meter

Add a progress meter.  It's not used anywhere yet.

gdb/ChangeLog:

2020-12-16  Tom Tromey  <tom@tromey.com>
    Tom Tromey  <tromey@redhat.com>
    Tom de Vries  <tdevries@suse.de>

* utils.h (get_chars_per_line): Declare.
* utils.c (get_chars_per_line): New function.
(fputs_maybe_filtered): Handle '\r'.
* ui-out.h (ui_out::progress_meter): New class.
(ui_out::progress, ui_out::do_progress_start)
(ui_out::do_progress_notify, ui_out::do_progress_end): New
methods.
* ui-out.c (do_progress_end)
(make_cleanup_ui_out_progress_begin_end, ui_out_progress): New
functions.
* mi/mi-out.h (mi_ui_out::do_progress_start)
(mi_ui_out::do_progress_notify, mi_ui_out::do_progress_end): New
methods.
* cli-out.h (struct cli_ui_out) <do_progress_start,
do_progress_notify, do_progress_end>: New methods.
<enum meter_stat, struct cli_progress_info>: New.
<m_meters>: New member.
* cli-out.c (cli_ui_out::do_progress_start)
(cli_ui_out::do_progress_notify, cli_ui_out::do_progress_end): New
methods.

3 years ago[gdb/testsuite] Fix shlib compilation with target board unix/-pie/-fPIE
Tom de Vries [Wed, 16 Dec 2020 17:18:40 +0000 (18:18 +0100)]
[gdb/testsuite] Fix shlib compilation with target board unix/-pie/-fPIE

When running test-case gdb.base/info-shared.exp with target board
unix/-pie/-fPIE, we run into:
...
spawn -ignore SIGHUP gcc -fno-stack-protector \
  outputs/gdb.base/info-shared/info-shared-solib1.c.o \
  -fdiagnostics-color=never -fPIC -shared -Wl,-soname,info-shared-solib1.so \
  -lm -fPIE -pie -o outputs/gdb.base/info-shared/info-shared-solib1.so^M
ld: Scrt1.o: in function `_start':^M
start.S:104: undefined reference to `main'^M
collect2: error: ld returned 1 exit status^M
compiler exited with status 1
...

The intention of the -pie/-fPIE flags is to build and test PIE executables on
platforms where that is not the default.  However, the flags clash with the
flags required to build shared libraries.

Fix this by filtering out PIE-related flags out of the multilib_flags settings
in compile_shared_lib.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-16  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (gdb_compile_shlib_1): Factor out of ...
(gdb_compile_shlib): ... here.  Filter out PIE-related flags.

3 years agoRecord FPSR for SIMD/FP data instructions
Luis Machado [Mon, 14 Dec 2020 14:40:01 +0000 (11:40 -0300)]
Record FPSR for SIMD/FP data instructions

I noticed this failure in gdb.reverse/reverse-insn.exp:

FAIL: gdb.reverse/insn-reverse.exp: adv_simd_vect_shift: compare registers on insn 0:fcvtzs     s0, s0, #1

Turns out we're not recording changes to the FPSR.  The SIMD/FP data
instructions may set bits in the FPSR, so it needs to be recorded for
proper reverse operations.

gdb/ChangeLog:

2020-12-16  Luis Machado  <luis.machado@linaro.org>

* aarch64-tdep.c (aarch64_record_data_proc_simd_fp): Record FPSR.

3 years agoFix TBI handling for watchpoints
Luis Machado [Thu, 10 Dec 2020 19:51:20 +0000 (16:51 -0300)]
Fix TBI handling for watchpoints

When inserting hw watchpoints, we take care of masking off the top byte
of the address (and sign-extending it if needed).  This guarantees we won't
pass tagged addresses to the kernel via ptrace.

However, from the kernel documentation on tagged pointers...

"Non-zero tags are not preserved when delivering signals. This means that
signal handlers in applications making use of tags cannot rely on the tag
information for user virtual addresses being maintained for fields inside
siginfo_t.

One exception to this rule is for signals raised in response to watchpoint
debug exceptions, where the tag information will be preserved."

So the stopped data address after a hw watchpoint hit can be potentially
tagged, and we don't handle this in GDB at the moment.  This results in
GDB missing a hw watchpoint hit and attempting to step over an unsteppable
hw watchpoint, causing it to spin endlessly.

The following patch fixes this by adjusting the stopped data address and adds
some tests to expose the problem.

gdb/ChangeLog:

2020-12-16  Luis Machado  <luis.machado@linaro.org>

* aarch64-linux-nat.c
(aarch64_linux_nat_target::stopped_data_address): Handle the TBI.

gdbserver/ChangeLog:

2020-12-16  Luis Machado  <luis.machado@linaro.org>

* linux-aarch64-low.cc (address_significant): New function.
(aarch64_target::low_stopped_data_address): Handle the TBI.

gdb/testsuite/ChangeLog:

2020-12-16  Luis Machado  <luis.machado@linaro.org>

* gdb.arch/aarch64-tagged-pointer.c (main): Add a few more
pointer-based memory accesses.
* gdb.arch/aarch64-tagged-pointer.exp: Exercise additional
hw watchpoint cases.

3 years agoconstify elfNN_bed
Alan Modra [Tue, 15 Dec 2020 14:12:21 +0000 (00:42 +1030)]
constify elfNN_bed

elfNN_bed was made writable as an expedient means of communicating
ld -z max-page-size and ld -z common-page-size values to BFD linker
code, and even for objcopy to communicate segment alignment between
copy_private_bfd_data, rewrite_elf_program_header and
assign_file_positions_for_load_sections.  Some time later elfNN_bed
elf_osabi was written by gas.  It turns out none of these
modifications to elfNN_bed was necessary, so make it const again.

include/
* bfdlink.h (struct bfd_link_info): Add maxpagesize and
commonpagesize.
bfd/
* elfxx-target.h (elfNN_bed): Constify.
* bfd.c (bfd_elf_set_pagesize): Delete.
(bfd_emul_set_maxpagesize, bfd_emul_set_commonpagesize): Delete.
* elf.c (get_program_header_size): Get commonpagesize from
link info.
(_bfd_elf_map_sections_to_segments): Get maxpagesize from link info.
(assign_file_positions_for_load_sections): Likewise.
(assign_file_positions_for_non_load_sections): Likewise.
(rewrite_elf_program_header): Add maxpagesize param.  Set map_p_align.
(copy_private_bfd_data): Don't call bfd_elf_set_maxpagesize.
Instead pass maxpagesize to rewrite_elf_program_header.
* elf32-nds32.c (relax_range_measurement): Add link_info param.
Get maxpagesize from link_info.  Adjust caller.
* bfd-in2.h: Regenerate.
gas/
* config/obj-elf.c (obj_elf_section): Don't set elf_osabi here.
(obj_elf_type): Likewise.
ld/
* ld.h (ld_config_type): Delete maxpagesize and commonpagesize.
* emultempl/elf.em: Use link_info rather than config
for maxpagesize and commonpagesize.
* emultempl/ppc32elf.em: Likewise.
* ldexp.c (fold_binary, fold_name): Likewise.
* ldemul.c (after_parse_default): Likewise.
(set_output_arch_default): Don't call bfd_emul_set_maxpagesize
or bfd_emul_set_commonpagesize.

3 years agoelflink.c constify
Alan Modra [Tue, 15 Dec 2020 14:10:15 +0000 (00:40 +1030)]
elflink.c constify

* elflink.c (elf_flags_to_names): Constify.

3 years agoXCOFF constify
Alan Modra [Tue, 15 Dec 2020 11:40:27 +0000 (22:10 +1030)]
XCOFF constify

There are occasions where it is reasonable to use a macro defining
function parameters, but this isn't one of them.  Use typedefs
instead, which also simplifies declaring a const array of function
pointers.

* libxcoff.h (struct xcoff_backend_data_rec): Constify
_xcoff_glink_code.
(XCOFF_RELOC_FUNCTION_ARGS, XCOFF_COMPLAIN_FUNCTION_ARGS): Delete.
(xcoff_reloc_function, xcoff_complain_function): New typedef.
(xcoff_calculate_relocation, xcoff_complain_overflow),
(xcoff_reloc_type_noop, xcoff_reloc_type_fail),
(xcoff_reloc_type_pos, xcoff_reloc_type_neg),
(xcoff_reloc_type_rel, xcoff_reloc_type_toc),
(xcoff_reloc_type_ba, xcoff_reloc_type_crel): Update declaration.
* coff-rs6000.c (xcoff_reloc_type_br): Declare using typedef.
(xcoff_complain_overflow_dont_func): Likewise.
(xcoff_complain_overflow_bitfield_func): Likewise.
(xcoff_complain_overflow_signed_func): Likewise.
(xcoff_complain_overflow_unsigned_func): Likewise.
(xcoff_calculate_relocation, xcoff_complain_overflow): Constify.
(xcoff_glink_code): Constify.
* coff64-rs6000.c (xcoff64_reloc_type_br): Declare using typedef.
(xcoff64_calculate_relocation, xcoff64_glink_code): Constify.

3 years agoxtensa constify
Alan Modra [Tue, 15 Dec 2020 11:39:06 +0000 (22:09 +1030)]
xtensa constify

Move lots of read-only arrays to .rodata.

include/
* xtensa-isa-internal.h (xtensa_format_internal),
(xtensa_slot_internal, xtensa_operand_internal),
(xtensa_arg_internal, xtensa_iclass_internal),
(xtensa_opcode_internal, xtensa_regfile_internal),
(xtensa_interface_internal, xtensa_funcUnit_internal),
(xtensa_state_internal, xtensa_sysreg_internal): Constify.
bfd/
* elf32-xtensa.c (narrowable, widenable): Constify.
* xtensa-modules.c: Constify many arrays.

3 years agoppc64 constify
Alan Modra [Tue, 15 Dec 2020 11:38:46 +0000 (22:08 +1030)]
ppc64 constify

Nothing to see here.

* elf64-ppc.c (synthetic_opd): Constify.

3 years agoarc constify
Alan Modra [Tue, 15 Dec 2020 11:38:20 +0000 (22:08 +1030)]
arc constify

Move a read-only array to .rodata.

* arc-plt.h (plt_versions): Constify.
* elf32-arc.c (arc_get_plt_version): Constify return pointer,
adjust uses throughout.

3 years agoLose some COFF/PE static vars, and peicode.h constify
Alan Modra [Tue, 15 Dec 2020 11:39:30 +0000 (22:09 +1030)]
Lose some COFF/PE static vars, and peicode.h constify

This patch tidies some COFF and PE code that unnecessarily used static
variables to communicate between functions.

* coffcode.h (pelength, peheader): Delete static variables.
(coff_apply_checksum): Instead, define them as auto vars, and pass..
(coff_read_word, coff_compute_checksum): ..to here.  Delete
unnecessary forward declarations.
* pei-x86_64.c (pdata_count): Delete static variable.
(struct pex64_paps): New.
(pex64_print_all_pdata_sections, pex64_bfd_print_pdata): Pass
a pex64_paps for counting.
* peicode.h (jtab): Constify.

3 years agogdb: multi-line support for "document" command
Rae Kim [Wed, 16 Dec 2020 03:51:09 +0000 (22:51 -0500)]
gdb: multi-line support for "document" command

"document" command executed in python, gdb.execute("document
<comname>\n...\nend\n"), will wait for user input. Python extension stops
working from that point.

multi-line suport was introduced in commit 56bcdbea2. But "document" support
seem to be implemented.

gdb/ChangeLog:

2020-12-02  Rae Kim  <rae.kim@gmail.com>

* cli/cli-script.c (do_document_command): Rename from
document_command. Handle multi-line input.
(multi_line_command_p): Handle document_control.
(build_command_line): Likewise.
(execute_control_command_1): Likewise.
(process_next_line): Likewise.
(document_command): Call do_document_command.
* cli/cli-script.h (enum command_control_type): Add
document_control.

gdb/testsuite/ChangeLog:

2020-12-02  Rae Kim  <rae.kim@gmail.com>
* gdb.base/document.exp: New test.

Change-Id: Ice262b980c05051de4c106af9f3fde5b2a6df6fe

3 years agoAdd expected type parameter to evaluate_expression
Tom Tromey [Wed, 16 Dec 2020 01:35:13 +0000 (18:35 -0700)]
Add expected type parameter to evaluate_expression

While working on the expression rewrite, I found a few spots that
called the internal functions of the expression evaluator, just to
pass in an expected type.  This patch adds a parameter to
evaluate_expression so that these functions can avoid this dependency.

Regression tested on x86-64 Fedora 28.

gdb/ChangeLog
2020-12-15  Tom Tromey  <tom@tromey.com>

* stap-probe.c (stap_probe::evaluate_argument): Use
evaluate_expression.
* dtrace-probe.c (dtrace_probe::evaluate_argument): Use
evaluate_expression.
* value.h (evaluate_expression): Add expect_type parameter.
* objc-lang.c (print_object_command): Call evaluate_expression.
* eval.c (evaluate_expression): Add expect_type parameter.

3 years agoIntroduce expression::first_opcode
Tom Tromey [Wed, 16 Dec 2020 01:14:42 +0000 (18:14 -0700)]
Introduce expression::first_opcode

This adds a new helper method, expression::first_opcode, that extracts
the outermost opcode of an expression.  This simplifies some patches
in the expression rewrite series.

Note that this patch requires the earlier patch to avoid manual
dissection of OP_TYPE operations.

2020-12-15  Tom Tromey  <tom@tromey.com>

* varobj.c (varobj_create): Use first_opcode.
* value.c (init_if_undefined_command): Use first_opcode.
* typeprint.c (whatis_exp): Use first_opcode.
* tracepoint.c (validate_actionline): Use first_opcode.
(encode_actions_1): Use first_opcode.
* stack.c (return_command): Use first_opcode.
* expression.h (struct expression) <first_opcode>: New method.
* eval.c (parse_and_eval_type): Use first_opcode.
* dtrace-probe.c (dtrace_process_dof_probe): Use first_opcode.

3 years agoClean up arguments to evaluate_subexp_do_call
Tom Tromey [Wed, 16 Dec 2020 00:53:34 +0000 (17:53 -0700)]
Clean up arguments to evaluate_subexp_do_call

I noticed hat evaluate_subexp_do_call takes an array of arguments and
a count -- but, unlike the usual convention, the count does not
include the first element.

This patch changes this function to match call_function_by_hand --
passing the callee separately, and using an array_view for the
arguments.  This makes it simpler to understand.

Regression tested on x86-64 Fedora 28.

gdb/ChangeLog
2020-12-15  Tom Tromey  <tom@tromey.com>

* f-lang.c (evaluate_subexp_f): Update.
* expression.h (evaluate_subexp_do_call): Update.
* eval.c (evaluate_subexp_do_call): Add callee parameter.  Replace
nargs, argvec with array_view.
(evaluate_funcall): Update.

3 years agoC++-ify Ada component interval handling
Tom Tromey [Wed, 16 Dec 2020 00:39:57 +0000 (17:39 -0700)]
C++-ify Ada component interval handling

The Ada component interval handling code, used for aggregate
assignments, does a pre-pass over the sub-expressions so that it can
size an array.  For my expression rewrite, it was handy to C++-ify
this.

gdb/ChangeLog
2020-12-15  Tom Tromey  <tom@tromey.com>

* ada-lang.c (num_component_specs): Remove.
(assign_aggregate): Update.
(aggregate_assign_positional, aggregate_assign_from_choices)
(aggregate_assign_others, add_component_interval): Change
arguments.

3 years agoAutomatic date update in version.in
GDB Administrator [Wed, 16 Dec 2020 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agoCosmetic improvements for OSABI access.
Cary Coutant [Tue, 15 Dec 2020 22:37:22 +0000 (14:37 -0800)]
Cosmetic improvements for OSABI access.

Add accessor methods to elfcpp::Ehdr class for EI_OSABI and EI_ABIVERSION;
use those to simplify initialization of Osabi class and eliminate the need
to template the class.

elfcpp/
* elfcpp.h (class Ehdr): Add get_ei_osabi and get_ei_abiversion methods.

gold/
* dwp.cc (class Dwo_file): Use new Ehdr::get_ei_osabi and
get_ei_abiversion methods.
* incremental.cc (make_sized_incremental_binary): Likewise.
* object.cc (Sized_relobj_file::Sized_relobj_file): Likewise.
(make_elf_sized_object): Likewise.
* object.h (class Osabi): Make the class untemplated.

3 years agogold: Add missing ChangeLog entries for commit ff4bc37d7
H.J. Lu [Tue, 15 Dec 2020 15:37:59 +0000 (07:37 -0800)]
gold: Add missing ChangeLog entries for commit ff4bc37d7

3 years agoHighlight deprecated commands using title style
Tom Tromey [Tue, 15 Dec 2020 15:07:32 +0000 (08:07 -0700)]
Highlight deprecated commands using title style

After Andrew's latest patch, I noticed that the deprecation warnings
could use the (so-called) title style when printing command names.
This patch implements this idea.

gdb/ChangeLog
2020-12-15  Tom Tromey  <tromey@adacore.com>

* cli/cli-decode.c (deprecated_cmd_warning): Use title style for
command names.

gdb/testsuite/ChangeLog
2020-12-15  Tom Tromey  <tromey@adacore.com>

* gdb.base/style.exp: Add deprecation tests.

3 years agoPR27071, gas bugs uncovered by fuzzing
Alan Modra [Tue, 15 Dec 2020 11:24:09 +0000 (21:54 +1030)]
PR27071, gas bugs uncovered by fuzzing

PR 27071
* config/obj-elf.c (elf_obj_symbol_clone_hook): New function.
(elf_format_ops): Set symbol_clone_hook.
* config/obj-elf.h (elf_obj_symbol_clone_hook): Declare.
(obj_symbol_clone_hook): Define.
* listing.c (buffer_line): Avoid integer overflow on paper_width
set to zero.

3 years agoAdd support for the SDIV and UDIV instructions to the ARM simulator.
Jens Bauer [Tue, 15 Dec 2020 12:40:35 +0000 (12:40 +0000)]
Add support for the SDIV and UDIV instructions to the ARM simulator.

* armemu.c (handle_v6_insn): Add support for SDIV and UDIV.
* thumbemu.c (handle_T2_insn): Likewise.

3 years ago[gdb/testsuite] Handle PS1 quirk in gdb.base/multi-line-starts-subshell.exp
Tom de Vries [Tue, 15 Dec 2020 09:18:23 +0000 (10:18 +0100)]
[gdb/testsuite] Handle PS1 quirk in gdb.base/multi-line-starts-subshell.exp

On SLE-11, I run into:
...
(gdb) if 1^M
 >shell HOME=/dev/null PS1="gdb-subshell$ " /bin/sh^M
 >end^M
hostname:/dir> FAIL: gdb.base/multi-line-starts-subshell.exp: \
  spawn subshell from multi-line (timeout)
...

The problem is that the PS1 setting has no effect, due to a bug on older
openSUSE/SLE version.  The mechanism there is:
- /etc/profile sets ENV=/etc/bash.bashrc
- /bin/sh is started
- /bin/sh executes ENV, in other words /etc/bash.bashrc
- during the execution of /etc/bash.bashrc, PS1 is set unconditionally

Fix this by setting PS1 after spawning the subshell.

Tested on x86_64-linux.

2020-12-15  Tom de Vries  <tdevries@suse.de>

PR testsuite/26952
* gdb.base/multi-line-starts-subshell.exp: Set PS1 after spawning
shell.

3 years agoImplement and document -z unique / -z nounique handling in gold
Vivek Das Mohapatra [Mon, 14 Dec 2020 17:25:55 +0000 (17:25 +0000)]
Implement and document -z unique / -z nounique handling in gold

* layout.cc (Layout::finish_dynamic_section): Set DF_GNU_1_UNIQUE.
* options.h (class General_options): Handle -z unique, -z nounique.

3 years agoDefine DT_GNU_FLAGS_1 and DF_GNU_1_UNIQUE for gold
Vivek Das Mohapatra [Mon, 14 Dec 2020 17:25:54 +0000 (17:25 +0000)]
Define DT_GNU_FLAGS_1 and DF_GNU_1_UNIQUE for gold

* elfcpp.h (enum DT): New enum member DT_GNU_FLAGS_1.
(enum DF_GNU_1): New enum DF_GNU_1 containing DF_GNU_1_UNIQUE.

3 years agoHandle DT_GNU_FLAGS_1 in readelf
Vivek Das Mohapatra [Mon, 14 Dec 2020 17:25:53 +0000 (17:25 +0000)]
Handle DT_GNU_FLAGS_1 in readelf

* readelf.c (get_dynamic_type): Handle DT_GNU_FLAGS_1.
(process_dynamic_section): Likewise.

3 years agoDocument -z unique/-z nounique in the ld man page and help output
Vivek Das Mohapatra [Mon, 14 Dec 2020 17:25:52 +0000 (17:25 +0000)]
Document -z unique/-z nounique in the ld man page and help output

* ld.texi (Options): Document -z unique and -z nounique.
* lexsup.c (elf_shlib_list_options): Likewise.

3 years agoHandle -z unique/-z nounique in ld
Vivek Das Mohapatra [Mon, 14 Dec 2020 17:25:51 +0000 (17:25 +0000)]
Handle -z unique/-z nounique in ld

Add (or suppress) a DT_GNU_FLAGS_1 dynamic section
with a bit flag value of DF_GNU_1_UNIQUE.

bfd/
* elflink.c (bfd_elf_size_dynamic_sections): Call
_bfd_elf_add_dynamic_entry to add a DT_GNU_FLAGS_1 section.
include/
* bfdlink.h (struct bfd_link_info): New field gnu_flags_1.
ld/
* emultempl/elf.em (gld${EMULATION_NAME}_handle_option):
Parse -z unique / -z nounique options.

3 years agoDefine a new DT_GNU_FLAGS_1 dynamic section for ld, readelf et al
Vivek Das Mohapatra [Mon, 14 Dec 2020 17:25:50 +0000 (17:25 +0000)]
Define a new DT_GNU_FLAGS_1 dynamic section for ld, readelf et al

DT_GNU_FLAGS_1 added to the DT_VALRNGLO-DT_VALRNGHI range.
DT_GNU_FLAGS_1 value DF_GNU_1_UNIQUE added.

* elf/common.h (DT_GNU_FLAGS_1, DF_GNU_1_UNIQUE): Define.

3 years agogdb/testsuite: fix typo in gdb_test_multiple doc
Simon Marchi [Tue, 15 Dec 2020 04:45:17 +0000 (23:45 -0500)]
gdb/testsuite: fix typo in gdb_test_multiple doc

gdb/testsuite/ChangeLog:

* lib/gdb.exp (gdb_test_multiple): Fix typo in doc.

Change-Id: Ieb188b3382395ce951bfba5a5f25aaea0f89ebf9

3 years agoAutomatic date update in version.in
GDB Administrator [Tue, 15 Dec 2020 00:00:17 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agoKeep input SHF_GNU_RETAIN sections and strip output SHF_GNU_RETAIN for GNU/FreBSD...
Cary Coutant [Mon, 14 Dec 2020 23:46:47 +0000 (15:46 -0800)]
Keep input SHF_GNU_RETAIN sections and strip output SHF_GNU_RETAIN for GNU/FreBSD ELFOSABIs.

2020-12-14  H.J. Lu  <hjl.tools@gmail.com>
    Cary Coutant  <ccoutant@gmail.com>

elfcpp/
PR gold/27039
* elfcpp.h (SHF): Add SHF_GNU_RETAIN.

gold/
     PR gold/27039
* layout.cc (Layout::layout): Strip SHF_GNU_RETAIN.
* object.cc (Sized_relobj_file::Sized_relobj_file): Initialize osabi_.
(Sized_relobj_file::do_layout): Keep SHF_GNU_RETAIN sections for
GNU/FreBSD ELFOSABIs.
* object.h (Osabi) New class.
(Sized_relobj_file): Add osabi() and osabi_.
* testsuite/Makefile.am (check_SCRIPTS): Add retain.sh.
(check_DATA): Add retain_1.out retain_2.out.
(MOSTLYCLEANFILES): Add retain_1 retain_2.
(retain_1.out): New target.
(retain_1): Likewise.
(retain_1.o): Likewise.
(retain_2.out): Likewise.
(retain_2): Likewise.
(retain_2.o): Likewise.
* testsuite/Makefile.in: Regenerate.
* testsuite/retain.sh: New file.
* testsuite/retain_1.s: Likewise.
* testsuite/retain_2.s: Likewise.

3 years agoAdd form used for SPECIAL_expr as comment in testsuite Dwarf Assembler
Mark Wielaard [Mon, 14 Dec 2020 19:00:50 +0000 (20:00 +0100)]
Add form used for SPECIAL_expr as comment in testsuite Dwarf Assembler

Replace the "SPECIAL_expr" comment with either "DW_FORM_block" or
"DW_FORM_exprloc" in the abbrev.

gdb/testsuite/ChangeLog:

* lib/dwarf.exp (Dwarf::_handle_attribute): Handle SPECIAL_expr
specially, set attr_form_comment to the actual FORM string used.

3 years agoUse DW_FORM_exprloc in testsuite Dwarf Assembler for DWARF version 4+.
Mark Wielaard [Mon, 14 Dec 2020 16:38:09 +0000 (17:38 +0100)]
Use DW_FORM_exprloc in testsuite Dwarf Assembler for DWARF version 4+.

Since DWARF version 4 expressions are represented by DW_FORM_exprloc
instead of a block form. Support this in the testsuite Dwarf Assembler
by setting the SPECIAL_expr form once we know the CU version.

This doesn't change any testsuite results, it just makes the produced
DWARF valid. gdb also accepts expressions in block form for DWARF
version 4 and above, but this is technically incorrect.

gdb/testsuite/ChangeLog:

* lib/dwarf.exp (Dwarf::_read_constants): Don't set
_constants(SPECIAL_expr) here, but set it...
(Dwarf::cu): ...here based on _cu_version.

3 years ago[gdb/testsuite] Don't pass -fPIC to gdb_compile_shlib
Tom de Vries [Mon, 14 Dec 2020 17:16:40 +0000 (18:16 +0100)]
[gdb/testsuite] Don't pass -fPIC to gdb_compile_shlib

When running test-case gdb.base/info-shared.exp, I see in gdb.log:
...
Executing on host: \
  gcc ... -fPIC -fpic -c -o info-shared-solib1.c.o info-shared-solib1.c
...

The -fPIC comes from the test-case:
...
if { [gdb_compile_shlib $srcfile_lib1 $binfile_lib1 \
         [list additional_flags=-fPIC]] != "" } {
...
but the -fpic, which overrides the -fPIC comes from gdb_compile_shlib.

The proc gdb_compile_shlib adds the -fpic or similar dependent on platform
and compiler.  However, in some cases it doesn't add anything, which is
probably why all those test-case pass -fPIC.

Fix this by removing -fPIC from all the calls to gdb_compile_shlib, and
ensuring that gdb_compile_shlib takes care of adding it, if required.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-14  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (gdb_compile_shlib): Make sure it's not necessary to
pass -fPIC.
* gdb.ada/catch_ex_std.exp: Don't pass -fPIC to gdb_compile_shlib.
* gdb.base/break-probes.exp: Same.
* gdb.base/ctxobj.exp: Same.
* gdb.base/dso2dso.exp: Same.
* gdb.base/global-var-nested-by-dso.exp: Same.
* gdb.base/info-shared.exp: Same.
* gdb.base/jit-reader-simple.exp: Same.
* gdb.base/print-file-var.exp: Same.
* gdb.base/skip-solib.exp: Same.
* gdb.btrace/dlopen.exp: Same.

3 years agoDo not manually dissect OP_TYPE operations
Tom Tromey [Mon, 14 Dec 2020 16:43:20 +0000 (09:43 -0700)]
Do not manually dissect OP_TYPE operations

Some code in GDB will examine the structure of an expression to see if
it starts with OP_TYPE, and then proceed to extract the type by hand.

There is no need to do this dissection manually.  evaluate_type does
the same thing via an "allowed" API.

This patch changes such code to use evaluate_type.  In two cases this
simplifies the code.

Regression tested on x86-64 Fedora 28.

gdb/ChangeLog
2020-12-14  Tom Tromey  <tom@tromey.com>

* dtrace-probe.c (dtrace_process_dof_probe): Use value_type.
* typeprint.c (whatis_exp): Always use evaluate_type.
(maintenance_print_type): Likewise.  Simplify.

3 years ago[gdb/testsuite] Handle missing xz in gdb.base/gnu-debugdata.exp
Tom de Vries [Mon, 14 Dec 2020 16:05:11 +0000 (17:05 +0100)]
[gdb/testsuite] Handle missing xz in gdb.base/gnu-debugdata.exp

When running test-case gdb.base/gnu-debugdata.exp on SLE-11, I run into:
...
FAIL: gdb.base/gnu-debugdata.exp: xz
...

The fact that xz is not installed does not mean there's a fail, merely that
the test is unsupported.

Fix this by detecting the "spawn failed" reply in run_on_host and issuing
UNSUPPORTED instead.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-14  Tom de Vries  <tdevries@suse.de>

PR testsuite/26963
* lib/gdb.exp (run_on_host): Declare test unsupported if spawn fails.

3 years ago[gdb/testsuite] Handle no glibc debuginfo in gdb.base/solib-corrupted.exp
Tom de Vries [Mon, 14 Dec 2020 16:05:11 +0000 (17:05 +0100)]
[gdb/testsuite] Handle no glibc debuginfo in gdb.base/solib-corrupted.exp

When running test-case gdb.base/solib-corrupted.exp on SLE-11, I get:
...
(gdb) PASS: gdb.base/solib-corrupted.exp: normal list
p/x _r_debug->r_map->l_next = _r_debug->r_map^M
'_r_debug' has unknown type; cast it to its declared type^M
(gdb) FAIL: gdb.base/solib-corrupted.exp: make solibs looping
...

The reason that _r_debug has unknown type is that glibc debuginfo is not
installed.  The test-case attempts to detect this but doesn't handle this
particular error string.

Fix this by adding the "unknown type" line to the regexp detecting missing
glibc debuginfo.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-14  Tom de Vries  <tdevries@suse.de>

PR testsuite/26962
* gdb.base/solib-corrupted.exp: Handle "'_r_debug' has unknown type;
cast it to its declared type".

3 years ago[gdb/testsuite] Handle shell prompt in batch-preserve-term-settings.exp
Tom de Vries [Mon, 14 Dec 2020 16:05:11 +0000 (17:05 +0100)]
[gdb/testsuite] Handle shell prompt in batch-preserve-term-settings.exp

On SLE-11, I run into:
...
FAIL: gdb.base/batch-preserve-term-settings.exp: batch run: spawn shell \
  (timeout)
...

The problem is that the shell prompt has PS1="\h:\w> ", but the test expects
a shell prompt ending in a space preceded by either '$' or '#':
...
set shell_prompt_re "\[$#\] "
...

We could easily fix this by adding '>' to shell_prompt_re, but this wouldn't
work for other PS1 setting.

Fix this instead by setting the shell prompt to "gdb-subshell$ " (as in
gdb.base/multi-line-starts-subshell.exp).

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-14  Tom de Vries  <tdevries@suse.de>

PR testsuite/26951
* gdb.base/batch-preserve-term-settings.exp: Use "gdb-subshell$ " as
shell prompt.

3 years agoHandle block-local names for Ada
Tom Tromey [Mon, 14 Dec 2020 15:14:06 +0000 (08:14 -0700)]
Handle block-local names for Ada

GNAT can generate a mangled name with "B_N" (where N is a number) in
the middle, like "hello__B_1__fourth.0".  This is used for names local
to a block.  Multiple levels of block-local name can also occur, a
possibility that was neglected by v1 of this patch.  This patch
changes gdb to handle these names.

The wild name matcher is updated a straightforward way.  The full
matcher is rewritten.  The hash function is updated to ensure that
this works.

This version does not seem to have the performance problems that
affected v1.  In particular, the previously-slow "bt" problem has been
fixed.

gdb/ChangeLog
2020-12-14  Tom Tromey  <tromey@adacore.com>

* dictionary.c (language_defn::search_name_hash): Ignore "B".
* ada-lang.c (advance_wild_match): Ignore "B".
(full_match): Remove.
(do_full_match): Rewrite.

gdb/testsuite/ChangeLog
2020-12-14  Tom Tromey  <tromey@adacore.com>

* gdb.ada/nested.exp: Add new tests.
* gdb.ada/nested/hello.adb (Fourth, Fifth): New procedures.