binutils-gdb.git
4 years agoRemove a call to show_source_line from TUI
Tom Tromey [Mon, 28 Sep 2020 02:30:30 +0000 (20:30 -0600)]
Remove a call to show_source_line from TUI

This removes a call to show_source_line from tui_source_window_base.
This call isn't needed because this function already calls the
'refill' method if the state changed.

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

* tui/tui-winsource.c
(tui_source_window_base::set_is_exec_point_at): Don't call
show_source_line.

4 years agoUse an inner window in tui_py_window
Tom Tromey [Mon, 28 Sep 2020 02:30:30 +0000 (20:30 -0600)]
Use an inner window in tui_py_window

This changes tui_py_window to create an inner curses window.  This
greatly simplifies tui_py_window::output, beacuse it no longer needs
to be careful to avoid overwriting the window's border.  This patch
also makes it a bit easier for a later patch to rewrite
tui_copy_source_line.

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

* python/py-tui.c (class tui_py_window) <refresh_window>: New
method.
<erase>: Update.
<cursor_x, cursor_y>: Remove.
<m_inner_window>: New member.
(tui_py_window::rerender): Create inner window.
(tui_py_window::output): Write to inner window.

4 years agoRemove test duplicate from gdb.tui
Tom Tromey [Mon, 28 Sep 2020 02:30:30 +0000 (20:30 -0600)]
Remove test duplicate from gdb.tui

I noticed a duplicated test in gdb.tui.  This patch removes it by
wrapping a test in with_test_prefix.

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

* gdb.tui/new-layout.exp: Use with_test_prefix.

4 years agoRe: PR26656, power10 libstdc++.so segfault in __cxxabiv1::__cxa_throw
Alan Modra [Mon, 28 Sep 2020 00:00:19 +0000 (09:30 +0930)]
Re: PR26656, power10 libstdc++.so segfault in __cxxabiv1::__cxa_throw

Some missing NULL checks meant a stub for a local symbol used a stub
looking like the __tls_get_addr_opt stub.

PR 26656
* elf64-ppc.c (ppc_build_one_stub, ppc_size_one_stub): Check for
NULL stub_entry->h before calling is_tls_get_addr.

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 28 Sep 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

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

4 years agogdb: Fix from_tty argument to gdb.execute in Python.
Gareth Rees [Sat, 26 Sep 2020 18:01:45 +0000 (11:01 -0700)]
gdb: Fix from_tty argument to gdb.execute in Python.

Prior to commit 56bcdbea2b, the from_tty keyword argument to the
Python function gdb.execute controlled whether the command took input
from the terminal. When from_tty=True, "starti" and similar commands
prompted the user:

    (gdb) python gdb.execute("starti", from_tty=True)
    The program being debugged has been started already.
    Start it from the beginning? (y or n) y
    Starting program: /bin/true

    Program stopped.

When from_tty=False, these commands did not prompt the user, and "yes"
was assumed:

    (gdb) python gdb.execute("starti", from_tty=False)

    Program stopped.

However, after commit 56bcdbea2b, the from_tty keyword argument no
longer had this effect. For example, as of commit 7ade7fba75:

    (gdb) python gdb.execute("starti", from_tty=True)
    The program being debugged has been started already.
    Start it from the beginning? (y or n) [answered Y; input not from terminal]
    Starting program: /bin/true

    Program stopped.

Note the "[answered Y; input not from terminal]" in the output even
though from_tty=True was requested.

Looking at commit 56bcdbea2b, it seems that the behaviour of the
from_tty argument was changed accidentally. The commit message said:

    Let gdb.execute handle multi-line commands

    This changes the Python API so that gdb.execute can now handle
    multi-line commands, like "commands" or "define".

and there was no mention of changing the effect of the from_tty
argument. It looks as though the code for setting the instream to
nullptr was accidentally moved from execute_user_command() to
execute_control_commands() along with the other scoped restores.

Accordingly, the simplest way to fix this is to partially reverse
commit 56bcdbea2b by moving the code for setting the instream to
nullptr back to execute_user_command() where it was to begin with.

Additionally, add a test case to reduce the risk of similar breakage
in future.

gdb/ChangeLog:

PR python/26586
* cli/cli-script.c (execute_control_commands): don't set
instream to nullptr here as this breaks the from_tty argument
to gdb.execute in Python.
(execute_user_command): set instream to nullptr here instead.

gdb/testsuite/ChangeLog:

PR python/26586
* gdb.python/python.exp: add test cases for the from_tty
argument to gdb.execute.

4 years ago[GOLD] PPC64_OPT_LOCALENTRY is incompatible with tail calls
Alan Modra [Sat, 26 Sep 2020 11:04:55 +0000 (20:34 +0930)]
[GOLD] PPC64_OPT_LOCALENTRY is incompatible with tail calls

Gold version of commit 3cd7c7d7ef.

* powerpc.cc (Target_powerpc): Rename power10_stubs_ to
power10_relocs_.
(Target_powerpc::set_power10_relocs): New accessor.
(Target_powerpc::set_power10_stubs): Delete.
(Target_powerpc::power10_stubs): Adjust.
(Target_powerpc::has_localentry0): New accessor.
(ld_0_11): New constant.
(glink_eh_frame_fde_64v1, glink_eh_frame_fde_64v2): Adjust.
(glink_eh_frame_fde_64v2_localentry0): New.
(Output_data_glink::pltresolve_size): Update.
(Output_data_glink::add_eh_frame): Use localentry0 version eh_frame.
(Output_data_glink::do_write): Move r2 save to start of ELFv2 stub
and only emit for has_localentry0.  Don't use r2 in the stub.
(Target_powerpc::Scan::local, global): Adjust for
set_power10_relocs renaming.
(Target_powerpc::scan_relocs): Warn and reset plt_localentry0_.

4 years agoPPC64_OPT_LOCALENTRY is incompatible with tail calls
Alan Modra [Sat, 26 Sep 2020 05:40:09 +0000 (15:10 +0930)]
PPC64_OPT_LOCALENTRY is incompatible with tail calls

The save of r2 in __glink_PLTresolve is the culprit.  Remove it,
unless we know we need it for --plt-localentry.  --plt-localentry
should not be used with power10 pc-relative code that makes tail
calls.

The patch also removes use of r2 as a scratch reg in the ELFv2
__glink_PLTresolve.  Using r2 isn't a problem, this is just reducing
the number of scratch regs.

bfd/
* elf64-ppc.c (GLINK_PLTRESOLVE_SIZE): Depend on has_plt_localentry0.
(LD_R0_0R11, ADD_R11_R0_R11): Define.
(ppc64_elf_tls_setup): Disable params->plt_localentry0 when power10
code detected.
(ppc64_elf_size_stubs): Update __glink_PLTresolve eh_frame.
(ppc64_elf_build_stubs): Move r2 save to start of __glink_PLTresolve,
and only emit for has_plt_localentry0.  Don't use r2 in the stub.
ld/
* testsuite/ld-powerpc/elfv2so.d,
* testsuite/ld-powerpc/notoc2.d,
* testsuite/ld-powerpc/tlsdesc.wf,
* testsuite/ld-powerpc/tlsdesc2.d,
* testsuite/ld-powerpc/tlsdesc2.wf,
* testsuite/ld-powerpc/tlsopt5.d,
* testsuite/ld-powerpc/tlsopt5.wf,
* testsuite/ld-powerpc/tlsopt6.d,
* testsuite/ld-powerpc/tlsopt6.wf: Update __glink_PLTresolve.

4 years agoubsan: opcodes/csky-opc.h:929 shift exponent 536870912
Alan Modra [Fri, 25 Sep 2020 11:22:46 +0000 (20:52 +0930)]
ubsan: opcodes/csky-opc.h:929 shift exponent 536870912

opcodes/
* csky-opc.h: Formatting.
(GENERAL_REG_BANK): Correct spelling.  Update use throughout file.
(get_register_name): Mask arch with CSKY_ARCH_MASK for shift,
and shift 1u.
(get_register_number): Likewise.
* csky-dis.c (get_gr_name, get_cr_name): Don't mask mach_flag.
gas/
* config/tc-csky.c (parse_type_ctrlreg): Don't mask mach_flag
for csky_get_control_regno.
(csky_get_reg_val): Likewise when calling csky_get_general_regno.

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

4 years agogdb: fix formatting of _debug_printf macros
Simon Marchi [Fri, 25 Sep 2020 18:54:16 +0000 (14:54 -0400)]
gdb: fix formatting of _debug_printf macros

The do/while in these macros are not formatted with proper GNU style,
fix that.

gdb/ChangeLog:

* infrun.h (infrun_debug_printf): Fix formatting.
* linux-nat.c (linux_nat_debug_printf): Fix formatting.

Change-Id: I3a723663c76d9091f785941923c2b6cf67459629

4 years agoAdd a missing munmap_list move constructor
Saagar Jha [Fri, 25 Sep 2020 07:05:24 +0000 (00:05 -0700)]
Add a missing munmap_list move constructor

compile_module attempts to request a move constructor, but because
munmap_list doesn't have one it gets implicitly deleted. This is an
warning on clang under -Wdefaulted-function-deleted (which is enabled by
default):

In file included from compile/compile-object-load.c:21:
compile/compile-object-load.h:56:3: error: explicitly defaulted move constructor is implicitly deleted [-Werror,-Wdefaulted-function-deleted]
  compile_module (compile_module &&other) = default;
  ^
compile/compile-object-load.h:86:22: note: move constructor of 'compile_module' is implicitly deleted because field 'munmap_list' has a deleted move constructor
  struct munmap_list munmap_list;
                     ^
compile/compile-object-load.h:30:28: note: 'munmap_list' has been explicitly marked deleted here
  DISABLE_COPY_AND_ASSIGN (munmap_list);
                           ^

gdb/ChangeLog:

* compile/compile-object-load.h: Give munmap_list a move
constructor.

Change-Id: I300c52e27da70087f18c7e359773c2b984073d8b

4 years agoImport mklog.py from gcc repo
Simon Marchi [Fri, 25 Sep 2020 14:24:29 +0000 (10:24 -0400)]
Import mklog.py from gcc repo

I've been using the mklog utility from the gcc repo for a while to
generate skeleton of ChangeLog entries.  It recently got a rewrite as a
Python script.  Unfortunately, to find the repository root, and
eventually to find in which ChangeLog file each entry goes, the new
script assumes it is located in the same git repository that it
generates ChangeLog entries for.

This means that if you make a change in the gcc source tree and run
mklog.py from that same source tree, it works.  But if you make changes
in your ~/src/binutils-gdb tree and run ~/src/gcc/contrib/mklog.py, it
won't work.

IIRC, the old script required that you ran it with the project's root
directory as the CWD.

The simplest way to fix this is to import the script in binutils-gdb and
use it from there.  It's also nice because we can use it without having
a clone of the gcc repo.

I also thought of adding a "--root" switch to the script to override the
project's base directory.  However:

1) It is more work.
2) If the script still lives in the gcc repo, it's less convenient than
   having it in binutils-gdb.

This patch imports contrib/mklog.py from the gcc repo, revision
c560591408440f441b8b327f5b41f9328d20b67b.

contrib/ChangeLog:

* mklog.py: New file, imported from gcc.

Note: the ChangeLog entry above was generated using
`git show | ./mklog.py`!

Change-Id: I955592ce6397681986dc82a09593c32d8b8de54f

4 years agogdb: fix whitespaces in ChangeLog
Simon Marchi [Fri, 25 Sep 2020 14:20:32 +0000 (10:20 -0400)]
gdb: fix whitespaces in ChangeLog

Change-Id: Ie5accb8915341cf9b4ed23162f9503d7ef947fcf

4 years agoFix gdb.base/infcall-nested-structs-c++.exp with Clang
Gary Benson [Fri, 25 Sep 2020 13:44:07 +0000 (14:44 +0100)]
Fix gdb.base/infcall-nested-structs-c++.exp with Clang

gdb.base/infcall-nested-structs-c++.exp failed to build using Clang
with many variations on the following error:

  gdb compile failed, /gdbtest/src/gdb/testsuite/gdb.base/infcall-nested-structs.c:207:46:
    warning: self-comparison always evaluates to true [-Wtautological-compare]

This commit builds this testcase with -Wno-tautological-compare when
using Clang, to avoid this failure.

gdb/testsuite/ChangeLog:

* gdb.base/infcall-nested-structs.exp.tcl: Add
additional_flags=-Wno-tautological-compare for C++
tests when compiling using Clang.

4 years agoFix compilation of .c files as C++ when using Clang
Gary Benson [Fri, 25 Sep 2020 13:29:35 +0000 (14:29 +0100)]
Fix compilation of .c files as C++ when using Clang

In commit 221db974e653659edb280787af1b3efdd1615083, this patch:

    2020-06-24  Pedro Alves  <palves@redhat.com>

    * lib/gdb.exp (gdb_compile): Pass "-x c++" explicitly when
    compiling C++ programs.

attempted to fix problems with testcases that compile .c files
with the C++ compiler.  They pass the "c++" option to gdb_compile,
resulting in the following error when using Clang:

    gdb compile failed, clang-10: warning: treating 'c' input as 'c++'
    when in C++ mode, this behavior is deprecated [-Wdeprecated]

This fix did not work for gdb.base/infcall-nested-structs-c++.exp,
however: the "-x c++" appeared in the compiler's commandline after
the .c file, so the option was not enabled for that file.

The previous files fixed all used build_executable_from_specs, which
compiles and links in separate steps, using gdb_compile: the compile
step passes $type=object to gdb_compile, while the link step passes
$type=executable.

gdb.base/infcall-nested-structs-c++.exp uses gdb_compile directly
instead, and it passes $type=executable to compile and link all in
one step.  Pedro found that DejaGnu's default_target_compile adds
the sources at the end when $type=object, but at the beginning when
$type=executable:

    # This is obscure: we put SOURCES at the end when building an
    # object, because otherwise, in some situations, libtool will
    # become confused about the name of the actual source file.
    if {$type == "object"} {
        set opts "$add_flags $sources"
    } else {
        set opts "$sources $add_flags"
    }

This commit moves the "-x c++" earlier in the compiler's commandline.
Unfortunately this then broke the testcase that required the original
fix, gdb.compile/compile-cplus.exp: the "-x c++" was being parsed for
the linker pass, causing the compiler to attempt to parse the .o files
as C++.  This commit makes passing "-x c++" conditional on the source
being a .c file.

gdb/testsuite/ChangeLog:

* lib/gdb.exp (gdb_compile): Pass "-x c++" earlier, and only
for .c files.

4 years agoasan: readelf buffer overflow and abort
Alan Modra [Fri, 25 Sep 2020 00:35:57 +0000 (10:05 +0930)]
asan: readelf buffer overflow and abort

* elfcomm.c (byte_put_little_endian, byte_put_big_endian): Support
more field sizes.
* readelf.c (target_specific_reloc_handling <MSP430>): Limit
allowed reloc_size.  Don't read_leb128 outside of section.

4 years agoRe: Sync libiberty and include with GCC for get_DW_UT_name
Alan Modra [Fri, 25 Sep 2020 00:30:01 +0000 (10:00 +0930)]
Re: Sync libiberty and include with GCC for get_DW_UT_name

* dwarf.h (DW_FIRST_UT, DW_UT, DW_END_UT): Define.

4 years agoPut together MOD_VEX_0F38* in i386-dis.c,
Cui,Lili [Wed, 23 Sep 2020 02:30:26 +0000 (10:30 +0800)]
Put together MOD_VEX_0F38* in i386-dis.c,

There are 11 MOD_VEX_0F38* inserted in MOD_0F38* group,
which should be placed in MOD_VEX_0F38* group.

opcode/
PR 26654
*i386-dis.c (enum): Put MOD_VEX_0F38* together.

4 years agoAutomatic date update in version.in
GDB Administrator [Fri, 25 Sep 2020 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoRISC-V: Error for relaxable branch in absolute section.
Jim Wilson [Thu, 24 Sep 2020 22:08:52 +0000 (15:08 -0700)]
RISC-V: Error for relaxable branch in absolute section.

Emit an error instead of crashing in frag_new, handling this same as the
i386 port.

gas/
PR 26400
* config/tc-riscv.c (append_insn): If in absolute section, emit
error before add_relaxed_insn call.
* testsuite/gas/riscv/absolute-sec.d: New.
* testsuite/gas/riscv/absolute-sec.l: New.
* testsuite/gas/riscv/absolute-sec.s: New.

4 years agoreadelf: Show Unit Type for DWARF5
Mark Wielaard [Wed, 23 Sep 2020 14:48:35 +0000 (16:48 +0200)]
readelf: Show Unit Type for DWARF5

binutils/ChangeLog:

* dwarf.c (process_debug_info): Print Unit Type for DWARF5.
* testsuite/binutils-all/dw5.W: Adjust expected output.
* testsuite/binutils-all/dwarf-attributes.W: Likewise.

gas/ChangeLog:

* testsuite/gas/elf/dwarf-5-cu.d: Adjust expected output.

4 years agoSync libiberty and include with GCC for get_DW_UT_name.
Mark Wielaard [Wed, 23 Sep 2020 14:41:06 +0000 (16:41 +0200)]
Sync libiberty and include with GCC for get_DW_UT_name.

This adds a get_DW_UT_name function to dwarfnames using dwarf2.def
for use in binutils readelf to show the unit types in a DWARF5 header.

include/ChangeLog:

Sync with GCC
* dwarf2.def: Add DWARF5 Unit type header encoding macros
DW_UT_FIRST, DW_UT and DW_UT_END.
* dwarf2.h (enum dwarf_unit_type): Removed and define using
DW_UT_FIRST, DW_UT and DW_UT_END macros.
(get_DW_UT_name): New function declaration.

libiberty/ChangeLog:

Sync with GCC
* dwarfnames.c (get_DW_UT_name): Define using DW_UT_FIRST, DW_UT
and DW_UT_END.

4 years agobinutils: Handle DWARF5 DW_FORM_ref_addr and DW_UT_partial.
Mark Wielaard [Wed, 23 Sep 2020 14:31:14 +0000 (16:31 +0200)]
binutils: Handle DWARF5 DW_FORM_ref_addr and DW_UT_partial.

dwz in DWARF5 mode might produce DW_UT_partial unit types, which are
the same as DW_UT_compile unit types (but start with a DW_TAG_partial_unit)
and it might produce DW_FORM_ref_addr to create a reference between
units. Accept both constructs.

binutils/ChangeLog:

* dwarf.c (read_and_display_attr_value): Handle DW_FORM_ref_addr
for dwarf_version 5 just as version 3 and 4 (only 2 is different).
(process_debug_info): Allow DW_UT_partial.

4 years agogdb: remove file_handler typedef
Simon Marchi [Thu, 24 Sep 2020 19:19:46 +0000 (15:19 -0400)]
gdb: remove file_handler typedef

Remove the typedef (unneeded with C++).  Re-format the comments to
follow the more common style.

gdbsupport/ChangeLog:

* event-loop.c (struct file_handler): Remove typedef, re-format.

Change-Id: I3aea21fba1eb2584c507de3412da4e4c98283b2d

4 years agoDon't let TUI focus on locator
Tom Tromey [Wed, 23 Sep 2020 18:57:19 +0000 (12:57 -0600)]
Don't let TUI focus on locator

PR tui/26638 notes that the C-x o binding can put the focus on the
locator window.  However, this is not useful and did not happen
historically.  This patch changes the TUI to skip this window when
switching focus.

gdb/ChangeLog
2020-09-24  Tom Tromey  <tromey@adacore.com>

PR tui/26638:
* tui/tui-stack.h (struct tui_locator_window) <can_focus>: New
method.
* tui/tui-data.h (struct tui_win_info) <can_focus>: New method.
* tui/tui-data.c (tui_next_win): Exclude non-focusable windows.
(tui_prev_win): Rewrite.

gdb/testsuite/ChangeLog
2020-09-24  Tom Tromey  <tromey@adacore.com>

PR tui/26638:
* gdb.tui/list.exp: Check output of "focus next".

4 years agoHandle 64bit breakpoints of WOW64 processes as SIGINT
Hannes Domani [Wed, 23 Sep 2020 16:16:24 +0000 (18:16 +0200)]
Handle 64bit breakpoints of WOW64 processes as SIGINT

When a WOW64 process triggers a breakpoint exception in 64bit code (which
happens when a 64bit gdb calls DebugBreakProcess for a 32bit target),
gdb ignores the breakpoint (because Wow64GetThreadContext can only report
the pc of 32bit code, and there is not int3 at this location).

But if these 64bit breakpoint exceptions are handled as SIGINT, gdb
doesn't check for int3, and always stops the target.

gdb/ChangeLog:

2020-09-23  Hannes Domani  <ssbssa@yahoo.de>

* nat/windows-nat.c (handle_exception): Handle 64bit breakpoints
in WOW64 processes as SIGINT.
* nat/windows-nat.h: Make wow64_process a shared variable.
* windows-nat.c: Remove static wow64_process variable.

gdbserver/ChangeLog:

2020-09-23  Hannes Domani  <ssbssa@yahoo.de>

* win32-low.cc: Remove local wow64_process variable.
* win32-low.h: Remove local wow64_process variable.

4 years agoarm: Add support for Neoverse V1 CPU
Alex Coplan [Thu, 24 Sep 2020 14:35:30 +0000 (15:35 +0100)]
arm: Add support for Neoverse V1 CPU

This patch adds support for Arm's Neoverse V1 CPU to AArch32 binutils.

gas/ChangeLog:

2020-09-24  Alex Coplan  <alex.coplan@arm.com>

* config/tc-arm.c (arm_cpus): Add Neoverse V1.
* doc/c-arm.texi: Document Neoverse V1 support.

4 years agoaarch64: Add support for Neoverse V1 CPU
Alex Coplan [Thu, 24 Sep 2020 14:25:04 +0000 (15:25 +0100)]
aarch64: Add support for Neoverse V1 CPU

This adds support for Arm's Neoverse V1 CPU to AArch64 binutils.

gas/ChangeLog:

2020-09-24  Alex Coplan  <alex.coplan@arm.com>

* config/tc-aarch64.c (aarch64_cpu_option_table): Add Neoverse V1.
* doc/c-aarch64.texi: Document Neoverse V1 support.

4 years agocsky/opcodes: enclose if body in curly braces
Andrew Burgess [Thu, 24 Sep 2020 14:03:43 +0000 (15:03 +0100)]
csky/opcodes: enclose if body in curly braces

This commit:

  commit afdcafe89118cee761f9bf67ea1b1efc29311300
  Date:   Thu Sep 17 14:30:28 2020 +0800

      CSKY: Add objdump option -M abi-names.

cases the build of GDB (configured with --enabled-targets=all) to fail
with this error:

  libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../src/opcodes -I. -I../../src/opcodes -I../bfd -I../../src/opcodes/../include -I../../src/opcodes/../bfd -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Werror -O0 -g3 -D_GLIBCXX_DEBUG=1 -MT csky-dis.lo -MD -MP -MF .deps/csky-dis.Tpo -c ../../src/opcodes/csky-dis.c -o csky-dis.o
  ../../src/opcodes/csky-dis.c: In function 'csky_output_operand':
  ../../src/opcodes/csky-dis.c:849:7: error: this 'if' clause does not guard... [-Werror=misleading-indentation]
    849 |       if (IS_CSKY_V1 (mach_flag))
        |       ^~
  ../../src/opcodes/csky-dis.c:851:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    851 |  strcat (str, buf);
        |  ^~~~~~

this commit adds { ... } around the if body to resolve this issue.

opcodes/ChangeLog:

* csky-dis.c (csky_output_operand): Enclose body of if in curly
braces.

4 years agoDocument that the lower case 'c' character in nm's output is used to signify a small...
Nick Clifton [Thu, 24 Sep 2020 13:23:39 +0000 (14:23 +0100)]
Document that the lower case 'c' character in nm's output is used to signify a small common.

PR 26662
* doc/binutils.texi (nm): Document that 'c' is used for small
common symbols.

4 years agoarm: Add support for Neoverse N2 CPU
Alex Coplan [Thu, 24 Sep 2020 09:10:52 +0000 (10:10 +0100)]
arm: Add support for Neoverse N2 CPU

This adds support for Arm's Neoverse N2 CPU to AArch32 binutils. The
Neoverse N2 CPU builds AArch32 at EL0 and therefore needs support in the
AArch32 assembler.

gas/ChangeLog:

2020-09-24  Alex Coplan  <alex.coplan@arm.com>

* config/tc-arm.c (arm_cpus): Add Neoverse N2.
* doc/c-arm.texi: Document -mcpu=neoverse-n2.

4 years agoAdd support for Intel TDX instructions.
Cui,Lili [Tue, 9 Jun 2020 02:43:39 +0000 (10:43 +0800)]
Add support for Intel TDX instructions.

gas/

* NEWS: Add TDX.
* config/tc-i386.c (cpu_arch): Add .tdx.
(cpu_noarch): Likewise.
* doc/c-i386.texi: Document tdx.
* testsuite/gas/i386/i386.exp: Run tdx tests.
* testsuite/gas/i386/tdx.d: Likewise.
* testsuite/gas/i386/tdx.s: Likewise.
* testsuite/gas/i386/x86-64-tdx.d: Likewise.
* testsuite/gas/i386/x86-64-tdx.s: Likewise.

opcodes/

* i386-dis.c (enum): Add PREFIX_0F01_REG_1_RM_5,
PREFIX_0F01_REG_1_RM_6, PREFIX_0F01_REG_1_RM_7,
X86_64_0F01_REG_1_RM_5_P_2, X86_64_0F01_REG_1_RM_6_P_2,
X86_64_0F01_REG_1_RM_7_P_2.
(prefix_table): Likewise.
(x86_64_table): Likewise.
(rm_table): Likewise.
* i386-gen.c (cpu_flag_init): Add CPU_TDX_FLAGS
and CPU_ANY_TDX_FLAGS.
(cpu_flags): Add CpuTDX.
* i386-opc.h (enum): Add CpuTDX.
(i386_cpu_flags): Add cputdx.
* i386-opc.tbl: Add TDX insns.
* i386-init.h: Regenerate.
* i386-tbl.h: Likewise.

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

4 years ago[GOLD] PowerPC64 __tls_get_addr_opt stub
Alan Modra [Wed, 23 Sep 2020 13:24:01 +0000 (22:54 +0930)]
[GOLD] PowerPC64 __tls_get_addr_opt stub

This stub doesn't have the r2 store at the beginning.

* powerpc.cc (Target_powerpc::Relocate::relocate): Don't skip
first insn of __tls_get_addr_opt stub.

4 years agoPR26656, power10 libstdc++.so segfault in __cxxabiv1::__cxa_throw
Alan Modra [Tue, 22 Sep 2020 13:21:42 +0000 (22:51 +0930)]
PR26656, power10 libstdc++.so segfault in __cxxabiv1::__cxa_throw

This adds missing support for a power10 version of the __tls_get_addr
call stub implementing DT_PPC64_OPT PPC64_OPT_TLS.  Without this,
power10 code using __tls_get_addr fails miserably at runtime unless
the --no-tls-get-addr-optimize option is given.

PR 26656
* elf64-ppc.c (plt_stub_size): Add "odd" param.  Use it with
size_power10_offset rather than calculating from start of stub.
Add size for notoc tls_get_addr_opt stub.
(plt_stub_pad): Add "odd" param, pass to plt_stub_size.
(build_tls_get_addr_head, build_tls_get_addr_tail): New functions.
(build_tls_get_addr_stub): Delete.
(ppc_build_one_stub): Use a temp for htab->params->stub_bfd.
Emit notoc tls_get_addr_opt stub.  Move eh_frame code to
suit.  Adjust code to use bfd_tls_get_addr_head/tail in place
of build_tls_get_addr_stub.
(ppc_size_one_stub): Size notoc tls_get_addr_opt stub.
Adjust plt_stub_size and plt_stub_pad calls.  Correct "odd"
when padding stub.  Size eh_frame for notoc stub too.
Correct lr_restore value.
(ppc64_elf_relocate_section): Don't skip over first insn of
notoc tls_get_addr_opt stub.

4 years agoPR26655, Power10 libstdc++.so R_PPC64_NONE dynamic relocs
Alan Modra [Wed, 23 Sep 2020 05:25:39 +0000 (14:55 +0930)]
PR26655, Power10 libstdc++.so R_PPC64_NONE dynamic relocs

Some of the powerpc64 code editing functions are better run after
dynamic symbols have stabilised in order to make proper decisions
based on SYMBOL_REFERENCES_LOCAL.  The dynamic symbols are processed
early in bfd_elf_size_dynamic_sections, before the backend
always_size_sections function is called.

One function, ppc64_elf_tls_setup must run before
bfd_elf_size_dynamic_sections because it changes dynamic symbols.
ppc64_elf_edit_opd and ppc64_elf_inline_plt can run early or late, I
think.  ppc64_elf_tls_optimize and ppc64_elf_edit_toc are better run
later.

So this patch arranges to call some edit functions later via
always_size_sections.

PR 26655
bfd/
* elf64-ppc.c (ppc64_elf_func_desc_adjust): Rename to..
(ppc64_elf_edit): Call params->edit.
(ppc64_elf_tls_setup): Don't call _bfd_elf_tls_setup.  Return a
bfd_boolean.
* elf64-ppc.h (struct ppc64_elf_params): Add "edit".
(ppc64_elf_tls_setup): Update declaration.
ld/
* emultempl/ppc64elf.em (params): Add ppc_edit.
(ppc_before_allocation): Split off some edit functions to..
(ppc_edit): ..this, new function.

4 years agoCSKY: Add objdump option -M abi-names.
Cooper Qu [Thu, 17 Sep 2020 06:30:28 +0000 (14:30 +0800)]
CSKY: Add objdump option -M abi-names.

Add option parser for disassembler, and refine the codes of
parse register operand and disassemble register operand.
While strengthen the operands legality check of some instructions.

Co-Authored-By: Lifang Xia <lifang_xia@c-sky.com>
gas/
* config/tc-csky.c (parse_type_ctrlreg): Use function
csky_get_control_regno to operand.
(csky_get_reg_val): Likewise.
(is_reg_sp_with_bracket): Use function csky_get_reg_val
to parse operand.
(is_reg_sp): Refine.
(is_oimm_within_range): Fix, report error when operand
is not constant.
(parse_type_cpreg): Refine.
(parse_type_cpcreg): Refine.
(get_operand_value): Add handle of OPRND_TYPE_IMM5b_LS.
(md_assemble): Fix no error reporting somtimes when
operands number are not fit.
(csky_addc64): Refine.
(csky_subc64): Refine.
(csky_or64): Refine.
(v1_work_fpu_fo): Refine.
(v1_work_fpu_read): Refine.
(v1_work_fpu_writed): Refine.
(v1_work_fpu_readd): Refine.
(v2_work_addc): New function, strengthen the operands legality
check of addc.
* gas/testsuite/gas/csky/all.d : Use register number format when
disassemble register name by default.
* gas/testsuite/gas/csky/cskyv2_all.d : Likewise.
* gas/testsuite/gas/csky/trust.d: Likewise.
* gas/testsuite/gas/csky/cskyv2_ck860.d : Fix.
* gas/testsuite/gas/csky/trust.s : Fix.

opcodes/
* csky-dis.c (using_abi): New.
(parse_csky_dis_options): New function.
(get_gr_name): New function.
(get_cr_name): New function.
(csky_output_operand): Use get_gr_name and get_cr_name to
disassemble and add handle of OPRND_TYPE_IMM5b_LS.
(print_insn_csky): Parse disassembler options.
* opcodes/csky-opc.h (OPRND_TYPE_IMM5b_LS): New enum.
(GENARAL_REG_BANK): Define.
(REG_SUPPORT_ALL): Define.
(REG_SUPPORT_ALL): New.
(ASH): Define.
(REG_SUPPORT_A): Define.
(REG_SUPPORT_B): Define.
(REG_SUPPORT_C): Define.
(REG_SUPPORT_D): Define.
(REG_SUPPORT_E): Define.
(csky_abiv1_general_regs): New.
(csky_abiv1_control_regs): New.
(csky_abiv2_general_regs): New.
(csky_abiv2_control_regs): New.
(get_register_name): New function.
(get_register_number): New function.
(csky_get_general_reg_name): New function.
(csky_get_general_regno): New function.
(csky_get_control_reg_name): New function.
(csky_get_control_regno): New function.
(csky_v2_opcodes): Prefer two oprerans format for bclri and
bseti, strengthen the operands legality check of addc, zext
and sext.

4 years agoHandle bit offset and bit size in base types
Tom Tromey [Wed, 23 Sep 2020 15:39:24 +0000 (09:39 -0600)]
Handle bit offset and bit size in base types

PR symtab/25470 points out that the Zig programming language allows
integers of various bit sizes (including zero), not just sizes that
are a multiple of 8.

This is supported in DWARF by applying both a byte size and a
DW_AT_bit_size.

This patch adds support for this feature to integer and boolean types.
Other base types are not handled -- for floating-point types, this
didn't seem to make sense, and for character types I didn't see much
need.  (These can be added later if desired.)

I've also added support for DW_AT_data_bit_offset at the same time.  I
don't know whether the Zig compiler requires this, but it was
described in the same section in the DWARF standard and was easy to
add.

A new test case is supplied, using the DWARF assembler.

gdb/ChangeLog
2020-09-23  Tom Tromey  <tom@tromey.com>

PR symtab/25470:
* value.c (unpack_long, pack_long, pack_unsigned_long): Handle bit
offset and bit size.
* printcmd.c (print_scalar_formatted): Handle zero-length
integer.
(print_scalar_formatted): Use bit_size_differs_p.
* gdbtypes.h (enum type_specific_kind) <TYPE_SPECIFIC_INT>: New
constant.
(union type_specific): <int_stuff>: New member.
(struct type) <bit_size_differs_p, bit_size, bit_offset>: New
methods.
* gdbtypes.c (init_integer_type, init_boolean_type): Initialize
TYPE_SPECIFIC_FIELD.
(recursive_dump_type, copy_type_recursive): Update.
* dwarf2/read.c (read_base_type): Handle DW_AT_bit_size and
DW_AT_data_bit_offset.

gdb/testsuite/ChangeLog
2020-09-23  Tom Tromey  <tom@tromey.com>

* gdb.dwarf2/intbits.exp: New file.
* gdb.dwarf2/intbits.c: New file.

4 years agoAvoid manual memory management of argv arrays in gdb/compile
Tom Tromey [Wed, 23 Sep 2020 15:32:54 +0000 (09:32 -0600)]
Avoid manual memory management of argv arrays in gdb/compile

This changes gdb/compile to use gdb_argv directly, rather than
manually managing the arrays itself.  A few new helpers are added to
gdb_argv.

gdb/ChangeLog
2020-09-23  Tom Tromey  <tom@tromey.com>

* utils.h (class gdb_argv): Add move operators.
<append>: New methods.
* compile/compile.c (build_argc_argv): Remove.
(compile_args_argc): Remove.
(compile_args_argv): Change type.
(set_compile_args): Simplify.
(append_args): Remove.
(filter_args): Remove argcp parameter.
(get_args): Return gdb_argv.  Simplify.
(compile_to_object): Update.

4 years agoSimplify compile_module cleanup
Tom Tromey [Wed, 23 Sep 2020 15:32:54 +0000 (09:32 -0600)]
Simplify compile_module cleanup

This simplifies compile_module cleanup by removing the need to
explicitly free anything.  struct setup_sections_data is also cleaned
up a bit.

gdb/ChangeLog
2020-09-23  Tom Tromey  <tom@tromey.com>

* compile/compile-object-run.c (do_module_cleanup)
<~do_module_cleanup> :Remove.
(do_module_cleanup): Update.
* compile/compile-object-load.h (struct munmap_list): Add move
assignment operator.
<source_file>: Now a std::string.
<munmap_list>: Rename.  No longer a pointer.
* compile/compile-object-load.c (struct setup_sections_data): Add
constructor.
<setup_one_section>: Declare.
<munmap_list>: Move earlier.
<m_bfd>: New member.
<m_last_size, m_last_section_first, m_last_prot,
m_last_max_alignment>: Rename, add initializers where needed.
(setup_sections_data::setup_one_section): Rename from
setup_sections.  Update.
(compile_object_load): Update.  Don't use bfd_map_over_sections.

4 years agoTransfer module ownership to do_module_cleanup
Tom Tromey [Wed, 23 Sep 2020 15:32:54 +0000 (09:32 -0600)]
Transfer module ownership to do_module_cleanup

This changes the do_module_cleanup structure to simply hold on to the
module itself.  This lets us remove most members from
do_module_cleanup.

gdb/ChangeLog
2020-09-23  Tom Tromey  <tom@tromey.com>

* compile/compile-object-run.c (struct do_module_cleanup): Add
parameters to constructor.  Update destructor.
<source_file, scope, scope_data, out_value_type, out_value_addr,
munmap_list_head, objfile_name_string>: Remove.
<module>: New member.
(do_module_cleanup): Update.
(compile_object_run): Update.

4 years agoIntroduce and use compile_module_up
Tom Tromey [Wed, 23 Sep 2020 15:32:54 +0000 (09:32 -0600)]
Introduce and use compile_module_up

This introduces compile_module_up, a unique pointer for
compile_module, and changes a few spots to use it.

gdb/ChangeLog
2020-09-23  Tom Tromey  <tom@tromey.com>

* compile/compile.c (eval_compile_command): Update.
* compile/compile-object-run.h (compile_object_run): Take a
compile_module_up.
* compile/compile-object-run.c (compile_object_run): Take a
compile_module_up.
* compile/compile-object-load.h (struct compile_module): Add
constructor, destructor.
(compile_module_up): New typedef.
(compile_object_load): Return compile_object_up.
* compile/compile-object-load.c (compile_object_load): Return
compile_module_up.

4 years agoUse new/delete for do_module_cleanup
Tom Tromey [Wed, 23 Sep 2020 15:32:54 +0000 (09:32 -0600)]
Use new/delete for do_module_cleanup

This changes do_module_cleanup to use new and delete.  It also removes
the use of the struct hack from this object -- this requires more
allocations for now, but this will be removed in a subsequent patch.

gdb/ChangeLog
2020-09-23  Tom Tromey  <tom@tromey.com>

* compile/compile-object-run.c (struct do_module_cleanup): Add
constructor, destructor.
<objfile_name_string>: Don't use struct hack.
(do_module_cleanup): Use delete.
(compile_object_run): Use new.

4 years agoRemove some manual memory management from compile interface
Tom Tromey [Wed, 23 Sep 2020 15:32:54 +0000 (09:32 -0600)]
Remove some manual memory management from compile interface

This changes gdb's compile code to use std::vector in a couple of
places, rather than manual memory management.

gdb/ChangeLog
2020-09-23  Tom Tromey  <tom@tromey.com>

* compile/compile-cplus-types.c
(compile_cplus_convert_struct_or_union): Use std::vector.
(compile_cplus_convert_func): Likewise.
* compile/compile-c-types.c (convert_func): Use std::vector.

4 years agoEnable support to Intel Keylocker instructions
Terry Guo [Mon, 5 Nov 2018 05:28:48 +0000 (13:28 +0800)]
Enable support to Intel Keylocker instructions

gas/
* NEWS: Add Key Locker.
* config/tc-i386.c (cpu_arch): Add .kl and .wide_kl.
(cpu_noarch): Likewise.
* doc/c-i386.texi: Document kl and wide_kl.
* testsuite/gas/i386/i386.exp: Run keylocker tests.
* testsuite/gas/i386/keylocker-intel.d: New test.
* testsuite/gas/i386/keylocker.d: Likewise.
* testsuite/gas/i386/keylocker.s: Likewise.
* testsuite/gas/i386/x86-64-keylocker-intel.d: Likewise.
* testsuite/gas/i386/x86-64-keylocker.d: Likewise.
* testsuite/gas/i386/x86-64-keylocker.s: Likewise.
* testsuite/gas/i386/x86-64-property-10.d: Likewise.
* testsuite/gas/i386/property-10.d: Likewise.
* testsuite/gas/i386/property-10.s: Likewise.

opcodes/
* i386-dis.c (enum): Add REG_0F38D8_PREFIX_1,
MOD_0F38FA_PREFIX_1, MOD_0F38FB_PREFIX_1,
MOD_0F38DC_PREFIX_1, MOD_0F38DD_PREFIX_1,
MOD_0F38DE_PREFIX_1, MOD_0F38DF_PREFIX_1,
PREFIX_0F38D8, PREFIX_0F38FA, PREFIX_0F38FB.
(reg_table): New instructions (see prefixes above).
(prefix_table): Likewise.
(three_byte_table): Likewise.
(mod_table): Likewise
* i386-gen.c (cpu_flag_init): Add CPU_KL_FLAGS, CPU_WIDE_KL_FLAGS,
CPU_ANY_KL_FLAGS and CPU_ANY_WIDE_KL_FLAGS.
(cpu_flags): Likewise.
(operand_type_init): Likewise.
* i386-opc.h (enum): Add CpuKL and CpuWide_KL.
(i386_cpu_flags): Add cpukl and cpuwide_kl.
* i386-opc.tbl: Add KL and WIDE_KL insns.
* i386-init.h: Regenerate.
* i386-tbl.h: Likewise.

4 years agoAutomatic date update in version.in
GDB Administrator [Wed, 23 Sep 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoLinker: If the type is pie the results should be an executable which entry point...
Frediano Ziglio [Tue, 22 Sep 2020 11:48:04 +0000 (12:48 +0100)]
Linker: If the type is pie the results should be an executable which entry point should be an executable entry point, not a DLL one.

* emultempl/pe.em (set_entry_point): Only use the DLL entry point
for DLLs.
* emultempl/pep.em (set_entry_point): Likewise.

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

4 years agoUpdate the binutils documentation to make it clear the the --strip-unneeded option...
Ludovic Court?s [Mon, 21 Sep 2020 15:08:55 +0000 (16:08 +0100)]
Update the binutils documentation to make it clear the the --strip-unneeded option of objcopy and strip implies the --strip-debug option.

* doc/binutils.texi (objcopy, strip): Say that
        '--strip-unneeded' implies '--strip-debug'.

4 years agoFix sparc prologue skipping
Tom Tromey [Mon, 21 Sep 2020 13:09:10 +0000 (07:09 -0600)]
Fix sparc prologue skipping

sparc can fail at inline prologue skipping.  Andrew Burgess tracked
this down to sparc32_skip_prologue, which should use
skip_prologue_using_sal rather than its hand-rolled variant.

I don't have a good way to test this with the gdb test suite (is there
a board file for using qemu?  That would help), but it fixes a
regression in the internal AdaCore test suite.  We've had this patch
internally at AdaCore for a while, but I just now finally got around
to making sure that backing it out reintroduces the problem.

gdb/ChangeLog
2020-09-21  Tom Tromey  <tromey@adacore.com>

* sparc-tdep.c (sparc32_skip_prologue): Use
skip_prologue_using_sal.

4 years agorx-dis.c:103:3: suspicious concatenation of string literals
Alan Modra [Mon, 21 Sep 2020 08:50:58 +0000 (18:20 +0930)]
rx-dis.c:103:3: suspicious concatenation of string literals

* rx-dis.c (flag_names): Add missing comma.
(register_names, flag_names, double_register_names),
(double_register_high_names, double_register_low_names),
(double_control_register_names, double_condition_names): Remove
trailing commas.

4 years agoPR26569, R_RISCV_RVC_JUMP results in buffer overflow
Alan Modra [Wed, 16 Sep 2020 22:14:53 +0000 (07:44 +0930)]
PR26569, R_RISCV_RVC_JUMP results in buffer overflow

This patch corrects "size" and "bitsize" in R_RISCV_RVC_* reloc howtos
so that elfnn-riscv.c:perform_relocation doesn't access past the end
of a section.  I've also corrected "size" in the R_RISCV_CALL* reloc
howtos since these relocs apply to two consecutive instructions.  That
caused fallout in the assembler with complaints about "fixup not
contained within frag" due to tc-riscv.c:append_insn finishing off a
frag after the auipc insn making up a "call" macro.  Which is a little
rude since the CALL reloc also relocates the following jalr.  Fixed by
changing the frag handling a little.

I've also changed R_RISCV_ALIGN and R_RISCV_TPREL_ADD marker reloc
howtos to look like R_RISCV_NONE, and corrected dst_mask for numerous
relocs, not that it matters very much.

bfd/
PR 26569
* elfxx-riscv.c (howto_table): Correct size and bitsize of
R_RISCV_RVC_BRANCH, R_RISCV_RVC_JUMP, and R_RISCV_RVC_LUI.
Correct size for R_RISCV_TLS_DTPMOD32, R_RISCV_TLS_DTPREL32,
R_RISCV_CALL, and R_RISCV_CALL_PLT.  Make R_RISCV_TPREL_ADD and
R_RISCV_ALIGN like R_RISCV_NONE.  Correct dst_mask many relocs.
gas/
* config/tc-riscv.c (append_insn): Don't tie off frags at CALL
relocs.
(riscv_call): Tie them off after the jalr.
(md_apply_fix): Zero fx_size of RELAX fixup.

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 21 Sep 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoFix mi_gdb_exit with secondary MI channels
Pedro Alves [Sun, 20 Sep 2020 14:58:26 +0000 (15:58 +0100)]
Fix mi_gdb_exit with secondary MI channels

Tests that use a secondary MI channel (i.e., either tests that call
mi_gdb_start with separate-mi-tty, or all tests when
FORCE_SEPARATE_MI_TTY=1 is specified on the make check command line),
don't close GDB correctly.

E.g., if you run gdb.mi/mi-exec-run.exp in a loop:

  while true; do make check TESTS="gdb.mi/mi-exec-run.exp"; done

you can see more than one gdb running at the same time:

  $ ps -ef | grep -v grep | grep "gdb/gdb"
  pedro      40507       1  7 15:47 ?        00:00:00 /home/pedro/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/pedro/gdb/build/gdb/testsuite/../data-directory
  pedro      40562       1  0 15:47 ?        00:00:00 /home/pedro/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/pedro/gdb/build/gdb/testsuite/../data-directory
  pedro      40727       1  0 15:47 ?        00:00:00 /home/pedro/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/pedro/gdb/build/gdb/testsuite/../data-directory
  pedro      40786       1  0 15:47 ?        00:00:00 /home/pedro/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/pedro/gdb/build/gdb/testsuite/../data-directory

This commit fixes it.

gdb/testsuite/ChangeLog:

* lib/mi-support.exp (mi_uncatched_gdb_exit) Switch to the main
spawn_id before calling remote_close.  Close secondary MI channel.

4 years agoRobustify gdb.base/testenv.exp:find_env
Pedro Alves [Sun, 20 Sep 2020 14:58:09 +0000 (15:58 +0100)]
Robustify gdb.base/testenv.exp:find_env

If printing 'envp[$i]' in find_env fails, the testcase goes into an
infinite loop:

 Running /home/pedro/rocm/gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/testenv.exp ...
 FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[0] ? envp[0] : ""
 FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[1] ? envp[1] : ""
 FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[2] ? envp[2] : ""
 FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[3] ? envp[3] : ""
 ...
 FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[2519] ? envp[2519] : ""
 FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[2520] ? envp[2520] : ""
 FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[2521] ? envp[2521] : ""
 ..
 FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[5128] ? envp[5128] : ""
 FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[5129] ? envp[5129] : ""
 FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[5130] ? envp[5130] : ""
 ...

Fix that by bailing out of the loop on failure.

gdb/testsuite/ChangeLog:

* gdb.base/testenv.exp (find_env): Bail out if printing 'envp[$i]'
fails.

4 years agoAutomatic date update in version.in
GDB Administrator [Sun, 20 Sep 2020 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoUse gdb_bfd_sections in generic_load
Tom Tromey [Sat, 19 Sep 2020 17:54:49 +0000 (11:54 -0600)]
Use gdb_bfd_sections in generic_load

This changes generic_load to avoid bfd_map_over_sections, in favor of
iteration.

gdb/ChangeLog
2020-09-19  Tom Tromey  <tom@tromey.com>

* symfile.c (add_section_size_callback): Remove.
(load_one_section): Rename from load_section_callback.  Change
parameters.
(generic_load): Use foreach.

4 years agoUse gdb_bfd_sections in build_section_table
Tom Tromey [Sat, 19 Sep 2020 17:54:49 +0000 (11:54 -0600)]
Use gdb_bfd_sections in build_section_table

This changes build_section_table to avoid bfd_map_over_sections, in
favor of iteration.  In this situation it seemed simple to just remove
the helper function entirely.

gdb/ChangeLog
2020-09-19  Tom Tromey  <tom@tromey.com>

* exec.c (add_to_section_table): Remove.
(build_section_table): Use foreach.

4 years agoUse gdb_bfd_sections in elf_symfile_read
Tom Tromey [Sat, 19 Sep 2020 17:54:49 +0000 (11:54 -0600)]
Use gdb_bfd_sections in elf_symfile_read

This changes elf_symfile_read to avoid bfd_map_over_sections, in favor
of iteration.

gdb/ChangeLog
2020-09-19  Tom Tromey  <tom@tromey.com>

* elfread.c (elf_locate_sections): Change parameters.
(elf_symfile_read): Use foreach.

4 years agoUse gdb_bfd_sections in restore_command
Tom Tromey [Sat, 19 Sep 2020 17:54:49 +0000 (11:54 -0600)]
Use gdb_bfd_sections in restore_command

This changes restore_command to avoid bfd_map_over_sections, in favor
of iteration.  A helper data structure can also be removed by this
patch.

gdb/ChangeLog
2020-09-19  Tom Tromey  <tom@tromey.com>

* cli/cli-dump.c (struct callback_data): Remove.
(restore_one_section): Rename from restore_section_callback.
Change parameters.
(restore_binary_file): Change parameters.
(restore_command): Use foreach.

4 years agoUse gdb_bfd_sections in gcore_memory_sections
Tom Tromey [Sat, 19 Sep 2020 17:54:49 +0000 (11:54 -0600)]
Use gdb_bfd_sections in gcore_memory_sections

This changes gcore_memory_sections to avoid bfd_map_over_sections, in
favor of iteration.

gdb/ChangeLog
2020-09-19  Tom Tromey  <tom@tromey.com>

* gcore.c (make_output_phdrs): Remove 'ignored' parameter.
(gcore_copy_callback): Likewise.
(gcore_memory_sections): Use foreach.

4 years agoUse gdb_bfd_sections in ELF osabi tag sniffing
Tom Tromey [Sat, 19 Sep 2020 17:54:49 +0000 (11:54 -0600)]
Use gdb_bfd_sections in ELF osabi tag sniffing

This changes some ELF osabi tag-sniffing functions to avoid
bfd_map_over_sections, in favor of iteration.  I could only readily
test the generic one.

gdb/ChangeLog
2020-09-19  Tom Tromey  <tom@tromey.com>

* osabi.h (generic_elf_osabi_sniff_abi_tag_sections): Update.
* osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Change
parameters.
(generic_elf_osabi_sniffer): Use foreach.
* mips-sde-tdep.c (mips_sde_elf_osabi_sniffer): Use foreach.
* arm-tdep.c (arm_elf_osabi_sniffer): Use foreach.

4 years agoUse gdb_bfd_sections in dwarf2/read.c
Tom Tromey [Sat, 19 Sep 2020 17:54:49 +0000 (11:54 -0600)]
Use gdb_bfd_sections in dwarf2/read.c

This changes some functions in dwarf2/read.c to avoid
bfd_map_over_sections, in favor of iteration.

gdb/ChangeLog
2020-09-19  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (locate_dwz_sections): Change parameters.
(dwarf2_get_dwz_file): Use foreach.
(dwarf2_locate_dwo_sections): Change parameters.
(open_and_init_dwo_file): Use foreach.
(dwarf2_locate_common_dwp_sections): Change parameters.
(open_and_init_dwp_file): Use foreach.

4 years agoUse gdb_bfd_sections in symfile.c
Tom Tromey [Sat, 19 Sep 2020 17:54:49 +0000 (11:54 -0600)]
Use gdb_bfd_sections in symfile.c

This changes some functions in symfile.c to avoid
bfd_map_over_sections, in favor of iteration.  Some helper types can
also be removed due to this change.

gdb/ChangeLog
2020-09-19  Tom Tromey  <tom@tromey.com>

* symfile.h: (find_lowest_section): Don't declare.
* symfile.c (find_lowest_section): Now static.  Change
parameters.
(struct place_section_arg): Remove.
(place_section): Change parameters.
(addr_info_make_relative): Use foreach.
(symfile_dummy_outputs): Remove.
(default_symfile_relocate): Use foreach.

4 years agoUse gdb_bfd_sections in build_objfile_section_table
Tom Tromey [Sat, 19 Sep 2020 17:54:49 +0000 (11:54 -0600)]
Use gdb_bfd_sections in build_objfile_section_table

This changes build_objfile_section_table to avoid
bfd_map_over_sections, in favor of iteration.

gdb/ChangeLog
2020-09-19  Tom Tromey  <tom@tromey.com>

* objfiles.c (add_to_objfile_sections): Rename from
add_to_objfile_sections_full.
(add_to_objfile_sections): Remove.
(build_objfile_section_table): Use foreach.

4 years agoUse gdb_bfd_sections in get_stap_base_address
Tom Tromey [Sat, 19 Sep 2020 17:54:49 +0000 (11:54 -0600)]
Use gdb_bfd_sections in get_stap_base_address

This changes get_stap_base_address to avoid bfd_map_over_sections, in
favor of iteration.

gdb/ChangeLog
2020-09-19  Tom Tromey  <tom@tromey.com>

* stap-probe.c (get_stap_base_address_1): Remove.
(get_stap_base_address): Use foreach.

4 years agoUse gdb_bfd_sections in gdb_bfd_close_or_warn
Tom Tromey [Sat, 19 Sep 2020 17:54:49 +0000 (11:54 -0600)]
Use gdb_bfd_sections in gdb_bfd_close_or_warn

This changes gdb_bfd_close_or_warn to avoid bfd_map_over_sections, in
favor of iteration.

gdb/ChangeLog
2020-09-19  Tom Tromey  <tom@tromey.com>

* gdb_bfd.c (free_one_bfd_section): Remove 'abfd' and 'ignore'
parameters.
(gdb_bfd_close_or_warn): Use foreach.

4 years agoUse gdb_bfd_sections in core_target_open
Tom Tromey [Sat, 19 Sep 2020 17:54:49 +0000 (11:54 -0600)]
Use gdb_bfd_sections in core_target_open

This changes core_target_open to avoid bfd_map_over_sections, in favor
of iteration.

gdb/ChangeLog
2020-09-19  Tom Tromey  <tom@tromey.com>

* corelow.c (add_to_thread_list): Change parameters.
(core_target_open): Use foreach.

4 years agoAdd a new overload of gdb_bfd_sections
Tom Tromey [Sat, 19 Sep 2020 17:54:49 +0000 (11:54 -0600)]
Add a new overload of gdb_bfd_sections

This adds a new overload of gdb_bfd_sections, that accepts a
gdb_bfd_ref_ptr.  This also fixes the formatting of the existing
function, since I happened to notice it was mildly off.

gdb/ChangeLog
2020-09-19  Tom Tromey  <tom@tromey.com>

* gdb_bfd.h (gdb_bfd_sections): New overload.  Fix formatting of
existing function.

4 years agogdb/fortran: Change whitespace when printing arrays
Andrew Burgess [Thu, 21 May 2020 16:35:51 +0000 (17:35 +0100)]
gdb/fortran: Change whitespace when printing arrays

This commit makes the whitespace usage when printing Fortran arrays
more consistent, and more inline with how we print C arrays.

Currently a 2 dimensional Fotran array is printed like this, I find
the marked whitespace unpleasant:

  (( 1, 2, 3) ( 4, 5, 6) )
    ^          ^        ^

After this commit the same array is printed like this:

  ((1, 2, 3) (4, 5, 6))

Which seems more inline with how we print C arrays, in the case of C
arrays we don't add extra whitespace before the first element.

gdb/ChangeLog:

* f-valprint.c (f77_print_array_1): Adjust printing of whitespace
for arrays.

gdb/testsuite/ChangeLog:

* gdb.fortran/array-slices.exp: Update expected results.
* gdb.fortran/class-allocatable-array.exp: Likewise.
* gdb.fortran/multi-dim.exp: Likewise.
* gdb.fortran/vla-type.exp: Likewise.
* gdb.mi/mi-vla-fortran.exp: Likewise.

4 years agogdb/fortran: Move Fortran expression handling into f-lang.c
Andrew Burgess [Thu, 7 May 2020 15:27:16 +0000 (16:27 +0100)]
gdb/fortran: Move Fortran expression handling into f-lang.c

The Fortran specific OP_F77_UNDETERMINED_ARGLIST is currently handled
in the generic expression handling code.  There's no reason why this
should be the case, so this commit moves handling of this into Fortran
specific files.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* eval.c: Remove 'f-lang.h' include.
(value_f90_subarray): Moved to f-lang.c.
(eval_call): Renamed to...
(evaluate_subexp_do_call): ...this, is no longer static, header
comment moved into header file.
(evaluate_funcall): Update call to eval_call.
(skip_undetermined_arglist): Moved to f-lang.c.
(fortran_value_subarray): Likewise.
(evaluate_subexp_standard): OP_F77_UNDETERMINED_ARGLIST handling
moved to evaluate_subexp_f.
(calc_f77_array_dims): Moved to f-lang.c
* expprint.c (print_subexp_funcall): New function.
(print_subexp_standard): OP_F77_UNDETERMINED_ARGLIST handling
moved to print_subexp_f, OP_FUNCALL uses new function.
(dump_subexp_body_funcall): New function.
(dump_subexp_body_standard): OP_F77_UNDETERMINED_ARGLIST handling
moved to dump_subexp_f, OP_FUNCALL uses new function.
* expression.h (evaluate_subexp_do_call): Declare.
* f-lang.c (value_f90_subarray): Moved from eval.c.
(skip_undetermined_arglist): Likewise.
(calc_f77_array_dims): Likewise.
(fortran_value_subarray): Likewise.
(evaluate_subexp_f): Add OP_F77_UNDETERMINED_ARGLIST support.
(operator_length_f): Likewise.
(print_subexp_f): Likewise.
(dump_subexp_body_f): Likewise.
* fortran-operator.def (OP_F77_UNDETERMINED_ARGLIST): Move
declaration of this operation to here.
* parse.c (operator_length_standard): OP_F77_UNDETERMINED_ARGLIST
support moved to operator_length_f.
* parser-defs.h (dump_subexp_body_funcall): Declare.
(print_subexp_funcall): Declare.
* std-operator.def (OP_F77_UNDETERMINED_ARGLIST): Moved to
fortran-operator.def.

4 years agogdb/fortran: Clean up array/string expression evaluation
Andrew Burgess [Wed, 6 May 2020 17:53:21 +0000 (18:53 +0100)]
gdb/fortran: Clean up array/string expression evaluation

This commit is a refactor of part of the Fortran array and string
handling code.

The current code is split into two blocks, linked, weirdly, with a
goto.  After this commit all the code is moved to its own function,
and arrays and strings are now handled using the same code; this will
be useful later when I want to add array stride support where strings
will want to be treated just like arrays, but is a good clean up even
without the array stride work, which is why I'm merging it now.

For now the new function is added as a static within eval.c, even
though the function is Fortran only.  A following commit will remove
some of the Fortran specific code from eval.c into one of the Fortran
specific files, including this new function.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* eval.c (fortran_value_subarray): New function, content is taken
from...
(evaluate_subexp_standard): ...here, in two places.  Now arrays
and strings both call the new function.
(calc_f77_array_dims): Add header comment, handle strings.

4 years agogdb: Update i386_analyze_prologue to skip endbr32
Victor Collod [Sat, 19 Sep 2020 00:53:02 +0000 (17:53 -0700)]
gdb: Update i386_analyze_prologue to skip endbr32

With -m32 -fcf-protection, GCC generates an `endbr32` instruction at the
function entry:

[hjl@gnu-cfl-2 gdb]$ cat /tmp/x.c
int
main(void)
{
  return 0;
}
[hjl@gnu-cfl-2 gdb]$ gcc -g -fcf-protection /tmp/x.c -m32
(gdb) b main
Breakpoint 1 at 0x8049176: file /tmp/x.c, line 3.
(gdb) r
Breakpoint 1, main () at /tmp/x.c:3
3 {
(gdb) disass
Dump of assembler code for function main:
=> 0x08049176 <+0>: endbr32
   0x0804917a <+4>: push   %ebp
   0x0804917b <+5>: mov    %esp,%ebp
   0x0804917d <+7>: mov    $0x0,%eax
   0x08049182 <+12>: pop    %ebp
   0x08049183 <+13>: ret
End of assembler dump.
(gdb)

Update i386_analyze_prologue to skip `endbr32`:

(gdb) b main
Breakpoint 1 at 0x804917d: file /tmp/x.c, line 4.
(gdb) r
Breakpoint 1, main () at /tmp/x.c:4
4   return 0;
(gdb) disass
Dump of assembler code for function main:
   0x08049176 <+0>: endbr32
   0x0804917a <+4>: push   %ebp
   0x0804917b <+5>: mov    %esp,%ebp
=> 0x0804917d <+7>: mov    $0x0,%eax
   0x08049182 <+12>: pop    %ebp
   0x08049183 <+13>: ret
End of assembler dump.
(gdb)

Tested with

$ make check RUNTESTFLAGS="--target_board='unix{-m32,}' i386-prologue-skip-cf-protection.exp"

on Fedora 32/x86-64.

2020-0X-YY  Victor Collod  <vcollod@nvidia.com>

gdb/ChangeLog:

PR gdb/26635
* i386-tdep.c (i386_skip_endbr): Add a helper function to skip endbr.
(i386_analyze_prologue): Call i386_skip_endbr.

gdb/testsuite/ChangeLog:

PR gdb/26635
* gdb.arch/amd64-prologue-skip-cf-protection.exp: Make the test
compatible with i386, and move it to...
* gdb.arch/i386-prologue-skip-cf-protection.exp: ... here.
* gdb.arch/amd64-prologue-skip-cf-protection.c: Move to...
* gdb.arch/i386-prologue-skip-cf-protection.c: ... here.

4 years agoAutomatic date update in version.in
GDB Administrator [Sat, 19 Sep 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoMake target_wait options use enum flags
Tom Tromey [Fri, 18 Sep 2020 20:20:44 +0000 (14:20 -0600)]
Make target_wait options use enum flags

This changes TARGET_WNOHANG to be a member of an enum, rather than a
define, and also adds a DEF_ENUM_FLAGS_TYPE for this type.  Then, it
changes target_wait and the various target wait methods to use this
type rather than "int".

This didn't catch any bugs, but it seems like a decent cleanup
nevertheless.

I did not change deprecated_target_wait_hook, since that's only used
out-of-tree (by Insight), and there didn't seem to be a need.

I can't build some of these targets, so I modified them on a
best-effort basis.  I don't think this patch should go in before the
release branch is made.

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

* windows-nat.c (struct windows_nat_target) <wait>: Update.
(windows_nat_target::wait): Update.
* target/wait.h (enum target_wait_flag): New.  Use
DEF_ENUM_FLAGS_TYPE.
* target/target.h (target_wait): Change type of options.
* target.h (target_options_to_string, default_target_wait):
Update.
(struct target_ops) <wait>: Change type of options.
* target.c (target_wait, default_target_wait, do_option): Change
type of "options".
(target_options_to_string): Likewise.
* target-delegates.c: Rebuild.
* target-debug.h (target_debug_print_target_wait_flags): Rename
from target_debug_print_options.
* sol-thread.c (class sol_thread_target) <wait>: Update.
(sol_thread_target::wait): Update.
* rs6000-nat.c (class rs6000_nat_target) <wait>: Update.
(rs6000_nat_target::wait): Update.
* remote.c (class remote_target) <wait, wait_ns, wait_as>:
Update.
(remote_target::wait_ns, remote_target::wait_as): Change type of
"options".
(remote_target::wait): Update.
* remote-sim.c (struct gdbsim_target) <wait>: Update.
(gdbsim_target::wait): Update.
* record-full.c (class record_full_base_target) <wait>: Update.
(record_full_wait_1): Change type of "options".
(record_full_base_target::wait): Update.
* record-btrace.c (class record_btrace_target) <wait>: Update.
(record_btrace_target::wait): Update.
* ravenscar-thread.c (struct ravenscar_thread_target) <wait>:
Update.
(ravenscar_thread_target::wait): Update.
* procfs.c (class procfs_target) <wait>: Update.
(procfs_target::wait): Update.
* obsd-nat.h (class obsd_nat_target) <wait>: Update.
* obsd-nat.c (obsd_nat_target::wait): Update.
* nto-procfs.c (struct nto_procfs_target) <wait>: Update.
(nto_procfs_target::wait): Update.
* nbsd-nat.h (struct nbsd_nat_target) <wait>: Update.
* nbsd-nat.c (nbsd_wait): Change type of "options".
(nbsd_nat_target::wait): Update.
* linux-thread-db.c (class thread_db_target) <wait>: Update.
(thread_db_target::wait): Update.
* linux-nat.h (class linux_nat_target) <wait>: Update.
* linux-nat.c (linux_nat_target::wait): Update.
(linux_nat_wait_1): Update.
* infrun.c (do_target_wait_1, do_target_wait): Change type of
"options".
* inf-ptrace.h (struct inf_ptrace_target) <wait>: Update.
* inf-ptrace.c (inf_ptrace_target::wait): Update.
* go32-nat.c (struct go32_nat_target) <wait>: Update.
(go32_nat_target::wait): Update.
* gnu-nat.h (struct gnu_nat_target) <wait>: Update.
* gnu-nat.c (gnu_nat_target::wait): Update.
* fbsd-nat.h (class fbsd_nat_target) <wait>: Update.
* fbsd-nat.c (fbsd_nat_target::wait): Update.
* darwin-nat.h (class darwin_nat_target) <wait>: Update.
* darwin-nat.c (darwin_nat_target::wait): Update.
* bsd-uthread.c (struct bsd_uthread_target) <wait>: Update.
(bsd_uthread_target::wait): Update.
* aix-thread.c (class aix_thread_target) <wait>: Update.
(aix_thread_target::wait): Update.

gdbserver/ChangeLog
2020-09-18  Tom Tromey  <tromey@adacore.com>

* netbsd-low.h (class netbsd_process_target) <wait>: Update.
* netbsd-low.cc (netbsd_waitpid, netbsd_wait)
(netbsd_process_target::wait): Change type of target_options.
* win32-low.h (class win32_process_target) <wait>: Update.
* win32-low.cc (win32_process_target::wait): Update.
* target.h (class process_stratum_target) <wait>: Update.
(mywait): Update.
* target.cc (mywait, target_wait): Change type of "options".
* linux-low.h (class linux_process_target) <wait, wait_1>:
Update.
* linux-low.cc (linux_process_target::wait)
(linux_process_target::wait_1): Update.

4 years agogdb: Fix use after free bug in compile_object_run
Andrew Burgess [Fri, 18 Sep 2020 17:23:06 +0000 (18:23 +0100)]
gdb: Fix use after free bug in compile_object_run

In this commit:

  commit 6108fd1823f9cf036bbbe528ffcdf2fee489b40a
  Date:   Thu Sep 17 11:47:50 2020 -0600

      Use htab_up in type copying

A use after free bug was introduced.  In compile-object-run.c, in the
function compile_object_run, the code used to look like this:

    htab_t copied_types;

    /* .... snip .... */

    /* OBJFILE may disappear while FUNC_TYPE still will be in use.  */
    copied_types = create_copied_types_hash (objfile);
    func_type = copy_type_recursive (objfile, func_type, copied_types);
    htab_delete (copied_types);

    /* .... snip .... */

    call_function_by_hand_dummy (func_val, NULL, args,
                                 do_module_cleanup, data);

The copied_types table exists on the obstack of objfile, but is
deleted once the call to copy_type_recursive has been completed.

After the change the code now looks like this:

    /* OBJFILE may disappear while FUNC_TYPE still will be in use.  */
    htab_up copied_types = create_copied_types_hash (objfile);
    func_type = copy_type_recursive (objfile, func_type, copied_types.get ());

    /* .... snip .... */

    call_function_by_hand_dummy (func_val, NULL, args,
                                 do_module_cleanup, data);

The copied_types is now a unique_ptr and deleted automatically when it
goes out of scope.

The problem however is that objfile, and its included obstack, may be
deleted by the call to do_module_cleanup, which is called by
call_function_by_hand_dummy.

This means that in the new code the objfile, and its obstack, are
deleted before copied_types is deleted, and as copied_types is on the
objfiles obstack, we are now reading undefined memory.

The solution in this commit is to wrap the call to
create_copied_types_hash and copy_type_recursive into a new static
helper function.  The htab_up will then be deleted within the new
function's scope, before objfile is deleted.

This resolves some non-deterministic test failures I was seeing in
gdb.compile/*.exp tests.

gdb/ChangeLog:

* compile/compile-object-run.c (create_copied_type_recursive): New
function.
(compile_object_run): Use new function.

4 years agobpf: xBPF SDIV, SMOD instructions
David Faust [Fri, 18 Sep 2020 16:56:43 +0000 (09:56 -0700)]
bpf: xBPF SDIV, SMOD instructions

Add gas and opcodes support for two xBPF-exclusive ALU operations:
SDIV (signed division) and SMOD (signed modulo), and add tests for
them in gas.

cpu/
* bpf.cpu (insn-op-code-alu): Add SDIV and SMOD.
(define-alu-insn-bin, daib): Take ISAs as an argument.
(define-alu-instructions): Update calls to daib pmacro with
ISAs; add sdiv and smod.

gas/
* testsuite/gas/bpf/alu-xbpf.d: New file.
* testsuite/gas/bpf/alu-xbpf.s: Likewise.
* testsuite/gas/bpf/alu32-xbpf.d: Likewise.
* testsuite/gas/bpf/alu32-xbpf.d: Likewise.
* testuiste/gas/bpf/bpf.exp: Run new tests.

opcodes/
* bpf-desc.c: Regenerate.
* bpf-desc.h: Likewise.
* bpf-opc.c: Likewise.
* bpf-opc.h: Likewise.

4 years agosim/m32r: return register sizes after fetch and store
Andrew Burgess [Sun, 13 Sep 2020 20:48:31 +0000 (21:48 +0100)]
sim/m32r: return register sizes after fetch and store

The m32r simulator currently always returns -1 for the register size
after both a fetch and a store.  In the fetch case GDB is forgiving of
this, but in the store case GDB treats a return value of -1 as an
error.

This commit updates the m32r simulator to return a valid register size
when fetching or storing a register.  This fixes any GDB test that
writes to a register, which will include any GDB test that makes an
inferior call, for example gdb.base/break.exp.

sim/m32r/ChangeLog:

* m32r.c (m32rbf_register_size): New function.
(m32rbf_fetch_register): Use new function.
(m32rbf_store_register): Likewise.

4 years agoMention x86_64 Cygwin core file support in NEWS.
Jon Turney [Fri, 21 Aug 2020 16:16:49 +0000 (17:16 +0100)]
Mention x86_64 Cygwin core file support in NEWS.

gdb/ChangeLog:

2020-08-21  Jon Turney  <jon.turney@dronecode.org.uk>

* NEWS: Mention x86_64 Cygwin core file support.

4 years agoAdd handling for 64-bit module addresses in Cygwin core dumps
Jon Turney [Mon, 29 Jun 2020 16:11:51 +0000 (17:11 +0100)]
Add handling for 64-bit module addresses in Cygwin core dumps

Add handling for 64-bit module addresses when processing '.module' fake
sections in Cygwin core dumps.

gdb/ChangeLog:

2020-07-01  Jon Turney  <jon.turney@dronecode.org.uk>

* windows-tdep.c (NOTE_INFO_MODULE, NOTE_INFO_MODULE64): Define.
(core_process_module_section): Handle NOTE_INFO_MODULE64.

4 years agoPromote windows_core_xfer_shared_libraries and windows_core_pid_to_str
Jon Turney [Tue, 30 Jun 2020 15:52:41 +0000 (16:52 +0100)]
Promote windows_core_xfer_shared_libraries and windows_core_pid_to_str

Move windows_core_xfer_shared_libraries() and windows_core_pid_to_str()
to windows-tdep, and use in amd64-windows-tdep.c to handle Cygwin x86_64
core dumps.

v2:
Keep _initialize function at the bottom of the file.

gdb/ChangeLog:

2020-07-01  Jon Turney  <jon.turney@dronecode.org.uk>

* windows-tdep.h: Add prototypes.
* i386-windows-tdep.c(windows_core_xfer_shared_libraries): Move.
(i386_windows_core_pid_to_str): Move and rename ...
* windows-tdep.c (windows_core_xfer_shared_libraries): ... to here
(windows_core_pid_to_str): ... and here.
* amd64-windows-tdep.c (amd64_windows_init_abi_common): Register here.

4 years agoAdd amd64_windows_gregset_reg_offset
Jon Turney [Tue, 30 Jun 2020 15:37:20 +0000 (16:37 +0100)]
Add amd64_windows_gregset_reg_offset

Register a gregset_reg_offset array for Cygwin x86_64 core dump parsing
(this causes the generic i386_iterate_over_regset_sections() '.reg'
section iterator to get installed by i386_gdbarch_init()).

gdb/ChangeLog:

2020-07-01  Jon Turney  <jon.turney@dronecode.org.uk>

* amd64-windows-tdep.c(amd64_windows_gregset_reg_offset): Add.
(amd64_windows_init_abi_common): ... and register.

4 years agoAdd sniffer for Cygwin x86_64 core dumps
Jon Turney [Mon, 29 Jun 2020 15:20:13 +0000 (16:20 +0100)]
Add sniffer for Cygwin x86_64 core dumps

Similarly to existing i386_cygwin_core_osabi_sniffer()

gdb/ChangeLog:

2020-07-01  Jon Turney  <jon.turney@dronecode.org.uk>

* amd64-windows-tdep.c (amd64_cygwin_core_osabi_sniffer): New.
(_initialize_amd64_windows_tdep): Register amd64_cygwin_core_osabi_sniffer.

4 years agoFix "thread find" with multiple inferiors/targets (PR gdb/26631)
Pedro Alves [Fri, 18 Sep 2020 12:40:18 +0000 (13:40 +0100)]
Fix "thread find" with multiple inferiors/targets (PR gdb/26631)

"thread find" with multiple inferiors got broken with the multi-target
work:

 Thread 1 "gdb" hit Breakpoint 1, internal_error (...) at ../../src/gdbsupport/errors.cc:51
 51      {
 (top-gdb) bt
 #0  internal_error (file=0xffffd4d0 <error: Cannot access memory at address 0xffffd4d0>, line=0, fmt=0x555556330320 "en_US.UTF-8") at ../../src/gdbsupport/errors.cc:51
 #1  0x0000555555bca4c7 in target_thread_name (info=0x555556801290) at ../../src/gdb/target.c:2035
 #2  0x0000555555beb07a in thread_find_command (arg=0x7fffffffe08e "1", from_tty=0) at ../../src/gdb/thread.c:1959
 #3  0x000055555572ec49 in do_const_cfunc (c=0x555556786bc0, args=0x7fffffffe08e "1", from_tty=0) at ../../src/gdb/cli/cli-decode.c:95
 #4  0x0000555555732abd in cmd_func (cmd=0x555556786bc0, args=0x7fffffffe08e "1", from_tty=0) at ../../src/gdb/cli/cli-decode.c:2181
 #5  0x0000555555bf1245 in execute_command (p=0x7fffffffe08e "1", from_tty=0) at ../../src/gdb/top.c:664
 #6  0x00005555559cad10 in catch_command_errors (command=0x555555bf0c31 <execute_command(char const*, int)>, arg=0x7fffffffe082 "thread find 1", from_tty=0) at ../../src/gdb/main.c:457
 #7  0x00005555559cc33d in captured_main_1 (context=0x7fffffffdb60) at ../../src/gdb/main.c:1218
 #8  0x00005555559cc571 in captured_main (data=0x7fffffffdb60) at ../../src/gdb/main.c:1243
 #9  0x00005555559cc5e8 in gdb_main (args=0x7fffffffdb60) at ../../src/gdb/main.c:1268
 #10 0x0000555555623816 in main (argc=17, argv=0x7fffffffdc78) at ../../src/gdb/gdb.c:32

The problem is that we're not switching to the inferior/target before
calling target methods, which trips on an assertion put in place
exactly to catch this sort of problem.

gdb/testsuite/ChangeLog:

PR gdb/26631
* gdb.multi/multi-target-thread-find.exp: New file.

gdb/ChangeLog:

PR gdb/26631
* thread.c (thread_find_command): Switch inferior before calling
target methods.

4 years agoSplit gdb.multi/multi-target.exp into separate testcases
Pedro Alves [Fri, 18 Sep 2020 12:40:18 +0000 (13:40 +0100)]
Split gdb.multi/multi-target.exp into separate testcases

gdb.multi/multi-target.exp sets up a debug environment with multiple
gdbservers, multiple native processes, and multiple cores, which has
proved useful for exercising a number of multi-target scenarios.

But, as we add more tests to gdb.base/multi-target.exp, it is growing
a bit too large (making a bit cumbersome to debug) and too slow to run
(if you have glibc debug info).

This commit thus splits the multi-target.exp into several testcases,
one per use case.  The common setup code is moved to a new
multi-target.exp.tcl file that is included by all the resulting
multi-target testcases.

gdb/testsuite/ChangeLog:

* gdb.multi/multi-target-continue.exp: New file, factored out from
multi-target.exp.
* gdb.multi/multi-target-info-inferiors.exp: New file, factored out from
multi-target.exp.
* gdb.multi/multi-target-interrupt.exp: New file, factored out from
multi-target.exp.
* gdb.multi/multi-target-no-resumed.exp: New file, factored out from
multi-target.exp.
* gdb.multi/multi-target-ping-pong-next.exp: New file, factored out from
multi-target.exp.
* gdb.multi/multi-target.exp.tcl: New file, factored out from
multi-target.exp.
* gdb.multi/multi-target.exp: Delete.

4 years agoEnsure that space allocated by assembler directives converts from an octet count...
Nick Clifton [Fri, 18 Sep 2020 12:28:46 +0000 (13:28 +0100)]
Ensure that space allocated by assembler directives converts from an octet count to a byte count.

PR 26556
* read.c (bss_alloc): Convert size parameter from octets to
bytes.

4 years agogdb/testsuite: Add missing expected results
Andrew Burgess [Thu, 2 Jul 2020 08:32:51 +0000 (09:32 +0100)]
gdb/testsuite: Add missing expected results

The tests in this script are driven from two lists of expected
results, one of the lists is missing some data so DejaGNU ends up
passing the empty string to gdb_test, which means the test always
passes.

This commit adds the missing expected results into the script.  The
tests still pass so there's no change in the results, but we are now
actually checking GDB's behaviour.

gdb/testsuite/ChangeLog:

* gdb.fortran/array-slices.exp: Add missing message data.

4 years agoAutomatic date update in version.in
GDB Administrator [Fri, 18 Sep 2020 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agogdb.cp/call-c.exp C++ify
Pedro Alves [Thu, 17 Sep 2020 22:33:43 +0000 (23:33 +0100)]
gdb.cp/call-c.exp C++ify

Make the testcase work when built with a C++ compiler.

gdb/testsuite/ChangeLog:

* gdb.cp/call-c-1.c (foo) [__cplusplus]: Add extern "C".

4 years agogdb.python/py-frame-inline.exp and C++
Pedro Alves [Thu, 17 Sep 2020 22:33:43 +0000 (23:33 +0100)]
gdb.python/py-frame-inline.exp and C++

Make the testcase work when built with a C++ compiler.

gdb/testsuite/ChangeLog:

* gdb.python/py-frame-inline.exp: Adjust to optionally expect a
full prototype.

4 years agogdb.python/py-as-string.exp C++ify
Pedro Alves [Thu, 17 Sep 2020 22:33:43 +0000 (23:33 +0100)]
gdb.python/py-as-string.exp C++ify

Make the testcase buildable with a C++ compiler.

gdb/testsuite/ChangeLog:

* gdb.python/py-as-string.c: Add cast.

4 years agogdb.base/sizeof.exp C++ify
Pedro Alves [Thu, 17 Sep 2020 22:33:43 +0000 (23:33 +0100)]
gdb.base/sizeof.exp C++ify

Fixes:

  src/gdb/testsuite/gdb.base/sizeof.c:54:9: error: cannot initialize a variable of type 'char *' with an lvalue of type 'void *'

... when the testcase is built with a C++ compiler.

gdb/testsuite/ChangeLog:

* gdb.base/sizeof.c (fill): Add cast.

4 years agogdb.base/share-env-with-gdbserver.exp C++ify
Pedro Alves [Thu, 17 Sep 2020 22:33:42 +0000 (23:33 +0100)]
gdb.base/share-env-with-gdbserver.exp C++ify

gdb/testsuite/ChangeLog:

* gdb.base/share-env-with-gdbserver.c (main): Add cast.

4 years agogdb.base/{prologue,symbol-alias}.exp C++ify
Pedro Alves [Thu, 17 Sep 2020 22:33:42 +0000 (23:33 +0100)]
gdb.base/{prologue,symbol-alias}.exp C++ify

Make these testcases work when compiled as C++ programs.

These testcases use the alias attribute, which requires passing in the
target function's mangled name in C++.  To avoid having to figure out
how the functions are mangled, explicitly specify a linkage name.
This is preferred over 'extern "C"' because that doesn't work with
static functions.

gdb/testsuite/ChangeLog:

* gdb.base/prologue.c [__cplusplus] (marker): Explicitly specify
linkage name.
* gdb.base/prologue.exp: Use print /d.
* gdb.base/symbol-alias.exp: Handle C++ output.
* gdb.base/symbol-alias2.c: Handle C++ output.
[__cplusplus] (func): Explicitly specify linkage name.

4 years agogdb.python/py-nested-maps.exp C++ify
Pedro Alves [Thu, 17 Sep 2020 22:33:42 +0000 (23:33 +0100)]
gdb.python/py-nested-maps.exp C++ify

This adjusts gdb.python/py-nested-maps.c to make it buildable as C++ program.

key_t is renamed because of:

  src/gdb/testsuite/gdb.python/py-nested-maps.c:23:8: error: definition of type 'key_t' conflicts with typedef of the same name
  struct key_t
 ^
  /usr/include/x86_64-linux-gnu/sys/types.h:121:17: note: 'key_t' declared here
  typedef __key_t key_t;
  ^

gdb/testsuite/ChangeLog:

* gdb.python/py-nested-maps.c (struct key_t): Rename to...
(struct my_key_t): ... this.  Adjust all references.
(struct value_t): Rename to ...
(struct my_value_t): ... this.  Adjust all references.
(create_map, add_map_element, create_map_map)
(add_map_map_element): Add casts.

4 years agogdb.python/{py-framefilter-mi,py-framefilter}.c C++ify
Pedro Alves [Thu, 17 Sep 2020 22:33:42 +0000 (23:33 +0100)]
gdb.python/{py-framefilter-mi,py-framefilter}.c C++ify

This adjusts:

 gdb.python/{py-framefilter-mi,py-framefilter}.c

to make them buildable as C++ programs.

gdb/testsuite/ChangeLog:

* gdb.python/py-framefilter-mi.c (funca): Add casts.
* gdb.python/py-framefilter.c.c (funca, func2): Add casts.

4 years agogdb.mi/var-cmd.c C++ify
Pedro Alves [Thu, 17 Sep 2020 22:33:41 +0000 (23:33 +0100)]
gdb.mi/var-cmd.c C++ify

This adjusts gdb.mi/var-cmd.c to make it buildable as a C++ program.

gdb/testsuite/ChangeLog:

* gdb.mi/var-cmd.c (do_anonymous_type_tests): Add cast.

4 years agogdb.base/{exprs,ptype,ptype1,setvar,whatis}.c C++ify
Pedro Alves [Thu, 17 Sep 2020 22:33:41 +0000 (23:33 +0100)]
gdb.base/{exprs,ptype,ptype1,setvar,whatis}.c C++ify

This adjusts:

 gdb.base/{exprs,ptype,ptype1,setvar,whatis}.c,

to make them buildable as C++ programs.

gdb/testsuite/ChangeLog:

* gdb.base/exprs.c: Replace 'this' with 'self' throughout.
* gdb.base/ptype.c: : Replace 'this' with 'self' throughout.
(charfoo, intfoo): Define full prototype.
* gdb.base/ptype1.c (charfoo): Define full prototype.
* gdb.base/setvar.c: Replace 'this' with 'self' throughout.
* gdb.base/whatis.c: Replace 'this' with 'self' throughout.