binutils-gdb.git
3 years agois_relocatable_executable --exclude-libs failure
Alan Modra [Tue, 5 Jan 2021 12:21:42 +0000 (22:51 +1030)]
is_relocatable_executable --exclude-libs failure

--exclude-libs makes symbols hidden, but that doesn't prevent them
being made dynamic for is_relocatable_executable targets.  Fix that.

* elflink.c (bfd_elf_link_record_dynamic_symbol): Handle no_export
for relocatable executable.

3 years agoUpdate libiberty with latest sources from gcc mainline
Nick Clifton [Tue, 5 Jan 2021 12:36:09 +0000 (12:36 +0000)]
Update libiberty with latest sources from gcc mainline

3 years agoUpdate config.sub and config.guess
Alan Modra [Tue, 5 Jan 2021 05:24:50 +0000 (15:54 +1030)]
Update config.sub and config.guess

* config.guess: Import from upstream.
* config.sub: Likewise.

3 years agoRe: elf: Allow mixed ordered/unordered inputs for non-relocatable link
Alan Modra [Tue, 5 Jan 2021 05:13:37 +0000 (15:43 +1030)]
Re: elf: Allow mixed ordered/unordered inputs for non-relocatable link

PR ld/26256
* testsuite/ld-elf/pr26256-1b.d: xfail s12z.
* testsuite/ld-scripts/crossref.exp (cross1): Don't xfail ia64.

3 years agoasan: heap buffer overflow in _bfd_vms_slurp_egsd
Alan Modra [Tue, 5 Jan 2021 02:47:24 +0000 (13:17 +1030)]
asan: heap buffer overflow in _bfd_vms_slurp_egsd

* vms-alpha.c (_bfd_vms_slurp_egsd): Read flags after size check.

3 years agoRISC-V: Ouput __global_pointer$ as dynamic symbol when generating dynamic PDE.
Nelson Chu [Wed, 16 Dec 2020 03:03:34 +0000 (19:03 -0800)]
RISC-V: Ouput __global_pointer$ as dynamic symbol when generating dynamic PDE.

When the ifunc resolver is in the executable, we may relax the variables
to gp-relative access instruction in the ifunc resolver, or in other functions
that called by the ifunc resolver.  But this will cause the uninitialized
gp problem since the ifunc need to be resolved at the early runtime, that
is at the pre-load stage, but we set the gp until the startup code.

At first, we try to add a new dynamic tag, DT_RISCV_GP, to stroe the gp value
and let ld.so can init the gp register early, before the pre-load stage.  But
we need to extend the ABI if we want to add a new dynamic tag.  Therefore,
in the psabi discussion, we try another solution, which was suggested by the
lld and FreeBSD linker experts, to let ld.so set the gp earlier - make sure
__global_pointer$ is output as a dynamic symbol when we are generating pde,
since we only do the relaxation for it.  Afterwards, ld.so can search the
DT_SYMTAB to get the gp value, and set the gp register before resolving ifunc.

bfd/
    * elfnn-riscv.c (allocate_dynrelocs): When we are generating pde, make
      sure gp symbol is output as a dynamic symbol.

3 years agosim: include stdlib.h for atoi()
Mike Frysinger [Tue, 5 Jan 2021 01:17:37 +0000 (20:17 -0500)]
sim: include stdlib.h for atoi()

Make sure the files using atoi() include stdlib.h for its prototype.
These files were relying on it being included implicitly by others
which isn't guaranteed, and newer toolchains produce warnings.

3 years agosim: stdlib.h for abs()
Mike Frysinger [Tue, 5 Jan 2021 01:11:48 +0000 (20:11 -0500)]
sim: stdlib.h for abs()

Make sure the files using abs() include stdlib.h for its prototype.
These files were relying on it being included implicitly by others
which isn't guaranteed, and newer toolchains produce warnings.

3 years agoAutomatic date update in version.in
GDB Administrator [Tue, 5 Jan 2021 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agogdb: bfin: use align helper
Mike Frysinger [Fri, 19 Jun 2015 08:24:13 +0000 (14:09 +0545)]
gdb: bfin: use align helper

3 years agosim: update bug URI to https://
Mike Frysinger [Sun, 3 Jan 2021 08:09:04 +0000 (03:09 -0500)]
sim: update bug URI to https://

3 years agosim: common: version: add build & homepage info when interactive
Mike Frysinger [Sun, 3 Jan 2021 08:06:28 +0000 (03:06 -0500)]
sim: common: version: add build & homepage info when interactive

This mirrors gdb behavior of dumping extra info when being run in
interactive mode.  It also gives us an excuse to use the otherwise
unused sim_print_config.

3 years agosim: common: use sim_config_print name
Mike Frysinger [Mon, 4 Jan 2021 23:09:31 +0000 (18:09 -0500)]
sim: common: use sim_config_print name

Meant to push this variant where naming preference is given to the
module the code resides in rather than the operation it performs.

3 years agosim: common: add a version output helper w/copyright+license info
Mike Frysinger [Sun, 3 Jan 2021 07:52:11 +0000 (02:52 -0500)]
sim: common: add a version output helper w/copyright+license info

This mirrors the existing sim_print_help function, and the behavior
of all other GNU tools with their --version.

3 years agosim: common: rename sim_print_config
Mike Frysinger [Mon, 4 Jan 2016 00:10:49 +0000 (19:10 -0500)]
sim: common: rename sim_print_config

print_sim_config has never been used anywhere, so rename it to follow
the sim_* naming style for all other symbols we export.

3 years agoelf: Allow mixed ordered/unordered inputs for non-relocatable link
H.J. Lu [Mon, 4 Jan 2021 20:37:49 +0000 (12:37 -0800)]
elf: Allow mixed ordered/unordered inputs for non-relocatable link

For non-relocatable link with SHF_LINK_ORDER inputs, allow mixed indirect
and data inputs with ordered and unordered inputs:

1. Add pattern to bfd_section for the matching section name pattern in
linker script and update BFD_FAKE_SECTION.
2. Sort the consecutive bfd_indirect_link_order sections with the same
pattern to allow linker script to overdide input section order.
3. Place unordered sections before ordered sections.
4. Change the offsets of the indirect input sections only.

bfd/

PR ld/26256
* elflink.c (compare_link_order): Place unordered sections before
ordered sections.
(elf_fixup_link_order): Add a link info argument.  Allow mixed
ordered and unordered input sections for non-relocatable link.
Sort the consecutive bfd_indirect_link_order sections with the
same pattern.  Change the offsets of the bfd_indirect_link_order
sections only.
(bfd_elf_final_link): Pass info to elf_fixup_link_order.
* section.c (bfd_section): Add pattern.
(BFD_FAKE_SECTION): Initialize pattern to NULL.
* bfd-in2.h: Regenerated.

gas/

PR ld/26256
* config/obj-elf.c (obj_elf_change_section): Also filter out
SHF_LINK_ORDER.

ld/

PR ld/26256
* ldlang.c (gc_section_callback): Set pattern.
* testsuite/ld-elf/pr26256-1.s: New file.
* testsuite/ld-elf/pr26256-1.t: Likewise.
* testsuite/ld-elf/pr26256-1a.d: Likewise.
* testsuite/ld-elf/pr26256-1b.d: Likewise.
* testsuite/ld-elf/pr26256-2.s: Likewise.
* testsuite/ld-elf/pr26256-2.t: Likewise.
* testsuite/ld-elf/pr26256-2a.d: Likewise.
* testsuite/ld-elf/pr26256-2b-alt.d: Likewise.
* testsuite/ld-elf/pr26256-2b.d: Likewise.
* testsuite/ld-elf/pr26256-3.s: Likewise.
* testsuite/ld-elf/pr26256-3a.d: Likewise.
* testsuite/ld-elf/pr26256-3a.t: Likewise.
* testsuite/ld-elf/pr26256-3b.d: Likewise.
* testsuite/ld-elf/pr26256-3b.t: Likewise.

3 years ago[gdb/symtab] Remove superfluous end-of-sequence marker
Tom de Vries [Mon, 4 Jan 2021 18:34:25 +0000 (19:34 +0100)]
[gdb/symtab] Remove superfluous end-of-sequence marker

While working on PR26935 I noticed that when running test-case
gdb.base/morestack.exp with target board unix/-m32/-fPIE/-pie and ld linker,
I get this linetable fragment for morestack.S using readelf -wL:
...
CU: ../../../../libgcc/config/i386/morestack.S:
Line number    Starting address    View    Stmt
109               0xc9c               x
  ...
838               0xe03               x
  -               0xe04

636                   0               x
637                 0x3               x
  -                 0x4
...
but with "maint info line-table" I get:
...
INDEX  LINE   ADDRESS            IS-STMT
0      END    0x00000004         Y
1      109    0x00000c9c         Y
  ...
110    838    0x00000e03         Y
111    END    0x00000e04         Y
...

So, apparently the entries with addresses 0x0 and 0x3 are filtered out
because the addresses are out of range, but the same doesn't happen with the
end-of-seq terminator.

Fix this by filtering out end-of-seq terminators that do not actually
terminate anything.

Tested on x86_64-linux.

gdb/ChangeLog:

2021-01-04  Tom de Vries  <tdevries@suse.de>

* buildsym.c (buildsym_compunit::record_line): Filter out end-of-seq
terminators that do not terminate anything.

gdb/testsuite/ChangeLog:

2021-01-04  Tom de Vries  <tdevries@suse.de>

* gdb.dwarf2/dw2-out-of-range-end-of-seq.exp: New file.

3 years agogdb: introduce scoped debug prints
Simon Marchi [Mon, 4 Jan 2021 16:56:10 +0000 (11:56 -0500)]
gdb: introduce scoped debug prints

I spent a lot of time reading infrun debug logs recently, and I think
they could be made much more readable by being indented, to clearly see
what operation is done as part of what other operation.  In the current
format, there are no visual cues to tell where things start and end,
it's just a big flat list.  It's also difficult to understand what
caused a given operation (e.g. a call to resume_1) to be done.

To help with this, I propose to add the new scoped_debug_start_end
structure, along with a bunch of macros to make it convenient to use.

The idea of scoped_debug_start_end is simply to print a start and end
message at construction and destruction.  It also increments/decrements
a depth counter in order to make debug statements printed during this
range use some indentation.  Some care is taken to handle the fact that
debug can be turned on or off in the middle of such a range.  For
example, a "set debug foo 1" command in a breakpoint command, or a
superior GDB manually changing the debug_foo variable.

Two macros are added in gdbsupport/common-debug.h, which are helpers to
define module-specific macros:

  - scoped_debug_start_end: takes a message that is printed both at
    construction / destruction, with "start: " and "end: " prefixes.
  - scoped_debug_enter_exit: prints hard-coded "enter" and "exit"
    messages, to denote the entry and exit of a function.

I added some examples in the infrun module to give an idea of how it can
be used and what the result looks like.  The macros are in capital
letters (INFRUN_SCOPED_DEBUG_START_END and
INFRUN_SCOPED_DEBUG_ENTER_EXIT) to mimic the existing SCOPE_EXIT, but
that can be changed if you prefer something else.

Here's an excerpt of the debug
statements printed when doing "continue", where a displaced step is
started:

    [infrun] proceed: enter
      [infrun] proceed: addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT
      [infrun] global_thread_step_over_chain_enqueue: enqueueing thread Thread 0x7ffff75a5640 (LWP 2289301) in global step over chain
      [infrun] start_step_over: enter
        [infrun] start_step_over: stealing global queue of threads to step, length = 1
        [infrun] start_step_over: resuming [Thread 0x7ffff75a5640 (LWP 2289301)] for step-over
        [infrun] resume_1: step=1, signal=GDB_SIGNAL_0, trap_expected=1, current thread [Thread 0x7ffff75a5640 (LWP 2289301)] at 0x5555555551bd
        [displaced] displaced_step_prepare_throw: displaced-stepping Thread 0x7ffff75a5640 (LWP 2289301) now
        [displaced] prepare: selected buffer at 0x5555555550c2
        [displaced] prepare: saved 0x5555555550c2: 1e fa 31 ed 49 89 d1 5e 48 89 e2 48 83 e4 f0 50
        [displaced] amd64_displaced_step_copy_insn: copy 0x5555555551bd->0x5555555550c2: c7 45 fc 00 00 00 00 eb 13 8b 05 d4 2e 00 00 83
        [displaced] displaced_step_prepare_throw: prepared successfully thread=Thread 0x7ffff75a5640 (LWP 2289301), original_pc=0x5555555551bd, displaced_pc=0x5555555550c2
        [displaced] resume_1: run 0x5555555550c2: c7 45 fc 00
        [infrun] infrun_async: enable=1
        [infrun] prepare_to_wait: prepare_to_wait
        [infrun] start_step_over: [Thread 0x7ffff75a5640 (LWP 2289301)] was resumed.
        [infrun] operator(): step-over queue now empty
      [infrun] start_step_over: exit
      [infrun] proceed: start: resuming threads, all-stop-on-top-of-non-stop
        [infrun] proceed: resuming Thread 0x7ffff7da7740 (LWP 2289296)
        [infrun] resume_1: step=0, signal=GDB_SIGNAL_0, trap_expected=0, current thread [Thread 0x7ffff7da7740 (LWP 2289296)] at 0x7ffff7f7d9b7
        [infrun] prepare_to_wait: prepare_to_wait
        [infrun] proceed: resuming Thread 0x7ffff7da6640 (LWP 2289300)
        [infrun] resume_1: thread Thread 0x7ffff7da6640 (LWP 2289300) has pending wait status status->kind = stopped, signal = GDB_SIGNAL_TRAP (currently_stepping=0).
        [infrun] prepare_to_wait: prepare_to_wait
        [infrun] proceed: [Thread 0x7ffff75a5640 (LWP 2289301)] resumed
        [infrun] proceed: resuming Thread 0x7ffff6da4640 (LWP 2289302)
        [infrun] resume_1: thread Thread 0x7ffff6da4640 (LWP 2289302) has pending wait status status->kind = stopped, signal = GDB_SIGNAL_TRAP (currently_stepping=0).
        [infrun] prepare_to_wait: prepare_to_wait
      [infrun] proceed: end: resuming threads, all-stop-on-top-of-non-stop
    [infrun] proceed: exit

We can easily see where the call to `proceed` starts and end.  We can
also see why there are a bunch of resume_1 calls, it's because we are
resuming threads, emulating all-stop on top of a non-stop target.

We also see that debug statements nest well with other modules that have
been migrated to use the "new" debug statement helpers (because they all
use debug_prefixed_vprintf in the end.  I think this is desirable, for
example we could see the debug statements about reading the DWARF info
of a library nested under the debug statements about loading that
library.

Of course, modules that haven't been migrated to use the "new" helpers
will still print without indentations.  This will be one good reason to
migrate them.

I think the runtime cost (when debug statements are disabled) of this is
reasonable, given the improvement in readability.  There is the cost of
the conditionals (like standard debug statements), one more condition
(if (m_must_decrement_print_depth)) and the cost of constructing a stack
object, which means copying a fews pointers.

Adding the print in fetch_inferior_event breaks some tests that use "set
debug infrun", because it prints a debug statement after the prompt.  I
adapted these tests to cope with it, by using the "-prompt" switch of
gdb_test_multiple to as if this debug statement is part of the expected
prompt.  It's unfortunate that we have to do this, but I think the debug
print is useful, and I don't want a few tests to get in the way of
adding good debug output.

gdbsupport/ChangeLog:

* common-debug.h (debug_print_depth): New.
(struct scoped_debug_start_end): New.
(scoped_debug_start_end): New.
(scoped_debug_enter_exit): New.
* common-debug.cc (debug_prefixed_vprintf): Print indentation.

gdb/ChangeLog:

* debug.c (debug_print_depth): New.
* infrun.h (INFRUN_SCOPED_DEBUG_START_END): New.
(INFRUN_SCOPED_DEBUG_ENTER_EXIT): New.
* infrun.c (start_step_over): Use
INFRUN_SCOPED_DEBUG_ENTER_EXIT.
(proceed): Use INFRUN_SCOPED_DEBUG_ENTER_EXIT and
INFRUN_SCOPED_DEBUG_START_END.
(fetch_inferior_event): Use INFRUN_SCOPED_DEBUG_ENTER_EXIT.

gdbserver/ChangeLog:

* debug.cc (debug_print_depth): New.

gdb/testsuite/ChangeLog:

        * gdb.base/ui-redirect.exp: Expect infrun debug print after
prompt.
        * gdb.threads/ia64-sigill.exp: Likewise.
        * gdb.threads/watchthreads-reorder.exp: Likewise.

Change-Id: I7c3805e6487807aa63a1bae318876a0c69dce949

3 years agogdb: use infrun_debug_printf in print_target_wait_results
Simon Marchi [Mon, 4 Jan 2021 16:56:10 +0000 (11:56 -0500)]
gdb: use infrun_debug_printf in print_target_wait_results

The code in print_target_wait_results uses a single call to debug_printf
in order to make sure a single timestamp is emitted, despite printing
multiple lines.  The result is:

    941502.043284 [infrun] target_wait (-1.0.0, status) =
    [infrun]   649832.649832.0 [process 649832],
    [infrun]   status->kind = stopped, signal = GDB_SIGNAL_TRAP

I find this decision a bit counter productive, because it messes up the
alignment of the three lines.  We don't care that three (slightly
different) timestamps are printed.

I suggest to change this function to use infrun_debug_printf, with this
result:

    941601.425771 [infrun] print_target_wait_results: target_wait (-1.0.0 [process -1], status) =
    941601.425824 [infrun] print_target_wait_results:   651481.651481.0 [process 651481],
    941601.425867 [infrun] print_target_wait_results:   status->kind = stopped, signal = GDB_SIGNAL_TRAP

Note that the current code only prints the waiton_ptid as a string
between square brackets if pid != -1.  I don't think this complexity is
needed in a debug print.  I made it so it's always printed, which I
think results in a much simpler function.

gdb/ChangeLog:

* infrun.c (print_target_wait_results): Use infrun_debug_printf.

Change-Id: I817bd10286b8e641a6c751ac3a1bd1ddf9b18ce0

3 years agogdb: make "set debug timestamp" work nice with new debug printouts
Simon Marchi [Mon, 4 Jan 2021 16:56:10 +0000 (11:56 -0500)]
gdb: make "set debug timestamp" work nice with new debug printouts

New in v2:

- implement by modifying vprintf_unfiltered rather than
  debug_prefixed_vprintf.

I tried enabling debug timestamps, and realized that it doesn't play
well with the revamp of the debug printouts I've been working on:

    $ ./gdb -q -nx --data-directory=data-directory -ex "set debug infrun" -ex "set debug timestamp" a.out
    Reading symbols from a.out...
    (gdb) start
    Temporary breakpoint 1 at 0x1131: file test.c, line 2.
    Starting program: /home/smarchi/build/binutils-gdb-all-targets/gdb/a.out
    939897.769338 [infrun] infrun_async:
    939897.769383 enable=1
    939897.769409
    939897.915218 [infrun] proceed:
    939897.915281 addr=0x7ffff7fd0100, signal=GDB_SIGNAL_0
    939897.915315
    939897.915417 [infrun] start_step_over:
    939897.915464 stealing global queue of threads to step, length = 0
    939897.915502
    939897.915567 [infrun] operator():
    939897.915601 step-over queue now empty
    939897.915633
    939897.915690 [infrun] proceed:
    939897.915729 resuming process 636244
    939897.915768
    939897.915892 [infrun] resume_1:
    939897.915954 step=0, signal=GDB_SIGNAL_0, trap_expected=0, current thread [process 636244] at 0x7ffff7fd0100
    939897.915991
    939897.916119 [infrun] prepare_to_wait:
    939897.916153 prepare_to_wait
    939897.916201
    939897.916661 [infrun] target_wait (-1.0.0, status) =
    [infrun]   636244.636244.0 [process 636244],
    [infrun]   status->kind = stopped, signal = GDB_SIGNAL_TRAP
    939897.916734 [infrun] handle_inferior_event:
    939897.916768 status->kind = stopped, signal = GDB_SIGNAL_TRAP
    939897.916799

This is due to debug_prefixed_vprintf being implemented as three
separate calls to debug_printf / debug_vprintf.  Each call gets its own
timestamp and newline, curtesy of vprintf_unfiltered.

My first idea was to add a "line_start" parameter to debug_vprintf,
allowing the caller to say whether the print is the start of the line.
A debug timestamp would only be printed if line_start was true.
However, that was much more invasive than the simple fix implemented in
this patch.

My second idea was to make debug_prefixed_vprintf use string_printf and
issue a single call to debug_printf.  That would however prevent future
use of styling in the debug messages.

What is implemented in this patch is the same as is implemented in
GDBserver: the timestamp-printing code in GDB tracks whether the last
debug output ended with a newline.  If so, it prints a timestamp on the
next debug output.

After the fix, it looks like this:

    $ ./gdb -q -nx --data-directory=data-directory -ex "set debug infrun" -ex "set debug timestamp" a.out
    Reading symbols from a.out...
    (gdb) start
    Temporary breakpoint 1 at 0x1131: file test.c, line 2.
    Starting program: /home/smarchi/build/binutils-gdb-all-targets/gdb/a.out
    941112.135662 [infrun] infrun_async: enable=1
    941112.279930 [infrun] proceed: addr=0x7ffff7fd0100, signal=GDB_SIGNAL_0
    941112.280064 [infrun] start_step_over: stealing global queue of threads to step, length = 0
    941112.280125 [infrun] operator(): step-over queue now empty
    941112.280194 [infrun] proceed: resuming process 646228
    941112.280332 [infrun] resume_1: step=0, signal=GDB_SIGNAL_0, trap_expected=0, current thread [process 646228] at 0x7ffff7fd0100
    941112.280480 [infrun] prepare_to_wait: prepare_to_wait
    941112.281004 [infrun] target_wait (-1.0.0, status) =
    [infrun]   646228.646228.0 [process 646228],
    [infrun]   status->kind = stopped, signal = GDB_SIGNAL_TRAP
    941112.281078 [infrun] handle_inferior_event: status->kind = stopped, signal = GDB_SIGNAL_TRAP

gdb/ChangeLog:

* utils.c (vfprintf_unfiltered): Print timestamp only when
previous debug output ended with a newline.

Change-Id: Idcfe3acc7e3d0f526a5f0a43a5e0884bf93c41ae

3 years agogdb/testsuite: avoid reading files through the remote protocol in gdb.server/*.exp
Simon Marchi [Mon, 4 Jan 2021 16:43:59 +0000 (11:43 -0500)]
gdb/testsuite: avoid reading files through the remote protocol in gdb.server/*.exp

When I run some tests in gdb.server (fox example
gdb.server/ext-attach.exp) on Ubuntu 20.04 with separate debug info for
glibc installed, they often time out.  This is because GDB reads the
debug info through the remote protocol which is particularly slow:

    attach 316937
    Attaching to program: /home/smarchi/build/binutils-gdb-all-targets/gdb/testsuite/outputs/gdb.server/ext-attach/ext-attach, process 316937
    Reading /lib/x86_64-linux-gnu/libc.so.6 from remote target...
    warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
    Reading /lib64/ld-linux-x86-64.so.2 from remote target...
    Reading symbols from target:/lib/x86_64-linux-gnu/libc.so.6...
    Reading /lib/x86_64-linux-gnu/libc-2.31.so from remote target...
    Reading /lib/x86_64-linux-gnu/.debug/libc-2.31.so from remote target...
    Reading /usr/lib/debug//lib/x86_64-linux-gnu/libc-2.31.so from remote target...
    FAIL: gdb.server/ext-attach.exp: attach to remote program 1 (timeout)

This is avoided in gdbserver boards by adding "set sysroot" to GDBFLAGS
(see boards/local-board.exp), which makes GDB read files from the local
filesystem.  But gdb.server tests spawn GDBserver directly, so are ran
even when using the default unix board, where the "set sysroot" isn't
used.

Modify these tests to append "set sysroot" to the GDBFLAGS, a bit like
lib/local-board.exp does.

One special case is gdb.server/sysroot.exp, whose intent is to test
different "set sysroot" values.  For this one, increase the timeout when
testing the "target:" sysroot.

gdb/testsuite/ChangeLog:

* gdb.server/abspath.exp: Append "set sysroot" to GDBFLAGS.
* gdb.server/connect-without-multi-process.exp: Likewise.
* gdb.server/exit-multiple-threads.exp: Likewise.
* gdb.server/ext-attach.exp: Likewise.
* gdb.server/ext-restart.exp: Likewise.
* gdb.server/ext-run.exp: Likewise.
* gdb.server/ext-wrapper.exp: Likewise.
* gdb.server/multi-ui-errors.exp: Likewise.
* gdb.server/no-thread-db.exp: Likewise.
* gdb.server/reconnect-ctrl-c.exp: Likewise.
* gdb.server/run-without-local-binary.exp: Likewise.
* gdb.server/server-kill.exp: Likewise.
* gdb.server/server-run.exp: Likewise.
* gdb.server/solib-list.exp: Likewise.
* gdb.server/stop-reply-no-thread.exp: Likewise.
* gdb.server/wrapper.exp: Likewise.
* gdb.server/sysroot.exp: Increase timeout when testing the
target: sysroot.

Change-Id: I7451bcc737f90e2cd0b977e9f09da3710774b0bf

3 years agogdb/testsuite: use clean_restart in gdb.server/server-run.exp
Simon Marchi [Mon, 4 Jan 2021 16:43:58 +0000 (11:43 -0500)]
gdb/testsuite: use clean_restart in gdb.server/server-run.exp

I think this sequence of commands can be replaced with clean_restart.

gdb/testsuite/ChangeLog:

* gdb.server/server-run.exp: Use clean_restart.

Change-Id: If8c3eaa89f4ee58901282f5f1d5d4e1100ce7ac5

3 years agogdb/testsuite: use clean_restart in gdb.server/ext-run.exp
Simon Marchi [Mon, 4 Jan 2021 16:43:58 +0000 (11:43 -0500)]
gdb/testsuite: use clean_restart in gdb.server/ext-run.exp

I think the sequence of commands here could be replaced with
clean_restart.  The test starts with GDB not started, so it should not
be started when we reach gdb_skip_xml_test.

gdb/testsuite/ChangeLog:

* gdb.server/ext-run.exp: Use clean_restart.

Change-Id: I8c033bad6c52f3d58d6aa377b8355fc633c7aede

3 years agogdb/testsuite: use build_executable in gdb.server/stop-reply-no-thread.exp
Simon Marchi [Mon, 4 Jan 2021 16:43:58 +0000 (11:43 -0500)]
gdb/testsuite: use build_executable in gdb.server/stop-reply-no-thread.exp

This test uses prepare_for_testing, then does a clean_restart for each
test configuration.  prepare_for_testing does a build_executable plus a
clean_restart.  So the clean_restart inside prepare_for_testing is done
for nothing.

Change prepare_for_testing to just build_executable to avoid the
unnecessary clean_restart.

gdb/testsuite/ChangeLog:

* gdb.server/stop-reply-no-thread.exp: Use build_executable
instead of prepare_for_testing.

Change-Id: I8b2a2e90353c57c39c49a3665083331b4882fdd0

3 years agogdb/testsuite: use clean_restart in gdb.server/solib-list.exp
Simon Marchi [Mon, 4 Jan 2021 16:43:58 +0000 (11:43 -0500)]
gdb/testsuite: use clean_restart in gdb.server/solib-list.exp

I think this sequence of commands can be replaced by clean_restart,
despite what the comment says, as long as we don't use the `binfile`
argument to clean_restart.

gdb/testsuite/ChangeLog:

* gdb.server/solib-list.exp: Use clean_restart.

Change-Id: I4930564c50a1865cbffe0d660a4296c9d2158084

3 years ago[gdb/testsuite] Don't require gold for gdb.base/morestack.exp
Tom de Vries [Mon, 4 Jan 2021 15:48:48 +0000 (16:48 +0100)]
[gdb/testsuite] Don't require gold for gdb.base/morestack.exp

While working on PR26935 I noticed that the test-case requires the gold
linker, but doesn't really need it.

The -fuse-ld=gold was added to support the printf in the test-case, which
prints some information but is not otherwise needed for the test-case.

Fix this by removing the printf and the corresponding -fuse-ld=gold.

Tested on x86_64-linux.

Also checked that the test still fails when the fix from the commit that added
the test-case is reverted.

gdb/testsuite/ChangeLog:

2021-01-04  Tom de Vries  <tdevries@suse.de>

* gdb.base/morestack.c: Remove printf.
* gdb.base/morestack.exp: Don't use -fuse-ld=gold.

3 years agoRefactor struct trad_frame_saved_regs
Luis Machado [Tue, 22 Dec 2020 20:45:21 +0000 (17:45 -0300)]
Refactor struct trad_frame_saved_regs

The following patch drops the overloading going on with the trad_frame_saved_reg
struct and defines a new struct with a KIND enum and a union of different
fields.

The new struct looks like this:

struct trad_frame_saved_reg
 {
  setters/getters

  ...

private:

  trad_frame_saved_reg_kind m_kind;

  union {
    LONGEST value;
    int realreg;
    LONGEST addr;
    const gdb_byte *value_bytes;
  } m_reg;
};

And the enums look like this:

/* Describes the kind of encoding a stored register has.  */
enum class trad_frame_saved_reg_kind
{
  /* Register value is unknown.  */
  UNKNOWN = 0,
  /* Register value is a constant.  */
  VALUE,
  /* Register value is in another register.  */
  REALREG,
  /* Register value is at an address.  */
  ADDR,
  /* Register value is a sequence of bytes.  */
  VALUE_BYTES
};

The patch also adds setters/getters and updates all the users of the old
struct.

It is worth mentioning that due to the previous overloaded nature of the
fields, some tdep files like to store negative offsets and indexes in the ADDR
field, so I kept the ADDR as LONGEST instead of CORE_ADDR. Those cases may
be better supported by a new enum entry.

I have not addressed those cases in this patch to prevent unwanted breakage,
given I have no way to test some of the targets. But it would be nice to
clean those up eventually.

The change to frame-unwind.* is to constify the parameter being passed to the
unwinding functions, given we now accept a "const gdb_byte *" for value bytes.

Tested on aarch64-linux/Ubuntu 20.04/18.04 and by building GDB with
--enable-targets=all.

gdb/ChangeLog:

2021-01-04  Luis Machado  <luis.machado@linaro.org>

Update all users of trad_frame_saved_reg to use the new member
functions.

Remote all struct keywords from declarations of trad_frame_saved_reg
types, except on forward declarations.

* aarch64-tdep.c: Update.
* alpha-mdebug-tdep.c: Update.
* alpha-tdep.c: Update.
* arc-tdep.c: Update.
* arm-tdep.c: Update.
* avr-tdep.c: Update.
* cris-tdep.c: Update.
* csky-tdep.c: Update.
* frv-tdep.c: Update.
* hppa-linux-tdep.c: Update.
* hppa-tdep.c: Update.
* hppa-tdep.h: Update.
* lm32-tdep.c: Update.
* m32r-linux-tdep.c: Update.
* m32r-tdep.c: Update.
* m68hc11-tdep.c: Update.
* mips-tdep.c: Update.
* moxie-tdep.c: Update.
* riscv-tdep.c: Update.
* rs6000-tdep.c: Update.
* s390-linux-tdep.c: Update.
* s390-tdep.c: Update.
* score-tdep.c: Update.
* sparc-netbsd-tdep.c: Update.
* sparc-sol2-tdep.c: Update.
* sparc64-fbsd-tdep.c: Update.
* sparc64-netbsd-tdep.c: Update.
* sparc64-obsd-tdep.c: Update.
* sparc64-sol2-tdep.c: Update.
* tilegx-tdep.c: Update.
* v850-tdep.c: Update.
* vax-tdep.c: Update.

* frame-unwind.c (frame_unwind_got_bytes): Make parameter const.
* frame-unwind.h (frame_unwind_got_bytes): Likewise.

* trad-frame.c: Update.
Remove TF_REG_* enum.
(trad_frame_alloc_saved_regs): Add a static assertion to check for
a trivially-constructible struct.
(trad_frame_reset_saved_regs): Adjust to use member function.
(trad_frame_value_p): Likewise.
(trad_frame_addr_p): Likewise.
(trad_frame_realreg_p): Likewise.
(trad_frame_value_bytes_p): Likewise.
(trad_frame_set_value): Likewise.
(trad_frame_set_realreg): Likewise.
(trad_frame_set_addr): Likewise.
(trad_frame_set_unknown): Likewise.
(trad_frame_set_value_bytes): Likewise.
(trad_frame_get_prev_register): Likewise.
* trad-frame.h: Update.
(trad_frame_saved_reg_kind): New enum.
(struct trad_frame_saved_reg) <addr, realreg, data>: Remove.
<m_kind, m_reg>: New member fields.
<set_value, set_realreg, set_addr, set_unknown, set_value_bytes>
<kind, value, realreg, addr, value_bytes, is_value, is_realreg>
<is_addr, is_unknown, is_value_bytes>: New member functions.

3 years agoWhen displaying ARM private file flag bits, use a 0x prefix.
Alexander Fedotov [Mon, 4 Jan 2021 15:13:57 +0000 (15:13 +0000)]
When displaying ARM private file flag bits, use a 0x prefix.

* elf32-arm.c (elf32_arm_print_private_bfd_data): Prefix hex value
of private flags with 0x.
* elfnn-aarch64.c (elfNN_aarch64_print_private_bfd_data): Likewise.

3 years agoPR26822, How to prevent a STT_FILE with absolute path in the linked image
Alan Modra [Mon, 4 Jan 2021 06:43:51 +0000 (17:13 +1030)]
PR26822, How to prevent a STT_FILE with absolute path in the linked image

bfd/
PR 26822
* elflink.c (elf_link_input_bfd): Use the file base name in
linker generated STT_FILE symbols.
ld/
PR 26822
* testsuite/ld-arm/non-contiguous-arm2.d: Adjust STT_FILE symbol match.
* testsuite/ld-arm/non-contiguous-arm3.d: Likewise.
* testsuite/ld-arm/non-contiguous-arm5.d: Likewise.
* testsuite/ld-arm/non-contiguous-arm6.d: Likewise.
* testsuite/ld-i386/tlsbin.rd: Likewise.
* testsuite/ld-i386/tlsbin2.rd: Likewise.
* testsuite/ld-i386/tlsbindesc.rd: Likewise.
* testsuite/ld-i386/tlsdesc.rd: Likewise.
* testsuite/ld-i386/tlsnopic.rd: Likewise.
* testsuite/ld-i386/tlspic.rd: Likewise.
* testsuite/ld-i386/tlspic2.rd: Likewise.
* testsuite/ld-mips-elf/global-local-symtab-sort-n64.d: Likewise.
* testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d: Likewise.
* testsuite/ld-mips-elf/global-local-symtab-sort-o32.d: Likewise.
* testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d: Likewise.
* testsuite/ld-plugin/pr17973.d: Likewise.
* testsuite/ld-tic6x/shlib-1.rd: Likewise.
* testsuite/ld-tic6x/shlib-1b.rd: Likewise.
* testsuite/ld-tic6x/shlib-1r.rd: Likewise.
* testsuite/ld-tic6x/shlib-1rb.rd: Likewise.
* testsuite/ld-tic6x/shlib-app-1.rd: Likewise.
* testsuite/ld-tic6x/shlib-app-1b.rd: Likewise.
* testsuite/ld-tic6x/shlib-app-1r.rd: Likewise.
* testsuite/ld-tic6x/shlib-app-1rb.rd: Likewise.
* testsuite/ld-tic6x/shlib-noindex.rd: Likewise.
* testsuite/ld-tic6x/static-app-1.rd: Likewise.
* testsuite/ld-tic6x/static-app-1b.rd: Likewise.
* testsuite/ld-tic6x/static-app-1r.rd: Likewise.
* testsuite/ld-tic6x/static-app-1rb.rd: Likewise.
* testsuite/ld-x86-64/tlsbin.rd: Likewise.
* testsuite/ld-x86-64/tlsbin2.rd: Likewise.
* testsuite/ld-x86-64/tlsbindesc.rd: Likewise.
* testsuite/ld-x86-64/tlsdesc.rd: Likewise.
* testsuite/ld-x86-64/tlspic.rd: Likewise.
* testsuite/ld-x86-64/tlspic2.rd: Likewise.
* testsuite/ld-xtensa/tlsbin.rd: Likewise.
* testsuite/ld-xtensa/tlspic.rd: Likewise.

3 years agoPR27102, gas: "section symbols are already global"
Alan Modra [Mon, 4 Jan 2021 00:46:21 +0000 (11:16 +1030)]
PR27102, gas: "section symbols are already global"

PR 27102
* symbols.c (S_SET_EXTERNAL): Revise section symbol warning
message and register symbol error message.

3 years agoRISC-V: Fix the merged orders of Z* extension for linker.
Nelson Chu [Mon, 4 Jan 2021 02:12:45 +0000 (10:12 +0800)]
RISC-V: Fix the merged orders of Z* extension for linker.

Similar to the commit 6729e2c2af2bd94408430734316597843718a484,
we have to check the first char of the Z* extensions, to make
sure that they follow the order of the standard extensions.

bfd/
    * elfxx-riscv.c (riscv_compare_subsets): Removed static.
    * elfxx-riscv.h: Add declaration.
    * elfnn-riscv.c (riscv_merge_multi_letter_ext): Use
    riscv_compare_subsets to check the orders.
    (riscv_skip_prefix): Removed.
    (riscv_prefix_cmp): Removed.

3 years agoPR26741, benign use after free in riscv_parse_prefixed_ext
Alan Modra [Sun, 3 Jan 2021 23:49:14 +0000 (10:19 +1030)]
PR26741, benign use after free in riscv_parse_prefixed_ext

ISO/IEC 9899:1999 C standard "J.2 Undefined behavior" says the
following is undefined behaviour:

"The value of a pointer that refers to space deallocated by a call to
the free or realloc function is used (7.20.3)."

PR 26741
* elfxx-riscv.c (riscv_parse_prefixed_ext): Free subset after
calculating subset version length.

3 years agoIn libctf, make AC_CONFIG_MACRO_DIR consistent with ACLOCAL_AMFLAGS
Nicolas Boulenguez [Sun, 27 Dec 2020 10:32:52 +0000 (11:32 +0100)]
In libctf, make AC_CONFIG_MACRO_DIR consistent with ACLOCAL_AMFLAGS

PR 27117
* configure.ac: Make AC_CONFIG_MACRO_DIR consistent with
ACLOCAL_AMFLAGS -I dirs.
* configure: Regenerate.

3 years agoPR27101, as: Reject (byte) .align 0x100000000
Alan Modra [Sun, 3 Jan 2021 22:23:37 +0000 (08:53 +1030)]
PR27101, as: Reject (byte) .align 0x100000000

This allows alignments up to 2**TC_ALIGN_LIMIT, which might be larger
than an unsigned int can hold.

PR 27101
* read.c (s_align): Use a large enough type for "align" to hold
the result of get_absolute_expression.

3 years agoAutomatic date update in version.in
GDB Administrator [Mon, 4 Jan 2021 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agogdb: fix typos in comments in target-float.c
Simon Marchi [Sun, 3 Jan 2021 02:32:14 +0000 (21:32 -0500)]
gdb: fix typos in comments in target-float.c

gdb/ChangeLog:

* target-float.c: Fix typos.

Change-Id: Ib65e90746d0a7c77c3fbead81139facb40b91977

3 years agoPR27140, ppc32 segmentation fault in make_stub
Alan Modra [Sat, 2 Jan 2021 11:15:02 +0000 (21:45 +1030)]
PR27140, ppc32 segmentation fault in make_stub

This fixes a thinko in commit fa40fbe4849.  st_other global entry bits
are relevant only for 64-bit ELFv2.  PowerPC gold leaves local sym
vector of st_other bits as NULL for 32-bit, hence the segfault.

PR 27140
* powerpc.cc (Target_powerpc::Branch_info::make_stub): Only access
object->st_other() when 64-bit.
(Stub_table::add_long_branch_entry): Ignore "other" when 32-bit.

3 years agosim: common: add align_{up,down} to match gdb
Mike Frysinger [Tue, 23 Jun 2015 16:32:47 +0000 (22:17 +0545)]
sim: common: add align_{up,down} to match gdb

We have ALIGN_{8,16,PAGE} and FLOOR_PAGE macros (where PAGE is defined as
4k) which were imported from the ppc sim.  But no other sim utilizes these
and hardcoding the sizes in the name is a bit limiting.

Let's delete these and import the two general macros that gdb uses:
align_up(addr, bytes)
align_down(addr, bytes)

This in turn allows us to cut over the Blackfin code immediately.

3 years agoAutomatic date update in version.in
GDB Administrator [Sun, 3 Jan 2021 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agoFix pretty printer of main_type.flds_bnds.bounds
Hannes Domani [Sat, 2 Jan 2021 16:35:25 +0000 (17:35 +0100)]
Fix pretty printer of main_type.flds_bnds.bounds

In struct dynamic_prop the members kind and data were renamed to m_kind and
m_data.

And flag_upper_bound_is_count is actually in bounds directly, not in its
high member.

gdb/ChangeLog:

2021-01-02  Hannes Domani  <ssbssa@yahoo.de>

* gdb-gdb.py.in: Fix main_type.flds_bnds.bounds pretty printer.

3 years agoAutomatic date update in version.in
GDB Administrator [Sat, 2 Jan 2021 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agoManual updates of copyright year range not covered by gdb/copyright.py
Joel Brobecker [Fri, 1 Jan 2021 08:08:28 +0000 (12:08 +0400)]
Manual updates of copyright year range not covered by gdb/copyright.py

gdb/ChangeLog:

        * gdbarch.sh: Update copyright year range.

gdb/doc/ChangeLog:

        * gdb.texinfo, refcard.tex: Update copyright year range.

3 years agoUpdate copyright year range in all GDB files
Joel Brobecker [Fri, 1 Jan 2021 08:03:39 +0000 (12:03 +0400)]
Update copyright year range in all GDB files

This commits the result of running gdb/copyright.py as per our Start
of New Year procedure...

gdb/ChangeLog

        Update copyright year range in copyright header of all GDB files.

3 years agogdb/copyright.py: Also update sources in "gdbserver" and "gdbsupport"
Joel Brobecker [Fri, 1 Jan 2021 07:56:12 +0000 (11:56 +0400)]
gdb/copyright.py: Also update sources in "gdbserver" and "gdbsupport"

This commit adjusts GDB's copyright.py script, following two past changes:
  - gdb/gdbserver/ being move to the toplevel directory;
  - gdb/common/ being renamed to gdbsupport/.

gdb/ChangeLog:

        * copyright.py (get_update_list): Add "gdbserver" and "gdbsupport"
        to the list of directories to update.

3 years agoUpdate copyright year in version message for gdb, gdbserver and gdbreplay
Joel Brobecker [Fri, 1 Jan 2021 07:53:14 +0000 (11:53 +0400)]
Update copyright year in version message for gdb, gdbserver and gdbreplay

gdb/ChangeLog:

        * top.c (print_gdb_version): Update copyright year.

gdbserver/ChangeLog:

        * server.cc (gdbserver_version): Update copyright year.
        * gdbreplay.cc (gdbreplay_version): Likewise.

3 years agoRotate gdb/ChangeLog
Joel Brobecker [Fri, 1 Jan 2021 07:45:58 +0000 (11:45 +0400)]
Rotate gdb/ChangeLog

As a results of the rotation, this introduces a new file which
needed to be added to DJGPP's fnchange.lst.

gdb/ChangeLog

       * config/djgpp/fnchange.lst: Add entry for gdb/ChangeLog-2020.

3 years agoPR27116, Spelling errors found by Debian style checker
Alan Modra [Fri, 1 Jan 2021 03:51:52 +0000 (14:21 +1030)]
PR27116, Spelling errors found by Debian style checker

PR 27116
bfd/
* xcofflink.c: Correct spelling in comments.
binutils/
* coffgrok.c (do_type): Correct spelling of auxiliary in errors.
* doc/binutils.texi: Correct grammar.
* readelf.c (process_version_sections): Correct spelling of auxiliary
in warning.
* testsuite/binutils-all/vax/objdump.exp: Comment grammar fix.
config/
* override.m4: Correct comment grammar.
gas/
* config/tc-i386.c: Correct comment spelling.
* config/tc-riscv.c: Likewise.
* config/tc-s390.c: Correct comment grammar.
* doc/c-i386.texi: Correct spelling.
* doc/c-s390.texi: Correct grammar.
gold/
* tilegx.cc: Correct comment spelling.
gprof/
* README: Correct grammar.
* gprof.texi: Likewise.
include/
* coff/internal.h: Correct comment spelling.
* coff/sym.h: Likewise.
* opcode/aarch64.h: Likewise.
ld/
* configure.tgt: Correct comment grammar.
* emultempl/m68hc1xelf.em: Likewise.
* ld.texi: Correct grammar.

3 years agoUpdate year range in copyright notice of binutils files
Alan Modra [Thu, 31 Dec 2020 22:58:58 +0000 (09:28 +1030)]
Update year range in copyright notice of binutils files

3 years agoAdd libctf to update-copyright.py
Alan Modra [Thu, 31 Dec 2020 22:53:40 +0000 (09:23 +1030)]
Add libctf to update-copyright.py

3 years agoChangeLog rotation
Alan Modra [Thu, 31 Dec 2020 22:47:13 +0000 (09:17 +1030)]
ChangeLog rotation

3 years agoAutomatic date update in version.in
GDB Administrator [Fri, 1 Jan 2021 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agogas: Change to "swym 0" as canonical nop insn for MMIX
Hans-Peter Nilsson [Thu, 31 Dec 2020 23:47:36 +0000 (00:47 +0100)]
gas: Change to "swym 0" as canonical nop insn for MMIX

While "set $0, $0" works, that's not the documented instruction to do
nothing for MMIX.  However, I'm not changing it for "nop_type 5" as
seen in gas.exp and org-1.s, because "set $0, $0" seems like it could
be re-used there, for some future ISA.

gas/
* config/tc-mmix.h (md_single_noop_insn): Change to "swym 0".

3 years agoUpdate gdb.rust tests for Rust 1.49
Tom Tromey [Thu, 31 Dec 2020 21:55:27 +0000 (14:55 -0700)]
Update gdb.rust tests for Rust 1.49

Rust 1.49 was released today, and it includes some library changes
which caused some gdb.rust tests to fail.  This patch adapts the test
suite to the new output.  I also verified that this continues to work
with Rust 1.48.

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

* gdb.rust/simple.exp: Update output for Rust 1.49.

3 years agoPR27128, nm -P portable output format regression
Alan Modra [Wed, 30 Dec 2020 11:30:57 +0000 (22:00 +1030)]
PR27128, nm -P portable output format regression

binutils/
PR 27128
* nm.c (print_symname): Append version string to symbol name
before printing the lot under control of "form".  Append version
to demangled names too.
ld/
PR 27128
* testsuite/ld-elf/pr27128.s: New file.
* testsuite/ld-elf/pr27128.t: Likewise.
* testsuite/ld-elf/pr27128a.d: Likewise.
* testsuite/ld-elf/pr27128b.d: Likewise.
* testsuite/ld-elf/pr27128c.d: Likewise.
* testsuite/ld-elf/pr27128d.d: Likewise.
* testsuite/ld-elf/pr27128e.d: Likewise.

3 years agoFix passing debug options for gcc
Bernd Edlinger [Tue, 3 Nov 2020 17:41:43 +0000 (18:41 +0100)]
Fix passing debug options for gcc

Fix a bug in the test where we were missing "additional_flags=",
causing -gstatement-frontiers not to be passed to the compiler.

The issue was introduced in
eb24648c453c28f2898fb599311ba004394a8b41 ("Fix gdb.cp/step-and-next-inline.exp with Clang").

gdb/testsuite:
2020-12-31  Bernd Edlinger  <bernd.edlinger@hotmail.de>

* gdb.cp/step-and-next-inline.exp: Fix test case.

3 years agogdb/testsuite: de-duplicate test names in gdb.python/py-frame-args.exp
Simon Marchi [Thu, 31 Dec 2020 04:45:36 +0000 (23:45 -0500)]
gdb/testsuite: de-duplicate test names in gdb.python/py-frame-args.exp

Use with_test_prefix to de-duplicate test names.

gdb/testsuite/ChangeLog:

* gdb.python/py-frame-args.exp: De-duplicate test names.

Change-Id: I5cc8bee692a0d071cb78258aca80ea642e00e7a8

3 years agosim/mips/sim-main.c: Include <stdlib.h> (for abort() declaration)
Pavel I. Kryukov [Thu, 31 Dec 2020 04:14:36 +0000 (08:14 +0400)]
sim/mips/sim-main.c: Include <stdlib.h> (for abort() declaration)

sim/mips/ChangeLog:

* sim-main.c: Include <stdlib.h>.

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

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

3 years agoelfedit: Pass osabi to reconcat
H.J. Lu [Tue, 29 Dec 2020 18:37:24 +0000 (10:37 -0800)]
elfedit: Pass osabi to reconcat

Pass osabi to reconcat to get

Usage: elfedit <option(s)> elffile(s)
...
  --input-osabi [none|HPUX|NetBSD|GNU|Linux|Solaris|AIX|Irix|FreeBSD|TRU64|Modesto|OpenBSD|OpenVMS|NSK|AROS|FenixOS]
                              Set input OSABI

instead of

  --input-osabi [|FenixOS]
                              Set input OSABI

* elfedit (usage): Pass osabi to reconcat.

3 years agoFix wrong method name
Hannes Domani [Tue, 29 Dec 2020 16:18:22 +0000 (17:18 +0100)]
Fix wrong method name

The objects returned by FrameDecorator.frame_args need to implement a
method named symbol, not argument.

gdb/doc/ChangeLog:

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

* python.texi (Frame Decorator API): Fix method name.

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

3 years agobinutils: Use the newly built assembler and linker
H.J. Lu [Mon, 28 Dec 2020 18:44:28 +0000 (10:44 -0800)]
binutils: Use the newly built assembler and linker

Use the newly built assembler and linker in test_gnu_debuglink by passing
$gcc_gas_flag to target_compile.

* testsuite/binutils-all/compress.exp (test_gnu_debuglink): Pass
$gcc_gas_flag to target_compile.

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

3 years agoSimplify MULTI_SUBSCRIPT implementation
Tom Tromey [Sun, 27 Dec 2020 20:36:55 +0000 (13:36 -0700)]
Simplify MULTI_SUBSCRIPT implementation

The MULTI_SUBSCRIPT code in evaluate_subexp_standard has a comment
saying that perhaps the EVAL_SKIP handling is incorrect.  This patch
simplifies this code.  In particular, it precomputes all the indices
in a separate loop and removes some complicated flow-control.

Tested using the gdb.modula2 and gdb.dlang test suites, as these are
the only parsers that emit MULTI_SUBSCRIPT.

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

* eval.c (evaluate_subexp_standard) <case MULTI_SUBSCRIPT>:
Simplify.

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

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

3 years agogas: Update 80387 floating point 's' suffix
H.J. Lu [Fri, 25 Dec 2020 13:56:36 +0000 (05:56 -0800)]
gas: Update 80387 floating point 's' suffix

Update 80387 floating point 's' suffix to read:

  * Integer constructors are '.word', '.long' or '.int', and '.quad'
     for the 16-, 32-, and 64-bit integer formats.  The corresponding
     instruction mnemonic suffixes are 's' (short), 'l' (long), and 'q'
     (quad).

instead of 's' (single).

PR gas/27106
* doc/c-i386.texi: Update 80387 floating point 's' suffix

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

3 years agogdb: avoid resolving dynamic properties for non-allocated arrays
Andrew Burgess [Fri, 18 Dec 2020 11:59:54 +0000 (11:59 +0000)]
gdb: avoid resolving dynamic properties for non-allocated arrays

In PR gdb/27059 an issue was discovered where GDB would sometimes
trigger undefined behaviour in the form of signed integer overflow.
The problem here is that GDB was reading random garbage from the
inferior memory space, assuming this data was valid, and performing
arithmetic on it.

This bug raises an interesting general problem with GDB's DWARF
expression evaluator, which is this:

We currently assume that the DWARF expressions being evaluated are
well formed, and well behaving.  As an example, this is the expression
that the bug was running into problems on, this was used as the
expression for a DW_AT_byte_stride of a DW_TAG_subrange_type:

DW_OP_push_object_address;
DW_OP_plus_uconst: 88;
DW_OP_deref;
DW_OP_push_object_address;
DW_OP_plus_uconst: 32;
DW_OP_deref;
DW_OP_mul

Two values are read from the inferior and multiplied together.  GDB
should not assume that any value read from the inferior is in any way
sane, as such the implementation of DW_OP_mul should be guarding
against overflow and doing something semi-sane here.

However, it turns out that the original bug PR gdb/27059, is hitting a
more specific case, which doesn't require changes to the DWARF
expression evaluator, so I'm going to leave the above issue for
another day.

In the test mentioned in the bug GDB is actually trying to resolve the
dynamic type of a Fortran array that is NOT allocated.  A
non-allocated Fortran array is one that does not have any data
allocated for it yet, and even the upper and lower bounds of the array
are not yet known.

It turns out that, at least for gfortran compiled code, the data
fields that describe the byte-stride are not initialised until the
array is allocated.

This leads me to the following conclusion: GDB should not try to
resolve the bounds, or stride information for an array that is not
allocated (or not associated, a similar, but slightly different
Fortran feature).  Instead, each of these properties should be set to
undefined if the array is not allocated (or associated).

That is what this commit does.  There's a new flag that is passed
around during the dynamic array resolution.  When this flag is true
the dynamic properties are resolved using the DWARF expressions as
they currently are, but when this flag is false the expressions are
not evaluated, and instead the properties are set to undefined.

gdb/ChangeLog:

PR gdb/27059
* eval.c (evaluate_subexp_for_sizeof): Handle not allocated and
not associated arrays.
* f-lang.c (fortran_adjust_dynamic_array_base_address_hack): Don't
adjust arrays that are not allocated/associated.
* gdbtypes.c (resolve_dynamic_range): Update header comment.  Add
new parameter which is used to sometimes set dynamic properties to
undefined.
(resolve_dynamic_array_or_string): Update header comment.  Add new
parameter which is used to guard evaluating dynamic properties.
Resolve allocated/associated properties first.

gdb/testsuite/ChangeLog:

PR gdb/27059
* gdb.dwarf2/dyn-type-unallocated.c: New file.
* gdb.dwarf2/dyn-type-unallocated.exp: New file.

3 years agogdb: include allocated/associated properties in 'maint print type'
Andrew Burgess [Fri, 18 Dec 2020 18:15:06 +0000 (18:15 +0000)]
gdb: include allocated/associated properties in 'maint print type'

Adds the allocated and associated dynamic properties into the output
of the 'maintenance print type' command.

gdb/ChangeLog:

* gdbtypes (recursive_dump_type): Include allocated and associated
properties.

3 years agogdb/gdbtypes.h: Fix comparison of uninitialized values
Lancelot SIX [Thu, 24 Dec 2020 16:01:21 +0000 (11:01 -0500)]
gdb/gdbtypes.h: Fix comparison of uninitialized values

When called with an array type of unknown dimensions,
is_scalar_type_recursive ended up comparing uninitialized values.

This was picked up by the following compiler warning:

  CXX    gdbtypes.o
/binutils-gdb/gdb/gdbtypes.c: In function int is_scalar_type_recursive(type*):
/binutils-gdb/gdb/gdbtypes.c:3670:38: warning: high_bound may be used uninitialized in this function [-Wmaybe-uninitialized]
 3670 |       return high_bound == low_bound && is_scalar_type_recursive (elt_type);
      | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/binutils-gdb/gdb/gdbtypes.c:3670:38: warning: low_bound may be used uninitialized in this function [-Wmaybe-uninitialized]

This patch makes sure that when dealing with an array of unknown size
(or an array of more than 1 element), is_scalar_type_recursive returns
false.

gdb/ChangeLog:

* gdbtypes.c (is_scalar_type_recursive): Prevent comparison
between uninitialized values.

Change-Id: Ifc005ced166aa7a065fef3e652977bae67625bf4

3 years agoSHF_GNU_RETAIN 7a and 7b tests
Alan Modra [Thu, 24 Dec 2020 12:22:51 +0000 (22:52 +1030)]
SHF_GNU_RETAIN 7a and 7b tests

* testsuite/ld-elf/retain7a.d: Don't run on hppa-linux.
* testsuite/ld-elf/retain7b.d: Correct name.  Don't run on tic6x.
Allow OSABI FreeBSD.

3 years agoasan: print_vms_time signed integer overflow
Alan Modra [Thu, 24 Dec 2020 05:41:03 +0000 (16:11 +1030)]
asan: print_vms_time signed integer overflow

I really don't think anyone cares about underflow of vms time values,
but the potential segfault on a gmtime failure is worth fixing.

* readelf.c (INT64_MIN): Define if not already defined.
(print_vms_time): Catch 64-bit overflow when converting from
vms time to posix time.  Don't segfault if gmtime returns NULL.

3 years agoPR27100, final link failed: bad value
Alan Modra [Thu, 24 Dec 2020 05:26:23 +0000 (15:56 +1030)]
PR27100, final link failed: bad value

The failure on this PR is due to using the same bfd section for
multiple output sections.  Commit 21401fc7bf67 managed to create
duplicate linker script output section statements, but not the actual
bfd sections.

PR 27100
* ldlang.h (lang_output_section_statement_type): Add dup_output.
* ldlang.c (lang_output_section_statement_lookup): Set dup_output.
(init_os): Test dup_output rather than constraint.
* testsuite/ld-scripts/pr27100.d,
* testsuite/ld-scripts/pr27100.s,
* testsuite/ld-scripts/pr27100.t: New test.
* testsuite/ld-scripts/data.exp: Run it.  Don't exclude aout here.
* testsuite/ld-scripts/data.d: Do so here instead.
* testsuite/ld-scripts/fill.d: Likewise.
* testsuite/ld-scripts/fill16.d: Likewise.

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

3 years agoClarify language for the '?' packet
Alex Bennée [Wed, 23 Dec 2020 21:36:16 +0000 (16:36 -0500)]
Clarify language for the '?' packet

Both QEMU and kgdb make the assumption that the '?' packet is only
sent during the initial setup of a gdbstub connection. Both use that
knowledge to reset breakpoints and ensure the gdbstub is in a
clean-state on a resumed connection. This can cause confusion for
others implementing clients that speak to gdbstub devices. To avoid
that make the language clearer that this is a start-up query packet
that you only expect to see once.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
gdb/doc/ChangeLog:

* gdb.texinfo (Packets): Clarify language for ? packet.

Change-Id: Iae25d3110fe28b8d2467704962a6889e55224ca5

3 years agox86-64: Add Intel LAM property support
H.J. Lu [Wed, 23 Dec 2020 21:00:39 +0000 (13:00 -0800)]
x86-64: Add Intel LAM property support

Add Intel Linear Address Masking (LAM) property support.  LAM modifies
the checking that is applied to 64-bit linear addresses, allowing
software to use of the untranslated address bits for metadata.

bfd/

* elf-linker-x86.h (elf_x86_cet_report): Renamed to ...
(elf_x86_prop_report): This.
(elf_linker_x86_params): Add lam_u48, lam_u57, lam_u48_report
and lam_u57_report.
* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Support
GNU_PROPERTY_X86_FEATURE_1_LAM_U48 and
GNU_PROPERTY_X86_FEATURE_1_LAM_U57.
(_bfd_x86_elf_link_fixup_gnu_properties): Keep LAM features only
for 64-bit output.

binutils/

* NEWS: Mention LAM_U48 and LAM_U57 support.
* elfedit.c (elf_x86_feature): Support lam_u48 and lam_u57.
(usage): Add lam_u48 and lam_u57.
* readelf.c (decode_x86_feature_1): Support LAM_U48 and LAM_U57.
* doc/binutils.texi: Update elfedit with lam_u48 and lam_u57
support.
* testsuite/binutils-all/x86-64/lam-u48.d: New file.
* testsuite/binutils-all/x86-64/lam-u48.s: Likewise.
* testsuite/binutils-all/x86-64/lam-u57.d: Likewise.
* testsuite/binutils-all/x86-64/lam-u57.s: Likewise.

include/

* elf/common.h (GNU_PROPERTY_X86_FEATURE_1_LAM_U48): New.
(GNU_PROPERTY_X86_FEATURE_1_LAM_U57): Likewise.

ld/

* NEWS: Mention LAM_U48 and LAM_U57 support.
* ld.texi: Document LAM_U48 and LAM_U57 support.
* emulparams/cet.sh: Updated.
* emulparams/elf_x86_64.sh: Source x86-64-lam.sh.
* emulparams/x86-64-lam.sh: New file.
* testsuite/ld-x86-64/property-x86-lam-u48-1a.d: Likewise.
* testsuite/ld-x86-64/property-x86-lam-u48-1b.d: Likewise.
* testsuite/ld-x86-64/property-x86-lam-u48-2.d: Likewise.
* testsuite/ld-x86-64/property-x86-lam-u48-3a.d: Likewise.
* testsuite/ld-x86-64/property-x86-lam-u48-3b.d: Likewise.
* testsuite/ld-x86-64/property-x86-lam-u48-4.d: Likewise.
* testsuite/ld-x86-64/property-x86-lam-u48-5.d: Likewise.
* testsuite/ld-x86-64/property-x86-lam-u48.s: Likewise.
* testsuite/ld-x86-64/property-x86-lam-u57-1a.d: Likewise.
* testsuite/ld-x86-64/property-x86-lam-u57-1b.d: Likewise.
* testsuite/ld-x86-64/property-x86-lam-u57-2.d: Likewise.
* testsuite/ld-x86-64/property-x86-lam-u57-3a.d: Likewise.
* testsuite/ld-x86-64/property-x86-lam-u57-3b.d: Likewise.
* testsuite/ld-x86-64/property-x86-lam-u57-4.d: Likewise.
* testsuite/ld-x86-64/property-x86-lam-u57-5.d: Likewise.
* testsuite/ld-x86-64/property-x86-lam-u57.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run LAM tests.

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